]> err.no Git - mapper/blob - src/maemo-osso.c
Fixes so it builds for hildon. Not complete.
[mapper] / src / maemo-osso.c
1 /* 
2  * Maemo hardware specific functions 
3  */
4
5 #include <config.h>
6
7 #define _GNU_SOURCE
8
9 #include <glib.h>
10
11 #ifdef WITH_HILDON
12
13 #include <libosso.h>
14 #include <osso-helplib.h>
15 #include <osso-ic-dbus.h>
16 #include <osso-ic.h>
17
18 #include "map.h"
19 #include "route.h"
20 #include "mapper-types.h"
21 #include "bt.h"
22 #include "gps.h"
23 #include "settings-gconf.h"
24 #include "settings.h"
25
26 void osso_cb_hw_state(osso_hw_state_t * state, gpointer data)
27 {
28 static gboolean _must_save_data = FALSE;
29 printf("%s()\n", __PRETTY_FUNCTION__);
30
31 if (state->system_inactivity_ind) {
32         if (_must_save_data)
33                 _must_save_data = FALSE;
34         else {
35                 if (_conn_state > RCVR_OFF) {
36                         GConfClient *gconf_client = gconf_client_get_default();
37                         if (!gconf_client || gconf_client_get_bool(gconf_client,
38                                                      GCONF_KEY_DISCONNECT_ON_COVER,
39                                                      NULL)) {
40                                 gconf_client_clear_cache(gconf_client);
41                                 g_object_unref(gconf_client);
42                                 set_conn_state(RCVR_OFF);
43                                 rcvr_disconnect();
44                                 track_add(0, FALSE);
45                                 /* Pretend autoroute is in progress to avoid download. */
46                                 if (_autoroute_data.enabled)
47                                         _autoroute_data.in_progress = TRUE;
48                         }
49                 }
50                 if (_curl_sid) {
51                         g_source_remove(_curl_sid);
52                         _curl_sid = 0;
53                 }
54         }
55 } else if (state->save_unsaved_data_ind) {
56         config_save();
57         _must_save_data = TRUE;
58 } else if (state->memory_low_ind) {
59         /* Drop any memory we can.. */
60 } else {
61         if (_conn_state == RCVR_OFF && _enable_gps) {
62                 set_conn_state(RCVR_DOWN);
63                 rcvr_connect_later();
64                 if (_autoroute_data.enabled)
65                         _autoroute_data.in_progress = TRUE;
66         }
67
68         /* Start curl in case there are downloads pending. */
69         if (iap_is_connected() && !_curl_sid)
70                 _curl_sid = g_timeout_add(100,
71                                           (GSourceFunc)
72                                           curl_download_timeout, NULL);
73 }
74 vprintf("%s(): return\n", __PRETTY_FUNCTION__);
75 }
76
77 #else
78
79 void osso_cb_hw_state(void *state, gpointer data)
80 {
81 }
82
83 #endif