]> err.no Git - mapper/commitdiff
Add (untested) libconic support
authorKaj-Michael Lang <milang@onion.tal.org>
Thu, 18 Oct 2007 22:57:15 +0000 (01:57 +0300)
committerKaj-Michael Lang <milang@onion.tal.org>
Thu, 18 Oct 2007 22:57:15 +0000 (01:57 +0300)
src/iap.c
src/iap.h
src/mapper.c

index c26c19f2b9fbbace655b2dc87f0fbf45cf86f592..abf09a34aa09dfe9f506b5b60dee972d3d3ae6c6 100644 (file)
--- a/src/iap.c
+++ b/src/iap.c
@@ -1,11 +1,16 @@
 #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) {
@@ -27,14 +40,13 @@ 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;
 }
 
@@ -43,11 +55,11 @@ if (!dbus_message_get_args(message, NULL,
                   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;
@@ -62,17 +74,76 @@ if (!strcmp(iap_state, "CONNECTED")) {
                        _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
@@ -81,6 +152,21 @@ iap_is_connected(void)
 return iap_connected;
 }
 
+#endif
+
 #else
+/* !WITH_OSSO */
+
+gboolean
+iap_connect(void)
+{
+return TRUE;
+}
+
+gboolean
+iap_is_connected(void)
+{
+return TRUE;
+}
 
 #endif
index 3d15708d0581c42bd4ab7beaa950c3b4a0f5dfbb..d496966f2f0ea811e1df5f92cca5b82df09a6d2c 100644 (file)
--- a/src/iap.h
+++ b/src/iap.h
@@ -1,7 +1,14 @@
 #ifndef _IAP_H
 #define _IAP_H
 
+#include <config.h>
+
+#ifdef WITH_OSSO_IC
 void iap_callback(struct iap_event_t *event, void *arg);
 DBusHandlerResult get_connection_status_signal_cb(DBusConnection * connection, DBusMessage * message, void *user_data);
+#endif
+
+gboolean iap_connect(void);
+gboolean iap_is_connected(void);
 
 #endif
index e3a1ea6bf67d6c2638c5d16c92a0d50ff7ef5ff1..989b5a68848f1c32f478e23ccdaa5089f0e45a97 100644 (file)
@@ -162,9 +162,9 @@ return 0;
 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;
@@ -174,12 +174,14 @@ filter_string = g_strdup_printf("interface=%s", ICD_DBUS_INTERFACE);
 /* 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;
 }
 
@@ -232,15 +234,17 @@ switch (mis) {
                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);