* Travis Reitter <travis.reitter@collabora.co.uk>
*/
-#include <config.h>
-
-#include <string.h>
-#include <stdlib.h>
+#include "config.h"
+#include "empathy-individual-information-dialog.h"
-#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
-#include <gio/gdesktopappinfo.h>
-
-#include <telepathy-glib/util.h>
-#include <folks/folks.h>
-#include <folks/folks-telepathy.h>
-#include <libempathy/empathy-individual-manager.h>
-#include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-pkg-kit.h>
-
-#include "empathy-individual-information-dialog.h"
+#include "empathy-individual-manager.h"
#include "empathy-individual-widget.h"
+#include "empathy-pkg-kit.h"
#include "empathy-ui-utils.h"
+#include "empathy-utils.h"
#define DEBUG_FLAG EMPATHY_DEBUG_CONTACT
-#include <libempathy/empathy-debug.h>
+#include "empathy-debug.h"
#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyIndividualInformationDialog)
typedef struct {
start_gnome_contacts (FolksIndividual *individual,
gboolean try_installing)
{
- GDesktopAppInfo *desktop_info;
- gchar *cmd;
- GAppInfo *app_info;
+ gchar *args;
GError *error = NULL;
- GdkAppLaunchContext *context = NULL;
- GdkDisplay *display;
g_return_if_fail (FOLKS_IS_INDIVIDUAL (individual));
- /* Start gnome-contacts */
- display = gdk_display_get_default ();
- context = gdk_display_get_app_launch_context (display);
-
- desktop_info = g_desktop_app_info_new ("gnome-contacts.desktop");
- if (desktop_info == NULL)
- {
- if (try_installing)
- {
- const gchar *packages[] = { "gnome-contacts", NULL };
+ args = g_strdup_printf ("-i %s", folks_individual_get_id (individual));
- DEBUG ("gnome-contacts not installed; try to install it");
+ /* First try the old desktop name */
+ if (empathy_launch_external_app ("gnome-contacts.desktop", args, NULL))
+ goto out;
- empathy_pkg_kit_install_packages_async (0, packages, NULL,
- NULL, install_gnome_contacts_cb, g_object_ref (individual));
- }
- else
+ if (!empathy_launch_external_app ("org.gnome.Contacts.desktop", args, &error))
+ {
+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
{
- show_gnome_contacts_error_dialog ();
+ 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 ();
+ }
}
-
- return;
}
- /* glib doesn't have API to start a desktop file with args... (#637875) */
- cmd = g_strdup_printf ("%s -i %s", g_app_info_get_commandline (
- (GAppInfo *) desktop_info), folks_individual_get_id (individual));
-
- app_info = g_app_info_create_from_commandline (cmd, NULL, 0, &error);
- if (app_info == NULL)
- {
- DEBUG ("Failed to create app_info: %s", error->message);
- g_error_free (error);
- return;
- }
-
- if (!g_app_info_launch (app_info, NULL, (GAppLaunchContext *) context,
- &error))
- {
- g_critical ("Failed to start gnome-contacts: %s", error->message);
- g_error_free (error);
- }
-
- g_object_unref (desktop_info);
- g_object_unref (app_info);
+out:
+ g_free (args);
}
/* Use gnome-contacts to display @individual or fallback to