[file-roller] Migrate from dbus-glib to glib's GDBus
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [file-roller] Migrate from dbus-glib to glib's GDBus
- Date: Fri, 2 Jul 2010 18:00:44 +0000 (UTC)
commit 1f67652249852a08c071e7cc4e639d35c6274390
Author: Paolo Bacchilega <paobac src gnome org>
Date: Fri Jul 2 15:46:47 2010 +0200
Migrate from dbus-glib to glib's GDBus
[bug #622900]
configure.ac | 13 +----
src/Makefile.am | 6 +--
src/dlg-package-installer.c | 117 +++++++++++++++++++++++--------------------
3 files changed, 68 insertions(+), 68 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 3022148..b31ede3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -25,8 +25,8 @@ dnl it too, or it will never make it into the spec file!
dnl
dnl ==========================================================================
-GLIB_REQUIRED=2.16.0
-GIO_REQUIRED=2.16.0
+GLIB_REQUIRED=2.25.5
+GIO_REQUIRED=2.25.5
GTK_REQUIRED=2.19.7
GCONF_REQUIRED=2.6.0
NAUTILUS_REQUIRED=2.22.2
@@ -99,15 +99,8 @@ AC_ARG_ENABLE(packagekit,
[AC_HELP_STRING([--disable-packagekit],[build without PackageKit support])],,
[enable_packagekit=yes])
if test "x$enable_packagekit" != "xno"; then
- PKG_CHECK_MODULES(DBUS, dbus-glib-1, has_dbus_glib=yes, has_dbug_glib=no)
- if test "x$has_dbus_glib" = "xyes"; then
- AC_DEFINE(ENABLE_PACKAGEKIT, 1, [define to enable PackageKit installer])
- else
- enable_packagekit=no
- fi
+ AC_DEFINE(ENABLE_PACKAGEKIT, 1, [define to enable PackageKit installer])
fi
-AC_SUBST(DBUS_CFLAGS)
-AC_SUBST(DBUS_LIBS)
dnl ******************************
diff --git a/src/Makefile.am b/src/Makefile.am
index 019a7ac..e099e67 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -42,8 +42,7 @@ INCLUDES = \
-DPRIVEXECDIR=\"$(privexecdir)\" \
-DSHDIR=\"$(shdir)\" \
$(DISABLE_DEPRECATED) \
- $(FR_CFLAGS) \
- $(DBUS_CFLAGS)
+ $(FR_CFLAGS)
BUILT_SOURCES = \
fr-marshal.c \
@@ -188,8 +187,7 @@ fr-enum-types.c: typedefs.h fr-enum-types.h
file_roller_LDADD = \
$(top_builddir)/copy-n-paste/libeggsmclient.la \
- $(FR_LIBS) \
- $(DBUS_LIBS)
+ $(FR_LIBS)
EXTRA_DIST = fr-marshal.list
diff --git a/src/dlg-package-installer.c b/src/dlg-package-installer.c
index 3737883..d50af2d 100644
--- a/src/dlg-package-installer.c
+++ b/src/dlg-package-installer.c
@@ -25,11 +25,6 @@
#include <glib/gi18n.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
-
-#ifdef ENABLE_PACKAGEKIT
-#include <dbus/dbus-glib.h>
-#endif /* ENABLE_PACKAGEKIT */
-
#include "dlg-package-installer.h"
#include "gtk-utils.h"
#include "main.h"
@@ -81,32 +76,33 @@ package_installer_terminated (InstallerData *idata,
#ifdef ENABLE_PACKAGEKIT
+
+
static void
-packagekit_install_package_call_notify_cb (DBusGProxy *proxy,
- DBusGProxyCall *call,
- gpointer user_data)
+packagekit_install_package_names_ready_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
{
InstallerData *idata = user_data;
- gboolean success;
+ GDBusProxy *proxy;
+ GVariant *values;
GError *error = NULL;
char *message = NULL;
- success = dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
- if (! success) {
- const char *remote = NULL;
-
- if (error->domain == DBUS_GERROR && error->code == DBUS_GERROR_REMOTE_EXCEPTION)
- remote = dbus_g_error_get_name (error);
- if ((remote == NULL) || (strcmp (remote, "org.freedesktop.PackageKit.Modify.Failed") == 0))
- message = g_strdup_printf ("%s\n%s",
- _("There was an internal error trying to search for applications:"),
- error->message);
- g_error_free (error);
+ proxy = G_DBUS_PROXY (source_object);
+ values = g_dbus_proxy_call_finish (proxy, res, &error);
+ if (values == NULL) {
+ message = g_strdup_printf ("%s\n%s",
+ _("There was an internal error trying to search for applications:"),
+ error->message);
+ g_clear_error (&error);
}
package_installer_terminated (idata, message);
g_free (message);
+ if (values != NULL)
+ g_variant_unref (values);
g_object_unref (proxy);
}
@@ -146,13 +142,13 @@ get_packages_real_names (char **names)
static void
install_packages (InstallerData *idata)
{
- gboolean success = FALSE;
- DBusGConnection *connection;
+ GDBusConnection *connection;
+ GError *error = NULL;
- connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
+ connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
if (connection != NULL) {
GdkWindow *window;
- DBusGProxy *proxy;
+ GDBusProxy *proxy;
window = gtk_widget_get_window (GTK_WIDGET (idata->window));
if (window != NULL) {
@@ -163,44 +159,55 @@ install_packages (InstallerData *idata)
gdk_cursor_unref (cursor);
}
- proxy = dbus_g_proxy_new_for_name (connection,
- "org.freedesktop.PackageKit",
- "/org/freedesktop/PackageKit",
- "org.freedesktop.PackageKit.Modify");
+ proxy = g_dbus_proxy_new_sync (connection,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ "org.freedesktop.PackageKit",
+ "/org/freedesktop/PackageKit",
+ "org.freedesktop.PackageKit.Modify",
+ NULL,
+ &error);
if (proxy != NULL) {
- guint xid;
- char **names;
- char **real_names;
- DBusGProxyCall *call;
-
- if (window != NULL)
- xid = GDK_WINDOW_XID (window);
- else
- xid = 0;
-
- dbus_g_proxy_set_default_timeout (proxy, INT_MAX);
-
- names = g_strsplit (idata->packages, ",", -1);
- real_names = get_packages_real_names (names);
- call = dbus_g_proxy_begin_call (proxy,
- "InstallPackageNames",
- (DBusGProxyCallNotify) packagekit_install_package_call_notify_cb,
- idata,
- NULL,
- G_TYPE_UINT, xid,
- G_TYPE_STRV, names,
- G_TYPE_STRING, "hide-confirm-search,hide-finished,hide-warning",
- G_TYPE_INVALID);
- success = (call != NULL);
+ guint xid;
+ char **names;
+ char **real_names;
+
+ if (window != NULL)
+ xid = GDK_WINDOW_XID (window);
+ else
+ xid = 0;
+
+ names = g_strsplit (idata->packages, ",", -1);
+ real_names = get_packages_real_names (names);
+
+ g_dbus_proxy_call (proxy,
+ "InstallPackageNames",
+ g_variant_new ("(u^asms)",
+ xid,
+ names,
+ "hide-confirm-search,hide-finished,hide-warning"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ packagekit_install_package_names_ready_cb,
+ idata);
g_strfreev (real_names);
g_strfreev (names);
}
}
- if (! success)
- package_installer_terminated (idata, _("Archive type not supported."));
+ if (error != NULL) {
+ char *message;
+
+ message = g_strdup_printf ("%s\n%s",
+ _("There was an internal error trying to search for applications:"),
+ error->message);
+ package_installer_terminated (idata, message);
+
+ g_clear_error (&error);
+ }
}
@@ -221,6 +228,8 @@ confirm_search_dialog_response_cb (GtkDialog *dialog,
installer_data_free (idata);
}
}
+
+
#endif /* ENABLE_PACKAGEKIT */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]