mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
finished converting GxsMessageFrameWidget to blocking API
This commit is contained in:
parent
55c810f848
commit
cf7a77e512
@ -217,7 +217,8 @@ bool RsGxsDataAccess::requestMsgInfo(uint32_t &token, uint32_t ansType,
|
||||
mmr->mMsgIds[*lit] = std::set<RsGxsMessageId>();
|
||||
|
||||
req = mmr;
|
||||
}else if(reqType & GXS_REQUEST_TYPE_MSG_DATA)
|
||||
}
|
||||
else if(reqType & GXS_REQUEST_TYPE_MSG_DATA)
|
||||
{
|
||||
MsgDataReq* mdr = new MsgDataReq();
|
||||
|
||||
@ -225,7 +226,8 @@ bool RsGxsDataAccess::requestMsgInfo(uint32_t &token, uint32_t ansType,
|
||||
mdr->mMsgIds[*lit] = std::set<RsGxsMessageId>();
|
||||
|
||||
req = mdr;
|
||||
}else if(reqType & GXS_REQUEST_TYPE_MSG_IDS)
|
||||
}
|
||||
else if(reqType & GXS_REQUEST_TYPE_MSG_IDS)
|
||||
{
|
||||
MsgIdReq* mir = new MsgIdReq();
|
||||
|
||||
|
@ -323,7 +323,20 @@ public:
|
||||
std::vector<RsGxsChannelGroup>& channelsInfo ) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get channel contents
|
||||
* @brief Get all channel messages and comments in a given channel
|
||||
* @jsonapi{development}
|
||||
* @param[in] channelId id of the channel of which the content is requested
|
||||
* @param[out] posts storage for posts
|
||||
* @param[out] comments storage for the comments
|
||||
* @return false if something failed, true otherwhise
|
||||
*/
|
||||
virtual bool getChannelAllContent(const RsGxsGroupId& channelId,
|
||||
std::vector<RsGxsChannelPost>& posts,
|
||||
std::vector<RsGxsComment>& comments ) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get channel messages and comments corresponding to the given message ID list. If the list is empty, nothing is returned. Since
|
||||
* comments are themselves messages, it is possible to get comments only by only supplying their message IDs.
|
||||
* @jsonapi{development}
|
||||
* @param[in] channelId id of the channel of which the content is requested
|
||||
* @param[in] contentsIds ids of requested contents
|
||||
@ -332,7 +345,7 @@ public:
|
||||
* @return false if something failed, true otherwhise
|
||||
*/
|
||||
virtual bool getChannelContent(const RsGxsGroupId& channelId,
|
||||
const std::set<RsGxsMessageId>& contentsIds,
|
||||
const std::set<RsGxsMessageId>& contentIds,
|
||||
std::vector<RsGxsChannelPost>& posts,
|
||||
std::vector<RsGxsComment>& comments ) = 0;
|
||||
|
||||
|
@ -40,8 +40,11 @@
|
||||
* are necessary, so at this point this workaround seems acceptable.
|
||||
*/
|
||||
|
||||
#define DEBUG_GXSIFACEHELPER 1
|
||||
|
||||
enum class TokenRequestType: uint8_t
|
||||
{
|
||||
UNDEFINED = 0x00,
|
||||
GROUP_INFO = 0x01,
|
||||
POSTS = 0x02,
|
||||
ALL_POSTS = 0x03,
|
||||
@ -284,7 +287,8 @@ public:
|
||||
if(mTokenService.requestMsgInfo(token, 0, opts, msgIds))
|
||||
{
|
||||
RS_STACK_MUTEX(mMtx);
|
||||
mActiveTokens[token]= msgIds.empty()?(TokenRequestType::ALL_POSTS):(TokenRequestType::POSTS);
|
||||
|
||||
mActiveTokens[token]= (msgIds.size()==1 && msgIds.begin()->second.size()==0) ?(TokenRequestType::ALL_POSTS):(TokenRequestType::POSTS);
|
||||
locked_dumpTokens();
|
||||
return true;
|
||||
}
|
||||
@ -459,15 +463,15 @@ private:
|
||||
|
||||
uint32_t count[7] = {0};
|
||||
|
||||
std::cerr << "Service 0x0" << std::hex << service_id
|
||||
std::cerr << "Service " << std::hex << service_id << std::dec
|
||||
<< " (" << rsServiceControl->getServiceName(RsServiceInfo::RsServiceInfoUIn16ToFullServiceId(service_id))
|
||||
<< ") this=0x" << (void*)this << ") Active tokens (per type): " ;
|
||||
<< ") this=" << std::hex << (void*)this << std::dec << ") Active tokens (per type): " ;
|
||||
|
||||
for(auto& it: mActiveTokens) // let's count how many token of each type we've got.
|
||||
++count[static_cast<int>(it.second)];
|
||||
|
||||
for(uint32_t i=0;i<7;++i)
|
||||
std::cerr /* << i << ":" */ << count[i] << " ";
|
||||
std::cerr << std::dec /* << i << ":" */ << count[i] << " ";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
};
|
||||
|
@ -150,6 +150,11 @@ public:
|
||||
|
||||
virtual bool getBoardsSummaries(std::list<RsGroupMetaData>& groupInfo) =0;
|
||||
|
||||
virtual bool getBoardAllContent(
|
||||
const RsGxsGroupId& boardId,
|
||||
std::vector<RsPostedPost>& posts,
|
||||
std::vector<RsGxsComment>& comments ) = 0;
|
||||
|
||||
virtual bool getBoardContent(
|
||||
const RsGxsGroupId& boardId,
|
||||
const std::set<RsGxsMessageId>& contentsIds,
|
||||
|
@ -1083,8 +1083,22 @@ bool p3GxsChannels::getContentSummaries(
|
||||
return res;
|
||||
}
|
||||
|
||||
bool p3GxsChannels::getChannelAllContent( const RsGxsGroupId& channelId,
|
||||
std::vector<RsGxsChannelPost>& posts,
|
||||
std::vector<RsGxsComment>& comments )
|
||||
{
|
||||
uint32_t token;
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||
|
||||
if( !requestMsgInfo(token, opts,std::list<RsGxsGroupId>({channelId})) || waitToken(token) != RsTokenService::COMPLETE )
|
||||
return false;
|
||||
|
||||
return getPostData(token, posts, comments);
|
||||
}
|
||||
|
||||
bool p3GxsChannels::getChannelContent( const RsGxsGroupId& channelId,
|
||||
const std::set<RsGxsMessageId>& contentsIds,
|
||||
const std::set<RsGxsMessageId>& contentIds,
|
||||
std::vector<RsGxsChannelPost>& posts,
|
||||
std::vector<RsGxsComment>& comments )
|
||||
{
|
||||
@ -1093,10 +1107,10 @@ bool p3GxsChannels::getChannelContent( const RsGxsGroupId& channelId,
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||
|
||||
GxsMsgReq msgIds;
|
||||
msgIds[channelId] = contentsIds;
|
||||
msgIds[channelId] = contentIds;
|
||||
|
||||
if( !requestMsgInfo(token, opts, msgIds) ||
|
||||
waitToken(token) != RsTokenService::COMPLETE ) return false;
|
||||
if( !requestMsgInfo(token, opts, msgIds) || waitToken(token) != RsTokenService::COMPLETE )
|
||||
return false;
|
||||
|
||||
return getPostData(token, posts, comments);
|
||||
}
|
||||
|
@ -185,9 +185,14 @@ virtual bool ExtraFileRemove(const RsFileHash &hash);
|
||||
const std::list<RsGxsGroupId>& chanIds,
|
||||
std::vector<RsGxsChannelGroup>& channelsInfo ) override;
|
||||
|
||||
/// Implementation of @see RsGxsChannels::getChannelContent
|
||||
/// Implementation of @see RsGxsChannels::getChannelAllMessages
|
||||
bool getChannelAllContent(const RsGxsGroupId& channelId,
|
||||
std::vector<RsGxsChannelPost>& posts,
|
||||
std::vector<RsGxsComment>& comments ) override;
|
||||
|
||||
/// Implementation of @see RsGxsChannels::getChannelMessages
|
||||
bool getChannelContent(const RsGxsGroupId& channelId,
|
||||
const std::set<RsGxsMessageId>& contentsIds,
|
||||
const std::set<RsGxsMessageId>& contentIds,
|
||||
std::vector<RsGxsChannelPost>& posts,
|
||||
std::vector<RsGxsComment>& comments ) override;
|
||||
|
||||
|
@ -322,6 +322,20 @@ bool p3Posted::getBoardsInfo(
|
||||
return getGroupData(token, groupsInfo) && !groupsInfo.empty();
|
||||
}
|
||||
|
||||
bool p3Posted::getBoardAllContent( const RsGxsGroupId& groupId,
|
||||
std::vector<RsPostedPost>& posts,
|
||||
std::vector<RsGxsComment>& comments )
|
||||
{
|
||||
uint32_t token;
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||
|
||||
if( !requestMsgInfo(token, opts, std::list<RsGxsGroupId>({groupId})) || waitToken(token) != RsTokenService::COMPLETE )
|
||||
return false;
|
||||
|
||||
return getPostData(token, posts, comments);
|
||||
}
|
||||
|
||||
bool p3Posted::getBoardContent( const RsGxsGroupId& groupId,
|
||||
const std::set<RsGxsMessageId>& contentsIds,
|
||||
std::vector<RsPostedPost>& posts,
|
||||
|
@ -61,6 +61,10 @@ virtual void receiveHelperChanges(std::vector<RsGxsNotify*>& changes)
|
||||
bool getBoardsInfo(const std::list<RsGxsGroupId>& boardsIds,
|
||||
std::vector<RsPostedGroup>& groupsInfo ) override;
|
||||
|
||||
bool getBoardAllContent(const RsGxsGroupId& groupId,
|
||||
std::vector<RsPostedPost>& posts,
|
||||
std::vector<RsGxsComment>& comments ) override;
|
||||
|
||||
bool getBoardContent(const RsGxsGroupId& groupId,
|
||||
const std::set<RsGxsMessageId>& contentsIds,
|
||||
std::vector<RsPostedPost>& posts,
|
||||
|
@ -888,6 +888,7 @@ void PostedListWidget::shallowClearPosts()
|
||||
bool PostedListWidget::insertGroupData(const RsGxsGenericGroupData *data)
|
||||
{
|
||||
insertPostedDetails(*dynamic_cast<const RsPostedGroup*>(data));
|
||||
return true;
|
||||
}
|
||||
|
||||
void PostedListWidget::insertAllPostedPosts(const std::vector<RsPostedPost>& posts, GxsMessageFramePostThread */*thread*/)
|
||||
@ -1048,7 +1049,7 @@ void PostedListWidget::getAllMsgData(std::vector<RsGxsGenericMsgData*>& psts)
|
||||
std::vector<RsPostedPost> posts;
|
||||
std::vector<RsGxsComment> comments;
|
||||
|
||||
rsPosted->getBoardContent( groupId(),std::set<RsGxsMessageId>(),posts,comments );
|
||||
rsPosted->getBoardAllContent( groupId(),posts,comments );
|
||||
|
||||
psts.clear();
|
||||
|
||||
@ -1073,10 +1074,7 @@ void PostedListWidget::insertPosts(const std::vector<RsGxsGenericMsgData*>& post
|
||||
std::vector<RsPostedPost> cposts;
|
||||
|
||||
for(auto post: posts) // This is not so nice but we have somehow to convert to RsGxsChannelPost at some timer, and the cposts list is being modified in the insert method.
|
||||
{
|
||||
cposts.push_back(*dynamic_cast<RsPostedPost*>(post));
|
||||
delete post;
|
||||
}
|
||||
|
||||
insertPostedPosts(cposts);
|
||||
}
|
||||
@ -1086,10 +1084,7 @@ void PostedListWidget::insertAllPosts(const std::vector<RsGxsGenericMsgData*>& p
|
||||
std::vector<RsPostedPost> cposts;
|
||||
|
||||
for(auto post: posts) // This is not so nice but we have somehow to convert to RsGxsChannelPost at some timer, and the cposts list is being modified in the insert method.
|
||||
{
|
||||
cposts.push_back(*dynamic_cast<RsPostedPost*>(post));
|
||||
delete post;
|
||||
}
|
||||
|
||||
insertAllPostedPosts(cposts, NULL);
|
||||
}
|
||||
|
@ -510,6 +510,12 @@ void GxsMessageFramePostWidget::loadPosts(const std::set<RsGxsMessageId>& msgIds
|
||||
|
||||
mNavigatePendingMsgId.clear();
|
||||
}
|
||||
|
||||
// don't forget to delete posts.
|
||||
|
||||
for(auto& post:posts)
|
||||
delete post;
|
||||
|
||||
}, this );
|
||||
});
|
||||
}
|
||||
|
@ -81,6 +81,8 @@ protected:
|
||||
//void requestPosts(const std::set<RsGxsMessageId> &msgIds);
|
||||
//void loadPosts(const uint32_t &token);
|
||||
#endif
|
||||
// In the following 3 methods, the memory ownership is kept by GxsMessageFramePostWidget
|
||||
|
||||
virtual bool insertGroupData(const RsGxsGenericGroupData *data) =0;
|
||||
virtual void insertPosts(const std::vector<RsGxsGenericMsgData*>& posts) =0;
|
||||
virtual void insertAllPosts(const std::vector<RsGxsGenericMsgData*>& posts, GxsMessageFramePostThread *thread) =0;
|
||||
|
@ -148,7 +148,7 @@ void GxsChannelPostsWidget::handleEvent_main_thread(std::shared_ptr<const RsEven
|
||||
case RsChannelEventCode::NEW_CHANNEL:
|
||||
case RsChannelEventCode::UPDATED_MESSAGE:
|
||||
case RsChannelEventCode::NEW_MESSAGE:
|
||||
if(e->mChannelGroupId == mChannelGroupId)
|
||||
if(e->mChannelGroupId == groupId())
|
||||
updateDisplay(true);
|
||||
break;
|
||||
default:
|
||||
@ -737,7 +737,6 @@ void GxsChannelPostsWidget::toggleAutoDownload()
|
||||
bool GxsChannelPostsWidget::insertGroupData(const RsGxsGenericGroupData *data)
|
||||
{
|
||||
insertChannelDetails(*dynamic_cast<const RsGxsChannelGroup*>(data));
|
||||
mChannelGroupId = data->mMeta.mGroupId;
|
||||
return true;
|
||||
|
||||
}
|
||||
@ -757,7 +756,7 @@ void GxsChannelPostsWidget::getMsgData(const std::set<RsGxsMessageId>& msgIds,st
|
||||
std::vector<RsGxsChannelPost> posts;
|
||||
std::vector<RsGxsComment> comments;
|
||||
|
||||
rsGxsChannels->getChannelContent( mChannelGroupId,msgIds,posts,comments );
|
||||
rsGxsChannels->getChannelContent( groupId(),msgIds,posts,comments );
|
||||
|
||||
psts.clear();
|
||||
|
||||
@ -770,7 +769,7 @@ void GxsChannelPostsWidget::getAllMsgData(std::vector<RsGxsGenericMsgData*>& pst
|
||||
std::vector<RsGxsChannelPost> posts;
|
||||
std::vector<RsGxsComment> comments;
|
||||
|
||||
rsGxsChannels->getChannelContent( mChannelGroupId,std::set<RsGxsMessageId>(),posts,comments );
|
||||
rsGxsChannels->getChannelAllContent( groupId(),posts,comments );
|
||||
|
||||
psts.clear();
|
||||
|
||||
@ -795,7 +794,6 @@ bool GxsChannelPostsWidget::getGroupData(RsGxsGenericGroupData *& data)
|
||||
{
|
||||
insertChannelDetails(distant_group);
|
||||
data = new RsGxsChannelGroup(distant_group);
|
||||
mChannelGroupId = distant_group.mMeta.mGroupId;
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
@ -808,10 +806,7 @@ void GxsChannelPostsWidget::insertAllPosts(const std::vector<RsGxsGenericMsgData
|
||||
std::vector<RsGxsChannelPost> cposts;
|
||||
|
||||
for(auto post: posts) // This is not so nice but we have somehow to convert to RsGxsChannelPost at some timer, and the cposts list is being modified in the insert method.
|
||||
{
|
||||
cposts.push_back(*dynamic_cast<RsGxsChannelPost*>(post));
|
||||
delete post;
|
||||
}
|
||||
cposts.push_back(*static_cast<RsGxsChannelPost*>(post));
|
||||
|
||||
insertChannelPosts(cposts, thread, false);
|
||||
}
|
||||
@ -820,10 +815,7 @@ void GxsChannelPostsWidget::insertPosts(const std::vector<RsGxsGenericMsgData*>&
|
||||
std::vector<RsGxsChannelPost> cposts;
|
||||
|
||||
for(auto post: posts) // This is not so nice but we have somehow to convert to RsGxsChannelPost at some timer, and the cposts list is being modified in the insert method.
|
||||
{
|
||||
cposts.push_back(*dynamic_cast<RsGxsChannelPost*>(post));
|
||||
delete post;
|
||||
}
|
||||
cposts.push_back(*static_cast<RsGxsChannelPost*>(post));
|
||||
|
||||
insertChannelPosts(cposts, NULL, true);
|
||||
}
|
||||
|
@ -66,8 +66,10 @@ protected:
|
||||
/* GxsMessageFramePostWidget */
|
||||
virtual void groupNameChanged(const QString &name);
|
||||
virtual bool insertGroupData(const RsGxsGenericGroupData *data) override;
|
||||
#ifdef TO_REMOVE
|
||||
virtual void insertAllPosts(const uint32_t &token, GxsMessageFramePostThread *thread);
|
||||
virtual void insertPosts(const uint32_t &token);
|
||||
#endif
|
||||
virtual void clearPosts();
|
||||
virtual bool useThread() { return mUseThread; }
|
||||
virtual void fillThreadCreatePost(const QVariant &post, bool related, int current, int count);
|
||||
@ -109,7 +111,6 @@ private:
|
||||
QAction *mAutoDownloadAction;
|
||||
|
||||
bool mUseThread;
|
||||
RsGxsGroupId mChannelGroupId;
|
||||
RsEventsHandlerId_t mEventHandlerId ;
|
||||
|
||||
/* UI - from Designer */
|
||||
|
Loading…
Reference in New Issue
Block a user