4 * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Youngae Kang <youngae.kang@samsung.com>, Yunhan Kim <yhan.kim@samsung.com>,
7 * Genie Kim <daejins.kim@samsung.com>, Minjune Kim <sena06.kim@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
25 static GMainLoop *loop = NULL;
28 exit_program (gpointer data)
30 g_main_loop_quit (loop);
31 g_debug ("Quit g_main_loop");
36 cb_service_enabled (GObject *self,
40 g_debug("cb_service_enabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
44 cb_service_disabled (GObject *self,
48 g_debug("cb_service_disabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
52 cb_zone_in (GObject *self,
57 g_debug("cb_zone_in: type(%d)", type);
58 LocationPosition *pos = (LocationPosition*) position;
59 LocationAccuracy *acc = (LocationAccuracy*) accuracy;
61 g_debug ("ASYNC>> ZoneIn> Current position: time: %d, lat: %f, long: %f, alt: %f",
62 pos->timestamp, pos->latitude, pos->longitude, pos->altitude);
63 g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
64 acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
68 cb_zone_out (GObject *self,
73 g_debug("cb_zone_out: type(%d)", type);
74 LocationPosition *pos = (LocationPosition*) position;
75 LocationAccuracy *acc = (LocationAccuracy*) accuracy;
77 g_debug ("ASYNC>> ZoneOut> Current position: time: %d, lat: %f, long: %f, alt: %f",
78 pos->timestamp, pos->latitude, pos->longitude, pos->altitude);
79 g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
80 acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
84 main (int argc, char *argv[])
86 LocationObject *loc = NULL;
90 loop = g_main_loop_new (NULL, TRUE);
92 loc = location_new (LOCATION_METHOD_GPS);
94 g_debug("location_new failed");
98 LocationPosition *rb = location_position_new(0, 37.258, 127.056, 0, LOCATION_STATUS_2D_FIX);
99 LocationPosition *lt = location_position_new(0, 37.260, 127.054, 0, LOCATION_STATUS_2D_FIX);
100 LocationBoundary *bound = location_boundary_new_for_rect(lt, rb);
101 location_position_free (rb);
102 location_position_free (lt);
104 g_object_set(loc, "boundary", bound, NULL);
105 location_boundary_free(bound);
106 } else g_warning("failed to location_boundary_new_for_rect()");
107 g_object_get(loc, "boundary", &bound, NULL);
109 g_debug("Set property>> boundary> type: %d, (%f,%f),(%f,%f)",
111 bound->rect.right_bottom->latitude, bound->rect.right_bottom->longitude,
112 bound->rect.left_top->latitude, bound->rect.left_top->longitude);
113 location_boundary_free (bound);
114 } else g_warning("failed to set property> boundary");
116 g_signal_connect (loc, "service-enabled", G_CALLBACK(cb_service_enabled), loc);
117 g_signal_connect (loc, "service-disabled", G_CALLBACK(cb_service_disabled), loc);
118 g_signal_connect (loc, "zone-in", G_CALLBACK(cb_zone_in), loc);
119 g_signal_connect (loc, "zone-out", G_CALLBACK(cb_zone_out), loc);
121 if( LOCATION_ERROR_NONE != location_start (loc) ){
122 g_debug("location_start failed");
126 g_timeout_add_seconds (60, exit_program, NULL);
127 g_main_loop_run (loop);