mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-29 01:16:20 -05:00
Modifications to use MsgRelatedData for Wiki pages.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5820 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
f74a328d61
commit
81e172d6f8
@ -598,70 +598,20 @@ void WikiDialog::loadPages(const uint32_t &token)
|
|||||||
|
|
||||||
void WikiDialog::insertModsForPage(const RsGxsGrpMsgIdPair &origPageId)
|
void WikiDialog::insertModsForPage(const RsGxsGrpMsgIdPair &origPageId)
|
||||||
{
|
{
|
||||||
requestModPageList(origPageId);
|
requestModPages(origPageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WikiDialog::requestModPageList(const RsGxsGrpMsgIdPair &origMsgId)
|
void WikiDialog::requestModPages(const RsGxsGrpMsgIdPair &origMsgId)
|
||||||
{
|
{
|
||||||
RsTokReqOptions opts;
|
RsTokReqOptions opts;
|
||||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_IDS;
|
opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA;
|
||||||
opts.mOptions = RS_TOKREQOPT_MSG_VERSIONS;
|
opts.mOptions = RS_TOKREQOPT_MSG_VERSIONS;
|
||||||
std::vector<RsGxsGrpMsgIdPair> msgIds;
|
std::vector<RsGxsGrpMsgIdPair> msgIds;
|
||||||
msgIds.push_back(origMsgId);
|
msgIds.push_back(origMsgId);
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
mWikiQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts, msgIds, WIKIDIALOG_MOD_LIST);
|
mWikiQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, WIKIDIALOG_MOD_PAGES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void WikiDialog::loadModPageList(const uint32_t &token)
|
|
||||||
{
|
|
||||||
std::cerr << "WikiDialog::loadModPageList()";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
|
|
||||||
/* translate into latest pages */
|
|
||||||
//std::list<std::string> msgIds;
|
|
||||||
GxsMsgIdResult msgIds;
|
|
||||||
|
|
||||||
if (rsWiki->getMsgList(token, msgIds))
|
|
||||||
{
|
|
||||||
GxsMsgIdResult::iterator git;
|
|
||||||
for(git = msgIds.begin(); git != msgIds.end(); git++)
|
|
||||||
{
|
|
||||||
std::cerr << "WikiDialog::loadModPageList() Loaded GroupId: " << git->first;
|
|
||||||
std::cerr << std::endl;
|
|
||||||
std::vector<RsGxsMessageId>::iterator vit;
|
|
||||||
for(vit = git->second.begin(); vit != git->second.end(); vit++)
|
|
||||||
{
|
|
||||||
std::cerr << "\tMsgId: " << *vit;
|
|
||||||
std::cerr << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::cerr << "WikiDialog::loadModPageList() ERROR No Data";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
requestModPages(msgIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WikiDialog::requestModPages(const GxsMsgIdResult &msgIds)
|
|
||||||
{
|
|
||||||
std::cerr << "WikiDialog::requestModPages()";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
|
|
||||||
RsTokReqOptions opts;
|
|
||||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
|
||||||
|
|
||||||
uint32_t token;
|
|
||||||
mWikiQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, WIKIDIALOG_MOD_PAGES);
|
|
||||||
|
|
||||||
//mWikiQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, WIKIDIALOG_MOD_PAGES);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void WikiDialog::loadModPages(const uint32_t &token)
|
void WikiDialog::loadModPages(const uint32_t &token)
|
||||||
{
|
{
|
||||||
std::cerr << "WikiDialog::loadModPages()";
|
std::cerr << "WikiDialog::loadModPages()";
|
||||||
@ -670,7 +620,7 @@ void WikiDialog::loadModPages(const uint32_t &token)
|
|||||||
|
|
||||||
std::vector<RsWikiSnapshot> snapshots;
|
std::vector<RsWikiSnapshot> snapshots;
|
||||||
std::vector<RsWikiSnapshot>::iterator vit;
|
std::vector<RsWikiSnapshot>::iterator vit;
|
||||||
if (!rsWiki->getSnapshots(token, snapshots))
|
if (!rsWiki->getRelatedSnapshots(token, snapshots))
|
||||||
{
|
{
|
||||||
// ERROR
|
// ERROR
|
||||||
std::cerr << "WikiDialog::loadModPages() ERROR";
|
std::cerr << "WikiDialog::loadModPages() ERROR";
|
||||||
@ -682,17 +632,23 @@ void WikiDialog::loadModPages(const uint32_t &token)
|
|||||||
{
|
{
|
||||||
RsWikiSnapshot &page = *vit;
|
RsWikiSnapshot &page = *vit;
|
||||||
|
|
||||||
std::cerr << "WikiDialog::loadModPages() PageId: " << page.mMeta.mMsgId;
|
std::cerr << "WikiDialog::loadModPages() TopLevel Result: PageTitle: " << page.mMeta.mMsgName;
|
||||||
std::cerr << " Page: " << page.mMeta.mMsgName;
|
std::cerr << " GroupId: " << page.mMeta.mGroupId;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "\tOrigMsgId: " << page.mMeta.mOrigMsgId;
|
||||||
|
std::cerr << " MsgId: " << page.mMeta.mMsgId;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "\tThreadId: " << page.mMeta.mThreadId;
|
||||||
|
std::cerr << " ParentId: " << page.mMeta.mParentId;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
//QTreeWidgetItem *modItem = new QTreeWidgetItem();
|
QTreeWidgetItem *modItem = new QTreeWidgetItem();
|
||||||
//modItem->setText(WIKI_MODS_COL_ORIGPAGEID, QString::fromStdString(page.mMeta.mOrigMsgId));
|
modItem->setText(WIKI_MODS_COL_ORIGPAGEID, QString::fromStdString(page.mMeta.mOrigMsgId));
|
||||||
//modItem->setText(WIKI_MODS_COL_PAGEID, QString::fromStdString(page.mMeta.mMsgId));
|
modItem->setText(WIKI_MODS_COL_PAGEID, QString::fromStdString(page.mMeta.mMsgId));
|
||||||
//ui.treeWidget_Mods->addTopLevelItem(modItem);
|
modItem->setText(WIKI_MODS_COL_PARENTID, QString::fromStdString(page.mMeta.mParentId));
|
||||||
|
ui.treeWidget_Mods->addTopLevelItem(modItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* then we need to request all pages from this thread */
|
/* then we need to request all pages from this thread */
|
||||||
requestEditTreeData();
|
requestEditTreeData();
|
||||||
}
|
}
|
||||||
@ -733,14 +689,43 @@ void WikiDialog::loadEditTreeData(const uint32_t &token)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string groupId;
|
||||||
|
std::string pageId;
|
||||||
|
std::string origPageId;
|
||||||
|
if (!getSelectedPage(groupId, pageId, origPageId))
|
||||||
|
{
|
||||||
|
// ERROR
|
||||||
|
std::cerr << "WikiDialog::loadEditTreeData() ERROR 2";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
std::cerr << "WikiDialog::loadEditTreeData() Loaded " << snapshots.size();
|
std::cerr << "WikiDialog::loadEditTreeData() Loaded " << snapshots.size();
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "WikiDialog::loadEditTreeData() Using ThreadId: " << origPageId;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::map<RsGxsMessageId, QTreeWidgetItem *> items;
|
std::map<RsGxsMessageId, QTreeWidgetItem *> items;
|
||||||
std::map<RsGxsMessageId, QTreeWidgetItem *>::iterator iit;
|
std::map<RsGxsMessageId, QTreeWidgetItem *>::iterator iit;
|
||||||
std::list<QTreeWidgetItem *> unparented;
|
std::list<QTreeWidgetItem *> unparented;
|
||||||
std::list<QTreeWidgetItem *>::iterator uit;
|
std::list<QTreeWidgetItem *>::iterator uit;
|
||||||
|
|
||||||
|
// Grab the existing TopLevelItems, and insert into map.
|
||||||
|
int itemCount = ui.treeWidget_Mods->topLevelItemCount();
|
||||||
|
for (int nIndex = 0; nIndex < itemCount; nIndex++)
|
||||||
|
{
|
||||||
|
QTreeWidgetItem *item = ui.treeWidget_Mods->topLevelItem(nIndex);
|
||||||
|
|
||||||
|
/* index by MsgId --> ONLY For Wiki Thread Head Items... SPECIAL HACK FOR HERE! */
|
||||||
|
std::string msgId = item->text(WIKI_MODS_COL_PAGEID).toStdString();
|
||||||
|
items[msgId] = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
for(vit = snapshots.begin(); vit != snapshots.end(); vit++)
|
for(vit = snapshots.begin(); vit != snapshots.end(); vit++)
|
||||||
{
|
{
|
||||||
RsWikiSnapshot &snapshot = *vit;
|
RsWikiSnapshot &snapshot = *vit;
|
||||||
@ -755,12 +740,29 @@ void WikiDialog::loadEditTreeData(const uint32_t &token)
|
|||||||
std::cerr << " ParentId: " << snapshot.mMeta.mParentId;
|
std::cerr << " ParentId: " << snapshot.mMeta.mParentId;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
if (snapshot.mMeta.mParentId == "")
|
||||||
|
{
|
||||||
|
/* Ignore! */
|
||||||
|
std::cerr << "Ignoring ThreadHead Item";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (snapshot.mMeta.mThreadId != origPageId)
|
||||||
|
{
|
||||||
|
/* Ignore! */
|
||||||
|
std::cerr << "Ignoring Different Thread Item";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* create an Entry */
|
/* create an Entry */
|
||||||
QTreeWidgetItem *modItem = new QTreeWidgetItem();
|
QTreeWidgetItem *modItem = new QTreeWidgetItem();
|
||||||
modItem->setText(WIKI_MODS_COL_ORIGPAGEID, QString::fromStdString(snapshot.mMeta.mOrigMsgId));
|
modItem->setText(WIKI_MODS_COL_ORIGPAGEID, QString::fromStdString(snapshot.mMeta.mOrigMsgId));
|
||||||
modItem->setText(WIKI_MODS_COL_PAGEID, QString::fromStdString(snapshot.mMeta.mMsgId));
|
modItem->setText(WIKI_MODS_COL_PAGEID, QString::fromStdString(snapshot.mMeta.mMsgId));
|
||||||
modItem->setText(WIKI_MODS_COL_PARENTID, QString::fromStdString(snapshot.mMeta.mParentId));
|
modItem->setText(WIKI_MODS_COL_PARENTID, QString::fromStdString(snapshot.mMeta.mParentId));
|
||||||
|
|
||||||
|
#if 0
|
||||||
/* if no parentId */
|
/* if no parentId */
|
||||||
if (snapshot.mMeta.mParentId == "")
|
if (snapshot.mMeta.mParentId == "")
|
||||||
{
|
{
|
||||||
@ -771,6 +773,7 @@ void WikiDialog::loadEditTreeData(const uint32_t &token)
|
|||||||
items[snapshot.mMeta.mMsgId] = modItem;
|
items[snapshot.mMeta.mMsgId] = modItem;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* find the parent */
|
/* find the parent */
|
||||||
iit = items.find(snapshot.mMeta.mParentId);
|
iit = items.find(snapshot.mMeta.mParentId);
|
||||||
@ -882,10 +885,6 @@ void WikiDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
|||||||
loadPages(req.mToken);
|
loadPages(req.mToken);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WIKIDIALOG_MOD_LIST:
|
|
||||||
loadModPageList(req.mToken);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WIKIDIALOG_MOD_PAGES:
|
case WIKIDIALOG_MOD_PAGES:
|
||||||
loadModPages(req.mToken);
|
loadModPages(req.mToken);
|
||||||
break;
|
break;
|
||||||
|
@ -84,18 +84,10 @@ std::string getSelectedMod();
|
|||||||
void requestGroupList();
|
void requestGroupList();
|
||||||
void loadGroupData(const uint32_t &token);
|
void loadGroupData(const uint32_t &token);
|
||||||
|
|
||||||
//void requestOriginalPages(const std::list<std::string> &groupIds);
|
|
||||||
//void loadOriginalPages(const uint32_t &token);
|
|
||||||
//void requestLatestPages(const std::list<std::string> &msgIds);
|
|
||||||
//void loadLatestPages(const uint32_t &token);
|
|
||||||
void requestPages(const std::list<RsGxsGroupId> &groupIds);
|
void requestPages(const std::list<RsGxsGroupId> &groupIds);
|
||||||
//void requestPages(const std::list<std::string> &msgIds);
|
|
||||||
void loadPages(const uint32_t &token);
|
void loadPages(const uint32_t &token);
|
||||||
|
|
||||||
|
void requestModPages(const RsGxsGrpMsgIdPair &origMsgId);
|
||||||
void requestModPageList(const RsGxsGrpMsgIdPair &origMsgId);
|
|
||||||
void loadModPageList(const uint32_t &token);
|
|
||||||
void requestModPages(const GxsMsgIdResult &msgIds);
|
|
||||||
void loadModPages(const uint32_t &token);
|
void loadModPages(const uint32_t &token);
|
||||||
|
|
||||||
void requestEditTreeData();
|
void requestEditTreeData();
|
||||||
@ -107,7 +99,6 @@ void loadWikiPage(const uint32_t &token);
|
|||||||
|
|
||||||
TokenQueue *mWikiQueue;
|
TokenQueue *mWikiQueue;
|
||||||
|
|
||||||
|
|
||||||
WikiAddDialog *mAddPageDialog;
|
WikiAddDialog *mAddPageDialog;
|
||||||
WikiAddDialog *mAddGroupDialog;
|
WikiAddDialog *mAddGroupDialog;
|
||||||
WikiEditDialog *mEditDialog;
|
WikiEditDialog *mEditDialog;
|
||||||
|
Loading…
Reference in New Issue
Block a user