Heya, Peter asked me to look at a few geoclue crashers[1] in the Red Hat bugzilla, and with some hints from Colin and help from Matthias who could reproduce the bug, I came up with the attached.
It seems correct to me, as I do something similar in fprintd. I hope Matthias will be able to smoke-test it in his test environment (home) before we merge it. Opinions? Cheers [1]: https://bugzilla.redhat.com/show_bug.cgi?id=556257 and https://bugzilla.redhat.com/show_bug.cgi?id=528897 being prime examples PS: Sorry about the dupe mail for some, addressbook completion problems
>From 8ab76c7ded22c46f47976dfbf459120e39e991f1 Mon Sep 17 00:00:00 2001 From: Bastien Nocera <[email protected]> Date: Wed, 27 Jan 2010 14:05:25 +0000 Subject: [PATCH] Add error type registration The error types need to be registered with dbus-glib to be used. Fixes possible crashers in geoclue-master and its providers. See: https://bugzilla.redhat.com/show_bug.cgi?id=528897#c15 With debugging help from Colin Walters and Matthias Clasen. --- geoclue/geoclue-error.c | 20 ++++++++++++++++++++ geoclue/geoclue-error.h | 21 +++++++++++++++++++-- geoclue/geoclue-types.c | 5 +++++ geoclue/geoclue-types.h | 17 ++--------------- 4 files changed, 46 insertions(+), 17 deletions(-) diff --git a/geoclue/geoclue-error.c b/geoclue/geoclue-error.c index fc57fed..2262048 100644 --- a/geoclue/geoclue-error.c +++ b/geoclue/geoclue-error.c @@ -35,3 +35,23 @@ geoclue_error_quark (void) return quark; } + +#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC } +GType +geoclue_error_get_type (void) +{ + static GType etype = 0; + + if (etype == 0) { + static const GEnumValue values[] = + { + ENUM_ENTRY (GEOCLUE_ERROR_NOT_IMPLEMENTED, "NotImplemented"), + ENUM_ENTRY (GEOCLUE_ERROR_NOT_AVAILABLE, "NotAvailable"), + ENUM_ENTRY (GEOCLUE_ERROR_FAILED, "Failed"), + { 0, 0, 0 } + }; + etype = g_enum_register_static ("GeoclueError", values); + } + return etype; +} + diff --git a/geoclue/geoclue-error.h b/geoclue/geoclue-error.h index 2d55304..bdbd38a 100644 --- a/geoclue/geoclue-error.h +++ b/geoclue/geoclue-error.h @@ -25,11 +25,28 @@ #ifndef _GEOCLUE_ERROR_H #define _GEOCLUE_ERROR_H -#include <glib.h> -#include <geoclue/geoclue-types.h> +#include <glib-object.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_TYPE_ERROR geoclue_error_get_type() #define GEOCLUE_ERROR (geoclue_error_quark ()) GQuark geoclue_error_quark (void); +GType geoclue_error_get_type (void); #endif 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
_______________________________________________ GeoClue mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/geoclue
