From f773e24851b8604ceafc3ceb7499eaac3cf2ecaa Mon Sep 17 00:00:00 2001 From: Tobias Hildebrandt Date: Mon, 13 Jun 2022 16:27:25 -0400 Subject: [PATCH] webview: add initial WebView support to the daemon Change-Id: Id6967f8fd0976caae81e4c951d0d5dc9901b23d3 --- .../cx.ring.Ring.PluginManagerInterface.xml | 61 +++++++ bin/dbus/dbusclient.cpp | 15 ++ bin/dbus/dbuspluginmanagerinterface.cpp | 26 ++- bin/dbus/dbuspluginmanagerinterface.h | 12 ++ configure.ac | 2 +- meson.build | 2 +- src/client/plugin_manager_interface.cpp | 33 ++++ src/client/ring_signal.cpp | 4 + src/client/ring_signal.h | 4 + src/jami/plugin_manager_interface.h | 24 +++ src/meson.build | 1 + src/plugin/CMakeLists.txt | 3 + src/plugin/Makefile.am | 3 + src/plugin/jamipluginmanager.h | 5 + src/plugin/webviewhandler.h | 75 ++++++++ src/plugin/webviewmessage.h | 42 +++++ src/plugin/webviewservicesmanager.cpp | 161 ++++++++++++++++++ src/plugin/webviewservicesmanager.h | 112 ++++++++++++ 18 files changed, 582 insertions(+), 3 deletions(-) create mode 100644 src/plugin/webviewhandler.h create mode 100644 src/plugin/webviewmessage.h create mode 100644 src/plugin/webviewservicesmanager.cpp create mode 100644 src/plugin/webviewservicesmanager.h diff --git a/bin/dbus/cx.ring.Ring.PluginManagerInterface.xml b/bin/dbus/cx.ring.Ring.PluginManagerInterface.xml index ce9861241a8..e47f8c58223 100644 --- a/bin/dbus/cx.ring.Ring.PluginManagerInterface.xml +++ b/bin/dbus/cx.ring.Ring.PluginManagerInterface.xml @@ -198,5 +198,66 @@ + + + + Called by the a client's webview to send a message to the plugin + + + + + + + + + + + + + + + Called by the a client's webview to notify the plugin that a webview has been created. + Returns a relative path to an HTML file inside the plugin's datapath. + + + + + + + + + + + + + + + + + + Called by the a client's webview to notify the plugin that a webview has been destroyed + + + + + + + + + + + + This signal is emitted when a plugin sends a message up to a webview + + + + + + + + + + + diff --git a/bin/dbus/dbusclient.cpp b/bin/dbus/dbusclient.cpp index 5c5fbed1bfa..03f08c1490d 100644 --- a/bin/dbus/dbusclient.cpp +++ b/bin/dbus/dbusclient.cpp @@ -153,6 +153,10 @@ DBusClient::initLibrary(int flags) auto videoM = videoManager_.get(); #endif +#ifdef ENABLE_PLUGIN + auto pluginM = pluginManagerInterface_.get(); +#endif + // Call event handlers const std::map callEvHandlers = {exportable_callback( @@ -322,6 +326,14 @@ DBusClient::initLibrary(int flags) }; #endif +#ifdef ENABLE_PLUGIN + // Plugin event handlers + const std::map pluginEvHandlers = { + exportable_callback( + bind(&DBusPluginManagerInterface::webViewMessageReceived, pluginM, _1, _2, _3, _4)), + }; +#endif + if (!DRing::init(static_cast(flags))) return -1; @@ -334,6 +346,9 @@ DBusClient::initLibrary(int flags) #ifdef ENABLE_VIDEO DRing::registerSignalHandlers(videoEvHandlers); #endif +#ifdef ENABLE_PLUGIN + DRing::registerSignalHandlers(pluginEvHandlers); +#endif if (!DRing::start()) return -1; diff --git a/bin/dbus/dbuspluginmanagerinterface.cpp b/bin/dbus/dbuspluginmanagerinterface.cpp index 3fd3b021141..636b46397e0 100644 --- a/bin/dbus/dbuspluginmanagerinterface.cpp +++ b/bin/dbus/dbuspluginmanagerinterface.cpp @@ -108,7 +108,6 @@ DBusPluginManagerInterface::getChatHandlers() -> decltype(DRing::getChatHandlers { return DRing::getChatHandlers(); } - void DBusPluginManagerInterface::toggleCallMediaHandler(const std::string& mediaHandlerId, const std::string& callId, @@ -162,3 +161,28 @@ DBusPluginManagerInterface::setPluginsEnabled(const bool& state) { DRing::setPluginsEnabled(state); } + +void +DBusPluginManagerInterface::sendWebViewMessage(const std::string& pluginId, + const std::string& webViewId, + const std::string& messageId, + const std::string& payload) +{ + DRing::sendWebViewAttach(pluginId, webViewId, messageId, payload); +} + +std::string +DBusPluginManagerInterface::sendWebViewAttach(const std::string& pluginId, + const std::string& accountId, + const std::string& webViewId, + const std::string& action) +{ + return DRing::sendWebViewAttach(pluginId, accountId, webViewId, action); +} + +void +DBusPluginManagerInterface::sendWebViewDetach(const std::string& pluginId, + const std::string& webViewId) +{ + DRing::sendWebViewDetach(pluginId, webViewId); +} diff --git a/bin/dbus/dbuspluginmanagerinterface.h b/bin/dbus/dbuspluginmanagerinterface.h index 4fc3ce6fe41..bd93bad652f 100644 --- a/bin/dbus/dbuspluginmanagerinterface.h +++ b/bin/dbus/dbuspluginmanagerinterface.h @@ -85,4 +85,16 @@ class DRING_PUBLIC DBusPluginManagerInterface bool getPluginsEnabled(); void setPluginsEnabled(const bool& state); + + void sendWebViewMessage(const std::string& pluginId, + const std::string& webViewId, + const std::string& messageId, + const std::string& payload); + + std::string sendWebViewAttach(const std::string& pluginId, + const std::string& accountId, + const std::string& webViewId, + const std::string& action); + + void sendWebViewDetach(const std::string& pluginId, const std::string& webViewId); }; diff --git a/configure.ac b/configure.ac index 8e7c38e37ea..05f3f0a3198 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ dnl Jami - configure.ac dnl Process this file with autoconf to produce a configure script. AC_PREREQ([2.69]) -AC_INIT([Jami Daemon],[13.1.0],[jami@gnu.org],[jami]) +AC_INIT([Jami Daemon],[13.2.0],[jami@gnu.org],[jami]) dnl Clear the implicit flags that default to '-g -O2', otherwise they dnl take precedence over the values we set via the diff --git a/meson.build b/meson.build index 45d0c07d7e7..f9d2c3f59c2 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ project('jami-daemon', ['c', 'cpp'], - version: '13.1.0', + version: '13.2.0', license: 'GPL3+', default_options: ['cpp_std=gnu++17', 'buildtype=debugoptimized'], meson_version:'>= 0.56' diff --git a/src/client/plugin_manager_interface.cpp b/src/client/plugin_manager_interface.cpp index 0a0115a846a..9ccdb517986 100644 --- a/src/client/plugin_manager_interface.cpp +++ b/src/client/plugin_manager_interface.cpp @@ -203,4 +203,37 @@ setPluginsEnabled(bool state) } jami::Manager::instance().saveConfig(); } + +void +sendWebViewMessage(const std::string& pluginId, + const std::string& webViewId, + const std::string& messageId, + const std::string& payload) +{ + jami::Manager::instance() + .getJamiPluginManager() + .getWebViewServicesManager() + .sendWebViewMessage(pluginId, webViewId, messageId, payload); +} + +std::string +sendWebViewAttach(const std::string& pluginId, + const std::string& accountId, + const std::string& webViewId, + const std::string& action) +{ + return jami::Manager::instance() + .getJamiPluginManager() + .getWebViewServicesManager() + .sendWebViewAttach(pluginId, accountId, webViewId, action); +} + +void +sendWebViewDetach(const std::string& pluginId, const std::string& webViewId) +{ + jami::Manager::instance() + .getJamiPluginManager() + .getWebViewServicesManager() + .sendWebViewDetach(pluginId, webViewId); +} } // namespace DRing diff --git a/src/client/ring_signal.cpp b/src/client/ring_signal.cpp index d17c72e2457..a0e4f9e7432 100644 --- a/src/client/ring_signal.cpp +++ b/src/client/ring_signal.cpp @@ -134,6 +134,10 @@ getSignalHandlers() exported_callback(), exported_callback(), exported_callback(), + +#ifdef ENABLE_PLUGIN + exported_callback(), +#endif }; return handlers; diff --git a/src/client/ring_signal.h b/src/client/ring_signal.h index e5c7a87a097..94c9582e68c 100644 --- a/src/client/ring_signal.h +++ b/src/client/ring_signal.h @@ -34,6 +34,10 @@ #include "videomanager_interface.h" #endif +#ifdef ENABLE_PLUGIN +#include "plugin_manager_interface.h" +#endif + #include "jami.h" #include "logger.h" #include "trace-tools.h" diff --git a/src/jami/plugin_manager_interface.h b/src/jami/plugin_manager_interface.h index 8df15ec0ad5..2d16610a391 100644 --- a/src/jami/plugin_manager_interface.h +++ b/src/jami/plugin_manager_interface.h @@ -69,4 +69,28 @@ DRING_PUBLIC std::vector getChatHandlerStatus(const std::string& ac const std::string& peerId); DRING_PUBLIC bool getPluginsEnabled(); DRING_PUBLIC void setPluginsEnabled(bool state); + +DRING_PUBLIC void sendWebViewMessage(const std::string& pluginId, + const std::string& webViewId, + const std::string& messageId, + const std::string& payload); + +DRING_PUBLIC std::string sendWebViewAttach(const std::string& pluginId, + const std::string& accountId, + const std::string& webViewId, + const std::string& action); + +DRING_PUBLIC void sendWebViewDetach(const std::string& pluginId, const std::string& webViewId); + +namespace PluginSignal { +struct DRING_PUBLIC WebViewMessageReceived +{ + constexpr static const char* name = "WebViewMessageReceived"; + using cb_type = void(const std::string& /*pluginId*/, + const std::string& /*webViewId*/, + const std::string& /*messageId*/, + const std::string& /*payload*/); +}; +} // namespace PluginSignal + } // namespace DRing diff --git a/src/meson.build b/src/meson.build index 9abdb1906d6..cf242a9ac75 100644 --- a/src/meson.build +++ b/src/meson.build @@ -296,6 +296,7 @@ if conf.get('ENABLE_PLUGIN') 'plugin/preferenceservicesmanager.cpp', 'plugin/callservicesmanager.cpp', 'plugin/chatservicesmanager.cpp', + 'plugin/webviewservicesmanager.cpp', 'plugin/jamipluginmanager.cpp', 'plugin/pluginloader.cpp', 'plugin/pluginmanager.cpp', diff --git a/src/plugin/CMakeLists.txt b/src/plugin/CMakeLists.txt index 968e154de73..fa6ef35a4fb 100644 --- a/src/plugin/CMakeLists.txt +++ b/src/plugin/CMakeLists.txt @@ -14,6 +14,9 @@ list (APPEND Source_Files__plugin "${CMAKE_CURRENT_SOURCE_DIR}/chatservicesmanager.h" "${CMAKE_CURRENT_SOURCE_DIR}/chatservicesmanager.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/preferencehandler.h" + "${CMAKE_CURRENT_SOURCE_DIR}/webviewservicesmanager.h" + "${CMAKE_CURRENT_SOURCE_DIR}/webviewservicesmanager.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/webviewhandler.h" "${CMAKE_CURRENT_SOURCE_DIR}/chathandler.h" "${CMAKE_CURRENT_SOURCE_DIR}/jamiplugin.h" "${CMAKE_CURRENT_SOURCE_DIR}/jamipluginmanager.h" diff --git a/src/plugin/Makefile.am b/src/plugin/Makefile.am index 02b6b728fbb..567640cd005 100644 --- a/src/plugin/Makefile.am +++ b/src/plugin/Makefile.am @@ -8,6 +8,8 @@ noinst_HEADERS += \ ./plugin/preferencehandler.h \ ./plugin/chathandler.h \ ./plugin/chatservicesmanager.h \ + ./plugin/webviewservicesmanager.h \ + ./plugin/webviewhandler.h \ ./plugin/jamiplugin.h \ ./plugin/jamipluginmanager.h \ ./plugin/mediahandler.h \ @@ -24,6 +26,7 @@ libplugin_la_SOURCES = \ ./plugin/pluginpreferencesutils.cpp \ ./plugin/pluginsutils.cpp \ ./plugin/chatservicesmanager.cpp \ + ./plugin/webviewservicesmanager.cpp \ ./plugin/callservicesmanager.cpp \ ./plugin/preferenceservicesmanager.cpp diff --git a/src/plugin/jamipluginmanager.h b/src/plugin/jamipluginmanager.h index 974ae216c53..e1f4a92d7df 100644 --- a/src/plugin/jamipluginmanager.h +++ b/src/plugin/jamipluginmanager.h @@ -21,6 +21,7 @@ #pragma once #include "noncopyable.h" +#include "plugin/webviewservicesmanager.h" #include "pluginmanager.h" #include "pluginpreferencesutils.h" @@ -48,6 +49,7 @@ class JamiPluginManager JamiPluginManager() : callsm_ {pm_} , chatsm_ {pm_} + , webviewsm_ {pm_} , preferencesm_ {pm_} { registerServices(); @@ -146,6 +148,8 @@ class JamiPluginManager ChatServicesManager& getChatServicesManager() { return chatsm_; } + WebViewServicesManager& getWebViewServicesManager() { return webviewsm_; } + PreferenceServicesManager& getPreferenceServicesManager() { return preferencesm_; } private: @@ -165,6 +169,7 @@ class JamiPluginManager // Services instances CallServicesManager callsm_; ChatServicesManager chatsm_; + WebViewServicesManager webviewsm_; PreferenceServicesManager preferencesm_; }; } // namespace jami diff --git a/src/plugin/webviewhandler.h b/src/plugin/webviewhandler.h new file mode 100644 index 00000000000..a9625d96a0a --- /dev/null +++ b/src/plugin/webviewhandler.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2022 Savoir-faire Linux Inc. + * + * Author: Tobias Hildebrandt + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#pragma once + +#include +#include + +namespace jami { + +/** + * @brief This is an abstract class (API) that needs to be implemented by a plugin. + * Any plugin that wants to open a WebView needs to implement this class. + */ +class WebViewHandler +{ +public: + virtual ~WebViewHandler() {} + + /** + * @brief Returns the dataPath of the plugin that created this WebViewHandler. + */ + std::string id() const { return id_; } + + /** + * @brief Should be called by the WebViewHandler creator to set the plugin's id_ variable. + */ + virtual void setId(const std::string& id) final { id_ = id; } + + // these functions are called by the client and must be implemented by the plugin + + /** + * @brief Called by the daemon whenever the client webview sends a message to the plugin + */ + virtual void pluginWebViewMessage(const std::string& webViewId, + const std::string& messageId, + const std::string& payload) + = 0; + + /** + * @brief Called by the daemon whenever the client attaches a new webview + * @returns Relative path to an HTML file inside of the plugin's datapath + */ + virtual std::string pluginWebViewAttach(const std::string& accountId, + const std::string& webViewId, + const std::string& action) + = 0; + + /** + * @brief Called by the daemon whenever the client detaches a webview + */ + virtual void pluginWebViewDetach(const std::string& webViewId) = 0; + +private: + // the dataPath of the plugin that created this WebViewHandler + std::string id_; +}; +} // namespace jami diff --git a/src/plugin/webviewmessage.h b/src/plugin/webviewmessage.h new file mode 100644 index 00000000000..27c9f499f8d --- /dev/null +++ b/src/plugin/webviewmessage.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2022 Savoir-faire Linux Inc. + * + * Author: Tobias Hildebrandt + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +#pragma once +#include + +namespace jami { +/** + * @struct WebViewMessage + * @brief Contains data about a web view message + * Used by WebViewServicesManager. Passed from a plugin to the daemon. After that, this struct is no + * longer used. + */ +struct WebViewMessage +{ + // Which webview is this message about + const std::string webViewId; + + // Message identifier + const std::string messageId; + + // The actual message itself. Can be a path, JSON, XML, or anything, + // as long as it fits in a string + const std::string payload; +}; +} // namespace jami diff --git a/src/plugin/webviewservicesmanager.cpp b/src/plugin/webviewservicesmanager.cpp new file mode 100644 index 00000000000..516ccaf0f6b --- /dev/null +++ b/src/plugin/webviewservicesmanager.cpp @@ -0,0 +1,161 @@ +/* + * Copyright (C) 2022 Savoir-faire Linux Inc. + * + * Author: Tobias Hildebrandt + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "webviewservicesmanager.h" +#include "client/ring_signal.h" +#include "pluginmanager.h" +#include "logger.h" +#include "manager.h" +#include "jamidht/jamiaccount.h" +#include "fileutils.h" +#include "plugin_manager_interface.h" +#include "pluginsutils.h" +#include "webviewmessage.h" +#include +#include + +namespace jami { + +WebViewServicesManager::WebViewServicesManager(PluginManager& pluginManager) +{ + registerComponentsLifeCycleManagers(pluginManager); + registerWebViewService(pluginManager); +} + +WebViewHandler* +WebViewServicesManager::getWebViewHandlerPointer(const std::string& pluginId) +{ + auto it = handlersIdMap.find(pluginId); + // check if handler with specified pluginId does not exist + if (it == handlersIdMap.end()) { + JAMI_ERR("handler with pluginId %s was not found!", pluginId.c_str()); + return nullptr; + } + + // we know that the pointer exists + return it->second.get(); +} + +void +WebViewServicesManager::registerComponentsLifeCycleManagers(PluginManager& pluginManager) +{ + // called by the plugin manager whenever a plugin is loaded + auto registerWebViewHandler = [this](void* data, std::mutex& pmMtx_) { + std::lock_guard lk(pmMtx_); + + WebViewHandlerPtr ptr {(static_cast(data))}; + + // make sure pointer is valid + if (!ptr) { + JAMI_ERR("trying to register a webview handler with invalid pointer!"); + return -1; + } + + // pointer is valid, get details + auto id = ptr->id(); + + // add the handler to our map + handlersIdMap[id] = std::move(ptr); + + return 0; + }; + + // called by the plugin manager whenever a plugin is unloaded + auto unregisterWebViewHandler = [this](void* data, std::mutex& pmMtx_) { + std::lock_guard pluginManagerLock(pmMtx_); + + WebViewHandler* ptr {(static_cast(data))}; + + // make sure pointer is valid + if (!ptr) { + JAMI_ERR("trying to unregister a webview handler with invalid pointer!"); + return false; + } + + // pointer is valid, get details + auto id = ptr->id(); + + // remove from our map, unique_ptr gets destroyed + handlersIdMap.erase(id); + + return true; + }; + + // register the functions + pluginManager.registerComponentManager("WebViewHandlerManager", + registerWebViewHandler, + unregisterWebViewHandler); +} + +void +WebViewServicesManager::registerWebViewService(PluginManager& pluginManager) +{ + // NOTE: These are API calls that can be called by the plugin + auto pluginWebViewMessage = [](const DLPlugin* plugin, void* data) { + // the plugin must pass data as a WebViewMessage pointer + auto* message = static_cast(data); + + // get datapath for the plugin + const std::string& dataPath = PluginUtils::dataPath(plugin->getPath()); + + emitSignal(dataPath, + message->webViewId, + message->messageId, + message->payload); + + return 0; + }; + + // register the service. + pluginManager.registerService("pluginWebViewMessage", pluginWebViewMessage); +} + +void +WebViewServicesManager::sendWebViewMessage(const std::string& pluginId, + const std::string& webViewId, + const std::string& messageId, + const std::string& payload) +{ + if (auto* handler = getWebViewHandlerPointer(pluginId)) { + handler->pluginWebViewMessage(webViewId, messageId, payload); + } +} + +std::string +WebViewServicesManager::sendWebViewAttach(const std::string& pluginId, + const std::string& accountId, + const std::string& webViewId, + const std::string& action) +{ + if (auto* handler = getWebViewHandlerPointer(pluginId)) { + return handler->pluginWebViewAttach(accountId, webViewId, action); + } + return ""; +} + +void +WebViewServicesManager::sendWebViewDetach(const std::string& pluginId, const std::string& webViewId) +{ + if (auto* handler = getWebViewHandlerPointer(pluginId)) { + handler->pluginWebViewDetach(webViewId); + } +} + +} // namespace jami diff --git a/src/plugin/webviewservicesmanager.h b/src/plugin/webviewservicesmanager.h new file mode 100644 index 00000000000..392a9d9ccb1 --- /dev/null +++ b/src/plugin/webviewservicesmanager.h @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2022 Savoir-faire Linux Inc. + * + * Author: Tobias Hildebrandt + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +// adapted from ChatServicesManager + +#pragma once + +#include "noncopyable.h" +#include "webviewhandler.h" +#include +#include +#include +#include +#include +#include + +namespace jami { + +class PluginManager; + +using WebViewHandlerPtr = std::unique_ptr; + +/** + * @brief This class provides the interface between loaded WebViewHandlers + * and client webviews. + */ +class WebViewServicesManager +{ +public: + /** + * @brief Registers the WebViewHandler services with the PluginManager, + * allows for loading/unloading, and interaction with client webviews + * @param pluginManager + */ + WebViewServicesManager(PluginManager& pluginManager); + + NON_COPYABLE(WebViewServicesManager); + + /** + * @brief Transmits a message from the client's webview to the plugin + * @param pluginId + * @param webViewId + * @param messageId + * @param payload The message itself + */ + void sendWebViewMessage(const std::string& pluginId, + const std::string& webViewId, + const std::string& messageId, + const std::string& payload); + + /** + * @brief Transmits an attach event from the client's webview to the plugin + * @param pluginId + * @param accountId + * @param webViewId + * @param action The reason why the webview was created + * @returns a relative path to an HTML file inside the datapath + */ + std::string sendWebViewAttach(const std::string& pluginId, + const std::string& accountId, + const std::string& webViewId, + const std::string& action); + + /** + * @brief Transmits a detach event from the client's webview to the plugin + * @param pluginId + * @param webViewId + */ + void sendWebViewDetach(const std::string& pluginId, const std::string& webViewId); + +private: + /** + * @brief Registers the WebViewHandler services with the PluginManager + * @param pluginManager + */ + void registerComponentsLifeCycleManagers(PluginManager& pluginManager); + + /** + * @brief Exposes services that aren't related to life cycle management + * @param pluginManager + */ + void registerWebViewService(PluginManager& pluginManager); + + /** + * @brief Get the webview handler for a specified plugin + * @return A WebViewHandler pointer + */ + WebViewHandler* getWebViewHandlerPointer(const std::string& pluginId); + + /** + * @brief map of all registered handlers, pluginId -> HandlerPtr + */ + std::map handlersIdMap {}; +}; +} // namespace jami