One step toward sending/receiving messages from both RsPeerId and GXSids

Backend side:
- MessageInfo now has lists of CC,TO and BCC for both RsPeerId and RsGxsId
- p3msgservice handles each type of destination accordingly, possibly encrypting/signing the message
- added new type RsTlvGxsIdSet
- removed virtual peers from p3msgservice (not needed anymore), and removed tunneling as well
Gui side:
- added GXS ids to message RetroShareLink
- messagecomposer now handles Group, RsPeerId and RsGxsIds.

Work in  progress. Does not fully work yet.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-IdCleaning@7184 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2014-03-16 22:19:26 +00:00
parent 8b096e0e15
commit 2c471b68ac
17 changed files with 532 additions and 552 deletions

View file

@ -93,28 +93,38 @@ typedef GRouterKeyIdType DistantMsgPeerId ;
class MessageInfo class MessageInfo
{ {
public: public:
MessageInfo() {} MessageInfo() {}
std::string msgId; std::string msgId;
RsPeerId srcId;
unsigned int msgflags; RsPeerId rspeerid_srcId;
RsGxsId rsgxsid_srcId;
std::list<RsPeerId> msgto; unsigned int msgflags;
std::list<RsPeerId> msgcc;
std::list<RsPeerId> msgbcc;
std::string title; // friend destinations
std::string msg; //
std::list<RsPeerId> rspeerid_msgto; // RsPeerId is used here for various purposes:
std::list<RsPeerId> rspeerid_msgcc; // - real peer ids which are actual friend locations
std::list<RsPeerId> rspeerid_msgbcc; // -
std::string attach_title; // distant peers
std::string attach_comment; //
std::list<FileInfo> files; std::list<RsGxsId> rsgxsid_msgto; // RsPeerId is used here for various purposes:
std::map<std::string,std::string> encryption_keys ; // for concerned ids only the public pgp key id to encrypt the message with. std::list<RsGxsId> rsgxsid_msgcc; // - real peer ids which are actual friend locations
int size; /* total of files */ std::list<RsGxsId> rsgxsid_msgbcc; // -
int count; /* file count */
int ts; std::string title;
std::string msg;
std::string attach_title;
std::string attach_comment;
std::list<FileInfo> files;
int size; /* total of files */
int count; /* file count */
int ts;
}; };
class MsgInfoSummary class MsgInfoSummary

View file

@ -1380,9 +1380,13 @@ void RsMsgItem::clear()
subject.clear(); subject.clear();
message.clear(); message.clear();
msgto.TlvClear(); rspeerid_msgto.TlvClear();
msgcc.TlvClear(); rspeerid_msgcc.TlvClear();
msgbcc.TlvClear(); rspeerid_msgbcc.TlvClear();
rsgxsid_msgto.TlvClear();
rsgxsid_msgcc.TlvClear();
rsgxsid_msgbcc.TlvClear();
attachment.TlvClear(); attachment.TlvClear();
} }
@ -1403,15 +1407,18 @@ std::ostream &RsMsgItem::print(std::ostream &out, uint16_t indent)
printIndent(out, int_Indent); printIndent(out, int_Indent);
out << "Message To: " << std::endl; 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); printIndent(out, int_Indent);
out << "Message CC: " << std::endl; 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); printIndent(out, int_Indent);
out << "Message BCC: " << std::endl; 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); printIndent(out, int_Indent);
std::string cnv_subject(subject.begin(), subject.end()); 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(subject);
s += GetTlvStringSize(message); s += GetTlvStringSize(message);
s += msgto.TlvSize(); s += rspeerid_msgto.TlvSize();
s += msgcc.TlvSize(); s += rspeerid_msgcc.TlvSize();
s += msgbcc.TlvSize(); s += rspeerid_msgbcc.TlvSize();
s += rsgxsid_msgto.TlvSize();
s += rsgxsid_msgcc.TlvSize();
s += rsgxsid_msgbcc.TlvSize();
s += attachment.TlvSize(); s += attachment.TlvSize();
if (m_bConfiguration) { 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_SUBJECT,subject);
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_MSG, message); ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_MSG, message);
ok &= msgto.SetTlv(data, tlvsize, &offset); ok &= rspeerid_msgto.SetTlv(data, tlvsize, &offset);
ok &= msgcc.SetTlv(data, tlvsize, &offset); ok &= rspeerid_msgcc.SetTlv(data, tlvsize, &offset);
ok &= msgbcc.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); 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_SUBJECT,item->subject);
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_MSG, item->message); 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->rspeerid_msgto.GetTlv(data, rssize, &offset);
ok &= item->msgbcc.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); ok &= item->attachment.GetTlv(data, rssize, &offset);
if (m_bConfiguration) { if (m_bConfiguration) {

View file

@ -458,11 +458,6 @@ class RsMsgItem: public RsMessageItem
public: public:
RsMsgItem() :RsMessageItem(RS_PKT_SUBTYPE_DEFAULT) {} 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 ~RsMsgItem() {}
virtual void clear(); virtual void clear();
@ -482,9 +477,13 @@ class RsMsgItem: public RsMessageItem
std::string subject; std::string subject;
std::string message; std::string message;
RsTlvPeerIdSet msgto; RsTlvPeerIdSet rspeerid_msgto;
RsTlvPeerIdSet msgcc; RsTlvPeerIdSet rspeerid_msgcc;
RsTlvPeerIdSet msgbcc; RsTlvPeerIdSet rspeerid_msgbcc;
RsTlvGxsIdSet rsgxsid_msgto;
RsTlvGxsIdSet rsgxsid_msgcc;
RsTlvGxsIdSet rsgxsid_msgbcc;
RsTlvFileSet attachment; RsTlvFileSet attachment;
}; };

View file

@ -212,6 +212,7 @@ const uint16_t TLV_TYPE_HASHSET = 0x1022;
const uint16_t TLV_TYPE_PGPIDSET = 0x1023; const uint16_t TLV_TYPE_PGPIDSET = 0x1023;
const uint16_t TLV_TYPE_RECOGNSET = 0x1024; const uint16_t TLV_TYPE_RECOGNSET = 0x1024;
const uint16_t TLV_TYPE_GXSIDSET = 0x1025;
const uint16_t TLV_TYPE_SERVICESET = 0x1030; const uint16_t TLV_TYPE_SERVICESET = 0x1030;

View file

@ -41,7 +41,7 @@
#include <serialiser/rstlvtypes.h> #include <serialiser/rstlvtypes.h>
#include <serialiser/rstlvbase.h> #include <serialiser/rstlvbase.h>
#include <serialiser/rsbaseserial.h> #include <serialiser/rsbaseserial.h>
#include <retroshare/rsgxsifacetypes.h>
//! A base class for all tlv items //! A base class for all tlv items
/*! This class is provided to allow the serialisation and deserialization of compund /*! This class is provided to allow the serialisation and deserialization of compund
@ -189,9 +189,10 @@ template<class ID_CLASS,uint32_t TLV_TYPE> class t_RsTlvIdSet: public RsTlvItem
std::list<ID_CLASS> ids ; std::list<ID_CLASS> ids ;
}; };
typedef t_RsTlvIdSet<RsPeerId,TLV_TYPE_PEERSET> RsTlvPeerIdSet ; typedef t_RsTlvIdSet<RsPeerId,TLV_TYPE_PEERSET> RsTlvPeerIdSet ;
typedef t_RsTlvIdSet<RsPgpId,TLV_TYPE_PGPIDSET> RsTlvPgpIdSet ; typedef t_RsTlvIdSet<RsPgpId,TLV_TYPE_PGPIDSET> RsTlvPgpIdSet ;
typedef t_RsTlvIdSet<Sha1CheckSum,TLV_TYPE_HASHSET> RsTlvHashSet ; typedef t_RsTlvIdSet<Sha1CheckSum,TLV_TYPE_HASHSET> RsTlvHashSet ;
typedef t_RsTlvIdSet<RsGxsId,TLV_TYPE_GXSIDSET> RsTlvGxsIdSet ;
class RsTlvServiceIdSet: public RsTlvItem class RsTlvServiceIdSet: public RsTlvItem
{ {

View file

@ -324,12 +324,11 @@ int p3MsgService::checkOutgoingMessages()
std::map<uint32_t, RsMsgItem *>::iterator mit; std::map<uint32_t, RsMsgItem *>::iterator mit;
for(mit = msgOutgoing.begin(); mit != msgOutgoing.end(); 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; continue;
}
/* find the certificate */ /* find the certificate */
RsPeerId pid = mit->second->PeerId(); RsPeerId pid = mit->second->PeerId();
bool tunnel_is_ok = false ; bool tunnel_is_ok = false ;
if(mit->second->msgFlags & RS_MSG_FLAGS_DISTANT) if(mit->second->msgFlags & RS_MSG_FLAGS_DISTANT)
@ -1034,47 +1033,34 @@ bool p3MsgService::MessageSend(MessageInfo &info)
{ {
std::list<RsPeerId>::const_iterator pit; std::list<RsPeerId>::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); RsMsgItem *msg = initMIRsMsg(info, *pit);
if (msg) if (msg)
{
sendMessage(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); RsMsgItem *msg = initMIRsMsg(info, *pit);
if (msg) if (msg)
{
sendMessage(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); RsMsgItem *msg = initMIRsMsg(info, *pit);
if (msg) if (msg)
{
sendMessage(msg); sendMessage(msg);
}
} }
/* send to ourselves as well */ /* send to ourselves as well */
RsMsgItem *msg = initMIRsMsg(info, mLinkMgr->getOwnId()); RsMsgItem *msg = initMIRsMsg(info, mLinkMgr->getOwnId());
if (msg) if (msg)
{ {
std::list<RsPgpId>::iterator it ; std::list<RsPgpId>::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] ;
if (msg->msgFlags & RS_MSG_FLAGS_SIGNED) if (msg->msgFlags & RS_MSG_FLAGS_SIGNED)
msg->msgFlags |= RS_MSG_FLAGS_SIGNATURE_CHECKS; // this is always true, since we are sending the message 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->subject = title;
msg->message = message; msg->message = message;
msg->msgto.ids.push_back(ownId); msg->rspeerid_msgto.ids.push_back(ownId);
processMsg(msg, true); processMsg(msg, true);
@ -1492,96 +1478,35 @@ void p3MsgService::initRsMI(RsMsgItem *msg, MessageInfo &mi)
mi.msgflags = 0; mi.msgflags = 0;
/* translate flags, if we sent it... outgoing */ /* 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) if (msg->msgFlags & RS_MSG_FLAGS_OUTGOING) mi.msgflags |= RS_MSG_OUTGOING;
mi.msgflags |= RS_MSG_SIGNED ; 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) if (msg->msgFlags & RS_MSG_FLAGS_SIGNED) mi.msgflags |= RS_MSG_SIGNED ;
mi.msgflags |= RS_MSG_SIGNATURE_CHECKS ; 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_ENCRYPTED) if (msg->msgFlags & RS_MSG_FLAGS_DECRYPTED) mi.msgflags |= RS_MSG_DECRYPTED ;
mi.msgflags |= RS_MSG_ENCRYPTED ; 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_DECRYPTED) if (msg->msgFlags & RS_MSG_FLAGS_REPLIED) mi.msgflags |= RS_MSG_REPLIED;
mi.msgflags |= RS_MSG_DECRYPTED ; 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_TRASH) 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;
mi.msgflags |= RS_MSG_TRASH; if (msg->msgFlags & RS_MSG_FLAGS_LOAD_EMBEDDED_IMAGES) mi.msgflags |= RS_MSG_LOAD_EMBEDDED_IMAGES;
}
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.ts = msg->sendTime;
mi.srcId = msg->PeerId(); mi.rspeerid_srcId = msg->PeerId();
{
//msg->msgId;
rs_sprintf(mi.msgId, "%lu", msg->msgId);
}
std::list<RsPeerId>::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(); mi.rsgxsid_msgto = msg->rsgxsid_msgto.ids ;
pit != msg->msgto.ids.end(); pit++) mi.rsgxsid_msgcc = msg->rsgxsid_msgcc.ids ;
{ mi.rsgxsid_msgbcc = msg->rsgxsid_msgbcc.ids ;
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.title = msg->subject; mi.title = msg->subject;
mi.msg = msg->message; mi.msg = msg->message;
@ -1592,9 +1517,7 @@ void p3MsgService::initRsMI(RsMsgItem *msg, MessageInfo &mi)
mi.count = 0; mi.count = 0;
mi.size = 0; mi.size = 0;
std::list<RsTlvFileItem>::iterator it; for(std::list<RsTlvFileItem>::iterator it = msg->attachment.items.begin(); it != msg->attachment.items.end(); it++)
for(it = msg->attachment.items.begin();
it != msg->attachment.items.end(); it++)
{ {
FileInfo fi; FileInfo fi;
fi.fname = RsDirUtil::getTopDir(it->name); fi.fname = RsDirUtil::getTopDir(it->name);
@ -1605,7 +1528,6 @@ void p3MsgService::initRsMI(RsMsgItem *msg, MessageInfo &mi)
mi.count++; mi.count++;
mi.size += fi.size; mi.size += fi.size;
} }
} }
void p3MsgService::initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis) void p3MsgService::initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis)
@ -1687,50 +1609,33 @@ void p3MsgService::initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis)
mis.ts = msg->sendTime; 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 -> msgFlags = 0;
msg -> msgId = 0; msg -> msgId = 0;
msg -> sendTime = time(NULL); msg -> sendTime = time(NULL);
msg -> recvTime = 0; msg -> recvTime = 0;
msg -> subject = info.title; 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<RsPeerId>::iterator pit; msg->rsgxsid_msgto.ids = info.rsgxsid_msgto ;
for(pit = info.msgto.begin(); pit != info.msgto.end(); pit++) msg->rsgxsid_msgcc.ids = info.rsgxsid_msgcc ;
{
msg -> msgto.ids.push_back(*pit);
}
for(pit = info.msgcc.begin(); pit != info.msgcc.end(); pit++)
{
msg -> msgcc.ids.push_back(*pit);
}
/* We don't fill in bcc (unless to ourselves) */ /* 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->rsgxsid_msgbcc.ids = info.rsgxsid_msgbcc ;
{ msg->rspeerid_msgbcc.ids = info.rspeerid_msgbcc ;
msg -> msgbcc.ids.push_back(*pit);
}
} }
msg -> attachment.title = info.attach_title; msg -> attachment.title = info.attach_title;
msg -> attachment.comment = info.attach_comment; msg -> attachment.comment = info.attach_comment;
RsPeerDetails details ; for(std::list<FileInfo>::const_iterator it = info.files.begin(); it != info.files.end(); it++)
if(!rsPeers->getPeerDetails(to,details))
msg->msgFlags |= RS_MSG_FLAGS_DISTANT;
std::list<FileInfo>::iterator it;
for(it = info.files.begin(); it != info.files.end(); it++)
{ {
RsTlvFileItem mfi; RsTlvFileItem mfi;
mfi.hash = it -> hash; mfi.hash = it -> hash;
@ -1738,32 +1643,45 @@ RsMsgItem *p3MsgService::initMIRsMsg(MessageInfo &info, const RsPeerId &to)
mfi.filesize = it -> size; mfi.filesize = it -> size;
msg -> attachment.items.push_back(mfi); msg -> attachment.items.push_back(mfi);
} }
/* translate flags from outside */ /* translate flags from outside */
if (info.msgflags & RS_MSG_USER_REQUEST) if (info.msgflags & RS_MSG_USER_REQUEST)
msg->msgFlags |= RS_MSG_FLAGS_USER_REQUEST; msg->msgFlags |= RS_MSG_FLAGS_USER_REQUEST;
if (info.msgflags & RS_MSG_FRIEND_RECOMMENDATION) if (info.msgflags & RS_MSG_FRIEND_RECOMMENDATION)
msg->msgFlags |= RS_MSG_FLAGS_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) if (info.msgflags & RS_MSG_SIGNED)
msg->msgFlags |= RS_MSG_FLAGS_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 // 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 // by the whole message serialized and binary encrypted, so as to obfuscate
// all its content. // all its content.
// //
createDistantMessage(to,info.rsgxsid_srcId,msg) ;
if(!info.encryption_keys.empty()) return msg ;
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) ; 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; return msg;
} }
@ -1892,9 +1810,12 @@ bool p3MsgService::createDistantMessage(const RsGxsId& destination_gxs_id,const
item->message = armoured_data ; item->message = armoured_data ;
item->subject = "" ; item->subject = "" ;
item->msgcc.ids.clear() ; item->rspeerid_msgcc.ids.clear() ;
item->msgbcc.ids.clear() ; item->rspeerid_msgbcc.ids.clear() ;
item->msgto.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->msgFlags |= RS_MSG_FLAGS_ENCRYPTED ;
item->attachment.TlvClear() ; item->attachment.TlvClear() ;

View file

@ -163,19 +163,22 @@ int checkOutgoingMessages();
p3GRouter *mGRouter ; p3GRouter *mGRouter ;
#endif #endif
uint32_t getNewUniqueMsgId(); uint32_t getNewUniqueMsgId();
int sendMessage(RsMsgItem *item); int sendMessage(RsMsgItem *item);
void checkSizeAndSendMessage(RsMsgItem *msg); void checkSizeAndSendMessage(RsMsgItem *msg);
int incomingMsgs(); int incomingMsgs();
void processMsg(RsMsgItem *mi, bool incoming); void processMsg(RsMsgItem *mi, bool incoming);
bool checkAndRebuildPartialMessage(RsMsgItem*) ; bool checkAndRebuildPartialMessage(RsMsgItem*) ;
void initRsMI(RsMsgItem *msg, MessageInfo &mi); void initRsMI(RsMsgItem *msg, MessageInfo &mi);
void initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis); void initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis);
RsMsgItem *initMIRsMsg(MessageInfo &info, const RsPeerId &to);
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; p3LinkMgr *mLinkMgr;

View file

@ -1114,19 +1114,28 @@ void MessagesDialog::insertMessages()
text.clear(); text.clear();
std::list<RsPeerId>::const_iterator pit; for(std::list<RsPeerId>::const_iterator pit = msgInfo.rspeerid_msgto.begin(); pit != msgInfo.rspeerid_msgto.end(); pit++)
for (pit = msgInfo.msgto.begin(); pit != msgInfo.msgto.end(); pit++)
{ {
if (text.isEmpty() == false) { if (!text.isEmpty())
text += ", "; text += ", ";
}
std::string peerName = rsPeers->getPeerName(*pit); std::string peerName = rsPeers->getPeerName(*pit);
if (peerName.empty()) { if (peerName.empty())
text += PeerDefs::rsid("", *pit); text += PeerDefs::rsid("", *pit);
} else { else
text += QString::fromUtf8(peerName.c_str());
}
for(std::list<RsGxsId>::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()); text += QString::fromUtf8(peerName.c_str());
}
} }
} else { } else {
std::cerr << "MessagesDialog::insertMsgTxtAndFiles() Couldn't find Msg" << std::endl; std::cerr << "MessagesDialog::insertMsgTxtAndFiles() Couldn't find Msg" << std::endl;

View file

@ -565,7 +565,23 @@ bool RetroShareLink::createMessage(const RsPeerId& peerId, const QString& subjec
return valid(); 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() void RetroShareLink::clear()
{ {
_valid = false; _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()) { if (detail.accept_connection || RsPeerId(detail.id) == rsPeers->getOwnId() || RsPgpId(detail.gpg_id) == rsPeers->getGPGOwnId()) {
MessageComposer *msg = MessageComposer::newMsg(); MessageComposer *msg = MessageComposer::newMsg();
msg->addRecipient(MessageComposer::TO, detail.id, false); msg->addRecipient(MessageComposer::TO, detail.id);
if (link.subject().isEmpty() == false) { if (link.subject().isEmpty() == false) {
msg->setTitleText(link.subject()); msg->setTitleText(link.subject());
} }

View file

@ -35,6 +35,7 @@
#include <stdint.h> #include <stdint.h>
#include <retroshare/rstypes.h> #include <retroshare/rstypes.h>
#include <retroshare/rsgxsifacetypes.h>
#include <QString> #include <QString>
#include <QVector> #include <QVector>
@ -79,7 +80,8 @@ class RetroShareLink
bool createForum(const std::string& id, const std::string& msgId); bool createForum(const std::string& id, const std::string& msgId);
bool createChannel(const std::string& id, const std::string& msgId); bool createChannel(const std::string& id, const std::string& msgId);
bool createSearch(const QString& keywords); 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 createCertificate(const RsPeerId &ssl_id) ;
bool createPrivateChatInvite(time_t time_stamp,const QString& gpg_id,const QString& encrypted_chat_info) ; 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) ; bool createPublicMsgInvite(time_t time_stamp,const QString& pgp_id,const QString& hash) ;

View file

@ -1312,7 +1312,7 @@ void FriendList::msgfriend()
std::string id = getRsId(peer); std::string id = getRsId(peer);
MessageComposer::msgFriend(RsPeerId(id), (peer->type() == TYPE_GROUP)); MessageComposer::msgFriend(RsPeerId(id)) ;
} }
void FriendList::recommendfriend() void FriendList::recommendfriend()

View file

@ -197,7 +197,7 @@ void ChatMsgItem::sendMsg()
return; return;
} }
nMsgDialog->addRecipient(MessageComposer::TO, mPeerId, false); nMsgDialog->addRecipient(MessageComposer::TO, mPeerId);
nMsgDialog->show(); nMsgDialog->show();
nMsgDialog->activateWindow(); nMsgDialog->activateWindow();
@ -245,7 +245,7 @@ void ChatMsgItem::sendMessage()
mi.title = tr("Quick Message").toUtf8().constData(); mi.title = tr("Quick Message").toUtf8().constData();
mi.msg = quickmsgText->toHtml().toUtf8().constData(); mi.msg = quickmsgText->toHtml().toUtf8().constData();
mi.msgto.push_back(mPeerId); mi.rspeerid_msgto.push_back(mPeerId);
rsMsgs->MessageSend(mi); rsMsgs->MessageSend(mi);

View file

@ -81,16 +81,16 @@ void MsgItem::updateItemStatic()
return; return;
/* get peer Id */ /* get peer Id */
mPeerId = mi.srcId; mPeerId = mi.rspeerid_srcId;
avatar->setId(mPeerId); avatar->setId(mPeerId);
QString title; QString title;
QString srcName; 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"; srcName = "RetroShare";
} else { } 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)); timestampLabel->setText(DateTime::formatLongDateTime(mi.ts));
@ -138,7 +138,7 @@ void MsgItem::updateItemStatic()
for(it = mi.files.begin(); it != mi.files.end(); it++) for(it = mi.files.begin(); it != mi.files.end(); it++)
{ {
/* add file */ /* 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); mFileItems.push_back(fi);
QLayout *layout = expandFrame->layout(); QLayout *layout = expandFrame->layout();

View file

@ -275,7 +275,7 @@ void PeerItem::sendMsg()
return; return;
} }
nMsgDialog->addRecipient(MessageComposer::TO, mPeerId, false); nMsgDialog->addRecipient(MessageComposer::TO, mPeerId);
nMsgDialog->show(); nMsgDialog->show();
nMsgDialog->activateWindow(); nMsgDialog->activateWindow();
@ -314,7 +314,7 @@ void PeerItem::sendMessage()
mi.title = tr("Quick Message").toUtf8().constData(); mi.title = tr("Quick Message").toUtf8().constData();
mi.msg = quickmsgText->toHtml().toUtf8().constData(); mi.msg = quickmsgText->toHtml().toUtf8().constData();
mi.msgto.push_back(mPeerId); mi.rspeerid_msgto.push_back(mPeerId);
rsMsgs->MessageSend(mi); rsMsgs->MessageSend(mi);

View file

@ -74,9 +74,6 @@
#define COLOR_CONNECT Qt::blue #define COLOR_CONNECT Qt::blue
#define TYPE_GROUP 0
#define TYPE_SSL 1
#define COLUMN_RECIPIENT_TYPE 0 #define COLUMN_RECIPIENT_TYPE 0
#define COLUMN_RECIPIENT_ICON 1 #define COLUMN_RECIPIENT_ICON 1
#define COLUMN_RECIPIENT_NAME 2 #define COLUMN_RECIPIENT_NAME 2
@ -84,7 +81,7 @@
#define COLUMN_RECIPIENT_DATA COLUMN_RECIPIENT_ICON // the column with a QTableWidgetItem #define COLUMN_RECIPIENT_DATA COLUMN_RECIPIENT_ICON // the column with a QTableWidgetItem
#define ROLE_RECIPIENT_ID Qt::UserRole #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_CHECKED 0
#define COLUMN_FILE_NAME 0 #define COLUMN_FILE_NAME 0
@ -373,18 +370,15 @@ void MessageComposer::processSettings(bool bLoad)
if (pMsgDialog == NULL) if (pMsgDialog == NULL)
return; return;
DistantMsgPeerId pid ; pMsgDialog->addRecipient(TO, id);
rsMsgs->getDistantMessagePeerId(id,pid) ;
pMsgDialog->addRecipient(TO, RsPeerId(pid), false);
pMsgDialog->show(); pMsgDialog->show();
/* window will destroy itself! */ /* 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 */ /* create a message */
@ -393,25 +387,10 @@ void MessageComposer::processSettings(bool bLoad)
return; return;
} }
if (group) { RsPeerDetails detail;
pMsgDialog->addRecipient(TO, id, true); if (rsPeers->getPeerDetails(id, detail) && detail.accept_connection)
} else {
RsPeerDetails detail;
if (rsPeers->getPeerDetails(id, detail) && detail.accept_connection)
{ {
// if (detail.isOnlyGPGdetail) { pMsgDialog->addRecipient(TO, id);
// //put all sslChilds in message list
// std::list<RsPeerId> sslIds;
// rsPeers->getAssociatedSSLIds(id, sslIds);
//
// std::list<RsPeerId>::const_iterator it;
// for (it = sslIds.begin(); it != sslIds.end(); it++) {
// pMsgDialog->addRecipient(TO, *it, false);
// }
// } else {
pMsgDialog->addRecipient(TO, detail.id, false);
// }
}
} }
pMsgDialog->show(); pMsgDialog->show();
@ -463,7 +442,7 @@ void MessageComposer::recommendFriend(const std::list <RsPeerId> &sslIds, const
composer->msgFlags |= RS_MSG_FRIEND_RECOMMENDATION; composer->msgFlags |= RS_MSG_FRIEND_RECOMMENDATION;
if (!to.isNull()) { if (!to.isNull()) {
composer->addRecipient(TO, to, false); composer->addRecipient(TO, to);
} }
RsPgpId ownPgpId = rsPeers->getGPGOwnId(); RsPgpId ownPgpId = rsPeers->getGPGOwnId();
RetroShareLink link; RetroShareLink link;
@ -482,7 +461,7 @@ void MessageComposer::recommendFriend(const std::list <RsPeerId> &sslIds, const
if (*peerIt == to) { if (*peerIt == to) {
continue; continue;
} }
composer->addRecipient(CC, *peerIt, false); composer->addRecipient(CC, *peerIt);
} }
if (autoSend) { if (autoSend) {
@ -686,15 +665,16 @@ void MessageComposer::peerStatusChanged(const QString& peer_id, int status)
for (row = 0; row < rowCount; row++) { for (row = 0; row < rowCount; row++) {
enumType type; enumType type;
destinationType dtype ;
std::string id; std::string id;
bool group; bool group;
if (getRecipientFromRow(row, type, id, group) && !id.empty() ) { if (getRecipientFromRow(row, type,dtype, id) && !id.empty() ) {
if (group == false && QString::fromStdString(id) == peer_id) { if (dtype == PEER_TYPE_SSL && QString::fromStdString(id) == peer_id)
{
QTableWidgetItem *item = ui.recipientWidget->item(row, COLUMN_RECIPIENT_ICON); QTableWidgetItem *item = ui.recipientWidget->item(row, COLUMN_RECIPIENT_ICON);
if (item) { if (item)
item->setIcon(QIcon(StatusDefs::imageUser(status))); item->setIcon(QIcon(StatusDefs::imageUser(status)));
}
} }
} }
} }
@ -895,38 +875,34 @@ MessageComposer *MessageComposer::newMsg(const std::string &msgId /* = ""*/)
std::list<std::string> groupIds; std::list<std::string> groupIds;
std::list<std::string>::iterator groupIt; std::list<std::string>::iterator groupIt;
std::list<RsPeerId>::iterator it;
// calculateGroupsOfSslIds(groupInfoList, msgInfo.msgto, groupIds); // calculateGroupsOfSslIds(groupInfoList, msgInfo.msgto, groupIds);
// for (groupIt = groupIds.begin(); groupIt != groupIds.end(); groupIt++ ) { // for (groupIt = groupIds.begin(); groupIt != groupIds.end(); groupIt++ ) {
// msgComposer->addRecipient(MessageComposer::TO, *groupIt, true) ; // 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.msgcc, groupIds); // calculateGroupsOfSslIds(groupInfoList, msgInfo.msgcc, groupIds);
// for (groupIt = groupIds.begin(); groupIt != groupIds.end(); groupIt++ ) { // for (groupIt = groupIds.begin(); groupIt != groupIds.end(); groupIt++ ) {
// msgComposer->addRecipient(MessageComposer::CC, *groupIt, true) ; // 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.msgbcc, groupIds); // calculateGroupsOfSslIds(groupInfoList, msgInfo.msgbcc, groupIds);
// for (groupIt = groupIds.begin(); groupIt != groupIds.end(); groupIt++ ) { // for (groupIt = groupIds.begin(); groupIt != groupIds.end(); groupIt++ ) {
// msgComposer->addRecipient(MessageComposer::BCC, *groupIt, true) ; // msgComposer->addRecipient(MessageComposer::BCC, *groupIt, true) ;
// } // }
for (it = msgInfo.msgbcc.begin(); it != msgInfo.msgbcc.end(); it++ ) {
msgComposer->addRecipient(MessageComposer::BCC, *it, false) ; for (std::list<RsPeerId>::const_iterator it = msgInfo.rspeerid_msgto.begin(); it != msgInfo.rspeerid_msgto.end(); it++ ) msgComposer->addRecipient(MessageComposer::TO, *it) ;
} for (std::list<RsPeerId>::const_iterator it = msgInfo.rspeerid_msgcc.begin(); it != msgInfo.rspeerid_msgcc.end(); it++ ) msgComposer->addRecipient(MessageComposer::CC, *it) ;
for (std::list<RsPeerId>::const_iterator it = msgInfo.rspeerid_msgbcc.begin(); it != msgInfo.rspeerid_msgbcc.end(); it++ ) msgComposer->addRecipient(MessageComposer::BCC, *it) ;
for (std::list<RsGxsId>::const_iterator it = msgInfo.rsgxsid_msgto.begin(); it != msgInfo.rsgxsid_msgto.end(); it++ ) msgComposer->addRecipient(MessageComposer::TO, *it) ;
for (std::list<RsGxsId>::const_iterator it = msgInfo.rsgxsid_msgcc.begin(); it != msgInfo.rsgxsid_msgcc.end(); it++ ) msgComposer->addRecipient(MessageComposer::CC, *it) ;
for (std::list<RsGxsId>::const_iterator it = msgInfo.rsgxsid_msgbcc.begin(); it != msgInfo.rsgxsid_msgbcc.end(); it++ ) msgComposer->addRecipient(MessageComposer::BCC, *it) ;
MsgTagInfo tagInfo; MsgTagInfo tagInfo;
rsMsgs->getMessageTag(msgId, tagInfo); rsMsgs->getMessageTag(msgId, tagInfo);
msgComposer->m_tagIds = tagInfo.tagIds; msgComposer->m_tagIds = tagInfo.tagIds;
msgComposer->showTagLabels(); msgComposer->showTagLabels();
msgComposer->ui.msgText->document()->setModified(false); msgComposer->ui.msgText->document()->setModified(false);
} }
@ -938,29 +914,44 @@ MessageComposer *MessageComposer::newMsg(const std::string &msgId /* = ""*/)
QString MessageComposer::buildReplyHeader(const MessageInfo &msgInfo) QString MessageComposer::buildReplyHeader(const MessageInfo &msgInfo)
{ {
RetroShareLink link; RetroShareLink link;
link.createMessage(msgInfo.srcId, ""); link.createMessage(msgInfo.rspeerid_srcId, "");
QString from = link.toHtml(); QString from = link.toHtml();
QString to; QString to;
std::list<RsPeerId>::const_iterator it; for ( std::list<RsPeerId>::const_iterator it = msgInfo.rspeerid_msgto.begin(); it != msgInfo.rspeerid_msgto.end(); it++)
for (it = msgInfo.msgto.begin(); it != msgInfo.msgto.end(); it++) { if (link.createMessage(*it, ""))
if (link.createMessage(*it, "")) { {
if (!to.isEmpty()) { if (!to.isEmpty())
to += ", "; to += ", ";
}
to += link.toHtml(); to += link.toHtml();
} }
} for ( std::list<RsGxsId>::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; QString cc;
for (it = msgInfo.msgcc.begin(); it != msgInfo.msgcc.end(); it++) { for (std::list<RsPeerId>::const_iterator it = msgInfo.rspeerid_msgcc.begin(); it != msgInfo.rspeerid_msgcc.end(); it++)
if (link.createMessage(*it, "")) { if (link.createMessage(*it, "")) {
if (!cc.isEmpty()) { if (!cc.isEmpty()) {
cc += ", "; cc += ", ";
} }
cc += link.toHtml(); cc += link.toHtml();
} }
} for (std::list<RsGxsId>::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("<span>-----%1-----").arg(tr("Original Message")); QString header = QString("<span>-----%1-----").arg(tr("Original Message"));
header += QString("<br><font size='3'><strong>%1: </strong>%2</font><br>").arg(tr("From"), from); header += QString("<br><font size='3'><strong>%1: </strong>%2</font><br>").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->setTitleText(QString::fromUtf8(msgInfo.title.c_str()), REPLY);
msgComposer->setQuotedMsg(QString::fromUtf8(msgInfo.msg.c_str()), buildReplyHeader(msgInfo)); 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(); RsPeerId ownId = rsPeers->getOwnId();
for (std::list<RsPeerId>::iterator tli = msgInfo.msgto.begin(); tli != msgInfo.msgto.end(); tli++) { for (std::list<RsPeerId>::iterator tli = msgInfo.rspeerid_msgto.begin(); tli != msgInfo.rspeerid_msgto.end(); tli++)
if (ownId != *tli) { if (ownId != *tli)
msgComposer->addRecipient(MessageComposer::TO, *tli, false) ; msgComposer->addRecipient(MessageComposer::TO, *tli) ;
}
}
for (std::list<RsPeerId>::iterator tli = msgInfo.msgcc.begin(); tli != msgInfo.msgcc.end(); tli++) { for (std::list<RsPeerId>::iterator tli = msgInfo.rspeerid_msgcc.begin(); tli != msgInfo.rspeerid_msgcc.end(); tli++)
if (ownId != *tli) { if (ownId != *tli)
msgComposer->addRecipient(MessageComposer::TO, *tli, false) ; msgComposer->addRecipient(MessageComposer::TO, *tli) ;
}
} for (std::list<RsGxsId>::iterator tli = msgInfo.rsgxsid_msgto.begin(); tli != msgInfo.rsgxsid_msgto.end(); tli++)
//if (ownId != *tli)
msgComposer->addRecipient(MessageComposer::TO, *tli) ;
for (std::list<RsGxsId>::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 // needed to send system flags with reply
@ -1142,9 +1139,10 @@ void MessageComposer::sendMessage()
} }
} }
template<class T> void addUnique(std::list<T>& lst,const T& t) { if(std::find(lst.begin(),lst.end(),t) == lst.end()) lst.push_back(t) ; }
bool MessageComposer::sendMessage_internal(bool bDraftbox) bool MessageComposer::sendMessage_internal(bool bDraftbox)
{ {
#ifdef SUSPENDED
/* construct a message */ /* construct a message */
MessageInfo mi; MessageInfo mi;
@ -1168,7 +1166,7 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox)
for (int i = 0; i < filesCount; i++) { for (int i = 0; i < filesCount; i++) {
QTreeWidgetItem *item = ui.msgFileList->topLevelItem(i); QTreeWidgetItem *item = ui.msgFileList->topLevelItem(i);
if (item->checkState(COLUMN_FILE_CHECKED)) { 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<FileInfo>::iterator it = _recList.begin(); it != _recList.end(); it++) { for(std::list<FileInfo>::iterator it = _recList.begin(); it != _recList.end(); it++) {
if (it->hash == hash) { if (it->hash == hash) {
mi.files.push_back(*it); mi.files.push_back(*it);
@ -1188,79 +1186,83 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox)
int rowCount = ui.recipientWidget->rowCount(); int rowCount = ui.recipientWidget->rowCount();
int row; int row;
for (row = 0; row < rowCount; row++) { for (row = 0; row < rowCount; row++)
{
enumType type; enumType type;
destinationType dtype ;
std::string id; std::string id;
bool group; bool group;
if (getRecipientFromRow(row, type, id, group) && !id.empty()) if (!getRecipientFromRow(row, type,dtype, id) || id.empty())
{ continue ;
if (group) {
RsGroupInfo groupInfo;
if (rsPeers->getGroupInfo(id, groupInfo) == false) {
// group not found
continue;
}
std::list<std::string>::const_iterator groupIt; switch(dtype)
for (groupIt = groupInfo.peerIds.begin(); groupIt != groupInfo.peerIds.end(); groupIt++) { {
std::list<RsPeerId> sslIds; case PEER_TYPE_GROUP: {
rsPeers->getAssociatedSSLIds(*groupIt, sslIds); RsGroupInfo groupInfo;
if (rsPeers->getGroupInfo(id, groupInfo) == false) {
// group not found
continue;
}
std::list<RsPeerId>::const_iterator sslIt; std::list<RsPgpId>::const_iterator groupIt;
for (sslIt = sslIds.begin(); sslIt != sslIds.end(); sslIt++) { for (groupIt = groupInfo.peerIds.begin(); groupIt != groupInfo.peerIds.end(); groupIt++) {
if (std::find(peers.begin(), peers.end(), *sslIt) == peers.end()) { std::list<RsPeerId> sslIds;
// no friend rsPeers->getAssociatedSSLIds(*groupIt, sslIds);
continue;
}
switch (type) { std::list<RsPeerId>::const_iterator sslIt;
case TO: for (sslIt = sslIds.begin(); sslIt != sslIds.end(); sslIt++) {
if (std::find(mi.msgto.begin(), mi.msgto.end(), *sslIt) == mi.msgto.end()) { if (std::find(peers.begin(), peers.end(), *sslIt) == peers.end()) {
mi.msgto.push_back(*sslIt); // no friend
} continue;
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;
}
} }
}
} else {
if (_distant_peers.find(id)==_distant_peers.end() && std::find(peers.begin(), peers.end(), id) == peers.end()) {
// no friend
continue;
}
switch (type) { switch (type)
case TO: {
if (std::find(mi.msgto.begin(), mi.msgto.end(), id) == mi.msgto.end()) { case TO: addUnique(mi.rspeerid_msgto,*sslIt);
mi.msgto.push_back(id);
}
break; break;
case CC: case CC: addUnique(mi.rspeerid_msgcc,*sslIt);
if (std::find(mi.msgcc.begin(), mi.msgcc.end(), id) == mi.msgcc.end()) {
mi.msgcc.push_back(id);
}
break; break;
case BCC: case BCC:addUnique(mi.rspeerid_msgbcc,*sslIt);
if (std::find(mi.msgbcc.begin(), mi.msgbcc.end(), id) == mi.msgbcc.end()) {
mi.msgbcc.push_back(id);
}
break; 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; mi.msgId = m_sDraftMsgId;
rsMsgs->MessageToDraft(mi, m_msgParentId); rsMsgs->MessageToDraft(mi, m_msgParentId);
@ -1278,16 +1280,18 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox)
rsMsgs->MessageForwarded(m_sDraftMsgId, true); rsMsgs->MessageForwarded(m_sDraftMsgId, true);
break; break;
} }
} else { }
else
{
/* check for the recipient */ /* 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); QMessageBox::warning(this, tr("RetroShare"), tr("Please insert at least one recipient."), QMessageBox::Ok);
return false; // Don't send with no recipient 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) { if (rsMsgs->MessageSend(mi) == false) {
return false; return false;
@ -1327,7 +1331,7 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox)
} }
} }
ui.msgText->document()->setModified(false); ui.msgText->document()->setModified(false);
#endif
return true; 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()) { if (row >= ui.recipientWidget->rowCount()) {
return false; return false;
@ -1369,12 +1373,12 @@ bool MessageComposer::getRecipientFromRow(int row, enumType &type, std::string &
type = (enumType) cb->itemData(cb->currentIndex(), Qt::UserRole).toInt(); type = (enumType) cb->itemData(cb->currentIndex(), Qt::UserRole).toInt();
id = ui.recipientWidget->item(row, COLUMN_RECIPIENT_DATA)->data(ROLE_RECIPIENT_ID).toString().toStdString(); 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; 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()) { if (row + 1 > ui.recipientWidget->rowCount()) {
ui.recipientWidget->setRowCount(row + 1); ui.recipientWidget->setRowCount(row + 1);
@ -1410,9 +1414,10 @@ void MessageComposer::setRecipientToRow(int row, enumType type, const std::strin
QIcon icon; QIcon icon;
QString name; QString name;
if (!id.empty()) if (!id.empty())
{ {
if (group) switch(dest_type)
{ {
case PEER_TYPE_GROUP: {
icon = QIcon(IMAGE_GROUP16); icon = QIcon(IMAGE_GROUP16);
RsGroupInfo groupInfo; RsGroupInfo groupInfo;
@ -1421,56 +1426,60 @@ void MessageComposer::setRecipientToRow(int row, enumType type, const std::strin
} else { } else {
name = tr("Unknown"); name = tr("Unknown");
} }
} }
else break ;
{
RsPeerDetails details;
if(_distant_peers.find(DistantMsgPeerId(id)) != _distant_peers.end()) case PEER_TYPE_GXS: {
{
RsIdentityDetails detail;
if(!rsIdentity->getIdDetails(_distant_peers[DistantMsgPeerId(id)], detail)) RsIdentityDetails detail;
{ RsGxsId gid(id) ;
std::cerr << "Can't get peer details from " << _distant_peers[DistantMsgPeerId(id)] << std::endl;
return ;
}
name = tr("Distant peer (name: %2, PGP key: %1)").arg(QString::fromStdString(_distant_peers[DistantMsgPeerId(id)].toStdString())).arg(QString::fromStdString(detail.mNickname)) ; if(!rsIdentity->getIdDetails(gid, detail))
icon = QIcon(StatusDefs::imageUser(RS_STATUS_ONLINE)); {
} std::cerr << "Can't get peer details from " << gid << std::endl;
else if(rsPeers->getPeerDetails(RsPeerId(id), details) && (!details.isOnlyGPGdetail)) return ;
{ }
name = PeerDefs::nameWithLocation(details);
StatusInfo peerStatusInfo; name = tr("Distant peer (name: %2, PGP key: %1)").arg(QString::fromStdString(gid.toStdString())).arg(QString::fromStdString(detail.mNickname)) ;
// No check of return value. Non existing status info is handled as offline. icon = QIcon(StatusDefs::imageUser(RS_STATUS_ONLINE));
rsStatus->getStatus(RsPeerId(id), peerStatusInfo); }
break ;
icon = QIcon(StatusDefs::imageUser(peerStatusInfo.status)); case PEER_TYPE_SSL: {
} RsPeerDetails details ;
else
{ if(!rsPeers->getPeerDetails(RsPeerId(id), details))
icon = QIcon(StatusDefs::imageUser(RS_STATUS_OFFLINE)); {
name = tr("Unknown friend"); 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)); comboBox->setCurrentIndex(comboBox->findData(type, Qt::UserRole));
lineEdit->setText(name); lineEdit->setText(name);
if (id.empty()) { if (id.empty())
lineEdit->setStyleSheet(QString(STYLE_FAIL).arg(lineEdit->objectName())); lineEdit->setStyleSheet(QString(STYLE_FAIL).arg(lineEdit->objectName()));
} else { else
lineEdit->setStyleSheet(QString(STYLE_NORMAL).arg(lineEdit->objectName())); lineEdit->setStyleSheet(QString(STYLE_NORMAL).arg(lineEdit->objectName()));
}
QTableWidgetItem *item = new QTableWidgetItem(icon, "", 0); QTableWidgetItem *item = new QTableWidgetItem(icon, "", 0);
item->setFlags(Qt::NoItemFlags); item->setFlags(Qt::NoItemFlags);
ui.recipientWidget->setItem(row, COLUMN_RECIPIENT_ICON, item); 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_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(); addEmptyRecipient();
} }
@ -1537,13 +1546,14 @@ void MessageComposer::editingRecipientFinished()
enumType type; enumType type;
std::string id; // dummy std::string id; // dummy
bool group; // dummy destinationType dtype ;
getRecipientFromRow(row, type, id, group);
getRecipientFromRow(row, type, dtype, id);
QString text = lineEdit->text(); QString text = lineEdit->text();
if (text.isEmpty()) { if (text.isEmpty()) {
setRecipientToRow(row, type, "", false); setRecipientToRow(row, type,PEER_TYPE_SSL, "");
return; return;
} }
@ -1561,7 +1571,7 @@ void MessageComposer::editingRecipientFinished()
QString name = PeerDefs::nameWithLocation(details); QString name = PeerDefs::nameWithLocation(details);
if (text.compare(name, Qt::CaseSensitive) == 0) { if (text.compare(name, Qt::CaseSensitive) == 0) {
// found it // found it
setRecipientToRow(row, type, details.id.toStdString(), false); setRecipientToRow(row, type, PEER_TYPE_SSL, details.id.toStdString());
return; return;
} }
} }
@ -1575,100 +1585,94 @@ void MessageComposer::editingRecipientFinished()
QString groupName = GroupDefs::name(*groupIt); QString groupName = GroupDefs::name(*groupIt);
if (text.compare(groupName, Qt::CaseSensitive) == 0) { if (text.compare(groupName, Qt::CaseSensitive) == 0) {
// found it // found it
setRecipientToRow(row, type, groupIt->id, true); setRecipientToRow(row, type, PEER_TYPE_GROUP, groupIt->id);
return; return;
} }
} }
setRecipientToRow(row, type, "", false); setRecipientToRow(row, type, PEER_TYPE_SSL, "");
lineEdit->setStyleSheet(QString(STYLE_FAIL).arg(lineEdit->objectName())); lineEdit->setStyleSheet(QString(STYLE_FAIL).arg(lineEdit->objectName()));
lineEdit->setText(text); lineEdit->setText(text);
} }
void MessageComposer::addRecipient(enumType type, const RsPeerId& pid)
void MessageComposer::addRecipient(enumType type, const DistantMsgPeerId& pid,const RsGxsId& gxs_id)
{ {
_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(); if (getRecipientFromRow(row, rowType, dtype, rowId))
int row; {
for (row = 0; row < rowCount; row++) if (rowId.empty()) // use row
{ break;
enumType rowType;
std::string rowId;
bool rowGroup;
if (getRecipientFromRow(row, rowType, rowId, rowGroup) == true) if (RsPeerId(rowId) == pid && rowType == type) // existing row
{ break;
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<RsPeerId> sslIds;
if (group) {
sslIds.push_back(id);
} else {
// check for gpg id or ssl id
RsPeerDetails detail;
if (!rsPeers->getPeerDetails(id, detail)) {
return;
} }
else // use row
// if (detail.isOnlyGPGdetail) break;
// {
// 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);
// }
} }
std::list<RsPeerId>::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) { setRecipientToRow(row, type, PEER_TYPE_SSL,pid.toStdString());
if (rowId.empty()) { }
// use row void MessageComposer::addRecipient(enumType type, const RsGxsId& gxs_id)
break; {
} _distant_peers.insert(gxs_id) ;
if (rowId == (*sslIt).toStdString() && rowType == type && group == rowGroup) { int rowCount = ui.recipientWidget->rowCount();
// existing row int row;
break; for (row = 0; row < rowCount; row++)
} {
} else { 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 // use row
break; 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() void MessageComposer::setupFileActions()
@ -2304,29 +2308,24 @@ void MessageComposer::fileHashingFinished(QList<HashedFile> hashedFiles)
void MessageComposer::addContact(enumType type) void MessageComposer::addContact(enumType type)
{ {
// std::list<std::string> ids; // std::list<std::string> ids;
// ui.friendSelectionWidget->selectedIds<std::string,FriendSelectionWidget::IDTYPE_GROUP>(ids,false); // ui.friendSelectionWidget->selectedIds<std::string,FriendSelectionWidget::IDTYPE_GROUP>(ids,false);
// //
// std::list<std::string>::iterator idIt; // std::list<std::string>::iterator idIt;
// for (idIt = ids.begin(); idIt != ids.end(); idIt++) { // for (idIt = ids.begin(); idIt != ids.end(); idIt++) {
// addRecipient(type, *idIt, true); // addRecipient(type, *idIt, true);
// } // }
std::list<RsPeerId> ids ; std::list<RsPeerId> ids ;
ui.friendSelectionWidget->selectedIds<RsPeerId,FriendSelectionWidget::IDTYPE_SSL>(ids, true); ui.friendSelectionWidget->selectedIds<RsPeerId,FriendSelectionWidget::IDTYPE_SSL>(ids, true);
for (std::list<RsPeerId>::const_iterator idIt = ids.begin(); idIt != ids.end(); idIt++) { for (std::list<RsPeerId>::const_iterator idIt = ids.begin(); idIt != ids.end(); idIt++) {
addRecipient(type, *idIt, false); addRecipient(type, *idIt);
} }
std::list<RsGxsId> id2 ; std::list<RsGxsId> id2 ;
ui.friendSelectionWidget->selectedIds<RsGxsId,FriendSelectionWidget::IDTYPE_GXS>(id2, true); ui.friendSelectionWidget->selectedIds<RsGxsId,FriendSelectionWidget::IDTYPE_GXS>(id2, true);
for (std::list<RsGxsId>::const_iterator idIt = id2.begin(); idIt != id2.end(); idIt++) for (std::list<RsGxsId>::const_iterator idIt = id2.begin(); idIt != id2.end(); idIt++)
{ addRecipient(type, *idIt);
DistantMsgPeerId pid ;
if(rsMsgs->getDistantMessagePeerId(*idIt,pid))
addRecipient(type, pid, *idIt);
}
} }
void MessageComposer::toggleShowNonFriend(bool bValue) void MessageComposer::toggleShowNonFriend(bool bValue)
@ -2355,21 +2354,23 @@ void MessageComposer::addBcc()
void MessageComposer::addRecommend() void MessageComposer::addRecommend()
{ {
std::list<RsPeerId> sslIds; std::list<RsPeerId> sslIds;
ui.friendSelectionWidget->selectedIds<RsPeerId,FriendSelectionWidget::IDTYPE_SSL>(sslIds, false); ui.friendSelectionWidget->selectedIds<RsPeerId,FriendSelectionWidget::IDTYPE_SSL>(sslIds, false);
if (sslIds.empty()) { std::list<RsGxsId> gxsIds ;
return; ui.friendSelectionWidget->selectedIds<RsGxsId,FriendSelectionWidget::IDTYPE_GXS>(gxsIds, true);
}
std::list <RsPeerId>::iterator it; if (sslIds.empty() && gxsIds.empty())
for (it = sslIds.begin(); it != sslIds.end(); it++) { return;
addRecipient(CC, *it, false);
}
QString text = buildRecommendHtml(sslIds); for(std::list <RsPeerId>::iterator it = sslIds.begin(); it != sslIds.end(); it++)
ui.msgText->textCursor().insertHtml(text); addRecipient(CC, *it);
ui.msgText->setFocus(Qt::OtherFocusReason); for (std::list<RsGxsId>::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() void MessageComposer::friendDetails()

View file

@ -42,6 +42,7 @@ class MessageComposer : public QMainWindow
public: public:
enum enumType { TO, CC, BCC }; enum enumType { TO, CC, BCC };
enum enumMessageType { NORMAL, REPLY, FORWARD }; enum enumMessageType { NORMAL, REPLY, FORWARD };
enum destinationType { PEER_TYPE_SSL, PEER_TYPE_GROUP, PEER_TYPE_GXS };
public: public:
/** Default Constructor */ /** Default Constructor */
@ -49,9 +50,9 @@ public:
MessageComposer(QWidget *parent = 0, Qt::WindowFlags flags = 0); MessageComposer(QWidget *parent = 0, Qt::WindowFlags flags = 0);
~MessageComposer(); ~MessageComposer();
static void msgFriend(const RsPeerId &id, bool group); static void msgFriend(const RsPeerId &id);
//static void msgDistantPeer(const std::string& hash,const std::string& pgp_id) ;
static void msgGxsIdentity(const RsGxsId& gxs_id) ; static void msgGxsIdentity(const RsGxsId& gxs_id) ;
static void msgGroup(const std::string& group_id) ;
static QString recommendMessage(); static QString recommendMessage();
static void recommendFriend(const std::list <RsPeerId> &sslIds, const RsPeerId &to = RsPeerId(), const QString &msg = "", bool autoSend = false); static void recommendFriend(const std::list <RsPeerId> &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 setTitleText(const QString &title, enumMessageType type = NORMAL);
void setQuotedMsg(const QString &msg, const QString &header); void setQuotedMsg(const QString &msg, const QString &header);
void setMsgText(const QString &msg, bool asHtml = false); void setMsgText(const QString &msg, bool asHtml = false);
void addRecipient(enumType type, const RsPeerId &id, bool group); void addRecipient(enumType type, const RsPeerId &id);
void addRecipient(enumType type, const DistantMsgPeerId &pid, const RsGxsId &gxs_id) ; void addRecipient(enumType type, const RsGxsId &gxs_id) ;
void addRecipient(enumType type, const std::string& group_id) ;
public slots: public slots:
/* actions to take.... */ /* actions to take.... */
@ -174,8 +176,8 @@ private:
void calculateTitle(); void calculateTitle();
void addEmptyRecipient(); void addEmptyRecipient();
bool getRecipientFromRow(int row, enumType &type, std::string &id, bool &group); bool getRecipientFromRow(int row, enumType &type, destinationType& dest_type, std::string &id);
void setRecipientToRow(int row, enumType type, const std::string &id, bool group); void setRecipientToRow(int row, enumType type, destinationType dest_type,const std::string &id);
void clearTagLabels(); void clearTagLabels();
void showTagLabels(); void showTagLabels();
@ -221,7 +223,7 @@ private:
Ui::MessageComposer ui; Ui::MessageComposer ui;
std::list<FileInfo> _recList ; std::list<FileInfo> _recList ;
std::map<DistantMsgPeerId,RsGxsId> _distant_peers ; // pairs (hash,gxs_id) std::set<RsGxsId> _distant_peers ; // we keep a list of them, in order to know which peer is a GXS id.
}; };
#endif #endif

View file

@ -304,7 +304,7 @@ void MessageWidget::getcurrentrecommended()
} }
std::list<RsPeerId> srcIds; std::list<RsPeerId> srcIds;
srcIds.push_back(msgInfo.srcId); srcIds.push_back(msgInfo.rspeerid_srcId);
QModelIndexList list = ui.msgList->selectionModel()->selectedIndexes(); QModelIndexList list = ui.msgList->selectionModel()->selectedIndexes();
@ -353,7 +353,7 @@ void MessageWidget::getallrecommended()
for(it = recList.begin(); it != recList.end(); it++) { for(it = recList.begin(); it != recList.end(); it++) {
std::cerr << "MessageWidget::getallrecommended() Calling File Request" << std::endl; std::cerr << "MessageWidget::getallrecommended() Calling File Request" << std::endl;
std::list<RsPeerId> srcIds; std::list<RsPeerId> 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); 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); ui.msgList->insertTopLevelItems(0, items);
/* iterate through the sources */ /* iterate through the sources */
std::list<RsPeerId>::const_iterator pit;
RetroShareLink link; RetroShareLink link;
QString text; QString text;
for(pit = msgInfo.msgto.begin(); pit != msgInfo.msgto.end(); pit++) { for(std::list<RsPeerId>::const_iterator pit = msgInfo.rspeerid_msgto.begin(); pit != msgInfo.rspeerid_msgto.end(); pit++) if (link.createMessage(*pit, "")) text += link.toHtml() + " ";
if (link.createMessage(*pit, "")) { for(std::list<RsGxsId >::const_iterator pit = msgInfo.rsgxsid_msgto.begin(); pit != msgInfo.rsgxsid_msgto.end(); pit++) if (link.createMessage(*pit, "")) text += link.toHtml() + " ";
text += link.toHtml() + " ";
}
}
ui.toText->setText(text); ui.toText->setText(text);
if (msgInfo.msgcc.size() > 0) { if (!msgInfo.rspeerid_msgcc.empty() || !msgInfo.rsgxsid_msgcc.empty())
{
ui.cclabel->setVisible(true); ui.cclabel->setVisible(true);
ui.ccText->setVisible(true); ui.ccText->setVisible(true);
text.clear(); text.clear();
for(pit = msgInfo.msgcc.begin(); pit != msgInfo.msgcc.end(); pit++) { for(std::list<RsPeerId>::const_iterator pit = msgInfo.rspeerid_msgcc.begin(); pit != msgInfo.rspeerid_msgcc.end(); pit++) if (link.createMessage(*pit, "")) text += link.toHtml() + " ";
if (link.createMessage(*pit, "")) { for(std::list<RsGxsId>::const_iterator pit = msgInfo.rsgxsid_msgcc.begin(); pit != msgInfo.rsgxsid_msgcc.end(); pit++) if (link.createMessage(*pit, "")) text += link.toHtml() + " ";
text += link.toHtml() + " ";
}
}
ui.ccText->setText(text); ui.ccText->setText(text);
} else { } else {
ui.cclabel->setVisible(false); ui.cclabel->setVisible(false);
@ -526,16 +521,15 @@ void MessageWidget::fill(const std::string &msgId)
ui.ccText->clear(); ui.ccText->clear();
} }
if (msgInfo.msgbcc.size() > 0) { if (!msgInfo.rspeerid_msgbcc.empty() || !msgInfo.rsgxsid_msgbcc.empty())
ui.bcclabel->setVisible(true); {
ui.bccText->setVisible(true); ui.bcclabel->setVisible(true);
ui.bccText->setVisible(true);
text.clear();
for(std::list<RsPeerId>::const_iterator pit = msgInfo.rspeerid_msgbcc.begin(); pit != msgInfo.rspeerid_msgbcc.end(); pit++) if (link.createMessage(*pit, "")) text += link.toHtml() + " ";
for(std::list<RsGxsId>::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); ui.bccText->setText(text);
} else { } else {
ui.bcclabel->setVisible(false); ui.bcclabel->setVisible(false);
@ -552,11 +546,11 @@ void MessageWidget::fill(const std::string &msgId)
// outgoing message are from me // outgoing message are from me
srcId = ownId; srcId = ownId;
} else { } else {
srcId = msgInfo.srcId; srcId = msgInfo.rspeerid_srcId;
} }
link.createMessage(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"); ui.fromText->setText("RetroShare");
} else { } else {
ui.fromText->setText(link.toHtml()); ui.fromText->setText(link.toHtml());