- Added basic infrastructure to plugin system in libretroshare and retroshare-gui.

- ported LinksCloud to a new plugin, and removed it from main sources

Next moves:
- add gui for managing plugins
- handle windows compilation



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4275 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2011-06-16 21:59:26 +00:00
parent 3925a7114a
commit a2c91a7924
28 changed files with 4676 additions and 243 deletions

View File

@ -88,8 +88,9 @@ void setP3Interface(P3Interface *pqi);
/* add Config Items (Extra, Controller) */ /* add Config Items (Extra, Controller) */
void addConfigComponents(p3ConfigMgr *mgr); void addConfigComponents(p3ConfigMgr *mgr);
CacheStrapper *getCacheStrapper(); virtual CacheStrapper *getCacheStrapper();
CacheTransfer *getCacheTransfer(); virtual CacheTransfer *getCacheTransfer();
std::string OwnId(); std::string OwnId();
/* Final Setup (once everything is assigned) */ /* Final Setup (once everything is assigned) */

View File

@ -128,6 +128,7 @@ PUBLIC_HEADERS = retroshare/rsblogs.h \
retroshare/rsforums.h \ retroshare/rsforums.h \
retroshare/rsiface.h \ retroshare/rsiface.h \
retroshare/rsinit.h \ retroshare/rsinit.h \
retroshare/rsplugin.h \
retroshare/rsloginhandler.h \ retroshare/rsloginhandler.h \
retroshare/rsmsgs.h \ retroshare/rsmsgs.h \
retroshare/rsnotify.h \ retroshare/rsnotify.h \
@ -137,6 +138,8 @@ PUBLIC_HEADERS = retroshare/rsblogs.h \
retroshare/rsturtle.h \ retroshare/rsturtle.h \
retroshare/rstypes.h retroshare/rstypes.h
HEADERS += plugins/pluginmanager.h
HEADERS += $$PUBLIC_HEADERS HEADERS += $$PUBLIC_HEADERS
# public headers to be... # public headers to be...
@ -359,7 +362,6 @@ HEADERS += rsserver/p3discovery.h \
rsserver/p3msgs.h \ rsserver/p3msgs.h \
rsserver/p3peers.h \ rsserver/p3peers.h \
rsserver/p3photo.h \ rsserver/p3photo.h \
rsserver/p3rank.h \
rsserver/p3status.h rsserver/p3status.h
HEADERS += serialiser/rsbaseitems.h \ HEADERS += serialiser/rsbaseitems.h \
@ -373,7 +375,6 @@ HEADERS += serialiser/rsbaseitems.h \
serialiser/rsgameitems.h \ serialiser/rsgameitems.h \
serialiser/rsmsgitems.h \ serialiser/rsmsgitems.h \
serialiser/rsphotoitems.h \ serialiser/rsphotoitems.h \
serialiser/rsrankitems.h \
serialiser/rsserial.h \ serialiser/rsserial.h \
serialiser/rsserviceids.h \ serialiser/rsserviceids.h \
serialiser/rsserviceitems.h \ serialiser/rsserviceitems.h \
@ -396,7 +397,6 @@ HEADERS += services/p3channels.h \
services/p3msgservice.h \ services/p3msgservice.h \
services/p3photoservice.h \ services/p3photoservice.h \
services/p3portservice.h \ services/p3portservice.h \
services/p3ranking.h \
services/p3service.h \ services/p3service.h \
services/p3statusservice.h \ services/p3statusservice.h \
services/p3tunnel.h services/p3tunnel.h
@ -477,13 +477,14 @@ SOURCES += rsserver/p3discovery.cc \
rsserver/p3msgs.cc \ rsserver/p3msgs.cc \
rsserver/p3peers.cc \ rsserver/p3peers.cc \
rsserver/p3photo.cc \ rsserver/p3photo.cc \
rsserver/p3rank.cc \
rsserver/p3status.cc \ rsserver/p3status.cc \
rsserver/rsiface.cc \ rsserver/rsiface.cc \
rsserver/rsinit.cc \ rsserver/rsinit.cc \
rsserver/rsloginhandler.cc \ rsserver/rsloginhandler.cc \
rsserver/rstypes.cc rsserver/rstypes.cc
SOURCES += plugins/pluginmanager.cc
SOURCES += serialiser/rsbaseitems.cc \ SOURCES += serialiser/rsbaseitems.cc \
serialiser/rsbaseserial.cc \ serialiser/rsbaseserial.cc \
serialiser/rsblogitems.cc \ serialiser/rsblogitems.cc \
@ -495,7 +496,6 @@ SOURCES += serialiser/rsbaseitems.cc \
serialiser/rsgameitems.cc \ serialiser/rsgameitems.cc \
serialiser/rsmsgitems.cc \ serialiser/rsmsgitems.cc \
serialiser/rsphotoitems.cc \ serialiser/rsphotoitems.cc \
serialiser/rsrankitems.cc \
serialiser/rsserial.cc \ serialiser/rsserial.cc \
serialiser/rsstatusitems.cc \ serialiser/rsstatusitems.cc \
serialiser/rstlvaddrs.cc \ serialiser/rstlvaddrs.cc \
@ -517,7 +517,6 @@ SOURCES += services/p3channels.cc \
services/p3msgservice.cc \ services/p3msgservice.cc \
services/p3photoservice.cc \ services/p3photoservice.cc \
services/p3portservice.cc \ services/p3portservice.cc \
services/p3ranking.cc \
services/p3service.cc \ services/p3service.cc \
services/p3statusservice.cc services/p3statusservice.cc
# removed because getPeer() doesn t exist services/p3tunnel.cc # removed because getPeer() doesn t exist services/p3tunnel.cc
@ -548,13 +547,11 @@ SOURCES += util/folderiterator.cc \
minimal { minimal {
SOURCES -= rsserver/p3msgs.cc \ SOURCES -= rsserver/p3msgs.cc \
rsserver/p3rank.cc \
rsserver/p3status.cc \ rsserver/p3status.cc \
rsserver/p3photo.cc rsserver/p3photo.cc
SOURCES -= serialiser/rsforumitems.cc \ SOURCES -= serialiser/rsforumitems.cc \
serialiser/rsstatusitems.cc \ serialiser/rsstatusitems.cc \
serialiser/rsrankitems.cc \
serialiser/rschannelitems.cc \ serialiser/rschannelitems.cc \
serialiser/rsgameitems.cc \ serialiser/rsgameitems.cc \
serialiser/rsphotoitems.cc serialiser/rsphotoitems.cc
@ -562,7 +559,6 @@ minimal {
SOURCES -= services/p3forums.cc \ SOURCES -= services/p3forums.cc \
services/p3msgservice.cc \ services/p3msgservice.cc \
services/p3statusservice.cc \ services/p3statusservice.cc \
services/p3ranking.cc \
services/p3channels.cc \ services/p3channels.cc \
services/p3gamelauncher.cc \ services/p3gamelauncher.cc \
services/p3photoservice.cc services/p3photoservice.cc

View File

@ -0,0 +1,25 @@
#pragma once
#include <dbase/cachestrapper.h>
// The following class abstracts the construction of a cache service. The user only has to
// supply RS with a type ID. If the ID is already in use, RS will complain.
//
class RsCacheService: public CacheSource, public CacheStore, public p3Config
{
public:
RsCacheService(uint16_t type,uint32_t config_type,uint32_t tick_delay_in_seconds) ;
uint32_t tickDelay() const { return _tick_delay_in_seconds ; }
virtual void tick() {}
// Functions from p3config
//
virtual RsSerialiser *setupSerialiser() { return NULL ; }
virtual bool saveList(bool&, std::list<RsItem*>&) { return false ;}
virtual bool loadList(std::list<RsItem*>&) { return false ;}
private:
uint32_t _tick_delay_in_seconds ;
};

View File

@ -0,0 +1,205 @@
#include <string.h>
#include "pluginmanager.h"
#include <dirent.h>
#include <util/folderiterator.h>
#include <ft/ftserver.h>
#include <dbase/cachestrapper.h>
#include <retroshare/rsplugin.h>
#include <retroshare/rsfiles.h>
#include <pqi/pqiservice.h>
#include <plugins/pluginclasses.h>
// lets disable the plugin system for now, as it's unfinished.
#define WINDOWS_SYS
#ifndef WINDOWS_SYS
#include <dlfcn.h>
#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<std::string>& plugin_directories)
{
_plugin_entry_symbol = "RETROSHARE_PLUGIN_provide" ;
// 0 - get the list of files to read
for(uint32_t i=0;i<plugin_directories.size();++i)
{
librs::util::FolderIterator dirIt(plugin_directories[i]);
if(!dirIt.isValid())
{
std::cerr << "Plugin directory : " << plugin_directories[i] << " does not exist." << std::endl ;
return ;
}
while(dirIt.readdir())
{
std::string fname;
dirIt.d_name(fname);
std::string fullname = plugin_directories[i] + "/" + fname;
if(!acceptablePluginName(fullname))
continue ;
std::cerr << "Found plugin " << fullname << std::endl;
std::cerr << " Loading plugin..." << std::endl;
loadPlugin(fullname) ;
}
dirIt.closedir();
}
std::cerr << "Loaded a total of " << _plugins.size() << " plugins." << std::endl;
}
bool RsPluginManager::loadPlugin(const std::string& plugin_name)
{
#ifndef WINDOWS_SYS
std::cerr << " Loading plugin " << plugin_name << std::endl;
// The following choice is somewhat dangerous since the program can stop when a symbol can
// not be resolved. However, this is the only way to bind a single .so for both the
// interface and command line executables.
int link_mode = RTLD_NOW | RTLD_GLOBAL ; // RTLD_NOW
//int link_mode = RTLD_GLOBAL ;
// Warning: this temporary vector is necessary, because linking with a .so that would include BundleManager.h
// is going to call the initialization of the static members of bundleManager a second time, and therefore
// will erase whatever is already initialized. So I first open all libraries, then fill the vectors.
//
void *handle = dlopen(plugin_name.c_str(),link_mode) ;
if(handle == NULL)
{
std::cerr << " Cannot open plugin: " << dlerror() << std::endl ;
return false ;
}
void *pf = dlsym(handle,_plugin_entry_symbol.c_str()) ;
if(pf == NULL)
std::cerr << dlerror() << std::endl ;
else
std::cerr << " Added function entry for symbol " << _plugin_entry_symbol << std::endl ;
RsPlugin *p = ( (*(RetroSharePluginEntry)pf)() ) ;
if(p == NULL)
{
std::cerr << " Plugin entry function " << _plugin_entry_symbol << " returns NULL ! It should return an object of type RsPlugin* " << std::endl;
return false ;
}
_plugins.push_back(p) ;
if(link_mode & RTLD_LAZY)
{
std::cerr << " Symbols have been linked in LAZY mode. This means that undefined symbols may" << std::endl ;
std::cerr << " crash your program any time." << std::endl ;
}
#else
std::cerr << " Plugin load is yet unimplemented under windows." << std::endl;
#endif
return true ;
}
p3ConnectMgr *RsPluginManager::getConnectMgr() const
{
assert(_connectmgr != NULL) ;
return _connectmgr ;
}
ftServer *RsPluginManager::getFileServer() const
{
assert(_ftserver != NULL) ;
return _ftserver ;
}
const std::string& RsPluginManager::getLocalCacheDir() const
{
assert(!_local_cache_dir.empty()) ;
return _local_cache_dir ;
}
const std::string& RsPluginManager::getRemoteCacheDir() const
{
assert(!_remote_cache_dir.empty()) ;
return _remote_cache_dir ;
}
void RsPluginManager::slowTickPlugins(time_t seconds)
{
for(uint32_t i=0;i<_plugins.size();++i)
if(_plugins[i]->rs_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)
{
}

View File

@ -0,0 +1,48 @@
#pragma once
#include <string>
#include <vector>
#include <retroshare/rsplugin.h>
class p3ConfigMgr ;
class p3ServiceServer ;
class p3ConnectMgr ;
class RsPluginManager: public RsPluginHandler
{
public:
RsPluginManager() {}
virtual ~RsPluginManager() {}
virtual int nbPlugins() const { return _plugins.size() ; }
virtual RsPlugin *plugin(int i) { return _plugins[i] ; }
virtual void slowTickPlugins(time_t sec) ;
virtual void addConfigurations(p3ConfigMgr *cfgMgr) ;
virtual const std::string& getLocalCacheDir() const ;
virtual const std::string& getRemoteCacheDir() const ;
virtual ftServer *getFileServer() const ;
virtual p3ConnectMgr *getConnectMgr() const ;
static void setPluginEntrySymbol(const std::string& s) { _plugin_entry_symbol = s ; }
static bool acceptablePluginName(const std::string& s) ;
static void setCacheDirectories(const std::string& local,const std::string& remote) ;
static void setFileServer(ftServer *ft) { _ftserver = ft ; }
static void setConnectMgr(p3ConnectMgr *cm) { _connectmgr = cm ; }
void loadPlugins(const std::vector<std::string>& plugin_directories) ;
void registerCacheServices() ;
void registerClientServices(p3ServiceServer *pqih) ;
private:
bool loadPlugin(const std::string& shared_library_name) ;
std::vector<RsPlugin *> _plugins ;
static std::string _plugin_entry_symbol ;
static std::string _remote_cache_dir ;
static std::string _local_cache_dir ;
static ftServer *_ftserver ;
static p3ConnectMgr *_connectmgr ;
};

View File

@ -82,7 +82,6 @@ const uint32_t CONFIG_TYPE_TURTLE = 0x0020;
/* wish these ids where higher... /* wish these ids where higher...
* may move when switch to v0.5 * may move when switch to v0.5
*/ */
const uint32_t CONFIG_TYPE_RANK_LINK = 0x0011;
const uint32_t CONFIG_TYPE_CHAT = 0x0012; const uint32_t CONFIG_TYPE_CHAT = 0x0012;
const uint32_t CONFIG_TYPE_STATUS = 0x0013; const uint32_t CONFIG_TYPE_STATUS = 0x0013;

View File

@ -37,6 +37,8 @@ class RsFiles;
extern RsFiles *rsFiles; extern RsFiles *rsFiles;
class Expression; class Expression;
class CacheStrapper ;
class CacheTransfer;
/* These are used mainly by ftController at the moment */ /* These are used mainly by ftController at the moment */
const uint32_t RS_FILE_CTRL_PAUSE = 0x00000100; const uint32_t RS_FILE_CTRL_PAUSE = 0x00000100;
@ -194,7 +196,8 @@ class RsFiles
virtual void setWatchPeriod(int minutes) =0; virtual void setWatchPeriod(int minutes) =0;
virtual int watchPeriod() const =0; virtual int watchPeriod() const =0;
virtual CacheStrapper *getCacheStrapper() =0;
virtual CacheTransfer *getCacheTransfer() =0;
virtual bool getShareDownloadDirectory() = 0; virtual bool getShareDownloadDirectory() = 0;
virtual bool shareDownloadDirectory(bool share) = 0; virtual bool shareDownloadDirectory(bool share) = 0;

View File

@ -26,6 +26,7 @@
#include "rsserver/p3face.h" #include "rsserver/p3face.h"
#include "retroshare/rsplugin.h"
#include "tcponudp/tou.h" #include "tcponudp/tou.h"
#include <sstream> #include <sstream>
@ -55,7 +56,6 @@ RsServer::RsServer(RsIface &i, NotifyBase &callback)
mChannels = NULL; mChannels = NULL;
mForums = NULL; mForums = NULL;
/* caches (that need ticking) */ /* caches (that need ticking) */
mRanking = NULL;
/* Config */ /* Config */
mConfigMgr = NULL; mConfigMgr = NULL;
@ -202,50 +202,9 @@ void RsServer::run()
#ifdef DEBUG_TICK #ifdef DEBUG_TICK
std::cerr << "RsServer::run() Updates()" << std::endl; std::cerr << "RsServer::run() Updates()" << std::endl;
#endif #endif
// These two have been completed!
//std::cerr << "RsServer::run() UpdateAllCerts()" << std::endl;
//UpdateAllCerts();
//std::cerr << "RsServer::run() UpdateAllNetwork()" << std::endl;
//UpdateAllNetwork();
// currently Dummy Functions.
//std::cerr << "RsServer::run() UpdateAllTransfers()" << std::endl;
//std::cerr << "RsServer::run() ";
//std::cerr << "UpdateRemotePeople()"<<std::endl;
//UpdateRemotePeople();
//std::cerr << "RsServer::run() UpdateAllFiles()" << std::endl;
//UpdateAllFiles();
//std::cerr << "RsServer::run() UpdateAllConfig()" << std::endl;
UpdateAllConfig(); UpdateAllConfig();
//std::cerr << "RsServer::run() CheckDHT()" << std::endl;
//CheckNetworking();
/* Tick slow services */
#ifndef MINIMAL_LIBRS
if (mRanking)
mRanking->tick();
#endif // MINIMAL_LIBRS
#if 0
std::string opt;
std::string val = "VALUE";
{
std::ostringstream out;
out << "SEC:" << lastSec;
opt = out.str();
}
mGeneralConfig->setSetting(opt, val);
#endif
mConfigMgr->tick(); /* saves stuff */ mConfigMgr->tick(); /* saves stuff */
} }
@ -268,6 +227,10 @@ void RsServer::run()
} }
} }
/* Tick slow services */
if(rsPlugins)
rsPlugins->slowTickPlugins((time_t)ts);
// slow update tick as well. // slow update tick as well.
// update(); // update();
} // end of slow tick. } // end of slow tick.

View File

@ -41,7 +41,6 @@
#include "services/p3disc.h" #include "services/p3disc.h"
#include "services/p3msgservice.h" #include "services/p3msgservice.h"
#include "services/p3chatservice.h" #include "services/p3chatservice.h"
#include "services/p3ranking.h"
#include "services/p3blogs.h" #include "services/p3blogs.h"
#include "services/p3statusservice.h" #include "services/p3statusservice.h"
#include "services/p3channels.h" #include "services/p3channels.h"
@ -165,7 +164,6 @@ class RsServer: public RsControl, public RsThread
p3Channels *mChannels; p3Channels *mChannels;
p3Forums *mForums; p3Forums *mForums;
/* caches (that need ticking) */ /* caches (that need ticking) */
p3Ranking *mRanking;
/* Config */ /* Config */
p3ConfigMgr *mConfigMgr; p3ConfigMgr *mConfigMgr;

View File

@ -38,6 +38,7 @@
#include "util/rsrandom.h" #include "util/rsrandom.h"
#include "util/folderiterator.h" #include "util/folderiterator.h"
#include "retroshare/rsinit.h" #include "retroshare/rsinit.h"
#include "plugins/pluginmanager.h"
#include "rsserver/rsloginhandler.h" #include "rsserver/rsloginhandler.h"
#include <list> #include <list>
@ -1703,7 +1704,6 @@ RsTurtle *rsTurtle = NULL ;
#include "services/p3msgservice.h" #include "services/p3msgservice.h"
#include "services/p3chatservice.h" #include "services/p3chatservice.h"
#include "services/p3gamelauncher.h" #include "services/p3gamelauncher.h"
#include "services/p3ranking.h"
#include "services/p3photoservice.h" #include "services/p3photoservice.h"
#include "services/p3forums.h" #include "services/p3forums.h"
#include "services/p3channels.h" #include "services/p3channels.h"
@ -1725,7 +1725,6 @@ RsTurtle *rsTurtle = NULL ;
/* Implemented Rs Interfaces */ /* Implemented Rs Interfaces */
#include "rsserver/p3face.h" #include "rsserver/p3face.h"
#include "rsserver/p3peers.h" #include "rsserver/p3peers.h"
#include "rsserver/p3rank.h"
#include "rsserver/p3msgs.h" #include "rsserver/p3msgs.h"
#include "rsserver/p3discovery.h" #include "rsserver/p3discovery.h"
#include "rsserver/p3photo.h" #include "rsserver/p3photo.h"
@ -1919,6 +1918,34 @@ int RsServer::StartupRetroShare()
mConfigMgr = new p3ConfigMgr(RsInitConfig::configDir, "rs-v0.5.cfg", "rs-v0.5.sgn"); mConfigMgr = new p3ConfigMgr(RsInitConfig::configDir, "rs-v0.5.cfg", "rs-v0.5.sgn");
mGeneralConfig = new p3GeneralConfig(); mGeneralConfig = new p3GeneralConfig();
/* create Cache Services */
std::string config_dir = RsInitConfig::configDir;
std::string localcachedir = config_dir + "/cache/local";
std::string remotecachedir = config_dir + "/cache/remote";
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 ;
plugins_directories.push_back(".") ; // this list should be saved/set to some correct value.
// possible entries include: /usr/lib/retroshare, ~/.retroshare/extensions/, etc.
RsPluginManager *mPluginsManager = new RsPluginManager ;
rsPlugins = mPluginsManager ;
// These are needed to load plugins: plugin devs might want to know the place of
// cache directories, get pointers to cache strapper, or access ownId()
//
mPluginsManager->setCacheDirectories(localcachedir,remotecachedir) ;
mPluginsManager->setFileServer(ftserver) ;
mPluginsManager->setConnectMgr(mConnMgr) ;
// Now load the plugins. This parses the available SO/DLL files for known symbols.
//
mPluginsManager->loadPlugins(plugins_directories) ;
/* create Services */ /* create Services */
ad = new p3disc(mConnMgr, pqih); ad = new p3disc(mConnMgr, pqih);
#ifndef MINIMAL_LIBRS #ifndef MINIMAL_LIBRS
@ -1943,51 +1970,32 @@ int RsServer::StartupRetroShare()
pqih -> addService(msgSrv); pqih -> addService(msgSrv);
pqih -> addService(chatSrv); pqih -> addService(chatSrv);
pqih ->addService(mStatusSrv); pqih ->addService(mStatusSrv);
#endif // MINIMAL_LIBRS #endif // MINIMAL_LIBRS
/* create Cache Services */
std::string config_dir = RsInitConfig::configDir;
std::string localcachedir = config_dir + "/cache/local";
std::string remotecachedir = config_dir + "/cache/remote";
std::string channelsdir = config_dir + "/channels";
std::string blogsdir = config_dir + "/blogs";
std::string forumdir = config_dir + "/forums";
#ifndef MINIMAL_LIBRS #ifndef MINIMAL_LIBRS
mRanking = new p3Ranking(mConnMgr, RS_SERVICE_TYPE_RANK, /* declaration of cache enable service rank */
mCacheStrapper, mCacheTransfer,
localcachedir, remotecachedir, 3600 * 24 * 30 * 6); // 6 Months
CachePair cp(mRanking, mRanking, CacheId(RS_SERVICE_TYPE_RANK, 0)); mForums = new p3Forums(RS_SERVICE_TYPE_FORUM, mCacheStrapper, mCacheTransfer, localcachedir, remotecachedir, forumdir);
mCacheStrapper -> addCachePair(cp); /* end of declaration */
mForums = new p3Forums(RS_SERVICE_TYPE_FORUM, mCacheStrapper -> addCachePair( CachePair(mForums, mForums, CacheId(RS_SERVICE_TYPE_FORUM, 0)));
mCacheStrapper, mCacheTransfer,
localcachedir, remotecachedir, forumdir);
CachePair cp4(mForums, mForums, CacheId(RS_SERVICE_TYPE_FORUM, 0));
mCacheStrapper -> addCachePair(cp4);
pqih -> addService(mForums); /* This must be also ticked as a service */ pqih -> addService(mForums); /* This must be also ticked as a service */
mChannels = new p3Channels(RS_SERVICE_TYPE_CHANNEL, mChannels = new p3Channels(RS_SERVICE_TYPE_CHANNEL, mCacheStrapper, mCacheTransfer, rsFiles, localcachedir, remotecachedir, channelsdir);
mCacheStrapper, mCacheTransfer, rsFiles,
localcachedir, remotecachedir, channelsdir);
CachePair cp5(mChannels, mChannels, CacheId(RS_SERVICE_TYPE_CHANNEL, 0)); mCacheStrapper -> addCachePair(CachePair(mChannels, mChannels, CacheId(RS_SERVICE_TYPE_CHANNEL, 0)));
mCacheStrapper -> addCachePair(cp5);
pqih -> addService(mChannels); /* This must be also ticked as a service */ pqih -> addService(mChannels); /* This must be also ticked as a service */
#ifdef RS_USE_BLOGS #ifdef RS_USE_BLOGS
p3Blogs *mBlogs = new p3Blogs(RS_SERVICE_TYPE_QBLOG, p3Blogs *mBlogs = new p3Blogs(RS_SERVICE_TYPE_QBLOG, mCacheStrapper, mCacheTransfer, rsFiles, localcachedir, remotecachedir, blogsdir);
mCacheStrapper, mCacheTransfer, rsFiles,
localcachedir, remotecachedir, blogsdir);
CachePair cp6(mBlogs, mBlogs, CacheId(RS_SERVICE_TYPE_QBLOG, 0)); mCacheStrapper -> addCachePair(CachePair(mBlogs, mBlogs, CacheId(RS_SERVICE_TYPE_QBLOG, 0)));
mCacheStrapper -> addCachePair(cp6);
pqih -> addService(mBlogs); /* This must be also ticked as a service */ pqih -> addService(mBlogs); /* This must be also ticked as a service */
#endif #endif
// now add plugin objects inside the loop:
// - client services provided by plugins.
// - cache services provided by plugins.
//
mPluginsManager->registerClientServices(pqih) ;
mPluginsManager->registerCacheServices() ;
#ifndef RS_RELEASE #ifndef RS_RELEASE
p3GameLauncher *gameLauncher = new p3GameLauncher(mConnMgr); p3GameLauncher *gameLauncher = new p3GameLauncher(mConnMgr);
@ -2044,7 +2052,6 @@ int RsServer::StartupRetroShare()
#ifdef RS_USE_BLOGS #ifdef RS_USE_BLOGS
mConfigMgr->addConfiguration("blogs.cfg", mBlogs); mConfigMgr->addConfiguration("blogs.cfg", mBlogs);
#endif #endif
mConfigMgr->addConfiguration("ranklink.cfg", mRanking);
mConfigMgr->addConfiguration("forums.cfg", mForums); mConfigMgr->addConfiguration("forums.cfg", mForums);
mConfigMgr->addConfiguration("channels.cfg", mChannels); mConfigMgr->addConfiguration("channels.cfg", mChannels);
mConfigMgr->addConfiguration("p3Status.cfg", mStatusSrv); mConfigMgr->addConfiguration("p3Status.cfg", mStatusSrv);
@ -2052,6 +2059,8 @@ int RsServer::StartupRetroShare()
mConfigMgr->addConfiguration("turtle.cfg", tr); mConfigMgr->addConfiguration("turtle.cfg", tr);
mConfigMgr->addConfiguration("p3disc.cfg", ad); mConfigMgr->addConfiguration("p3disc.cfg", ad);
mPluginsManager->addConfigurations(mConfigMgr) ;
ftserver->addConfiguration(mConfigMgr); ftserver->addConfiguration(mConfigMgr);
/**************************************************************************/ /**************************************************************************/
@ -2213,7 +2222,6 @@ int RsServer::StartupRetroShare()
rsMsgs = new p3Msgs(msgSrv, chatSrv); rsMsgs = new p3Msgs(msgSrv, chatSrv);
rsForums = mForums; rsForums = mForums;
rsChannels = mChannels; rsChannels = mChannels;
rsRanks = new p3Rank(mRanking);
#ifdef RS_USE_BLOGS #ifdef RS_USE_BLOGS
rsBlogs = mBlogs; rsBlogs = mBlogs;
#endif #endif
@ -2228,7 +2236,6 @@ int RsServer::StartupRetroShare()
#endif #endif
#endif // MINIMAL_LIBRS #endif // MINIMAL_LIBRS
#ifndef MINIMAL_LIBRS #ifndef MINIMAL_LIBRS
/* put a welcome message in! */ /* put a welcome message in! */
if (RsInitConfig::firsttime_run) if (RsInitConfig::firsttime_run)

View File

@ -39,7 +39,6 @@
/* These are Cache Only */ /* These are Cache Only */
const uint16_t RS_SERVICE_TYPE_FILE_INDEX = 0x0001; const uint16_t RS_SERVICE_TYPE_FILE_INDEX = 0x0001;
const uint16_t RS_SERVICE_TYPE_RANK = 0x0002;
/* These are Services only */ /* These are Services only */
const uint16_t RS_SERVICE_TYPE_DISC = 0x0011; const uint16_t RS_SERVICE_TYPE_DISC = 0x0011;

View File

@ -0,0 +1,124 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2008 Robert Fernie
*
* 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 <gui/common/vmessagebox.h>
#include "AddLinksDialog.h"
#include <gui/RetroShareLink.h>
#include "rsrank.h"
/* Images for context menu icons */
#define IMAGE_EXPORTFRIEND ":/images/exportpeers_16x16.png"
#define IMAGE_GREAT ":/images/filerating5.png"
#define IMAGE_GOOD ":/images/filerating4.png"
#define IMAGE_OK ":/images/filerating3.png"
#define IMAGE_SUX ":/images/filerating2.png"
#define IMAGE_BADLINK ":/images/filerating1.png"
/** Constructor */
AddLinksDialog::AddLinksDialog(QString url, QWidget *parent)
: QDialog(parent)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
setAttribute ( Qt::WA_DeleteOnClose, true );
/* add button */
connect(ui.addLinkButton, SIGNAL(clicked()), this, SLOT(addLinkComment()));
connect(ui.closepushButton, SIGNAL(clicked()), this, SLOT(close()));
connect( ui.anonBox, SIGNAL( stateChanged ( int ) ), this, SLOT( load ( void ) ) );
ui.linkLineEdit->setText(url);
RetroShareLink link(url);
if(link.valid() && link.type() == RetroShareLink::TYPE_FILE)
ui.titleLineEdit->setText(link.name());
else
ui.titleLineEdit->setText("New File");
load();
/* Hide platform specific features */
#ifdef Q_WS_WIN
#endif
}
int AddLinksDialog::IndexToScore(int index)
{
if ((index == -1) || (index > 4))
return 0;
int score = 2 - index;
return score;
}
void AddLinksDialog::addLinkComment()
{
/* get the title / link / comment */
QString title = ui.titleLineEdit->text();
QString link = ui.linkLineEdit->text();
QString comment = ui.linkTextEdit->toPlainText();
int32_t score = AddLinksDialog::IndexToScore(ui.scoreBox->currentIndex());
if ((link == "") || (title == ""))
{
QMessageBox::warning(NULL, tr("Add Link Failure"), tr("Missing Link and/or Title"), QMessageBox::Ok);
/* can't do anything */
return;
}
/* add it either way */
if (ui.anonBox->isChecked())
{
rsRanks->anonRankMsg("", link.toStdWString(), title.toStdWString());
}
else
{
rsRanks->newRankMsg(link.toStdWString(),
title.toStdWString(),
comment.toStdWString(), score);
}
close();
}
void AddLinksDialog::load()
{
if (ui.anonBox->isChecked())
{
/* disable comment + score */
ui.scoreBox->setEnabled(false);
ui.linkTextEdit->setEnabled(false);
/* done! */
return;
}
else
{
/* enable comment + score */
ui.scoreBox->setEnabled(true);
ui.linkTextEdit->setEnabled(true);
}
}

View File

@ -0,0 +1,48 @@
/****************************************************************
* RetroShare GUI is distributed under the following license:
*
* Copyright (C) 2008 Robert Fernie
*
* 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.
****************************************************************/
#ifndef _ADDLINKS_DIALOG_H
#define _ADDLINKS_DIALOG_H
#include "ui_AddLinksDialog.h"
class AddLinksDialog : public QDialog
{
Q_OBJECT
public:
/** Default Constructor */
AddLinksDialog(QString url, QWidget *parent = 0);
/** Default Destructor */
static int IndexToScore(int index);
public slots:
void addLinkComment();
void load();
private:
/** Qt Designer generated object */
Ui::AddLinksDialog ui;
};
#endif

View File

@ -0,0 +1,288 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AddLinksDialog</class>
<widget class="QDialog" name="AddLinksDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>614</width>
<height>415</height>
</rect>
</property>
<property name="windowTitle">
<string>Add Link</string>
</property>
<property name="windowIcon">
<iconset resource="images.qrc">
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0" colspan="4">
<widget class="QFrame" name="frame">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>52</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QFrame#frame{background-image: url(:/images/connect/connectFriendBanner.png);}
</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="linksiconlabel">
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="images.qrc">:/images/irkick.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'DejaVu Sans'; font-size:18pt; font-weight:600; color:#ffffff;&quot;&gt;Add Link to Cloud&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0" colspan="4">
<widget class="QFrame" name="frame_2">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="1" column="1">
<widget class="QPushButton" name="closepushButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="addLinkButton">
<property name="text">
<string>Add Link</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>375</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" colspan="3">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Add a new Link</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="spacing">
<number>1</number>
</property>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Title:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>Url:</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLineEdit" name="titleLineEdit"/>
</item>
<item>
<widget class="QLineEdit" name="linkLineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QFrame" name="frame_3">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>40</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QFrame#frame_3{
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 #FEFEFE, stop:1 #E8E8E8);
border: 1px solid #CCCCCC;}</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QCheckBox" name="anonBox">
<property name="text">
<string>Add Anonymous Link</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="scoreBox">
<item>
<property name="text">
<string>+2 Great!</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/filerating5.png</normaloff>:/images/filerating5.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>+1 Good</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/filerating4.png</normaloff>:/images/filerating4.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>0 Okay</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/filerating3.png</normaloff>:/images/filerating3.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>-1 Sux</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/filerating2.png</normaloff>:/images/filerating2.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>-2 Bad Link</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/filerating1.png</normaloff>:/images/filerating1.png</iconset>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>299</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QTextEdit" name="linkTextEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="images.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -0,0 +1,11 @@
!include("../Common/retroshare_plugin.pri"): error("Could not include file ../Common/retroshare_plugin.pri")
CONFIG *= qt uic debug resources
SOURCES = p3ranking.cc LinksDialog.cpp rsrankitems.cc AddLinksDialog.cpp LinksCloudPlugin.cpp
HEADERS = rsrank.h p3ranking.h LinksDialog.h rsrankitems.h AddLinksDialog.h LinksCloudPlugin.h
FORMS = LinksDialog.ui AddLinksDialog.ui
TARGET = LinksCloud
RESOURCES = images.qrc

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,92 @@
/****************************************************************
* RetroShare GUI is distributed under the following license:
*
* Copyright (C) 2008 Robert Fernie
*
* 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.
****************************************************************/
#ifndef _LINKS_DIALOG_H
#define _LINKS_DIALOG_H
#include <gui/mainpage.h>
#include "ui_LinksDialog.h"
class LinksDialog : public MainPage
{
Q_OBJECT
public:
/** Default Constructor */
LinksDialog(QWidget *parent = 0);
/** Default Destructor */
void insertExample();
private slots:
/** Create the context popup menu and it's submenus */
void linkTreeWidgetCostumPopupMenu( QPoint point );
void voteup_anon();
void voteup_score(int score);
void voteup_p2();
void voteup_p1();
void voteup_p0();
void voteup_m1();
void voteup_m2();
void downloadSelected();
void changedSortRank( int index );
void changedSortPeriod( int index );
void changedSortFrom( int index );
void changedSortTop( int index );
void updateLinks();
void addLinkComment( void );
void toggleWindows( void );
void openLink ( QTreeWidgetItem * item, int column );
void changedItem(QTreeWidgetItem *curr, QTreeWidgetItem *prev);
void checkAnon();
void checkUpdate();
void anchorClicked (const QUrl &);
void addNewLink();
private:
void updateComments(std::string rid, std::string pid);
int mStart; /* start of rank list */
std::string mLinkId;
/* Worker Functions */
/* (1) Update Display */
/* (2) Utility Fns */
QTreeWidgetItem *getCurrentLine();
QTreeWidget *exampletreeWidget;
/** Qt Designer generated object */
Ui::LinksDialog ui;
};
#endif

View File

@ -0,0 +1,587 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>LinksDialog</class>
<widget class="QWidget" name="LinksDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>738</width>
<height>583</height>
</rect>
</property>
<property name="windowTitle">
<string/>
</property>
<layout class="QGridLayout">
<property name="horizontalSpacing">
<number>6</number>
</property>
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="1" column="0" colspan="3">
<widget class="QSplitter" name="msgSplitter">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QWidget" name="layoutWidget">
<layout class="QGridLayout">
<item row="0" column="0" colspan="13">
<widget class="QTreeWidget" name="linkTreeWidget">
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<column>
<property name="text">
<string>Title / Comment</string>
</property>
</column>
<column>
<property name="text">
<string>Score</string>
</property>
</column>
<column>
<property name="text">
<string>Peer / Link</string>
</property>
</column>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="expandButton">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/edit_remove24.png</normaloff>:/images/edit_remove24.png</iconset>
</property>
</widget>
</item>
<item row="3" column="1">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>16</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="2">
<widget class="QLabel" name="label">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Sort by</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QComboBox" name="rankComboBox">
<item>
<property name="text">
<string>Combo</string>
</property>
</item>
<item>
<property name="text">
<string>Time</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/kalarm.png</normaloff>:/images/kalarm.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>Ranking</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/records.png</normaloff>:/images/records.png</iconset>
</property>
</item>
</widget>
</item>
<item row="3" column="4">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>16</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="5">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>In last</string>
</property>
</widget>
</item>
<item row="3" column="6">
<widget class="QComboBox" name="periodComboBox">
<item>
<property name="text">
<string>Month</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/view_calendar_month.png</normaloff>:/images/view_calendar_month.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>Week</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/view_calendar_week.png</normaloff>:/images/view_calendar_week.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>Day</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/view_calendar_day.png</normaloff>:/images/view_calendar_day.png</iconset>
</property>
</item>
</widget>
</item>
<item row="3" column="7">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>16</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="8">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>From</string>
</property>
</widget>
</item>
<item row="3" column="9">
<widget class="QComboBox" name="fromComboBox">
<item>
<property name="text">
<string>All Peers</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/user/friends24.png</normaloff>:/images/user/friends24.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>Own Links</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/user/identity16.png</normaloff>:/images/user/identity16.png</iconset>
</property>
</item>
</widget>
</item>
<item row="3" column="10">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>16</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="11">
<widget class="QLabel" name="label_5">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Show</string>
</property>
</widget>
</item>
<item row="3" column="12">
<widget class="QComboBox" name="topComboBox">
<item>
<property name="text">
<string>Top 100</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/records.png</normaloff>:/images/records.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>101-200</string>
</property>
</item>
<item>
<property name="text">
<string>201-300</string>
</property>
</item>
<item>
<property name="text">
<string>301-400</string>
</property>
</item>
<item>
<property name="text">
<string>401-500</string>
</property>
</item>
<item>
<property name="text">
<string>Bottom 100</string>
</property>
</item>
</widget>
</item>
<item row="1" column="1" colspan="12">
<widget class="QTextBrowser" name="linklabel">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>22</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QTextBrowser{border: 2px solid #CCCCCC;
border-radius: 10px;
background: white;}</string>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="openLinks">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_9">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Link:</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget_1">
<layout class="QVBoxLayout">
<item>
<layout class="QHBoxLayout">
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>311</width>
<height>32</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="anonBox">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Add Anonymous Link</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="addButton">
<property name="text">
<string>Add Link/Comment</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Title:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="titleLineEdit">
<property name="styleSheet">
<string notr="true">QLineEdit{border: 2px solid #CCCCCC;
border-radius: 10px;
background: white;}</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>Score:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="scoreBox">
<item>
<property name="text">
<string>+2 Great!</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/filerating5.png</normaloff>:/images/filerating5.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>+1 Good</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/filerating4.png</normaloff>:/images/filerating4.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>0 Okay</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/filerating3.png</normaloff>:/images/filerating3.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>-1 Sux</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/filerating2.png</normaloff>:/images/filerating2.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>-2 Bad Link</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/filerating1.png</normaloff>:/images/filerating1.png</iconset>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>Url:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="linkLineEdit">
<property name="styleSheet">
<string notr="true">QLineEdit{border: 2px solid #CCCCCC;
border-radius: 10px;
background: white;}</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTextEdit" name="linkTextEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QTextEdit{border: 2px solid #CCCCCC;
border-radius: 10px;
background: white;}</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="0" column="0" colspan="3">
<widget class="QFrame" name="frame">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>32</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QFrame#frame{
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 #FEFEFE, stop:1 #E8E8E8);
border: 1px solid #CCCCCC;}</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_1">
<property name="margin">
<number>2</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="linksiconlabel">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="images.qrc">:/images/irkick.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_4">
<property name="text">
<string>&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Links Cloud&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>596</width>
<height>15</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="pushButton">
<property name="styleSheet">
<string notr="true">QPushButton:hover {
border: 1px solid #CCCCCC;
}</string>
</property>
<property name="text">
<string>Add new link</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/edit_add24.png</normaloff>:/images/edit_add24.png</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="images.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/" >
<file>images/irkick.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,165 @@
/*
* libretroshare/src/services: p3ranking.h
*
* 3P/PQI network interface for RetroShare.
*
* Copyright 2007-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#ifndef P3_GENERIC_RANKING_HEADER
#define P3_GENERIC_RANKING_HEADER
class pqistore ;
#include "retroshare/rsplugin.h"
#include "plugins/pluginclasses.h"
#include "rsrank.h"
/*
* A Generic Ranking system.
* Each User provides one cache...
*
* can be overloaded for specific types
* (links, shares, photos etc)
*
* This is not generic yet!!!
*/
class RsRankMsg;
class RsRankLinkMsg;
const uint16_t RS_SERVICE_TYPE_RANK = 0x0002 ;
const uint32_t CONFIG_TYPE_RANK_LINK = 0x0011 ;
class RankGroup
{
public:
std::string rid; /* Random Id */
std::wstring link;
std::wstring title;
float rank;
bool ownTag;
std::map<std::string, RsRankLinkMsg *> comments;
};
class p3Ranking: public RsCacheService, public RsRanks
{
public:
p3Ranking() ;
/******************************* CACHE SOURCE / STORE Interface *********************/
/* overloaded functions from Cache Source */
virtual bool loadLocalCache(const CacheData &data);
/* overloaded functions from Cache Store */
virtual int loadCache(const CacheData &data);
/******************************* CACHE SOURCE / STORE Interface *********************/
public:
/************* Extern Interface *******/
/* changed */
virtual bool updated();
/* Set Sort Methods */
virtual bool setSortPeriod(uint32_t period);
virtual bool setSortMethod(uint32_t type);
virtual bool clearPeerFilter();
virtual bool setPeerFilter(std::list<std::string> peers);
/* get Ids */
virtual uint32_t getRankingsCount();
virtual float getMaxRank();
virtual bool getRankings(uint32_t first, uint32_t count, std::list<std::string> &rids);
virtual bool getRankDetails(std::string rid, RsRankDetails &details);
/* Add New Comment / Msg */
virtual std::string newRankMsg(std::wstring link, std::wstring title, std::wstring comment, int32_t score);
virtual bool updateComment(std::string rid, std::wstring comment, int32_t score);
virtual std::string anonRankMsg(std::string rid, std::wstring link, std::wstring title);
virtual void tick();
void loadRankFile(std::string filename, std::string src);
void addRankMsg(RsRankLinkMsg *msg);
void publishMsgs(bool own);
float locked_calcRank(RankGroup &grp); /* returns 0->100 */
void locked_reSortGroup(RankGroup &grp);
void sortAllMsgs();
pqistore *createStore(std::string file, std::string src, bool reading);
/****************** p3Config STUFF *******************/
protected:
bool addAnonToList(RsRankLinkMsg *msg);
virtual RsSerialiser *setupSerialiser();
virtual bool saveList(bool &cleanup, std::list<RsItem *>&);
virtual bool loadList(std::list<RsItem *>& load);
virtual void saveDone();
private:
void createDummyData();
uint32_t storePeriod;
p3ConnectMgr *mConnMgr;
RsMutex mRankMtx;
/***** below here is locked *****/
bool mRepublish;
bool mRepublishFriends;
time_t mRepublishFriendTS;
uint32_t mStorePeriod;
std::string mOwnId;
bool mUpdated;
bool mRepost;
std::map<std::string, RankGroup> mData;
std::multimap<float, std::string> mRankings;
/* Filter/Sort params */
std::list<std::string> mPeerFilter;
uint32_t mViewPeriod;
uint32_t mSortType;
/* Anonymous Link List */
std::list<RsRankLinkMsg *> mAnon;
};
#endif

View File

@ -0,0 +1,96 @@
#ifndef RETROSHARE_RANKING_GUI_INTERFACE_H
#define RETROSHARE_RANKING_GUI_INTERFACE_H
/*
* libretroshare/src/rsiface: rsrank.h
*
* RetroShare C++ Interface.
*
* Copyright 2007-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include <inttypes.h>
#include <string>
#include <list>
/* The Main Interface Class - for information about your Peers */
class RsRanks;
extern RsRanks *rsRanks;
class RsRankComment
{
public:
std::string id;
std::wstring comment;
int32_t score;
time_t timestamp;
};
class RsRankDetails
{
public:
std::string rid;
std::wstring link;
std::wstring title;
float rank;
bool ownTag;
std::list<RsRankComment> comments;
};
const uint32_t RS_RANK_SCORE = 0x0001;
const uint32_t RS_RANK_TIME = 0x0002;
const uint32_t RS_RANK_ALG = 0x0003;
std::ostream &operator<<(std::ostream &out, const RsRankDetails &detail);
class RsRanks
{
public:
RsRanks() { return; }
virtual ~RsRanks() { return; }
/* needs update? */
virtual bool updated() = 0;
/* Set Sort Methods */
virtual bool setSortPeriod(uint32_t period) = 0;
virtual bool setSortMethod(uint32_t type) = 0;
virtual bool clearPeerFilter() = 0;
virtual bool setPeerFilter(std::list<std::string> peers) = 0;
/* get Ids */
virtual uint32_t getRankingsCount() = 0;
virtual float getMaxRank() = 0;
virtual bool getRankings(uint32_t first, uint32_t count, std::list<std::string> &rids) = 0;
virtual bool getRankDetails(std::string rid, RsRankDetails &details) = 0;
/* Add New Comment / Msg */
virtual std::string newRankMsg(std::wstring link, std::wstring title, std::wstring comment, int32_t score) = 0;
virtual bool updateComment(std::string rid, std::wstring comment, int32_t score) = 0;
virtual std::string anonRankMsg(std::string rid, std::wstring link, std::wstring title) = 0;
};
#endif

View File

@ -0,0 +1,253 @@
/*
* libretroshare/src/serialiser: rsbaseitems.cc
*
* RetroShare Serialiser.
*
* Copyright 2007-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include "serialiser/rsbaseserial.h"
#include "serialiser/rstlvbase.h"
#include "rsrankitems.h"
#define RSSERIAL_DEBUG 1
#include <iostream>
/*************************************************************************/
void RsRankMsg::clear()
{
rid.clear();
timestamp = 0;
title.clear();
comment.clear();
}
std::ostream &RsRankMsg::print(std::ostream &out, uint16_t indent)
{
printRsItemBase(out, "RsRankMsg", indent);
uint16_t int_Indent = indent + 2;
printIndent(out, int_Indent);
out << "rid: " << rid << std::endl;
printIndent(out, int_Indent);
out << "timestamp: " << timestamp << std::endl;
printIndent(out, int_Indent);
std::string cnv_title(title.begin(), title.end());
out << "msg: " << cnv_title << std::endl;
printIndent(out, int_Indent);
std::string cnv_comment(comment.begin(), comment.end());
out << "comment: " << cnv_comment << std::endl;
printIndent(out, int_Indent);
out << "score: " << score << std::endl;
printRsItemEnd(out, "RsRankMsg", indent);
return out;
}
/*************************************************************************/
void RsRankLinkMsg::clear()
{
rid.clear();
pid.clear();
timestamp = 0;
title.clear();
comment.clear();
score = 0;
linktype = 0;
link.clear();
}
std::ostream &RsRankLinkMsg::print(std::ostream &out, uint16_t indent)
{
printRsItemBase(out, "RsRankLinkMsg", indent);
uint16_t int_Indent = indent + 2;
printIndent(out, int_Indent);
out << "rid: " << rid << std::endl;
printIndent(out, int_Indent);
out << "pid: " << pid << std::endl;
printIndent(out, int_Indent);
out << "timestamp: " << timestamp << std::endl;
printIndent(out, int_Indent);
std::string cnv_title(title.begin(), title.end());
out << "msg: " << cnv_title << std::endl;
printIndent(out, int_Indent);
std::string cnv_comment(comment.begin(), comment.end());
out << "comment: " << cnv_comment << std::endl;
printIndent(out, int_Indent);
out << "score: " << score << std::endl;
printIndent(out, int_Indent);
out << "linktype: " << linktype << std::endl;
printIndent(out, int_Indent);
std::string cnv_link(link.begin(), link.end());
out << "link: " << cnv_link << std::endl;
printRsItemEnd(out, "RsRankLinkMsg", indent);
return out;
}
uint32_t RsRankSerialiser::sizeLink(RsRankLinkMsg *item)
{
uint32_t s = 8; /* header */
s += GetTlvStringSize(item->rid);
s += GetTlvStringSize(item->pid);
s += 4; /* timestamp */
s += GetTlvWideStringSize(item->title);
s += GetTlvWideStringSize(item->comment);
s += 4; /* score */
s += 4; /* linktype */
s += GetTlvWideStringSize(item->link);
return s;
}
/* serialise the data to the buffer */
bool RsRankSerialiser::serialiseLink(RsRankLinkMsg *item, void *data, uint32_t *pktsize)
{
uint32_t tlvsize = sizeLink(item);
uint32_t offset = 0;
if (*pktsize < tlvsize)
return false; /* not enough space */
*pktsize = tlvsize;
bool ok = true;
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
/* skip the header */
offset += 8;
/* add mandatory parts first */
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_GENID, item->rid);
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_PEERID, item->pid);
ok &= setRawUInt32(data, tlvsize, &offset, item->timestamp);
ok &= SetTlvWideString(data, tlvsize, &offset, TLV_TYPE_WSTR_TITLE, item->title);
ok &= SetTlvWideString(data, tlvsize, &offset, TLV_TYPE_WSTR_COMMENT, item->comment);
ok &= setRawUInt32(data, tlvsize, &offset, *((uint32_t *) &(item->score)));
ok &= setRawUInt32(data, tlvsize, &offset, item->linktype);
ok &= SetTlvWideString(data, tlvsize, &offset, TLV_TYPE_WSTR_LINK, item->link);
if (offset != tlvsize)
{
ok = false;
std::cerr << "RsRankLinkSerialiser::serialiseLink() Size Error! " << std::endl;
}
return ok;
}
RsRankLinkMsg *RsRankSerialiser::deserialiseLink(void *data, uint32_t *pktsize)
{
/* get the type and size */
uint32_t rstype = getRsItemId(data);
uint32_t rssize = getRsItemSize(data);
uint32_t offset = 0;
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
(RS_SERVICE_TYPE_RANK != getRsItemService(rstype)) ||
(RS_PKT_SUBTYPE_RANK_LINK3 != getRsItemSubType(rstype)))
{
return NULL; /* wrong type */
}
if (*pktsize < rssize) /* check size */
return NULL; /* not enough data */
/* set the packet length */
*pktsize = rssize;
bool ok = true;
/* ready to load */
RsRankLinkMsg *item = new RsRankLinkMsg();
item->clear();
/* skip the header */
offset += 8;
/* get mandatory parts first */
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_GENID, item->rid);
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_PEERID, item->pid);
ok &= getRawUInt32(data, rssize, &offset, &(item->timestamp));
ok &= GetTlvWideString(data, rssize, &offset, TLV_TYPE_WSTR_TITLE, item->title);
ok &= GetTlvWideString(data, rssize, &offset, TLV_TYPE_WSTR_COMMENT, item->comment);
ok &= getRawUInt32(data, rssize, &offset, (uint32_t *) &(item->score));
ok &= getRawUInt32(data, rssize, &offset, &(item->linktype));
ok &= GetTlvWideString(data, rssize, &offset, TLV_TYPE_WSTR_LINK, item->link);
if (offset != rssize)
{
/* error */
delete item;
return NULL;
}
if (!ok)
{
delete item;
return NULL;
}
return item;
}
uint32_t RsRankSerialiser::size(RsItem *item)
{
return sizeLink((RsRankLinkMsg *) item);
}
bool RsRankSerialiser::serialise(RsItem *item, void *data, uint32_t *pktsize)
{
return serialiseLink((RsRankLinkMsg *) item, data, pktsize);
}
RsItem *RsRankSerialiser::deserialise(void *data, uint32_t *pktsize)
{
return deserialiseLink(data, pktsize);
}
/*************************************************************************/

View File

@ -0,0 +1,110 @@
#ifndef RS_RANK_ITEMS_H
#define RS_RANK_ITEMS_H
/*
* libretroshare/src/serialiser: rsrankitems.h
*
* RetroShare Serialiser.
*
* Copyright 2007-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include "serialiser/rsserial.h"
#include "serialiser/rstlvtypes.h"
#include "p3ranking.h"
const uint8_t RS_PKT_SUBTYPE_RANK_LINK3 = 0x04;
const uint8_t RS_PKT_SUBTYPE_RANK_PHOTO = 0x05;
/**************************************************************************/
class RsRankMsg: public RsItem
{
public:
RsRankMsg(uint8_t subtype) :RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_RANK, subtype) { return; }
virtual ~RsRankMsg() { return; }
virtual void clear();
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
std::string rid; /* Random Id */
std::string pid; /* Peer Id (cannot use RsItem::PeerId - as FoF transport!) */
uint32_t timestamp;
std::wstring title;
std::wstring comment;
int32_t score;
};
/* Flags */
const uint32_t RS_LINK_TYPE_WEB = 0x0001;
const uint32_t RS_LINK_TYPE_OFF = 0x0002;
class RsRankLinkMsg: public RsRankMsg
{
public:
RsRankLinkMsg()
:RsRankMsg(RS_PKT_SUBTYPE_RANK_LINK3) { return; }
virtual ~RsRankLinkMsg() { return; }
virtual void clear();
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
/**** SAME as RsRankMsg ****
std::string rid;
uint32_t timestamp;
std::wstring title;
std::wstring comment;
int32_t score;
***************************/
/* Link specific Fields */
uint32_t linktype; /* to be used later! */
std::wstring link;
};
class RsRankSerialiser: public RsSerialType
{
public:
RsRankSerialiser()
:RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_RANK)
{ return; }
virtual ~RsRankSerialiser()
{ return; }
virtual uint32_t size(RsItem *);
virtual bool serialise (RsItem *item, void *data, uint32_t *size);
virtual RsItem * deserialise(void *data, uint32_t *size);
private:
/* For RS_PKT_SUBTYPE_RANK_LINK */
virtual uint32_t sizeLink(RsRankLinkMsg *);
virtual bool serialiseLink (RsRankLinkMsg *item, void *data, uint32_t *size);
virtual RsRankLinkMsg *deserialiseLink(void *data, uint32_t *size);
};
/**************************************************************************/
#endif /* RS_RANK_ITEMS_H */

View File

@ -1,5 +1,4 @@
CONFIG += qt gui uic qrc resources uitools idle bitdht # framecatcher# blogs CONFIG += qt gui uic qrc resources uitools idle bitdht # framecatcher# blogs
#CONFIG += use_links
QT += network xml script QT += network xml script
TEMPLATE = app TEMPLATE = app
@ -39,6 +38,7 @@ linux-* {
LIBS += ../../libretroshare/src/lib/libretroshare.a LIBS += ../../libretroshare/src/lib/libretroshare.a
LIBS += -lssl -lgpgme -lupnp -lXss -lgnome-keyring LIBS += -lssl -lgpgme -lupnp -lXss -lgnome-keyring
LIBS *= -rdynamic
DEFINES *= HAVE_XSS # for idle time, libx screensaver extensions DEFINES *= HAVE_XSS # for idle time, libx screensaver extensions
DEFINES *= UBUNTU DEFINES *= UBUNTU
} }
@ -660,18 +660,18 @@ SOURCES += gui/unfinished/blogs/BlogsDialog.cpp \
DEFINES += BLOGS DEFINES += BLOGS
} }
use_links { # use_links {
HEADERS += gui/AddLinksDialog.h \ # HEADERS += gui/AddLinksDialog.h \
gui/LinksDialog.h # gui/LinksDialog.h
#
FORMS += gui/AddLinksDialog.ui \ # FORMS += gui/AddLinksDialog.ui \
gui/LinksDialog.ui # gui/LinksDialog.ui
#
SOURCES += gui/AddLinksDialog.cpp \ # SOURCES += gui/AddLinksDialog.cpp \
gui/LinksDialog.cpp # gui/LinksDialog.cpp
#
DEFINES += RS_USE_LINKS # DEFINES += RS_USE_LINKS
} # }
unfinished { unfinished {

View File

@ -32,6 +32,7 @@
#include "gui/unfinished/blogs/BlogsDialog.h" #include "gui/unfinished/blogs/BlogsDialog.h"
#endif #endif
#include <retroshare/rsplugin.h>
#include "rshare.h" #include "rshare.h"
#include "MainWindow.h" #include "MainWindow.h"
#include "MessengerWindow.h" #include "MessengerWindow.h"
@ -43,9 +44,6 @@
#include "PluginsPage.h" #include "PluginsPage.h"
#include "ShareManager.h" #include "ShareManager.h"
#include "NetworkView.h" #include "NetworkView.h"
#ifdef RS_USE_LINKS
#include "LinksDialog.h"
#endif
#include "ForumsDialog.h" #include "ForumsDialog.h"
#include "FriendsDialog.h" #include "FriendsDialog.h"
#include "HelpDialog.h" #include "HelpDialog.h"
@ -96,7 +94,6 @@
#define IMAGE_PEERS ":/images/groupchat.png" #define IMAGE_PEERS ":/images/groupchat.png"
#define IMAGE_SEARCH ":/images/filefind.png" #define IMAGE_SEARCH ":/images/filefind.png"
#define IMAGE_TRANSFERS ":/images/ktorrent32.png" #define IMAGE_TRANSFERS ":/images/ktorrent32.png"
#define IMAGE_LINKS ":/images/irkick.png"
#define IMAGE_FILES ":/images/fileshare32.png" #define IMAGE_FILES ":/images/fileshare32.png"
#define IMAGE_CHANNELS ":/images/channels.png" #define IMAGE_CHANNELS ":/images/channels.png"
#define IMAGE_FORUMS ":/images/konversation.png" #define IMAGE_FORUMS ":/images/konversation.png"
@ -244,17 +241,22 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags flags)
channelAction = createPageAction(QIcon(IMAGE_CHANNELS), tr("Channels"), grp)); channelAction = createPageAction(QIcon(IMAGE_CHANNELS), tr("Channels"), grp));
#ifdef BLOGS #ifdef BLOGS
ui.stackPages->add(blogsFeed = new BlogsDialog(ui.stackPages), ui.stackPages->add(blogsFeed = new BlogsDialog(ui.stackPages), createPageAction(QIcon(IMAGE_BLOGS), tr("Blogs"), grp));
createPageAction(QIcon(IMAGE_BLOGS), tr("Blogs"), grp));
#endif #endif
ui.stackPages->add(forumsDialog = new ForumsDialog(ui.stackPages), ui.stackPages->add(forumsDialog = new ForumsDialog(ui.stackPages),
forumAction = createPageAction(QIcon(IMAGE_FORUMS), tr("Forums"), grp)); forumAction = createPageAction(QIcon(IMAGE_FORUMS), tr("Forums"), grp));
#ifdef RS_USE_LINKS std::cerr << "Looking for interfaces in existing plugins:" << std::endl;
ui.stackPages->add(linksDialog = new LinksDialog(ui.stackPages), for(uint32_t i = 0;i<rsPlugins->nbPlugins();++i)
createPageAction(QIcon(IMAGE_LINKS), tr("Links Cloud"), grp)); {
#endif if(rsPlugins->plugin(i)->qt_page() != NULL && rsPlugins->plugin(i)->qt_icon() != NULL)
{
std::cerr << " Addign widget page for plugin " << rsPlugins->plugin(i)->getPluginName() << std::endl;
ui.stackPages->add(rsPlugins->plugin(i)->qt_page(), createPageAction(*rsPlugins->plugin(i)->qt_icon(), QString::fromStdString(rsPlugins->plugin(i)->getPluginName()), grp));
}
//ui.stackPages->add(linksDialog = new LinksDialog(ui.stackPages), createPageAction(QIcon(IMAGE_LINKS), tr("Links Cloud"), grp));
}
#ifndef RS_RELEASE_VERSION #ifndef RS_RELEASE_VERSION
#ifdef PLUGINMGR #ifdef PLUGINMGR
@ -913,11 +915,6 @@ void MainWindow::addAction(QAction *action, const char *slot)
case Messages: case Messages:
Page = _instance->messagesDialog; Page = _instance->messagesDialog;
break; break;
#ifdef RS_USE_LINKS
case Links:
Page = _instance->linksDialog;
break;
#endif
case Channels: case Channels:
Page = _instance->channelFeed; Page = _instance->channelFeed;
break; break;

View File

@ -9,7 +9,6 @@
<file>images/pgp.png</file> <file>images/pgp.png</file>
<file>images/rs_wizard.png</file> <file>images/rs_wizard.png</file>
<file>images/about.png</file> <file>images/about.png</file>
<file>images/irkick.png</file>
<file>images/backblue.png</file> <file>images/backblue.png</file>
<file>images/backchat.png</file> <file>images/backchat.png</file>
<file>images/buttonframe.png</file> <file>images/buttonframe.png</file>