diff options
author | Javier S. Pedro <maemo@javispedro.com> | 2013-04-01 15:04:58 +0200 |
---|---|---|
committer | Javier S. Pedro <maemo@javispedro.com> | 2013-04-01 15:04:58 +0200 |
commit | 5ef8b38e55c1883224fe1f01f47aba45b7b42666 (patch) | |
tree | 67a873c6a7c5263d202793314c3b3a61543fbb40 /board.h | |
download | tapasboard-5ef8b38e55c1883224fe1f01f47aba45b7b42666.tar.gz tapasboard-5ef8b38e55c1883224fe1f01f47aba45b7b42666.zip |
initial import
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 |