mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
support for retroshare links in gxs forums
- only group can link at the moment added more nxs tests and better cleanup - test ability sync with a delayed circle load git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7384 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
838e263ba3
commit
0dabe4b8a1
@ -933,14 +933,12 @@ void SetForegroundWindowInternal(HWND hWnd)
|
||||
case Messages:
|
||||
_instance->ui->stackPages->setCurrentPage( _instance->messagesDialog );
|
||||
break;
|
||||
#if 0
|
||||
case Channels:
|
||||
_instance->ui->stackPages->setCurrentPage( _instance->channelFeed );
|
||||
_instance->ui->stackPages->setCurrentPage( _instance->gxschannelDialog );
|
||||
return true ;
|
||||
case Forums:
|
||||
_instance->ui->stackPages->setCurrentPage( _instance->forumsDialog );
|
||||
_instance->ui->stackPages->setCurrentPage( _instance->gxsforumDialog );
|
||||
return true ;
|
||||
#endif
|
||||
#ifdef BLOGS
|
||||
case Blogs:
|
||||
Page = _instance->blogsFeed;
|
||||
@ -1029,12 +1027,10 @@ void SetForegroundWindowInternal(HWND hWnd)
|
||||
case Links:
|
||||
return _instance->linksDialog;
|
||||
#endif
|
||||
#if 0
|
||||
case Channels:
|
||||
return _instance->channelFeed;
|
||||
return _instance->gxschannelDialog;
|
||||
case Forums:
|
||||
return _instance->forumsDialog;
|
||||
#endif
|
||||
return _instance->gxsforumDialog;
|
||||
#ifdef BLOGS
|
||||
case Blogs:
|
||||
return _instance->blogsFeed;
|
||||
|
@ -87,8 +87,8 @@ public:
|
||||
Transfers = 3, /** Transfers page. */
|
||||
SharedDirectories = 4, /** Shared Directories page. */
|
||||
Messages = 5, /** Messages page. */
|
||||
// Channels = 6, /** Channels page. */
|
||||
// Forums = 7, /** Forums page. */
|
||||
Channels = 6, /** Channels page. */
|
||||
Forums = 7, /** Forums page. */
|
||||
Search = 8, /** Search page. */
|
||||
#ifdef BLOGS
|
||||
Blogs = 9, /** Blogs page. */
|
||||
|
@ -36,8 +36,7 @@
|
||||
|
||||
#include "RetroShareLink.h"
|
||||
#include "MainWindow.h"
|
||||
//#include "ForumsDialog.h"
|
||||
//#include "ChannelFeed.h"
|
||||
#include "gui/gxsforums/GxsForumsDialog.h"
|
||||
#include "SearchDialog.h"
|
||||
#include "msgs/MessageComposer.h"
|
||||
#include "util/misc.h"
|
||||
@ -51,7 +50,7 @@
|
||||
#include <retroshare/rsmsgs.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rsidentity.h>
|
||||
//#include <retroshare/rschannels.h>
|
||||
#include <retroshare/rsgxsforums.h>
|
||||
|
||||
//#define DEBUG_RSLINK 1
|
||||
|
||||
@ -543,6 +542,33 @@ bool RetroShareLink::createChannel(const std::string &id, const std::string &msg
|
||||
return valid();
|
||||
}
|
||||
|
||||
bool RetroShareLink::createGxsLink(const RsGxsGroupId &id, const RsGxsMessageId &msgId,
|
||||
const std::string& groupName, const std::string& msgSubject,
|
||||
const RetroShareLink::enumType &linkType)
|
||||
{
|
||||
clear();
|
||||
|
||||
if (!id.isNull()) {
|
||||
_hash = QString::fromStdString(id.toStdString());
|
||||
|
||||
if(!msgId.isNull())
|
||||
_msgId = QString::fromStdString(msgId.toStdString());
|
||||
|
||||
_type = linkType;
|
||||
|
||||
if (msgId.isNull()) {
|
||||
_name = QString::fromStdString(groupName);
|
||||
} else {
|
||||
_name = QString::fromStdString(msgSubject);
|
||||
}
|
||||
}
|
||||
|
||||
check();
|
||||
|
||||
return valid();
|
||||
}
|
||||
|
||||
|
||||
bool RetroShareLink::createSearch(const QString& keywords)
|
||||
{
|
||||
clear();
|
||||
@ -1402,38 +1428,21 @@ static void processList(const QStringList &list, const QString &textSingular, co
|
||||
break;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
case TYPE_FORUM:
|
||||
{
|
||||
#ifdef DEBUG_RSLINK
|
||||
std::cerr << " RetroShareLink::process ForumRequest : name : " << link.name().toStdString() << ". id : " << link.hash().toStdString() << ". msgId : " << link.msgId().toStdString() << std::endl;
|
||||
#endif
|
||||
|
||||
ForumInfo fi;
|
||||
if (!rsForums->getForumInfo(link.id().toStdString(), fi)) {
|
||||
if (link.msgId().isEmpty()) {
|
||||
forumUnknown.append(link.name());
|
||||
} else {
|
||||
forumMsgUnknown.append(link.name());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
ForumMsgInfo msg;
|
||||
if (!link.msgId().isEmpty()) {
|
||||
if (!rsForums->getForumMessage(fi.forumId, link.msgId().toStdString(), msg)) {
|
||||
forumMsgUnknown.append(link.name());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
MainWindow::showWindow(MainWindow::Forums);
|
||||
ForumsDialog *forumsDialog = dynamic_cast<ForumsDialog*>(MainWindow::getPage(MainWindow::Forums));
|
||||
GxsForumsDialog *forumsDialog = dynamic_cast<GxsForumsDialog*>(MainWindow::getPage(MainWindow::Forums));
|
||||
if (!forumsDialog) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (forumsDialog->navigate(fi.forumId, msg.msgId)) {
|
||||
if (forumsDialog->navigate(RsGxsGroupId(link.id().toStdString()), RsGxsMessageId(link.msgId().toStdString()))) {
|
||||
if (link.msgId().isEmpty()) {
|
||||
forumFound.append(link.name());
|
||||
} else {
|
||||
@ -1448,7 +1457,7 @@ static void processList(const QStringList &list, const QString &textSingular, co
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
#if 0
|
||||
case TYPE_CHANNEL:
|
||||
{
|
||||
#ifdef DEBUG_RSLINK
|
||||
|
@ -79,6 +79,9 @@ class RetroShareLink
|
||||
bool createPerson(const RsPgpId &id);
|
||||
bool createForum(const std::string& id, const std::string& msgId);
|
||||
bool createChannel(const std::string& id, const std::string& msgId);
|
||||
bool createGxsLink(const RsGxsGroupId &id, const RsGxsMessageId &msgId,
|
||||
const std::string& groupName, const std::string& msgSubject,
|
||||
const RetroShareLink::enumType &linkType);
|
||||
bool createSearch(const QString& keywords);
|
||||
bool createMessage(const RsPeerId &peerId, const QString& subject);
|
||||
bool createMessage(const RsGxsId &peerId, const QString& subject);
|
||||
|
@ -457,6 +457,21 @@ RSTreeWidget *GroupTreeWidget::treeWidget()
|
||||
return ui->treeWidget;
|
||||
}
|
||||
|
||||
bool GroupTreeWidget::getGroupName(QString id, QTreeWidgetItem* categoryItem, QString& name)
|
||||
{
|
||||
int childCount = categoryItem->childCount();
|
||||
for (int child = 0; child < childCount; child++) {
|
||||
QTreeWidgetItem *childItem = categoryItem->child(child);
|
||||
if (childItem->data(COLUMN_DATA, ROLE_ID).toString() == id) {
|
||||
/* Found child */
|
||||
|
||||
name = childItem->text(COLUMN_NAME);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int GroupTreeWidget::subscribeFlags(const QString &id)
|
||||
{
|
||||
QTreeWidgetItem *item = getItemFromId(id);
|
||||
|
@ -98,6 +98,7 @@ public:
|
||||
|
||||
void setTextColorCategory(QColor color) { mTextColor[GROUPTREEWIDGET_COLOR_CATEGORY] = color; }
|
||||
void setTextColorPrivateKey(QColor color) { mTextColor[GROUPTREEWIDGET_COLOR_PRIVATEKEY] = color; }
|
||||
bool getGroupName(QString id, QTreeWidgetItem* item, QString& name);
|
||||
|
||||
int subscribeFlags(const QString &id);
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "gui/gxs/RsGxsUpdateBroadcastBase.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
/**
|
||||
* #define DEBUG_ITEM 1
|
||||
|
@ -351,25 +351,48 @@ void GxsGroupFrameDialog::copyGroupLink()
|
||||
return;
|
||||
}
|
||||
|
||||
// THIS CODE CALLS getForumInfo() to verify that the Ids are valid.
|
||||
// As we are switching to Request/Response this is now harder to do...
|
||||
// So not bothering any more - shouldn't be necessary.
|
||||
// IF we get errors - fix them, rather than patching here.
|
||||
#if 0
|
||||
ForumInfo fi;
|
||||
if (rsGxsForums->getForumInfo(mCurrForumId, fi)) {
|
||||
RetroShareLink link;
|
||||
if (link.createForum(fi.forumId, "")) {
|
||||
|
||||
QString name;
|
||||
if(!getCurrentGroupName(name)) return;
|
||||
|
||||
if (link.createGxsLink(mGroupId, RsGxsMessageId(), name.toStdString(), "", getLinkType())) {
|
||||
QList<RetroShareLink> urls;
|
||||
urls.push_back(link);
|
||||
RSLinkClipboard::copyLinks(urls);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
QMessageBox::warning(this, "RetroShare", "ToDo");
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool GxsGroupFrameDialog::getCurrentGroupName(QString& name)
|
||||
{
|
||||
GroupTreeWidget* gtw = ui->groupTreeWidget;
|
||||
|
||||
QString id = QString::fromStdString(mGroupId.toStdString());
|
||||
|
||||
if(gtw->getGroupName(id, mYourGroups, name))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if(gtw->getGroupName(id, mSubscribedGroups, name))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if(gtw->getGroupName(id, mYourGroups, name))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if(gtw->getGroupName(id, mOtherGroups, name))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GxsGroupFrameDialog::markMsgAsRead()
|
||||
{
|
||||
GxsMessageFrameWidget *msgWidget = messageWidget(mGroupId, false);
|
||||
@ -429,23 +452,23 @@ void GxsGroupFrameDialog::loadComment(const RsGxsGroupId &grpId, const RsGxsMess
|
||||
ui->messageTabWidget->setCurrentWidget(commentDialog);
|
||||
}
|
||||
|
||||
bool GxsGroupFrameDialog::navigate(const RsGxsGroupId groupId, const std::string& msgId)
|
||||
bool GxsGroupFrameDialog::navigate(const RsGxsGroupId groupId, const RsGxsMessageId& msgId)
|
||||
{
|
||||
if (groupId.isNull()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ui->groupTreeWidget->activateId(QString::fromStdString(groupId.toStdString()), msgId.empty()) == NULL) {
|
||||
if (ui->groupTreeWidget->activateId(QString::fromStdString(groupId.toStdString()), msgId.isNull()) == NULL) {
|
||||
return false;
|
||||
}
|
||||
// if (mGroupId == groupId) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// if (msgId.isNull()) {
|
||||
// return true;
|
||||
// }
|
||||
|
||||
if (mGroupId != groupId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (msgId.empty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//#TODO
|
||||
// if (mThreadLoading) {
|
||||
@ -458,7 +481,7 @@ bool GxsGroupFrameDialog::navigate(const RsGxsGroupId groupId, const std::string
|
||||
// QTreeWidgetItem *item = NULL;
|
||||
// while ((item = *itemIterator) != NULL) {
|
||||
// itemIterator++;
|
||||
|
||||
//
|
||||
// if (item->data(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID).toString().toStdString() == msgId) {
|
||||
// ui->threadTreeWidget->setCurrentItem(item);
|
||||
// ui->threadTreeWidget->setFocus();
|
||||
@ -466,7 +489,7 @@ bool GxsGroupFrameDialog::navigate(const RsGxsGroupId groupId, const std::string
|
||||
// }
|
||||
// }
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
GxsMessageFrameWidget *GxsGroupFrameDialog::messageWidget(const RsGxsGroupId &groupId, bool ownTab)
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include "gui/gxs/RsGxsUpdateBroadcastPage.h"
|
||||
#include "RsAutoUpdatePage.h"
|
||||
#include "gui/RetroShareLink.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
@ -71,7 +72,7 @@ public:
|
||||
GxsGroupFrameDialog(RsGxsIfaceHelper *ifaceImpl, QWidget *parent = 0);
|
||||
~GxsGroupFrameDialog();
|
||||
|
||||
bool navigate(const RsGxsGroupId groupId, const std::string& msgId);
|
||||
bool navigate(const RsGxsGroupId groupId, const RsGxsMessageId& msgId);
|
||||
|
||||
// Callback for all Loads.
|
||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
@ -81,8 +82,10 @@ protected:
|
||||
virtual void updateDisplay(bool complete);
|
||||
|
||||
RsGxsGroupId groupId() { return mGroupId; }
|
||||
|
||||
void setSingleTab(bool singleTab);
|
||||
bool getCurrentGroupName(QString& name);
|
||||
virtual RetroShareLink::enumType getLinkType() = 0;
|
||||
|
||||
|
||||
private slots:
|
||||
void todo();
|
||||
@ -119,6 +122,7 @@ private:
|
||||
virtual QString text(TextType type) = 0;
|
||||
virtual QString icon(IconType type) = 0;
|
||||
virtual QString settingsGroupName() = 0;
|
||||
|
||||
virtual GxsGroupDialog *createNewGroupDialog(TokenQueue *tokenQueue) = 0;
|
||||
virtual GxsGroupDialog *createGroupDialog(TokenQueue *tokenQueue, RsTokenService *tokenService, GxsGroupDialog::Mode mode, RsGxsGroupId groupId) = 0;
|
||||
virtual int shareKeyType() = 0;
|
||||
|
@ -41,7 +41,8 @@ public:
|
||||
virtual QString helpText() const { return ""; } //MainPage
|
||||
|
||||
// virtual UserNotify *getUserNotify(QObject *parent);
|
||||
|
||||
protected:
|
||||
RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_CHANNEL; }
|
||||
private slots:
|
||||
void settingsChanged();
|
||||
void toggleAutoDownload();
|
||||
|
@ -80,6 +80,11 @@ QString GxsForumsDialog::text(TextType type)
|
||||
return "";
|
||||
}
|
||||
|
||||
RetroShareLink::enumType GxsForumsDialog::getLinkType()
|
||||
{
|
||||
return RetroShareLink::TYPE_FORUM;
|
||||
}
|
||||
|
||||
QString GxsForumsDialog::icon(IconType type)
|
||||
{
|
||||
switch (type) {
|
||||
|
@ -40,6 +40,10 @@ public:
|
||||
|
||||
// virtual UserNotify *getUserNotify(QObject *parent);
|
||||
|
||||
protected:
|
||||
|
||||
RetroShareLink::enumType getLinkType();
|
||||
|
||||
private slots:
|
||||
void settingsChanged();
|
||||
|
||||
|
@ -10,8 +10,7 @@
|
||||
|
||||
|
||||
|
||||
rs_nxs_test::RsNxsSimpleDummyCircles::RsNxsSimpleDummyCircles(
|
||||
std::list<Membership>& membership, bool cached) {
|
||||
rs_nxs_test::RsNxsSimpleDummyCircles::RsNxsSimpleDummyCircles() {
|
||||
}
|
||||
|
||||
bool rs_nxs_test::RsNxsSimpleDummyCircles::isLoaded(
|
||||
@ -111,4 +110,34 @@ bool rs_nxs_test::RsNxsDelayedDummyCircles::allowed(
|
||||
|
||||
}
|
||||
|
||||
const RsPgpId& rs_nxs_test::RsDummyPgpUtils::getPGPOwnId() {
|
||||
return mOwnId;
|
||||
}
|
||||
|
||||
RsPgpId rs_nxs_test::RsDummyPgpUtils::getPGPId(const RsPeerId& sslid) {
|
||||
return RsPgpId().random();
|
||||
}
|
||||
|
||||
bool rs_nxs_test::RsDummyPgpUtils::getGPGAllList(std::list<RsPgpId>& ids) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool rs_nxs_test::RsDummyPgpUtils::getKeyFingerprint(const RsPgpId& id,
|
||||
PGPFingerprintType& fp) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool rs_nxs_test::RsDummyPgpUtils::VerifySignBin(const void* data, uint32_t len,
|
||||
unsigned char* sign, unsigned int signlen,
|
||||
const PGPFingerprintType& withfingerprint) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool rs_nxs_test::RsDummyPgpUtils::askForDeferredSelfSignature(const void* data,
|
||||
const uint32_t len, unsigned char* sign, unsigned int* signlen,
|
||||
int& signature_result) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <gxs/rsgixs.h>
|
||||
#include <gxs/rsgxsnetutils.h>
|
||||
#include <algorithm>
|
||||
#include <pgp/pgpauxutils.h>
|
||||
|
||||
|
||||
namespace rs_nxs_test
|
||||
@ -21,23 +22,18 @@ namespace rs_nxs_test
|
||||
|
||||
|
||||
/*!
|
||||
* This dummy circles implementation
|
||||
* allow instantiation with simple membership
|
||||
* list for a given circle
|
||||
* This is a dummy circles implementation
|
||||
*/
|
||||
class RsNxsSimpleDummyCircles : public RsGcxs
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
typedef std::map<RsGxsCircleId, std::list<RsPgpId> > Membership;
|
||||
|
||||
/*!
|
||||
*
|
||||
* @param membership
|
||||
* @param cached
|
||||
*/
|
||||
RsNxsSimpleDummyCircles(std::list<Membership>& membership, bool cached);
|
||||
RsNxsSimpleDummyCircles();
|
||||
|
||||
/* GXS Interface - for working out who can receive */
|
||||
bool isLoaded(const RsGxsCircleId &circleId);
|
||||
@ -47,9 +43,6 @@ namespace rs_nxs_test
|
||||
int canReceive(const RsGxsCircleId &circleId, const RsPgpId &id);
|
||||
bool recipients(const RsGxsCircleId &circleId, std::list<RsPgpId> &friendlist);
|
||||
|
||||
private:
|
||||
|
||||
std::list<Membership> mMembership;
|
||||
};
|
||||
|
||||
/*!
|
||||
@ -146,6 +139,24 @@ namespace rs_nxs_test
|
||||
|
||||
};
|
||||
|
||||
class RsDummyPgpUtils : public PgpAuxUtils
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~RsDummyPgpUtils(){}
|
||||
const RsPgpId &getPGPOwnId() ;
|
||||
RsPgpId getPGPId(const RsPeerId& sslid) ;
|
||||
bool getGPGAllList(std::list<RsPgpId> &ids) ;
|
||||
bool getKeyFingerprint(const RsPgpId& id,PGPFingerprintType& fp) const;
|
||||
|
||||
bool VerifySignBin(const void *data, uint32_t len, unsigned char *sign, unsigned int signlen, const PGPFingerprintType& withfingerprint);
|
||||
bool askForDeferredSelfSignature(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen,int& signature_result );
|
||||
|
||||
|
||||
private:
|
||||
|
||||
RsPgpId mOwnId;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ using namespace rs_nxs_test;
|
||||
|
||||
|
||||
|
||||
NxsGrpSync::NxsGrpSync()
|
||||
NxsGrpSync::NxsGrpSync(RsGcxs* circle, RsGixsReputation* reputation)
|
||||
{
|
||||
|
||||
int numPeers = 2;
|
||||
@ -42,11 +42,24 @@ NxsGrpSync::NxsGrpSync()
|
||||
}
|
||||
|
||||
RsNxsSimpleDummyReputation::RepMap reMap;
|
||||
std::list<RsNxsSimpleDummyCircles::Membership> membership;
|
||||
// now reputation service
|
||||
mRep = new RsNxsSimpleDummyReputation(reMap, true);
|
||||
mCircles = new RsNxsSimpleDummyCircles(membership, true);
|
||||
|
||||
if(!reputation)
|
||||
mRep = new RsNxsSimpleDummyReputation(reMap, true);
|
||||
else
|
||||
{
|
||||
mRep = reputation;
|
||||
}
|
||||
|
||||
if(!circle)
|
||||
mCircles = new RsNxsSimpleDummyCircles();
|
||||
else
|
||||
{
|
||||
mCircles = circle;
|
||||
}
|
||||
|
||||
|
||||
mPgpUtils = new RsDummyPgpUtils();
|
||||
|
||||
// lets create some a group each for all peers
|
||||
DataMap::iterator mit = mDataServices.begin();
|
||||
@ -60,6 +73,12 @@ NxsGrpSync::NxsGrpSync()
|
||||
grp->metaData = meta;
|
||||
meta->mSubscribeFlags = GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED;
|
||||
|
||||
if(circle)
|
||||
{
|
||||
meta->mCircleType = GXS_CIRCLE_TYPE_EXTERNAL;
|
||||
meta->mCircleId.random();
|
||||
}
|
||||
|
||||
RsGxsGroupId grpId = grp->grpId;
|
||||
|
||||
RsGeneralDataService::GrpStoreMap gsp;
|
||||
@ -126,6 +145,11 @@ RsServiceInfo rs_nxs_test::NxsGrpSync::getServiceInfo() {
|
||||
return mServInfo;
|
||||
}
|
||||
|
||||
PgpAuxUtils* rs_nxs_test::NxsGrpSync::getDummyPgpUtils()
|
||||
{
|
||||
return mPgpUtils;
|
||||
}
|
||||
|
||||
const NxsGrpTestScenario::ExpectedMap& rs_nxs_test::NxsGrpSync::getExpectedMap() {
|
||||
return mExpectedResult;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ namespace rs_nxs_test
|
||||
{
|
||||
public:
|
||||
|
||||
NxsGrpSync();
|
||||
NxsGrpSync(RsGcxs* circle = NULL, RsGixsReputation* reputation = NULL);
|
||||
~NxsGrpSync();
|
||||
|
||||
void getPeers(std::list<RsPeerId>& peerIds);
|
||||
@ -27,6 +27,7 @@ namespace rs_nxs_test
|
||||
RsGixsReputation* getDummyReputations(const RsPeerId& peerId);
|
||||
uint16_t getServiceType();
|
||||
RsServiceInfo getServiceInfo();
|
||||
PgpAuxUtils* getDummyPgpUtils();
|
||||
|
||||
protected:
|
||||
|
||||
@ -42,6 +43,7 @@ namespace rs_nxs_test
|
||||
RsGixsReputation* mRep;
|
||||
RsGcxs* mCircles;
|
||||
RsServiceInfo mServInfo;
|
||||
PgpAuxUtils* mPgpUtils;
|
||||
|
||||
ExpectedMap mExpectedResult;
|
||||
|
||||
|
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* NxsGrpSyncDelayed.cpp
|
||||
*
|
||||
* Created on: 19 May 2014
|
||||
* Author: crispy
|
||||
*/
|
||||
|
||||
#include "nxsgrpsyncdelayed.h"
|
||||
#include "nxsdummyservices.h"
|
||||
|
||||
namespace rs_nxs_test {
|
||||
|
||||
NxsGrpSyncDelayed::NxsGrpSyncDelayed()
|
||||
: NxsGrpSync(new rs_nxs_test::RsNxsDelayedDummyCircles(4), NULL) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
NxsGrpSyncDelayed::~NxsGrpSyncDelayed() {
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
||||
} /* namespace rs_nxs_test */
|
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* NxsGrpSyncDelayed.h
|
||||
*
|
||||
* Created on: 19 May 2014
|
||||
* Author: crispy
|
||||
*/
|
||||
|
||||
#ifndef NXSGRPSYNCDELAYED_H_
|
||||
#define NXSGRPSYNCDELAYED_H_
|
||||
|
||||
#include "nxsgrpsync_test.h"
|
||||
|
||||
namespace rs_nxs_test {
|
||||
|
||||
class NxsGrpSyncDelayed : public NxsGrpSync {
|
||||
public:
|
||||
NxsGrpSyncDelayed();
|
||||
virtual ~NxsGrpSyncDelayed();
|
||||
};
|
||||
|
||||
} /* namespace rs_nxs_test */
|
||||
#endif /* NXSGRPSYNCDELAYED_H_ */
|
@ -35,7 +35,7 @@ bool NxsGrpTestScenario::checkTestPassed()
|
||||
RsGxsGroupId::std_vector result(expGrpIds.size()+grpIds.size());
|
||||
std::sort(grpIds.begin(), grpIds.end());
|
||||
std::sort(expGrpIds.begin(), expGrpIds.end());
|
||||
RsGxsGroupId::std_vector::iterator it = std::set_difference(grpIds.begin(), grpIds.end(),
|
||||
RsGxsGroupId::std_vector::iterator it = std::set_symmetric_difference(grpIds.begin(), grpIds.end(),
|
||||
expGrpIds.begin(), expGrpIds.end(), result.begin());
|
||||
|
||||
result.resize(it - result.begin());
|
||||
|
@ -17,7 +17,7 @@
|
||||
using namespace rs_nxs_test;
|
||||
|
||||
rs_nxs_test::NxsMsgSync::NxsMsgSync()
|
||||
{
|
||||
: mPgpUtils(NULL) {
|
||||
int numPeers = 2;
|
||||
|
||||
// create 2 peers
|
||||
@ -43,10 +43,9 @@ rs_nxs_test::NxsMsgSync::NxsMsgSync()
|
||||
}
|
||||
|
||||
RsNxsSimpleDummyReputation::RepMap reMap;
|
||||
std::list<RsNxsSimpleDummyCircles::Membership> membership;
|
||||
// now reputation service
|
||||
mRep = new RsNxsSimpleDummyReputation(reMap, true);
|
||||
mCircles = new RsNxsSimpleDummyCircles(membership, true);
|
||||
mCircles = new RsNxsSimpleDummyCircles();
|
||||
|
||||
// lets create 2 groups and all peers will have them
|
||||
int nGrps = 2;
|
||||
@ -146,6 +145,11 @@ RsServiceInfo rs_nxs_test::NxsMsgSync::getServiceInfo() {
|
||||
return mServInfo;
|
||||
}
|
||||
|
||||
PgpAuxUtils* rs_nxs_test::NxsMsgSync::getDummyPgpUtils()
|
||||
{
|
||||
return mPgpUtils;
|
||||
}
|
||||
|
||||
const NxsMsgTestScenario::ExpectedMap& rs_nxs_test::NxsMsgSync::getExpectedMap() {
|
||||
return mExpectedResult;
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ namespace rs_nxs_test {
|
||||
RsGixsReputation* getDummyReputations(const RsPeerId& peerId);
|
||||
uint16_t getServiceType();
|
||||
RsServiceInfo getServiceInfo();
|
||||
PgpAuxUtils* getDummyPgpUtils();
|
||||
|
||||
protected:
|
||||
|
||||
@ -39,6 +40,7 @@ namespace rs_nxs_test {
|
||||
RsGixsReputation* mRep;
|
||||
RsGcxs* mCircles;
|
||||
RsServiceInfo mServInfo;
|
||||
PgpAuxUtils* mPgpUtils;
|
||||
|
||||
NxsMsgTestScenario::ExpectedMap mExpectedResult;
|
||||
|
||||
|
@ -70,7 +70,9 @@ rs_nxs_test::NxsTestHub::NxsTestHub(NxsTestScenario::pointer testScenario)
|
||||
new NotifyWithPeerId(*cit, *this),
|
||||
mTestScenario->getServiceInfo(),
|
||||
mTestScenario->getDummyReputations(*cit),
|
||||
mTestScenario->getDummyCircles(*cit), NULL, true
|
||||
mTestScenario->getDummyCircles(*cit),
|
||||
mTestScenario->getDummyPgpUtils(),
|
||||
true
|
||||
)
|
||||
);
|
||||
|
||||
@ -137,8 +139,6 @@ void rs_nxs_test::NxsTestHub::EndTest()
|
||||
{
|
||||
mit->second->join();
|
||||
}
|
||||
|
||||
mTestScenario->cleanTestScenario();
|
||||
}
|
||||
|
||||
void rs_nxs_test::NxsTestHub::notifyNewMessages(const RsPeerId& pid,
|
||||
@ -194,6 +194,11 @@ bool rs_nxs_test::NxsTestHub::recvItem(RsRawItem* item, const RsPeerId& peerFrom
|
||||
return true;
|
||||
}
|
||||
|
||||
void rs_nxs_test::NxsTestHub::CleanUpTest()
|
||||
{
|
||||
mTestScenario->cleanTestScenario();
|
||||
}
|
||||
|
||||
void rs_nxs_test::NxsTestHub::tick()
|
||||
{
|
||||
// for each nxs instance pull out all items from each and then move to destination peer
|
||||
|
@ -74,6 +74,10 @@ namespace rs_nxs_test
|
||||
*/
|
||||
void EndTest();
|
||||
|
||||
/*!
|
||||
* Clean up test environment
|
||||
*/
|
||||
void CleanUpTest();
|
||||
/*!
|
||||
* @param messages messages are deleted after function returns
|
||||
*/
|
||||
|
@ -37,6 +37,7 @@ namespace rs_nxs_test
|
||||
virtual RsGixsReputation* getDummyReputations(const RsPeerId& peerId) = 0;
|
||||
virtual uint16_t getServiceType() = 0;
|
||||
virtual RsServiceInfo getServiceInfo() = 0;
|
||||
virtual PgpAuxUtils* getDummyPgpUtils() = 0;
|
||||
|
||||
virtual void cleanTestScenario() = 0;
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "nxsgrpsync_test.h"
|
||||
#include "nxsmsgsync_test.h"
|
||||
#include "nxstesthub.h"
|
||||
#include "nxsgrpsyncdelayed.h"
|
||||
|
||||
TEST(libretroshare_gxs, gxs_grp_sync)
|
||||
{
|
||||
@ -25,6 +26,25 @@ TEST(libretroshare_gxs, gxs_grp_sync)
|
||||
|
||||
ASSERT_TRUE(tHub.testsPassed());
|
||||
|
||||
tHub.CleanUpTest();
|
||||
}
|
||||
|
||||
TEST(libretroshare_gxs, gxs_grp_sync_delayed)
|
||||
{
|
||||
rs_nxs_test::NxsTestScenario::pointer gsync_test = rs_nxs_test::NxsTestScenario::pointer(
|
||||
new rs_nxs_test::NxsGrpSyncDelayed());
|
||||
rs_nxs_test::NxsTestHub tHub(gsync_test);
|
||||
tHub.StartTest();
|
||||
|
||||
// wait for ten seconds
|
||||
rs_nxs_test::NxsTestHub::Wait(20);
|
||||
|
||||
tHub.EndTest();
|
||||
|
||||
ASSERT_TRUE(tHub.testsPassed());
|
||||
|
||||
tHub.CleanUpTest();
|
||||
|
||||
}
|
||||
|
||||
TEST(libretroshare_gxs, gxs_msg_sync)
|
||||
@ -40,4 +60,12 @@ TEST(libretroshare_gxs, gxs_msg_sync)
|
||||
tHub.EndTest();
|
||||
|
||||
ASSERT_TRUE(tHub.testsPassed());
|
||||
|
||||
tHub.CleanUpTest();
|
||||
}
|
||||
|
||||
TEST(libretroshare_gxs, gxs_msg_sync_delayed)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user