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