Fix compilation of forum API

This commit is contained in:
Gioacchino Mazzurco 2018-12-16 17:40:47 +01:00
parent 9264ef821f
commit d19531cfcc
No known key found for this signature in database
GPG Key ID: A1FBCA3872E87051
4 changed files with 27 additions and 55 deletions

View File

@ -143,40 +143,28 @@ public:
const std::list<RsGxsGroupId>& forumIds, const std::list<RsGxsGroupId>& forumIds,
std::vector<RsGxsForumGroup>& forumsInfo ) = 0; std::vector<RsGxsForumGroup>& forumsInfo ) = 0;
/** /**
* @brief Get content of specified forums. Blocking API * @brief Get message metadatas for a specific forum. Blocking API
* @jsonapi{development} * @jsonapi{development}
* @param[in] forumIds id of the forum of which the content is requested * @param[in] forumId id of the forum of which the content is requested
* @param[out] messages storage for the forum messages * @param[out] msgMetas storage for the forum messages meta data
* @return false if something failed, true otherwhise
*/
virtual bool getForumsContent(
const std::list<RsGxsGroupId>& forumIds,
std::vector<RsGxsForumMsg>& messages ) = 0;
/**
* @brief Get message metadatas for some messages of a specific forum. Blocking API
* @jsonapi{development}
* @param[in] forumIds id of the forum of which the content is requested
* @param[out] msg_metas storage for the forum messages meta data
* @return false if something failed, true otherwhise * @return false if something failed, true otherwhise
*/ */
virtual bool getForumMsgMetaData( const RsGxsGroupId& forumId, virtual bool getForumMsgMetaData( const RsGxsGroupId& forumId,
std::vector<RsMsgMetaData>& msg_metas) =0; std::vector<RsMsgMetaData>& msgMetas) = 0;
/** /**
* @brief Get specific list of messages from a single forums. Blocking API * @brief Get specific list of messages from a single forums. Blocking API
* @jsonapi{development} * @jsonapi{development}
* @param[in] forumId id of the forum of which the content is requested * @param[in] forumId id of the forum of which the content is requested
* @param[in] msgs_to_request list of message ids to request * @param[in] msgsIds list of message ids to request
* @param[out] msgs storage for the forum messages * @param[out] msgs storage for the forum messages
* @return false if something failed, true otherwhise * @return false if something failed, true otherwhise
*/ */
virtual bool getForumsContent( virtual bool getForumContent(
const RsGxsGroupId& forumId, const RsGxsGroupId& forumId,
std::set<RsGxsMessageId>& msgs_to_request, std::set<RsGxsMessageId>& msgsIds,
std::vector<RsGxsForumMsg>& msgs) =0; std::vector<RsGxsForumMsg>& msgs) = 0;
/** /**
* @brief Toggle message read status. Blocking API. * @brief Toggle message read status. Blocking API.
@ -200,7 +188,7 @@ public:
/* Specific Service Data */ /* Specific Service Data */
RS_DEPRECATED_FOR("getForumsSummaries, getForumsInfo") RS_DEPRECATED_FOR("getForumsSummaries, getForumsInfo")
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsForumGroup> &groups) = 0; virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsForumGroup> &groups) = 0;
RS_DEPRECATED_FOR(getForumsContent) RS_DEPRECATED_FOR(getForumContent)
virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs) = 0; virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs) = 0;
RS_DEPRECATED_FOR(markRead) RS_DEPRECATED_FOR(markRead)
virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read) = 0; virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read) = 0;

View File

@ -460,7 +460,9 @@ bool p3GxsForums::getForumsInfo(
return getGroupData(token, forumsInfo); return getGroupData(token, forumsInfo);
} }
bool p3GxsForums::getForumsContent( const RsGxsGroupId& forumId, std::set<RsGxsMessageId>& msgs_to_request,std::vector<RsGxsForumMsg>& msgs) bool p3GxsForums::getForumContent(
const RsGxsGroupId& forumId, std::set<RsGxsMessageId>& msgs_to_request,
std::vector<RsGxsForumMsg>& msgs )
{ {
uint32_t token; uint32_t token;
RsTokReqOptions opts; RsTokReqOptions opts;
@ -469,21 +471,11 @@ bool p3GxsForums::getForumsContent( const RsGxsGroupId& forumId, std::set<RsGxsM
GxsMsgReq msgIds; GxsMsgReq msgIds;
msgIds[forumId] = msgs_to_request; msgIds[forumId] = msgs_to_request;
if( !requestMsgInfo(token, opts, msgIds) || waitToken(token,std::chrono::milliseconds(5000)) != RsTokenService::COMPLETE ) return false; if( !requestMsgInfo(token, opts, msgIds) ||
waitToken(token,std::chrono::seconds(5)) != RsTokenService::COMPLETE )
return false;
return getMsgData(token, msgs) ; return getMsgData(token, msgs);
}
bool p3GxsForums::getForumsContent(
const std::list<RsGxsGroupId>& forumIds,
std::vector<RsGxsForumMsg>& messages )
{
uint32_t token;
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
if( !requestMsgInfo(token, opts, forumIds)
|| waitToken(token,std::chrono::milliseconds(5000)) != RsTokenService::COMPLETE ) return false;
return getMsgData(token, messages);
} }

View File

@ -72,16 +72,14 @@ public:
const std::list<RsGxsGroupId>& forumIds, const std::list<RsGxsGroupId>& forumIds,
std::vector<RsGxsForumGroup>& forumsInfo ); std::vector<RsGxsForumGroup>& forumsInfo );
/// @see RsGxsForums::getForumsContent
virtual bool getForumsContent(
const std::list<RsGxsGroupId>& forumIds,
std::vector<RsGxsForumMsg>& messages );
/// @see RsGxsForums::getForumMsgMetaData /// @see RsGxsForums::getForumMsgMetaData
virtual bool getForumMsgMetaData(const RsGxsGroupId& forumId, std::vector<RsMsgMetaData>& msg_metas) ; virtual bool getForumMsgMetaData(const RsGxsGroupId& forumId, std::vector<RsMsgMetaData>& msg_metas) ;
/// @see RsGxsForums::getForumsContent /// @see RsGxsForums::getForumContent
virtual bool getForumsContent( const RsGxsGroupId& forumId, std::set<RsGxsMessageId>& msgs_to_request,std::vector<RsGxsForumMsg>& msgs) ; virtual bool getForumContent(
const RsGxsGroupId& forumId,
std::set<RsGxsMessageId>& msgs_to_request,
std::vector<RsGxsForumMsg>& msgs );
/// @see RsGxsForums::markRead /// @see RsGxsForums::markRead
virtual bool markRead(const RsGxsGrpMsgIdPair& messageId, bool read); virtual bool markRead(const RsGxsGrpMsgIdPair& messageId, bool read);

View File

@ -1653,7 +1653,7 @@ void GxsForumThreadWidget::async_msg_action(const MsgMethod &action)
msgs_to_request.insert(mThreadId); msgs_to_request.insert(mThreadId);
if(!rsGxsForums->getForumsContent(groupId(),msgs_to_request,msgs)) if(!rsGxsForums->getForumContent(groupId(),msgs_to_request,msgs))
{ {
std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve forum group info for forum " << groupId() << std::endl; std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve forum group info for forum " << groupId() << std::endl;
return; return;
@ -1675,9 +1675,7 @@ void GxsForumThreadWidget::async_msg_action(const MsgMethod &action)
{ {
/* Here it goes any code you want to be executed on the Qt Gui /* 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 * thread, for example to update the data model with new information
* after a blocking call to RetroShare API complete, note that * after a blocking call to RetroShare API complete */
* Qt::QueuedConnection is important!
*/
(this->*action)(msg); (this->*action)(msg);
@ -1927,9 +1925,7 @@ void GxsForumThreadWidget::updateGroupData()
{ {
/* Here it goes any code you want to be executed on the Qt Gui /* 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 * thread, for example to update the data model with new information
* after a blocking call to RetroShare API complete, note that * after a blocking call to RetroShare API complete */
* Qt::QueuedConnection is important!
*/
mForumGroup = *group; mForumGroup = *group;
delete group; delete group;
@ -1957,7 +1953,7 @@ void GxsForumThreadWidget::updateMessageData(const RsGxsMessageId& msgId)
msgs_to_request.insert(msgId); msgs_to_request.insert(msgId);
if(!rsGxsForums->getForumsContent(groupId(),msgs_to_request,msgs)) if(!rsGxsForums->getForumContent(groupId(),msgs_to_request,msgs))
{ {
std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve forum group info for forum " << groupId() << std::endl; std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve forum group info for forum " << groupId() << std::endl;
return; return;
@ -1986,9 +1982,7 @@ void GxsForumThreadWidget::updateMessageData(const RsGxsMessageId& msgId)
{ {
/* Here it goes any code you want to be executed on the Qt Gui /* 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 * thread, for example to update the data model with new information
* after a blocking call to RetroShare API complete, note that * after a blocking call to RetroShare API complete */
* Qt::QueuedConnection is important!
*/
insertMessageData(*msg); insertMessageData(*msg);