removed token queue from CreateGxsChannelMsg

This commit is contained in:
csoler 2020-03-31 22:10:11 +02:00
parent cf7a77e512
commit 4e3cb16535
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
2 changed files with 67 additions and 88 deletions

View File

@ -33,6 +33,7 @@
#include "util/HandleRichText.h" #include "util/HandleRichText.h"
#include "util/misc.h" #include "util/misc.h"
#include "util/rsdir.h" #include "util/rsdir.h"
#include "util/qtthreadsutils.h"
#include "util/RichTextEdit.h" #include "util/RichTextEdit.h"
#include <retroshare/rsfiles.h> #include <retroshare/rsfiles.h>
@ -54,7 +55,6 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId, RsGxsMessageId
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
setupUi(this); setupUi(this);
Settings->loadWidgetInformation(this); Settings->loadWidgetInformation(this);
mChannelQueue = new TokenQueue(rsGxsChannels->getTokenService(), this);
headerFrame->setHeaderImage(QPixmap(":/icons/png/channel.png")); headerFrame->setHeaderImage(QPixmap(":/icons/png/channel.png"));
@ -104,8 +104,6 @@ CreateGxsChannelMsg::~CreateGxsChannelMsg()
#ifdef CHANNELS_FRAME_CATCHER #ifdef CHANNELS_FRAME_CATCHER
delete fCatcher; delete fCatcher;
#endif #endif
delete(mChannelQueue);
} }
void CreateGxsChannelMsg::contextMenu(QPoint /*point*/) void CreateGxsChannelMsg::contextMenu(QPoint /*point*/)
@ -591,26 +589,10 @@ void CreateGxsChannelMsg::newChannelMsg()
/* request Data */ /* request Data */
{ {
RsTokReqOptions opts; loadChannelInfo();
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
std::list<RsGxsGroupId> groupIds;
groupIds.push_back(mChannelId);
std::cerr << "CreateGxsChannelMsg::newChannelMsg() Req Group Summary(" << mChannelId << ")";
std::cerr << std::endl;
uint32_t token;
mChannelQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, groupIds, CREATEMSG_CHANNELINFO);
if(!mOrigPostId.isNull()) if(!mOrigPostId.isNull())
{ loadOriginalChannelPostInfo();
GxsMsgReq message_ids;
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
message_ids[mChannelId].insert(mOrigPostId);
mChannelQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, message_ids, CREATEMSG_CHANNEL_POST_INFO);
}
} }
} }
@ -746,89 +728,92 @@ void CreateGxsChannelMsg::addThumbnail()
thumbnail_label->setPixmap(picture); thumbnail_label->setPixmap(picture);
} }
void CreateGxsChannelMsg::loadChannelPostInfo(const uint32_t &token) void CreateGxsChannelMsg::loadOriginalChannelPostInfo()
{ {
#ifdef DEBUG_CREATE_GXS_MSG #ifdef DEBUG_CREATE_GXS_MSG
std::cerr << "CreateGxsChannelMsg::loadChannelPostInfo()"; std::cerr << "CreateGxsChannelMsg::loadChannelPostInfo()";
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
RsThread::async([this]()
std::vector<RsGxsChannelPost> posts;
rsGxsChannels->getPostData(token, posts);
if (posts.size() != 1)
{ {
std::cerr << "CreateGxsChannelMsg::loadChannelPostInfo() ERROR INVALID Number of posts in request" << std::endl; std::vector<RsGxsChannelPost> posts;
return ; std::vector<RsGxsComment> comments;
}
// now populate the widget with the channel post data. if( !rsGxsChannels->getChannelContent(mChannelId,std::set<RsGxsMessageId>({mOrigPostId}),posts,comments) || posts.size() != 1)
const RsGxsChannelPost& post = posts[0]; {
std::cerr << "Cannot get channel post data for channel " << mChannelId << " and post " << mOrigPostId << std::endl;
return;
}
if(post.mMeta.mGroupId != mChannelId || post.mMeta.mMsgId != mOrigPostId) RsQThreadUtils::postToObject( [posts,this]()
{ {
std::cerr << "CreateGxsChannelMsg::loadChannelPostInfo() ERROR INVALID post ID or channel ID" << std::endl; /* Here it goes any code you want to be executed on the Qt Gui
return ; * thread, for example to update the data model with new information
} * after a blocking call to RetroShare API complete */
subjectEdit->setText(QString::fromUtf8(post.mMeta.mMsgName.c_str())) ; const RsGxsChannelPost& post(posts[0]);
RichTextEditWidget->setText(QString::fromUtf8(post.mMsg.c_str()));
for(std::list<RsGxsFile>::const_iterator it(post.mFiles.begin());it!=post.mFiles.end();++it) if(post.mMeta.mGroupId != mChannelId || post.mMeta.mMsgId != mOrigPostId)
addAttachment(it->mHash,it->mName,it->mSize,true,RsPeerId(),true); {
std::cerr << "CreateGxsChannelMsg::loadChannelPostInfo() ERROR INVALID post ID or channel ID" << std::endl;
return ;
}
subjectEdit->setText(QString::fromUtf8(post.mMeta.mMsgName.c_str())) ;
RichTextEditWidget->setText(QString::fromUtf8(post.mMsg.c_str()));
for(std::list<RsGxsFile>::const_iterator it(post.mFiles.begin());it!=post.mFiles.end();++it)
addAttachment(it->mHash,it->mName,it->mSize,true,RsPeerId(),true);
if(post.mThumbnail.mData != NULL)
{
GxsIdDetails::loadPixmapFromData(post.mThumbnail.mData,post.mThumbnail.mSize,picture,GxsIdDetails::ORIGINAL);
thumbnail_label->setPixmap(picture);
}
}, this );
});
if(post.mThumbnail.mData != NULL)
{
GxsIdDetails::loadPixmapFromData(post.mThumbnail.mData,post.mThumbnail.mSize,picture,GxsIdDetails::ORIGINAL);
thumbnail_label->setPixmap(picture);
}
} }
void CreateGxsChannelMsg::loadChannelInfo(const uint32_t &token) void CreateGxsChannelMsg::loadChannelInfo()
{ {
#ifdef DEBUG_CREATE_GXS_MSG #ifdef DEBUG_CREATE_GXS_MSG
std::cerr << "CreateGxsChannelMsg::loadChannelInfo()"; std::cerr << "CreateGxsChannelMsg::loadChannelInfo()";
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
std::list<RsGroupMetaData> groupInfo;
rsGxsChannels->getGroupSummary(token, groupInfo);
if (groupInfo.size() == 1) RsThread::async([this]()
{ {
RsGroupMetaData fi = groupInfo.front(); std::vector<RsGxsChannelGroup> groups;
saveChannelInfo(fi);
}
else
{
std::cerr << "CreateGxsChannelMsg::loadForumInfo() ERROR INVALID Number of Forums";
std::cerr << std::endl;
}
}
void CreateGxsChannelMsg::loadRequest(const TokenQueue *queue, const TokenRequest &req) if( !rsGxsChannels->getChannelsInfo(std::list<RsGxsGroupId>({mChannelId}),groups) || groups.size() != 1)
{ {
#ifdef DEBUG_CREATE_GXS_MSG std::cerr << "Cannot get channel group data for channel " << mChannelId << std::endl;
std::cerr << "CreateGxsChannelMsg::loadRequest() UserType: " << req.mUserType; return;
std::cerr << std::endl; }
#endif
if (queue == mChannelQueue) RsQThreadUtils::postToObject( [groups,this]()
{
/* now switch on req */
switch(req.mUserType)
{ {
case CREATEMSG_CHANNELINFO: /* Here it goes any code you want to be executed on the Qt Gui
loadChannelInfo(req.mToken); * thread, for example to update the data model with new information
break; * after a blocking call to RetroShare API complete */
case CREATEMSG_CHANNEL_POST_INFO:
loadChannelPostInfo(req.mToken); if (groups.size() == 1)
break; {
default: const RsGroupMetaData& fi = groups.front().mMeta;
std::cerr << "CreateGxsChannelMsg::loadRequest() UNKNOWN UserType "; saveChannelInfo(fi);
}
else
{
std::cerr << "CreateGxsChannelMsg::loadForumInfo() ERROR INVALID Number of Forums";
std::cerr << std::endl; std::cerr << std::endl;
} }
}
}, this );
});
} }
void CreateGxsChannelMsg::on_channelpostButton_clicked() void CreateGxsChannelMsg::on_channelpostButton_clicked()

View File

@ -22,7 +22,6 @@
#define _CREATE_GXSCHANNEL_MSG_H #define _CREATE_GXSCHANNEL_MSG_H
#include "ui_CreateGxsChannelMsg.h" #include "ui_CreateGxsChannelMsg.h"
#include "util/TokenQueue.h"
#include <retroshare/rsgxschannels.h> #include <retroshare/rsgxschannels.h>
#ifdef CHANNELS_FRAME_CATCHER #ifdef CHANNELS_FRAME_CATCHER
@ -31,7 +30,7 @@
class SubFileItem; class SubFileItem;
class CreateGxsChannelMsg : public QDialog, public TokenResponse, private Ui::CreateGxsChannelMsg class CreateGxsChannelMsg : public QDialog, private Ui::CreateGxsChannelMsg
{ {
Q_OBJECT Q_OBJECT
@ -51,9 +50,6 @@ public:
QPixmap picture; QPixmap picture;
// overload from TokenResponse
virtual void loadRequest(const TokenQueue*, const TokenRequest&);
protected: protected:
virtual void dragEnterEvent(QDragEnterEvent *event); virtual void dragEnterEvent(QDragEnterEvent *event);
virtual void dropEvent(QDropEvent *event); virtual void dropEvent(QDropEvent *event);
@ -74,8 +70,8 @@ private slots:
void on_channelpostButton_clicked(); void on_channelpostButton_clicked();
void on_attachmentsButton_clicked(); void on_attachmentsButton_clicked();
private: private:
void loadChannelInfo(const uint32_t &token); void loadChannelInfo();
void loadChannelPostInfo(const uint32_t &token); void loadOriginalChannelPostInfo();
void saveChannelInfo(const RsGroupMetaData &group); void saveChannelInfo(const RsGroupMetaData &group);
void parseRsFileListAttachments(const std::string &attachList); void parseRsFileListAttachments(const std::string &attachList);
@ -93,8 +89,6 @@ private:
bool mCheckAttachment; bool mCheckAttachment;
bool mAutoMediaThumbNail; bool mAutoMediaThumbNail;
TokenQueue *mChannelQueue;
#ifdef CHANNELS_FRAME_CATCHER #ifdef CHANNELS_FRAME_CATCHER
framecatcher* fCatcher; framecatcher* fCatcher;
#endif #endif