Added api for news feeds to the plugin interface.

Added news feeds to the FeedReader plugin.
Recompile needed.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6066 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2013-01-08 22:07:52 +00:00
parent f12473f7f7
commit a60422069c
21 changed files with 1080 additions and 99 deletions

View File

@ -52,6 +52,7 @@ class RsPQIService ;
class RsAutoUpdatePage ; class RsAutoUpdatePage ;
class PopupChatDialog ; class PopupChatDialog ;
class SoundEvents; class SoundEvents;
class FeedNotify;
// Plugin API version. Not used yet, but will be in the future the // Plugin API version. Not used yet, but will be in the future the
// main value that decides for compatibility. // main value that decides for compatibility.
@ -94,12 +95,12 @@ class RsPlugin
//================================ Services ==================================// //================================ Services ==================================//
// //
// Cache service. Use this for providing cache-based services, such as channels, forums. // Cache service. Use this for providing cache-based services, such as channels, forums.
// Example plugin: LinksCloud // Example plugin: LinksCloud
// //
virtual RsCacheService *rs_cache_service() const { return NULL ; } virtual RsCacheService *rs_cache_service() const { return NULL ; }
// Peer-to-Peer service. Use this for providing a service based to friend to friend // Peer-to-Peer service. Use this for providing a service based to friend to friend
// exchange of data, such as chat, messages, etc. // exchange of data, such as chat, messages, etc.
// Example plugin: VOIP // Example plugin: VOIP
// //
virtual RsPQIService *rs_pqi_service() const { return NULL ; } virtual RsPQIService *rs_pqi_service() const { return NULL ; }
@ -133,13 +134,18 @@ class RsPlugin
// Any derived class of PopupChatDialog to be used for chat. // Any derived class of PopupChatDialog to be used for chat.
// //
virtual PopupChatDialog *qt_allocate_new_popup_chat_dialog() const { return NULL ; } virtual PopupChatDialog *qt_allocate_new_popup_chat_dialog() const { return NULL ; }
virtual QTranslator *qt_translator(QApplication * /* app */, const QString& /* languageCode */, const QString& /* externalDir */ ) const { return NULL ; } virtual QTranslator *qt_translator(QApplication * /* app */, const QString& /* languageCode */, const QString& /* externalDir */ ) const { return NULL ; }
// //
//================================== Notify ==================================//
//
virtual FeedNotify *qt_feedNotify() { return NULL; }
//
//========================== Plugin Description ==============================// //========================== Plugin Description ==============================//
// //
// All these items appear in the config->plugins tab, as a description of the plugin. // All these items appear in the config->plugins tab, as a description of the plugin.
// //
uint32_t getSvnRevision() const { return SVN_REVISION_NUMBER ; } // This is read from libretroshare/util/rsversion.h uint32_t getSvnRevision() const { return SVN_REVISION_NUMBER ; } // This is read from libretroshare/util/rsversion.h
@ -148,9 +154,9 @@ class RsPlugin
virtual std::string getPluginName() const = 0 ; virtual std::string getPluginName() const = 0 ;
virtual void getPluginVersion(int& major,int& minor,int& svn_rev) const = 0 ; virtual void getPluginVersion(int& major,int& minor,int& svn_rev) const = 0 ;
// //
//========================== Plugin Interface ================================// //========================== Plugin Interface ================================//
// //
// Use these methods to access main objects from RetroShare. // Use these methods to access main objects from RetroShare.
// //
virtual void setInterfaces(RsPlugInInterfaces& interfaces) = 0; virtual void setInterfaces(RsPlugInInterfaces& interfaces) = 0;

View File

@ -13,7 +13,9 @@ SOURCES = FeedReaderPlugin.cpp \
gui/FeedReaderNotify.cpp \ gui/FeedReaderNotify.cpp \
gui/FeedReaderConfig.cpp \ gui/FeedReaderConfig.cpp \
gui/FeedReaderStringDefs.cpp \ gui/FeedReaderStringDefs.cpp \
gui/FeedReaderFeedNotify.cpp \
gui/FeedReaderUserNotify.cpp \ gui/FeedReaderUserNotify.cpp \
gui/FeedReaderFeedItem.cpp \
util/CURLWrapper.cpp \ util/CURLWrapper.cpp \
util/XMLWrapper.cpp \ util/XMLWrapper.cpp \
util/HTMLWrapper.cpp \ util/HTMLWrapper.cpp \
@ -31,7 +33,9 @@ HEADERS = FeedReaderPlugin.h \
gui/FeedReaderNotify.h \ gui/FeedReaderNotify.h \
gui/FeedReaderConfig.h \ gui/FeedReaderConfig.h \
gui/FeedReaderStringDefs.h \ gui/FeedReaderStringDefs.h \
gui/FeedReaderFeedNotify.h \
gui/FeedReaderUserNotify.h \ gui/FeedReaderUserNotify.h \
gui/FeedReaderFeedItem.h \
util/CURLWrapper.h \ util/CURLWrapper.h \
util/XMLWrapper.h \ util/XMLWrapper.h \
util/HTMLWrapper.h \ util/HTMLWrapper.h \
@ -41,7 +45,8 @@ FORMS = gui/FeedReaderDialog.ui \
gui/FeedReaderMessageWidget.ui \ gui/FeedReaderMessageWidget.ui \
gui/AddFeedDialog.ui \ gui/AddFeedDialog.ui \
gui/PreviewFeedDialog.ui \ gui/PreviewFeedDialog.ui \
gui/FeedReaderConfig.ui gui/FeedReaderConfig.ui \
gui/FeedReaderFeedItem.ui
TARGET = FeedReader TARGET = FeedReader

View File

@ -27,7 +27,9 @@
#include "FeedReaderPlugin.h" #include "FeedReaderPlugin.h"
#include "gui/FeedReaderDialog.h" #include "gui/FeedReaderDialog.h"
#include "gui/FeedReaderNotify.h"
#include "gui/FeedReaderConfig.h" #include "gui/FeedReaderConfig.h"
#include "gui/FeedReaderFeedNotify.h"
#include "services/p3FeedReader.h" #include "services/p3FeedReader.h"
#define IMAGE_FEEDREADER ":/images/FeedReader.png" #define IMAGE_FEEDREADER ":/images/FeedReader.png"
@ -77,6 +79,8 @@ FeedReaderPlugin::FeedReaderPlugin()
mIcon = NULL ; mIcon = NULL ;
mPlugInHandler = NULL; mPlugInHandler = NULL;
mFeedReader = NULL; mFeedReader = NULL;
mNotify = NULL;
mFeedNotify = NULL;
} }
void FeedReaderPlugin::setInterfaces(RsPlugInInterfaces &/*interfaces*/) void FeedReaderPlugin::setInterfaces(RsPlugInInterfaces &/*interfaces*/)
@ -91,17 +95,28 @@ ConfigPage *FeedReaderPlugin::qt_config_page() const
MainPage *FeedReaderPlugin::qt_page() const MainPage *FeedReaderPlugin::qt_page() const
{ {
if (mainpage == NULL) { if (mainpage == NULL) {
mainpage = new FeedReaderDialog(mFeedReader); mainpage = new FeedReaderDialog(mFeedReader, mNotify);
} }
return mainpage; return mainpage;
} }
FeedNotify *FeedReaderPlugin::qt_feedNotify()
{
if (!mFeedNotify) {
mFeedNotify = new FeedReaderFeedNotify(mFeedReader, mNotify);
}
return mFeedNotify;
}
RsPQIService *FeedReaderPlugin::rs_pqi_service() const RsPQIService *FeedReaderPlugin::rs_pqi_service() const
{ {
if (mFeedReader == NULL) { if (mFeedReader == NULL) {
mFeedReader = new p3FeedReader(mPlugInHandler); mFeedReader = new p3FeedReader(mPlugInHandler);
rsFeedReader = mFeedReader; rsFeedReader = mFeedReader;
mNotify = new FeedReaderNotify();
mFeedReader->setNotify(mNotify);
} }
return mFeedReader; return mFeedReader;
@ -110,8 +125,17 @@ RsPQIService *FeedReaderPlugin::rs_pqi_service() const
void FeedReaderPlugin::stop() void FeedReaderPlugin::stop()
{ {
if (mFeedReader) { if (mFeedReader) {
mFeedReader->setNotify(NULL);
mFeedReader->stop(); mFeedReader->stop();
} }
if (mNotify) {
delete(mNotify);
mNotify = NULL;
}
if (mFeedNotify) {
delete mFeedNotify;
mFeedNotify = NULL;
}
} }
void FeedReaderPlugin::setPlugInHandler(RsPluginHandler *pgHandler) void FeedReaderPlugin::setPlugInHandler(RsPluginHandler *pgHandler)

View File

@ -27,6 +27,7 @@
#include "services/p3FeedReader.h" #include "services/p3FeedReader.h"
class p3FeedReader; class p3FeedReader;
class FeedReaderNotify;
class RsForums; class RsForums;
class FeedReaderPlugin: public RsPlugin class FeedReaderPlugin: public RsPlugin
@ -52,10 +53,13 @@ public:
virtual void setInterfaces(RsPlugInInterfaces& interfaces); virtual void setInterfaces(RsPlugInInterfaces& interfaces);
virtual ConfigPage *qt_config_page() const; virtual ConfigPage *qt_config_page() const;
virtual FeedNotify *qt_feedNotify();
private: private:
mutable p3FeedReader *mFeedReader; mutable p3FeedReader *mFeedReader;
mutable FeedReaderNotify *mNotify;
mutable RsPluginHandler *mPlugInHandler; mutable RsPluginHandler *mPlugInHandler;
mutable MainPage *mainpage; mutable MainPage *mainpage;
mutable QIcon *mIcon; mutable QIcon *mIcon;
mutable FeedNotify *mFeedNotify;
}; };

View File

@ -55,8 +55,8 @@
#define ROLE_FEED_ERROR Qt::UserRole + 8 #define ROLE_FEED_ERROR Qt::UserRole + 8
#define ROLE_FEED_DEACTIVATED Qt::UserRole + 9 #define ROLE_FEED_DEACTIVATED Qt::UserRole + 9
FeedReaderDialog::FeedReaderDialog(RsFeedReader *feedReader, QWidget *parent) FeedReaderDialog::FeedReaderDialog(RsFeedReader *feedReader, FeedReaderNotify *notify, QWidget *parent)
: MainPage(parent), mFeedReader(feedReader), ui(new Ui::FeedReaderDialog) : MainPage(parent), mFeedReader(feedReader), mNotify(notify), ui(new Ui::FeedReaderDialog)
{ {
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
ui->setupUi(this); ui->setupUi(this);
@ -65,8 +65,6 @@ FeedReaderDialog::FeedReaderDialog(RsFeedReader *feedReader, QWidget *parent)
mOpenFeedIds = NULL; mOpenFeedIds = NULL;
mMessageWidget = NULL; mMessageWidget = NULL;
mNotify = new FeedReaderNotify();
mFeedReader->setNotify(mNotify);
connect(mNotify, SIGNAL(feedChanged(QString,int)), this, SLOT(feedChanged(QString,int))); connect(mNotify, SIGNAL(feedChanged(QString,int)), this, SLOT(feedChanged(QString,int)));
connect(mNotify, SIGNAL(msgChanged(QString,QString,int)), this, SLOT(msgChanged(QString,QString,int))); connect(mNotify, SIGNAL(msgChanged(QString,QString,int)), this, SLOT(msgChanged(QString,QString,int)));
@ -126,9 +124,6 @@ FeedReaderDialog::~FeedReaderDialog()
delete(mFeedCompareRole); delete(mFeedCompareRole);
delete(ui); delete(ui);
mFeedReader->setNotify(NULL);
delete(mNotify);
if (mOpenFeedIds) { if (mOpenFeedIds) {
delete mOpenFeedIds; delete mOpenFeedIds;
mOpenFeedIds = NULL; mOpenFeedIds = NULL;

View File

@ -40,7 +40,7 @@ class FeedReaderDialog : public MainPage
Q_OBJECT Q_OBJECT
public: public:
FeedReaderDialog(RsFeedReader *feedReader, QWidget *parent = 0); FeedReaderDialog(RsFeedReader *feedReader, FeedReaderNotify *notify, QWidget *parent = 0);
~FeedReaderDialog(); ~FeedReaderDialog();
virtual UserNotify *getUserNotify(QObject *parent); virtual UserNotify *getUserNotify(QObject *parent);

View File

@ -0,0 +1,166 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2012 by Thunder
*
* 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 <QUrl>
#include <QClipboard>
#include <QDesktopServices>
#include "FeedReaderFeedItem.h"
#include "ui_FeedReaderFeedItem.h"
#include "FeedReaderNotify.h"
#include "util/DateTime.h"
#include "gui/feeds/FeedHolder.h"
/** Constructor */
FeedReaderFeedItem::FeedReaderFeedItem(RsFeedReader *feedReader, FeedReaderNotify *notify, FeedHolder *parent, const FeedInfo &feedInfo, const FeedMsgInfo &msgInfo)
: QWidget(NULL), mFeedReader(feedReader), mNotify(notify), mParent(parent), ui(new Ui::FeedReaderFeedItem)
{
/* Invoke the Qt Designer generated object setup routine */
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose, true);
connect(ui->expandButton, SIGNAL(clicked(void)), this, SLOT(toggle(void)));
connect(ui->clearButton, SIGNAL(clicked(void)), this, SLOT(removeItem(void)));
connect(ui->readAndClearButton, SIGNAL(clicked()), this, SLOT(readAndClearItem()));
connect(ui->linkButton, SIGNAL(clicked()), this, SLOT(openLink()));
connect(mNotify, SIGNAL(msgChanged(QString,QString,int)), this, SLOT(msgChanged(QString,QString,int)), Qt::QueuedConnection);
ui->expandFrame->hide();
mFeedId = feedInfo.feedId;
mMsgId = msgInfo.msgId;
ui->titleLabel->setText(QString::fromUtf8(feedInfo.name.c_str()));
ui->msgTitleLabel->setText(QString::fromUtf8(msgInfo.title.c_str()));
ui->descriptionLabel->setText(QString::fromUtf8(msgInfo.description.c_str()));
ui->dateTimeLabel->setText(DateTime::formatLongDateTime(msgInfo.pubDate));
/* build menu for link button */
mLink = QString::fromUtf8(msgInfo.link.c_str());
if (mLink.isEmpty()) {
ui->linkButton->setEnabled(false);
} else {
QMenu *menu = new QMenu(this);
QAction *action = menu->addAction(tr("Open link in browser"), this, SLOT(openLink()));
menu->addAction(tr("Copy link to clipboard"), this, SLOT(copyLink()));
QFont font = action->font();
font.setBold(true);
action->setFont(font);
ui->linkButton->setMenu(menu);
}
}
FeedReaderFeedItem::~FeedReaderFeedItem()
{
delete(ui);
}
void FeedReaderFeedItem::toggle()
{
mParent->lockLayout(this, true);
if (ui->expandFrame->isHidden()) {
ui->expandFrame->show();
ui->expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png")));
ui->expandButton->setToolTip(tr("Hide"));
setMsgRead();
} else {
ui->expandFrame->hide();
ui->expandButton->setIcon(QIcon(QString(":/images/edit_add24.png")));
ui->expandButton->setToolTip(tr("Expand"));
}
mParent->lockLayout(this, false);
}
void FeedReaderFeedItem::removeItem()
{
mParent->lockLayout(this, true);
hide();
mParent->lockLayout(this, false);
if (mParent) {
mParent->deleteFeedItem(this, 0);
}
}
/*********** SPECIFIC FUNCTIONS ***********************/
void FeedReaderFeedItem::readAndClearItem()
{
setMsgRead();
removeItem();
}
void FeedReaderFeedItem::setMsgRead()
{
disconnect(mNotify, SIGNAL(msgChanged(QString,QString,int)), this, SLOT(msgChanged(QString,QString,int)));
mFeedReader->setMessageRead(mFeedId, mMsgId, true);
connect(mNotify, SIGNAL(msgChanged(QString,QString,int)), this, SLOT(msgChanged(QString,QString,int)), Qt::QueuedConnection);
}
void FeedReaderFeedItem::msgChanged(const QString &feedId, const QString &msgId, int /*type*/)
{
if (feedId.toStdString() != mFeedId) {
return;
}
if (msgId.toStdString() != mMsgId) {
return;
}
FeedMsgInfo msgInfo;
if (!mFeedReader->getMsgInfo(mFeedId, mMsgId, msgInfo)) {
return;
}
if (!msgInfo.flag.isnew) {
close();
return;
}
}
void FeedReaderFeedItem::copyLink()
{
if (mLink.isEmpty()) {
return;
}
QApplication::clipboard()->setText(mLink);
}
void FeedReaderFeedItem::openLink()
{
if (mLink.isEmpty()) {
return;
}
QDesktopServices::openUrl(QUrl(mLink));
}

View File

@ -0,0 +1,70 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2013 by Thunder
*
* 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 _FEEDREADERFEEDITEM_H
#define _FEEDREADERFEEDITEM_H
#include <QWidget>
namespace Ui {
class FeedReaderFeedItem;
}
class RsFeedReader;
class FeedReaderNotify;
class FeedHolder;
class FeedInfo;
class FeedMsgInfo;
class FeedReaderFeedItem : public QWidget
{
Q_OBJECT
public:
FeedReaderFeedItem(RsFeedReader *feedReader, FeedReaderNotify *notify, FeedHolder *parent, const FeedInfo &feedInfo, const FeedMsgInfo &msgInfo);
~FeedReaderFeedItem();
private slots:
/* default stuff */
void removeItem();
void toggle();
void readAndClearItem();
void copyLink();
void openLink();
void msgChanged(const QString &feedId, const QString &msgId, int type);
private:
void setMsgRead();
RsFeedReader *mFeedReader;
FeedReaderNotify *mNotify;
FeedHolder *mParent;
std::string mFeedId;
std::string mMsgId;
QString mLink;
Ui::FeedReaderFeedItem *ui;
};
#endif // _FEEDREADERFEEDITEM_H

View File

@ -0,0 +1,321 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FeedReaderFeedItem</class>
<widget class="QWidget" name="FeedReaderFeedItem">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>629</width>
<height>121</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<property name="leftMargin">
<number>1</number>
</property>
<property name="topMargin">
<number>1</number>
</property>
<property name="rightMargin">
<number>1</number>
</property>
<property name="bottomMargin">
<number>1</number>
</property>
<property name="horizontalSpacing">
<number>6</number>
</property>
<property name="verticalSpacing">
<number>1</number>
</property>
<item row="0" column="0">
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="logoLabel">
<property name="maximumSize">
<size>
<width>48</width>
<height>48</height>
</size>
</property>
<property name="pixmap">
<pixmap resource="FeedReader_images.qrc">:/images/FeedReader.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="titleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true">Feed name</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="dateTimeLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
<stylestrategy>PreferAntialias</stylestrategy>
</font>
</property>
<property name="text">
<string notr="true">DateTime</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>8</number>
</property>
<item>
<widget class="QLabel" name="msgTitleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>60</height>
</size>
</property>
<property name="text">
<string notr="true">&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:'MS Shell Dlg 2'; 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; color:#666666;&quot;&gt;Short Description&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="linkButton">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="icon">
<iconset resource="FeedReader_images.qrc">
<normaloff>:/images/Link.png</normaloff>:/images/Link.png</iconset>
</property>
<property name="popupMode">
<enum>QToolButton::MenuButtonPopup</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="expandButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Expand</string>
</property>
<property name="icon">
<iconset resource="../../../retroshare-gui/src/gui/images.qrc">
<normaloff>:/images/edit_add24.png</normaloff>:/images/edit_add24.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="readAndClearButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Set as read and remove item</string>
</property>
<property name="icon">
<iconset resource="../../../retroshare-gui/src/gui/images.qrc">
<normaloff>:/images/cancel.png</normaloff>:/images/cancel.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="clearButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Remove Item</string>
</property>
<property name="icon">
<iconset resource="../../../retroshare-gui/src/gui/images.qrc">
<normaloff>:/images/close_normal.png</normaloff>:/images/close_normal.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QFrame" name="expandFrame">
<layout class="QVBoxLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="msgFrame">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="QLabel" name="descriptionLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="margin">
<number>6</number>
</property>
<property name="indent">
<number>-1</number>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="FeedReader_images.qrc"/>
<include location="../../../retroshare-gui/src/gui/images.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -0,0 +1,118 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2012 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 <QMutex>
#include "FeedReaderFeedNotify.h"
#include "FeedReaderNotify.h"
#include "FeedReaderFeedItem.h"
#include "gui/settings/rsharesettings.h"
#include "retroshare/rsiface.h"
FeedReaderFeedNotify::FeedReaderFeedNotify(RsFeedReader *feedReader, FeedReaderNotify *notify, QObject *parent) :
FeedNotify(parent), mFeedReader(feedReader), mNotify(notify)
{
mMutex = new QMutex();
connect(mNotify, SIGNAL(msgChanged(QString,QString,int)), this, SLOT(msgChanged(QString,QString,int)), Qt::QueuedConnection);
}
FeedReaderFeedNotify::~FeedReaderFeedNotify()
{
delete(mMutex);
}
bool FeedReaderFeedNotify::hasSetting(QString &name)
{
name = tr("Feed Reader");
return true;
}
bool FeedReaderFeedNotify::notifyEnabled()
{
return Settings->valueFromGroup("FeedReader", "FeedNotifyEnable", false).toBool();
}
void FeedReaderFeedNotify::setNotifyEnabled(bool enabled)
{
Settings->setValueToGroup("FeedReader", "FeedNotifyEnable", enabled);
if (!enabled) {
/* remove pending feed items */
mMutex->lock();
mPendingNewsFeed.clear();
mMutex->unlock();
}
}
void FeedReaderFeedNotify::msgChanged(const QString &feedId, const QString &msgId, int type)
{
if (feedId.isEmpty() || msgId.isEmpty()) {
return;
}
if (type != NOTIFY_TYPE_ADD) {
return;
}
if (!notifyEnabled()) {
return;
}
mMutex->lock();
FeedItem feedItem;
feedItem.mFeedId = feedId;
feedItem.mMsgId = msgId;
mPendingNewsFeed.push_back(feedItem);
mMutex->unlock();
}
QWidget *FeedReaderFeedNotify::feedItem(FeedHolder *parent)
{
bool msgPending = false;
FeedInfo feedInfo;
FeedMsgInfo msgInfo;
mMutex->lock();
while (!mPendingNewsFeed.empty()) {
FeedItem feedItem = mPendingNewsFeed.front();
mPendingNewsFeed.pop_front();
if (mFeedReader->getFeedInfo(feedItem.mFeedId.toStdString(), feedInfo) &&
mFeedReader->getMsgInfo(feedItem.mFeedId.toStdString(), feedItem.mMsgId.toStdString(), msgInfo)) {
if (msgInfo.flag.isnew) {
msgPending = true;
break;
}
}
}
mMutex->unlock();
if (!msgPending) {
return NULL;
}
return new FeedReaderFeedItem(mFeedReader, mNotify, parent, feedInfo, msgInfo);
}

View File

@ -0,0 +1,65 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2012 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 FEEDREADERFEEDNOTIFY_H
#define FEEDREADERFEEDNOTIFY_H
#include "gui/common/FeedNotify.h"
class RsFeedReader;
class FeedReaderNotify;
class QMutex;
class FeedReaderFeedNotify : public FeedNotify
{
Q_OBJECT
protected:
class FeedItem
{
public:
FeedItem() {}
public:
QString mFeedId;
QString mMsgId;
};
public:
FeedReaderFeedNotify(RsFeedReader *feedReader, FeedReaderNotify *notify, QObject *parent = 0);
~FeedReaderFeedNotify();
virtual bool hasSetting(QString &name);
virtual bool notifyEnabled();
virtual void setNotifyEnabled(bool enabled);
virtual QWidget *feedItem(FeedHolder *parent);
private slots:
void msgChanged(const QString &feedId, const QString &msgId, int type);
private:
RsFeedReader *mFeedReader;
FeedReaderNotify *mNotify;
QMutex *mMutex;
QList<FeedItem> mPendingNewsFeed;
};
#endif // FEEDREADERFEEDNOTIFY_H

View File

@ -42,40 +42,22 @@ bool FeedReaderUserNotify::hasSetting(QString &name)
bool FeedReaderUserNotify::notifyEnabled() bool FeedReaderUserNotify::notifyEnabled()
{ {
bool enable = true; return Settings->valueFromGroup("FeedReader", "TrayNotifyEnable", true).toBool();
Settings->beginGroup(QString("FeedReader"));
enable = Settings->value("TrayNotifyEnable", enable).toBool();
Settings->endGroup();
return enable;
} }
bool FeedReaderUserNotify::notifyCombined() bool FeedReaderUserNotify::notifyCombined()
{ {
bool combined = false; return Settings->valueFromGroup("FeedReader", "TrayNotifyCombined", false).toBool();
Settings->beginGroup(QString("FeedReader"));
combined = Settings->value("TrayNotifyCombined", combined).toBool();
Settings->endGroup();
return combined;
} }
bool FeedReaderUserNotify::notifyBlink() bool FeedReaderUserNotify::notifyBlink()
{ {
bool blink = false; return Settings->valueFromGroup("FeedReader", "TrayNotifyBlink", false).toBool();
Settings->beginGroup(QString("FeedReader"));
blink = Settings->value("TrayNotifyBlink", blink).toBool();
Settings->endGroup();
return blink;
} }
void FeedReaderUserNotify::setNotifyEnabled(bool enabled, bool combined, bool blink) void FeedReaderUserNotify::setNotifyEnabled(bool enabled, bool combined, bool blink)
{ {
Settings->beginGroup(QString("FeedReader")); Settings->beginGroup("FeedReader");
Settings->setValue("TrayNotifyEnable", enabled); Settings->setValue("TrayNotifyEnable", enabled);
Settings->setValue("TrayNotifyCombined", combined); Settings->setValue("TrayNotifyCombined", combined);
Settings->setValue("TrayNotifyBlink", blink); Settings->setValue("TrayNotifyBlink", blink);

View File

@ -287,113 +287,155 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/FeedReaderDialog.cpp" line="95"/> <location filename="../gui/FeedReaderDialog.cpp" line="93"/>
<source>Message Folders</source> <source>Message Folders</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/FeedReaderDialog.cpp" line="292"/> <location filename="../gui/FeedReaderDialog.cpp" line="287"/>
<source>New</source> <source>New</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/FeedReaderDialog.cpp" line="293"/> <location filename="../gui/FeedReaderDialog.cpp" line="288"/>
<source>Feed</source> <source>Feed</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/FeedReaderDialog.cpp" line="297"/> <location filename="../gui/FeedReaderDialog.cpp" line="292"/>
<source>Folder</source> <source>Folder</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/FeedReaderDialog.cpp" line="305"/> <location filename="../gui/FeedReaderDialog.cpp" line="300"/>
<source>Open in new tab</source> <source>Open in new tab</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/FeedReaderDialog.cpp" line="313"/> <location filename="../gui/FeedReaderDialog.cpp" line="308"/>
<source>Edit</source> <source>Edit</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/FeedReaderDialog.cpp" line="318"/> <location filename="../gui/FeedReaderDialog.cpp" line="313"/>
<source>Delete</source> <source>Delete</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/FeedReaderDialog.cpp" line="330"/> <location filename="../gui/FeedReaderDialog.cpp" line="325"/>
<source>Update</source> <source>Update</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/FeedReaderDialog.cpp" line="333"/> <location filename="../gui/FeedReaderDialog.cpp" line="328"/>
<source>Activate</source> <source>Activate</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/FeedReaderDialog.cpp" line="333"/> <location filename="../gui/FeedReaderDialog.cpp" line="328"/>
<source>Deactivate</source> <source>Deactivate</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/FeedReaderDialog.cpp" line="513"/> <location filename="../gui/FeedReaderDialog.cpp" line="508"/>
<source>No name</source> <source>No name</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/FeedReaderDialog.cpp" line="723"/> <location filename="../gui/FeedReaderDialog.cpp" line="718"/>
<source>Add new folder</source> <source>Add new folder</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/FeedReaderDialog.cpp" line="724"/> <location filename="../gui/FeedReaderDialog.cpp" line="719"/>
<source>Please enter a name for the folder</source> <source>Please enter a name for the folder</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/FeedReaderDialog.cpp" line="730"/> <location filename="../gui/FeedReaderDialog.cpp" line="725"/>
<location filename="../gui/FeedReaderDialog.cpp" line="783"/> <location filename="../gui/FeedReaderDialog.cpp" line="778"/>
<source>Create folder</source> <source>Create folder</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/FeedReaderDialog.cpp" line="730"/> <location filename="../gui/FeedReaderDialog.cpp" line="725"/>
<location filename="../gui/FeedReaderDialog.cpp" line="783"/> <location filename="../gui/FeedReaderDialog.cpp" line="778"/>
<source>Cannot create folder.</source> <source>Cannot create folder.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/FeedReaderDialog.cpp" line="756"/> <location filename="../gui/FeedReaderDialog.cpp" line="751"/>
<source>Remove folder</source> <source>Remove folder</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/FeedReaderDialog.cpp" line="756"/> <location filename="../gui/FeedReaderDialog.cpp" line="751"/>
<source>Remove feed</source> <source>Remove feed</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/FeedReaderDialog.cpp" line="756"/> <location filename="../gui/FeedReaderDialog.cpp" line="751"/>
<source>Do you want to remove the folder %1?</source> <source>Do you want to remove the folder %1?</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/FeedReaderDialog.cpp" line="756"/> <location filename="../gui/FeedReaderDialog.cpp" line="751"/>
<source>Do you want to remove the feed %1?</source> <source>Do you want to remove the feed %1?</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/FeedReaderDialog.cpp" line="776"/> <location filename="../gui/FeedReaderDialog.cpp" line="771"/>
<source>Edit folder</source> <source>Edit folder</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/FeedReaderDialog.cpp" line="777"/> <location filename="../gui/FeedReaderDialog.cpp" line="772"/>
<source>Please enter a new name for the folder</source> <source>Please enter a new name for the folder</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
<context>
<name>FeedReaderFeedItem</name>
<message>
<location filename="../gui/FeedReaderFeedItem.ui" line="178"/>
<location filename="../gui/FeedReaderFeedItem.cpp" line="97"/>
<source>Expand</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui/FeedReaderFeedItem.ui" line="204"/>
<source>Set as read and remove item</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui/FeedReaderFeedItem.ui" line="230"/>
<source>Remove Item</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui/FeedReaderFeedItem.cpp" line="68"/>
<source>Open link in browser</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui/FeedReaderFeedItem.cpp" line="69"/>
<source>Copy link to clipboard</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../gui/FeedReaderFeedItem.cpp" line="91"/>
<source>Hide</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FeedReaderFeedNotify</name>
<message>
<location filename="../gui/FeedReaderFeedNotify.cpp" line="45"/>
<source>Feed Reader</source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>FeedReaderMessageWidget</name> <name>FeedReaderMessageWidget</name>
<message> <message>
@ -480,42 +522,42 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/FeedReaderMessageWidget.cpp" line="230"/> <location filename="../gui/FeedReaderMessageWidget.cpp" line="232"/>
<source>No name</source> <source>No name</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/FeedReaderMessageWidget.cpp" line="268"/> <location filename="../gui/FeedReaderMessageWidget.cpp" line="270"/>
<source>Mark as read</source> <source>Mark as read</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/FeedReaderMessageWidget.cpp" line="271"/> <location filename="../gui/FeedReaderMessageWidget.cpp" line="273"/>
<source>Mark as unread</source> <source>Mark as unread</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/FeedReaderMessageWidget.cpp" line="274"/> <location filename="../gui/FeedReaderMessageWidget.cpp" line="276"/>
<source>Mark all as read</source> <source>Mark all as read</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/FeedReaderMessageWidget.cpp" line="279"/> <location filename="../gui/FeedReaderMessageWidget.cpp" line="281"/>
<source>Copy link</source> <source>Copy link</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/FeedReaderMessageWidget.cpp" line="282"/> <location filename="../gui/FeedReaderMessageWidget.cpp" line="284"/>
<source>Remove</source> <source>Remove</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/FeedReaderMessageWidget.cpp" line="655"/> <location filename="../gui/FeedReaderMessageWidget.cpp" line="654"/>
<source>Hide</source> <source>Hide</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/FeedReaderMessageWidget.cpp" line="659"/> <location filename="../gui/FeedReaderMessageWidget.cpp" line="658"/>
<source>Expand</source> <source>Expand</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -523,12 +565,12 @@
<context> <context>
<name>FeedReaderPlugin</name> <name>FeedReaderPlugin</name>
<message> <message>
<location filename="../FeedReaderPlugin.cpp" line="135"/> <location filename="../FeedReaderPlugin.cpp" line="159"/>
<source>This plugin provides a Feedreader.</source> <source>This plugin provides a Feedreader.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../FeedReaderPlugin.cpp" line="140"/> <location filename="../FeedReaderPlugin.cpp" line="164"/>
<source>FeedReader</source> <source>FeedReader</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>

View File

@ -15,7 +15,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
@ -28,6 +28,7 @@
#include <retroshare/rschannels.h> #include <retroshare/rschannels.h>
#include <retroshare/rsforums.h> #include <retroshare/rsforums.h>
#include <retroshare/rsmsgs.h> #include <retroshare/rsmsgs.h>
#include <retroshare/rsplugin.h>
#include "feeds/ChanNewItem.h" #include "feeds/ChanNewItem.h"
#include "feeds/ChanMsgItem.h" #include "feeds/ChanMsgItem.h"
@ -49,6 +50,7 @@
#include "settings/rsharesettings.h" #include "settings/rsharesettings.h"
#include "chat/ChatDialog.h" #include "chat/ChatDialog.h"
#include "msgs/MessageComposer.h" #include "msgs/MessageComposer.h"
#include "common/FeedNotify.h"
const uint32_t NEWSFEED_PEERLIST = 0x0001; const uint32_t NEWSFEED_PEERLIST = 0x0001;
const uint32_t NEWSFEED_FORUMNEWLIST = 0x0002; const uint32_t NEWSFEED_FORUMNEWLIST = 0x0002;
@ -71,8 +73,8 @@ static NewsFeed *instance = NULL;
NewsFeed::NewsFeed(QWidget *parent) NewsFeed::NewsFeed(QWidget *parent)
: MainPage (parent) : MainPage (parent)
{ {
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
setupUi(this); setupUi(this);
if (!instance) { if (!instance) {
instance = this; instance = this;
@ -195,6 +197,23 @@ void NewsFeed::updateFeed()
default: default:
break; break;
} }
} else {
/* process plugin feeds */
int pluginCount = rsPlugins->nbPlugins();
for (int i = 0; i < pluginCount; ++i) {
RsPlugin *rsPlugin = rsPlugins->plugin(i);
if (rsPlugin) {
FeedNotify *feedNotify = rsPlugin->qt_feedNotify();
if (feedNotify && feedNotify->notifyEnabled()) {
QWidget *item = feedNotify->feedItem(this);
if (item) {
addFeedItem(item);
break;
}
}
}
}
} }
} }
@ -430,7 +449,7 @@ void NewsFeed::addFeedItemIfUnique(QWidget *item, int itemType, const std::strin
} }
} }
} }
addFeedItem(item); addFeedItem(item);
} }
@ -551,12 +570,12 @@ void NewsFeed::addFeedItemSecurityUnknownOut(RsFeedItem &fi)
{ {
/* make new widget */ /* make new widget */
SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, fi.mId1, fi.mId2, fi.mId4, SEC_TYPE_UNKNOWN_OUT, false); SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, fi.mId1, fi.mId2, fi.mId4, SEC_TYPE_UNKNOWN_OUT, false);
/* store */ /* store */
/* add to layout */ /* add to layout */
addFeedItemIfUnique(pi, SEC_TYPE_UNKNOWN_OUT, fi.mId2, false); addFeedItemIfUnique(pi, SEC_TYPE_UNKNOWN_OUT, fi.mId2, false);
#ifdef NEWS_DEBUG #ifdef NEWS_DEBUG
std::cerr << "NewsFeed::addFeedItemSecurityUnknownOut()"; std::cerr << "NewsFeed::addFeedItemSecurityUnknownOut()";
std::cerr << std::endl; std::cerr << std::endl;

View File

@ -0,0 +1,50 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2012 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 "FeedNotify.h"
FeedNotify::FeedNotify(QObject *parent) :
QObject(parent)
{
}
FeedNotify::~FeedNotify()
{
}
bool FeedNotify::hasSetting(QString &/*name*/)
{
return false;
}
bool FeedNotify::notifyEnabled()
{
return false;
}
void FeedNotify::setNotifyEnabled(bool /*enabled*/)
{
}
QWidget *FeedNotify::feedItem(FeedHolder */*parent*/)
{
return NULL;
}

View File

@ -0,0 +1,43 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2012 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 FEEDNOTIFY_H
#define FEEDNOTIFY_H
#include <QObject>
class FeedHolder;
class FeedNotify : public QObject
{
Q_OBJECT
public:
FeedNotify(QObject *parent = 0);
~FeedNotify();
virtual bool hasSetting(QString &/*name*/);
virtual bool notifyEnabled();
virtual void setNotifyEnabled(bool /*enabled*/);
virtual QWidget *feedItem(FeedHolder */*parent*/);
};
#endif // FEEDNOTIFY_H

View File

@ -19,15 +19,16 @@
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
#include <rshare.h> #include <rshare.h>
#include "NotifyPage.h" #include "NotifyPage.h"
#include <retroshare/rsnotify.h> #include <retroshare/rsnotify.h>
#include <retroshare/rsplugin.h>
#include "rsharesettings.h" #include "rsharesettings.h"
#include "gui/MainWindow.h" #include "gui/MainWindow.h"
#include "gui/common/UserNotify.h" #include "gui/common/UserNotify.h"
#include "gui/common/FeedNotify.h"
#include "gui/notifyqt.h" #include "gui/notifyqt.h"
#include "gui/NewsFeed.h" #include "gui/NewsFeed.h"
@ -41,11 +42,34 @@ NotifyPage::NotifyPage(QWidget * parent, Qt::WFlags flags)
connect(ui.notifyButton, SIGNAL(clicked()), this, SLOT(testNotify())); connect(ui.notifyButton, SIGNAL(clicked()), this, SLOT(testNotify()));
connect(ui.toasterButton, SIGNAL(clicked()), this, SLOT(testToaster())); connect(ui.toasterButton, SIGNAL(clicked()), this, SLOT(testToaster()));
/* add user notify */
QFont font = ui.notify_Peers->font(); // use font from existing checkbox QFont font = ui.notify_Peers->font(); // use font from existing checkbox
/* add feed notify */
int row = 0;
int pluginCount = rsPlugins->nbPlugins();
for (int i = 0; i < pluginCount; ++i) {
RsPlugin *rsPlugin = rsPlugins->plugin(i);
if (rsPlugin) {
FeedNotify *feedNotify = rsPlugin->qt_feedNotify();
if (feedNotify) {
QString name;
if (!feedNotify->hasSetting(name)) {
continue;
}
QCheckBox *enabledCheckBox = new QCheckBox(name, this);
enabledCheckBox->setFont(font);
ui.feedLayout->addWidget(enabledCheckBox, row++);
mFeedNotifySettingList.push_back(FeedNotifySetting(feedNotify, enabledCheckBox));
}
}
}
/* add user notify */
const QList<UserNotify*> &userNotifyList = MainWindow::getInstance()->getUserNotifyList(); const QList<UserNotify*> &userNotifyList = MainWindow::getInstance()->getUserNotifyList();
QList<UserNotify*>::const_iterator it; QList<UserNotify*>::const_iterator it;
int row = 0; row = 0;
for (it = userNotifyList.begin(); it != userNotifyList.end(); ++it) { for (it = userNotifyList.begin(); it != userNotifyList.end(); ++it) {
UserNotify *userNotify = *it; UserNotify *userNotify = *it;
@ -135,6 +159,12 @@ NotifyPage::save(QString &/*errmsg*/)
if (ui.message_ConnectAttempt->isChecked()) if (ui.message_ConnectAttempt->isChecked())
messageflags |= RS_MESSAGE_CONNECT_ATTEMPT; messageflags |= RS_MESSAGE_CONNECT_ATTEMPT;
/* save feed notify */
QList<FeedNotifySetting>::iterator feedNotifyIt;
for (feedNotifyIt = mFeedNotifySettingList.begin(); feedNotifyIt != mFeedNotifySettingList.end(); ++feedNotifyIt) {
feedNotifyIt->mFeedNotify->setNotifyEnabled(feedNotifyIt->mEnabledCheckBox->isChecked());
}
/* save user notify */ /* save user notify */
QList<UserNotifySetting>::iterator notifyIt; QList<UserNotifySetting>::iterator notifyIt;
for (notifyIt = mUserNotifySettingList.begin(); notifyIt != mUserNotifySettingList.end(); ++notifyIt) { for (notifyIt = mUserNotifySettingList.begin(); notifyIt != mUserNotifySettingList.end(); ++notifyIt) {
@ -218,12 +248,18 @@ void NotifyPage::load()
ui.spinBoxToasterXMargin->setValue(margin.x()); ui.spinBoxToasterXMargin->setValue(margin.x());
ui.spinBoxToasterYMargin->setValue(margin.y()); ui.spinBoxToasterYMargin->setValue(margin.y());
/* load feed notify */
QList<FeedNotifySetting>::iterator feedNotifyIt;
for (feedNotifyIt = mFeedNotifySettingList.begin(); feedNotifyIt != mFeedNotifySettingList.end(); ++feedNotifyIt) {
feedNotifyIt->mEnabledCheckBox->setChecked(feedNotifyIt->mFeedNotify->notifyEnabled());
}
/* load user notify */ /* load user notify */
QList<UserNotifySetting>::iterator notifyIt; QList<UserNotifySetting>::iterator userNotifyIt;
for (notifyIt = mUserNotifySettingList.begin(); notifyIt != mUserNotifySettingList.end(); ++notifyIt) { for (userNotifyIt = mUserNotifySettingList.begin(); userNotifyIt != mUserNotifySettingList.end(); ++userNotifyIt) {
notifyIt->mEnabledCheckBox->setChecked(notifyIt->mUserNotify->notifyEnabled()); userNotifyIt->mEnabledCheckBox->setChecked(userNotifyIt->mUserNotify->notifyEnabled());
notifyIt->mCombinedCheckBox->setChecked(notifyIt->mUserNotify->notifyCombined()); userNotifyIt->mCombinedCheckBox->setChecked(userNotifyIt->mUserNotify->notifyCombined());
notifyIt->mBlinkCheckBox->setChecked(notifyIt->mUserNotify->notifyBlink()); userNotifyIt->mBlinkCheckBox->setChecked(userNotifyIt->mUserNotify->notifyBlink());
} }
notifyToggled(); notifyToggled();

View File

@ -26,6 +26,7 @@
#include "ui_NotifyPage.h" #include "ui_NotifyPage.h"
class UserNotify; class UserNotify;
class FeedNotify;
class UserNotifySetting class UserNotifySetting
{ {
@ -40,6 +41,17 @@ public:
: mUserNotify(userNotify), mEnabledCheckBox(enabledCheckBox), mCombinedCheckBox(combinedCheckBox), mBlinkCheckBox(blinkCheckBox) {} : mUserNotify(userNotify), mEnabledCheckBox(enabledCheckBox), mCombinedCheckBox(combinedCheckBox), mBlinkCheckBox(blinkCheckBox) {}
}; };
class FeedNotifySetting
{
public:
FeedNotify *mFeedNotify;
QCheckBox *mEnabledCheckBox;
public:
FeedNotifySetting(FeedNotify *feedNotify, QCheckBox *enabledCheckBox)
: mFeedNotify(feedNotify), mEnabledCheckBox(enabledCheckBox) {}
};
class NotifyPage : public ConfigPage class NotifyPage : public ConfigPage
{ {
Q_OBJECT Q_OBJECT
@ -67,6 +79,7 @@ private:
uint getNewsFlags(); uint getNewsFlags();
uint getNotifyFlags(); uint getNotifyFlags();
QList<FeedNotifySetting> mFeedNotifySettingList;
QList<UserNotifySetting> mUserNotifySettingList; QList<UserNotifySetting> mUserNotifySettingList;
/** Qt Designer generated object */ /** Qt Designer generated object */

View File

@ -22,7 +22,16 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="margin"> <property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number> <number>6</number>
</property> </property>
<item> <item>
@ -76,6 +85,9 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<layout class="QVBoxLayout" name="feedLayout"/>
</item>
<item> <item>
<widget class="Line" name="line"> <widget class="Line" name="line">
<property name="orientation"> <property name="orientation">

View File

@ -3164,6 +3164,14 @@ p, li { white-space: pre-wrap; }
<source>Paste my certificate link</source> <source>Paste my certificate link</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>No Forum</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Loading</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>CreateLobbyDialog</name> <name>CreateLobbyDialog</name>
@ -6034,10 +6042,6 @@ p, li { white-space: pre-wrap; }
<source>Add Icon</source> <source>Add Icon</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Key recipients can publish to restricted-type Wiki Group, and can view and publish for private-type channels</source>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>Share Publish Key</source> <source>Share Publish Key</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@ -6151,11 +6155,7 @@ p, li { white-space: pre-wrap; }
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>Add Wiki Moderators</source> <source>Key recipients can publish to restricted-type group and can view and publish for private-type channels</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select Wiki Moderators</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
@ -12308,6 +12308,14 @@ Try to be patient!</source>
<source>Edit Wiki Group</source> <source>Edit Wiki Group</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Add Wiki Moderators</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select Wiki Moderators</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>WireDialog</name> <name>WireDialog</name>

View File

@ -413,6 +413,7 @@ HEADERS += rshare.h \
gui/common/LineEditClear.h \ gui/common/LineEditClear.h \
gui/common/DropLineEdit.h \ gui/common/DropLineEdit.h \
gui/common/LinkTextBrowser.h \ gui/common/LinkTextBrowser.h \
gui/common/FeedNotify.h \
gui/common/UserNotify.h \ gui/common/UserNotify.h \
gui/common/HeaderFrame.h \ gui/common/HeaderFrame.h \
gui/common/MimeTextEdit.h \ gui/common/MimeTextEdit.h \
@ -680,6 +681,7 @@ SOURCES += main.cpp \
gui/common/LineEditClear.cpp \ gui/common/LineEditClear.cpp \
gui/common/DropLineEdit.cpp \ gui/common/DropLineEdit.cpp \
gui/common/LinkTextBrowser.cpp \ gui/common/LinkTextBrowser.cpp \
gui/common/FeedNotify.cpp \
gui/common/UserNotify.cpp \ gui/common/UserNotify.cpp \
gui/common/HeaderFrame.cpp \ gui/common/HeaderFrame.cpp \
gui/common/MimeTextEdit.cpp \ gui/common/MimeTextEdit.cpp \