mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-12 11:02:30 -04:00
Improvement of the plugin system:
- Added configuration saving for plugin manager and serialization methods - added a list of accepted plugin hashes - added plugin widget for each plugin in settings, to allow enabling/disabling plugins - updated LinkCloud plugin to new rsPlugin class - put the addconfiguration for plugin manager in rsinit.cc a bit earlier to allow to load the list of accepted hashes early enough - added icon for disabled plugins git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4393 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
de87a89437
commit
ccfbfa9984
21 changed files with 965 additions and 103 deletions
|
@ -19,7 +19,10 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "PluginsPage.h"
|
||||
#include "PluginItem.h"
|
||||
#include "rshare.h"
|
||||
#include "rsharesettings.h"
|
||||
|
||||
|
@ -35,17 +38,67 @@ PluginsPage::PluginsPage(QWidget * parent, Qt::WFlags flags)
|
|||
|
||||
QString text ;
|
||||
|
||||
std::cerr << "PluginsPage: adding plugins" << std::endl;
|
||||
|
||||
if(rsPlugins->nbPlugins() > 0)
|
||||
for(int i=0;i<rsPlugins->nbPlugins();++i)
|
||||
{
|
||||
text += "<b>"+tr("Plugin")+":</b> \t" + QString::fromStdString(rsPlugins->plugin(i)->getPluginName()) + "<BR/>" ;
|
||||
text += "<b>"+tr("Description")+":</b> \t" + QString::fromStdString(rsPlugins->plugin(i)->getShortPluginDescription()) + "<BR/>" ;
|
||||
text += "<br/>" ;
|
||||
}
|
||||
else
|
||||
text = tr("<h3>No plugins loaded.</h3>") ;
|
||||
std::cerr << " Adding new page." << std::endl;
|
||||
|
||||
ui._loadedPlugins_TB->setHtml(text) ;
|
||||
std::string file_name, file_hash, error_string ;
|
||||
uint32_t status ;
|
||||
|
||||
rsPlugins->getPluginStatus(i,status,file_name,file_hash,error_string) ;
|
||||
|
||||
QString status_string ;
|
||||
|
||||
switch(status)
|
||||
{
|
||||
case PLUGIN_STATUS_UNKNOWN_HASH: status_string = tr("Hash rejected. Add to white list.") ;
|
||||
break ;
|
||||
case PLUGIN_STATUS_DLOPEN_ERROR: status_string = tr("Loading error.") ;
|
||||
break ;
|
||||
case PLUGIN_STATUS_MISSING_SYMBOL: status_string = tr("Missing symbol. Wrong version?") ;
|
||||
break ;
|
||||
case PLUGIN_STATUS_NULL_PLUGIN: status_string = tr("No plugin object") ;
|
||||
break ;
|
||||
case PLUGIN_STATUS_LOADED: status_string = tr("Plugins is loaded.") ;
|
||||
break ;
|
||||
default:
|
||||
status_string = tr("Unknown status.") ;
|
||||
}
|
||||
|
||||
QIcon plugin_icon(":images/disabled_plugin_48.png") ;
|
||||
RsPlugin *plugin = rsPlugins->plugin(i) ;
|
||||
QString pluginTitle = tr("Title unavailable") ;
|
||||
QString pluginDescription = tr("Description unavailable") ;
|
||||
|
||||
if(plugin!=NULL)
|
||||
{
|
||||
if(plugin->qt_icon() != NULL)
|
||||
plugin_icon = *plugin->qt_icon() ;
|
||||
|
||||
pluginTitle = QString::fromStdString(plugin->getPluginName()) ;
|
||||
pluginDescription = QString::fromStdString(plugin->getShortPluginDescription()) ;
|
||||
}
|
||||
|
||||
PluginItem *item = new PluginItem(i,pluginTitle,pluginDescription,status_string,
|
||||
QString::fromStdString(file_name),
|
||||
QString::fromStdString(file_hash),QString::fromStdString(error_string),
|
||||
plugin_icon) ;
|
||||
|
||||
ui._pluginsLayout->insertWidget(0,item) ;
|
||||
|
||||
if(plugin == NULL || plugin->qt_config_panel() == NULL)
|
||||
item->_configure_PB->setEnabled(false) ;
|
||||
|
||||
if(plugin != NULL)
|
||||
item->_enabled_CB->setChecked(true) ;
|
||||
|
||||
QObject::connect(item,SIGNAL(pluginEnabled(bool,const QString&)),this,SLOT(togglePlugin(bool,const QString&))) ;
|
||||
QObject::connect(item,SIGNAL(pluginConfigure(int)),this,SLOT(configurePlugin(int))) ;
|
||||
}
|
||||
ui._pluginsLayout->update() ;
|
||||
|
||||
const std::vector<std::string>& dirs(rsPlugins->getPluginDirectories()) ;
|
||||
text = "" ;
|
||||
|
@ -55,6 +108,22 @@ PluginsPage::PluginsPage(QWidget * parent, Qt::WFlags flags)
|
|||
|
||||
ui._lookupDirectories_TB->setHtml(text) ;
|
||||
}
|
||||
void PluginsPage::configurePlugin(int i)
|
||||
{
|
||||
std::cerr << "Launching configuration window for plugin " << i << std::endl;
|
||||
|
||||
if(rsPlugins->plugin(i) != NULL && rsPlugins->plugin(i)->qt_config_panel() != NULL)
|
||||
rsPlugins->plugin(i)->qt_config_panel()->show() ;
|
||||
}
|
||||
void PluginsPage::togglePlugin(bool b,const QString& hash)
|
||||
{
|
||||
std::cerr << "Switching status of plugin " << hash.toStdString() << " to " << b << std::endl;
|
||||
|
||||
if(b)
|
||||
rsPlugins->enablePlugin(hash.toStdString()) ;
|
||||
else
|
||||
rsPlugins->disablePlugin(hash.toStdString()) ;
|
||||
}
|
||||
|
||||
PluginsPage::~PluginsPage()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue