summaryrefslogtreecommitdiff
path: root/src/examples
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-12-09 15:31:00 +0100
commit4ff8fb140cf6c9bda359c8872095d2c1c28fad86 (patch)
tree911554cc63aa874e8f7cc4acb0f69768a6d52f49 /src/examples
parent431f3b1fcef2b49b4c43539c51ad50fcd99a55bd (diff)
elocation: remove beta library
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. Reviewed-by: Chris Michael <cp.michael@samsung.com> Reviewed-by: Vincent Torri <vincent.torri@gmail.com> Differential Revision: https://phab.enlightenment.org/D10788
Diffstat (limited to 'src/examples')
-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
4 files changed, 0 insertions, 320 deletions
diff --git a/src/examples/elementary/location_example_01.c b/src/examples/elementary/location_example_01.c
deleted file mode 100644
index 7b8ad6f897..0000000000
--- 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 380d3ef446..e88ddfe567 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 5945c2ea49..0000000000
--- 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 b9c8b99d87..0000000000
--- 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}