mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 06:06:10 -04:00
Improvement to plugin system:
- made config page system more automatic, to allow addign config pages from plugins - added (disabled) checkbox and function to allow all plugins for development - added config page methods to RsPlugin class git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4957 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
13283b40ee
commit
5679a30e67
25 changed files with 220 additions and 300 deletions
|
@ -36,6 +36,7 @@ RsPluginHandler *rsPlugins ;
|
|||
|
||||
RsPluginManager::RsPluginManager() : p3Config(CONFIG_TYPE_PLUGINS)
|
||||
{
|
||||
_allow_all_plugins = false ;
|
||||
}
|
||||
|
||||
void RsPluginManager::loadConfiguration()
|
||||
|
@ -145,10 +146,20 @@ void RsPluginManager::getPluginStatus(int i,uint32_t& status,std::string& file_n
|
|||
file_name = _plugins[i].file_name ;
|
||||
}
|
||||
|
||||
bool RsPluginManager::getAllowAllPlugins() const
|
||||
{
|
||||
return _allow_all_plugins ;
|
||||
}
|
||||
void RsPluginManager::allowAllPlugins(bool b)
|
||||
{
|
||||
_allow_all_plugins = b ;
|
||||
IndicateConfigChanged() ;
|
||||
}
|
||||
RsSerialiser *RsPluginManager::setupSerialiser()
|
||||
{
|
||||
RsSerialiser *rss = new RsSerialiser ;
|
||||
rss->addSerialType(new RsPluginSerialiser()) ;
|
||||
rss->addSerialType(new RsPluginSerialiser()) ;
|
||||
rss->addSerialType(new RsGeneralConfigSerialiser()) ;
|
||||
|
||||
return rss ;
|
||||
}
|
||||
|
@ -203,7 +214,7 @@ bool RsPluginManager::loadPlugin(const std::string& plugin_name)
|
|||
|
||||
std::cerr << " -> hash = " << pinfo.file_hash << std::endl;
|
||||
|
||||
if(_accepted_hashes.find(pinfo.file_hash) == _accepted_hashes.end())
|
||||
if((!_allow_all_plugins) && _accepted_hashes.find(pinfo.file_hash) == _accepted_hashes.end())
|
||||
{
|
||||
std::cerr << " -> hash is not in white list. Plugin is rejected. Go to config->plugins to authorise this plugin." << std::endl;
|
||||
pinfo.status = PLUGIN_STATUS_UNKNOWN_HASH ;
|
||||
|
@ -342,7 +353,19 @@ bool RsPluginManager::loadList(std::list<RsItem*>& list)
|
|||
_accepted_hashes.insert(*it) ;
|
||||
std::cerr << " loaded hash " << *it << std::endl;
|
||||
}
|
||||
|
||||
|
||||
RsConfigKeyValueSet *witem = dynamic_cast<RsConfigKeyValueSet *>(*it) ;
|
||||
|
||||
if(witem)
|
||||
{
|
||||
for(std::list<RsTlvKeyValue>::const_iterator kit = witem->tlvkvs.pairs.begin(); kit != witem->tlvkvs.pairs.end(); ++kit)
|
||||
if((*kit).key == "ALLOW_ALL_PLUGINS")
|
||||
{
|
||||
std::cerr << "WARNING: Allowing all plugins. No hash will be checked. Be careful! " << std::endl ;
|
||||
_allow_all_plugins = (kit->value == "YES");
|
||||
}
|
||||
}
|
||||
|
||||
delete (*it);
|
||||
}
|
||||
return true;
|
||||
|
@ -359,6 +382,14 @@ bool RsPluginManager::saveList(bool& cleanup, std::list<RsItem*>& list)
|
|||
|
||||
list.push_back(vitem) ;
|
||||
|
||||
RsConfigKeyValueSet *witem = new RsConfigKeyValueSet ;
|
||||
RsTlvKeyValue kv;
|
||||
kv.key = "ALLOW_ALL_PLUGINS" ;
|
||||
kv.value = _allow_all_plugins?"YES":"NO" ;
|
||||
witem->tlvkvs.pairs.push_back(kv) ;
|
||||
|
||||
list.push_back(witem) ;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,9 @@ class RsPluginManager: public RsPluginHandler, public p3Config
|
|||
virtual ftServer *getFileServer() const ;
|
||||
virtual p3LinkMgr *getLinkMgr() const ;
|
||||
|
||||
virtual void allowAllPlugins(bool b) ;
|
||||
virtual bool getAllowAllPlugins() const ;
|
||||
|
||||
// ---------------- Derived from p3Config -------------------//
|
||||
//
|
||||
bool saveList(bool& cleanup, std::list<RsItem*>& list) ;
|
||||
|
@ -84,6 +87,7 @@ class RsPluginManager: public RsPluginHandler, public p3Config
|
|||
|
||||
std::vector<PluginInfo> _plugins ;
|
||||
std::set<std::string> _accepted_hashes ;
|
||||
bool _allow_all_plugins ;
|
||||
|
||||
static std::string _plugin_entry_symbol ;
|
||||
static std::string _remote_cache_dir ;
|
||||
|
|
|
@ -45,6 +45,7 @@ class QTranslator;
|
|||
class QApplication;
|
||||
class RsCacheService ;
|
||||
class ftServer ;
|
||||
class ConfigPage ;
|
||||
class pqiService ;
|
||||
|
||||
// Used for the status of plugins.
|
||||
|
@ -83,6 +84,8 @@ class RsPlugin
|
|||
virtual MainPage *qt_page() const { return NULL ; }
|
||||
virtual QWidget *qt_config_panel() const { return NULL ; }
|
||||
virtual QIcon *qt_icon() const { return NULL ; }
|
||||
virtual ConfigPage *qt_config_page() const { return NULL ; }
|
||||
|
||||
virtual QTranslator *qt_translator(QApplication * /* app */, const QString& /* languageCode */ ) const { return NULL ; }
|
||||
|
||||
virtual std::string configurationFileName() const { return std::string() ; }
|
||||
|
@ -105,6 +108,9 @@ class RsPluginHandler
|
|||
virtual void enablePlugin(const std::string& hash) = 0;
|
||||
virtual void disablePlugin(const std::string& hash) = 0;
|
||||
|
||||
virtual void allowAllPlugins(bool b) = 0 ;
|
||||
virtual bool getAllowAllPlugins() const = 0 ;
|
||||
|
||||
virtual void slowTickPlugins(time_t sec) = 0 ;
|
||||
|
||||
virtual const std::string& getLocalCacheDir() const =0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue