diff --git a/libretroshare/src/retroshare/rsplugin.h b/libretroshare/src/retroshare/rsplugin.h index b83c34d6e..41b87455f 100644 --- a/libretroshare/src/retroshare/rsplugin.h +++ b/libretroshare/src/retroshare/rsplugin.h @@ -52,6 +52,7 @@ class RsPQIService ; class RsAutoUpdatePage ; class PopupChatDialog ; class SoundEvents; +class FeedNotify; // Plugin API version. Not used yet, but will be in the future the // main value that decides for compatibility. @@ -94,12 +95,12 @@ class RsPlugin //================================ Services ==================================// // // 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 - // exchange of data, such as chat, messages, etc. + // exchange of data, such as chat, messages, etc. // Example plugin: VOIP // virtual RsPQIService *rs_pqi_service() const { return NULL ; } @@ -133,13 +134,18 @@ class RsPlugin // 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 ; } - // + // + //================================== Notify ==================================// + // + virtual FeedNotify *qt_feedNotify() { return NULL; } + + // //========================== Plugin Description ==============================// - // + // // 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 @@ -148,9 +154,9 @@ class RsPlugin virtual std::string getPluginName() const = 0 ; virtual void getPluginVersion(int& major,int& minor,int& svn_rev) const = 0 ; - // + // //========================== Plugin Interface ================================// - // + // // Use these methods to access main objects from RetroShare. // virtual void setInterfaces(RsPlugInInterfaces& interfaces) = 0; diff --git a/plugins/FeedReader/FeedReader.pro b/plugins/FeedReader/FeedReader.pro index 651222e73..51cca6812 100644 --- a/plugins/FeedReader/FeedReader.pro +++ b/plugins/FeedReader/FeedReader.pro @@ -13,7 +13,9 @@ SOURCES = FeedReaderPlugin.cpp \ gui/FeedReaderNotify.cpp \ gui/FeedReaderConfig.cpp \ gui/FeedReaderStringDefs.cpp \ + gui/FeedReaderFeedNotify.cpp \ gui/FeedReaderUserNotify.cpp \ + gui/FeedReaderFeedItem.cpp \ util/CURLWrapper.cpp \ util/XMLWrapper.cpp \ util/HTMLWrapper.cpp \ @@ -31,7 +33,9 @@ HEADERS = FeedReaderPlugin.h \ gui/FeedReaderNotify.h \ gui/FeedReaderConfig.h \ gui/FeedReaderStringDefs.h \ + gui/FeedReaderFeedNotify.h \ gui/FeedReaderUserNotify.h \ + gui/FeedReaderFeedItem.h \ util/CURLWrapper.h \ util/XMLWrapper.h \ util/HTMLWrapper.h \ @@ -41,7 +45,8 @@ FORMS = gui/FeedReaderDialog.ui \ gui/FeedReaderMessageWidget.ui \ gui/AddFeedDialog.ui \ gui/PreviewFeedDialog.ui \ - gui/FeedReaderConfig.ui + gui/FeedReaderConfig.ui \ + gui/FeedReaderFeedItem.ui TARGET = FeedReader diff --git a/plugins/FeedReader/FeedReaderPlugin.cpp b/plugins/FeedReader/FeedReaderPlugin.cpp index 66320dfb9..be1cc88b7 100644 --- a/plugins/FeedReader/FeedReaderPlugin.cpp +++ b/plugins/FeedReader/FeedReaderPlugin.cpp @@ -27,7 +27,9 @@ #include "FeedReaderPlugin.h" #include "gui/FeedReaderDialog.h" +#include "gui/FeedReaderNotify.h" #include "gui/FeedReaderConfig.h" +#include "gui/FeedReaderFeedNotify.h" #include "services/p3FeedReader.h" #define IMAGE_FEEDREADER ":/images/FeedReader.png" @@ -77,6 +79,8 @@ FeedReaderPlugin::FeedReaderPlugin() mIcon = NULL ; mPlugInHandler = NULL; mFeedReader = NULL; + mNotify = NULL; + mFeedNotify = NULL; } void FeedReaderPlugin::setInterfaces(RsPlugInInterfaces &/*interfaces*/) @@ -91,17 +95,28 @@ ConfigPage *FeedReaderPlugin::qt_config_page() const MainPage *FeedReaderPlugin::qt_page() const { if (mainpage == NULL) { - mainpage = new FeedReaderDialog(mFeedReader); + mainpage = new FeedReaderDialog(mFeedReader, mNotify); } return mainpage; } +FeedNotify *FeedReaderPlugin::qt_feedNotify() +{ + if (!mFeedNotify) { + mFeedNotify = new FeedReaderFeedNotify(mFeedReader, mNotify); + } + return mFeedNotify; +} + RsPQIService *FeedReaderPlugin::rs_pqi_service() const { if (mFeedReader == NULL) { mFeedReader = new p3FeedReader(mPlugInHandler); rsFeedReader = mFeedReader; + + mNotify = new FeedReaderNotify(); + mFeedReader->setNotify(mNotify); } return mFeedReader; @@ -110,8 +125,17 @@ RsPQIService *FeedReaderPlugin::rs_pqi_service() const void FeedReaderPlugin::stop() { if (mFeedReader) { + mFeedReader->setNotify(NULL); mFeedReader->stop(); } + if (mNotify) { + delete(mNotify); + mNotify = NULL; + } + if (mFeedNotify) { + delete mFeedNotify; + mFeedNotify = NULL; + } } void FeedReaderPlugin::setPlugInHandler(RsPluginHandler *pgHandler) diff --git a/plugins/FeedReader/FeedReaderPlugin.h b/plugins/FeedReader/FeedReaderPlugin.h index 169e81424..bc268c8cb 100644 --- a/plugins/FeedReader/FeedReaderPlugin.h +++ b/plugins/FeedReader/FeedReaderPlugin.h @@ -27,6 +27,7 @@ #include "services/p3FeedReader.h" class p3FeedReader; +class FeedReaderNotify; class RsForums; class FeedReaderPlugin: public RsPlugin @@ -52,10 +53,13 @@ public: virtual void setInterfaces(RsPlugInInterfaces& interfaces); virtual ConfigPage *qt_config_page() const; + virtual FeedNotify *qt_feedNotify(); + private: mutable p3FeedReader *mFeedReader; + mutable FeedReaderNotify *mNotify; mutable RsPluginHandler *mPlugInHandler; mutable MainPage *mainpage; mutable QIcon *mIcon; + mutable FeedNotify *mFeedNotify; }; - diff --git a/plugins/FeedReader/gui/FeedReaderDialog.cpp b/plugins/FeedReader/gui/FeedReaderDialog.cpp index fc4656b54..9f27db088 100644 --- a/plugins/FeedReader/gui/FeedReaderDialog.cpp +++ b/plugins/FeedReader/gui/FeedReaderDialog.cpp @@ -55,8 +55,8 @@ #define ROLE_FEED_ERROR Qt::UserRole + 8 #define ROLE_FEED_DEACTIVATED Qt::UserRole + 9 -FeedReaderDialog::FeedReaderDialog(RsFeedReader *feedReader, QWidget *parent) - : MainPage(parent), mFeedReader(feedReader), ui(new Ui::FeedReaderDialog) +FeedReaderDialog::FeedReaderDialog(RsFeedReader *feedReader, FeedReaderNotify *notify, QWidget *parent) + : MainPage(parent), mFeedReader(feedReader), mNotify(notify), ui(new Ui::FeedReaderDialog) { /* Invoke the Qt Designer generated object setup routine */ ui->setupUi(this); @@ -65,8 +65,6 @@ FeedReaderDialog::FeedReaderDialog(RsFeedReader *feedReader, QWidget *parent) mOpenFeedIds = NULL; mMessageWidget = NULL; - mNotify = new FeedReaderNotify(); - mFeedReader->setNotify(mNotify); connect(mNotify, SIGNAL(feedChanged(QString,int)), this, SLOT(feedChanged(QString,int))); connect(mNotify, SIGNAL(msgChanged(QString,QString,int)), this, SLOT(msgChanged(QString,QString,int))); @@ -126,9 +124,6 @@ FeedReaderDialog::~FeedReaderDialog() delete(mFeedCompareRole); delete(ui); - mFeedReader->setNotify(NULL); - delete(mNotify); - if (mOpenFeedIds) { delete mOpenFeedIds; mOpenFeedIds = NULL; diff --git a/plugins/FeedReader/gui/FeedReaderDialog.h b/plugins/FeedReader/gui/FeedReaderDialog.h index 496d78181..f61415bf9 100644 --- a/plugins/FeedReader/gui/FeedReaderDialog.h +++ b/plugins/FeedReader/gui/FeedReaderDialog.h @@ -40,7 +40,7 @@ class FeedReaderDialog : public MainPage Q_OBJECT public: - FeedReaderDialog(RsFeedReader *feedReader, QWidget *parent = 0); + FeedReaderDialog(RsFeedReader *feedReader, FeedReaderNotify *notify, QWidget *parent = 0); ~FeedReaderDialog(); virtual UserNotify *getUserNotify(QObject *parent); diff --git a/plugins/FeedReader/gui/FeedReaderFeedItem.cpp b/plugins/FeedReader/gui/FeedReaderFeedItem.cpp new file mode 100644 index 000000000..38599b986 --- /dev/null +++ b/plugins/FeedReader/gui/FeedReaderFeedItem.cpp @@ -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 +#include +#include +#include + +#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)); +} diff --git a/plugins/FeedReader/gui/FeedReaderFeedItem.h b/plugins/FeedReader/gui/FeedReaderFeedItem.h new file mode 100644 index 000000000..16332236c --- /dev/null +++ b/plugins/FeedReader/gui/FeedReaderFeedItem.h @@ -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 + +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 diff --git a/plugins/FeedReader/gui/FeedReaderFeedItem.ui b/plugins/FeedReader/gui/FeedReaderFeedItem.ui new file mode 100644 index 000000000..dbe7ac572 --- /dev/null +++ b/plugins/FeedReader/gui/FeedReaderFeedItem.ui @@ -0,0 +1,321 @@ + + + FeedReaderFeedItem + + + + 0 + 0 + 629 + 121 + + + + + 1 + + + 1 + + + 1 + + + 1 + + + 6 + + + 1 + + + + + + 0 + 0 + + + + true + + + QFrame::Box + + + QFrame::Sunken + + + + + + + + + + + 48 + 48 + + + + :/images/FeedReader.png + + + true + + + + + + + + + + + + + + 0 + 0 + + + + + 11 + 75 + true + + + + Feed name + + + + + + + + 75 + true + PreferAntialias + + + + DateTime + + + + + + + + + 8 + + + + + + 0 + 0 + + + + + 16777215 + 60 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt; color:#666666;">Short Description</span></p></body></html> + + + true + + + true + + + + + + + Qt::NoFocus + + + + :/images/Link.png:/images/Link.png + + + QToolButton::MenuButtonPopup + + + + + + + + 0 + 0 + + + + + 24 + 16777215 + + + + Qt::NoFocus + + + Expand + + + + :/images/edit_add24.png:/images/edit_add24.png + + + + + + + + 0 + 0 + + + + + 24 + 16777215 + + + + Qt::NoFocus + + + Set as read and remove item + + + + :/images/cancel.png:/images/cancel.png + + + + + + + + 0 + 0 + + + + + 24 + 16777215 + + + + Qt::NoFocus + + + Remove Item + + + + :/images/close_normal.png:/images/close_normal.png + + + + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::Box + + + QFrame::Sunken + + + + 5 + + + 5 + + + 5 + + + 5 + + + + + + 0 + 0 + + + + true + + + 6 + + + -1 + + + true + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/FeedReader/gui/FeedReaderFeedNotify.cpp b/plugins/FeedReader/gui/FeedReaderFeedNotify.cpp new file mode 100644 index 000000000..11bc211c2 --- /dev/null +++ b/plugins/FeedReader/gui/FeedReaderFeedNotify.cpp @@ -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 + +#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); +} diff --git a/plugins/FeedReader/gui/FeedReaderFeedNotify.h b/plugins/FeedReader/gui/FeedReaderFeedNotify.h new file mode 100644 index 000000000..4a72fc1a0 --- /dev/null +++ b/plugins/FeedReader/gui/FeedReaderFeedNotify.h @@ -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 mPendingNewsFeed; +}; + +#endif // FEEDREADERFEEDNOTIFY_H diff --git a/plugins/FeedReader/gui/FeedReaderUserNotify.cpp b/plugins/FeedReader/gui/FeedReaderUserNotify.cpp index 86a752017..e1d4e21a6 100644 --- a/plugins/FeedReader/gui/FeedReaderUserNotify.cpp +++ b/plugins/FeedReader/gui/FeedReaderUserNotify.cpp @@ -42,40 +42,22 @@ bool FeedReaderUserNotify::hasSetting(QString &name) bool FeedReaderUserNotify::notifyEnabled() { - bool enable = true; - - Settings->beginGroup(QString("FeedReader")); - enable = Settings->value("TrayNotifyEnable", enable).toBool(); - Settings->endGroup(); - - return enable; + return Settings->valueFromGroup("FeedReader", "TrayNotifyEnable", true).toBool(); } bool FeedReaderUserNotify::notifyCombined() { - bool combined = false; - - Settings->beginGroup(QString("FeedReader")); - combined = Settings->value("TrayNotifyCombined", combined).toBool(); - Settings->endGroup(); - - return combined; + return Settings->valueFromGroup("FeedReader", "TrayNotifyCombined", false).toBool(); } bool FeedReaderUserNotify::notifyBlink() { - bool blink = false; - - Settings->beginGroup(QString("FeedReader")); - blink = Settings->value("TrayNotifyBlink", blink).toBool(); - Settings->endGroup(); - - return blink; + return Settings->valueFromGroup("FeedReader", "TrayNotifyBlink", false).toBool(); } void FeedReaderUserNotify::setNotifyEnabled(bool enabled, bool combined, bool blink) { - Settings->beginGroup(QString("FeedReader")); + Settings->beginGroup("FeedReader"); Settings->setValue("TrayNotifyEnable", enabled); Settings->setValue("TrayNotifyCombined", combined); Settings->setValue("TrayNotifyBlink", blink); diff --git a/plugins/FeedReader/lang/FeedReader_en.ts b/plugins/FeedReader/lang/FeedReader_en.ts index f8ca8792d..6a3dfe70a 100644 --- a/plugins/FeedReader/lang/FeedReader_en.ts +++ b/plugins/FeedReader/lang/FeedReader_en.ts @@ -287,113 +287,155 @@ - + Message Folders - + New - + Feed - + Folder - + Open in new tab - + Edit - + Delete - + Update - + Activate - + Deactivate - + No name - + Add new folder - + Please enter a name for the folder - - + + Create folder - - + + Cannot create folder. - + Remove folder - + Remove feed - + Do you want to remove the folder %1? - + Do you want to remove the feed %1? - + Edit folder - + Please enter a new name for the folder + + FeedReaderFeedItem + + + + Expand + + + + + Set as read and remove item + + + + + Remove Item + + + + + Open link in browser + + + + + Copy link to clipboard + + + + + Hide + + + + + FeedReaderFeedNotify + + + Feed Reader + + + FeedReaderMessageWidget @@ -480,42 +522,42 @@ - + No name - + Mark as read - + Mark as unread - + Mark all as read - + Copy link - + Remove - + Hide - + Expand @@ -523,12 +565,12 @@ FeedReaderPlugin - + This plugin provides a Feedreader. - + FeedReader diff --git a/retroshare-gui/src/gui/NewsFeed.cpp b/retroshare-gui/src/gui/NewsFeed.cpp index c95b85dc2..842fc6938 100644 --- a/retroshare-gui/src/gui/NewsFeed.cpp +++ b/retroshare-gui/src/gui/NewsFeed.cpp @@ -15,7 +15,7 @@ * * 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, + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. ****************************************************************/ @@ -28,6 +28,7 @@ #include #include #include +#include #include "feeds/ChanNewItem.h" #include "feeds/ChanMsgItem.h" @@ -49,6 +50,7 @@ #include "settings/rsharesettings.h" #include "chat/ChatDialog.h" #include "msgs/MessageComposer.h" +#include "common/FeedNotify.h" const uint32_t NEWSFEED_PEERLIST = 0x0001; const uint32_t NEWSFEED_FORUMNEWLIST = 0x0002; @@ -71,8 +73,8 @@ static NewsFeed *instance = NULL; NewsFeed::NewsFeed(QWidget *parent) : MainPage (parent) { - /* Invoke the Qt Designer generated object setup routine */ - setupUi(this); + /* Invoke the Qt Designer generated object setup routine */ + setupUi(this); if (!instance) { instance = this; @@ -195,6 +197,23 @@ void NewsFeed::updateFeed() default: 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); } @@ -551,12 +570,12 @@ void NewsFeed::addFeedItemSecurityUnknownOut(RsFeedItem &fi) { /* make new widget */ SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, fi.mId1, fi.mId2, fi.mId4, SEC_TYPE_UNKNOWN_OUT, false); - + /* store */ - + /* add to layout */ addFeedItemIfUnique(pi, SEC_TYPE_UNKNOWN_OUT, fi.mId2, false); - + #ifdef NEWS_DEBUG std::cerr << "NewsFeed::addFeedItemSecurityUnknownOut()"; std::cerr << std::endl; diff --git a/retroshare-gui/src/gui/common/FeedNotify.cpp b/retroshare-gui/src/gui/common/FeedNotify.cpp new file mode 100644 index 000000000..3c2109c70 --- /dev/null +++ b/retroshare-gui/src/gui/common/FeedNotify.cpp @@ -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; +} diff --git a/retroshare-gui/src/gui/common/FeedNotify.h b/retroshare-gui/src/gui/common/FeedNotify.h new file mode 100644 index 000000000..2d1b54074 --- /dev/null +++ b/retroshare-gui/src/gui/common/FeedNotify.h @@ -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 + +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 diff --git a/retroshare-gui/src/gui/settings/NotifyPage.cpp b/retroshare-gui/src/gui/settings/NotifyPage.cpp index 3ca38f6ef..418a568a2 100755 --- a/retroshare-gui/src/gui/settings/NotifyPage.cpp +++ b/retroshare-gui/src/gui/settings/NotifyPage.cpp @@ -19,15 +19,16 @@ * Boston, MA 02110-1301, USA. ****************************************************************/ - #include #include "NotifyPage.h" #include +#include #include "rsharesettings.h" #include "gui/MainWindow.h" #include "gui/common/UserNotify.h" +#include "gui/common/FeedNotify.h" #include "gui/notifyqt.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.toasterButton, SIGNAL(clicked()), this, SLOT(testToaster())); - /* add user notify */ 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 &userNotifyList = MainWindow::getInstance()->getUserNotifyList(); QList::const_iterator it; - int row = 0; + row = 0; for (it = userNotifyList.begin(); it != userNotifyList.end(); ++it) { UserNotify *userNotify = *it; @@ -135,6 +159,12 @@ NotifyPage::save(QString &/*errmsg*/) if (ui.message_ConnectAttempt->isChecked()) messageflags |= RS_MESSAGE_CONNECT_ATTEMPT; + /* save feed notify */ + QList::iterator feedNotifyIt; + for (feedNotifyIt = mFeedNotifySettingList.begin(); feedNotifyIt != mFeedNotifySettingList.end(); ++feedNotifyIt) { + feedNotifyIt->mFeedNotify->setNotifyEnabled(feedNotifyIt->mEnabledCheckBox->isChecked()); + } + /* save user notify */ QList::iterator notifyIt; for (notifyIt = mUserNotifySettingList.begin(); notifyIt != mUserNotifySettingList.end(); ++notifyIt) { @@ -218,12 +248,18 @@ void NotifyPage::load() ui.spinBoxToasterXMargin->setValue(margin.x()); ui.spinBoxToasterYMargin->setValue(margin.y()); + /* load feed notify */ + QList::iterator feedNotifyIt; + for (feedNotifyIt = mFeedNotifySettingList.begin(); feedNotifyIt != mFeedNotifySettingList.end(); ++feedNotifyIt) { + feedNotifyIt->mEnabledCheckBox->setChecked(feedNotifyIt->mFeedNotify->notifyEnabled()); + } + /* load user notify */ - QList::iterator notifyIt; - for (notifyIt = mUserNotifySettingList.begin(); notifyIt != mUserNotifySettingList.end(); ++notifyIt) { - notifyIt->mEnabledCheckBox->setChecked(notifyIt->mUserNotify->notifyEnabled()); - notifyIt->mCombinedCheckBox->setChecked(notifyIt->mUserNotify->notifyCombined()); - notifyIt->mBlinkCheckBox->setChecked(notifyIt->mUserNotify->notifyBlink()); + QList::iterator userNotifyIt; + for (userNotifyIt = mUserNotifySettingList.begin(); userNotifyIt != mUserNotifySettingList.end(); ++userNotifyIt) { + userNotifyIt->mEnabledCheckBox->setChecked(userNotifyIt->mUserNotify->notifyEnabled()); + userNotifyIt->mCombinedCheckBox->setChecked(userNotifyIt->mUserNotify->notifyCombined()); + userNotifyIt->mBlinkCheckBox->setChecked(userNotifyIt->mUserNotify->notifyBlink()); } notifyToggled(); diff --git a/retroshare-gui/src/gui/settings/NotifyPage.h b/retroshare-gui/src/gui/settings/NotifyPage.h index d1bb4c3a4..6b4bfe5f9 100755 --- a/retroshare-gui/src/gui/settings/NotifyPage.h +++ b/retroshare-gui/src/gui/settings/NotifyPage.h @@ -26,6 +26,7 @@ #include "ui_NotifyPage.h" class UserNotify; +class FeedNotify; class UserNotifySetting { @@ -40,6 +41,17 @@ public: : 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 { Q_OBJECT @@ -67,6 +79,7 @@ private: uint getNewsFlags(); uint getNotifyFlags(); + QList mFeedNotifySettingList; QList mUserNotifySettingList; /** Qt Designer generated object */ diff --git a/retroshare-gui/src/gui/settings/NotifyPage.ui b/retroshare-gui/src/gui/settings/NotifyPage.ui index 5f4631529..2c786ef4a 100755 --- a/retroshare-gui/src/gui/settings/NotifyPage.ui +++ b/retroshare-gui/src/gui/settings/NotifyPage.ui @@ -22,7 +22,16 @@ 0 - + + 6 + + + 6 + + + 6 + + 6 @@ -76,6 +85,9 @@ + + + diff --git a/retroshare-gui/src/lang/retroshare_en.ts b/retroshare-gui/src/lang/retroshare_en.ts index 87304b748..9cdd66743 100644 --- a/retroshare-gui/src/lang/retroshare_en.ts +++ b/retroshare-gui/src/lang/retroshare_en.ts @@ -3164,6 +3164,14 @@ p, li { white-space: pre-wrap; } Paste my certificate link + + No Forum + + + + Loading + + CreateLobbyDialog @@ -6034,10 +6042,6 @@ p, li { white-space: pre-wrap; } Add Icon - - Key recipients can publish to restricted-type Wiki Group, and can view and publish for private-type channels - - Share Publish Key @@ -6151,11 +6155,7 @@ p, li { white-space: pre-wrap; } - Add Wiki Moderators - - - - Select Wiki Moderators + Key recipients can publish to restricted-type group and can view and publish for private-type channels @@ -12308,6 +12308,14 @@ Try to be patient! Edit Wiki Group + + Add Wiki Moderators + + + + Select Wiki Moderators + + WireDialog diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index 6cda0ba1c..34b19cc79 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -413,6 +413,7 @@ HEADERS += rshare.h \ gui/common/LineEditClear.h \ gui/common/DropLineEdit.h \ gui/common/LinkTextBrowser.h \ + gui/common/FeedNotify.h \ gui/common/UserNotify.h \ gui/common/HeaderFrame.h \ gui/common/MimeTextEdit.h \ @@ -680,6 +681,7 @@ SOURCES += main.cpp \ gui/common/LineEditClear.cpp \ gui/common/DropLineEdit.cpp \ gui/common/LinkTextBrowser.cpp \ + gui/common/FeedNotify.cpp \ gui/common/UserNotify.cpp \ gui/common/HeaderFrame.cpp \ gui/common/MimeTextEdit.cpp \