diff --git a/libretroshare/src/services/p3msgservice.cc b/libretroshare/src/services/p3msgservice.cc index cc426fe26..5b68c804c 100644 --- a/libretroshare/src/services/p3msgservice.cc +++ b/libretroshare/src/services/p3msgservice.cc @@ -253,10 +253,18 @@ void p3MsgService::checkSizeAndSendMessage(RsMsgItem *msg) // Indicate that the message is to be continued. // item->msgFlags |= RS_MSG_FLAGS_PARTIAL ; - sendItem(item) ; + + if(msg->msgFlags & RS_MSG_FLAGS_DISTANT) + sendPrivateMsgItem(msg) ; + else + sendItem(item) ; } std::cerr << " Chopped off msg of size " << msg->message.size() << std::endl; - sendItem(msg) ; + + if(msg->msgFlags & RS_MSG_FLAGS_DISTANT) + sendPrivateMsgItem(msg) ; + else + sendItem(msg) ; } int p3MsgService::checkOutgoingMessages() @@ -286,7 +294,7 @@ int p3MsgService::checkOutgoingMessages() std::string pid = mit->second->PeerId(); bool toSend = false; - if (mLinkMgr->isOnline(pid)) + if(mit->second.msgFlags & RS_MSG_FLAGS_DISTANT || mLinkMgr->isOnline(pid)) { toSend = true; } @@ -1558,6 +1566,10 @@ RsMsgItem *p3MsgService::initMIRsMsg(MessageInfo &info, const std::string &to) 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++) { @@ -1570,13 +1582,10 @@ RsMsgItem *p3MsgService::initMIRsMsg(MessageInfo &info, const std::string &to) /* 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; - } //std::cerr << "p3MsgService::initMIRsMsg()" << std::endl; //msg->print(std::cerr); @@ -1596,7 +1605,7 @@ bool p3MsgService::createDistantOfflineMessengingInvite(time_t time_of_validity, hash = t_RsGenericIdType(hash_bytes).toStdString(false) ; DistantMessengingInvite invite ; - invite.time_of_validity = time_of_validity ; + invite.time_of_validity = time_of_validity + time(NULL); { RsStackMutex stack(mMsgMtx); /********** STACK LOCKED MTX ******/ @@ -1614,6 +1623,10 @@ bool p3MsgService::getDistantOfflineMessengingInvites(std::vectorfirst ; invite.issuer_pgp_id = AuthGPG::getAuthGPG()->getGPGOwnId() ; invite.time_of_validity = it->second.time_of_validity ; + + invites.push_back(invite) ; + + std::cerr << " adding invite with hash " << invite.hash << std::endl; } return true ; diff --git a/retroshare-gui/src/gui/RetroShareLink.cpp b/retroshare-gui/src/gui/RetroShareLink.cpp index 8bfc533aa..34aa0eb9a 100644 --- a/retroshare-gui/src/gui/RetroShareLink.cpp +++ b/retroshare-gui/src/gui/RetroShareLink.cpp @@ -1200,7 +1200,7 @@ static void processList(const QStringList &list, const QString &textSingular, co break ; } - MessageComposer::msgFriend(link._hash.toStdString(), false); + MessageComposer::msgDistantPeer(link._hash.toStdString(),link._GPGid.toStdString()) ; } break ; case TYPE_PRIVATE_CHAT: diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index 283b71e0d..2bb16fcdd 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -352,6 +352,22 @@ void MessageComposer::processSettings(bool bLoad) Settings->endGroup(); } +/*static*/ void MessageComposer::msgDistantPeer(const std::string& hash,const std::string& pgp_id) +{ +// std::cerr << "MessageComposer::msgfriend()" << std::endl; + + /* create a message */ + + MessageComposer *pMsgDialog = MessageComposer::newMsg(); + if (pMsgDialog == NULL) + return; + + pMsgDialog->addRecipient(TO, hash,pgp_id) ; + pMsgDialog->show(); + + /* window will destroy itself! */ +} + /*static*/ void MessageComposer::msgFriend(const std::string &id, bool group) { @@ -1402,7 +1418,13 @@ void MessageComposer::setRecipientToRow(int row, enumType type, std::string id, } } else { RsPeerDetails details; - if (rsPeers->getPeerDetails(id, details)) { + if(_distant_peers.find(id) != _distant_peers.end()) + { + name = tr("Distant peer (PGP key: %1)").arg(QString::fromStdString(_distant_peers[id])) ; + icon = QIcon(StatusDefs::imageUser(RS_STATUS_ONLINE)); + } + else if (rsPeers->getPeerDetails(id, details)) + { name = PeerDefs::nameWithLocation(details); StatusInfo peerStatusInfo; @@ -1546,6 +1568,32 @@ void MessageComposer::editingRecipientFinished() lineEdit->setText(text); } +void MessageComposer::addRecipient(enumType type, const std::string& hash,const std::string& pgp_id) +{ + _distant_peers[hash] = pgp_id ; + + 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; + + if (rowId == hash && rowType == type) // existing row + break; + } + else // use row + break; + } + + setRecipientToRow(row, type, hash, false); +} void MessageComposer::addRecipient(enumType type, const std::string &id, bool group) { std::list sslIds; diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.h b/retroshare-gui/src/gui/msgs/MessageComposer.h index bc9faa4e1..f5aa98bee 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.h +++ b/retroshare-gui/src/gui/msgs/MessageComposer.h @@ -49,6 +49,8 @@ public: ~MessageComposer(); static void msgFriend(const std::string &id, bool group); + static void msgDistantPeer(const std::string& hash,const std::string& pgp_id) ; + static QString recommendMessage(); static void recommendFriend(const std::list &sslIds, const std::string &to = "", const QString &msg = "", bool autoSend = false); static void sendConnectAttemptMsg(const std::string &gpgId, const std::string &sslId, const QString &sslName); @@ -65,6 +67,7 @@ public: void setQuotedMsg(const QString &msg, const QString &header); void setMsgText(const QString &msg, bool asHtml = false); void addRecipient(enumType type, const std::string &id, bool group); + void addRecipient(enumType type, const std::string &hash, const std::string& pgp_id) ; public slots: /* actions to take.... */ @@ -217,6 +220,7 @@ private: Ui::MessageComposer ui; std::list _recList ; + std::map _distant_peers ; // pairs (hash,pgp_id) }; #endif