mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-03 14:45:12 -04:00
1/4 convertion of GxsGroupFrameDialog to blocking API
This commit is contained in:
parent
1a9ac16546
commit
2387150f64
18 changed files with 251 additions and 131 deletions
|
@ -25,6 +25,9 @@
|
|||
* #define RS_DATA_SERVICE_DEBUG_TIME 1
|
||||
* #define RS_DATA_SERVICE_DEBUG_CACHE 1
|
||||
****/
|
||||
#define RS_DATA_SERVICE_DEBUG 1
|
||||
#define RS_DATA_SERVICE_DEBUG_TIME 1
|
||||
#define RS_DATA_SERVICE_DEBUG_CACHE 1
|
||||
|
||||
#include <fstream>
|
||||
#include <util/rsdir.h>
|
||||
|
@ -1343,6 +1346,7 @@ int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaRes
|
|||
}
|
||||
|
||||
#ifdef RS_DATA_SERVICE_DEBUG_TIME
|
||||
if(mDbName==std::string("gxsforums_db"))
|
||||
std::cerr << "RsDataService::retrieveGxsMsgMetaData() " << mDbName << ", Requests: " << reqIds.size() << ", Results: " << resultCount << ", Time: " << timer.duration() << std::endl;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
/***********
|
||||
* #define DATA_DEBUG 1
|
||||
**********/
|
||||
#define DATA_DEBUG 1
|
||||
|
||||
RsGxsDataAccess::RsGxsDataAccess(RsGeneralDataService* ds) :
|
||||
mDataStore(ds), mDataMutex("RsGxsDataAccess"), mNextToken(0) {}
|
||||
|
|
|
@ -45,11 +45,10 @@ class RsGxsChannels;
|
|||
extern RsGxsChannels* rsGxsChannels;
|
||||
|
||||
|
||||
struct RsGxsChannelGroup : RsSerializable
|
||||
struct RsGxsChannelGroup : RsSerializable, RsGxsGenericGroupData
|
||||
{
|
||||
RsGxsChannelGroup() : mAutoDownload(false) {}
|
||||
|
||||
RsGroupMetaData mMeta;
|
||||
std::string mDescription;
|
||||
RsGxsImage mImage;
|
||||
|
||||
|
|
|
@ -54,11 +54,8 @@ static const uint32_t RS_GXS_FORUM_MSG_FLAGS_MODERATED = 0x00000001;
|
|||
#define IS_FORUM_MSG_MODERATION(flags) (flags & RS_GXS_FORUM_MSG_FLAGS_MODERATED)
|
||||
|
||||
|
||||
struct RsGxsForumGroup : RsSerializable
|
||||
struct RsGxsForumGroup : RsSerializable, RsGxsGenericGroupData
|
||||
{
|
||||
/** Forum GXS metadata */
|
||||
RsGroupMetaData mMeta;
|
||||
|
||||
/** @brief Forum desciption */
|
||||
std::string mDescription;
|
||||
|
||||
|
|
|
@ -118,8 +118,15 @@ struct RsGroupMetaData : RsSerializable
|
|||
}
|
||||
};
|
||||
|
||||
// This is the parent class of all interface-level GXS group data. Derived classes
|
||||
// will include service-specific information, such as icon, description, etc
|
||||
|
||||
struct RsGxsGenericGroupData
|
||||
{
|
||||
virtual ~RsGxsGenericGroupData() = default; // making the type polymorphic
|
||||
|
||||
RsGroupMetaData mMeta;
|
||||
};
|
||||
|
||||
struct RsMsgMetaData : RsSerializable
|
||||
{
|
||||
|
|
|
@ -40,9 +40,8 @@ class RsPosted;
|
|||
*/
|
||||
extern RsPosted* rsPosted;
|
||||
|
||||
struct RsPostedGroup
|
||||
struct RsPostedGroup: RsGxsGenericGroupData
|
||||
{
|
||||
RsGroupMetaData mMeta;
|
||||
std::string mDescription;
|
||||
RsGxsImage mGroupImage;
|
||||
};
|
||||
|
@ -150,6 +149,8 @@ public:
|
|||
const std::list<RsGxsGroupId>& boardsIds,
|
||||
std::vector<RsPostedGroup>& boardsInfo ) = 0;
|
||||
|
||||
virtual bool getBoardsSummaries(std::list<RsGroupMetaData>& groupInfo) =0;
|
||||
|
||||
virtual bool getBoardContent(
|
||||
const RsGxsGroupId& boardId,
|
||||
const std::set<RsGxsMessageId>& contentsIds,
|
||||
|
|
|
@ -1033,15 +1033,23 @@ bool p3GxsChannels::getChannelsSummaries(
|
|||
return getGroupSummary(token, channels);
|
||||
}
|
||||
|
||||
bool p3GxsChannels::getChannelsInfo(
|
||||
const std::list<RsGxsGroupId>& chanIds,
|
||||
std::vector<RsGxsChannelGroup>& channelsInfo )
|
||||
bool p3GxsChannels::getChannelsInfo( const std::list<RsGxsGroupId>& chanIds, std::vector<RsGxsChannelGroup>& channelsInfo )
|
||||
{
|
||||
uint32_t token;
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
if( !requestGroupInfo(token, opts, chanIds)
|
||||
|| waitToken(token) != RsTokenService::COMPLETE ) return false;
|
||||
|
||||
if(chanIds.empty())
|
||||
{
|
||||
if( !requestGroupInfo(token, opts) || waitToken(token) != RsTokenService::COMPLETE )
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !requestGroupInfo(token, opts, chanIds) || waitToken(token) != RsTokenService::COMPLETE )
|
||||
return false;
|
||||
}
|
||||
|
||||
return getGroupData(token, channelsInfo) && !channelsInfo.empty();
|
||||
}
|
||||
|
||||
|
|
|
@ -666,15 +666,22 @@ bool p3GxsForums::getForumsSummaries( std::list<RsGroupMetaData>& forums )
|
|||
return getGroupSummary(token, forums);
|
||||
}
|
||||
|
||||
bool p3GxsForums::getForumsInfo(
|
||||
const std::list<RsGxsGroupId>& forumIds,
|
||||
std::vector<RsGxsForumGroup>& forumsInfo )
|
||||
bool p3GxsForums::getForumsInfo( const std::list<RsGxsGroupId>& forumIds, std::vector<RsGxsForumGroup>& forumsInfo )
|
||||
{
|
||||
uint32_t token;
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
if( !requestGroupInfo(token, opts, forumIds)
|
||||
|| waitToken(token,std::chrono::milliseconds(5000)) != RsTokenService::COMPLETE ) return false;
|
||||
|
||||
if(forumIds.empty())
|
||||
{
|
||||
if( !requestGroupInfo(token, opts) || waitToken(token,std::chrono::milliseconds(5000)) != RsTokenService::COMPLETE )
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !requestGroupInfo(token, opts, forumIds) || waitToken(token,std::chrono::milliseconds(5000)) != RsTokenService::COMPLETE )
|
||||
return false;
|
||||
}
|
||||
return getGroupData(token, forumsInfo);
|
||||
}
|
||||
|
||||
|
|
|
@ -330,5 +330,15 @@ bool p3Posted::getBoardContent( const RsGxsGroupId& groupId,
|
|||
return getPostData(token, posts, comments);
|
||||
}
|
||||
|
||||
bool p3Posted::getBoardsSummaries(std::list<RsGroupMetaData>& boards )
|
||||
{
|
||||
uint32_t token;
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
|
||||
if( !requestGroupInfo(token, opts) || waitToken(token) != RsTokenService::COMPLETE ) return false;
|
||||
|
||||
return getGroupSummary(token, boards);
|
||||
}
|
||||
|
||||
RsPosted::~RsPosted() = default;
|
||||
RsGxsPostedEvent::~RsGxsPostedEvent() = default;
|
||||
|
|
|
@ -66,6 +66,8 @@ virtual void receiveHelperChanges(std::vector<RsGxsNotify*>& changes)
|
|||
std::vector<RsPostedPost>& posts,
|
||||
std::vector<RsGxsComment>& comments ) override;
|
||||
|
||||
bool getBoardsSummaries(std::list<RsGroupMetaData>& groupInfo) override;
|
||||
|
||||
virtual bool getGroupData(const uint32_t &token, std::vector<RsPostedGroup> &groups);
|
||||
virtual bool getPostData(const uint32_t &token, std::vector<RsPostedPost> &posts, std::vector<RsGxsComment> &cmts);
|
||||
virtual bool getPostData(const uint32_t &token, std::vector<RsPostedPost> &posts) { std::vector<RsGxsComment> cmts; return getPostData( token, posts, cmts);}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue