Heya, Both patches are ready to go into master and packages. The D-Bus error "special sauce" one fixes the crash that Matthias has seen and reported by others on the Red Hat bugzilla.
Cheers
>From 10a0efe5366c5f71df4ef263b53c5344a7151881 Mon Sep 17 00:00:00 2001 From: Bastien Nocera <[email protected]> Date: Wed, 27 Jan 2010 14:05:25 +0000 Subject: [PATCH 1/2] Add error type registration The error types need to be registered with dbus-glib to be used. --- .gitignore | 2 ++ docs/reference/geoclue.types | 1 + geoclue/Makefile.am | 39 +++++++++++++++++++++++++++++++++++---- geoclue/geoclue-error.h | 20 ++++++++++++++++++-- geoclue/geoclue-types.c | 5 +++++ geoclue/geoclue-types.h | 17 ++--------------- 6 files changed, 63 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index 0d1734f..a7c0caa 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,5 @@ example/geoclue-map-example-moving example/geoclue-map-layout-example example/geoclue-position-example geoclue/geoclue-master +geoclue/geoclue-enum-types.h +geoclue/geoclue-enum-types.c diff --git a/docs/reference/geoclue.types b/docs/reference/geoclue.types index e0ac708..064bb81 100644 --- a/docs/reference/geoclue.types +++ b/docs/reference/geoclue.types @@ -23,6 +23,7 @@ geoclue_velocity_get_type geoclue_address_get_type geoclue_geocode_get_type geoclue_reverse_geocode_get_type +geoclue_error_get_type gc_web_service_get_type gc_provider_get_type diff --git a/geoclue/Makefile.am b/geoclue/Makefile.am index 0a8a876..362f19d 100644 --- a/geoclue/Makefile.am +++ b/geoclue/Makefile.am @@ -19,7 +19,9 @@ nodist_libgeoclue_la_SOURCES = \ gc-iface-velocity-glue.h BUILT_SOURCES = \ - $(nodist_libgeoclue_la_SOURCES) + $(nodist_libgeoclue_la_SOURCES) \ + geoclue-enum-types.h \ + geoclue-enum-types.c libgeoclue_la_SOURCES = \ geoclue-accuracy.c \ @@ -41,7 +43,8 @@ libgeoclue_la_SOURCES = \ gc-iface-geocode.c \ gc-iface-position.c \ gc-iface-reverse-geocode.c \ - gc-iface-velocity.c + gc-iface-velocity.c \ + geoclue-enum-types.c libgeoclue_la_LIBADD = \ $(GEOCLUE_LIBS) @@ -71,7 +74,8 @@ geoclue_headers = \ geoclue-position.h \ geoclue-reverse-geocode.h \ geoclue-types.h \ - geoclue-velocity.h + geoclue-velocity.h \ + geoclue-enum-types.h libgeoclue_includedir = $(includedir)/geoclue libgeoclue_include_HEADERS = \ @@ -89,7 +93,9 @@ CLEANFILES = $(BUILT_SOURCES) \ stamp-gc-iface-velocity-glue.h DISTCLEANFILES = \ - $(nodist_libgeoclue_la_SOURCES) + $(nodist_libgeoclue_la_SOURCES) \ + geoclue-enum-types.h \ + geoclue-enum-types.c geoclue-marshal.h: geoclue-marshal.list $(GLIB_GENMARSHAL) $(GLIB_GENMARSHAL) $< --header --prefix=geoclue_marshal > $@ @@ -143,3 +149,28 @@ stamp-%-bindings.h: ../interfaces/%.xml && (cmp -s xgen-$(@F) $(@F:stamp-%=%) || cp xgen-$(@F) $(@F:stamp-%=%)) \ && rm -f xgen-$(@F) \ && echo timestamp > $(@F) + +geoclue_headers_to_scan_for_enums = geoclue-error.h +# Generate the enums source code, with glib-mkenums: +# This is based on the same Makefile.am stuff in pango: +geoclue_built_headers = geoclue-enum-types.h +geoclue_built_cfiles = geoclue-enum-types.c + +geoclue-enum-types.h: $(geoclue_headers_to_scan_for_enums) Makefile + $(AM_V_GEN) (cd $(srcdir) && glib-mkenums \ + --fhead "#ifndef __GEOCLUE_ENUM_TYPES_H__\n#define __GEOCLUE_ENUM_TYPES_H__\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n" \ + --fprod "/* enumerations from \"@filen...@\" */\n" \ + --vhead "GType @enum_n...@_get_type (void);\n#define geoclue_ty...@enumshort@ (@enum_n...@_get_type())\n" \ + --ftail "G_END_DECLS\n\n#endif /* __GEOCLUE_ENUM_TYPES_H__ */" \ + $(geoclue_headers_to_scan_for_enums)) > $@ + +geoclue-enum-types.c: $(geoclue_headers_to_scan_for_enums) Makefile geoclue-enum-types.h + $(AM_V_GEN) (cd $(srcdir) && glib-mkenums \ + --fhead "#include <geoclue-error.h>\n" \ + --fhead "#include \"geoclue-enum-types.h\"\n" \ + --fhead "#include <glib-object.h>" \ + --fprod "\n/* enumerations from \"@filen...@\" */" \ + --vhead "gtyp...@enum_name@_get_type (void)\n{\n static GType etype = 0;\n if (etype == 0) {\n static const g...@type@Value values[] = {" \ + --vprod " { @VALUENAME@, \"@valuen...@\", \"@valuen...@\" }," \ + --vtail " { 0, NULL, NULL }\n };\n etype = g...@type@_register_static (\"@enumn...@\", values);\n }\n return etype;\n}\n" \ + $(geoclue_headers_to_scan_for_enums)) > $@ diff --git a/geoclue/geoclue-error.h b/geoclue/geoclue-error.h index 2d55304..1138578 100644 --- a/geoclue/geoclue-error.h +++ b/geoclue/geoclue-error.h @@ -25,9 +25,25 @@ #ifndef _GEOCLUE_ERROR_H #define _GEOCLUE_ERROR_H -#include <glib.h> -#include <geoclue/geoclue-types.h> +#include <glib-object.h> +#include <geoclue/geoclue-enum-types.h> +/** + * GeoclueError: + * @GEOCLUE_ERROR_NOT_IMPLEMENTED: Method is not implemented + * @GEOCLUE_ERROR_NOT_AVAILABLE: Needed information is not currently + * available (e.g. web service did not respond) + * @GEOCLUE_ERROR_FAILED: Generic fatal error + * + * Error values for providers. + **/ +typedef enum { + GEOCLUE_ERROR_NOT_IMPLEMENTED, + GEOCLUE_ERROR_NOT_AVAILABLE, + GEOCLUE_ERROR_FAILED, +} GeoclueError; + +#define GEOCLUE_ERROR_DBUS_INTERFACE "org.freedesktop.Geoclue.Error" #define GEOCLUE_ERROR (geoclue_error_quark ()) GQuark geoclue_error_quark (void); diff --git a/geoclue/geoclue-types.c b/geoclue/geoclue-types.c index 53dba3f..15197b6 100644 --- a/geoclue/geoclue-types.c +++ b/geoclue/geoclue-types.c @@ -25,6 +25,7 @@ #include <geoclue/geoclue-marshal.h> #include <geoclue/geoclue-types.h> #include <geoclue/geoclue-accuracy.h> +#include <geoclue/geoclue-error.h> void geoclue_types_init (void) @@ -61,4 +62,8 @@ geoclue_types_init (void) G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); + + dbus_g_error_domain_register (GEOCLUE_ERROR, + GEOCLUE_ERROR_DBUS_INTERFACE, + GEOCLUE_TYPE_ERROR); } diff --git a/geoclue/geoclue-types.h b/geoclue/geoclue-types.h index 5e39fbd..9ecbc40 100644 --- a/geoclue/geoclue-types.h +++ b/geoclue/geoclue-types.h @@ -25,6 +25,8 @@ #ifndef _GEOCLUE_TYPES_H #define _GEOCLUE_TYPES_H +#include <geoclue/geoclue-error.h> + /** * SECTION:geoclue-types * @short_description: Type definitions and defines useful for Geoclue clients @@ -99,21 +101,6 @@ typedef enum { } GeoclueVelocityFields; /** - * GeoclueError: - * @GEOCLUE_ERROR_NOT_IMPLEMENTED: Method is not implemented - * @GEOCLUE_ERROR_NOT_AVAILABLE: Needed information is not currently - * available (e.g. web service did not respond) - * @GEOCLUE_ERROR_FAILED: Generic fatal error - * - * Error values for providers. - **/ -typedef enum { - GEOCLUE_ERROR_NOT_IMPLEMENTED, - GEOCLUE_ERROR_NOT_AVAILABLE, - GEOCLUE_ERROR_FAILED, -} GeoclueError; - -/** * GEOCLUE_ADDRESS_KEY_COUNTRYCODE: * * A key for address hashtables. The hash value should be a ISO 3166 two -- 1.6.6
>From 87ba0b5d803d5db088732a4445149f6be6911b8a Mon Sep 17 00:00:00 2001 From: Bastien Nocera <[email protected]> Date: Thu, 28 Jan 2010 11:17:24 +0000 Subject: [PATCH 2/2] Don't lose special D-Bus error sauce when copying When copying errors for later use, make sure to copy D-Bus errors special sauce (domain name of the error copied after the string itself). Fixes possible crashers in geoclue-master when returning a cached provider error. See: https://bugzilla.redhat.com/show_bug.cgi?id=528897#c15 With debugging help from Colin Walters and Matthias Clasen. --- src/master-provider.c | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/src/master-provider.c b/src/master-provider.c index c54919a..dd49ee7 100644 --- a/src/master-provider.c +++ b/src/master-provider.c @@ -126,6 +126,19 @@ copy_error (GError **target, GError *source) } if (source) { *target = g_error_copy (source); + + /* If the error type is a D-Bus remote exception, + * don't lose the "magic" sauce after the message string. + * See the code in gerror_to_dbus_error_message() in dbus-glib */ + if (source->domain == DBUS_GERROR && + source->code == DBUS_GERROR_REMOTE_EXCEPTION) { + int len; + g_free ((*target)->message); + len = strlen (source->message); + len += strlen (source->message + len + 1); + len += 2; + (*target)->message = g_memdup (source->message, len); + } } } -- 1.6.6
_______________________________________________ GeoClue mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/geoclue
