OSDN Git Service

alert: Update Alert Status and Ringer Setting characteristic values
authorAnderson Lizardo <anderson.lizardo@openbossa.org>
Tue, 2 Oct 2012 20:24:44 +0000 (16:24 -0400)
committerJohan Hedberg <johan.hedberg@intel.com>
Wed, 3 Oct 2012 19:28:35 +0000 (22:28 +0300)
Now these characteristic values are updated when the agent changes any
PASP alert state or setting.

profiles/alert/server.c

index 2c124b4..0c525e8 100644 (file)
@@ -339,6 +339,27 @@ static void update_new_alert(gpointer data, gpointer user_data)
                                                                value[0], NULL);
 }
 
+static void update_phone_alerts(const char *category, const char *description)
+{
+       unsigned int i;
+
+       if (g_str_equal(category, "ringer")) {
+               if (g_str_equal(description, "enabled"))
+                       ringer_setting = RINGER_NORMAL;
+               else if (g_str_equal(description, "disabled"))
+                       ringer_setting = RINGER_SILENT;
+       }
+
+       for (i = 0; i < G_N_ELEMENTS(pasp_categories); i++) {
+               if (g_str_equal(pasp_categories[i], category)) {
+                       if (g_str_equal(description, "active"))
+                               alert_status |= (1 << i);
+                       else if (g_str_equal(description, "not active"))
+                               alert_status &= ~(1 << i);
+               }
+       }
+}
+
 static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
                                                                void *data)
 {
@@ -399,6 +420,9 @@ static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
                }
        }
 
+       if (pasp_category(category))
+               update_phone_alerts(category, description);
+
        DBG("NewAlert(\"%s\", %d, \"%s\")", category, count, description);
 
        return dbus_message_new_method_return(msg);