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_updated (GObject *self,
42 g_debug("cb_service_updated: type(%d) userdata(0x%x)", type, (unsigned int)userdata);
46 cb_service_enabled (GObject *self,
50 g_debug("cb_service_enabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
54 cb_service_disabled (GObject *self,
58 g_debug("cb_service_disabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
62 main (int argc, char *argv[])
64 LocationObject *loc = NULL;
68 loop = g_main_loop_new (NULL, TRUE);
70 loc = location_new (LOCATION_METHOD_GPS);
72 g_debug("location_new failed");
76 LocationMethod method = LOCATION_METHOD_NONE;
77 g_object_get(loc, "method", &method, NULL);
78 g_debug("Get property>> method:%d", method);
81 g_object_get(loc, "dev-name", &devname, NULL);
83 g_debug("Get property>> dev-name: %s", devname);
85 } else g_warning("failed to get property> dev-name");
87 g_object_set(loc, "dev-name", "/dev/test", NULL);
88 g_object_get(loc, "dev-name", &devname, NULL);
90 g_debug("Get property>> dev-name: %s", devname);
92 } else g_warning("failed to set property> dev-name");
94 g_signal_connect (loc, "service-enabled", G_CALLBACK(cb_service_enabled), loc);
95 g_signal_connect (loc, "service-disabled", G_CALLBACK(cb_service_disabled), loc);
96 g_signal_connect (loc, "service-updated", G_CALLBACK(cb_service_updated), loc);
98 if( LOCATION_ERROR_NONE != location_start (loc) ){
99 g_debug("location_start failed");
103 g_timeout_add_seconds (60, exit_program, NULL);
104 g_main_loop_run (loop);
108 LocationPosition *pos = NULL;
109 g_object_get(loc, "last-position", &pos, NULL);
111 g_debug ("Get property>> last-position> time: %d, lat: %f, long: %f, alt: %f, status: %d",
112 pos->timestamp, pos->latitude, pos->longitude, pos->altitude, pos->status);
113 location_position_free(pos);
114 } else g_warning("failed to get property> last-position");