summaryrefslogtreecommitdiff
path: root/libsowatch/watchserver.cpp
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2013-05-06 23:13:37 +0200
committerJavier S. Pedro <maemo@javispedro.com>2013-05-06 23:13:37 +0200
commitae37832316d905889c82706b351b3c037c9e1ab6 (patch)
treed90c4a18729937b782f557e170cf95d4ef38f031 /libsowatch/watchserver.cpp
parentd83093df7602aa2896de71292b47948540c22a44 (diff)
downloadsowatch-ae37832316d905889c82706b351b3c037c9e1ab6.tar.gz
sowatch-ae37832316d905889c82706b351b3c037c9e1ab6.zip
prepare for weather qml notifications
Diffstat (limited to 'libsowatch/watchserver.cpp')
-rw-r--r--libsowatch/watchserver.cpp47
1 files changed, 6 insertions, 41 deletions
diff --git a/libsowatch/watchserver.cpp b/libsowatch/watchserver.cpp
index 41dc78e..0b7b60f 100644
--- a/libsowatch/watchserver.cpp
+++ b/libsowatch/watchserver.cpp
@@ -162,6 +162,7 @@ const NotificationsModel * WatchServer::notifications() const
void WatchServer::postNotification(Notification *notification)
{
const Notification::Type type = notification->type();
+ const Notification::Priority priority = notification->priority();
// Add notification to model
_notifications->add(notification);
@@ -173,14 +174,8 @@ void WatchServer::postNotification(Notification *notification)
qDebug() << "notification received" << notification->title() << "(" << notification->count() << ")";
- _watch->updateNotificationCount(type, getNotificationCount(type));
-
- if (type == Notification::WeatherNotification) {
- // Weather notifications, we handle differently.
- WeatherNotification* weather = static_cast<WeatherNotification*>(notification);
- _weather = weather;
- _watch->updateWeather(weather);
- return; // And do not display it the usual way
+ if (priority == Notification::Silent) {
+ return; // Do not display notification in the usual way
}
QDateTime oldThreshold = QDateTime::currentDateTime().addSecs(-_oldNotificationThreshold);
@@ -191,8 +186,9 @@ void WatchServer::postNotification(Notification *notification)
if (_pendingNotifications.isEmpty()) {
_pendingNotifications.enqueue(notification);
nextNotification();
- } else if (type == Notification::CallNotification) {
- // Oops, priority!!!!
+ } else if (priority == Notification::Urgent) {
+ // Notification has priority, so we switch to it even if there is
+ // an active notification.
_pendingNotifications.prepend(notification);
nextNotification();
} else {
@@ -319,21 +315,12 @@ void WatchServer::syncTime()
}
}
-uint WatchServer::getNotificationCount(Notification::Type type)
-{
- // TODO: deprecate
- return 0;
- //return _notifications->fullCountByType(type);
-}
-
void WatchServer::removeNotification(Notification::Type type, Notification *n)
{
// Warning: This function might be called with n being deleted.
_notifications->remove(type, n);
_notificationCounts.remove(n);
- _watch->updateNotificationCount(type, getNotificationCount(type));
-
if (!_pendingNotifications.isEmpty() && _pendingNotifications.head() == n) {
qDebug() << "removing top notification";
_pendingNotifications.removeAll(n);
@@ -341,12 +328,6 @@ void WatchServer::removeNotification(Notification::Type type, Notification *n)
} else {
_pendingNotifications.removeAll(n);
}
- if (type == Notification::WeatherNotification) {
- WeatherNotification* w = static_cast<WeatherNotification*>(n);
- if (_weather == w) {
- _weather = 0;
- }
- }
// No longer interested in this notification
disconnect(n, 0, this, 0);
@@ -419,22 +400,6 @@ void WatchServer::handleNotificationChanged()
qDebug() << "notification changed" << n->title() << "(" << n->count() << ")";
- _watch->updateNotificationCount(type, getNotificationCount(type));
-
- if (type == Notification::WeatherNotification) {
- WeatherNotification* w = static_cast<WeatherNotification*>(n);
- if (!_weather || _weather->dateTime() < w->dateTime()) {
- // Prefer showing the most recent data
- _weather = w;
- }
- if (_weather == w) {
- // This is the weather notification we are currently displaying on the watch
- // Therefore, update the displayed information
- _watch->updateWeather(w);
- }
- return; // Do not display it the usual way
- }
-
if (!_pendingNotifications.isEmpty() && _pendingNotifications.head() == n) {
// This is the notification that is being currently signaled on the watch
// Therefore, show it again no matter what.