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