From 4dd77457ad28292adeeeaffcb2de92f3759bc3fd Mon Sep 17 00:00:00 2001 From: thunder2 Date: Sat, 28 Sep 2013 22:05:38 +0000 Subject: [PATCH] Added info widget for encrypted messages in MessageWidget. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6774 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/services/p3msgservice.cc | 1 + retroshare-gui/src/gui/MessagesDialog.cpp | 36 ++---- retroshare-gui/src/gui/msgs/MessageWidget.cpp | 51 +++++++- retroshare-gui/src/gui/msgs/MessageWidget.h | 3 + retroshare-gui/src/gui/msgs/MessageWidget.ui | 119 ++++++++++++++++++ retroshare-gui/src/gui/notifyqt.cpp | 2 +- .../src/gui/qss/stylesheet/Standard.qss | 9 ++ retroshare-gui/src/lang/retroshare_en.ts | 104 ++++++++------- 8 files changed, 248 insertions(+), 77 deletions(-) diff --git a/libretroshare/src/services/p3msgservice.cc b/libretroshare/src/services/p3msgservice.cc index 73be85bb9..4dfa6ad08 100644 --- a/libretroshare/src/services/p3msgservice.cc +++ b/libretroshare/src/services/p3msgservice.cc @@ -2044,6 +2044,7 @@ bool p3MsgService::decryptMessage(const std::string& mId) delete item ; IndicateConfigChanged() ; + rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD); return true ; } diff --git a/retroshare-gui/src/gui/MessagesDialog.cpp b/retroshare-gui/src/gui/MessagesDialog.cpp index 6b1719295..7d6cd68b9 100644 --- a/retroshare-gui/src/gui/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/MessagesDialog.cpp @@ -727,7 +727,7 @@ void MessagesDialog::changeBox(int) listMode = LIST_BOX; insertMessages(); - insertMsgTxtAndFiles(); + insertMsgTxtAndFiles(ui.messagestreeView->currentIndex()); inChange = false; } @@ -749,7 +749,7 @@ void MessagesDialog::changeQuickView(int newrow) listMode = LIST_QUICKVIEW; insertMessages(); - insertMsgTxtAndFiles(); + insertMsgTxtAndFiles(ui.messagestreeView->currentIndex()); inChange = false; } @@ -1516,33 +1516,15 @@ void MessagesDialog::insertMsgTxtAndFiles(QModelIndex Index, bool bSetToRead) void MessagesDialog::decryptSelectedMsg() { - MessageInfo msgInfo; + if (!MessageWidget::decryptMsg(mCurrMsgId)) { + return; + } - if (!rsMsgs->getMessage(mCurrMsgId, msgInfo)) - return ; + // Force refill + mCurrMsgId.clear(); + msgWidget->fill(""); - if(!msgInfo.msgflags & RS_MSG_ENCRYPTED) - { - QMessageBox::warning(NULL,tr("Decryption failed!"),tr("This message is not encrypted. Cannot decrypt!")) ; - return ; - } - - if(!rsMsgs->decryptMessage(mCurrMsgId) ) - QMessageBox::warning(NULL,tr("Decryption failed!"),tr("This message could not be decrypted.")) ; - - //setMsgAsReadUnread(currentIndex.row(), true); - timer->start(); - - updateMessageSummaryList(); - - //QModelIndex currentIndex = ui.messagestreeView->currentIndex(); - //QModelIndex index = ui.messagestreeView->model()->index(currentIndex.row(), COLUMN_UNREAD, currentIndex.parent()); - //currentChanged(index); - - MessagesModel->removeRows (0, MessagesModel->rowCount()); - - insertMessages(); - insertMsgTxtAndFiles(); + insertMsgTxtAndFiles(ui.messagestreeView->currentIndex()); } bool MessagesDialog::getCurrentMsg(std::string &cid, std::string &mid) diff --git a/retroshare-gui/src/gui/msgs/MessageWidget.cpp b/retroshare-gui/src/gui/msgs/MessageWidget.cpp index 5a07dd075..dcead1499 100644 --- a/retroshare-gui/src/gui/msgs/MessageWidget.cpp +++ b/retroshare-gui/src/gui/msgs/MessageWidget.cpp @@ -131,12 +131,14 @@ MessageWidget::MessageWidget(bool controlled, QWidget *parent, Qt::WFlags flags) connect(ui.expandFilesButton, SIGNAL(clicked()), this, SLOT(togglefileview())); connect(ui.downloadButton, SIGNAL(clicked()), this, SLOT(getallrecommended())); connect(ui.msgText, SIGNAL(anchorClicked(QUrl)), this, SLOT(anchorClicked(QUrl))); + connect(ui.decryptButton, SIGNAL(clicked()), this, SLOT(decrypt())); connect(NotifyQt::getInstance(), SIGNAL(messagesTagsChanged()), this, SLOT(messagesTagsChanged())); connect(NotifyQt::getInstance(), SIGNAL(messagesChanged()), this, SLOT(messagesChanged())); ui.imageBlockWidget->addButtonAction(tr("Load images always for this message"), this, SLOT(loadImagesAlways()), true); ui.msgText->setImageBlockWidget(ui.imageBlockWidget); + ui.decryptFrame->hide(); /* hide the Tree +/- */ ui.msgList->setRootIsDecorated( false ); @@ -435,6 +437,8 @@ void MessageWidget::fill(const std::string &msgId) return; } + ui.decryptFrame->hide(); + currMsgId = msgId; if (currMsgId.empty()) { @@ -558,7 +562,11 @@ void MessageWidget::fill(const std::string &msgId) ui.fromText->setToolTip(PeerDefs::rsidFromId(srcId)); } - ui.subjectText->setText(QString::fromStdWString(msgInfo.title)); + if (msgInfo.msgflags & RS_MSG_ENCRYPTED) { + ui.subjectText->setText(tr("Encrypted message")); + } else { + ui.subjectText->setText(QString::fromStdWString(msgInfo.title)); + } text = RsHtmlMsg(msgInfo.msgflags).formatText(ui.msgText->document(), QString::fromStdWString(msgInfo.msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS | RSHTML_FORMATTEXT_REPLACE_LINKS); ui.msgText->resetImagesStatus(Settings->getMsgLoadEmbeddedImages() || (msgInfo.msgflags & RS_MSG_LOAD_EMBEDDED_IMAGES)); @@ -566,6 +574,10 @@ void MessageWidget::fill(const std::string &msgId) ui.filesText->setText(QString("(%1 %2)").arg(msgInfo.count).arg(msgInfo.count == 1 ? tr("File") : tr("Files"))); + if (msgInfo.msgflags & RS_MSG_ENCRYPTED) { + ui.decryptFrame->show(); + } + showTagLabels(); currMsgFlags = msgInfo.msgflags; @@ -723,3 +735,40 @@ void MessageWidget::loadImagesAlways() rsMsgs->MessageLoadEmbeddedImages(currMsgId, true); } + +void MessageWidget::decrypt() +{ + if (!decryptMsg(currMsgId)) { + return; + } + + // Force refill + std::string msgId = currMsgId; + currMsgId.clear(); + + fill(msgId); +} + +bool MessageWidget::decryptMsg(const std::string &msgId) +{ + if (msgId.empty()) { + return false; + } + + MessageInfo msgInfo; + if (!rsMsgs->getMessage(msgId, msgInfo)) { + return false; + } + + if (!(msgInfo.msgflags & RS_MSG_ENCRYPTED)) { + QMessageBox::warning(NULL, tr("Decryption failed!"), tr("This message is not encrypted. Cannot decrypt!")); + return false; + } + + if (!rsMsgs->decryptMessage(msgId)) { + QMessageBox::warning(NULL, tr("Decryption failed!"), tr("This message could not be decrypted.")); + return false; + } + + return true; +} diff --git a/retroshare-gui/src/gui/msgs/MessageWidget.h b/retroshare-gui/src/gui/msgs/MessageWidget.h index c36d1e9b3..24418acf1 100644 --- a/retroshare-gui/src/gui/msgs/MessageWidget.h +++ b/retroshare-gui/src/gui/msgs/MessageWidget.h @@ -59,6 +59,8 @@ public: QString subject(bool noEmpty); + static bool decryptMsg(const std::string &msgId); + private slots: void reply(); void replyAll(); @@ -79,6 +81,7 @@ private slots: void anchorClicked(const QUrl &url); void loadImagesAlways(); + void decrypt(); private: void clearTagLabels(); diff --git a/retroshare-gui/src/gui/msgs/MessageWidget.ui b/retroshare-gui/src/gui/msgs/MessageWidget.ui index c9afa96c0..8ae5c3d58 100644 --- a/retroshare-gui/src/gui/msgs/MessageWidget.ui +++ b/retroshare-gui/src/gui/msgs/MessageWidget.ui @@ -336,6 +336,125 @@ + + + + + + + + + 255 + 255 + 255 + + + + + + + 204 + 255 + 204 + + + + + + + + + 255 + 255 + 255 + + + + + + + 204 + 255 + 204 + + + + + + + + + 204 + 255 + 204 + + + + + + + 204 + 255 + 204 + + + + + + + + true + + + QFrame::Box + + + + 6 + + + 6 + + + + + + + + :/images/mail-encrypted-full.png + + + + + + + This messages is encrypted. Click the right button to decrypt it. + + + + + + + Qt::Horizontal + + + + 280 + 20 + + + + + + + + Decrypt + + + + + + diff --git a/retroshare-gui/src/gui/notifyqt.cpp b/retroshare-gui/src/gui/notifyqt.cpp index 2b808765a..7801780f1 100644 --- a/retroshare-gui/src/gui/notifyqt.cpp +++ b/retroshare-gui/src/gui/notifyqt.cpp @@ -780,7 +780,7 @@ void NotifyQt::UpdateGUI() if (popupflags & RS_POPUP_MSG) { - toaster = new Toaster(new MessageToaster(std::string(), tr("Unknown title"), QString("[%1]").arg(tr("Encrypted message")))); + toaster = new Toaster(new MessageToaster(std::string(), tr("Encrypted message"), QString("[%1]").arg(tr("Encrypted message")))); } break; case RS_POPUP_MSG: diff --git a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss index ad9e35d41..10b50daf3 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss +++ b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss @@ -490,3 +490,12 @@ ShareManager QLabel#labelInstructions { background: #FFFFD7; background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #FFFFD7, stop:1 #FFFFB2); } + +/* MessageWidget */ + +MessageWidget QFrame#decryptFrame { + border: 1px solid #50FF5B; + border-radius: 6px; + background: #CCFFCC; + background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #CCFFCC, stop:1 #AAFFAA); +} diff --git a/retroshare-gui/src/lang/retroshare_en.ts b/retroshare-gui/src/lang/retroshare_en.ts index 36dcde342..6cefecd83 100644 --- a/retroshare-gui/src/lang/retroshare_en.ts +++ b/retroshare-gui/src/lang/retroshare_en.ts @@ -1563,22 +1563,6 @@ Double click lobbies to enter and chat. History - - Group Chat - - - - Enable - - - - Number of saved messages (0 = unlimited) - - - - Load number of messages (0 = off) - - Style @@ -1695,6 +1679,30 @@ Double click lobbies to enter and chat. Private chat invite to + + <html><head/><body><p align="justify">In this tab you can setup how many chat messages Retroshare will keep saved on the disc and how much of the previous conversation it will display, for the different chat systems. The max storage period allows to discard old messages and prevents the chat history from filling up with volatile chat (e.g. chat lobbies and distant chat).</p></body></html> + + + + Chatlobbies + + + + Enabled: + + + + Saved messages (0 = unlimited): + + + + Number of messages restored (0 = off): + + + + Maximum storage period, in days: + + ChatStyle @@ -5815,14 +5823,6 @@ p, li { white-space: pre-wrap; } Copy certificate link - - Copy RetroShare Link - - - - Paste Friend Link - - Deny Friend @@ -5895,6 +5895,10 @@ p, li { white-space: pre-wrap; } Display + + Paste certificate link + + FriendRequestToaster @@ -9103,6 +9107,30 @@ Do you want to save message ? Load images always for this message + + This messages is encrypted. Click the right button to decrypt it. + + + + Decrypt + + + + Encrypted message + + + + Decryption failed! + + + + This message is not encrypted. Cannot decrypt! + + + + This message could not be decrypted. + + MessageWindow @@ -9501,14 +9529,6 @@ Do you want to save message ? Encrypted message. Right-click to decrypt it. - - Decryption failed! - - - - This message could not be decrypted. - - Messages @@ -9529,10 +9549,6 @@ Do you want to save message ? This message was signed but the signature doesn't check - - This message is not encrypted. Cannot decrypt! - - <h1><img width="32" src=":/images/64px_help.png">&nbsp;&nbsp;Messages</h1> <p>Messages are like <b>e-mail</b>: you send/receive them from your friends when both of you are connected.</p> <p>It is also possible to send messages to non friends, using tunnels. Such messages are always encrypted. It is recommended to cryptographically sign distant messages, as a proof of your identity, using the <img width="16" src=":/images/stock_signature_ok.png"/> button in the message composer window. Distant messages are not guarrantied to arrive, since this requires the distant peer to accept them (You need yourself to switch this on in Config-Messages).</p> <p>Some additional features allow you to exchange data in messages: you may recommend files to your friends by pasting file links, or recommend friends-to-be to other friends, in order to streathen your network.</p> @@ -12597,18 +12613,6 @@ The default value is 20. Shared Folder Manager - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">This is a list of shared folders. You can add and remove folders using the buttons at the bottom.</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">When you add a new folder, intially all files in that folder are shared.</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:8pt;">You can separately setup share flags for each shared directory:</span><span style=" font-size:8pt;"> </span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:8pt; font-weight:600;">Browsable</span><span style=" font-family:'Sans'; font-size:8pt;">: files are browsable from your direct friends.</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans'; font-size:8pt; font-weight:600;">Network Wide</span><span style=" font-family:'Sans'; font-size:8pt;">: files can be downloaded by anybody through anonymous tunnels.</span></p></body></html> - - Directory @@ -12681,6 +12685,10 @@ p, li { white-space: pre-wrap; } Directory not found or directory name not accepted. + + This is a list of shared folders. You can add and remove folders using the buttons at the bottom. When you add a new folder, intially all files in that folder are shared. You can separately setup share flags for each shared directory. + + SharedFilesDialog