diff --git a/libretroshare/src/plugins/pluginmanager.cc b/libretroshare/src/plugins/pluginmanager.cc index 8c5d7d30c..db0a90462 100644 --- a/libretroshare/src/plugins/pluginmanager.cc +++ b/libretroshare/src/plugins/pluginmanager.cc @@ -152,6 +152,33 @@ RsSerialiser *RsPluginManager::setupSerialiser() return rss ; } +void RsPluginManager::loadPlugins(const std::vector& plugins) +{ + for(uint32_t i=0;isetPlugInHandler(this); // WIN fix, cannot share global space with shared libraries + + // The following choice is conservative by forcing RS to resolve all dependencies at + // the time of loading the plugin. + + pinfo.status = PLUGIN_STATUS_LOADED ; + + _plugins.push_back(pinfo) ; + return true; +} + bool RsPluginManager::loadPlugin(const std::string& plugin_name) { std::cerr << " Loading plugin " << plugin_name << std::endl; diff --git a/libretroshare/src/plugins/pluginmanager.h b/libretroshare/src/plugins/pluginmanager.h index 475a8ab5d..b3da878cb 100644 --- a/libretroshare/src/plugins/pluginmanager.h +++ b/libretroshare/src/plugins/pluginmanager.h @@ -62,12 +62,23 @@ class RsPluginManager: public RsPluginHandler, public p3Config static void setFileServer(ftServer *ft) { _ftserver = ft ; } static void setLinkMgr(p3LinkMgr *cm) { _linkmgr = cm ; } - + // Normal plugin loading system. Parses through the plugin directories and loads + // dso libraries, checks for the hash, and loads/rejects plugins according to + // the user's choice. + // void loadPlugins(const std::vector& plugin_directories) ; + // Explicit function to load a plugin programatically. + // No hash-checking is performed (there's no DSO file to hash!) + // Mostly convenient for insering plugins in development. + // + void loadPlugins(const std::vector& explicit_plugin_entries) ; + void registerCacheServices() ; void registerClientServices(p3ServiceServer *pqih) ; + private: + bool loadPlugin(RsPlugin *) ; bool loadPlugin(const std::string& shared_library_name) ; std::string hashPlugin(const std::string& shared_library_name) ; diff --git a/libretroshare/src/rsserver/rsinit.cc b/libretroshare/src/rsserver/rsinit.cc index fb6be7c7b..faa98edda 100644 --- a/libretroshare/src/rsserver/rsinit.cc +++ b/libretroshare/src/rsserver/rsinit.cc @@ -2060,11 +2060,22 @@ int RsServer::StartupRetroShare() // mPluginsManager->loadPlugins(plugins_directories) ; - // set interfaces for plugins - RsPlugInInterfaces interfaces; - interfaces.mFiles = rsFiles; - interfaces.mPeers = rsPeers; - mPluginsManager->setInterfaces(interfaces); + // Also load some plugins explicitly. This is helpful for + // - developping plugins + // + std::vector programatically_inserted_plugins ; + + // Push your own plugins into this list, before the call: + // + // programatically_inserted_plugins.push_back(myCoolPlugin) ; + // + mPluginsManager->loadPlugins(programatically_inserted_plugins) ; + + // set interfaces for plugins + RsPlugInInterfaces interfaces; + interfaces.mFiles = rsFiles; + interfaces.mPeers = rsPeers; + mPluginsManager->setInterfaces(interfaces); /* create Services */ ad = new p3disc(mPeerMgr, mLinkMgr, mNetMgr, pqih);