← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~larsu/evolution-indicator/messaging-menu-fixes into lp:evolution-indicator

 

Lars Uebernickel has proposed merging lp:~larsu/evolution-indicator/messaging-menu-fixes into lp:evolution-indicator.

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

For more details, see:
https://code.launchpad.net/~larsu/evolution-indicator/messaging-menu-fixes/+merge/153957

A couple of minor fixes to lp:~twolife/evolution-indicator/eds-3.6_messaging-menu that I found while testing.
-- 
https://code.launchpad.net/~larsu/evolution-indicator/messaging-menu-fixes/+merge/153957
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	2013-03-18 23:24:24 +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	2013-03-18 23:24:24 +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,21 +57,15 @@
 #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"
 
-#define  USER_BLACKLIST_DIR      "indicators/messages/applications-blacklist"
-#define  USER_BLACKLIST_FILENAME "evolution"
-
 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 UnityLauncherEntry       *launcher = NULL;
@@ -91,7 +84,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 +93,14 @@
 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_in_indicator_applet (void);
-static void hide_evolution_in_indicator_applet (void);
+static void show_evolution (MessagingMenuApp *mmapp, const gchar *url, gpointer user_data);
 
 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 +173,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 +193,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 +295,33 @@
 {
   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)
+  {
+      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 +331,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 {
@@ -444,17 +386,11 @@
   value = entry->value;
 
   show_count = gconf_value_get_bool (value);
- 
+
   if (show_count)
-    {
-      indicate_server_show (server);
-      show_evolution_in_indicator_applet ();
-    }
+    messaging_menu_app_register (mmapp);
   else
-    {
-      indicate_server_hide (server);
-      hide_evolution_in_indicator_applet ();
-    }
+    messaging_menu_app_unregister (mmapp);
 
   g_debug ("EI: Messages in panel %s", 
            show_count ? "true" : "false");
@@ -475,130 +411,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,111 +458,85 @@
     }
   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:";
 
-static void
-command_item_activate (DbusmenuMenuitem * mi, guint timestamp, gpointer user_data)
-{
-	gchar * command = (gchar *)user_data;
-	if (!g_spawn_command_line_async(command, NULL)) {
-		g_warning("EI: Unable to execute command '%s'", command);
-	}
-	return;
-}
-
 int
 e_plugin_lib_enable (EPlugin *ep, int enable)
 {
@@ -748,27 +570,10 @@
       }
     }
 
-    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");
-	DbusmenuMenuitem * root = dbusmenu_menuitem_new();
-
-	DbusmenuMenuitem * mi = dbusmenu_menuitem_new();
-	dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Compose New Message"));
-	g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(command_item_activate), EVO_COMPOSE_CMD);
-	dbusmenu_menuitem_child_append(root, mi);
-
-	mi = dbusmenu_menuitem_new();
-	dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_LABEL, _("Contacts"));
-	g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(command_item_activate), EVO_CONTACTS_CMD);
-	dbusmenu_menuitem_child_append(root, mi);
-
-	dbusmenu_server_set_root(menu_server, root);
-	indicate_server_set_menu(server, menu_server);
+    if (mmapp == NULL)
+       mmapp = messaging_menu_app_new ("evolution.desktop");
+
+    g_signal_connect (mmapp, "activate-source", G_CALLBACK (show_evolution), NULL);
 
     launcher = unity_launcher_entry_get_for_desktop_file (EVOLUTION_DESKTOP_FILE);
 
@@ -797,22 +602,14 @@
     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 ();
-    }
+      messaging_menu_app_register (mmapp);
     else
-      {
-        indicate_server_hide (server);
-        hide_evolution_in_indicator_applet ();
-      }
+      messaging_menu_app_unregister (mmapp);
   }
   else
   {
@@ -820,28 +617,21 @@
     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;
-
-    /* Free server */
-    indicate_server_hide (server);
-    g_object_unref (server);
-    server = NULL;
-
-    /* Remove evolution from indicator menu */
-    hide_evolution_in_indicator_applet ();
-    
+    g_slist_foreach (accounts, (GFunc)unref_account, NULL);
+    g_slist_free (accounts);
+    accounts = NULL;
+
+    messaging_menu_app_unregister (mmapp);
+
     g_debug ("EI: Disabled");
   }
 
-	return 0;
+  return 0;
 }
 
 GtkWidget *
@@ -995,7 +785,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 +794,7 @@
 
   if (shell)
   {
-    GSList    *i;
+    MessagingMailAccount *account;
     EShellWindow *shell_window;
     EShellView *shell_view;
     GtkAction *action;
@@ -1014,7 +804,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 +813,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
@@ -1045,113 +834,3 @@
     return;
   }
 }
-
-
-/*
- *
- *  SHOW/HIDE EVOLUTION IN INDICATOR APPLET
- *
- */
-
-static void
-show_evolution_in_indicator_applet (void)
-{
-  gchar *bpath;
-
-  bpath = g_build_filename (g_get_user_config_dir (),
-                            USER_BLACKLIST_DIR,
-                            USER_BLACKLIST_FILENAME,
-                            NULL);
-
-  if (g_file_test (bpath, G_FILE_TEST_EXISTS))
-    {
-      GFile *bfile;
-
-      bfile = g_file_new_for_path (bpath);
-
-      if (bfile)
-        {
-          GError *error = NULL;
-
-          g_file_delete (bfile, NULL, &error);
-
-          if (error)
-            {
-              g_warning ("EI: Unable to remove blacklist file: %s", error->message);
-              g_error_free (error);
-            }
-
-          g_object_unref (bfile);
-        }
-    }
-
-  g_free (bpath);
-}
-
-static void
-hide_evolution_in_indicator_applet (void)
-{
-  gchar  *bdir;
-  gchar  *bpath;
-  GError *error = NULL;
-
-  bdir = g_build_filename (g_get_user_config_dir (),
-                           USER_BLACKLIST_DIR,
-                           NULL);
-  if (!g_file_test (bdir, G_FILE_TEST_IS_DIR))
-    {
-      GFile *dirfile;
-
-      dirfile = g_file_new_for_path (bdir);
-      if (dirfile)
-        {
-          g_file_make_directory_with_parents (dirfile,
-                                              NULL, 
-                                              &error);
-          if (error)
-            {
-              g_warning ("EI: Unable to create blacklist directory: %s",
-                         error->message);
-              g_error_free (error);
-              g_object_unref (dirfile);
-              g_free (bdir);
-              g_free (bpath);
-              return;
-            }
-        }
-      else
-        {
-          g_warning ("EI: Unable to create blacklist directory: Unable to create "
-                     "GFile for path %s", bdir);
-          g_free (bdir);
-          g_free (bpath);
-          return;
-        }
-
-      g_object_unref (dirfile);
-    }
-  g_free (bdir);
-
-  bpath = g_build_filename (g_get_user_config_dir (),
-                            USER_BLACKLIST_DIR,
-                            USER_BLACKLIST_FILENAME,
-                            NULL);
-
-  if (g_file_set_contents (bpath,
-                           EVOLUTION_DESKTOP_FILE,
-                           -1,
-                           &error))
-    {
-      g_debug ("EI: Successfully wrote blacklist file to %s", bpath);
-    }
-  else
-    {
-      g_debug ("EI: Unable to write blacklist file to %s: %s",
-               bpath,
-               error ? error->message : "Unknown");
-      if (error)
-        g_error_free (error);
-    }
-
-  g_free (bpath);
-}

=== modified file 'src/org-freedesktop-evolution-indicator.eplug.xml'
--- src/org-freedesktop-evolution-indicator.eplug.xml	2011-07-10 13:45:32 +0000
+++ src/org-freedesktop-evolution-indicator.eplug.xml	2013-03-18 23:24:24 +0000
@@ -5,7 +5,8 @@
     location="@PLUGINDIR@/liborg-freedesktop-evolution-indicator.so" 
     id="org.freedesktop.evolution_indicator" 
     domain="@GETTEXT_PACKAGE@"
-    _name="Evolution Indicator">
+    _name="Evolution Indicator"
+    load-on-startup="true">
 
 		<_description>Shows new mail count in a message indicator.</_description>
 		<author name="Neil Jagdish Patel" email="neil.patel@xxxxxxxxxxxxx"/>


Follow ups