| 1 | // For license of this file, see <project-root-folder>/LICENSE.md. |
| 2 | |
| 3 | #ifndef SERVICE_H |
| 4 | #define SERVICE_H |
| 5 | |
| 6 | #include <QDialog> |
| 7 | #include <QIcon> |
| 8 | #include <QString> |
| 9 | |
| 10 | class ServiceRoot; |
| 11 | class FeedsModel; |
| 12 | |
| 13 | // TOP LEVEL class which provides basic information about the "service" |
| 14 | class RSSGUARD_DLLSPEC ServiceEntryPoint { |
| 15 | public: |
| 16 | virtual ~ServiceEntryPoint() = default; |
| 17 | |
| 18 | // Creates new service root item, which is ready to be added |
| 19 | // into the model. This method can for example display |
| 20 | // some kind of first-time configuration dialog inside itself |
| 21 | // before returning the root item. |
| 22 | // Returns nullptr if initialization of new root cannot be done. |
| 23 | virtual ServiceRoot* createNewRoot() const = 0; |
| 24 | |
| 25 | // Performs initialization of all service accounts created using this entry |
| 26 | // point from persistent DB. |
| 27 | // Returns list of root nodes which will be afterwards added |
| 28 | // to the global feed model. |
| 29 | virtual QList<ServiceRoot*> initializeSubtree() const = 0; |
| 30 | |
| 31 | // Human readable service name, for example "TT-RSS". |
| 32 | virtual QString name() const = 0; |
| 33 | |
| 34 | // Some arbitrary string. |
| 35 | // NOTE: Keep in sync with ServiceRoot::code(). |
| 36 | virtual QString code() const = 0; |
| 37 | |
| 38 | // Human readable service description, for example "Services which offers TT-RSS integration.". |
| 39 | virtual QString description() const = 0; |
| 40 | |
| 41 | // Author of the service. |
| 42 | virtual QString author() const = 0; |
| 43 | |
| 44 | // Icon of the service. |
| 45 | virtual QIcon icon() const = 0; |
| 46 | |
| 47 | bool isDynamicallyLoaded() const; |
| 48 | void setIsDynamicallyLoaded(bool dynamic); |
| 49 | |
| 50 | private: |
| 51 | bool m_isDynamicallyLoaded = false; |
| 52 | }; |
| 53 | |
| 54 | inline bool ServiceEntryPoint::isDynamicallyLoaded() const { |
| 55 | return m_isDynamicallyLoaded; |
| 56 | } |
| 57 | |
| 58 | inline void ServiceEntryPoint::setIsDynamicallyLoaded(bool dynamic) { |
| 59 | m_isDynamicallyLoaded = dynamic; |
| 60 | } |
| 61 | |
| 62 | Q_DECLARE_INTERFACE(ServiceEntryPoint, "io.github.martinrotter.rssguard.serviceentrypoint") |
| 63 | |
| 64 | #endif // SERVICE_H |