]> err.no Git - mapper/blob - src/maemo-osso.c
Fixes so it builds again under maemo scratchbox.
[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 #include <gtk/gtk.h>
11
12 #ifdef WITH_HILDON
13
14 #include <libosso.h>
15 #include <osso-ic-dbus.h>
16 #include <osso-ic.h>
17
18 #include "bt.h"
19 #include "gps.h"
20 #include "map.h"
21 #include "route.h"
22 #include "settings.h"
23 #include "ui-common.h"
24
25 gint
26 dbus_cb_default(const gchar *interface, const gchar *method,
27         GArray *arguments, gpointer data, osso_rpc_t *retval)
28 {
29 printf("%s()\n", __PRETTY_FUNCTION__);
30      
31 if(!strcmp(method, "top_application"))
32         gtk_idle_add((GSourceFunc)window_present, NULL);
33  
34 retval->type = DBUS_TYPE_INVALID;
35     
36 vprintf("%s(): return\n", __PRETTY_FUNCTION__);
37 return OSSO_OK;
38 }
39
40
41 void osso_cb_hw_state(osso_hw_state_t * state, gpointer data)
42 {
43         static gboolean _must_save_data = FALSE;
44         printf("%s()\n", __PRETTY_FUNCTION__);
45
46         if (state->system_inactivity_ind) {
47                 if (_must_save_data)
48                         _must_save_data = FALSE;
49                 else {
50                         if (_conn_state > RCVR_OFF) {
51                                 GConfClient *gconf_client =
52                                     gconf_client_get_default();
53                                 if (!gconf_client
54                                     || gconf_client_get_bool(gconf_client,
55                                                              GCONF_KEY_DISCONNECT_ON_COVER,
56                                                              NULL)) {
57                                         gconf_client_clear_cache(gconf_client);
58                                         g_object_unref(gconf_client);
59                                         set_conn_state(RCVR_OFF);
60                                         rcvr_disconnect();
61                                         track_add(0, FALSE);
62                                         /* Pretend autoroute is in progress to avoid download. */
63                                         if (_autoroute_data.enabled)
64                                                 _autoroute_data.in_progress = TRUE;
65                                 }
66                         }
67                         if (_curl_sid) {
68                                 g_source_remove(_curl_sid);
69                                 _curl_sid = 0;
70                         }
71                 }
72         } else if (state->save_unsaved_data_ind) {
73                 config_save();
74                 _must_save_data = TRUE;
75         } else if (state->memory_low_ind) {
76                 /* Drop any memory we can.. */
77         } else {
78                 if (_conn_state == RCVR_OFF && _enable_gps) {
79                         set_conn_state(RCVR_DOWN);
80                         rcvr_connect_later();
81                         if (_autoroute_data.enabled)
82                                 _autoroute_data.in_progress = TRUE;
83                 }
84
85                 /* Start curl in case there are downloads pending. */
86                 if (_iap_connected && !_curl_sid)
87                         _curl_sid = g_timeout_add(100,
88                                                   (GSourceFunc)
89                                                   curl_download_timeout, NULL);
90         }
91
92         vprintf("%s(): return\n", __PRETTY_FUNCTION__);
93 }
94
95 #else
96
97 void osso_cb_hw_state(void *state, gpointer data)
98 {
99 }
100
101 #endif