Modified Identity & Wiki GXS code so that it compiles.

- Just commented out the issues - still needs to be converted to new system.
 - Included it in build
 - Not actually enabled in the GUI yet.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5750 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2012-10-31 23:32:56 +00:00
parent 2fadb6d44d
commit cfef2cc052
10 changed files with 275 additions and 138 deletions

View File

@ -2,9 +2,9 @@ CONFIG += qt gui uic qrc resources uitools idle bitdht
# Below is for GXS services. # Below is for GXS services.
CONFIG += photoshare CONFIG += photoshare
#CONFIG += wikipoos CONFIG += wikipoos
#CONFIG += thewire #CONFIG += thewire
#CONFIG += identities CONFIG += identities
#CONFIG += forumsv2 #CONFIG += forumsv2
CONFIG += posted CONFIG += posted
CONFIG += unfinished CONFIG += unfinished
@ -194,15 +194,15 @@ freebsd-* {
# ########################################### # ###########################################
bitdht { bitdht {
#LIBS += ../../libbitdht/src/lib/libbitdht.a LIBS += ../../libbitdht/src/lib/libbitdht.a
#PRE_TARGETDEPS *= ../../libbitdht/src/lib/libbitdht.a PRE_TARGETDEPS *= ../../libbitdht/src/lib/libbitdht.a
#LIBS += C:\Development\Rs\v0.5-gxs-b1\libbitdht\libbitdht-build-desktop\lib\libbitdht.a #LIBS += C:\Development\Rs\v0.5-gxs-b1\libbitdht\libbitdht-build-desktop\lib\libbitdht.a
#PRE_TARGETDEPS *= C:\Development\Rs\v0.5-gxs-b1\libbitdht\libbitdht-build-desktop\lib\libbitdht.a #PRE_TARGETDEPS *= C:\Development\Rs\v0.5-gxs-b1\libbitdht\libbitdht-build-desktop\lib\libbitdht.a
# Chris version. # Chris version.
LIBS += ../../libbitdht/libbitdht-build-desktop/lib/libbitdht.a #LIBS += ../../libbitdht/libbitdht-build-desktop/lib/libbitdht.a
PRE_TARGETDEPS *= ../../libbitdht/libbitdht-build-desktop/lib/libbitdht.a #PRE_TARGETDEPS *= ../../libbitdht/libbitdht-build-desktop/lib/libbitdht.a
} }
win32 { win32 {
@ -1007,22 +1007,22 @@ posted {
gxsgui { gxsgui {
HEADERS += gui/gxs/GxsGroupDialog.h \ HEADERS += gui/gxs/GxsGroupDialog.h \
gui/gxs/GxsCommentTreeWidget.h gui/gxs/GxsCommentTreeWidget.h \
# gui/gxs/ForumV2GroupDialog.h \ gui/gxs/WikiGroupDialog.h \
# gui/gxs/WikiGroupDialog.h \
# gui/gxs/ForumV2GroupDialog.h \
# gui/gxs/GxsMsgDialog.h \ # gui/gxs/GxsMsgDialog.h \
FORMS += gui/gxs/GxsGroupDialog.ui \ FORMS += gui/gxs/GxsGroupDialog.ui \
# gui/gxs/GxsMsgDialog.ui \ # gui/gxs/GxsMsgDialog.ui \
# gui/gxs/GxsCommentTreeWidget.ui \ # gui/gxs/GxsCommentTreeWidget.ui \
SOURCES += gui/gxs/GxsGroupDialog.cpp \ SOURCES += gui/gxs/GxsGroupDialog.cpp \
gui/gxs/GxsCommentTreeWidget.cpp gui/gxs/GxsCommentTreeWidget.cpp \
#gui/gxs/ForumV2GroupDialog.cpp \ gui/gxs/WikiGroupDialog.cpp \
# gui/gxs/WikiGroupDialog.cpp \
#
#gui/gxs/ForumV2GroupDialog.cpp \
# gui/gxs/GxsMsgDialog.cpp \ # gui/gxs/GxsMsgDialog.cpp \

View File

@ -79,8 +79,9 @@ IdDialog::IdDialog(QWidget *parent)
timer->start(1000); timer->start(1000);
rsIdentity->generateDummyData(); rsIdentity->generateDummyData();
#if 0
mIdQueue = new TokenQueue(rsIdentity, this); mIdQueue = new TokenQueue(rsIdentity, this);
#endif
} }
@ -145,8 +146,10 @@ void IdDialog::requestIdDetails(std::string &id)
void IdDialog::insertIdDetails(uint32_t token) void IdDialog::insertIdDetails(uint32_t token)
{ {
/* get details from libretroshare */ /* get details from libretroshare */
RsIdGroup data; RsGxsIdGroup data;
#if 0
if (!rsIdentity->getGroupData(token, data)) if (!rsIdentity->getGroupData(token, data))
#endif
{ {
ui.lineEdit_KeyId->setText("ERROR GETTING KEY!"); ui.lineEdit_KeyId->setText("ERROR GETTING KEY!");
return; return;
@ -287,8 +290,12 @@ void IdDialog::insertIdList(uint32_t token)
//for(it = ids.begin(); it != ids.end(); it++) //for(it = ids.begin(); it != ids.end(); it++)
//{ //{
RsIdGroup data; RsGxsIdGroup data;
#if 0
while(rsIdentity->getGroupData(token, data)) while(rsIdentity->getGroupData(token, data))
#else
while(0)
#endif
{ {
/* do filtering */ /* do filtering */

View File

@ -41,8 +41,9 @@ IdEditDialog::IdEditDialog(QWidget *parent)
connect(ui.radioButton_Pseudo, SIGNAL( toggled( bool ) ), this, SLOT( IdTypeToggled( bool ) ) ); connect(ui.radioButton_Pseudo, SIGNAL( toggled( bool ) ), this, SLOT( IdTypeToggled( bool ) ) );
connect(ui.pushButton_Update, SIGNAL( clicked( void ) ), this, SLOT( updateId( void ) ) ); connect(ui.pushButton_Update, SIGNAL( clicked( void ) ), this, SLOT( updateId( void ) ) );
connect(ui.pushButton_Cancel, SIGNAL( clicked( void ) ), this, SLOT( cancelId( void ) ) ); connect(ui.pushButton_Cancel, SIGNAL( clicked( void ) ), this, SLOT( cancelId( void ) ) );
#if 0
mIdQueue = new TokenQueue(rsIdentity, this); mIdQueue = new TokenQueue(rsIdentity, this);
#endif
} }
void IdEditDialog::setupNewId(bool pseudo) void IdEditDialog::setupNewId(bool pseudo)
@ -122,8 +123,10 @@ void IdEditDialog::loadExistingId(uint32_t token)
ui.radioButton_Pseudo->setEnabled(false); ui.radioButton_Pseudo->setEnabled(false);
/* get details from libretroshare */ /* get details from libretroshare */
RsIdGroup data; RsGxsIdGroup data;
#if 0
if (!rsIdentity->getGroupData(token, data)) if (!rsIdentity->getGroupData(token, data))
#endif
{ {
ui.lineEdit_KeyId->setText("ERROR KEYID INVALID"); ui.lineEdit_KeyId->setText("ERROR KEYID INVALID");
ui.lineEdit_Nickname->setText(""); ui.lineEdit_Nickname->setText("");
@ -184,7 +187,7 @@ void IdEditDialog::loadExistingId(uint32_t token)
void IdEditDialog::updateId() void IdEditDialog::updateId()
{ {
RsIdGroup rid; RsGxsIdGroup rid;
// Must set, Nickname, KeyId(if existing), mIdType, GpgId. // Must set, Nickname, KeyId(if existing), mIdType, GpgId.
rid.mMeta.mGroupName = ui.lineEdit_Nickname->text().toStdString(); rid.mMeta.mGroupName = ui.lineEdit_Nickname->text().toStdString();

View File

@ -53,21 +53,26 @@ void WikiAddDialog::createGroup()
std::cerr << std::endl; std::cerr << std::endl;
RsWikiGroup group; RsWikiCollection group;
#if 0
group.mShareOptions.mShareType = 0; group.mShareOptions.mShareType = 0;
group.mShareOptions.mShareGroupId = "unknown"; group.mShareOptions.mShareGroupId = "unknown";
group.mShareOptions.mPublishKey = "unknown"; group.mShareOptions.mPublishKey = "unknown";
group.mShareOptions.mCommentMode = 0; group.mShareOptions.mCommentMode = 0;
group.mShareOptions.mResizeMode = 0; group.mShareOptions.mResizeMode = 0;
#endif
group.mMeta.mGroupName = ui.lineEdit_Name->text().toStdString(); group.mMeta.mGroupName = ui.lineEdit_Name->text().toStdString();
group.mCategory = "Unknown"; group.mCategory = "Unknown";
uint32_t token; uint32_t token;
bool isNew = true; bool isNew = true;
#if 0
// Don't worry about getting the response? // Don't worry about getting the response?
rsWiki->createGroup(token, group, isNew); rsWiki->createGroup(token, group, isNew);
#endif
clearDialog(); clearDialog();

View File

@ -76,7 +76,9 @@ WikiDialog::WikiDialog(QWidget *parent)
timer->start(1000); timer->start(1000);
/* setup TokenQueue */ /* setup TokenQueue */
#if 0
mWikiQueue = new TokenQueue(rsWiki, this); mWikiQueue = new TokenQueue(rsWiki, this);
#endif
} }
@ -114,7 +116,7 @@ void WikiDialog::OpenOrShowAddPageDialog()
std::cerr << std::endl; std::cerr << std::endl;
#if 0 #if 0
RsWikiGroup group; RsWikiCollection group;
if (!rsWiki->getGroup(groupId, group)) if (!rsWiki->getGroup(groupId, group))
{ {
std::cerr << "WikiDialog::OpenOrShowAddPageDialog() Failed to Get Group"; std::cerr << "WikiDialog::OpenOrShowAddPageDialog() Failed to Get Group";
@ -154,8 +156,8 @@ void WikiDialog::OpenOrShowAddGroupDialog()
void WikiDialog::newGroup() void WikiDialog::newGroup()
{ {
WikiGroupDialog cf (this); WikiGroupDialog cf(mWikiQueue, this);
cf.newGroup(); //cf.newGroup();
cf.exec (); cf.exec ();
} }
@ -171,10 +173,9 @@ void WikiDialog::showGroupDetails()
} }
WikiGroupDialog cf (this); //RsWikiCollection collection;
cf.existingGroup(groupId, GXS_GROUP_DIALOG_SHOW_MODE); //WikiGroupDialog cf (collection, this);
//cf.exec ();
cf.exec ();
} }
void WikiDialog::editGroupDetails() void WikiDialog::editGroupDetails()
@ -188,10 +189,10 @@ void WikiDialog::editGroupDetails()
} }
WikiGroupDialog cf (this); //WikiGroupDialog cf (this);
cf.existingGroup(groupId, GXS_GROUP_DIALOG_EDIT_MODE); //cf.existingGroup(groupId, GXS_GROUP_DIALOG_EDIT_MODE);
cf.exec (); //cf.exec ();
} }
@ -235,11 +236,11 @@ void WikiDialog::OpenOrShowEditDialog()
} }
#if 0 #if 0
RsWikiGroup group; RsWikiCollection group;
rsWiki->getGroup(groupId, group); rsWiki->getGroup(groupId, group);
mEditDialog->setGroup(group); mEditDialog->setGroup(group);
RsWikiPage page; RsWikiSnapshot page;
rsWiki->getPage(realPageId, page); rsWiki->getPage(realPageId, page);
mEditDialog->setPreviousPage(page); mEditDialog->setPreviousPage(page);
#endif #endif
@ -297,7 +298,7 @@ void WikiDialog::modTreeChanged()
} }
void WikiDialog::updateWikiPage(const RsWikiPage &page) void WikiDialog::updateWikiPage(const RsWikiSnapshot &page)
{ {
ui.textBrowser->setPlainText(QString::fromStdString(page.mPage)); ui.textBrowser->setPlainText(QString::fromStdString(page.mPage));
} }
@ -329,6 +330,7 @@ void WikiDialog::clearModsTree()
#define WIKI_GROUP_COL_ORIGPAGEID 2 #define WIKI_GROUP_COL_ORIGPAGEID 2
// THIS WAS ALREADY COMMENTED OUT!!!
#if 0 #if 0
######################################################### #########################################################
void WikiDialog::insertWikiGroups() void WikiDialog::insertWikiGroups()
@ -348,7 +350,7 @@ void WikiDialog::insertWikiGroups()
for(it = groupIds.begin(); it != groupIds.end(); it++) for(it = groupIds.begin(); it != groupIds.end(); it++)
{ {
/* add a group Item */ /* add a group Item */
RsWikiGroup group; RsWikiCollection group;
rsWiki->getGroup(*it, group); rsWiki->getGroup(*it, group);
QTreeWidgetItem *groupItem = new QTreeWidgetItem(NULL); QTreeWidgetItem *groupItem = new QTreeWidgetItem(NULL);
@ -370,7 +372,7 @@ void WikiDialog::insertWikiGroups()
std::cerr << std::endl; std::cerr << std::endl;
/* get newest page */ /* get newest page */
RsWikiPage page; RsWikiSnapshot page;
std::string latestPageId; std::string latestPageId;
if (!rsWiki->getLatestPage(*pit, latestPageId)) if (!rsWiki->getLatestPage(*pit, latestPageId))
{ {
@ -506,7 +508,7 @@ void WikiDialog::insertModsForPage(std::string &origPageId)
for(it = pageIds.begin(); it != pageIds.end(); it++) for(it = pageIds.begin(); it != pageIds.end(); it++)
{ {
RsWikiPage page; RsWikiSnapshot page;
rsWiki->getPage(*it, page); rsWiki->getPage(*it, page);
QTreeWidgetItem *modItem = new QTreeWidgetItem(NULL); QTreeWidgetItem *modItem = new QTreeWidgetItem(NULL);
@ -589,7 +591,9 @@ void WikiDialog::requestGroupData(const std::list<std::string> &groupIds)
{ {
RsTokReqOptions opts; RsTokReqOptions opts;
uint32_t token; uint32_t token;
#if 0
mWikiQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, WIKIDIALOG_LISTING_GROUPDATA); mWikiQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, WIKIDIALOG_LISTING_GROUPDATA);
#endif
} }
void WikiDialog::loadGroupData(const uint32_t &token) void WikiDialog::loadGroupData(const uint32_t &token)
@ -602,8 +606,12 @@ void WikiDialog::loadGroupData(const uint32_t &token)
bool moreData = true; bool moreData = true;
while(moreData) while(moreData)
{ {
RsWikiGroup group; RsWikiCollection group;
#if 0
if (rsWiki->getGroupData(token, group)) if (rsWiki->getGroupData(token, group))
#else
if (0)
#endif
{ {
/* Add Widget, and request Pages */ /* Add Widget, and request Pages */
@ -645,7 +653,11 @@ void WikiDialog::loadOriginalPages(const uint32_t &token)
/* translate into latest pages */ /* translate into latest pages */
std::list<std::string> msgIds; std::list<std::string> msgIds;
#if 0
if (rsWiki->getMsgList(token, msgIds)) if (rsWiki->getMsgList(token, msgIds))
#else
if (0)
#endif
{ {
std::cerr << "WikiDialog::loadOriginalPages() Loaded " << msgIds.size(); std::cerr << "WikiDialog::loadOriginalPages() Loaded " << msgIds.size();
std::cerr << std::endl; std::cerr << std::endl;
@ -666,7 +678,23 @@ void WikiDialog::requestLatestPages(const std::list<std::string> &msgIds)
RsTokReqOptions opts; RsTokReqOptions opts;
opts.mOptions = RS_TOKREQOPT_MSG_LATEST; opts.mOptions = RS_TOKREQOPT_MSG_LATEST;
uint32_t token; uint32_t token;
#if 0
mWikiQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts, msgIds, WIKIDIALOG_LISTING_LATESTPAGES); mWikiQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts, msgIds, WIKIDIALOG_LISTING_LATESTPAGES);
#endif
}
void convert_result_to_list(const GxsMsgIdResult &result, std::list<RsGxsMessageId> &list)
{
GxsMsgIdResult::const_iterator it;
for(it = result.begin(); it != result.end(); it++)
{
std::vector<RsGxsMessageId>::const_iterator vit;
for (vit = it->second.begin(); vit != it->second.end(); vit++)
{
list.push_back(*vit);
}
}
} }
void WikiDialog::loadLatestPages(const uint32_t &token) void WikiDialog::loadLatestPages(const uint32_t &token)
@ -674,7 +702,8 @@ void WikiDialog::loadLatestPages(const uint32_t &token)
std::cerr << "WikiDialog::loadLatestPages()"; std::cerr << "WikiDialog::loadLatestPages()";
std::cerr << std::endl; std::cerr << std::endl;
std::list<std::string> msgIds; //std::list<std::string> msgIds;
GxsMsgIdResult msgIds;
if (rsWiki->getMsgList(token, msgIds)) if (rsWiki->getMsgList(token, msgIds))
{ {
std::cerr << "WikiDialog::loadLatestPages() Loaded " << msgIds.size(); std::cerr << "WikiDialog::loadLatestPages() Loaded " << msgIds.size();
@ -687,17 +716,22 @@ void WikiDialog::loadLatestPages(const uint32_t &token)
return; return;
} }
std::list<RsGxsMessageId> list;
convert_result_to_list(msgIds, list);
/* request actual data */ /* request actual data */
requestPages(msgIds); //requestPages(list);
} }
void WikiDialog::requestPages(const std::list<std::string> &msgIds) #if 0
void WikiDialog::requestPages(std::list<RsGxsMessageId> &msgids)
{ {
RsTokReqOptions opts; RsTokReqOptions opts;
uint32_t token; uint32_t token;
mWikiQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, WIKIDIALOG_LISTING_PAGES); mWikiQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, WIKIDIALOG_LISTING_PAGES);
} }
#endif
void WikiDialog::loadPages(const uint32_t &token) void WikiDialog::loadPages(const uint32_t &token)
{ {
@ -708,56 +742,54 @@ void WikiDialog::loadPages(const uint32_t &token)
QTreeWidgetItem *groupItem = NULL; QTreeWidgetItem *groupItem = NULL;
std::vector<RsWikiSnapshot> snapshots;
std::vector<RsWikiSnapshot>::iterator vit;
if (!rsWiki->getSnapshots(token, snapshots))
{
// ERROR
return;
}
bool moreData = true; for(vit = snapshots.begin(); vit != snapshots.end(); vit++)
while(moreData) {
{ RsWikiSnapshot page = *vit;
RsWikiPage page; if (!groupItem)
if (rsWiki->getMsgData(token, page)) {
{ /* find the entry */
if (!groupItem) int itemCount = ui.treeWidget_Pages->topLevelItemCount();
{ for (int nIndex = 0; nIndex < itemCount;)
/* find the entry */ {
int itemCount = ui.treeWidget_Pages->topLevelItemCount(); QTreeWidgetItem *tmpItem = ui.treeWidget_Pages->topLevelItem(nIndex);
for (int nIndex = 0; nIndex < itemCount;) std::string tmpid = tmpItem->data(WIKI_GROUP_COL_GROUPID,
{ Qt::DisplayRole).toString().toStdString();
QTreeWidgetItem *tmpItem = ui.treeWidget_Pages->topLevelItem(nIndex); if (tmpid == page.mMeta.mGroupId)
std::string tmpid = tmpItem->data(WIKI_GROUP_COL_GROUPID,
Qt::DisplayRole).toString().toStdString();
if (tmpid == page.mMeta.mGroupId)
{
groupItem = tmpItem;
break;
}
}
if (!groupItem)
{ {
/* error */ groupItem = tmpItem;
std::cerr << "WikiDialog::loadPages() ERROR Unable to find group"; break;
std::cerr << std::endl;
return;
} }
} }
if (!groupItem)
{
/* error */
std::cerr << "WikiDialog::loadPages() ERROR Unable to find group";
std::cerr << std::endl;
return;
}
}
std::cerr << "WikiDialog::loadPages() PageId: " << page.mMeta.mMsgId;
std::cerr << " Page: " << page.mMeta.mMsgName;
std::cerr << std::endl;
QTreeWidgetItem *pageItem = new QTreeWidgetItem(); std::cerr << "WikiDialog::loadPages() PageId: " << page.mMeta.mMsgId;
pageItem->setText(WIKI_GROUP_COL_PAGENAME, QString::fromStdString(page.mMeta.mMsgName)); std::cerr << " Page: " << page.mMeta.mMsgName;
pageItem->setText(WIKI_GROUP_COL_PAGEID, QString::fromStdString(page.mMeta.mMsgId)); std::cerr << std::endl;
pageItem->setText(WIKI_GROUP_COL_ORIGPAGEID, QString::fromStdString(page.mMeta.mOrigMsgId));
groupItem->addChild(pageItem); QTreeWidgetItem *pageItem = new QTreeWidgetItem();
pageItem->setText(WIKI_GROUP_COL_PAGENAME, QString::fromStdString(page.mMeta.mMsgName));
pageItem->setText(WIKI_GROUP_COL_PAGEID, QString::fromStdString(page.mMeta.mMsgId));
pageItem->setText(WIKI_GROUP_COL_ORIGPAGEID, QString::fromStdString(page.mMeta.mOrigMsgId));
} groupItem->addChild(pageItem);
else }
{
moreData = false;
}
}
//return true; //return true;
} }
@ -778,7 +810,9 @@ void WikiDialog::requestModPageList(const std::string &origMsgId)
msgIds.push_back(origMsgId); msgIds.push_back(origMsgId);
uint32_t token; uint32_t token;
#if 0
mWikiQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts, msgIds, WIKIDIALOG_MOD_LIST); mWikiQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts, msgIds, WIKIDIALOG_MOD_LIST);
#endif
} }
@ -788,7 +822,9 @@ void WikiDialog::loadModPageList(const uint32_t &token)
std::cerr << std::endl; std::cerr << std::endl;
/* translate into latest pages */ /* translate into latest pages */
std::list<std::string> msgIds; //std::list<std::string> msgIds;
GxsMsgIdResult msgIds;
if (rsWiki->getMsgList(token, msgIds)) if (rsWiki->getMsgList(token, msgIds))
{ {
std::cerr << "WikiDialog::loadModPageList() Loaded " << msgIds.size(); std::cerr << "WikiDialog::loadModPageList() Loaded " << msgIds.size();
@ -801,16 +837,20 @@ void WikiDialog::loadModPageList(const uint32_t &token)
return; return;
} }
requestModPages(msgIds); std::list<RsGxsMessageId> list;
convert_result_to_list(msgIds, list);
requestModPages(list);
} }
void WikiDialog::requestModPages(const std::list<std::string> &msgIds) void WikiDialog::requestModPages(const std::list<RsGxsMessageId> &msgIds)
{ {
RsTokReqOptions opts; RsTokReqOptions opts;
uint32_t token; uint32_t token;
#if 0
mWikiQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, WIKIDIALOG_MOD_PAGES); mWikiQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, WIKIDIALOG_MOD_PAGES);
#endif
} }
@ -822,8 +862,11 @@ void WikiDialog::loadModPages(const uint32_t &token)
bool moreData = true; bool moreData = true;
while(moreData) while(moreData)
{ {
RsWikiPage page; RsWikiSnapshot page;
#if 0
if (rsWiki->getMsgData(token, page)) if (rsWiki->getMsgData(token, page))
#endif
if (0)
{ {
std::cerr << "WikiDialog::loadModPages() PageId: " << page.mMeta.mMsgId; std::cerr << "WikiDialog::loadModPages() PageId: " << page.mMeta.mMsgId;
std::cerr << " Page: " << page.mMeta.mMsgName; std::cerr << " Page: " << page.mMeta.mMsgName;
@ -855,7 +898,9 @@ void WikiDialog::requestWikiPage(const std::string &msgId)
msgIds.push_back(msgId); msgIds.push_back(msgId);
uint32_t token; uint32_t token;
#if 0
mWikiQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, WIKIDIALOG_WIKI_PAGE); mWikiQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, WIKIDIALOG_WIKI_PAGE);
#endif
} }
@ -865,23 +910,33 @@ void WikiDialog::loadWikiPage(const uint32_t &token)
std::cerr << std::endl; std::cerr << std::endl;
// Should only have one WikiPage.... // Should only have one WikiPage....
bool moreData = true; std::vector<RsWikiSnapshot> snapshots;
while(moreData) if (!rsWiki->getSnapshots(token, snapshots))
{ {
RsWikiPage page; // ERROR
if (rsWiki->getMsgData(token, page)) return;
{ }
std::cerr << "WikiDialog::loadModPages() PageId: " << page.mMeta.mMsgId;
std::cerr << " Page: " << page.mMeta.mMsgName;
std::cerr << std::endl;
updateWikiPage(page); if (snapshots.size() < 1)
} {
else // ERROR
{ return;
moreData = false; }
}
}
if (snapshots.size() > 1)
{
// ERROR
return;
}
RsWikiSnapshot page = snapshots[0];
std::cerr << "WikiDialog::loadModPages() PageId: " << page.mMeta.mMsgId;
std::cerr << " Page: " << page.mMeta.mMsgName;
std::cerr << std::endl;
updateWikiPage(page);
} }

View File

@ -68,7 +68,7 @@ void clearModsTree();
void insertWikiGroups(); void insertWikiGroups();
void insertModsForPage(const std::string &origPageId); void insertModsForPage(const std::string &origPageId);
void updateWikiPage(const RsWikiPage &page); void updateWikiPage(const RsWikiSnapshot &page);
bool getSelectedPage(std::string &pageId, std::string &origPageId); bool getSelectedPage(std::string &pageId, std::string &origPageId);
std::string getSelectedPage(); std::string getSelectedPage();

View File

@ -36,25 +36,27 @@ WikiEditDialog::WikiEditDialog(QWidget *parent)
connect(ui.pushButton_Revert, SIGNAL( clicked( void ) ), this, SLOT( revertEdit( void ) ) ); connect(ui.pushButton_Revert, SIGNAL( clicked( void ) ), this, SLOT( revertEdit( void ) ) );
connect(ui.pushButton_Submit, SIGNAL( clicked( void ) ), this, SLOT( submitEdit( void ) ) ); connect(ui.pushButton_Submit, SIGNAL( clicked( void ) ), this, SLOT( submitEdit( void ) ) );
#if 0
mWikiQueue = new TokenQueue(rsWiki, this); mWikiQueue = new TokenQueue(rsWiki, this);
#endif
} }
void WikiEditDialog::setGroup(RsWikiGroup &group) void WikiEditDialog::setGroup(RsWikiCollection &group)
{ {
mWikiGroup = group; mWikiCollection = group;
ui.lineEdit_Group->setText(QString::fromStdString(mWikiGroup.mMeta.mGroupName)); ui.lineEdit_Group->setText(QString::fromStdString(mWikiCollection.mMeta.mGroupName));
} }
void WikiEditDialog::setPreviousPage(RsWikiPage &page) void WikiEditDialog::setPreviousPage(RsWikiSnapshot &page)
{ {
mNewPage = false; mNewPage = false;
mWikiPage = page; mWikiSnapshot = page;
ui.lineEdit_Page->setText(QString::fromStdString(mWikiPage.mMeta.mMsgName)); ui.lineEdit_Page->setText(QString::fromStdString(mWikiSnapshot.mMeta.mMsgName));
ui.lineEdit_PrevVersion->setText(QString::fromStdString(mWikiPage.mMeta.mMsgId)); ui.lineEdit_PrevVersion->setText(QString::fromStdString(mWikiSnapshot.mMeta.mMsgId));
ui.textEdit->setPlainText(QString::fromStdString(mWikiPage.mPage)); ui.textEdit->setPlainText(QString::fromStdString(mWikiSnapshot.mPage));
} }
@ -81,7 +83,7 @@ void WikiEditDialog::revertEdit()
} }
else else
{ {
ui.textEdit->setPlainText(QString::fromStdString(mWikiPage.mPage)); ui.textEdit->setPlainText(QString::fromStdString(mWikiSnapshot.mPage));
} }
} }
@ -90,23 +92,29 @@ void WikiEditDialog::submitEdit()
{ {
if (mNewPage) if (mNewPage)
{ {
mWikiPage.mMeta.mGroupId = mWikiGroup.mMeta.mGroupId; mWikiSnapshot.mMeta.mGroupId = mWikiCollection.mMeta.mGroupId;
mWikiPage.mMeta.mOrigMsgId = ""; mWikiSnapshot.mMeta.mOrigMsgId = "";
mWikiPage.mMeta.mMsgId = ""; mWikiSnapshot.mMeta.mMsgId = "";
mWikiPage.mPrevId = ""; #if 0
mWikiSnapshot.mPrevId = "";
#endif
} }
else else
{ {
mWikiPage.mPrevId = mWikiPage.mMeta.mMsgId; #if 0
mWikiPage.mMeta.mMsgId = ""; mWikiSnapshot.mPrevId = mWikiSnapshot.mMeta.mMsgId;
#endif
mWikiSnapshot.mMeta.mMsgId = "";
} }
mWikiPage.mMeta.mMsgName = ui.lineEdit_Page->text().toStdString(); mWikiSnapshot.mMeta.mMsgName = ui.lineEdit_Page->text().toStdString();
mWikiPage.mPage = ui.textEdit->toPlainText().toStdString(); mWikiSnapshot.mPage = ui.textEdit->toPlainText().toStdString();
uint32_t token; uint32_t token;
bool isNew = mNewPage; bool isNew = mNewPage;
rsWiki->createPage(token, mWikiPage, isNew); #if 0
rsWiki->createPage(token, mWikiSnapshot, isNew);
#endif
hide(); hide();
} }
@ -144,8 +152,12 @@ void WikiEditDialog::loadGroup(const uint32_t &token)
std::cerr << "WikiEditDialog::loadGroup()"; std::cerr << "WikiEditDialog::loadGroup()";
std::cerr << std::endl; std::cerr << std::endl;
RsWikiGroup group; RsWikiCollection group;
#if 0
if (rsWiki->getGroupData(token, group)) if (rsWiki->getGroupData(token, group))
#else
if (0)
#endif
{ {
setGroup(group); setGroup(group);
} }
@ -161,7 +173,9 @@ void WikiEditDialog::requestPage(const std::string &msgId)
RsTokReqOptions opts; RsTokReqOptions opts;
uint32_t token; uint32_t token;
#if 0
mWikiQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, ids, 0); mWikiQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, ids, 0);
#endif
} }
void WikiEditDialog::loadPage(const uint32_t &token) void WikiEditDialog::loadPage(const uint32_t &token)
@ -169,8 +183,12 @@ void WikiEditDialog::loadPage(const uint32_t &token)
std::cerr << "WikiEditDialog::loadPage()"; std::cerr << "WikiEditDialog::loadPage()";
std::cerr << std::endl; std::cerr << std::endl;
RsWikiPage page; RsWikiSnapshot page;
#if 0
if (rsWiki->getMsgData(token, page)) if (rsWiki->getMsgData(token, page))
#else
if (0)
#endif
{ {
setPreviousPage(page); setPreviousPage(page);
} }

View File

@ -49,8 +49,8 @@ void submitEdit();
private: private:
void setGroup(RsWikiGroup &group); void setGroup(RsWikiCollection &group);
void setPreviousPage(RsWikiPage &page); void setPreviousPage(RsWikiSnapshot &page);
void requestPage(const std::string &msgId); void requestPage(const std::string &msgId);
void loadPage(const uint32_t &token); void loadPage(const uint32_t &token);
@ -58,8 +58,8 @@ void requestGroup(const std::string &groupId);
void loadGroup(const uint32_t &token); void loadGroup(const uint32_t &token);
bool mNewPage; bool mNewPage;
RsWikiGroup mWikiGroup; RsWikiCollection mWikiCollection;
RsWikiPage mWikiPage; RsWikiSnapshot mWikiSnapshot;
Ui::WikiEditDialog ui; Ui::WikiEditDialog ui;

View File

@ -24,8 +24,8 @@
#include <retroshare/rswiki.h> #include <retroshare/rswiki.h>
#include <iostream> #include <iostream>
WikiGroupDialog::WikiGroupDialog(QWidget *parent) WikiGroupDialog::WikiGroupDialog(TokenQueue *tokenQueue, QWidget *parent)
:GxsGroupDialog(rsWiki, parent) :GxsGroupDialog(tokenQueue, parent, GXS_GROUP_DIALOG_CREATE_MODE)
{ {
// To start with we only have open forums - with distribution controls. // To start with we only have open forums - with distribution controls.
@ -58,7 +58,32 @@ WikiGroupDialog::WikiGroupDialog(QWidget *parent)
GXS_GROUP_DEFAULTS_COMMENTS_NO | GXS_GROUP_DEFAULTS_COMMENTS_NO |
0); 0);
setFlags(enabledFlags, readonlyFlags, defaultsFlags); //setFlags(enabledFlags, readonlyFlags, defaultsFlags);
setFlags(enabledFlags, defaultsFlags);
}
WikiGroupDialog::WikiGroupDialog(const RsWikiCollection &collection, QWidget *parent)
:GxsGroupDialog(NULL, parent, GXS_GROUP_DIALOG_SHOW_MODE)
{
// To start with we only have open forums - with distribution controls.
uint32_t enabledFlags = ( GXS_GROUP_FLAGS_ICON |
GXS_GROUP_FLAGS_DESCRIPTION |
GXS_GROUP_FLAGS_DISTRIBUTION |
GXS_GROUP_FLAGS_SHAREKEYS |
0);
uint32_t readonlyFlags = 0;
uint32_t defaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC |
GXS_GROUP_DEFAULTS_PUBLISH_OPEN |
GXS_GROUP_DEFAULTS_PERSONAL_REQUIRED |
GXS_GROUP_DEFAULTS_COMMENTS_NO |
0);
setFlags(enabledFlags, defaultsFlags);
} }
@ -66,20 +91,37 @@ WikiGroupDialog::WikiGroupDialog(QWidget *parent)
bool WikiGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta) bool WikiGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta)
{ {
// Specific Function. // Specific Function.
RsWikiGroup grp; RsWikiCollection grp;
grp.mMeta = meta; grp.mMeta = meta;
//grp.mDescription = std::string(desc.toUtf8()); //grp.mDescription = std::string(desc.toUtf8());
rsWiki->createGroup(token, grp, true); rsWiki->submitCollection(token, grp);
return true; return true;
} }
QPixmap WikiGroupDialog::service_getLogo()
{
return QPixmap(); // null pixmap
}
QString WikiGroupDialog::service_getDescription()
{
return QString();
}
RsGroupMetaData WikiGroupDialog::service_getMeta()
{
return mGrp.mMeta;
}
#if 0
void WikiGroupDialog::service_loadExistingGroup(const uint32_t &token) void WikiGroupDialog::service_loadExistingGroup(const uint32_t &token)
{ {
std::cerr << "WikiGroupDialog::service_loadExistingGroup()"; std::cerr << "WikiGroupDialog::service_loadExistingGroup()";
std::cerr << std::endl; std::cerr << std::endl;
RsWikiGroup group; RsWikiCollection group;
if (!rsWiki->getGroupData(token, group)) if (!rsWiki->getGroupData(token, group))
{ {
std::cerr << "WikiGroupDialog::service_loadExistingGroup() ERROR Getting Group"; std::cerr << "WikiGroupDialog::service_loadExistingGroup() ERROR Getting Group";
@ -94,7 +136,6 @@ void WikiGroupDialog::service_loadExistingGroup(const uint32_t &token)
/* now load any extra data we feel like */ /* now load any extra data we feel like */
} }
#endif

View File

@ -24,19 +24,27 @@
#define _WIKI_GROUP_DIALOG_H #define _WIKI_GROUP_DIALOG_H
#include "GxsGroupDialog.h" #include "GxsGroupDialog.h"
#include "retroshare/rswiki.h"
class WikiGroupDialog : public GxsGroupDialog class WikiGroupDialog : public GxsGroupDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
WikiGroupDialog(QWidget *parent); WikiGroupDialog(TokenQueue *tokenQueue, QWidget *parent);
WikiGroupDialog(const RsWikiCollection &collection, QWidget *parent);
protected: protected:
virtual bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta); virtual bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta);
// virtual bool service_CompleteCreateGroup(const RsGroupMetaData &meta); virtual QPixmap service_getLogo();
virtual QString service_getDescription();
virtual RsGroupMetaData service_getMeta();
virtual void service_loadExistingGroup(const uint32_t &token); //virtual void service_loadExistingGroup(const uint32_t &token);
private:
RsWikiCollection mGrp;
}; };