mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-06 21:58:57 -04:00
removed most of the token queue system from GxsFeedItems
This commit is contained in:
parent
d1b26c9d36
commit
7e08d24b64
18 changed files with 607 additions and 491 deletions
|
@ -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()
|
||||||
{
|
{
|
||||||
std::vector<RsPostedGroup> groups;
|
RsThread::async([this]()
|
||||||
if (!rsPosted->getGroupData(token, groups))
|
|
||||||
{
|
{
|
||||||
std::cerr << "PostedCardView::loadGroup() ERROR getting data";
|
// 1 - get group data
|
||||||
std::cerr << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (groups.size() != 1)
|
#ifdef DEBUG_FORUMS
|
||||||
{
|
std::cerr << "Retrieving post data for post " << mThreadId << std::endl;
|
||||||
std::cerr << "PostedCardView::loadGroup() Wrong number of Items";
|
#endif
|
||||||
std::cerr << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setGroup(groups[0]);
|
std::vector<RsPostedGroup> groups;
|
||||||
|
const std::list<RsGxsGroupId> 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<RsPostedPost> posts;
|
RsThread::async([this]()
|
||||||
std::vector<RsGxsComment> cmts;
|
|
||||||
if (!rsPosted->getPostData(token, posts, cmts))
|
|
||||||
{
|
{
|
||||||
std::cerr << "GxsChannelPostItem::loadMessage() ERROR getting data";
|
// 1 - get group data
|
||||||
std::cerr << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (posts.size() == 1)
|
std::vector<RsPostedPost> posts;
|
||||||
{
|
std::vector<RsGxsComment> comments;
|
||||||
setPost(posts[0]);
|
|
||||||
}
|
|
||||||
else if (cmts.size() == 1)
|
|
||||||
{
|
|
||||||
RsGxsComment cmt = cmts[0];
|
|
||||||
|
|
||||||
//ui->newCommentLabel->show();
|
#warning Code needed in rsPosted
|
||||||
//ui->commLabel->show();
|
#ifdef TODO
|
||||||
//ui->commLabel->setText(QString::fromUtf8(cmt.mComment.c_str()));
|
if(! rsPosted->getPostedContent( groupId(), std::set<RsGxsMessageId>( { 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<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;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t comNb = cmts.size();
|
std::set<RsGxsMessageId> msgIds;
|
||||||
QString sComButText = tr("Comment");
|
|
||||||
if (comNb == 1) {
|
for(auto MsgId: messageVersions())
|
||||||
sComButText = sComButText.append("(1)");
|
msgIds.insert(MsgId);
|
||||||
} else if (comNb > 1) {
|
|
||||||
sComButText = " " + tr("Comments").append(" (%1)").arg(comNb);
|
std::vector<RsPostedPost> posts;
|
||||||
}
|
std::vector<RsGxsComment> comments;
|
||||||
ui->commentButton->setText(sComButText);
|
|
||||||
|
#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()
|
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");
|
||||||
|
|
||||||
|
|
|
@ -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();
|
||||||
|
|
|
@ -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,88 +169,151 @@ bool PostedItem::setPost(const RsPostedPost &post, bool doFill)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostedItem::loadGroup(const uint32_t &token)
|
void PostedItem::loadGroup()
|
||||||
{
|
{
|
||||||
std::vector<RsPostedGroup> groups;
|
RsThread::async([this]()
|
||||||
if (!rsPosted->getGroupData(token, groups))
|
|
||||||
{
|
{
|
||||||
std::cerr << "PostedItem::loadGroup() ERROR getting data";
|
// 1 - get group data
|
||||||
std::cerr << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (groups.size() != 1)
|
#ifdef DEBUG_FORUMS
|
||||||
{
|
std::cerr << "Retrieving post data for post " << mThreadId << std::endl;
|
||||||
std::cerr << "PostedItem::loadGroup() Wrong number of Items";
|
#endif
|
||||||
std::cerr << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setGroup(groups[0]);
|
std::vector<RsPostedGroup> groups;
|
||||||
|
const std::list<RsGxsGroupId> 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<RsPostedPost> posts;
|
RsThread::async([this]()
|
||||||
std::vector<RsGxsComment> cmts;
|
|
||||||
if (!rsPosted->getPostData(token, posts, cmts))
|
|
||||||
{
|
{
|
||||||
std::cerr << "GxsChannelPostItem::loadMessage() ERROR getting data";
|
// 1 - get group data
|
||||||
std::cerr << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (posts.size() == 1)
|
std::vector<RsPostedPost> posts;
|
||||||
{
|
std::vector<RsGxsComment> comments;
|
||||||
setPost(posts[0]);
|
|
||||||
}
|
|
||||||
else if (cmts.size() == 1)
|
|
||||||
{
|
|
||||||
RsGxsComment cmt = cmts[0];
|
|
||||||
|
|
||||||
ui->newCommentLabel->show();
|
#warning Code needed in rsPosted
|
||||||
ui->commLabel->show();
|
#ifdef TODO
|
||||||
ui->commLabel->setText(QString::fromUtf8(cmt.mComment.c_str()));
|
if(! rsPosted->getPostedContent( groupId(), std::set<RsGxsMessageId>( { messageId() } ),posts,comments))
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
RsErr() << "PostedItem::loadMessage() ERROR getting data" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//Change this item to be uploaded with thread element.
|
if (posts.size() == 1)
|
||||||
setMessageId(cmt.mMeta.mThreadId);
|
{
|
||||||
requestMessage();
|
std::cerr << (void*)this << ": Obtained post, with msgId = " << posts[0].mMeta.mMsgId << std::endl;
|
||||||
}
|
const RsPostedPost& post(posts[0]);
|
||||||
else
|
|
||||||
{
|
RsQThreadUtils::postToObject( [post,this]() { setPost(post); }, this );
|
||||||
std::cerr << "GxsChannelPostItem::loadMessage() Wrong number of Items. Remove It.";
|
}
|
||||||
std::cerr << std::endl;
|
else if(comments.size() == 1)
|
||||||
removeItem();
|
{
|
||||||
return;
|
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<RsGxsComment> cmts;
|
#ifdef DEBUG_ITEM
|
||||||
if (!rsPosted->getRelatedComments(token, cmts))
|
std::cerr << "GxsChannelPostItem::loadComment()";
|
||||||
{
|
std::cerr << std::endl;
|
||||||
std::cerr << "GxsChannelPostItem::loadComment() ERROR getting data";
|
#endif
|
||||||
std::cerr << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t comNb = cmts.size();
|
RsThread::async([this]()
|
||||||
QString sComButText = tr("Comment");
|
{
|
||||||
if (comNb == 1) {
|
// 1 - get group data
|
||||||
sComButText = sComButText.append("(1)");
|
|
||||||
} else if (comNb > 1) {
|
std::set<RsGxsMessageId> msgIds;
|
||||||
sComButText = " " + tr("Comments").append(" (%1)").arg(comNb);
|
|
||||||
}
|
for(auto MsgId: messageVersions())
|
||||||
ui->commentButton->setText(sComButText);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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()
|
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");
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ public:
|
||||||
bool setGroup(const RsPostedGroup& group, bool doFill = true);
|
bool setGroup(const RsPostedGroup& group, bool doFill = true);
|
||||||
bool setPost(const RsPostedPost& post, bool doFill = true);
|
bool setPost(const RsPostedPost& post, bool doFill = true);
|
||||||
|
|
||||||
const RsPostedPost &getPost() const;
|
const RsPostedPost& getPost() const;
|
||||||
RsPostedPost &post();
|
RsPostedPost &post();
|
||||||
|
|
||||||
uint64_t uniqueIdentifier() const override { return hash_64bits("PostedItem " + messageId().toStdString()); }
|
uint64_t uniqueIdentifier() const override { return hash_64bits("PostedItem " + messageId().toStdString()); }
|
||||||
|
@ -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();
|
||||||
|
|
|
@ -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;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::vector<RsGxsChannelGroup> groups;
|
|
||||||
if (!rsGxsChannels->getGroupData(token, groups))
|
|
||||||
{
|
{
|
||||||
std::cerr << "GxsChannelGroupItem::loadGroup() ERROR getting data";
|
// 1 - get group data
|
||||||
std::cerr << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (groups.size() != 1)
|
std::vector<RsGxsChannelGroup> groups;
|
||||||
{
|
const std::list<RsGxsGroupId> groupIds = { groupId() };
|
||||||
std::cerr << "GxsChannelGroupItem::loadGroup() Wrong number of Items";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
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()
|
QString GxsChannelGroupItem::groupName()
|
||||||
|
|
|
@ -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:
|
||||||
|
|
|
@ -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,107 +231,149 @@ 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;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (groups.size() != 1)
|
std::vector<RsGxsChannelGroup> groups;
|
||||||
{
|
const std::list<RsGxsGroupId> groupIds = { groupId() };
|
||||||
std::cerr << "GxsChannelGroupItem::loadGroup() Wrong number of Items";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
#ifdef DEBUG_ITEM
|
||||||
std::cerr << "GxsChannelPostItem::loadMessage()";
|
std::cerr << "GxsChannelPostItem::loadMessage()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
RsThread::async([this]()
|
||||||
std::vector<RsGxsChannelPost> posts;
|
|
||||||
std::vector<RsGxsComment> cmts;
|
|
||||||
if (!rsGxsChannels->getPostData(token, posts, cmts))
|
|
||||||
{
|
{
|
||||||
std::cerr << "GxsChannelPostItem::loadMessage() ERROR getting data";
|
// 1 - get group data
|
||||||
std::cerr << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (posts.size() == 1)
|
std::vector<RsGxsChannelPost> posts;
|
||||||
{
|
std::vector<RsGxsComment> comments;
|
||||||
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::cerr << (void*)this << ": Obtained comment, setting messageId to threadID = " << cmt.mMeta.mThreadId << std::endl;
|
if(! rsGxsChannels->getChannelContent( groupId(), std::set<RsGxsMessageId>( { messageId() } ),posts,comments))
|
||||||
ui->newCommentLabel->show();
|
{
|
||||||
ui->commLabel->show();
|
RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
|
||||||
ui->commLabel->setText(QString::fromUtf8(cmt.mComment.c_str()));
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//Change this item to be uploaded with thread element.
|
if (posts.size() == 1)
|
||||||
setMessageId(cmt.mMeta.mThreadId);
|
{
|
||||||
requestMessage();
|
std::cerr << (void*)this << ": Obtained post, with msgId = " << posts[0].mMeta.mMsgId << std::endl;
|
||||||
}
|
const RsGxsChannelPost& post(posts[0]);
|
||||||
else
|
|
||||||
{
|
RsQThreadUtils::postToObject( [post,this]() { setPost(post); }, this );
|
||||||
std::cerr << "GxsChannelPostItem::loadMessage() Wrong number of Items. Remove It.";
|
}
|
||||||
std::cerr << std::endl;
|
else if(comments.size() == 1)
|
||||||
removeItem();
|
{
|
||||||
return;
|
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
|
#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;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t comNb = cmts.size();
|
std::set<RsGxsMessageId> msgIds;
|
||||||
QString sComButText = tr("Comment");
|
|
||||||
if (comNb == 1) {
|
for(auto MsgId: messageVersions())
|
||||||
sComButText = sComButText.append("(1)");
|
msgIds.insert(MsgId);
|
||||||
} else if (comNb > 1) {
|
|
||||||
sComButText = tr("Comments ").append("(%1)").arg(comNb);
|
std::vector<RsGxsChannelPost> posts;
|
||||||
}
|
std::vector<RsGxsComment> comments;
|
||||||
ui->commentButton->setText(sComButText);
|
|
||||||
|
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()
|
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()";
|
||||||
|
|
|
@ -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 */
|
||||||
|
|
|
@ -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,29 +88,43 @@ 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() };
|
||||||
{
|
|
||||||
std::cerr << "GxsForumGroupItem::loadGroup() ERROR getting data";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (groups.size() != 1)
|
if(!rsGxsForums->getForumsInfo(forumIds,groups))
|
||||||
{
|
{
|
||||||
std::cerr << "GxsForumGroupItem::loadGroup() Wrong number of Items";
|
RsErr() << "GxsForumGroupItem::loadGroup() ERROR getting data" << std::endl;
|
||||||
std::cerr << std::endl;
|
return;
|
||||||
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()
|
QString GxsForumGroupItem::groupName()
|
||||||
|
|
|
@ -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:
|
||||||
|
|
|
@ -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,91 +167,144 @@ 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() };
|
||||||
{
|
|
||||||
std::cerr << "GxsForumGroupItem::loadGroup() ERROR getting data";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (groups.size() != 1)
|
if(!rsGxsForums->getForumsInfo(forumIds,groups))
|
||||||
{
|
{
|
||||||
std::cerr << "GxsForumGroupItem::loadGroup() Wrong number of Items";
|
RsErr() << "GxsForumGroupItem::loadGroup() ERROR getting data" << std::endl;
|
||||||
std::cerr << std::endl;
|
return;
|
||||||
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
|
#ifdef DEBUG_ITEM
|
||||||
std::cerr << "GxsForumMsgItem::loadMessage()";
|
std::cerr << "GxsForumMsgItem::loadMessage()";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::vector<RsGxsForumMsg> msgs;
|
RsThread::async([this]()
|
||||||
if (!rsGxsForums->getMsgData(token, msgs))
|
|
||||||
{
|
{
|
||||||
std::cerr << "GxsForumMsgItem::loadMessage() ERROR getting data";
|
// 1 - get group data
|
||||||
std::cerr << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msgs.size() != 1)
|
|
||||||
{
|
|
||||||
std::cerr << "GxsForumMsgItem::loadMessage() Wrong number of Items";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setMessage(msgs[0]);
|
#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>( { 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
|
#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
|
||||||
std::cerr << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msgs.size() != 1)
|
#ifdef DEBUG_FORUMS
|
||||||
{
|
std::cerr << "Retrieving post data for post " << mThreadId << std::endl;
|
||||||
std::cerr << "GxsForumMsgItem::loadParentMessage() Wrong number of Items";
|
#endif
|
||||||
std::cerr << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mParentMessage = msgs[0];
|
std::vector<RsGxsForumMsg> msgs;
|
||||||
|
const std::list<RsGxsGroupId> forumIds = { groupId() };
|
||||||
|
|
||||||
fill();
|
if(!rsGxsForums->getForumContent(groupId(),std::set<RsGxsMessageId>( { 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()
|
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,14 +368,13 @@ 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());
|
||||||
ui->parentMsgLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(mParentMessage.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
|
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);
|
ui->parentNameLabel->setId(mParentMessage.mMeta.mAuthorId);
|
||||||
|
|
||||||
RsIdentityDetails idDetails ;
|
RsIdentityDetails idDetails ;
|
||||||
rsIdentity->getIdDetails(mParentMessage.mMeta.mAuthorId,idDetails);
|
rsIdentity->getIdDetails(mParentMessage.mMeta.mAuthorId,idDetails);
|
||||||
|
|
||||||
|
@ -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()
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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() };
|
||||||
{
|
|
||||||
std::cerr << "PostedGroupItem::loadGroup() ERROR getting data";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (groups.size() != 1)
|
#warning Code needed in rsPosted
|
||||||
{
|
#ifdef TODO
|
||||||
std::cerr << "PostedGroupItem::loadGroup() Wrong number of Items";
|
if(!rsPosted->getPostedGroupInfo(groupIds,groups))
|
||||||
std::cerr << std::endl;
|
#endif
|
||||||
return;
|
{
|
||||||
}
|
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()
|
QString PostedGroupItem::groupName()
|
||||||
|
|
|
@ -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:
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue