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;
26 GSource* sat_src = NULL;
29 exit_program (gpointer data)
31 g_main_loop_quit (loop);
32 g_debug ("Quit g_main_loop");
37 cb_service_updated (GObject *self,
43 g_debug("cb_service_updated: type(%d) userdata(0x%x)", type, (unsigned int)userdata);
45 LocationObject *loc = (LocationObject*)userdata;
46 LocationSatellite *sat = NULL;
49 g_object_get (loc, "satellite", &sat, NULL);
51 g_debug ("SYNC>> Current Sattelite> satellite in view = %d, satellite in used = %d", sat->num_of_sat_inview, sat->num_of_sat_used);
52 g_debug ("\tinview satellite information = ");
53 for (idx=0; idx<sat->num_of_sat_inview; idx++) {
59 location_satellite_get_satellite_details(sat, idx, &prn, &used, &elevation, &azimuth, &snr);
60 g_debug ("\t\t[%02d] used: %d, prn: %d, elevation: %d, azimuth: %d, snr: %d",
61 idx, used, prn, elevation, azimuth, snr);
63 location_satellite_free (sat);
64 } else g_warning ("SYNC>> Current Sattelite> failed");
68 cb_service_enabled (GObject *self,
72 g_debug("cb_service_enabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
76 cb_service_disabled (GObject *self,
80 g_debug("cb_service_disabled: status(%d) userdata(0x%x)", status, (unsigned int)userdata);
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 g_signal_connect (loc, "service-enabled", G_CALLBACK(cb_service_enabled), loc);
99 g_signal_connect (loc, "service-disabled", G_CALLBACK(cb_service_disabled), loc);
100 g_signal_connect (loc, "service-updated", G_CALLBACK(cb_service_updated), loc);
102 if( LOCATION_ERROR_NONE != location_start (loc) ){
103 g_debug("location_start failed");
107 g_timeout_add_seconds(60, exit_program, NULL);
108 g_main_loop_run (loop);