diff --git a/retroshare-gui/src/gui/Posted/PostedCardView.cpp b/retroshare-gui/src/gui/Posted/PostedCardView.cpp index 1fef4f160..59d8976cc 100644 --- a/retroshare-gui/src/gui/Posted/PostedCardView.cpp +++ b/retroshare-gui/src/gui/Posted/PostedCardView.cpp @@ -28,6 +28,7 @@ #include "gui/feeds/FeedHolder.h" #include "gui/gxs/GxsIdDetails.h" #include "util/misc.h" +#include "util/qtthreadsutils.h" #include "util/HandleRichText.h" #include "ui_PostedCardView.h" @@ -158,88 +159,143 @@ bool PostedCardView::setPost(const RsPostedPost &post, bool doFill) return true; } -void PostedCardView::loadGroup(const uint32_t &token) +void PostedCardView::loadGroup() { - std::vector groups; - if (!rsPosted->getGroupData(token, groups)) + RsThread::async([this]() { - std::cerr << "PostedCardView::loadGroup() ERROR getting data"; - std::cerr << std::endl; - return; - } + // 1 - get group data - if (groups.size() != 1) - { - std::cerr << "PostedCardView::loadGroup() Wrong number of Items"; - std::cerr << std::endl; - return; - } +#ifdef DEBUG_FORUMS + std::cerr << "Retrieving post data for post " << mThreadId << std::endl; +#endif - setGroup(groups[0]); + std::vector groups; + const std::list groupIds = { groupId() }; + +#warning Code needed in rsPosted +#ifdef TODO + if(!rsPosted->getPostedGroupInfo(groupIds,groups)) +#endif + { + RsErr() << "GxsPostedGroupItem::loadGroup() ERROR getting data" << std::endl; + return; + } + + if (groups.size() != 1) + { + std::cerr << "GxsPostedGroupItem::loadGroup() Wrong number of Items"; + std::cerr << std::endl; + return; + } + RsPostedGroup group(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() { - std::vector posts; - std::vector cmts; - if (!rsPosted->getPostData(token, posts, cmts)) + RsThread::async([this]() { - std::cerr << "GxsChannelPostItem::loadMessage() ERROR getting data"; - std::cerr << std::endl; - return; - } + // 1 - get group data - if (posts.size() == 1) - { - setPost(posts[0]); - } - else if (cmts.size() == 1) - { - RsGxsComment cmt = cmts[0]; + std::vector posts; + std::vector comments; - //ui->newCommentLabel->show(); - //ui->commLabel->show(); - //ui->commLabel->setText(QString::fromUtf8(cmt.mComment.c_str())); +#warning Code needed in rsPosted +#ifdef TODO + if(! rsPosted->getPostedContent( groupId(), std::set( { messageId() } ),posts,comments)) +#endif + { + RsErr() << "PostedItem::loadMessage() ERROR getting data" << std::endl; + return; + } + + if (posts.size() == 1) + { + 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(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]() + { + //Change this item to be uploaded with thread element. + setMessageId(cmt.mMeta.mThreadId); + requestMessage(); + + }, this ); + + } + else + { + std::cerr << "GxsChannelPostItem::loadMessage() Wrong number of Items. Remove It."; + std::cerr << std::endl; + + RsQThreadUtils::postToObject( [this]() { removeItem(); }, this ); + } + }); - //Change this item to be uploaded with thread element. - setMessageId(cmt.mMeta.mThreadId); - requestMessage(); - } - else - { - std::cerr << "GxsChannelPostItem::loadMessage() Wrong number of Items. Remove It."; - std::cerr << std::endl; - removeItem(); - return; - } } -void PostedCardView::loadComment(const uint32_t &token) +void PostedCardView::loadComment() { - std::vector cmts; - if (!rsPosted->getRelatedComments(token, cmts)) + RsThread::async([this]() { - std::cerr << "GxsChannelPostItem::loadComment() ERROR getting data"; - std::cerr << std::endl; - return; - } + // 1 - get group data - size_t comNb = cmts.size(); - QString sComButText = tr("Comment"); - if (comNb == 1) { - sComButText = sComButText.append("(1)"); - } else if (comNb > 1) { - sComButText = " " + tr("Comments").append(" (%1)").arg(comNb); - } - ui->commentButton->setText(sComButText); + std::set msgIds; + + for(auto MsgId: messageVersions()) + msgIds.insert(MsgId); + + std::vector posts; + std::vector 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; + } + + int comNb = comments.size(); + + RsQThreadUtils::postToObject( [comNb,this]() + { + QString sComButText = tr("Comment"); + if (comNb == 1) + sComButText = sComButText.append("(1)"); + else if(comNb > 1) + sComButText = tr("Comments ").append("(%1)").arg(comNb); + + ui->commentButton->setText(sComButText); + + }, this ); + }); } void PostedCardView::fill() { - if (isLoading()) { - /* Wait for all requests */ - return; - } +// if (isLoading()) { +// /* Wait for all requests */ +// return; +// } QPixmap sqpixmap2 = QPixmap(":/images/thumb-default.png"); diff --git a/retroshare-gui/src/gui/Posted/PostedCardView.h b/retroshare-gui/src/gui/Posted/PostedCardView.h index 7fc303680..49f6e68c4 100644 --- a/retroshare-gui/src/gui/Posted/PostedCardView.h +++ b/retroshare-gui/src/gui/Posted/PostedCardView.h @@ -69,13 +69,13 @@ signals: protected: /* GxsGroupFeedItem */ virtual QString groupName(); - virtual void loadGroup(const uint32_t &token); + virtual void loadGroup() override; virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_UNKNOWN; } /* GxsFeedItem */ virtual QString messageName(); - virtual void loadMessage(const uint32_t &token); - virtual void loadComment(const uint32_t &token); + virtual void loadMessage(); + virtual void loadComment(); private: void setup(); diff --git a/retroshare-gui/src/gui/Posted/PostedItem.cpp b/retroshare-gui/src/gui/Posted/PostedItem.cpp index b09452a8e..01e02738f 100644 --- a/retroshare-gui/src/gui/Posted/PostedItem.cpp +++ b/retroshare-gui/src/gui/Posted/PostedItem.cpp @@ -28,6 +28,7 @@ #include "gui/feeds/FeedHolder.h" #include "gui/gxs/GxsIdDetails.h" #include "util/misc.h" +#include "util/qtthreadsutils.h" #include "util/HandleRichText.h" #include "PhotoView.h" #include "ui_PostedItem.h" @@ -168,88 +169,151 @@ bool PostedItem::setPost(const RsPostedPost &post, bool doFill) return true; } -void PostedItem::loadGroup(const uint32_t &token) +void PostedItem::loadGroup() { - std::vector groups; - if (!rsPosted->getGroupData(token, groups)) + RsThread::async([this]() { - std::cerr << "PostedItem::loadGroup() ERROR getting data"; - std::cerr << std::endl; - return; - } + // 1 - get group data - if (groups.size() != 1) - { - std::cerr << "PostedItem::loadGroup() Wrong number of Items"; - std::cerr << std::endl; - return; - } +#ifdef DEBUG_FORUMS + std::cerr << "Retrieving post data for post " << mThreadId << std::endl; +#endif - setGroup(groups[0]); + std::vector groups; + const std::list groupIds = { groupId() }; + +#warning Code needed in rsPosted +#ifdef TODO + if(!rsPosted->getPostedGroupInfo(groupIds,groups)) +#endif + { + RsErr() << "GxsPostedGroupItem::loadGroup() ERROR getting data" << std::endl; + return; + } + + if (groups.size() != 1) + { + std::cerr << "GxsPostedGroupItem::loadGroup() Wrong number of Items"; + std::cerr << std::endl; + return; + } + RsPostedGroup group(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() { - std::vector posts; - std::vector cmts; - if (!rsPosted->getPostData(token, posts, cmts)) + RsThread::async([this]() { - std::cerr << "GxsChannelPostItem::loadMessage() ERROR getting data"; - std::cerr << std::endl; - return; - } + // 1 - get group data - if (posts.size() == 1) - { - setPost(posts[0]); - } - else if (cmts.size() == 1) - { - RsGxsComment cmt = cmts[0]; + std::vector posts; + std::vector comments; - ui->newCommentLabel->show(); - ui->commLabel->show(); - ui->commLabel->setText(QString::fromUtf8(cmt.mComment.c_str())); +#warning Code needed in rsPosted +#ifdef TODO + if(! rsPosted->getPostedContent( groupId(), std::set( { messageId() } ),posts,comments)) +#endif + { + RsErr() << "PostedItem::loadMessage() ERROR getting data" << std::endl; + return; + } - //Change this item to be uploaded with thread element. - setMessageId(cmt.mMeta.mThreadId); - requestMessage(); - } - else - { - std::cerr << "GxsChannelPostItem::loadMessage() Wrong number of Items. Remove It."; - std::cerr << std::endl; - removeItem(); - return; - } + if (posts.size() == 1) + { + 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(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->commLabel->show(); + ui->commLabel->setText(QString::fromUtf8(cmt.mComment.c_str())); + + //Change this item to be uploaded with thread element. + setMessageId(cmt.mMeta.mThreadId); + requestMessage(); + + }, this ); + + } + else + { + std::cerr << "GxsChannelPostItem::loadMessage() Wrong number of Items. Remove It."; + std::cerr << std::endl; + + RsQThreadUtils::postToObject( [this]() { removeItem(); }, this ); + } + }); } -void PostedItem::loadComment(const uint32_t &token) +void PostedItem::loadComment() { - std::vector cmts; - if (!rsPosted->getRelatedComments(token, cmts)) - { - std::cerr << "GxsChannelPostItem::loadComment() ERROR getting data"; - std::cerr << std::endl; - return; - } +#ifdef DEBUG_ITEM + std::cerr << "GxsChannelPostItem::loadComment()"; + std::cerr << std::endl; +#endif - size_t comNb = cmts.size(); - QString sComButText = tr("Comment"); - if (comNb == 1) { - sComButText = sComButText.append("(1)"); - } else if (comNb > 1) { - sComButText = " " + tr("Comments").append(" (%1)").arg(comNb); - } - ui->commentButton->setText(sComButText); + RsThread::async([this]() + { + // 1 - get group data + + std::set msgIds; + + for(auto MsgId: messageVersions()) + msgIds.insert(MsgId); + + std::vector posts; + std::vector 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; + } + + int comNb = comments.size(); + + RsQThreadUtils::postToObject( [comNb,this]() + { + QString sComButText = tr("Comment"); + if (comNb == 1) + sComButText = sComButText.append("(1)"); + else if(comNb > 1) + sComButText = tr("Comments ").append("(%1)").arg(comNb); + + ui->commentButton->setText(sComButText); + + }, this ); + }); } void PostedItem::fill() { - if (isLoading()) { - /* Wait for all requests */ - return; - } +// if (isLoading()) { +// /* Wait for all requests */ +// return; +// } QPixmap sqpixmap2 = QPixmap(":/images/thumb-default.png"); diff --git a/retroshare-gui/src/gui/Posted/PostedItem.h b/retroshare-gui/src/gui/Posted/PostedItem.h index 97b6974d0..0d6a161f6 100644 --- a/retroshare-gui/src/gui/Posted/PostedItem.h +++ b/retroshare-gui/src/gui/Posted/PostedItem.h @@ -46,7 +46,7 @@ public: bool setGroup(const RsPostedGroup& group, bool doFill = true); bool setPost(const RsPostedPost& post, bool doFill = true); - const RsPostedPost &getPost() const; + const RsPostedPost& getPost() const; RsPostedPost &post(); uint64_t uniqueIdentifier() const override { return hash_64bits("PostedItem " + messageId().toStdString()); } @@ -71,13 +71,14 @@ signals: protected: /* GxsGroupFeedItem */ virtual QString groupName(); - virtual void loadGroup(const uint32_t &token); + virtual void loadGroup() override; virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_UNKNOWN; } /* GxsFeedItem */ virtual QString messageName(); - virtual void loadMessage(const uint32_t &token); - virtual void loadComment(const uint32_t &token); + + virtual void loadMessage(); + virtual void loadComment(); private: void setup(); diff --git a/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.cpp b/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.cpp index af3e575dd..cb3e67aca 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.cpp @@ -23,6 +23,7 @@ #include "ui_GxsChannelGroupItem.h" #include "FeedHolder.h" +#include "util/qtthreadsutils.h" #include "gui/NewsFeed.h" #include "gui/RetroShareLink.h" @@ -89,29 +90,39 @@ bool GxsChannelGroupItem::setGroup(const RsGxsChannelGroup &group) return true; } -void GxsChannelGroupItem::loadGroup(const uint32_t &token) +void GxsChannelGroupItem::loadGroup() { -#ifdef DEBUG_ITEM - std::cerr << "GxsChannelGroupItem::loadGroup()"; - std::cerr << std::endl; -#endif - - std::vector groups; - if (!rsGxsChannels->getGroupData(token, groups)) + RsThread::async([this]() { - std::cerr << "GxsChannelGroupItem::loadGroup() ERROR getting data"; - std::cerr << std::endl; - return; - } + // 1 - get group data - if (groups.size() != 1) - { - std::cerr << "GxsChannelGroupItem::loadGroup() Wrong number of Items"; - std::cerr << std::endl; - return; - } + std::vector groups; + const std::list groupIds = { groupId() }; - setGroup(groups[0]); + if(!rsGxsChannels->getChannelsInfo(groupIds,groups)) + { + RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl; + return; + } + + if (groups.size() != 1) + { + std::cerr << "GxsGxsChannelGroupItem::loadGroup() Wrong number of Items"; + std::cerr << std::endl; + return; + } + RsGxsChannelGroup group(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() diff --git a/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.h b/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.h index 266d1c019..cd7f6510b 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.h +++ b/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.h @@ -48,7 +48,7 @@ protected: /* GxsGroupFeedItem */ virtual QString groupName(); - virtual void loadGroup(const uint32_t &token); + virtual void loadGroup() override; virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_CHANNEL; } private slots: diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp index af2116616..c7cc02a11 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp @@ -30,6 +30,7 @@ #include "FeedHolder.h" #include "SubFileItem.h" #include "util/misc.h" +#include "util/qtthreadsutils.h" #include "gui/RetroShareLink.h" #include "util/HandleRichText.h" #include "util/DateTime.h" @@ -230,107 +231,149 @@ void GxsChannelPostItem::loadComments() comments(title); } -void GxsChannelPostItem::loadGroup(const uint32_t &token) +void GxsChannelPostItem::loadGroup() { #ifdef DEBUG_ITEM std::cerr << "GxsChannelGroupItem::loadGroup()"; std::cerr << std::endl; #endif - std::vector groups; - if (!rsGxsChannels->getGroupData(token, groups)) + RsThread::async([this]() { - std::cerr << "GxsChannelGroupItem::loadGroup() ERROR getting data"; - std::cerr << std::endl; - return; - } + // 1 - get group data - if (groups.size() != 1) - { - std::cerr << "GxsChannelGroupItem::loadGroup() Wrong number of Items"; - std::cerr << std::endl; - return; - } + std::vector groups; + const std::list groupIds = { groupId() }; - setGroup(groups[0]); + if(!rsGxsChannels->getChannelsInfo(groupIds,groups)) + { + RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl; + return; + } + + if (groups.size() != 1) + { + std::cerr << "GxsGxsChannelGroupItem::loadGroup() Wrong number of Items"; + std::cerr << std::endl; + return; + } + RsGxsChannelGroup group(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 std::cerr << "GxsChannelPostItem::loadMessage()"; std::cerr << std::endl; #endif - - std::vector posts; - std::vector cmts; - if (!rsGxsChannels->getPostData(token, posts, cmts)) + RsThread::async([this]() { - std::cerr << "GxsChannelPostItem::loadMessage() ERROR getting data"; - std::cerr << std::endl; - return; - } + // 1 - get group data - if (posts.size() == 1) - { - std::cerr << (void*)this << ": Obtained post, with msgId = " << posts[0].mMeta.mMsgId << std::endl; - setPost(posts[0]); - } - else if (cmts.size() == 1) - { - RsGxsComment cmt = cmts[0]; + std::vector posts; + std::vector comments; - 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())); + if(! rsGxsChannels->getChannelContent( groupId(), std::set( { messageId() } ),posts,comments)) + { + RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl; + return; + } - //Change this item to be uploaded with thread element. - setMessageId(cmt.mMeta.mThreadId); - requestMessage(); - } - else - { - std::cerr << "GxsChannelPostItem::loadMessage() Wrong number of Items. Remove It."; - std::cerr << std::endl; - removeItem(); - return; - } + if (posts.size() == 1) + { + std::cerr << (void*)this << ": Obtained post, with msgId = " << posts[0].mMeta.mMsgId << std::endl; + const RsGxsChannelPost& post(posts[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->commLabel->show(); + ui->commLabel->setText(QString::fromUtf8(cmt.mComment.c_str())); + + //Change this item to be uploaded with thread element. + setMessageId(cmt.mMeta.mThreadId); + requestMessage(); + + }, this ); + + } + else + { + std::cerr << "GxsChannelPostItem::loadMessage() Wrong number of Items. Remove It."; + std::cerr << std::endl; + + RsQThreadUtils::postToObject( [this]() { removeItem(); }, this ); + } + }); } -void GxsChannelPostItem::loadComment(const uint32_t &token) +void GxsChannelPostItem::loadComment() { #ifdef DEBUG_ITEM std::cerr << "GxsChannelPostItem::loadComment()"; std::cerr << std::endl; #endif - std::vector cmts; - if (!rsGxsChannels->getRelatedComments(token, cmts)) + RsThread::async([this]() { - std::cerr << "GxsChannelPostItem::loadComment() ERROR getting data"; - std::cerr << std::endl; - return; - } + // 1 - get group data - size_t comNb = cmts.size(); - QString sComButText = tr("Comment"); - if (comNb == 1) { - sComButText = sComButText.append("(1)"); - } else if (comNb > 1) { - sComButText = tr("Comments ").append("(%1)").arg(comNb); - } - ui->commentButton->setText(sComButText); + std::set msgIds; + + for(auto MsgId: messageVersions()) + msgIds.insert(MsgId); + + std::vector posts; + std::vector comments; + + if(! rsGxsChannels->getChannelContent( groupId(),msgIds,posts,comments)) + { + RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl; + return; + } + + int comNb = comments.size(); + + RsQThreadUtils::postToObject( [comNb,this]() + { + QString sComButText = tr("Comment"); + if (comNb == 1) + sComButText = sComButText.append("(1)"); + else if(comNb > 1) + sComButText = tr("Comments ").append("(%1)").arg(comNb); + + ui->commentButton->setText(sComButText); + + }, this ); + }); } void GxsChannelPostItem::fill() { /* fill in */ - if (isLoading()) { - /* Wait for all requests */ - return; - } +// if (isLoading()) { + // /* Wait for all requests */ + //return; +// } #ifdef DEBUG_ITEM std::cerr << "GxsChannelPostItem::fill()"; diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h index a067098d9..566acda30 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.h @@ -81,13 +81,13 @@ protected: /* GxsGroupFeedItem */ virtual QString groupName(); - virtual void loadGroup(const uint32_t &token); + virtual void loadGroup() override; virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_CHANNEL; } /* GxsFeedItem */ virtual QString messageName(); - virtual void loadMessage(const uint32_t &token); - virtual void loadComment(const uint32_t &token); + virtual void loadMessage(); + virtual void loadComment(); private slots: /* default stuff */ diff --git a/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp b/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp index 8b97d73cf..57cf259ab 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsForumGroupItem.cpp @@ -23,6 +23,7 @@ #include "FeedHolder.h" #include "gui/RetroShareLink.h" +#include "util/qtthreadsutils.h" /**** * #define DEBUG_ITEM 1 @@ -87,29 +88,43 @@ bool GxsForumGroupItem::setGroup(const RsGxsForumGroup &group) return true; } -void GxsForumGroupItem::loadGroup(const uint32_t &token) +void GxsForumGroupItem::loadGroup() { -#ifdef DEBUG_ITEM - std::cerr << "GxsForumGroupItem::loadGroup()"; - std::cerr << std::endl; + RsThread::async([this]() + { + // 1 - get group data + +#ifdef DEBUG_FORUMS + std::cerr << "Retrieving post data for post " << mThreadId << std::endl; #endif - std::vector groups; - if (!rsGxsForums->getGroupData(token, groups)) - { - std::cerr << "GxsForumGroupItem::loadGroup() ERROR getting data"; - std::cerr << std::endl; - return; - } + std::vector groups; + const std::list forumIds = { groupId() }; - if (groups.size() != 1) - { - std::cerr << "GxsForumGroupItem::loadGroup() Wrong number of Items"; - std::cerr << std::endl; - return; - } + if(!rsGxsForums->getForumsInfo(forumIds,groups)) + { + RsErr() << "GxsForumGroupItem::loadGroup() ERROR getting data" << std::endl; + return; + } - setGroup(groups[0]); + if (groups.size() != 1) + { + std::cerr << "GxsForumGroupItem::loadGroup() Wrong number of Items"; + std::cerr << std::endl; + return; + } + const RsGxsForumGroup& group(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() diff --git a/retroshare-gui/src/gui/feeds/GxsForumGroupItem.h b/retroshare-gui/src/gui/feeds/GxsForumGroupItem.h index 3ac198630..442ad70e8 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumGroupItem.h +++ b/retroshare-gui/src/gui/feeds/GxsForumGroupItem.h @@ -50,7 +50,7 @@ protected: /* GxsGroupFeedItem */ virtual QString groupName(); - virtual void loadGroup(const uint32_t &token); + virtual void loadGroup() override; virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_FORUM; } private slots: diff --git a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp index 0e691258c..50decda82 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp @@ -30,6 +30,7 @@ #include "gui/RetroShareLink.h" #include "gui/gxs/GxsIdDetails.h" #include "util/HandleRichText.h" +#include "util/qtthreadsutils.h" #include "util/DateTime.h" #include @@ -94,7 +95,6 @@ void GxsForumMsgItem::setup() mInFill = false; mCloseOnRead = false; - mTokenTypeParentMessage = nextTokenType(); /* clear ui */ ui->titleLabel->setText(tr("Loading")); @@ -154,13 +154,10 @@ bool GxsForumMsgItem::setMessage(const RsGxsForumMsg &msg, bool doFill) mMessage = msg; - if (!isTop()) { - requestParentMessage(mMessage.mMeta.mParentId); - } else { - if (doFill) { - fill(); - } - } + if (!isTop()) + loadParentMessage(mMessage.mMeta.mParentId); + else if(doFill) + fill(); return true; } @@ -170,91 +167,144 @@ QString GxsForumMsgItem::groupName() return QString::fromUtf8(mGroup.mMeta.mGroupName.c_str()); } -void GxsForumMsgItem::loadGroup(const uint32_t &token) +void GxsForumMsgItem::loadGroup() { -#ifdef DEBUG_ITEM - std::cerr << "GxsForumGroupItem::loadGroup()"; - std::cerr << std::endl; + RsThread::async([this]() + { + // 1 - get group data + +#ifdef DEBUG_FORUMS + std::cerr << "Retrieving post data for post " << mThreadId << std::endl; #endif - std::vector groups; - if (!rsGxsForums->getGroupData(token, groups)) - { - std::cerr << "GxsForumGroupItem::loadGroup() ERROR getting data"; - std::cerr << std::endl; - return; - } + std::vector groups; + const std::list forumIds = { groupId() }; - if (groups.size() != 1) - { - std::cerr << "GxsForumGroupItem::loadGroup() Wrong number of Items"; - std::cerr << std::endl; - return; - } + if(!rsGxsForums->getForumsInfo(forumIds,groups)) + { + RsErr() << "GxsForumGroupItem::loadGroup() ERROR getting data" << std::endl; + return; + } - setGroup(groups[0]); + if (groups.size() != 1) + { + std::cerr << "GxsForumGroupItem::loadGroup() Wrong number of Items"; + std::cerr << std::endl; + return; + } + RsGxsForumGroup group(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 std::cerr << "GxsForumMsgItem::loadMessage()"; std::cerr << std::endl; #endif - std::vector msgs; - if (!rsGxsForums->getMsgData(token, msgs)) + RsThread::async([this]() { - std::cerr << "GxsForumMsgItem::loadMessage() ERROR getting data"; - std::cerr << std::endl; - return; - } - - if (msgs.size() != 1) - { - std::cerr << "GxsForumMsgItem::loadMessage() Wrong number of Items"; - std::cerr << std::endl; - return; - } + // 1 - get group data - setMessage(msgs[0]); +#ifdef DEBUG_FORUMS + std::cerr << "Retrieving post data for post " << mThreadId << std::endl; +#endif + + std::vector msgs; + const std::list forumIds = { groupId() }; + + if(!rsGxsForums->getForumContent(groupId(),std::set( { messageId() } ),msgs)) + { + std::cerr << "GxsForumMsgItem::loadMessage() ERROR getting data"; + std::cerr << std::endl; + return; + } + + if (msgs.size() != 1) + { + std::cerr << "GxsForumMsgItem::loadMessage() Wrong number of Items"; + std::cerr << std::endl; + return; + } + const RsGxsForumMsg& msg(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 std::cerr << "GxsForumMsgItem::loadParentMessage()"; std::cerr << std::endl; #endif - std::vector msgs; - if (!rsGxsForums->getMsgData(token, msgs)) + RsThread::async([parent_msg,this]() { - std::cerr << "GxsForumMsgItem::loadParentMessage() ERROR getting data"; - std::cerr << std::endl; - return; - } + // 1 - get group data - if (msgs.size() != 1) - { - std::cerr << "GxsForumMsgItem::loadParentMessage() Wrong number of Items"; - std::cerr << std::endl; - return; - } +#ifdef DEBUG_FORUMS + std::cerr << "Retrieving post data for post " << mThreadId << std::endl; +#endif - mParentMessage = msgs[0]; + std::vector msgs; + const std::list forumIds = { groupId() }; - fill(); + if(!rsGxsForums->getForumContent(groupId(),std::set( { parent_msg } ),msgs)) + { + std::cerr << "GxsForumMsgItem::loadMessage() ERROR getting data"; + std::cerr << std::endl; + return; + } + + if (msgs.size() != 1) + { + std::cerr << "GxsForumMsgItem::loadMessage() Wrong number of Items"; + std::cerr << std::endl; + return; + } + const RsGxsForumMsg& msg(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(); + + }, this ); + }); } void GxsForumMsgItem::fill() { /* fill in */ - if (isLoading()) { - /* Wait for all requests */ - return; - } +// if (isLoading()) { +// /* Wait for all requests */ +// return; +// } #ifdef DEBUG_ITEM std::cerr << "GxsForumMsgItem::fill()"; @@ -307,18 +357,6 @@ void GxsForumMsgItem::fill() 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()); ui->subLabel->setText(msgLink.toHtml()); if (wasExpanded() || ui->expandFrame->isVisible()) { @@ -330,14 +368,13 @@ void GxsForumMsgItem::fill() if (isTop()) { ui->parentFrame->hide(); } 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())); ui->parentSubLabel->setText(linkParent.toHtml()); ui->parentMsgLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(mParentMessage.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); ui->parentNameLabel->setId(mParentMessage.mMeta.mAuthorId); - + RsIdentityDetails idDetails ; rsIdentity->getIdDetails(mParentMessage.mMeta.mAuthorId,idDetails); @@ -348,16 +385,6 @@ void GxsForumMsgItem::fill() 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 */ @@ -440,63 +467,6 @@ void GxsForumMsgItem::setReadStatus(bool isNew, bool /*isUnread*/) 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 &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 ***********************/ void GxsForumMsgItem::readAndClearItem() diff --git a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.h b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.h index 332d5877e..35872ab9c 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.h +++ b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.h @@ -50,20 +50,18 @@ protected: virtual void expandFill(bool first); /* load message data */ - void requestParentMessage(const RsGxsMessageId &msgId); - virtual void loadParentMessage(const uint32_t &token); + virtual void loadParentMessage(const RsGxsMessageId &parent_msg); /* GxsGroupFeedItem */ virtual QString groupName(); - virtual void loadGroup(const uint32_t &token); - virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req); + virtual void loadGroup() override; virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_FORUM; } - virtual bool isLoading(); + //virtual bool isLoading(); /* GxsFeedItem */ virtual QString messageName(); - virtual void loadMessage(const uint32_t &token); - virtual void loadComment(const uint32_t &/*token*/){ return;} + virtual void loadMessage() override; + virtual void loadComment() override { return; } private slots: /* default stuff */ @@ -90,7 +88,6 @@ private: RsGxsForumGroup mGroup; RsGxsForumMsg mMessage; RsGxsForumMsg mParentMessage; - uint32_t mTokenTypeParentMessage; /** Qt Designer generated object */ Ui::GxsForumMsgItem *ui; diff --git a/retroshare-gui/src/gui/feeds/PostedGroupItem.cpp b/retroshare-gui/src/gui/feeds/PostedGroupItem.cpp index 50cfb92d1..be8d3b78f 100644 --- a/retroshare-gui/src/gui/feeds/PostedGroupItem.cpp +++ b/retroshare-gui/src/gui/feeds/PostedGroupItem.cpp @@ -22,6 +22,7 @@ #include "ui_PostedGroupItem.h" #include "FeedHolder.h" +#include "util/qtthreadsutils.h" #include "gui/RetroShareLink.h" #include "gui/gxs/GxsIdDetails.h" @@ -90,29 +91,46 @@ bool PostedGroupItem::setGroup(const RsPostedGroup &group) return true; } -void PostedGroupItem::loadGroup(const uint32_t &token) +void PostedGroupItem::loadGroup() { -#ifdef DEBUG_ITEM - std::cerr << "PostedGroupItem::loadGroup()"; - std::cerr << std::endl; + RsThread::async([this]() + { + // 1 - get group data + +#ifdef DEBUG_FORUMS + std::cerr << "Retrieving post data for post " << mThreadId << std::endl; #endif - std::vector groups; - if (!rsPosted->getGroupData(token, groups)) - { - std::cerr << "PostedGroupItem::loadGroup() ERROR getting data"; - std::cerr << std::endl; - return; - } + std::vector groups; + const std::list groupIds = { groupId() }; - if (groups.size() != 1) - { - std::cerr << "PostedGroupItem::loadGroup() Wrong number of Items"; - std::cerr << std::endl; - return; - } +#warning Code needed in rsPosted +#ifdef TODO + if(!rsPosted->getPostedGroupInfo(groupIds,groups)) +#endif + { + RsErr() << "GxsPostedGroupItem::loadGroup() ERROR getting data" << std::endl; + return; + } - setGroup(groups[0]); + if (groups.size() != 1) + { + std::cerr << "GxsPostedGroupItem::loadGroup() Wrong number of Items"; + std::cerr << std::endl; + return; + } + RsPostedGroup group(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() diff --git a/retroshare-gui/src/gui/feeds/PostedGroupItem.h b/retroshare-gui/src/gui/feeds/PostedGroupItem.h index 88e1906dc..642dc4be0 100644 --- a/retroshare-gui/src/gui/feeds/PostedGroupItem.h +++ b/retroshare-gui/src/gui/feeds/PostedGroupItem.h @@ -50,7 +50,7 @@ protected: /* GxsGroupFeedItem */ virtual QString groupName(); - virtual void loadGroup(const uint32_t &token); + virtual void loadGroup() override; virtual RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_UNKNOWN; } private slots: diff --git a/retroshare-gui/src/gui/gxs/GxsFeedItem.cpp b/retroshare-gui/src/gui/gxs/GxsFeedItem.cpp index 2f11fe00e..ec796a38c 100644 --- a/retroshare-gui/src/gui/gxs/GxsFeedItem.cpp +++ b/retroshare-gui/src/gui/gxs/GxsFeedItem.cpp @@ -40,8 +40,10 @@ GxsFeedItem::GxsFeedItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsGro /* load data if we can */ mMessageId = messageId; +#ifdef TO_REMOVE mTokenTypeMessage = nextTokenType(); mTokenTypeComment = nextTokenType(); +#endif } GxsFeedItem::~GxsFeedItem() @@ -106,6 +108,8 @@ void GxsFeedItem::fillDisplay(RsGxsUpdateBroadcastBase *updateBroadcastBase, boo void GxsFeedItem::requestMessage() { + loadMessage(); +#ifdef TO_REMOVE #ifdef DEBUG_ITEM std::cerr << "GxsFeedItem::requestMessage()"; std::cerr << std::endl; @@ -129,15 +133,19 @@ void GxsFeedItem::requestMessage() uint32_t token; mLoadQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeMessage); +#endif } void GxsFeedItem::requestComment() { + loadComment(); +#ifdef TO_REMOVE #ifdef DEBUG_ITEM std::cerr << "GxsFeedItem::requestComment()"; std::cerr << std::endl; #endif +#ifdef TO_REMOVE if (!initLoadQueue()) { return; } @@ -146,6 +154,7 @@ void GxsFeedItem::requestComment() /* Request already running */ return; } +#endif RsTokReqOptions opts; opts.mReqType = GXS_REQUEST_TYPE_MSG_RELATED_DATA; @@ -153,15 +162,17 @@ void GxsFeedItem::requestComment() std::vector msgIds; - for(int i=0;irequestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeComment); +#endif } +#ifdef TO_REMOVE void GxsFeedItem::loadRequest(const TokenQueue *queue, const TokenRequest &req) { #ifdef DEBUG_ITEM @@ -195,3 +206,4 @@ bool GxsFeedItem::isLoading() return false; } +#endif diff --git a/retroshare-gui/src/gui/gxs/GxsFeedItem.h b/retroshare-gui/src/gui/gxs/GxsFeedItem.h index 91fda9cf6..c7c16ea79 100644 --- a/retroshare-gui/src/gui/gxs/GxsFeedItem.h +++ b/retroshare-gui/src/gui/gxs/GxsFeedItem.h @@ -45,15 +45,17 @@ protected: void requestComment(); virtual QString messageName() = 0; - virtual void loadMessage(const uint32_t &token) = 0; - virtual void loadComment(const uint32_t &token) = 0; + virtual void loadMessage() = 0; + virtual void loadComment() = 0; /* GxsGroupFeedItem */ - virtual bool isLoading(); + //virtual bool isLoading(); //virtual void fillDisplay(RsGxsUpdateBroadcastBase *updateBroadcastBase, bool complete); +#ifdef TO_REMOVE /* TokenResponse */ virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req); +#endif protected slots: void comments(const QString &title); diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFeedItem.cpp b/retroshare-gui/src/gui/gxs/GxsGroupFeedItem.cpp index b8d60dd24..631dcc1e8 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFeedItem.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupFeedItem.cpp @@ -46,12 +46,12 @@ GxsGroupFeedItem::GxsGroupFeedItem(FeedHolder *feedHolder, uint32_t feedId, cons mGroupId = groupId; mGxsIface = iface; +#ifdef TO_REMOVE mNextTokenType = 0; mTokenTypeGroup = nextTokenType(); mLoadQueue = NULL; -#ifdef TO_REMOVE if (mGxsIface && autoUpdate) { /* Connect to update broadcast */ mUpdateBroadcastBase = new RsGxsUpdateBroadcastBase(mGxsIface); @@ -69,11 +69,11 @@ GxsGroupFeedItem::~GxsGroupFeedItem() std::cerr << std::endl; #endif +#ifdef TO_REMOVE if (mLoadQueue) { delete mLoadQueue; } -#ifdef TO_REMOVE if (mUpdateBroadcastBase) { delete(mUpdateBroadcastBase); @@ -81,20 +81,6 @@ GxsGroupFeedItem::~GxsGroupFeedItem() #endif } -bool GxsGroupFeedItem::initLoadQueue() -{ - if (mLoadQueue) { - return true; - } - - if (!mGxsIface) { - return false; - } - - mLoadQueue = new TokenQueue(mGxsIface->getTokenService(), this); - return (mLoadQueue != NULL); -} - void GxsGroupFeedItem::unsubscribe() { #ifdef DEBUG_ITEM @@ -144,7 +130,6 @@ void GxsGroupFeedItem::copyGroupLink() void GxsGroupFeedItem::fillDisplaySlot(bool complete) { requestGroup(); -// fillDisplay(mUpdateBroadcastBase, complete); } #ifdef TO_REMOVE @@ -162,51 +147,6 @@ void GxsGroupFeedItem::fillDisplay(RsGxsUpdateBroadcastBase *updateBroadcastBase void GxsGroupFeedItem::requestGroup() { -#ifdef DEBUG_ITEM - std::cerr << "GxsGroupFeedItem::requestGroup()"; - std::cerr << std::endl; -#endif - - if (!initLoadQueue()) { - return; - } - - if (mLoadQueue->activeRequestExist(mTokenTypeGroup)) { - /* Request already running */ - return; - } - - std::list 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); + loadGroup(); } -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; -} diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFeedItem.h b/retroshare-gui/src/gui/gxs/GxsGroupFeedItem.h index 6c9c8d21d..653d62bb1 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFeedItem.h +++ b/retroshare-gui/src/gui/gxs/GxsGroupFeedItem.h @@ -25,7 +25,6 @@ #include #include "gui/feeds/FeedItem.h" -#include "util/TokenQueue.h" #include "gui/RetroShareLink.h" #include @@ -33,7 +32,7 @@ class FeedHolder; class RsGxsUpdateBroadcastBase; -class GxsGroupFeedItem : public FeedItem, public TokenResponse +class GxsGroupFeedItem : public FeedItem { Q_OBJECT @@ -46,20 +45,12 @@ public: uint32_t feedId() const { return mFeedId; } protected: - uint32_t nextTokenType() { return ++mNextTokenType; } - bool initLoadQueue(); - /* load group data */ void requestGroup(); - virtual bool isLoading(); - virtual void loadGroup(const uint32_t &token) = 0; + virtual void loadGroup() = 0; virtual RetroShareLink::enumType getLinkType() = 0; virtual QString groupName() = 0; - //virtual void fillDisplay(RsGxsUpdateBroadcastBase *updateBroadcastBase, bool complete); - - /* TokenResponse */ - virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req); protected slots: void subscribe(); @@ -69,7 +60,6 @@ protected slots: protected: bool mIsHome; RsGxsIfaceHelper *mGxsIface; - TokenQueue *mLoadQueue; private slots: /* RsGxsUpdateBroadcastBase */ @@ -77,9 +67,6 @@ private slots: private: RsGxsGroupId mGroupId; -// RsGxsUpdateBroadcastBase *mUpdateBroadcastBase; - uint32_t mNextTokenType; - uint32_t mTokenTypeGroup; }; Q_DECLARE_METATYPE(RsGxsGroupId)