]> git.0d.be Git - empathy.git/commitdiff
Try installing gnome-contacts using PackageKit
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Tue, 7 Feb 2012 16:12:15 +0000 (17:12 +0100)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 8 Feb 2012 13:30:43 +0000 (14:30 +0100)
https://bugzilla.gnome.org/show_bug.cgi?id=669578

libempathy-gtk/empathy-individual-menu.c

index 6d9359d65fa5550759050549f153d992492436da..4174cc759b7d78f880eee390db0b521e07ad2ae6 100644 (file)
@@ -39,6 +39,7 @@
 #include <libempathy/empathy-chatroom-manager.h>
 #include <libempathy/empathy-utils.h>
 #include <libempathy/empathy-contact-list.h>
+#include <libempathy/empathy-pkg-kit.h>
 
 #include "empathy-account-selector-dialog.h"
 #include "empathy-individual-menu.h"
@@ -1310,7 +1311,37 @@ show_gnome_contacts_error_dialog (void)
 }
 
 static void
-start_gnome_contacts (FolksIndividual *individual)
+start_gnome_contacts (FolksIndividual *individual,
+    gboolean try_installing);
+
+static void
+install_gnome_contacts_cb (GObject *source,
+    GAsyncResult *result,
+    gpointer user_data)
+{
+  FolksIndividual *individual = user_data;
+  GError *error = NULL;
+
+  if (!empathy_pkg_kit_install_packages_finish (result, &error))
+    {
+      DEBUG ("Failed to install gnome-contacts: %s", error->message);
+      g_error_free (error);
+
+      show_gnome_contacts_error_dialog ();
+      goto out;
+    }
+
+  DEBUG ("gnome-contacts installed");
+
+  start_gnome_contacts (individual, FALSE);
+
+out:
+  g_object_unref (individual);
+}
+
+static void
+start_gnome_contacts (FolksIndividual *individual,
+    gboolean try_installing)
 {
   GDesktopAppInfo *desktop_info;
   gchar *cmd;
@@ -1326,9 +1357,20 @@ start_gnome_contacts (FolksIndividual *individual)
   desktop_info = g_desktop_app_info_new ("gnome-contacts.desktop");
   if (desktop_info == NULL)
     {
-      DEBUG ("gnome-contacts not installed");
+      if (try_installing)
+        {
+          const gchar *packages[] = { "gnome-contacts", NULL };
+
+          DEBUG ("gnome-contacts not installed; try to install it");
+
+          empathy_pkg_kit_install_packages_async (0, packages, NULL,
+              NULL, install_gnome_contacts_cb, g_object_ref (individual));
+        }
+      else
+        {
+          show_gnome_contacts_error_dialog ();
+        }
 
-      show_gnome_contacts_error_dialog ();
       return;
     }
 
@@ -1358,7 +1400,7 @@ start_gnome_contacts (FolksIndividual *individual)
 static void
 individual_info_menu_item_activate_cb (FolksIndividual *individual)
 {
-  start_gnome_contacts (individual);
+  start_gnome_contacts (individual, TRUE);
 }
 
 static GtkWidget *
@@ -1377,7 +1419,7 @@ empathy_individual_info_menu_item_new (FolksIndividual *individual)
   gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
   gtk_widget_show (image);
 
-  g_signal_connect_swapped (item, "activate",
+  g_signal_connect (item, "activate",
           G_CALLBACK (individual_info_menu_item_activate_cb),
           individual);