mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-04 23:25:32 -04:00
finished converting GxsMessageFrameWidget to blocking API
This commit is contained in:
parent
55c810f848
commit
cf7a77e512
13 changed files with 98 additions and 41 deletions
|
@ -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
|
||||
|
@ -331,10 +344,10 @@ public:
|
|||
* @param[out] comments storage for the comments
|
||||
* @return false if something failed, true otherwhise
|
||||
*/
|
||||
virtual bool getChannelContent( const RsGxsGroupId& channelId,
|
||||
const std::set<RsGxsMessageId>& contentsIds,
|
||||
std::vector<RsGxsChannelPost>& posts,
|
||||
std::vector<RsGxsComment>& comments ) = 0;
|
||||
virtual bool getChannelContent(const RsGxsGroupId& channelId,
|
||||
const std::set<RsGxsMessageId>& contentIds,
|
||||
std::vector<RsGxsChannelPost>& posts,
|
||||
std::vector<RsGxsComment>& comments ) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get channel content summaries
|
||||
|
|
|
@ -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,20 +1083,34 @@ 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,
|
||||
std::vector<RsGxsChannelPost>& posts,
|
||||
std::vector<RsGxsComment>& comments )
|
||||
const std::set<RsGxsMessageId>& contentIds,
|
||||
std::vector<RsGxsChannelPost>& posts,
|
||||
std::vector<RsGxsComment>& comments )
|
||||
{
|
||||
uint32_t token;
|
||||
RsTokReqOptions opts;
|
||||
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
|
||||
bool getChannelContent( const RsGxsGroupId& channelId,
|
||||
const std::set<RsGxsMessageId>& contentsIds,
|
||||
/// 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>& 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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue