Remove notification from status aread when marking as read
authorArtem Garmash <artemgarmash@gmail.com>
Sun, 10 Jan 2010 17:43:06 +0000 (19:43 +0200)
committerArtem Garmash <artem.garmash@nokia.com>
Sun, 27 Jun 2010 19:13:42 +0000 (22:13 +0300)
src/el-home-applet.c

index 3d58568..c73026d 100644 (file)
 #define SCROLL_STEP 1 /* pixel */
 #define TEXT_Y_OFFSET (HEADER_HEIGHT + HILDON_MARGIN_HALF)
 
+#define NOTIFICATION_UI_DBUS_NAME     "org.freedesktop.Telepathy.Client.NotificationUI"
+#define NOTIFICATION_UI_DBUS_PATH     "/org/freedesktop/Telepathy/Client/NotificationUI"
+#define NOTIFICATION_UI_DBUS_IFACE    "com.nokia.RtcomNotificationUi"
+
 struct _ELHomeAppletPrivate
 {
         RTComEl *eventlogger;
@@ -824,6 +828,72 @@ read_event (ELHomeApplet *self)
 }
 
 static void
+remove_notification (ELHomeApplet *self)
+{
+        ELHomeAppletPrivate *priv = self->priv;
+
+        DBusGConnection* conn;
+        GError *error;
+        DBusGProxy *proxy;
+        GPtrArray *conv_structs;
+        GType conv_structs_type;
+        GValueArray *account_info;
+        GValue value = {0, };
+        DBusGProxyCall *call;
+
+        if (!(priv->remote_id && priv->local_id))
+                return;
+
+        conn = hd_home_plugin_item_get_dbus_g_connection (HD_HOME_PLUGIN_ITEM (self),
+                                                          DBUS_BUS_SESSION,
+                                                          &error);
+        if (!conn) {
+                g_error ("Failed get dbus g connection %s", error->message);
+                g_error_free (error);
+                return;
+        }
+
+        proxy = dbus_g_proxy_new_for_name (conn,
+                                           NOTIFICATION_UI_DBUS_NAME,
+                                           NOTIFICATION_UI_DBUS_PATH,
+                                           NOTIFICATION_UI_DBUS_IFACE);
+
+        conv_structs = g_ptr_array_sized_new (1);
+        account_info = g_value_array_new (2);
+
+        g_value_init (&value, G_TYPE_STRING);
+        g_value_set_string (&value, priv->local_id);
+        g_value_array_append (account_info, &value);
+        g_value_unset (&value);
+
+        g_value_init (&value, G_TYPE_STRING);
+        g_value_set_string (&value, priv->remote_id);
+        g_value_array_append (account_info, &value);
+        g_value_unset (&value);
+
+        g_ptr_array_add (conv_structs, account_info);
+
+        conv_structs_type = dbus_g_type_get_collection
+                ("GPtrArray",
+                 dbus_g_type_get_struct ("GValueArray",
+                                         G_TYPE_STRING,
+                                         G_TYPE_STRING,
+                                         G_TYPE_INVALID));
+
+        call = dbus_g_proxy_begin_call (proxy,
+                                        "ClearConversationNotifications",
+                                        NULL, NULL, NULL,
+                                        conv_structs_type,
+                                        conv_structs,
+                                        G_TYPE_INVALID);
+
+        g_value_array_free (account_info);
+        g_ptr_array_free (conv_structs, TRUE);
+
+        g_object_unref (proxy);
+}
+
+static void
 mark_as_read (ELHomeApplet *self)
 {
         ELHomeAppletPrivate *priv = self->priv;
@@ -833,6 +903,7 @@ mark_as_read (ELHomeApplet *self)
                                          priv->event_id,
                                          TRUE,
                                          NULL);
+                remove_notification (self);
         }
 }