mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-07 22:02:32 -04:00
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:
parent
f12473f7f7
commit
a60422069c
21 changed files with 1080 additions and 99 deletions
|
@ -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 <retroshare/rschannels.h>
|
||||
#include <retroshare/rsforums.h>
|
||||
#include <retroshare/rsmsgs.h>
|
||||
#include <retroshare/rsplugin.h>
|
||||
|
||||
#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;
|
||||
|
|
50
retroshare-gui/src/gui/common/FeedNotify.cpp
Normal file
50
retroshare-gui/src/gui/common/FeedNotify.cpp
Normal 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;
|
||||
}
|
43
retroshare-gui/src/gui/common/FeedNotify.h
Normal file
43
retroshare-gui/src/gui/common/FeedNotify.h
Normal 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
|
|
@ -19,15 +19,16 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
|
||||
#include <rshare.h>
|
||||
#include "NotifyPage.h"
|
||||
|
||||
#include <retroshare/rsnotify.h>
|
||||
#include <retroshare/rsplugin.h>
|
||||
#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<UserNotify*> &userNotifyList = MainWindow::getInstance()->getUserNotifyList();
|
||||
QList<UserNotify*>::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<FeedNotifySetting>::iterator feedNotifyIt;
|
||||
for (feedNotifyIt = mFeedNotifySettingList.begin(); feedNotifyIt != mFeedNotifySettingList.end(); ++feedNotifyIt) {
|
||||
feedNotifyIt->mFeedNotify->setNotifyEnabled(feedNotifyIt->mEnabledCheckBox->isChecked());
|
||||
}
|
||||
|
||||
/* save user notify */
|
||||
QList<UserNotifySetting>::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<FeedNotifySetting>::iterator feedNotifyIt;
|
||||
for (feedNotifyIt = mFeedNotifySettingList.begin(); feedNotifyIt != mFeedNotifySettingList.end(); ++feedNotifyIt) {
|
||||
feedNotifyIt->mEnabledCheckBox->setChecked(feedNotifyIt->mFeedNotify->notifyEnabled());
|
||||
}
|
||||
|
||||
/* load user notify */
|
||||
QList<UserNotifySetting>::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<UserNotifySetting>::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();
|
||||
|
|
|
@ -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<FeedNotifySetting> mFeedNotifySettingList;
|
||||
QList<UserNotifySetting> mUserNotifySettingList;
|
||||
|
||||
/** Qt Designer generated object */
|
||||
|
|
|
@ -22,7 +22,16 @@
|
|||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</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>
|
||||
</property>
|
||||
<item>
|
||||
|
@ -76,6 +85,9 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="feedLayout"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
|
|
|
@ -3164,6 +3164,14 @@ p, li { white-space: pre-wrap; }
|
|||
<source>Paste my certificate link</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>No Forum</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Loading</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>CreateLobbyDialog</name>
|
||||
|
@ -6034,10 +6042,6 @@ p, li { white-space: pre-wrap; }
|
|||
<source>Add Icon</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</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>
|
||||
<source>Share Publish Key</source>
|
||||
<translation type="unfinished"></translation>
|
||||
|
@ -6151,11 +6155,7 @@ p, li { white-space: pre-wrap; }
|
|||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Add Wiki Moderators</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Select 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>
|
||||
</context>
|
||||
|
@ -12308,6 +12308,14 @@ Try to be patient!</source>
|
|||
<source>Edit Wiki Group</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</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>
|
||||
<name>WireDialog</name>
|
||||
|
|
|
@ -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 \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue