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
This commit is contained in:
thunder2 2013-09-28 22:05:38 +00:00
parent 40ed94f7fb
commit 4dd77457ad
8 changed files with 248 additions and 77 deletions

View File

@ -2044,6 +2044,7 @@ bool p3MsgService::decryptMessage(const std::string& mId)
delete item ; delete item ;
IndicateConfigChanged() ; IndicateConfigChanged() ;
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_MESSAGELIST,NOTIFY_TYPE_MOD);
return true ; return true ;
} }

View File

@ -727,7 +727,7 @@ void MessagesDialog::changeBox(int)
listMode = LIST_BOX; listMode = LIST_BOX;
insertMessages(); insertMessages();
insertMsgTxtAndFiles(); insertMsgTxtAndFiles(ui.messagestreeView->currentIndex());
inChange = false; inChange = false;
} }
@ -749,7 +749,7 @@ void MessagesDialog::changeQuickView(int newrow)
listMode = LIST_QUICKVIEW; listMode = LIST_QUICKVIEW;
insertMessages(); insertMessages();
insertMsgTxtAndFiles(); insertMsgTxtAndFiles(ui.messagestreeView->currentIndex());
inChange = false; inChange = false;
} }
@ -1516,33 +1516,15 @@ void MessagesDialog::insertMsgTxtAndFiles(QModelIndex Index, bool bSetToRead)
void MessagesDialog::decryptSelectedMsg() void MessagesDialog::decryptSelectedMsg()
{ {
MessageInfo msgInfo; if (!MessageWidget::decryptMsg(mCurrMsgId)) {
return;
}
if (!rsMsgs->getMessage(mCurrMsgId, msgInfo)) // Force refill
return ; mCurrMsgId.clear();
msgWidget->fill("");
if(!msgInfo.msgflags & RS_MSG_ENCRYPTED) insertMsgTxtAndFiles(ui.messagestreeView->currentIndex());
{
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();
} }
bool MessagesDialog::getCurrentMsg(std::string &cid, std::string &mid) bool MessagesDialog::getCurrentMsg(std::string &cid, std::string &mid)

View File

@ -131,12 +131,14 @@ MessageWidget::MessageWidget(bool controlled, QWidget *parent, Qt::WFlags flags)
connect(ui.expandFilesButton, SIGNAL(clicked()), this, SLOT(togglefileview())); connect(ui.expandFilesButton, SIGNAL(clicked()), this, SLOT(togglefileview()));
connect(ui.downloadButton, SIGNAL(clicked()), this, SLOT(getallrecommended())); connect(ui.downloadButton, SIGNAL(clicked()), this, SLOT(getallrecommended()));
connect(ui.msgText, SIGNAL(anchorClicked(QUrl)), this, SLOT(anchorClicked(QUrl))); 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(messagesTagsChanged()), this, SLOT(messagesTagsChanged()));
connect(NotifyQt::getInstance(), SIGNAL(messagesChanged()), this, SLOT(messagesChanged())); connect(NotifyQt::getInstance(), SIGNAL(messagesChanged()), this, SLOT(messagesChanged()));
ui.imageBlockWidget->addButtonAction(tr("Load images always for this message"), this, SLOT(loadImagesAlways()), true); ui.imageBlockWidget->addButtonAction(tr("Load images always for this message"), this, SLOT(loadImagesAlways()), true);
ui.msgText->setImageBlockWidget(ui.imageBlockWidget); ui.msgText->setImageBlockWidget(ui.imageBlockWidget);
ui.decryptFrame->hide();
/* hide the Tree +/- */ /* hide the Tree +/- */
ui.msgList->setRootIsDecorated( false ); ui.msgList->setRootIsDecorated( false );
@ -435,6 +437,8 @@ void MessageWidget::fill(const std::string &msgId)
return; return;
} }
ui.decryptFrame->hide();
currMsgId = msgId; currMsgId = msgId;
if (currMsgId.empty()) { if (currMsgId.empty()) {
@ -558,7 +562,11 @@ void MessageWidget::fill(const std::string &msgId)
ui.fromText->setToolTip(PeerDefs::rsidFromId(srcId)); 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); 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)); 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"))); 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(); showTagLabels();
currMsgFlags = msgInfo.msgflags; currMsgFlags = msgInfo.msgflags;
@ -723,3 +735,40 @@ void MessageWidget::loadImagesAlways()
rsMsgs->MessageLoadEmbeddedImages(currMsgId, true); 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;
}

View File

@ -59,6 +59,8 @@ public:
QString subject(bool noEmpty); QString subject(bool noEmpty);
static bool decryptMsg(const std::string &msgId);
private slots: private slots:
void reply(); void reply();
void replyAll(); void replyAll();
@ -79,6 +81,7 @@ private slots:
void anchorClicked(const QUrl &url); void anchorClicked(const QUrl &url);
void loadImagesAlways(); void loadImagesAlways();
void decrypt();
private: private:
void clearTagLabels(); void clearTagLabels();

View File

@ -336,6 +336,125 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QFrame" name="decryptFrame">
<property name="palette">
<palette>
<active>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>204</red>
<green>255</green>
<blue>204</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>204</red>
<green>255</green>
<blue>204</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>204</red>
<green>255</green>
<blue>204</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>204</red>
<green>255</green>
<blue>204</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>6</number>
</property>
<item>
<widget class="QLabel" name="decryptImage">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/mail-encrypted-full.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="decryptLabel">
<property name="text">
<string>This messages is encrypted. Click the right button to decrypt it.</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>280</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="decryptButton">
<property name="text">
<string>Decrypt</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item> <item>
<widget class="RSTextBrowser" name="msgText"> <widget class="RSTextBrowser" name="msgText">
<property name="sizePolicy"> <property name="sizePolicy">

View File

@ -780,7 +780,7 @@ void NotifyQt::UpdateGUI()
if (popupflags & RS_POPUP_MSG) 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; break;
case RS_POPUP_MSG: case RS_POPUP_MSG:

View File

@ -490,3 +490,12 @@ ShareManager QLabel#labelInstructions {
background: #FFFFD7; background: #FFFFD7;
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #FFFFD7, stop:1 #FFFFB2); 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);
}

View File

@ -1563,22 +1563,6 @@ Double click lobbies to enter and chat.</source>
<source>History</source> <source>History</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Group Chat</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enable</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Number of saved messages (0 = unlimited)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Load number of messages (0 = off)</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>Style</source> <source>Style</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@ -1695,6 +1679,30 @@ Double click lobbies to enter and chat.</source>
<source>Private chat invite to </source> <source>Private chat invite to </source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;justify&quot;&gt;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).&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Chatlobbies</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enabled:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Saved messages (0 = unlimited):</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Number of messages restored (0 = off):</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Maximum storage period, in days:</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>ChatStyle</name> <name>ChatStyle</name>
@ -5815,14 +5823,6 @@ p, li { white-space: pre-wrap; }
<source>Copy certificate link</source> <source>Copy certificate link</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Copy RetroShare Link</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Paste Friend Link</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>Deny Friend</source> <source>Deny Friend</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@ -5895,6 +5895,10 @@ p, li { white-space: pre-wrap; }
<source>Display</source> <source>Display</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Paste certificate link</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>FriendRequestToaster</name> <name>FriendRequestToaster</name>
@ -9103,6 +9107,30 @@ Do you want to save message ?</source>
<source>Load images always for this message</source> <source>Load images always for this message</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>This messages is encrypted. Click the right button to decrypt it.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Decrypt</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Encrypted message</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Decryption failed!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This message is not encrypted. Cannot decrypt!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This message could not be decrypted.</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>MessageWindow</name> <name>MessageWindow</name>
@ -9501,14 +9529,6 @@ Do you want to save message ?</source>
<source>Encrypted message. Right-click to decrypt it.</source> <source>Encrypted message. Right-click to decrypt it.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Decryption failed!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>This message could not be decrypted.</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>Messages</source> <source>Messages</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@ -9529,10 +9549,6 @@ Do you want to save message ?</source>
<source>This message was signed but the signature doesn&apos;t check</source> <source>This message was signed but the signature doesn&apos;t check</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>This message is not encrypted. Cannot decrypt!</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source> &lt;h1&gt;&lt;img width=&quot;32&quot; src=&quot;:/images/64px_help.png&quot;&gt;&amp;nbsp;&amp;nbsp;Messages&lt;/h1&gt; &lt;p&gt;Messages are like &lt;b&gt;e-mail&lt;/b&gt;: you send/receive them from your friends when both of you are connected.&lt;/p&gt; &lt;p&gt;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 &lt;img width=&quot;16&quot; src=&quot;:/images/stock_signature_ok.png&quot;/&gt; 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).&lt;/p&gt; &lt;p&gt;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.&lt;/p&gt; </source> <source> &lt;h1&gt;&lt;img width=&quot;32&quot; src=&quot;:/images/64px_help.png&quot;&gt;&amp;nbsp;&amp;nbsp;Messages&lt;/h1&gt; &lt;p&gt;Messages are like &lt;b&gt;e-mail&lt;/b&gt;: you send/receive them from your friends when both of you are connected.&lt;/p&gt; &lt;p&gt;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 &lt;img width=&quot;16&quot; src=&quot;:/images/stock_signature_ok.png&quot;/&gt; 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).&lt;/p&gt; &lt;p&gt;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.&lt;/p&gt; </source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@ -12597,18 +12613,6 @@ The default value is 20.</source>
<source>Shared Folder Manager</source> <source>Shared Folder Manager</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:&apos;MS Shell Dlg 2&apos;; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt;This is a list of shared folders. You can add and remove folders using the buttons at the bottom.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt;When you add a new folder, intially all files in that folder are shared.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:&apos;Sans&apos;; font-size:8pt;&quot;&gt;You can separately setup share flags for each shared directory:&lt;/span&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:&apos;Sans&apos;; font-size:8pt; font-weight:600;&quot;&gt;Browsable&lt;/span&gt;&lt;span style=&quot; font-family:&apos;Sans&apos;; font-size:8pt;&quot;&gt;: files are browsable from your direct friends.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:&apos;Sans&apos;; font-size:8pt; font-weight:600;&quot;&gt;Network Wide&lt;/span&gt;&lt;span style=&quot; font-family:&apos;Sans&apos;; font-size:8pt;&quot;&gt;: files can be downloaded by anybody through anonymous tunnels.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>Directory</source> <source>Directory</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@ -12681,6 +12685,10 @@ p, li { white-space: pre-wrap; }
<source>Directory not found or directory name not accepted.</source> <source>Directory not found or directory name not accepted.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>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.</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>SharedFilesDialog</name> <name>SharedFilesDialog</name>