Fix dereference after null check
[platform/upstream/connman.git] / src / technology.c
index 34476df..f16ee38 100644 (file)
@@ -711,6 +711,7 @@ static void append_properties(DBusMessageIter *iter,
                                        DBUS_TYPE_STRING,
                                        &technology->tethering_passphrase);
 
+#if defined TIZEN_EXT
        connman_dbus_dict_append_basic(&dict, "MacPolicy",
                                        DBUS_TYPE_UINT32,
                                        &(technology->mac_policy));
@@ -722,10 +723,14 @@ static void append_properties(DBusMessageIter *iter,
        connman_dbus_dict_append_basic(&dict, "RandomMacLifetime",
                                        DBUS_TYPE_UINT32,
                                        &(technology->random_mac_lifetime));
-#if defined TIZEN_EXT
+
        if (technology->type == CONNMAN_SERVICE_TYPE_WIFI)
                connman_dbus_dict_append_dict(&dict, "Device.List",
                                        append_devices, technology);
+       if (technology->regdom)
+               connman_dbus_dict_append_basic(&dict, "CountryCode",
+                                       DBUS_TYPE_STRING,
+                                       &technology->regdom);
 #endif
        connman_dbus_dict_close(iter, &dict);
 }
@@ -1658,6 +1663,43 @@ static void __connman_technology_notify_device_detected(
 
        DBG("Successfuly sent DeviceDetected signal");
 }
+
+void __connman_technology_notify_roaming_state(const char *ifname,
+               const char *state, const char *cur_bssid, const char *dst_bssid)
+{
+       DBG("");
+       DBusMessage *signal;
+       DBusMessageIter array, dict;
+
+       signal = dbus_message_new_signal(CONNMAN_MANAGER_PATH,
+                       CONNMAN_MANAGER_INTERFACE, "RoamingStateChanged");
+       if (!signal)
+               return;
+
+       dbus_message_iter_init_append(signal, &array);
+
+       connman_dbus_dict_open(&array, &dict);
+
+       if (ifname)
+               connman_dbus_dict_append_basic(&dict, "Interface",
+                                       DBUS_TYPE_STRING, &ifname);
+       if (state)
+               connman_dbus_dict_append_basic(&dict, "State",
+                                       DBUS_TYPE_STRING, &state);
+       if (cur_bssid)
+               connman_dbus_dict_append_basic(&dict, "ConnectedBSSID",
+                                       DBUS_TYPE_STRING, &cur_bssid);
+       if (dst_bssid)
+               connman_dbus_dict_append_basic(&dict, "TargetBSSID",
+                                       DBUS_TYPE_STRING, &dst_bssid);
+
+       connman_dbus_dict_close(&array, &dict);
+
+       dbus_connection_send(connection, signal, NULL);
+       dbus_message_unref(signal);
+
+       DBG("Successfully sent Roaming State Changed signal");
+}
 #endif
 
 void __connman_technology_scan_started(struct connman_device *device)
@@ -2210,10 +2252,17 @@ void technology_save_device(struct connman_device *device)
        enum connman_service_type type;
 
        type = __connman_device_get_service_type(device);
+
+       if (type != CONNMAN_SERVICE_TYPE_WIFI)
+               return;
+
        technology = technology_get(type);
        if (!technology)
                return;
 
+       if (!g_slist_find(technology->device_list, device))
+               return;
+
        GKeyFile *keyfile;
        gchar *identifier;
        const char *name = get_name(technology->type);
@@ -2235,7 +2284,7 @@ void technology_save_device(struct connman_device *device)
        gchar **ifname_list = NULL;
        guint dev_count = g_slist_length(technology->device_list);
 
-       if (dev_count > 1) {
+       if (dev_count >= 1) {
                GString *ifname_str = g_string_new(NULL);
 
                if (ifname_str) {
@@ -3215,7 +3264,7 @@ int __connman_technology_add_device(struct connman_device *device)
 #if defined TIZEN_EXT
                bool found = true;
                int err = 0;
-               if (technology->enabled_devices) {
+               if (technology->enabled_devices && type == CONNMAN_SERVICE_TYPE_WIFI) {
                        int i = 0;
                        found = false;
                        const char *ifname = connman_device_get_string(device, "Interface");
@@ -3252,6 +3301,8 @@ done:
                                                                device);
 
 #if defined TIZEN_EXT
+       technology_save_device(device);
+
        const char *ifname = connman_device_get_string(device, "Interface");
        __connman_technology_notify_device_detected(technology, ifname, true);
 
@@ -3282,6 +3333,8 @@ int __connman_technology_remove_device(struct connman_device *device)
                                                                device);
 
 #if defined TIZEN_EXT
+       technology_save_device(device);
+
        const char *ifname = connman_device_get_string(device, "Interface");
        __connman_technology_notify_device_detected(technology, ifname, false);
 #endif