blob: ee0f72fbca0fff0f7c435d523531b9ad9c2970e6 [file] [log] [blame]
agsantos520da842020-12-01 16:39:06 -05001/**
2 * Copyright (C) 2020 Savoir-faire Linux Inc.
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
agsantos82678f32020-12-09 15:03:24 -050023#include "BotPeerChatSubscriber.h"
agsantos520da842020-12-01 16:39:06 -050024
25#include "plugin/jamiplugin.h"
26#include "plugin/chathandler.h"
27
28#include <string>
29#include <map>
30#include <memory>
31#include <set>
32
33using chatSubjectPtr = std::shared_ptr<jami::PublishObservable<jami::pluginMessagePtr>>;
34
35namespace jami {
36
agsantos82678f32020-12-09 15:03:24 -050037class BotChatHandler : public jami::ChatHandler
agsantos520da842020-12-01 16:39:06 -050038{
39public:
agsantos82678f32020-12-09 15:03:24 -050040 BotChatHandler(const JAMI_PluginAPI* api,
41 std::map<std::string, std::string>&& preferences,
agsantos520da842020-12-01 16:39:06 -050042 std::string&& dataPath);
agsantos82678f32020-12-09 15:03:24 -050043 ~BotChatHandler() override;
agsantos520da842020-12-01 16:39:06 -050044
45 virtual void notifyChatSubject(std::pair<std::string, std::string>& subjectConnection,
46 chatSubjectPtr subject) override;
47 virtual std::map<std::string, std::string> getChatHandlerDetails() override;
48 virtual void detach(chatSubjectPtr subject) override;
49 virtual void setPreferenceAttribute(const std::string& key, const std::string& value) override;
50 virtual bool preferenceMapHasKey(const std::string& key) override;
51
agsantos82678f32020-12-09 15:03:24 -050052 std::shared_ptr<BotPeerChatSubscriber> peerChatSubscriber_;
agsantos520da842020-12-01 16:39:06 -050053
54private:
55 const JAMI_PluginAPI* api_;
56 const std::string datapath_;
agsantos82678f32020-12-09 15:03:24 -050057 std::map<std::string, std::string> preferences_;
agsantos520da842020-12-01 16:39:06 -050058 std::set<chatSubjectPtr> subjects;
59};
60} // namespace jami