summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Schmidt <s.schmidt@samsung.com>2019-10-02 17:45:07 +0200
committerStefan Schmidt <s.schmidt@samsung.com>2019-10-30 17:00:31 +0100
commit145d2975846bfd1c7099decc8b6fabc0cda32d33 (patch)
treefab0400402fa33c7ee9742f1305cbacff68d960d
parentf4019d3303f678b9f040d50cc98c8ba36fd4d1a9 (diff)
elocation: remove beta librarydevs/stefan/elocation-removal
This has never been fully finished or really used. The GeoClue project dbus API moved on to a newer version as well. We still have it marked as beta so we should take the chance and get rid of it to cleanup our tree a little bit.
-rw-r--r--doc/elementary_examples.dox1
-rw-r--r--doc/elementary_examples_cxx.dox224
-rw-r--r--doc/main.dox1
-rw-r--r--meson.build3
-rw-r--r--src/examples/elementary/location_example_01.c151
-rw-r--r--src/examples/elementary/meson.build1
-rw-r--r--src/examples/elocation/.gitignore1
-rw-r--r--src/examples/elocation/elocation.c167
-rw-r--r--src/lib/elementary/Elementary.h4
-rw-r--r--src/lib/elementary/Elementary_Options.h.in4
-rw-r--r--src/lib/elementary/elm_main.c15
-rw-r--r--src/lib/elementary/meson.build3
-rw-r--r--src/lib/elocation/Elocation.h433
-rw-r--r--src/lib/elocation/elocation.c1414
-rw-r--r--src/lib/elocation/elocation_private.h186
-rw-r--r--src/lib/elocation/gen/eldbus_geo_clue2_client.c448
-rw-r--r--src/lib/elocation/gen/eldbus_geo_clue2_client.h36
-rw-r--r--src/lib/elocation/gen/eldbus_geo_clue2_location.c246
-rw-r--r--src/lib/elocation/gen/eldbus_geo_clue2_location.h22
-rw-r--r--src/lib/elocation/gen/eldbus_geo_clue2_manager.c209
-rw-r--r--src/lib/elocation/gen/eldbus_geo_clue2_manager.h23
-rw-r--r--src/lib/elocation/gen/eldbus_utils.h24
-rw-r--r--src/lib/elocation/gen/meson.build5
-rw-r--r--src/lib/elocation/gen/org.freedesktop.GeoClue2.xml199
-rw-r--r--src/lib/elocation/meson.build28
-rw-r--r--src/tests/elocation/elocation_suite.c235
26 files changed, 2 insertions, 4081 deletions
diff --git a/doc/elementary_examples.dox b/doc/elementary_examples.dox
index dc7acba..76aa37e 100644
--- a/doc/elementary_examples.dox
+++ b/doc/elementary_examples.dox
@@ -6809,7 +6809,6 @@
6809 * @example efl_thread_win32_2.c 6809 * @example efl_thread_win32_2.c
6810 * @example efl_thread_win32_3.c 6810 * @example efl_thread_win32_3.c
6811 * @example efl_thread_win32_4.c 6811 * @example efl_thread_win32_4.c
6812 * @example location_example_01.c
6813 * @example naviframe_example.c 6812 * @example naviframe_example.c
6814 */ 6813 */
6815 6814
diff --git a/doc/elementary_examples_cxx.dox b/doc/elementary_examples_cxx.dox
index 6197450..6ba06cc 100644
--- a/doc/elementary_examples_cxx.dox
+++ b/doc/elementary_examples_cxx.dox
@@ -3201,230 +3201,6 @@
3201 */ 3201 */
3202 3202
3203/** 3203/**
3204 * @page location_cxx_example_01 Location example with C++ Binding
3205 * @dontinclude location_cxx_example_01.cc
3206
3207 * This example shows how to integrate the Elocation.h library with
3208 * elementary.
3209
3210 * The first part consists of including the headers. In this case we
3211 * need to include both Elementary C++ binding and Elocation,
3212
3213 * @skip Elementary.hh
3214 * @until endif
3215
3216 * @attention All necessary libraries from Elementary, Elightenment, C
3217 * and/or C++ headers should be include here.
3218
3219 * Before our main code, we need a set of callbacks to react on
3220 * incoming elocation events. They are standard ecore events and we
3221 * register callbacks on these events in the main function.
3222
3223 * @skip void
3224 * @until ECORE_CALLBACK_DONE
3225 * @until }
3226
3227 * Now we need to actually start the code and initializing pointers
3228 * for address, addr_geocode, position and pos_geocode and an integer
3229 * status. We also run a check for elm_need_elocation.
3230
3231 * @skip EAPI_MAIN
3232 * @until -1
3233
3234 * Now let's set the elm_policy, which defines for a given policy
3235 * group/identifier a new policy's value, respectively. In this
3236 * example the only policy we need to set a value for is @c
3237 * ELM_POLICY_QUIT, possibles values for it are:
3238
3239 * @li @p ELM_POLICY_QUIT_NONE: Never quit the application
3240 * automatically;
3241
3242 * @li @p ELM_POLICY_QUIT_LAST_WINDOW_CLOSED: quit when the
3243 * application's last window is closed;
3244
3245 * @li @p ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN : quit when the
3246 * application's last window is hidden;
3247
3248 * @skipline elm_policy_set
3249
3250 * As you can see, the policy we chose was to quit when the last win
3251 * is hidden as opposed to examples with the C bindings where we
3252 * perpetually set it to quit when last win was closed. This changed
3253 * was necessary because in C++ binding as the elm mainloop stop
3254 * running all object are destroyed, references are unreferenced and
3255 * events are stopped at ELM_MAIN().
3256
3257 * @see For more details consult elm_policy_set
3258
3259 * Next step is creating an elementary window, in this example we use
3260 * the C++ binding method with the elm_win_util_standard_add that is a
3261 * elm_win_legacy function, better explained below. And then we set
3262 * the autohide state for it.
3263
3264 * @p elm_win_util_standard_add (const char *name, const char *tittle)
3265 * Adds a window object with standard setup.
3266 * Parameters:
3267
3268 * @li @p name - The name of the window;
3269
3270 * @li @p title - The title for the window.
3271
3272 * This creates a window but also puts in a standard background with
3273 * @p elm_bg_add(), as well as setting the window title to @p
3274 * title. The window type created is of type @c ELM_WIN_BASIC, with
3275 * the @c NULL as the parent widget. Returns the created object or @c
3276 * NULL on failure.
3277
3278 * The autohide works similarly to @p autodel, automatically handling
3279 * "delete,request" signals when set to @p true, with the difference
3280 * that it will hide the window, instead of destroying it.
3281
3282 * It is specially designed to work together with @p
3283 * ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN which allows exiting
3284 * Elementary's main loop when all the windows are hidden.
3285
3286 * @skip ::elm::win
3287 * @until autohide_set
3288
3289 * @note @p autodel and @a autohide are not mutually exclusive. The
3290 * window will be destructed if both autodel and autohide is set to @p
3291 * EINA_TRUE or @p true.
3292
3293 * For this example we're using a label that will display the text
3294 * "Getting location ...". First we'll create our label, setting it's
3295 * parent, then setting the following label's options:
3296
3297 * @li @p line_wrap_set: Set the wrapping behavior of the label, by
3298 * default no wrapping is done. Possible values for wrap are:
3299 * @p ELM_WRAP_NONE - No wrapping;
3300 * @p ELM_WRAP_CHAR - wrap between characters;
3301 * @p ELM_WRAP_WORD - wrap between words;
3302 * @p ELM_WRAP_MIXED - Word wrap, and if that fails, char wrap.
3303
3304 * @ skipline wrap
3305
3306 * @li @p text_set: Set the text that label will display.
3307
3308 * @skipline text
3309
3310 * @li @p slide_mode_set: Set the slide mode of the label widget. By
3311 * default, slide mode is none. Possible values for mode are:
3312
3313 * ELM_LABEL_SLIDE_MODE_NONE - no slide effect
3314
3315 * ELM_LABEL_SLIDE_MODE_AUTO - slide only if the label area is bigger
3316 * than the text width length
3317
3318 * ELM_LABEL_SLIDE_MODE_ALWAYS -slide always
3319
3320 * @attention ELM_LABEL_SLIDE_MODE_AUTO, ELM_LABEL_SLIDE_MODE_ALWAYS
3321 * only work with the themes "slide_short", "slide_long" and
3322 * "slide_bounce". ELM_LABEL_SLIDE_MODE_AUTO,
3323 * ELM_LABEL_SLIDE_MODE_ALWAYS don't work if the line
3324 * wrap(elm_label_line_wrap_set()) or
3325 * ellipsis(elm_label_ellipsis_set()) is set.
3326
3327 * @skipline slide
3328
3329 * To better understand, the function @c size_hint_weight_set for C++
3330 * bindings originated from C bindings function
3331 * evas_object_size_hint_weight_set, that is EFL Evas type function.
3332 * With this function we set the hints for an object's weight. The
3333 * parameters are:
3334
3335 * @li x - Nonnegative double value to use as horizontal weight hint.
3336
3337 * @li y - Nonnegative double value to use as vertical weight hint.
3338
3339 * This is not a size enforcement in any way, it's just a hint that
3340 * should be used whenever appropriate. This is a hint on how a
3341 * container object should resize a given child within its area.
3342
3343 * Containers may adhere to the simpler logic of just expanding the
3344 * child object's dimensions to fit its own (see the EVAS_HINT_EXPAND
3345 * helper weight macro in the EFL Evas Documentation) or the complete
3346 * one of taking each child's weight hint as real weights to how much
3347 * of its size to allocate for them in each axis. A container is
3348 * supposed to, after normalizing the weights of its children (with
3349 * weight hints), distribute the space it has to layout them by those
3350 * factors – most weighted children get larger in this process than
3351 * the least ones.
3352
3353 * @dontinclude location_cxx_example_01.cc
3354 * @skipline weight_set
3355
3356 * @note Default weight hint values are 0.0, for both axis.
3357
3358 * The function @c size_hint_align_set for C++ bindings originated
3359 * from C bindings function evas_object_size_hint_align_set, that is
3360 * EFL Evas type function. With this function we set the hints for an
3361 * object's alignment. The parameters are:
3362
3363 * @li x - Double, ranging from 0.0 to 1.0 or with the special value
3364 * EVAS_HINT_FILL, to use as horizontal alignment hint.
3365
3366 * @li y - Double, ranging from 0.0 to 1.0 or with the special value
3367 * EVAS_HINT_FILL, to use as vertical alignment hint.
3368
3369 * These are hints on how to align an object inside the boundaries of
3370 * a container/manager. Accepted values are in the 0.0 to 1.0 range,
3371 * with the special value EVAS_HINT_FILL used to specify "justify" or
3372 * "fill" by some users. In this case, maximum size hints should be
3373 * enforced with higher priority, if they are set. Also, any padding
3374 * hint set on objects should add up to the alignment space on the
3375 * final scene composition.
3376
3377 * For the horizontal component, 0.0 means to the left, 1.0 means to
3378 * the right. Analogously, for the vertical component, 0.0 to the top,
3379 * 1.0 means to the bottom.
3380
3381 * This is not a size enforcement in any way, it's just a hint that
3382 * should be used whenever appropriate.
3383
3384 * @note Default alignment hint values are 0.5, for both axis.
3385
3386 * @skipline align_set
3387
3388 * Setting the size for label and make it visible.
3389
3390 * @skip size
3391 * @until visibility
3392
3393 * Going back to our elocation, first we'll create an address
3394 * and position object that we'll use for all our operations.
3395
3396 * @skip address
3397 * @until position
3398
3399 * We also have to register our callback so we get updates later on.
3400
3401 * @skipline ecore
3402
3403 * Now we need to get the elocation position and print it, using our
3404 * label. This fills in the object with the data from GeoClue.
3405
3406 * @skip elocation
3407 * @until print
3408
3409 * Now we only have to set the size for our window and make it
3410 * visible.
3411
3412 * @skip size_set
3413 * @until visibility_set
3414
3415 * And finally, start the elm mainloop, starting to handle events and
3416 * drawing operations.
3417
3418 * @skip elm_run
3419 * @until ELM_MAIN
3420
3421 * The full code for this example can be found at @ref location_cxx_example_01.cc
3422
3423 * @example location_cxx_example_01.cc
3424 */
3425
3426
3427/**
3428 * @page menu_cxx_example_01 Menu Example with C++ Binding 3204 * @page menu_cxx_example_01 Menu Example with C++ Binding
3429 * @dontinclude menu_cxx_example_01.cc 3205 * @dontinclude menu_cxx_example_01.cc
3430 3206
diff --git a/doc/main.dox b/doc/main.dox
index d9e50bc..b2a79ff 100644
--- a/doc/main.dox
+++ b/doc/main.dox
@@ -43,7 +43,6 @@
43 * <h3>Early stage libraries (BETA testing)</h3> 43 * <h3>Early stage libraries (BETA testing)</h3>
44 * 44 *
45 * @li @ref eolian_main an EO file parser and code generator. 45 * @li @ref eolian_main an EO file parser and code generator.
46 * @li @ref elocation_main awareness library.
47 * 46 *
48 * If you are looking for methods that do not fit into the above list you can 47 * If you are looking for methods that do not fit into the above list you can
49 * see the full <a href="modules.html" />module listing</a>. 48 * see the full <a href="modules.html" />module listing</a>.
diff --git a/meson.build b/meson.build
index 702e383..aff79a4 100644
--- a/meson.build
+++ b/meson.build
@@ -292,8 +292,7 @@ subprojects = [
292['emotion' ,[] , true, true, false, false, true, true, ['eina', 'efl', 'eo'], []], 292['emotion' ,[] , true, true, false, false, true, true, ['eina', 'efl', 'eo'], []],
293['ethumb' ,[] , true, true, true, false, false, false, ['eina', 'efl', 'eo'], []], 293['ethumb' ,[] , true, true, true, false, false, false, ['eina', 'efl', 'eo'], []],
294['ethumb_client' ,[] , false, true, true, false, false, true, ['eina', 'efl', 'eo', 'ethumb'], []], 294['ethumb_client' ,[] , false, true, true, false, false, true, ['eina', 'efl', 'eo', 'ethumb'], []],
295['elocation' ,[] , false, true, false, false, false, false, ['ecore', 'eldbus'], []], 295['elementary' ,[] , true, true, true, true, true, true, ['eina', 'efl', 'eo', 'eet', 'evas', 'ecore', 'ecore-evas', 'ecore-file', 'ecore-input', 'edje', 'ethumb-client', 'emotion', 'ecore-imf', 'ecore-con', 'eldbus', 'efreet', 'efreet-mime', 'efreet-trash', 'eio'], ['atspi']],
296['elementary' ,[] , true, true, true, true, true, true, ['eina', 'efl', 'eo', 'eet', 'evas', 'ecore', 'ecore-evas', 'ecore-file', 'ecore-input', 'edje', 'ethumb-client', 'emotion', 'ecore-imf', 'ecore-con', 'eldbus', 'efreet', 'efreet-mime', 'efreet-trash', 'eio', 'elocation'], ['atspi']],
297['efl_wl' ,['wl'] , false, true, true, false, false, false, ['evas', 'ecore'], []], 296['efl_wl' ,['wl'] , false, true, true, false, false, false, ['evas', 'ecore'], []],
298['elua' ,['elua'] , false, true, true, false, true, false, ['eina', 'luajit'], []], 297['elua' ,['elua'] , false, true, true, false, true, false, ['eina', 'luajit'], []],
299['ecore_wayland' ,['wl-deprecated'] , false, true, false, false, false, false, ['eina'], []], 298['ecore_wayland' ,['wl-deprecated'] , false, true, false, false, false, false, ['eina'], []],
diff --git a/src/examples/elementary/location_example_01.c b/src/examples/elementary/location_example_01.c
deleted file mode 100644
index 7b8ad6f..0000000
--- a/src/examples/elementary/location_example_01.c
+++ /dev/null
@@ -1,151 +0,0 @@
1//Compile with:
2//gcc -o location_example_01 location_example_01.c -g `pkg-config --cflags --libs elementary elocation`
3#ifndef EFL_BETA_API_SUPPORT
4# define EFL_BETA_API_SUPPORT
5#endif
6
7#include <Elementary.h>
8#ifdef ELM_ELOCATION
9#include <Elocation.h>
10#endif
11
12static Evas_Object *pos_label, *addr_label, *box, *win;
13
14#ifdef ELM_ELOCATION
15static void
16_print_position(Elocation_Position *position)
17{
18 char buffer[1024];
19
20 if (!position) return;
21 snprintf(buffer, sizeof(buffer),
22 "<b>### Position Detail ###</b><br/>"
23 "<b>GeoClue position reply with data from timestamp</b> %i<br/>"
24 "<b>Latitude:</b> %f<br/>"
25 "<b>Longitude:</b> %f<br/>"
26 "<b>Altitude:</b> %f<br/>"
27 "<b>Accuracy level:</b> %i<br/>"
28 "<b>Accuracy horizontal:</b> %f<br/>"
29 "<b>Accuracy vertical:</b> %f",
30 position->timestamp, position->latitude, position->longitude,
31 position->altitude, position->accur->level,
32 position->accur->horizontal, position->accur->vertical);
33 elm_object_text_set(pos_label, buffer);
34}
35
36static void
37_print_address(Elocation_Address *address)
38{
39 char buffer[1024];
40
41 if (!address) return;
42 snprintf(buffer, sizeof(buffer),
43 "<b>### Address Detail ###</b><br/>"
44 "<b>Address update with data from timestamp:</b> %i<br/>"
45 "<b>Country:</b> %s<br/>"
46 "<b>Countrycode:</b> %s<br/>"
47 "<b>Locality:</b> %s<br/>"
48 "<b>Postalcode:</b> %s<br/>"
49 "<b>Region:</b> %s<br/>"
50 "<b>Timezone:</b> %s<br/>"
51 "<b>Accuracy level:</b> %i<br/>"
52 "<b>Accuracy horizontal:</b> %f<br/>"
53 "<b>Accuracy vertical:</b> %f",
54 address->timestamp, address->country, address->countrycode,
55 address->locality, address->postalcode, address->region,
56 address->timezone, address->accur->level, address->accur->horizontal,
57 address->accur->vertical);
58 elm_object_text_set(addr_label, buffer);
59}
60
61static Eina_Bool
62_position_changed(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *event)
63{
64 Elocation_Position *position;
65
66 position = event;
67 _print_position(position);
68 return ECORE_CALLBACK_DONE;
69}
70
71static Eina_Bool
72_address_changed(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *event)
73{
74 Elocation_Address *address;
75
76 address = event;
77 _print_address(address);
78
79 return ECORE_CALLBACK_DONE;
80}
81#endif
82
83EAPI_MAIN int
84elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
85{
86#ifdef ELM_ELOCATION
87 Elocation_Address *address;
88 Elocation_Position *position;
89#endif
90
91 /* The program will proceed only if Ewebkit library is available. */
92 if (elm_need_elocation() == EINA_FALSE)
93 return -1;
94
95 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
96
97 win = elm_win_util_standard_add("elocation", "Elocation example");
98 elm_win_autodel_set(win, EINA_TRUE);
99
100 box = elm_box_add(win);
101 elm_win_resize_object_add(win, box);
102 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
103 evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
104
105 pos_label = elm_label_add(box);
106 elm_label_line_wrap_set(pos_label, ELM_WRAP_CHAR);
107 elm_object_text_set(pos_label, "Getting location ...");
108 evas_object_size_hint_weight_set(pos_label, EVAS_HINT_EXPAND, 0.0);
109 evas_object_size_hint_align_set(pos_label, EVAS_HINT_FILL, EVAS_HINT_FILL);
110 elm_label_slide_mode_set(pos_label, ELM_LABEL_SLIDE_MODE_ALWAYS);
111 elm_box_pack_end(box, pos_label);
112 evas_object_show(pos_label);
113 elm_box_padding_set(box, 0, 50);
114
115 addr_label = elm_label_add(box);
116 elm_label_line_wrap_set(addr_label, ELM_WRAP_CHAR);
117 elm_object_text_set(addr_label, "Getting location ...");
118 evas_object_size_hint_weight_set(addr_label, EVAS_HINT_EXPAND, 0.0);
119 evas_object_size_hint_align_set(addr_label, EVAS_HINT_FILL, EVAS_HINT_FILL);
120 elm_label_slide_mode_set(addr_label, ELM_LABEL_SLIDE_MODE_ALWAYS);
121 elm_box_pack_end(box, addr_label);
122 evas_object_show(addr_label);
123
124#ifdef ELM_ELOCATION
125 address = elocation_address_new();
126 position = elocation_position_new();
127
128 ecore_event_handler_add(ELOCATION_EVENT_POSITION, _position_changed, NULL);
129 ecore_event_handler_add(ELOCATION_EVENT_ADDRESS, _address_changed, NULL);
130
131 elocation_position_get(position);
132 _print_position(position);
133
134 elocation_address_get(address);
135 _print_address(address);
136#endif
137
138 evas_object_show(box);
139 evas_object_resize(win, 600, 480);
140 evas_object_show(win);
141
142 elm_run();
143
144#ifdef ELM_ELOCATION
145 elocation_position_free(position);
146 elocation_address_free(address);
147#endif
148
149 return 0;
150}
151ELM_MAIN()
diff --git a/src/examples/elementary/meson.build b/src/examples/elementary/meson.build
index 5348929..4b00c7b 100644
--- a/src/examples/elementary/meson.build
+++ b/src/examples/elementary/meson.build
@@ -59,7 +59,6 @@ examples = [
59 'list_example_01', 59 'list_example_01',
60 'list_example_02', 60 'list_example_02',
61 'list_example_03', 61 'list_example_03',
62 'location_example_01',
63 'map_example_01', 62 'map_example_01',
64 'map_example_02', 63 'map_example_02',
65 'map_example_03', 64 'map_example_03',
diff --git a/src/examples/elocation/.gitignore b/src/examples/elocation/.gitignore
deleted file mode 100644
index 5945c2e..0000000
--- a/src/examples/elocation/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
1/elocation
diff --git a/src/examples/elocation/elocation.c b/src/examples/elocation/elocation.c
deleted file mode 100644
index b9c8b99..0000000
--- a/src/examples/elocation/elocation.c
+++ /dev/null
@@ -1,167 +0,0 @@
1#include <stdio.h>
2
3#define EFL_BETA_API_SUPPORT
4
5#include <Ecore.h>
6#include <Elocation.h>
7
8/* A set of callbacks to react on incoming elocation events. They are standard
9 * ecore events and we register callbacks based on these events in the main
10 * function.
11 */
12static Eina_Bool
13status_changed(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *event)
14{
15 int *status = event;
16
17 printf("Status changed to: %i\n", *status);
18 printf("\n");
19
20 return ECORE_CALLBACK_DONE;
21}
22
23static Eina_Bool
24rgeocode_arrived(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *event)
25{
26 Elocation_Address *address;
27
28 address = event;
29 printf("Geocode reply:\n");
30 printf("Country: %s\n", address->country);
31 printf("Countrycode: %s\n", address->countrycode);
32 printf("Locality: %s\n", address->locality);
33 printf("Postalcode: %s\n", address->postalcode);
34 printf("Region: %s\n", address->region);
35 printf("Timezone: %s\n", address->timezone);
36 printf("Accuracy level: %i\n", address->accur->level);
37 printf("Accuracy horizontal: %f\n", address->accur->horizontal);
38 printf("Accuracy vertical: %f\n", address->accur->vertical);
39 printf("\n");
40
41 return ECORE_CALLBACK_DONE;
42}
43
44static Eina_Bool
45geocode_arrived(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *event)
46{
47 Elocation_Position *position;
48
49 position = event;
50 printf("Reverse geocode reply:\n");
51 printf("Latitude:\t %f\n", position->latitude);
52 printf("Longitude:\t %f\n", position->longitude);
53 printf("Altitude:\t %f\n", position->altitude);
54 printf("Accuracy level: %i\n", position->accur->level);
55 printf("Accuracy horizontal: %f\n", position->accur->horizontal);
56 printf("Accuracy vertical: %f\n", position->accur->vertical);
57 printf("\n");
58
59 return ECORE_CALLBACK_DONE;
60}
61
62static Eina_Bool
63address_changed(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *event)
64{
65 Elocation_Address *address;
66
67 address = event;
68 printf("Address update with data from timestamp: %i\n", address->timestamp);
69 printf("Country: %s\n", address->country);
70 printf("Countrycode: %s\n", address->countrycode);
71 printf("Locality: %s\n", address->locality);
72 printf("Postalcode: %s\n", address->postalcode);
73 printf("Region: %s\n", address->region);
74 printf("Timezone: %s\n", address->timezone);
75 printf("Accuracy level: %i\n", address->accur->level);
76 printf("Accuracy horizontal: %f\n", address->accur->horizontal);
77 printf("Accuracy vertical: %f\n", address->accur->vertical);
78 printf("\n");
79
80 return ECORE_CALLBACK_DONE;
81}
82
83static Eina_Bool
84position_changed(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *event)
85{
86 Elocation_Position *position;
87
88 position = event;
89 printf("GeoClue position reply with data from timestamp %i\n", position->timestamp);
90 printf("Latitude:\t %f\n", position->latitude);
91 printf("Longitude:\t %f\n", position->longitude);
92 printf("Altitude:\t %f\n", position->altitude);
93 printf("Accuracy level: %i\n", position->accur->level);
94 printf("Accuracy horizontal: %f\n", position->accur->horizontal);
95 printf("Accuracy vertical: %f\n", position->accur->vertical);
96 printf("\n");
97
98 return ECORE_CALLBACK_DONE;
99}
100
101int
102main(void)
103{
104 Elocation_Address *address, *addr_geocode;
105 Elocation_Position *position, *pos_geocode;
106 int status;
107
108 /* Init the needed efl subsystems so we can safely use them */
109 ecore_init();
110 eldbus_init();
111 elocation_init();
112
113 /* Create an address and positon object that we use for all our operations.
114 * Needs to be freed manually with elocation_*_free when we now longer use
115 * them */
116 address = elocation_address_new();
117 position = elocation_position_new();
118
119 /* Register callback so we get updates later on */
120 ecore_event_handler_add(ELOCATION_EVENT_STATUS, status_changed, NULL);
121 ecore_event_handler_add(ELOCATION_EVENT_POSITION, position_changed, NULL);
122 ecore_event_handler_add(ELOCATION_EVENT_ADDRESS, address_changed, NULL);
123 ecore_event_handler_add(ELOCATION_EVENT_GEOCODE, geocode_arrived, NULL);
124 ecore_event_handler_add(ELOCATION_EVENT_REVERSEGEOCODE, rgeocode_arrived, NULL);
125
126 /* To the initial request for status address and position. This fills in the
127 * objects with the data from GeoClue */
128 elocation_status_get(&status);
129 elocation_position_get(position);
130 elocation_address_get(address);
131
132 /* Another set of address and position object. This time for demonstrating
133 * the GeoCode functionalities */
134 addr_geocode = elocation_address_new();
135 pos_geocode = elocation_position_new();
136
137 /* The Freeform API could use any string to transform it into position
138 * coordinates. How good that works depends on the used GeoClue provider */
139 elocation_freeform_address_to_position("London", pos_geocode);
140
141 /* Some demo values to show the position to address conversion */
142 pos_geocode->latitude = 51.7522;
143 pos_geocode->longitude = -1.25596;
144 pos_geocode->accur->level = 3;
145 elocation_position_to_address(pos_geocode, addr_geocode);
146
147 /* And now from address to position */
148 addr_geocode->locality = "Cambridge";
149 addr_geocode->countrycode = "UK";
150 elocation_address_to_position(addr_geocode, pos_geocode);
151
152 /* Enter the mainloop now that we are setup with initial data and waiting for
153 * events. */
154 ecore_main_loop_begin();
155
156 /* Cleanup allocated memory now that we shut down */
157 elocation_address_free(addr_geocode);
158 elocation_position_free(pos_geocode);
159 elocation_address_free(address);
160 elocation_position_free(position);
161
162 /* Make sure we also shut down the initialized subsystems */
163 elocation_shutdown();
164 eldbus_shutdown();
165 ecore_shutdown();
166 return 0;
167}
diff --git a/src/lib/elementary/Elementary.h b/src/lib/elementary/Elementary.h
index cf58752..a3fa4f4 100644
--- a/src/lib/elementary/Elementary.h
+++ b/src/lib/elementary/Elementary.h
@@ -73,10 +73,6 @@
73#include <Efreet_Trash.h> 73#include <Efreet_Trash.h>
74#include <Ethumb_Client.h> 74#include <Ethumb_Client.h>
75 75
76#ifdef ELM_ELOCATION
77#include <Elocation.h>
78#endif
79
80#ifdef ELM_EMAP 76#ifdef ELM_EMAP
81#include <EMap.h> 77#include <EMap.h>
82#endif 78#endif
diff --git a/src/lib/elementary/Elementary_Options.h.in b/src/lib/elementary/Elementary_Options.h.in
index a52444d..2110b58 100644
--- a/src/lib/elementary/Elementary_Options.h.in
+++ b/src/lib/elementary/Elementary_Options.h.in
@@ -13,8 +13,4 @@
13@ELM_LIBINTL_H_DEF@ ELM_LIBINTL_H 13@ELM_LIBINTL_H_DEF@ ELM_LIBINTL_H
14@ELM_DIRENT_H_DEF@ ELM_DIRENT_H 14@ELM_DIRENT_H_DEF@ ELM_DIRENT_H
15 15
16#ifdef EFL_BETA_API_SUPPORT
17# define ELM_ELOCATION
18#endif
19
20#endif 16#endif
diff --git a/src/lib/elementary/elm_main.c b/src/lib/elementary/elm_main.c
index 069d1ce..449766d 100644
--- a/src/lib/elementary/elm_main.c
+++ b/src/lib/elementary/elm_main.c
@@ -690,30 +690,15 @@ _elm_unneed_eldbus(void)
690 eldbus_shutdown(); 690 eldbus_shutdown();
691} 691}
692 692
693#ifdef ELM_ELOCATION
694static Eina_Bool _elm_need_elocation = EINA_FALSE;
695#endif
696EAPI Eina_Bool 693EAPI Eina_Bool
697elm_need_elocation(void) 694elm_need_elocation(void)
698{ 695{
699#ifdef ELM_ELOCATION
700 if (_elm_need_elocation) return EINA_TRUE;
701 _elm_need_elocation = EINA_TRUE;
702 elocation_init();
703 return EINA_TRUE;
704#else
705 return EINA_FALSE; 696 return EINA_FALSE;
706#endif
707} 697}
708 698
709static void 699static void
710_elm_unneed_elocation(void) 700_elm_unneed_elocation(void)
711{ 701{
712#ifdef ELM_ELOCATION
713 if (!_elm_need_elocation) return;
714 _elm_need_elocation = EINA_FALSE;
715 elocation_shutdown();
716#endif
717} 702}
718 703
719static Eina_Bool _elm_need_efreet = EINA_FALSE; 704static Eina_Bool _elm_need_efreet = EINA_FALSE;
diff --git a/src/lib/elementary/meson.build b/src/lib/elementary/meson.build
index c2cd86b..5cd301d 100644
--- a/src/lib/elementary/meson.build
+++ b/src/lib/elementary/meson.build
@@ -947,7 +947,7 @@ elementary_src = [
947 947
948elementary_deps = [emile, eo, efl, edje, ethumb, ethumb_client, emotion, ecore_imf, ecore_con, eldbus, efreet, efreet_mime, efreet_trash, eio, atspi, dl, intl] 948elementary_deps = [emile, eo, efl, edje, ethumb, ethumb_client, emotion, ecore_imf, ecore_con, eldbus, efreet, efreet_mime, efreet_trash, eio, atspi, dl, intl]
949elementary_pub_deps = [eina, eet, evas, ecore, ecore_evas, ecore_file, ecore_input, ecore_imf, ecore_con, 949elementary_pub_deps = [eina, eet, evas, ecore, ecore_evas, ecore_file, ecore_input, ecore_imf, ecore_con,
950 edje, eldbus, efreet, efreet_mime, efreet_trash, ethumb_client, efl, elocation] 950 edje, eldbus, efreet, efreet_mime, efreet_trash, ethumb_client, efl]
951 951
952elm_options = configuration_data() 952elm_options = configuration_data()
953 953
@@ -962,7 +962,6 @@ else
962 elm_options.set('DLL_EXPORT', '1') 962 elm_options.set('DLL_EXPORT', '1')
963endif 963endif
964 964
965elm_options.set('ELM_ELOCATION', '1')
966elm_options.set('ELM_EFREET', '1') 965elm_options.set('ELM_EFREET', '1')
967 966
968if config_h.has('HAVE_ALLOCA_H') 967if config_h.has('HAVE_ALLOCA_H')
diff --git a/src/lib/elocation/Elocation.h b/src/lib/elocation/Elocation.h
deleted file mode 100644
index 6ebec63..0000000
--- a/src/lib/elocation/Elocation.h
+++ /dev/null
@@ -1,433 +0,0 @@
1/**
2 * @file Elocation.h
3 * @brief Elocation Library
4 *
5 * @defgroup Location Location
6 */
7
8/**
9 * @page elocation_main Elocation (BETA)
10 *
11 * @section intro Elocation Use Cases
12 *
13 * Elocation is meant as a convenience library to ease application developers
14 * the usage of geo information in their apps. Adding a geo tag to a picture or
15 * translating an address to a GPS position and show it on a map widget are just
16 * some of the use cases.
17 *
18 * In the beginning elocation will rely on the GeoClue DBus service. Its has
19 * providers for various techniques to get hold off the current position.
20 * Ranging from GeoIP over wifi and GSM cell location to GPS. As well as
21 * provider to translates between location in a textual form to coordinates
22 * (GeoCode).
23 *
24 * Elocation covers all of these interfaces but in the end it depends on your
25 * system and the installed GeoClue providers what can be used.
26 *
27 * Currently it offer the following functionality:
28 * @li Request current address in textual form
29 * @li Request current position in GPS format
30 * @li Translate a position into and address or an address in a position
31 *
32 * You can find the API documentation at @ref Location
33*/
34#ifndef _ELOCATION_H
35#define _ELOCATION_H
36
37#ifdef EAPI
38# undef EAPI
39#endif
40
41#ifdef _WIN32
42# ifdef EFL_BUILD
43# ifdef DLL_EXPORT
44# define EAPI __declspec(dllexport)
45# else
46# define EAPI
47# endif
48# else
49# define EAPI __declspec(dllimport)
50# endif
51#else
52# ifdef __GNUC__
53# if __GNUC__ >= 4
54# define EAPI __attribute__ ((visibility("default")))
55# else
56# define EAPI
57# endif
58# else
59# define EAPI
60# endif
61#endif
62
63#ifdef EFL_BETA_API_SUPPORT
64
65#include <stdio.h>
66
67#include <Ecore.h>
68#include <Eldbus.h>
69
70#ifdef __cplusplus
71extern "C" {
72#endif
73
74/**
75 * @ingroup Location
76 * @brief Available location events that are emitted from the library
77 * @since 1.13
78 *
79 * Ecore events emitted by the library. Applications can register ecore event
80 * handlers to react on such events. After the initial query this can be used
81 * to keep track of changes and update your UI or data accordingly.
82 * @{
83 */
84EAPI extern int ELOCATION_EVENT_STATUS; /**< Status changed */
85EAPI extern int ELOCATION_EVENT_POSITION; /**< Position changed */
86EAPI extern int ELOCATION_EVENT_ADDRESS; /**< Address changed */
87EAPI extern int ELOCATION_EVENT_VELOCITY; /**< Velocity changed */
88EAPI extern int ELOCATION_EVENT_GEOCODE; /**< Reply for geocode translation arrived */
89EAPI extern int ELOCATION_EVENT_REVERSEGEOCODE; /**< Reply for geocode translation arrived */
90EAPI extern int ELOCATION_EVENT_NMEA; /**< NMEA update */
91EAPI extern int ELOCATION_EVENT_SATELLITE; /**< Satellite info changed */
92EAPI extern int ELOCATION_EVENT_POI; /**< POI reply */
93EAPI extern int ELOCATION_EVENT_META_READY; /**< Meta provider is ready to be used */
94/**@}*/
95
96/**
97 * @ingroup Location
98 * @typedef Elocation_Accuracy_Level
99 * @since 1.13
100 *
101 * Different location accuracy levels from country level up to detailed,
102 * e.g. GPS, information.
103 * @{
104 */
105typedef enum {
106 ELOCATION_ACCURACY_LEVEL_NONE = 0,
107 ELOCATION_ACCURACY_LEVEL_COUNTRY = 1,
108 ELOCATION_ACCURACY_LEVEL_REGION, /* GeoClue1 only */
109 ELOCATION_ACCURACY_LEVEL_LOCALITY, /* GeoClue1 only */
110 ELOCATION_ACCURACY_LEVEL_POSTALCODE, /* GeoClue1 only */
111 ELOCATION_ACCURACY_LEVEL_CITY = 4, /* GeoClue2 only */
112 ELOCATION_ACCURACY_LEVEL_NEIGHBORHOOD = 5, /* GeoClue2 only */
113 ELOCATION_ACCURACY_LEVEL_STREET = 6,
114 ELOCATION_ACCURACY_LEVEL_DETAILED, /* GeoClue1 only */
115 ELOCATION_ACCURACY_LEVEL_EXACT = 8, /* GeoClue2 only */
116} Elocation_Accuracy_Level;
117/**@}*/
118
119/**
120 * @ingroup Location
121 * @typedef Elocation_Resource_Flags
122 * @since 1.13
123 *
124 * Flags for available system resources to be used for locating. So far they
125 * cover physical resources like network connection, cellular network
126 * connection and GPS.
127 * @{
128 */
129typedef enum {
130 ELOCATION_RESOURCE_NONE = 0,
131 ELOCATION_RESOURCE_NETWORK = 1 << 0, /**< Internet connection is available */
132 ELOCATION_RESOURCE_CELL = 1 << 1, /**< Cell network information, e.g. GSM, is available */
133 ELOCATION_RESOURCE_GPS = 1 << 2, /**< GPS information is available */
134
135 ELOCATION_RESOURCE_ALL = (1 << 10) - 1 /**< All resources are available */
136} Elocation_Resource_Flags;
137/**@}*/
138
139/**
140 * @ingroup Location
141 * @typedef Elocation_Accuracy
142 * @since 1.13
143 *
144 * Information about the accuracy of the reported location. For details about
145 * the level of accuracy see #Elocation_Accuracy_Level. It also covers
146 * horizontal and vertical accuracy. The values depend on the used provider
147 * and may very in quality.
148 */
149typedef struct _Elocation_Accuracy
150{
151 Elocation_Accuracy_Level level;
152 double horizontal;
153 double vertical;
154} Elocation_Accuracy;
155
156/**
157 * @ingroup Location
158 * @typedef Elocation_Address
159 * @since 1.13
160 *
161 * Location information in textual form. Depending on the used provider this
162 * can cover only the country or a detailed address with postcode and street.
163 * The level of detail varies depending on the used provider.
164 * A timestamp is available to calculate the age of the address data.
165 */
166typedef struct _Elocation_Address
167{
168 unsigned int timestamp; /**< Timestamp of data read out in seconds since epoch */
169 char *country;
170 char *countrycode;
171 char *locality;
172 char *postalcode;
173 char *region;
174 char *timezone;
175 Elocation_Accuracy *accur;
176} Elocation_Address;
177
178/**
179 * @ingroup Location
180 * @typedef Elocation_Position
181 * @since 1.13
182 *
183 * Location information based on the GPS grid. Latitude, longitude and altitude.
184 * A timestamp is available to calculate the age of the address data.
185 */
186typedef struct _Elocation_Position
187{
188 unsigned int timestamp; /**< Timestamp of data read out in seconds since epoch */
189 double latitude;
190 double longitude;
191 double altitude;
192 Elocation_Accuracy *accur;
193} Elocation_Position;
194
195/**
196 * @ingroup Location
197 * @typedef Elocation_Velocity
198 * @since 1.13
199 *
200 * Velocity information. So far this interface is only offered with GPS based
201 * providers. It offers information about speed, direction and climb.
202 * A timestamp is available to calculate the age of the address data.
203 *
204 * FIXME: check units and formats of this values coming in from GeoClue
205 */
206typedef struct _Elocation_Velocity
207{
208 unsigned int timestamp; /**< Timestamp of data read out in seconds since epoch */
209 double speed;
210 double direction;
211 double climb;
212} Elocation_Velocity;
213
214/**
215 * @ingroup Location
216 * @typedef Elocation_Requirements
217 * @since 1.13
218 *
219 * Requirement settings for the location provider. Requirements can be a level
220 * of accuracy or allowed resources like network access or GPS. See
221 * #Elocation_Resource_Flags for all available resource flags.
222 *
223 * Based on this setting the best provider is chosen between the available
224 * providers of GeoClue.
225 */
226typedef struct _Elocation_Requirements
227{
228 Elocation_Accuracy_Level accurancy_level;
229 int min_time; /**< Minimal time between updates. Not implemented upstream */
230 Eina_Bool require_update;
231 Elocation_Resource_Flags allowed_resources;
232} Elocation_Requirements;
233
234/**
235 * @brief Create a new address object to operate on.
236 * @return Address object.
237 *
238 * The returned address object is safe to be operated on. It can be used for
239 * all other elocation functions. Once finished with it it need to be destroyed
240 * with a call to #elocation_address_free.
241 *
242 * @ingroup Location
243 * @since 1.13
244 */
245EAPI Elocation_Address *elocation_address_new(void);
246
247/**
248 * @brief Free an address object
249 * @param address Address object to be freed.
250 *
251 * Destroys an address object created with #elocation_address_new. Should be
252 * used during the cleanup of the application or whenever the address object is
253 * no longer needed.
254 *
255 * @ingroup Location
256 * @since 1.13
257 */
258EAPI void elocation_address_free(Elocation_Address *address);
259
260/**
261 * @brief Create a new position object to operate on.
262 * @return Position object.
263 *
264 * The returned address object is safe to be operated on. It can be used for
265 * all other elocation functions. Once finished with it it need to be destroyed
266 * with a call to #elocation_address_free.
267 *
268 * @ingroup Location
269 * @since 1.13
270 */
271EAPI Elocation_Position *elocation_position_new(void);
272
273/**
274 * @brief Free an position object
275 * @param position Position object to be freed.
276 *
277 * Destroys a position object created with #elocation_address_new. Should be
278 * used during the cleanup of the application or whenever the location object is
279 * no longer needed.
280 *
281 * @ingroup Location
282 * @since 1.13
283 */
284EAPI void elocation_position_free(Elocation_Position *position);
285
286/**
287 * @brief Get the current address information.
288 * @param address Address struct to be filled with information.
289 * @return EINA_TRUE for success and EINA_FALSE for failure.
290 *
291 * Request the latest address. The requested to the underling components might
292 * be asynchronous so better check the timestamp if the data has changed. To get
293 * events when the address changes one can also subscribe to the
294 * #ELOCATION_EVENT_ADDRESS ecore event which will have the address object as
295 * event.
296 *
297 * @ingroup Location
298 * @since 1.13
299 */
300EAPI Eina_Bool elocation_address_get(Elocation_Address *address);
301
302/**
303 * @brief Get the current position information.
304 * @param position Position struct to be filled with information.
305 * @return EINA_TRUE for success and EINA_FALSE for failure.
306 *
307 * Request the latest position. The requested to the underling components might
308 * be asynchronous so better check the timestamp if the data has changed. To get
309 * events when the position changes one can also subscribe to the
310 * #ELOCATION_EVENT_POSITION ecore event which will have the position object as
311 * event.
312 *
313 * @ingroup Location
314 * @since 1.13
315 */
316EAPI Eina_Bool elocation_position_get(Elocation_Position *position);
317
318/**
319 * @brief Get the current status.
320 * @param status Status
321 * @return EINA_TRUE for success and EINA_FALSE for failure.
322 *
323 * @ingroup Location
324 * @since 1.13
325 */
326EAPI Eina_Bool elocation_status_get(int *status);
327
328/**
329 * @brief Set the requirements.
330 * @param requirements Requirements
331 * @return EINA_TRUE for success and EINA_FALSE for failure.
332 *
333 * Set the requirements for selecting a provider.
334 *
335 * @ingroup Location
336 * @since 1.13
337 */
338EAPI Eina_Bool elocation_requirements_set(Elocation_Requirements *requirements);
339
340/**
341 * @brief Convert position to address
342 * @param position_shadow Position input
343 * @param address_shadow Address output
344 * @return EINA_TRUE for success and EINA_FALSE for failure.
345 *
346 * Use a GeoCode provider to translate from a given GPS coordinate
347 * representation of a location to a representation in textual form.
348 *
349 * @ingroup Location
350 * @since 1.13
351 */
352EAPI Eina_Bool elocation_position_to_address(Elocation_Position *position_shadow, Elocation_Address *address_shadow);
353
354/**
355 * @brief Convert address to position
356 * @param address_shadow Address input
357 * @param position_shadow Position output
358 * @return EINA_TRUE for success and EINA_FALSE for failure.
359 *
360 * Use a GeoCode provider to translate from a given textual form
361 * representation of a location to a representation as GPS coordinates.
362 *
363 * @ingroup Location
364 * @since 1.13
365 */
366EAPI Eina_Bool elocation_address_to_position(Elocation_Address *address_shadow, Elocation_Position *position_shadow);
367
368/**
369 * @brief Convert free form address tring to position
370 * @param freeform_address Address string in free form
371 * @param position_shadow Position output
372 * @return EINA_TRUE for success and EINA_FALSE for failure.
373 *
374 * Similar GeoCode translation from textual form to GPS coordinates as
375 * #elocation_address_to_position but in this case the address is a simple
376 * string which hopefully contains enough information for the provider to
377 * understand and translate.
378 *
379 * Useful for an easy search interface in an application but also more error
380 * prone regarding correct results.
381 *
382 * @ingroup Location
383 * @since 1.13
384 */
385EAPI Eina_Bool elocation_freeform_address_to_position(const char *freeform_address, Elocation_Position *position_shadow);
386
387/**
388 * @brief Request a landmark position
389 * @param position_shadow Position ouput
390 * @param address_shadow Address input
391 * @return EINA_TRUE for success and EINA_FALSE for failure.
392 *
393 * Request a landmark position also known as Point Of Interest (POI) from
394 * GeoClue.
395 *
396 * @ingroup Location
397 * @since 1.13
398 */
399EAPI Eina_Bool elocation_landmarks_get(Elocation_Position *position_shadow, Elocation_Address *address_shadow);
400
401/**
402 * @brief Initialize the elocation subsystem.
403 * @return EINA_TRUE for success and EINA_FALSE for failure.
404 *
405 * This function must be called before using any of the Elocation functionality
406 * in your application to make sure it it setup correctly for usage.
407 *
408 * @ingroup Location
409 * @since 1.13
410 */
411EAPI Eina_Bool elocation_init(void);
412
413/**
414 * @brief Cleanup and shutdown the elocation subsystem.
415 *
416 * This function must be called when the application is no longer using any of
417 * the Elocation functionality to allow the subsystem to shutdown cleanly.
418 *
419 * @ingroup Location
420 * @since 1.13
421 */
422EAPI void elocation_shutdown(void);
423
424#ifdef __cplusplus
425}
426#endif
427
428#endif /* BETA API */
429
430#undef EAPI
431#define EAPI
432
433#endif
diff --git a/src/lib/elocation/elocation.c b/src/lib/elocation/elocation.c
deleted file mode 100644
index 33c77d2..0000000
--- a/src/lib/elocation/elocation.c
+++ /dev/null
@@ -1,1414 +0,0 @@
1#ifdef HAVE_CONFIG_H
2#include "config.h"
3#endif
4
5#include <stdio.h>
6
7#include <Eina.h>
8#include <Ecore.h>
9#include <Eldbus.h>
10#include <Elocation.h>
11#include <elocation_private.h>
12
13/* FIXME: These globals really need to get reduced before leaving the PROTO
14 * area.
15 */
16static char *unique_name = NULL;
17static Eldbus_Connection *conn = NULL;
18static Elocation_Provider *address_provider = NULL;
19static Elocation_Provider *position_provider = NULL;
20static Eldbus_Object *obj_meta = NULL;
21static Eldbus_Proxy *manager_master = NULL;
22static Eldbus_Proxy *meta_geoclue = NULL;
23static Eldbus_Proxy *meta_address = NULL;
24static Eldbus_Proxy *meta_position = NULL;
25static Eldbus_Proxy *meta_masterclient = NULL;
26static Eldbus_Proxy *meta_velocity = NULL;
27static Eldbus_Proxy *meta_nmea = NULL;
28static Eldbus_Proxy *meta_satellite = NULL;
29static Eldbus_Proxy *geonames_geocode = NULL;
30static Eldbus_Proxy *geonames_rgeocode = NULL;
31static Eldbus_Proxy *master_poi = NULL;
32static Elocation_Address *address = NULL;
33static Elocation_Position *position = NULL;
34static Elocation_Address *addr_geocode = NULL;
35static Elocation_Position *pos_geocode = NULL;
36static Elocation_Velocity *velocity = NULL;
37static int status = -1; /* 0 is a valid status code */
38static char nmea_sentence[256];
39
40int _elocation_log_dom = -1;
41
42/* Elocation ecore event types we provide to the application. */
43EAPI int ELOCATION_EVENT_STATUS = 0;
44EAPI int ELOCATION_EVENT_POSITION = 0;
45EAPI int ELOCATION_EVENT_ADDRESS = 0;
46EAPI int ELOCATION_EVENT_VELOCITY = 0;
47EAPI int ELOCATION_EVENT_GEOCODE = 0;
48EAPI int ELOCATION_EVENT_REVERSEGEOCODE = 0;
49EAPI int ELOCATION_EVENT_NMEA = 0;
50EAPI int ELOCATION_EVENT_SATELLITE = 0;
51EAPI int ELOCATION_EVENT_POI = 0;
52EAPI int ELOCATION_EVENT_META_READY = 0;
53
54/* Internal events */
55int ELOCATION_EVENT_IN = 0;
56int ELOCATION_EVENT_OUT = 0;
57
58static void
59_dummy_free(void *user_data EINA_UNUSED, void *func_data EINA_UNUSED)
60{
61 /* Don't free the event data after dispatching the event. We keep track of
62 * it on our own
63 */
64}
65
66/* Generic provider message unmarshaller. Used from all different provider
67 * calbacks that receive such a message
68 */
69static Eina_Bool
70unmarshall_provider(const Eldbus_Message *reply, Elocation_Provider *provider)
71{
72 char *name = NULL, *desc = NULL, *service = NULL, *path = NULL;
73
74 if (!eldbus_message_arguments_get(reply, "ssss", &name, &desc, &service, &path))
75 return EINA_FALSE;
76
77 provider->name = strdup(name);
78 provider->description = strdup(desc);
79 provider->service = strdup(service);
80 provider->path = strdup(path);
81 return EINA_TRUE;
82}
83
84static void
85meta_address_provider_info_cb(void *data, const Eldbus_Message *reply, Eldbus_Pending *pending EINA_UNUSED)
86{
87 const char *err, *errmsg;
88 Elocation_Provider *addr_provider;
89
90 addr_provider = data;
91
92 if (eldbus_message_error_get(reply, &err, &errmsg))
93 {
94 ERR("Error: %s %s", err, errmsg);
95 return;
96 }
97
98 if (!unmarshall_provider(reply, addr_provider))
99 {
100 ERR("Error: Unable to unmarshall address provider");
101 return;
102 }
103
104 DBG("Meta address provider name: %s, %s, %s, %s", addr_provider->name,
105 addr_provider->description,
106 addr_provider->service,
107 addr_provider->path);
108}
109
110static void
111meta_position_provider_info_cb(void *data, const Eldbus_Message *reply, Eldbus_Pending *pending EINA_UNUSED)
112{
113 const char *err, *errmsg;
114 Elocation_Provider *pos_provider;
115
116 pos_provider = data;
117
118 if (eldbus_message_error_get(reply, &err, &errmsg))
119 {
120 ERR("Error: %s %s", err, errmsg);
121 return;
122 }
123
124 if (!unmarshall_provider(reply, pos_provider))
125 {
126 ERR("Error: Unable to unmarshall position provider");
127 return;
128 }
129
130 DBG("Meta position provider name: %s, %s, %s, %s", pos_provider->name,
131 pos_provider->description,
132 pos_provider->service,
133 pos_provider->path);
134}
135
136static void
137meta_address_provider_info_signal_cb(void *data, const Eldbus_Message *reply)
138{
139 Elocation_Provider *addr_provider;
140 addr_provider = data;
141
142 if (!unmarshall_provider(reply, addr_provider))
143 {
144 ERR("Error: Unable to unmarshall address provider");
145 return;
146 }
147
148 DBG("Meta address provider name changed: %s, %s, %s, %s", addr_provider->name,
149 addr_provider->description,
150 addr_provider->service,
151 addr_provider->path);
152}
153
154static void
155meta_position_provider_info_signal_cb(void *data, const Eldbus_Message *reply)
156{
157 Elocation_Provider *pos_provider;
158 pos_provider = data;
159
160 if (!unmarshall_provider(reply, pos_provider))
161 {
162 ERR("Error: Unable to unmarshall position provider");
163 return;
164 }
165
166 DBG("Meta position provider name changed: %s, %s, %s, %s", pos_provider->name,
167 pos_provider->description,
168 pos_provider->service,
169 pos_provider->path);
170}
171
172/* A address is quite flexible what kind of key value pairs it contains in the
173 * dict. Similar to a reverse GeoCode message as both return an address object.
174 */
175static Eina_Bool
176unmarshall_address(const Eldbus_Message *reply, Elocation_Address *addr)
177{
178 int32_t level, timestamp;
179 Eldbus_Message_Iter *sub, *dict, *entry;
180 double horizontal;
181 double vertical;
182 const char *key, *signature;
183 char *value;
184
185 signature = eldbus_message_signature_get(reply);
186
187 if (!strcmp(signature, "ia{ss}(idd)"))
188 {
189 if (!eldbus_message_arguments_get(reply, "ia{ss}(idd)", &timestamp, &dict, &sub))
190 return EINA_FALSE;
191 addr->timestamp = timestamp;
192 }
193 else if (!strcmp(signature, "a{ss}(idd)"))
194 {
195 if (!eldbus_message_arguments_get(reply, "a{ss}(idd)", &dict, &sub))
196 return EINA_FALSE;
197 addr->timestamp = 0;
198 }
199 else
200 return EINA_FALSE;
201
202
203 /* Cleanup potential old entries before re-using */
204 addr->country = NULL;
205 addr->countrycode = NULL;
206 addr->locality = NULL;
207 addr->postalcode = NULL;
208 addr->region = NULL;
209 addr->timezone = NULL;
210
211 while (eldbus_message_iter_get_and_next(dict, 'e', &entry))
212 {
213 if (!eldbus_message_iter_arguments_get(entry, "ss", &key, &value))
214 continue;
215
216 if (!strcmp(key, "country"))
217 {
218 free(addr->country);
219 addr->country = strdup(value);
220 }
221 else if (!strcmp(key, "countrycode"))
222 {
223 free(addr->countrycode);
224 addr->countrycode = strdup(value);
225 }
226 else if (!strcmp(key, "locality"))
227 {
228 free(addr->locality);
229 addr->locality = strdup(value);
230 }
231 else if (!strcmp(key, "postalcode"))
232 {
233 free(addr->postalcode);
234 addr->postalcode = strdup(value);
235 }
236 else if (!strcmp(key, "region"))
237 {
238 free(addr->region);
239 addr->region = strdup(value);
240 }
241 else if (!strcmp(key, "timezone"))
242 {
243 free(addr->timezone);
244 addr->timezone = strdup(value);
245 }
246 }
247
248 if (!eldbus_message_iter_arguments_get(sub, "idd", &level, &horizontal, &vertical))
249 return EINA_FALSE;
250
251 addr->accur->level = level;
252 addr->accur->horizontal = horizontal;
253 addr->accur->vertical = vertical;
254 return EINA_TRUE;
255}
256
257/* Receive and unmarshall a reverse GeoCode message. The dict can contain a
258 * variable set of key value pairs so we need to handle this with care
259 */
260static void
261rgeocode_cb(void *data EINA_UNUSED, const Eldbus_Message *reply, Eldbus_Pending *pending EINA_UNUSED)
262{
263 const char *err, *errmsg;
264
265 if (eldbus_message_error_get(reply, &err, &errmsg))
266 {
267 ERR("Error: %s %s", err, errmsg);
268 return;
269 }
270
271 if (!unmarshall_address(reply, addr_geocode))
272 {
273 ERR("Error: Unable to unmarshall address");
274 return;
275 }
276
277 /* Send out an event to all interested parties that we have an update */
278 ecore_event_add(ELOCATION_EVENT_REVERSEGEOCODE, addr_geocode, _dummy_free, NULL);
279}
280
281/* Point of Interest (POI) aka landmark message unmarshalling. Thsi interface is
282 * not in standard GeoClue but currently a Tizen extension.
283 */
284static void
285poi_cb(void *data EINA_UNUSED, const Eldbus_Message *reply, Eldbus_Pending *pending EINA_UNUSED)
286{
287 int32_t count, id, rank;
288 double lat, lon, bound_left, bound_top, bound_right, bound_bottom;
289 const char *name, *icon, *house, *road, *village, *suburb, *postcode;
290 const char *city, *county, *country, *country_code;
291 Eldbus_Message_Iter *array, *struct_landmark;
292 const char *err, *errmsg;
293
294 if (eldbus_message_error_get(reply, &err, &errmsg))
295 {
296 ERR("Error: %s %s", err, errmsg);
297 return;
298 }
299
300 /* Yeah, its quite a horrible message. The POI interface could use a better design */
301 if (!eldbus_message_arguments_get(reply, "ia(iiddddddsssssssssss", &count ,&array))
302 return;
303
304 /* TODO re-check that the parameter ordering is what we expect */
305 while (eldbus_message_iter_get_and_next(array, 'r', &struct_landmark))
306 {
307 if (!eldbus_message_iter_arguments_get(struct_landmark, "iiddddddsssssssssss", &id, &rank,
308 &lat, &lon, &bound_left, &bound_top, &bound_right,
309 &bound_bottom, &name, &icon, &house, &road,
310 &village, &suburb, &postcode, &city, &county,
311 &country, &country_code))
312 return;
313
314 DBG("Landmark received: %i, %i, %f, %f, %f, %f, %f, %f, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,",
315 id, rank, lat, lon, bound_left, bound_top, bound_right,
316 bound_bottom, name, icon, house, road, village,
317 suburb, postcode, city, county, country, country_code);
318 }
319
320 /* Send out an event to all interested parties that we have an update */
321 ecore_event_add(ELOCATION_EVENT_POI, NULL, _dummy_free, NULL);
322}
323
324/* Unmarshall a GeoCode message */
325static void
326geocode_cb(void *data EINA_UNUSED, const Eldbus_Message *reply, Eldbus_Pending *pending EINA_UNUSED)
327{
328 GeocluePositionFields fields;
329 int32_t level;
330 double horizontal = 0.0;
331 double vertical = 0.0;
332 double latitude = 0.0;
333 double longitude = 0.0;
334 double altitude = 0.0;
335 Eldbus_Message_Iter *sub;
336 const char *err, *errmsg;
337
338 if (eldbus_message_error_get(reply, &err, &errmsg))
339 {
340 ERR("Error: %s %s", err, errmsg);
341 return;
342 }
343
344 if (!eldbus_message_arguments_get(reply, "iddd(idd)", &fields,&latitude,
345 &longitude, &altitude, &sub))
346 return;
347
348 /* GeoClue uses some flags to mark position fields as valid. We set invalid
349 * fields to 0.0 */
350 if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE)
351 pos_geocode->latitude = latitude;
352 else
353 pos_geocode->latitude = 0.0;
354
355 if (fields & GEOCLUE_POSITION_FIELDS_LONGITUDE)
356 pos_geocode->longitude = longitude;
357 else
358 pos_geocode->longitude = 0.0;
359
360 if (fields & GEOCLUE_POSITION_FIELDS_ALTITUDE)
361 pos_geocode->altitude = altitude;
362 else
363 pos_geocode->altitude = 0.0;
364
365 if (!eldbus_message_iter_arguments_get(sub, "idd", &level, &horizontal, &vertical))
366 return;
367
368 pos_geocode->accur->level = level;
369 pos_geocode->accur->horizontal = horizontal;
370 pos_geocode->accur->vertical = vertical;
371 /* Send out an event to all interested parties that we have an update */
372 ecore_event_add(ELOCATION_EVENT_GEOCODE, pos_geocode, _dummy_free, NULL);
373}
374
375static void
376address_cb(void *data EINA_UNUSED, const Eldbus_Message *reply, Eldbus_Pending *pending EINA_UNUSED)
377{
378 const char *err, *errmsg;
379
380 if (eldbus_message_error_get(reply, &err, &errmsg))
381 {
382 ERR("Error: %s %s", err, errmsg);
383 return;
384 }
385
386 if (!unmarshall_address(reply, address))
387 {
388 ERR("Error: Unable to unmarshall address");
389 return;
390 }
391
392 /* Send out an event to all interested parties that we have an update */
393 ecore_event_add(ELOCATION_EVENT_ADDRESS, address, _dummy_free, NULL);
394}
395
396static void
397address_signal_cb(void *data EINA_UNUSED, const Eldbus_Message *reply)
398{
399 const char *err, *errmsg;
400
401 if (eldbus_message_error_get(reply, &err, &errmsg))
402 {
403 ERR("Error: %s %s", err, errmsg);
404 return;
405 }
406
407 if (!unmarshall_address(reply, address))
408 {
409 ERR("Error: Unable to unmarshall address");
410 return;
411 }
412
413 /* Send out an event to all interested parties that we have an update */
414 ecore_event_add(ELOCATION_EVENT_ADDRESS, address, _dummy_free, NULL);
415}
416
417/* Unmarshall a velocity message. This is only available if we use a GPS
418 * provider from GeoClue. None of the other providers offer this currently.
419 */
420static Eina_Bool
421unmarshall_velocity(const Eldbus_Message *reply)
422{
423 GeoclueVelocityFields fields;
424 int32_t timestamp = 0;
425 double speed = 0.0;
426 double direction = 0.0;
427 double climb = 0.0;
428
429 if (!eldbus_message_arguments_get(reply, "iiddd", &fields, &timestamp,
430 &speed, &direction, &climb))
431 return EINA_FALSE;
432
433 velocity->timestamp = timestamp;
434
435 /* GeoClue uses some flags to mark velocity fields as valid. We set invalid
436 * fields to 0.0 */
437 if (fields & GEOCLUE_VELOCITY_FIELDS_SPEED)
438 velocity->speed = speed;
439 else
440 velocity->speed = 0.0;
441
442 if (fields & GEOCLUE_VELOCITY_FIELDS_DIRECTION)
443 velocity->direction = direction;
444 else
445 velocity->direction = 0.0;
446
447 if (fields & GEOCLUE_VELOCITY_FIELDS_CLIMB)
448 velocity->climb = climb;
449 else
450 velocity->climb = 0.0;
451
452 return EINA_TRUE;
453}
454
455static void
456velocity_cb(void *data EINA_UNUSED, const Eldbus_Message *reply, Eldbus_Pending *pending EINA_UNUSED)
457{
458 const char *err, *errmsg;
459
460 if (eldbus_message_error_get(reply, &err, &errmsg))
461 {
462 WARN("Warning: %s %s", err, errmsg);
463 return;
464 }
465
466 if (!unmarshall_velocity(reply))
467 {
468 ERR("Error: Unable to unmarshall velocity");
469 return;
470 }
471
472 /* Send out an event to all interested parties that we have an update */
473 ecore_event_add(ELOCATION_EVENT_VELOCITY, velocity, _dummy_free, NULL);
474}
475
476static void
477velocity_signal_cb(void *data EINA_UNUSED, const Eldbus_Message *reply)
478{
479 if (!unmarshall_velocity(reply))
480 {
481 ERR("Error: Unable to unmarshall velocity");
482 return;
483 }
484
485 /* Send out an event to all interested parties that we have an update */
486 ecore_event_add(ELOCATION_EVENT_VELOCITY, velocity, _dummy_free, NULL);
487}
488
489/* Unmarshall an raw NMEA message. It conatins a raw NMEA sentence which we can
490 * pass on to applications that want to use their own NMEA parser. This is not
491 * reommended. Better use the other interfaces to access the needed data.
492 *
493 * This is currently a Tizen only interface and not in GeoClue upstream.
494 */
495static Eina_Bool
496unmarshall_nmea(const Eldbus_Message *reply)
497{
498 int32_t timestamp = 0;
499
500 if (!eldbus_message_arguments_get(reply, "is", &timestamp, &nmea_sentence))
501 return EINA_FALSE;
502
503 return EINA_TRUE;
504}
505
506static void
507nmea_cb(void *data EINA_UNUSED, const Eldbus_Message *reply, Eldbus_Pending *pending EINA_UNUSED)
508{
509 const char *err, *errmsg;
510
511 if (eldbus_message_error_get(reply, &err, &errmsg))
512 {
513 WARN("Warning: %s %s", err, errmsg);
514 return;
515 }
516
517 if (!unmarshall_nmea(reply))
518 {
519 ERR("Error: Unable to unmarshall nmea");
520 return;
521 }
522
523 /* Send out an event to all interested parties that we have an update */
524 ecore_event_add(ELOCATION_EVENT_NMEA, nmea_sentence, _dummy_free, NULL);
525}
526
527static void
528nmea_signal_cb(void *data EINA_UNUSED, const Eldbus_Message *reply)
529{
530 if (!unmarshall_nmea(reply))
531 {
532 ERR("Error: Unable to unmarshall nmea");
533 return;
534 }
535
536 ecore_event_add(ELOCATION_EVENT_NMEA, nmea_sentence, _dummy_free, NULL);
537}
538
539/* Unmarshall a satellite information message. This offers GPS specific
540 * information about the used satellites and its properties. It can be used for
541 * applications that rely on GPS and want to show more information like a 3D fix
542 * or used satellites.
543 *
544 * This is currently a Tizen only interface and not available in GeoClue upstream.
545 */
546static Eina_Bool
547unmarshall_satellite(const Eldbus_Message *reply)
548{
549 int32_t timestamp = 0, satellite_used = 0, satellite_visible = 0;
550 int32_t snr = 0, elevation = 0, azimuth = 0, prn = 0, used_prn = 0;
551 Eldbus_Message_Iter *sub_prn, *sub_info, *struct_info;
552
553 if (!eldbus_message_arguments_get(reply, "iiiaia(iiii)", &timestamp, &satellite_used,
554 &satellite_visible, &sub_prn, &sub_info))
555 return EINA_FALSE;
556
557 while (eldbus_message_iter_get_and_next(sub_prn, 'i', &used_prn))
558 {
559 DBG("Satellite used PRN %i", used_prn);
560 }
561
562 /* TODO re-check that the parameter ordering is what we expect */
563 while (eldbus_message_iter_get_and_next(sub_info, 'r', &struct_info))
564 {
565 if (!eldbus_message_iter_arguments_get(struct_info, "iiii", &prn, &elevation, &azimuth, &snr))
566 return EINA_FALSE;
567
568 DBG("Satellite info %i, %i, %i, %i", prn, elevation, azimuth, snr);
569 }
570
571 return EINA_TRUE;
572}
573
574static void
575satellite_cb(void *data EINA_UNUSED, const Eldbus_Message *reply, Eldbus_Pending *pending EINA_UNUSED)
576{
577 const char *err, *errmsg;
578
579 if (eldbus_message_error_get(reply, &err, &errmsg))
580 {
581 WARN("Warning: %s %s", err, errmsg);
582 return;
583 }
584
585 if (!unmarshall_satellite(reply))
586 {
587 ERR("Error: Unable to unmarshall satellite");
588 return;
589 }
590
591 /* Send out an event to all interested parties that we have an update */
592 ecore_event_add(ELOCATION_EVENT_SATELLITE, NULL, _dummy_free, NULL);
593}
594
595static void
596last_satellite_cb(void *data EINA_UNUSED, const Eldbus_Message *reply, Eldbus_Pending *pending EINA_UNUSED)
597{
598 const char *err, *errmsg;
599
600 if (eldbus_message_error_get(reply, &err, &errmsg))
601 {
602 WARN("Warning: %s %s", err, errmsg);
603 return;
604 }
605
606 if (!unmarshall_satellite(reply))
607 {
608 ERR("Error: Unable to unmarshall last satellite");
609 return;
610 }
611
612 /* Send out an event to all interested parties that we have an update */
613 ecore_event_add(ELOCATION_EVENT_SATELLITE, NULL, _dummy_free, NULL);
614}
615
616static void
617satellite_signal_cb(void *data EINA_UNUSED, const Eldbus_Message *reply)
618{
619 if (!unmarshall_satellite(reply))
620 {
621 ERR("Error: Unable to unmarshall satellite");
622 return;
623 }
624
625 /* Send out an event to all interested parties that we have an update */
626 ecore_event_add(ELOCATION_EVENT_SATELLITE, NULL, _dummy_free, NULL);
627}
628
629/* Unmarshall position coordination message */
630static Eina_Bool
631unmarshall_position(const Eldbus_Message *reply)
632{
633 GeocluePositionFields fields;
634 int32_t level, timestamp;
635 double horizontal = 0.0;
636 double vertical = 0.0;
637 double latitude = 0.0;
638 double longitude = 0.0;
639 double altitude = 0.0;
640 Eldbus_Message_Iter *sub;
641
642 if (!eldbus_message_arguments_get(reply, "iiddd(idd)", &fields, &timestamp,
643 &latitude, &longitude, &altitude, &sub))
644 return EINA_FALSE;
645
646 if (!eldbus_message_iter_arguments_get(sub, "idd", &level, &horizontal, &vertical))
647 return EINA_FALSE;
648
649 position->timestamp = timestamp;
650
651 /* GeoClue uses some flags to mark position fields as valid. We set invalid
652 * fields to 0.0 */
653 if (fields & GEOCLUE_POSITION_FIELDS_LATITUDE)
654 position->latitude = latitude;
655 else
656 position->latitude = 0.0;
657
658 if (fields & GEOCLUE_POSITION_FIELDS_LONGITUDE)
659 position->longitude = longitude;
660 else
661 position->longitude = 0.0;
662
663 if (fields & GEOCLUE_POSITION_FIELDS_ALTITUDE)
664 position->altitude = altitude;
665 else
666 position->altitude = 0.0;
667
668 position->accur->level = level;
669 position->accur->horizontal = horizontal;
670 position->accur->vertical = vertical;
671
672 return EINA_TRUE;
673}
674
675static void
676position_cb(void *data EINA_UNUSED, const Eldbus_Message *reply, Eldbus_Pending *pending EINA_UNUSED)
677{
678 const char *err, *errmsg;
679
680 if (eldbus_message_error_get(reply, &err, &errmsg))
681 {
682 ERR("Error: %s %s", err, errmsg);
683 return;
684 }
685
686 if (!unmarshall_position(reply))
687 {
688 ERR("Error: Unable to unmarshall position");
689 return;
690 }
691
692 /* Send out an event to all interested parties that we have an update */
693 ecore_event_add(ELOCATION_EVENT_POSITION, position, _dummy_free, NULL);
694}
695
696static void
697position_signal_cb(void *data EINA_UNUSED, const Eldbus_Message *reply)
698{
699 if (!unmarshall_position(reply))
700 {
701 ERR("Error: Unable to unmarshall position");
702 return;
703 }
704
705 /* Send out an event to all interested parties that we have an update */
706 ecore_event_add(ELOCATION_EVENT_POSITION, position, _dummy_free, NULL);
707}
708
709static Eina_Bool
710geoclue_start(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *event EINA_UNUSED)
711{
712 DBG("GeoClue start event at %s", unique_name);
713 return ECORE_CALLBACK_DONE;
714}
715
716static Eina_Bool
717geoclue_stop(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *event EINA_UNUSED)
718{
719 DBG("GeoClue stop event");
720 return ECORE_CALLBACK_DONE;
721}
722
723static void
724_reference_add_cb(void *data EINA_UNUSED, const Eldbus_Message *reply, Eldbus_Pending *pending EINA_UNUSED)
725{
726 const char *err, *errmsg;
727
728 if (eldbus_message_error_get(reply, &err, &errmsg))
729 {
730 ERR("Error: %s %s", err, errmsg);
731 return;
732 }
733
734 DBG("Reference added");
735}
736
737static void
738_reference_del_cb(void *data EINA_UNUSED, const Eldbus_Message *reply EINA_UNUSED, Eldbus_Pending *pending EINA_UNUSED)
739{
740 /* Dummy callback. We are not waiting for any reply here on shutdown */
741}
742
743static void
744status_cb(void *data EINA_UNUSED, const Eldbus_Message *reply, Eldbus_Pending *pending EINA_UNUSED)
745{
746 const char *err, *errmsg;
747
748 if (eldbus_message_error_get(reply, &err, &errmsg))
749 {
750 ERR("Error: %s %s", err, errmsg);
751 return;
752 }
753
754 if (!eldbus_message_arguments_get(reply,"i", &status))
755 {
756 ERR("Error: Unable to unmarshall status");
757 return;
758 }
759
760 address_provider->status = position_provider->status = status;
761 /* Send out an event to all interested parties that we have an update */
762 ecore_event_add(ELOCATION_EVENT_STATUS, &status, _dummy_free, NULL);
763}
764
765static void
766status_signal_cb(void *data EINA_UNUSED, const Eldbus_Message *reply)
767{
768 if (!eldbus_message_arguments_get(reply,"i", &status))
769 {
770 ERR("Error: Unable to unmarshall status");
771 return;
772 }
773
774 address_provider->status = position_provider->status = status;
775 /* Send out an event to all interested parties that we have an update */
776 ecore_event_add(ELOCATION_EVENT_STATUS, &status, _dummy_free, NULL);
777}
778
779static void
780_dummy_cb(void *data EINA_UNUSED, const Eldbus_Message *msg EINA_UNUSED, Eldbus_Pending *pending EINA_UNUSED)
781{
782}
783
784/* We got notified from GeoClue that the meta-provider we asked for is now
785 * ready. That means we can finish up our initialization and set up all
786 * callbacks and handling for the interfaces we use on the meta-provider.
787 *
788 * We also call the interfaces to get an initial set of data that we can provide
789 * to eager aplications.
790 */
791static void
792create_cb(void *data EINA_UNUSED, const Eldbus_Message *reply, Eldbus_Pending *pending EINA_UNUSED)
793{
794 const char *object_path;
795 Eina_Bool updates;
796 int accur_level, min_time, resources;
797 const char *err, *errmsg;
798
799 if (eldbus_message_error_get(reply, &err, &errmsg))
800 {
801 ERR("Error: %s %s", err, errmsg);
802 return;
803 }
804
805 if (!eldbus_message_arguments_get(reply, "o", &object_path)) return;
806
807 DBG("Object path for client: %s", object_path);
808
809 /* With the created object path we now have a meta provider we can operate on.
810 * Geoclue handles the selection of the best provider internally for the meta
811 * provider */
812 obj_meta = eldbus_object_get(conn, GEOCLUE_DBUS_NAME, object_path);
813 if (!obj_meta)
814 {
815 ERR("Error: could not get object for client");
816 return;
817 }
818
819 meta_geoclue = eldbus_proxy_get(obj_meta, GEOCLUE_GEOCLUE_IFACE);
820 if (!meta_geoclue)
821 {
822 ERR("Error: could not get proxy for geoclue");
823 return;
824 }
825
826 meta_address = eldbus_proxy_get(obj_meta, GEOCLUE_ADDRESS_IFACE);
827 if (!meta_address)
828 {
829 ERR("Error: could not get proxy address");
830 return;
831 }
832
833 meta_position = eldbus_proxy_get(obj_meta, GEOCLUE_POSITION_IFACE);
834 if (!meta_position)
835 {
836 ERR("Error: could not get proxy for position");
837 return;
838 }
839
840 meta_masterclient = eldbus_proxy_get(obj_meta, GEOCLUE_MASTERCLIENT_IFACE);
841 if (!meta_masterclient)
842 {
843 ERR("Error: could not get proxy for master client");
844 return;
845 }
846
847 meta_velocity = eldbus_proxy_get(obj_meta, GEOCLUE_VELOCITY_IFACE);
848 if (!meta_velocity)
849 {
850 ERR("Error: could not get proxy for velocity");
851 return;
852 }
853
854 meta_nmea = eldbus_proxy_get(obj_meta, GEOCLUE_NMEA_IFACE);
855 if (!meta_nmea)
856 {
857 ERR("Error: could not get proxy for nmea");
858 return;
859 }
860
861 meta_satellite = eldbus_proxy_get(obj_meta, GEOCLUE_SATELLITE_IFACE);
862 if (!meta_satellite)
863 {
864 ERR("Error: could not get proxy for satellite");
865 return;
866 }
867
868 /* Send Geoclue a set of requirements we have for the provider and start the address and position
869 * meta provider afterwards. After this we should be ready for operation. */
870 updates = EINA_FALSE; /* Especially the web providers do not offer updates */
871 accur_level = ELOCATION_ACCURACY_LEVEL_COUNTRY;
872 min_time = 0; /* Minimal times between updates (no implemented yet) */
873 resources = ELOCATION_RESOURCE_ALL;
874
875 eldbus_proxy_signal_handler_add(meta_masterclient, "AddressProviderChanged",
876 meta_address_provider_info_signal_cb, address_provider);
877 eldbus_proxy_signal_handler_add(meta_masterclient, "PositionProviderChanged",
878 meta_position_provider_info_signal_cb, position_provider);
879
880 if (!eldbus_proxy_call(meta_masterclient, "SetRequirements", _dummy_cb, NULL, -1, "iibi",
881 accur_level, min_time, updates, resources))
882 {
883 ERR("Error: could not call SetRequirements");
884 return;
885 }
886
887 if (!eldbus_proxy_call(meta_masterclient, "AddressStart", _dummy_cb, NULL, -1, ""))
888 {
889 ERR("Error: could not call AddressStart");
890 return;
891 }
892
893 if (!eldbus_proxy_call(meta_masterclient, "PositionStart", _dummy_cb, NULL, -1, ""))
894 {
895 ERR("Error: could not call PositionStart");
896 return;
897 }
898
899 if (!eldbus_proxy_call(meta_geoclue, "AddReference", _reference_add_cb, NULL, -1, ""))
900 {
901 ERR("Error: could not call AddReference");
902 return;
903 }
904
905 if (!eldbus_proxy_call(meta_address, "GetAddress", address_cb, NULL, -1, ""))
906 {
907 ERR("Error: could not call GetAddress");
908 return;
909 }
910
911 if (!eldbus_proxy_call(meta_position, "GetPosition", position_cb, NULL, -1, ""))
912 {
913 ERR("Error: could not call GetPosition");
914 return;
915 }
916
917 if (!eldbus_proxy_call(meta_geoclue, "GetStatus", status_cb, NULL, -1, ""))
918 {
919 ERR("Error: could not call GetStatus");
920 return;
921 }
922
923 if (!eldbus_proxy_call(meta_velocity, "GetVelocity", velocity_cb, NULL, -1, ""))
924 {
925 ERR("Error: could not call GetVelocity");
926 return;
927 }
928
929 if (!eldbus_proxy_call(meta_nmea, "GetNmea", nmea_cb, NULL, -1, ""))
930 {
931 ERR("Error: could not call GetNmea");
932 return;
933 }
934
935 if (!eldbus_proxy_call(meta_satellite, "GetSatellite", satellite_cb, NULL, -1, ""))
936 {
937 ERR("Error: could not call GetSatellite");
938 return;
939 }
940
941 if (!eldbus_proxy_call(meta_satellite, "GetLastSatellite", last_satellite_cb, NULL, -1, ""))
942 {
943 ERR("Error: could not call GetLastSatellite");
944 return;
945 }
946
947 if (!eldbus_proxy_call(meta_masterclient, "GetAddressProvider", meta_address_provider_info_cb,
948 address_provider, -1, ""))
949 {
950 ERR("Error: could not call GetAddressProvider");
951 return;
952 }
953
954 if (!eldbus_proxy_call(meta_masterclient, "GetPositionProvider", meta_position_provider_info_cb,
955 position_provider, -1, ""))
956 {
957 ERR("Error: could not call GetPositionProvider");
958 return;
959 }
960
961 eldbus_proxy_signal_handler_add(meta_address, "AddressChanged", address_signal_cb, NULL);
962 eldbus_proxy_signal_handler_add(meta_position, "PositionChanged", position_signal_cb, NULL);
963 eldbus_proxy_signal_handler_add(meta_geoclue, "StatusChanged", status_signal_cb, NULL);
964 eldbus_proxy_signal_handler_add(meta_velocity, "VelocityChanged", velocity_signal_cb, NULL);
965 eldbus_proxy_signal_handler_add(meta_nmea, "NmeaChanged", nmea_signal_cb, NULL);
966 eldbus_proxy_signal_handler_add(meta_satellite, "SatelliteChanged", satellite_signal_cb, NULL);
967
968 ecore_event_add(ELOCATION_EVENT_META_READY, NULL, NULL, NULL);
969}
970
971static void
972_name_owner_changed(void *data EINA_UNUSED, const char *bus EINA_UNUSED, const char *old, const char *new)
973{
974 if (old[0] == '\0' && new[0] != '\0')
975 {
976 ecore_event_add(ELOCATION_EVENT_IN, NULL, NULL, NULL);
977 unique_name = strdup(new);
978 }
979 else if (old[0] != '\0' && new[0] == '\0')
980 {
981 if (strcmp(unique_name, old) != 0)
982 WARN("%s was not the known name %s, ignored.", old, unique_name);
983 else
984 ecore_event_add(ELOCATION_EVENT_OUT, NULL, NULL, NULL);
985 }
986 else
987 {
988 DBG("unknown change from %s to %s", old, new);
989 }
990}
991
992/* Public API function to request a landmarks position based on an address object */
993EAPI Eina_Bool
994elocation_landmarks_get(Elocation_Position *position_shadow EINA_UNUSED, Elocation_Address *address_shadow EINA_UNUSED)
995{
996 Eldbus_Message *msg;
997 Eldbus_Message_Iter *iter;
998 const char *keyword = NULL, *lang = NULL, *country_code = NULL;
999 int limit = 0;
1000 double left= 0.0, top = 0.0, right = 0.0, bottom = 0.0;
1001
1002 msg = eldbus_proxy_method_call_new(master_poi, "SearchByPosition");
1003 iter = eldbus_message_iter_get(msg);
1004 eldbus_message_iter_basic_append(iter, 's', keyword);
1005 eldbus_message_iter_basic_append(iter, 's', lang);
1006 eldbus_message_iter_basic_append(iter, 's', country_code);
1007 eldbus_message_iter_basic_append(iter, 'i', limit);
1008 eldbus_message_iter_basic_append(iter, 'd', left);
1009 eldbus_message_iter_basic_append(iter, 'd', top);
1010 eldbus_message_iter_basic_append(iter, 'd', right);
1011 eldbus_message_iter_basic_append(iter, 'd', bottom);
1012 if (!eldbus_proxy_send(master_poi, msg, poi_cb, NULL, -1))
1013 {
1014 ERR("Error: could not call SearchByPosition");
1015 eldbus_message_unref(msg);
1016 return EINA_FALSE;
1017 }
1018
1019 return EINA_TRUE;
1020}
1021
1022/* Public API function to get an address from a position */
1023EAPI Eina_Bool
1024elocation_position_to_address(Elocation_Position *position_shadow, Elocation_Address *address_shadow EINA_UNUSED)
1025{
1026 Eldbus_Message *msg;
1027 Eldbus_Message_Iter *iter, *structure;
1028
1029 msg = eldbus_proxy_method_call_new(geonames_rgeocode, "PositionToAddress");
1030 iter = eldbus_message_iter_get(msg);
1031 eldbus_message_iter_basic_append(iter, 'd', position_shadow->latitude);
1032 eldbus_message_iter_basic_append(iter, 'd', position_shadow->longitude);
1033 structure = eldbus_message_iter_container_new(iter, 'r', NULL);
1034 eldbus_message_iter_basic_append(structure, 'i', position_shadow->accur->level);
1035 eldbus_message_iter_basic_append(structure, 'd', position_shadow->accur->horizontal);
1036 eldbus_message_iter_basic_append(structure, 'd', position_shadow->accur->vertical);
1037 eldbus_message_iter_container_close(iter, structure);
1038 if (!eldbus_proxy_send(geonames_rgeocode, msg, rgeocode_cb, NULL, -1))
1039 {
1040 ERR("Error: could not call PositionToAddress");
1041 eldbus_message_unref(msg);
1042 return EINA_FALSE;
1043 }
1044
1045 return EINA_TRUE;
1046}
1047
1048/* Public API function to get a position from and address */
1049EAPI Eina_Bool
1050elocation_address_to_position(Elocation_Address *address_shadow, Elocation_Position *position_shadow EINA_UNUSED)
1051{
1052 Eldbus_Message *msg;
1053 Eldbus_Message_Iter *iter, *array;
1054
1055 /* In function macro to generate a key value pair structure for the dict */
1056 #define ENTRY(key) { #key, address_shadow->key }
1057 struct keyval {
1058 const char *key;
1059 const char *val;
1060 } keyval[] = {
1061 ENTRY(country),
1062 ENTRY(countrycode),
1063 ENTRY(locality),
1064 ENTRY(postalcode),
1065 ENTRY(region),
1066 ENTRY(timezone),
1067 { NULL, NULL }
1068 };
1069 #undef ENTRY
1070
1071 struct keyval *k;
1072
1073 msg = eldbus_proxy_method_call_new(geonames_geocode, "AddressToPosition");
1074 iter = eldbus_message_iter_get(msg);
1075
1076 array = eldbus_message_iter_container_new(iter, 'a', "{ss}");
1077
1078 for (k = keyval; k && k->key; k++)
1079 {
1080 Eldbus_Message_Iter *entry;
1081
1082 if (!k->val) continue;
1083
1084 entry = eldbus_message_iter_container_new(array, 'e', NULL);
1085 eldbus_message_iter_arguments_append(entry, "ss", k->key, k->val);
1086 eldbus_message_iter_container_close(array, entry);
1087 }
1088
1089 eldbus_message_iter_container_close(iter, array);
1090
1091 if (!eldbus_proxy_send(geonames_geocode, msg, geocode_cb, NULL, -1))
1092 {
1093 ERR("Error: could not call AddressToPosition");
1094 eldbus_message_unref(msg);
1095 return EINA_FALSE;
1096 }
1097
1098 return EINA_TRUE;
1099}
1100
1101/* Public API function to get the position from a freeform text input style
1102 * address
1103 */
1104EAPI Eina_Bool
1105elocation_freeform_address_to_position(const char *freeform_address, Elocation_Position *position_shadow EINA_UNUSED)
1106{
1107 if (!eldbus_proxy_call(geonames_geocode, "FreeformAddressToPosition", geocode_cb, NULL, -1, "s", freeform_address))
1108 {
1109 ERR("Error: could not call FreeformAddressToPosition");
1110 return EINA_FALSE;
1111 }
1112 return EINA_TRUE;
1113}
1114
1115/* Public API function to request the current address */
1116EAPI Eina_Bool
1117elocation_address_get(Elocation_Address *address_shadow)
1118{
1119 if (!address) return EINA_FALSE;
1120 if (address == address_shadow) return EINA_TRUE;
1121
1122 *address_shadow = *address;
1123 return EINA_TRUE;
1124}
1125
1126/* Public API function to request the current position */
1127EAPI Eina_Bool
1128elocation_position_get(Elocation_Position *position_shadow)
1129{
1130 if (!position) return EINA_FALSE;
1131 if (position == position_shadow) return EINA_TRUE;
1132
1133 *position_shadow = *position;
1134 return EINA_TRUE;
1135}
1136
1137/* Public API function to request the status */
1138EAPI Eina_Bool
1139elocation_status_get(int *status_shadow)
1140{
1141 if (status < 0) return EINA_FALSE;
1142 if (&status == status_shadow) return EINA_TRUE;
1143
1144 *status_shadow = status;
1145 return EINA_TRUE;
1146}
1147
1148/* Public API function to create a new position object */
1149EAPI Elocation_Position *
1150elocation_position_new(void)
1151{
1152 /* Malloc the global struct we operate on here in this lib. This shadows the
1153 * updated data we are giving to the application */
1154 position = calloc(1, sizeof(Elocation_Position));
1155 if (!position) return NULL;
1156
1157 position->accur = calloc(1, sizeof(Elocation_Accuracy));
1158 if (!position->accur) return NULL;
1159
1160 return position;
1161}
1162
1163/* Public API function to create an new address object */
1164EAPI Elocation_Address *
1165elocation_address_new(void)
1166{
1167 /* Malloc the global struct we operate on here in this lib. This shadows the
1168 * updated data we are giving to the application */
1169 address = calloc(1, sizeof(Elocation_Address));
1170 if (!address) return NULL;
1171
1172 address->accur = calloc(1, sizeof(Elocation_Accuracy));
1173 if (!address->accur) return NULL;
1174
1175 return address;
1176}
1177
1178/* Public API function to free an position object */
1179EAPI void
1180elocation_position_free(Elocation_Position *position_shadow)
1181{
1182 if (position != position_shadow)
1183 {
1184 ERR("Corrupted position object");
1185 return;
1186 }
1187
1188 free(position->accur);
1189 free(position);
1190}
1191
1192/* Public API function to free an address object */
1193EAPI void
1194elocation_address_free(Elocation_Address *address_shadow)
1195{
1196 if (address != address_shadow)
1197 {
1198 ERR("Corrupted address object");
1199 return;
1200 }
1201
1202 if (address)
1203 {
1204 free(address->country);
1205 free(address->countrycode);
1206 free(address->locality);
1207 free(address->postalcode);
1208 free(address->region);
1209 free(address->timezone);
1210 free(address->accur);
1211 free(address);
1212 }
1213}
1214
1215/* Public API function to initialize the elocation library */
1216EAPI Eina_Bool
1217elocation_init(void)
1218{
1219 Eldbus_Object *obj_master = NULL;
1220 Eldbus_Object *obj_geonames = NULL;
1221
1222 if (!eina_init()) return EINA_FALSE;
1223 if (!ecore_init()) return EINA_FALSE;
1224 if (!eldbus_init()) return EINA_FALSE;
1225
1226 _elocation_log_dom = eina_log_domain_register("elocation", EINA_COLOR_BLUE);
1227 if (_elocation_log_dom < 0)
1228 {
1229 EINA_LOG_ERR("Could not register 'elocation' log domain.");
1230 }
1231
1232 /* Create objects, one for each kind, we operate on internally */
1233 address_provider = calloc(1, sizeof(Elocation_Provider));
1234 position_provider = calloc(1, sizeof(Elocation_Provider));
1235
1236 addr_geocode = calloc(1, sizeof(Elocation_Address));
1237 if (!addr_geocode) return EINA_FALSE;
1238
1239 addr_geocode->accur = calloc(1, sizeof(Elocation_Accuracy));
1240 if (!addr_geocode->accur) return EINA_FALSE;
1241
1242 pos_geocode = calloc(1, sizeof(Elocation_Position));
1243 if (!pos_geocode) return EINA_FALSE;
1244
1245 pos_geocode->accur = calloc(1, sizeof(Elocation_Accuracy));
1246 if (!pos_geocode->accur) return EINA_FALSE;
1247
1248 conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION);
1249 if (!conn)
1250 {
1251 ERR("Error: could not connect to session bus.");
1252 return EXIT_FAILURE;
1253 }
1254
1255 /* Create all ecore event types we send out to interested applications */
1256 ELOCATION_EVENT_IN = ecore_event_type_new();
1257 ELOCATION_EVENT_OUT = ecore_event_type_new();
1258 ELOCATION_EVENT_STATUS = ecore_event_type_new();
1259 ELOCATION_EVENT_POSITION = ecore_event_type_new();
1260 ELOCATION_EVENT_ADDRESS = ecore_event_type_new();
1261 ELOCATION_EVENT_VELOCITY = ecore_event_type_new();
1262 ELOCATION_EVENT_GEOCODE = ecore_event_type_new();
1263 ELOCATION_EVENT_REVERSEGEOCODE = ecore_event_type_new();
1264 ELOCATION_EVENT_NMEA = ecore_event_type_new();
1265 ELOCATION_EVENT_SATELLITE = ecore_event_type_new();
1266 ELOCATION_EVENT_POI = ecore_event_type_new();
1267 ELOCATION_EVENT_META_READY = ecore_event_type_new();
1268
1269 obj_master= eldbus_object_get(conn, GEOCLUE_DBUS_NAME, GEOCLUE_OBJECT_PATH);
1270 if (!obj_master)
1271 {
1272 ERR("Error: could not get object");
1273 return EXIT_FAILURE;
1274 }
1275
1276 manager_master = eldbus_proxy_get(obj_master, GEOCLUE_MASTER_IFACE);
1277 if (!manager_master)
1278 {
1279 ERR("Error: could not get proxy");
1280 return EXIT_FAILURE;
1281 }
1282
1283 /* Create a meta provider for all normal use cases. This will allow GeoClue
1284 * to decide which provider is the best for us internally.
1285 * Right now we don't have the functionality in place to specifically request
1286 * a provider but we maybe need this in the future. We will try without it
1287 * for now.
1288 */
1289 if (!eldbus_proxy_call(manager_master, "Create", create_cb, NULL, -1, ""))
1290 {
1291 ERR("Error: could not call Create");
1292 return EXIT_FAILURE;
1293 }
1294
1295 master_poi = eldbus_proxy_get(obj_master, GEOCLUE_POI_IFACE);
1296 if (!master_poi)
1297 {
1298 ERR("Error: could not get proxy");
1299 return EXIT_FAILURE;
1300 }
1301
1302 /* Geocode and reverse geocode never show up as meta provider. Still we want
1303 * to be able to convert so we keep them around directly here. */
1304 obj_geonames= eldbus_object_get(conn, GEONAMES_DBUS_NAME, GEONAMES_OBJECT_PATH);
1305 if (!obj_geonames)
1306 {
1307 ERR("Error: could not get object for geonames");
1308 return EXIT_FAILURE;
1309 }
1310
1311 geonames_geocode = eldbus_proxy_get(obj_geonames, GEOCLUE_GEOCODE_IFACE);
1312 if (!geonames_geocode)
1313 {
1314 ERR("Error: could not get proxy");
1315 return EXIT_FAILURE;
1316 }
1317
1318 geonames_rgeocode = eldbus_proxy_get(obj_geonames, GEOCLUE_REVERSEGEOCODE_IFACE);
1319 if (!geonames_rgeocode)
1320 {
1321 ERR("Error: could not get proxy");
1322 return EXIT_FAILURE;
1323 }
1324
1325 eldbus_name_owner_changed_callback_add(conn, GEOCLUE_DBUS_NAME, _name_owner_changed,
1326 NULL, EINA_TRUE);
1327
1328 ecore_event_handler_add(ELOCATION_EVENT_IN, geoclue_start, NULL);
1329 ecore_event_handler_add(ELOCATION_EVENT_OUT, geoclue_stop, NULL);
1330
1331 return EINA_TRUE;
1332}
1333
1334/* Public API function to shutdown the elocation library form the application */
1335EAPI void
1336elocation_shutdown(void)
1337{
1338 /* Depending on if the create_cb was successfully received meta_geoclue is
1339 * setup or not. So we * need to check here if this is not the case
1340 */
1341 if (meta_geoclue)
1342 {
1343 /* To allow geoclue freeing unused providers we free our reference on it here */
1344 if (!eldbus_proxy_call(meta_geoclue, "RemoveReference", _reference_del_cb, NULL, -1, ""))
1345 {
1346 ERR("Error: could not call RemoveReference");
1347 }
1348 }
1349
1350 ecore_event_type_flush(ELOCATION_EVENT_IN,
1351 ELOCATION_EVENT_OUT,
1352 ELOCATION_EVENT_STATUS,
1353 ELOCATION_EVENT_POSITION,
1354 ELOCATION_EVENT_ADDRESS,
1355 ELOCATION_EVENT_VELOCITY,
1356 ELOCATION_EVENT_GEOCODE,
1357 ELOCATION_EVENT_REVERSEGEOCODE,
1358 ELOCATION_EVENT_NMEA,
1359 ELOCATION_EVENT_SATELLITE,
1360 ELOCATION_EVENT_POI,
1361 ELOCATION_EVENT_META_READY);
1362
1363 /* Quite a bit of allocated string and generic memory cleanup. This should be
1364 *less when we went away from all this global var business.
1365 */
1366 if (address_provider)
1367 {
1368 free(address_provider->name);
1369 free(address_provider->description);
1370 free(address_provider->service);
1371 free(address_provider->path);
1372 free(address_provider);
1373 }
1374
1375 if (position_provider)
1376 {
1377 free(position_provider->name);
1378 free(position_provider->description);
1379 free(position_provider->service);
1380 free(position_provider->path);
1381 free(position_provider);
1382 }
1383
1384 if (pos_geocode)
1385 {
1386 free(pos_geocode->accur);
1387 free(pos_geocode);
1388 }
1389
1390 if (addr_geocode)
1391 {
1392 free(addr_geocode->country);
1393 free(addr_geocode->countrycode);
1394 free(addr_geocode->locality);
1395 free(addr_geocode->postalcode);
1396 free(addr_geocode->region);
1397 free(addr_geocode->timezone);
1398 free(addr_geocode->accur);
1399 free(addr_geocode);
1400 }
1401
1402 /* Unreference some eldbus strcutures we now longer use. To allow eldbus to
1403 * free them internally.
1404 */
1405 if (manager_master)
1406 eldbus_proxy_unref(manager_master);
1407
1408 eldbus_name_owner_changed_callback_del(conn, GEOCLUE_DBUS_NAME, _name_owner_changed, NULL);
1409 eldbus_connection_unref(conn);
1410 eldbus_shutdown();
1411 ecore_shutdown();
1412 eina_log_domain_unregister(_elocation_log_dom);
1413 eina_shutdown();
1414}
diff --git a/src/lib/elocation/elocation_private.h b/src/lib/elocation/elocation_private.h
deleted file mode 100644
index b0d4865..0000000
--- a/src/lib/elocation/elocation_private.h
+++ /dev/null
@@ -1,186 +0,0 @@
1#ifndef _ELOCATION_PRIVATE_H
2#define _ELOCATION_PRIVATE_H
3
4#ifdef EFL_BETA_API_SUPPORT
5
6#ifdef HAVE_CONFIG_H
7#include "config.h"
8#endif
9
10#include <stdio.h>
11
12#include <Eina.h>
13#include <Ecore.h>
14#include <Eldbus.h>
15
16#ifndef ELOCATION_COLOR_DEFAULT
17#define ELOCATION_COLOR_DEFAULT EINA_COLOR_BLUE
18#endif
19extern int _elocation_log_dom;
20#ifdef CRI
21#undef CRI
22#endif
23
24#ifdef ERR
25#undef ERR
26#endif
27#ifdef INF
28#undef INF
29#endif
30#ifdef WARN
31#undef WARN
32#endif
33#ifdef DBG
34#undef DBG
35#endif
36
37#define CRI(...) EINA_LOG_DOM_CRIT(_elocation_log_dom, __VA_ARGS__)
38#define DBG(...) EINA_LOG_DOM_DBG(_elocation_log_dom, __VA_ARGS__)
39#define INF(...) EINA_LOG_DOM_INFO(_elocation_log_dom, __VA_ARGS__)
40#define WARN(...) EINA_LOG_DOM_WARN(_elocation_log_dom, __VA_ARGS__)
41#define ERR(...) EINA_LOG_DOM_ERR(_elocation_log_dom, __VA_ARGS__)
42
43/* Provider bus names and object paths. Master is the generic one which should
44 * pick up the best one internally based on given requirements. It is also still
45 * possible to use providers directly */
46#define GEOCLUE_DBUS_NAME "org.freedesktop.Geoclue.Master"
47#define GEOCLUE_OBJECT_PATH "/org/freedesktop/Geoclue/Master"
48#define GSMLOC_DBUS_NAME "org.freedesktop.Geoclue.Providers.Gsmloc"
49#define GSMLOC_OBJECT_PATH "/org/freedesktop/Geoclue/Providers/Gsmloc"
50#define HOSTIP_DBUS_NAME "org.freedesktop.Geoclue.Providers.Hostip"
51#define HOSTIP_OBJECT_PATH "/org/freedesktop/Geoclue/Providers/Hostip"
52#define SKYHOOK_DBUS_NAME "org.freedesktop.Geoclue.Providers.Skyhook"
53#define SKYHOOK_OBJECT_PATH "/org/freedesktop/Geoclue/Providers/Skyhook"
54#define UBUNTU_DBUS_NAME "org.freedesktop.Geoclue.Providers.UbuntuGeoIP"
55#define UBUNTU_OBJECT_PATH "/org/freedesktop/Geoclue/Providers/UbuntuGeoIP"
56#define GEONAMES_DBUS_NAME "org.freedesktop.Geoclue.Providers.Geonames"
57#define GEONAMES_OBJECT_PATH "/org/freedesktop/Geoclue/Providers/Geonames"
58#define PLAZES_DBUS_NAME "org.freedesktop.Geoclue.Providers.Plazes"
59#define PLAZES_OBJECT_PATH "/org/freedesktop/Geoclue/Providers/Plazes"
60#define YAHOO_DBUS_NAME "org.freedesktop.Geoclue.Providers.Yahoo"
61#define YAHOO_OBJECT_PATH "/org/freedesktop/Geoclue/Providers/Yahoo"
62
63/* Master interfaces to control geoclue */
64#define GEOCLUE_MASTER_IFACE "org.freedesktop.Geoclue.Master"
65#define GEOCLUE_MASTERCLIENT_IFACE "org.freedesktop.Geoclue.MasterClient"
66
67/* Provider interfaces to access location data */
68#define GEOCLUE_GEOCLUE_IFACE "org.freedesktop.Geoclue"
69#define GEOCLUE_POSITION_IFACE "org.freedesktop.Geoclue.Position"
70#define GEOCLUE_ADDRESS_IFACE "org.freedesktop.Geoclue.Address"
71#define GEOCLUE_VELOCITY_IFACE "org.freedesktop.Geoclue.Velocity"
72#define GEOCLUE_GEOCODE_IFACE "org.freedesktop.Geoclue.Geocode"
73#define GEOCLUE_REVERSEGEOCODE_IFACE "org.freedesktop.Geoclue.ReverseGeocode"
74
75/* More provider interfaces. These three are not in upstream geoclue but only
76 * in the Tizen version. Lets hope they get upstream at some point. Right now
77 * we will test at runtime if they are offered and ignore them if not */
78#define GEOCLUE_NMEA_IFACE "org.freedesktop.Geoclue.Nmea"
79#define GEOCLUE_SATELLITE_IFACE "org.freedesktop.Geoclue.Satellite"
80#define GEOCLUE_POI_IFACE "org.freedesktop.Geoclue.Poi"
81
82#define GEOCLUE_ADDRESS_KEY_AREA "area"
83#define GEOCLUE_ADDRESS_KEY_COUNTRY "country"
84#define GEOCLUE_ADDRESS_KEY_COUNTRYCODE "countrycode"
85#define GEOCLUE_ADDRESS_KEY_LOCALITY "locality"
86#define GEOCLUE_ADDRESS_KEY_POSTALCODE "postalcode"
87#define GEOCLUE_ADDRESS_KEY_REGION "region"
88#define GEOCLUE_ADDRESS_KEY_STREET "street"
89
90extern int ELOCATION_EVENT_IN;
91extern int ELOCATION_EVENT_OUT;
92
93/* Some ENUMs that we mimic from GeoClue code as we only access it over the DBus
94 * interface and share no header file for such defines.
95 */
96
97/**
98 * @ingroup Location
99 * @typedef GeocluePositionFields
100 * @since 1.13
101 *
102 * Bitmask to indicate which of the supplied positions fields are valid.
103 *
104 * @{
105 */
106typedef enum {
107 GEOCLUE_POSITION_FIELDS_NONE = 0,
108 GEOCLUE_POSITION_FIELDS_LATITUDE = 1 << 0,
109 GEOCLUE_POSITION_FIELDS_LONGITUDE = 1 << 1,
110 GEOCLUE_POSITION_FIELDS_ALTITUDE = 1 << 2
111} GeocluePositionFields;
112/**@}*/
113
114/**
115 * @ingroup Location
116 * @typedef GeoclueNetworkStatus
117 * @since 1.13
118 *
119 * Status of the network connectivity for GeoClue. Needed for all providers that
120 * access external data to determine the location. For example GeoIP or GeoCode
121 * providers.
122 *
123 * @{
124 */
125typedef enum {
126 GEOCLUE_CONNECTIVITY_UNKNOWN,
127 GEOCLUE_CONNECTIVITY_OFFLINE,
128 GEOCLUE_CONNECTIVITY_ACQUIRING,
129 GEOCLUE_CONNECTIVITY_ONLINE,
130} GeoclueNetworkStatus;
131/**@}*/
132
133/**
134 * @ingroup Location
135 * @typedef GeoclueStatus
136 * @since 1.13
137 *
138 * Status of a GeoClue provider.
139 *
140 * @{
141 */
142typedef enum {
143 GEOCLUE_STATUS_ERROR,
144 GEOCLUE_STATUS_UNAVAILABLE,
145 GEOCLUE_STATUS_ACQUIRING,
146 GEOCLUE_STATUS_AVAILABLE
147} GeoclueStatus;
148/**@}*/
149
150/**
151 * @ingroup Location
152 * @typedef GeoclueVelocityFields
153 * @since 1.13
154 *
155 * Bitmask to indicate which of the supplied velocity fields are valid.
156 *
157 * @{
158 */
159typedef enum {
160 GEOCLUE_VELOCITY_FIELDS_NONE = 0,
161 GEOCLUE_VELOCITY_FIELDS_SPEED = 1 << 0,
162 GEOCLUE_VELOCITY_FIELDS_DIRECTION = 1 << 1,
163 GEOCLUE_VELOCITY_FIELDS_CLIMB = 1 << 2
164} GeoclueVelocityFields;
165/**@}*/
166
167/**
168 * @ingroup Location
169 * @typedef Elocation_Provider
170 * @since 1.13
171 *
172 * Data structure to hold information about a GeoClue provider.
173 *
174 */
175typedef struct _Elocation_Provider
176{
177 char *name;
178 char *description;
179 char *service;
180 char *path;
181 GeoclueStatus status;
182} Elocation_Provider;
183
184#endif /* BETA API */
185
186#endif
diff --git a/src/lib/elocation/gen/eldbus_geo_clue2_client.c b/src/lib/elocation/gen/eldbus_geo_clue2_client.c
deleted file mode 100644
index b116647..0000000
--- a/src/lib/elocation/gen/eldbus_geo_clue2_client.c
+++ /dev/null
@@ -1,448 +0,0 @@
1#ifndef EFL_BETA_API_SUPPORT
2# define EFL_BETA_API_SUPPORT
3#endif
4
5#include "eldbus_geo_clue2_client.h"
6
7static int _log_main = -1;
8#undef ERR
9#define ERR(...) EINA_LOG_DOM_ERR(_log_main, __VA_ARGS__);
10int GEO_CLUE2_CLIENT_LOCATION_UPDATED_EVENT = 0;
11
12static void
13cb_geo_clue2_client_start(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)
14{
15 void *user_data = eldbus_pending_data_del(pending, "__user_data");
16 Geo_Clue2_Client_Start_Cb cb = data;
17 const char *error, *error_msg;
18 Eldbus_Proxy *proxy = eldbus_pending_data_del(pending, "__proxy");
19 if (eldbus_message_error_get(msg, &error, &error_msg))
20 {
21 Eldbus_Error_Info error_info = {error, error_msg};
22 cb(proxy, user_data, pending, &error_info);
23 return;
24 }
25 if (!eldbus_message_arguments_get(msg, ""))
26 {
27 Eldbus_Error_Info error_info = {"", ""};
28 ERR("Error: Getting arguments from message.");
29 cb(proxy, user_data, pending, &error_info);
30 return;
31 }
32 cb(proxy, user_data, pending, NULL);
33 return;
34}
35
36Eldbus_Pending *
37geo_clue2_client_start_call(Eldbus_Proxy *proxy, Geo_Clue2_Client_Start_Cb cb, const void *data)
38{
39 Eldbus_Message *msg;
40 Eldbus_Pending *p;
41 EINA_SAFETY_ON_NULL_RETURN_VAL(proxy, NULL);
42 msg = eldbus_proxy_method_call_new(proxy, "Start");
43 if (!eldbus_message_arguments_append(msg, ""))
44 {
45 ERR("Error: Filling message.");
46 eldbus_message_unref(msg);
47 return NULL;
48 }
49 p = eldbus_proxy_send(proxy, msg, cb_geo_clue2_client_start, cb, -1);
50 if (data)
51 eldbus_pending_data_set(p, "__user_data", data);
52 eldbus_pending_data_set(p, "__proxy", proxy);
53 return p;
54}
55
56static void
57cb_geo_clue2_client_stop(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)
58{
59 void *user_data = eldbus_pending_data_del(pending, "__user_data");
60 Geo_Clue2_Client_Stop_Cb cb = data;
61 const char *error, *error_msg;
62 Eldbus_Proxy *proxy = eldbus_pending_data_del(pending, "__proxy");
63 if (eldbus_message_error_get(msg, &error, &error_msg))
64 {
65 Eldbus_Error_Info error_info = {error, error_msg};
66 cb(proxy, user_data, pending, &error_info);
67 return;
68 }
69 if (!eldbus_message_arguments_get(msg, ""))
70 {
71 Eldbus_Error_Info error_info = {"", ""};
72 ERR("Error: Getting arguments from message.");
73 cb(proxy, user_data, pending, &error_info);
74 return;
75 }
76 cb(proxy, user_data, pending, NULL);
77 return;
78}
79
80Eldbus_Pending *
81geo_clue2_client_stop_call(Eldbus_Proxy *proxy, Geo_Clue2_Client_Stop_Cb cb, const void *data)
82{
83 Eldbus_Message *msg;
84 Eldbus_Pending *p;
85 EINA_SAFETY_ON_NULL_RETURN_VAL(proxy, NULL);
86 msg = eldbus_proxy_method_call_new(proxy, "Stop");
87 if (!eldbus_message_arguments_append(msg, ""))
88 {
89 ERR("Error: Filling message.");
90 eldbus_message_unref(msg);
91 return NULL;
92 }
93 p = eldbus_proxy_send(proxy, msg, cb_geo_clue2_client_stop, cb, -1);
94 if (data)
95 eldbus_pending_data_set(p, "__user_data", data);
96 eldbus_pending_data_set(p, "__proxy", proxy);
97 return p;
98}
99
100static void
101geo_clue2_client_location_updated_data_free(void *user_data EINA_UNUSED, void *func_data)
102{
103 Geo_Clue2_Client_LocationUpdated_Data *s_data = func_data;
104 free(s_data->old);
105 free(s_data->new);
106 free(s_data);
107}
108
109static void
110on_geo_clue2_client_location_updated(void *data, const Eldbus_Message *msg)
111{
112 Eldbus_Proxy *proxy = data;
113 Geo_Clue2_Client_LocationUpdated_Data *s_data = calloc(1, sizeof(Geo_Clue2_Client_LocationUpdated_Data));
114 s_data->proxy = proxy;
115 if (!eldbus_message_arguments_get(msg, "oo", &s_data->old, &s_data->new))
116 {
117 ERR("Error: Getting arguments from message.");
118 free(s_data);
119 return;
120 }
121 s_data->old = strdup(s_data->old);
122 s_data->new = strdup(s_data->new);
123 ecore_event_add(GEO_CLUE2_CLIENT_LOCATION_UPDATED_EVENT, s_data, geo_clue2_client_location_updated_data_free, NULL);
124}
125
126static void
127cb_geo_clue2_client_location(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)
128{
129 void *user_data = eldbus_pending_data_del(pending, "__user_data");
130 const char *error, *error_msg;
131 Eldbus_Codegen_Property_String_Get_Cb cb = data;
132 Eldbus_Proxy *proxy = eldbus_pending_data_del(pending, "__proxy");
133 Eldbus_Message_Iter *variant;
134 const char *v;
135 if (eldbus_message_error_get(msg, &error, &error_msg))
136 {
137 Eldbus_Error_Info error_info = {error, error_msg};
138 cb(user_data, pending, "Location", proxy, &error_info, NULL);
139 return;
140 }
141 if (!eldbus_message_arguments_get(msg, "v", &variant))
142 {
143 Eldbus_Error_Info error_info = {"", ""};
144 cb(user_data, pending, "Location", proxy, &error_info, NULL);
145 return;
146 }
147 if (!eldbus_message_iter_arguments_get(variant, "o", &v))
148 {
149 Eldbus_Error_Info error_info = {"", ""};
150 cb(user_data, pending, "Location", proxy, &error_info, NULL);
151 return;
152 }
153 cb(user_data, pending, "Location", proxy, NULL, v);
154}
155
156Eldbus_Pending *
157geo_clue2_client_location_propget(Eldbus_Proxy *proxy, Eldbus_Codegen_Property_String_Get_Cb cb, const void *data)
158{
159 Eldbus_Pending *p;
160 EINA_SAFETY_ON_NULL_RETURN_VAL(proxy, NULL);
161 p = eldbus_proxy_property_get(proxy, "Location", cb_geo_clue2_client_location, cb);
162 if (data)
163 eldbus_pending_data_set(p, "__user_data", data);
164 eldbus_pending_data_set(p, "__proxy", proxy);
165 return p;
166}
167
168static void
169cb_geo_clue2_client_distance_threshold(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)
170{
171 void *user_data = eldbus_pending_data_del(pending, "__user_data");
172 const char *error, *error_msg;
173 Eldbus_Codegen_Property_Uint32_Get_Cb cb = data;
174 Eldbus_Proxy *proxy = eldbus_pending_data_del(pending, "__proxy");
175 Eldbus_Message_Iter *variant;
176 unsigned int v;
177 if (eldbus_message_error_get(msg, &error, &error_msg))
178 {
179 Eldbus_Error_Info error_info = {error, error_msg};
180 cb(user_data, pending, "DistanceThreshold", proxy, &error_info, 0);
181 return;
182 }
183 if (!eldbus_message_arguments_get(msg, "v", &variant))
184 {
185 Eldbus_Error_Info error_info = {"", ""};
186 cb(user_data, pending, "DistanceThreshold", proxy, &error_info, 0);
187 return;
188 }
189 if (!eldbus_message_iter_arguments_get(variant, "u", &v))
190 {
191 Eldbus_Error_Info error_info = {"", ""};
192 cb(user_data, pending, "DistanceThreshold", proxy, &error_info, 0);
193 return;
194 }
195 cb(user_data, pending, "DistanceThreshold", proxy, NULL, v);
196}
197
198Eldbus_Pending *
199geo_clue2_client_distance_threshold_propget(Eldbus_Proxy *proxy, Eldbus_Codegen_Property_Uint32_Get_Cb cb, const void *data)
200{
201 Eldbus_Pending *p;
202 EINA_SAFETY_ON_NULL_RETURN_VAL(proxy, NULL);
203 p = eldbus_proxy_property_get(proxy, "DistanceThreshold", cb_geo_clue2_client_distance_threshold, cb);
204 if (data)
205 eldbus_pending_data_set(p, "__user_data", data);
206 eldbus_pending_data_set(p, "__proxy", proxy);
207 return p;
208}
209
210static void
211cb_geo_clue2_client_distance_threshold_set(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)
212{
213 const char *error, *error_msg;
214 void *user_data = eldbus_pending_data_del(pending, "__user_data");
215 Eldbus_Proxy *proxy = eldbus_pending_data_del(pending, "__proxy");
216 Eldbus_Codegen_Property_Set_Cb cb = data;
217 if (eldbus_message_error_get(msg, &error, &error_msg)) {
218 Eldbus_Error_Info error_info = {error, error_msg};
219
220 cb(user_data, "DistanceThreshold", proxy, pending, &error_info);
221 return;
222 }
223 cb(user_data, "DistanceThreshold", proxy, pending, NULL);
224}
225
226Eldbus_Pending *
227geo_clue2_client_distance_threshold_propset(Eldbus_Proxy *proxy, Eldbus_Codegen_Property_Set_Cb cb, const void *data, const void *value)
228{
229 Eldbus_Pending *p;
230 EINA_SAFETY_ON_NULL_RETURN_VAL(proxy, NULL);
231 EINA_SAFETY_ON_NULL_RETURN_VAL(value, NULL);
232 p = eldbus_proxy_property_set(proxy, "DistanceThreshold", "u", value, cb_geo_clue2_client_distance_threshold_set, cb);
233 eldbus_pending_data_set(p, "__user_data", data);
234 eldbus_pending_data_set(p, "__proxy", proxy);
235 return p;
236}
237
238static void
239cb_geo_clue2_client_desktop_id(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)
240{
241 void *user_data = eldbus_pending_data_del(pending, "__user_data");
242 const char *error, *error_msg;
243 Eldbus_Codegen_Property_String_Get_Cb cb = data;
244 Eldbus_Proxy *proxy = eldbus_pending_data_del(pending, "__proxy");
245 Eldbus_Message_Iter *variant;
246 const char *v;
247 if (eldbus_message_error_get(msg, &error, &error_msg))
248 {
249 Eldbus_Error_Info error_info = {error, error_msg};
250 cb(user_data, pending, "DesktopId", proxy, &error_info, NULL);
251 return;
252 }
253 if (!eldbus_message_arguments_get(msg, "v", &variant))
254 {
255 Eldbus_Error_Info error_info = {"", ""};
256 cb(user_data, pending, "DesktopId", proxy, &error_info, NULL);
257 return;
258 }
259 if (!eldbus_message_iter_arguments_get(variant, "s", &v))
260 {
261 Eldbus_Error_Info error_info = {"", ""};
262 cb(user_data, pending, "DesktopId", proxy, &error_info, NULL);
263 return;
264 }
265 cb(user_data, pending, "DesktopId", proxy, NULL, v);
266}
267
268Eldbus_Pending *
269geo_clue2_client_desktop_id_propget(Eldbus_Proxy *proxy, Eldbus_Codegen_Property_String_Get_Cb cb, const void *data)
270{
271 Eldbus_Pending *p;
272 EINA_SAFETY_ON_NULL_RETURN_VAL(proxy, NULL);
273 p = eldbus_proxy_property_get(proxy, "DesktopId", cb_geo_clue2_client_desktop_id, cb);
274 if (data)
275 eldbus_pending_data_set(p, "__user_data", data);
276 eldbus_pending_data_set(p, "__proxy", proxy);
277 return p;
278}
279
280static void
281cb_geo_clue2_client_desktop_id_set(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)
282{
283 const char *error, *error_msg;
284 void *user_data = eldbus_pending_data_del(pending, "__user_data");
285 Eldbus_Proxy *proxy = eldbus_pending_data_del(pending, "__proxy");
286 Eldbus_Codegen_Property_Set_Cb cb = data;
287 if (eldbus_message_error_get(msg, &error, &error_msg)) {
288 Eldbus_Error_Info error_info = {error, error_msg};
289
290 cb(user_data, "DesktopId", proxy, pending, &error_info);
291 return;
292 }
293 cb(user_data, "DesktopId", proxy, pending, NULL);
294}
295
296Eldbus_Pending *
297geo_clue2_client_desktop_id_propset(Eldbus_Proxy *proxy, Eldbus_Codegen_Property_Set_Cb cb, const void *data, const void *value)
298{
299 Eldbus_Pending *p;
300 EINA_SAFETY_ON_NULL_RETURN_VAL(proxy, NULL);
301 EINA_SAFETY_ON_NULL_RETURN_VAL(value, NULL);
302 p = eldbus_proxy_property_set(proxy, "DesktopId", "s", value, cb_geo_clue2_client_desktop_id_set, cb);
303 eldbus_pending_data_set(p, "__user_data", data);
304 eldbus_pending_data_set(p, "__proxy", proxy);
305 return p;
306}
307
308static void
309cb_geo_clue2_client_requested_accuracy_level(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)
310{
311 void *user_data = eldbus_pending_data_del(pending, "__user_data");
312 const char *error, *error_msg;
313 Eldbus_Codegen_Property_Uint32_Get_Cb cb = data;
314 Eldbus_Proxy *proxy = eldbus_pending_data_del(pending, "__proxy");
315 Eldbus_Message_Iter *variant;
316 unsigned int v;
317 if (eldbus_message_error_get(msg, &error, &error_msg))
318 {
319 Eldbus_Error_Info error_info = {error, error_msg};
320 cb(user_data, pending, "RequestedAccuracyLevel", proxy, &error_info, 0);
321 return;
322 }
323 if (!eldbus_message_arguments_get(msg, "v", &variant))
324 {
325 Eldbus_Error_Info error_info = {"", ""};
326 cb(user_data, pending, "RequestedAccuracyLevel", proxy, &error_info, 0);
327 return;
328 }
329 if (!eldbus_message_iter_arguments_get(variant, "u", &v))
330 {
331 Eldbus_Error_Info error_info = {"", ""};
332 cb(user_data, pending, "RequestedAccuracyLevel", proxy, &error_info, 0);
333 return;
334 }
335 cb(user_data, pending, "RequestedAccuracyLevel", proxy, NULL, v);
336}
337
338Eldbus_Pending *
339geo_clue2_client_requested_accuracy_level_propget(Eldbus_Proxy *proxy, Eldbus_Codegen_Property_Uint32_Get_Cb cb, const void *data)
340{
341 Eldbus_Pending *p;
342 EINA_SAFETY_ON_NULL_RETURN_VAL(proxy, NULL);
343 p = eldbus_proxy_property_get(proxy, "RequestedAccuracyLevel", cb_geo_clue2_client_requested_accuracy_level, cb);
344 if (data)
345 eldbus_pending_data_set(p, "__user_data", data);
346 eldbus_pending_data_set(p, "__proxy", proxy);
347 return p;
348}
349
350static void
351cb_geo_clue2_client_requested_accuracy_level_set(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)
352{
353 const char *error, *error_msg;
354 void *user_data = eldbus_pending_data_del(pending, "__user_data");
355 Eldbus_Proxy *proxy = eldbus_pending_data_del(pending, "__proxy");
356 Eldbus_Codegen_Property_Set_Cb cb = data;
357 if (eldbus_message_error_get(msg, &error, &error_msg)) {
358 Eldbus_Error_Info error_info = {error, error_msg};
359
360 cb(user_data, "RequestedAccuracyLevel", proxy, pending, &error_info);
361 return;
362 }
363 cb(user_data, "RequestedAccuracyLevel", proxy, pending, NULL);
364}
365
366Eldbus_Pending *
367geo_clue2_client_requested_accuracy_level_propset(Eldbus_Proxy *proxy, Eldbus_Codegen_Property_Set_Cb cb, const void *data, const void *value)
368{
369 Eldbus_Pending *p;
370 EINA_SAFETY_ON_NULL_RETURN_VAL(proxy, NULL);
371 EINA_SAFETY_ON_NULL_RETURN_VAL(value, NULL);
372 p = eldbus_proxy_property_set(proxy, "RequestedAccuracyLevel", "u", value, cb_geo_clue2_client_requested_accuracy_level_set, cb);
373 eldbus_pending_data_set(p, "__user_data", data);
374 eldbus_pending_data_set(p, "__proxy", proxy);
375 return p;
376}
377
378static void
379cb_geo_clue2_client_active(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)
380{
381 void *user_data = eldbus_pending_data_del(pending, "__user_data");
382 const char *error, *error_msg;
383 Eldbus_Codegen_Property_Bool_Get_Cb cb = data;
384 Eldbus_Proxy *proxy = eldbus_pending_data_del(pending, "__proxy");
385 Eldbus_Message_Iter *variant;
386 Eina_Bool v;
387 if (eldbus_message_error_get(msg, &error, &error_msg))
388 {
389 Eldbus_Error_Info error_info = {error, error_msg};
390 cb(user_data, pending, "Active", proxy, &error_info, 0);
391 return;
392 }
393 if (!eldbus_message_arguments_get(msg, "v", &variant))
394 {
395 Eldbus_Error_Info error_info = {"", ""};
396 cb(user_data, pending, "Active", proxy, &error_info, 0);
397 return;
398 }
399 if (!eldbus_message_iter_arguments_get(variant, "b", &v))
400 {
401 Eldbus_Error_Info error_info = {"", ""};
402 cb(user_data, pending, "Active", proxy, &error_info, 0);
403 return;
404 }
405 cb(user_data, pending, "Active", proxy, NULL, v);
406}
407
408Eldbus_Pending *
409geo_clue2_client_active_propget(Eldbus_Proxy *proxy, Eldbus_Codegen_Property_Bool_Get_Cb cb, const void *data)
410{
411 Eldbus_Pending *p;
412 EINA_SAFETY_ON_NULL_RETURN_VAL(proxy, NULL);
413 p = eldbus_proxy_property_get(proxy, "Active", cb_geo_clue2_client_active, cb);
414 if (data)
415 eldbus_pending_data_set(p, "__user_data", data);
416 eldbus_pending_data_set(p, "__proxy", proxy);
417 return p;
418}
419
420void
421geo_clue2_client_log_domain_set(int id)
422{
423 _log_main = id;
424}
425
426void
427geo_clue2_client_proxy_unref(Eldbus_Proxy *proxy)
428{
429 Eldbus_Object *obj = eldbus_proxy_object_get(proxy);
430 eldbus_proxy_unref(proxy);
431 eldbus_object_unref(obj);
432}
433
434Eldbus_Proxy *
435geo_clue2_client_proxy_get(Eldbus_Connection *conn, const char *bus, const char *path)
436{
437 Eldbus_Object *obj;
438 Eldbus_Proxy *proxy;
439 EINA_SAFETY_ON_NULL_RETURN_VAL(conn, NULL);
440 EINA_SAFETY_ON_NULL_RETURN_VAL(bus, NULL);
441 if (!path) path = "/";
442 obj = eldbus_object_get(conn, bus, path);
443 proxy = eldbus_proxy_get(obj, "org.freedesktop.GeoClue2.Client");
444 eldbus_proxy_signal_handler_add(proxy, "LocationUpdated", on_geo_clue2_client_location_updated, proxy);
445 if (!GEO_CLUE2_CLIENT_LOCATION_UPDATED_EVENT)
446 GEO_CLUE2_CLIENT_LOCATION_UPDATED_EVENT = ecore_event_type_new();
447 return proxy;
448}
diff --git a/src/lib/elocation/gen/eldbus_geo_clue2_client.h b/src/lib/elocation/gen/eldbus_geo_clue2_client.h
deleted file mode 100644
index 3626e6d..0000000
--- a/src/lib/elocation/gen/eldbus_geo_clue2_client.h
+++ /dev/null
@@ -1,36 +0,0 @@
1#ifndef ELDBUS_GEO_CLUE2_CLIENT_H
2#define ELDBUS_GEO_CLUE2_CLIENT_H
3
4#ifdef EFL_BETA_API_SUPPORT
5
6#include <Eina.h>
7#include <Ecore.h>
8#include <Eldbus.h>
9#include "eldbus_utils.h"
10
11Eldbus_Proxy *geo_clue2_client_proxy_get(Eldbus_Connection *conn, const char *bus, const char *path);
12void geo_clue2_client_proxy_unref(Eldbus_Proxy *proxy);
13void geo_clue2_client_log_domain_set(int id);
14typedef void (*Geo_Clue2_Client_Start_Cb)(Eldbus_Proxy *proxy, void *data, Eldbus_Pending *pending, Eldbus_Error_Info *error);
15Eldbus_Pending *geo_clue2_client_start_call(Eldbus_Proxy *proxy, Geo_Clue2_Client_Start_Cb cb, const void *data);
16typedef void (*Geo_Clue2_Client_Stop_Cb)(Eldbus_Proxy *proxy, void *data, Eldbus_Pending *pending, Eldbus_Error_Info *error);
17Eldbus_Pending *geo_clue2_client_stop_call(Eldbus_Proxy *proxy, Geo_Clue2_Client_Stop_Cb cb, const void *data);
18extern int GEO_CLUE2_CLIENT_LOCATION_UPDATED_EVENT;
19typedef struct _Geo_Clue2_Client_LocationUpdated_Data
20{
21 Eldbus_Proxy *proxy;
22 char *old;
23 char *new;
24} Geo_Clue2_Client_LocationUpdated_Data;
25Eldbus_Pending *geo_clue2_client_location_propget(Eldbus_Proxy *proxy, Eldbus_Codegen_Property_String_Get_Cb cb, const void *data);
26Eldbus_Pending *geo_clue2_client_distance_threshold_propget(Eldbus_Proxy *proxy, Eldbus_Codegen_Property_Uint32_Get_Cb cb, const void *data);
27Eldbus_Pending *geo_clue2_client_distance_threshold_propset(Eldbus_Proxy *proxy, Eldbus_Codegen_Property_Set_Cb cb, const void *data, const void *value);
28Eldbus_Pending *geo_clue2_client_desktop_id_propget(Eldbus_Proxy *proxy, Eldbus_Codegen_Property_String_Get_Cb cb, const void *data);
29Eldbus_Pending *geo_clue2_client_desktop_id_propset(Eldbus_Proxy *proxy, Eldbus_Codegen_Property_Set_Cb cb, const void *data, const void *value);
30Eldbus_Pending *geo_clue2_client_requested_accuracy_level_propget(Eldbus_Proxy *proxy, Eldbus_Codegen_Property_Uint32_Get_Cb cb, const void *data);
31Eldbus_Pending *geo_clue2_client_requested_accuracy_level_propset(Eldbus_Proxy *proxy, Eldbus_Codegen_Property_Set_Cb cb, const void *data, const void *value);
32Eldbus_Pending *geo_clue2_client_active_propget(Eldbus_Proxy *proxy, Eldbus_Codegen_Property_Bool_Get_Cb cb, const void *data);
33
34#endif /* BETA API */
35
36#endif
diff --git a/src/lib/elocation/gen/eldbus_geo_clue2_location.c b/src/lib/elocation/gen/eldbus_geo_clue2_location.c
deleted file mode 100644
index 57728c1..0000000
--- a/src/lib/elocation/gen/eldbus_geo_clue2_location.c
+++ /dev/null
@@ -1,246 +0,0 @@
1#ifndef EFL_BETA_API_SUPPORT
2# define EFL_BETA_API_SUPPORT
3#endif
4
5#include "eldbus_geo_clue2_location.h"
6
7static int _log_main = -1;
8#undef ERR
9#define ERR(...) EINA_LOG_DOM_ERR(_log_main, __VA_ARGS__);
10
11static void
12cb_geo_clue2_location_latitude(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)
13{
14 void *user_data = eldbus_pending_data_del(pending, "__user_data");
15 const char *error, *error_msg;
16 Eldbus_Codegen_Property_Double_Get_Cb cb = data;
17 Eldbus_Proxy *proxy = eldbus_pending_data_del(pending, "__proxy");
18 Eldbus_Message_Iter *variant;
19 double v;
20 if (eldbus_message_error_get(msg, &error, &error_msg))
21 {
22 Eldbus_Error_Info error_info = {error, error_msg};
23 cb(user_data, pending, "Latitude", proxy, &error_info, 0);
24 return;
25 }
26 if (!eldbus_message_arguments_get(msg, "v", &variant))
27 {
28 Eldbus_Error_Info error_info = {"", ""};
29 cb(user_data, pending, "Latitude", proxy, &error_info, 0);
30 return;
31 }
32 if (!eldbus_message_iter_arguments_get(variant, "d", &v))
33 {
34 Eldbus_Error_Info error_info = {"", ""};
35 cb(user_data, pending, "Latitude", proxy, &error_info, 0);
36 return;
37 }
38 cb(user_data, pending, "Latitude", proxy, NULL, v);
39}
40
41Eldbus_Pending *
42geo_clue2_location_latitude_propget(Eldbus_Proxy *proxy, Eldbus_Codegen_Property_Double_Get_Cb cb, const void *data)
43{
44 Eldbus_Pending *p;
45 EINA_SAFETY_ON_NULL_RETURN_VAL(proxy, NULL);
46 p = eldbus_proxy_property_get(proxy, "Latitude", cb_geo_clue2_location_latitude, cb);
47 if (data)
48 eldbus_pending_data_set(p, "__user_data", data);
49 eldbus_pending_data_set(p, "__proxy", proxy);
50 return p;
51}
52
53static void
54cb_geo_clue2_location_longitude(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)
55{
56 void *user_data = eldbus_pending_data_del(pending, "__user_data");
57 const char *error, *error_msg;
58 Eldbus_Codegen_Property_Double_Get_Cb cb = data;
59 Eldbus_Proxy *proxy = eldbus_pending_data_del(pending, "__proxy");
60 Eldbus_Message_Iter *variant;
61 double v;
62 if (eldbus_message_error_get(msg, &error, &error_msg))
63 {
64 Eldbus_Error_Info error_info = {error, error_msg};
65 cb(user_data, pending, "Longitude", proxy, &error_info, 0);
66 return;
67 }
68 if (!eldbus_message_arguments_get(msg, "v", &variant))
69 {
70 Eldbus_Error_Info error_info = {"", ""};
71 cb(user_data, pending, "Longitude", proxy, &error_info, 0);
72 return;
73 }
74 if (!eldbus_message_iter_arguments_get(variant, "d", &v))
75 {
76 Eldbus_Error_Info error_info = {"", ""};
77 cb(user_data, pending, "Longitude", proxy, &error_info, 0);
78 return;
79 }
80 cb(user_data, pending, "Longitude", proxy, NULL, v);
81}
82
83Eldbus_Pending *
84geo_clue2_location_longitude_propget(Eldbus_Proxy *proxy, Eldbus_Codegen_Property_Double_Get_Cb cb, const void *data)
85{
86 Eldbus_Pending *p;
87 EINA_SAFETY_ON_NULL_RETURN_VAL(proxy, NULL);
88 p = eldbus_proxy_property_get(proxy, "Longitude", cb_geo_clue2_location_longitude, cb);
89 if (data)
90 eldbus_pending_data_set(p, "__user_data", data);
91 eldbus_pending_data_set(p, "__proxy", proxy);
92 return p;
93}
94
95static void
96cb_geo_clue2_location_accuracy(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)
97{
98 void *user_data = eldbus_pending_data_del(pending, "__user_data");
99 const char *error, *error_msg;
100 Eldbus_Codegen_Property_Double_Get_Cb cb = data;
101 Eldbus_Proxy *proxy = eldbus_pending_data_del(pending, "__proxy");
102 Eldbus_Message_Iter *variant;
103 double v;
104 if (eldbus_message_error_get(msg, &error, &error_msg))
105 {
106 Eldbus_Error_Info error_info = {error, error_msg};
107 cb(user_data, pending, "Accuracy", proxy, &error_info, 0);
108 return;
109 }
110 if (!eldbus_message_arguments_get(msg, "v", &variant))
111 {
112 Eldbus_Error_Info error_info = {"", ""};
113 cb(user_data, pending, "Accuracy", proxy, &error_info, 0);
114 return;
115 }
116 if (!eldbus_message_iter_arguments_get(variant, "d", &v))
117 {
118 Eldbus_Error_Info error_info = {"", ""};
119 cb(user_data, pending, "Accuracy", proxy, &error_info, 0);
120 return;
121 }
122 cb(user_data, pending, "Accuracy", proxy, NULL, v);
123}
124
125Eldbus_Pending *
126geo_clue2_location_accuracy_propget(Eldbus_Proxy *proxy, Eldbus_Codegen_Property_Double_Get_Cb cb, const void *data)
127{
128 Eldbus_Pending *p;
129 EINA_SAFETY_ON_NULL_RETURN_VAL(proxy, NULL);
130 p = eldbus_proxy_property_get(proxy, "Accuracy", cb_geo_clue2_location_accuracy, cb);
131 if (data)
132 eldbus_pending_data_set(p, "__user_data", data);
133 eldbus_pending_data_set(p, "__proxy", proxy);
134 return p;
135}
136
137static void
138cb_geo_clue2_location_altitude(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)
139{
140 void *user_data = eldbus_pending_data_del(pending, "__user_data");
141 const char *error, *error_msg;
142 Eldbus_Codegen_Property_Double_Get_Cb cb = data;
143 Eldbus_Proxy *proxy = eldbus_pending_data_del(pending, "__proxy");
144 Eldbus_Message_Iter *variant;
145 double v;
146 if (eldbus_message_error_get(msg, &error, &error_msg))
147 {
148 Eldbus_Error_Info error_info = {error, error_msg};
149 cb(user_data, pending, "Altitude", proxy, &error_info, 0);
150 return;
151 }
152 if (!eldbus_message_arguments_get(msg, "v", &variant))
153 {
154 Eldbus_Error_Info error_info = {"", ""};
155 cb(user_data, pending, "Altitude", proxy, &error_info, 0);
156 return;
157 }
158 if (!eldbus_message_iter_arguments_get(variant, "d", &v))
159 {
160 Eldbus_Error_Info error_info = {"", ""};
161 cb(user_data, pending, "Altitude", proxy, &error_info, 0);
162 return;
163 }
164 cb(user_data, pending, "Altitude", proxy, NULL, v);
165}
166
167Eldbus_Pending *
168geo_clue2_location_altitude_propget(Eldbus_Proxy *proxy, Eldbus_Codegen_Property_Double_Get_Cb cb, const void *data)
169{
170 Eldbus_Pending *p;
171 EINA_SAFETY_ON_NULL_RETURN_VAL(proxy, NULL);
172 p = eldbus_proxy_property_get(proxy, "Altitude", cb_geo_clue2_location_altitude, cb);
173 if (data)
174 eldbus_pending_data_set(p, "__user_data", data);
175 eldbus_pending_data_set(p, "__proxy", proxy);
176 return p;
177}
178
179static void
180cb_geo_clue2_location_description(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)
181{
182 void *user_data = eldbus_pending_data_del(pending, "__user_data");
183 const char *error, *error_msg;
184 Eldbus_Codegen_Property_String_Get_Cb cb = data;
185 Eldbus_Proxy *proxy = eldbus_pending_data_del(pending, "__proxy");
186 Eldbus_Message_Iter *variant;
187 const char *v;
188 if (eldbus_message_error_get(msg, &error, &error_msg))
189 {
190 Eldbus_Error_Info error_info = {error, error_msg};
191 cb(user_data, pending, "Description", proxy, &error_info, NULL);
192 return;
193 }
194 if (!eldbus_message_arguments_get(msg, "v", &variant))
195 {
196 Eldbus_Error_Info error_info = {"", ""};
197 cb(user_data, pending, "Description", proxy, &error_info, NULL);
198 return;
199 }
200 if (!eldbus_message_iter_arguments_get(variant, "s", &v))
201 {
202 Eldbus_Error_Info error_info = {"", ""};
203 cb(user_data, pending, "Description", proxy, &error_info, NULL);
204 return;
205 }
206 cb(user_data, pending, "Description", proxy, NULL, v);
207}
208
209Eldbus_Pending *
210geo_clue2_location_description_propget(Eldbus_Proxy *proxy, Eldbus_Codegen_Property_String_Get_Cb cb, const void *data)
211{
212 Eldbus_Pending *p;
213 EINA_SAFETY_ON_NULL_RETURN_VAL(proxy, NULL);
214 p = eldbus_proxy_property_get(proxy, "Description", cb_geo_clue2_location_description, cb);
215 if (data)
216 eldbus_pending_data_set(p, "__user_data", data);
217 eldbus_pending_data_set(p, "__proxy", proxy);
218 return p;
219}
220
221void
222geo_clue2_location_log_domain_set(int id)
223{
224 _log_main = id;
225}
226
227void
228geo_clue2_location_proxy_unref(Eldbus_Proxy *proxy)
229{
230 Eldbus_Object *obj = eldbus_proxy_object_get(proxy);
231 eldbus_proxy_unref(proxy);
232 eldbus_object_unref(obj);
233}
234
235Eldbus_Proxy *
236geo_clue2_location_proxy_get(Eldbus_Connection *conn, const char *bus, const char *path)
237{
238 Eldbus_Object *obj;
239 Eldbus_Proxy *proxy;
240 EINA_SAFETY_ON_NULL_RETURN_VAL(conn, NULL);
241 EINA_SAFETY_ON_NULL_RETURN_VAL(bus, NULL);
242 if (!path) path = "/";
243 obj = eldbus_object_get(conn, bus, path);
244 proxy = eldbus_proxy_get(obj, "org.freedesktop.GeoClue2.Location");
245 return proxy;
246}
diff --git a/src/lib/elocation/gen/eldbus_geo_clue2_location.h b/src/lib/elocation/gen/eldbus_geo_clue2_location.h
deleted file mode 100644
index 91f2c75..0000000
--- a/src/lib/elocation/gen/eldbus_geo_clue2_location.h
+++ /dev/null
@@ -1,22 +0,0 @@
1#ifndef ELDBUS_GEO_CLUE2_LOCATION_H
2#define ELDBUS_GEO_CLUE2_LOCATION_H
3
4#ifdef EFL_BETA_API_SUPPORT
5
6#include <Eina.h>
7#include <Ecore.h>
8#include <Eldbus.h>
9#include "eldbus_utils.h"
10
11Eldbus_Proxy *geo_clue2_location_proxy_get(Eldbus_Connection *conn, const char *bus, const char *path);
12void geo_clue2_location_proxy_unref(Eldbus_Proxy *proxy);
13void geo_clue2_location_log_domain_set(int id);
14Eldbus_Pending *geo_clue2_location_latitude_propget(Eldbus_Proxy *proxy, Eldbus_Codegen_Property_Double_Get_Cb cb, const void *data);
15Eldbus_Pending *geo_clue2_location_longitude_propget(Eldbus_Proxy *proxy, Eldbus_Codegen_Property_Double_Get_Cb cb, const void *data);
16Eldbus_Pending *geo_clue2_location_accuracy_propget(Eldbus_Proxy *proxy, Eldbus_Codegen_Property_Double_Get_Cb cb, const void *data);
17Eldbus_Pending *geo_clue2_location_altitude_propget(Eldbus_Proxy *proxy, Eldbus_Codegen_Property_Double_Get_Cb cb, const void *data);
18Eldbus_Pending *geo_clue2_location_description_propget(Eldbus_Proxy *proxy, Eldbus_Codegen_Property_String_Get_Cb cb, const void *data);
19
20#endif /* BETA API */
21
22#endif
diff --git a/src/lib/elocation/gen/eldbus_geo_clue2_manager.c b/src/lib/elocation/gen/eldbus_geo_clue2_manager.c
deleted file mode 100644
index 838a530..0000000
--- a/src/lib/elocation/gen/eldbus_geo_clue2_manager.c
+++ /dev/null
@@ -1,209 +0,0 @@
1#ifndef EFL_BETA_API_SUPPORT
2# define EFL_BETA_API_SUPPORT
3#endif
4
5#include "eldbus_geo_clue2_manager.h"
6
7static int _log_main = -1;
8#undef ERR
9#define ERR(...) EINA_LOG_DOM_ERR(_log_main, __VA_ARGS__);
10
11static void
12cb_geo_clue2_manager_get_client(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)
13{
14 void *user_data = eldbus_pending_data_del(pending, "__user_data");
15 Geo_Clue2_Manager_Get_Client_Cb cb = data;
16 const char *error, *error_msg;
17 Eldbus_Proxy *proxy = eldbus_pending_data_del(pending, "__proxy");
18 const char *client = NULL;
19 if (eldbus_message_error_get(msg, &error, &error_msg))
20 {
21 Eldbus_Error_Info error_info = {error, error_msg};
22 cb(proxy, user_data, pending, &error_info, client);
23 return;
24 }
25 if (!eldbus_message_arguments_get(msg, "o", &client))
26 {
27 Eldbus_Error_Info error_info = {"", ""};
28 ERR("Error: Getting arguments from message.");
29 cb(proxy, user_data, pending, &error_info, client);
30 return;
31 }
32 cb(proxy, user_data, pending, NULL, client);
33 return;
34}
35
36Eldbus_Pending *
37geo_clue2_manager_get_client_call(Eldbus_Proxy *proxy, Geo_Clue2_Manager_Get_Client_Cb cb, const void *data)
38{
39 Eldbus_Message *msg;
40 Eldbus_Pending *p;
41 EINA_SAFETY_ON_NULL_RETURN_VAL(proxy, NULL);
42 msg = eldbus_proxy_method_call_new(proxy, "GetClient");
43 if (!eldbus_message_arguments_append(msg, ""))
44 {
45 ERR("Error: Filling message.");
46 eldbus_message_unref(msg);
47 return NULL;
48 }
49 p = eldbus_proxy_send(proxy, msg, cb_geo_clue2_manager_get_client, cb, -1);
50 if (data)
51 eldbus_pending_data_set(p, "__user_data", data);
52 eldbus_pending_data_set(p, "__proxy", proxy);
53 return p;
54}
55
56static void
57cb_geo_clue2_manager_add_agent(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)
58{
59 void *user_data = eldbus_pending_data_del(pending, "__user_data");
60 Geo_Clue2_Manager_Add_Agent_Cb cb = data;
61 const char *error, *error_msg;
62 Eldbus_Proxy *proxy = eldbus_pending_data_del(pending, "__proxy");
63 if (eldbus_message_error_get(msg, &error, &error_msg))
64 {
65 Eldbus_Error_Info error_info = {error, error_msg};
66 cb(proxy, user_data, pending, &error_info);
67 return;
68 }
69 if (!eldbus_message_arguments_get(msg, ""))
70 {
71 Eldbus_Error_Info error_info = {"", ""};
72 ERR("Error: Getting arguments from message.");
73 cb(proxy, user_data, pending, &error_info);
74 return;
75 }
76 cb(proxy, user_data, pending, NULL);
77 return;
78}
79
80Eldbus_Pending *
81geo_clue2_manager_add_agent_call(Eldbus_Proxy *proxy, Geo_Clue2_Manager_Add_Agent_Cb cb, const void *data, const char *id)
82{
83 Eldbus_Message *msg;
84 Eldbus_Pending *p;
85 EINA_SAFETY_ON_NULL_RETURN_VAL(proxy, NULL);
86 msg = eldbus_proxy_method_call_new(proxy, "AddAgent");
87 if (!eldbus_message_arguments_append(msg, "s", id))
88 {
89 ERR("Error: Filling message.");
90 eldbus_message_unref(msg);
91 return NULL;
92 }
93 p = eldbus_proxy_send(proxy, msg, cb_geo_clue2_manager_add_agent, cb, -1);
94 if (data)
95 eldbus_pending_data_set(p, "__user_data", data);
96 eldbus_pending_data_set(p, "__proxy", proxy);
97 return p;
98}
99
100static void
101cb_geo_clue2_manager_in_use(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)
102{
103 void *user_data = eldbus_pending_data_del(pending, "__user_data");
104 const char *error, *error_msg;
105 Eldbus_Codegen_Property_Bool_Get_Cb cb = data;
106 Eldbus_Proxy *proxy = eldbus_pending_data_del(pending, "__proxy");
107 Eldbus_Message_Iter *variant;
108 Eina_Bool v;
109 if (eldbus_message_error_get(msg, &error, &error_msg))
110 {
111 Eldbus_Error_Info error_info = {error, error_msg};
112 cb(user_data, pending, "InUse", proxy, &error_info, 0);
113 return;
114 }
115 if (!eldbus_message_arguments_get(msg, "v", &variant))
116 {
117 Eldbus_Error_Info error_info = {"", ""};
118 cb(user_data, pending, "InUse", proxy, &error_info, 0);
119 return;
120 }
121 if (!eldbus_message_iter_arguments_get(variant, "b", &v))
122 {
123 Eldbus_Error_Info error_info = {"", ""};
124 cb(user_data, pending, "InUse", proxy, &error_info, 0);
125 return;
126 }
127 cb(user_data, pending, "InUse", proxy, NULL, v);
128}
129
130Eldbus_Pending *
131geo_clue2_manager_in_use_propget(Eldbus_Proxy *proxy, Eldbus_Codegen_Property_Bool_Get_Cb cb, const void *data)
132{
133 Eldbus_Pending *p;
134 EINA_SAFETY_ON_NULL_RETURN_VAL(proxy, NULL);
135 p = eldbus_proxy_property_get(proxy, "InUse", cb_geo_clue2_manager_in_use, cb);
136 if (data)
137 eldbus_pending_data_set(p, "__user_data", data);
138 eldbus_pending_data_set(p, "__proxy", proxy);
139 return p;
140}
141
142static void
143cb_geo_clue2_manager_available_accuracy_level(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)
144{
145 void *user_data = eldbus_pending_data_del(pending, "__user_data");
146 const char *error, *error_msg;
147 Eldbus_Codegen_Property_Uint32_Get_Cb cb = data;
148 Eldbus_Proxy *proxy = eldbus_pending_data_del(pending, "__proxy");
149 Eldbus_Message_Iter *variant;
150 unsigned int v;
151 if (eldbus_message_error_get(msg, &error, &error_msg))
152 {
153 Eldbus_Error_Info error_info = {error, error_msg};
154 cb(user_data, pending, "AvailableAccuracyLevel", proxy, &error_info, 0);
155 return;
156 }
157 if (!eldbus_message_arguments_get(msg, "v", &variant))
158 {
159 Eldbus_Error_Info error_info = {"", ""};
160 cb(user_data, pending, "AvailableAccuracyLevel", proxy, &error_info, 0);
161 return;
162 }
163 if (!eldbus_message_iter_arguments_get(variant, "u", &v))
164 {
165 Eldbus_Error_Info error_info = {"", ""};
166 cb(user_data, pending, "AvailableAccuracyLevel", proxy, &error_info, 0);
167 return;
168 }
169 cb(user_data, pending, "AvailableAccuracyLevel", proxy, NULL, v);
170}
171
172Eldbus_Pending *
173geo_clue2_manager_available_accuracy_level_propget(Eldbus_Proxy *proxy, Eldbus_Codegen_Property_Uint32_Get_Cb cb, const void *data)
174{
175 Eldbus_Pending *p;
176 EINA_SAFETY_ON_NULL_RETURN_VAL(proxy, NULL);
177 p = eldbus_proxy_property_get(proxy, "AvailableAccuracyLevel", cb_geo_clue2_manager_available_accuracy_level, cb);
178 if (data)
179 eldbus_pending_data_set(p, "__user_data", data);
180 eldbus_pending_data_set(p, "__proxy", proxy);
181 return p;
182}
183
184void
185geo_clue2_manager_log_domain_set(int id)
186{
187 _log_main = id;
188}
189
190void
191geo_clue2_manager_proxy_unref(Eldbus_Proxy *proxy)
192{
193 Eldbus_Object *obj = eldbus_proxy_object_get(proxy);
194 eldbus_proxy_unref(proxy);
195 eldbus_object_unref(obj);
196}
197
198Eldbus_Proxy *
199geo_clue2_manager_proxy_get(Eldbus_Connection *conn, const char *bus, const char *path)