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:
chrisparker126 2011-10-08 17:47:36 +00:00
parent 2173ee0d2e
commit c1af9b13ad
14 changed files with 179 additions and 52 deletions

View file

@ -9,3 +9,55 @@ linux-g++-64 {
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
}

View file

@ -22,7 +22,7 @@
#include <gui/common/vmessagebox.h>
#include "AddLinksDialog.h"
#include <gui/RetroShareLink.h>
//#include <gui/RetroShareLink.h>
#include "rsrank.h"
/* Images for context menu icons */
@ -50,11 +50,11 @@ AddLinksDialog::AddLinksDialog(QString url, QWidget *parent)
ui.linkLineEdit->setText(url);
RetroShareLink link(url);
// RetroShareLink link(url);
if(link.valid() && link.type() == RetroShareLink::TYPE_FILE)
ui.titleLineEdit->setText(link.name());
else
// if(link.valid() && link.type() == RetroShareLink::TYPE_FILE)
// ui.titleLineEdit->setText(link.name());
// else
ui.titleLineEdit->setText("New File");
load();

View file

@ -27,13 +27,22 @@ LinksCloudPlugin::LinksCloudPlugin()
{
mRanking = 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
{
if(mainpage == NULL)
mainpage = new LinksDialog ;
mainpage = new LinksDialog(mPeers, mFiles) ;
return mainpage ;
}
@ -42,13 +51,18 @@ RsCacheService *LinksCloudPlugin::rs_cache_service() const
{
if(mRanking == NULL)
{
mRanking = new p3Ranking ; // , 3600 * 24 * 30 * 6); // 6 Months
mRanking = new p3Ranking(mPlugInHandler) ; // , 3600 * 24 * 30 * 6); // 6 Months
rsRanks = mRanking ;
}
return mRanking ;
}
void LinksCloudPlugin::setPlugInHandler(RsPluginHandler *pgHandler){
mPlugInHandler = pgHandler;
}
QIcon *LinksCloudPlugin::qt_icon() const
{
if(mIcon == NULL)

View file

@ -16,13 +16,18 @@ class LinksCloudPlugin: public RsPlugin
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 setPlugInHandler(RsPluginHandler *pgHandler);
virtual std::string configurationFileName() const { return std::string() ; }
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:
mutable p3Ranking *mRanking ;
mutable RsPluginHandler *mPlugInHandler;
mutable RsFiles* mFiles;
mutable RsPeers* mPeers;
mutable MainPage *mainpage ;
mutable QIcon *mIcon ;
};

View file

@ -24,12 +24,9 @@
#include <QMessageBox>
#include <QDateTime>
#include <QDesktopServices>
#include "LinksDialog.h"
#include <gui/RetroShareLink.h>
#include "AddLinksDialog.h"
#include <retroshare/rspeers.h>
#include <retroshare/rsfiles.h>
#include "rsrank.h"
#include <sstream>
@ -50,8 +47,8 @@
*****/
/** Constructor */
LinksDialog::LinksDialog(QWidget *parent)
: MainPage(parent)
LinksDialog::LinksDialog(RsPeers *peers, RsFiles *files, QWidget *parent)
: MainPage(parent), mPeers(peers), mFiles(files)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
@ -247,7 +244,7 @@ void LinksDialog::changedSortFrom( int index )
case 0:
break;
case 1:
peers.push_back(rsPeers->getOwnId());
peers.push_back(mPeers->getOwnId());
break;
}
@ -467,7 +464,7 @@ void LinksDialog::updateLinks()
qtime.setTime_t(cit->timestamp);
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 == "")
{
peerLabel = "<";
@ -673,7 +670,7 @@ void LinksDialog::updateComments(std::string rid, std::string )
mLinkId = rid;
/* 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++)
{
@ -913,7 +910,7 @@ void LinksDialog::voteup_score(int score)
std::list<RsRankComment>::iterator cit;
/* 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++)
{
@ -975,24 +972,24 @@ void LinksDialog::downloadSelected()
std::cerr << "LinksDialog::downloadSelected() : " << link.toStdString() << std::endl;
#endif
RetroShareLink rslink(QString::fromStdWString(detail.link));
//RetroShareLink rslink(QString::fromStdWString(detail.link));
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.") ;
return ;
}
//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.") ;
// return ;
// }
/* retrieve all peers id for this file */
FileInfo info;
rsFiles->FileDetails(rslink.hash().toStdString(), 0, info);
// FileInfo info;
// rsFiles->FileDetails(rslink.hash().toStdString(), 0, info);
std::list<std::string> srcIds;
std::list<TransferInfo>::iterator pit;
for (pit = info.peers.begin(); pit != info.peers.end(); pit ++)
srcIds.push_back(pit->peerId);
// std::list<std::string> srcIds;
// std::list<TransferInfo>::iterator pit;
// for (pit = info.peers.begin(); pit != info.peers.end(); pit ++)
// 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 )
@ -1017,7 +1014,7 @@ void LinksDialog::anchorClicked (const QUrl& link )
{
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);
mb.setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png")));

View file

@ -23,6 +23,8 @@
#define _LINKS_DIALOG_H
#include <gui/mainpage.h>
#include <retroshare/rsfiles.h>
#include <retroshare/rspeers.h>
#include "ui_LinksDialog.h"
@ -32,7 +34,7 @@ class LinksDialog : public MainPage
public:
/** Default Constructor */
LinksDialog(QWidget *parent = 0);
LinksDialog(RsPeers* peers, RsFiles* files, QWidget *parent = 0);
/** Default Destructor */
void insertExample();
@ -84,6 +86,11 @@ void updateComments(std::string rid, std::string pid);
QTreeWidget *exampletreeWidget;
// gui interface
RsPeers* mPeers;
RsFiles* mFiles;
/** Qt Designer generated object */
Ui::LinksDialog ui;
};

View file

@ -28,7 +28,7 @@
#include <retroshare/rsplugin.h>
#include <iomanip>
#include "pqi/p3connmgr.h"
#include "pqi/p3linkmgr.h"
#include "pqi/pqibin.h"
#include "pqi/authssl.h"
#include "pqi/pqistore.h"
@ -55,13 +55,13 @@ std::string generateRandomLinkId();
*********/
#define RANK_DEBUG 1
p3Ranking::p3Ranking()
: RsCacheService(RS_SERVICE_TYPE_RANK,CONFIG_TYPE_RANK_LINK,5),
p3Ranking::p3Ranking(RsPluginHandler* pgHandler)
: 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"))
{
RsStackMutex stack(mRankMtx); /********** STACK LOCKED MTX ******/
mOwnId = rsPlugins->getConnectMgr()->getOwnId();
mOwnId = pgHandler->getLinkMgr()->getOwnId();
mViewPeriod = 60 * 60 * 24 * 30; /* one Month */
mSortType = RS_RANK_ALG;
}

View file

@ -65,7 +65,7 @@ class p3Ranking: public RsCacheService, public RsRanks
{
public:
p3Ranking() ;
p3Ranking(RsPluginHandler* pgHandler) ;
/******************************* CACHE SOURCE / STORE Interface *********************/
@ -130,7 +130,7 @@ class p3Ranking: public RsCacheService, public RsRanks
void createDummyData();
uint32_t storePeriod;
p3ConnectMgr *mConnMgr;
p3LinkMgr *mConnMgr;
RsMutex mRankMtx;