1 // For license of this file, see <project-root-folder>/LICENSE.md. 2 3 #ifndef FEEDREADER_H 4 #define FEEDREADER_H 5 6 #include <QObject> 7 8 #include "core/feeddownloader.h" 9 #include "core/messagefilter.h" 10 #include "services/abstract/cacheforserviceroot.h" 11 #include "services/abstract/feed.h" 12 13 #include <QFutureWatcher> 14 15 class FeedsModel; 16 class MessagesModel; 17 class MessagesProxyModel; 18 class FeedsProxyModel; 19 class ServiceEntryPoint; 20 class QTimer; 21 class QThread; 22 23 class RSSGUARD_DLLSPEC FeedReader : public QObject { 24 Q_OBJECT 25 26 public: 27 explicit FeedReader(QObject* parent = nullptr); 28 virtual ~FeedReader(); 29 30 // List of all installed "feed service plugins". 31 QList<ServiceEntryPoint*> feedServices(); 32 33 // Access to DB cleaner. 34 FeedDownloader* feedDownloader() const; 35 FeedsModel* feedsModel() const; 36 MessagesModel* messagesModel() const; 37 FeedsProxyModel* feedsProxyModel() const; 38 MessagesProxyModel* messagesProxyModel() const; 39 40 // Update feeds in extra thread. 41 void updateFeeds(const QList<Feed*>& feeds); 42 43 // Push back cached message states back to servers in extra thread. 44 void synchronizeMessageData(const QList<CacheForServiceRoot*>& caches); 45 46 void showMessageFiltersManager(); 47 48 // True if feed update is running right now. 49 bool isFeedUpdateRunning() const; 50 51 // Resets global auto-download intervals according to settings 52 // and starts/stop the timer as needed. 53 void updateAutoUpdateStatus(); 54 55 bool autoUpdateEnabled() const; 56 int autoUpdateRemainingInterval() const; 57 int autoUpdateInitialInterval() const; 58 59 void loadSavedMessageFilters(); 60 QList<MessageFilter*> messageFilters() const; 61 MessageFilter* addMessageFilter(const QString& title, const QString& script); 62 void removeMessageFilter(MessageFilter* filter); 63 void updateMessageFilter(MessageFilter* filter); 64 void assignMessageFilterToFeed(Feed* feed, MessageFilter* filter); 65 void removeMessageFilterToFeedAssignment(Feed* feed, MessageFilter* filter); 66 67 public slots: 68 void updateAllFeeds(); 69 void updateManuallyIntervaledFeeds(); 70 void stopRunningFeedUpdate(); 71 void quit(); 72 73 private slots: 74 void executeNextAutoUpdate(); 75 76 signals: 77 void feedUpdatesStarted(); 78 void feedUpdatesFinished(FeedDownloadResults updated_feeds); 79 void feedUpdatesProgress(const Feed* feed, int current, int total); 80 81 private: 82 void initializeFeedDownloader(); 83 84 private: 85 QList<ServiceEntryPoint*> m_feedServices; 86 QList<MessageFilter*> m_messageFilters; 87 FeedsModel* m_feedsModel; 88 FeedsProxyModel* m_feedsProxyModel; 89 MessagesModel* m_messagesModel; 90 MessagesProxyModel* m_messagesProxyModel; 91 92 // Auto-update stuff. 93 QTimer* m_autoUpdateTimer; 94 bool m_globalAutoUpdateEnabled{}; 95 bool m_globalAutoUpdateOnlyUnfocused{}; 96 int m_globalAutoUpdateInitialInterval{}; 97 int m_globalAutoUpdateRemainingInterval{}; 98 QThread* m_feedDownloaderThread; 99 FeedDownloader* m_feedDownloader; 100 }; 101 102 #endif // FEEDREADER_H 103