LCOV - code coverage report
Current view: top level - src/plugin - chathandler.h (source / functions) Hit Total Coverage
Test: jami-coverage-filtered.info Lines: 1 1 100.0 %
Date: 2024-04-19 19:18:04 Functions: 1 1 100.0 %

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

Generated by: LCOV version 1.14