2 * This file is part of mapper
4 * Copyright (C) 2007 Kaj-Michael Lang
5 * Copyright (C) 2006-2007 John Costigan.
7 * POI and GPS-Info code originally written by Cezary Jackiewicz.
9 * Default map data provided by http://www.openstreetmap.org/
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.
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.
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.
35 #include <osso-ic-dbus.h>
43 #include "map-download.h"
45 #include "config-gconf.h"
47 gboolean iap_connecting=FALSE;
48 gboolean iap_connected=FALSE;
50 /*************************************************************/
58 iap_callback(struct iap_event_t *event, void *arg)
60 iap_connecting = FALSE;
61 if (event->type == OSSO_IAP_CONNECTED && !iap_connected) {
63 config_update_proxy();
65 _curl_sid = g_timeout_add(100, (GSourceFunc)map_download_timeout, NULL);
70 get_connection_status_signal_cb(DBusConnection * connection, DBusMessage * message, void *user_data)
72 gchar *iap_name = NULL, *iap_nw_type = NULL, *iap_state = NULL;
75 if (!dbus_message_is_signal(message, ICD_DBUS_INTERFACE, ICD_STATUS_CHANGED_SIG)) {
76 g_printf("%s(): return DBUS_HANDLER_RESULT_NOT_YET_HANDLED\n", __PRETTY_FUNCTION__);
77 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
80 if (!dbus_message_get_args(message, NULL,
81 DBUS_TYPE_STRING, &iap_name,
82 DBUS_TYPE_STRING, &iap_nw_type,
83 DBUS_TYPE_STRING, &iap_state,
85 g_printf("%s(): return DBUS_HANDLER_RESULT_NOT_YET_HANDLED\n", __PRETTY_FUNCTION__);
86 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
89 g_printf(" > iap_state = %s\n", iap_state);
90 if (!strcmp(iap_state, "CONNECTED")) {
93 config_update_proxy();
95 _curl_sid = g_timeout_add(100, (GSourceFunc)map_download_timeout, NULL);
97 } else if (iap_connected) {
98 iap_connected = FALSE;
100 g_source_remove(_curl_sid);
104 g_printf("%s(): return DBUS_HANDLER_RESULT_HANDLED\n", __PRETTY_FUNCTION__);
105 return DBUS_HANDLER_RESULT_HANDLED;
111 if (!iap_connected && !iap_connecting) {
112 iap_connecting = TRUE;
113 osso_iap_connect(OSSO_IAP_ANY, OSSO_IAP_REQUESTED_CONNECT, NULL);
120 iap_is_connected(void)
122 return iap_connected;
127 /*************************************************************/
134 static ConIcConnection *connection=NULL;
137 iap_connection_cb(ConIcConnection *connection, ConIcConnectionEvent *event, gpointer user_data)
139 ConIcConnectionStatus status;
140 ConIcConnectionError error;
142 g_assert(CON_IC_IS_CONNECTION_EVENT(event));
144 status=con_ic_connection_event_get_status(event);
147 case CON_IC_STATUS_CONNECTED:
148 g_printf("Connected\n");
150 iap_connecting=FALSE;
152 case CON_IC_STATUS_DISCONNECTED:
153 g_printf("Disconnected\n");
155 iap_connecting=FALSE;
157 case CON_IC_STATUS_DISCONNECTING:
158 g_printf("Disconnecting\n");
159 iap_connecting=FALSE;
170 if (connection==NULL) {
171 connection=con_ic_connection_new();
172 g_signal_connect(G_OBJECT(connection), "connection-event", G_CALLBACK(iap_connection_cb), NULL);
174 if (iap_connecting==TRUE)
176 g_printf("Requesting connection\n");
178 return con_ic_connection_connect(connection, CON_IC_CONNECT_FLAG_NONE);
182 iap_is_connected(void)
184 #ifdef MAEMO_SDK_DEBUG
185 g_printerr("SDK: Assuming connection is ok.\n");
188 return iap_connected;
203 iap_is_connected(void)