Merge pull request #1361 from sehraf/pr_jsonfy-rsMsg

[jsonapi] add most remaining functions of rsMsg
This commit is contained in:
csoler 2018-10-10 22:04:32 +02:00 committed by GitHub
commit 18eee374f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 272 additions and 76 deletions

View file

@ -165,9 +165,8 @@ class MessageInfo_v2
int count; /* file count */
};
class MessageInfo
struct MessageInfo : RsSerializable
{
public:
MessageInfo(): msgflags(0), size(0), count(0), ts(0) {}
std::string msgId;
@ -199,13 +198,42 @@ public:
int count; /* file count */
int ts;
// RsSerializable interface
void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) {
RS_SERIAL_PROCESS(msgId);
RS_SERIAL_PROCESS(rspeerid_srcId);
RS_SERIAL_PROCESS(rsgxsid_srcId);
RS_SERIAL_PROCESS(msgflags);
RS_SERIAL_PROCESS(rspeerid_msgto);
RS_SERIAL_PROCESS(rspeerid_msgcc);
RS_SERIAL_PROCESS(rspeerid_msgbcc);
RS_SERIAL_PROCESS(rsgxsid_msgto);
RS_SERIAL_PROCESS(rsgxsid_msgcc);
RS_SERIAL_PROCESS(rsgxsid_msgcc);
RS_SERIAL_PROCESS(title);
RS_SERIAL_PROCESS(msg);
RS_SERIAL_PROCESS(attach_title);
RS_SERIAL_PROCESS(attach_comment);
RS_SERIAL_PROCESS(files);
RS_SERIAL_PROCESS(size);
RS_SERIAL_PROCESS(count);
RS_SERIAL_PROCESS(ts);
}
};
class MsgInfoSummary
struct MsgInfoSummary : RsSerializable
{
public:
MsgInfoSummary(): msgflags(0), count(0), ts(0) {}
MsgInfoSummary() : msgflags(0), count(0), ts(0) {}
std::string msgId;
RsPeerId srcId;
@ -216,25 +244,41 @@ class MsgInfoSummary
int count; /* file count */
rstime_t ts;
// RsSerializable interface
void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) {
RS_SERIAL_PROCESS(msgId);
RS_SERIAL_PROCESS(srcId);
RS_SERIAL_PROCESS(msgflags);
RS_SERIAL_PROCESS(title);
RS_SERIAL_PROCESS(count);
RS_SERIAL_PROCESS(ts);
}
};
class MsgTagInfo
struct MsgTagInfo : RsSerializable
{
public:
MsgTagInfo() {}
std::string msgId;
std::list<uint32_t> tagIds;
// RsSerializable interface
void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) {
RS_SERIAL_PROCESS(msgId);
RS_SERIAL_PROCESS(tagIds);
}
};
class MsgTagType
struct MsgTagType : RsSerializable
{
public:
MsgTagType() {}
/* map containing tagId -> pair (text, rgb color) */
std::map<uint32_t, std::pair<std::string, uint32_t> > types;
// RsSerializable interface
void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) {
RS_SERIAL_PROCESS(types);
}
};
} //namespace Rs
@ -444,52 +488,204 @@ public:
RsMsgs() {}
virtual ~RsMsgs() {}
/****************************************/
/* Message Items */
/****************************************/
/****************************************/
/* Message Items */
/****************************************/
virtual bool getMessageSummaries(std::list<Rs::Msgs::MsgInfoSummary> &msgList) = 0;
virtual bool getMessage(const std::string &mId, Rs::Msgs::MessageInfo &msg) = 0;
virtual void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox, unsigned int *pnTrashbox) = 0;
/**
* @brief getMessageSummaries
* @jsonapi{development}
* @param[out] msgList
* @return always true
*/
virtual bool getMessageSummaries(std::list<Rs::Msgs::MsgInfoSummary> &msgList) = 0;
virtual bool MessageSend(Rs::Msgs::MessageInfo &info) = 0;
virtual bool SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag) = 0;
virtual bool MessageToDraft(Rs::Msgs::MessageInfo &info, const std::string &msgParentId) = 0;
virtual bool MessageToTrash(const std::string &mid, bool bTrash) = 0;
virtual bool getMsgParentId(const std::string &msgId, std::string &msgParentId) = 0;
/**
* @brief getMessage
* @jsonapi{development}
* @param[in] msgId message ID to lookup
* @param[out] msg
* @return true on success
*/
virtual bool getMessage(const std::string &msgId, Rs::Msgs::MessageInfo &msg) = 0;
/**
* @brief getMessageCount
* @jsonapi{development}
* @param[out] nInbox
* @param[out] nInboxNew
* @param[out] nOutbox
* @param[out] nDraftbox
* @param[out] nSentbox
* @param[out] nTrashbox
*/
virtual void getMessageCount(uint32_t &nInbox, uint32_t &nInboxNew, uint32_t &nOutbox, uint32_t &nDraftbox, uint32_t &nSentbox, uint32_t &nTrashbox) = 0;
virtual bool MessageDelete(const std::string &mid) = 0;
virtual bool MessageRead(const std::string &mid, bool unreadByUser) = 0;
virtual bool MessageReplied(const std::string &mid, bool replied) = 0;
virtual bool MessageForwarded(const std::string &mid, bool forwarded) = 0;
virtual bool MessageStar(const std::string &mid, bool mark) = 0;
virtual bool MessageLoadEmbeddedImages(const std::string &mid, bool load) = 0;
/**
* @brief MessageSend
* @jsonapi{development}
* @param[in] info
* @return always true
*/
virtual bool MessageSend(Rs::Msgs::MessageInfo &info) = 0;
/* message tagging */
/**
* @brief SystemMessage
* @jsonapi{development}
* @param[in] title
* @param[in] message
* @param[in] systemFlag
* @return true on success
*/
virtual bool SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag) = 0;
virtual bool getMessageTagTypes(Rs::Msgs::MsgTagType& tags) = 0;
/* set == false && tagId == 0 --> remove all */
virtual bool setMessageTagType(uint32_t tagId, std::string& text, uint32_t rgb_color) = 0;
virtual bool removeMessageTagType(uint32_t tagId) = 0;
/**
* @brief MessageToDraft
* @jsonapi{development}
* @param[in] info
* @param[in] msgParentId
* @return true on success
*/
virtual bool MessageToDraft(Rs::Msgs::MessageInfo &info, const std::string &msgParentId) = 0;
virtual bool getMessageTag(const std::string &msgId, Rs::Msgs::MsgTagInfo& info) = 0;
virtual bool setMessageTag(const std::string &msgId, uint32_t tagId, bool set) = 0;
/**
* @brief MessageToTrash
* @jsonapi{development}
* @param[in] msgId
* @param[in] bTrash
* @return true on success
*/
virtual bool MessageToTrash(const std::string &msgId, bool bTrash) = 0;
virtual bool resetMessageStandardTagTypes(Rs::Msgs::MsgTagType& tags) = 0;
/**
* @brief getMsgParentId
* @jsonapi{development}
* @param[in] msgId
* @param[out] msgParentId
* @return true on success
*/
virtual bool getMsgParentId(const std::string &msgId, std::string &msgParentId) = 0;
/****************************************/
/* Private distant messages */
/****************************************/
/**
* @brief MessageDelete
* @jsonapi{development}
* @param[in] msgId
* @return true on success
*/
virtual bool MessageDelete(const std::string &msgId) = 0;
/**
* @brief MessageRead
* @jsonapi{development}
* @param[in] msgId
* @param[in] unreadByUser
* @return true on success
*/
virtual bool MessageRead(const std::string &msgId, bool unreadByUser) = 0;
/**
* @brief MessageReplied
* @jsonapi{development}
* @param[in] msgId
* @param[in] replied
* @return true on success
*/
virtual bool MessageReplied(const std::string &msgId, bool replied) = 0;
/**
* @brief MessageForwarded
* @jsonapi{development}
* @param[in] msgId
* @param[in] forwarded
* @return true on success
*/
virtual bool MessageForwarded(const std::string &msgId, bool forwarded) = 0;
/**
* @brief MessageStar
* @jsonapi{development}
* @param[in] msgId
* @param[in] mark
* @return true on success
*/
virtual bool MessageStar(const std::string &msgId, bool mark) = 0;
/**
* @brief MessageLoadEmbeddedImages
* @jsonapi{development}
* @param[in] msgId
* @param[in] load
* @return true on success
*/
virtual bool MessageLoadEmbeddedImages(const std::string &msgId, bool load) = 0;
/* message tagging */
/**
* @brief getMessageTagTypes
* @jsonapi{development}
* @param[out] tags
* @return always true
*/
virtual bool getMessageTagTypes(Rs::Msgs::MsgTagType& tags) = 0;
/**
* @brief setMessageTagType
* @jsonapi{development}
* @param[in] tagId
* @param[in] text
* @param[in] rgb_color
* @return true on success
*/
virtual bool setMessageTagType(uint32_t tagId, std::string& text, uint32_t rgb_color) = 0;
/**
* @brief removeMessageTagType
* @jsonapi{development}
* @param[in] tagId
* @return true on success
*/
virtual bool removeMessageTagType(uint32_t tagId) = 0;
/**
* @brief getMessageTag
* @jsonapi{development}
* @param[in] msgId
* @param[out] info
* @return true on success
*/
virtual bool getMessageTag(const std::string &msgId, Rs::Msgs::MsgTagInfo& info) = 0;
/**
* @brief setMessageTag
* set == false && tagId == 0 --> remove all
* @jsonapi{development}
* @param[in] msgId
* @param[in] tagId
* @param[in] set
* @return true on success
*/
virtual bool setMessageTag(const std::string &msgId, uint32_t tagId, bool set) = 0;
/**
* @brief resetMessageStandardTagTypes
* @jsonapi{development}
* @param[out] tags
* @return always true
*/
virtual bool resetMessageStandardTagTypes(Rs::Msgs::MsgTagType& tags) = 0;
/****************************************/
/* Private distant messages */
/****************************************/
virtual uint32_t getDistantMessagingPermissionFlags()=0 ;
virtual void setDistantMessagingPermissionFlags(uint32_t flags)=0 ;
/****************************************/
/* Chat */
/****************************************/
// sendChat for broadcast, private, lobby and private distant chat
// note: for lobby chat, you first have to subscribe to a lobby
// for private distant chat, it is reqired to have an active distant chat session
/****************************************/
/* Chat */
/****************************************/
// sendChat for broadcast, private, lobby and private distant chat
// note: for lobby chat, you first have to subscribe to a lobby
// for private distant chat, it is reqired to have an active distant chat session
/**
* @brief sendChat send a chat message to a given id