10 #include <osso-ic-dbus.h>
18 #include "map-download.h"
20 #include "config-gconf.h"
22 gboolean iap_connecting=FALSE;
23 gboolean iap_connected=FALSE;
25 /*************************************************************/
33 iap_callback(struct iap_event_t *event, void *arg)
35 iap_connecting = FALSE;
36 if (event->type == OSSO_IAP_CONNECTED && !iap_connected) {
38 config_update_proxy();
40 _curl_sid = g_timeout_add(100, (GSourceFunc)map_download_timeout, NULL);
45 get_connection_status_signal_cb(DBusConnection * connection, DBusMessage * message, void *user_data)
47 gchar *iap_name = NULL, *iap_nw_type = NULL, *iap_state = NULL;
50 if (!dbus_message_is_signal(message, ICD_DBUS_INTERFACE, ICD_STATUS_CHANGED_SIG)) {
51 g_printf("%s(): return DBUS_HANDLER_RESULT_NOT_YET_HANDLED\n", __PRETTY_FUNCTION__);
52 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
55 if (!dbus_message_get_args(message, NULL,
56 DBUS_TYPE_STRING, &iap_name,
57 DBUS_TYPE_STRING, &iap_nw_type,
58 DBUS_TYPE_STRING, &iap_state,
60 g_printf("%s(): return DBUS_HANDLER_RESULT_NOT_YET_HANDLED\n", __PRETTY_FUNCTION__);
61 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
64 g_printf(" > iap_state = %s\n", iap_state);
65 if (!strcmp(iap_state, "CONNECTED")) {
68 config_update_proxy();
70 _curl_sid = g_timeout_add(100, (GSourceFunc)map_download_timeout, NULL);
72 } else if (iap_connected) {
73 iap_connected = FALSE;
75 g_source_remove(_curl_sid);
79 g_printf("%s(): return DBUS_HANDLER_RESULT_HANDLED\n", __PRETTY_FUNCTION__);
80 return DBUS_HANDLER_RESULT_HANDLED;
86 if (!iap_connected && !iap_connecting) {
87 iap_connecting = TRUE;
88 osso_iap_connect(OSSO_IAP_ANY, OSSO_IAP_REQUESTED_CONNECT, NULL);
95 iap_is_connected(void)
104 static ConIcConnection *connection=NULL;
107 iap_connection_cb(ConIcConnection *connection, ConIcConnectionEvent *event, gpointer user_data)
109 ConIcConnectionStatus status;
110 ConIcConnectionError error;
112 g_assert(CON_IC_IS_CONNECTION_EVENT(event));
114 status=con_ic_connection_event_get_status(event);
117 case CON_IC_STATUS_CONNECTED:
118 g_printf("Connected\n");
120 iap_connecting=FALSE;
122 case CON_IC_STATUS_DISCONNECTED:
123 g_printf("Disconnected\n");
125 iap_connecting=FALSE;
127 case CON_IC_STATUS_DISCONNECTING:
128 g_printf("Disconnecting\n");
129 iap_connecting=FALSE;
140 if (connection==NULL) {
141 connection=con_ic_connection_new();
142 g_signal_connect(G_OBJECT(connection), "connection-event", G_CALLBACK(iap_connection_cb), NULL);
144 if (iap_connecting==TRUE)
146 g_printf("Requesting connection\n");
148 return con_ic_connection_connect(connection, CON_IC_CONNECT_FLAG_NONE);
152 iap_is_connected(void)
154 return iap_connected;
169 iap_is_connected(void)