diff --git a/libretroshare/src/retroshare/rsmsgs.h b/libretroshare/src/retroshare/rsmsgs.h index a51b4dbc1..d9c6e611c 100644 --- a/libretroshare/src/retroshare/rsmsgs.h +++ b/libretroshare/src/retroshare/rsmsgs.h @@ -93,28 +93,38 @@ typedef GRouterKeyIdType DistantMsgPeerId ; class MessageInfo { - public: - MessageInfo() {} - std::string msgId; - RsPeerId srcId; +public: + MessageInfo() {} + std::string msgId; - unsigned int msgflags; + RsPeerId rspeerid_srcId; + RsGxsId rsgxsid_srcId; - std::list msgto; - std::list msgcc; - std::list msgbcc; + unsigned int msgflags; - std::string title; - std::string msg; + // friend destinations + // + std::list rspeerid_msgto; // RsPeerId is used here for various purposes: + std::list rspeerid_msgcc; // - real peer ids which are actual friend locations + std::list rspeerid_msgbcc; // - - std::string attach_title; - std::string attach_comment; - std::list files; - std::map encryption_keys ; // for concerned ids only the public pgp key id to encrypt the message with. - int size; /* total of files */ - int count; /* file count */ + // distant peers + // + std::list rsgxsid_msgto; // RsPeerId is used here for various purposes: + std::list rsgxsid_msgcc; // - real peer ids which are actual friend locations + std::list rsgxsid_msgbcc; // - - int ts; + std::string title; + std::string msg; + + std::string attach_title; + std::string attach_comment; + std::list files; + + int size; /* total of files */ + int count; /* file count */ + + int ts; }; class MsgInfoSummary diff --git a/libretroshare/src/serialiser/rsmsgitems.cc b/libretroshare/src/serialiser/rsmsgitems.cc index 86b5e85aa..32f3e467b 100644 --- a/libretroshare/src/serialiser/rsmsgitems.cc +++ b/libretroshare/src/serialiser/rsmsgitems.cc @@ -1380,9 +1380,13 @@ void RsMsgItem::clear() subject.clear(); message.clear(); - msgto.TlvClear(); - msgcc.TlvClear(); - msgbcc.TlvClear(); + rspeerid_msgto.TlvClear(); + rspeerid_msgcc.TlvClear(); + rspeerid_msgbcc.TlvClear(); + + rsgxsid_msgto.TlvClear(); + rsgxsid_msgcc.TlvClear(); + rsgxsid_msgbcc.TlvClear(); attachment.TlvClear(); } @@ -1403,15 +1407,18 @@ std::ostream &RsMsgItem::print(std::ostream &out, uint16_t indent) printIndent(out, int_Indent); out << "Message To: " << std::endl; - msgto.print(out, int_Indent); + rspeerid_msgto.print(out, int_Indent); + rsgxsid_msgto.print(out, int_Indent); printIndent(out, int_Indent); out << "Message CC: " << std::endl; - msgcc.print(out, int_Indent); + rspeerid_msgcc.print(out, int_Indent); + rsgxsid_msgcc.print(out, int_Indent); printIndent(out, int_Indent); out << "Message BCC: " << std::endl; - msgbcc.print(out, int_Indent); + rspeerid_msgbcc.print(out, int_Indent); + rsgxsid_msgbcc.print(out, int_Indent); printIndent(out, int_Indent); std::string cnv_subject(subject.begin(), subject.end()); @@ -1514,9 +1521,14 @@ uint32_t RsMsgItem::serial_size(bool m_bConfiguration) s += GetTlvStringSize(subject); s += GetTlvStringSize(message); - s += msgto.TlvSize(); - s += msgcc.TlvSize(); - s += msgbcc.TlvSize(); + s += rspeerid_msgto.TlvSize(); + s += rspeerid_msgcc.TlvSize(); + s += rspeerid_msgbcc.TlvSize(); + + s += rsgxsid_msgto.TlvSize(); + s += rsgxsid_msgcc.TlvSize(); + s += rsgxsid_msgbcc.TlvSize(); + s += attachment.TlvSize(); if (m_bConfiguration) { @@ -1558,9 +1570,13 @@ bool RsMsgItem::serialise(void *data, uint32_t& pktsize,bool config) ok &= SetTlvString(data,tlvsize,&offset,TLV_TYPE_STR_SUBJECT,subject); ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_MSG, message); - ok &= msgto.SetTlv(data, tlvsize, &offset); - ok &= msgcc.SetTlv(data, tlvsize, &offset); - ok &= msgbcc.SetTlv(data, tlvsize, &offset); + ok &= rspeerid_msgto.SetTlv(data, tlvsize, &offset); + ok &= rspeerid_msgcc.SetTlv(data, tlvsize, &offset); + ok &= rspeerid_msgbcc.SetTlv(data, tlvsize, &offset); + + ok &= rsgxsid_msgto.SetTlv(data, tlvsize, &offset); + ok &= rsgxsid_msgcc.SetTlv(data, tlvsize, &offset); + ok &= rsgxsid_msgbcc.SetTlv(data, tlvsize, &offset); ok &= attachment.SetTlv(data, tlvsize, &offset); @@ -1614,9 +1630,14 @@ RsMsgItem *RsMsgSerialiser::deserialiseMsgItem(void *data, uint32_t *pktsize) ok &= GetTlvString(data,rssize,&offset,TLV_TYPE_STR_SUBJECT,item->subject); ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_MSG, item->message); - ok &= item->msgto.GetTlv(data, rssize, &offset); - ok &= item->msgcc.GetTlv(data, rssize, &offset); - ok &= item->msgbcc.GetTlv(data, rssize, &offset); + + ok &= item->rspeerid_msgto.GetTlv(data, rssize, &offset); + ok &= item->rspeerid_msgcc.GetTlv(data, rssize, &offset); + ok &= item->rspeerid_msgbcc.GetTlv(data, rssize, &offset); + ok &= item->rsgxsid_msgto.GetTlv(data, rssize, &offset); + ok &= item->rsgxsid_msgcc.GetTlv(data, rssize, &offset); + ok &= item->rsgxsid_msgbcc.GetTlv(data, rssize, &offset); + ok &= item->attachment.GetTlv(data, rssize, &offset); if (m_bConfiguration) { diff --git a/libretroshare/src/serialiser/rsmsgitems.h b/libretroshare/src/serialiser/rsmsgitems.h index 4e55d61c8..a6b82e60f 100644 --- a/libretroshare/src/serialiser/rsmsgitems.h +++ b/libretroshare/src/serialiser/rsmsgitems.h @@ -458,11 +458,6 @@ class RsMsgItem: public RsMessageItem public: RsMsgItem() :RsMessageItem(RS_PKT_SUBTYPE_DEFAULT) {} -// RsMsgItem(uint16_t type) -// :RsItem(RS_PKT_VERSION_SERVICE, type, -// RS_PKT_SUBTYPE_DEFAULT) -// { setPriorityLevel(QOS_PRIORITY_RS_MSG_ITEM) ; } - virtual ~RsMsgItem() {} virtual void clear(); @@ -482,9 +477,13 @@ class RsMsgItem: public RsMessageItem std::string subject; std::string message; - RsTlvPeerIdSet msgto; - RsTlvPeerIdSet msgcc; - RsTlvPeerIdSet msgbcc; + RsTlvPeerIdSet rspeerid_msgto; + RsTlvPeerIdSet rspeerid_msgcc; + RsTlvPeerIdSet rspeerid_msgbcc; + + RsTlvGxsIdSet rsgxsid_msgto; + RsTlvGxsIdSet rsgxsid_msgcc; + RsTlvGxsIdSet rsgxsid_msgbcc; RsTlvFileSet attachment; }; diff --git a/libretroshare/src/serialiser/rstlvbase.h b/libretroshare/src/serialiser/rstlvbase.h index f57dabf3e..9bdf4bbb9 100644 --- a/libretroshare/src/serialiser/rstlvbase.h +++ b/libretroshare/src/serialiser/rstlvbase.h @@ -212,6 +212,7 @@ const uint16_t TLV_TYPE_HASHSET = 0x1022; const uint16_t TLV_TYPE_PGPIDSET = 0x1023; const uint16_t TLV_TYPE_RECOGNSET = 0x1024; +const uint16_t TLV_TYPE_GXSIDSET = 0x1025; const uint16_t TLV_TYPE_SERVICESET = 0x1030; diff --git a/libretroshare/src/serialiser/rstlvtypes.h b/libretroshare/src/serialiser/rstlvtypes.h index ce00d7143..2e748860c 100644 --- a/libretroshare/src/serialiser/rstlvtypes.h +++ b/libretroshare/src/serialiser/rstlvtypes.h @@ -41,7 +41,7 @@ #include #include #include - +#include //! A base class for all tlv items /*! This class is provided to allow the serialisation and deserialization of compund @@ -189,9 +189,10 @@ template class t_RsTlvIdSet: public RsTlvItem std::list ids ; }; -typedef t_RsTlvIdSet RsTlvPeerIdSet ; -typedef t_RsTlvIdSet RsTlvPgpIdSet ; +typedef t_RsTlvIdSet RsTlvPeerIdSet ; +typedef t_RsTlvIdSet RsTlvPgpIdSet ; typedef t_RsTlvIdSet RsTlvHashSet ; +typedef t_RsTlvIdSet RsTlvGxsIdSet ; class RsTlvServiceIdSet: public RsTlvItem { diff --git a/libretroshare/src/services/p3msgservice.cc b/libretroshare/src/services/p3msgservice.cc index f083cac66..3e578a037 100644 --- a/libretroshare/src/services/p3msgservice.cc +++ b/libretroshare/src/services/p3msgservice.cc @@ -324,12 +324,11 @@ int p3MsgService::checkOutgoingMessages() std::map::iterator mit; for(mit = msgOutgoing.begin(); mit != msgOutgoing.end(); mit++) { - if (mit->second->msgFlags & RS_MSG_FLAGS_TRASH) { + if (mit->second->msgFlags & RS_MSG_FLAGS_TRASH) continue; - } /* find the certificate */ - RsPeerId pid = mit->second->PeerId(); + RsPeerId pid = mit->second->PeerId(); bool tunnel_is_ok = false ; if(mit->second->msgFlags & RS_MSG_FLAGS_DISTANT) @@ -1034,47 +1033,34 @@ bool p3MsgService::MessageSend(MessageInfo &info) { std::list::const_iterator pit; - for(pit = info.msgto.begin(); pit != info.msgto.end(); pit++) + for(pit = info.rspeerid_msgto.begin(); pit != info.rspeerid_msgto.end(); pit++) { RsMsgItem *msg = initMIRsMsg(info, *pit); + if (msg) - { sendMessage(msg); - } } - for(pit = info.msgcc.begin(); pit != info.msgcc.end(); pit++) + for(pit = info.rspeerid_msgcc.begin(); pit != info.rspeerid_msgcc.end(); pit++) { RsMsgItem *msg = initMIRsMsg(info, *pit); if (msg) - { sendMessage(msg); - } } - for(pit = info.msgbcc.begin(); pit != info.msgbcc.end(); pit++) + for(pit = info.rspeerid_msgbcc.begin(); pit != info.rspeerid_msgbcc.end(); pit++) { RsMsgItem *msg = initMIRsMsg(info, *pit); if (msg) - { sendMessage(msg); - } } /* send to ourselves as well */ RsMsgItem *msg = initMIRsMsg(info, mLinkMgr->getOwnId()); + if (msg) { - std::list::iterator it ; - - // Update destination ids in place of distant message hash, since this Outgoing message is for display - // -// for(it = msg->msgbcc.ids.begin(); it != msg->msgbcc.ids.end(); it++) -// if(info.encryption_keys.find(*it) != info.encryption_keys.end()) *it = info.encryption_keys[*it] ; -// for(it = msg->msgcc.ids.begin(); it != msg->msgcc.ids.end(); it++) -// if(info.encryption_keys.find(*it) != info.encryption_keys.end()) *it = info.encryption_keys[*it] ; -// for(it = msg->msgto.ids.begin(); it != msg->msgto.ids.end(); it++) -// if(info.encryption_keys.find(*it) != info.encryption_keys.end()) *it = info.encryption_keys[*it] ; + std::list::iterator it ; if (msg->msgFlags & RS_MSG_FLAGS_SIGNED) msg->msgFlags |= RS_MSG_FLAGS_SIGNATURE_CHECKS; // this is always true, since we are sending the message @@ -1118,7 +1104,7 @@ bool p3MsgService::SystemMessage(const std::string &title, const std::string &me msg->subject = title; msg->message = message; - msg->msgto.ids.push_back(ownId); + msg->rspeerid_msgto.ids.push_back(ownId); processMsg(msg, true); @@ -1492,96 +1478,35 @@ void p3MsgService::initRsMI(RsMsgItem *msg, MessageInfo &mi) mi.msgflags = 0; /* translate flags, if we sent it... outgoing */ - if ((msg->msgFlags & RS_MSG_FLAGS_OUTGOING) - /*|| (msg->PeerId() == mLinkMgr->getOwnId())*/) - { - mi.msgflags |= RS_MSG_OUTGOING; - } - /* if it has a pending flag, then its in the outbox */ - if (msg->msgFlags & RS_MSG_FLAGS_PENDING) - { - mi.msgflags |= RS_MSG_PENDING; - } - if (msg->msgFlags & RS_MSG_FLAGS_DRAFT) - { - mi.msgflags |= RS_MSG_DRAFT; - } - if (msg->msgFlags & RS_MSG_FLAGS_NEW) - { - mi.msgflags |= RS_MSG_NEW; - } - if (msg->msgFlags & RS_MSG_FLAGS_SIGNED) - mi.msgflags |= RS_MSG_SIGNED ; + if (msg->msgFlags & RS_MSG_FLAGS_OUTGOING) mi.msgflags |= RS_MSG_OUTGOING; + if (msg->msgFlags & RS_MSG_FLAGS_PENDING) mi.msgflags |= RS_MSG_PENDING; /* if it has a pending flag, then its in the outbox */ + if (msg->msgFlags & RS_MSG_FLAGS_DRAFT) mi.msgflags |= RS_MSG_DRAFT; + if (msg->msgFlags & RS_MSG_FLAGS_NEW) mi.msgflags |= RS_MSG_NEW; - if (msg->msgFlags & RS_MSG_FLAGS_SIGNATURE_CHECKS) - mi.msgflags |= RS_MSG_SIGNATURE_CHECKS ; - - if (msg->msgFlags & RS_MSG_FLAGS_ENCRYPTED) - mi.msgflags |= RS_MSG_ENCRYPTED ; - - if (msg->msgFlags & RS_MSG_FLAGS_DECRYPTED) - mi.msgflags |= RS_MSG_DECRYPTED ; - - if (msg->msgFlags & RS_MSG_FLAGS_TRASH) - { - mi.msgflags |= RS_MSG_TRASH; - } - if (msg->msgFlags & RS_MSG_FLAGS_UNREAD_BY_USER) - { - 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; - } - if (msg->msgFlags & RS_MSG_FLAGS_STAR) - { - mi.msgflags |= RS_MSG_STAR; - } - if (msg->msgFlags & RS_MSG_FLAGS_USER_REQUEST) - { - mi.msgflags |= RS_MSG_USER_REQUEST; - } - if (msg->msgFlags & RS_MSG_FLAGS_FRIEND_RECOMMENDATION) - { - mi.msgflags |= RS_MSG_FRIEND_RECOMMENDATION; - } - if (msg->msgFlags & RS_MSG_FLAGS_LOAD_EMBEDDED_IMAGES) - { - mi.msgflags |= RS_MSG_LOAD_EMBEDDED_IMAGES; - } + if (msg->msgFlags & RS_MSG_FLAGS_SIGNED) mi.msgflags |= RS_MSG_SIGNED ; + if (msg->msgFlags & RS_MSG_FLAGS_SIGNATURE_CHECKS) mi.msgflags |= RS_MSG_SIGNATURE_CHECKS ; + if (msg->msgFlags & RS_MSG_FLAGS_ENCRYPTED) mi.msgflags |= RS_MSG_ENCRYPTED ; + if (msg->msgFlags & RS_MSG_FLAGS_DECRYPTED) mi.msgflags |= RS_MSG_DECRYPTED ; + if (msg->msgFlags & RS_MSG_FLAGS_TRASH) mi.msgflags |= RS_MSG_TRASH; + if (msg->msgFlags & RS_MSG_FLAGS_UNREAD_BY_USER) 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; + if (msg->msgFlags & RS_MSG_FLAGS_STAR) mi.msgflags |= RS_MSG_STAR; + if (msg->msgFlags & RS_MSG_FLAGS_USER_REQUEST) mi.msgflags |= RS_MSG_USER_REQUEST; + if (msg->msgFlags & RS_MSG_FLAGS_FRIEND_RECOMMENDATION) mi.msgflags |= RS_MSG_FRIEND_RECOMMENDATION; + if (msg->msgFlags & RS_MSG_FLAGS_LOAD_EMBEDDED_IMAGES) mi.msgflags |= RS_MSG_LOAD_EMBEDDED_IMAGES; mi.ts = msg->sendTime; - mi.srcId = msg->PeerId(); - { - //msg->msgId; - rs_sprintf(mi.msgId, "%lu", msg->msgId); - } + mi.rspeerid_srcId = msg->PeerId(); - std::list::iterator pit; + mi.rspeerid_msgto = msg->rspeerid_msgto.ids ; + mi.rspeerid_msgcc = msg->rspeerid_msgcc.ids ; + mi.rspeerid_msgbcc = msg->rspeerid_msgbcc.ids ; - for(pit = msg->msgto.ids.begin(); - pit != msg->msgto.ids.end(); pit++) - { - mi.msgto.push_back(*pit); - } - - for(pit = msg->msgcc.ids.begin(); - pit != msg->msgcc.ids.end(); pit++) - { - mi.msgcc.push_back(*pit); - } - - for(pit = msg->msgbcc.ids.begin(); - pit != msg->msgbcc.ids.end(); pit++) - { - mi.msgbcc.push_back(*pit); - } + mi.rsgxsid_msgto = msg->rsgxsid_msgto.ids ; + mi.rsgxsid_msgcc = msg->rsgxsid_msgcc.ids ; + mi.rsgxsid_msgbcc = msg->rsgxsid_msgbcc.ids ; mi.title = msg->subject; mi.msg = msg->message; @@ -1592,9 +1517,7 @@ void p3MsgService::initRsMI(RsMsgItem *msg, MessageInfo &mi) mi.count = 0; mi.size = 0; - std::list::iterator it; - for(it = msg->attachment.items.begin(); - it != msg->attachment.items.end(); it++) + for(std::list::iterator it = msg->attachment.items.begin(); it != msg->attachment.items.end(); it++) { FileInfo fi; fi.fname = RsDirUtil::getTopDir(it->name); @@ -1605,7 +1528,6 @@ void p3MsgService::initRsMI(RsMsgItem *msg, MessageInfo &mi) mi.count++; mi.size += fi.size; } - } void p3MsgService::initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis) @@ -1687,50 +1609,33 @@ void p3MsgService::initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis) mis.ts = msg->sendTime; } -RsMsgItem *p3MsgService::initMIRsMsg(MessageInfo &info, const RsPeerId &to) +void p3MsgService::initMIRsMsg(RsMsgItem *msg,const MessageInfo& info) { - RsMsgItem *msg = new RsMsgItem(); - - msg -> PeerId(to); - msg -> msgFlags = 0; msg -> msgId = 0; msg -> sendTime = time(NULL); msg -> recvTime = 0; - msg -> subject = info.title; + msg -> message = info.msg; - msg -> message = info.msg; + msg->rspeerid_msgto.ids = info.rspeerid_msgto ; + msg->rspeerid_msgcc.ids = info.rspeerid_msgcc ; - std::list::iterator pit; - for(pit = info.msgto.begin(); pit != info.msgto.end(); pit++) - { - msg -> msgto.ids.push_back(*pit); - } - - for(pit = info.msgcc.begin(); pit != info.msgcc.end(); pit++) - { - msg -> msgcc.ids.push_back(*pit); - } + msg->rsgxsid_msgto.ids = info.rsgxsid_msgto ; + msg->rsgxsid_msgcc.ids = info.rsgxsid_msgcc ; /* We don't fill in bcc (unless to ourselves) */ - if (to == mLinkMgr->getOwnId()) + + if (msg->PeerId() == mLinkMgr->getOwnId()) { - for(pit = info.msgbcc.begin(); pit != info.msgbcc.end(); pit++) - { - msg -> msgbcc.ids.push_back(*pit); - } + msg->rsgxsid_msgbcc.ids = info.rsgxsid_msgbcc ; + msg->rspeerid_msgbcc.ids = info.rspeerid_msgbcc ; } msg -> attachment.title = info.attach_title; msg -> attachment.comment = info.attach_comment; - RsPeerDetails details ; - if(!rsPeers->getPeerDetails(to,details)) - msg->msgFlags |= RS_MSG_FLAGS_DISTANT; - - std::list::iterator it; - for(it = info.files.begin(); it != info.files.end(); it++) + for(std::list::const_iterator it = info.files.begin(); it != info.files.end(); it++) { RsTlvFileItem mfi; mfi.hash = it -> hash; @@ -1738,32 +1643,45 @@ RsMsgItem *p3MsgService::initMIRsMsg(MessageInfo &info, const RsPeerId &to) mfi.filesize = it -> size; msg -> attachment.items.push_back(mfi); } - /* translate flags from outside */ if (info.msgflags & RS_MSG_USER_REQUEST) msg->msgFlags |= RS_MSG_FLAGS_USER_REQUEST; if (info.msgflags & RS_MSG_FRIEND_RECOMMENDATION) msg->msgFlags |= RS_MSG_FLAGS_FRIEND_RECOMMENDATION; +} +RsMsgItem *p3MsgService::initMIRsMsg(const MessageInfo& info, const RsGxsId& to) +{ + RsMsgItem *msg = new RsMsgItem(); + + initMIRsMsg(msg,info) ; + + msg->PeerId(RsPeerId(to)); + msg->msgFlags |= RS_MSG_FLAGS_DISTANT; if (info.msgflags & RS_MSG_SIGNED) msg->msgFlags |= RS_MSG_FLAGS_SIGNED; - /* load embedded images from own messages */ - msg->msgFlags |= RS_MSG_FLAGS_LOAD_EMBEDDED_IMAGES; - // See if we need to encrypt this message. If so, we replace the msg text // by the whole message serialized and binary encrypted, so as to obfuscate // all its content. // + createDistantMessage(to,info.rsgxsid_srcId,msg) ; - if(!info.encryption_keys.empty()) - std::cerr << "(WW) Cannot encrypt message. Code needs to be improved." << std::endl; -// if(info.encryption_keys.find(to) != info.encryption_keys.end()) -// encryptMessage(info.encryption_keys[to],msg) ; + return msg ; +} + +RsMsgItem *p3MsgService::initMIRsMsg(const MessageInfo &info, const RsPeerId& to) +{ + RsMsgItem *msg = new RsMsgItem(); + + initMIRsMsg(msg,info) ; + + msg->PeerId(to) ; + + /* load embedded images from own messages */ + msg->msgFlags |= RS_MSG_FLAGS_LOAD_EMBEDDED_IMAGES; - //std::cerr << "p3MsgService::initMIRsMsg()" << std::endl; - //msg->print(std::cerr); return msg; } @@ -1892,9 +1810,12 @@ bool p3MsgService::createDistantMessage(const RsGxsId& destination_gxs_id,const item->message = armoured_data ; item->subject = "" ; - item->msgcc.ids.clear() ; - item->msgbcc.ids.clear() ; - item->msgto.ids.clear() ; + item->rspeerid_msgcc.ids.clear() ; + item->rspeerid_msgbcc.ids.clear() ; + item->rspeerid_msgto.ids.clear() ; + item->rsgxsid_msgcc.ids.clear() ; + item->rsgxsid_msgbcc.ids.clear() ; + item->rsgxsid_msgto.ids.clear() ; item->msgFlags |= RS_MSG_FLAGS_ENCRYPTED ; item->attachment.TlvClear() ; diff --git a/libretroshare/src/services/p3msgservice.h b/libretroshare/src/services/p3msgservice.h index 2293b4d9d..30329e59f 100644 --- a/libretroshare/src/services/p3msgservice.h +++ b/libretroshare/src/services/p3msgservice.h @@ -163,19 +163,22 @@ int checkOutgoingMessages(); p3GRouter *mGRouter ; #endif -uint32_t getNewUniqueMsgId(); -int sendMessage(RsMsgItem *item); -void checkSizeAndSendMessage(RsMsgItem *msg); + uint32_t getNewUniqueMsgId(); + int sendMessage(RsMsgItem *item); + void checkSizeAndSendMessage(RsMsgItem *msg); -int incomingMsgs(); -void processMsg(RsMsgItem *mi, bool incoming); -bool checkAndRebuildPartialMessage(RsMsgItem*) ; + int incomingMsgs(); + void processMsg(RsMsgItem *mi, bool incoming); + bool checkAndRebuildPartialMessage(RsMsgItem*) ; -void initRsMI(RsMsgItem *msg, MessageInfo &mi); -void initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis); -RsMsgItem *initMIRsMsg(MessageInfo &info, const RsPeerId &to); + void initRsMI(RsMsgItem *msg, MessageInfo &mi); + void initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis); -void initStandardTagTypes(); + RsMsgItem *initMIRsMsg(const MessageInfo &info, const RsPeerId& to); + RsMsgItem *initMIRsMsg(const MessageInfo &info, const RsGxsId& to); + void initMIRsMsg(RsMsgItem *item,const MessageInfo &info) ; + + void initStandardTagTypes(); p3LinkMgr *mLinkMgr; diff --git a/retroshare-gui/src/gui/MessagesDialog.cpp b/retroshare-gui/src/gui/MessagesDialog.cpp index aa2ee3e5a..a92acea38 100644 --- a/retroshare-gui/src/gui/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/MessagesDialog.cpp @@ -1114,19 +1114,28 @@ void MessagesDialog::insertMessages() text.clear(); - std::list::const_iterator pit; - for (pit = msgInfo.msgto.begin(); pit != msgInfo.msgto.end(); pit++) + for(std::list::const_iterator pit = msgInfo.rspeerid_msgto.begin(); pit != msgInfo.rspeerid_msgto.end(); pit++) { - if (text.isEmpty() == false) { + if (!text.isEmpty()) text += ", "; - } std::string peerName = rsPeers->getPeerName(*pit); - if (peerName.empty()) { + if (peerName.empty()) text += PeerDefs::rsid("", *pit); - } else { + else + text += QString::fromUtf8(peerName.c_str()); + } + for(std::list::const_iterator pit = msgInfo.rsgxsid_msgto.begin(); pit != msgInfo.rsgxsid_msgto.end(); pit++) + { + if (!text.isEmpty()) + text += ", "; + + // We should improve this by showing the real names of each GXS id. + std::string peerName = "GXS_id("+(*pit).toStdString() + ")" ; + if (peerName.empty()) + text += PeerDefs::rsid("", *pit); + else text += QString::fromUtf8(peerName.c_str()); - } } } else { std::cerr << "MessagesDialog::insertMsgTxtAndFiles() Couldn't find Msg" << std::endl; diff --git a/retroshare-gui/src/gui/RetroShareLink.cpp b/retroshare-gui/src/gui/RetroShareLink.cpp index 2bac249f0..fd302a833 100644 --- a/retroshare-gui/src/gui/RetroShareLink.cpp +++ b/retroshare-gui/src/gui/RetroShareLink.cpp @@ -565,7 +565,23 @@ bool RetroShareLink::createMessage(const RsPeerId& peerId, const QString& subjec return valid(); } +bool RetroShareLink::createMessage(const RsGxsId& peerId, const QString& subject) +{ + clear(); + _hash = QString::fromStdString(peerId.toStdString()); + + //PeerDefs::rsidFromId(peerId, &_name); + _name = QString::fromStdString("GXS_id("+peerId.toStdString()+")") ; + // do something better here!! + _subject = subject; + + _type = TYPE_MESSAGE; + + check(); + + return valid(); +} void RetroShareLink::clear() { _valid = false; @@ -1507,7 +1523,7 @@ static void processList(const QStringList &list, const QString &textSingular, co { if (detail.accept_connection || RsPeerId(detail.id) == rsPeers->getOwnId() || RsPgpId(detail.gpg_id) == rsPeers->getGPGOwnId()) { MessageComposer *msg = MessageComposer::newMsg(); - msg->addRecipient(MessageComposer::TO, detail.id, false); + msg->addRecipient(MessageComposer::TO, detail.id); if (link.subject().isEmpty() == false) { msg->setTitleText(link.subject()); } diff --git a/retroshare-gui/src/gui/RetroShareLink.h b/retroshare-gui/src/gui/RetroShareLink.h index 6c27d39a3..9f5e7a026 100644 --- a/retroshare-gui/src/gui/RetroShareLink.h +++ b/retroshare-gui/src/gui/RetroShareLink.h @@ -35,6 +35,7 @@ #include #include +#include #include #include @@ -79,7 +80,8 @@ class RetroShareLink bool createForum(const std::string& id, const std::string& msgId); bool createChannel(const std::string& id, const std::string& msgId); bool createSearch(const QString& keywords); - bool createMessage(const RsPeerId& peerId, const QString& subject); + bool createMessage(const RsPeerId &peerId, const QString& subject); + bool createMessage(const RsGxsId &peerId, const QString& subject); bool createCertificate(const RsPeerId &ssl_id) ; bool createPrivateChatInvite(time_t time_stamp,const QString& gpg_id,const QString& encrypted_chat_info) ; bool createPublicMsgInvite(time_t time_stamp,const QString& pgp_id,const QString& hash) ; diff --git a/retroshare-gui/src/gui/common/FriendList.cpp b/retroshare-gui/src/gui/common/FriendList.cpp index 6035fbac7..fd3519fe8 100644 --- a/retroshare-gui/src/gui/common/FriendList.cpp +++ b/retroshare-gui/src/gui/common/FriendList.cpp @@ -1312,7 +1312,7 @@ void FriendList::msgfriend() std::string id = getRsId(peer); - MessageComposer::msgFriend(RsPeerId(id), (peer->type() == TYPE_GROUP)); + MessageComposer::msgFriend(RsPeerId(id)) ; } void FriendList::recommendfriend() diff --git a/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp b/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp index fa9bc6cc6..64b42939d 100644 --- a/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp @@ -197,7 +197,7 @@ void ChatMsgItem::sendMsg() return; } - nMsgDialog->addRecipient(MessageComposer::TO, mPeerId, false); + nMsgDialog->addRecipient(MessageComposer::TO, mPeerId); nMsgDialog->show(); nMsgDialog->activateWindow(); @@ -245,7 +245,7 @@ void ChatMsgItem::sendMessage() mi.title = tr("Quick Message").toUtf8().constData(); mi.msg = quickmsgText->toHtml().toUtf8().constData(); - mi.msgto.push_back(mPeerId); + mi.rspeerid_msgto.push_back(mPeerId); rsMsgs->MessageSend(mi); diff --git a/retroshare-gui/src/gui/feeds/MsgItem.cpp b/retroshare-gui/src/gui/feeds/MsgItem.cpp index 85f75daa1..186a71748 100644 --- a/retroshare-gui/src/gui/feeds/MsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/MsgItem.cpp @@ -81,16 +81,16 @@ void MsgItem::updateItemStatic() return; /* get peer Id */ - mPeerId = mi.srcId; + mPeerId = mi.rspeerid_srcId; avatar->setId(mPeerId); QString title; QString srcName; - if ((mi.msgflags & RS_MSG_SYSTEM) && mi.srcId == rsPeers->getOwnId()) { + if ((mi.msgflags & RS_MSG_SYSTEM) && mi.rspeerid_srcId == rsPeers->getOwnId()) { srcName = "RetroShare"; } else { - srcName = QString::fromUtf8(rsPeers->getPeerName(mi.srcId).c_str()); + srcName = QString::fromUtf8(rsPeers->getPeerName(mi.rspeerid_srcId).c_str()); } timestampLabel->setText(DateTime::formatLongDateTime(mi.ts)); @@ -138,7 +138,7 @@ void MsgItem::updateItemStatic() for(it = mi.files.begin(); it != mi.files.end(); it++) { /* add file */ - SubFileItem *fi = new SubFileItem(it->hash, it->fname, it->path, it->size, SFI_STATE_REMOTE, mi.srcId); + SubFileItem *fi = new SubFileItem(it->hash, it->fname, it->path, it->size, SFI_STATE_REMOTE, mi.rspeerid_srcId); mFileItems.push_back(fi); QLayout *layout = expandFrame->layout(); diff --git a/retroshare-gui/src/gui/feeds/PeerItem.cpp b/retroshare-gui/src/gui/feeds/PeerItem.cpp index d391b8b90..37ebe4945 100644 --- a/retroshare-gui/src/gui/feeds/PeerItem.cpp +++ b/retroshare-gui/src/gui/feeds/PeerItem.cpp @@ -275,7 +275,7 @@ void PeerItem::sendMsg() return; } - nMsgDialog->addRecipient(MessageComposer::TO, mPeerId, false); + nMsgDialog->addRecipient(MessageComposer::TO, mPeerId); nMsgDialog->show(); nMsgDialog->activateWindow(); @@ -314,7 +314,7 @@ void PeerItem::sendMessage() mi.title = tr("Quick Message").toUtf8().constData(); mi.msg = quickmsgText->toHtml().toUtf8().constData(); - mi.msgto.push_back(mPeerId); + mi.rspeerid_msgto.push_back(mPeerId); rsMsgs->MessageSend(mi); diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index 5138f4770..5bf7cd117 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -74,9 +74,6 @@ #define COLOR_CONNECT Qt::blue -#define TYPE_GROUP 0 -#define TYPE_SSL 1 - #define COLUMN_RECIPIENT_TYPE 0 #define COLUMN_RECIPIENT_ICON 1 #define COLUMN_RECIPIENT_NAME 2 @@ -84,7 +81,7 @@ #define COLUMN_RECIPIENT_DATA COLUMN_RECIPIENT_ICON // the column with a QTableWidgetItem #define ROLE_RECIPIENT_ID Qt::UserRole -#define ROLE_RECIPIENT_GROUP Qt::UserRole + 1 +#define ROLE_RECIPIENT_TYPE Qt::UserRole + 1 #define COLUMN_FILE_CHECKED 0 #define COLUMN_FILE_NAME 0 @@ -373,18 +370,15 @@ void MessageComposer::processSettings(bool bLoad) if (pMsgDialog == NULL) return; - DistantMsgPeerId pid ; - rsMsgs->getDistantMessagePeerId(id,pid) ; - - pMsgDialog->addRecipient(TO, RsPeerId(pid), false); + pMsgDialog->addRecipient(TO, id); pMsgDialog->show(); /* window will destroy itself! */ } -/*static*/ void MessageComposer::msgFriend(const RsPeerId &id, bool group) +/*static*/ void MessageComposer::msgFriend(const RsPeerId &id) { -// std::cerr << "MessageComposer::msgfriend()" << std::endl; + // std::cerr << "MessageComposer::msgfriend()" << std::endl; /* create a message */ @@ -393,25 +387,10 @@ void MessageComposer::processSettings(bool bLoad) return; } - if (group) { - pMsgDialog->addRecipient(TO, id, true); - } else { - RsPeerDetails detail; - if (rsPeers->getPeerDetails(id, detail) && detail.accept_connection) + RsPeerDetails detail; + if (rsPeers->getPeerDetails(id, detail) && detail.accept_connection) { - // if (detail.isOnlyGPGdetail) { - // //put all sslChilds in message list - // std::list sslIds; - // rsPeers->getAssociatedSSLIds(id, sslIds); - // - // std::list::const_iterator it; - // for (it = sslIds.begin(); it != sslIds.end(); it++) { - // pMsgDialog->addRecipient(TO, *it, false); - // } - // } else { - pMsgDialog->addRecipient(TO, detail.id, false); - // } - } + pMsgDialog->addRecipient(TO, id); } pMsgDialog->show(); @@ -463,7 +442,7 @@ void MessageComposer::recommendFriend(const std::list &sslIds, const composer->msgFlags |= RS_MSG_FRIEND_RECOMMENDATION; if (!to.isNull()) { - composer->addRecipient(TO, to, false); + composer->addRecipient(TO, to); } RsPgpId ownPgpId = rsPeers->getGPGOwnId(); RetroShareLink link; @@ -482,7 +461,7 @@ void MessageComposer::recommendFriend(const std::list &sslIds, const if (*peerIt == to) { continue; } - composer->addRecipient(CC, *peerIt, false); + composer->addRecipient(CC, *peerIt); } if (autoSend) { @@ -686,15 +665,16 @@ void MessageComposer::peerStatusChanged(const QString& peer_id, int status) for (row = 0; row < rowCount; row++) { enumType type; + destinationType dtype ; std::string id; bool group; - if (getRecipientFromRow(row, type, id, group) && !id.empty() ) { - if (group == false && QString::fromStdString(id) == peer_id) { + if (getRecipientFromRow(row, type,dtype, id) && !id.empty() ) { + if (dtype == PEER_TYPE_SSL && QString::fromStdString(id) == peer_id) + { QTableWidgetItem *item = ui.recipientWidget->item(row, COLUMN_RECIPIENT_ICON); - if (item) { + if (item) item->setIcon(QIcon(StatusDefs::imageUser(status))); - } } } } @@ -895,38 +875,34 @@ MessageComposer *MessageComposer::newMsg(const std::string &msgId /* = ""*/) std::list groupIds; std::list::iterator groupIt; - std::list::iterator it; - // calculateGroupsOfSslIds(groupInfoList, msgInfo.msgto, groupIds); - // for (groupIt = groupIds.begin(); groupIt != groupIds.end(); groupIt++ ) { - // msgComposer->addRecipient(MessageComposer::TO, *groupIt, true) ; - // } - for (it = msgInfo.msgto.begin(); it != msgInfo.msgto.end(); it++ ) { - msgComposer->addRecipient(MessageComposer::TO, *it, false) ; - } + // calculateGroupsOfSslIds(groupInfoList, msgInfo.msgto, groupIds); + // for (groupIt = groupIds.begin(); groupIt != groupIds.end(); groupIt++ ) { + // msgComposer->addRecipient(MessageComposer::TO, *groupIt, true) ; + // } - // calculateGroupsOfSslIds(groupInfoList, msgInfo.msgcc, groupIds); - // for (groupIt = groupIds.begin(); groupIt != groupIds.end(); groupIt++ ) { - // msgComposer->addRecipient(MessageComposer::CC, *groupIt, true) ; - // } - for (it = msgInfo.msgcc.begin(); it != msgInfo.msgcc.end(); it++ ) { - msgComposer->addRecipient(MessageComposer::CC, *it, false) ; - } + // calculateGroupsOfSslIds(groupInfoList, msgInfo.msgcc, groupIds); + // for (groupIt = groupIds.begin(); groupIt != groupIds.end(); groupIt++ ) { + // msgComposer->addRecipient(MessageComposer::CC, *groupIt, true) ; + // } -// calculateGroupsOfSslIds(groupInfoList, msgInfo.msgbcc, groupIds); -// for (groupIt = groupIds.begin(); groupIt != groupIds.end(); groupIt++ ) { -// msgComposer->addRecipient(MessageComposer::BCC, *groupIt, true) ; -// } - for (it = msgInfo.msgbcc.begin(); it != msgInfo.msgbcc.end(); it++ ) { - msgComposer->addRecipient(MessageComposer::BCC, *it, false) ; - } + // calculateGroupsOfSslIds(groupInfoList, msgInfo.msgbcc, groupIds); + // for (groupIt = groupIds.begin(); groupIt != groupIds.end(); groupIt++ ) { + // msgComposer->addRecipient(MessageComposer::BCC, *groupIt, true) ; + // } + + for (std::list::const_iterator it = msgInfo.rspeerid_msgto.begin(); it != msgInfo.rspeerid_msgto.end(); it++ ) msgComposer->addRecipient(MessageComposer::TO, *it) ; + for (std::list::const_iterator it = msgInfo.rspeerid_msgcc.begin(); it != msgInfo.rspeerid_msgcc.end(); it++ ) msgComposer->addRecipient(MessageComposer::CC, *it) ; + for (std::list::const_iterator it = msgInfo.rspeerid_msgbcc.begin(); it != msgInfo.rspeerid_msgbcc.end(); it++ ) msgComposer->addRecipient(MessageComposer::BCC, *it) ; + for (std::list::const_iterator it = msgInfo.rsgxsid_msgto.begin(); it != msgInfo.rsgxsid_msgto.end(); it++ ) msgComposer->addRecipient(MessageComposer::TO, *it) ; + for (std::list::const_iterator it = msgInfo.rsgxsid_msgcc.begin(); it != msgInfo.rsgxsid_msgcc.end(); it++ ) msgComposer->addRecipient(MessageComposer::CC, *it) ; + for (std::list::const_iterator it = msgInfo.rsgxsid_msgbcc.begin(); it != msgInfo.rsgxsid_msgbcc.end(); it++ ) msgComposer->addRecipient(MessageComposer::BCC, *it) ; MsgTagInfo tagInfo; rsMsgs->getMessageTag(msgId, tagInfo); + msgComposer->m_tagIds = tagInfo.tagIds; - msgComposer->showTagLabels(); - msgComposer->ui.msgText->document()->setModified(false); } @@ -938,29 +914,44 @@ MessageComposer *MessageComposer::newMsg(const std::string &msgId /* = ""*/) QString MessageComposer::buildReplyHeader(const MessageInfo &msgInfo) { RetroShareLink link; - link.createMessage(msgInfo.srcId, ""); + link.createMessage(msgInfo.rspeerid_srcId, ""); QString from = link.toHtml(); QString to; - std::list::const_iterator it; - for (it = msgInfo.msgto.begin(); it != msgInfo.msgto.end(); it++) { - if (link.createMessage(*it, "")) { - if (!to.isEmpty()) { + for ( std::list::const_iterator it = msgInfo.rspeerid_msgto.begin(); it != msgInfo.rspeerid_msgto.end(); it++) + if (link.createMessage(*it, "")) + { + if (!to.isEmpty()) to += ", "; - } + to += link.toHtml(); } - } + for ( std::list::const_iterator it = msgInfo.rsgxsid_msgto.begin(); it != msgInfo.rsgxsid_msgto.end(); it++) + if (link.createMessage(*it, "")) + { + if (!to.isEmpty()) + to += ", "; + + to += link.toHtml(); + } + QString cc; - for (it = msgInfo.msgcc.begin(); it != msgInfo.msgcc.end(); it++) { + for (std::list::const_iterator it = msgInfo.rspeerid_msgcc.begin(); it != msgInfo.rspeerid_msgcc.end(); it++) if (link.createMessage(*it, "")) { if (!cc.isEmpty()) { cc += ", "; } cc += link.toHtml(); } - } + for (std::list::const_iterator it = msgInfo.rsgxsid_msgcc.begin(); it != msgInfo.rsgxsid_msgcc.end(); it++) + if (link.createMessage(*it, "")) { + if (!cc.isEmpty()) { + cc += ", "; + } + cc += link.toHtml(); + } + QString header = QString("-----%1-----").arg(tr("Original Message")); header += QString("
%1: %2
").arg(tr("From"), from); @@ -1033,22 +1024,28 @@ MessageComposer *MessageComposer::replyMsg(const std::string &msgId, bool all) msgComposer->setTitleText(QString::fromUtf8(msgInfo.title.c_str()), REPLY); msgComposer->setQuotedMsg(QString::fromUtf8(msgInfo.msg.c_str()), buildReplyHeader(msgInfo)); - msgComposer->addRecipient(MessageComposer::TO, msgInfo.srcId, false); + if(!msgInfo.rspeerid_srcId.isNull()) msgComposer->addRecipient(MessageComposer::TO, msgInfo.rspeerid_srcId); + if(!msgInfo.rsgxsid_srcId.isNull()) msgComposer->addRecipient(MessageComposer::TO, msgInfo.rsgxsid_srcId); - if (all) { + if (all) + { RsPeerId ownId = rsPeers->getOwnId(); - for (std::list::iterator tli = msgInfo.msgto.begin(); tli != msgInfo.msgto.end(); tli++) { - if (ownId != *tli) { - msgComposer->addRecipient(MessageComposer::TO, *tli, false) ; - } - } + for (std::list::iterator tli = msgInfo.rspeerid_msgto.begin(); tli != msgInfo.rspeerid_msgto.end(); tli++) + if (ownId != *tli) + msgComposer->addRecipient(MessageComposer::TO, *tli) ; - for (std::list::iterator tli = msgInfo.msgcc.begin(); tli != msgInfo.msgcc.end(); tli++) { - if (ownId != *tli) { - msgComposer->addRecipient(MessageComposer::TO, *tli, false) ; - } - } + for (std::list::iterator tli = msgInfo.rspeerid_msgcc.begin(); tli != msgInfo.rspeerid_msgcc.end(); tli++) + if (ownId != *tli) + msgComposer->addRecipient(MessageComposer::TO, *tli) ; + + for (std::list::iterator tli = msgInfo.rsgxsid_msgto.begin(); tli != msgInfo.rsgxsid_msgto.end(); tli++) + //if (ownId != *tli) + msgComposer->addRecipient(MessageComposer::TO, *tli) ; + + for (std::list::iterator tli = msgInfo.rsgxsid_msgcc.begin(); tli != msgInfo.rsgxsid_msgcc.end(); tli++) + //if (ownId != *tli) + msgComposer->addRecipient(MessageComposer::TO, *tli) ; } // needed to send system flags with reply @@ -1142,9 +1139,10 @@ void MessageComposer::sendMessage() } } +template void addUnique(std::list& lst,const T& t) { if(std::find(lst.begin(),lst.end(),t) == lst.end()) lst.push_back(t) ; } + bool MessageComposer::sendMessage_internal(bool bDraftbox) { -#ifdef SUSPENDED /* construct a message */ MessageInfo mi; @@ -1168,7 +1166,7 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox) for (int i = 0; i < filesCount; i++) { QTreeWidgetItem *item = ui.msgFileList->topLevelItem(i); if (item->checkState(COLUMN_FILE_CHECKED)) { - std::string hash = item->text(COLUMN_FILE_HASH).toStdString(); + RsFileHash hash ( item->text(COLUMN_FILE_HASH).toStdString() ); for(std::list::iterator it = _recList.begin(); it != _recList.end(); it++) { if (it->hash == hash) { mi.files.push_back(*it); @@ -1188,79 +1186,83 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox) int rowCount = ui.recipientWidget->rowCount(); int row; - for (row = 0; row < rowCount; row++) { + for (row = 0; row < rowCount; row++) + { enumType type; + destinationType dtype ; std::string id; bool group; - if (getRecipientFromRow(row, type, id, group) && !id.empty()) - { - if (group) { - RsGroupInfo groupInfo; - if (rsPeers->getGroupInfo(id, groupInfo) == false) { - // group not found - continue; - } + if (!getRecipientFromRow(row, type,dtype, id) || id.empty()) + continue ; - std::list::const_iterator groupIt; - for (groupIt = groupInfo.peerIds.begin(); groupIt != groupInfo.peerIds.end(); groupIt++) { - std::list sslIds; - rsPeers->getAssociatedSSLIds(*groupIt, sslIds); + switch(dtype) + { + case PEER_TYPE_GROUP: { + RsGroupInfo groupInfo; + if (rsPeers->getGroupInfo(id, groupInfo) == false) { + // group not found + continue; + } - std::list::const_iterator sslIt; - for (sslIt = sslIds.begin(); sslIt != sslIds.end(); sslIt++) { - if (std::find(peers.begin(), peers.end(), *sslIt) == peers.end()) { - // no friend - continue; - } + std::list::const_iterator groupIt; + for (groupIt = groupInfo.peerIds.begin(); groupIt != groupInfo.peerIds.end(); groupIt++) { + std::list sslIds; + rsPeers->getAssociatedSSLIds(*groupIt, sslIds); - switch (type) { - case TO: - if (std::find(mi.msgto.begin(), mi.msgto.end(), *sslIt) == mi.msgto.end()) { - mi.msgto.push_back(*sslIt); - } - break; - case CC: - if (std::find(mi.msgcc.begin(), mi.msgcc.end(), *sslIt) == mi.msgcc.end()) { - mi.msgcc.push_back(*sslIt); - } - break; - case BCC: - if (std::find(mi.msgbcc.begin(), mi.msgbcc.end(), *sslIt) == mi.msgbcc.end()) { - mi.msgbcc.push_back(*sslIt); - } - break; - } + std::list::const_iterator sslIt; + for (sslIt = sslIds.begin(); sslIt != sslIds.end(); sslIt++) { + if (std::find(peers.begin(), peers.end(), *sslIt) == peers.end()) { + // no friend + continue; } - } - } else { - if (_distant_peers.find(id)==_distant_peers.end() && std::find(peers.begin(), peers.end(), id) == peers.end()) { - // no friend - continue; - } - switch (type) { - case TO: - if (std::find(mi.msgto.begin(), mi.msgto.end(), id) == mi.msgto.end()) { - mi.msgto.push_back(id); - } + switch (type) + { + case TO: addUnique(mi.rspeerid_msgto,*sslIt); break; - case CC: - if (std::find(mi.msgcc.begin(), mi.msgcc.end(), id) == mi.msgcc.end()) { - mi.msgcc.push_back(id); - } + case CC: addUnique(mi.rspeerid_msgcc,*sslIt); break; - case BCC: - if (std::find(mi.msgbcc.begin(), mi.msgbcc.end(), id) == mi.msgbcc.end()) { - mi.msgbcc.push_back(id); - } + case BCC:addUnique(mi.rspeerid_msgbcc,*sslIt); break; + } } } } + break ; + case PEER_TYPE_SSL: + { + RsPeerId pid(id) ; + + switch (type) + { + case TO: addUnique(mi.rspeerid_msgto,pid); + case CC: addUnique(mi.rspeerid_msgcc,pid); + case BCC:addUnique(mi.rspeerid_msgbcc,pid); + } + } + break ; + case PEER_TYPE_GXS: + { + RsGxsId gid(id) ; + + switch (type) + { + case TO: addUnique(mi.rsgxsid_msgto,gid) ; + case CC: addUnique(mi.rsgxsid_msgcc,gid) ; + case BCC:addUnique(mi.rsgxsid_msgbcc,gid) ; + } + } + break ; + + default: + std::cerr << __PRETTY_FUNCTION__ << ": Unhandled desitnation type " << dtype << std::endl; + break ; + } } - if (bDraftbox) { + if (bDraftbox) + { mi.msgId = m_sDraftMsgId; rsMsgs->MessageToDraft(mi, m_msgParentId); @@ -1278,16 +1280,18 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox) rsMsgs->MessageForwarded(m_sDraftMsgId, true); break; } - } else { + } + else + { /* check for the recipient */ - if (mi.msgto.empty()) { + if (mi.rspeerid_msgto.empty() && mi.rspeerid_msgcc.empty() && mi.rspeerid_msgbcc.empty() + && mi.rsgxsid_msgto.empty() && mi.rsgxsid_msgcc.empty() && mi.rsgxsid_msgbcc.empty()) + { QMessageBox::warning(this, tr("RetroShare"), tr("Please insert at least one recipient."), QMessageBox::Ok); return false; // Don't send with no recipient } - mi.encryption_keys = _distant_peers ; - - if(ui.signMessage_CB->isChecked()) - mi.msgflags |= RS_MSG_SIGNED ; + if(ui.signMessage_CB->isChecked()) + mi.msgflags |= RS_MSG_SIGNED ; if (rsMsgs->MessageSend(mi) == false) { return false; @@ -1327,7 +1331,7 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox) } } ui.msgText->document()->setModified(false); -#endif + return true; } @@ -1353,10 +1357,10 @@ void MessageComposer::addEmptyRecipient() } } - setRecipientToRow(lastRow, TO,"", false); + setRecipientToRow(lastRow, TO,PEER_TYPE_SSL,""); } -bool MessageComposer::getRecipientFromRow(int row, enumType &type, std::string &id, bool &group) +bool MessageComposer::getRecipientFromRow(int row, enumType &type, destinationType& dest_type,std::string &id) { if (row >= ui.recipientWidget->rowCount()) { return false; @@ -1369,12 +1373,12 @@ bool MessageComposer::getRecipientFromRow(int row, enumType &type, std::string & type = (enumType) cb->itemData(cb->currentIndex(), Qt::UserRole).toInt(); id = ui.recipientWidget->item(row, COLUMN_RECIPIENT_DATA)->data(ROLE_RECIPIENT_ID).toString().toStdString(); - group = ui.recipientWidget->item(row, COLUMN_RECIPIENT_DATA)->data(ROLE_RECIPIENT_GROUP).toBool(); + dest_type = (destinationType)ui.recipientWidget->item(row, COLUMN_RECIPIENT_DATA)->data(ROLE_RECIPIENT_TYPE).toInt(); return true; } -void MessageComposer::setRecipientToRow(int row, enumType type, const std::string& id, bool group) +void MessageComposer::setRecipientToRow(int row, enumType type, destinationType dest_type, const std::string &id) { if (row + 1 > ui.recipientWidget->rowCount()) { ui.recipientWidget->setRowCount(row + 1); @@ -1410,9 +1414,10 @@ void MessageComposer::setRecipientToRow(int row, enumType type, const std::strin QIcon icon; QString name; if (!id.empty()) - { - if (group) - { + { + switch(dest_type) + { + case PEER_TYPE_GROUP: { icon = QIcon(IMAGE_GROUP16); RsGroupInfo groupInfo; @@ -1421,56 +1426,60 @@ void MessageComposer::setRecipientToRow(int row, enumType type, const std::strin } else { name = tr("Unknown"); } - } - else - { - RsPeerDetails details; + } + break ; - if(_distant_peers.find(DistantMsgPeerId(id)) != _distant_peers.end()) - { - RsIdentityDetails detail; + case PEER_TYPE_GXS: { - if(!rsIdentity->getIdDetails(_distant_peers[DistantMsgPeerId(id)], detail)) - { - std::cerr << "Can't get peer details from " << _distant_peers[DistantMsgPeerId(id)] << std::endl; - return ; - } + RsIdentityDetails detail; + RsGxsId gid(id) ; - name = tr("Distant peer (name: %2, PGP key: %1)").arg(QString::fromStdString(_distant_peers[DistantMsgPeerId(id)].toStdString())).arg(QString::fromStdString(detail.mNickname)) ; - icon = QIcon(StatusDefs::imageUser(RS_STATUS_ONLINE)); - } - else if(rsPeers->getPeerDetails(RsPeerId(id), details) && (!details.isOnlyGPGdetail)) - { - name = PeerDefs::nameWithLocation(details); + if(!rsIdentity->getIdDetails(gid, detail)) + { + std::cerr << "Can't get peer details from " << gid << std::endl; + return ; + } - StatusInfo peerStatusInfo; - // No check of return value. Non existing status info is handled as offline. - rsStatus->getStatus(RsPeerId(id), peerStatusInfo); + name = tr("Distant peer (name: %2, PGP key: %1)").arg(QString::fromStdString(gid.toStdString())).arg(QString::fromStdString(detail.mNickname)) ; + icon = QIcon(StatusDefs::imageUser(RS_STATUS_ONLINE)); + } + break ; - icon = QIcon(StatusDefs::imageUser(peerStatusInfo.status)); - } - else - { - icon = QIcon(StatusDefs::imageUser(RS_STATUS_OFFLINE)); - name = tr("Unknown friend"); - } - } + case PEER_TYPE_SSL: { + RsPeerDetails details ; + + if(!rsPeers->getPeerDetails(RsPeerId(id), details)) + { + std::cerr << "Can't get peer details from " << id << std::endl; + return ; + } + name = PeerDefs::nameWithLocation(details); + + StatusInfo peerStatusInfo; + // No check of return value. Non existing status info is handled as offline. + rsStatus->getStatus(RsPeerId(id), peerStatusInfo); + + icon = QIcon(StatusDefs::imageUser(peerStatusInfo.status)); + } + default: + std::cerr << __PRETTY_FUNCTION__ << ": Unhandled type " << dest_type << std::endl; + return ; + } } comboBox->setCurrentIndex(comboBox->findData(type, Qt::UserRole)); lineEdit->setText(name); - if (id.empty()) { + if (id.empty()) lineEdit->setStyleSheet(QString(STYLE_FAIL).arg(lineEdit->objectName())); - } else { + else lineEdit->setStyleSheet(QString(STYLE_NORMAL).arg(lineEdit->objectName())); - } QTableWidgetItem *item = new QTableWidgetItem(icon, "", 0); item->setFlags(Qt::NoItemFlags); ui.recipientWidget->setItem(row, COLUMN_RECIPIENT_ICON, item); ui.recipientWidget->item(row, COLUMN_RECIPIENT_DATA)->setData(ROLE_RECIPIENT_ID, QString::fromStdString(id)); - ui.recipientWidget->item(row, COLUMN_RECIPIENT_DATA)->setData(ROLE_RECIPIENT_GROUP, group); + ui.recipientWidget->item(row, COLUMN_RECIPIENT_DATA)->setData(ROLE_RECIPIENT_TYPE, dest_type); addEmptyRecipient(); } @@ -1537,13 +1546,14 @@ void MessageComposer::editingRecipientFinished() enumType type; std::string id; // dummy - bool group; // dummy - getRecipientFromRow(row, type, id, group); + destinationType dtype ; + + getRecipientFromRow(row, type, dtype, id); QString text = lineEdit->text(); if (text.isEmpty()) { - setRecipientToRow(row, type, "", false); + setRecipientToRow(row, type,PEER_TYPE_SSL, ""); return; } @@ -1561,7 +1571,7 @@ void MessageComposer::editingRecipientFinished() QString name = PeerDefs::nameWithLocation(details); if (text.compare(name, Qt::CaseSensitive) == 0) { // found it - setRecipientToRow(row, type, details.id.toStdString(), false); + setRecipientToRow(row, type, PEER_TYPE_SSL, details.id.toStdString()); return; } } @@ -1575,100 +1585,94 @@ void MessageComposer::editingRecipientFinished() QString groupName = GroupDefs::name(*groupIt); if (text.compare(groupName, Qt::CaseSensitive) == 0) { // found it - setRecipientToRow(row, type, groupIt->id, true); + setRecipientToRow(row, type, PEER_TYPE_GROUP, groupIt->id); return; } } - setRecipientToRow(row, type, "", false); + setRecipientToRow(row, type, PEER_TYPE_SSL, ""); lineEdit->setStyleSheet(QString(STYLE_FAIL).arg(lineEdit->objectName())); lineEdit->setText(text); } - -void MessageComposer::addRecipient(enumType type, const DistantMsgPeerId& pid,const RsGxsId& gxs_id) +void MessageComposer::addRecipient(enumType type, const RsPeerId& pid) { - _distant_peers[pid] = gxs_id ; + int rowCount = ui.recipientWidget->rowCount(); + int row; + for (row = 0; row < rowCount; row++) + { + enumType rowType; + std::string rowId; + destinationType dtype ; - int rowCount = ui.recipientWidget->rowCount(); - int row; - for (row = 0; row < rowCount; row++) - { - enumType rowType; - std::string rowId; - bool rowGroup; + if (getRecipientFromRow(row, rowType, dtype, rowId)) + { + if (rowId.empty()) // use row + break; - if (getRecipientFromRow(row, rowType, rowId, rowGroup) == true) - { - if (rowId.empty()) // use row - break; - - if (rowId == pid.toStdString() && rowType == type) // existing row - break; - } - else // use row - break; - } - - setRecipientToRow(row, type, pid.toStdString(), false); -} -void MessageComposer::addRecipient(enumType type, const RsPeerId &id, bool group) -{ - std::list sslIds; - if (group) { - sslIds.push_back(id); - } else { - // check for gpg id or ssl id - RsPeerDetails detail; - if (!rsPeers->getPeerDetails(id, detail)) { - return; + if (RsPeerId(rowId) == pid && rowType == type) // existing row + break; } - -// if (detail.isOnlyGPGdetail) -// { -// if( (!rsPeers->getAssociatedSSLIds(id, sslIds)) || sslIds.empty()) -// { -// std::string hash ; -// if(rsMsgs->getDistantMessageHash(id,hash)) -// addRecipient(type, hash, id); -// else -// { -// QMessageBox::warning(this,tr("PGP key unknown"),tr("You dont have the PGP key of the message sender. So you cannot respond!"),QMessageBox::Ok) ; -// return; -// } -// } -// } -// else { - sslIds.push_back(id); -// } + else // use row + break; } - std::list::const_iterator sslIt; - for (sslIt = sslIds.begin(); sslIt != sslIds.end(); sslIt++) { - // search existing or empty row - int rowCount = ui.recipientWidget->rowCount(); - int row; - for (row = 0; row < rowCount; row++) { - enumType rowType; - std::string rowId; - bool rowGroup; - if (getRecipientFromRow(row, rowType, rowId, rowGroup) == true) { - if (rowId.empty()) { - // use row - break; - } + setRecipientToRow(row, type, PEER_TYPE_SSL,pid.toStdString()); +} +void MessageComposer::addRecipient(enumType type, const RsGxsId& gxs_id) +{ + _distant_peers.insert(gxs_id) ; - if (rowId == (*sslIt).toStdString() && rowType == type && group == rowGroup) { - // existing row - break; - } - } else { + int rowCount = ui.recipientWidget->rowCount(); + int row; + for (row = 0; row < rowCount; row++) + { + enumType rowType; + std::string rowId; + destinationType dtype ; + + if (getRecipientFromRow(row, rowType, dtype, rowId)) + { + if (rowId.empty()) // use row + break; + + if (RsGxsId(rowId) == gxs_id && rowType == type) // existing row + break; + } + else // use row + break; + } + + setRecipientToRow(row, type, PEER_TYPE_GXS,gxs_id.toStdString()); +} +void MessageComposer::addRecipient(enumType type, const std::string& id) +{ + // search existing or empty row + int rowCount = ui.recipientWidget->rowCount(); + int row; + for (row = 0; row < rowCount; row++) { + enumType rowType; + std::string rowId; + destinationType dtype ; + bool rowGroup; + + if (getRecipientFromRow(row, rowType, dtype,rowId)) + { + if (rowId.empty()) { // use row break; } - } - setRecipientToRow(row, type, (*sslIt).toStdString(), group); + if (rowId == id && rowType == type && dtype == PEER_TYPE_GROUP) { + // existing row + break; + } + } else { + // use row + break; + } } + + setRecipientToRow(row, type, PEER_TYPE_GROUP, id); } void MessageComposer::setupFileActions() @@ -2304,29 +2308,24 @@ void MessageComposer::fileHashingFinished(QList hashedFiles) void MessageComposer::addContact(enumType type) { - // std::list ids; - // ui.friendSelectionWidget->selectedIds(ids,false); - // - // std::list::iterator idIt; - // for (idIt = ids.begin(); idIt != ids.end(); idIt++) { - // addRecipient(type, *idIt, true); - // } + // std::list ids; + // ui.friendSelectionWidget->selectedIds(ids,false); + // + // std::list::iterator idIt; + // for (idIt = ids.begin(); idIt != ids.end(); idIt++) { + // addRecipient(type, *idIt, true); + // } - std::list ids ; - ui.friendSelectionWidget->selectedIds(ids, true); - for (std::list::const_iterator idIt = ids.begin(); idIt != ids.end(); idIt++) { - addRecipient(type, *idIt, false); - } + std::list ids ; + ui.friendSelectionWidget->selectedIds(ids, true); + for (std::list::const_iterator idIt = ids.begin(); idIt != ids.end(); idIt++) { + addRecipient(type, *idIt); + } - std::list id2 ; - ui.friendSelectionWidget->selectedIds(id2, true); - for (std::list::const_iterator idIt = id2.begin(); idIt != id2.end(); idIt++) - { - DistantMsgPeerId pid ; - - if(rsMsgs->getDistantMessagePeerId(*idIt,pid)) - addRecipient(type, pid, *idIt); - } + std::list id2 ; + ui.friendSelectionWidget->selectedIds(id2, true); + for (std::list::const_iterator idIt = id2.begin(); idIt != id2.end(); idIt++) + addRecipient(type, *idIt); } void MessageComposer::toggleShowNonFriend(bool bValue) @@ -2355,21 +2354,23 @@ void MessageComposer::addBcc() void MessageComposer::addRecommend() { - std::list sslIds; - ui.friendSelectionWidget->selectedIds(sslIds, false); + std::list sslIds; + ui.friendSelectionWidget->selectedIds(sslIds, false); - if (sslIds.empty()) { - return; - } + std::list gxsIds ; + ui.friendSelectionWidget->selectedIds(gxsIds, true); - std::list ::iterator it; - for (it = sslIds.begin(); it != sslIds.end(); it++) { - addRecipient(CC, *it, false); - } + if (sslIds.empty() && gxsIds.empty()) + return; - QString text = buildRecommendHtml(sslIds); - ui.msgText->textCursor().insertHtml(text); - ui.msgText->setFocus(Qt::OtherFocusReason); + for(std::list ::iterator it = sslIds.begin(); it != sslIds.end(); it++) + addRecipient(CC, *it); + for (std::list::const_iterator it = gxsIds.begin(); it != gxsIds.end(); it++) + addRecipient(TO, *it); + + QString text = buildRecommendHtml(sslIds); + ui.msgText->textCursor().insertHtml(text); + ui.msgText->setFocus(Qt::OtherFocusReason); } void MessageComposer::friendDetails() diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.h b/retroshare-gui/src/gui/msgs/MessageComposer.h index 0dd04163a..c93680da8 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.h +++ b/retroshare-gui/src/gui/msgs/MessageComposer.h @@ -42,6 +42,7 @@ class MessageComposer : public QMainWindow public: enum enumType { TO, CC, BCC }; enum enumMessageType { NORMAL, REPLY, FORWARD }; + enum destinationType { PEER_TYPE_SSL, PEER_TYPE_GROUP, PEER_TYPE_GXS }; public: /** Default Constructor */ @@ -49,9 +50,9 @@ public: MessageComposer(QWidget *parent = 0, Qt::WindowFlags flags = 0); ~MessageComposer(); - static void msgFriend(const RsPeerId &id, bool group); - //static void msgDistantPeer(const std::string& hash,const std::string& pgp_id) ; + static void msgFriend(const RsPeerId &id); static void msgGxsIdentity(const RsGxsId& gxs_id) ; + static void msgGroup(const std::string& group_id) ; static QString recommendMessage(); static void recommendFriend(const std::list &sslIds, const RsPeerId &to = RsPeerId(), const QString &msg = "", bool autoSend = false); @@ -68,8 +69,9 @@ public: void setTitleText(const QString &title, enumMessageType type = NORMAL); void setQuotedMsg(const QString &msg, const QString &header); void setMsgText(const QString &msg, bool asHtml = false); - void addRecipient(enumType type, const RsPeerId &id, bool group); - void addRecipient(enumType type, const DistantMsgPeerId &pid, const RsGxsId &gxs_id) ; + void addRecipient(enumType type, const RsPeerId &id); + void addRecipient(enumType type, const RsGxsId &gxs_id) ; + void addRecipient(enumType type, const std::string& group_id) ; public slots: /* actions to take.... */ @@ -174,8 +176,8 @@ private: void calculateTitle(); void addEmptyRecipient(); - bool getRecipientFromRow(int row, enumType &type, std::string &id, bool &group); - void setRecipientToRow(int row, enumType type, const std::string &id, bool group); + bool getRecipientFromRow(int row, enumType &type, destinationType& dest_type, std::string &id); + void setRecipientToRow(int row, enumType type, destinationType dest_type,const std::string &id); void clearTagLabels(); void showTagLabels(); @@ -221,7 +223,7 @@ private: Ui::MessageComposer ui; std::list _recList ; - std::map _distant_peers ; // pairs (hash,gxs_id) + std::set _distant_peers ; // we keep a list of them, in order to know which peer is a GXS id. }; #endif diff --git a/retroshare-gui/src/gui/msgs/MessageWidget.cpp b/retroshare-gui/src/gui/msgs/MessageWidget.cpp index 7e772ef8f..ab44729c0 100644 --- a/retroshare-gui/src/gui/msgs/MessageWidget.cpp +++ b/retroshare-gui/src/gui/msgs/MessageWidget.cpp @@ -304,7 +304,7 @@ void MessageWidget::getcurrentrecommended() } std::list srcIds; - srcIds.push_back(msgInfo.srcId); + srcIds.push_back(msgInfo.rspeerid_srcId); QModelIndexList list = ui.msgList->selectionModel()->selectedIndexes(); @@ -353,7 +353,7 @@ void MessageWidget::getallrecommended() for(it = recList.begin(); it != recList.end(); it++) { std::cerr << "MessageWidget::getallrecommended() Calling File Request" << std::endl; std::list srcIds; - srcIds.push_back(msgInfo.srcId); + srcIds.push_back(msgInfo.rspeerid_srcId); rsFiles->FileRequest(it->fname, it->hash, it->size, "", RS_FILE_REQ_ANONYMOUS_ROUTING, srcIds); } } @@ -497,28 +497,23 @@ void MessageWidget::fill(const std::string &msgId) ui.msgList->insertTopLevelItems(0, items); /* iterate through the sources */ - std::list::const_iterator pit; - RetroShareLink link; QString text; - for(pit = msgInfo.msgto.begin(); pit != msgInfo.msgto.end(); pit++) { - if (link.createMessage(*pit, "")) { - text += link.toHtml() + " "; - } - } + for(std::list::const_iterator pit = msgInfo.rspeerid_msgto.begin(); pit != msgInfo.rspeerid_msgto.end(); pit++) if (link.createMessage(*pit, "")) text += link.toHtml() + " "; + for(std::list::const_iterator pit = msgInfo.rsgxsid_msgto.begin(); pit != msgInfo.rsgxsid_msgto.end(); pit++) if (link.createMessage(*pit, "")) text += link.toHtml() + " "; + ui.toText->setText(text); - if (msgInfo.msgcc.size() > 0) { + if (!msgInfo.rspeerid_msgcc.empty() || !msgInfo.rsgxsid_msgcc.empty()) + { ui.cclabel->setVisible(true); ui.ccText->setVisible(true); text.clear(); - for(pit = msgInfo.msgcc.begin(); pit != msgInfo.msgcc.end(); pit++) { - if (link.createMessage(*pit, "")) { - text += link.toHtml() + " "; - } - } + for(std::list::const_iterator pit = msgInfo.rspeerid_msgcc.begin(); pit != msgInfo.rspeerid_msgcc.end(); pit++) if (link.createMessage(*pit, "")) text += link.toHtml() + " "; + for(std::list::const_iterator pit = msgInfo.rsgxsid_msgcc.begin(); pit != msgInfo.rsgxsid_msgcc.end(); pit++) if (link.createMessage(*pit, "")) text += link.toHtml() + " "; + ui.ccText->setText(text); } else { ui.cclabel->setVisible(false); @@ -526,16 +521,15 @@ void MessageWidget::fill(const std::string &msgId) ui.ccText->clear(); } - if (msgInfo.msgbcc.size() > 0) { - ui.bcclabel->setVisible(true); - ui.bccText->setVisible(true); + if (!msgInfo.rspeerid_msgbcc.empty() || !msgInfo.rsgxsid_msgbcc.empty()) + { + ui.bcclabel->setVisible(true); + ui.bccText->setVisible(true); + + text.clear(); + for(std::list::const_iterator pit = msgInfo.rspeerid_msgbcc.begin(); pit != msgInfo.rspeerid_msgbcc.end(); pit++) if (link.createMessage(*pit, "")) text += link.toHtml() + " "; + for(std::list::const_iterator pit = msgInfo.rsgxsid_msgbcc.begin(); pit != msgInfo.rsgxsid_msgbcc.end(); pit++) if (link.createMessage(*pit, "")) text += link.toHtml() + " "; - text.clear(); - for(pit = msgInfo.msgbcc.begin(); pit != msgInfo.msgbcc.end(); pit++) { - if (link.createMessage(*pit, "")) { - text += link.toHtml() + " "; - } - } ui.bccText->setText(text); } else { ui.bcclabel->setVisible(false); @@ -552,11 +546,11 @@ void MessageWidget::fill(const std::string &msgId) // outgoing message are from me srcId = ownId; } else { - srcId = msgInfo.srcId; + srcId = msgInfo.rspeerid_srcId; } link.createMessage(srcId, ""); - if ((msgInfo.msgflags & RS_MSG_SYSTEM) && msgInfo.srcId == ownId) { + if ((msgInfo.msgflags & RS_MSG_SYSTEM) && msgInfo.rspeerid_srcId == ownId) { ui.fromText->setText("RetroShare"); } else { ui.fromText->setText(link.toHtml());