Commit 4ce7c649 authored by Jonas Kümmerlin's avatar Jonas Kümmerlin Committed by Andre Miranda

Replace dbus-glib with GDBus

The thumbnailer code is a bit hairy, but it appears to work.
Let's wait for the crashes and bug reports.
parent d8bc91d4
......@@ -78,13 +78,11 @@ appdatadir = $(datadir)/appdata
appdata_DATA = $(appdata_in_files:.xml.in=.xml)
appdata_in_files = thunar.appdata.xml.in
if HAVE_DBUS
servicedir = $(datadir)/dbus-1/services
service_in_files = org.xfce.FileManager.service.in org.xfce.Thunar.service.in
service_DATA = $(service_in_files:.service.in=.service)
%.service: %.service.in
$(AM_V_GEN) $(SED) -e "s,\@bindir\@,$(bindir),g" < $< > $@
endif
polkit_policydir = $(datadir)/polkit-1/actions
polkit_in_in_files = \
......
......@@ -162,12 +162,6 @@ dnl **********************************
XDT_CHECK_OPTIONAL_PACKAGE([GIO_UNIX], [gio-unix-2.0],
[2.30.0], [gio-unix], [GIO UNIX features])
dnl **********************************
dnl *** Optional support for D-BUS ***
dnl **********************************
XDT_CHECK_OPTIONAL_PACKAGE([DBUS], [dbus-glib-1],
[0.34], [dbus], [D-BUS support])
dnl ***************************************************************
dnl *** Optional support for GUDev (required for thunar-volman) ***
dnl ***************************************************************
......@@ -252,11 +246,6 @@ dnl ***************************
echo
echo "Build Configuration:"
echo
if test x"$DBUS_FOUND" = x"yes"; then
echo "* D-BUS support: yes"
else
echo "* D-BUS support: no"
fi
if test x"$GIO_UNIX_FOUND" = x"yes"; then
echo "* GIO UNIX features: yes"
else
......
......@@ -12,7 +12,6 @@ thunar/thunar-column-model.c
thunar/thunar-compact-view.c
thunar/thunar-component.c
thunar/thunar-create-dialog.c
thunar/thunar-dbus-client.c
thunar/thunar-dbus-service.c
thunar/thunar-deep-count-job.c
thunar/thunar-details-view.c
......
......@@ -31,6 +31,12 @@ thunar_built_sources = \
thunar-renamer-dialog-ui.h \
thunar-standard-view-ui.h \
thunar-thumbnail-frame.c \
thunar-dbus-service-infos.h \
thunar-dbus-service-infos.c \
thunar-thumbnailer-proxy.c \
thunar-thumbnailer-proxy.h \
thunar-thumbnail-cache-proxy.h \
thunar-thumbnail-cache-proxy.c \
thunar-window-ui.h
......@@ -65,6 +71,8 @@ thunar_SOURCES = \
thunar-component.h \
thunar-create-dialog.c \
thunar-create-dialog.h \
thunar-dbus-service.c \
thunar-dbus-service.h \
thunar-deep-count-job.h \
thunar-deep-count-job.c \
thunar-details-view.c \
......@@ -238,28 +246,6 @@ thunar_LDADD = \
thunar_DEPENDENCIES = \
$(top_builddir)/thunarx/libthunarx-$(THUNARX_VERSION_API).la
if HAVE_DBUS
thunar_built_sources += \
thunar-dbus-service-infos.h \
thunar-thumbnail-cache-proxy.h \
thunar-thumbnailer-proxy.h
thunar_dbus_sources = \
thunar-dbus-client.c \
thunar-dbus-client.h \
thunar-dbus-service.c \
thunar-dbus-service.h \
thunar-thumbnail-cache-proxy.h \
thunar-thumbnailer-proxy.h
thunar_CFLAGS += \
-DDBUS_API_SUBJECT_TO_CHANGE \
$(DBUS_CFLAGS)
thunar_LDADD += \
$(DBUS_LIBS)
endif
if HAVE_GIO_UNIX
thunar_CFLAGS += \
$(GIO_UNIX_CFLAGS)
......@@ -296,28 +282,14 @@ DISTCLEANFILES += \
BUILT_SOURCES = \
$(thunar_built_sources)
if HAVE_DBUS
thunar-dbus-service-infos.h: $(srcdir)/thunar-dbus-service-infos.xml Makefile
$(AM_V_GEN) dbus-binding-tool --prefix=thunar_dbus_service --mode=glib-server $(srcdir)/thunar-dbus-service-infos.xml > thunar-dbus-service-infos.h
thunar-dbus-service-infos.h thunar-dbus-service-infos.c: $(srcdir)/thunar-dbus-service-infos.xml Makefile
$(AM_V_GEN) gdbus-codegen --c-namespace Thunar --generate-c-code=thunar-dbus-service-infos $(srcdir)/thunar-dbus-service-infos.xml
thunar-thumbnailer-proxy.h: $(srcdir)/thunar-thumbnailer-dbus.xml Makefile
$(AM_V_GEN) ( \
dbus-binding-tool --mode=glib-client \
$(srcdir)/thunar-thumbnailer-dbus.xml > thunar-thumbnailer-proxy.h.tmp \
&& $(SED) -e 's/org_freedesktop_thumbnails_Thumbnailer1/thunar_thumbnailer_proxy/g' \
thunar-thumbnailer-proxy.h.tmp > thunar-thumbnailer-proxy.h \
&& $(RM) thunar-thumbnailer-proxy.h.tmp \
)
thunar-thumbnailer-proxy.h thunar-thumbnailer-proxy.c: $(srcdir)/thunar-thumbnailer-dbus.xml Makefile
$(AM_V_GEN) gdbus-codegen --c-namespace Thunar --generate-c-code thunar-thumbnailer-proxy $(srcdir)/thunar-thumbnailer-dbus.xml
thunar-thumbnail-cache-proxy.h: $(srcdir)/thunar-thumbnail-cache-dbus.xml Makefile
$(AM_V_GEN) ( \
dbus-binding-tool --mode=glib-client \
$(srcdir)/thunar-thumbnail-cache-dbus.xml > thunar-thumbnail-cache-proxy.h.tmp \
&& $(SED) -e 's/org_freedesktop_thumbnails_Cache1/thunar_thumbnail_cache_proxy/g' \
thunar-thumbnail-cache-proxy.h.tmp > thunar-thumbnail-cache-proxy.h \
&& $(RM) thunar-thumbnail-cache-proxy.h.tmp \
)
endif
thunar-thumbnail-cache-proxy.h thunar-thumbnail-cache-proxy.c: $(srcdir)/thunar-thumbnail-cache-dbus.xml Makefile
$(AM_V_GEN) gdbus-codegen --c-namespace Thunar --generate-c-code thunar-thumbnail-cache-proxy $(srcdir)/thunar-thumbnail-cache-dbus.xml
thunar-thumbnail-frame.c: $(srcdir)/thunar-thumbnail-frame.png Makefile
$(AM_V_GEN) (echo "#include <thunar/thunar-thumbnail-frame.h>" && gdk-pixbuf-csource --extern --raw --stream --name=thunar_thumbnail_frame $(srcdir)/thunar-thumbnail-frame.png) > thunar-thumbnail-frame.c
......
......@@ -36,8 +36,6 @@
#include <xfconf/xfconf.h>
#include <thunar/thunar-application.h>
#include <thunar/thunar-dbus-client.h>
#include <thunar/thunar-dbus-service.h>
#include <thunar/thunar-gobject-extensions.h>
#include <thunar/thunar-private.h>
#include <thunar/thunar-notify.h>
......
......@@ -61,6 +61,7 @@
#include <thunar/thunar-util.h>
#include <thunar/thunar-view.h>
#include <thunar/thunar-session-client.h>
#include <thunar/thunar-dbus-service.h>
#define ACCEL_MAP_PATH "Thunar/accels.scm"
......@@ -117,6 +118,10 @@ static int thunar_application_handle_local_options (GApplication
GVariantDict *options);
static int thunar_application_command_line (GApplication *application,
GApplicationCommandLine *command_line);
static gboolean thunar_application_dbus_register (GApplication *application,
GDBusConnection *connection,
const gchar *object_path,
GError **error);
static void thunar_application_accel_map_changed (ThunarApplication *application);
static gboolean thunar_application_accel_map_save (gpointer user_data);
static void thunar_application_collect_and_launch (ThunarApplication *application,
......@@ -175,6 +180,8 @@ struct _ThunarApplication
ThunarThumbnailCache *thumbnail_cache;
ThunarThumbnailer *thumbnailer;
ThunarDBusService *dbus_service;
gboolean daemon;
guint accel_map_save_id;
......@@ -229,6 +236,7 @@ thunar_application_class_init (ThunarApplicationClass *klass)
gapplication_class->shutdown = thunar_application_shutdown;
gapplication_class->handle_local_options = thunar_application_handle_local_options;
gapplication_class->command_line = thunar_application_command_line;
gapplication_class->dbus_register = thunar_application_dbus_register;
/**
* ThunarApplication:daemon:
......@@ -364,6 +372,9 @@ thunar_application_shutdown (GApplication *gapp)
/* disconnect from the session manager */
g_object_unref (G_OBJECT (application->session_client));
/* remove the dbus service */
g_clear_pointer (&application->dbus_service, g_object_unref);
G_APPLICATION_CLASS (thunar_application_parent_class)->shutdown (gapp);
}
......@@ -480,6 +491,24 @@ out:
static gboolean
thunar_application_dbus_register (GApplication *gapp,
GDBusConnection *connection,
const gchar *object_path,
GError **error)
{
ThunarApplication *application = THUNAR_APPLICATION (gapp);
if (application->dbus_service) /* WTF? */
return TRUE;
application->dbus_service = g_object_new (THUNAR_TYPE_DBUS_SERVICE, NULL);
return thunar_dbus_service_export_on_connection (application->dbus_service, connection, error);
}
static void
thunar_application_activate (GApplication *gapp)
{
......
/* vi:set et ai sw=2 sts=2 ts=2: */
/*-
* Copyright (c) 2006 Benedikt Meurer <benny@xfce.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <dbus/dbus-glib-lowlevel.h>
#include <dbus/dbus.h>
#include <thunar/thunar-dbus-client.h>
#include <thunar/thunar-private.h>
/**
* thunar_dbus_client_bulk_rename:
* @working_directory : the default working directory for the bulk rename dialog.
* @filenames : the list of files that should be displayed by default or
* the empty list to start with an empty bulk rename dialog.
* @standalone : whether to run the bulk renamer in standalone mode.
* @screen : the #GdkScreen on which to display the dialog or %NULL to
* use the default #GdkScreen.
* @startup_id : startup id to properly finish startup notification and set
* the window timestamp or %NULL.
* @error : return location for errors or %NULL.
*
* Tries to invoke the BulkRename() method on a running Thunar instance, that is
* registered with the current D-BUS session bus. Returns %TRUE if the method was
* successfully invoked, else %FALSE.
*
* If %TRUE is returned, the current process may afterwards just terminate, as
* all @filenames will be handled by the remote instance.
*
* Return value: %TRUE on success, else %FALSE.
**/
gboolean
thunar_dbus_client_bulk_rename (const gchar *working_directory,
gchar **filenames,
gboolean standalone,
GdkScreen *screen,
const gchar *startup_id,
GError **error)
{
DBusConnection *connection;
DBusMessage *message;
DBusMessage *result;
DBusError derror;
gchar *display_name;
_thunar_return_val_if_fail (screen == NULL || GDK_IS_SCREEN (screen), FALSE);
_thunar_return_val_if_fail (g_path_is_absolute (working_directory), FALSE);
_thunar_return_val_if_fail (error == NULL || *error == NULL, FALSE);
_thunar_return_val_if_fail (filenames != NULL, FALSE);
/* initialize the DBusError struct */
dbus_error_init (&derror);
/* fallback to default screen if no other is specified */
if (G_LIKELY (screen == NULL))
screen = gdk_screen_get_default ();
/* try to connect to the session bus */
connection = dbus_bus_get (DBUS_BUS_SESSION, &derror);
if (G_UNLIKELY (connection == NULL))
{
dbus_set_g_error (error, &derror);
dbus_error_free (&derror);
return FALSE;
}
/* determine the display name for the screen */
display_name = gdk_screen_make_display_name (screen);
/* dbus does not like null values */
if (startup_id == NULL)
startup_id = "";
/* generate the BulkRename() method (disable activation!) */
message = dbus_message_new_method_call ("org.xfce.Thunar", "/org/xfce/FileManager", "org.xfce.Thunar", "BulkRename");
dbus_message_set_auto_start (message, FALSE);
dbus_message_append_args (message,
DBUS_TYPE_STRING, &working_directory,
DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &filenames, g_strv_length (filenames),
DBUS_TYPE_BOOLEAN, &standalone,
DBUS_TYPE_STRING, &display_name,
DBUS_TYPE_STRING, &startup_id,
DBUS_TYPE_INVALID);
/* release the display name */
g_free (display_name);
/* send the message and release our references on connection and message */
dbus_error_init (&derror);
result = dbus_connection_send_with_reply_and_block (connection, message, -1, &derror);
dbus_message_unref (message);
/* check if no reply was received */
if (G_UNLIKELY (result == NULL))
{
dbus_set_g_error (error, &derror);
dbus_error_free (&derror);
return FALSE;
}
/* but maybe we received an error */
if (dbus_message_get_type (result) == DBUS_MESSAGE_TYPE_ERROR)
{
dbus_set_error_from_message (&derror, result);
dbus_set_g_error (error, &derror);
dbus_message_unref (result);
dbus_error_free (&derror);
return FALSE;
}
/* let's asume that it worked */
dbus_message_unref (result);
return TRUE;
}
/**
* thunar_dbus_client_launch_files:
* @working_directory : the directory relative to which @filenames may be looked up.
* @filenames : the list of @filenames to launch.
* @screen : the #GdkScreen on which to launch the @filenames or %NULL
* to use the default #GdkScreen.
* @startup_id : startup id to properly finish startup notification and set
* the window timestamp or %NULL.
* @error : return location for errors or %NULL.
*
* Tries to invoke the LaunchFiles() method on a running Thunar instance, that is
* registered with the current D-BUS session bus. Returns %TRUE if the method was
* successfully invoked, else %FALSE.
*
* If %TRUE is returned, the current process may afterwards just terminate, as
* all @filenames will be handled by the remote instance. Else, if %FALSE is
* returned the current process should try to launch the @filenames itself.
*
* Return value: %TRUE on success, else %FALSE.
**/
gboolean
thunar_dbus_client_launch_files (const gchar *working_directory,
gchar **filenames,
GdkScreen *screen,
const gchar *startup_id,
GError **error)
{
DBusConnection *connection;
DBusMessage *message;
DBusMessage *result;
DBusError derror;
gchar *display_name;
_thunar_return_val_if_fail (g_path_is_absolute (working_directory), FALSE);
_thunar_return_val_if_fail (filenames != NULL && *filenames != NULL, FALSE);
_thunar_return_val_if_fail (screen == NULL || GDK_IS_SCREEN (screen), FALSE);
_thunar_return_val_if_fail (error == NULL || *error == NULL, FALSE);
/* initialize the DBusError struct */
dbus_error_init (&derror);
/* fallback to default screen if no other is specified */
if (G_LIKELY (screen == NULL))
screen = gdk_screen_get_default ();
/* try to connect to the session bus */
connection = dbus_bus_get (DBUS_BUS_SESSION, &derror);
if (G_UNLIKELY (connection == NULL))
{
dbus_set_g_error (error, &derror);
dbus_error_free (&derror);
return FALSE;
}
/* determine the display name for the screen */
display_name = gdk_screen_make_display_name (screen);
/* dbus does not like null values */
if (startup_id == NULL)
startup_id = "";
/* generate the LaunchFiles() method (disable activation!) */
message = dbus_message_new_method_call ("org.xfce.Thunar", "/org/xfce/FileManager", "org.xfce.FileManager", "LaunchFiles");
dbus_message_set_auto_start (message, FALSE);
dbus_message_append_args (message,
DBUS_TYPE_STRING, &working_directory,
DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &filenames, g_strv_length (filenames),
DBUS_TYPE_STRING, &display_name,
DBUS_TYPE_STRING, &startup_id,
DBUS_TYPE_INVALID);
/* release the display name */
g_free (display_name);
/* send the message and release our references on connection and message */
dbus_error_init (&derror);
result = dbus_connection_send_with_reply_and_block (connection, message, -1, &derror);
dbus_message_unref (message);
/* check if no reply was received */
if (G_UNLIKELY (result == NULL))
{
dbus_set_g_error (error, &derror);
dbus_error_free (&derror);
return FALSE;
}
/* but maybe we received an error */
if (dbus_message_get_type (result) == DBUS_MESSAGE_TYPE_ERROR)
{
dbus_set_error_from_message (&derror, result);
dbus_set_g_error (error, &derror);
dbus_message_unref (result);
dbus_error_free (&derror);
return FALSE;
}
/* let's asume that it worked */
dbus_message_unref (result);
return TRUE;
}
/**
* thunar_dbus_client_terminate:
* @error : Return location for errors or %NULL.
*
* Tells a running Thunar instance, connected to the D-BUS
* session bus, to terminate immediately.
*
* Return value: %TRUE if any instance was terminated, else
* %FALSE and @error is set.
**/
gboolean
thunar_dbus_client_terminate (GError **error)
{
DBusConnection *connection;
DBusMessage *message;
DBusMessage *result;
DBusError derror;
_thunar_return_val_if_fail (error == NULL || *error == NULL, FALSE);
/* initialize the DBusError struct */
dbus_error_init (&derror);
/* try to connect to the session bus */
connection = dbus_bus_get (DBUS_BUS_SESSION, &derror);
if (G_UNLIKELY (connection == NULL))
{
dbus_set_g_error (error, &derror);
dbus_error_free (&derror);
return FALSE;
}
/* generate the LaunchFiles() method (disable activation!) */
message = dbus_message_new_method_call ("org.xfce.Thunar", "/org/xfce/FileManager", "org.xfce.Thunar", "Terminate");
dbus_message_set_auto_start (message, FALSE);
/* send the message and release our references on connection and message */
dbus_error_init (&derror);
result = dbus_connection_send_with_reply_and_block (connection, message, -1, &derror);
dbus_message_unref (message);
/* check if no reply was received */
if (G_UNLIKELY (result == NULL))
{
/* check if there was nothing to terminate */
if (dbus_error_has_name (&derror, DBUS_ERROR_NAME_HAS_NO_OWNER))
{
dbus_error_free (&derror);
return TRUE;
}
/* Looks like there was a real error */
dbus_set_g_error (error, &derror);
dbus_error_free (&derror);
return FALSE;
}
/* but maybe we received an error */
if (dbus_message_get_type (result) == DBUS_MESSAGE_TYPE_ERROR)
{
dbus_set_error_from_message (&derror, result);
dbus_set_g_error (error, &derror);
dbus_message_unref (result);
dbus_error_free (&derror);
return FALSE;
}
/* let's asume that it worked */
dbus_message_unref (result);
return TRUE;
}
/* vi:set et ai sw=2 sts=2 ts=2: */
/*-
* Copyright (c) 2006 Benedikt Meurer <benny@xfce.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __THUNAR_DBUS_CLIENT_H__
#define __THUNAR_DBUS_CLIENT_H__
#include <gdk/gdk.h>
G_BEGIN_DECLS;
gboolean thunar_dbus_client_bulk_rename (const gchar *working_directory,
gchar **filenames,
gboolean standalone,
GdkScreen *screen,
const gchar *startup_id,
GError **error);
gboolean thunar_dbus_client_launch_files (const gchar *working_directory,
gchar **filenames,
GdkScreen *screen,
const gchar *startup_id,
GError **error);
gboolean thunar_dbus_client_terminate (GError **error);
G_END_DECLS;
#endif /* !__THUNAR_DBUS_CLIENT_H__ */
This diff is collapsed.
......@@ -26,7 +26,7 @@
File Managers.
-->
<interface name="org.xfce.FileManager">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="thunar_dbus_service" />
<annotation name="org.gtk.GDBus.C.Name" value="DBusFileManager" />
<!--
DisplayChooserDialog (uri : STRING, open : BOOLEAN, display : STRING, startup_id : STRING) : VOID
......@@ -350,7 +350,7 @@
Managers that support a trash bin.
-->
<interface name="org.xfce.Trash">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="thunar_dbus_service" />
<annotation name="org.gtk.GDBus.C.Name" value="DBusTrash" />
<!--
DisplayTrash (display : STRING, startup_id : STRING) : VOID
......@@ -441,7 +441,7 @@
do not use this interface, but use org.xfce.FileManager instead.
-->
<interface name="org.xfce.Thunar">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="thunar_dbus_service" />
<annotation name="org.gtk.GDBus.C.Name" value="DBusThunar" />
<!--
BulkRename (working_directory : STRING, filenames : ARRAY OF STRING, standalone : BOOLEAN, display : STRING, startup_id : STRING) : VOID
......
This diff is collapsed.
......@@ -36,7 +36,9 @@ typedef struct _ThunarDBusService ThunarDBusService;
GType thunar_dbus_service_get_type (void) G_GNUC_CONST;
gboolean thunar_dbus_service_has_connection (ThunarDBusService *dbus_service);
gboolean thunar_dbus_service_export_on_connection (ThunarDBusService *service,
GDBusConnection *connection,
GError **error);
G_END_DECLS;
......
<?xml version="1.0" encoding="UTF-8"?>
<node name="/org/freedesktop/thumbnails/Cache1">
<interface name="org.freedesktop.thumbnails.Cache1">
<annotation name="org.gtk.GDBus.C.Name" value="ThumbnailCacheDBus" />
<method name="Move">
<annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
<arg type="as" name="from_uris" direction="in" />
......
This diff is collapsed.
......@@ -22,12 +22,7 @@
#include <config.h>
#endif