mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 06:06:10 -04:00
- Change methods of RsMsgs from "std::string" to "const std::string&"
- Fixed sent messages doesn't get the flag RS_MSG_FLAGS_NEW - Rework reply and forward message, now the replied or forwarded message gets the state and not the answer itself - Added RsMsgParentId (with test) to save the parent of the message in draft - Change methods of MessageComposer from "std::string" to "QString" - Show image in the message row in MessagesDialog again - Fixed umlauts in recommended files in MessageComposer - Renamed tab "Live Chat" in "Group Chat" - Fixed german translation recompile of the GUI needed git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3741 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
935903287d
commit
3c65283f8f
22 changed files with 820 additions and 382 deletions
|
@ -50,6 +50,8 @@
|
|||
#define RS_MSG_NEW 0x0010 /* New */
|
||||
#define RS_MSG_TRASH 0x0020 /* Trash */
|
||||
#define RS_MSG_UNREAD_BY_USER 0x0040 /* Unread by user */
|
||||
#define RS_MSG_REPLIED 0x0080 /* Message is replied */
|
||||
#define RS_MSG_FORWARDED 0x0100 /* Message is forwarded */
|
||||
|
||||
#define RS_MSGTAGTYPE_IMPORTANT 1
|
||||
#define RS_MSGTAGTYPE_WORK 2
|
||||
|
@ -152,15 +154,18 @@ virtual ~RsMsgs() { return; }
|
|||
/* Message Items */
|
||||
|
||||
virtual bool getMessageSummaries(std::list<MsgInfoSummary> &msgList) = 0;
|
||||
virtual bool getMessage(std::string mId, MessageInfo &msg) = 0;
|
||||
virtual bool getMessage(const std::string &mId, 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;
|
||||
|
||||
virtual bool MessageSend(MessageInfo &info) = 0;
|
||||
virtual bool MessageToDraft(MessageInfo &info) = 0;
|
||||
virtual bool MessageToTrash(std::string mid, bool bTrash) = 0;
|
||||
virtual bool MessageToDraft(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;
|
||||
|
||||
virtual bool MessageDelete(std::string mid) = 0;
|
||||
virtual bool MessageRead(std::string mid, bool bUnreadByUser) = 0;
|
||||
virtual bool MessageDelete(const std::string &mid) = 0;
|
||||
virtual bool MessageRead(const std::string &mid, bool bUnreadByUser) = 0;
|
||||
virtual bool MessageReplied(const std::string &mid, bool replied) = 0;
|
||||
virtual bool MessageForwarded(const std::string &mid, bool forwarded) = 0;
|
||||
|
||||
/* message tagging */
|
||||
|
||||
|
@ -169,8 +174,8 @@ virtual bool getMessageTagTypes(MsgTagType& tags) = 0;
|
|||
virtual bool setMessageTagType(uint32_t tagId, std::string& text, uint32_t rgb_color) = 0;
|
||||
virtual bool removeMessageTagType(uint32_t tagId) = 0;
|
||||
|
||||
virtual bool getMessageTag(std::string msgId, MsgTagInfo& info) = 0;
|
||||
virtual bool setMessageTag(std::string msgId, uint32_t tagId, bool set) = 0;
|
||||
virtual bool getMessageTag(const std::string &msgId, MsgTagInfo& info) = 0;
|
||||
virtual bool setMessageTag(const std::string &msgId, uint32_t tagId, bool set) = 0;
|
||||
|
||||
virtual bool resetMessageStandardTagTypes(MsgTagType& tags) = 0;
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ bool p3Msgs::getMessageSummaries(std::list<MsgInfoSummary> &msgList)
|
|||
|
||||
|
||||
|
||||
bool p3Msgs::getMessage(std::string mid, MessageInfo &msg)
|
||||
bool p3Msgs::getMessage(const std::string &mid, MessageInfo &msg)
|
||||
{
|
||||
return mMsgSrv->getMessage(mid, msg);
|
||||
}
|
||||
|
@ -75,19 +75,24 @@ bool p3Msgs::MessageSend(MessageInfo &info)
|
|||
return mMsgSrv->MessageSend(info);
|
||||
}
|
||||
|
||||
bool p3Msgs::MessageToDraft(MessageInfo &info)
|
||||
bool p3Msgs::MessageToDraft(MessageInfo &info, const std::string &msgParentId)
|
||||
{
|
||||
return mMsgSrv->MessageToDraft(info);
|
||||
return mMsgSrv->MessageToDraft(info, msgParentId);
|
||||
}
|
||||
|
||||
bool p3Msgs::MessageToTrash(std::string mid, bool bTrash)
|
||||
bool p3Msgs::MessageToTrash(const std::string &mid, bool bTrash)
|
||||
{
|
||||
return mMsgSrv->MessageToTrash(mid, bTrash);
|
||||
return mMsgSrv->MessageToTrash(mid, bTrash);
|
||||
}
|
||||
|
||||
bool p3Msgs::getMsgParentId(const std::string &msgId, std::string &msgParentId)
|
||||
{
|
||||
return mMsgSrv->getMsgParentId(msgId, msgParentId);
|
||||
}
|
||||
|
||||
/****************************************/
|
||||
/****************************************/
|
||||
bool p3Msgs::MessageDelete(std::string mid)
|
||||
bool p3Msgs::MessageDelete(const std::string &mid)
|
||||
{
|
||||
//std::cerr << "p3Msgs::MessageDelete() ";
|
||||
//std::cerr << "mid: " << mid << std::endl;
|
||||
|
@ -95,7 +100,7 @@ bool p3Msgs::MessageDelete(std::string mid)
|
|||
return mMsgSrv -> removeMsgId(mid);
|
||||
}
|
||||
|
||||
bool p3Msgs::MessageRead(std::string mid, bool bUnreadByUser)
|
||||
bool p3Msgs::MessageRead(const std::string &mid, bool bUnreadByUser)
|
||||
{
|
||||
//std::cerr << "p3Msgs::MessageRead() ";
|
||||
//std::cerr << "mid: " << mid << std::endl;
|
||||
|
@ -103,6 +108,16 @@ bool p3Msgs::MessageRead(std::string mid, bool bUnreadByUser)
|
|||
return mMsgSrv -> markMsgIdRead(mid, bUnreadByUser);
|
||||
}
|
||||
|
||||
bool p3Msgs::MessageReplied(const std::string &mid, bool replied)
|
||||
{
|
||||
return mMsgSrv->setMsgFlag(mid, replied ? RS_MSG_FLAGS_REPLIED : 0, 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);
|
||||
}
|
||||
|
||||
bool p3Msgs::getMessageTagTypes(MsgTagType& tags)
|
||||
{
|
||||
return mMsgSrv->getMessageTagTypes(tags);
|
||||
|
@ -118,12 +133,12 @@ bool p3Msgs::removeMessageTagType(uint32_t tagId)
|
|||
return mMsgSrv->removeMessageTagType(tagId);
|
||||
}
|
||||
|
||||
bool p3Msgs::getMessageTag(std::string msgId, MsgTagInfo& info)
|
||||
bool p3Msgs::getMessageTag(const std::string &msgId, MsgTagInfo& info)
|
||||
{
|
||||
return mMsgSrv->getMessageTag(msgId, info);
|
||||
}
|
||||
|
||||
bool p3Msgs::setMessageTag(std::string msgId, uint32_t tagId, bool set)
|
||||
bool p3Msgs::setMessageTag(const std::string &msgId, uint32_t tagId, bool set)
|
||||
{
|
||||
return mMsgSrv->setMessageTag(msgId, tagId, set);
|
||||
}
|
||||
|
|
|
@ -54,22 +54,25 @@ class p3Msgs: public RsMsgs
|
|||
* @param msgList ref to list summarising client's msgs
|
||||
*/
|
||||
virtual bool getMessageSummaries(std::list<MsgInfoSummary> &msgList);
|
||||
virtual bool getMessage(std::string mId, MessageInfo &msg);
|
||||
virtual bool getMessage(const std::string &mId, MessageInfo &msg);
|
||||
virtual void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox, unsigned int *pnTrashbox);
|
||||
|
||||
virtual bool MessageSend(MessageInfo &info);
|
||||
virtual bool MessageToDraft(MessageInfo &info);
|
||||
virtual bool MessageToTrash(std::string mid, bool bTrash);
|
||||
virtual bool MessageDelete(std::string mid);
|
||||
virtual bool MessageRead(std::string mid, bool bUnreadByUser);
|
||||
virtual bool MessageToDraft(MessageInfo &info, const std::string &msgParentId);
|
||||
virtual bool MessageToTrash(const std::string &mid, bool bTrash);
|
||||
virtual bool MessageDelete(const std::string &mid);
|
||||
virtual bool MessageRead(const std::string &mid, bool bUnreadByUser);
|
||||
virtual bool MessageReplied(const std::string &mid, bool replied);
|
||||
virtual bool MessageForwarded(const std::string &mid, bool forwarded);
|
||||
virtual bool getMsgParentId(const std::string &msgId, std::string &msgParentId);
|
||||
|
||||
virtual bool getMessageTagTypes(MsgTagType& tags);
|
||||
virtual bool setMessageTagType(uint32_t tagId, std::string& text, uint32_t rgb_color);
|
||||
virtual bool removeMessageTagType(uint32_t tagId);
|
||||
|
||||
virtual bool getMessageTag(std::string msgId, MsgTagInfo& info);
|
||||
virtual bool getMessageTag(const std::string &msgId, MsgTagInfo& info);
|
||||
/* set == false && tagId == 0 --> remove all */
|
||||
virtual bool setMessageTag(std::string msgId, uint32_t tagId, bool set);
|
||||
virtual bool setMessageTag(const std::string &msgId, uint32_t tagId, bool set);
|
||||
|
||||
virtual bool resetMessageStandardTagTypes(MsgTagType& tags);
|
||||
|
||||
|
|
|
@ -1102,12 +1102,146 @@ RsMsgSrcId* RsMsgSerialiser::deserialiseMsgSrcIdItem(void* data, uint32_t* pktsi
|
|||
}
|
||||
|
||||
/************************* end of definition of msgSrcId serialisation functions ************************/
|
||||
|
||||
/************************************** Message ParentId **********************/
|
||||
|
||||
RsMsgParentId::~RsMsgParentId()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::ostream& RsMsgParentId::print(std::ostream& out, uint16_t indent)
|
||||
{
|
||||
printRsItemBase(out, "RsMsgParentIdItem", indent);
|
||||
uint16_t int_Indent = indent + 2;
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
out << "msgId : " << msgId << std::endl;
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
out << "msgParentId: " << msgParentId << std::endl;
|
||||
|
||||
|
||||
printRsItemEnd(out, "RsMsgParentId", indent);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
void RsMsgParentId::clear()
|
||||
{
|
||||
msgId = 0;
|
||||
msgParentId = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t RsMsgSerialiser::sizeMsgParentIdItem(RsMsgParentId* item)
|
||||
{
|
||||
uint32_t s = 8; /* header */
|
||||
|
||||
s += 4; // srcId
|
||||
s += 4; // msgParentId
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
bool RsMsgSerialiser::serialiseMsgParentIdItem(RsMsgParentId *item, void *data, uint32_t* pktsize)
|
||||
{
|
||||
uint32_t tlvsize = sizeMsgParentIdItem(item);
|
||||
uint32_t offset = 0;
|
||||
|
||||
if (*pktsize < tlvsize)
|
||||
return false; /* not enough space */
|
||||
|
||||
*pktsize = tlvsize;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
||||
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsMsgSerialiser::serialiseMsgParentIdItem() Header: " << ok << std::endl;
|
||||
std::cerr << "RsMsgSerialiser::serialiseMsgParentIdItem() Size: " << tlvsize << std::endl;
|
||||
#endif
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->msgId);
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->msgParentId);
|
||||
|
||||
if (offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsMsgSerialiser::serialiseMsgParentIdItem() Size Error! " << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
RsMsgParentId* RsMsgSerialiser::deserialiseMsgParentIdItem(void* data, uint32_t* pktsize)
|
||||
{
|
||||
/* get the type and size */
|
||||
uint32_t rstype = getRsItemId(data);
|
||||
uint32_t rssize = getRsItemSize(data);
|
||||
|
||||
uint32_t offset = 0;
|
||||
|
||||
|
||||
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
|
||||
(RS_SERVICE_TYPE_MSG != getRsItemService(rstype)) ||
|
||||
(RS_PKT_SUBTYPE_MSG_PARENT_TAG != getRsItemSubType(rstype)))
|
||||
{
|
||||
return NULL; /* wrong type */
|
||||
}
|
||||
|
||||
if (*pktsize < rssize) /* check size */
|
||||
return NULL; /* not enough data */
|
||||
|
||||
/* set the packet length */
|
||||
*pktsize = rssize;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
/* ready to load */
|
||||
RsMsgParentId *item = new RsMsgParentId();
|
||||
item->clear();
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
|
||||
/* get mandatory parts first */
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(item->msgId));
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(item->msgParentId));
|
||||
|
||||
if (offset != rssize)
|
||||
{
|
||||
/* error */
|
||||
delete item;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
delete item;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
/************************* end of definition of msgParentId serialisation functions ************************/
|
||||
|
||||
uint32_t RsMsgSerialiser::size(RsItem *i)
|
||||
{
|
||||
RsMsgItem *mi;
|
||||
RsMsgTagType *mtt;
|
||||
RsMsgTags *mts;
|
||||
RsMsgSrcId *msi;
|
||||
RsMsgParentId *msp;
|
||||
|
||||
/* in order of frequency */
|
||||
if (NULL != (mi = dynamic_cast<RsMsgItem *>(i)))
|
||||
|
@ -1118,6 +1252,10 @@ uint32_t RsMsgSerialiser::size(RsItem *i)
|
|||
{
|
||||
return sizeMsgSrcIdItem(msi);
|
||||
}
|
||||
else if (NULL != (msp = dynamic_cast<RsMsgParentId *>(i)))
|
||||
{
|
||||
return sizeMsgParentIdItem(msp);
|
||||
}
|
||||
else if (NULL != (mtt = dynamic_cast<RsMsgTagType *>(i)))
|
||||
{
|
||||
return sizeTagItem(mtt);
|
||||
|
@ -1138,6 +1276,7 @@ bool RsMsgSerialiser::serialise(RsItem *i, void *data, uint32_t *pktsize)
|
|||
|
||||
RsMsgItem *mi;
|
||||
RsMsgSrcId* msi;
|
||||
RsMsgParentId* msp;
|
||||
RsMsgTagType *mtt;
|
||||
RsMsgTags *mts;
|
||||
|
||||
|
@ -1150,6 +1289,10 @@ bool RsMsgSerialiser::serialise(RsItem *i, void *data, uint32_t *pktsize)
|
|||
{
|
||||
return serialiseMsgSrcIdItem(msi, data, pktsize);
|
||||
}
|
||||
else if (NULL != (msp = dynamic_cast<RsMsgParentId *>(i)))
|
||||
{
|
||||
return serialiseMsgParentIdItem(msp, data, pktsize);
|
||||
}
|
||||
else if (NULL != (mtt = dynamic_cast<RsMsgTagType *>(i)))
|
||||
{
|
||||
return serialiseTagItem(mtt, data, pktsize);
|
||||
|
@ -1185,6 +1328,9 @@ RsItem* RsMsgSerialiser::deserialise(void *data, uint32_t *pktsize)
|
|||
case RS_PKT_SUBTYPE_MSG_SRC_TAG:
|
||||
return deserialiseMsgSrcIdItem(data, pktsize);
|
||||
break;
|
||||
case RS_PKT_SUBTYPE_MSG_PARENT_TAG:
|
||||
return deserialiseMsgParentIdItem(data, pktsize);
|
||||
break;
|
||||
case RS_PKT_SUBTYPE_MSG_TAG_TYPE:
|
||||
return deserialiseTagItem(data, pktsize);
|
||||
break;
|
||||
|
|
|
@ -54,6 +54,7 @@ const uint8_t RS_PKT_SUBTYPE_PRIVATECHATMSG_CONFIG = 0x05 ; // default is 0x01
|
|||
const uint8_t RS_PKT_SUBTYPE_MSG_TAG_TYPE = 0x03;
|
||||
const uint8_t RS_PKT_SUBTYPE_MSG_TAGS = 0x04;
|
||||
const uint8_t RS_PKT_SUBTYPE_MSG_SRC_TAG = 0x05;
|
||||
const uint8_t RS_PKT_SUBTYPE_MSG_PARENT_TAG = 0x06;
|
||||
|
||||
|
||||
class RsChatItem: public RsItem
|
||||
|
@ -184,6 +185,8 @@ const uint32_t RS_MSG_FLAGS_DRAFT = 0x0004;
|
|||
const uint32_t RS_MSG_FLAGS_NEW = 0x0010;
|
||||
const uint32_t RS_MSG_FLAGS_TRASH = 0x0020;
|
||||
const uint32_t RS_MSG_FLAGS_UNREAD_BY_USER = 0x0040;
|
||||
const uint32_t RS_MSG_FLAGS_REPLIED = 0x0080;
|
||||
const uint32_t RS_MSG_FLAGS_FORWARDED = 0x0100;
|
||||
|
||||
class RsMsgItem: public RsItem
|
||||
{
|
||||
|
@ -275,6 +278,26 @@ public:
|
|||
|
||||
};
|
||||
|
||||
class RsMsgParentId : public RsItem
|
||||
{
|
||||
|
||||
public:
|
||||
RsMsgParentId()
|
||||
: RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_MSG,
|
||||
RS_PKT_SUBTYPE_MSG_PARENT_TAG)
|
||||
{ return;}
|
||||
|
||||
std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
virtual ~RsMsgParentId();
|
||||
virtual void clear();
|
||||
|
||||
|
||||
uint32_t msgId;
|
||||
uint32_t msgParentId;
|
||||
|
||||
};
|
||||
|
||||
class RsMsgSerialiser: public RsSerialType
|
||||
{
|
||||
public:
|
||||
|
@ -311,6 +334,9 @@ virtual uint32_t sizeMsgSrcIdItem(RsMsgSrcId *);
|
|||
virtual bool serialiseMsgSrcIdItem (RsMsgSrcId *item, void *data, uint32_t *size);
|
||||
virtual RsMsgSrcId *deserialiseMsgSrcIdItem(void *data, uint32_t *size);
|
||||
|
||||
virtual uint32_t sizeMsgParentIdItem(RsMsgParentId *);
|
||||
virtual bool serialiseMsgParentIdItem (RsMsgParentId *item, void *data, uint32_t *size);
|
||||
virtual RsMsgParentId *deserialiseMsgParentIdItem(void *data, uint32_t *size);
|
||||
|
||||
|
||||
bool m_bConfiguration; // is set to true for saving configuration (enables serialising msgId)
|
||||
|
|
|
@ -135,7 +135,6 @@ int p3MsgService::incomingMsgs()
|
|||
changed = true ;
|
||||
++i;
|
||||
mi -> recvTime = time(NULL);
|
||||
mi -> msgFlags = RS_MSG_FLAGS_NEW;
|
||||
mi -> msgId = getNewUniqueMsgId();
|
||||
|
||||
std::string mesg;
|
||||
|
@ -149,6 +148,8 @@ int p3MsgService::incomingMsgs()
|
|||
}
|
||||
else
|
||||
{
|
||||
mi -> msgFlags = RS_MSG_FLAGS_NEW;
|
||||
|
||||
/* from a peer */
|
||||
MsgInfoSummary mis;
|
||||
initRsMIS(mi, mis);
|
||||
|
@ -285,6 +286,7 @@ std::list<RsItem*> p3MsgService::saveList(bool& cleanup)
|
|||
std::map<uint32_t, RsMsgTagType* >::iterator mit2;
|
||||
std::map<uint32_t, RsMsgTags* >::iterator mit3;
|
||||
std::list<RsMsgSrcId* >::iterator lit;
|
||||
std::map<uint32_t, RsMsgParentId* >::iterator mit4;
|
||||
|
||||
MsgTagType stdTags;
|
||||
|
||||
|
@ -308,6 +310,9 @@ std::list<RsItem*> p3MsgService::saveList(bool& cleanup)
|
|||
for(mit3 = mMsgTags.begin(); mit3 != mMsgTags.end(); mit3++)
|
||||
itemList.push_back(mit3->second);
|
||||
|
||||
for(mit4 = mParentId.begin(); mit4 != mParentId.end(); mit4++)
|
||||
itemList.push_back(mit4->second);
|
||||
|
||||
return itemList;
|
||||
}
|
||||
|
||||
|
@ -371,6 +376,7 @@ bool p3MsgService::loadList(std::list<RsItem*> load)
|
|||
RsMsgTagType* mtt;
|
||||
RsMsgTags* mti;
|
||||
RsMsgSrcId* msi;
|
||||
RsMsgParentId* msp;
|
||||
|
||||
std::list<RsMsgItem*> items;
|
||||
std::list<RsItem*>::iterator it;
|
||||
|
@ -415,6 +421,10 @@ bool p3MsgService::loadList(std::list<RsItem*> load)
|
|||
srcIdMsgMap.insert(std::pair<uint32_t, std::string>(msi->msgId, msi->srcId));
|
||||
mSrcIdList.push_back(msi); // does not need to be kept
|
||||
}
|
||||
else if(NULL != (msp = dynamic_cast<RsMsgParentId *>(*it)))
|
||||
{
|
||||
mParentId.insert(std::pair<uint32_t, RsMsgParentId*>(msp->msgId, msp));
|
||||
}
|
||||
}
|
||||
|
||||
// sort items into lists
|
||||
|
@ -453,6 +463,20 @@ bool p3MsgService::loadList(std::list<RsItem*> load)
|
|||
}
|
||||
}
|
||||
|
||||
/* remove missing msgId in mParentId */
|
||||
std::map<uint32_t, RsMsgParentId *>::iterator mit = mParentId.begin();
|
||||
while (mit != mParentId.end()) {
|
||||
if (imsg.find(mit->first) == imsg.end()) {
|
||||
if (msgOutgoing.find(mit->first) == msgOutgoing.end()) {
|
||||
/* not found */
|
||||
mParentId.erase(mit++);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
mit++;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -523,7 +547,7 @@ bool p3MsgService::getMessageSummaries(std::list<MsgInfoSummary> &msgList)
|
|||
}
|
||||
|
||||
|
||||
bool p3MsgService::getMessage(std::string &mId, MessageInfo &msg)
|
||||
bool p3MsgService::getMessage(const std::string &mId, MessageInfo &msg)
|
||||
{
|
||||
std::map<uint32_t, RsMsgItem *>::iterator mit;
|
||||
uint32_t msgId = atoi(mId.c_str());
|
||||
|
@ -590,7 +614,7 @@ void p3MsgService::getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxN
|
|||
}
|
||||
|
||||
/* remove based on the unique mid (stored in sid) */
|
||||
bool p3MsgService::removeMsgId(std::string &mid)
|
||||
bool p3MsgService::removeMsgId(const std::string &mid)
|
||||
{
|
||||
std::map<uint32_t, RsMsgItem *>::iterator mit;
|
||||
uint32_t msgId = atoi(mid.c_str());
|
||||
|
@ -627,6 +651,7 @@ bool p3MsgService::removeMsgId(std::string &mid)
|
|||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||
|
||||
setMessageTag(mid, 0, false);
|
||||
setMsgParentId(msgId, 0);
|
||||
|
||||
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD);
|
||||
}
|
||||
|
@ -634,7 +659,7 @@ bool p3MsgService::removeMsgId(std::string &mid)
|
|||
return changed;
|
||||
}
|
||||
|
||||
bool p3MsgService::markMsgIdRead(std::string &mid, bool bUnreadByUser)
|
||||
bool p3MsgService::markMsgIdRead(const std::string &mid, bool bUnreadByUser)
|
||||
{
|
||||
std::map<uint32_t, RsMsgItem *>::iterator mit;
|
||||
uint32_t msgId = atoi(mid.c_str());
|
||||
|
@ -677,6 +702,104 @@ bool p3MsgService::markMsgIdRead(std::string &mid, bool bUnreadByUser)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool p3MsgService::setMsgFlag(const std::string &mid, uint32_t flag, uint32_t mask)
|
||||
{
|
||||
std::map<uint32_t, RsMsgItem *>::iterator mit;
|
||||
uint32_t msgId = atoi(mid.c_str());
|
||||
|
||||
bool changed = false;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
mit = imsg.find(msgId);
|
||||
if (mit == imsg.end())
|
||||
{
|
||||
mit = msgOutgoing.find(msgId);
|
||||
if (mit == msgOutgoing.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t oldFlag = mit->second->msgFlags;
|
||||
|
||||
mit->second->msgFlags &= ~mask;
|
||||
mit->second->msgFlags |= flag;
|
||||
|
||||
if (mit->second->msgFlags != oldFlag) {
|
||||
changed = true;
|
||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||
}
|
||||
} /* UNLOCKED */
|
||||
|
||||
if (changed) {
|
||||
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3MsgService::getMsgParentId(const std::string &msgId, std::string &msgParentId)
|
||||
{
|
||||
msgParentId.clear();
|
||||
|
||||
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
std::map<uint32_t, RsMsgParentId *>::iterator mit = mParentId.find(atoi(msgId.c_str()));
|
||||
if (mit == mParentId.end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::ostringstream out;
|
||||
out << mit->second->msgParentId;
|
||||
msgParentId = out.str();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3MsgService::setMsgParentId(uint32_t msgId, uint32_t msgParentId)
|
||||
{
|
||||
std::map<uint32_t, RsMsgParentId *>::iterator mit;
|
||||
|
||||
bool changed = false;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
mit = mParentId.find(msgId);
|
||||
if (mit == mParentId.end())
|
||||
{
|
||||
if (msgParentId) {
|
||||
RsMsgParentId* msp = new RsMsgParentId();
|
||||
msp->PeerId (mConnMgr->getOwnId());
|
||||
msp->msgId = msgId;
|
||||
msp->msgParentId = msgParentId;
|
||||
mParentId.insert(std::pair<uint32_t, RsMsgParentId*>(msgId, msp));
|
||||
|
||||
changed = true;
|
||||
}
|
||||
} else {
|
||||
if (msgParentId) {
|
||||
if (mit->second->msgParentId != msgParentId) {
|
||||
mit->second->msgParentId = msgParentId;
|
||||
changed = true;
|
||||
}
|
||||
} else {
|
||||
delete mit->second;
|
||||
mParentId.erase(mit);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
} /* UNLOCKED */
|
||||
|
||||
if (changed) {
|
||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/****************************************/
|
||||
/****************************************/
|
||||
/* Message Items */
|
||||
|
@ -745,7 +868,7 @@ bool p3MsgService::MessageSend(MessageInfo &info)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool p3MsgService::MessageToDraft(MessageInfo &info)
|
||||
bool p3MsgService::MessageToDraft(MessageInfo &info, const std::string &msgParentId)
|
||||
{
|
||||
RsMsgItem *msg = initMIRsMsg(info, mConnMgr->getOwnId());
|
||||
if (msg)
|
||||
|
@ -786,6 +909,8 @@ bool p3MsgService::MessageToDraft(MessageInfo &info)
|
|||
info.msgId = out.str();
|
||||
}
|
||||
|
||||
setMsgParentId(msg->msgId, atoi(msgParentId.c_str()));
|
||||
|
||||
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
|
||||
|
||||
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD);
|
||||
|
@ -919,7 +1044,7 @@ bool p3MsgService::removeMessageTagType(uint32_t tagId)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool p3MsgService::getMessageTag(std::string &msgId, MsgTagInfo& info)
|
||||
bool p3MsgService::getMessageTag(const std::string &msgId, MsgTagInfo& info)
|
||||
{
|
||||
RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
|
@ -945,7 +1070,7 @@ bool p3MsgService::getMessageTag(std::string &msgId, MsgTagInfo& info)
|
|||
}
|
||||
|
||||
/* set == false && tagId == 0 --> remove all */
|
||||
bool p3MsgService::setMessageTag(std::string &msgId, uint32_t tagId, bool set)
|
||||
bool p3MsgService::setMessageTag(const std::string &msgId, uint32_t tagId, bool set)
|
||||
{
|
||||
uint32_t mid = atoi(msgId.c_str());
|
||||
if (mid == 0) {
|
||||
|
@ -1047,7 +1172,7 @@ bool p3MsgService::resetMessageStandardTagTypes(MsgTagType& tags)
|
|||
}
|
||||
|
||||
/* move message to trash based on the unique mid */
|
||||
bool p3MsgService::MessageToTrash(std::string mid, bool bTrash)
|
||||
bool p3MsgService::MessageToTrash(const std::string &mid, bool bTrash)
|
||||
{
|
||||
std::map<uint32_t, RsMsgItem *>::iterator mit;
|
||||
uint32_t msgId = atoi(mid.c_str());
|
||||
|
@ -1141,6 +1266,14 @@ void p3MsgService::initRsMI(RsMsgItem *msg, MessageInfo &mi)
|
|||
{
|
||||
mi.msgflags |= RS_MSG_UNREAD_BY_USER;
|
||||
}
|
||||
if (msg->msgFlags & RS_MSG_FLAGS_REPLIED)
|
||||
{
|
||||
mi.msgflags |= RS_MSG_REPLIED;
|
||||
}
|
||||
if (msg->msgFlags & RS_MSG_FLAGS_FORWARDED)
|
||||
{
|
||||
mi.msgflags |= RS_MSG_FORWARDED;
|
||||
}
|
||||
|
||||
mi.ts = msg->sendTime;
|
||||
mi.srcId = msg->PeerId();
|
||||
|
@ -1228,6 +1361,14 @@ void p3MsgService::initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis)
|
|||
{
|
||||
mis.msgflags |= RS_MSG_UNREAD_BY_USER;
|
||||
}
|
||||
if (msg->msgFlags & RS_MSG_FLAGS_REPLIED)
|
||||
{
|
||||
mis.msgflags |= RS_MSG_REPLIED;
|
||||
}
|
||||
if (msg->msgFlags & RS_MSG_FLAGS_FORWARDED)
|
||||
{
|
||||
mis.msgflags |= RS_MSG_FORWARDED;
|
||||
}
|
||||
|
||||
mis.srcId = msg->PeerId();
|
||||
{
|
||||
|
|
|
@ -56,23 +56,27 @@ bool MsgNotifications(); /* popup - messages */
|
|||
bool getMessageNotifications(std::list<MsgInfoSummary> ¬eList);
|
||||
|
||||
bool getMessageSummaries(std::list<MsgInfoSummary> &msgList);
|
||||
bool getMessage(std::string &mid, MessageInfo &msg);
|
||||
bool getMessage(const std::string &mid, MessageInfo &msg);
|
||||
void getMessageCount(unsigned int *pnInbox, unsigned int *pnInboxNew, unsigned int *pnOutbox, unsigned int *pnDraftbox, unsigned int *pnSentbox, unsigned int *pnTrashbox);
|
||||
|
||||
bool removeMsgId(std::string &mid);
|
||||
bool markMsgIdRead(std::string &mid, bool bUnreadByUser);
|
||||
bool removeMsgId(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 getMsgParentId(const std::string &msgId, std::string &msgParentId);
|
||||
// msgParentId == 0 --> remove
|
||||
bool setMsgParentId(uint32_t msgId, uint32_t msgParentId);
|
||||
|
||||
bool MessageSend(MessageInfo &info);
|
||||
bool MessageToDraft(MessageInfo &info);
|
||||
bool MessageToTrash(std::string mid, bool bTrash);
|
||||
bool MessageToDraft(MessageInfo &info, const std::string &msgParentId);
|
||||
bool MessageToTrash(const std::string &mid, bool bTrash);
|
||||
|
||||
bool getMessageTagTypes(MsgTagType& tags);
|
||||
bool setMessageTagType(uint32_t tagId, std::string& text, uint32_t rgb_color);
|
||||
bool removeMessageTagType(uint32_t tagId);
|
||||
|
||||
bool getMessageTag(std::string &msgId, MsgTagInfo& info);
|
||||
bool getMessageTag(const std::string &msgId, MsgTagInfo& info);
|
||||
/* set == false && tagId == 0 --> remove all */
|
||||
bool setMessageTag(std::string &msgId, uint32_t tagId, bool set);
|
||||
bool setMessageTag(const std::string &msgId, uint32_t tagId, bool set);
|
||||
|
||||
bool resetMessageStandardTagTypes(MsgTagType& tags);
|
||||
|
||||
|
@ -134,6 +138,9 @@ void initStandardTagTypes();
|
|||
// used delete msgSrcIds after config save
|
||||
std::list<RsMsgSrcId*> mSrcIdList;
|
||||
|
||||
// save the parent of the messages in draft for replied and forwarded
|
||||
std::map<uint32_t, RsMsgParentId*> mParentId;
|
||||
|
||||
std::string config_dir;
|
||||
};
|
||||
|
||||
|
|
|
@ -124,6 +124,13 @@ RsSerialType* init_item(RsMsgSrcId& ms)
|
|||
return new RsMsgSerialiser();
|
||||
}
|
||||
|
||||
RsSerialType* init_item(RsMsgParentId& ms)
|
||||
{
|
||||
ms.msgId = rand()%354;
|
||||
ms.msgParentId = rand()%476;
|
||||
|
||||
return new RsMsgSerialiser();
|
||||
}
|
||||
|
||||
bool operator ==(const RsChatMsgItem& cmiLeft,const RsChatMsgItem& cmiRight)
|
||||
{
|
||||
|
@ -223,6 +230,14 @@ bool operator ==(const RsMsgSrcId& msLeft, const RsMsgSrcId& msRight)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool operator ==(const RsMsgParentId& msLeft, const RsMsgParentId& msRight)
|
||||
{
|
||||
if(msLeft.msgId != msRight.msgId) return false;
|
||||
if(msLeft.msgParentId != msRight.msgParentId) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_RsItem<RsChatMsgItem >(); REPORT("Serialise/Deserialise RsChatMsgItem");
|
||||
|
@ -233,6 +248,7 @@ int main()
|
|||
test_RsItem<RsMsgTagType>(); REPORT("Serialise/Deserialise RsMsgTagType");
|
||||
test_RsItem<RsMsgTags>(); REPORT("Serialise/Deserialise RsMsgTags");
|
||||
test_RsItem<RsMsgSrcId>(); REPORT("Serialise/Deserialise RsMsgSrcId");
|
||||
test_RsItem<RsMsgParentId>(); REPORT("Serialise/Deserialise RsMsgParentId");
|
||||
|
||||
std::cerr << std::endl;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue