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

@ -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;
}