#include <config.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
+
+#ifdef WITH_CONIC
+#include <conic.h>
+#endif
#include "iap.h"
#include "map-download.h"
#include "config-gconf.h"
gboolean iap_connecting=FALSE;
-gboolean iap_connected=TRUE;
+gboolean iap_connected=FALSE;
+
+/*************************************************************/
+
+/**
+ * Old OSSO IC
+ */
+#ifdef WITH_OSSO_IC
-void iap_callback(struct iap_event_t *event, void *arg)
+void
+iap_callback(struct iap_event_t *event, void *arg)
{
iap_connecting = FALSE;
if (event->type == OSSO_IAP_CONNECTED && !iap_connected) {
}
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;
/* 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__);
+ g_printf("%s(): return DBUS_HANDLER_RESULT_NOT_YET_HANDLED\n", __PRETTY_FUNCTION__);
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
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__);
+ 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);
+g_printf(" > iap_state = %s\n", iap_state);
if (!strcmp(iap_state, "CONNECTED")) {
if (!iap_connected) {
iap_connected = TRUE;
_curl_sid = 0;
}
}
-vprintf("%s(): return DBUS_HANDLER_RESULT_HANDLED\n", __PRETTY_FUNCTION__);
+g_printf("%s(): return DBUS_HANDLER_RESULT_HANDLED\n", __PRETTY_FUNCTION__);
return DBUS_HANDLER_RESULT_HANDLED;
}
-void
+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
+
+#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
return iap_connected;
}
+#endif
+
#else
+/* !WITH_OSSO */
+
+gboolean
+iap_connect(void)
+{
+return TRUE;
+}
+
+gboolean
+iap_is_connected(void)
+{
+return TRUE;
+}
#endif
static gint
mapper_osso_cb_init(void)
{
-#ifdef WITH_OSSO
gchar *filter_string;
+#ifdef WITH_OSSO
if (OSSO_OK != osso_rpc_set_default_cb_f(_osso, dbus_cb_default, NULL)) {
g_printerr("osso_rpc_set_default_cb_f failed.\n");
return 1;
/* add match */
dbus_bus_add_match(dbus_conn, filter_string, NULL);
g_free(filter_string);
+#endif
+
/* add the callback */
+#ifdef WITH_OSSO_IC
dbus_connection_add_filter(dbus_conn, get_connection_status_signal_cb, NULL, NULL);
-
osso_iap_cb(iap_callback);
-
#endif
+
return 0;
}
mis=MAPPER_INIT_MISC;
break;
case MAPPER_INIT_MISC:
- #ifdef WITH_OSSO
- osso_hw_set_event_cb(_osso, NULL, osso_cb_hw_state, NULL);
- #endif
-
- /* Initialize D-Bus. */
+ /* Initialize D-Bus system connection. */
if (NULL == (dbus_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error))) {
g_printerr("Failed to open connection to D-Bus: %s.\n", error->message);
error = NULL;
}
+
+ /* XXX: Move this */
+ #ifdef WITH_OSSO
+ osso_hw_set_event_cb(_osso, NULL, osso_cb_hw_state, NULL);
+ #endif
+
#ifdef WITH_HILDON_DBUS_BT
if (NULL == (_rfcomm_req_proxy = dbus_g_proxy_new_for_name(dbus_conn, BTCOND_SERVICE, BTCOND_REQ_PATH, BTCOND_REQ_INTERFACE))) {
g_printerr("Failed to open connection to %s.\n", BTCOND_REQ_INTERFACE);