mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-26 07:16:11 -05:00
removed token queue from CreateGxsChannelMsg
This commit is contained in:
parent
cf7a77e512
commit
4e3cb16535
@ -33,6 +33,7 @@
|
||||
#include "util/HandleRichText.h"
|
||||
#include "util/misc.h"
|
||||
#include "util/rsdir.h"
|
||||
#include "util/qtthreadsutils.h"
|
||||
#include "util/RichTextEdit.h"
|
||||
|
||||
#include <retroshare/rsfiles.h>
|
||||
@ -54,7 +55,6 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId, RsGxsMessageId
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
setupUi(this);
|
||||
Settings->loadWidgetInformation(this);
|
||||
mChannelQueue = new TokenQueue(rsGxsChannels->getTokenService(), this);
|
||||
|
||||
headerFrame->setHeaderImage(QPixmap(":/icons/png/channel.png"));
|
||||
|
||||
@ -104,8 +104,6 @@ CreateGxsChannelMsg::~CreateGxsChannelMsg()
|
||||
#ifdef CHANNELS_FRAME_CATCHER
|
||||
delete fCatcher;
|
||||
#endif
|
||||
|
||||
delete(mChannelQueue);
|
||||
}
|
||||
|
||||
void CreateGxsChannelMsg::contextMenu(QPoint /*point*/)
|
||||
@ -591,26 +589,10 @@ void CreateGxsChannelMsg::newChannelMsg()
|
||||
|
||||
/* request Data */
|
||||
{
|
||||
RsTokReqOptions opts;
|
||||
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);
|
||||
loadChannelInfo();
|
||||
|
||||
if(!mOrigPostId.isNull())
|
||||
{
|
||||
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);
|
||||
}
|
||||
loadOriginalChannelPostInfo();
|
||||
}
|
||||
}
|
||||
|
||||
@ -746,89 +728,92 @@ void CreateGxsChannelMsg::addThumbnail()
|
||||
thumbnail_label->setPixmap(picture);
|
||||
}
|
||||
|
||||
void CreateGxsChannelMsg::loadChannelPostInfo(const uint32_t &token)
|
||||
void CreateGxsChannelMsg::loadOriginalChannelPostInfo()
|
||||
{
|
||||
#ifdef DEBUG_CREATE_GXS_MSG
|
||||
std::cerr << "CreateGxsChannelMsg::loadChannelPostInfo()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::vector<RsGxsChannelPost> posts;
|
||||
rsGxsChannels->getPostData(token, posts);
|
||||
|
||||
if (posts.size() != 1)
|
||||
RsThread::async([this]()
|
||||
{
|
||||
std::cerr << "CreateGxsChannelMsg::loadChannelPostInfo() ERROR INVALID Number of posts in request" << std::endl;
|
||||
return ;
|
||||
}
|
||||
std::vector<RsGxsChannelPost> posts;
|
||||
std::vector<RsGxsComment> comments;
|
||||
|
||||
// now populate the widget with the channel post data.
|
||||
const RsGxsChannelPost& post = posts[0];
|
||||
if( !rsGxsChannels->getChannelContent(mChannelId,std::set<RsGxsMessageId>({mOrigPostId}),posts,comments) || posts.size() != 1)
|
||||
{
|
||||
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)
|
||||
{
|
||||
std::cerr << "CreateGxsChannelMsg::loadChannelPostInfo() ERROR INVALID post ID or channel ID" << std::endl;
|
||||
return ;
|
||||
}
|
||||
RsQThreadUtils::postToObject( [posts,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 */
|
||||
|
||||
subjectEdit->setText(QString::fromUtf8(post.mMeta.mMsgName.c_str())) ;
|
||||
RichTextEditWidget->setText(QString::fromUtf8(post.mMsg.c_str()));
|
||||
const RsGxsChannelPost& post(posts[0]);
|
||||
|
||||
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.mMeta.mGroupId != mChannelId || post.mMeta.mMsgId != mOrigPostId)
|
||||
{
|
||||
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
|
||||
std::cerr << "CreateGxsChannelMsg::loadChannelInfo()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::list<RsGroupMetaData> groupInfo;
|
||||
rsGxsChannels->getGroupSummary(token, groupInfo);
|
||||
|
||||
if (groupInfo.size() == 1)
|
||||
RsThread::async([this]()
|
||||
{
|
||||
RsGroupMetaData fi = groupInfo.front();
|
||||
saveChannelInfo(fi);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "CreateGxsChannelMsg::loadForumInfo() ERROR INVALID Number of Forums";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
}
|
||||
std::vector<RsGxsChannelGroup> groups;
|
||||
|
||||
void CreateGxsChannelMsg::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||
{
|
||||
#ifdef DEBUG_CREATE_GXS_MSG
|
||||
std::cerr << "CreateGxsChannelMsg::loadRequest() UserType: " << req.mUserType;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
if( !rsGxsChannels->getChannelsInfo(std::list<RsGxsGroupId>({mChannelId}),groups) || groups.size() != 1)
|
||||
{
|
||||
std::cerr << "Cannot get channel group data for channel " << mChannelId << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (queue == mChannelQueue)
|
||||
{
|
||||
/* now switch on req */
|
||||
switch(req.mUserType)
|
||||
RsQThreadUtils::postToObject( [groups,this]()
|
||||
{
|
||||
case CREATEMSG_CHANNELINFO:
|
||||
loadChannelInfo(req.mToken);
|
||||
break;
|
||||
case CREATEMSG_CHANNEL_POST_INFO:
|
||||
loadChannelPostInfo(req.mToken);
|
||||
break;
|
||||
default:
|
||||
std::cerr << "CreateGxsChannelMsg::loadRequest() UNKNOWN UserType ";
|
||||
/* 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 */
|
||||
|
||||
if (groups.size() == 1)
|
||||
{
|
||||
const RsGroupMetaData& fi = groups.front().mMeta;
|
||||
saveChannelInfo(fi);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "CreateGxsChannelMsg::loadForumInfo() ERROR INVALID Number of Forums";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}, this );
|
||||
});
|
||||
}
|
||||
|
||||
void CreateGxsChannelMsg::on_channelpostButton_clicked()
|
||||
|
@ -22,7 +22,6 @@
|
||||
#define _CREATE_GXSCHANNEL_MSG_H
|
||||
|
||||
#include "ui_CreateGxsChannelMsg.h"
|
||||
#include "util/TokenQueue.h"
|
||||
#include <retroshare/rsgxschannels.h>
|
||||
|
||||
#ifdef CHANNELS_FRAME_CATCHER
|
||||
@ -31,7 +30,7 @@
|
||||
|
||||
class SubFileItem;
|
||||
|
||||
class CreateGxsChannelMsg : public QDialog, public TokenResponse, private Ui::CreateGxsChannelMsg
|
||||
class CreateGxsChannelMsg : public QDialog, private Ui::CreateGxsChannelMsg
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -51,9 +50,6 @@ public:
|
||||
|
||||
QPixmap picture;
|
||||
|
||||
// overload from TokenResponse
|
||||
virtual void loadRequest(const TokenQueue*, const TokenRequest&);
|
||||
|
||||
protected:
|
||||
virtual void dragEnterEvent(QDragEnterEvent *event);
|
||||
virtual void dropEvent(QDropEvent *event);
|
||||
@ -74,8 +70,8 @@ private slots:
|
||||
void on_channelpostButton_clicked();
|
||||
void on_attachmentsButton_clicked();
|
||||
private:
|
||||
void loadChannelInfo(const uint32_t &token);
|
||||
void loadChannelPostInfo(const uint32_t &token);
|
||||
void loadChannelInfo();
|
||||
void loadOriginalChannelPostInfo();
|
||||
void saveChannelInfo(const RsGroupMetaData &group);
|
||||
|
||||
void parseRsFileListAttachments(const std::string &attachList);
|
||||
@ -93,8 +89,6 @@ private:
|
||||
bool mCheckAttachment;
|
||||
bool mAutoMediaThumbNail;
|
||||
|
||||
TokenQueue *mChannelQueue;
|
||||
|
||||
#ifdef CHANNELS_FRAME_CATCHER
|
||||
framecatcher* fCatcher;
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user