diff --git a/.gitignore b/.gitignore index 0d1734f89b9b34d991b9e8fccc921ac4118aac52..a7c0caa8096ad037b7fa1c80c421059d015583c5 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 e0ac708f1fbb41ece6957cc138099c7d41128beb..064bb81f21619015b4b6a3da50829fbdfba58e7b 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 0a8a87618b562a568f8e669a980a70b920acc9bc..362f19d9d70a3bd462edc559bdb6c10c35cfebe0 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 \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 \n" \ + --fhead "#include \"geoclue-enum-types.h\"\n" \ + --fhead "#include " \ + --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)) > $@ diff --git a/geoclue/geoclue-error.c b/geoclue/geoclue-error.c index fc57fed5cba8c7a182e7aa35b88e5a4c505e048c..54df6ed5bc5f834e058f5e4b75093259ba5a2508 100644 --- a/geoclue/geoclue-error.c +++ b/geoclue/geoclue-error.c @@ -35,3 +35,4 @@ geoclue_error_quark (void) return quark; } + diff --git a/geoclue/geoclue-error.h b/geoclue/geoclue-error.h index 2d5530408539ee95bd12c30b46b1262b98434d87..113857845d1d0e28981ca66da94edbc26ca87378 100644 --- a/geoclue/geoclue-error.h +++ b/geoclue/geoclue-error.h @@ -25,9 +25,25 @@ #ifndef _GEOCLUE_ERROR_H #define _GEOCLUE_ERROR_H -#include -#include +#include +#include +/** + * 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 53dba3f0e86a9df5b4f5c46b52f7f7d7d1ea96ee..15197b647b672b584321a99589465791b6aabea3 100644 --- a/geoclue/geoclue-types.c +++ b/geoclue/geoclue-types.c @@ -25,6 +25,7 @@ #include #include #include +#include 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 5e39fbd8004071c5542f853d3e6e991724eef91e..9ecbc40e66b761d2a313fa0e0aca0756ff891390 100644 --- a/geoclue/geoclue-types.h +++ b/geoclue/geoclue-types.h @@ -25,6 +25,8 @@ #ifndef _GEOCLUE_TYPES_H #define _GEOCLUE_TYPES_H +#include + /** * SECTION:geoclue-types * @short_description: Type definitions and defines useful for Geoclue clients @@ -98,21 +100,6 @@ typedef enum { GEOCLUE_VELOCITY_FIELDS_CLIMB = 1 << 2 } 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: *