-#include <config.h>
-
-#ifdef WITH_HILDON
+/*
+ * This file is part of mapper
+ *
+ * Copyright (C) 2007 Kaj-Michael Lang
+ * Copyright (C) 2006-2007 John Costigan.
+ *
+ * POI and GPS-Info code originally written by Cezary Jackiewicz.
+ *
+ * Default map data provided by http://www.openstreetmap.org/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <strings.h>
-#include <stddef.h>
-#include <errno.h>
-#include <sys/wait.h>
-#include <glib/gstdio.h>
-#include <gtk/gtk.h>
-#include <fcntl.h>
+#include <config.h>
-#include <curl/multi.h>
+#include <glib.h>
-#include <dbus/dbus-glib.h>
-#include <bt-dbus.h>
+#ifdef WITH_OSSO
#include <libosso.h>
-#include <osso-helplib.h>
-#include <osso-ic-dbus.h>
+
+#ifdef WITH_OSSO_IC
#include <osso-ic.h>
+#include <osso-ic-dbus.h>
+#endif
-#include "settings.h"
+#ifdef WITH_CONIC
+#include <conic.h>
+#endif
+
+#include "iap.h"
+#include "map-download.h"
#include "gps.h"
-#include "map.h"
+#include "config-gconf.h"
+
+gboolean iap_connecting=FALSE;
+gboolean iap_connected=FALSE;
-gboolean _iap_connecting=FALSE;
-gboolean _iap_connected=FALSE;
+/*************************************************************/
-void iap_callback(struct iap_event_t *event, void *arg)
+/**
+ * Old OSSO IC
+ */
+#ifdef WITH_OSSO_IC
+
+void
+iap_callback(struct iap_event_t *event, void *arg)
{
- printf("%s()\n", __PRETTY_FUNCTION__);
- _iap_connecting = FALSE;
- if (event->type == OSSO_IAP_CONNECTED && !_iap_connected) {
- _iap_connected = TRUE;
- config_update_proxy();
- if (!_curl_sid)
- _curl_sid = g_timeout_add(100,
- (GSourceFunc)
- curl_download_timeout, NULL);
- }
- vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+iap_connecting = FALSE;
+if (event->type == OSSO_IAP_CONNECTED && !iap_connected) {
+ iap_connected = TRUE;
+ config_update_proxy();
+ if (!_curl_sid)
+ _curl_sid = g_timeout_add(100, (GSourceFunc)map_download_timeout, NULL);
+}
}
DBusHandlerResult
-get_connection_status_signal_cb(DBusConnection * connection,
- DBusMessage * message, void *user_data)
+get_connection_status_signal_cb(DBusConnection * connection, DBusMessage * message, void *user_data)
{
- gchar *iap_name = NULL, *iap_nw_type = NULL, *iap_state = NULL;
- printf("%s()\n", __PRETTY_FUNCTION__);
-
- /* check signal */
- if (!dbus_message_is_signal(message,
- ICD_DBUS_INTERFACE,
- ICD_STATUS_CHANGED_SIG)) {
- vprintf("%s(): return DBUS_HANDLER_RESULT_NOT_YET_HANDLED\n",
- __PRETTY_FUNCTION__);
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- }
+gchar *iap_name = NULL, *iap_nw_type = NULL, *iap_state = NULL;
+
+/* check signal */
+if (!dbus_message_is_signal(message, ICD_DBUS_INTERFACE, ICD_STATUS_CHANGED_SIG)) {
+ g_printf("%s(): return DBUS_HANDLER_RESULT_NOT_YET_HANDLED\n", __PRETTY_FUNCTION__);
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
- if (!dbus_message_get_args(message, NULL,
- DBUS_TYPE_STRING, &iap_name,
- DBUS_TYPE_STRING, &iap_nw_type,
- DBUS_TYPE_STRING, &iap_state,
- DBUS_TYPE_INVALID)) {
- vprintf("%s(): return DBUS_HANDLER_RESULT_NOT_YET_HANDLED\n",
- __PRETTY_FUNCTION__);
+if (!dbus_message_get_args(message, NULL,
+ DBUS_TYPE_STRING, &iap_name,
+ DBUS_TYPE_STRING, &iap_nw_type,
+ DBUS_TYPE_STRING, &iap_state,
+ DBUS_TYPE_INVALID)) {
+ g_printf("%s(): return DBUS_HANDLER_RESULT_NOT_YET_HANDLED\n", __PRETTY_FUNCTION__);
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- }
+}
- printf(" > iap_state = %s\n", iap_state);
- if (!strcmp(iap_state, "CONNECTED")) {
- if (!_iap_connected) {
- _iap_connected = TRUE;
- config_update_proxy();
- if (!_curl_sid)
- _curl_sid = g_timeout_add(100,
- (GSourceFunc)
- curl_download_timeout,
- NULL);
+g_printf(" > iap_state = %s\n", iap_state);
+if (!strcmp(iap_state, "CONNECTED")) {
+ if (!iap_connected) {
+ iap_connected = TRUE;
+ config_update_proxy();
+ if (!_curl_sid)
+ _curl_sid = g_timeout_add(100, (GSourceFunc)map_download_timeout, NULL);
}
- } else if (_iap_connected) {
- _iap_connected = FALSE;
+ } else if (iap_connected) {
+ iap_connected = FALSE;
if (_curl_sid) {
g_source_remove(_curl_sid);
_curl_sid = 0;
}
}
+g_printf("%s(): return DBUS_HANDLER_RESULT_HANDLED\n", __PRETTY_FUNCTION__);
+return DBUS_HANDLER_RESULT_HANDLED;
+}
- vprintf("%s(): return DBUS_HANDLER_RESULT_HANDLED\n",
- __PRETTY_FUNCTION__);
- return DBUS_HANDLER_RESULT_HANDLED;
+gboolean
+iap_connect(void)
+{
+if (!iap_connected && !iap_connecting) {
+ iap_connecting = TRUE;
+ osso_iap_connect(OSSO_IAP_ANY, OSSO_IAP_REQUESTED_CONNECT, NULL);
+ return TRUE;
+}
+return FALSE;
+}
+
+gboolean
+iap_is_connected(void)
+{
+return iap_connected;
}
+#endif
+
+/*************************************************************/
+/*
+ * libconic
+ *
+ */
+
+#ifdef WITH_CONIC
+static ConIcConnection *connection=NULL;
+
+static void
+iap_connection_cb(ConIcConnection *connection, ConIcConnectionEvent *event, gpointer user_data)
+{
+ConIcConnectionStatus status;
+ConIcConnectionError error;
+
+g_assert(CON_IC_IS_CONNECTION_EVENT(event));
+
+status=con_ic_connection_event_get_status(event);
+
+switch (status) {
+ case CON_IC_STATUS_CONNECTED:
+ g_printf("Connected\n");
+ iap_connected=TRUE;
+ iap_connecting=FALSE;
+ break;
+ case CON_IC_STATUS_DISCONNECTED:
+ g_printf("Disconnected\n");
+ iap_connected=FALSE;
+ iap_connecting=FALSE;
+ break;
+ case CON_IC_STATUS_DISCONNECTING:
+ g_printf("Disconnecting\n");
+ iap_connecting=FALSE;
+ break;
+ default:
+ break;
+}
+
+}
+
+gboolean
+iap_connect(void)
+{
+if (connection==NULL) {
+ connection=con_ic_connection_new();
+ g_signal_connect(G_OBJECT(connection), "connection-event", G_CALLBACK(iap_connection_cb), NULL);
+}
+if (iap_connecting==TRUE)
+ return TRUE;
+g_printf("Requesting connection\n");
+iap_connecting=TRUE;
+return con_ic_connection_connect(connection, CON_IC_CONNECT_FLAG_NONE);
+}
+
+gboolean
+iap_is_connected(void)
+{
+#ifdef MAEMO_SDK_DEBUG
+g_printerr("SDK: Assuming connection is ok.\n");
+return TRUE;
+#endif
+return iap_connected;
+}
+
+#endif
+
#else
+/* !WITH_OSSO */
+
+gboolean
+iap_connect(void)
+{
+return TRUE;
+}
+
+gboolean
+iap_is_connected(void)
+{
+return TRUE;
+}
#endif