2012-08-02 09:17:53 -04:00
|
|
|
/****************************************************************
|
|
|
|
* RetroShare GUI 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 <QApplication>
|
|
|
|
#include <QIcon>
|
|
|
|
|
|
|
|
#include <retroshare/rsplugin.h>
|
|
|
|
#include <QTranslator>
|
|
|
|
|
|
|
|
#include "FeedReaderPlugin.h"
|
|
|
|
#include "gui/FeedReaderDialog.h"
|
2013-01-08 17:07:52 -05:00
|
|
|
#include "gui/FeedReaderNotify.h"
|
2012-08-02 09:17:53 -04:00
|
|
|
#include "gui/FeedReaderConfig.h"
|
2013-01-08 17:07:52 -05:00
|
|
|
#include "gui/FeedReaderFeedNotify.h"
|
2012-08-02 09:17:53 -04:00
|
|
|
#include "services/p3FeedReader.h"
|
|
|
|
|
2015-06-14 13:45:26 -04:00
|
|
|
#include <libxml/xmlversion.h>
|
|
|
|
#include <libxslt/xsltconfig.h>
|
|
|
|
#include <curl/curlver.h>
|
|
|
|
|
2012-08-02 09:17:53 -04:00
|
|
|
#define IMAGE_FEEDREADER ":/images/FeedReader.png"
|
|
|
|
|
|
|
|
static void *inited = new FeedReaderPlugin();
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#ifdef WIN32
|
|
|
|
__declspec(dllexport)
|
|
|
|
#endif
|
2015-06-16 10:20:59 -04:00
|
|
|
RsPlugin *RETROSHARE_PLUGIN_provide()
|
2012-08-02 09:17:53 -04:00
|
|
|
{
|
2015-06-16 10:20:59 -04:00
|
|
|
return new FeedReaderPlugin();
|
2012-08-02 09:17:53 -04:00
|
|
|
}
|
2012-12-16 16:22:14 -05:00
|
|
|
|
|
|
|
// This symbol contains the svn revision number grabbed from the executable.
|
|
|
|
// It will be tested by RS to load the plugin automatically, since it is safe to load plugins
|
|
|
|
// with same revision numbers, assuming that the revision numbers are up-to-date.
|
|
|
|
//
|
|
|
|
#ifdef WIN32
|
|
|
|
__declspec(dllexport)
|
|
|
|
#endif
|
2015-01-14 18:26:51 -05:00
|
|
|
uint32_t RETROSHARE_PLUGIN_revision = RS_REVISION_NUMBER ;
|
2012-12-16 16:22:14 -05:00
|
|
|
|
|
|
|
// This symbol contains the svn revision number grabbed from the executable.
|
|
|
|
// It will be tested by RS to load the plugin automatically, since it is safe to load plugins
|
|
|
|
// with same revision numbers, assuming that the revision numbers are up-to-date.
|
|
|
|
//
|
|
|
|
#ifdef WIN32
|
|
|
|
__declspec(dllexport)
|
|
|
|
#endif
|
|
|
|
uint32_t RETROSHARE_PLUGIN_api = RS_PLUGIN_API_VERSION ;
|
2012-08-02 09:17:53 -04:00
|
|
|
}
|
|
|
|
|
2015-01-14 18:26:51 -05:00
|
|
|
void FeedReaderPlugin::getPluginVersion(int& major, int& minor, int &build, int& svn_rev) const
|
2012-08-02 09:17:53 -04:00
|
|
|
{
|
2015-01-14 18:26:51 -05:00
|
|
|
major = RS_MAJOR_VERSION;
|
|
|
|
minor = RS_MINOR_VERSION;
|
|
|
|
build = RS_BUILD_NUMBER;
|
|
|
|
svn_rev = RS_REVISION_NUMBER;
|
2012-08-02 09:17:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
FeedReaderPlugin::FeedReaderPlugin()
|
|
|
|
{
|
|
|
|
mainpage = NULL ;
|
|
|
|
mIcon = NULL ;
|
|
|
|
mPlugInHandler = NULL;
|
|
|
|
mFeedReader = NULL;
|
2013-01-08 17:07:52 -05:00
|
|
|
mNotify = NULL;
|
|
|
|
mFeedNotify = NULL;
|
2015-06-28 06:11:47 -04:00
|
|
|
|
|
|
|
Q_INIT_RESOURCE(FeedReader_images);
|
|
|
|
Q_INIT_RESOURCE(FeedReader_qss);
|
2012-08-02 09:17:53 -04:00
|
|
|
}
|
|
|
|
|
2014-01-03 10:05:48 -05:00
|
|
|
void FeedReaderPlugin::setInterfaces(RsPlugInInterfaces &interfaces)
|
2012-08-02 09:17:53 -04:00
|
|
|
{
|
2014-01-03 10:05:48 -05:00
|
|
|
mInterfaces = interfaces;
|
2014-09-28 18:33:17 -04:00
|
|
|
|
2014-11-24 17:40:29 -05:00
|
|
|
mFeedReader = new p3FeedReader(mPlugInHandler, mInterfaces.mGxsForums);
|
2014-09-28 18:33:17 -04:00
|
|
|
rsFeedReader = mFeedReader;
|
|
|
|
|
|
|
|
mNotify = new FeedReaderNotify();
|
|
|
|
mFeedReader->setNotify(mNotify);
|
2012-08-02 09:17:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
ConfigPage *FeedReaderPlugin::qt_config_page() const
|
|
|
|
{
|
|
|
|
return new FeedReaderConfig();
|
|
|
|
}
|
|
|
|
|
|
|
|
MainPage *FeedReaderPlugin::qt_page() const
|
|
|
|
{
|
|
|
|
if (mainpage == NULL) {
|
2013-01-08 17:07:52 -05:00
|
|
|
mainpage = new FeedReaderDialog(mFeedReader, mNotify);
|
2012-08-02 09:17:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return mainpage;
|
|
|
|
}
|
|
|
|
|
2013-01-08 17:07:52 -05:00
|
|
|
FeedNotify *FeedReaderPlugin::qt_feedNotify()
|
|
|
|
{
|
|
|
|
if (!mFeedNotify) {
|
|
|
|
mFeedNotify = new FeedReaderFeedNotify(mFeedReader, mNotify);
|
|
|
|
}
|
|
|
|
return mFeedNotify;
|
|
|
|
}
|
|
|
|
|
2012-08-02 09:17:53 -04:00
|
|
|
void FeedReaderPlugin::stop()
|
|
|
|
{
|
|
|
|
if (mFeedReader) {
|
2013-01-08 17:07:52 -05:00
|
|
|
mFeedReader->setNotify(NULL);
|
2012-08-02 09:17:53 -04:00
|
|
|
mFeedReader->stop();
|
|
|
|
}
|
2013-01-08 17:07:52 -05:00
|
|
|
if (mNotify) {
|
|
|
|
delete(mNotify);
|
|
|
|
mNotify = NULL;
|
|
|
|
}
|
|
|
|
if (mFeedNotify) {
|
|
|
|
delete mFeedNotify;
|
|
|
|
mFeedNotify = NULL;
|
|
|
|
}
|
2012-08-02 09:17:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void FeedReaderPlugin::setPlugInHandler(RsPluginHandler *pgHandler)
|
|
|
|
{
|
|
|
|
mPlugInHandler = pgHandler;
|
|
|
|
}
|
|
|
|
|
|
|
|
QIcon *FeedReaderPlugin::qt_icon() const
|
|
|
|
{
|
|
|
|
if (mIcon == NULL) {
|
|
|
|
mIcon = new QIcon(IMAGE_FEEDREADER);
|
|
|
|
}
|
|
|
|
|
|
|
|
return mIcon;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string FeedReaderPlugin::getShortPluginDescription() const
|
|
|
|
{
|
|
|
|
return QApplication::translate("FeedReaderPlugin", "This plugin provides a Feedreader.").toUtf8().constData();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string FeedReaderPlugin::getPluginName() const
|
|
|
|
{
|
|
|
|
return QApplication::translate("FeedReaderPlugin", "FeedReader").toUtf8().constData();
|
|
|
|
}
|
|
|
|
|
2015-06-14 13:45:26 -04:00
|
|
|
void FeedReaderPlugin::getLibraries(std::list<RsLibraryInfo> &libraries)
|
|
|
|
{
|
|
|
|
libraries.push_back(RsLibraryInfo("LibCurl", LIBCURL_VERSION));
|
|
|
|
libraries.push_back(RsLibraryInfo("Libxml2", LIBXML_DOTTED_VERSION));
|
|
|
|
libraries.push_back(RsLibraryInfo("libxslt", LIBXSLT_DOTTED_VERSION));
|
|
|
|
}
|
|
|
|
|
2012-12-20 13:36:58 -05:00
|
|
|
QTranslator* FeedReaderPlugin::qt_translator(QApplication */*app*/, const QString& languageCode, const QString& externalDir) const
|
2012-08-02 09:17:53 -04:00
|
|
|
{
|
|
|
|
if (languageCode == "en") {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
QTranslator* translator = new QTranslator();
|
2012-12-20 13:36:58 -05:00
|
|
|
if (translator->load(externalDir + "/FeedReader_" + languageCode + ".qm")) {
|
|
|
|
return translator;
|
|
|
|
} else if (translator->load(":/lang/FeedReader_" + languageCode + ".qm")) {
|
2012-08-02 09:17:53 -04:00
|
|
|
return translator;
|
|
|
|
}
|
|
|
|
|
|
|
|
delete(translator);
|
|
|
|
return NULL;
|
|
|
|
}
|