Merge "Enable Wireguard VPN Plugin" into tizen
[platform/upstream/connman.git] / plugins / bluetooth.c
index f72a4af..704d216 100755 (executable)
@@ -212,22 +212,10 @@ static void pan_connect_cb(DBusMessage *message, void *user_data)
        DBusMessageIter iter;
 
        pan = g_hash_table_lookup(networks, path);
-       if (!pan) {
-               DBG("network already removed");
-               return;
-       }
-
-#ifdef TIZEN_EXT
-       /*
-        * Network could be removed because of BT adapter power off
-        * This is to handle the scenario where network is removed
-        * before the connect_cb is called
-        */
-       if (!pan->network) {
+       if (!pan || !pan->network) {
                DBG("network already removed");
                return;
        }
-#endif
 
        if (dbus_message_get_type(message) == DBUS_MESSAGE_TYPE_ERROR) {
                const char *dbus_error = dbus_message_get_error_name(message);
@@ -236,6 +224,7 @@ static void pan_connect_cb(DBusMessage *message, void *user_data)
 
                if (strcmp(dbus_error,
                                "org.bluez.Error.AlreadyConnected") != 0) {
+                       connman_network_set_associating(pan->network, false);
                        connman_network_set_error(pan->network,
                                CONNMAN_NETWORK_ERROR_ASSOCIATE_FAIL);
                        return;
@@ -293,7 +282,7 @@ static void pan_disconnect_cb(DBusMessage *message, void *user_data)
        struct bluetooth_pan *pan;
 
        pan = g_hash_table_lookup(networks, path);
-       if (!pan) {
+       if (!pan || !pan->network) {
                DBG("network already removed");
                return;
        }
@@ -366,6 +355,7 @@ static void pan_create_nap(struct bluetooth_pan *pan)
 {
        struct connman_device *device;
        const char* role;
+       const char *adapter;
 
        role = proxy_get_role(pan->btdevice_proxy);
        if (!role) {
@@ -373,8 +363,12 @@ static void pan_create_nap(struct bluetooth_pan *pan)
                return;
        }
 
-       device = g_hash_table_lookup(devices,
-                       proxy_get_string(pan->btdevice_proxy, "Adapter"));
+       adapter = proxy_get_string(pan->btdevice_proxy, "Adapter");
+
+       if (!adapter)
+               return;
+
+       device = g_hash_table_lookup(devices, adapter);
 
        if (!device || !connman_device_get_powered(device))
                return;
@@ -550,7 +544,6 @@ static void device_enable_cb(const DBusError *error, void *user_data)
 #if !defined TIZEN_EXT
        enable_device(device, path);
 #endif
-
 out:
        g_free(path);
 }
@@ -740,21 +733,23 @@ static bool tethering_create(const char *path,
                struct connman_technology *technology, const char *bridge,
                bool enabled)
 {
-       struct tethering_info *tethering;
+       struct tethering_info *tethering = g_new0(struct tethering_info, 1);
        GDBusProxy *proxy;
        const char *method;
        bool result;
 
        DBG("path %s bridge %s", path, bridge);
 
-       if (!bridge)
-               return -EINVAL;
+       if (!bridge) {
+               g_free(tethering);
+               return false;
+       }
 
        proxy = g_dbus_proxy_new(client, path, "org.bluez.NetworkServer1");
-       if (!proxy)
+       if (!proxy) {
+               g_free(tethering);
                return false;
-
-       tethering = g_new0(struct tethering_info, 1);
+       }
 
        tethering->technology = technology;
        tethering->bridge = g_strdup(bridge);
@@ -909,7 +904,7 @@ static void bluetooth_tech_remove(struct connman_technology *technology)
 
 static int bluetooth_tech_set_tethering(struct connman_technology *technology,
                const char *identifier, const char *passphrase,
-               const char *bridge, bool enabled, bool hidden)
+               const char *bridge, bool enabled)
 {
        GHashTableIter hash_iter;
        gpointer key, value;