Commit b0808f23 authored by Bastien Nocera's avatar Bastien Nocera Committed by Ross Burton

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.
parent 33cf3bc9
...@@ -37,3 +37,5 @@ example/geoclue-map-example-moving ...@@ -37,3 +37,5 @@ example/geoclue-map-example-moving
example/geoclue-map-layout-example example/geoclue-map-layout-example
example/geoclue-position-example example/geoclue-position-example
geoclue/geoclue-master geoclue/geoclue-master
geoclue/geoclue-enum-types.h
geoclue/geoclue-enum-types.c
...@@ -23,6 +23,7 @@ geoclue_velocity_get_type ...@@ -23,6 +23,7 @@ geoclue_velocity_get_type
geoclue_address_get_type geoclue_address_get_type
geoclue_geocode_get_type geoclue_geocode_get_type
geoclue_reverse_geocode_get_type geoclue_reverse_geocode_get_type
geoclue_error_get_type
gc_web_service_get_type gc_web_service_get_type
gc_provider_get_type gc_provider_get_type
...@@ -19,7 +19,9 @@ nodist_libgeoclue_la_SOURCES = \ ...@@ -19,7 +19,9 @@ nodist_libgeoclue_la_SOURCES = \
gc-iface-velocity-glue.h gc-iface-velocity-glue.h
BUILT_SOURCES = \ BUILT_SOURCES = \
$(nodist_libgeoclue_la_SOURCES) $(nodist_libgeoclue_la_SOURCES) \
geoclue-enum-types.h \
geoclue-enum-types.c
libgeoclue_la_SOURCES = \ libgeoclue_la_SOURCES = \
geoclue-accuracy.c \ geoclue-accuracy.c \
...@@ -41,7 +43,8 @@ libgeoclue_la_SOURCES = \ ...@@ -41,7 +43,8 @@ libgeoclue_la_SOURCES = \
gc-iface-geocode.c \ gc-iface-geocode.c \
gc-iface-position.c \ gc-iface-position.c \
gc-iface-reverse-geocode.c \ gc-iface-reverse-geocode.c \
gc-iface-velocity.c gc-iface-velocity.c \
geoclue-enum-types.c
libgeoclue_la_LIBADD = \ libgeoclue_la_LIBADD = \
$(GEOCLUE_LIBS) $(GEOCLUE_LIBS)
...@@ -71,7 +74,8 @@ geoclue_headers = \ ...@@ -71,7 +74,8 @@ geoclue_headers = \
geoclue-position.h \ geoclue-position.h \
geoclue-reverse-geocode.h \ geoclue-reverse-geocode.h \
geoclue-types.h \ geoclue-types.h \
geoclue-velocity.h geoclue-velocity.h \
geoclue-enum-types.h
libgeoclue_includedir = $(includedir)/geoclue libgeoclue_includedir = $(includedir)/geoclue
libgeoclue_include_HEADERS = \ libgeoclue_include_HEADERS = \
...@@ -89,7 +93,9 @@ CLEANFILES = $(BUILT_SOURCES) \ ...@@ -89,7 +93,9 @@ CLEANFILES = $(BUILT_SOURCES) \
stamp-gc-iface-velocity-glue.h stamp-gc-iface-velocity-glue.h
DISTCLEANFILES = \ 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) geoclue-marshal.h: geoclue-marshal.list $(GLIB_GENMARSHAL)
$(GLIB_GENMARSHAL) $< --header --prefix=geoclue_marshal > $@ $(GLIB_GENMARSHAL) $< --header --prefix=geoclue_marshal > $@
...@@ -143,3 +149,28 @@ stamp-%-bindings.h: ../interfaces/%.xml ...@@ -143,3 +149,28 @@ stamp-%-bindings.h: ../interfaces/%.xml
&& (cmp -s xgen-$(@F) $(@F:stamp-%=%) || cp xgen-$(@F) $(@F:stamp-%=%)) \ && (cmp -s xgen-$(@F) $(@F:stamp-%=%) || cp xgen-$(@F) $(@F:stamp-%=%)) \
&& rm -f xgen-$(@F) \ && rm -f xgen-$(@F) \
&& echo timestamp > $(@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 \"@filename@\" */\n" \
--vhead "GType @enum_name@_get_type (void);\n#define GEOCLUE_TYPE_@ENUMSHORT@ (@enum_name@_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 \"@filename@\" */" \
--vhead "GType\n@enum_name@_get_type (void)\n{\n static GType etype = 0;\n if (etype == 0) {\n static const G@Type@Value values[] = {" \
--vprod " { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \
--vtail " { 0, NULL, NULL }\n };\n etype = g_@type@_register_static (\"@EnumName@\", values);\n }\n return etype;\n}\n" \
$(geoclue_headers_to_scan_for_enums)) > $@
...@@ -35,3 +35,4 @@ geoclue_error_quark (void) ...@@ -35,3 +35,4 @@ geoclue_error_quark (void)
return quark; return quark;
} }
...@@ -25,9 +25,25 @@ ...@@ -25,9 +25,25 @@
#ifndef _GEOCLUE_ERROR_H #ifndef _GEOCLUE_ERROR_H
#define _GEOCLUE_ERROR_H #define _GEOCLUE_ERROR_H
#include <glib.h> #include <glib-object.h>
#include <geoclue/geoclue-types.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 ()) #define GEOCLUE_ERROR (geoclue_error_quark ())
GQuark geoclue_error_quark (void); GQuark geoclue_error_quark (void);
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <geoclue/geoclue-marshal.h> #include <geoclue/geoclue-marshal.h>
#include <geoclue/geoclue-types.h> #include <geoclue/geoclue-types.h>
#include <geoclue/geoclue-accuracy.h> #include <geoclue/geoclue-accuracy.h>
#include <geoclue/geoclue-error.h>
void void
geoclue_types_init (void) geoclue_types_init (void)
...@@ -61,4 +62,8 @@ geoclue_types_init (void) ...@@ -61,4 +62,8 @@ geoclue_types_init (void)
G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_INVALID); G_TYPE_INVALID);
dbus_g_error_domain_register (GEOCLUE_ERROR,
GEOCLUE_ERROR_DBUS_INTERFACE,
GEOCLUE_TYPE_ERROR);
} }
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#ifndef _GEOCLUE_TYPES_H #ifndef _GEOCLUE_TYPES_H
#define _GEOCLUE_TYPES_H #define _GEOCLUE_TYPES_H
#include <geoclue/geoclue-error.h>
/** /**
* SECTION:geoclue-types * SECTION:geoclue-types
* @short_description: Type definitions and defines useful for Geoclue clients * @short_description: Type definitions and defines useful for Geoclue clients
...@@ -98,21 +100,6 @@ typedef enum { ...@@ -98,21 +100,6 @@ typedef enum {
GEOCLUE_VELOCITY_FIELDS_CLIMB = 1 << 2 GEOCLUE_VELOCITY_FIELDS_CLIMB = 1 << 2
} GeoclueVelocityFields; } 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: * GEOCLUE_ADDRESS_KEY_COUNTRYCODE:
* *
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment