LCOV - code coverage report
Current view: top level - src/plugin - preferencehandler.h (source / functions) Hit Total Coverage
Test: jami-coverage-filtered.info Lines: 0 1 0.0 %
Date: 2024-12-21 08:56:24 Functions: 0 1 0.0 %

          Line data    Source code
       1             : /*
       2             :  *  Copyright (C) 2004-2024 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 <string>
      20             : #include <map>
      21             : 
      22             : namespace jami {
      23             : 
      24             : /**
      25             :  * @brief This abstract class is an API we need to implement from plugin side.
      26             :  * In other words, a plugin functionality that handles preferences per account
      27             :  * must start from the implementation of this class.
      28             :  */
      29             : class PreferenceHandler
      30             : {
      31             : public:
      32             :     virtual ~PreferenceHandler() {}
      33             : 
      34             :     /**
      35             :      * @brief Returns a map with handler's name, iconPath, and pluginId.
      36             :      */
      37             :     virtual std::map<std::string, std::string> getHandlerDetails() = 0;
      38             : 
      39             :     /**
      40             :      * @brief If a preference can have different values depending on accountId, those values should
      41             :      * be stored in the plugin through this function.
      42             :      * @param accountId
      43             :      * @param key
      44             :      * @param value
      45             :      */
      46             :     virtual void setPreferenceAttribute(const std::string& accountId,
      47             :                                         const std::string& key,
      48             :                                         const std::string& value)
      49             :         = 0;
      50             : 
      51             :     /**
      52             :      * @brief If a preference can be stored as per accountId, this function should return True.
      53             :      * @param key
      54             :      * @return True if preference can be changed through setPreferenceAttribute method.
      55             :      */
      56             :     virtual bool preferenceMapHasKey(const std::string& key) = 0;
      57             : 
      58             :     /**
      59             :      * @brief Reset stored preferences for given accountId.
      60             :      * @param accountId
      61             :      */
      62             :     virtual void resetPreferenceAttributes(const std::string& accountId) = 0;
      63             : 
      64             :     /**
      65             :      * @brief Returns the dataPath of the plugin that created this PreferenceHandler.
      66             :      */
      67           0 :     std::string id() const { return id_; }
      68             : 
      69             :     /**
      70             :      * @brief Should be called by the PreferenceHandler creator to set the plugins id_ variable.
      71             :      */
      72             :     virtual void setId(const std::string& id) final { id_ = id; }
      73             : 
      74             : private:
      75             :     // Is the dataPath of the plugin that created this ChatHandler.
      76             :     std::string id_;
      77             : };
      78             : } // namespace jami

Generated by: LCOV version 1.14