added settings page for plugins.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4283 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2011-06-17 19:59:01 +00:00
parent 3c93d21b34
commit e6f2d22a8c
12 changed files with 699 additions and 6 deletions

View File

@ -138,7 +138,8 @@ PUBLIC_HEADERS = retroshare/rsblogs.h \
retroshare/rsturtle.h \
retroshare/rstypes.h
HEADERS += plugins/pluginmanager.h
HEADERS += plugins/pluginmanager.h \
plugins/dlfcn_win32.h
HEADERS += $$PUBLIC_HEADERS
@ -483,7 +484,8 @@ SOURCES += rsserver/p3discovery.cc \
rsserver/rsloginhandler.cc \
rsserver/rstypes.cc
SOURCES += plugins/pluginmanager.cc
SOURCES += plugins/pluginmanager.cc \
plugins/dlfcn_win32.cc
SOURCES += serialiser/rsbaseitems.cc \
serialiser/rsbaseserial.cc \

View File

@ -20,6 +20,8 @@
std::string RsPluginManager::_plugin_entry_symbol ;
std::string RsPluginManager::_local_cache_dir ;
std::string RsPluginManager::_remote_cache_dir ;
std::vector<std::string> RsPluginManager::_plugin_directories ;
ftServer *RsPluginManager::_ftserver = NULL ;
p3ConnectMgr *RsPluginManager::_connectmgr = NULL ;
@ -45,6 +47,7 @@ bool RsPluginManager::acceptablePluginName(const std::string& name)
void RsPluginManager::loadPlugins(const std::vector<std::string>& plugin_directories)
{
_plugin_directories = plugin_directories ;
_plugin_entry_symbol = "RETROSHARE_PLUGIN_provide" ;
// 0 - get the list of files to read
@ -55,7 +58,7 @@ void RsPluginManager::loadPlugins(const std::vector<std::string>& plugin_directo
if(!dirIt.isValid())
{
std::cerr << "Plugin directory : " << plugin_directories[i] << " does not exist." << std::endl ;
return ;
continue ;
}
while(dirIt.readdir())

View File

@ -16,6 +16,8 @@ class RsPluginManager: public RsPluginHandler
virtual int nbPlugins() const { return _plugins.size() ; }
virtual RsPlugin *plugin(int i) { return _plugins[i] ; }
virtual const std::vector<std::string>& getPluginDirectories() const { return _plugin_directories ; }
virtual void slowTickPlugins(time_t sec) ;
virtual void addConfigurations(p3ConfigMgr *cfgMgr) ;
@ -44,5 +46,7 @@ class RsPluginManager: public RsPluginHandler
static std::string _local_cache_dir ;
static ftServer *_ftserver ;
static p3ConnectMgr *_connectmgr ;
static std::vector<std::string> _plugin_directories ;
};

View File

@ -28,6 +28,7 @@
#include <time.h>
#include <stdint.h>
#include <string>
#include <vector>
class RsPluginHandler ;
extern RsPluginHandler *rsPlugins ;
@ -61,6 +62,8 @@ class RsPluginHandler
//
virtual int nbPlugins() const = 0 ;
virtual RsPlugin *plugin(int i) = 0 ;
virtual const std::vector<std::string>& getPluginDirectories() const = 0;
virtual void slowTickPlugins(time_t sec) = 0 ;
virtual const std::string& getLocalCacheDir() const =0;

View File

@ -1925,10 +1925,13 @@ int RsServer::StartupRetroShare()
std::string channelsdir = config_dir + "/channels";
std::string blogsdir = config_dir + "/blogs";
std::string forumdir = config_dir + "/forums";
std::string plugins_dir = "." ;
std::vector<std::string> plugins_directories ;
#ifndef WINDOWS_SYS
plugins_directories.push_back(std::string("/usr/lib/retroshare/extensions/")) ;
#endif
plugins_directories.push_back(RsInitConfig::basedir + "/extensions/") ;
plugins_directories.push_back(".") ; // this list should be saved/set to some correct value.
// possible entries include: /usr/lib/retroshare, ~/.retroshare/extensions/, etc.

View File

@ -290,6 +290,7 @@ HEADERS += rshare.h \
gui/settings/MessagePage.h \
gui/settings/NewTag.h \
gui/settings/ForumPage.h \
gui/settings/PluginsPage.h \
gui/settings/AppearancePage.h \
gui/settings/FileAssociationsPage.h \
gui/settings/SoundPage.h \
@ -401,6 +402,7 @@ FORMS += gui/StartDialog.ui \
gui/settings/MessagePage.ui \
gui/settings/NewTag.ui \
gui/settings/ForumPage.ui \
gui/settings/PluginsPage.ui \
gui/settings/AppearancePage.ui \
gui/settings/TransferPage.ui \
gui/settings/SoundPage.ui \
@ -543,6 +545,7 @@ SOURCES += main.cpp \
gui/settings/MessagePage.cpp \
gui/settings/NewTag.cpp \
gui/settings/ForumPage.cpp \
gui/settings/PluginsPage.cpp \
gui/settings/AppearancePage.cpp \
gui/settings/FileAssociationsPage.cpp \
gui/settings/SoundPage.cpp \

View File

@ -0,0 +1,73 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2006, crypton
*
* 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 2
* 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 "PluginsPage.h"
#include "rshare.h"
#include "rsharesettings.h"
#include <retroshare/rsplugin.h>
#include "../MainWindow.h"
PluginsPage::PluginsPage(QWidget * parent, Qt::WFlags flags)
: ConfigPage(parent, flags)
{
ui.setupUi(this);
setAttribute(Qt::WA_QuitOnClose, false);
QString text ;
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>") ;
ui._loadedPlugins_TB->setHtml(text) ;
const std::vector<std::string>& dirs(rsPlugins->getPluginDirectories()) ;
text = "" ;
for(int i=0;i<dirs.size();++i)
text += "<b>"+QString::fromStdString(dirs[i]) + "</b><br/>" ;
ui._lookupDirectories_TB->setHtml(text) ;
}
PluginsPage::~PluginsPage()
{
}
/** Saves the changes on this page */
bool PluginsPage::save(QString &errmsg)
{
// nothing to save for now.
return true;
}
/** Loads the settings for this page */
void PluginsPage::load()
{
}

View File

@ -0,0 +1,43 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2006, crypton
*
* 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 2
* 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 "configpage.h"
#include "ui_PluginsPage.h"
class PluginsPage : public ConfigPage
{
Q_OBJECT
public:
PluginsPage(QWidget * parent = 0, Qt::WFlags flags = 0);
~PluginsPage();
/** Saves the changes on this page */
bool save(QString &errmsg);
/** Loads the settings for this page */
void load();
private:
Ui::PluginsPage ui;
};

View File

@ -0,0 +1,544 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PluginsPage</class>
<widget class="QWidget" name="PluginsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>423</width>
<height>340</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>208</red>
<green>208</green>
<blue>208</blue>
</color>
</brush>
</colorrole>
<colorrole role="Light">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Midlight">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>247</red>
<green>247</green>
<blue>247</blue>
</color>
</brush>
</colorrole>
<colorrole role="Dark">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>104</red>
<green>104</green>
<blue>104</blue>
</color>
</brush>
</colorrole>
<colorrole role="Mid">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>139</red>
<green>139</green>
<blue>139</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="BrightText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>240</red>
<green>240</green>
<blue>240</blue>
</color>
</brush>
</colorrole>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Highlight">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>128</blue>
</color>
</brush>
</colorrole>
<colorrole role="HighlightedText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Link">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="LinkVisited">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="AlternateBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>231</red>
<green>231</green>
<blue>231</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>208</red>
<green>208</green>
<blue>208</blue>
</color>
</brush>
</colorrole>
<colorrole role="Light">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Midlight">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>247</red>
<green>247</green>
<blue>247</blue>
</color>
</brush>
</colorrole>
<colorrole role="Dark">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>104</red>
<green>104</green>
<blue>104</blue>
</color>
</brush>
</colorrole>
<colorrole role="Mid">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>139</red>
<green>139</green>
<blue>139</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="BrightText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>240</red>
<green>240</green>
<blue>240</blue>
</color>
</brush>
</colorrole>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Highlight">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>192</red>
<green>192</green>
<blue>192</blue>
</color>
</brush>
</colorrole>
<colorrole role="HighlightedText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Link">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="LinkVisited">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="AlternateBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>231</red>
<green>231</green>
<blue>231</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>104</red>
<green>104</green>
<blue>104</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>208</red>
<green>208</green>
<blue>208</blue>
</color>
</brush>
</colorrole>
<colorrole role="Light">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Midlight">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>247</red>
<green>247</green>
<blue>247</blue>
</color>
</brush>
</colorrole>
<colorrole role="Dark">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>104</red>
<green>104</green>
<blue>104</blue>
</color>
</brush>
</colorrole>
<colorrole role="Mid">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>139</red>
<green>139</green>
<blue>139</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>104</red>
<green>104</green>
<blue>104</blue>
</color>
</brush>
</colorrole>
<colorrole role="BrightText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>104</red>
<green>104</green>
<blue>104</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>240</red>
<green>240</green>
<blue>240</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>240</red>
<green>240</green>
<blue>240</blue>
</color>
</brush>
</colorrole>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Highlight">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>128</blue>
</color>
</brush>
</colorrole>
<colorrole role="HighlightedText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Link">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="LinkVisited">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="AlternateBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>231</red>
<green>231</green>
<blue>231</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="font">
<font>
<family>Arial</family>
<pointsize>8</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
<underline>false</underline>
<strikeout>false</strikeout>
</font>
</property>
<property name="contextMenuPolicy">
<enum>Qt::NoContextMenu</enum>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Loaded plugins</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QTextBrowser" name="_loadedPlugins_TB"/>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Plugin look-up directories</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTextBrowser" name="_lookupDirectories_TB"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -34,6 +34,7 @@
#include "ChatPage.h"
#include "MessagePage.h"
#include "ForumPage.h"
#include "PluginsPage.h"
#define IMAGE_GENERAL ":/images/kcmsystem24.png"
@ -114,6 +115,7 @@ RSettingsWin::initStackedWidget()
stackedWidget->addWidget(new ChatPage());
stackedWidget->addWidget(new AppearancePage());
stackedWidget->addWidget(new SoundPage() );
stackedWidget->addWidget(new PluginsPage() );
setNewPage(General);
}
@ -157,6 +159,10 @@ RSettingsWin::setNewPage(int page)
text = tr("Forum");
pageicon->setPixmap(QPixmap(":/images/konversation.png"));
break;
case Plugins:
text = tr("Plugins");
pageicon->setPixmap(QPixmap(":/images/extension_32.png"));
break;
case Chat:
text = tr("Chat");
pageicon->setPixmap(QPixmap(":/images/chat_24.png"));

View File

@ -32,7 +32,7 @@ class RSettingsWin: public QDialog, private Ui::Settings
public:
enum PageType { LastPage = -1, General = 0, Server, Transfer,
Directories, Notify, Security, Message, Forum, Chat, Appearance, Sound, Fileassociations };
Directories, Notify, Security, Message, Forum, Chat, Appearance, Sound, Plugins,Fileassociations };
static void showYourself(QWidget *parent, PageType page = LastPage);
static void postModDirectories(bool update_local);

View File

@ -176,6 +176,15 @@
<normaloff>:/images/sound.png</normaloff>:/images/sound.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>Plugins</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/extension_32.png</normaloff>:/images/extension_32.png</iconset>
</property>
</item>
</widget>
</item>
<item row="0" column="1">