agsantos | 520da84 | 2020-12-01 16:39:06 -0500 | [diff] [blame] | 1 | /** |
Sébastien Blin | cb783e3 | 2021-02-12 11:34:10 -0500 | [diff] [blame] | 2 | * Copyright (C) 2020-2021 Savoir-faire Linux Inc. |
agsantos | 520da84 | 2020-12-01 16:39:06 -0500 | [diff] [blame] | 3 | * |
| 4 | * Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 3 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 | */ |
| 20 | |
| 21 | #pragma once |
| 22 | |
agsantos | 82678f3 | 2020-12-09 15:03:24 -0500 | [diff] [blame] | 23 | #include "BotPeerChatSubscriber.h" |
agsantos | 520da84 | 2020-12-01 16:39:06 -0500 | [diff] [blame] | 24 | |
| 25 | #include "plugin/jamiplugin.h" |
| 26 | #include "plugin/chathandler.h" |
| 27 | |
| 28 | #include <string> |
| 29 | #include <map> |
| 30 | #include <memory> |
| 31 | #include <set> |
| 32 | |
| 33 | using chatSubjectPtr = std::shared_ptr<jami::PublishObservable<jami::pluginMessagePtr>>; |
| 34 | |
| 35 | namespace jami { |
| 36 | |
agsantos | 82678f3 | 2020-12-09 15:03:24 -0500 | [diff] [blame] | 37 | class BotChatHandler : public jami::ChatHandler |
agsantos | 520da84 | 2020-12-01 16:39:06 -0500 | [diff] [blame] | 38 | { |
| 39 | public: |
agsantos | 82678f3 | 2020-12-09 15:03:24 -0500 | [diff] [blame] | 40 | BotChatHandler(const JAMI_PluginAPI* api, |
agsantos | 3fcc621 | 2021-08-18 17:11:29 -0300 | [diff] [blame] | 41 | std::string&& dataPath, |
| 42 | PluginPreferenceHandler* prefHandler); |
agsantos | b3c9084 | 2020-12-10 14:19:41 -0500 | [diff] [blame] | 43 | ~BotChatHandler(); |
agsantos | 520da84 | 2020-12-01 16:39:06 -0500 | [diff] [blame] | 44 | |
Aline Gondim Santos | 32818a7 | 2022-06-06 17:28:59 -0400 | [diff] [blame] | 45 | void notifyChatSubject(std::pair<std::string, std::string>& subjectConnection, |
| 46 | chatSubjectPtr subject) override; |
| 47 | std::map<std::string, std::string> getChatHandlerDetails() override; |
| 48 | void detach(chatSubjectPtr subject) override; |
| 49 | void setPreferenceAttribute(const std::string& key, const std::string& value) override {} |
| 50 | bool preferenceMapHasKey(const std::string& key) override { return false; } |
agsantos | 520da84 | 2020-12-01 16:39:06 -0500 | [diff] [blame] | 51 | |
agsantos | 3fcc621 | 2021-08-18 17:11:29 -0300 | [diff] [blame] | 52 | std::shared_ptr<BotPeerChatSubscriber> peerChatSubscriber_ {}; |
agsantos | 520da84 | 2020-12-01 16:39:06 -0500 | [diff] [blame] | 53 | |
| 54 | private: |
| 55 | const JAMI_PluginAPI* api_; |
| 56 | const std::string datapath_; |
agsantos | 3fcc621 | 2021-08-18 17:11:29 -0300 | [diff] [blame] | 57 | PluginPreferenceHandler* aph_; |
agsantos | 520da84 | 2020-12-01 16:39:06 -0500 | [diff] [blame] | 58 | std::set<chatSubjectPtr> subjects; |
| 59 | }; |
| 60 | } // namespace jami |