[SPIN] Added the connman disconnect reason property.
[platform/upstream/connman.git] / gsupplicant / supplicant.c
index 8449fb9..89591fe 100755 (executable)
@@ -181,6 +181,9 @@ struct _GSupplicantInterface {
        GHashTable *bss_mapping;
        void *data;
        const char *pending_peer_path;
+#if defined TIZEN_EXT
+       int disconnect_reason;
+#endif
 };
 
 struct g_supplicant_bss {
@@ -2280,6 +2283,17 @@ static void interface_property(const char *key, DBusMessageIter *iter,
        } else if (g_strcmp0(key, "Networks") == 0) {
                supplicant_dbus_array_foreach(iter, interface_network_added,
                                                                interface);
+#if defined TIZEN_EXT
+       } else if (g_strcmp0(key, "DisconnectReason") == 0) {
+               int disconnect_reason = 0;
+
+               dbus_message_iter_get_basic(iter, &disconnect_reason);
+               interface->disconnect_reason = disconnect_reason;
+
+               SUPPLICANT_DBG("disconnect reason (%d)",
+                               interface->disconnect_reason);
+
+#endif
        } else
                SUPPLICANT_DBG("key %s type %c",
                                key, dbus_message_iter_get_arg_type(iter));
@@ -2663,7 +2677,9 @@ static void signal_bss_changed(const char *path, DBusMessageIter *iter)
                return;
 
        supplicant_dbus_property_foreach(iter, bss_property, bss);
-
+#if defined TIZEN_EXT
+       network->frequency = bss->frequency;
+#endif
        old_security = network->security;
        bss_compute_security(bss);
 
@@ -4267,8 +4283,14 @@ static int interface_ready_to_scan(GSupplicantInterface *interface)
        case G_SUPPLICANT_STATE_4WAY_HANDSHAKE:
        case G_SUPPLICANT_STATE_GROUP_HANDSHAKE:
                return -EBUSY;
+#if defined TIZEN_EXT
+       case G_SUPPLICANT_STATE_DISABLED:
+               return -ENOLINK;
+       case G_SUPPLICANT_STATE_UNKNOWN:
+#else
        case G_SUPPLICANT_STATE_UNKNOWN:
        case G_SUPPLICANT_STATE_DISABLED:
+#endif
        case G_SUPPLICANT_STATE_DISCONNECTED:
        case G_SUPPLICANT_STATE_INACTIVE:
        case G_SUPPLICANT_STATE_SCANNING:
@@ -5643,6 +5665,23 @@ int g_supplicant_interface_remove_network(GSupplicantInterface *interface)
 
        return network_remove(data);
 }
+
+int g_supplicant_interface_get_disconnect_reason(GSupplicantInterface *interface)
+{
+       int reason_code = 0;
+
+       SUPPLICANT_DBG("");
+
+       if (interface == NULL)
+               return -EINVAL;
+
+       if (system_available == FALSE)
+               return -EFAULT;
+
+       reason_code = interface->disconnect_reason;
+
+       return reason_code;
+}
 #endif
 
 static const char *g_supplicant_rule0 = "type=signal,"