1 #ifndef SEAFILE_CLIENT_SEAHUB_MESSAGES_MONITOR_ 2 #define SEAFILE_CLIENT_SEAHUB_MESSAGES_MONITOR_ 3 4 #include <QObject> 5 6 class QTimer; 7 8 class ApiError; 9 class GetUnseenSeahubNotificationsRequest; 10 11 class SeahubNotificationsMonitor : public QObject 12 { 13 Q_OBJECT 14 public: 15 static SeahubNotificationsMonitor* instance(); 16 17 void start(); 18 void refresh(bool force); 19 getUnreadNotifications()20 int getUnreadNotifications() const { return unread_count_; } 21 22 void openNotificationsPageInBrowser(); 23 24 public slots: 25 void refresh(); 26 27 signals: 28 void notificationsChanged(); 29 30 private slots: 31 void onRequestSuccess(int count); 32 void onRequestFailed(const ApiError& error); 33 void onAccountChanged(); 34 35 private: 36 SeahubNotificationsMonitor(QObject *parent=0); 37 static SeahubNotificationsMonitor *singleton_; 38 39 void resetStatus(); 40 void setUnreadNotificationsCount(int count); 41 42 QTimer *refresh_timer_; 43 GetUnseenSeahubNotificationsRequest *check_messages_req_; 44 bool in_refresh_; 45 46 int unread_count_; 47 }; 48 49 #endif // SEAFILE_CLIENT_SEAHUB_MESSAGES_MONITOR_ 50