]> err.no Git - mapper/blob - src/maemo-osso.c
Merge branch 'master' of git+ssh://tal.org/home/git/mapper
[mapper] / src / maemo-osso.c
1 /*
2  * This file is part of mapper
3  *
4  * Copyright (C) 2007 Kaj-Michael Lang
5  * Copyright (C) 2006-2007 John Costigan.
6  *
7  * POI and GPS-Info code originally written by Cezary Jackiewicz.
8  *
9  * Default map data provided by http://www.openstreetmap.org/
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License along
22  * with this program; if not, write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  */
25
26 /* 
27  * Maemo hardware specific functions 
28  */
29
30 #include <config.h>
31
32 #define _GNU_SOURCE
33
34 #include <glib.h>
35 #include <gtk/gtk.h>
36
37 #ifdef WITH_OSSO
38 #include <libosso.h>
39
40 #ifdef WITH_OSSO_IC
41 #include <osso-ic.h>
42 #include <osso-ic-dbus.h>
43 #endif
44
45 #include "map.h"
46 #include "map-download.h"
47 #include "route.h"
48 #include "mapper-types.h"
49 #include "bt.h"
50 #include "gps.h"
51 #include "settings-gconf.h"
52 #include "settings.h"
53 #include "config-gconf.h"
54 #include "ui-common.h"
55
56 gint
57 dbus_cb_default(const gchar *interface, const gchar *method, GArray *arguments, gpointer data, osso_rpc_t *retval)
58 {
59 if(!strcmp(method, "top_application"))
60         gtk_idle_add((GSourceFunc)window_present, NULL);
61 retval->type = DBUS_TYPE_INVALID;
62
63 return OSSO_OK;
64 }
65
66 void
67 osso_cb_hw_state(osso_hw_state_t * state, gpointer data)
68 {
69 static gboolean _must_save_data = FALSE;
70
71 if (state->system_inactivity_ind) {
72         if (_must_save_data)
73                 _must_save_data = FALSE;
74         else {
75                 if (_conn_state > RCVR_OFF) {
76                         if (gconf_client_get_bool(gconf_client, GCONF_KEY_DISCONNECT_ON_COVER, NULL)) {
77                                 gconf_client_clear_cache(gconf_client);
78                                 gps_conn_set_state(RCVR_OFF);
79                                 rcvr_disconnect();
80                                 track_add(0, FALSE);
81                                 /* Pretend autoroute is in progress to avoid download. */
82                                 if (_autoroute_data.enabled)
83                                         _autoroute_data.in_progress = TRUE;
84                         }
85                 }
86                 if (_curl_sid) {
87                         g_source_remove(_curl_sid);
88                         _curl_sid = 0;
89                 }
90         }
91 } else if (state->save_unsaved_data_ind) {
92         config_save();
93         _must_save_data = TRUE;
94 } else if (state->memory_low_ind) {
95         /* Drop any memory we can.. */
96 } else {
97         if (_conn_state == RCVR_OFF && _enable_gps) {
98                 gps_conn_set_state(RCVR_DOWN);
99                 rcvr_connect_later();
100                 if (_autoroute_data.enabled)
101                         _autoroute_data.in_progress = TRUE;
102         }
103
104         /* Start curl in case there are downloads pending. */
105         if (iap_is_connected() && !_curl_sid)
106                 _curl_sid = g_timeout_add(100, (GSourceFunc)map_download_timeout, NULL);
107 }
108 }
109
110 #else
111
112 void 
113 osso_cb_hw_state(void *state, gpointer data)
114 {
115 }
116
117 #endif