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);
44 LocationAccuracy *acc = (LocationAccuracy*) accuracy;
46 case VELOCITY_UPDATED: {
47 LocationVelocity *vel = (LocationVelocity*) data;
48 g_debug ("ASYNC>> Current velocity> time: %d, speed: %f, direction:%f, climb:%f",
49 vel->timestamp, vel->speed, vel->direction, vel->climb);
50 g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
51 acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
57 cb_service_enabled (GObject *self,
61 g_debug("cb_service_enabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
63 LocationObject *loc = (LocationObject*)userdata;
64 LocationAccuracy *acc = NULL;
65 LocationVelocity *vel = NULL;
67 if (LOCATION_ERROR_NONE == location_get_velocity (loc, &vel, &acc)) {
68 g_debug ("SYNC>> Current velocity> time: %d, speed: %f, direction:%f, climb:%f",
69 vel->timestamp, vel->speed, vel->direction, vel->climb);
70 g_debug ("\tAccuracy level %d (%.0f meters %.0f meters)",
71 acc->level, acc->horizontal_accuracy, acc->vertical_accuracy);
72 location_velocity_free(vel);
73 location_accuracy_free(acc);
74 } else g_warning ("SYNC>> Current velocity> failed");
78 cb_service_disabled (GObject *self,
82 g_debug("cb_service_disabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
86 main (int argc, char *argv[])
88 LocationObject *loc = NULL;
92 loop = g_main_loop_new (NULL, TRUE);
94 loc = location_new (LOCATION_METHOD_GPS);
96 g_debug("location_new failed");
100 g_signal_connect (loc, "service-enabled", G_CALLBACK(cb_service_enabled), loc);
101 g_signal_connect (loc, "service-disabled", G_CALLBACK(cb_service_disabled), loc);
102 g_signal_connect (loc, "service-updated", G_CALLBACK(cb_service_updated), loc);
104 if( LOCATION_ERROR_NONE != location_start (loc) ){
105 g_debug("location_start failed");
109 g_timeout_add_seconds(60, exit_program, NULL);
110 g_main_loop_run (loop);