← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~twolife/evolution-indicator/eds-3.6_messaging-menu into lp:evolution-indicator

 

Mathieu Trudel-Lapierre has proposed merging lp:~twolife/evolution-indicator/eds-3.6_messaging-menu into lp:evolution-indicator.

Requested reviews:
  Lars Uebernickel (larsu)
  Indicator Applet Developers (indicator-applet-developers)

For more details, see:
https://code.launchpad.net/~twolife/evolution-indicator/eds-3.6_messaging-menu/+merge/140996

We should really merge this and do a proper release of evolution-indicator....
-- 
https://code.launchpad.net/~twolife/evolution-indicator/eds-3.6_messaging-menu/+merge/140996
Your team ayatana-commits is subscribed to branch lp:evolution-indicator.
=== modified file 'configure.ac'
--- configure.ac	2012-05-25 21:05:11 +0000
+++ configure.ac	2012-12-20 21:27:20 +0000
@@ -70,7 +70,6 @@
 AC_SUBST(GCC_FLAGS)
 
 PKG_CHECK_MODULES(DEPS,
-                  indicate-0.7 >= 0.6.90
                   $EVOLUTION_PLUGIN
                   dbus-1
                   dbus-glib-1
@@ -81,6 +80,7 @@
                   libebackend-1.2
                   libsoup-2.4
                   gconf-2.0
+                  messaging-menu
                   )
 AC_SUBST(DEPS_CFLAGS)
 AC_SUBST(DEPS_LIBS)

=== modified file 'src/evolution-indicator.c'
--- src/evolution-indicator.c	2012-05-25 21:05:11 +0000
+++ src/evolution-indicator.c	2012-12-20 21:27:20 +0000
@@ -28,6 +28,7 @@
 #include <glib/gprintf.h>
 
 #include <gconf/gconf.h>
+#include <gconf/gconf-client.h>
 
 #include <canberra.h>
 #include <libnotify/notify.h>
@@ -44,9 +45,7 @@
 
 #include <camel/camel.h>
 
-#include <libindicate/server.h>
-#include <libindicate/indicator.h>
-#include <libindicate/indicator-messages.h>
+#include <messaging-menu.h>
 
 #include <unity.h>
 
@@ -58,9 +57,6 @@
 #define SHOW_BUBBLE       CONF_DIR"/show_bubble"
 #define SHOW_NEW_IN_PANEL CONF_DIR"/show_new_messages_in_panel"
 
-#define ACCOUNT_DIR "/apps/evolution/mail"
-#define ACCOUNTS    ACCOUNT_DIR"/accounts"
-
 #define EVOLUTION_DESKTOP_FILE "/usr/share/applications/evolution.desktop"
 
 #define UNREAD_DATA "unread"
@@ -71,10 +67,11 @@
 static GStaticMutex  mlock       = G_STATIC_MUTEX_INIT;
 static GConfClient  *client      = NULL;
 
-static IndicateServer *server     = NULL;
-static GSList         *indicators = NULL;
+static MessagingMenuApp *mmapp    = NULL;
+static GSList           *accounts = NULL;
 static gint            n_accounts = 0;
 
+static DbusmenuServer        *menu_server = NULL;
 static UnityLauncherEntry       *launcher = NULL;
 
 static NotifyNotification *notification   = NULL;
@@ -91,7 +88,6 @@
 static guint         play_sound_id  = 0;
 static guint         show_bubble_id = 0;
 static guint         show_count_id  = 0;
-static guint         accounts_id    = 0;
 
 static gint message_count = 0;
 
@@ -101,28 +97,17 @@
 int         e_plugin_lib_enable               (EPlugin *ep, int enable);
 GtkWidget * e_plugin_lib_get_configure_widget (EPlugin *ep);
 
-static void show_evolution (gpointer arg0, guint timestamp, gpointer arg1);
+static void show_evolution (MessagingMenuApp *mmapp, const gchar *url, gpointer user_data);
 
 static void show_evolution_in_indicator_applet (void);
 static void hide_evolution_in_indicator_applet (void);
 
 typedef struct {
-  gchar *url;
-  gchar *name;
-  gchar *parent;
-  gchar *last_parent;
-
-  gint reap_type;
-
-  gboolean enabled;
-
-} ParserData;
-
-enum {
-  REAP_NONE = 0,
-  REAP_URL,
-  REAP_NAME
-};
+    gchar *name;
+    gchar *url;
+    gint n_count;
+} MessagingMailAccount;
+MessagingMailAccount * find_accounts_for_url(GSList*, const gchar*);
 
 static GtkWidget *
 get_cfg_widget (void)
@@ -195,43 +180,18 @@
   return FALSE;
 }
 
-static gint
-get_indicator_unread_count (IndicateIndicator *indicator)
-{
-  return GPOINTER_TO_INT (g_object_get_data (G_OBJECT (indicator),
-                                             UNREAD_DATA));
-}
-
-static void
-set_indicator_unread_count (IndicateIndicator *indicator, gint count)
-{
-  gchar *count_str;
-
-  count_str = g_strdup_printf ("%d", count);
-  indicate_indicator_set_property (indicator,
-                                   INDICATE_INDICATOR_MESSAGES_PROP_COUNT,
-                                   count_str);
-  g_object_set_data (G_OBJECT (indicator),
-                     UNREAD_DATA,
-                     GINT_TO_POINTER (count));
-
-  g_free (count_str);
-}
-
 void
 org_gnome_mail_new_notify (EPlugin *ep, EMEventTargetFolder *t)
 {
-  gchar *url;
-  CamelURL *service_url;
-
   g_return_if_fail (t != NULL);
 
-  service_url = camel_service_new_camel_url (CAMEL_SERVICE (t->store));
-  url = camel_url_to_string (service_url, 0);
+  MessagingMailAccount *account;
+  CamelURL *service_url = camel_service_new_camel_url (CAMEL_SERVICE (t->store));
+  gchar *url = camel_url_to_string (service_url, 0);
   camel_url_free (service_url);
 
   if (!t->new)
-		return;
+    return;
 
   if (only_inbox && !(t->is_inbox))
   {
@@ -240,50 +200,44 @@
   }
 
   if (evolution_is_focused ())
-{
+  {
     g_debug ("EI: Evolution is focused");
     return;
   }
 
-	g_static_mutex_lock (&mlock);
+  g_static_mutex_lock (&mlock);
 
   g_debug ("EI:mail_new_notify: %s", url);
 
-  message_count += t->new;
- 
-  if (show_count)
+
+  if(g_str_has_prefix (url, "pop"))
   {
-    IndicateIndicator *indicator = NULL;
-    GSList *i;
-
-    for (i = indicators; i; i = i->next)
-      {
-        IndicateIndicator *indi = i->data;
-
-        if (g_strstr_len (url,
-                          -1,
-                          indicate_indicator_get_property (indi, "url")))
+      g_free(url);
+      url = g_strdup_printf("%s", "pop:");
+  }
+
+  account = find_accounts_for_url(accounts, url);
+  if(account) {
+        account->n_count += t->new;
+        message_count += t->new;
+
+        if (show_count)
+        {
+          if (messaging_menu_app_has_source(MESSAGING_MENU_APP (mmapp), url))
           {
-            indicator = indi;
-            break;
-          }
-      }
-    if (indicator)
-      {
-        gint count;
-          
-        count = get_indicator_unread_count (indicator);
-        set_indicator_unread_count (indicator, count + t->new);
+            messaging_menu_app_set_source_count (MESSAGING_MENU_APP (mmapp), url, account->n_count);
+          }
+          else {
+            gchar *name = account->name;
+            messaging_menu_app_append_source_with_count (MESSAGING_MENU_APP (mmapp), url, NULL, name, account->n_count);
+          }
+          messaging_menu_app_draw_attention (MESSAGING_MENU_APP (mmapp), url);
+        }
 
-        indicate_indicator_set_property (indicator,
-                                         INDICATE_INDICATOR_MESSAGES_PROP_ATTENTION,
-                                         "true");
-      }
-    else
-      {
-        g_warning ("EI: Unable to find account that matches %s", url);
-      }
-    }
+  }
+  else {
+      g_warning ("EI: Unable to find account that matches %s", url);
+  }
 
   update_unity_launcher_count ();
 
@@ -348,26 +302,37 @@
 {
   g_return_if_fail (t != NULL);
 
-  GSList *i;
+  MessagingMailAccount *account;
+  CamelStore *store = camel_folder_get_parent_store(t->folder);
+  CamelURL *service_url = camel_service_new_camel_url (CAMEL_SERVICE (store));
+  gchar *url = camel_url_to_string (service_url, 0);
+  camel_url_free (service_url);
 
-	g_static_mutex_lock (&mlock);
+  g_static_mutex_lock (&mlock);
 
   g_debug ("EI: mail_read_notify");
 
-  for (i = indicators; i; i = i->next)
-    {
-      IndicateIndicator *indicator = i->data;
-
-      set_indicator_unread_count (indicator, 0);
-      indicate_indicator_set_property (indicator,
-                                       INDICATE_INDICATOR_MESSAGES_PROP_ATTENTION,
-                                       "false");
-
-      g_debug ("EI: Setting %s to 0 unread messages",
-               indicate_indicator_get_property (indicator, "name"));
-
-    }
-  message_count = 0;
+  if(g_str_has_prefix (url, "pop"))
+  {
+      g_free(url);
+      url = g_strdup_printf("%s", "pop:");
+  }
+
+  account = find_accounts_for_url(accounts, url);
+  if(account)
+  {
+      if (messaging_menu_app_has_source(MESSAGING_MENU_APP (mmapp), url))
+      {
+          messaging_menu_app_remove_attention (MESSAGING_MENU_APP (mmapp), url);
+          messaging_menu_app_remove_source (MESSAGING_MENU_APP (mmapp), url);
+      }
+      message_count -= account->n_count;
+      account->n_count = 0;
+      g_debug ("EI: Setting %s to 0 unread messages", url);
+  }
+  else {
+      g_warning ("EI: Unable to find account that matches %s", url);
+  }
 
   update_unity_launcher_count ();
 
@@ -377,22 +342,10 @@
 void
 update_unity_launcher_count ()
 {
-  GSList *i;
-  int count = 0;
-
   g_debug ("EI: update_unity_launcher_count");
 
-  for (i = indicators; i; i = i->next)
-  {
-    IndicateIndicator *indicator = i->data;
-
-    count = count + get_indicator_unread_count (indicator);
-
-    g_debug ("EI: Setting count to %d unread messages", count);
-
-  }
-  unity_launcher_entry_set_count (launcher, count);
-  if (count > 0)
+  unity_launcher_entry_set_count (launcher, message_count);
+  if (message_count > 0)
   {
     unity_launcher_entry_set_count_visible (launcher, TRUE);
   } else {
@@ -447,12 +400,10 @@
  
   if (show_count)
     {
-      indicate_server_show (server);
       show_evolution_in_indicator_applet ();
     }
   else
     {
-      indicate_server_hide (server);
       hide_evolution_in_indicator_applet ();
     }
 
@@ -475,130 +426,42 @@
   g_debug ("EI: Show Bubbles %s", show_bubble ? "true" : "false");
 }
 
-static IndicateIndicator *
-find_indicator_for_url (GSList *indicator_list, const gchar *url)
+MessagingMailAccount *
+find_accounts_for_url (GSList *accounts_list, const gchar *url)
 {
   GSList *i;
 
-  for (i = indicator_list; i; i = i->next)
+  for (i = accounts_list; i; i = i->next)
     {
-      IndicateIndicator *indicator = i->data;
+      MessagingMailAccount *a = i->data;
 
-      if (g_strcmp0 (indicate_indicator_get_property (indicator, "url"), url)
+      if (g_strcmp0 (a->url, url)
           == 0)
-        return indicator;
+        return a;
     }
   return NULL;
 }
 
-static IndicateIndicator *
-create_indicator (const gchar *url, const gchar *name)
-{
-  IndicateIndicator *indicator;
-
-  indicator = indicate_indicator_new ();
-  indicate_indicator_set_property (indicator,
-                                   INDICATE_INDICATOR_MESSAGES_PROP_NAME,
-                                   name);
-  indicate_indicator_set_property (indicator,
-                                   "url",
-                                   url);
-  set_indicator_unread_count (indicator, 0);
-  indicate_indicator_show (indicator);
-
-  /* FIXME: I need to find a way to show a mailbox individually */
-  g_signal_connect (indicator, "user-display",
-                    G_CALLBACK (show_evolution), NULL);
-
-  g_debug ("EI: New Indicator: %s %s", name, url);
-
-  return indicator;
-}
-
-static void
-start_element_handler (GMarkupParseContext *context,
-                       const gchar         *element_name,
-                       const gchar        **attribute_names,
-                       const gchar        **attribute_values,
-                       gpointer             user_data,
-                       GError             **error)
-{
-  ParserData *data = (ParserData *)user_data;
-
-  if (g_strcmp0 (element_name, "account") == 0)
-    {
-      gint i = 0;
-
-      while (attribute_names[i] != NULL)
-        {
-          if (g_strcmp0 (attribute_names[i], "name") == 0)
-            {
-              data->name = g_strdup (attribute_values[i]);
-            }
-          else if (g_strcmp0 (attribute_names[i], "enabled") == 0)
-            {
-              if (g_strcmp0 (attribute_values[i], "false") == 0)
-                data->enabled = FALSE;
-            }
-          i++;
-        }
-    }
-  else if (g_strcmp0 (element_name, "url") == 0)
-    data->reap_type = REAP_URL;
-  else
-    data->reap_type = REAP_NONE;
-
-  if (data->last_parent)
-    g_free (data->last_parent);
-  
-  data->last_parent = data->parent;
-  data->parent = g_strdup (element_name);
-}
-
-static void
-text_handler (GMarkupParseContext *context,
-              const gchar         *text,
-              gsize                text_len,
-              gpointer             user_data,
-              GError             **error)
-{
-  ParserData *data = (ParserData *)user_data;
-
-  if (!data->url
-      && data->reap_type == REAP_URL
-      && g_strcmp0(data->last_parent, "source") == 0)
-    {
-      gchar **tokens;
-
-      tokens = g_strsplit (text, ";", 2);
-
-      data->url = g_strdup (tokens[0]);
-
-      /* Accounts with no configured way to receive mail will not have a URL */
-      if (!data->url)
-        data->enabled = FALSE;
-
-      g_strfreev (tokens);
-    }
+void
+unref_account(MessagingMailAccount *m)
+{
+    g_free(m->name);
+    g_free(m->url);
+    g_free(m);
 }
 
 static void
 update_accounts (void)
 {
-  GSList   *accounts;
+  ESourceRegistry * registry = NULL;
   GError   *error = NULL;
-  gint      i = 1;
-  GTimeVal  timeval = { 0 };
-  
-  g_get_current_time (&timeval);
-  accounts = gconf_client_get_list (client,
-                                    ACCOUNTS,
-                                    GCONF_VALUE_STRING,
-                                    &error);
-  if (accounts == NULL || error)
+
+  registry = e_source_registry_new_sync (NULL, &error);
+
+  if (!registry || error)
     {
-      g_warning ("EI: Unable to determine number of accounts, "
-                 "defaulting to '1' (%s)",
+      g_warning ("Failed to get access to source registry: %s\n"
+                 "defaulting number of account to '1'",
                  error ? error->message : "unknown");
       if (error)
         g_error_free (error);
@@ -610,98 +473,82 @@
     }
   else
     {
+      GList *list_sources = e_source_registry_list_sources (registry, E_SOURCE_EXTENSION_MAIL_ACCOUNT);
       GSList *old_list;
-      GSList *a;
-      static GMarkupParser parser = {
-          start_element_handler,
-          NULL,
-          text_handler,
-          NULL,
-          NULL
-      };
-
-      old_list = indicators;
-      indicators = NULL;
+      GList *a;
+
+      struct accountData {
+          gchar *name;
+          gchar *protocol;
+          gchar *user;
+          gchar *host;
+          guint16 port;
+          gchar *url;
+      } data;
+
+      old_list = accounts;
+      accounts = NULL;
       
-      for (a = accounts; a; a = a->next)
+      for (a = list_sources; a; a = a->next)
         {
-          gchar               *account_info = a->data;
-          GMarkupParseContext *context;
-          ParserData           data = { NULL, NULL, NULL, NULL, 0, TRUE };
-          IndicateIndicator   *indicator;
-                                        
-          /* Parse account XML to get some useful details about the account */
-          context = g_markup_parse_context_new (&parser, 0, &data, NULL);
-          g_markup_parse_context_parse (context,
-                                        account_info,
-                                        strlen (account_info),
-                                        NULL);
+          MessagingMailAccount *account;
+          ESource *source = E_SOURCE (a->data);
+          if (e_source_get_removable(source) && e_source_get_enabled(source))
+          {
+              ESourceExtension *extension;
+
+              extension = e_source_get_extension(source, E_SOURCE_EXTENSION_MAIL_ACCOUNT);
+              data.protocol = e_source_backend_dup_backend_name ((ESourceBackend *)extension);
+              extension = e_source_get_extension(source, E_SOURCE_EXTENSION_AUTHENTICATION);
+              data.user = e_source_authentication_dup_user ((ESourceAuthentication *)extension);
+              data.host = e_source_authentication_dup_host ((ESourceAuthentication *)extension);
+              data.port = e_source_authentication_get_port ((ESourceAuthentication *)extension);
+
+              if(g_str_has_prefix (data.protocol, "pop")) {
+                  data.name = g_dgettext (EVO_I18N_DOMAIN, "Inbox");
+                  data.url = g_strdup_printf("%s", "pop:");
+              } else {
+                  data.name = e_source_dup_display_name(source);
+                  data.url = g_strdup_printf("%s://%s@%s:%d", data.protocol, g_uri_escape_string(data.user, NULL, FALSE), data.host, data.port);
+              }
 
           /* Check to see account already exists and, if not, create it */
-          indicator = find_indicator_for_url (indicators, data.url);
-          if (indicator)
+          account = find_accounts_for_url (accounts, data.url);
+          if (account)
             {
-              old_list = g_slist_remove (old_list, indicator);
-              indicators = g_slist_append (indicators, indicator);
+              old_list = g_slist_remove (old_list, account);
+              accounts = g_slist_append (accounts, account);
             }
           else
             {
-              if (data.url && g_str_has_prefix (data.url, "pop:"))
-                {
-                  indicator = create_indicator ("pop:",
-                                                g_dgettext (EVO_I18N_DOMAIN,
-                                                            "Inbox"));
-                }
-              else
-                {
-                  indicator = create_indicator (data.url, data.name);
-                }
-              indicators = g_slist_append (indicators, indicator);
-
+              account = g_new(MessagingMailAccount, 1);
+              account->name = g_strdup(data.name);
+              account->url = g_strdup(data.url);
+              account->n_count = 0;
+              accounts = g_slist_append (accounts, account);
               g_debug ("EI: New account: %s (%s)", data.name, data.url);
             }
 
-          if (!data.enabled)
-            indicate_indicator_hide (indicator);
-
-          /* Fake a time */
-          g_time_val_add (&timeval, -1000000 * 60 * i);
-          indicate_indicator_set_property_time (indicator,
-                                     INDICATE_INDICATOR_MESSAGES_PROP_TIME,
-                                                &timeval);
-
-          i++;
-
           /* Clean up */
           g_free (data.url);
           g_free (data.name);
-          g_free (data.parent);
-          g_free (data.last_parent);
-          data.reap_type = REAP_NONE;
-          data.enabled = TRUE;
-          
-          g_markup_parse_context_free (context);
+          g_free (data.protocol);
+          g_free (data.user);
+          g_free (data.host);
+
+          }
         }
 
-      g_slist_foreach (old_list, (GFunc)g_object_unref, NULL);
+      g_slist_foreach (old_list, (GFunc)unref_account, NULL);
       g_slist_free (old_list);
 
       n_accounts = g_slist_length (accounts);
-      g_slist_free (accounts);
+      g_list_free (list_sources);
     }
 
   g_debug ("EI: Number of email accounts: %d", n_accounts);
 }
 
-static void
-on_accounts_changed (GConfClient *gclient,
-                     guint        id,
-                     GConfEntry  *entry,
-                     gpointer     data)
-{
-  update_accounts ();
-}
-
 #define EVO_CONTACTS_CMD  "evolution -c contacts"
 #define EVO_COMPOSE_CMD   "evolution mailto:";
 
@@ -748,13 +595,15 @@
       }
     }
 
-    server = indicate_server_ref_default ();
-    indicate_server_set_type (server, "message");
-    indicate_server_set_desktop_file (server, EVOLUTION_DESKTOP_FILE);
-    g_signal_connect (server, "server-display",
-                      G_CALLBACK (show_evolution), NULL);
-
-	DbusmenuServer * menu_server = dbusmenu_server_new("/messaging/commands");
+    if (mmapp == NULL)
+       mmapp = messaging_menu_app_new ("evolution.desktop");
+
+    messaging_menu_app_register (MESSAGING_MENU_APP (mmapp));
+    g_signal_connect (mmapp, "activate-source", G_CALLBACK (show_evolution), NULL);
+
+    if (menu_server == NULL)
+    {
+	menu_server = dbusmenu_server_new("/messaging/commands");
 	DbusmenuMenuitem * root = dbusmenu_menuitem_new();
 
 	DbusmenuMenuitem * mi = dbusmenu_menuitem_new();
@@ -768,7 +617,7 @@
 	dbusmenu_menuitem_child_append(root, mi);
 
 	dbusmenu_server_set_root(menu_server, root);
-	indicate_server_set_menu(server, menu_server);
+    }
 
     launcher = unity_launcher_entry_get_for_desktop_file (EVOLUTION_DESKTOP_FILE);
 
@@ -797,20 +646,16 @@
     show_count_id = gconf_client_notify_add (client, SHOW_NEW_IN_PANEL, 
                              show_new_in_panel_changed, NULL, NULL, NULL);
 
-    gconf_client_add_dir (client, ACCOUNT_DIR,GCONF_CLIENT_PRELOAD_NONE, NULL);
     update_accounts ();
-    accounts_id = gconf_client_notify_add (client, ACCOUNTS,
-                                           on_accounts_changed, NULL,
-                                           NULL, NULL);
+
+    // TODO: find a way to be notify and run update_accounts(); on accounts changes
 
     if (show_count)
     {
-      indicate_server_show (server);
       show_evolution_in_indicator_applet ();
     }
     else
       {
-        indicate_server_hide (server);
         hide_evolution_in_indicator_applet ();
       }
   }
@@ -820,20 +665,16 @@
     gconf_client_notify_remove (client, play_sound_id);
     gconf_client_notify_remove (client, show_bubble_id);
     gconf_client_notify_remove (client, show_count_id);
-    gconf_client_notify_remove (client, accounts_id);
 
     g_object_unref (client);
     client = NULL;
-    
+
     /* Free indicators */
-    g_slist_foreach (indicators, (GFunc)g_object_unref, NULL);
-    g_slist_free (indicators);
-    indicators = NULL;
+    g_slist_foreach (accounts, (GFunc)unref_account, NULL);
+    g_slist_free (accounts);
+    accounts = NULL;
 
-    /* Free server */
-    indicate_server_hide (server);
-    g_object_unref (server);
-    server = NULL;
+    messaging_menu_app_unregister (mmapp);
 
     /* Remove evolution from indicator menu */
     hide_evolution_in_indicator_applet ();
@@ -841,7 +682,7 @@
     g_debug ("EI: Disabled");
   }
 
-	return 0;
+  return 0;
 }
 
 GtkWidget *
@@ -995,7 +836,7 @@
  */
 
 static void
-show_evolution (gpointer arg0, guint timestamp, gpointer arg1)
+show_evolution (MessagingMenuApp *mmapp, const gchar *url, gpointer user_data)
 {
 #define MAIL_ICON "evolution-mail"
   EShell *shell = e_shell_get_default ();
@@ -1004,7 +845,7 @@
 
   if (shell)
   {
-    GSList    *i;
+    MessagingMailAccount *account;
     EShellWindow *shell_window;
     EShellView *shell_view;
     GtkAction *action;
@@ -1014,7 +855,7 @@
     shell_window = E_SHELL_WINDOW (e_shell_get_active_window (shell));
     if (!evolution_is_focused ())
     {
-        gtk_window_present_with_time (GTK_WINDOW (shell_window), timestamp);
+        gtk_window_present (GTK_WINDOW (shell_window));
     }
 
     /* Switch to the mail view. */
@@ -1023,20 +864,19 @@
     gtk_action_activate (action);
 
     /* Setup the indicators */
-    for (i = indicators; i; i = i->next)
+    account = find_accounts_for_url(accounts, url);
+    if(account)
     {
-      IndicateIndicator *indicator = i->data;
-
-      set_indicator_unread_count (indicator, 0);
-      indicate_indicator_set_property (indicator,
-                                       INDICATE_INDICATOR_MESSAGES_PROP_ATTENTION,
-                                       "false");
-
-      g_debug ("EI: Setting %s to 0 unread messages",
-               indicate_indicator_get_property (indicator, "name"));
-
-    }
-    message_count = 0;
+      gchar *url = account->url;
+
+      message_count -= account->n_count;
+      account->n_count = 0;
+      g_debug ("EI: Setting %s to 0 unread messages", url);
+    }
+    else {
+          g_warning ("EI: Unable to find account that matches %s", url);
+    }
+
     update_unity_launcher_count ();
   }
   else


Follow ups