+
+ if (priv->event_id >= 0) {
+ gboolean new_account = g_strcmp0 (priv->local_id, local_id);
+
+ if (g_strcmp0 (priv->remote_id, remote_id) ||
+ new_account ||
+ !priv->contact) {
+ clean_contact (self, TRUE);
+ start_aggregator (self);
+ }
+ else if (priv->contact) {
+ show_contact (self);
+ }
+
+ if (new_account) {
+ if (g_strcmp0 (priv->local_id, "ring/tel/ring") == 0) {
+ icon_name = "general_sms";
+ }
+ else {
+ McAccount *account;
+ OssoABookAccountManager *am = osso_abook_account_manager_get_default ();
+ if (!osso_abook_waitable_is_ready (OSSO_ABOOK_WAITABLE (am), NULL)) {
+ osso_abook_account_manager_call_when_ready (am,
+ am_ready,
+ self,
+ NULL);
+ }
+ else {
+ account = osso_abook_account_manager_lookup_by_name (NULL,
+ priv->local_id);
+ if (account) {
+ McProfile *profile = mc_profile_lookup (mc_account_compat_get_profile (account));
+ icon_name = mc_profile_get_icon_name (profile);
+ }
+ }
+ }
+
+ if (icon_name) {
+ gtk_image_set_from_icon_name (GTK_IMAGE (priv->icon),
+ icon_name,
+ HILDON_ICON_SIZE_XSMALL);
+ gtk_widget_show (priv->icon);
+ }
+ else
+ gtk_widget_hide (priv->icon);
+ }
+ }
+ else {
+ gchar *text;
+ gint n_sms_events = 0, n_sms_convs = 0;
+ gint n_chat_events = 0, n_chat_convs = 0;
+ const gchar *fmt = "%d <span size=\"small\">(%d)</span>";
+
+ query_read_events (priv->eventlogger,
+ "RTCOM_EL_SERVICE_SMS",
+ &n_sms_events, &n_sms_convs);
+ query_read_events (priv->eventlogger,
+ "RTCOM_EL_SERVICE_CHAT",
+ &n_chat_events, &n_chat_convs);
+
+ text = g_strdup_printf (fmt, n_sms_convs, n_sms_events);
+ gtk_label_set_markup (GTK_LABEL (priv->sms_total), text);
+ g_free (text);
+
+ text = g_strdup_printf (fmt, n_chat_convs, n_chat_events);
+ gtk_label_set_markup (GTK_LABEL (priv->chat_total), text);
+ g_free (text);
+
+ gtk_label_set_text (GTK_LABEL (priv->sender),
+ dgettext ("rtcom-messaging-ui",
+ "messaging_ap_conversations"));
+
+ clean_contact (self, TRUE);
+ gtk_widget_hide (priv->icon);
+ }
+
+ g_free (local_id);
+ g_free (remote_id);
+}
+
+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);