Debian Codegraph @

src/librssguard-standard/src/standardserviceroot.h

raw symbols SCIP
1 // For license of this file, see <project-root-folder>/LICENSE.md.
2
3 #ifndef STANDARDSERVICEROOT_H
4 #define STANDARDSERVICEROOT_H
5
6 #include "src/standardfeed.h"
7
8 #include <librssguard/services/abstract/serviceroot.h>
9
10 #include <QCoreApplication>
11 #include <QMutex>
12 #include <QPair>
13
14 class StandardCategory;
15 class FeedsImportExportModel;
16 class QMenu;
17
18 class StandardServiceRoot : public ServiceRoot {
19 Q_OBJECT
20
21 friend class FormStandardFeedDetails;
22 friend class FormStandardImportExport;
23
24 public:
25 explicit StandardServiceRoot(RootItem* parent = nullptr);
26 virtual ~StandardServiceRoot();
27
28 virtual FormAccountDetails* accountSetupDialog() const;
29 virtual void onDatabaseCleanup();
30 virtual void onAfterFeedsPurged(const QList<Feed*>& feeds);
31 virtual void start(bool freshly_activated);
32 virtual void stop();
33 virtual QString code() const;
34 virtual bool canBeEdited() const;
35 virtual void editItems(const QList<RootItem*>& items);
36 virtual bool supportsFeedAdding() const;
37 virtual bool supportsCategoryAdding() const;
38 virtual Qt::ItemFlags additionalFlags() const;
39 virtual QVariantHash customDatabaseData() const;
40 virtual void setCustomDatabaseData(const QVariantHash& data);
41 virtual QList<Message> obtainNewMessages(Feed* feed,
42 const QHash<ServiceRoot::BagOfMessages, QStringList>& stated_messages,
43 const QHash<QString, QStringList>& tagged_messages);
44
45 QList<QAction*> serviceMenu();
46 QList<QAction*> getContextMenuForFeed(StandardFeed* feed);
47
48 void spaceHost(const QString& host, const QString& url);
49 void resetHostSpacing(const QString& host, const QDateTime& next_dt);
50
51 // If set to number > 0, then requests to fetch feeds
52 // will be spaced by the given number (in seconds).
53 // This is used to avoid too many concurrent network
54 // requests from to the same server and getting HTTP/429
55 // errors or other DDoS-attack-related bans.
56 int spacingSameHostsRequests() const;
57 void setSpacingSameHostsRequests(int spacing);
58
59 static QString defaultTitle();
60
61 public slots:
62 void addNewFeed(RootItem* selected_item, const QString& url = QString());
63 void addNewCategory(RootItem* selected_item);
64
65 private slots:
66 void importFeeds();
67 void exportFeeds();
68
69 private:
70 // Takes structure residing under given root item and adds feeds/categories from
71 // it to active structure.
72 // NOTE: This is used for import/export of the model.
73 bool mergeImportExportModel(FeedsImportExportModel* model, RootItem* target_root_node, QString& output_message);
74
75 QPointer<StandardFeed> m_feedForMetadata = {};
76 QList<QAction*> m_feedContextMenu = {};
77
78 int m_spacingSameHostsRequests;
79 QHash<QString, QDateTime> m_spacingHosts;
80 QMutex m_spacingMutex;
81 };
82
83 #endif // STANDARDSERVICEROOT_H