From 5ef8b38e55c1883224fe1f01f47aba45b7b42666 Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Mon, 1 Apr 2013 15:04:58 +0200 Subject: initial import --- board.h | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 board.h (limited to 'board.h') diff --git a/board.h b/board.h new file mode 100644 index 0000000..38e5297 --- /dev/null +++ b/board.h @@ -0,0 +1,75 @@ +#ifndef BOARD_H +#define BOARD_H + +#include +#include +#include + +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 _queue; +}; + +inline bool Board::busy() const +{ + return !_queue.empty(); +} + +inline QSqlDatabase Board::database() +{ + return _db; +} + +inline XmlRpcInterface * Board::service() +{ + return _iface; +} + +#endif // BOARD_H -- cgit v1.2.3