Mark access points with "linksys" SSID as unique
[connman] / plugins / bluetooth.c
index 8f90a98..009c6c7 100644 (file)
@@ -2,7 +2,7 @@
  *
  *  Connection Manager
  *
- *  Copyright (C) 2007-2008  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2007-2009  Intel Corporation. All rights reserved.
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License version 2 as
@@ -117,6 +117,13 @@ static void get_properties(DBusConnection *connection,
                return;
        }
 
+       if (call == NULL) {
+               connman_error("D-Bus connection not available");
+               dbus_message_unref(message);
+               g_free(data);
+               return;
+       }
+
        data->connection = connection;
        data->message    = message;
        data->callback   = callback;
@@ -218,7 +225,7 @@ done:
 static int pan_connect(struct connman_network *network)
 {
        struct network_data *data = connman_network_get_data(network);
-       const char *path = connman_network_get_path(network);
+       const char *path = connman_network_get_string(network, "Node");
        const char *uuid = "nap";
        DBusMessage *message;
        DBusPendingCall *call;
@@ -240,6 +247,12 @@ static int pan_connect(struct connman_network *network)
                return -EINVAL;
        }
 
+       if (call == NULL) {
+               connman_error("D-Bus connection not available");
+               dbus_message_unref(message);
+               return -EINVAL;
+       }
+
        dbus_pending_call_set_notify(call, connect_reply, network, NULL);
 
        dbus_message_unref(message);
@@ -284,7 +297,7 @@ done:
 static int pan_disconnect(struct connman_network *network)
 {
        struct network_data *data = connman_network_get_data(network);
-       const char *path = connman_network_get_path(network);
+       const char *path = connman_network_get_string(network, "Node");
        DBusMessage *message;
        DBusPendingCall *call;
 
@@ -298,8 +311,7 @@ static int pan_disconnect(struct connman_network *network)
        if (message == NULL)
                return -ENOMEM;
 
-       dbus_message_append_args(message, DBUS_TYPE_STRING, &data->interface,
-                                                       DBUS_TYPE_INVALID);
+       dbus_message_append_args(message, DBUS_TYPE_INVALID);
 
        if (dbus_connection_send_with_reply(data->connection, message,
                                                &call, TIMEOUT) == FALSE) {
@@ -308,6 +320,12 @@ static int pan_disconnect(struct connman_network *network)
                return -EINVAL;
        }
 
+       if (call == NULL) {
+               connman_error("D-Bus connection not available");
+               dbus_message_unref(message);
+               return -EINVAL;
+       }
+
        dbus_pending_call_set_notify(call, disconnect_reply, network, NULL);
 
        dbus_message_unref(message);
@@ -394,6 +412,12 @@ static int change_powered(DBusConnection *connection, const char *path,
                return -EINVAL;
        }
 
+       if (call == NULL) {
+               connman_error("D-Bus connection not available");
+               dbus_message_unref(message);
+               return -EINVAL;
+       }
+
        dbus_pending_call_set_notify(call, powered_reply, NULL, NULL);
 
        dbus_message_unref(message);
@@ -404,7 +428,7 @@ static int change_powered(DBusConnection *connection, const char *path,
 static int bluetooth_enable(struct connman_device *adapter)
 {
        struct adapter_data *data = connman_device_get_data(adapter);
-       const char *path = connman_device_get_path(adapter);
+       const char *path = connman_device_get_string(adapter, "Node");
 
        DBG("adapter %p", adapter);
 
@@ -414,7 +438,7 @@ static int bluetooth_enable(struct connman_device *adapter)
 static int bluetooth_disable(struct connman_device *adapter)
 {
        struct adapter_data *data = connman_device_get_data(adapter);
-       const char *path = connman_device_get_path(adapter);
+       const char *path = connman_device_get_string(adapter, "Node");
 
        DBG("adapter %p", adapter);
 
@@ -465,7 +489,8 @@ static struct connman_device *find_adapter(const char *path)
 
        for (list = adapter_list; list; list = list->next) {
                struct connman_device *adapter = list->data;
-               const char *adapter_path = connman_device_get_path(adapter);
+               const char *adapter_path = connman_device_get_string(adapter,
+                                                                       "Node");
 
                if (adapter_path == NULL)
                        continue;
@@ -495,7 +520,9 @@ static void device_properties(DBusConnection *connection, const char *path,
        if (network == NULL)
                return;
 
-       connman_network_set_path(network, path);
+       connman_network_set_protocol(network, CONNMAN_NETWORK_PROTOCOL_IP);
+
+       connman_network_set_string(network, "Node", path);
 
        connman_device_add_network(device, network);
 }
@@ -614,7 +641,7 @@ static void adapter_properties(DBusConnection *connection, const char *path,
        if (adapter == NULL)
                return;
 
-       connman_device_set_path(adapter, path);
+       connman_device_set_string(adapter, "Node", path);
 
        if (node != NULL && g_str_has_prefix(node, "hci") == TRUE) {
                int index;
@@ -627,7 +654,7 @@ static void adapter_properties(DBusConnection *connection, const char *path,
        connman_device_set_interface(adapter, node);
 
        connman_device_set_policy(adapter, CONNMAN_DEVICE_POLICY_MANUAL);
-       connman_device_set_mode(adapter, CONNMAN_DEVICE_MODE_MULTIPLE_NETWORKS);
+       connman_device_set_mode(adapter, CONNMAN_DEVICE_MODE_NETWORK_MULTIPLE);
 
        if (connman_device_register(adapter) < 0) {
                connman_device_unref(adapter);
@@ -716,13 +743,18 @@ static void bluetooth_connect(DBusConnection *connection, void *user_data)
        if (dbus_connection_send_with_reply(connection, message,
                                                &call, TIMEOUT) == FALSE) {
                connman_error("Failed to get Bluetooth adapters");
-               dbus_message_unref(message);
-               return;
+               goto done;
+       }
+
+       if (call == NULL) {
+               connman_error("D-Bus connection not available");
+               goto done;
        }
 
        dbus_pending_call_set_notify(call, list_adapters_reply,
                                                        connection, NULL);
 
+done:
        dbus_message_unref(message);
 }
 
@@ -847,4 +879,4 @@ static void bluetooth_exit(void)
 }
 
 CONNMAN_PLUGIN_DEFINE(bluetooth, "Bluetooth technology plugin", VERSION,
-                                               bluetooth_init, bluetooth_exit)
+               CONNMAN_PLUGIN_PRIORITY_DEFAULT, bluetooth_init, bluetooth_exit)