diff options
Diffstat (limited to 'board.h')
-rw-r--r-- | board.h | 75 |
1 files changed, 75 insertions, 0 deletions
@@ -0,0 +1,75 @@ +#ifndef BOARD_H +#define BOARD_H + +#include <QtCore/QObject> +#include <QtCore/QQueue> +#include <QtSql/QSqlDatabase> + +class Action; +class XmlRpcInterface; + +class Board : public QObject +{ + Q_OBJECT +public: + explicit Board(const QString& boardUrl, QObject *parent = 0); + + bool busy() const; + void enqueueAction(Action* action); + + QSqlDatabase database(); + XmlRpcInterface *service(); + + QString getConfig(const QString& key) const; + void setConfig(const QString& key, const QString &value); + + int rootForumId() const; + + void notifyConfigChanged(); + void notifyForumsChanged(); + void notifyForumTopicsChanged(int forumId, int start, int end); + +signals: + void configChanged(); + void forumsChanged(); + void imageChanged(const QString& imageUrl); + void forumTopicsChanged(int forumId, int start, int end); + +private: + static QString createSlug(const QString& forumUrl); + static QString getDbDir(); + static QString getDbPathFor(const QString& slug); + bool initializeDb(); + bool removeFromActionQueue(Action *action); + void executeActionFromQueue(); + void fetchConfigIfOutdated(); + void fetchForumsIfOutdated(); + +private slots: + void handleActionFinished(Action *action); + void handleActionError(Action *action, const QString& message); + +private: + QString _url; + QString _slug; + QSqlDatabase _db; + XmlRpcInterface *_iface; + QQueue<Action*> _queue; +}; + +inline bool Board::busy() const +{ + return !_queue.empty(); +} + +inline QSqlDatabase Board::database() +{ + return _db; +} + +inline XmlRpcInterface * Board::service() +{ + return _iface; +} + +#endif // BOARD_H |