From 6e22510e7c2626336895ffc47d575623e77bc492 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Fri, 30 Oct 2015 08:32:02 +0100 Subject: [PATCH] Some beginning work, created some service entry points. --- CMakeLists.txt | 8 +++ src/core/rootitem.h | 1 - src/gui/feedmessageviewer.cpp | 2 +- src/miscellaneous/application.cpp | 16 ++++- src/miscellaneous/application.h | 4 ++ src/services/abstract/feed.cpp | 25 +++++++ src/services/abstract/feed.h | 30 ++++++++ src/services/abstract/serviceentrypoint.cpp | 25 +++++++ src/services/abstract/serviceentrypoint.h | 72 +++++++++++++++++++ src/services/abstract/serviceroot.cpp | 26 +++++++ src/services/abstract/serviceroot.h | 29 ++++++++ src/services/standard/standardfeed.h | 2 +- .../standard/standardserviceentrypoint.cpp | 69 ++++++++++++++++++ .../standard/standardserviceentrypoint.h | 41 +++++++++++ .../tt-rss/ttrssserviceentrypoint.cpp | 70 ++++++++++++++++++ src/services/tt-rss/ttrssserviceentrypoint.h | 42 +++++++++++ 16 files changed, 458 insertions(+), 4 deletions(-) create mode 100755 src/services/abstract/feed.cpp create mode 100755 src/services/abstract/feed.h create mode 100755 src/services/abstract/serviceentrypoint.cpp create mode 100755 src/services/abstract/serviceentrypoint.h create mode 100755 src/services/abstract/serviceroot.cpp create mode 100755 src/services/abstract/serviceroot.h create mode 100755 src/services/standard/standardserviceentrypoint.cpp create mode 100755 src/services/standard/standardserviceentrypoint.h create mode 100755 src/services/tt-rss/ttrssserviceentrypoint.cpp create mode 100755 src/services/tt-rss/ttrssserviceentrypoint.h diff --git a/CMakeLists.txt b/CMakeLists.txt index d5e9a949e..fe4915afa 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -415,6 +415,10 @@ set(APP_SOURCES src/core/recyclebin.cpp src/core/feedsselection.cpp + # ABSTRACT service sources. + src/services/abstract/serviceentrypoint.cpp + src/services/abstract/serviceroot.cpp + # STANDARD feed service sources. src/services/standard/standardfeed.cpp src/services/standard/standardfeedsimportexportmodel.cpp @@ -422,6 +426,10 @@ set(APP_SOURCES src/services/standard/gui/formstandardcategorydetails.cpp src/services/standard/gui/formstandardfeeddetails.cpp src/services/standard/gui/formstandardimportexport.cpp + src/services/standard/standardserviceentrypoint.cpp + + # TT-RSS feed service sources. + src/services/tt-rss/ttrssserviceentrypoint.cpp # NETWORK-WEB sources. src/network-web/basenetworkaccessmanager.cpp diff --git a/src/core/rootitem.h b/src/core/rootitem.h index 964fa6122..b54cd6616 100755 --- a/src/core/rootitem.h +++ b/src/core/rootitem.h @@ -19,7 +19,6 @@ #define ROOTITEM_H #include - #include #include diff --git a/src/gui/feedmessageviewer.cpp b/src/gui/feedmessageviewer.cpp index cbc77346b..922dd667e 100755 --- a/src/gui/feedmessageviewer.cpp +++ b/src/gui/feedmessageviewer.cpp @@ -561,7 +561,7 @@ void FeedMessageViewer::updateFeeds(QList feeds) { m_feedDownloaderThread = new QThread(); // Downloader setup. - qRegisterMetaType >("QList"); + qRegisterMetaType >("QList"); m_feedDownloader->moveToThread(m_feedDownloaderThread); connect(this, SIGNAL(feedsUpdateRequested(QList)), m_feedDownloader, SLOT(updateFeeds(QList))); diff --git a/src/miscellaneous/application.cpp b/src/miscellaneous/application.cpp index 669a52653..e4f7190ca 100755 --- a/src/miscellaneous/application.cpp +++ b/src/miscellaneous/application.cpp @@ -28,6 +28,9 @@ #include "exceptions/applicationexception.h" #include "adblock/adblockmanager.h" +#include "services/standard/standardserviceentrypoint.h" +#include "services/tt-rss/ttrssserviceentrypoint.h" + #include #include #include @@ -35,7 +38,7 @@ Application::Application(const QString &id, int &argc, char **argv) : QtSingleApplication(id, argc, argv), - m_updateFeedsLock(NULL), m_userActions(QList()), m_mainForm(NULL), + m_updateFeedsLock(NULL), m_feedServices(QList()), m_userActions(QList()), m_mainForm(NULL), m_trayIcon(NULL), m_settings(NULL), m_system(NULL), m_skins(NULL), m_localization(NULL), m_icons(NULL), m_database(NULL), m_downloadManager(NULL), m_shouldRestart(false), m_notification(NULL) { @@ -46,6 +49,17 @@ Application::Application(const QString &id, int &argc, char **argv) Application::~Application() { delete m_updateFeedsLock; + qDeleteAll(m_feedServices); +} + +QList Application::feedServices() { + if (m_feedServices.isEmpty()) { + // NOTE: All installed services create their entry points here. + m_feedServices.append(new StandardServiceEntryPoint()); + m_feedServices.append(new TtRssServiceEntryPoint()); + } + + return m_feedServices; } QList Application::userActions() { diff --git a/src/miscellaneous/application.h b/src/miscellaneous/application.h index d8930ee0b..d23a7a847 100755 --- a/src/miscellaneous/application.h +++ b/src/miscellaneous/application.h @@ -30,6 +30,7 @@ #include "gui/systemtrayicon.h" #include "gui/notifications/notification.h" #include "network-web/downloadmanager.h" +#include "services/abstract/serviceentrypoint.h" #include @@ -54,6 +55,8 @@ class Application : public QtSingleApplication { explicit Application(const QString &id, int &argc, char **argv); virtual ~Application(); + QList feedServices(); + QList userActions(); inline SystemFactory *system() { @@ -183,6 +186,7 @@ class Application : public QtSingleApplication { // tries to lock the lock for writing), then no other // action will be allowed to lock for reading. Mutex *m_updateFeedsLock; + QList m_feedServices; QList m_userActions; FormMain *m_mainForm; SystemTrayIcon *m_trayIcon; diff --git a/src/services/abstract/feed.cpp b/src/services/abstract/feed.cpp new file mode 100755 index 000000000..7436aa231 --- /dev/null +++ b/src/services/abstract/feed.cpp @@ -0,0 +1,25 @@ +// This file is part of RSS Guard. +// +// Copyright (C) 2011-2015 by Martin Rotter +// +// RSS Guard 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 3 of the License, or +// (at your option) any later version. +// +// RSS Guard 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 RSS Guard. If not, see . + +#include "services/abstract/feed.h" + + +Feed::Feed() { +} + +Feed::~Feed() { +} diff --git a/src/services/abstract/feed.h b/src/services/abstract/feed.h new file mode 100755 index 000000000..93b945a67 --- /dev/null +++ b/src/services/abstract/feed.h @@ -0,0 +1,30 @@ +// This file is part of RSS Guard. +// +// Copyright (C) 2011-2015 by Martin Rotter +// +// RSS Guard 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 3 of the License, or +// (at your option) any later version. +// +// RSS Guard 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 RSS Guard. If not, see . + +#ifndef FEED_H +#define FEED_H + +#include "core/rootitem.h" + + +class Feed : public RootItem { + public: + explicit Feed(); + virtual ~Feed(); +}; + +#endif // FEED_H diff --git a/src/services/abstract/serviceentrypoint.cpp b/src/services/abstract/serviceentrypoint.cpp new file mode 100755 index 000000000..a368e207c --- /dev/null +++ b/src/services/abstract/serviceentrypoint.cpp @@ -0,0 +1,25 @@ +// This file is part of RSS Guard. +// +// Copyright (C) 2011-2015 by Martin Rotter +// +// RSS Guard 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 3 of the License, or +// (at your option) any later version. +// +// RSS Guard 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 RSS Guard. If not, see . + +#include "services/abstract/serviceentrypoint.h" + + +ServiceEntryPoint::ServiceEntryPoint() { +} + +ServiceEntryPoint::~ServiceEntryPoint() { +} diff --git a/src/services/abstract/serviceentrypoint.h b/src/services/abstract/serviceentrypoint.h new file mode 100755 index 000000000..f8b16b7f1 --- /dev/null +++ b/src/services/abstract/serviceentrypoint.h @@ -0,0 +1,72 @@ +// This file is part of RSS Guard. +// +// Copyright (C) 2011-2015 by Martin Rotter +// +// RSS Guard 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 3 of the License, or +// (at your option) any later version. +// +// RSS Guard 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 RSS Guard. If not, see . + +#ifndef SERVICE_H +#define SERVICE_H + +#include +#include +#include + + +// TOP LEVEL class which provides basic information about the "service" +class ServiceEntryPoint { + public: + // Constructors. + explicit ServiceEntryPoint(); + virtual ~ServiceEntryPoint(); + + // Must this service account be activated by default? + // NOTE: This is true particularly for "standard" service + // which operates with normal RSS/ATOM feeds. + virtual bool isDefaultService() = 0; + + // Can this service account be added just once? + // NOTE: This is true particularly for "standard" service + // which operates with normal RSS/ATOM feeds. + virtual bool isSingleInstanceService() = 0; + + // Can this service account be added by user via GUI? + // NOTE: This is true particularly for "standard" service + // which operates with normal RSS/ATOM feeds. + virtual bool canBeAdded() = 0; + + // Can this service account by deleted by user via GUI? + // NOTE: This is false particularly for "standard" service + // which operates with normal RSS/ATOM feeds. + virtual bool canBeDeleted() = 0; + + // Can properties of this service account be edited by user via GUI? + virtual bool canBeEdited() = 0; + + // Human readable service name, for example "TT-RSS". + virtual QString name() = 0; + + // Human readable service description, for example "Services which offers TT-RSS integration.". + virtual QString description() = 0; + + // Version of the service, using of semantic versioning is recommended. + virtual QString version() = 0; + + // Author of the service. + virtual QString author() = 0; + + // Icon of the service. + virtual QIcon icon() = 0; +}; + +#endif // SERVICE_H diff --git a/src/services/abstract/serviceroot.cpp b/src/services/abstract/serviceroot.cpp new file mode 100755 index 000000000..0d437c68c --- /dev/null +++ b/src/services/abstract/serviceroot.cpp @@ -0,0 +1,26 @@ +// This file is part of RSS Guard. +// +// Copyright (C) 2011-2015 by Martin Rotter +// +// RSS Guard 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 3 of the License, or +// (at your option) any later version. +// +// RSS Guard 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 RSS Guard. If not, see . + +#include "services/abstract/serviceroot.h" + + +ServiceRoot::ServiceRoot() { +} + +ServiceRoot::~ServiceRoot() { +} + diff --git a/src/services/abstract/serviceroot.h b/src/services/abstract/serviceroot.h new file mode 100755 index 000000000..41b318e60 --- /dev/null +++ b/src/services/abstract/serviceroot.h @@ -0,0 +1,29 @@ +// This file is part of RSS Guard. +// +// Copyright (C) 2011-2015 by Martin Rotter +// +// RSS Guard 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 3 of the License, or +// (at your option) any later version. +// +// RSS Guard 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 RSS Guard. If not, see . + +#ifndef SERVICEROOT_H +#define SERVICEROOT_H + +// THIS IS the root node of the service. +// TODO: Inherit proper base root class for this. +class ServiceRoot { + public: + explicit ServiceRoot(); + virtual ~ServiceRoot(); +}; + +#endif // SERVICEROOT_H diff --git a/src/services/standard/standardfeed.h b/src/services/standard/standardfeed.h index d3d23b3cc..41dfeec43 100755 --- a/src/services/standard/standardfeed.h +++ b/src/services/standard/standardfeed.h @@ -34,7 +34,7 @@ class FeedsModel; // Represents BASE class for feeds contained in FeedsModel. // NOTE: This class should be derived to create PARTICULAR feed types. class StandardFeed : public RootItem { - Q_DECLARE_TR_FUNCTIONS(Feed) + Q_DECLARE_TR_FUNCTIONS(StandardFeed) public: // Describes possible types of feeds. diff --git a/src/services/standard/standardserviceentrypoint.cpp b/src/services/standard/standardserviceentrypoint.cpp new file mode 100755 index 000000000..62d5fc901 --- /dev/null +++ b/src/services/standard/standardserviceentrypoint.cpp @@ -0,0 +1,69 @@ +// This file is part of RSS Guard. +// +// Copyright (C) 2011-2015 by Martin Rotter +// +// RSS Guard 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 3 of the License, or +// (at your option) any later version. +// +// RSS Guard 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 RSS Guard. If not, see . + + +#include "services/standard/standardserviceentrypoint.h" + +#include "definitions/definitions.h" +#include "miscellaneous/application.h" + + +StandardServiceEntryPoint::StandardServiceEntryPoint() { +} + +StandardServiceEntryPoint::~StandardServiceEntryPoint() { +} + +bool StandardServiceEntryPoint::isDefaultService() { + return true; +} + +bool StandardServiceEntryPoint::isSingleInstanceService() { + return true; +} + +bool StandardServiceEntryPoint::canBeAdded() { + return false; +} + +bool StandardServiceEntryPoint::canBeDeleted() { + return false; +} + +bool StandardServiceEntryPoint::canBeEdited() { + return false; +} + +QString StandardServiceEntryPoint::name() { + return QSL("Standard (RSS/RDF/ATOM)"); +} + +QString StandardServiceEntryPoint::description() { + return QSL("This service offers integration with standard online RSS/RDF/ATOM feeds and podcasts."); +} + +QString StandardServiceEntryPoint::version() { + return APP_VERSION; +} + +QString StandardServiceEntryPoint::author() { + return APP_AUTHOR; +} + +QIcon StandardServiceEntryPoint::icon() { + return QIcon(APP_ICON_PATH); +} diff --git a/src/services/standard/standardserviceentrypoint.h b/src/services/standard/standardserviceentrypoint.h new file mode 100755 index 000000000..1aef07b39 --- /dev/null +++ b/src/services/standard/standardserviceentrypoint.h @@ -0,0 +1,41 @@ +// This file is part of RSS Guard. +// +// Copyright (C) 2011-2015 by Martin Rotter +// +// RSS Guard 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 3 of the License, or +// (at your option) any later version. +// +// RSS Guard 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 RSS Guard. If not, see . + +#ifndef STANDARDSERVICEENTRYPOINT_H +#define STANDARDSERVICEENTRYPOINT_H + +#include "services/abstract/serviceentrypoint.h" + + +class StandardServiceEntryPoint : public ServiceEntryPoint { + public: + explicit StandardServiceEntryPoint(); + virtual ~StandardServiceEntryPoint(); + + bool isDefaultService(); + bool isSingleInstanceService(); + bool canBeAdded(); + bool canBeDeleted(); + bool canBeEdited(); + QString name(); + QString description(); + QString version(); + QString author(); + QIcon icon(); +}; + +#endif // STANDARDSERVICEENTRYPOINT_H diff --git a/src/services/tt-rss/ttrssserviceentrypoint.cpp b/src/services/tt-rss/ttrssserviceentrypoint.cpp new file mode 100755 index 000000000..d1fc413da --- /dev/null +++ b/src/services/tt-rss/ttrssserviceentrypoint.cpp @@ -0,0 +1,70 @@ +// This file is part of RSS Guard. +// +// Copyright (C) 2011-2015 by Martin Rotter +// +// RSS Guard 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 3 of the License, or +// (at your option) any later version. +// +// RSS Guard 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 RSS Guard. If not, see . + +#include "services/tt-rss/ttrssserviceentrypoint.h" + +#include "definitions/definitions.h" +#include "miscellaneous/application.h" + + +TtRssServiceEntryPoint::TtRssServiceEntryPoint(){ +} + + +TtRssServiceEntryPoint::~TtRssServiceEntryPoint() { + +} + +bool TtRssServiceEntryPoint::isDefaultService() { + return false; +} + +bool TtRssServiceEntryPoint::isSingleInstanceService() { + return false; +} + +bool TtRssServiceEntryPoint::canBeAdded() { + return true; +} + +bool TtRssServiceEntryPoint::canBeDeleted() { + return true; +} + +bool TtRssServiceEntryPoint::canBeEdited() { + return true; +} + +QString TtRssServiceEntryPoint::name() { + return QSL("TT-RSS (TinyTiny RSS)"); +} + +QString TtRssServiceEntryPoint::description() { + return QSL("This service offers integration with TinyTiny RSS."); +} + +QString TtRssServiceEntryPoint::version() { + return QSL("0.0.1"); +} + +QString TtRssServiceEntryPoint::author() { + return APP_AUTHOR; +} + +QIcon TtRssServiceEntryPoint::icon() { + return QIcon(APP_ICON_PATH); +} diff --git a/src/services/tt-rss/ttrssserviceentrypoint.h b/src/services/tt-rss/ttrssserviceentrypoint.h new file mode 100755 index 000000000..5294af5ad --- /dev/null +++ b/src/services/tt-rss/ttrssserviceentrypoint.h @@ -0,0 +1,42 @@ +// This file is part of RSS Guard. +// +// Copyright (C) 2011-2015 by Martin Rotter +// +// RSS Guard 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 3 of the License, or +// (at your option) any later version. +// +// RSS Guard 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 RSS Guard. If not, see . + + +#ifndef TTRSSSERVICEENTRYPOINT_H +#define TTRSSSERVICEENTRYPOINT_H + +#include "services/abstract/serviceentrypoint.h" + + +class TtRssServiceEntryPoint : public ServiceEntryPoint { + public: + explicit TtRssServiceEntryPoint(); + virtual ~TtRssServiceEntryPoint(); + + bool isDefaultService(); + bool isSingleInstanceService(); + bool canBeAdded(); + bool canBeDeleted(); + bool canBeEdited(); + QString name(); + QString description(); + QString version(); + QString author(); + QIcon icon(); +}; + +#endif // TTRSSSERVICEENTRYPOINT_H