mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-03 22:55:04 -04:00
Extend libresapi with minimal support for channels
The code is not elegant as this version of the API will be soon obsolete but it offer a bunch of channels functionalities, comments and votes are not implemented yet /channels/list_channels get all visibile channels /channels/get_channel get content of a subscribed channel /channels/toggle_subscribe subscribe/unsubscribe to a channel /channels/toggle_auto_download set/unset auto-download for files attached to posts in a channel /channels/toggle_read mark a post as read /channels/create_channel create a new channel /channels/create_post create a new post in given channel, group_id paramenter renamed to channel_id for consistence mChannels use reference instead of pointer as it must be valid for the whole lifetime of the object RsGxsCommentService and derivatives use proper types for parameter, avoid reference when unneeded
This commit is contained in:
parent
73c6deebf4
commit
8d1f1da242
7 changed files with 449 additions and 77 deletions
|
@ -124,24 +124,27 @@ class RsGxsComment
|
|||
};
|
||||
|
||||
|
||||
class RsGxsCommentService
|
||||
struct RsGxsCommentService
|
||||
{
|
||||
public:
|
||||
RsGxsCommentService() {}
|
||||
virtual ~RsGxsCommentService() {}
|
||||
|
||||
RsGxsCommentService() { return; }
|
||||
virtual ~RsGxsCommentService() { return; }
|
||||
/** Get previously requested comment data with token */
|
||||
virtual bool getCommentData( uint32_t token,
|
||||
std::vector<RsGxsComment> &comments ) = 0;
|
||||
virtual bool getRelatedComments( uint32_t token,
|
||||
std::vector<RsGxsComment> &comments ) = 0;
|
||||
|
||||
virtual bool getCommentData(const uint32_t &token, std::vector<RsGxsComment> &comments) = 0;
|
||||
virtual bool getRelatedComments(const uint32_t &token, std::vector<RsGxsComment> &comments) = 0;
|
||||
virtual bool createComment(uint32_t &token, RsGxsComment &comment) = 0;
|
||||
virtual bool createVote(uint32_t &token, RsGxsVote &vote) = 0;
|
||||
|
||||
//virtual bool getDetailedCommentData(const uint32_t &token, std::vector<RsGxsComment> &comments);
|
||||
|
||||
virtual bool createComment(uint32_t &token, RsGxsComment &comment) = 0;
|
||||
virtual bool createVote(uint32_t &token, RsGxsVote &vote) = 0;
|
||||
|
||||
virtual bool acknowledgeComment(const uint32_t& token, std::pair<RsGxsGroupId, RsGxsMessageId>& msgId) = 0;
|
||||
virtual bool acknowledgeVote(const uint32_t& token, std::pair<RsGxsGroupId, RsGxsMessageId>& msgId) = 0;
|
||||
virtual bool acknowledgeComment(
|
||||
uint32_t token,
|
||||
std::pair<RsGxsGroupId, RsGxsMessageId>& msgId ) = 0;
|
||||
|
||||
virtual bool acknowledgeVote(
|
||||
uint32_t token,
|
||||
std::pair<RsGxsGroupId, RsGxsMessageId>& msgId ) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1179,7 +1179,9 @@ void p3GxsChannels::setMessageProcessedStatus(uint32_t& token, const RsGxsGrpMsg
|
|||
setMsgStatusFlags(token, msgId, status, mask);
|
||||
}
|
||||
|
||||
void p3GxsChannels::setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read)
|
||||
void p3GxsChannels::setMessageReadStatus( uint32_t& token,
|
||||
const RsGxsGrpMsgIdPair& msgId,
|
||||
bool read )
|
||||
{
|
||||
#ifdef GXSCHANNELS_DEBUG
|
||||
std::cerr << "p3GxsChannels::setMessageReadStatus()";
|
||||
|
@ -1189,10 +1191,8 @@ void p3GxsChannels::setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPai
|
|||
/* Always remove status unprocessed */
|
||||
uint32_t mask = GXS_SERV::GXS_MSG_STATUS_GUI_NEW | GXS_SERV::GXS_MSG_STATUS_GUI_UNREAD;
|
||||
uint32_t status = GXS_SERV::GXS_MSG_STATUS_GUI_UNREAD;
|
||||
if (read)
|
||||
{
|
||||
status = 0;
|
||||
}
|
||||
if (read) status = 0;
|
||||
|
||||
setMsgStatusFlags(token, msgId, status, mask);
|
||||
}
|
||||
|
||||
|
|
|
@ -108,15 +108,12 @@ virtual bool setChannelDownloadDirectory(const RsGxsGroupId &groupId, const std:
|
|||
virtual bool getChannelDownloadDirectory(const RsGxsGroupId &groupId, std::string& directory);
|
||||
|
||||
/* Comment service - Provide RsGxsCommentService - redirect to p3GxsCommentService */
|
||||
virtual bool getCommentData(const uint32_t &token, std::vector<RsGxsComment> &msgs)
|
||||
{
|
||||
return mCommentService->getGxsCommentData(token, msgs);
|
||||
}
|
||||
virtual bool getCommentData(uint32_t token, std::vector<RsGxsComment> &msgs)
|
||||
{ return mCommentService->getGxsCommentData(token, msgs); }
|
||||
|
||||
virtual bool getRelatedComments(const uint32_t &token, std::vector<RsGxsComment> &msgs)
|
||||
{
|
||||
return mCommentService->getGxsRelatedComments(token, msgs);
|
||||
}
|
||||
virtual bool getRelatedComments( uint32_t token,
|
||||
std::vector<RsGxsComment> &msgs )
|
||||
{ return mCommentService->getGxsRelatedComments(token, msgs); }
|
||||
|
||||
virtual bool createComment(uint32_t &token, RsGxsComment &msg)
|
||||
{
|
||||
|
@ -128,13 +125,13 @@ virtual bool createVote(uint32_t &token, RsGxsVote &msg)
|
|||
return mCommentService->createGxsVote(token, msg);
|
||||
}
|
||||
|
||||
virtual bool acknowledgeComment(const uint32_t& token, std::pair<RsGxsGroupId, RsGxsMessageId>& msgId)
|
||||
virtual bool acknowledgeComment(uint32_t token, std::pair<RsGxsGroupId, RsGxsMessageId>& msgId)
|
||||
{
|
||||
return acknowledgeMsg(token, msgId);
|
||||
}
|
||||
|
||||
|
||||
virtual bool acknowledgeVote(const uint32_t& token, std::pair<RsGxsGroupId, RsGxsMessageId>& msgId)
|
||||
virtual bool acknowledgeVote(uint32_t token, std::pair<RsGxsGroupId, RsGxsMessageId>& msgId)
|
||||
{
|
||||
if (mCommentService->acknowledgeVote(token, msgId))
|
||||
{
|
||||
|
|
|
@ -83,16 +83,14 @@ virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgI
|
|||
}
|
||||
|
||||
|
||||
/* Comment service - Provide RsGxsCommentService - redirect to p3GxsCommentService */
|
||||
virtual bool getCommentData(const uint32_t &token, std::vector<RsGxsComment> &msgs)
|
||||
{
|
||||
return mCommentService->getGxsCommentData(token, msgs);
|
||||
}
|
||||
/** Comment service - Provide RsGxsCommentService -
|
||||
* redirect to p3GxsCommentService */
|
||||
virtual bool getCommentData(uint32_t token, std::vector<RsGxsComment> &msgs)
|
||||
{ return mCommentService->getGxsCommentData(token, msgs); }
|
||||
|
||||
virtual bool getRelatedComments(const uint32_t &token, std::vector<RsGxsComment> &msgs)
|
||||
{
|
||||
return mCommentService->getGxsRelatedComments(token, msgs);
|
||||
}
|
||||
virtual bool getRelatedComments( uint32_t token,
|
||||
std::vector<RsGxsComment> &msgs )
|
||||
{ return mCommentService->getGxsRelatedComments(token, msgs); }
|
||||
|
||||
virtual bool createComment(uint32_t &token, RsGxsComment &msg)
|
||||
{
|
||||
|
@ -104,17 +102,14 @@ virtual bool createVote(uint32_t &token, RsGxsVote &msg)
|
|||
return mCommentService->createGxsVote(token, msg);
|
||||
}
|
||||
|
||||
virtual bool acknowledgeComment(const uint32_t& token, std::pair<RsGxsGroupId, RsGxsMessageId>& msgId)
|
||||
{
|
||||
return acknowledgeMsg(token, msgId);
|
||||
}
|
||||
virtual bool acknowledgeComment(
|
||||
uint32_t token, std::pair<RsGxsGroupId, RsGxsMessageId>& msgId )
|
||||
{ return acknowledgeMsg(token, msgId); }
|
||||
|
||||
virtual bool acknowledgeVote(const uint32_t& token, std::pair<RsGxsGroupId, RsGxsMessageId>& msgId)
|
||||
virtual bool acknowledgeVote(
|
||||
uint32_t token, std::pair<RsGxsGroupId, RsGxsMessageId>& msgId )
|
||||
{
|
||||
if (mCommentService->acknowledgeVote(token, msgId))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (mCommentService->acknowledgeVote(token, msgId)) return true;
|
||||
return acknowledgeMsg(token, msgId);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue