mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-17 13:24:15 -05:00
fix for windows plugin system
uses call back to expose the retroshare interface to plugins git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4633 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
2173ee0d2e
commit
c1af9b13ad
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <dbase/cachestrapper.h>
|
#include <dbase/cachestrapper.h>
|
||||||
|
#include "plugins/pluginmanager.h"
|
||||||
|
|
||||||
// The following class abstracts the construction of a cache service. The user only has to
|
// 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.
|
// supply RS with a type ID. If the ID is already in use, RS will complain.
|
||||||
@ -8,7 +9,7 @@
|
|||||||
class RsCacheService: public CacheSource, public CacheStore, public p3Config
|
class RsCacheService: public CacheSource, public CacheStore, public p3Config
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RsCacheService(uint16_t type,uint32_t config_type,uint32_t tick_delay_in_seconds) ;
|
RsCacheService(uint16_t type,uint32_t config_type,uint32_t tick_delay_in_seconds, RsPluginHandler* pgHandler) ;
|
||||||
|
|
||||||
uint32_t tickDelay() const { return _tick_delay_in_seconds ; }
|
uint32_t tickDelay() const { return _tick_delay_in_seconds ; }
|
||||||
virtual void tick() {}
|
virtual void tick() {}
|
||||||
|
@ -43,6 +43,19 @@ void RsPluginManager::loadConfiguration()
|
|||||||
p3Config::loadConfiguration(dummyHash);
|
p3Config::loadConfiguration(dummyHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RsPluginManager::setInterfaces(RsPlugInInterfaces &interfaces)
|
||||||
|
{
|
||||||
|
std::cerr << "RsPluginManager::setInterfaces() " << std::endl;
|
||||||
|
|
||||||
|
for(uint32_t i=0;i<_plugins.size();++i)
|
||||||
|
|
||||||
|
if(_plugins[i].plugin != NULL && _plugins[i].plugin->rs_cache_service() != NULL)
|
||||||
|
{
|
||||||
|
_plugins[i].plugin->setInterfaces(interfaces);
|
||||||
|
std::cerr << " setting iterface for plugin " << _plugins[i].plugin->getPluginName() << ", with RS_ID " << _plugins[i].plugin->rs_service_id() << std::endl ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void RsPluginManager::setCacheDirectories(const std::string& local_cache, const std::string& remote_cache)
|
void RsPluginManager::setCacheDirectories(const std::string& local_cache, const std::string& remote_cache)
|
||||||
{
|
{
|
||||||
_local_cache_dir = local_cache ;
|
_local_cache_dir = local_cache ;
|
||||||
@ -134,7 +147,7 @@ void RsPluginManager::getPluginStatus(int i,uint32_t& status,std::string& file_n
|
|||||||
RsSerialiser *RsPluginManager::setupSerialiser()
|
RsSerialiser *RsPluginManager::setupSerialiser()
|
||||||
{
|
{
|
||||||
RsSerialiser *rss = new RsSerialiser ;
|
RsSerialiser *rss = new RsSerialiser ;
|
||||||
rss->addSerialType(new RsPluginSerialiser()) ;
|
rss->addSerialType(new RsPluginSerialiser()) ;
|
||||||
|
|
||||||
return rss ;
|
return rss ;
|
||||||
}
|
}
|
||||||
@ -209,6 +222,7 @@ bool RsPluginManager::loadPlugin(const std::string& plugin_name)
|
|||||||
|
|
||||||
pinfo.status = PLUGIN_STATUS_LOADED ;
|
pinfo.status = PLUGIN_STATUS_LOADED ;
|
||||||
pinfo.plugin = p ;
|
pinfo.plugin = p ;
|
||||||
|
p->setPlugInHandler(this); // WIN fix, cannot share global space with shared libraries
|
||||||
pinfo.info_string = "" ;
|
pinfo.info_string = "" ;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -220,6 +234,8 @@ p3LinkMgr *RsPluginManager::getLinkMgr() const
|
|||||||
assert(_linkmgr != NULL) ;
|
assert(_linkmgr != NULL) ;
|
||||||
return _linkmgr ;
|
return _linkmgr ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ftServer *RsPluginManager::getFileServer() const
|
ftServer *RsPluginManager::getFileServer() const
|
||||||
{
|
{
|
||||||
assert(_ftserver != NULL) ;
|
assert(_ftserver != NULL) ;
|
||||||
@ -318,9 +334,9 @@ bool RsPluginManager::saveList(bool& cleanup, std::list<RsItem*>& list)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
RsCacheService::RsCacheService(uint16_t service_type,uint32_t config_type,uint32_t tick_delay)
|
RsCacheService::RsCacheService(uint16_t service_type,uint32_t config_type,uint32_t tick_delay, RsPluginHandler* pgHandler)
|
||||||
: CacheSource(service_type, true, rsPlugins->getFileServer()->getCacheStrapper(), rsPlugins->getLocalCacheDir()),
|
: CacheSource(service_type, true, pgHandler->getFileServer()->getCacheStrapper(), pgHandler->getLocalCacheDir()),
|
||||||
CacheStore (service_type, true, rsPlugins->getFileServer()->getCacheStrapper(), rsPlugins->getFileServer()->getCacheTransfer(), rsPlugins->getRemoteCacheDir()),
|
CacheStore (service_type, true, pgHandler->getFileServer()->getCacheStrapper(), pgHandler->getFileServer()->getCacheTransfer(), pgHandler->getRemoteCacheDir()),
|
||||||
p3Config(config_type), // CONFIG_TYPE_RANK_LINK
|
p3Config(config_type), // CONFIG_TYPE_RANK_LINK
|
||||||
_tick_delay_in_seconds(tick_delay)
|
_tick_delay_in_seconds(tick_delay)
|
||||||
{
|
{
|
||||||
|
@ -51,12 +51,18 @@ class RsPluginManager: public RsPluginHandler, public p3Config
|
|||||||
virtual void addConfigurations(p3ConfigMgr *cfgMgr) ;
|
virtual void addConfigurations(p3ConfigMgr *cfgMgr) ;
|
||||||
virtual void loadConfiguration() ;
|
virtual void loadConfiguration() ;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* sets interfaces for all loaded plugins
|
||||||
|
* @param interfaces
|
||||||
|
*/
|
||||||
|
void setInterfaces(RsPlugInInterfaces& interfaces);
|
||||||
static void setPluginEntrySymbol(const std::string& s) { _plugin_entry_symbol = s ; }
|
static void setPluginEntrySymbol(const std::string& s) { _plugin_entry_symbol = s ; }
|
||||||
static bool acceptablePluginName(const std::string& s) ;
|
static bool acceptablePluginName(const std::string& s) ;
|
||||||
static void setCacheDirectories(const std::string& local,const std::string& remote) ;
|
static void setCacheDirectories(const std::string& local,const std::string& remote) ;
|
||||||
static void setFileServer(ftServer *ft) { _ftserver = ft ; }
|
static void setFileServer(ftServer *ft) { _ftserver = ft ; }
|
||||||
static void setLinkMgr(p3LinkMgr *cm) { _linkmgr = cm ; }
|
static void setLinkMgr(p3LinkMgr *cm) { _linkmgr = cm ; }
|
||||||
|
|
||||||
|
|
||||||
void loadPlugins(const std::vector<std::string>& plugin_directories) ;
|
void loadPlugins(const std::vector<std::string>& plugin_directories) ;
|
||||||
|
|
||||||
void registerCacheServices() ;
|
void registerCacheServices() ;
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include "retroshare/rspeers.h"
|
||||||
|
#include "retroshare/rsfiles.h"
|
||||||
|
|
||||||
class RsPluginHandler ;
|
class RsPluginHandler ;
|
||||||
extern RsPluginHandler *rsPlugins ;
|
extern RsPluginHandler *rsPlugins ;
|
||||||
@ -52,6 +54,23 @@ class pqiService ;
|
|||||||
#define PLUGIN_STATUS_NULL_PLUGIN 0x0004
|
#define PLUGIN_STATUS_NULL_PLUGIN 0x0004
|
||||||
#define PLUGIN_STATUS_LOADED 0x0005
|
#define PLUGIN_STATUS_LOADED 0x0005
|
||||||
|
|
||||||
|
class RsPluginHandler;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
*
|
||||||
|
* convenience class to store gui interfaces
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class RsPlugInInterfaces {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
RsPlugInInterfaces() { mPeers = NULL; mFiles = NULL; }
|
||||||
|
RsPeers* mPeers;
|
||||||
|
RsFiles* mFiles;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
class RsPlugin
|
class RsPlugin
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -67,6 +86,8 @@ class RsPlugin
|
|||||||
virtual std::string getShortPluginDescription() const = 0 ;
|
virtual std::string getShortPluginDescription() const = 0 ;
|
||||||
virtual std::string getPluginName() const = 0 ;
|
virtual std::string getPluginName() const = 0 ;
|
||||||
virtual void getPluginVersion(int& major,int& minor,int& svn_rev) const = 0 ;
|
virtual void getPluginVersion(int& major,int& minor,int& svn_rev) const = 0 ;
|
||||||
|
virtual void setPlugInHandler(RsPluginHandler* pgHandler) = 0;
|
||||||
|
virtual void setInterfaces(RsPlugInInterfaces& interfaces) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RsPluginHandler
|
class RsPluginHandler
|
||||||
|
@ -128,9 +128,9 @@ void RsServer::run()
|
|||||||
while(isRunning())
|
while(isRunning())
|
||||||
{
|
{
|
||||||
#ifndef WINDOWS_SYS
|
#ifndef WINDOWS_SYS
|
||||||
usleep((int) (timeDelta * 1000000));
|
usleep((int) (timeDelta * 1000000));
|
||||||
#else
|
#else
|
||||||
Sleep((int) (timeDelta * 1000));
|
Sleep((int) (timeDelta * 1000));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ts = getCurrentTS();
|
ts = getCurrentTS();
|
||||||
|
@ -1850,16 +1850,18 @@ int RsServer::StartupRetroShare()
|
|||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
std::cerr << "setup classes / structures" << std::endl;
|
std::cerr << "setup classes / structures" << std::endl;
|
||||||
|
|
||||||
/* Setup Notify Early - So we can use it. */
|
|
||||||
rsNotify = new p3Notify();
|
|
||||||
|
|
||||||
/* History Manager */
|
/* History Manager */
|
||||||
mHistoryMgr = new p3HistoryMgr();
|
mHistoryMgr = new p3HistoryMgr();
|
||||||
|
|
||||||
mPeerMgr = new p3PeerMgrIMPL();
|
mPeerMgr = new p3PeerMgrIMPL();
|
||||||
mNetMgr = new p3NetMgrIMPL();
|
mNetMgr = new p3NetMgrIMPL();
|
||||||
mLinkMgr = new p3LinkMgrIMPL(mPeerMgr, mNetMgr);
|
mLinkMgr = new p3LinkMgrIMPL(mPeerMgr, mNetMgr);
|
||||||
|
|
||||||
|
/* Setup Notify Early - So we can use it. */
|
||||||
|
rsNotify = new p3Notify();
|
||||||
|
rsPeers = new p3Peers(mLinkMgr, mPeerMgr, mNetMgr);
|
||||||
|
|
||||||
mPeerMgr->setManagers(mLinkMgr, mNetMgr, mHistoryMgr);
|
mPeerMgr->setManagers(mLinkMgr, mNetMgr, mHistoryMgr);
|
||||||
mNetMgr->setManagers(mPeerMgr, mLinkMgr);
|
mNetMgr->setManagers(mPeerMgr, mLinkMgr);
|
||||||
|
|
||||||
@ -2044,12 +2046,18 @@ int RsServer::StartupRetroShare()
|
|||||||
//
|
//
|
||||||
mPluginsManager->setCacheDirectories(localcachedir,remotecachedir) ;
|
mPluginsManager->setCacheDirectories(localcachedir,remotecachedir) ;
|
||||||
mPluginsManager->setFileServer(ftserver) ;
|
mPluginsManager->setFileServer(ftserver) ;
|
||||||
mPluginsManager->setLinkMgr(mLinkMgr) ;
|
mPluginsManager->setLinkMgr(mLinkMgr) ;
|
||||||
|
|
||||||
// Now load the plugins. This parses the available SO/DLL files for known symbols.
|
// Now load the plugins. This parses the available SO/DLL files for known symbols.
|
||||||
//
|
//
|
||||||
mPluginsManager->loadPlugins(plugins_directories) ;
|
mPluginsManager->loadPlugins(plugins_directories) ;
|
||||||
|
|
||||||
|
// set interfaces for plugins
|
||||||
|
RsPlugInInterfaces interfaces;
|
||||||
|
interfaces.mFiles = rsFiles;
|
||||||
|
interfaces.mPeers = rsPeers;
|
||||||
|
mPluginsManager->setInterfaces(interfaces);
|
||||||
|
|
||||||
/* create Services */
|
/* create Services */
|
||||||
ad = new p3disc(mPeerMgr, mLinkMgr, pqih);
|
ad = new p3disc(mPeerMgr, mLinkMgr, pqih);
|
||||||
#ifndef MINIMAL_LIBRS
|
#ifndef MINIMAL_LIBRS
|
||||||
@ -2330,7 +2338,7 @@ int RsServer::StartupRetroShare()
|
|||||||
|
|
||||||
/* Setup GUI Interfaces. */
|
/* Setup GUI Interfaces. */
|
||||||
|
|
||||||
rsPeers = new p3Peers(mLinkMgr, mPeerMgr, mNetMgr);
|
|
||||||
rsDisc = new p3Discovery(ad);
|
rsDisc = new p3Discovery(ad);
|
||||||
rsConfig = new p3ServerConfig(mPeerMgr, mLinkMgr, mNetMgr, mGeneralConfig);
|
rsConfig = new p3ServerConfig(mPeerMgr, mLinkMgr, mNetMgr, mGeneralConfig);
|
||||||
|
|
||||||
|
@ -9,3 +9,55 @@ linux-g++-64 {
|
|||||||
LIBS *= -ldl
|
LIBS *= -ldl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
win32 {
|
||||||
|
QMAKE_CC = g++
|
||||||
|
OBJECTS_DIR = temp/obj
|
||||||
|
MOC_DIR = temp/moc
|
||||||
|
DEFINES *= WINDOWS_SYS WIN32 STATICLIB MINGW
|
||||||
|
DEFINES *= MINIUPNPC_VERSION=13
|
||||||
|
DESTDIR = lib
|
||||||
|
|
||||||
|
# Switch off optimization for release version
|
||||||
|
QMAKE_CXXFLAGS_RELEASE -= -O2
|
||||||
|
QMAKE_CXXFLAGS_RELEASE += -O0
|
||||||
|
QMAKE_CFLAGS_RELEASE -= -O2
|
||||||
|
QMAKE_CFLAGS_RELEASE += -O0
|
||||||
|
|
||||||
|
# Switch on optimization for debug version
|
||||||
|
#QMAKE_CXXFLAGS_DEBUG += -O2
|
||||||
|
#QMAKE_CFLAGS_DEBUG += -O2
|
||||||
|
|
||||||
|
DEFINES += USE_CMD_ARGS
|
||||||
|
|
||||||
|
#miniupnp implementation files
|
||||||
|
HEADERS += upnp/upnputil.h
|
||||||
|
SOURCES += upnp/upnputil.c
|
||||||
|
|
||||||
|
|
||||||
|
UPNPC_DIR = ../../../lib/miniupnpc-1.3
|
||||||
|
GPG_ERROR_DIR = ../../../lib/libgpg-error-1.7
|
||||||
|
GPGME_DIR = ../../../lib/gpgme-1.1.8
|
||||||
|
|
||||||
|
PTHREADS_DIR = ../../../lib/pthreads-w32-2-8-0-release
|
||||||
|
ZLIB_DIR = ../../../lib/zlib-1.2.3
|
||||||
|
SSL_DIR = ../../../OpenSSL
|
||||||
|
|
||||||
|
|
||||||
|
INCLUDEPATH += . $${SSL_DIR}/include $${UPNPC_DIR} $${PTHREADS_DIR} $${ZLIB_DIR} $${GPGME_DIR}/src $${GPG_ERROR_DIR}/src
|
||||||
|
|
||||||
|
PRE_TARGETDEPS += ../../libretroshare/libretroshare-build-desktop/lib/libretroshare.a
|
||||||
|
LIBS += ../../libretroshare/libretroshare-build-desktop/lib/libretroshare.a
|
||||||
|
|
||||||
|
LIBS += ../../libbitdht/libbitdht-build-desktop/lib/libbitdht.a
|
||||||
|
PRE_TARGETDEPS *= ../../libbitdht/libbitdht-build-desktop/lib/libbitdht.a
|
||||||
|
|
||||||
|
LIBS += -L"../../../lib"
|
||||||
|
LIBS += -lssl -lcrypto -lgpgme -lpthreadGC2d -lminiupnpc -lz
|
||||||
|
# added after bitdht
|
||||||
|
LIBS += -lws2_32
|
||||||
|
LIBS += -luuid -lole32 -liphlpapi -lcrypt32-cygwin -lgdi32
|
||||||
|
LIBS += -lole32 -lwinmm
|
||||||
|
|
||||||
|
GPG_ERROR_DIR = ../../../lib/libgpg-error-1.7
|
||||||
|
GPGME_DIR = ../../../lib/gpgme-1.1.8
|
||||||
|
}
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#include <gui/common/vmessagebox.h>
|
#include <gui/common/vmessagebox.h>
|
||||||
|
|
||||||
#include "AddLinksDialog.h"
|
#include "AddLinksDialog.h"
|
||||||
#include <gui/RetroShareLink.h>
|
//#include <gui/RetroShareLink.h>
|
||||||
#include "rsrank.h"
|
#include "rsrank.h"
|
||||||
|
|
||||||
/* Images for context menu icons */
|
/* Images for context menu icons */
|
||||||
@ -50,11 +50,11 @@ AddLinksDialog::AddLinksDialog(QString url, QWidget *parent)
|
|||||||
|
|
||||||
ui.linkLineEdit->setText(url);
|
ui.linkLineEdit->setText(url);
|
||||||
|
|
||||||
RetroShareLink link(url);
|
// RetroShareLink link(url);
|
||||||
|
|
||||||
if(link.valid() && link.type() == RetroShareLink::TYPE_FILE)
|
// if(link.valid() && link.type() == RetroShareLink::TYPE_FILE)
|
||||||
ui.titleLineEdit->setText(link.name());
|
// ui.titleLineEdit->setText(link.name());
|
||||||
else
|
// else
|
||||||
ui.titleLineEdit->setText("New File");
|
ui.titleLineEdit->setText("New File");
|
||||||
|
|
||||||
load();
|
load();
|
||||||
|
@ -27,13 +27,22 @@ LinksCloudPlugin::LinksCloudPlugin()
|
|||||||
{
|
{
|
||||||
mRanking = NULL ;
|
mRanking = NULL ;
|
||||||
mainpage = NULL ;
|
mainpage = NULL ;
|
||||||
mIcon = NULL ;
|
mIcon = NULL ;
|
||||||
|
mPlugInHandler = NULL;
|
||||||
|
mPeers = NULL;
|
||||||
|
mFiles = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LinksCloudPlugin::setInterfaces(RsPlugInInterfaces &interfaces){
|
||||||
|
|
||||||
|
mPeers = interfaces.mPeers;
|
||||||
|
mFiles = interfaces.mFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
MainPage *LinksCloudPlugin::qt_page() const
|
MainPage *LinksCloudPlugin::qt_page() const
|
||||||
{
|
{
|
||||||
if(mainpage == NULL)
|
if(mainpage == NULL)
|
||||||
mainpage = new LinksDialog ;
|
mainpage = new LinksDialog(mPeers, mFiles) ;
|
||||||
|
|
||||||
return mainpage ;
|
return mainpage ;
|
||||||
}
|
}
|
||||||
@ -42,13 +51,18 @@ RsCacheService *LinksCloudPlugin::rs_cache_service() const
|
|||||||
{
|
{
|
||||||
if(mRanking == NULL)
|
if(mRanking == NULL)
|
||||||
{
|
{
|
||||||
mRanking = new p3Ranking ; // , 3600 * 24 * 30 * 6); // 6 Months
|
mRanking = new p3Ranking(mPlugInHandler) ; // , 3600 * 24 * 30 * 6); // 6 Months
|
||||||
rsRanks = mRanking ;
|
rsRanks = mRanking ;
|
||||||
}
|
}
|
||||||
|
|
||||||
return mRanking ;
|
return mRanking ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LinksCloudPlugin::setPlugInHandler(RsPluginHandler *pgHandler){
|
||||||
|
mPlugInHandler = pgHandler;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
QIcon *LinksCloudPlugin::qt_icon() const
|
QIcon *LinksCloudPlugin::qt_icon() const
|
||||||
{
|
{
|
||||||
if(mIcon == NULL)
|
if(mIcon == NULL)
|
||||||
|
@ -16,13 +16,18 @@ class LinksCloudPlugin: public RsPlugin
|
|||||||
virtual uint16_t rs_service_id() const { return RS_SERVICE_TYPE_RANK ; }
|
virtual uint16_t rs_service_id() const { return RS_SERVICE_TYPE_RANK ; }
|
||||||
|
|
||||||
virtual void getPluginVersion(int& major,int& minor,int& svn_rev) const ;
|
virtual void getPluginVersion(int& major,int& minor,int& svn_rev) const ;
|
||||||
|
virtual void setPlugInHandler(RsPluginHandler *pgHandler);
|
||||||
|
|
||||||
virtual std::string configurationFileName() const { return std::string() ; }
|
virtual std::string configurationFileName() const { return std::string() ; }
|
||||||
|
|
||||||
virtual std::string getShortPluginDescription() const ;
|
virtual std::string getShortPluginDescription() const ;
|
||||||
virtual std::string getPluginName() const { return "LinksCloud" ; }
|
virtual std::string getPluginName() const { return "LinksCloud" ; }
|
||||||
|
virtual void setInterfaces(RsPlugInInterfaces& interfaces);
|
||||||
private:
|
private:
|
||||||
mutable p3Ranking *mRanking ;
|
mutable p3Ranking *mRanking ;
|
||||||
|
mutable RsPluginHandler *mPlugInHandler;
|
||||||
|
mutable RsFiles* mFiles;
|
||||||
|
mutable RsPeers* mPeers;
|
||||||
mutable MainPage *mainpage ;
|
mutable MainPage *mainpage ;
|
||||||
mutable QIcon *mIcon ;
|
mutable QIcon *mIcon ;
|
||||||
};
|
};
|
||||||
|
@ -24,12 +24,9 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
|
||||||
#include "LinksDialog.h"
|
#include "LinksDialog.h"
|
||||||
#include <gui/RetroShareLink.h>
|
#include <gui/RetroShareLink.h>
|
||||||
#include "AddLinksDialog.h"
|
#include "AddLinksDialog.h"
|
||||||
#include <retroshare/rspeers.h>
|
|
||||||
#include <retroshare/rsfiles.h>
|
|
||||||
#include "rsrank.h"
|
#include "rsrank.h"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -50,8 +47,8 @@
|
|||||||
*****/
|
*****/
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
LinksDialog::LinksDialog(QWidget *parent)
|
LinksDialog::LinksDialog(RsPeers *peers, RsFiles *files, QWidget *parent)
|
||||||
: MainPage(parent)
|
: MainPage(parent), mPeers(peers), mFiles(files)
|
||||||
{
|
{
|
||||||
/* Invoke the Qt Designer generated object setup routine */
|
/* Invoke the Qt Designer generated object setup routine */
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
@ -247,7 +244,7 @@ void LinksDialog::changedSortFrom( int index )
|
|||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
peers.push_back(rsPeers->getOwnId());
|
peers.push_back(mPeers->getOwnId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -467,7 +464,7 @@ void LinksDialog::updateLinks()
|
|||||||
qtime.setTime_t(cit->timestamp);
|
qtime.setTime_t(cit->timestamp);
|
||||||
QString timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss");
|
QString timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss");
|
||||||
|
|
||||||
QString peerLabel = QString::fromStdString(rsPeers->getPeerName(cit->id));
|
QString peerLabel = QString::fromStdString(mPeers->getPeerName(cit->id));
|
||||||
if (peerLabel == "")
|
if (peerLabel == "")
|
||||||
{
|
{
|
||||||
peerLabel = "<";
|
peerLabel = "<";
|
||||||
@ -673,7 +670,7 @@ void LinksDialog::updateComments(std::string rid, std::string )
|
|||||||
mLinkId = rid;
|
mLinkId = rid;
|
||||||
|
|
||||||
/* Add your text to the comment */
|
/* Add your text to the comment */
|
||||||
std::string ownId = rsPeers->getOwnId();
|
std::string ownId = mPeers->getOwnId();
|
||||||
|
|
||||||
for(cit = detail.comments.begin(); cit != detail.comments.end(); cit++)
|
for(cit = detail.comments.begin(); cit != detail.comments.end(); cit++)
|
||||||
{
|
{
|
||||||
@ -913,7 +910,7 @@ void LinksDialog::voteup_score(int score)
|
|||||||
|
|
||||||
std::list<RsRankComment>::iterator cit;
|
std::list<RsRankComment>::iterator cit;
|
||||||
/* Add your text to the comment */
|
/* Add your text to the comment */
|
||||||
std::string ownId = rsPeers->getOwnId();
|
std::string ownId = mPeers->getOwnId();
|
||||||
|
|
||||||
for(cit = detail.comments.begin(); cit != detail.comments.end(); cit++)
|
for(cit = detail.comments.begin(); cit != detail.comments.end(); cit++)
|
||||||
{
|
{
|
||||||
@ -975,24 +972,24 @@ void LinksDialog::downloadSelected()
|
|||||||
std::cerr << "LinksDialog::downloadSelected() : " << link.toStdString() << std::endl;
|
std::cerr << "LinksDialog::downloadSelected() : " << link.toStdString() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RetroShareLink rslink(QString::fromStdWString(detail.link));
|
//RetroShareLink rslink(QString::fromStdWString(detail.link));
|
||||||
|
|
||||||
if(!rslink.valid() || rslink.type() != RetroShareLink::TYPE_FILE)
|
//if(!rslink.valid() || rslink.type() != RetroShareLink::TYPE_FILE)
|
||||||
{
|
//{
|
||||||
QMessageBox::critical(NULL,"Badly formed link","This link is badly formed. Can't parse/use it. This is a bug. Please contact the developers.") ;
|
// QMessageBox::critical(NULL,"Badly formed link","This link is badly formed. Can't parse/use it. This is a bug. Please contact the developers.") ;
|
||||||
return ;
|
// return ;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* retrieve all peers id for this file */
|
/* retrieve all peers id for this file */
|
||||||
FileInfo info;
|
// FileInfo info;
|
||||||
rsFiles->FileDetails(rslink.hash().toStdString(), 0, info);
|
// rsFiles->FileDetails(rslink.hash().toStdString(), 0, info);
|
||||||
|
|
||||||
std::list<std::string> srcIds;
|
// std::list<std::string> srcIds;
|
||||||
std::list<TransferInfo>::iterator pit;
|
// std::list<TransferInfo>::iterator pit;
|
||||||
for (pit = info.peers.begin(); pit != info.peers.end(); pit ++)
|
// for (pit = info.peers.begin(); pit != info.peers.end(); pit ++)
|
||||||
srcIds.push_back(pit->peerId);
|
// srcIds.push_back(pit->peerId);
|
||||||
|
|
||||||
rsFiles->FileRequest(rslink.name().toStdString(), rslink.hash().toStdString(), rslink.size(), "", 0, srcIds);
|
// rsFiles->FileRequest(rslink.name().toStdString(), rslink.hash().toStdString(), rslink.size(), "", 0, srcIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinksDialog::anchorClicked (const QUrl& link )
|
void LinksDialog::anchorClicked (const QUrl& link )
|
||||||
@ -1017,7 +1014,7 @@ void LinksDialog::anchorClicked (const QUrl& link )
|
|||||||
{
|
{
|
||||||
std::list<std::string> srcIds;
|
std::list<std::string> srcIds;
|
||||||
|
|
||||||
if(rsFiles->FileRequest(fileName, fileHash, fileSize, "", RS_FILE_HINTS_NETWORK_WIDE, srcIds))
|
if(mFiles->FileRequest(fileName, fileHash, fileSize, "", RS_FILE_HINTS_NETWORK_WIDE, srcIds))
|
||||||
{
|
{
|
||||||
QMessageBox mb(tr("File Request Confirmation"), tr("The file has been added to your download list."),QMessageBox::Information,QMessageBox::Ok,0,0,this);
|
QMessageBox mb(tr("File Request Confirmation"), tr("The file has been added to your download list."),QMessageBox::Information,QMessageBox::Ok,0,0,this);
|
||||||
mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png")));
|
mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png")));
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
#define _LINKS_DIALOG_H
|
#define _LINKS_DIALOG_H
|
||||||
|
|
||||||
#include <gui/mainpage.h>
|
#include <gui/mainpage.h>
|
||||||
|
#include <retroshare/rsfiles.h>
|
||||||
|
#include <retroshare/rspeers.h>
|
||||||
#include "ui_LinksDialog.h"
|
#include "ui_LinksDialog.h"
|
||||||
|
|
||||||
|
|
||||||
@ -32,7 +34,7 @@ class LinksDialog : public MainPage
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
/** Default Constructor */
|
/** Default Constructor */
|
||||||
LinksDialog(QWidget *parent = 0);
|
LinksDialog(RsPeers* peers, RsFiles* files, QWidget *parent = 0);
|
||||||
/** Default Destructor */
|
/** Default Destructor */
|
||||||
|
|
||||||
void insertExample();
|
void insertExample();
|
||||||
@ -84,6 +86,11 @@ void updateComments(std::string rid, std::string pid);
|
|||||||
|
|
||||||
QTreeWidget *exampletreeWidget;
|
QTreeWidget *exampletreeWidget;
|
||||||
|
|
||||||
|
// gui interface
|
||||||
|
RsPeers* mPeers;
|
||||||
|
RsFiles* mFiles;
|
||||||
|
|
||||||
|
|
||||||
/** Qt Designer generated object */
|
/** Qt Designer generated object */
|
||||||
Ui::LinksDialog ui;
|
Ui::LinksDialog ui;
|
||||||
};
|
};
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include <retroshare/rsplugin.h>
|
#include <retroshare/rsplugin.h>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
#include "pqi/p3connmgr.h"
|
#include "pqi/p3linkmgr.h"
|
||||||
#include "pqi/pqibin.h"
|
#include "pqi/pqibin.h"
|
||||||
#include "pqi/authssl.h"
|
#include "pqi/authssl.h"
|
||||||
#include "pqi/pqistore.h"
|
#include "pqi/pqistore.h"
|
||||||
@ -55,13 +55,13 @@ std::string generateRandomLinkId();
|
|||||||
*********/
|
*********/
|
||||||
#define RANK_DEBUG 1
|
#define RANK_DEBUG 1
|
||||||
|
|
||||||
p3Ranking::p3Ranking()
|
p3Ranking::p3Ranking(RsPluginHandler* pgHandler)
|
||||||
: RsCacheService(RS_SERVICE_TYPE_RANK,CONFIG_TYPE_RANK_LINK,5),
|
: RsCacheService(RS_SERVICE_TYPE_RANK,CONFIG_TYPE_RANK_LINK,5, pgHandler),
|
||||||
mRepublish(false), mRepublishFriends(false), mRepublishFriendTS(0), mStorePeriod(RANK_STORE_PERIOD), mUpdated(true),mRankMtx(std::string("p3Ranking"))
|
mRepublish(false), mRepublishFriends(false), mRepublishFriendTS(0), mStorePeriod(RANK_STORE_PERIOD), mUpdated(true),mRankMtx(std::string("p3Ranking"))
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mRankMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mRankMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
mOwnId = rsPlugins->getConnectMgr()->getOwnId();
|
mOwnId = pgHandler->getLinkMgr()->getOwnId();
|
||||||
mViewPeriod = 60 * 60 * 24 * 30; /* one Month */
|
mViewPeriod = 60 * 60 * 24 * 30; /* one Month */
|
||||||
mSortType = RS_RANK_ALG;
|
mSortType = RS_RANK_ALG;
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ class p3Ranking: public RsCacheService, public RsRanks
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
p3Ranking() ;
|
p3Ranking(RsPluginHandler* pgHandler) ;
|
||||||
|
|
||||||
|
|
||||||
/******************************* CACHE SOURCE / STORE Interface *********************/
|
/******************************* CACHE SOURCE / STORE Interface *********************/
|
||||||
@ -130,7 +130,7 @@ class p3Ranking: public RsCacheService, public RsRanks
|
|||||||
void createDummyData();
|
void createDummyData();
|
||||||
|
|
||||||
uint32_t storePeriod;
|
uint32_t storePeriod;
|
||||||
p3ConnectMgr *mConnMgr;
|
p3LinkMgr *mConnMgr;
|
||||||
|
|
||||||
RsMutex mRankMtx;
|
RsMutex mRankMtx;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user