diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 1e4d9321f..91bad36b9 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -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 ); - return true ; -#endif + _instance->ui->stackPages->setCurrentPage( _instance->gxsforumDialog ); + return true ; #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; diff --git a/retroshare-gui/src/gui/MainWindow.h b/retroshare-gui/src/gui/MainWindow.h index dc4bac8c1..cdf358ff7 100644 --- a/retroshare-gui/src/gui/MainWindow.h +++ b/retroshare-gui/src/gui/MainWindow.h @@ -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. */ diff --git a/retroshare-gui/src/gui/RetroShareLink.cpp b/retroshare-gui/src/gui/RetroShareLink.cpp index caeb63633..c2c72d669 100644 --- a/retroshare-gui/src/gui/RetroShareLink.cpp +++ b/retroshare-gui/src/gui/RetroShareLink.cpp @@ -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 #include #include -//#include +#include //#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(MainWindow::getPage(MainWindow::Forums)); + MainWindow::showWindow(MainWindow::Forums); + GxsForumsDialog *forumsDialog = dynamic_cast(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 diff --git a/retroshare-gui/src/gui/RetroShareLink.h b/retroshare-gui/src/gui/RetroShareLink.h index ef27740ac..8ff5112b0 100644 --- a/retroshare-gui/src/gui/RetroShareLink.h +++ b/retroshare-gui/src/gui/RetroShareLink.h @@ -66,7 +66,7 @@ class RetroShareLink TYPE_CERTIFICATE = 0x07, TYPE_EXTRAFILE = 0x08, TYPE_PRIVATE_CHAT = 0x09, - TYPE_PUBLIC_MSG = 0x0a + TYPE_PUBLIC_MSG = 0x0a }; public: @@ -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); @@ -99,13 +102,13 @@ class RetroShareLink const QString& SSLId() const { return _SSLid ; } const QString& GPGId() const { return _GPGid ; } const QString& localIPAndPort() const { return _loc_ip_port ; } - const QString& externalIPAndPort() const { return _ext_ip_port ; } - const QString& dyndns() const { return _dyndns_name ; } - const QString& location() const { return _location ; } - const QString& radix() const { return _radix ; } - time_t timeStamp() const { return _time_stamp ; } - const QString& encryptedPrivateChatInfo() const { return _encrypted_chat_info ; } - QString title() const; + const QString& externalIPAndPort() const { return _ext_ip_port ; } + const QString& dyndns() const { return _dyndns_name ; } + const QString& location() const { return _location ; } + const QString& radix() const { return _radix ; } + time_t timeStamp() const { return _time_stamp ; } + const QString& encryptedPrivateChatInfo() const { return _encrypted_chat_info ; } + QString title() const; unsigned int subType() const { return _subType; } void setSubType(unsigned int subType) { _subType = subType; } @@ -157,13 +160,13 @@ class RetroShareLink QString _GPGBase64String ; // GPG Cert QString _GPGBase64CheckSum ; // GPG Cert QString _location ; // location - QString _ext_ip_port ; - QString _loc_ip_port ; - QString _dyndns_name ; - QString _radix ; - QString _encrypted_chat_info ; // encrypted data string for the recipient of a chat invite - time_t _time_stamp ; // time stamp at which the link will expire. - + QString _ext_ip_port ; + QString _loc_ip_port ; + QString _dyndns_name ; + QString _radix ; + QString _encrypted_chat_info ; // encrypted data string for the recipient of a chat invite + time_t _time_stamp ; // time stamp at which the link will expire. + unsigned int _subType; // for general use as sub type for _type (RSLINK_SUBTYPE_...) }; diff --git a/retroshare-gui/src/gui/common/GroupTreeWidget.cpp b/retroshare-gui/src/gui/common/GroupTreeWidget.cpp index 4ee468c27..06c8e58fc 100644 --- a/retroshare-gui/src/gui/common/GroupTreeWidget.cpp +++ b/retroshare-gui/src/gui/common/GroupTreeWidget.cpp @@ -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); diff --git a/retroshare-gui/src/gui/common/GroupTreeWidget.h b/retroshare-gui/src/gui/common/GroupTreeWidget.h index dd7326ac3..11dccbba2 100644 --- a/retroshare-gui/src/gui/common/GroupTreeWidget.h +++ b/retroshare-gui/src/gui/common/GroupTreeWidget.h @@ -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); diff --git a/retroshare-gui/src/gui/gxs/GxsFeedItem.cpp b/retroshare-gui/src/gui/gxs/GxsFeedItem.cpp index 12f95d439..60d5501d9 100644 --- a/retroshare-gui/src/gui/gxs/GxsFeedItem.cpp +++ b/retroshare-gui/src/gui/gxs/GxsFeedItem.cpp @@ -26,6 +26,7 @@ #include "gui/gxs/RsGxsUpdateBroadcastBase.h" #include +#include /** * #define DEBUG_ITEM 1 diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp index 3d971728c..465461154 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp @@ -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, "")) { - QList urls; - urls.push_back(link); - RSLinkClipboard::copyLinks(urls); - } - } -#endif + RetroShareLink link; - QMessageBox::warning(this, "RetroShare", "ToDo"); + QString name; + if(!getCurrentGroupName(name)) return; + + if (link.createGxsLink(mGroupId, RsGxsMessageId(), name.toStdString(), "", getLinkType())) { + QList urls; + urls.push_back(link); + RSLinkClipboard::copyLinks(urls); + } } + + +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,44 +452,44 @@ 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.empty()) { - return true; - } - -//#TODO -// if (mThreadLoading) { -// mThreadLoad.FocusMsgId = msgId; + } +// if (mGroupId == groupId) { +// return false; +// } +// +// if (msgId.isNull()) { // return true; // } - /* Search exisiting item */ -// QTreeWidgetItemIterator itemIterator(ui->threadTreeWidget); -// 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(); -// return true; -// } -// } +//#TODO +// if (mThreadLoading) { +// mThreadLoad.FocusMsgId = msgId; +// return true; +// } - return false; + /* Search exisiting item */ +// QTreeWidgetItemIterator itemIterator(ui->threadTreeWidget); +// 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(); +// return true; +// } +// } + + return true; } GxsMessageFrameWidget *GxsGroupFrameDialog::messageWidget(const RsGxsGroupId &groupId, bool ownTab) diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h index 18c3cf3e3..392dae3d5 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h @@ -24,6 +24,7 @@ #include "gui/gxs/RsGxsUpdateBroadcastPage.h" #include "RsAutoUpdatePage.h" +#include "gui/RetroShareLink.h" #include @@ -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; diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.h b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.h index a34d12844..1d3cb80de 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.h @@ -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(); diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp index 6367000c2..87da73478 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.cpp @@ -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) { diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.h b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.h index 5eddd0c48..4d9d01962 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.h +++ b/retroshare-gui/src/gui/gxsforums/GxsForumsDialog.h @@ -40,6 +40,10 @@ public: // virtual UserNotify *getUserNotify(QObject *parent); +protected: + + RetroShareLink::enumType getLinkType(); + private slots: void settingsChanged(); diff --git a/tests/unittests/libretroshare/gxs/nxs_test/nxsdummyservices.cc b/tests/unittests/libretroshare/gxs/nxs_test/nxsdummyservices.cc index d27417c83..ec772a4a1 100644 --- a/tests/unittests/libretroshare/gxs/nxs_test/nxsdummyservices.cc +++ b/tests/unittests/libretroshare/gxs/nxs_test/nxsdummyservices.cc @@ -10,8 +10,7 @@ -rs_nxs_test::RsNxsSimpleDummyCircles::RsNxsSimpleDummyCircles( - std::list& membership, bool cached) { +rs_nxs_test::RsNxsSimpleDummyCircles::RsNxsSimpleDummyCircles() { } bool rs_nxs_test::RsNxsSimpleDummyCircles::isLoaded( @@ -101,14 +100,44 @@ bool rs_nxs_test::RsNxsDelayedDummyCircles::allowed( if(mMembershipCallCount[circleId] >= mCountBeforePresent) { mMembershipCallCount[circleId]++; - return true; + return true; } else { mMembershipCallCount[circleId]++; - return false; + return false; } } +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& 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; +} + + diff --git a/tests/unittests/libretroshare/gxs/nxs_test/nxsdummyservices.h b/tests/unittests/libretroshare/gxs/nxs_test/nxsdummyservices.h index eec3f0a1a..38f9f599b 100644 --- a/tests/unittests/libretroshare/gxs/nxs_test/nxsdummyservices.h +++ b/tests/unittests/libretroshare/gxs/nxs_test/nxsdummyservices.h @@ -14,6 +14,7 @@ #include #include #include +#include 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 > Membership; - /*! * * @param membership * @param cached */ - RsNxsSimpleDummyCircles(std::list& 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 &friendlist); - private: - - std::list 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 &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; + }; } diff --git a/tests/unittests/libretroshare/gxs/nxs_test/nxsgrpsync_test.cc b/tests/unittests/libretroshare/gxs/nxs_test/nxsgrpsync_test.cc index b01f715f0..1e539d7a4 100644 --- a/tests/unittests/libretroshare/gxs/nxs_test/nxsgrpsync_test.cc +++ b/tests/unittests/libretroshare/gxs/nxs_test/nxsgrpsync_test.cc @@ -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 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,7 +73,13 @@ NxsGrpSync::NxsGrpSync() grp->metaData = meta; meta->mSubscribeFlags = GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED; - RsGxsGroupId grpId = grp->grpId; + if(circle) + { + meta->mCircleType = GXS_CIRCLE_TYPE_EXTERNAL; + meta->mCircleId.random(); + } + + RsGxsGroupId grpId = grp->grpId; RsGeneralDataService::GrpStoreMap gsp; gsp.insert(std::make_pair(grp, meta)); @@ -69,8 +88,8 @@ NxsGrpSync::NxsGrpSync() // the expected result is that each peer has the group of the others it = mPeerIds.begin(); for(; it != mPeerIds.end(); it++) - { - mExpectedResult[*it].push_back(grpId); + { + mExpectedResult[*it].push_back(grpId); } } @@ -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; } diff --git a/tests/unittests/libretroshare/gxs/nxs_test/nxsgrpsync_test.h b/tests/unittests/libretroshare/gxs/nxs_test/nxsgrpsync_test.h index c23a0ece7..a0916ae08 100644 --- a/tests/unittests/libretroshare/gxs/nxs_test/nxsgrpsync_test.h +++ b/tests/unittests/libretroshare/gxs/nxs_test/nxsgrpsync_test.h @@ -17,7 +17,7 @@ namespace rs_nxs_test { public: - NxsGrpSync(); + NxsGrpSync(RsGcxs* circle = NULL, RsGixsReputation* reputation = NULL); ~NxsGrpSync(); void getPeers(std::list& 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; diff --git a/tests/unittests/libretroshare/gxs/nxs_test/nxsgrpsyncdelayed.cc b/tests/unittests/libretroshare/gxs/nxs_test/nxsgrpsyncdelayed.cc new file mode 100644 index 000000000..b9e7dcd28 --- /dev/null +++ b/tests/unittests/libretroshare/gxs/nxs_test/nxsgrpsyncdelayed.cc @@ -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 */ diff --git a/tests/unittests/libretroshare/gxs/nxs_test/nxsgrpsyncdelayed.h b/tests/unittests/libretroshare/gxs/nxs_test/nxsgrpsyncdelayed.h new file mode 100644 index 000000000..2124d6c7e --- /dev/null +++ b/tests/unittests/libretroshare/gxs/nxs_test/nxsgrpsyncdelayed.h @@ -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_ */ diff --git a/tests/unittests/libretroshare/gxs/nxs_test/nxsgrptestscenario.cc b/tests/unittests/libretroshare/gxs/nxs_test/nxsgrptestscenario.cc index 8919b2a94..2bb241dd5 100644 --- a/tests/unittests/libretroshare/gxs/nxs_test/nxsgrptestscenario.cc +++ b/tests/unittests/libretroshare/gxs/nxs_test/nxsgrptestscenario.cc @@ -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()); diff --git a/tests/unittests/libretroshare/gxs/nxs_test/nxsmsgsync_test.cc b/tests/unittests/libretroshare/gxs/nxs_test/nxsmsgsync_test.cc index d9cd602ae..cb38f9a7a 100644 --- a/tests/unittests/libretroshare/gxs/nxs_test/nxsmsgsync_test.cc +++ b/tests/unittests/libretroshare/gxs/nxs_test/nxsmsgsync_test.cc @@ -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 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; } diff --git a/tests/unittests/libretroshare/gxs/nxs_test/nxsmsgsync_test.h b/tests/unittests/libretroshare/gxs/nxs_test/nxsmsgsync_test.h index 459074fc2..f81af79e9 100644 --- a/tests/unittests/libretroshare/gxs/nxs_test/nxsmsgsync_test.h +++ b/tests/unittests/libretroshare/gxs/nxs_test/nxsmsgsync_test.h @@ -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; diff --git a/tests/unittests/libretroshare/gxs/nxs_test/nxstesthub.cc b/tests/unittests/libretroshare/gxs/nxs_test/nxstesthub.cc index deed48a19..4b9329eb0 100644 --- a/tests/unittests/libretroshare/gxs/nxs_test/nxstesthub.cc +++ b/tests/unittests/libretroshare/gxs/nxs_test/nxstesthub.cc @@ -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 diff --git a/tests/unittests/libretroshare/gxs/nxs_test/nxstesthub.h b/tests/unittests/libretroshare/gxs/nxs_test/nxstesthub.h index 3c459554f..e4da2abd4 100644 --- a/tests/unittests/libretroshare/gxs/nxs_test/nxstesthub.h +++ b/tests/unittests/libretroshare/gxs/nxs_test/nxstesthub.h @@ -74,6 +74,10 @@ namespace rs_nxs_test */ void EndTest(); + /*! + * Clean up test environment + */ + void CleanUpTest(); /*! * @param messages messages are deleted after function returns */ diff --git a/tests/unittests/libretroshare/gxs/nxs_test/nxstestscenario.h b/tests/unittests/libretroshare/gxs/nxs_test/nxstestscenario.h index 4d01c2d7d..310427ec5 100644 --- a/tests/unittests/libretroshare/gxs/nxs_test/nxstestscenario.h +++ b/tests/unittests/libretroshare/gxs/nxs_test/nxstestscenario.h @@ -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; diff --git a/tests/unittests/libretroshare/gxs/nxs_test/rsgxsnetservice_test.cc b/tests/unittests/libretroshare/gxs/nxs_test/rsgxsnetservice_test.cc index bb173f357..f0dcbe9f1 100644 --- a/tests/unittests/libretroshare/gxs/nxs_test/rsgxsnetservice_test.cc +++ b/tests/unittests/libretroshare/gxs/nxs_test/rsgxsnetservice_test.cc @@ -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) +{ + +} +