mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-08 17:15:16 -04:00
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:
parent
40ed94f7fb
commit
4dd77457ad
8 changed files with 248 additions and 77 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -336,6 +336,125 @@
|
|||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
<widget class="RSTextBrowser" name="msgText">
|
||||
<property name="sizePolicy">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue