removed most of the token queue system from GxsFeedItems

This commit is contained in:
csoler 2020-02-16 20:57:36 +01:00
parent d1b26c9d36
commit 7e08d24b64
No known key found for this signature in database
GPG key ID: 7BCA522266C0804C
18 changed files with 607 additions and 491 deletions

View file

@ -28,6 +28,7 @@
#include "gui/feeds/FeedHolder.h" #include "gui/feeds/FeedHolder.h"
#include "gui/gxs/GxsIdDetails.h" #include "gui/gxs/GxsIdDetails.h"
#include "util/misc.h" #include "util/misc.h"
#include "util/qtthreadsutils.h"
#include "util/HandleRichText.h" #include "util/HandleRichText.h"
#include "ui_PostedCardView.h" #include "ui_PostedCardView.h"
@ -158,88 +159,143 @@ bool PostedCardView::setPost(const RsPostedPost &post, bool doFill)
return true; return true;
} }
void PostedCardView::loadGroup(const uint32_t &token) void PostedCardView::loadGroup()
{ {
RsThread::async([this]()
{
// 1 - get group data
#ifdef DEBUG_FORUMS
std::cerr << "Retrieving post data for post " << mThreadId << std::endl;
#endif
std::vector<RsPostedGroup> groups; std::vector<RsPostedGroup> groups;
if (!rsPosted->getGroupData(token, groups)) const std::list<RsGxsGroupId> groupIds = { groupId() };
#warning Code needed in rsPosted
#ifdef TODO
if(!rsPosted->getPostedGroupInfo(groupIds,groups))
#endif
{ {
std::cerr << "PostedCardView::loadGroup() ERROR getting data"; RsErr() << "GxsPostedGroupItem::loadGroup() ERROR getting data" << std::endl;
std::cerr << std::endl;
return; return;
} }
if (groups.size() != 1) if (groups.size() != 1)
{ {
std::cerr << "PostedCardView::loadGroup() Wrong number of Items"; std::cerr << "GxsPostedGroupItem::loadGroup() Wrong number of Items";
std::cerr << std::endl; std::cerr << std::endl;
return; return;
} }
RsPostedGroup group(groups[0]);
setGroup(groups[0]); RsQThreadUtils::postToObject( [group,this]()
{
/* Here it goes any code you want to be executed on the Qt Gui
* thread, for example to update the data model with new information
* after a blocking call to RetroShare API complete */
setGroup(group);
}, this );
});
} }
void PostedCardView::loadMessage(const uint32_t &token) void PostedCardView::loadMessage()
{ {
RsThread::async([this]()
{
// 1 - get group data
std::vector<RsPostedPost> posts; std::vector<RsPostedPost> posts;
std::vector<RsGxsComment> cmts; std::vector<RsGxsComment> comments;
if (!rsPosted->getPostData(token, posts, cmts))
#warning Code needed in rsPosted
#ifdef TODO
if(! rsPosted->getPostedContent( groupId(), std::set<RsGxsMessageId>( { messageId() } ),posts,comments))
#endif
{ {
std::cerr << "GxsChannelPostItem::loadMessage() ERROR getting data"; RsErr() << "PostedItem::loadMessage() ERROR getting data" << std::endl;
std::cerr << std::endl;
return; return;
} }
if (posts.size() == 1) if (posts.size() == 1)
{ {
setPost(posts[0]); std::cerr << (void*)this << ": Obtained post, with msgId = " << posts[0].mMeta.mMsgId << std::endl;
const RsPostedPost& post(posts[0]);
RsQThreadUtils::postToObject( [post,this]() { setPost(post); }, this );
} }
else if (cmts.size() == 1) else if(comments.size() == 1)
{ {
RsGxsComment cmt = cmts[0]; const RsGxsComment& cmt = comments[0];
std::cerr << (void*)this << ": Obtained comment, setting messageId to threadID = " << cmt.mMeta.mThreadId << std::endl;
//ui->newCommentLabel->show();
//ui->commLabel->show();
//ui->commLabel->setText(QString::fromUtf8(cmt.mComment.c_str()));
RsQThreadUtils::postToObject( [cmt,this]()
{
//Change this item to be uploaded with thread element. //Change this item to be uploaded with thread element.
setMessageId(cmt.mMeta.mThreadId); setMessageId(cmt.mMeta.mThreadId);
requestMessage(); requestMessage();
}, this );
} }
else else
{ {
std::cerr << "GxsChannelPostItem::loadMessage() Wrong number of Items. Remove It."; std::cerr << "GxsChannelPostItem::loadMessage() Wrong number of Items. Remove It.";
std::cerr << std::endl; std::cerr << std::endl;
removeItem();
return; RsQThreadUtils::postToObject( [this]() { removeItem(); }, this );
} }
});
} }
void PostedCardView::loadComment(const uint32_t &token) void PostedCardView::loadComment()
{ {
std::vector<RsGxsComment> cmts; RsThread::async([this]()
if (!rsPosted->getRelatedComments(token, cmts))
{ {
std::cerr << "GxsChannelPostItem::loadComment() ERROR getting data"; // 1 - get group data
std::cerr << std::endl;
std::set<RsGxsMessageId> msgIds;
for(auto MsgId: messageVersions())
msgIds.insert(MsgId);
std::vector<RsPostedPost> posts;
std::vector<RsGxsComment> comments;
#warning Code needed in rsPosted
#ifdef TODO
if(! rsPosted->getPostedContent( groupId(),msgIds,posts,comments))
#endif
{
RsErr() << "PostedCardView::loadGroup() ERROR getting data" << std::endl;
return; return;
} }
size_t comNb = cmts.size(); int comNb = comments.size();
RsQThreadUtils::postToObject( [comNb,this]()
{
QString sComButText = tr("Comment"); QString sComButText = tr("Comment");
if (comNb == 1) { if (comNb == 1)
sComButText = sComButText.append("(1)"); sComButText = sComButText.append("(1)");
} else if (comNb > 1) { else if(comNb > 1)
sComButText = " " + tr("Comments").append(" (%1)").arg(comNb); sComButText = tr("Comments ").append("(%1)").arg(comNb);
}
ui->commentButton->setText(sComButText); ui->commentButton->setText(sComButText);
}, this );
});
} }
void PostedCardView::fill() void PostedCardView::fill()
{ {
if (isLoading()) { // if (isLoading()) {
/* Wait for all requests */ // /* Wait for all requests */
return; // return;
} // }
QPixmap sqpixmap2 = QPixmap(":/images/thumb-default.png"); QPixmap sqpixmap2 = QPixmap(":/images/thumb-default.png");

View file

@ -69,13 +69,13 @@ signals:
protected: protected:
/* GxsGroupFeedItem */ /* GxsGroupFeedItem */
virtual QString groupName(); virtual QString groupName();
virtual void loadGroup(const uint32_t &token); virtual void loadGroup() override;
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_UNKNOWN; } virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_UNKNOWN; }
/* GxsFeedItem */ /* GxsFeedItem */
virtual QString messageName(); virtual QString messageName();
virtual void loadMessage(const uint32_t &token); virtual void loadMessage();
virtual void loadComment(const uint32_t &token); virtual void loadComment();
private: private:
void setup(); void setup();

View file

@ -28,6 +28,7 @@
#include "gui/feeds/FeedHolder.h" #include "gui/feeds/FeedHolder.h"
#include "gui/gxs/GxsIdDetails.h" #include "gui/gxs/GxsIdDetails.h"
#include "util/misc.h" #include "util/misc.h"
#include "util/qtthreadsutils.h"
#include "util/HandleRichText.h" #include "util/HandleRichText.h"
#include "PhotoView.h" #include "PhotoView.h"
#include "ui_PostedItem.h" #include "ui_PostedItem.h"
@ -168,45 +169,80 @@ bool PostedItem::setPost(const RsPostedPost &post, bool doFill)
return true; return true;
} }
void PostedItem::loadGroup(const uint32_t &token) void PostedItem::loadGroup()
{ {
RsThread::async([this]()
{
// 1 - get group data
#ifdef DEBUG_FORUMS
std::cerr << "Retrieving post data for post " << mThreadId << std::endl;
#endif
std::vector<RsPostedGroup> groups; std::vector<RsPostedGroup> groups;
if (!rsPosted->getGroupData(token, groups)) const std::list<RsGxsGroupId> groupIds = { groupId() };
#warning Code needed in rsPosted
#ifdef TODO
if(!rsPosted->getPostedGroupInfo(groupIds,groups))
#endif
{ {
std::cerr << "PostedItem::loadGroup() ERROR getting data"; RsErr() << "GxsPostedGroupItem::loadGroup() ERROR getting data" << std::endl;
std::cerr << std::endl;
return; return;
} }
if (groups.size() != 1) if (groups.size() != 1)
{ {
std::cerr << "PostedItem::loadGroup() Wrong number of Items"; std::cerr << "GxsPostedGroupItem::loadGroup() Wrong number of Items";
std::cerr << std::endl; std::cerr << std::endl;
return; return;
} }
RsPostedGroup group(groups[0]);
setGroup(groups[0]); RsQThreadUtils::postToObject( [group,this]()
{
/* Here it goes any code you want to be executed on the Qt Gui
* thread, for example to update the data model with new information
* after a blocking call to RetroShare API complete */
setGroup(group);
}, this );
});
} }
void PostedItem::loadMessage(const uint32_t &token) void PostedItem::loadMessage()
{ {
RsThread::async([this]()
{
// 1 - get group data
std::vector<RsPostedPost> posts; std::vector<RsPostedPost> posts;
std::vector<RsGxsComment> cmts; std::vector<RsGxsComment> comments;
if (!rsPosted->getPostData(token, posts, cmts))
#warning Code needed in rsPosted
#ifdef TODO
if(! rsPosted->getPostedContent( groupId(), std::set<RsGxsMessageId>( { messageId() } ),posts,comments))
#endif
{ {
std::cerr << "GxsChannelPostItem::loadMessage() ERROR getting data"; RsErr() << "PostedItem::loadMessage() ERROR getting data" << std::endl;
std::cerr << std::endl;
return; return;
} }
if (posts.size() == 1) if (posts.size() == 1)
{ {
setPost(posts[0]); std::cerr << (void*)this << ": Obtained post, with msgId = " << posts[0].mMeta.mMsgId << std::endl;
} const RsPostedPost& post(posts[0]);
else if (cmts.size() == 1)
{
RsGxsComment cmt = cmts[0];
RsQThreadUtils::postToObject( [post,this]() { setPost(post); }, this );
}
else if(comments.size() == 1)
{
const RsGxsComment& cmt = comments[0];
std::cerr << (void*)this << ": Obtained comment, setting messageId to threadID = " << cmt.mMeta.mThreadId << std::endl;
RsQThreadUtils::postToObject( [cmt,this]()
{
ui->newCommentLabel->show(); ui->newCommentLabel->show();
ui->commLabel->show(); ui->commLabel->show();
ui->commLabel->setText(QString::fromUtf8(cmt.mComment.c_str())); ui->commLabel->setText(QString::fromUtf8(cmt.mComment.c_str()));
@ -214,42 +250,70 @@ void PostedItem::loadMessage(const uint32_t &token)
//Change this item to be uploaded with thread element. //Change this item to be uploaded with thread element.
setMessageId(cmt.mMeta.mThreadId); setMessageId(cmt.mMeta.mThreadId);
requestMessage(); requestMessage();
}, this );
} }
else else
{ {
std::cerr << "GxsChannelPostItem::loadMessage() Wrong number of Items. Remove It."; std::cerr << "GxsChannelPostItem::loadMessage() Wrong number of Items. Remove It.";
std::cerr << std::endl; std::cerr << std::endl;
removeItem();
return; RsQThreadUtils::postToObject( [this]() { removeItem(); }, this );
} }
});
} }
void PostedItem::loadComment(const uint32_t &token) void PostedItem::loadComment()
{ {
std::vector<RsGxsComment> cmts; #ifdef DEBUG_ITEM
if (!rsPosted->getRelatedComments(token, cmts)) std::cerr << "GxsChannelPostItem::loadComment()";
{
std::cerr << "GxsChannelPostItem::loadComment() ERROR getting data";
std::cerr << std::endl; std::cerr << std::endl;
#endif
RsThread::async([this]()
{
// 1 - get group data
std::set<RsGxsMessageId> msgIds;
for(auto MsgId: messageVersions())
msgIds.insert(MsgId);
std::vector<RsPostedPost> posts;
std::vector<RsGxsComment> comments;
#warning Code needed in rsPosted
#ifdef TODO
if(! rsPosted->getPostedContent( groupId(),msgIds,posts,comments))
#endif
{
RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
return; return;
} }
size_t comNb = cmts.size(); int comNb = comments.size();
RsQThreadUtils::postToObject( [comNb,this]()
{
QString sComButText = tr("Comment"); QString sComButText = tr("Comment");
if (comNb == 1) { if (comNb == 1)
sComButText = sComButText.append("(1)"); sComButText = sComButText.append("(1)");
} else if (comNb > 1) { else if(comNb > 1)
sComButText = " " + tr("Comments").append(" (%1)").arg(comNb); sComButText = tr("Comments ").append("(%1)").arg(comNb);
}
ui->commentButton->setText(sComButText); ui->commentButton->setText(sComButText);
}, this );
});
} }
void PostedItem::fill() void PostedItem::fill()
{ {
if (isLoading()) { // if (isLoading()) {
/* Wait for all requests */ // /* Wait for all requests */
return; // return;
} // }
QPixmap sqpixmap2 = QPixmap(":/images/thumb-default.png"); QPixmap sqpixmap2 = QPixmap(":/images/thumb-default.png");

View file

@ -71,13 +71,14 @@ signals:
protected: protected:
/* GxsGroupFeedItem */ /* GxsGroupFeedItem */
virtual QString groupName(); virtual QString groupName();
virtual void loadGroup(const uint32_t &token); virtual void loadGroup() override;
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_UNKNOWN; } virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_UNKNOWN; }
/* GxsFeedItem */ /* GxsFeedItem */
virtual QString messageName(); virtual QString messageName();
virtual void loadMessage(const uint32_t &token);
virtual void loadComment(const uint32_t &token); virtual void loadMessage();
virtual void loadComment();
private: private:
void setup(); void setup();

View file

@ -23,6 +23,7 @@
#include "ui_GxsChannelGroupItem.h" #include "ui_GxsChannelGroupItem.h"
#include "FeedHolder.h" #include "FeedHolder.h"
#include "util/qtthreadsutils.h"
#include "gui/NewsFeed.h" #include "gui/NewsFeed.h"
#include "gui/RetroShareLink.h" #include "gui/RetroShareLink.h"
@ -89,29 +90,39 @@ bool GxsChannelGroupItem::setGroup(const RsGxsChannelGroup &group)
return true; return true;
} }
void GxsChannelGroupItem::loadGroup(const uint32_t &token) void GxsChannelGroupItem::loadGroup()
{ {
#ifdef DEBUG_ITEM RsThread::async([this]()
std::cerr << "GxsChannelGroupItem::loadGroup()"; {
std::cerr << std::endl; // 1 - get group data
#endif
std::vector<RsGxsChannelGroup> groups; std::vector<RsGxsChannelGroup> groups;
if (!rsGxsChannels->getGroupData(token, groups)) const std::list<RsGxsGroupId> groupIds = { groupId() };
if(!rsGxsChannels->getChannelsInfo(groupIds,groups))
{ {
std::cerr << "GxsChannelGroupItem::loadGroup() ERROR getting data"; RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
std::cerr << std::endl;
return; return;
} }
if (groups.size() != 1) if (groups.size() != 1)
{ {
std::cerr << "GxsChannelGroupItem::loadGroup() Wrong number of Items"; std::cerr << "GxsGxsChannelGroupItem::loadGroup() Wrong number of Items";
std::cerr << std::endl; std::cerr << std::endl;
return; return;
} }
RsGxsChannelGroup group(groups[0]);
setGroup(groups[0]); RsQThreadUtils::postToObject( [group,this]()
{
/* Here it goes any code you want to be executed on the Qt Gui
* thread, for example to update the data model with new information
* after a blocking call to RetroShare API complete */
setGroup(group);
}, this );
});
} }
QString GxsChannelGroupItem::groupName() QString GxsChannelGroupItem::groupName()

View file

@ -48,7 +48,7 @@ protected:
/* GxsGroupFeedItem */ /* GxsGroupFeedItem */
virtual QString groupName(); virtual QString groupName();
virtual void loadGroup(const uint32_t &token); virtual void loadGroup() override;
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_CHANNEL; } virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_CHANNEL; }
private slots: private slots:

View file

@ -30,6 +30,7 @@
#include "FeedHolder.h" #include "FeedHolder.h"
#include "SubFileItem.h" #include "SubFileItem.h"
#include "util/misc.h" #include "util/misc.h"
#include "util/qtthreadsutils.h"
#include "gui/RetroShareLink.h" #include "gui/RetroShareLink.h"
#include "util/HandleRichText.h" #include "util/HandleRichText.h"
#include "util/DateTime.h" #include "util/DateTime.h"
@ -230,57 +231,79 @@ void GxsChannelPostItem::loadComments()
comments(title); comments(title);
} }
void GxsChannelPostItem::loadGroup(const uint32_t &token) void GxsChannelPostItem::loadGroup()
{ {
#ifdef DEBUG_ITEM #ifdef DEBUG_ITEM
std::cerr << "GxsChannelGroupItem::loadGroup()"; std::cerr << "GxsChannelGroupItem::loadGroup()";
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
std::vector<RsGxsChannelGroup> groups; RsThread::async([this]()
if (!rsGxsChannels->getGroupData(token, groups))
{ {
std::cerr << "GxsChannelGroupItem::loadGroup() ERROR getting data"; // 1 - get group data
std::cerr << std::endl;
std::vector<RsGxsChannelGroup> groups;
const std::list<RsGxsGroupId> groupIds = { groupId() };
if(!rsGxsChannels->getChannelsInfo(groupIds,groups))
{
RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
return; return;
} }
if (groups.size() != 1) if (groups.size() != 1)
{ {
std::cerr << "GxsChannelGroupItem::loadGroup() Wrong number of Items"; std::cerr << "GxsGxsChannelGroupItem::loadGroup() Wrong number of Items";
std::cerr << std::endl; std::cerr << std::endl;
return; return;
} }
RsGxsChannelGroup group(groups[0]);
setGroup(groups[0]); RsQThreadUtils::postToObject( [group,this]()
{
/* Here it goes any code you want to be executed on the Qt Gui
* thread, for example to update the data model with new information
* after a blocking call to RetroShare API complete */
setGroup(group);
}, this );
});
} }
void GxsChannelPostItem::loadMessage(const uint32_t &token) void GxsChannelPostItem::loadMessage()
{ {
#ifdef DEBUG_ITEM #ifdef DEBUG_ITEM
std::cerr << "GxsChannelPostItem::loadMessage()"; std::cerr << "GxsChannelPostItem::loadMessage()";
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
RsThread::async([this]()
{
// 1 - get group data
std::vector<RsGxsChannelPost> posts; std::vector<RsGxsChannelPost> posts;
std::vector<RsGxsComment> cmts; std::vector<RsGxsComment> comments;
if (!rsGxsChannels->getPostData(token, posts, cmts))
if(! rsGxsChannels->getChannelContent( groupId(), std::set<RsGxsMessageId>( { messageId() } ),posts,comments))
{ {
std::cerr << "GxsChannelPostItem::loadMessage() ERROR getting data"; RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
std::cerr << std::endl;
return; return;
} }
if (posts.size() == 1) if (posts.size() == 1)
{ {
std::cerr << (void*)this << ": Obtained post, with msgId = " << posts[0].mMeta.mMsgId << std::endl; std::cerr << (void*)this << ": Obtained post, with msgId = " << posts[0].mMeta.mMsgId << std::endl;
setPost(posts[0]); const RsGxsChannelPost& post(posts[0]);
}
else if (cmts.size() == 1)
{
RsGxsComment cmt = cmts[0];
RsQThreadUtils::postToObject( [post,this]() { setPost(post); }, this );
}
else if(comments.size() == 1)
{
const RsGxsComment& cmt = comments[0];
std::cerr << (void*)this << ": Obtained comment, setting messageId to threadID = " << cmt.mMeta.mThreadId << std::endl; std::cerr << (void*)this << ": Obtained comment, setting messageId to threadID = " << cmt.mMeta.mThreadId << std::endl;
RsQThreadUtils::postToObject( [cmt,this]()
{
ui->newCommentLabel->show(); ui->newCommentLabel->show();
ui->commLabel->show(); ui->commLabel->show();
ui->commLabel->setText(QString::fromUtf8(cmt.mComment.c_str())); ui->commLabel->setText(QString::fromUtf8(cmt.mComment.c_str()));
@ -288,49 +311,69 @@ void GxsChannelPostItem::loadMessage(const uint32_t &token)
//Change this item to be uploaded with thread element. //Change this item to be uploaded with thread element.
setMessageId(cmt.mMeta.mThreadId); setMessageId(cmt.mMeta.mThreadId);
requestMessage(); requestMessage();
}, this );
} }
else else
{ {
std::cerr << "GxsChannelPostItem::loadMessage() Wrong number of Items. Remove It."; std::cerr << "GxsChannelPostItem::loadMessage() Wrong number of Items. Remove It.";
std::cerr << std::endl; std::cerr << std::endl;
removeItem();
return; RsQThreadUtils::postToObject( [this]() { removeItem(); }, this );
} }
});
} }
void GxsChannelPostItem::loadComment(const uint32_t &token) void GxsChannelPostItem::loadComment()
{ {
#ifdef DEBUG_ITEM #ifdef DEBUG_ITEM
std::cerr << "GxsChannelPostItem::loadComment()"; std::cerr << "GxsChannelPostItem::loadComment()";
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
std::vector<RsGxsComment> cmts; RsThread::async([this]()
if (!rsGxsChannels->getRelatedComments(token, cmts))
{ {
std::cerr << "GxsChannelPostItem::loadComment() ERROR getting data"; // 1 - get group data
std::cerr << std::endl;
std::set<RsGxsMessageId> msgIds;
for(auto MsgId: messageVersions())
msgIds.insert(MsgId);
std::vector<RsGxsChannelPost> posts;
std::vector<RsGxsComment> comments;
if(! rsGxsChannels->getChannelContent( groupId(),msgIds,posts,comments))
{
RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
return; return;
} }
size_t comNb = cmts.size(); int comNb = comments.size();
RsQThreadUtils::postToObject( [comNb,this]()
{
QString sComButText = tr("Comment"); QString sComButText = tr("Comment");
if (comNb == 1) { if (comNb == 1)
sComButText = sComButText.append("(1)"); sComButText = sComButText.append("(1)");
} else if (comNb > 1) { else if(comNb > 1)
sComButText = tr("Comments ").append("(%1)").arg(comNb); sComButText = tr("Comments ").append("(%1)").arg(comNb);
}
ui->commentButton->setText(sComButText); ui->commentButton->setText(sComButText);
}, this );
});
} }
void GxsChannelPostItem::fill() void GxsChannelPostItem::fill()
{ {
/* fill in */ /* fill in */
if (isLoading()) { // if (isLoading()) {
/* Wait for all requests */ // /* Wait for all requests */
return; //return;
} // }
#ifdef DEBUG_ITEM #ifdef DEBUG_ITEM
std::cerr << "GxsChannelPostItem::fill()"; std::cerr << "GxsChannelPostItem::fill()";

View file

@ -81,13 +81,13 @@ protected:
/* GxsGroupFeedItem */ /* GxsGroupFeedItem */
virtual QString groupName(); virtual QString groupName();
virtual void loadGroup(const uint32_t &token); virtual void loadGroup() override;
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_CHANNEL; } virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_CHANNEL; }
/* GxsFeedItem */ /* GxsFeedItem */
virtual QString messageName(); virtual QString messageName();
virtual void loadMessage(const uint32_t &token); virtual void loadMessage();
virtual void loadComment(const uint32_t &token); virtual void loadComment();
private slots: private slots:
/* default stuff */ /* default stuff */

View file

@ -23,6 +23,7 @@
#include "FeedHolder.h" #include "FeedHolder.h"
#include "gui/RetroShareLink.h" #include "gui/RetroShareLink.h"
#include "util/qtthreadsutils.h"
/**** /****
* #define DEBUG_ITEM 1 * #define DEBUG_ITEM 1
@ -87,18 +88,22 @@ bool GxsForumGroupItem::setGroup(const RsGxsForumGroup &group)
return true; return true;
} }
void GxsForumGroupItem::loadGroup(const uint32_t &token) void GxsForumGroupItem::loadGroup()
{ {
#ifdef DEBUG_ITEM RsThread::async([this]()
std::cerr << "GxsForumGroupItem::loadGroup()"; {
std::cerr << std::endl; // 1 - get group data
#ifdef DEBUG_FORUMS
std::cerr << "Retrieving post data for post " << mThreadId << std::endl;
#endif #endif
std::vector<RsGxsForumGroup> groups; std::vector<RsGxsForumGroup> groups;
if (!rsGxsForums->getGroupData(token, groups)) const std::list<RsGxsGroupId> forumIds = { groupId() };
if(!rsGxsForums->getForumsInfo(forumIds,groups))
{ {
std::cerr << "GxsForumGroupItem::loadGroup() ERROR getting data"; RsErr() << "GxsForumGroupItem::loadGroup() ERROR getting data" << std::endl;
std::cerr << std::endl;
return; return;
} }
@ -108,8 +113,18 @@ void GxsForumGroupItem::loadGroup(const uint32_t &token)
std::cerr << std::endl; std::cerr << std::endl;
return; return;
} }
const RsGxsForumGroup& group(groups[0]);
setGroup(groups[0]); RsQThreadUtils::postToObject( [group,this]()
{
/* Here it goes any code you want to be executed on the Qt Gui
* thread, for example to update the data model with new information
* after a blocking call to RetroShare API complete */
setGroup(group);
}, this );
});
} }
QString GxsForumGroupItem::groupName() QString GxsForumGroupItem::groupName()

View file

@ -50,7 +50,7 @@ protected:
/* GxsGroupFeedItem */ /* GxsGroupFeedItem */
virtual QString groupName(); virtual QString groupName();
virtual void loadGroup(const uint32_t &token); virtual void loadGroup() override;
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_FORUM; } virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_FORUM; }
private slots: private slots:

View file

@ -30,6 +30,7 @@
#include "gui/RetroShareLink.h" #include "gui/RetroShareLink.h"
#include "gui/gxs/GxsIdDetails.h" #include "gui/gxs/GxsIdDetails.h"
#include "util/HandleRichText.h" #include "util/HandleRichText.h"
#include "util/qtthreadsutils.h"
#include "util/DateTime.h" #include "util/DateTime.h"
#include <retroshare/rsidentity.h> #include <retroshare/rsidentity.h>
@ -94,7 +95,6 @@ void GxsForumMsgItem::setup()
mInFill = false; mInFill = false;
mCloseOnRead = false; mCloseOnRead = false;
mTokenTypeParentMessage = nextTokenType();
/* clear ui */ /* clear ui */
ui->titleLabel->setText(tr("Loading")); ui->titleLabel->setText(tr("Loading"));
@ -154,13 +154,10 @@ bool GxsForumMsgItem::setMessage(const RsGxsForumMsg &msg, bool doFill)
mMessage = msg; mMessage = msg;
if (!isTop()) { if (!isTop())
requestParentMessage(mMessage.mMeta.mParentId); loadParentMessage(mMessage.mMeta.mParentId);
} else { else if(doFill)
if (doFill) {
fill(); fill();
}
}
return true; return true;
} }
@ -170,18 +167,22 @@ QString GxsForumMsgItem::groupName()
return QString::fromUtf8(mGroup.mMeta.mGroupName.c_str()); return QString::fromUtf8(mGroup.mMeta.mGroupName.c_str());
} }
void GxsForumMsgItem::loadGroup(const uint32_t &token) void GxsForumMsgItem::loadGroup()
{ {
#ifdef DEBUG_ITEM RsThread::async([this]()
std::cerr << "GxsForumGroupItem::loadGroup()"; {
std::cerr << std::endl; // 1 - get group data
#ifdef DEBUG_FORUMS
std::cerr << "Retrieving post data for post " << mThreadId << std::endl;
#endif #endif
std::vector<RsGxsForumGroup> groups; std::vector<RsGxsForumGroup> groups;
if (!rsGxsForums->getGroupData(token, groups)) const std::list<RsGxsGroupId> forumIds = { groupId() };
if(!rsGxsForums->getForumsInfo(forumIds,groups))
{ {
std::cerr << "GxsForumGroupItem::loadGroup() ERROR getting data"; RsErr() << "GxsForumGroupItem::loadGroup() ERROR getting data" << std::endl;
std::cerr << std::endl;
return; return;
} }
@ -191,19 +192,39 @@ void GxsForumMsgItem::loadGroup(const uint32_t &token)
std::cerr << std::endl; std::cerr << std::endl;
return; return;
} }
RsGxsForumGroup group(groups[0]);
setGroup(groups[0]); RsQThreadUtils::postToObject( [group,this]()
{
/* Here it goes any code you want to be executed on the Qt Gui
* thread, for example to update the data model with new information
* after a blocking call to RetroShare API complete */
setGroup(group);
}, this );
});
} }
void GxsForumMsgItem::loadMessage(const uint32_t &token) void GxsForumMsgItem::loadMessage()
{ {
#ifdef DEBUG_ITEM #ifdef DEBUG_ITEM
std::cerr << "GxsForumMsgItem::loadMessage()"; std::cerr << "GxsForumMsgItem::loadMessage()";
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
RsThread::async([this]()
{
// 1 - get group data
#ifdef DEBUG_FORUMS
std::cerr << "Retrieving post data for post " << mThreadId << std::endl;
#endif
std::vector<RsGxsForumMsg> msgs; std::vector<RsGxsForumMsg> msgs;
if (!rsGxsForums->getMsgData(token, msgs)) const std::list<RsGxsGroupId> forumIds = { groupId() };
if(!rsGxsForums->getForumContent(groupId(),std::set<RsGxsMessageId>( { messageId() } ),msgs))
{ {
std::cerr << "GxsForumMsgItem::loadMessage() ERROR getting data"; std::cerr << "GxsForumMsgItem::loadMessage() ERROR getting data";
std::cerr << std::endl; std::cerr << std::endl;
@ -216,45 +237,74 @@ void GxsForumMsgItem::loadMessage(const uint32_t &token)
std::cerr << std::endl; std::cerr << std::endl;
return; return;
} }
const RsGxsForumMsg& msg(msgs[0]);
setMessage(msgs[0]); RsQThreadUtils::postToObject( [msg,this]()
{
/* Here it goes any code you want to be executed on the Qt Gui
* thread, for example to update the data model with new information
* after a blocking call to RetroShare API complete */
setMessage(msg);
}, this );
});
} }
void GxsForumMsgItem::loadParentMessage(const uint32_t &token) void GxsForumMsgItem::loadParentMessage(const RsGxsMessageId& parent_msg)
{ {
#ifdef DEBUG_ITEM #ifdef DEBUG_ITEM
std::cerr << "GxsForumMsgItem::loadParentMessage()"; std::cerr << "GxsForumMsgItem::loadParentMessage()";
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
std::vector<RsGxsForumMsg> msgs; RsThread::async([parent_msg,this]()
if (!rsGxsForums->getMsgData(token, msgs))
{ {
std::cerr << "GxsForumMsgItem::loadParentMessage() ERROR getting data"; // 1 - get group data
#ifdef DEBUG_FORUMS
std::cerr << "Retrieving post data for post " << mThreadId << std::endl;
#endif
std::vector<RsGxsForumMsg> msgs;
const std::list<RsGxsGroupId> forumIds = { groupId() };
if(!rsGxsForums->getForumContent(groupId(),std::set<RsGxsMessageId>( { parent_msg } ),msgs))
{
std::cerr << "GxsForumMsgItem::loadMessage() ERROR getting data";
std::cerr << std::endl; std::cerr << std::endl;
return; return;
} }
if (msgs.size() != 1) if (msgs.size() != 1)
{ {
std::cerr << "GxsForumMsgItem::loadParentMessage() Wrong number of Items"; std::cerr << "GxsForumMsgItem::loadMessage() Wrong number of Items";
std::cerr << std::endl; std::cerr << std::endl;
return; return;
} }
const RsGxsForumMsg& msg(msgs[0]);
mParentMessage = msgs[0]; RsQThreadUtils::postToObject( [msg,this]()
{
/* Here it goes any code you want to be executed on the Qt Gui
* thread, for example to update the data model with new information
* after a blocking call to RetroShare API complete */
mParentMessage = msg;
fill(); fill();
}, this );
});
} }
void GxsForumMsgItem::fill() void GxsForumMsgItem::fill()
{ {
/* fill in */ /* fill in */
if (isLoading()) { // if (isLoading()) {
/* Wait for all requests */ // /* Wait for all requests */
return; // return;
} // }
#ifdef DEBUG_ITEM #ifdef DEBUG_ITEM
std::cerr << "GxsForumMsgItem::fill()"; std::cerr << "GxsForumMsgItem::fill()";
@ -307,18 +357,6 @@ void GxsForumMsgItem::fill()
ui->nameLabel->setId(mMessage.mMeta.mAuthorId); ui->nameLabel->setId(mMessage.mMeta.mAuthorId);
// ui->avatar->setId(msg.srcId, true);
// if (rsPeers->getPeerName(msg.srcId) != "") {
// RetroShareLink linkMessage;
// linkMessage.createMessage(msg.srcId, "");
// nameLabel->setText(linkMessage.toHtml());
// }
// else
// {
// nameLabel->setText(tr("Anonymous"));
// }
RetroShareLink msgLink = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_FORUM, mMessage.mMeta.mGroupId, mMessage.mMeta.mMsgId, messageName()); RetroShareLink msgLink = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_FORUM, mMessage.mMeta.mGroupId, mMessage.mMeta.mMsgId, messageName());
ui->subLabel->setText(msgLink.toHtml()); ui->subLabel->setText(msgLink.toHtml());
if (wasExpanded() || ui->expandFrame->isVisible()) { if (wasExpanded() || ui->expandFrame->isVisible()) {
@ -330,7 +368,6 @@ void GxsForumMsgItem::fill()
if (isTop()) { if (isTop()) {
ui->parentFrame->hide(); ui->parentFrame->hide();
} else { } else {
// ui->parentAvatar->setId(msgParent.srcId, true);
RetroShareLink linkParent = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_FORUM, mParentMessage.mMeta.mGroupId, mParentMessage.mMeta.mMsgId, QString::fromUtf8(mParentMessage.mMeta.mMsgName.c_str())); RetroShareLink linkParent = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_FORUM, mParentMessage.mMeta.mGroupId, mParentMessage.mMeta.mMsgId, QString::fromUtf8(mParentMessage.mMeta.mMsgName.c_str()));
ui->parentSubLabel->setText(linkParent.toHtml()); ui->parentSubLabel->setText(linkParent.toHtml());
@ -348,16 +385,6 @@ void GxsForumMsgItem::fill()
ui->parentAvatar->setPixmap(pixmap); ui->parentAvatar->setPixmap(pixmap);
// if (rsPeers->getPeerName(msgParent.srcId) !="")
// {
// RetroShareLink linkMessage;
// linkMessage.createMessage(msgParent.srcId, "");
// ui->parentNameLabel->setText(linkMessage.toHtml());
// }
// else
// {
// ui->parentNameLabel->setText(tr("Anonymous"));
// }
} }
/* header stuff */ /* header stuff */
@ -440,63 +467,6 @@ void GxsForumMsgItem::setReadStatus(bool isNew, bool /*isUnread*/)
ui->frame->style()->polish( ui->frame); ui->frame->style()->polish( ui->frame);
} }
void GxsForumMsgItem::requestParentMessage(const RsGxsMessageId &msgId)
{
#ifdef DEBUG_ITEM
std::cerr << "GxsFeedItem::requestMessage()";
std::cerr << std::endl;
#endif
if (!initLoadQueue()) {
return;
}
if (mLoadQueue->activeRequestExist(mTokenTypeParentMessage)) {
/* Request already running */
return;
}
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
GxsMsgReq msgIds;
std::set<RsGxsMessageId> &vect_msgIds = msgIds[groupId()];
vect_msgIds.insert(msgId);
uint32_t token;
mLoadQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeParentMessage);
}
void GxsForumMsgItem::loadRequest(const TokenQueue *queue, const TokenRequest &req)
{
#ifdef DEBUG_ITEM
std::cerr << "GxsFeedItem::loadRequest()";
std::cerr << std::endl;
#endif
if (queue == mLoadQueue) {
if (req.mUserType == mTokenTypeParentMessage) {
loadParentMessage(req.mToken);
return;
}
}
GxsFeedItem::loadRequest(queue, req);
}
bool GxsForumMsgItem::isLoading()
{
if (GxsFeedItem::isLoading()) {
return true;
}
if (mLoadQueue && mLoadQueue->activeRequestExist(mTokenTypeParentMessage)) {
return true;
}
return false;
}
/*********** SPECIFIC FUNCTIONS ***********************/ /*********** SPECIFIC FUNCTIONS ***********************/
void GxsForumMsgItem::readAndClearItem() void GxsForumMsgItem::readAndClearItem()

View file

@ -50,20 +50,18 @@ protected:
virtual void expandFill(bool first); virtual void expandFill(bool first);
/* load message data */ /* load message data */
void requestParentMessage(const RsGxsMessageId &msgId); virtual void loadParentMessage(const RsGxsMessageId &parent_msg);
virtual void loadParentMessage(const uint32_t &token);
/* GxsGroupFeedItem */ /* GxsGroupFeedItem */
virtual QString groupName(); virtual QString groupName();
virtual void loadGroup(const uint32_t &token); virtual void loadGroup() override;
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_FORUM; } virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_FORUM; }
virtual bool isLoading(); //virtual bool isLoading();
/* GxsFeedItem */ /* GxsFeedItem */
virtual QString messageName(); virtual QString messageName();
virtual void loadMessage(const uint32_t &token); virtual void loadMessage() override;
virtual void loadComment(const uint32_t &/*token*/){ return;} virtual void loadComment() override { return; }
private slots: private slots:
/* default stuff */ /* default stuff */
@ -90,7 +88,6 @@ private:
RsGxsForumGroup mGroup; RsGxsForumGroup mGroup;
RsGxsForumMsg mMessage; RsGxsForumMsg mMessage;
RsGxsForumMsg mParentMessage; RsGxsForumMsg mParentMessage;
uint32_t mTokenTypeParentMessage;
/** Qt Designer generated object */ /** Qt Designer generated object */
Ui::GxsForumMsgItem *ui; Ui::GxsForumMsgItem *ui;

View file

@ -22,6 +22,7 @@
#include "ui_PostedGroupItem.h" #include "ui_PostedGroupItem.h"
#include "FeedHolder.h" #include "FeedHolder.h"
#include "util/qtthreadsutils.h"
#include "gui/RetroShareLink.h" #include "gui/RetroShareLink.h"
#include "gui/gxs/GxsIdDetails.h" #include "gui/gxs/GxsIdDetails.h"
@ -90,29 +91,46 @@ bool PostedGroupItem::setGroup(const RsPostedGroup &group)
return true; return true;
} }
void PostedGroupItem::loadGroup(const uint32_t &token) void PostedGroupItem::loadGroup()
{ {
#ifdef DEBUG_ITEM RsThread::async([this]()
std::cerr << "PostedGroupItem::loadGroup()"; {
std::cerr << std::endl; // 1 - get group data
#ifdef DEBUG_FORUMS
std::cerr << "Retrieving post data for post " << mThreadId << std::endl;
#endif #endif
std::vector<RsPostedGroup> groups; std::vector<RsPostedGroup> groups;
if (!rsPosted->getGroupData(token, groups)) const std::list<RsGxsGroupId> groupIds = { groupId() };
#warning Code needed in rsPosted
#ifdef TODO
if(!rsPosted->getPostedGroupInfo(groupIds,groups))
#endif
{ {
std::cerr << "PostedGroupItem::loadGroup() ERROR getting data"; RsErr() << "GxsPostedGroupItem::loadGroup() ERROR getting data" << std::endl;
std::cerr << std::endl;
return; return;
} }
if (groups.size() != 1) if (groups.size() != 1)
{ {
std::cerr << "PostedGroupItem::loadGroup() Wrong number of Items"; std::cerr << "GxsPostedGroupItem::loadGroup() Wrong number of Items";
std::cerr << std::endl; std::cerr << std::endl;
return; return;
} }
RsPostedGroup group(groups[0]);
setGroup(groups[0]); RsQThreadUtils::postToObject( [group,this]()
{
/* Here it goes any code you want to be executed on the Qt Gui
* thread, for example to update the data model with new information
* after a blocking call to RetroShare API complete */
setGroup(group);
}, this );
});
} }
QString PostedGroupItem::groupName() QString PostedGroupItem::groupName()

View file

@ -50,7 +50,7 @@ protected:
/* GxsGroupFeedItem */ /* GxsGroupFeedItem */
virtual QString groupName(); virtual QString groupName();
virtual void loadGroup(const uint32_t &token); virtual void loadGroup() override;
virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_UNKNOWN; } virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_UNKNOWN; }
private slots: private slots:

View file

@ -40,8 +40,10 @@ GxsFeedItem::GxsFeedItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGro
/* load data if we can */ /* load data if we can */
mMessageId = messageId; mMessageId = messageId;
#ifdef TO_REMOVE
mTokenTypeMessage = nextTokenType(); mTokenTypeMessage = nextTokenType();
mTokenTypeComment = nextTokenType(); mTokenTypeComment = nextTokenType();
#endif
} }
GxsFeedItem::~GxsFeedItem() GxsFeedItem::~GxsFeedItem()
@ -106,6 +108,8 @@ void GxsFeedItem::fillDisplay(RsGxsUpdateBroadcastBase *updateBroadcastBase, boo
void GxsFeedItem::requestMessage() void GxsFeedItem::requestMessage()
{ {
loadMessage();
#ifdef TO_REMOVE
#ifdef DEBUG_ITEM #ifdef DEBUG_ITEM
std::cerr << "GxsFeedItem::requestMessage()"; std::cerr << "GxsFeedItem::requestMessage()";
std::cerr << std::endl; std::cerr << std::endl;
@ -129,15 +133,19 @@ void GxsFeedItem::requestMessage()
uint32_t token; uint32_t token;
mLoadQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeMessage); mLoadQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeMessage);
#endif
} }
void GxsFeedItem::requestComment() void GxsFeedItem::requestComment()
{ {
loadComment();
#ifdef TO_REMOVE
#ifdef DEBUG_ITEM #ifdef DEBUG_ITEM
std::cerr << "GxsFeedItem::requestComment()"; std::cerr << "GxsFeedItem::requestComment()";
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
#ifdef TO_REMOVE
if (!initLoadQueue()) { if (!initLoadQueue()) {
return; return;
} }
@ -146,6 +154,7 @@ void GxsFeedItem::requestComment()
/* Request already running */ /* Request already running */
return; return;
} }
#endif
RsTokReqOptions opts; RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA; opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA;
@ -153,15 +162,17 @@ void GxsFeedItem::requestComment()
std::vector<RsGxsGrpMsgIdPair> msgIds; std::vector<RsGxsGrpMsgIdPair> msgIds;
for(int i=0;i<mMessageVersions.size();++i) for(int i=0;i<mmessageversions.size();++i)
msgIds.push_back(std::make_pair(groupId(),mMessageVersions[i])) ; msgids.push_back(std::make_pair(groupid(),mmessageversions[i])) ;
msgIds.push_back(std::make_pair(groupId(),messageId())); msgids.push_back(std::make_pair(groupid(),messageid()));
uint32_t token; uint32_t token;
mLoadQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeComment); mLoadQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeComment);
#endif
} }
#ifdef TO_REMOVE
void GxsFeedItem::loadRequest(const TokenQueue *queue, const TokenRequest &req) void GxsFeedItem::loadRequest(const TokenQueue *queue, const TokenRequest &req)
{ {
#ifdef DEBUG_ITEM #ifdef DEBUG_ITEM
@ -195,3 +206,4 @@ bool GxsFeedItem::isLoading()
return false; return false;
} }
#endif

View file

@ -45,15 +45,17 @@ protected:
void requestComment(); void requestComment();
virtual QString messageName() = 0; virtual QString messageName() = 0;
virtual void loadMessage(const uint32_t &token) = 0; virtual void loadMessage() = 0;
virtual void loadComment(const uint32_t &token) = 0; virtual void loadComment() = 0;
/* GxsGroupFeedItem */ /* GxsGroupFeedItem */
virtual bool isLoading(); //virtual bool isLoading();
//virtual void fillDisplay(RsGxsUpdateBroadcastBase *updateBroadcastBase, bool complete); //virtual void fillDisplay(RsGxsUpdateBroadcastBase *updateBroadcastBase, bool complete);
#ifdef TO_REMOVE
/* TokenResponse */ /* TokenResponse */
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req); virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
#endif
protected slots: protected slots:
void comments(const QString &title); void comments(const QString &title);

View file

@ -46,12 +46,12 @@ GxsGroupFeedItem::GxsGroupFeedItem(FeedHolder *feedHolder, uint32_t feedId, cons
mGroupId = groupId; mGroupId = groupId;
mGxsIface = iface; mGxsIface = iface;
#ifdef TO_REMOVE
mNextTokenType = 0; mNextTokenType = 0;
mTokenTypeGroup = nextTokenType(); mTokenTypeGroup = nextTokenType();
mLoadQueue = NULL; mLoadQueue = NULL;
#ifdef TO_REMOVE
if (mGxsIface && autoUpdate) { if (mGxsIface && autoUpdate) {
/* Connect to update broadcast */ /* Connect to update broadcast */
mUpdateBroadcastBase = new RsGxsUpdateBroadcastBase(mGxsIface); mUpdateBroadcastBase = new RsGxsUpdateBroadcastBase(mGxsIface);
@ -69,11 +69,11 @@ GxsGroupFeedItem::~GxsGroupFeedItem()
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
#ifdef TO_REMOVE
if (mLoadQueue) { if (mLoadQueue) {
delete mLoadQueue; delete mLoadQueue;
} }
#ifdef TO_REMOVE
if (mUpdateBroadcastBase) if (mUpdateBroadcastBase)
{ {
delete(mUpdateBroadcastBase); delete(mUpdateBroadcastBase);
@ -81,20 +81,6 @@ GxsGroupFeedItem::~GxsGroupFeedItem()
#endif #endif
} }
bool GxsGroupFeedItem::initLoadQueue()
{
if (mLoadQueue) {
return true;
}
if (!mGxsIface) {
return false;
}
mLoadQueue = new TokenQueue(mGxsIface->getTokenService(), this);
return (mLoadQueue != NULL);
}
void GxsGroupFeedItem::unsubscribe() void GxsGroupFeedItem::unsubscribe()
{ {
#ifdef DEBUG_ITEM #ifdef DEBUG_ITEM
@ -144,7 +130,6 @@ void GxsGroupFeedItem::copyGroupLink()
void GxsGroupFeedItem::fillDisplaySlot(bool complete) void GxsGroupFeedItem::fillDisplaySlot(bool complete)
{ {
requestGroup(); requestGroup();
// fillDisplay(mUpdateBroadcastBase, complete);
} }
#ifdef TO_REMOVE #ifdef TO_REMOVE
@ -162,51 +147,6 @@ void GxsGroupFeedItem::fillDisplay(RsGxsUpdateBroadcastBase *updateBroadcastBase
void GxsGroupFeedItem::requestGroup() void GxsGroupFeedItem::requestGroup()
{ {
#ifdef DEBUG_ITEM loadGroup();
std::cerr << "GxsGroupFeedItem::requestGroup()";
std::cerr << std::endl;
#endif
if (!initLoadQueue()) {
return;
} }
if (mLoadQueue->activeRequestExist(mTokenTypeGroup)) {
/* Request already running */
return;
}
std::list<RsGxsGroupId> ids;
ids.push_back(mGroupId);
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
uint32_t token;
mLoadQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, ids, mTokenTypeGroup);
}
void GxsGroupFeedItem::loadRequest(const TokenQueue *queue, const TokenRequest &req)
{
#ifdef DEBUG_ITEM
std::cerr << "GxsGroupFeedItem::loadRequest()";
std::cerr << std::endl;
#endif
if (queue == mLoadQueue) {
if (req.mUserType == mTokenTypeGroup) {
loadGroup(req.mToken);
} else {
std::cerr << "GxsGroupFeedItem::loadRequest() ERROR: INVALID TYPE";
std::cerr << std::endl;
}
}
}
bool GxsGroupFeedItem::isLoading()
{
if (mLoadQueue && mLoadQueue->activeRequestExist(mTokenTypeGroup)) {
return true;
}
return false;
}

View file

@ -25,7 +25,6 @@
#include <retroshare/rsgxsifacehelper.h> #include <retroshare/rsgxsifacehelper.h>
#include "gui/feeds/FeedItem.h" #include "gui/feeds/FeedItem.h"
#include "util/TokenQueue.h"
#include "gui/RetroShareLink.h" #include "gui/RetroShareLink.h"
#include <stdint.h> #include <stdint.h>
@ -33,7 +32,7 @@
class FeedHolder; class FeedHolder;
class RsGxsUpdateBroadcastBase; class RsGxsUpdateBroadcastBase;
class GxsGroupFeedItem : public FeedItem, public TokenResponse class GxsGroupFeedItem : public FeedItem
{ {
Q_OBJECT Q_OBJECT
@ -46,20 +45,12 @@ public:
uint32_t feedId() const { return mFeedId; } uint32_t feedId() const { return mFeedId; }
protected: protected:
uint32_t nextTokenType() { return ++mNextTokenType; }
bool initLoadQueue();
/* load group data */ /* load group data */
void requestGroup(); void requestGroup();
virtual bool isLoading(); virtual void loadGroup() = 0;
virtual void loadGroup(const uint32_t &token) = 0;
virtual RetroShareLink::enumType getLinkType() = 0; virtual RetroShareLink::enumType getLinkType() = 0;
virtual QString groupName() = 0; virtual QString groupName() = 0;
//virtual void fillDisplay(RsGxsUpdateBroadcastBase *updateBroadcastBase, bool complete);
/* TokenResponse */
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
protected slots: protected slots:
void subscribe(); void subscribe();
@ -69,7 +60,6 @@ protected slots:
protected: protected:
bool mIsHome; bool mIsHome;
RsGxsIfaceHelper *mGxsIface; RsGxsIfaceHelper *mGxsIface;
TokenQueue *mLoadQueue;
private slots: private slots:
/* RsGxsUpdateBroadcastBase */ /* RsGxsUpdateBroadcastBase */
@ -77,9 +67,6 @@ private slots:
private: private:
RsGxsGroupId mGroupId; RsGxsGroupId mGroupId;
// RsGxsUpdateBroadcastBase *mUpdateBroadcastBase;
uint32_t mNextTokenType;
uint32_t mTokenTypeGroup;
}; };
Q_DECLARE_METATYPE(RsGxsGroupId) Q_DECLARE_METATYPE(RsGxsGroupId)