Ring Daemon 16.0.0
Loading...
Searching...
No Matches
chathandler.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2004-2025 Savoir-faire Linux Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17#pragma once
18
19#include "observer.h"
20#include "streamdata.h"
21#include <string>
22#include <map>
23
24namespace jami {
25
26using pluginMessagePtr = std::shared_ptr<JamiMessage>;
27using chatSubjectPtr = std::shared_ptr<PublishObservable<pluginMessagePtr>>;
28
35{
36public:
37 virtual ~ChatHandler() {}
38
44 virtual void notifyChatSubject(std::pair<std::string, std::string>& subjectConnection,
46 = 0;
47
51 virtual std::map<std::string, std::string> getChatHandlerDetails() = 0;
52
57 virtual void detach(chatSubjectPtr subject) = 0;
58
65 virtual void setPreferenceAttribute(const std::string& key, const std::string& value) = 0;
66
73 virtual bool preferenceMapHasKey(const std::string& key) = 0;
74
78 std::string id() const { return id_; }
79
83 virtual void setId(const std::string& id) final { id_ = id; }
84
85private:
86 // Is the dataPath of the plugin that created this ChatHandler.
87 std::string id_;
88};
89} // namespace jami
This abstract class is an API we need to implement from plugin side.
Definition chathandler.h:35
virtual ~ChatHandler()
Definition chathandler.h:37
std::string id() const
Returns the dataPath of the plugin that created this ChatHandler.
Definition chathandler.h:78
virtual void notifyChatSubject(std::pair< std::string, std::string > &subjectConnection, chatSubjectPtr subject)=0
Should attach a chat subject (Observable) and the plugin data process (Observer).
virtual std::map< std::string, std::string > getChatHandlerDetails()=0
Returns a map with handler's name, iconPath, and pluginId.
virtual void detach(chatSubjectPtr subject)=0
Should detach a chat subject (Observable) and the plugin data process (Observer).
virtual void setPreferenceAttribute(const std::string &key, const std::string &value)=0
If a preference can be changed without the need to reload the plugin, it should be done through this ...
virtual bool preferenceMapHasKey(const std::string &key)=0
If a preference can be changed without the need to reload the plugin, this function should return Tru...
virtual void setId(const std::string &id) final
Should be called by the ChatHandler creator to set the plugins id_ variable.
Definition chathandler.h:83
void emitSignal(Args... args)
Definition ring_signal.h:64
std::shared_ptr< JamiMessage > pluginMessagePtr
Definition chathandler.h:26
std::shared_ptr< PublishObservable< pluginMessagePtr > > chatSubjectPtr
Definition chathandler.h:27