#include #include "pluginmanager.h" #include #include #include #include #include #include #include #include // lets disable the plugin system for now, as it's unfinished. #define WINDOWS_SYS #ifndef WINDOWS_SYS #include #endif std::string RsPluginManager::_plugin_entry_symbol ; std::string RsPluginManager::_local_cache_dir ; std::string RsPluginManager::_remote_cache_dir ; ftServer *RsPluginManager::_ftserver = NULL ; p3ConnectMgr *RsPluginManager::_connectmgr = NULL ; typedef RsPlugin *(*RetroSharePluginEntry)(void) ; RsPluginHandler *rsPlugins ; void RsPluginManager::setCacheDirectories(const std::string& local_cache, const std::string& remote_cache) { _local_cache_dir = local_cache ; _remote_cache_dir = remote_cache ; } bool RsPluginManager::acceptablePluginName(const std::string& name) { // Needs some windows specific code here // #ifdef WINDOWS_SYS return name.size() > 4 && !strcmp(name.c_str()+name.size()-3,".dll") ; #else return name.size() > 3 && !strcmp(name.c_str()+name.size()-3,".so") ; #endif } void RsPluginManager::loadPlugins(const std::vector& plugin_directories) { _plugin_entry_symbol = "RETROSHARE_PLUGIN_provide" ; // 0 - get the list of files to read for(uint32_t i=0;irs_cache_service() != NULL && (seconds % _plugins[i]->rs_cache_service()->tickDelay() )) { std::cerr << " ticking plugin " << _plugins[i]->getPluginName() << std::endl; _plugins[i]->rs_cache_service()->tick() ; } } void RsPluginManager::registerCacheServices() { std::cerr << " Registering cache services." << std::endl; for(uint32_t i=0;i<_plugins.size();++i) if(_plugins[i]->rs_cache_service() != NULL) { rsFiles->getCacheStrapper()->addCachePair(CachePair(_plugins[i]->rs_cache_service(),_plugins[i]->rs_cache_service(),CacheId(_plugins[i]->rs_service_id(), 0))) ; std::cerr << " adding new cache pair for plugin " << _plugins[i]->getPluginName() << ", with RS_ID " << _plugins[i]->rs_service_id() << std::endl ; } } void RsPluginManager::registerClientServices(p3ServiceServer *pqih) { std::cerr << " Registering pqi services." << std::endl; for(uint32_t i=0;i<_plugins.size();++i) if(_plugins[i]->rs_pqi_service() != NULL) { pqih->addService(_plugins[i]->rs_pqi_service()) ; std::cerr << " Added pqi service for plugin " << _plugins[i]->getPluginName() << std::endl; } } void RsPluginManager::addConfigurations(p3ConfigMgr *ConfigMgr) { std::cerr << " Registering configuration files." << std::endl; for(uint32_t i=0;i<_plugins.size();++i) if(_plugins[i]->configurationFileName().length() > 0) { ConfigMgr->addConfiguration(_plugins[i]->configurationFileName(), _plugins[i]->rs_cache_service()); std::cerr << " Added configuration for plugin " << _plugins[i]->getPluginName() << ", with file " << _plugins[i]->configurationFileName() << std::endl; } } RsCacheService::RsCacheService(uint16_t service_type,uint32_t config_type,uint32_t tick_delay) : CacheSource(service_type, true, rsPlugins->getFileServer()->getCacheStrapper(), rsPlugins->getLocalCacheDir()), CacheStore (service_type, true, rsPlugins->getFileServer()->getCacheStrapper(), rsPlugins->getFileServer()->getCacheTransfer(), rsPlugins->getRemoteCacheDir()), p3Config(config_type), // CONFIG_TYPE_RANK_LINK _tick_delay_in_seconds(tick_delay) { }