LCOV - code coverage report
Current view: top level - src/plugin - webviewhandler.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 <map>
      20             : #include <string>
      21             : 
      22             : namespace jami {
      23             : 
      24             : /**
      25             :  * @brief This is an abstract class (API) that needs to be implemented by a plugin.
      26             :  * Any plugin that wants to open a WebView needs to implement this class.
      27             :  */
      28             : class WebViewHandler
      29             : {
      30             : public:
      31             :     virtual ~WebViewHandler() {}
      32             : 
      33             :     /**
      34             :      * @brief Returns the dataPath of the plugin that created this WebViewHandler.
      35             :      */
      36           0 :     std::string id() const { return id_; }
      37             : 
      38             :     /**
      39             :      * @brief Should be called by the WebViewHandler creator to set the plugin's id_ variable.
      40             :      */
      41             :     virtual void setId(const std::string& id) final { id_ = id; }
      42             : 
      43             :     // these functions are called by the client and must be implemented by the plugin
      44             : 
      45             :     /**
      46             :      * @brief Called by the daemon whenever the client webview sends a message to the plugin
      47             :      */
      48             :     virtual void pluginWebViewMessage(const std::string& webViewId,
      49             :                                       const std::string& messageId,
      50             :                                       const std::string& payload)
      51             :         = 0;
      52             : 
      53             :     /**
      54             :      * @brief Called by the daemon whenever the client attaches a new webview
      55             :      * @returns Relative path to an HTML file inside of the plugin's datapath
      56             :      */
      57             :     virtual std::string pluginWebViewAttach(const std::string& accountId,
      58             :                                             const std::string& webViewId,
      59             :                                             const std::string& action)
      60             :         = 0;
      61             : 
      62             :     /**
      63             :      * @brief Called by the daemon whenever the client detaches a webview
      64             :      */
      65             :     virtual void pluginWebViewDetach(const std::string& webViewId) = 0;
      66             : 
      67             : private:
      68             :     // the dataPath of the plugin that created this WebViewHandler
      69             :     std::string id_;
      70             : };
      71             : } // namespace jami

Generated by: LCOV version 1.14