]> err.no Git - mapper/blob - src/maemo-osso.c
More chinook changes
[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_OSSO
13 #include <libosso.h>
14
15 #ifdef WITH_OSSO_IC
16 #include <osso-ic.h>
17 #include <osso-ic-dbus.h>
18 #endif
19
20 #include "map.h"
21 #include "map-download.h"
22 #include "route.h"
23 #include "mapper-types.h"
24 #include "bt.h"
25 #include "gps.h"
26 #include "settings-gconf.h"
27 #include "settings.h"
28 #include "config-gconf.h"
29 #include "ui-common.h"
30
31 gint
32 dbus_cb_default(const gchar *interface, const gchar *method, GArray *arguments, gpointer data, osso_rpc_t *retval)
33 {
34 if(!strcmp(method, "top_application"))
35         gtk_idle_add((GSourceFunc)window_present, NULL);
36 retval->type = DBUS_TYPE_INVALID;
37
38 return OSSO_OK;
39 }
40
41 void
42 osso_cb_hw_state(osso_hw_state_t * state, gpointer data)
43 {
44 static gboolean _must_save_data = FALSE;
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                         if (gconf_client_get_bool(gconf_client, GCONF_KEY_DISCONNECT_ON_COVER, NULL)) {
52                                 gconf_client_clear_cache(gconf_client);
53                                 set_conn_state(RCVR_OFF);
54                                 rcvr_disconnect();
55                                 track_add(0, FALSE);
56                                 /* Pretend autoroute is in progress to avoid download. */
57                                 if (_autoroute_data.enabled)
58                                         _autoroute_data.in_progress = TRUE;
59                         }
60                 }
61                 if (_curl_sid) {
62                         g_source_remove(_curl_sid);
63                         _curl_sid = 0;
64                 }
65         }
66 } else if (state->save_unsaved_data_ind) {
67         config_save();
68         _must_save_data = TRUE;
69 } else if (state->memory_low_ind) {
70         /* Drop any memory we can.. */
71 } else {
72         if (_conn_state == RCVR_OFF && _enable_gps) {
73                 set_conn_state(RCVR_DOWN);
74                 rcvr_connect_later();
75                 if (_autoroute_data.enabled)
76                         _autoroute_data.in_progress = TRUE;
77         }
78
79         /* Start curl in case there are downloads pending. */
80         if (iap_is_connected() && !_curl_sid)
81                 _curl_sid = g_timeout_add(100, (GSourceFunc)map_download_timeout, NULL);
82 }
83 }
84
85 #else
86
87 void 
88 osso_cb_hw_state(void *state, gpointer data)
89 {
90 }
91
92 #endif