Skip to content

Commit

Permalink
save weather service state in daemon and emit status
Browse files Browse the repository at this point in the history
  • Loading branch information
StefWe authored and FlorentRevest committed Jan 6, 2020
1 parent c618b15 commit 4551c95
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions asteroidsyncservice/watch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Watch::Watch(const QDBusObjectPath &path, QObject *parent) : QObject(parent), m_
connect(m_iface, SIGNAL(ScreenshotServiceChanged()), this, SIGNAL(screenshotServiceChanged()));
connect(m_iface, SIGNAL(ProgressChanged(unsigned int)), this, SLOT(onScreenshotTransferProgress(unsigned int)));
connect(m_iface, SIGNAL(ScreenshotReceived(QByteArray)), this, SLOT(onScreenshotReceived(QByteArray)));
connect(m_iface, SIGNAL(WeatherServiceChanged()), this, SIGNAL(weatherServiceChanged()));

dataChanged();
}
Expand Down Expand Up @@ -187,3 +188,8 @@ QString Watch::createScreenshotFilename(const QString filename)
QDateTime dt = QDateTime::currentDateTime();
return dt.toString(filename);
}

bool Watch::weatherServiceReady()
{
return fetchProperty("StatusWeatherService").toBool();
}
3 changes: 3 additions & 0 deletions asteroidsyncservice/watch.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Watch : public QObject
Q_OBJECT
Q_PROPERTY(QString name READ name CONSTANT)
Q_PROPERTY(QString weatherCityName READ weatherCityName WRITE setWeatherCityName NOTIFY weatherCityNameChanged)
Q_PROPERTY(bool weatherServiceReady READ weatherServiceReady NOTIFY weatherServiceChanged)
Q_PROPERTY(quint8 batteryLevel READ batteryLevel NOTIFY batteryLevelChanged)
Q_PROPERTY(bool timeServiceReady READ timeServiceReady NOTIFY timeServiceChanged)
Q_PROPERTY(bool notificationServiceReady READ notificationServiceReady NOTIFY notificationServiceChanged)
Expand All @@ -58,6 +59,7 @@ class Watch : public QObject
bool notificationServiceReady();
Q_INVOKABLE void setVibration(QString v);
Q_INVOKABLE void sendNotify(unsigned int id, QString appName, QString icon, QString body, QString summary);
bool weatherServiceReady();

public slots:
void requestScreenshot();
Expand All @@ -71,6 +73,7 @@ public slots:
void screenshotServiceChanged();
void screenshotProgressChanged();
void screenshotReceived(QString screenshotPath);
void weatherServiceChanged();

private:
void dataChanged();
Expand Down
14 changes: 14 additions & 0 deletions asteroidsyncserviced/dbusinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ DBusWatch::DBusWatch(Watch *watch, WatchesManager* wm, QObject *parent): QObject
connect(m_screenshotService, SIGNAL(ready()), this, SLOT(onScreenshotServiceReady()));
connect(m_screenshotService, SIGNAL(progressChanged(unsigned int)), this, SIGNAL(ProgressChanged(unsigned int)));
connect(m_screenshotService, SIGNAL(screenshotReceived(QByteArray)), this, SIGNAL(ScreenshotReceived(QByteArray)));
connect(m_weatherService, SIGNAL(ready()), this, SLOT(onWeatherServiceReady()));
connect(wm, SIGNAL(disconnected()), this, SLOT(onDisconnected()));
}

Expand All @@ -55,6 +56,9 @@ void DBusWatch::onDisconnected()

m_screenshotServiceReady = false;
emit ScreenshotServiceChanged();

m_weatherServiceReady = false;
emit WeatherServiceChanged();
}

void DBusWatch::SelectWatch()
Expand Down Expand Up @@ -135,6 +139,16 @@ bool DBusWatch::StatusScreenshotService()
return m_screenshotServiceReady;
}

void DBusWatch::onWeatherServiceReady()
{
m_weatherServiceReady = true;
emit WeatherServiceChanged();
}

bool DBusWatch::StatusWeatherService()
{
return m_weatherServiceReady;
}

/* Manager Interface */

Expand Down
4 changes: 4 additions & 0 deletions asteroidsyncserviced/dbusinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class DBusWatch: public QObject
void ScreenshotServiceChanged();
void ProgressChanged(unsigned int);
void ScreenshotReceived(QByteArray);
void WeatherServiceChanged();

public slots:
void SelectWatch();
Expand All @@ -56,6 +57,7 @@ public slots:
bool StatusTimeService();
bool StatusNotifyService();
bool StatusScreenshotService();
bool StatusWeatherService();
void RequestScreenshot();
void WeatherSetCityName(QString cityName);
void SetTime(QDateTime t);
Expand All @@ -66,6 +68,7 @@ private slots:
void onTimeServiceReady();
void onNotifyServiceReady();
void onScreenshotServiceReady();
void onWeatherServiceReady();
void onDisconnected();

private:
Expand All @@ -81,6 +84,7 @@ private slots:
bool m_timeServiceReady = false;
bool m_notifyServiceReady = false;
bool m_screenshotServiceReady = false;
bool m_weatherServiceReady = false;
};

class DBusInterface : public QObject
Expand Down

0 comments on commit 4551c95

Please sign in to comment.