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