LCOV - code coverage report
Current view: top level - foo/src/plugin - chathandler.h (source / functions) Hit Total Coverage
Test: jami-coverage-filtered.info Lines: 0 1 0.0 %
Date: 2025-12-18 10:07:43 Functions: 0 1 0.0 %

          Line data    Source code
       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             : 
      24             : namespace jami {
      25             : 
      26             : using pluginMessagePtr = std::shared_ptr<JamiMessage>;
      27             : using chatSubjectPtr = std::shared_ptr<PublishObservable<pluginMessagePtr>>;
      28             : 
      29             : /**
      30             :  * @brief This abstract class is an API we need to implement from plugin side.
      31             :  * In other words, a plugin functionality that plays with messages, must start
      32             :  * from the implementation of this class.
      33             :  */
      34             : class ChatHandler
      35             : {
      36             : public:
      37             :     virtual ~ChatHandler() {}
      38             : 
      39             :     /**
      40             :      * @brief Should attach a chat subject (Observable) and the plugin data process (Observer).
      41             :      * @param subjectConnection accountId, peerId pair
      42             :      * @param subject chat Subject pointer
      43             :      */
      44             :     virtual void notifyChatSubject(std::pair<std::string, std::string>& subjectConnection, chatSubjectPtr subject) = 0;
      45             : 
      46             :     /**
      47             :      * @brief Returns a map with handler's name, iconPath, and pluginId.
      48             :      */
      49             :     virtual std::map<std::string, std::string> getChatHandlerDetails() = 0;
      50             : 
      51             :     /**
      52             :      * @brief Should detach a chat subject (Observable) and the plugin data process (Observer).
      53             :      * @param subject chat subject pointer
      54             :      */
      55             :     virtual void detach(chatSubjectPtr subject) = 0;
      56             : 
      57             :     /**
      58             :      * @brief If a preference can be changed without the need to reload the plugin, it
      59             :      * should be done through this function.
      60             :      * @param key
      61             :      * @param value
      62             :      */
      63             :     virtual void setPreferenceAttribute(const std::string& key, const std::string& value) = 0;
      64             : 
      65             :     /**
      66             :      * @brief If a preference can be changed without the need to reload the plugin, this function
      67             :      * should return True.
      68             :      * @param key
      69             :      * @return True if preference can be changed through setPreferenceAttribute method.
      70             :      */
      71             :     virtual bool preferenceMapHasKey(const std::string& key) = 0;
      72             : 
      73             :     /**
      74             :      * @brief Returns the dataPath of the plugin that created this ChatHandler.
      75             :      */
      76           0 :     std::string id() const { return id_; }
      77             : 
      78             :     /**
      79             :      * @brief Should be called by the ChatHandler creator to set the plugins id_ variable.
      80             :      */
      81             :     virtual void setId(const std::string& id) final { id_ = id; }
      82             : 
      83             : private:
      84             :     // Is the dataPath of the plugin that created this ChatHandler.
      85             :     std::string id_;
      86             : };
      87             : } // namespace jami

Generated by: LCOV version 1.14