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