diff options
47 files changed, 813 insertions, 415 deletions
@@ -1,3 +1,31 @@ +2004-06-20 Havoc Pennington <hp@redhat.com> + + * dbus/dbus-glib-error-enum.h: autogenerate the GError enum + codes from the dbus error names + + * glib/dbus-glib.h: move to subdir dbus/ since it's included + as dbus/dbus-glib.h and that breakage is now visible due to + including dbus/dbus-glib.h in dbus-glib-lowlevel.h + + * glib/dbus-glib.h: s/gproxy/g_proxy/ + + * dbus/dbus-shared.h: new header to hold stuff shared with + binding APIs + + * dbus/dbus-protocol.h (DBUS_ERROR_*): move errors here rather + than dbus-errors.h + + * glib/dbus-glib.h (dbus_set_g_error): move to + dbus-glib-lowlevel.h + + * glib/dbus-glib.h: remove dbus/dbus.h from here; change a bunch + of stuff to enable this + + * dbus/dbus-glib-lowlevel.h: put dbus/dbus.h here + + * a bunch of other changes with the same basic "separate glib + bindings from dbus.h" theme + 2004-06-10 Owen Fraser-Green <owen@discobabe.net> * dbus-sharp.pc.in: Removed glib-sharp inclusion in Libs. diff --git a/dbus/Makefile.am b/dbus/Makefile.am index 255fd7a6..a9ec8808 100644 --- a/dbus/Makefile.am +++ b/dbus/Makefile.am @@ -1,6 +1,20 @@ INCLUDES=-I$(top_srcdir) $(DBUS_CLIENT_CFLAGS) -DDBUS_COMPILATION +if HAVE_GLIB +DBUS_GLIB_BUILT_INCLUDES= \ + dbus-glib-error-enum.h + +GLIB_INCLUDES= \ + dbus-glib.h \ + dbus-glib-lowlevel.h \ + $(DBUS_GLIB_BUILT_INCLUDES) + +dbus-glib-error-enum.h: dbus-protocol.h make-dbus-glib-error-enum.sh + $(srcdir)/make-dbus-glib-error-enum.sh dbus-protocol.h $@ + +endif + dbusincludedir=$(includedir)/dbus-1.0/dbus dbusarchincludedir=$(libdir)/dbus-1.0/include/dbus @@ -18,8 +32,10 @@ dbusinclude_HEADERS= \ dbus-pending-call.h \ dbus-protocol.h \ dbus-server.h \ + dbus-shared.h \ dbus-threads.h \ - dbus-types.h + dbus-types.h \ + $(GLIB_INCLUDES) dbusarchinclude_HEADERS= \ dbus-arch-deps.h @@ -117,8 +133,9 @@ libdbus_convenience_la_SOURCES= \ $(DBUS_SHARED_SOURCES) \ $(DBUS_UTIL_SOURCES) -BUILT_SOURCES=$(dbusarchinclude_HEADERS) -EXTRA_DIST=dbus-arch-deps.h.in +BUILT_SOURCES=$(dbusarchinclude_HEADERS) $(DBUS_GLIB_BUILT_INCLUDES) +EXTRA_DIST=dbus-arch-deps.h.in make-dbus-glib-error-enum.sh +CLEANFILES=$(DBUS_GLIB_BUILT_INCLUDES) ## this library is the same as libdbus, but exports all the symbols ## and is only used for static linking within the dbus package. diff --git a/dbus/dbus-address.c b/dbus/dbus-address.c index f5cc56d2..ef163ce3 100644 --- a/dbus/dbus-address.c +++ b/dbus/dbus-address.c @@ -2,6 +2,7 @@ /* dbus-address.c Server address parser. * * Copyright (C) 2003 CodeFactory AB + * Copyright (C) 2004 Red Hat, Inc. * * Licensed under the Academic Free License version 2.0 * @@ -26,6 +27,7 @@ #include "dbus-internals.h" #include "dbus-list.h" #include "dbus-string.h" +#include "dbus-protocol.h" /** * @defgroup DBusAddressInternals Address parsing diff --git a/dbus/dbus-auth.c b/dbus/dbus-auth.c index e41137f8..83dfc8a7 100644 --- a/dbus/dbus-auth.c +++ b/dbus/dbus-auth.c @@ -1,7 +1,7 @@ /* -*- mode: C; c-file-style: "gnu" -*- */ /* dbus-auth.c Authentication * - * Copyright (C) 2002, 2003 Red Hat Inc. + * Copyright (C) 2002, 2003, 2004 Red Hat Inc. * * Licensed under the Academic Free License version 2.0 * @@ -27,6 +27,7 @@ #include "dbus-keyring.h" #include "dbus-sha.h" #include "dbus-userdb.h" +#include "dbus-protocol.h" /** * @defgroup DBusAuth Authentication diff --git a/dbus/dbus-bus.h b/dbus/dbus-bus.h index 2bde290e..dd5e5eb7 100644 --- a/dbus/dbus-bus.h +++ b/dbus/dbus-bus.h @@ -31,13 +31,6 @@ DBUS_BEGIN_DECLS; -typedef enum -{ - DBUS_BUS_SESSION, /**< The login session bus */ - DBUS_BUS_SYSTEM, /**< The systemwide bus */ - DBUS_BUS_ACTIVATION /**< The bus that activated us, if any */ -} DBusBusType; - DBusConnection *dbus_bus_get (DBusBusType type, DBusError *error); dbus_bool_t dbus_bus_register (DBusConnection *connection, diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index 9b59338b..d68c3958 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -22,6 +22,7 @@ */ #include <config.h> +#include "dbus-shared.h" #include "dbus-connection.h" #include "dbus-list.h" #include "dbus-timeout.h" diff --git a/dbus/dbus-connection.h b/dbus/dbus-connection.h index 5dcbc8c0..fb6dfbcd 100644 --- a/dbus/dbus-connection.h +++ b/dbus/dbus-connection.h @@ -30,6 +30,7 @@ #include <dbus/dbus-errors.h> #include <dbus/dbus-memory.h> #include <dbus/dbus-message.h> +#include <dbus/dbus-shared.h> DBUS_BEGIN_DECLS; @@ -58,13 +59,6 @@ typedef enum DBUS_DISPATCH_NEED_MEMORY /**< More memory is needed to continue. */ } DBusDispatchStatus; -typedef enum -{ - DBUS_HANDLER_RESULT_HANDLED, /**< Message has had its effect */ - DBUS_HANDLER_RESULT_NOT_YET_HANDLED, /**< Message has not had any effect */ - DBUS_HANDLER_RESULT_NEED_MEMORY /**< Need more memory to return another result */ -} DBusHandlerResult; - typedef dbus_bool_t (* DBusAddWatchFunction) (DBusWatch *watch, void *data); typedef void (* DBusWatchToggledFunction) (DBusWatch *watch, diff --git a/dbus/dbus-errors.c b/dbus/dbus-errors.c index 2a7dd853..db7b5a86 100644 --- a/dbus/dbus-errors.c +++ b/dbus/dbus-errors.c @@ -1,7 +1,7 @@ /* -*- mode: C; c-file-style: "gnu" -*- */ /* dbus-errors.c Error reporting * - * Copyright (C) 2002 Red Hat Inc. + * Copyright (C) 2002, 2004 Red Hat Inc. * Copyright (C) 2003 CodeFactory AB * * Licensed under the Academic Free License version 2.0 @@ -24,6 +24,7 @@ #include "dbus-errors.h" #include "dbus-internals.h" #include "dbus-string.h" +#include "dbus-protocol.h" #include <stdarg.h> #include <string.h> diff --git a/dbus/dbus-errors.h b/dbus/dbus-errors.h index ec8c5d96..344c449c 100644 --- a/dbus/dbus-errors.h +++ b/dbus/dbus-errors.h @@ -52,35 +52,6 @@ struct DBusError void *padding1; /**< placeholder */ }; -#define DBUS_ERROR_FAILED "org.freedesktop.DBus.Error.Failed" -#define DBUS_ERROR_NO_MEMORY "org.freedesktop.DBus.Error.NoMemory" -#define DBUS_ERROR_ACTIVATE_SERVICE_NOT_FOUND "org.freedesktop.DBus.Error.ServiceNotFound" -#define DBUS_ERROR_SERVICE_DOES_NOT_EXIST "org.freedesktop.DBus.Error.ServiceDoesNotExist" -#define DBUS_ERROR_SERVICE_HAS_NO_OWNER "org.freedesktop.DBus.Error.ServiceHasNoOwner" -#define DBUS_ERROR_NO_REPLY "org.freedesktop.DBus.Error.NoReply" -#define DBUS_ERROR_IO_ERROR "org.freedesktop.DBus.Error.IOError" -#define DBUS_ERROR_BAD_ADDRESS "org.freedesktop.DBus.Error.BadAddress" -#define DBUS_ERROR_NOT_SUPPORTED "org.freedesktop.DBus.Error.NotSupported" -#define DBUS_ERROR_LIMITS_EXCEEDED "org.freedesktop.DBus.Error.LimitsExceeded" -#define DBUS_ERROR_ACCESS_DENIED "org.freedesktop.DBus.Error.AccessDenied" -#define DBUS_ERROR_AUTH_FAILED "org.freedesktop.DBus.Error.AuthFailed" -#define DBUS_ERROR_NO_SERVER "org.freedesktop.DBus.Error.NoServer" -#define DBUS_ERROR_TIMEOUT "org.freedesktop.DBus.Error.Timeout" -#define DBUS_ERROR_NO_NETWORK "org.freedesktop.DBus.Error.NoNetwork" -#define DBUS_ERROR_ADDRESS_IN_USE "org.freedesktop.DBus.Error.AddressInUse" -#define DBUS_ERROR_DISCONNECTED "org.freedesktop.DBus.Error.Disconnected" -#define DBUS_ERROR_INVALID_ARGS "org.freedesktop.DBus.Error.InvalidArgs" -#define DBUS_ERROR_FILE_NOT_FOUND "org.freedesktop.DBus.Error.FileNotFound" -#define DBUS_ERROR_UNKNOWN_METHOD "org.freedesktop.DBus.Error.UnknownMethod" -#define DBUS_ERROR_TIMED_OUT "org.freedesktop.DBus.Error.TimedOut" -#define DBUS_ERROR_MATCH_RULE_NOT_FOUND "org.freedesktop.DBus.Error.MatchRuleNotFound" -#define DBUS_ERROR_MATCH_RULE_INVALID "org.freedesktop.DBus.Error.MatchRuleInvalid" -#define DBUS_ERROR_SPAWN_EXEC_FAILED "org.freedesktop.DBus.Error.Spawn.ExecFailed" -#define DBUS_ERROR_SPAWN_FORK_FAILED "org.freedesktop.DBus.Error.Spawn.ForkFailed" -#define DBUS_ERROR_SPAWN_CHILD_EXITED "org.freedesktop.DBus.Error.Spawn.ChildExited" -#define DBUS_ERROR_SPAWN_CHILD_SIGNALED "org.freedesktop.DBus.Error.Spawn.ChildSignaled" -#define DBUS_ERROR_SPAWN_FAILED "org.freedesktop.DBus.Error.Spawn.Failed" - void dbus_error_init (DBusError *error); void dbus_error_free (DBusError *error); void dbus_set_error (DBusError *error, diff --git a/dbus/dbus-glib-lowlevel.h b/dbus/dbus-glib-lowlevel.h new file mode 100644 index 00000000..ac2cfa86 --- /dev/null +++ b/dbus/dbus-glib-lowlevel.h @@ -0,0 +1,70 @@ +/* -*- mode: C; c-file-style: "gnu" -*- */ +/* dbus-glib-lowlevel.h GLib integration details that require dbus/dbus.h + * + * Copyright (C) 2002, 2003 CodeFactory AB + * Copyright (C) 2003, 2004 Red Hat, Inc. + * + * Licensed under the Academic Free License version 2.0 + * + * 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 DBUS_GLIB_LOWLEVEL_H +#define DBUS_GLIB_LOWLEVEL_H + +#include <dbus/dbus-glib.h> +#include <dbus/dbus.h> + +G_BEGIN_DECLS + +void dbus_set_g_error (GError **gerror, + DBusError *derror); + +#define DBUS_TYPE_CONNECTION (dbus_connection_get_g_type ()) +#define DBUS_TYPE_MESSAGE (dbus_message_get_g_type ()) +GType dbus_connection_get_g_type (void) G_GNUC_CONST; +GType dbus_message_get_g_type (void) G_GNUC_CONST; + +#define DBUS_TYPE_G_CONNECTION (dbus_g_connection_get_g_type ()) +#define DBUS_TYPE_G_MESSAGE (dbus_g_message_get_g_type ()) +GType dbus_g_connection_get_g_type (void) G_GNUC_CONST; +GType dbus_g_message_get_g_type (void) G_GNUC_CONST; + +void dbus_connection_setup_with_g_main (DBusConnection *connection, + GMainContext *context); +void dbus_server_setup_with_g_main (DBusServer *server, + GMainContext *context); +DBusConnection* dbus_bus_get_with_g_main (DBusBusType type, + GError **error); + +void dbus_g_proxy_send (DBusGProxy *proxy, + DBusMessage *message, + dbus_uint32_t *client_serial); + +DBusConnection* dbus_g_connection_get_connection (DBusGConnection *gconnection); +DBusMessage* dbus_g_message_get_message (DBusGMessage *gmessage); + +/* dbus_g_pending_call_get_pending_call() deliberately skipped for now; + * not sure it makes sense to use any of the DBusPendingCall functions + * on the wrapped pending call (once we have the right exported + * g-functions anyhow) + */ + +G_END_DECLS + +#endif /* DBUS_GLIB_LOWLEVEL_H */ + + + diff --git a/dbus/dbus-glib.h b/dbus/dbus-glib.h new file mode 100644 index 00000000..08c39765 --- /dev/null +++ b/dbus/dbus-glib.h @@ -0,0 +1,157 @@ +/* -*- mode: C; c-file-style: "gnu" -*- */ +/* dbus-glib.h GLib integration + * + * Copyright (C) 2002, 2003 CodeFactory AB + * Copyright (C) 2003, 2004 Red Hat, Inc. + * + * Licensed under the Academic Free License version 2.0 + * + * 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 DBUS_GLIB_H +#define DBUS_GLIB_H + +#include <glib-object.h> +#include <dbus/dbus-protocol.h> +#include <dbus/dbus-shared.h> + +G_BEGIN_DECLS + +#define DBUS_INSIDE_DBUS_GLIB_H 1 + + +/** + * Convert to/from DBusConnection with DBUS_CONNECTION_FROM_G_CONNECTION() + */ +typedef struct DBusGConnection DBusGConnection; +/** + * Convert to/from DBusMessage with DBUS_MESSAGE_FROM_G_MESSAGE() + */ +typedef struct DBusGMessage DBusGMessage; +/** + * Convert to/from DBusPendingCall with DBUS_PENDING_CALL_FROM_G_PENDING_CALL() + */ +typedef struct DBusGPendingCall DBusGPendingCall; + +void dbus_g_connection_flush (DBusGConnection *connection); + +GQuark dbus_g_error_quark (void); +#define DBUS_GERROR dbus_g_error_quark () + +typedef enum +{ +#include <dbus/dbus-glib-error-enum.h> +} DBusGError; + +void dbus_g_thread_init (void); +DBusGConnection* dbus_g_bus_get (DBusBusType type, + GError **error); + +typedef struct DBusGObjectInfo DBusGObjectInfo; +typedef struct DBusGMethodInfo DBusGMethodInfo; + +typedef DBusHandlerResult (* DBusGMethodMarshaller) (DBusGConnection *connection, + DBusGMessage *message, + void *user_data); + +/** + * Object typically generated by dbus-glib-tool that + * stores a mapping from introspection data to a + * function pointer for a C method to be invoked. + */ +struct DBusGMethodInfo +{ + GCallback function; /**< C method to invoke */ + DBusGMethodMarshaller marshaller; /**< Marshaller to go DBusGMessage to C method */ + int data_offset; /**< Offset into the introspection data */ +}; + +/** + * Introspection data for a GObject, normally autogenerated by + * a tool such as dbus-glib-tool. + */ +struct DBusGObjectInfo +{ + int format_version; /**< Allows us to change the rest of this struct + * by adding DBusGObjectInfo2, DBusGObjectInfo3, etc. + */ + const DBusGMethodInfo *infos; /**< Array of method pointers */ + const unsigned char *data; /**< Introspection data */ +}; + +void dbus_g_object_class_install_info (GObjectClass *object_class, + const DBusGObjectInfo *info); +void dbus_g_connection_register_g_object (DBusGConnection *connection, + const char *at_path, + GObject *object); + + +typedef struct DBusGProxy DBusGProxy; +typedef struct DBusGProxyClass DBusGProxyClass; + +#define DBUS_TYPE_G_PROXY (dbus_g_proxy_get_type ()) +#define DBUS_G_PROXY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), DBUS_TYPE_G_PROXY, DBusGProxy)) +#define DBUS_G_PROXY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DBUS_TYPE_G_PROXY, DBusGProxyClass)) +#define DBUS_IS_G_PROXY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), DBUS_TYPE_G_PROXY)) +#define DBUS_IS_G_PROXY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DBUS_TYPE_G_PROXY)) +#define DBUS_G_PROXY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DBUS_TYPE_G_PROXY, DBusGProxyClass)) + + +GType dbus_g_proxy_get_type (void) G_GNUC_CONST; +DBusGProxy* dbus_g_proxy_new_for_service (DBusGConnection *connection, + const char *service_name, + const char *path_name, + const char *interface_name); +DBusGProxy* dbus_g_proxy_new_for_service_owner (DBusGConnection *connection, + const char *service_name, + const char *path_name, + const char *interface_name, + GError **error); +DBusGProxy* dbus_g_proxy_new_for_peer (DBusGConnection *connection, + const char *path_name, + const char *interface_name); +void dbus_g_proxy_connect_signal (DBusGProxy *proxy, + const char *signal_name, + GCallback handler, + void *data, + GClosureNotify free_data_func); +void dbus_g_proxy_disconnect_signal (DBusGProxy *proxy, + const char *signal_name, + GCallback handler, + void *data); +DBusGPendingCall* dbus_g_proxy_begin_call (DBusGProxy *proxy, + const char *method, + int first_arg_type, + ...); +gboolean dbus_g_proxy_end_call (DBusGProxy *proxy, + DBusGPendingCall *pending, + GError **error, + int first_arg_type, + ...); +void dbus_g_proxy_call_no_reply (DBusGProxy *proxy, + const char *method, + int first_arg_type, + ...); + + +#undef DBUS_INSIDE_DBUS_GLIB_H + +G_END_DECLS + +#endif /* DBUS_GLIB_H */ + + + diff --git a/dbus/dbus-keyring.c b/dbus/dbus-keyring.c index 92989b8d..dd22fb64 100644 --- a/dbus/dbus-keyring.c +++ b/dbus/dbus-keyring.c @@ -1,7 +1,7 @@ /* -*- mode: C; c-file-style: "gnu" -*- */ /* dbus-keyring.c Store secret cookies in your homedir * - * Copyright (C) 2003 Red Hat Inc. + * Copyright (C) 2003, 2004 Red Hat Inc. * * Licensed under the Academic Free License version 2.0 * @@ -23,6 +23,7 @@ #include "dbus-keyring.h" #include "dbus-userdb.h" +#include "dbus-protocol.h" #include <dbus/dbus-string.h> #include <dbus/dbus-list.h> #include <dbus/dbus-sysdeps.h> diff --git a/dbus/dbus-protocol.h b/dbus/dbus-protocol.h index 75c9b22c..c30339c9 100644 --- a/dbus/dbus-protocol.h +++ b/dbus/dbus-protocol.h @@ -119,7 +119,42 @@ extern "C" { /* Activation replies */ #define DBUS_ACTIVATION_REPLY_ACTIVATED 0x0 #define DBUS_ACTIVATION_REPLY_ALREADY_ACTIVE 0x1 - + +/* Errors */ +/* WARNING these get autoconverted to an enum in dbus-glib.h. Thus, + * if you change the order it breaks the ABI. Keep them in order. + * Also, don't change the formatting since that will break the sed + * script. + */ +#define DBUS_ERROR_FAILED "org.freedesktop.DBus.Error.Failed" +#define DBUS_ERROR_NO_MEMORY "org.freedesktop.DBus.Error.NoMemory" +#define DBUS_ERROR_ACTIVATE_SERVICE_NOT_FOUND "org.freedesktop.DBus.Error.ServiceNotFound" +#define DBUS_ERROR_SERVICE_DOES_NOT_EXIST "org.freedesktop.DBus.Error.ServiceDoesNotExist" +#define DBUS_ERROR_SERVICE_HAS_NO_OWNER "org.freedesktop.DBus.Error.ServiceHasNoOwner" +#define DBUS_ERROR_NO_REPLY "org.freedesktop.DBus.Error.NoReply" +#define DBUS_ERROR_IO_ERROR "org.freedesktop.DBus.Error.IOError" +#define DBUS_ERROR_BAD_ADDRESS "org.freedesktop.DBus.Error.BadAddress" +#define DBUS_ERROR_NOT_SUPPORTED "org.freedesktop.DBus.Error.NotSupported" +#define DBUS_ERROR_LIMITS_EXCEEDED "org.freedesktop.DBus.Error.LimitsExceeded" +#define DBUS_ERROR_ACCESS_DENIED "org.freedesktop.DBus.Error.AccessDenied" +#define DBUS_ERROR_AUTH_FAILED "org.freedesktop.DBus.Error.AuthFailed" +#define DBUS_ERROR_NO_SERVER "org.freedesktop.DBus.Error.NoServer" +#define DBUS_ERROR_TIMEOUT "org.freedesktop.DBus.Error.Timeout" +#define DBUS_ERROR_NO_NETWORK "org.freedesktop.DBus.Error.NoNetwork" +#define DBUS_ERROR_ADDRESS_IN_USE "org.freedesktop.DBus.Error.AddressInUse" +#define DBUS_ERROR_DISCONNECTED "org.freedesktop.DBus.Error.Disconnected" +#define DBUS_ERROR_INVALID_ARGS "org.freedesktop.DBus.Error.InvalidArgs" +#define DBUS_ERROR_FILE_NOT_FOUND "org.freedesktop.DBus.Error.FileNotFound" +#define DBUS_ERROR_UNKNOWN_METHOD "org.freedesktop.DBus.Error.UnknownMethod" +#define DBUS_ERROR_TIMED_OUT "org.freedesktop.DBus.Error.TimedOut" +#define DBUS_ERROR_MATCH_RULE_NOT_FOUND "org.freedesktop.DBus.Error.MatchRuleNotFound" +#define DBUS_ERROR_MATCH_RULE_INVALID "org.freedesktop.DBus.Error.MatchRuleInvalid" +#define DBUS_ERROR_SPAWN_EXEC_FAILED "org.freedesktop.DBus.Error.Spawn.ExecFailed" +#define DBUS_ERROR_SPAWN_FORK_FAILED "org.freedesktop.DBus.Error.Spawn.ForkFailed" +#define DBUS_ERROR_SPAWN_CHILD_EXITED "org.freedesktop.DBus.Error.Spawn.ChildExited" +#define DBUS_ERROR_SPAWN_CHILD_SIGNALED "org.freedesktop.DBus.Error.Spawn.ChildSignaled" +#define DBUS_ERROR_SPAWN_FAILED "org.freedesktop.DBus.Error.Spawn.Failed" + #ifdef __cplusplus } #endif diff --git a/dbus/dbus-server-debug-pipe.c b/dbus/dbus-server-debug-pipe.c index 4340e154..9f1d55f2 100644 --- a/dbus/dbus-server-debug-pipe.c +++ b/dbus/dbus-server-debug-pipe.c @@ -2,7 +2,7 @@ /* dbus-server-debug-pipe.c In-proc debug server implementation * * Copyright (C) 2003 CodeFactory AB - * Copyright (C) 2003 Red Hat, Inc. + * Copyright (C) 2003, 2004 Red Hat, Inc. * * Licensed under the Academic Free License version 2.0 * @@ -28,6 +28,7 @@ #include "dbus-connection-internal.h" #include "dbus-hash.h" #include "dbus-string.h" +#include "dbus-protocol.h" #ifdef DBUS_BUILD_TESTS diff --git a/dbus/dbus-server-unix.c b/dbus/dbus-server-unix.c index a1d7b4ce..4c79c372 100644 --- a/dbus/dbus-server-unix.c +++ b/dbus/dbus-server-unix.c @@ -1,7 +1,7 @@ /* -*- mode: C; c-file-style: "gnu" -*- */ /* dbus-server-unix.c Server implementation for Unix network protocols. * - * Copyright (C) 2002, 2003 Red Hat Inc. + * Copyright (C) 2002, 2003, 2004 Red Hat Inc. * * Licensed under the Academic Free License version 2.0 * diff --git a/dbus/dbus-server.c b/dbus/dbus-server.c index 2fa52ebe..9661927a 100644 --- a/dbus/dbus-server.c +++ b/dbus/dbus-server.c @@ -1,7 +1,7 @@ /* -*- mode: C; c-file-style: "gnu" -*- */ /* dbus-server.c DBusServer object * - * Copyright (C) 2002, 2003 Red Hat Inc. + * Copyright (C) 2002, 2003, 2004 Red Hat Inc. * * Licensed under the Academic Free License version 2.0 * @@ -28,6 +28,7 @@ #include "dbus-server-debug-pipe.h" #endif #include "dbus-address.h" +#include "dbus-protocol.h" /** * @defgroup DBusServer DBusServer diff --git a/dbus/dbus-server.h b/dbus/dbus-server.h index 98b2a31b..ba9894e9 100644 --- a/dbus/dbus-server.h +++ b/dbus/dbus-server.h @@ -30,6 +30,7 @@ #include <dbus/dbus-errors.h> #include <dbus/dbus-message.h> #include <dbus/dbus-connection.h> +#include <dbus/dbus-protocol.h> DBUS_BEGIN_DECLS; diff --git a/dbus/dbus-shared.h b/dbus/dbus-shared.h new file mode 100644 index 00000000..29889754 --- /dev/null +++ b/dbus/dbus-shared.h @@ -0,0 +1,53 @@ +/* -*- mode: C; c-file-style: "gnu" -*- */ +/* dbus-shared.h Stuff used by both dbus/dbus.h low-level and C/C++ binding APIs + * + * Copyright (C) 2004 Red Hat, Inc. + * + * Licensed under the Academic Free License version 2.0 + * + * 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 DBUS_SHARED_H +#define DBUS_SHARED_H + +/* Don't include anything in here from anywhere else. It's + * intended for use by any random library. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum +{ + DBUS_BUS_SESSION, /**< The login session bus */ + DBUS_BUS_SYSTEM, /**< The systemwide bus */ + DBUS_BUS_ACTIVATION /**< The bus that activated us, if any */ +} DBusBusType; + +typedef enum +{ + DBUS_HANDLER_RESULT_HANDLED, /**< Message has had its effect */ + DBUS_HANDLER_RESULT_NOT_YET_HANDLED, /**< Message has not had any effect */ + DBUS_HANDLER_RESULT_NEED_MEMORY /**< Need more memory to return another result */ +} DBusHandlerResult; + +#ifdef __cplusplus +} +#endif + +#endif /* DBUS_PROTOCOL_H */ diff --git a/dbus/dbus-spawn.c b/dbus/dbus-spawn.c index 0d32d685..821be25c 100644 --- a/dbus/dbus-spawn.c +++ b/dbus/dbus-spawn.c @@ -1,7 +1,7 @@ /* -*- mode: C; c-file-style: "gnu" -*- */ /* dbus-spawn.c Wrapper around fork/exec * - * Copyright (C) 2002, 2003 Red Hat, Inc. + * Copyright (C) 2002, 2003, 2004 Red Hat, Inc. * Copyright (C) 2003 CodeFactory AB * * Licensed under the Academic Free License version 2.0 @@ -25,6 +25,7 @@ #include "dbus-sysdeps.h" #include "dbus-internals.h" #include "dbus-test.h" +#include "dbus-protocol.h" #include <unistd.h> #include <fcntl.h> diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c index e9d00201..ed1e61a2 100644 --- a/dbus/dbus-sysdeps.c +++ b/dbus/dbus-sysdeps.c @@ -25,6 +25,7 @@ #include "dbus-internals.h" #include "dbus-sysdeps.h" #include "dbus-threads.h" +#include "dbus-protocol.h" #include "dbus-test.h" #include <sys/types.h> #include <stdlib.h> diff --git a/dbus/dbus-transport.h b/dbus/dbus-transport.h index a642b21a..2c17c2a1 100644 --- a/dbus/dbus-transport.h +++ b/dbus/dbus-transport.h @@ -1,7 +1,7 @@ /* -*- mode: C; c-file-style: "gnu" -*- */ /* dbus-transport.h DBusTransport object (internal to D-BUS implementation) * - * Copyright (C) 2002 Red Hat Inc. + * Copyright (C) 2002, 2004 Red Hat Inc. * * Licensed under the Academic Free License version 2.0 * @@ -25,6 +25,7 @@ #include <dbus/dbus-internals.h> #include <dbus/dbus-connection.h> +#include <dbus/dbus-protocol.h> DBUS_BEGIN_DECLS; diff --git a/dbus/dbus-userdb.c b/dbus/dbus-userdb.c index 4dc05b81..e2b6c496 100644 --- a/dbus/dbus-userdb.c +++ b/dbus/dbus-userdb.c @@ -1,7 +1,7 @@ /* -*- mode: C; c-file-style: "gnu" -*- */ /* dbus-userdb.c User database abstraction * - * Copyright (C) 2003 Red Hat, Inc. + * Copyright (C) 2003, 2004 Red Hat, Inc. * * Licensed under the Academic Free License version 2.0 * @@ -24,6 +24,7 @@ #include "dbus-hash.h" #include "dbus-test.h" #include "dbus-internals.h" +#include "dbus-protocol.h" #include <string.h> /** diff --git a/dbus/dbus.h b/dbus/dbus.h index 8c42849a..e4031177 100644 --- a/dbus/dbus.h +++ b/dbus/dbus.h @@ -40,6 +40,7 @@ #include <dbus/dbus-pending-call.h> #include <dbus/dbus-protocol.h> #include <dbus/dbus-server.h> +#include <dbus/dbus-shared.h> #include <dbus/dbus-threads.h> #include <dbus/dbus-types.h> diff --git a/dbus/make-dbus-glib-error-enum.sh b/dbus/make-dbus-glib-error-enum.sh new file mode 100755 index 00000000..5b0df6c9 --- /dev/null +++ b/dbus/make-dbus-glib-error-enum.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +SRC=$1 +DEST=$2 + +function die() +{ + echo $1 1>&2 + /bin/rm $DEST.tmp + exit 1 +} + +cat $SRC | grep '#define DBUS_ERROR' | sed -e 's/#define //g' | \ + sed -e 's/".*//g' | sed -e 's/_ERROR/_GERROR/g' | sed -e 's/ *$/,/g' > $DEST.tmp + +if ! test -s $DEST.tmp ; then + die "$DEST.tmp is empty, something went wrong, see any preceding error message" +fi + +echo "#ifndef DBUS_INSIDE_DBUS_GLIB_H" >> $DEST.tmp +echo '#error "' "$DEST" 'may only be included by dbus-glib.h"' >> $DEST.tmp +echo "#endif" >> $DEST.tmp + +mv $DEST.tmp $DEST || die "could not move $DEST.tmp to $DEST" @@ -72,7 +72,9 @@ Important for 1.0 memory" and just fully encapsulate the get_args() type of stuff. - - dbus_gproxy or dbus_g_proxy? + - dbus_gproxy_connect_signal() has to take a signature for the signal + so it can figure out how to invoke the callback, or we have to rely + on having introspection data. Might as Well for 1.0 === diff --git a/glib/Makefile.am b/glib/Makefile.am index 5d2172e3..d6f00d07 100644 --- a/glib/Makefile.am +++ b/glib/Makefile.am @@ -1,13 +1,9 @@ INCLUDES=-I$(top_srcdir) $(DBUS_CLIENT_CFLAGS) $(DBUS_GLIB_CFLAGS) $(DBUS_GLIB_TOOL_CFLAGS) -DDBUS_COMPILATION=1 -DDBUS_LOCALEDIR=\"$(prefix)/@DATADIRNAME@/locale\" -dbusincludedir=$(includedir)/dbus-1.0/dbus - lib_LTLIBRARIES=libdbus-glib-1.la -dbusinclude_HEADERS= \ - dbus-glib.h - libdbus_glib_1_la_SOURCES = \ + dbus-glib.c \ dbus-gmain.c \ dbus-gobject.c \ dbus-gproxy.c \ diff --git a/glib/dbus-gidl.c b/glib/dbus-gidl.c index 7db25c86..c8efc46d 100644 --- a/glib/dbus-gidl.c +++ b/glib/dbus-gidl.c @@ -549,7 +549,7 @@ arg_info_get_direction (ArgInfo *info) * Unit test for GLib IDL internals * @returns #TRUE on success. */ -dbus_bool_t +gboolean _dbus_gidl_test (void) { diff --git a/glib/dbus-glib-tool.c b/glib/dbus-glib-tool.c index d1195516..bd66e18d 100644 --- a/glib/dbus-glib-tool.c +++ b/glib/dbus-glib-tool.c @@ -295,7 +295,7 @@ test_die (const char *failure) * Unit test for GLib utility tool * @returns #TRUE on success. */ -static dbus_bool_t +static gboolean _dbus_gtool_test (const char *test_data_dir) { diff --git a/glib/dbus-glib.c b/glib/dbus-glib.c new file mode 100644 index 00000000..476e5cd2 --- /dev/null +++ b/glib/dbus-glib.c @@ -0,0 +1,67 @@ +/* -*- mode: C; c-file-style: "gnu" -*- */ +/* dbus-glib.c General GLib binding stuff + * + * Copyright (C) 2004 Red Hat, Inc. + * + * Licensed under the Academic Free License version 2.0 + * + * 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 + * + */ + +#include <config.h> +#include <dbus/dbus-glib.h> +#include <dbus/dbus-glib-lowlevel.h> +#include "dbus-gtest.h" +#include "dbus-gutils.h" + +#include <libintl.h> +#define _(x) dgettext (GETTEXT_PACKAGE, x) +#define N_(x) x + +/** + * @ingroup DBusGLib + * @{ + */ + +/** + * Blocks until outgoing calls and signal emissions have been sent. + * + * @param connection the connection to flush + */ +void +dbus_g_connection_flush (DBusGConnection *connection) +{ + dbus_connection_flush (DBUS_CONNECTION_FROM_G_CONNECTION (connection)); +} + +/** @} */ /* end of public API */ + + +#ifdef DBUS_BUILD_TESTS + +/** + * @ingroup DBusGLibInternals + * Unit test for general glib stuff + * @returns #TRUE on success. + */ +gboolean +_dbus_glib_test (const char *test_data_dir) +{ + + return TRUE; +} + +#endif /* DBUS_BUILD_TESTS */ diff --git a/glib/dbus-glib.h b/glib/dbus-glib.h deleted file mode 100644 index 483a6e81..00000000 --- a/glib/dbus-glib.h +++ /dev/null @@ -1,159 +0,0 @@ -/* -*- mode: C; c-file-style: "gnu" -*- */ -/* dbus-glib.h GLib integration - * - * Copyright (C) 2002, 2003 CodeFactory AB - * Copyright (C) 2003 Red Hat, Inc. - * - * Licensed under the Academic Free License version 2.0 - * - * 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 DBUS_GLIB_H -#define DBUS_GLIB_H - -#include <dbus/dbus.h> -#include <glib-object.h> - -G_BEGIN_DECLS - -#define DBUS_INSIDE_DBUS_GLIB_H 1 - -GQuark dbus_g_error_quark (void); -#define DBUS_GERROR dbus_g_error_quark () - -#define DBUS_TYPE_CONNECTION (dbus_connection_get_g_type ()) -#define DBUS_TYPE_MESSAGE (dbus_message_get_g_type ()) -GType dbus_connection_get_g_type (void) G_GNUC_CONST; -GType dbus_message_get_g_type (void) G_GNUC_CONST; - -typedef enum -{ - /* FIXME map all the DBUS_ERROR to DBUS_GERROR, should - * probably be automated in some way, perhaps - * via lame perl script - */ - DBUS_GERROR_FAILED -} DBusGError; - -void dbus_set_g_error (GError **gerror, - DBusError *derror); - -void dbus_g_thread_init (void); -void dbus_connection_setup_with_g_main (DBusConnection *connection, - GMainContext *context); -void dbus_server_setup_with_g_main (DBusServer *server, - GMainContext *context); -DBusConnection* dbus_bus_get_with_g_main (DBusBusType type, - GError **error); - -typedef struct DBusGObjectInfo DBusGObjectInfo; -typedef struct DBusGMethodInfo DBusGMethodInfo; - -/** - * Object typically generated by dbus-glib-tool that - * stores a mapping from introspection data to a - * function pointer for a C method to be invoked. - */ -struct DBusGMethodInfo -{ - GCallback function; /**< C method to invoke */ - DBusHandleMessageFunction marshaller; /**< Marshaller to go DBusMessage to C method */ - int data_offset; /**< Offset into the introspection data */ -}; - -/** - * Introspection data for a GObject, normally autogenerated by - * a tool such as dbus-glib-tool. - */ -struct DBusGObjectInfo -{ - int format_version; /**< Allows us to change the rest of this struct - * by adding DBusGObjectInfo2, DBusGObjectInfo3, etc. - */ - const DBusGMethodInfo *infos; /**< Array of method pointers */ - const unsigned char *data; /**< Introspection data */ -}; - -void dbus_g_object_class_install_info (GObjectClass *object_class, - const DBusGObjectInfo *info); -void dbus_connection_register_g_object (DBusConnection *connection, - const char *at_path, - GObject *object); - - -typedef struct DBusGProxy DBusGProxy; -typedef struct DBusGProxyClass DBusGProxyClass; - -typedef void (* DBusGProxySignalHandler) (DBusGProxy *proxy, - DBusMessage *signal, - void *user_data); - -#define DBUS_TYPE_GPROXY (dbus_gproxy_get_type ()) -#define DBUS_GPROXY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), DBUS_TYPE_GPROXY, DBusGProxy)) -#define DBUS_GPROXY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DBUS_TYPE_GPROXY, DBusGProxyClass)) -#define DBUS_IS_GPROXY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), DBUS_TYPE_GPROXY)) -#define DBUS_IS_GPROXY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DBUS_TYPE_GPROXY)) -#define DBUS_GPROXY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DBUS_TYPE_GPROXY, DBusGProxyClass)) - - -GType dbus_gproxy_get_type (void) G_GNUC_CONST; -DBusGProxy* dbus_gproxy_new_for_service (DBusConnection *connection, - const char *service_name, - const char *path_name, - const char *interface_name); -DBusGProxy* dbus_gproxy_new_for_service_owner (DBusConnection *connection, - const char *service_name, - const char *path_name, - const char *interface_name, - GError **error); -DBusGProxy* dbus_gproxy_new_for_peer (DBusConnection *connection, - const char *path_name, - const char *interface_name); -void dbus_gproxy_connect_signal (DBusGProxy *proxy, - const char *signal_name, - DBusGProxySignalHandler handler, - void *data, - GClosureNotify free_data_func); -void dbus_gproxy_disconnect_signal (DBusGProxy *proxy, - const char *signal_name, - DBusGProxySignalHandler handler, - void *data); -DBusPendingCall* dbus_gproxy_begin_call (DBusGProxy *proxy, - const char *method, - int first_arg_type, - ...); -gboolean dbus_gproxy_end_call (DBusGProxy *proxy, - DBusPendingCall *pending, - GError **error, - int first_arg_type, - ...); -void dbus_gproxy_call_no_reply (DBusGProxy *proxy, - const char *method, - int first_arg_type, - ...); -void dbus_gproxy_send (DBusGProxy *proxy, - DBusMessage *message, - dbus_uint32_t *client_serial); - - -#undef DBUS_INSIDE_DBUS_GLIB_H - -G_END_DECLS - -#endif /* DBUS_GLIB_H */ - - - diff --git a/glib/dbus-gmain.c b/glib/dbus-gmain.c index da2e555d..c0741ac2 100644 --- a/glib/dbus-gmain.c +++ b/glib/dbus-gmain.c @@ -1,7 +1,7 @@ /* -*- mode: C; c-file-style: "gnu" -*- */ /* dbus-gmain.c GLib main loop integration * - * Copyright (C) 2002, 2003 CodeFactory AB + * Copyright (C) 2002, 2003 CodeFactory AB * * Licensed under the Academic Free License version 2.0 * @@ -22,8 +22,10 @@ */ #include <config.h> -#include "dbus-glib.h" +#include <dbus/dbus-glib.h> +#include <dbus/dbus-glib-lowlevel.h> #include "dbus-gtest.h" +#include "dbus-gutils.h" #include <libintl.h> #define _(x) dgettext (GETTEXT_PACKAGE, x) @@ -582,16 +584,19 @@ dbus_server_setup_with_g_main (DBusServer *server, } /** - * Calls dbus_bus_get() then calls dbus_connection_setup_with_g_main() - * on the result and returns the bus connection. + * Returns a connection to the given bus. The connection is a global variable + * shared with other callers of this function. + * + * (Internally, calls dbus_bus_get() then calls + * dbus_connection_setup_with_g_main() on the result.) * * @param type bus type * @param error address where an error can be returned. * @returns a DBusConnection */ -DBusConnection* -dbus_bus_get_with_g_main (DBusBusType type, - GError **error) +DBusGConnection* +dbus_g_bus_get (DBusBusType type, + GError **error) { DBusConnection *connection; DBusError derror; @@ -612,7 +617,7 @@ dbus_bus_get_with_g_main (DBusBusType type, dbus_connection_setup_with_g_main (connection, NULL); } - return connection; + return DBUS_G_CONNECTION_FROM_CONNECTION (connection); } /** @@ -688,6 +693,104 @@ dbus_message_get_g_type (void) return our_type; } +static DBusGConnection* +dbus_g_connection_ref (DBusGConnection *gconnection) +{ + DBusConnection *c; + + c = DBUS_CONNECTION_FROM_G_CONNECTION (gconnection); + dbus_connection_ref (c); + return gconnection; +} + +static void +dbus_g_connection_unref (DBusGConnection *gconnection) +{ + DBusConnection *c; + + c = DBUS_CONNECTION_FROM_G_CONNECTION (gconnection); + dbus_connection_unref (c); +} + + +static DBusGMessage* +dbus_g_message_ref (DBusGMessage *gmessage) +{ + DBusMessage *c; + + c = DBUS_MESSAGE_FROM_G_MESSAGE (gmessage); + dbus_message_ref (c); + return gmessage; +} + +static void +dbus_g_message_unref (DBusGMessage *gmessage) +{ + DBusMessage *c; + + c = DBUS_MESSAGE_FROM_G_MESSAGE (gmessage); + dbus_message_unref (c); +} + +/** + * Get the GLib type ID for a DBusGConnection boxed type. + * + * @returns GLib type + */ +GType +dbus_g_connection_get_g_type (void) +{ + static GType our_type = 0; + + if (our_type == 0) + our_type = g_boxed_type_register_static ("DBusGConnection", + (GBoxedCopyFunc) dbus_g_connection_ref, + (GBoxedFreeFunc) dbus_g_connection_unref); + + return our_type; +} + +/** + * Get the GLib type ID for a DBusGMessage boxed type. + * + * @returns GLib type + */ +GType +dbus_g_message_get_g_type (void) +{ + static GType our_type = 0; + + if (our_type == 0) + our_type = g_boxed_type_register_static ("DBusGMessage", + (GBoxedCopyFunc) dbus_g_message_ref, + (GBoxedFreeFunc) dbus_g_message_unref); + + return our_type; +} + +/** + * Get the DBusConnection corresponding to this DBusGConnection. + * The return value does not have its refcount incremented. + * + * @returns DBusConnection + */ +DBusConnection* +dbus_g_connection_get_connection (DBusGConnection *gconnection) +{ + return DBUS_CONNECTION_FROM_G_CONNECTION (gconnection); +} + +/** + * Get the DBusMessage corresponding to this DBusGMessage. + * The return value does not have its refcount incremented. + * + * @returns DBusMessage + */ +DBusMessage* +dbus_g_message_get_message (DBusGMessage *gmessage) +{ + return DBUS_MESSAGE_FROM_G_MESSAGE (gmessage); +} /** @} */ /* end of public API */ @@ -698,7 +801,7 @@ dbus_message_get_g_type (void) * Unit test for GLib main loop integration * @returns #TRUE on success. */ -dbus_bool_t +gboolean _dbus_gmain_test (const char *test_data_dir) { diff --git a/glib/dbus-gobject.c b/glib/dbus-gobject.c index 80f766c5..dfd33f3e 100644 --- a/glib/dbus-gobject.c +++ b/glib/dbus-gobject.c @@ -1,7 +1,7 @@ /* -*- mode: C; c-file-style: "gnu" -*- */ /* dbus-gobject.c Exporting a GObject remotely * - * Copyright (C) 2003 Red Hat, Inc. + * Copyright (C) 2003, 2004 Red Hat, Inc. * * Licensed under the Academic Free License version 2.0 * @@ -22,7 +22,8 @@ */ #include <config.h> -#include "dbus-glib.h" +#include <dbus/dbus-glib.h> +#include <dbus/dbus-glib-lowlevel.h> #include "dbus-gtest.h" #include "dbus-gutils.h" #include "dbus-gvalue.h" @@ -502,7 +503,7 @@ static DBusObjectPathVTable gobject_dbus_vtable = { * class_init() for the object class. * * Once introspection information has been installed, instances of the - * object registered with dbus_connection_register_g_object() can have + * object registered with dbus_g_connection_register_g_object() can have * their methods invoked remotely. * * @param object_class class struct of the object @@ -540,15 +541,15 @@ dbus_g_object_class_install_info (GObjectClass *object_class, * @param object the object */ void -dbus_connection_register_g_object (DBusConnection *connection, - const char *at_path, - GObject *object) +dbus_g_connection_register_g_object (DBusGConnection *connection, + const char *at_path, + GObject *object) { g_return_if_fail (connection != NULL); g_return_if_fail (at_path != NULL); g_return_if_fail (G_IS_OBJECT (object)); - if (!dbus_connection_register_object_path (connection, + if (!dbus_connection_register_object_path (DBUS_CONNECTION_FROM_G_CONNECTION (connection), at_path, &gobject_dbus_vtable, object)) @@ -569,7 +570,7 @@ dbus_connection_register_g_object (DBusConnection *connection, * Unit test for GLib GObject integration ("skeletons") * @returns #TRUE on success. */ -dbus_bool_t +gboolean _dbus_gobject_test (const char *test_data_dir) { int i; diff --git a/glib/dbus-gproxy.c b/glib/dbus-gproxy.c index 4e8d200f..a5827be9 100644 --- a/glib/dbus-gproxy.c +++ b/glib/dbus-gproxy.c @@ -1,7 +1,7 @@ /* -*- mode: C; c-file-style: "gnu" -*- */ /* dbus-gcall.c convenience routines for calling methods, etc. * - * Copyright (C) 2003 Red Hat, Inc. + * Copyright (C) 2003, 2004 Red Hat, Inc. * * Licensed under the Academic Free License version 2.0 * @@ -20,7 +20,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ -#include "dbus-glib.h" +#include <dbus/dbus-glib.h> +#include <dbus/dbus-glib-lowlevel.h> +#include "dbus-gutils.h" #include <string.h> /** @@ -56,12 +58,12 @@ struct DBusGProxyClass GObjectClass parent_class; /**< Parent class */ }; -static void dbus_gproxy_init (DBusGProxy *proxy); -static void dbus_gproxy_class_init (DBusGProxyClass *klass); -static void dbus_gproxy_finalize (GObject *object); -static void dbus_gproxy_dispose (GObject *object); -static void dbus_gproxy_destroy (DBusGProxy *proxy); -static void dbus_gproxy_emit_received (DBusGProxy *proxy, +static void dbus_g_proxy_init (DBusGProxy *proxy); +static void dbus_g_proxy_class_init (DBusGProxyClass *klass); +static void dbus_g_proxy_finalize (GObject *object); +static void dbus_g_proxy_dispose (GObject *object); +static void dbus_g_proxy_destroy (DBusGProxy *proxy); +static void dbus_g_proxy_emit_received (DBusGProxy *proxy, DBusMessage *message); @@ -97,8 +99,8 @@ struct DBusGProxyManager }; -static DBusGProxyManager *dbus_gproxy_manager_ref (DBusGProxyManager *manager); -static DBusHandlerResult dbus_gproxy_manager_filter (DBusConnection *connection, +static DBusGProxyManager *dbus_g_proxy_manager_ref (DBusGProxyManager *manager); +static DBusHandlerResult dbus_g_proxy_manager_filter (DBusConnection *connection, DBusMessage *message, void *user_data); @@ -107,28 +109,28 @@ static DBusHandlerResult dbus_gproxy_manager_filter (DBusConnection *connecti /** Unlock the DBusGProxyManager */ #define UNLOCK_MANAGER(mgr) (g_static_mutex_unlock (&(mgr)->lock)) -static int gproxy_manager_slot = -1; +static int g_proxy_manager_slot = -1; /* Lock controlling get/set manager as data on each connection */ -static GStaticMutex connection_gproxy_lock = G_STATIC_MUTEX_INIT; +static GStaticMutex connection_g_proxy_lock = G_STATIC_MUTEX_INIT; static DBusGProxyManager* -dbus_gproxy_manager_get (DBusConnection *connection) +dbus_g_proxy_manager_get (DBusConnection *connection) { DBusGProxyManager *manager; - dbus_connection_allocate_data_slot (&gproxy_manager_slot); - if (gproxy_manager_slot < 0) + dbus_connection_allocate_data_slot (&g_proxy_manager_slot); + if (g_proxy_manager_slot < 0) g_error ("out of memory"); - g_static_mutex_lock (&connection_gproxy_lock); + g_static_mutex_lock (&connection_g_proxy_lock); - manager = dbus_connection_get_data (connection, gproxy_manager_slot); + manager = dbus_connection_get_data (connection, g_proxy_manager_slot); if (manager != NULL) { - dbus_connection_free_data_slot (&gproxy_manager_slot); - dbus_gproxy_manager_ref (manager); - g_static_mutex_unlock (&connection_gproxy_lock); + dbus_connection_free_data_slot (&g_proxy_manager_slot); + dbus_g_proxy_manager_ref (manager); + g_static_mutex_unlock (&connection_g_proxy_lock); return manager; } @@ -145,19 +147,19 @@ dbus_gproxy_manager_get (DBusConnection *connection) */ dbus_connection_ref (manager->connection); - dbus_connection_set_data (connection, gproxy_manager_slot, + dbus_connection_set_data (connection, g_proxy_manager_slot, manager, NULL); - dbus_connection_add_filter (connection, dbus_gproxy_manager_filter, + dbus_connection_add_filter (connection, dbus_g_proxy_manager_filter, manager, NULL); - g_static_mutex_unlock (&connection_gproxy_lock); + g_static_mutex_unlock (&connection_g_proxy_lock); return manager; } static DBusGProxyManager * -dbus_gproxy_manager_ref (DBusGProxyManager *manager) +dbus_g_proxy_manager_ref (DBusGProxyManager *manager) { g_assert (manager != NULL); g_assert (manager->refcount > 0); @@ -172,7 +174,7 @@ dbus_gproxy_manager_ref (DBusGProxyManager *manager) } static void -dbus_gproxy_manager_unref (DBusGProxyManager *manager) +dbus_g_proxy_manager_unref (DBusGProxyManager *manager) { g_assert (manager != NULL); g_assert (manager->refcount > 0); @@ -196,21 +198,21 @@ dbus_gproxy_manager_unref (DBusGProxyManager *manager) g_static_mutex_free (&manager->lock); - g_static_mutex_lock (&connection_gproxy_lock); + g_static_mutex_lock (&connection_g_proxy_lock); - dbus_connection_remove_filter (manager->connection, dbus_gproxy_manager_filter, + dbus_connection_remove_filter (manager->connection, dbus_g_proxy_manager_filter, manager); dbus_connection_set_data (manager->connection, - gproxy_manager_slot, + g_proxy_manager_slot, NULL, NULL); - g_static_mutex_unlock (&connection_gproxy_lock); + g_static_mutex_unlock (&connection_g_proxy_lock); dbus_connection_unref (manager->connection); g_free (manager); - dbus_connection_free_data_slot (&gproxy_manager_slot); + dbus_connection_free_data_slot (&g_proxy_manager_slot); } else { @@ -356,7 +358,7 @@ tristring_from_message (DBusMessage *message) } static DBusGProxyList* -gproxy_list_new (DBusGProxy *first_proxy) +g_proxy_list_new (DBusGProxy *first_proxy) { DBusGProxyList *list; @@ -370,7 +372,7 @@ gproxy_list_new (DBusGProxy *first_proxy) } static void -gproxy_list_free (DBusGProxyList *list) +g_proxy_list_free (DBusGProxyList *list) { /* we don't hold a reference to the proxies in the list, * as they ref the GProxyManager @@ -381,7 +383,7 @@ gproxy_list_free (DBusGProxyList *list) } static char* -gproxy_get_match_rule (DBusGProxy *proxy) +g_proxy_get_match_rule (DBusGProxy *proxy) { /* FIXME Escaping is required here */ @@ -394,7 +396,7 @@ gproxy_get_match_rule (DBusGProxy *proxy) } static void -dbus_gproxy_manager_register (DBusGProxyManager *manager, +dbus_g_proxy_manager_register (DBusGProxyManager *manager, DBusGProxy *proxy) { DBusGProxyList *list; @@ -407,7 +409,7 @@ dbus_gproxy_manager_register (DBusGProxyManager *manager, manager->proxy_lists = g_hash_table_new_full (tristring_hash, tristring_equal, NULL, - (GFreeFunc) gproxy_list_free); + (GFreeFunc) g_proxy_list_free); } else { @@ -422,7 +424,7 @@ dbus_gproxy_manager_register (DBusGProxyManager *manager, if (list == NULL) { - list = gproxy_list_new (proxy); + list = g_proxy_list_new (proxy); g_hash_table_replace (manager->proxy_lists, list->name, list); @@ -436,7 +438,7 @@ dbus_gproxy_manager_register (DBusGProxyManager *manager, */ char *rule; - rule = gproxy_get_match_rule (proxy); + rule = g_proxy_get_match_rule (proxy); /* We don't check for errors; it's not like anyone would handle them, * and we don't want a round trip here. @@ -455,7 +457,7 @@ dbus_gproxy_manager_register (DBusGProxyManager *manager, } static void -dbus_gproxy_manager_unregister (DBusGProxyManager *manager, +dbus_g_proxy_manager_unregister (DBusGProxyManager *manager, DBusGProxy *proxy) { DBusGProxyList *list; @@ -522,7 +524,7 @@ list_proxies_foreach (gpointer key, tmp = list->proxies; while (tmp != NULL) { - DBusGProxy *proxy = DBUS_GPROXY (tmp->data); + DBusGProxy *proxy = DBUS_G_PROXY (tmp->data); g_object_ref (proxy); *ret = g_slist_prepend (*ret, proxy); @@ -532,7 +534,7 @@ list_proxies_foreach (gpointer key, } static GSList* -dbus_gproxy_manager_list_all (DBusGProxyManager *manager) +dbus_g_proxy_manager_list_all (DBusGProxyManager *manager) { GSList *ret; @@ -549,7 +551,7 @@ dbus_gproxy_manager_list_all (DBusGProxyManager *manager) } static DBusHandlerResult -dbus_gproxy_manager_filter (DBusConnection *connection, +dbus_g_proxy_manager_filter (DBusConnection *connection, DBusMessage *message, void *user_data) { @@ -560,7 +562,7 @@ dbus_gproxy_manager_filter (DBusConnection *connection, manager = user_data; - dbus_gproxy_manager_ref (manager); + dbus_g_proxy_manager_ref (manager); LOCK_MANAGER (manager); @@ -574,17 +576,17 @@ dbus_gproxy_manager_filter (DBusConnection *connection, GSList *all; GSList *tmp; - all = dbus_gproxy_manager_list_all (manager); + all = dbus_g_proxy_manager_list_all (manager); tmp = all; while (tmp != NULL) { DBusGProxy *proxy; - proxy = DBUS_GPROXY (tmp->data); + proxy = DBUS_G_PROXY (tmp->data); UNLOCK_MANAGER (manager); - dbus_gproxy_destroy (proxy); + dbus_g_proxy_destroy (proxy); g_object_unref (G_OBJECT (proxy)); LOCK_MANAGER (manager); @@ -635,10 +637,10 @@ dbus_gproxy_manager_filter (DBusConnection *connection, { DBusGProxy *proxy; - proxy = DBUS_GPROXY (tmp->data); + proxy = DBUS_G_PROXY (tmp->data); UNLOCK_MANAGER (manager); - dbus_gproxy_emit_received (proxy, message); + dbus_g_proxy_emit_received (proxy, message); g_object_unref (G_OBJECT (proxy)); LOCK_MANAGER (manager); @@ -650,7 +652,7 @@ dbus_gproxy_manager_filter (DBusConnection *connection, } UNLOCK_MANAGER (manager); - dbus_gproxy_manager_unref (manager); + dbus_g_proxy_manager_unref (manager); /* "Handling" signals doesn't make sense, they are for everyone * who cares @@ -675,20 +677,20 @@ static void *parent_class; static guint signals[LAST_SIGNAL] = { 0 }; static void -dbus_gproxy_init (DBusGProxy *proxy) +dbus_g_proxy_init (DBusGProxy *proxy) { /* Nothing */ } static void -dbus_gproxy_class_init (DBusGProxyClass *klass) +dbus_g_proxy_class_init (DBusGProxyClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); parent_class = g_type_class_peek_parent (klass); - object_class->finalize = dbus_gproxy_finalize; - object_class->dispose = dbus_gproxy_dispose; + object_class->finalize = dbus_g_proxy_finalize; + object_class->dispose = dbus_g_proxy_dispose; signals[DESTROY] = g_signal_new ("destroy", @@ -712,11 +714,11 @@ dbus_gproxy_class_init (DBusGProxyClass *klass) static void -dbus_gproxy_dispose (GObject *object) +dbus_g_proxy_dispose (GObject *object) { DBusGProxy *proxy; - proxy = DBUS_GPROXY (object); + proxy = DBUS_G_PROXY (object); g_signal_emit (object, signals[DESTROY], 0); @@ -724,16 +726,16 @@ dbus_gproxy_dispose (GObject *object) } static void -dbus_gproxy_finalize (GObject *object) +dbus_g_proxy_finalize (GObject *object) { DBusGProxy *proxy; - proxy = DBUS_GPROXY (object); + proxy = DBUS_G_PROXY (object); if (proxy->manager) { - dbus_gproxy_manager_unregister (proxy->manager, proxy); - dbus_gproxy_manager_unref (proxy->manager); + dbus_g_proxy_manager_unregister (proxy->manager, proxy); + dbus_g_proxy_manager_unref (proxy->manager); } g_free (proxy->service); @@ -744,7 +746,7 @@ dbus_gproxy_finalize (GObject *object) } static void -dbus_gproxy_destroy (DBusGProxy *proxy) +dbus_g_proxy_destroy (DBusGProxy *proxy) { /* FIXME do we need the GTK_IN_DESTRUCTION style flag * from GtkObject? @@ -768,7 +770,7 @@ create_signal_detail (const char *interface, } static void -dbus_gproxy_emit_received (DBusGProxy *proxy, +dbus_g_proxy_emit_received (DBusGProxy *proxy, DBusMessage *message) { const char *interface; @@ -811,7 +813,7 @@ dbus_gproxy_emit_received (DBusGProxy *proxy, * @returns type ID for DBusGProxy class */ GType -dbus_gproxy_get_type (void) +dbus_g_proxy_get_type (void) { static GType object_type = 0; @@ -822,12 +824,12 @@ dbus_gproxy_get_type (void) sizeof (DBusGProxyClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, - (GClassInitFunc) dbus_gproxy_class_init, + (GClassInitFunc) dbus_g_proxy_class_init, NULL, /* class_finalize */ NULL, /* class_data */ sizeof (DBusGProxy), 0, /* n_preallocs */ - (GInstanceInitFunc) dbus_gproxy_init, + (GInstanceInitFunc) dbus_g_proxy_init, }; object_type = g_type_register_static (G_TYPE_OBJECT, @@ -839,28 +841,28 @@ dbus_gproxy_get_type (void) } static DBusGProxy* -dbus_gproxy_new (DBusConnection *connection, - const char *service_name, - const char *path_name, - const char *interface_name) +dbus_g_proxy_new (DBusGConnection *connection, + const char *service_name, + const char *path_name, + const char *interface_name) { DBusGProxy *proxy; g_assert (connection != NULL); - proxy = g_object_new (DBUS_TYPE_GPROXY, NULL); + proxy = g_object_new (DBUS_TYPE_G_PROXY, NULL); /* These should all be construct-only mandatory properties, * for now we just don't let people use g_object_new(). */ - proxy->manager = dbus_gproxy_manager_get (connection); + proxy->manager = dbus_g_proxy_manager_get (DBUS_CONNECTION_FROM_G_CONNECTION (connection)); proxy->service = g_strdup (service_name); proxy->path = g_strdup (path_name); proxy->interface = g_strdup (interface_name); - dbus_gproxy_manager_register (proxy->manager, proxy); + dbus_g_proxy_manager_register (proxy->manager, proxy); return proxy; } @@ -873,7 +875,7 @@ dbus_gproxy_new (DBusConnection *connection, * TIME, for example between two different method calls. If you need a * fixed owner, you need to request the current owner and bind a proxy * to that rather than to the generic service name; see - * dbus_gproxy_new_for_service_owner(). + * dbus_g_proxy_new_for_service_owner(). * * A service-associated proxy only makes sense with a message bus, * not for app-to-app direct dbus connections. @@ -888,10 +890,10 @@ dbus_gproxy_new (DBusConnection *connection, * @returns new proxy object */ DBusGProxy* -dbus_gproxy_new_for_service (DBusConnection *connection, - const char *service_name, - const char *path_name, - const char *interface_name) +dbus_g_proxy_new_for_service (DBusGConnection *connection, + const char *service_name, + const char *path_name, + const char *interface_name) { DBusGProxy *proxy; @@ -900,26 +902,26 @@ dbus_gproxy_new_for_service (DBusConnection *connection, g_return_val_if_fail (path_name != NULL, NULL); g_return_val_if_fail (interface_name != NULL, NULL); - proxy = dbus_gproxy_new (connection, service_name, + proxy = dbus_g_proxy_new (connection, service_name, path_name, interface_name); return proxy; } /** - * Similar to dbus_gproxy_new_for_service(), but makes a round-trip + * Similar to dbus_g_proxy_new_for_service(), but makes a round-trip * request to the message bus to get the current service owner, then * binds the proxy specifically to the current owner. As a result, the * service owner will not change over time, and the proxy will emit * the "destroy" signal when the owner disappears from the message * bus. * - * An example of the difference between dbus_gproxy_new_for_service() - * and dbus_gproxy_new_for_service_owner(): if you pass the service name - * "org.freedesktop.Database" dbus_gproxy_new_for_service() remains bound - * to that name as it changes owner. dbus_gproxy_new_for_service_owner() + * An example of the difference between dbus_g_proxy_new_for_service() + * and dbus_g_proxy_new_for_service_owner(): if you pass the service name + * "org.freedesktop.Database" dbus_g_proxy_new_for_service() remains bound + * to that name as it changes owner. dbus_g_proxy_new_for_service_owner() * will fail if the service has no owner. If the service has an owner, - * dbus_gproxy_new_for_service_owner() will bind to the unique name + * dbus_g_proxy_new_for_service_owner() will bind to the unique name * of that owner rather than the generic service name. * * @param connection the connection to the remote bus @@ -930,14 +932,13 @@ dbus_gproxy_new_for_service (DBusConnection *connection, * @returns new proxy object, or #NULL on error */ DBusGProxy* -dbus_gproxy_new_for_service_owner (DBusConnection *connection, +dbus_g_proxy_new_for_service_owner (DBusGConnection *connection, const char *service_name, const char *path_name, const char *interface_name, GError **error) { DBusGProxy *proxy; - DBusMessage *request, *reply; DBusError derror; char *base_service_name; @@ -965,8 +966,10 @@ dbus_gproxy_new_for_service_owner (DBusConnection *connection, DBUS_TYPE_INVALID)) g_error ("Out of memory"); - reply = dbus_connection_send_with_reply_and_block (connection, request, - 2000, &derror); + reply = + dbus_connection_send_with_reply_and_block (DBUS_CONNECTION_FROM_G_CONNECTION (connection), + request, + 2000, &derror); if (reply == NULL) goto error; @@ -979,7 +982,7 @@ dbus_gproxy_new_for_service_owner (DBusConnection *connection, goto error; - proxy = dbus_gproxy_new (connection, base_service_name, + proxy = dbus_g_proxy_new (connection, base_service_name, path_name, interface_name); goto out; @@ -1014,7 +1017,7 @@ dbus_gproxy_new_for_service_owner (DBusConnection *connection, * */ DBusGProxy* -dbus_gproxy_new_for_peer (DBusConnection *connection, +dbus_g_proxy_new_for_peer (DBusGConnection *connection, const char *path_name, const char *interface_name) { @@ -1024,7 +1027,7 @@ dbus_gproxy_new_for_peer (DBusConnection *connection, g_return_val_if_fail (path_name != NULL, NULL); g_return_val_if_fail (interface_name != NULL, NULL); - proxy = dbus_gproxy_new (connection, NULL, + proxy = dbus_g_proxy_new (connection, NULL, path_name, interface_name); return proxy; @@ -1038,7 +1041,7 @@ dbus_gproxy_new_for_peer (DBusConnection *connection, * dbus_connection_flush() to write out pending data. The call will * be completed after a timeout, or when a reply is received. * To collect the results of the call (which may be an error, - * or a reply), use dbus_gproxy_end_call(). + * or a reply), use dbus_g_proxy_end_call(). * * @todo this particular function shouldn't die on out of memory, * since you should be able to do a call with large arguments. @@ -1049,8 +1052,8 @@ dbus_gproxy_new_for_peer (DBusConnection *connection, * * @returns opaque pending call object * */ -DBusPendingCall* -dbus_gproxy_begin_call (DBusGProxy *proxy, +DBusGPendingCall* +dbus_g_proxy_begin_call (DBusGProxy *proxy, const char *method, int first_arg_type, ...) @@ -1059,7 +1062,7 @@ dbus_gproxy_begin_call (DBusGProxy *proxy, DBusMessage *message; va_list args; - g_return_val_if_fail (DBUS_IS_GPROXY (proxy), NULL); + g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), NULL); message = dbus_message_new_method_call (proxy->service, proxy->path, @@ -1080,7 +1083,7 @@ dbus_gproxy_begin_call (DBusGProxy *proxy, -1)) goto oom; - return pending; + return DBUS_G_PENDING_CALL_FROM_PENDING_CALL (pending); oom: /* FIXME we should create a pending call that's @@ -1094,7 +1097,7 @@ dbus_gproxy_begin_call (DBusGProxy *proxy, /** * Collects the results of a method call. The method call was normally - * initiated with dbus_gproxy_end_call(). This function will block if + * initiated with dbus_g_proxy_end_call(). This function will block if * the results haven't yet been received; use * dbus_pending_call_set_notify() to be notified asynchronously that a * pending call has been completed. Use @@ -1109,17 +1112,17 @@ dbus_gproxy_begin_call (DBusGProxy *proxy, * The list should be terminated with DBUS_TYPE_INVALID. * * This function doesn't affect the reference count of the - * #DBusPendingCall, the caller of dbus_gproxy_begin_call() still owns + * #DBusPendingCall, the caller of dbus_g_proxy_begin_call() still owns * a reference. * * @param proxy a proxy for a remote interface - * @param pending the pending call from dbus_gproxy_begin_call() + * @param pending the pending call from dbus_g_proxy_begin_call() * @param error return location for an error * @param first_arg_type type of first "out" argument * @returns #FALSE if an error is set */ gboolean -dbus_gproxy_end_call (DBusGProxy *proxy, - DBusPendingCall *pending, +dbus_g_proxy_end_call (DBusGProxy *proxy, + DBusGPendingCall *pending, GError **error, int first_arg_type, ...) @@ -1128,11 +1131,11 @@ dbus_gproxy_end_call (DBusGProxy *proxy, va_list args; DBusError derror; - g_return_val_if_fail (DBUS_IS_GPROXY (proxy), FALSE); + g_return_val_if_fail (DBUS_IS_G_PROXY (proxy), FALSE); g_return_val_if_fail (pending != NULL, FALSE); - dbus_pending_call_block (pending); - message = dbus_pending_call_get_reply (pending); + dbus_pending_call_block (DBUS_PENDING_CALL_FROM_G_PENDING_CALL (pending)); + message = dbus_pending_call_get_reply (DBUS_PENDING_CALL_FROM_G_PENDING_CALL (pending)); g_assert (message != NULL); @@ -1168,7 +1171,7 @@ dbus_gproxy_end_call (DBusGProxy *proxy, } /** - * Sends a method call message as with dbus_gproxy_begin_call(), but + * Sends a method call message as with dbus_g_proxy_begin_call(), but * does not ask for a reply or allow you to receive one. * * @todo this particular function shouldn't die on out of memory, @@ -1179,7 +1182,7 @@ dbus_gproxy_end_call (DBusGProxy *proxy, * @param first_arg_type type of the first argument */ void -dbus_gproxy_call_no_reply (DBusGProxy *proxy, +dbus_g_proxy_call_no_reply (DBusGProxy *proxy, const char *method, int first_arg_type, ...) @@ -1187,7 +1190,7 @@ dbus_gproxy_call_no_reply (DBusGProxy *proxy, DBusMessage *message; va_list args; - g_return_if_fail (DBUS_IS_GPROXY (proxy)); + g_return_if_fail (DBUS_IS_G_PROXY (proxy)); message = dbus_message_new_method_call (proxy->service, proxy->path, @@ -1234,11 +1237,11 @@ dbus_gproxy_call_no_reply (DBusGProxy *proxy, * @param message the message to address and send * @param client_serial return location for message's serial, or #NULL */ void -dbus_gproxy_send (DBusGProxy *proxy, +dbus_g_proxy_send (DBusGProxy *proxy, DBusMessage *message, dbus_uint32_t *client_serial) { - g_return_if_fail (DBUS_IS_GPROXY (proxy)); + g_return_if_fail (DBUS_IS_G_PROXY (proxy)); if (proxy->service) { @@ -1265,6 +1268,10 @@ dbus_gproxy_send (DBusGProxy *proxy, * the remote interface emits the specified signal, the proxy will * emit a corresponding GLib signal. * + * @todo Right now there's no way to specify the signature to use + * for invoking the GCallback. Need to either rely on introspection, + * or require signature here. + * * @param proxy a proxy for a remote interface * @param signal_name the DBus signal name to listen for * @param handler the handler to connect @@ -1272,16 +1279,16 @@ dbus_gproxy_send (DBusGProxy *proxy, * @param free_data_func callback function to destroy data */ void -dbus_gproxy_connect_signal (DBusGProxy *proxy, +dbus_g_proxy_connect_signal (DBusGProxy *proxy, const char *signal_name, - DBusGProxySignalHandler handler, + GCallback handler, void *data, GClosureNotify free_data_func) { GClosure *closure; char *detail; - g_return_if_fail (DBUS_IS_GPROXY (proxy)); + g_return_if_fail (DBUS_IS_G_PROXY (proxy)); g_return_if_fail (signal_name != NULL); g_return_if_fail (handler != NULL); @@ -1306,15 +1313,15 @@ dbus_gproxy_connect_signal (DBusGProxy *proxy, * @param data the data that was registered with handler */ void -dbus_gproxy_disconnect_signal (DBusGProxy *proxy, +dbus_g_proxy_disconnect_signal (DBusGProxy *proxy, const char *signal_name, - DBusGProxySignalHandler handler, + GCallback handler, void *data) { char *detail; GQuark q; - g_return_if_fail (DBUS_IS_GPROXY (proxy)); + g_return_if_fail (DBUS_IS_G_PROXY (proxy)); g_return_if_fail (signal_name != NULL); g_return_if_fail (handler != NULL); @@ -1350,8 +1357,8 @@ dbus_gproxy_disconnect_signal (DBusGProxy *proxy, * Unit test for GLib proxy functions * @returns #TRUE on success. */ -dbus_bool_t -_dbus_gproxy_test (void) +gboolean +_dbus_g_proxy_test (void) { diff --git a/glib/dbus-gtest.c b/glib/dbus-gtest.c index 420fc229..f583e3ba 100644 --- a/glib/dbus-gtest.c +++ b/glib/dbus-gtest.c @@ -56,6 +56,10 @@ dbus_glib_internal_do_not_use_run_tests (const char *test_data_dir) else printf ("No test data!\n"); + printf ("%s: running glib tests\n", "dbus-glib-test"); + if (!_dbus_glib_test (test_data_dir)) + die ("glib"); + printf ("%s: running utils tests\n", "dbus-glib-test"); if (!_dbus_gutils_test (test_data_dir)) die ("gutils"); diff --git a/glib/dbus-gtest.h b/glib/dbus-gtest.h index 95b496e1..f0ef02e4 100644 --- a/glib/dbus-gtest.h +++ b/glib/dbus-gtest.h @@ -24,11 +24,12 @@ #ifndef DBUS_GLIB_TEST_H #define DBUS_GLIB_TEST_H -#include "dbus-glib.h" +#include <dbus/dbus-glib.h> -dbus_bool_t _dbus_gmain_test (const char *test_data_dir); -dbus_bool_t _dbus_gobject_test (const char *test_data_dir); -dbus_bool_t _dbus_gutils_test (const char *test_data_dir); +gboolean _dbus_gmain_test (const char *test_data_dir); +gboolean _dbus_gobject_test (const char *test_data_dir); +gboolean _dbus_gutils_test (const char *test_data_dir); +gboolean _dbus_glib_test (const char *test_data_dir); void dbus_glib_internal_do_not_use_run_tests (const char *test_data_dir); diff --git a/glib/dbus-gthread.c b/glib/dbus-gthread.c index b0b2f14d..8bc55a57 100644 --- a/glib/dbus-gthread.c +++ b/glib/dbus-gthread.c @@ -23,7 +23,8 @@ #include <glib.h> #include <dbus/dbus.h> -#include "dbus-glib.h" +#include <dbus/dbus-glib.h> +#include <dbus/dbus-glib-lowlevel.h> /** @addtogroup DBusGLibInternals * @{ diff --git a/glib/dbus-gtool-test.h b/glib/dbus-gtool-test.h index 4e679a13..73c27235 100644 --- a/glib/dbus-gtool-test.h +++ b/glib/dbus-gtool-test.h @@ -24,8 +24,8 @@ #ifndef DBUS_GLIB_TOOL_TEST_H #define DBUS_GLIB_TOOL_TEST_H -#include "dbus-glib.h" +#include <dbus/dbus-glib.h> -dbus_bool_t _dbus_gtool_test (const char *test_data_dir); +gboolean _dbus_gtool_test (const char *test_data_dir); #endif /* DBUS_GLIB_TEST_H */ diff --git a/glib/dbus-gutils.c b/glib/dbus-gutils.c index 8c4d3d09..dd8739a6 100644 --- a/glib/dbus-gutils.c +++ b/glib/dbus-gutils.c @@ -118,7 +118,7 @@ _dbus_gutils_type_to_string (int type) * Unit test for GLib utils internals * @returns #TRUE on success. */ -dbus_bool_t +gboolean _dbus_gutils_test (const char *test_data_dir) { diff --git a/glib/dbus-gutils.h b/glib/dbus-gutils.h index 84041d04..bed2d295 100644 --- a/glib/dbus-gutils.h +++ b/glib/dbus-gutils.h @@ -35,6 +35,21 @@ char **_dbus_gutils_split_path (const char *path); const char *_dbus_gutils_type_to_string (int type); +/* These munge the pointer to enforce that a plain cast won't work, + * accessor functions must be used; i.e. to ensure the ABI + * reflects our encapsulation. + */ +#define _DBUS_POINTER_SHIFT(p) ((void*) (((char*)p) + sizeof (void*))) +#define _DBUS_POINTER_UNSHIFT(p) ((void*) (((char*)p) - sizeof (void*))) + +#define DBUS_CONNECTION_FROM_G_CONNECTION(x) ((DBusConnection*) _DBUS_POINTER_UNSHIFT(x)) +#define DBUS_MESSAGE_FROM_G_MESSAGE(x) ((DBusMessage*) _DBUS_POINTER_UNSHIFT(x)) +#define DBUS_PENDING_CALL_FROM_G_PENDING_CALL(x) ((DBusPendingCall*) _DBUS_POINTER_UNSHIFT(x)) + +#define DBUS_G_CONNECTION_FROM_CONNECTION(x) ((DBusGConnection*) _DBUS_POINTER_SHIFT(x)) +#define DBUS_G_MESSAGE_FROM_MESSAGE(x) ((DBusGMessage*) _DBUS_POINTER_SHIFT(x)) +#define DBUS_G_PENDING_CALL_FROM_PENDING_CALL(x) ((DBusGPendingCall*) _DBUS_POINTER_SHIFT(x)) + G_END_DECLS #endif /* DBUS_GLIB_UTILS_H */ diff --git a/test/glib/Makefile.am b/test/glib/Makefile.am index a44787ab..a679bcc1 100644 --- a/test/glib/Makefile.am +++ b/test/glib/Makefile.am @@ -1,4 +1,4 @@ -INCLUDES=-I$(top_srcdir) $(DBUS_CLIENT_CFLAGS) $(DBUS_GLIB_CFLAGS) -I$(top_srcdir)/glib +INCLUDES=-I$(top_srcdir) $(DBUS_CLIENT_CFLAGS) $(DBUS_GLIB_CFLAGS) ## note that TESTS has special meaning (stuff to use in make check) ## so if adding tests not to be run in make check, don't add them to @@ -58,4 +58,4 @@ test_profile_SOURCES= \ test-profile.c test_profile_LDADD= $(DBUS_GLIB_THREADS_LIBS) $(top_builddir)/glib/libdbus-glib-1.la -endif
\ No newline at end of file +endif diff --git a/test/glib/test-dbus-glib.c b/test/glib/test-dbus-glib.c index ad08164a..2315c97c 100644 --- a/test/glib/test-dbus-glib.c +++ b/test/glib/test-dbus-glib.c @@ -1,5 +1,5 @@ /* -*- mode: C; c-file-style: "gnu" -*- */ -#include "dbus-glib.h" +#include <dbus/dbus-glib.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -16,10 +16,15 @@ timed_exit (gpointer loop) static void foo_signal_handler (DBusGProxy *proxy, - DBusMessage *signal, void *user_data) { +#if 0 double d; + + /* FIXME - need to fix up dbus_gproxy_signal_connect() to be able to + * get signal args + */ + DBusError derror; if (!dbus_message_is_signal (signal, @@ -38,6 +43,7 @@ foo_signal_handler (DBusGProxy *proxy, dbus_error_free (&derror); exit (1); } +#endif n_times_foo_received += 1; @@ -47,15 +53,15 @@ foo_signal_handler (DBusGProxy *proxy, int main (int argc, char **argv) { - DBusConnection *connection; + DBusGConnection *connection; GError *error; DBusGProxy *driver; DBusGProxy *proxy; - DBusPendingCall *call; + DBusGPendingCall *call; char **service_list; int service_list_len; int i; - dbus_uint32_t result; + guint32 result; char *str; g_type_init (); @@ -63,8 +69,8 @@ main (int argc, char **argv) loop = g_main_loop_new (NULL, FALSE); error = NULL; - connection = dbus_bus_get_with_g_main (DBUS_BUS_SESSION, - &error); + connection = dbus_g_bus_get (DBUS_BUS_SESSION, + &error); if (connection == NULL) { g_printerr ("Failed to open connection to bus: %s\n", @@ -75,20 +81,20 @@ main (int argc, char **argv) /* Create a proxy object for the "bus driver" */ - driver = dbus_gproxy_new_for_service (connection, - DBUS_SERVICE_ORG_FREEDESKTOP_DBUS, - DBUS_PATH_ORG_FREEDESKTOP_DBUS, - DBUS_INTERFACE_ORG_FREEDESKTOP_DBUS); + driver = dbus_g_proxy_new_for_service (connection, + DBUS_SERVICE_ORG_FREEDESKTOP_DBUS, + DBUS_PATH_ORG_FREEDESKTOP_DBUS, + DBUS_INTERFACE_ORG_FREEDESKTOP_DBUS); /* Call ListServices method */ - call = dbus_gproxy_begin_call (driver, "ListServices", DBUS_TYPE_INVALID); + call = dbus_g_proxy_begin_call (driver, "ListServices", DBUS_TYPE_INVALID); error = NULL; - if (!dbus_gproxy_end_call (driver, call, &error, - DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, - &service_list, &service_list_len, - DBUS_TYPE_INVALID)) + if (!dbus_g_proxy_end_call (driver, call, &error, + DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, + &service_list, &service_list_len, + DBUS_TYPE_INVALID)) { g_printerr ("Failed to complete ListServices call: %s\n", error->message); @@ -105,11 +111,11 @@ main (int argc, char **argv) ++i; } g_assert (service_list[i] == NULL); - - dbus_free_string_array (service_list); + + g_strfreev (service_list); /* Test handling of unknown method */ - call = dbus_gproxy_begin_call (driver, "ThisMethodDoesNotExist", + call = dbus_g_proxy_begin_call (driver, "ThisMethodDoesNotExist", DBUS_TYPE_STRING, "blah blah blah blah blah", DBUS_TYPE_INT32, @@ -117,7 +123,7 @@ main (int argc, char **argv) DBUS_TYPE_INVALID); error = NULL; - if (dbus_gproxy_end_call (driver, call, &error, + if (dbus_g_proxy_end_call (driver, call, &error, DBUS_TYPE_INVALID)) { g_printerr ("Calling nonexistent method succeeded!\n"); @@ -129,7 +135,7 @@ main (int argc, char **argv) g_error_free (error); /* Activate a service */ - call = dbus_gproxy_begin_call (driver, "ActivateService", + call = dbus_g_proxy_begin_call (driver, "ActivateService", DBUS_TYPE_STRING, "org.freedesktop.DBus.TestSuiteEchoService", DBUS_TYPE_UINT32, @@ -137,7 +143,7 @@ main (int argc, char **argv) DBUS_TYPE_INVALID); error = NULL; - if (!dbus_gproxy_end_call (driver, call, &error, + if (!dbus_g_proxy_end_call (driver, call, &error, DBUS_TYPE_UINT32, &result, DBUS_TYPE_INVALID)) { @@ -150,7 +156,7 @@ main (int argc, char **argv) g_print ("Activation of echo service = 0x%x\n", result); /* Activate a service again */ - call = dbus_gproxy_begin_call (driver, "ActivateService", + call = dbus_g_proxy_begin_call (driver, "ActivateService", DBUS_TYPE_STRING, "org.freedesktop.DBus.TestSuiteEchoService", DBUS_TYPE_UINT32, @@ -158,7 +164,7 @@ main (int argc, char **argv) DBUS_TYPE_INVALID); error = NULL; - if (!dbus_gproxy_end_call (driver, call, &error, + if (!dbus_g_proxy_end_call (driver, call, &error, DBUS_TYPE_UINT32, &result, DBUS_TYPE_INVALID)) { @@ -172,11 +178,11 @@ main (int argc, char **argv) /* Talk to the new service */ - proxy = dbus_gproxy_new_for_service_owner (connection, - "org.freedesktop.DBus.TestSuiteEchoService", - "/org/freedesktop/TestSuite", - "org.freedesktop.TestSuite", - &error); + proxy = dbus_g_proxy_new_for_service_owner (connection, + "org.freedesktop.DBus.TestSuiteEchoService", + "/org/freedesktop/TestSuite", + "org.freedesktop.TestSuite", + &error); if (proxy == NULL) { @@ -186,13 +192,13 @@ main (int argc, char **argv) exit (1); } - call = dbus_gproxy_begin_call (proxy, "Echo", + call = dbus_g_proxy_begin_call (proxy, "Echo", DBUS_TYPE_STRING, "my string hello", DBUS_TYPE_INVALID); error = NULL; - if (!dbus_gproxy_end_call (proxy, call, &error, + if (!dbus_g_proxy_end_call (proxy, call, &error, DBUS_TYPE_STRING, &str, DBUS_TYPE_INVALID)) { @@ -203,18 +209,18 @@ main (int argc, char **argv) } g_print ("String echoed = \"%s\"\n", str); - dbus_free (str); + g_free (str); /* Test oneway call and signal handling */ - dbus_gproxy_connect_signal (proxy, "Foo", - foo_signal_handler, - NULL, NULL); + dbus_g_proxy_connect_signal (proxy, "Foo", + G_CALLBACK (foo_signal_handler), + NULL, NULL); - dbus_gproxy_call_no_reply (proxy, "EmitFoo", - DBUS_TYPE_INVALID); - - dbus_connection_flush (connection); + dbus_g_proxy_call_no_reply (proxy, "EmitFoo", + DBUS_TYPE_INVALID); + + dbus_g_connection_flush (connection); g_timeout_add (5000, timed_exit, loop); diff --git a/test/glib/test-profile.c b/test/glib/test-profile.c index 4d0dcf2b..d35a3235 100644 --- a/test/glib/test-profile.c +++ b/test/glib/test-profile.c @@ -28,7 +28,7 @@ #include <config.h> #include <glib.h> -#include "dbus-glib.h" +#include <dbus/dbus-glib-lowlevel.h> #include <stdlib.h> #define N_CLIENT_THREADS 1 diff --git a/test/glib/test-service-glib.c b/test/glib/test-service-glib.c index d3601940..aa409aa3 100644 --- a/test/glib/test-service-glib.c +++ b/test/glib/test-service-glib.c @@ -1,5 +1,5 @@ /* -*- mode: C; c-file-style: "gnu" -*- */ -#include "dbus-glib.h" +#include <dbus/dbus-glib.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -9,7 +9,7 @@ static GMainLoop *loop; int main (int argc, char **argv) { - DBusConnection *connection; + DBusGConnection *connection; GError *error; g_type_init (); @@ -17,8 +17,8 @@ main (int argc, char **argv) loop = g_main_loop_new (NULL, FALSE); error = NULL; - connection = dbus_bus_get_with_g_main (DBUS_BUS_ACTIVATION, - &error); + connection = dbus_g_bus_get (DBUS_BUS_ACTIVATION, + &error); if (connection == NULL) { g_printerr ("Failed to open connection to bus: %s\n", diff --git a/test/glib/test-thread-client.c b/test/glib/test-thread-client.c index 122c839a..3a370671 100644 --- a/test/glib/test-thread-client.c +++ b/test/glib/test-thread-client.c @@ -1,5 +1,5 @@ #include <glib.h> -#include "dbus-glib.h" +#include <dbus/dbus-glib-lowlevel.h> #include <stdio.h> #include <string.h> #include <unistd.h> diff --git a/test/glib/test-thread-server.c b/test/glib/test-thread-server.c index dd560328..3d8a3544 100644 --- a/test/glib/test-thread-server.c +++ b/test/glib/test-thread-server.c @@ -1,5 +1,5 @@ #include <glib.h> -#include "dbus-glib.h" +#include <dbus/dbus-glib-lowlevel.h> #include <stdio.h> #include <string.h> diff --git a/tools/dbus-monitor.c b/tools/dbus-monitor.c index 91668546..3795ee3f 100644 --- a/tools/dbus-monitor.c +++ b/tools/dbus-monitor.c @@ -24,9 +24,7 @@ #include <string.h> #include <glib.h> -#include <dbus/dbus.h> - /* Don't copy this, for programs outside the dbus tree it's dbus/dbus-glib.h */ -#include <glib/dbus-glib.h> +#include <dbus/dbus-glib-lowlevel.h> #include "dbus-print-message.h" static DBusHandlerResult diff --git a/tools/dbus-tree-view.h b/tools/dbus-tree-view.h index 1d59d342..1bc61f6b 100644 --- a/tools/dbus-tree-view.h +++ b/tools/dbus-tree-view.h @@ -24,7 +24,7 @@ #define DBUS_TREE_VIEW_H #include <gtk/gtk.h> -#include <glib/dbus-glib.h> +#include <dbus/dbus-glib.h> #include <glib/dbus-gidl.h> GtkWidget* dbus_tree_view_new (void); |