Added new action "Load images always for this message" to image blocking.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6760 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2013-09-24 20:19:21 +00:00
parent 0a3419c692
commit 6a9dfed408
16 changed files with 255 additions and 97 deletions

View File

@ -37,6 +37,7 @@
#define FORUM_MSG_STATUS_MASK 0x000f
#define FORUM_MSG_STATUS_READ 0x0001
#define FORUM_MSG_STATUS_UNREAD_BY_USER 0x0002
#define FORUM_MSG_STATUS_LOAD_EMBEDDED_IMAGES 0x0004
class ForumInfo
{

View File

@ -61,6 +61,7 @@
#define RS_MSG_ENCRYPTED 0x1000 /* message is encrypted */
#define RS_MSG_SIGNATURE_CHECKS 0x2000 /* message was signed, and signature checked */
#define RS_MSG_SIGNED 0x4000 /* message was signed and signature didn't check */
#define RS_MSG_LOAD_EMBEDDED_IMAGES 0x8000 /* load embedded images */
#define RS_CHAT_LOBBY_EVENT_PEER_LEFT 0x01
#define RS_CHAT_LOBBY_EVENT_PEER_STATUS 0x02
@ -264,6 +265,7 @@ virtual bool MessageRead(const std::string &mid, bool unreadByUser) = 0;
virtual bool MessageReplied(const std::string &mid, bool replied) = 0;
virtual bool MessageForwarded(const std::string &mid, bool forwarded) = 0;
virtual bool MessageStar(const std::string &mid, bool mark) = 0;
virtual bool MessageLoadEmbeddedImages(const std::string &mid, bool load) = 0;
/* message tagging */

View File

@ -169,6 +169,11 @@ bool p3Msgs::MessageForwarded(const std::string &mid, bool forwarded)
return mMsgSrv->setMsgFlag(mid, forwarded ? RS_MSG_FLAGS_FORWARDED : 0, RS_MSG_FLAGS_FORWARDED);
}
bool p3Msgs::MessageLoadEmbeddedImages(const std::string &mid, bool load)
{
return mMsgSrv->setMsgFlag(mid, load ? RS_MSG_FLAGS_LOAD_EMBEDDED_IMAGES : 0, RS_MSG_FLAGS_LOAD_EMBEDDED_IMAGES);
}
bool p3Msgs::getMessageTagTypes(MsgTagType& tags)
{
return mMsgSrv->getMessageTagTypes(tags);

View File

@ -67,6 +67,7 @@ class p3Msgs: public RsMsgs
virtual bool MessageReplied(const std::string &mid, bool replied);
virtual bool MessageForwarded(const std::string &mid, bool forwarded);
virtual bool MessageStar(const std::string &mid, bool star);
virtual bool MessageLoadEmbeddedImages(const std::string &mid, bool load);
virtual bool getMsgParentId(const std::string &msgId, std::string &msgParentId);
virtual bool getMessageTagTypes(MsgTagType& tags);

View File

@ -431,6 +431,7 @@ const uint32_t RS_MSG_FLAGS_ENCRYPTED = 0x00004000;
const uint32_t RS_MSG_FLAGS_DISTANT = 0x00008000;
const uint32_t RS_MSG_FLAGS_SIGNATURE_CHECKS = 0x00010000;
const uint32_t RS_MSG_FLAGS_SIGNED = 0x00020000;
const uint32_t RS_MSG_FLAGS_LOAD_EMBEDDED_IMAGES = 0x00040000;
class RsMessageItem: public RsItem
{

View File

@ -362,7 +362,7 @@ bool p3Forums::ForumMessageSend(ForumMsgInfo &info)
// return id
info.msgId = mId;
return setMessageStatus(info.forumId, mId, FORUM_MSG_STATUS_READ, FORUM_MSG_STATUS_MASK);
return setMessageStatus(info.forumId, mId, FORUM_MSG_STATUS_READ | FORUM_MSG_STATUS_LOAD_EMBEDDED_IMAGES, FORUM_MSG_STATUS_MASK);
}
bool p3Forums::setMessageStatus(const std::string& fId,const std::string& mId,const uint32_t status, const uint32_t statusMask)

View File

@ -1539,6 +1539,10 @@ void p3MsgService::initRsMI(RsMsgItem *msg, MessageInfo &mi)
{
mi.msgflags |= RS_MSG_FRIEND_RECOMMENDATION;
}
if (msg->msgFlags & RS_MSG_FLAGS_LOAD_EMBEDDED_IMAGES)
{
mi.msgflags |= RS_MSG_LOAD_EMBEDDED_IMAGES;
}
mi.ts = msg->sendTime;
mi.srcId = msg->PeerId();
@ -1652,6 +1656,10 @@ void p3MsgService::initRsMIS(RsMsgItem *msg, MsgInfoSummary &mis)
{
mis.msgflags |= RS_MSG_FRIEND_RECOMMENDATION;
}
if (msg->msgFlags & RS_MSG_FLAGS_LOAD_EMBEDDED_IMAGES)
{
mis.msgflags |= RS_MSG_LOAD_EMBEDDED_IMAGES;
}
mis.srcId = msg->PeerId();
{
@ -1726,6 +1734,9 @@ RsMsgItem *p3MsgService::initMIRsMsg(MessageInfo &info, const std::string &to)
if (info.msgflags & RS_MSG_SIGNED)
msg->msgFlags |= RS_MSG_FLAGS_SIGNED;
/* load embedded images from own messages */
msg->msgFlags |= RS_MSG_FLAGS_LOAD_EMBEDDED_IMAGES;
// See if we need to encrypt this message. If so, we replace the msg text
// by the whole message serialized and binary encrypted, so as to obfuscate
// all its content.

View File

@ -139,6 +139,7 @@ ForumsDialog::ForumsDialog(QWidget *parent)
connect(NotifyQt::getInstance(), SIGNAL(forumMsgReadSatusChanged(QString,QString,int)), this, SLOT(forumMsgReadSatusChanged(QString,QString,int)));
ui.imageBlockWidget->addButtonAction(tr("Load images always for this message"), this, SLOT(loadImagesAlways()), true);
ui.postText->setImageBlockWidget(ui.imageBlockWidget);
/* Set initial size the splitter */
@ -481,11 +482,11 @@ void ForumsDialog::togglethreadview()
void ForumsDialog::togglethreadview_internal()
{
if (ui.expandButton->isChecked()) {
ui.postText->setVisible(true);
ui.postFrame->setVisible(true);
ui.expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png")));
ui.expandButton->setToolTip(tr("Hide"));
} else {
ui.postText->setVisible(false);
ui.postFrame->setVisible(false);
ui.expandButton->setIcon(QIcon(QString(":/images/edit_add24.png")));
ui.expandButton->setToolTip(tr("Expand"));
}
@ -1210,7 +1211,16 @@ void ForumsDialog::insertPost()
QString extraTxt = RsHtml().formatText(ui.postText->document(), messageFromInfo(msg), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS);
ui.postText->resetImagesStatus(Settings->getForumLoadEmbeddedImages());
bool loadEmbeddedImages = Settings->getForumLoadEmbeddedImages();
if (!loadEmbeddedImages) {
uint32_t status = 0;
rsForums->getMessageStatus(mCurrForumId, mCurrThreadId, status);
if (status & FORUM_MSG_STATUS_LOAD_EMBEDDED_IMAGES) {
loadEmbeddedImages = true;
}
}
ui.postText->resetImagesStatus(loadEmbeddedImages);
ui.postText->setHtml(extraTxt);
ui.threadTitle->setText(titleFromInfo(msg));
}
@ -2119,3 +2129,12 @@ void ForumsFillThread::run()
std::cerr << "ForumsFillThread::run() stopped: " << (wasStopped() ? "yes" : "no") << std::endl;
#endif
}
void ForumsDialog::loadImagesAlways()
{
if (mCurrForumId.empty() || mCurrThreadId.empty()) {
return;
}
rsForums->setMessageStatus(mCurrForumId, mCurrThreadId, FORUM_MSG_STATUS_LOAD_EMBEDDED_IMAGES, FORUM_MSG_STATUS_LOAD_EMBEDDED_IMAGES);
}

View File

@ -128,6 +128,8 @@ private slots:
void shareKey();
void loadImagesAlways();
private:
void insertForums();
void insertThreads();

View File

@ -113,8 +113,8 @@
<enum>Qt::Vertical</enum>
</property>
<widget class="QWidget" name="layoutWidget">
<layout class="QGridLayout">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QFrame" name="toolBarFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
@ -200,7 +200,7 @@
</layout>
</widget>
</item>
<item row="1" column="0">
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="label_17">
@ -278,7 +278,54 @@
</item>
</layout>
</item>
<item row="4" column="0">
<item>
<widget class="QTreeWidget" name="threadTreeWidget">
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="allColumnsShowFocus">
<bool>true</bool>
</property>
<column>
<property name="text">
<string>Title</string>
</property>
</column>
<column>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/message-state-header.png</normaloff>:/images/message-state-header.png</iconset>
</property>
</column>
<column>
<property name="text">
<string>Date</string>
</property>
</column>
<column>
<property name="text">
<string>Author</string>
</property>
</column>
<column>
<property name="text">
<string>Signed</string>
</property>
</column>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="progressBarLayOut">
<item>
<widget class="QLabel" name="progLayOutTxt">
@ -311,7 +358,7 @@
</item>
</layout>
</item>
<item row="5" column="0">
<item>
<layout class="QGridLayout">
<item row="0" column="1">
<widget class="QLabel" name="threadlabel">
@ -487,60 +534,16 @@
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QTreeWidget" name="threadTreeWidget">
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="allColumnsShowFocus">
<bool>true</bool>
</property>
<column>
<property name="text">
<string>Title</string>
</property>
</column>
<column>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/message-state-header.png</normaloff>:/images/message-state-header.png</iconset>
</property>
</column>
<column>
<property name="text">
<string>Date</string>
</property>
</column>
<column>
<property name="text">
<string>Author</string>
</property>
</column>
<column>
<property name="text">
<string>Signed</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="verticalLayoutWidget">
<layout class="QVBoxLayout" name="postLayout">
<widget class="QFrame" name="postFrame">
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>2</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="RSImageBlockWidget" name="imageBlockWidget" native="true">
<property name="sizePolicy">

View File

@ -1,3 +1,26 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2013 RetroShare Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#include <QMenu>
#include "RSImageBlockWidget.h"
#include "ui_RSImageBlockWidget.h"
@ -14,3 +37,30 @@ RSImageBlockWidget::~RSImageBlockWidget()
{
delete ui;
}
void RSImageBlockWidget::addButtonAction(const QString &text, const QObject *receiver, const char *member, bool standardAction)
{
QMenu *menu = ui->loadImagesButton->menu();
if (!menu) {
/* Set popup mode */
ui->loadImagesButton->setPopupMode(QToolButton::MenuButtonPopup);
ui->loadImagesButton->setIcon(ui->loadImagesButton->icon()); // Sometimes Qt doesn't recalculate sizeHint
/* Create popup menu */
menu = new QMenu;
ui->loadImagesButton->setMenu(menu);
/* Add 'click' action as action */
QAction *action = menu->addAction(ui->loadImagesButton->text(), this, SIGNAL(showImages()));
menu->setDefaultAction(action);
}
/* Add new action */
QAction *action = menu->addAction(text, receiver, member);
ui->loadImagesButton->addAction(action);
if (standardAction) {
/* Connect standard action */
connect(action, SIGNAL(triggered()), this, SIGNAL(showImages()));
}
}

View File

@ -1,3 +1,24 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2013 RetroShare Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#ifndef RSIMAGEBLOCKWIDGET_H
#define RSIMAGEBLOCKWIDGET_H
@ -15,6 +36,8 @@ public:
explicit RSImageBlockWidget(QWidget *parent = 0);
~RSImageBlockWidget();
void addButtonAction(const QString &text, const QObject *receiver, const char *member, bool standardAction);
signals:
void showImages();

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>476</width>
<height>37</height>
<height>34</height>
</rect>
</property>
<property name="windowTitle">
@ -110,14 +110,14 @@
</property>
<property name="sizeHint" stdset="0">
<size>
<width>162</width>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="loadImagesButton">
<widget class="QToolButton" name="loadImagesButton">
<property name="text">
<string>Load images</string>
</property>

View File

@ -135,6 +135,7 @@ MessageWidget::MessageWidget(bool controlled, QWidget *parent, Qt::WFlags flags)
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);
/* hide the Tree +/- */
@ -560,7 +561,7 @@ void MessageWidget::fill(const std::string &msgId)
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());
ui.msgText->resetImagesStatus(Settings->getMsgLoadEmbeddedImages() || (msgInfo.msgflags & RS_MSG_LOAD_EMBEDDED_IMAGES));
ui.msgText->setHtml(text);
ui.filesText->setText(QString("(%1 %2)").arg(msgInfo.count).arg(msgInfo.count == 1 ? tr("File") : tr("Files")));
@ -713,3 +714,12 @@ void MessageWidget::anchorClicked(const QUrl &url)
links.append(link);
RetroShareLink::process(links);
}
void MessageWidget::loadImagesAlways()
{
if (currMsgId.empty()) {
return;
}
rsMsgs->MessageLoadEmbeddedImages(currMsgId, true);
}

View File

@ -78,6 +78,8 @@ private slots:
void anchorClicked(const QUrl &url);
void loadImagesAlways();
private:
void clearTagLabels();
void showTagLabels();

View File

@ -1343,22 +1343,6 @@ Please choose one of it to chat with.</source>
<source>Selected lobby info</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Lobby name: </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Lobby Id: </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Topic: </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Type: </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Private</source>
<translation type="unfinished"></translation>
@ -1367,22 +1351,10 @@ Please choose one of it to chat with.</source>
<source>Public</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Peers: </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>You&apos;re not subscribed to this lobby; Double click-it to enter and chat.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No lobby selected.
Select lobbies at left to show details.
Double click lobbies to enter and chat.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Invitation to chat lobby</source>
<translation type="unfinished"></translation>
@ -1435,6 +1407,36 @@ Double click lobbies to enter and chat.</source>
<source>No</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Lobby Name:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Lobby Id:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Topic:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Type:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Peers:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>TextLabel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>No lobby selected.
Select lobbies at left to show details.
Double click lobbies to enter and chat.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChatMsgItem</name>
@ -5671,6 +5673,10 @@ p, li { white-space: pre-wrap; }
<source> &lt;h1&gt;&lt;img width=&quot;32&quot; src=&quot;:/images/64px_help.png&quot;&gt;&amp;nbsp;&amp;nbsp;Forums&lt;/h1&gt; &lt;p&gt;Retroshare Forums look like internet forums, but they work in a decentralized way: You see forums your friends are subscribed to, and you forward subscribed forums to your friends. This automatically promotes interesting forums in the network.&lt;/p&gt; &lt;p&gt;Forums are either Authenticated (&lt;img src=&quot;:/images/konv_message2.png&quot; width=&quot;12&quot;/&gt;) in which case you need to cryptographically sign your posts, or anonymous (&lt;img src=&quot;:/images/konversation.png&quot; width=&quot;12&quot;/&gt;). The former class is more resistant to spamming.&lt;/p&gt; &lt;p&gt;Forum posts propagate from friend to friend using small cache file exchanges. When you first connect to a new friend, it&apos;s likely you will receive many such cache files, and new forums will appear. &lt;/p&gt; </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Load images always for this message</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ForumsFillThread</name>
@ -6269,10 +6275,6 @@ anonymous, you can use a fake email.</source>
<source>Location</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Put a meaningful location. ex : home, laptop, etc. This field will be used to differentiate different installations with the same identity (PGP key).</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Create new identity</source>
<translation type="unfinished"></translation>
@ -6423,6 +6425,28 @@ Fill in your PGP password when asked, to sign your new key.</source>
<source>Failed to Generate your new Certificate, maybe PGP password is wrong!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Password (check)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;justify&quot;&gt;Before proceeding, move your mouse around to help Retroshare collect as much randomness as possible. Filling the progressbar to 20% is needed, 100% is advised.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>[Required] Type the same password again here.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Put a meaningful location. ex : home, laptop, etc.
This field will be used to differentiate different installations with
the same identity (PGP key).</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Passwords to not match</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>GeneralPage</name>
@ -9075,6 +9099,10 @@ Do you want to save message ?</source>
<source>HTML-Files (*.htm *.html);;All Files (*)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Load images always for this message</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MessageWindow</name>