#ifndef SOWATCH_WATCHSERVER_H #define SOWATCH_WATCHSERVER_H #include #include #include #include #include #include "sowatch_global.h" #include "notificationsmodel.h" namespace sowatch { class Watch; class Watchlet; class NotificationProvider; class WeatherNotification; class SOWATCH_EXPORT WatchServer : public QObject { Q_OBJECT Q_PROPERTY(Watch* watch READ watch CONSTANT) Q_PROPERTY(QString nextWatchletButton READ nextWatchletButton WRITE setNextWatchletButton) public: explicit WatchServer(Watch *watch, QObject *parent = 0); Watch* watch(); const Watch* watch() const; QString nextWatchletButton() const; void setNextWatchletButton(const QString& value); void addWatchlet(Watchlet *watchlet); void insertWatchlet(int position, Watchlet *watchlet); void moveWatchlet(const Watchlet *watchlet, int to); void removeWatchlet(const Watchlet *watchlet); void addProvider(NotificationProvider *provider); void removeProvider(const NotificationProvider *provider); /** Get a list of all current live notifications. */ const NotificationsModel * notifications() const; public slots: void postNotification(Notification *notification); void nextNotification(); void runWatchlet(Watchlet* watchlet); void runWatchlet(const QString& id); void closeWatchlet(); void nextWatchlet(); void syncTime(); signals: void watchConnected(); void watchDisconnected(); private: Watch* _watch; /** The watch button that causes next watchlet to be run. */ int _nextWatchletButton; /** The amount of seconds that have to pass for a notification to be considered "outdated" and not shown. */ int _oldNotificationThreshold; /** A list of watchlets, in order. */ QList _watchlets; /** Stores all the watchlets with a given watchled id. */ QMap _watchletIds; /** Stores current live notifications. */ NotificationsModel *_notifications; /** A list of notifications that are yet to be shown to the user. */ QQueue _pendingNotifications; /** Stores the count of notifications hidden between each notification object. */ QMap _notificationCounts; /** We store a currently live weather forecast. */ WeatherNotification* _weather; /** Current watchlet. */ Watchlet* _currentWatchlet; /** Is the current watchlet active? */ bool _currentWatchletActive; /** The current watchlet index if any, for use by nextWatchlet() */ int _currentWatchletIndex; /** Used for periodic watch time syncing. */ QTimer* _syncTimeTimer; /** Counts all notifications from a given type. */ uint getNotificationCount(Notification::Type type); /** Remove a notification of a certain type. */ void removeNotification(Notification::Type type, Notification* n); void deactivateCurrentWatchlet(); void reactivateCurrentWatchlet(); void goToIdle(); private slots: void handleWatchConnected(); void handleWatchDisconnected(); void handleWatchIdling(); void handleWatchButtonPress(int button); void handleNotificationChanged(); void handleNotificationDismissed(); void handleNotificationDestroyed(); }; } #endif // SOWATCH_WATCHSERVER_H