mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-04 09:05:34 -05: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:
|
case Messages:
|
||||||
_instance->ui->stackPages->setCurrentPage( _instance->messagesDialog );
|
_instance->ui->stackPages->setCurrentPage( _instance->messagesDialog );
|
||||||
break;
|
break;
|
||||||
#if 0
|
|
||||||
case Channels:
|
case Channels:
|
||||||
_instance->ui->stackPages->setCurrentPage( _instance->channelFeed );
|
_instance->ui->stackPages->setCurrentPage( _instance->gxschannelDialog );
|
||||||
return true ;
|
return true ;
|
||||||
case Forums:
|
case Forums:
|
||||||
_instance->ui->stackPages->setCurrentPage( _instance->forumsDialog );
|
_instance->ui->stackPages->setCurrentPage( _instance->gxsforumDialog );
|
||||||
return true ;
|
return true ;
|
||||||
#endif
|
|
||||||
#ifdef BLOGS
|
#ifdef BLOGS
|
||||||
case Blogs:
|
case Blogs:
|
||||||
Page = _instance->blogsFeed;
|
Page = _instance->blogsFeed;
|
||||||
@ -1029,12 +1027,10 @@ void SetForegroundWindowInternal(HWND hWnd)
|
|||||||
case Links:
|
case Links:
|
||||||
return _instance->linksDialog;
|
return _instance->linksDialog;
|
||||||
#endif
|
#endif
|
||||||
#if 0
|
|
||||||
case Channels:
|
case Channels:
|
||||||
return _instance->channelFeed;
|
return _instance->gxschannelDialog;
|
||||||
case Forums:
|
case Forums:
|
||||||
return _instance->forumsDialog;
|
return _instance->gxsforumDialog;
|
||||||
#endif
|
|
||||||
#ifdef BLOGS
|
#ifdef BLOGS
|
||||||
case Blogs:
|
case Blogs:
|
||||||
return _instance->blogsFeed;
|
return _instance->blogsFeed;
|
||||||
|
@ -87,8 +87,8 @@ public:
|
|||||||
Transfers = 3, /** Transfers page. */
|
Transfers = 3, /** Transfers page. */
|
||||||
SharedDirectories = 4, /** Shared Directories page. */
|
SharedDirectories = 4, /** Shared Directories page. */
|
||||||
Messages = 5, /** Messages page. */
|
Messages = 5, /** Messages page. */
|
||||||
// Channels = 6, /** Channels page. */
|
Channels = 6, /** Channels page. */
|
||||||
// Forums = 7, /** Forums page. */
|
Forums = 7, /** Forums page. */
|
||||||
Search = 8, /** Search page. */
|
Search = 8, /** Search page. */
|
||||||
#ifdef BLOGS
|
#ifdef BLOGS
|
||||||
Blogs = 9, /** Blogs page. */
|
Blogs = 9, /** Blogs page. */
|
||||||
|
@ -36,8 +36,7 @@
|
|||||||
|
|
||||||
#include "RetroShareLink.h"
|
#include "RetroShareLink.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
//#include "ForumsDialog.h"
|
#include "gui/gxsforums/GxsForumsDialog.h"
|
||||||
//#include "ChannelFeed.h"
|
|
||||||
#include "SearchDialog.h"
|
#include "SearchDialog.h"
|
||||||
#include "msgs/MessageComposer.h"
|
#include "msgs/MessageComposer.h"
|
||||||
#include "util/misc.h"
|
#include "util/misc.h"
|
||||||
@ -51,7 +50,7 @@
|
|||||||
#include <retroshare/rsmsgs.h>
|
#include <retroshare/rsmsgs.h>
|
||||||
#include <retroshare/rspeers.h>
|
#include <retroshare/rspeers.h>
|
||||||
#include <retroshare/rsidentity.h>
|
#include <retroshare/rsidentity.h>
|
||||||
//#include <retroshare/rschannels.h>
|
#include <retroshare/rsgxsforums.h>
|
||||||
|
|
||||||
//#define DEBUG_RSLINK 1
|
//#define DEBUG_RSLINK 1
|
||||||
|
|
||||||
@ -543,6 +542,33 @@ bool RetroShareLink::createChannel(const std::string &id, const std::string &msg
|
|||||||
return valid();
|
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)
|
bool RetroShareLink::createSearch(const QString& keywords)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
@ -1402,38 +1428,21 @@ static void processList(const QStringList &list, const QString &textSingular, co
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
case TYPE_FORUM:
|
case TYPE_FORUM:
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_RSLINK
|
#ifdef DEBUG_RSLINK
|
||||||
std::cerr << " RetroShareLink::process ForumRequest : name : " << link.name().toStdString() << ". id : " << link.hash().toStdString() << ". msgId : " << link.msgId().toStdString() << std::endl;
|
std::cerr << " RetroShareLink::process ForumRequest : name : " << link.name().toStdString() << ". id : " << link.hash().toStdString() << ". msgId : " << link.msgId().toStdString() << std::endl;
|
||||||
#endif
|
#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);
|
MainWindow::showWindow(MainWindow::Forums);
|
||||||
ForumsDialog *forumsDialog = dynamic_cast<ForumsDialog*>(MainWindow::getPage(MainWindow::Forums));
|
GxsForumsDialog *forumsDialog = dynamic_cast<GxsForumsDialog*>(MainWindow::getPage(MainWindow::Forums));
|
||||||
if (!forumsDialog) {
|
if (!forumsDialog) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (forumsDialog->navigate(fi.forumId, msg.msgId)) {
|
if (forumsDialog->navigate(RsGxsGroupId(link.id().toStdString()), RsGxsMessageId(link.msgId().toStdString()))) {
|
||||||
if (link.msgId().isEmpty()) {
|
if (link.msgId().isEmpty()) {
|
||||||
forumFound.append(link.name());
|
forumFound.append(link.name());
|
||||||
} else {
|
} else {
|
||||||
@ -1448,7 +1457,7 @@ static void processList(const QStringList &list, const QString &textSingular, co
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
case TYPE_CHANNEL:
|
case TYPE_CHANNEL:
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_RSLINK
|
#ifdef DEBUG_RSLINK
|
||||||
|
@ -79,6 +79,9 @@ class RetroShareLink
|
|||||||
bool createPerson(const RsPgpId &id);
|
bool createPerson(const RsPgpId &id);
|
||||||
bool createForum(const std::string& id, const std::string& msgId);
|
bool createForum(const std::string& id, const std::string& msgId);
|
||||||
bool createChannel(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 createSearch(const QString& keywords);
|
||||||
bool createMessage(const RsPeerId &peerId, const QString& subject);
|
bool createMessage(const RsPeerId &peerId, const QString& subject);
|
||||||
bool createMessage(const RsGxsId &peerId, const QString& subject);
|
bool createMessage(const RsGxsId &peerId, const QString& subject);
|
||||||
|
@ -457,6 +457,21 @@ RSTreeWidget *GroupTreeWidget::treeWidget()
|
|||||||
return ui->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)
|
int GroupTreeWidget::subscribeFlags(const QString &id)
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *item = getItemFromId(id);
|
QTreeWidgetItem *item = getItemFromId(id);
|
||||||
|
@ -98,6 +98,7 @@ public:
|
|||||||
|
|
||||||
void setTextColorCategory(QColor color) { mTextColor[GROUPTREEWIDGET_COLOR_CATEGORY] = color; }
|
void setTextColorCategory(QColor color) { mTextColor[GROUPTREEWIDGET_COLOR_CATEGORY] = color; }
|
||||||
void setTextColorPrivateKey(QColor color) { mTextColor[GROUPTREEWIDGET_COLOR_PRIVATEKEY] = color; }
|
void setTextColorPrivateKey(QColor color) { mTextColor[GROUPTREEWIDGET_COLOR_PRIVATEKEY] = color; }
|
||||||
|
bool getGroupName(QString id, QTreeWidgetItem* item, QString& name);
|
||||||
|
|
||||||
int subscribeFlags(const QString &id);
|
int subscribeFlags(const QString &id);
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "gui/gxs/RsGxsUpdateBroadcastBase.h"
|
#include "gui/gxs/RsGxsUpdateBroadcastBase.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* #define DEBUG_ITEM 1
|
* #define DEBUG_ITEM 1
|
||||||
|
@ -351,25 +351,48 @@ void GxsGroupFrameDialog::copyGroupLink()
|
|||||||
return;
|
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;
|
RetroShareLink link;
|
||||||
if (link.createForum(fi.forumId, "")) {
|
|
||||||
|
QString name;
|
||||||
|
if(!getCurrentGroupName(name)) return;
|
||||||
|
|
||||||
|
if (link.createGxsLink(mGroupId, RsGxsMessageId(), name.toStdString(), "", getLinkType())) {
|
||||||
QList<RetroShareLink> urls;
|
QList<RetroShareLink> urls;
|
||||||
urls.push_back(link);
|
urls.push_back(link);
|
||||||
RSLinkClipboard::copyLinks(urls);
|
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()
|
void GxsGroupFrameDialog::markMsgAsRead()
|
||||||
{
|
{
|
||||||
GxsMessageFrameWidget *msgWidget = messageWidget(mGroupId, false);
|
GxsMessageFrameWidget *msgWidget = messageWidget(mGroupId, false);
|
||||||
@ -429,23 +452,23 @@ void GxsGroupFrameDialog::loadComment(const RsGxsGroupId &grpId, const RsGxsMess
|
|||||||
ui->messageTabWidget->setCurrentWidget(commentDialog);
|
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()) {
|
if (groupId.isNull()) {
|
||||||
return false;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
// if (mGroupId == groupId) {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (msgId.isNull()) {
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
|
||||||
if (mGroupId != groupId) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msgId.empty()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//#TODO
|
//#TODO
|
||||||
// if (mThreadLoading) {
|
// if (mThreadLoading) {
|
||||||
@ -458,7 +481,7 @@ bool GxsGroupFrameDialog::navigate(const RsGxsGroupId groupId, const std::string
|
|||||||
// QTreeWidgetItem *item = NULL;
|
// QTreeWidgetItem *item = NULL;
|
||||||
// while ((item = *itemIterator) != NULL) {
|
// while ((item = *itemIterator) != NULL) {
|
||||||
// itemIterator++;
|
// itemIterator++;
|
||||||
|
//
|
||||||
// if (item->data(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID).toString().toStdString() == msgId) {
|
// if (item->data(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID).toString().toStdString() == msgId) {
|
||||||
// ui->threadTreeWidget->setCurrentItem(item);
|
// ui->threadTreeWidget->setCurrentItem(item);
|
||||||
// ui->threadTreeWidget->setFocus();
|
// 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)
|
GxsMessageFrameWidget *GxsGroupFrameDialog::messageWidget(const RsGxsGroupId &groupId, bool ownTab)
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include "gui/gxs/RsGxsUpdateBroadcastPage.h"
|
#include "gui/gxs/RsGxsUpdateBroadcastPage.h"
|
||||||
#include "RsAutoUpdatePage.h"
|
#include "RsAutoUpdatePage.h"
|
||||||
|
#include "gui/RetroShareLink.h"
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
@ -71,7 +72,7 @@ public:
|
|||||||
GxsGroupFrameDialog(RsGxsIfaceHelper *ifaceImpl, QWidget *parent = 0);
|
GxsGroupFrameDialog(RsGxsIfaceHelper *ifaceImpl, QWidget *parent = 0);
|
||||||
~GxsGroupFrameDialog();
|
~GxsGroupFrameDialog();
|
||||||
|
|
||||||
bool navigate(const RsGxsGroupId groupId, const std::string& msgId);
|
bool navigate(const RsGxsGroupId groupId, const RsGxsMessageId& msgId);
|
||||||
|
|
||||||
// Callback for all Loads.
|
// Callback for all Loads.
|
||||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||||
@ -81,8 +82,10 @@ protected:
|
|||||||
virtual void updateDisplay(bool complete);
|
virtual void updateDisplay(bool complete);
|
||||||
|
|
||||||
RsGxsGroupId groupId() { return mGroupId; }
|
RsGxsGroupId groupId() { return mGroupId; }
|
||||||
|
|
||||||
void setSingleTab(bool singleTab);
|
void setSingleTab(bool singleTab);
|
||||||
|
bool getCurrentGroupName(QString& name);
|
||||||
|
virtual RetroShareLink::enumType getLinkType() = 0;
|
||||||
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void todo();
|
void todo();
|
||||||
@ -119,6 +122,7 @@ private:
|
|||||||
virtual QString text(TextType type) = 0;
|
virtual QString text(TextType type) = 0;
|
||||||
virtual QString icon(IconType type) = 0;
|
virtual QString icon(IconType type) = 0;
|
||||||
virtual QString settingsGroupName() = 0;
|
virtual QString settingsGroupName() = 0;
|
||||||
|
|
||||||
virtual GxsGroupDialog *createNewGroupDialog(TokenQueue *tokenQueue) = 0;
|
virtual GxsGroupDialog *createNewGroupDialog(TokenQueue *tokenQueue) = 0;
|
||||||
virtual GxsGroupDialog *createGroupDialog(TokenQueue *tokenQueue, RsTokenService *tokenService, GxsGroupDialog::Mode mode, RsGxsGroupId groupId) = 0;
|
virtual GxsGroupDialog *createGroupDialog(TokenQueue *tokenQueue, RsTokenService *tokenService, GxsGroupDialog::Mode mode, RsGxsGroupId groupId) = 0;
|
||||||
virtual int shareKeyType() = 0;
|
virtual int shareKeyType() = 0;
|
||||||
|
@ -41,7 +41,8 @@ public:
|
|||||||
virtual QString helpText() const { return ""; } //MainPage
|
virtual QString helpText() const { return ""; } //MainPage
|
||||||
|
|
||||||
// virtual UserNotify *getUserNotify(QObject *parent);
|
// virtual UserNotify *getUserNotify(QObject *parent);
|
||||||
|
protected:
|
||||||
|
RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_CHANNEL; }
|
||||||
private slots:
|
private slots:
|
||||||
void settingsChanged();
|
void settingsChanged();
|
||||||
void toggleAutoDownload();
|
void toggleAutoDownload();
|
||||||
|
@ -80,6 +80,11 @@ QString GxsForumsDialog::text(TextType type)
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RetroShareLink::enumType GxsForumsDialog::getLinkType()
|
||||||
|
{
|
||||||
|
return RetroShareLink::TYPE_FORUM;
|
||||||
|
}
|
||||||
|
|
||||||
QString GxsForumsDialog::icon(IconType type)
|
QString GxsForumsDialog::icon(IconType type)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -40,6 +40,10 @@ public:
|
|||||||
|
|
||||||
// virtual UserNotify *getUserNotify(QObject *parent);
|
// virtual UserNotify *getUserNotify(QObject *parent);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
RetroShareLink::enumType getLinkType();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void settingsChanged();
|
void settingsChanged();
|
||||||
|
|
||||||
|
@ -10,8 +10,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
rs_nxs_test::RsNxsSimpleDummyCircles::RsNxsSimpleDummyCircles(
|
rs_nxs_test::RsNxsSimpleDummyCircles::RsNxsSimpleDummyCircles() {
|
||||||
std::list<Membership>& membership, bool cached) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool rs_nxs_test::RsNxsSimpleDummyCircles::isLoaded(
|
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/rsgixs.h>
|
||||||
#include <gxs/rsgxsnetutils.h>
|
#include <gxs/rsgxsnetutils.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <pgp/pgpauxutils.h>
|
||||||
|
|
||||||
|
|
||||||
namespace rs_nxs_test
|
namespace rs_nxs_test
|
||||||
@ -21,23 +22,18 @@ namespace rs_nxs_test
|
|||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* This dummy circles implementation
|
* This is a dummy circles implementation
|
||||||
* allow instantiation with simple membership
|
|
||||||
* list for a given circle
|
|
||||||
*/
|
*/
|
||||||
class RsNxsSimpleDummyCircles : public RsGcxs
|
class RsNxsSimpleDummyCircles : public RsGcxs
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
typedef std::map<RsGxsCircleId, std::list<RsPgpId> > Membership;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
*
|
*
|
||||||
* @param membership
|
* @param membership
|
||||||
* @param cached
|
* @param cached
|
||||||
*/
|
*/
|
||||||
RsNxsSimpleDummyCircles(std::list<Membership>& membership, bool cached);
|
RsNxsSimpleDummyCircles();
|
||||||
|
|
||||||
/* GXS Interface - for working out who can receive */
|
/* GXS Interface - for working out who can receive */
|
||||||
bool isLoaded(const RsGxsCircleId &circleId);
|
bool isLoaded(const RsGxsCircleId &circleId);
|
||||||
@ -47,9 +43,6 @@ namespace rs_nxs_test
|
|||||||
int canReceive(const RsGxsCircleId &circleId, const RsPgpId &id);
|
int canReceive(const RsGxsCircleId &circleId, const RsPgpId &id);
|
||||||
bool recipients(const RsGxsCircleId &circleId, std::list<RsPgpId> &friendlist);
|
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;
|
int numPeers = 2;
|
||||||
@ -42,11 +42,24 @@ NxsGrpSync::NxsGrpSync()
|
|||||||
}
|
}
|
||||||
|
|
||||||
RsNxsSimpleDummyReputation::RepMap reMap;
|
RsNxsSimpleDummyReputation::RepMap reMap;
|
||||||
std::list<RsNxsSimpleDummyCircles::Membership> membership;
|
|
||||||
// now reputation service
|
// 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
|
// lets create some a group each for all peers
|
||||||
DataMap::iterator mit = mDataServices.begin();
|
DataMap::iterator mit = mDataServices.begin();
|
||||||
@ -60,6 +73,12 @@ NxsGrpSync::NxsGrpSync()
|
|||||||
grp->metaData = meta;
|
grp->metaData = meta;
|
||||||
meta->mSubscribeFlags = GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED;
|
meta->mSubscribeFlags = GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED;
|
||||||
|
|
||||||
|
if(circle)
|
||||||
|
{
|
||||||
|
meta->mCircleType = GXS_CIRCLE_TYPE_EXTERNAL;
|
||||||
|
meta->mCircleId.random();
|
||||||
|
}
|
||||||
|
|
||||||
RsGxsGroupId grpId = grp->grpId;
|
RsGxsGroupId grpId = grp->grpId;
|
||||||
|
|
||||||
RsGeneralDataService::GrpStoreMap gsp;
|
RsGeneralDataService::GrpStoreMap gsp;
|
||||||
@ -126,6 +145,11 @@ RsServiceInfo rs_nxs_test::NxsGrpSync::getServiceInfo() {
|
|||||||
return mServInfo;
|
return mServInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PgpAuxUtils* rs_nxs_test::NxsGrpSync::getDummyPgpUtils()
|
||||||
|
{
|
||||||
|
return mPgpUtils;
|
||||||
|
}
|
||||||
|
|
||||||
const NxsGrpTestScenario::ExpectedMap& rs_nxs_test::NxsGrpSync::getExpectedMap() {
|
const NxsGrpTestScenario::ExpectedMap& rs_nxs_test::NxsGrpSync::getExpectedMap() {
|
||||||
return mExpectedResult;
|
return mExpectedResult;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ namespace rs_nxs_test
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
NxsGrpSync();
|
NxsGrpSync(RsGcxs* circle = NULL, RsGixsReputation* reputation = NULL);
|
||||||
~NxsGrpSync();
|
~NxsGrpSync();
|
||||||
|
|
||||||
void getPeers(std::list<RsPeerId>& peerIds);
|
void getPeers(std::list<RsPeerId>& peerIds);
|
||||||
@ -27,6 +27,7 @@ namespace rs_nxs_test
|
|||||||
RsGixsReputation* getDummyReputations(const RsPeerId& peerId);
|
RsGixsReputation* getDummyReputations(const RsPeerId& peerId);
|
||||||
uint16_t getServiceType();
|
uint16_t getServiceType();
|
||||||
RsServiceInfo getServiceInfo();
|
RsServiceInfo getServiceInfo();
|
||||||
|
PgpAuxUtils* getDummyPgpUtils();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@ -42,6 +43,7 @@ namespace rs_nxs_test
|
|||||||
RsGixsReputation* mRep;
|
RsGixsReputation* mRep;
|
||||||
RsGcxs* mCircles;
|
RsGcxs* mCircles;
|
||||||
RsServiceInfo mServInfo;
|
RsServiceInfo mServInfo;
|
||||||
|
PgpAuxUtils* mPgpUtils;
|
||||||
|
|
||||||
ExpectedMap mExpectedResult;
|
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());
|
RsGxsGroupId::std_vector result(expGrpIds.size()+grpIds.size());
|
||||||
std::sort(grpIds.begin(), grpIds.end());
|
std::sort(grpIds.begin(), grpIds.end());
|
||||||
std::sort(expGrpIds.begin(), expGrpIds.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());
|
expGrpIds.begin(), expGrpIds.end(), result.begin());
|
||||||
|
|
||||||
result.resize(it - result.begin());
|
result.resize(it - result.begin());
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
using namespace rs_nxs_test;
|
using namespace rs_nxs_test;
|
||||||
|
|
||||||
rs_nxs_test::NxsMsgSync::NxsMsgSync()
|
rs_nxs_test::NxsMsgSync::NxsMsgSync()
|
||||||
{
|
: mPgpUtils(NULL) {
|
||||||
int numPeers = 2;
|
int numPeers = 2;
|
||||||
|
|
||||||
// create 2 peers
|
// create 2 peers
|
||||||
@ -43,10 +43,9 @@ rs_nxs_test::NxsMsgSync::NxsMsgSync()
|
|||||||
}
|
}
|
||||||
|
|
||||||
RsNxsSimpleDummyReputation::RepMap reMap;
|
RsNxsSimpleDummyReputation::RepMap reMap;
|
||||||
std::list<RsNxsSimpleDummyCircles::Membership> membership;
|
|
||||||
// now reputation service
|
// now reputation service
|
||||||
mRep = new RsNxsSimpleDummyReputation(reMap, true);
|
mRep = new RsNxsSimpleDummyReputation(reMap, true);
|
||||||
mCircles = new RsNxsSimpleDummyCircles(membership, true);
|
mCircles = new RsNxsSimpleDummyCircles();
|
||||||
|
|
||||||
// lets create 2 groups and all peers will have them
|
// lets create 2 groups and all peers will have them
|
||||||
int nGrps = 2;
|
int nGrps = 2;
|
||||||
@ -146,6 +145,11 @@ RsServiceInfo rs_nxs_test::NxsMsgSync::getServiceInfo() {
|
|||||||
return mServInfo;
|
return mServInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PgpAuxUtils* rs_nxs_test::NxsMsgSync::getDummyPgpUtils()
|
||||||
|
{
|
||||||
|
return mPgpUtils;
|
||||||
|
}
|
||||||
|
|
||||||
const NxsMsgTestScenario::ExpectedMap& rs_nxs_test::NxsMsgSync::getExpectedMap() {
|
const NxsMsgTestScenario::ExpectedMap& rs_nxs_test::NxsMsgSync::getExpectedMap() {
|
||||||
return mExpectedResult;
|
return mExpectedResult;
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ namespace rs_nxs_test {
|
|||||||
RsGixsReputation* getDummyReputations(const RsPeerId& peerId);
|
RsGixsReputation* getDummyReputations(const RsPeerId& peerId);
|
||||||
uint16_t getServiceType();
|
uint16_t getServiceType();
|
||||||
RsServiceInfo getServiceInfo();
|
RsServiceInfo getServiceInfo();
|
||||||
|
PgpAuxUtils* getDummyPgpUtils();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@ -39,6 +40,7 @@ namespace rs_nxs_test {
|
|||||||
RsGixsReputation* mRep;
|
RsGixsReputation* mRep;
|
||||||
RsGcxs* mCircles;
|
RsGcxs* mCircles;
|
||||||
RsServiceInfo mServInfo;
|
RsServiceInfo mServInfo;
|
||||||
|
PgpAuxUtils* mPgpUtils;
|
||||||
|
|
||||||
NxsMsgTestScenario::ExpectedMap mExpectedResult;
|
NxsMsgTestScenario::ExpectedMap mExpectedResult;
|
||||||
|
|
||||||
|
@ -70,7 +70,9 @@ rs_nxs_test::NxsTestHub::NxsTestHub(NxsTestScenario::pointer testScenario)
|
|||||||
new NotifyWithPeerId(*cit, *this),
|
new NotifyWithPeerId(*cit, *this),
|
||||||
mTestScenario->getServiceInfo(),
|
mTestScenario->getServiceInfo(),
|
||||||
mTestScenario->getDummyReputations(*cit),
|
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();
|
mit->second->join();
|
||||||
}
|
}
|
||||||
|
|
||||||
mTestScenario->cleanTestScenario();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void rs_nxs_test::NxsTestHub::notifyNewMessages(const RsPeerId& pid,
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rs_nxs_test::NxsTestHub::CleanUpTest()
|
||||||
|
{
|
||||||
|
mTestScenario->cleanTestScenario();
|
||||||
|
}
|
||||||
|
|
||||||
void rs_nxs_test::NxsTestHub::tick()
|
void rs_nxs_test::NxsTestHub::tick()
|
||||||
{
|
{
|
||||||
// for each nxs instance pull out all items from each and then move to destination peer
|
// 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();
|
void EndTest();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Clean up test environment
|
||||||
|
*/
|
||||||
|
void CleanUpTest();
|
||||||
/*!
|
/*!
|
||||||
* @param messages messages are deleted after function returns
|
* @param messages messages are deleted after function returns
|
||||||
*/
|
*/
|
||||||
|
@ -37,6 +37,7 @@ namespace rs_nxs_test
|
|||||||
virtual RsGixsReputation* getDummyReputations(const RsPeerId& peerId) = 0;
|
virtual RsGixsReputation* getDummyReputations(const RsPeerId& peerId) = 0;
|
||||||
virtual uint16_t getServiceType() = 0;
|
virtual uint16_t getServiceType() = 0;
|
||||||
virtual RsServiceInfo getServiceInfo() = 0;
|
virtual RsServiceInfo getServiceInfo() = 0;
|
||||||
|
virtual PgpAuxUtils* getDummyPgpUtils() = 0;
|
||||||
|
|
||||||
virtual void cleanTestScenario() = 0;
|
virtual void cleanTestScenario() = 0;
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "nxsgrpsync_test.h"
|
#include "nxsgrpsync_test.h"
|
||||||
#include "nxsmsgsync_test.h"
|
#include "nxsmsgsync_test.h"
|
||||||
#include "nxstesthub.h"
|
#include "nxstesthub.h"
|
||||||
|
#include "nxsgrpsyncdelayed.h"
|
||||||
|
|
||||||
TEST(libretroshare_gxs, gxs_grp_sync)
|
TEST(libretroshare_gxs, gxs_grp_sync)
|
||||||
{
|
{
|
||||||
@ -25,6 +26,25 @@ TEST(libretroshare_gxs, gxs_grp_sync)
|
|||||||
|
|
||||||
ASSERT_TRUE(tHub.testsPassed());
|
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)
|
TEST(libretroshare_gxs, gxs_msg_sync)
|
||||||
@ -40,4 +60,12 @@ TEST(libretroshare_gxs, gxs_msg_sync)
|
|||||||
tHub.EndTest();
|
tHub.EndTest();
|
||||||
|
|
||||||
ASSERT_TRUE(tHub.testsPassed());
|
ASSERT_TRUE(tHub.testsPassed());
|
||||||
|
|
||||||
|
tHub.CleanUpTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(libretroshare_gxs, gxs_msg_sync_delayed)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user