diff --git a/src/retroshare/rsmsgs.h b/src/retroshare/rsmsgs.h index 2abdea083..8f7559c82 100644 --- a/src/retroshare/rsmsgs.h +++ b/src/retroshare/rsmsgs.h @@ -38,34 +38,41 @@ #define RS_MSG_BOXMASK 0x000f /* Mask for determining Box */ -#define RS_MSG_OUTGOING 0x0001 /* !Inbox */ -#define RS_MSG_PENDING 0x0002 /* OutBox */ -#define RS_MSG_DRAFT 0x0004 /* Draft */ +enum class RsMsgFlags: uint32_t +{ + RS_MSG_INCOMING = 0x00000000, /* !Inbox */ + RS_MSG_OUTGOING = 0x00000001, /* !Inbox */ + RS_MSG_PENDING = 0x00000002, /* OutBox */ + RS_MSG_DRAFT = 0x00000004, /* Draft */ + + RS_MSG_NEW = 0x00000010, /* New */ + RS_MSG_TRASH = 0x00000020, /* Trash */ + RS_MSG_UNREAD_BY_USER = 0x00000040, /* Unread by user */ + RS_MSG_REPLIED = 0x00000080, /* Message is replied */ + RS_MSG_FORWARDED = 0x00000100, /* Message is forwarded */ + RS_MSG_STAR = 0x00000200, /* Message is marked with a star */ + + // system message + RS_MSG_USER_REQUEST = 0x00000400, /* user request */ + RS_MSG_FRIEND_RECOMMENDATION = 0x00000800, /* friend recommendation */ + RS_MSG_DISTANT = 0x00001000,/* message is distant */ + RS_MSG_SIGNATURE_CHECKS = 0x00002000,/* message was signed, and signature checked */ + RS_MSG_SIGNED = 0x00004000,/* message was signed and signature didn't check */ + RS_MSG_LOAD_EMBEDDED_IMAGES = 0x00008000, /* load embedded images */ + RS_MSG_PUBLISH_KEY = 0x00020000, /* publish key */ + RS_MSG_SPAM = 0x00040000, /* Message is marked as spam */ +}; + +RS_REGISTER_ENUM_FLAGS_TYPE(RsMsgFlags); /* ORs of above */ -#define RS_MSG_INBOX 0x00 /* Inbox */ -#define RS_MSG_SENTBOX 0x01 /* Sentbox = OUTGOING */ -#define RS_MSG_OUTBOX 0x03 /* Outbox = OUTGOING + PENDING */ -#define RS_MSG_DRAFTBOX 0x05 /* Draftbox = OUTGOING + DRAFT */ -#define RS_MSG_TRASHBOX 0x20 /* Trashbox = RS_MSG_TRASH */ - -#define RS_MSG_NEW 0x000010 /* New */ -#define RS_MSG_TRASH 0x000020 /* Trash */ -#define RS_MSG_UNREAD_BY_USER 0x000040 /* Unread by user */ -#define RS_MSG_REPLIED 0x000080 /* Message is replied */ -#define RS_MSG_FORWARDED 0x000100 /* Message is forwarded */ -#define RS_MSG_STAR 0x000200 /* Message is marked with a star */ -// system message -#define RS_MSG_USER_REQUEST 0x000400 /* user request */ -#define RS_MSG_FRIEND_RECOMMENDATION 0x000800 /* friend recommendation */ -#define RS_MSG_DISTANT 0x001000 /* message is distant */ -#define RS_MSG_SIGNATURE_CHECKS 0x002000 /* message was signed, and signature checked */ -#define RS_MSG_SIGNED 0x004000 /* message was signed and signature didn't check */ -#define RS_MSG_LOAD_EMBEDDED_IMAGES 0x008000 /* load embedded images */ -#define RS_MSG_PUBLISH_KEY 0x020000 /* publish key */ -#define RS_MSG_SPAM 0x040000 /* Message is marked as spam */ - -#define RS_MSG_SYSTEM (RS_MSG_USER_REQUEST | RS_MSG_FRIEND_RECOMMENDATION | RS_MSG_PUBLISH_KEY) +static const RsMsgFlags RS_MSG_INBOX (RsMsgFlags::RS_MSG_INCOMING); /* Inbox */ +static const RsMsgFlags RS_MSG_SENTBOX (RsMsgFlags::RS_MSG_OUTGOING); /* Sentbox = OUTGOING */ +static const RsMsgFlags RS_MSG_OUTBOX (RsMsgFlags::RS_MSG_OUTGOING | RsMsgFlags::RS_MSG_PENDING); /* Outbox = OUTGOING + PENDING */ +static const RsMsgFlags RS_MSG_DRAFTBOX (RsMsgFlags::RS_MSG_OUTGOING | RsMsgFlags::RS_MSG_DRAFT); /* Draftbox = OUTGOING + DRAFT */ +static const RsMsgFlags RS_MSG_TRASHBOX (RsMsgFlags::RS_MSG_TRASH); /* Trashbox = RS_MSG_TRASH */ + +static const RsMsgFlags RS_MSG_SYSTEM (RsMsgFlags::RS_MSG_USER_REQUEST | RsMsgFlags::RS_MSG_FRIEND_RECOMMENDATION | RsMsgFlags::RS_MSG_PUBLISH_KEY); #define RS_CHAT_LOBBY_EVENT_PEER_LEFT 0x01 #define RS_CHAT_LOBBY_EVENT_PEER_STATUS 0x02 @@ -194,14 +201,14 @@ class MsgAddress: public RsSerializable struct MessageInfo : RsSerializable { - MessageInfo(): msgflags(0), size(0), count(0), ts(0) {} + MessageInfo(): msgflags(RsMsgFlags(0)), size(0), count(0), ts(0) {} std::string msgId; MsgAddress from; MsgAddress to; - unsigned int msgflags; + RsMsgFlags msgflags; std::set destinations; @@ -247,13 +254,13 @@ typedef std::set MsgTagInfo ; struct MsgInfoSummary : RsSerializable { - MsgInfoSummary() : msgflags(0), count(0), ts(0) {} + MsgInfoSummary() : msgflags(RsMsgFlags(0)), count(0), ts(0) {} RsMailMessageId msgId; MsgAddress from; MsgAddress to; // specific address the message has been sent to (may be used for e.g. reply) - uint32_t msgflags; + RsMsgFlags msgflags; MsgTagInfo msgtags; std::string title; @@ -677,7 +684,7 @@ class RsMsgs * @param[in] systemFlag * @return true on success */ - virtual bool SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag) = 0; + virtual bool SystemMessage(const std::string &title, const std::string &message, RsMsgFlags systemFlag) = 0; /** * @brief MessageToDraft diff --git a/src/rsitems/rsmsgitems.cc b/src/rsitems/rsmsgitems.cc index 7542d358e..29631ec35 100644 --- a/src/rsitems/rsmsgitems.cc +++ b/src/rsitems/rsmsgitems.cc @@ -59,7 +59,7 @@ RsItem *RsMsgSerialiser::create_item(uint16_t service,uint8_t type) const void RsMsgItem::clear() { msgId = 0; - msgFlags = 0; + msgFlags = RsMsgItemFlags(0); sendTime = 0; recvTime = 0; subject.clear(); @@ -132,7 +132,7 @@ void RsMsgParentId::serial_process(RsGenericSerializer::SerializeJob j,RsGeneric void RsMsgItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) { - RsTypeSerializer::serial_process(j,ctx,msgFlags,"msgFlags"); + RsTypeSerializer::serial_process(j,ctx,msgFlags,"msgFlags"); RsTypeSerializer::serial_process(j,ctx,sendTime,"sendTime"); RsTypeSerializer::serial_process(j,ctx,recvTime,"recvTime"); diff --git a/src/rsitems/rsmsgitems.h b/src/rsitems/rsmsgitems.h index 5e4078336..b3b9b2d01 100644 --- a/src/rsitems/rsmsgitems.h +++ b/src/rsitems/rsmsgitems.h @@ -49,30 +49,37 @@ const uint8_t RS_PKT_SUBTYPE_MSG_OUTGOING_MAP_STORAGE = 0x0b; /**************************************************************************/ -const uint32_t RS_MSG_FLAGS_OUTGOING = 0x00000001; -const uint32_t RS_MSG_FLAGS_PENDING = 0x00000002; -const uint32_t RS_MSG_FLAGS_DRAFT = 0x00000004; -const uint32_t RS_MSG_FLAGS_NEW = 0x00000010; -const uint32_t RS_MSG_FLAGS_TRASH = 0x00000020; -const uint32_t RS_MSG_FLAGS_UNREAD_BY_USER = 0x00000040; -const uint32_t RS_MSG_FLAGS_REPLIED = 0x00000080; -const uint32_t RS_MSG_FLAGS_FORWARDED = 0x00000100; -const uint32_t RS_MSG_FLAGS_STAR = 0x00000200; -const uint32_t RS_MSG_FLAGS_PARTIAL = 0x00000400; -const uint32_t RS_MSG_FLAGS_USER_REQUEST = 0x00000800; -const uint32_t RS_MSG_FLAGS_FRIEND_RECOMMENDATION = 0x00001000; -const uint32_t RS_MSG_FLAGS_RETURN_RECEPT = 0x00002000; -const uint32_t RS_MSG_FLAGS_ENCRYPTED = 0x00004000; -const uint32_t RS_MSG_FLAGS_DISTANT = 0x00008000; -const uint32_t RS_MSG_FLAGS_SIGNATURE_CHECKS = 0x00010000; -const uint32_t RS_MSG_FLAGS_SIGNED = 0x00020000; -const uint32_t RS_MSG_FLAGS_LOAD_EMBEDDED_IMAGES = 0x00040000; -const uint32_t RS_MSG_FLAGS_DECRYPTED = 0x00080000; -const uint32_t RS_MSG_FLAGS_ROUTED = 0x00100000; -const uint32_t RS_MSG_FLAGS_PUBLISH_KEY = 0x00200000; -const uint32_t RS_MSG_FLAGS_SPAM = 0x00400000; - -const uint32_t RS_MSG_FLAGS_SYSTEM = RS_MSG_FLAGS_USER_REQUEST | RS_MSG_FLAGS_FRIEND_RECOMMENDATION | RS_MSG_FLAGS_PUBLISH_KEY; +enum class RsMsgItemFlags: uint32_t +{ + RS_MSG_FLAGS_OUTGOING = 0x00000001, + RS_MSG_FLAGS_PENDING = 0x00000002, + RS_MSG_FLAGS_DRAFT = 0x00000004, + RS_MSG_FLAGS_NEW = 0x00000010, + RS_MSG_FLAGS_TRASH = 0x00000020, + RS_MSG_FLAGS_UNREAD_BY_USER = 0x00000040, + RS_MSG_FLAGS_REPLIED = 0x00000080, + RS_MSG_FLAGS_FORWARDED = 0x00000100, + RS_MSG_FLAGS_STAR = 0x00000200, + RS_MSG_FLAGS_PARTIAL = 0x00000400, + RS_MSG_FLAGS_USER_REQUEST = 0x00000800, + RS_MSG_FLAGS_FRIEND_RECOMMENDATION = 0x00001000, + RS_MSG_FLAGS_RETURN_RECEPT = 0x00002000, + RS_MSG_FLAGS_ENCRYPTED = 0x00004000, + RS_MSG_FLAGS_DISTANT = 0x00008000, + RS_MSG_FLAGS_SIGNATURE_CHECKS = 0x00010000, + RS_MSG_FLAGS_SIGNED = 0x00020000, + RS_MSG_FLAGS_LOAD_EMBEDDED_IMAGES = 0x00040000, + RS_MSG_FLAGS_DECRYPTED = 0x00080000, + RS_MSG_FLAGS_ROUTED = 0x00100000, + RS_MSG_FLAGS_PUBLISH_KEY = 0x00200000, + RS_MSG_FLAGS_SPAM = 0x00400000, +}; + +RS_REGISTER_ENUM_FLAGS_TYPE(RsMsgItemFlags); + +const RsMsgItemFlags RS_MSG_FLAGS_SYSTEM = RsMsgItemFlags::RS_MSG_FLAGS_USER_REQUEST + | RsMsgItemFlags::RS_MSG_FLAGS_FRIEND_RECOMMENDATION + | RsMsgItemFlags::RS_MSG_FLAGS_PUBLISH_KEY; typedef uint32_t MessageIdentifier; @@ -101,7 +108,7 @@ class RsMsgItem: public RsMessageItem // ----------- Specific fields ------------- // - uint32_t msgFlags; + RsMsgItemFlags msgFlags; MessageIdentifier msgId; uint32_t sendTime; @@ -187,7 +194,7 @@ struct RsOutgoingMessageInfo: public RsSerializable Rs::Msgs::MsgAddress origin; Rs::Msgs::MsgAddress destination; - uint32_t flags; + RsMsgItemFlags flags; GRouterMsgPropagationId grouter_id; }; diff --git a/src/rsserver/p3msgs.cc b/src/rsserver/p3msgs.cc index a6ae38f9d..2afb911a9 100644 --- a/src/rsserver/p3msgs.cc +++ b/src/rsserver/p3msgs.cc @@ -317,7 +317,7 @@ uint32_t p3Msgs::sendMail( trackingIds, errorMsg ); } -bool p3Msgs::SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag) +bool p3Msgs::SystemMessage(const std::string &title, const std::string &message, RsMsgFlags systemFlag) { return mMsgSrv->SystemMessage(title, message, systemFlag); } @@ -357,17 +357,17 @@ bool p3Msgs::MessageRead(const std::string &mid, bool unreadByUser) bool p3Msgs::MessageReplied(const std::string &mid, bool replied) { - return mMsgSrv->setMsgFlag(mid, replied ? RS_MSG_FLAGS_REPLIED : 0, RS_MSG_FLAGS_REPLIED); + return mMsgSrv->setMsgFlag(mid, replied ? RsMsgItemFlags::RS_MSG_FLAGS_REPLIED : RsMsgItemFlags(0), RsMsgItemFlags::RS_MSG_FLAGS_REPLIED); } bool p3Msgs::MessageForwarded(const std::string &mid, bool forwarded) { - return mMsgSrv->setMsgFlag(mid, forwarded ? RS_MSG_FLAGS_FORWARDED : 0, RS_MSG_FLAGS_FORWARDED); + return mMsgSrv->setMsgFlag(mid, forwarded ? RsMsgItemFlags::RS_MSG_FLAGS_FORWARDED : RsMsgItemFlags(0), RsMsgItemFlags::RS_MSG_FLAGS_FORWARDED); } bool p3Msgs::MessageLoadEmbeddedImages(const std::string &mid, bool load) { - return mMsgSrv->setMsgFlag(mid, load ? RS_MSG_FLAGS_LOAD_EMBEDDED_IMAGES : 0, RS_MSG_FLAGS_LOAD_EMBEDDED_IMAGES); + return mMsgSrv->setMsgFlag(mid, load ? RsMsgItemFlags::RS_MSG_FLAGS_LOAD_EMBEDDED_IMAGES : RsMsgItemFlags(0), RsMsgItemFlags::RS_MSG_FLAGS_LOAD_EMBEDDED_IMAGES); } bool p3Msgs::getMessageTagTypes(MsgTagType& tags) diff --git a/src/rsserver/p3msgs.h b/src/rsserver/p3msgs.h index 683be360c..32aa616e2 100644 --- a/src/rsserver/p3msgs.h +++ b/src/rsserver/p3msgs.h @@ -70,7 +70,7 @@ class p3Msgs: public RsMsgs RS_DEPRECATED_FOR(sendMail) virtual bool MessageSend(Rs::Msgs::MessageInfo &info)override ; - virtual bool SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag)override ; + virtual bool SystemMessage(const std::string &title, const std::string &message, RsMsgFlags systemFlag)override ; virtual bool MessageToDraft(Rs::Msgs::MessageInfo &info, const std::string &msgParentId)override ; virtual bool MessageToTrash(const std::string &mid, bool bTrash)override ; virtual bool MessageDelete(const std::string &mid)override ; diff --git a/src/services/p3msgservice.cc b/src/services/p3msgservice.cc index cea670536..429cc1160 100644 --- a/src/services/p3msgservice.cc +++ b/src/services/p3msgservice.cc @@ -1257,7 +1257,7 @@ bool p3MsgService::markMsgIdRead(const std::string &mid, bool unreadByUser) return true; } -bool p3MsgService::setMsgFlag(const std::string &mid, uint32_t flag, uint32_t mask) +bool p3MsgService::setMsgFlag(const std::string &mid, RsMsgItemFlags flag, RsMsgItemFlags mask) { uint32_t msgId = atoi(mid.c_str()); @@ -1273,7 +1273,7 @@ bool p3MsgService::setMsgFlag(const std::string &mid, uint32_t flag, uint32_t } auto msg = &sit->second->msg; - uint32_t oldFlag = msg->msgFlags; + auto oldFlag = msg->msgFlags; msg->msgFlags &= ~mask; msg->msgFlags |= flag; @@ -1348,7 +1348,7 @@ bool p3MsgService::setMsgParentId(uint32_t msgId, uint32_t msgParentId) /****************************************/ /* Message Items */ // no from field because it's implicitly our own PeerId -MessageIdentifier p3MsgService::internal_sendMessage(MessageIdentifier id,const MsgAddress& from,const MsgAddress& to,uint32_t flags) +MessageIdentifier p3MsgService::internal_sendMessage(MessageIdentifier id,const MsgAddress& from,const MsgAddress& to,RsMsgFlags flags) { auto msgId = getNewUniqueMsgId(); /* grabs Mtx as well */ { @@ -1361,19 +1361,19 @@ MessageIdentifier p3MsgService::internal_sendMessage(MessageIdentifier id,const // then add the new msg id with the correct from/to - info.flags = flags; + info.flags = uint32_t(flags); info.destination = to; - info.flags |= RS_MSG_OUTGOING ; + info.flags |= RS_MSG_FLAGS_OUTGOING ; if(to.type() == MsgAddress::MSG_ADDRESS_TYPE_RSGXSID) { - info.flags |= RS_MSG_DISTANT; + info.flags |= RS_MSG_FLAGS_DISTANT; info.origin = from; } else { - info.flags |= RS_MSG_LOAD_EMBEDDED_IMAGES; /* load embedded images only for node-to-node messages?? */ // (cyril: ?!?!) + info.flags |= RS_MSG_FLAGS_LOAD_EMBEDDED_IMAGES; /* load embedded images only for node-to-node messages?? */ // (cyril: ?!?!) info.origin = Rs::Msgs::MsgAddress(mServiceCtrl->getOwnId(),Rs::Msgs::MsgAddress::MSG_ADDRESS_MODE_TO); } } @@ -1454,7 +1454,7 @@ bool p3MsgService::MessageSend(MessageInfo &info) // Update info for caller (is that necessary?) info.msgId = std::to_string(msg->msgId); - info.msgflags = msg->msgFlags; + // info.msgflags = msg->msgFlags; // commented out to avoid type conversion. The flags should be identical anyway. // Then stores outgoing message references for each destination in the msgOutgoing list @@ -1566,9 +1566,9 @@ uint32_t p3MsgService::sendMail( return ret; } -bool p3MsgService::SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag) +bool p3MsgService::SystemMessage(const std::string &title, const std::string &message, RsMsgFlags systemFlag) { - if ((systemFlag & RS_MSG_SYSTEM) == 0) { + if (!(systemFlag & RS_MSG_SYSTEM)) { /* no flag specified */ return false; } @@ -1580,13 +1580,13 @@ bool p3MsgService::SystemMessage(const std::string &title, const std::string &me msg->msgFlags = 0; - if (systemFlag & RS_MSG_USER_REQUEST) { + if (!!(systemFlag & RsMsgFlags::RS_MSG_USER_REQUEST)) { msg->msgFlags |= RS_MSG_FLAGS_USER_REQUEST; } - if (systemFlag & RS_MSG_FRIEND_RECOMMENDATION) { + if (!!(systemFlag & RsMsgFlags::RS_MSG_FRIEND_RECOMMENDATION)) { msg->msgFlags |= RS_MSG_FLAGS_FRIEND_RECOMMENDATION; } - if (systemFlag & RS_MSG_PUBLISH_KEY) { + if (!!(systemFlag & RsMsgFlags::RS_MSG_PUBLISH_KEY)) { msg->msgFlags |= RS_MSG_FLAGS_PUBLISH_KEY; } @@ -1987,24 +1987,24 @@ void p3MsgService::initRsMI(const RsMailStorageItem& msi, const MsgAddress& from /* translate flags, if we sent it... outgoing */ - if (flags & RS_MSG_FLAGS_OUTGOING) mi.msgflags |= RS_MSG_OUTGOING; - if (flags & RS_MSG_FLAGS_PENDING) mi.msgflags |= RS_MSG_PENDING; /* if it has a pending flag, then its in the outbox */ - if (flags & RS_MSG_FLAGS_DRAFT) mi.msgflags |= RS_MSG_DRAFT; - if (flags & RS_MSG_FLAGS_NEW) mi.msgflags |= RS_MSG_NEW; - - if (flags & RS_MSG_FLAGS_SIGNED) mi.msgflags |= RS_MSG_SIGNED ; - if (flags & RS_MSG_FLAGS_SIGNATURE_CHECKS) mi.msgflags |= RS_MSG_SIGNATURE_CHECKS ; - if (flags & RS_MSG_FLAGS_DISTANT) mi.msgflags |= RS_MSG_DISTANT ; - if (flags & RS_MSG_FLAGS_TRASH) mi.msgflags |= RS_MSG_TRASH; - if (flags & RS_MSG_FLAGS_UNREAD_BY_USER) mi.msgflags |= RS_MSG_UNREAD_BY_USER; - if (flags & RS_MSG_FLAGS_REPLIED) mi.msgflags |= RS_MSG_REPLIED; - if (flags & RS_MSG_FLAGS_FORWARDED) mi.msgflags |= RS_MSG_FORWARDED; - if (flags & RS_MSG_FLAGS_STAR) mi.msgflags |= RS_MSG_STAR; - if (flags & RS_MSG_FLAGS_SPAM) mi.msgflags |= RS_MSG_SPAM; - if (flags & RS_MSG_FLAGS_USER_REQUEST) mi.msgflags |= RS_MSG_USER_REQUEST; - if (flags & RS_MSG_FLAGS_FRIEND_RECOMMENDATION) mi.msgflags |= RS_MSG_FRIEND_RECOMMENDATION; - if (flags & RS_MSG_FLAGS_PUBLISH_KEY) mi.msgflags |= RS_MSG_PUBLISH_KEY; - if (flags & RS_MSG_FLAGS_LOAD_EMBEDDED_IMAGES) mi.msgflags |= RS_MSG_LOAD_EMBEDDED_IMAGES; + if (flags & RS_MSG_FLAGS_OUTGOING) mi.msgflags |= RsMsgFlags::RS_MSG_OUTGOING; + if (flags & RS_MSG_FLAGS_PENDING) mi.msgflags |= RsMsgFlags::RS_MSG_PENDING; /* if it has a pending flag, then its in the outbox */ + if (flags & RS_MSG_FLAGS_DRAFT) mi.msgflags |= RsMsgFlags::RS_MSG_DRAFT; + if (flags & RS_MSG_FLAGS_NEW) mi.msgflags |= RsMsgFlags::RS_MSG_NEW; + + if (flags & RS_MSG_FLAGS_SIGNED) mi.msgflags |= RsMsgFlags::RS_MSG_SIGNED ; + if (flags & RS_MSG_FLAGS_SIGNATURE_CHECKS) mi.msgflags |= RsMsgFlags::RS_MSG_SIGNATURE_CHECKS ; + if (flags & RS_MSG_FLAGS_DISTANT) mi.msgflags |= RsMsgFlags::RS_MSG_DISTANT ; + if (flags & RS_MSG_FLAGS_TRASH) mi.msgflags |= RsMsgFlags::RS_MSG_TRASH; + if (flags & RS_MSG_FLAGS_UNREAD_BY_USER) mi.msgflags |= RsMsgFlags::RS_MSG_UNREAD_BY_USER; + if (flags & RS_MSG_FLAGS_REPLIED) mi.msgflags |= RsMsgFlags::RS_MSG_REPLIED; + if (flags & RS_MSG_FLAGS_FORWARDED) mi.msgflags |= RsMsgFlags::RS_MSG_FORWARDED; + if (flags & RS_MSG_FLAGS_STAR) mi.msgflags |= RsMsgFlags::RS_MSG_STAR; + if (flags & RS_MSG_FLAGS_SPAM) mi.msgflags |= RsMsgFlags::RS_MSG_SPAM; + if (flags & RS_MSG_FLAGS_USER_REQUEST) mi.msgflags |= RsMsgFlags::RS_MSG_USER_REQUEST; + if (flags & RS_MSG_FLAGS_FRIEND_RECOMMENDATION) mi.msgflags |= RsMsgFlags::RS_MSG_FRIEND_RECOMMENDATION; + if (flags & RS_MSG_FLAGS_PUBLISH_KEY) mi.msgflags |= RsMsgFlags::RS_MSG_PUBLISH_KEY; + if (flags & RS_MSG_FLAGS_LOAD_EMBEDDED_IMAGES) mi.msgflags |= RsMsgFlags::RS_MSG_LOAD_EMBEDDED_IMAGES; mi.ts = msg->sendTime; @@ -2045,7 +2045,7 @@ void p3MsgService::initRsMI(const RsMailStorageItem& msi, const MsgAddress& from void p3MsgService::initRsMIS(const RsMailStorageItem& msi, const MsgAddress& from, const MsgAddress& to, MessageIdentifier mid,MsgInfoSummary& mis) { mis.msgId = std::to_string(mid); - mis.msgflags = 0; + mis.msgflags = RsMsgFlags(0); const RsMsgItem *msg = &msi.msg; // trick to keep the old code @@ -2059,72 +2059,72 @@ void p3MsgService::initRsMIS(const RsMailStorageItem& msi, const MsgAddress& fro mis.from = msi.from; if(msg->msgFlags & RS_MSG_FLAGS_DISTANT) - mis.msgflags |= RS_MSG_DISTANT ; + mis.msgflags |= RsMsgFlags::RS_MSG_DISTANT ; if (msg->msgFlags & RS_MSG_FLAGS_SIGNED) - mis.msgflags |= RS_MSG_SIGNED ; + mis.msgflags |= RsMsgFlags::RS_MSG_SIGNED ; if (msg->msgFlags & RS_MSG_FLAGS_SIGNATURE_CHECKS) - mis.msgflags |= RS_MSG_SIGNATURE_CHECKS ; + mis.msgflags |= RsMsgFlags::RS_MSG_SIGNATURE_CHECKS ; /* translate flags, if we sent it... outgoing */ if ((msg->msgFlags & RS_MSG_FLAGS_OUTGOING) /*|| (msg->PeerId() == mServiceCtrl->getOwnId())*/) { - mis.msgflags |= RS_MSG_OUTGOING; + mis.msgflags |= RsMsgFlags::RS_MSG_OUTGOING; } /* if it has a pending flag, then its in the outbox */ if (msg->msgFlags & RS_MSG_FLAGS_PENDING) { - mis.msgflags |= RS_MSG_PENDING; + mis.msgflags |= RsMsgFlags::RS_MSG_PENDING; } if (msg->msgFlags & RS_MSG_FLAGS_DRAFT) { - mis.msgflags |= RS_MSG_DRAFT; + mis.msgflags |= RsMsgFlags::RS_MSG_DRAFT; } if (msg->msgFlags & RS_MSG_FLAGS_NEW) { - mis.msgflags |= RS_MSG_NEW; + mis.msgflags |= RsMsgFlags::RS_MSG_NEW; } if (msg->msgFlags & RS_MSG_FLAGS_TRASH) { - mis.msgflags |= RS_MSG_TRASH; + mis.msgflags |= RsMsgFlags::RS_MSG_TRASH; } if (msg->msgFlags & RS_MSG_FLAGS_UNREAD_BY_USER) { - mis.msgflags |= RS_MSG_UNREAD_BY_USER; + mis.msgflags |= RsMsgFlags::RS_MSG_UNREAD_BY_USER; } if (msg->msgFlags & RS_MSG_FLAGS_REPLIED) { - mis.msgflags |= RS_MSG_REPLIED; + mis.msgflags |= RsMsgFlags::RS_MSG_REPLIED; } if (msg->msgFlags & RS_MSG_FLAGS_FORWARDED) { - mis.msgflags |= RS_MSG_FORWARDED; + mis.msgflags |= RsMsgFlags::RS_MSG_FORWARDED; } if (msg->msgFlags & RS_MSG_FLAGS_STAR) { - mis.msgflags |= RS_MSG_STAR; + mis.msgflags |= RsMsgFlags::RS_MSG_STAR; } if (msg->msgFlags & RS_MSG_FLAGS_SPAM) { - mis.msgflags |= RS_MSG_SPAM; + mis.msgflags |= RsMsgFlags::RS_MSG_SPAM; } if (msg->msgFlags & RS_MSG_FLAGS_USER_REQUEST) { - mis.msgflags |= RS_MSG_USER_REQUEST; + mis.msgflags |= RsMsgFlags::RS_MSG_USER_REQUEST; } if (msg->msgFlags & RS_MSG_FLAGS_FRIEND_RECOMMENDATION) { - mis.msgflags |= RS_MSG_FRIEND_RECOMMENDATION; + mis.msgflags |= RsMsgFlags::RS_MSG_FRIEND_RECOMMENDATION; } if (msg->msgFlags & RS_MSG_FLAGS_PUBLISH_KEY) { - mis.msgflags |= RS_MSG_PUBLISH_KEY; + mis.msgflags |= RsMsgFlags::RS_MSG_PUBLISH_KEY; } if (msg->msgFlags & RS_MSG_FLAGS_LOAD_EMBEDDED_IMAGES) { - mis.msgflags |= RS_MSG_LOAD_EMBEDDED_IMAGES; + mis.msgflags |= RsMsgFlags::RS_MSG_LOAD_EMBEDDED_IMAGES; } mis.title = msg->subject; @@ -2196,13 +2196,13 @@ bool p3MsgService::initMIRsMsg(RsMailStorageItem *msi,const MessageInfo& info) msg -> attachment.items.push_back(mfi); } /* translate flags from outside */ - if (info.msgflags & RS_MSG_USER_REQUEST) + if (!!(info.msgflags & RsMsgFlags::RS_MSG_USER_REQUEST)) msg->msgFlags |= RS_MSG_FLAGS_USER_REQUEST; - if (info.msgflags & RS_MSG_FRIEND_RECOMMENDATION) + if (!!(info.msgflags & RsMsgFlags::RS_MSG_FRIEND_RECOMMENDATION)) msg->msgFlags |= RS_MSG_FLAGS_FRIEND_RECOMMENDATION; - if (info.msgflags & RS_MSG_SIGNED) + if (!!(info.msgflags & RsMsgFlags::RS_MSG_SIGNED)) msg->msgFlags |= RS_MSG_FLAGS_SIGNED; return true; @@ -2304,7 +2304,7 @@ void p3MsgService::notifyDataStatus( const GRouterMsgPropagationId& id, if(mit != it->second.end()) { std::cerr << " reseting the ROUTED flag so that the message is requested again" << std::endl; - mit->second.flags &= ~RS_MSG_FLAGS_ROUTED; + mit->second.flags &= ~RsMsgFlags::RS_MSG_FLAGS_ROUTED; break; } else diff --git a/src/services/p3msgservice.h b/src/services/p3msgservice.h index 0e3a7ff33..8f12fefc4 100644 --- a/src/services/p3msgservice.h +++ b/src/services/p3msgservice.h @@ -82,14 +82,14 @@ class p3MsgService : bool deleteMessage(const std::string &mid); bool markMsgIdRead(const std::string &mid, bool bUnreadByUser); - bool setMsgFlag(const std::string &mid, uint32_t flag, uint32_t mask); + bool setMsgFlag(const std::string &mid, RsMsgItemFlags flag, RsMsgItemFlags mask); bool getMsgParentId(const std::string &msgId, std::string &msgParentId); // msgParentId == 0 --> remove bool setMsgParentId(uint32_t msgId, uint32_t msgParentId); RS_DEPRECATED_FOR(sendMail) bool MessageSend(Rs::Msgs::MessageInfo &info); - bool SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag); + bool SystemMessage(const std::string &title, const std::string &message, RsMsgFlags systemFlag); bool MessageToDraft(Rs::Msgs::MessageInfo &info, const std::string &msgParentId); bool MessageToTrash(const std::string &mid, bool bTrash); @@ -183,7 +183,7 @@ class p3MsgService : void handleIncomingItem(RsMsgItem *, const Rs::Msgs::MsgAddress &from, const Rs::Msgs::MsgAddress &to) ; uint32_t getNewUniqueMsgId(); - MessageIdentifier internal_sendMessage(MessageIdentifier id, const Rs::Msgs::MsgAddress &from, const Rs::Msgs::MsgAddress &to, uint32_t flags); + MessageIdentifier internal_sendMessage(MessageIdentifier id, const Rs::Msgs::MsgAddress &from, const Rs::Msgs::MsgAddress &to, RsMsgFlags flags); uint32_t sendDistantMessage(RsMsgItem *item,const RsGxsId& signing_gxs_id); void checkSizeAndSendMessage(RsMsgItem *msg, const RsPeerId &destination); void cleanListOfReceivedMessageHashes();