From a5d88d967ea4b1c561a15dfb48e86377cd857084 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 7 May 2014 20:53:16 +0000 Subject: [PATCH] added code to transmit the sender GXS id in the message widget. Still need to make distant message links work git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7347 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/services/p3msgservice.cc | 5 ++ retroshare-gui/src/gui/common/PeerDefs.cpp | 2 + .../src/gui/msgs/MessageComposer.cpp | 36 +++++++++++++ retroshare-gui/src/gui/msgs/MessageComposer.h | 1 + .../src/gui/msgs/MessageComposer.ui | 54 +++++++++++-------- 5 files changed, 76 insertions(+), 22 deletions(-) diff --git a/libretroshare/src/services/p3msgservice.cc b/libretroshare/src/services/p3msgservice.cc index 684cc69be..460bdbc33 100644 --- a/libretroshare/src/services/p3msgservice.cc +++ b/libretroshare/src/services/p3msgservice.cc @@ -748,6 +748,11 @@ bool p3MsgService::getMessage(const std::string &mId, MessageInfo &msg) /* mit valid */ initRsMI(mit->second, msg); + + std::map::const_iterator it = mSrcIds.find(msgId) ; + if(it != mSrcIds.end()) + msg.rsgxsid_srcId = RsGxsId(it->second->srcId) ; + return true; } diff --git a/retroshare-gui/src/gui/common/PeerDefs.cpp b/retroshare-gui/src/gui/common/PeerDefs.cpp index 8bebe03e4..7c080a2b5 100644 --- a/retroshare-gui/src/gui/common/PeerDefs.cpp +++ b/retroshare-gui/src/gui/common/PeerDefs.cpp @@ -99,6 +99,8 @@ const QString PeerDefs::rsidFromId(const RsPeerId &id, QString *name /* = NULL*/ rsid = PeerDefs::rsid(peerName, *it); if(name) *name = QString::fromUtf8(peerName.c_str()); + + return rsid ; } rsid = PeerDefs::rsid("", id); diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index aa8360ca9..9340cffbd 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -236,6 +236,29 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags) setupFormatActions(); + std::list own_ids ; + rsIdentity->getOwnIds(own_ids) ; + + ui.respond_to_CB->addItem(tr("[no identity]"), QVariant(QString::fromStdString(RsGxsId().toStdString()))) ; + + for(std::list::const_iterator it(own_ids.begin());it!=own_ids.end();++it) + { + RsIdentityDetails details ; + rsIdentity->getIdDetails(*it,details) ; + + std::cerr << "Adding identity: id=" << (*it) << ", name=" << details.mNickname << std::endl; + + if(details.mNickname.empty()) // I don't know why, but that happens + ui.respond_to_CB->addItem(QString::fromStdString((*it).toStdString()), QString::fromStdString((*it).toStdString())) ; + else + ui.respond_to_CB->addItem(QString::fromUtf8(details.mNickname.c_str()), QString::fromStdString((*it).toStdString())) ; + } + + QObject::connect(ui.respond_to_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(updateSigningButton(int))) ; + + if(!own_ids.empty()) + ui.respond_to_CB->setCurrentIndex(1) ; + /*ui.comboStyle->addItem("Standard"); ui.comboStyle->addItem("Bullet List (Disc)"); ui.comboStyle->addItem("Bullet List (Circle)"); @@ -331,6 +354,13 @@ MessageComposer::~MessageComposer() { delete(m_compareRole); } +void MessageComposer::updateSigningButton(int n) +{ + if(n == 0) + ui.signMessage_CB->setEnabled(false) ; + else + ui.signMessage_CB->setEnabled(true) ; +} void MessageComposer::processSettings(bool bLoad) { @@ -1146,6 +1176,12 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox) /* construct a message */ MessageInfo mi; + // add a GXS signer/from in case the message is to be sent to a distant peer + + mi.rsgxsid_srcId = RsGxsId(ui.respond_to_CB->itemData(ui.respond_to_CB->currentIndex()).toString().toStdString()) ; + + std::cerr << "MessageSend: setting 'from' field to GXS id = " << mi.rsgxsid_srcId << std::endl; + mi.title = misc::removeNewLine(ui.titleEdit->text()).toUtf8().constData(); // needed to send system flags with reply mi.msgflags = msgFlags; diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.h b/retroshare-gui/src/gui/msgs/MessageComposer.h index c93680da8..0ed6f52f3 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.h +++ b/retroshare-gui/src/gui/msgs/MessageComposer.h @@ -80,6 +80,7 @@ public slots: void addImage(); void changeFormatType(int styleIndex ); + void updateSigningButton(int) ; protected: void closeEvent (QCloseEvent * event); diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.ui b/retroshare-gui/src/gui/msgs/MessageComposer.ui index d13d0a434..a000b3fe0 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.ui +++ b/retroshare-gui/src/gui/msgs/MessageComposer.ui @@ -6,7 +6,7 @@ 0 0 - 796 + 892 682 @@ -641,23 +641,6 @@ - - - - <html><head/><body><p>Cryptographically sign message to distant peers. This is prevents intermediate peers to spoof your identity.</p></body></html> - - - - - - - :/images/stock_signature_ok.png:/images/stock_signature_ok.png - - - true - - - @@ -728,7 +711,7 @@ - + @@ -762,6 +745,16 @@ + + + + + + Respond to: + + + + Qt::Horizontal @@ -774,8 +767,25 @@ - - + + + + + + + <html><head/><body><p>Cryptographically sign message to distant peers. This is prevents intermediate peers to spoof your identity.</p></body></html> + + + + + + + :/images/stock_signature_ok.png:/images/stock_signature_ok.png + + + true + + @@ -859,7 +869,7 @@ 0 0 - 796 + 892 25