Network layout: Update the wireless list when connection is changed 33/49633/1 accepted/tizen/tv/20151019.073943 submit/tizen/20151016.071245 tizen_3.0.m2.a1_tv_release
authorHyojung Jo <hj903.jo@samsung.com>
Fri, 16 Oct 2015 05:39:20 +0000 (14:39 +0900)
committerHyojung Jo <hj903.jo@samsung.com>
Fri, 16 Oct 2015 05:39:20 +0000 (14:39 +0900)
Change-Id: I69be9a50426709c1528fbf485dc2ac4f76c89784
Signed-off-by: Hyojung Jo <hj903.jo@samsung.com>
include/listmgr.h
src/common/listmgr.c
src/data/data_wireless.c
src/layout/layout_network.c

index 59449b0..115f2c8 100644 (file)
@@ -32,5 +32,6 @@ bool listmgr_show_list(struct listmgr *listmgr, const char *list_id,
                const char *part, Eina_List *list);
 bool listmgr_hide_list(struct listmgr *listmgr, const char *list_id,
                const char *part);
+bool listmgr_update_list(struct listmgr *listmgr, const char *list_id);
 
 #endif /* __AIR_SETTINGS_LISTMGR_H__ */
index efb12f9..d49b0c4 100644 (file)
@@ -290,6 +290,41 @@ bool listmgr_show_list(struct listmgr *listmgr, const char *list_id,
        return true;
 }
 
+bool listmgr_update_list(struct listmgr *listmgr, const char *list_id)
+{
+       struct list_info *linfo;
+       Eina_List *list, *l;
+       Elm_Object_Item *it;
+
+       if (!listmgr || !list_id) {
+               _ERR("Invalid argument.");
+               return false;
+       }
+
+       linfo = _get_list_info(listmgr, list_id);
+       if (!linfo) {
+               _ERR("List %s does not exist.", list_id);
+               return false;
+       }
+
+       list = elm_gengrid_realized_items_get(linfo->grid);
+       if (!list) {
+               _ERR("List is NULL.");
+               return false;
+       }
+
+       EINA_LIST_FOREACH(list, l, it) {
+               if (!it)
+                       continue;
+
+               elm_gengrid_item_update(it);
+               elm_object_item_signal_callback_add(it, SIG_ITEM_SELECTED,
+                               SRC_EDC, _grid_item_selected_cb, linfo);
+       }
+
+       return true;
+}
+
 bool listmgr_hide_list(struct listmgr *listmgr, const char *list_id,
                const char *part)
 {
index bcb994e..579c7e4 100644 (file)
@@ -89,15 +89,62 @@ static bool _destroy(void *dclass_data)
                return false;
        }
 
+       if (priv->new_passcode)
+               free(priv->new_passcode);
+
        free(priv);
 
        return true;
 }
 
+static void _wifi_connection_state_changed_cb(wifi_connection_state_e state,
+               wifi_ap_h ap, void *data)
+{
+       wifi_connection_state_e connection_state;
+       struct wifi_ap_info *ap_info;
+       Eina_List *l;
+       struct _priv *priv;
+       char *essid;
+       int r;
+
+       if (!data) {
+               _ERR("Invalid argument.");
+               return;
+       }
+
+       priv = data;
+
+       r = wifi_ap_get_essid(ap, &essid);
+       if (r != WIFI_ERROR_NONE) {
+               _ERR("wifi_ap_get_essid failed.");
+               return;
+       }
+
+       r = wifi_ap_get_connection_state(ap, &connection_state);
+       if (r != WIFI_ERROR_NONE) {
+               _ERR("wifi_ap_get_connection_state failed.");
+               return;
+       }
+
+       EINA_LIST_FOREACH(priv->list, l, ap_info) {
+               if (!ap_info->ap || !ap_info->essid)
+                       continue;
+
+               if (!strcmp(ap_info->essid, essid)) {
+                       ap_info->connection_state = connection_state;
+                       break;
+               }
+       }
+
+       if (ap_info->connection_state == WIFI_CONNECTION_STATE_CONNECTED
+                       && priv->event_cb)
+               priv->event_cb(EVENT_DATA_SELECT_DONE, priv->cb_data);
+}
+
 static bool _wifi_found_ap_cb(wifi_ap_h ap, void *data)
 {
+       struct _priv *priv;
        struct wifi_ap_info *ap_info;
-       Eina_List **list;
        wifi_connection_state_e connection_state;
        wifi_security_type_e secure_type;
        char *essid;
@@ -108,7 +155,7 @@ static bool _wifi_found_ap_cb(wifi_ap_h ap, void *data)
                return EINA_FALSE;
        }
 
-       list = data;
+       priv = data;
 
        r = wifi_ap_get_essid(ap, &essid);
        if (r != WIFI_ERROR_NONE) {
@@ -141,11 +188,14 @@ static bool _wifi_found_ap_cb(wifi_ap_h ap, void *data)
                return EINA_TRUE;
        }
 
+       wifi_set_connection_state_changed_cb(_wifi_connection_state_changed_cb,
+                       priv);
+
        ap_info->essid = essid;
        ap_info->connection_state = connection_state;
        ap_info->secure_type = secure_type;
 
-       *list = eina_list_append(*list, ap_info);
+       priv->list = eina_list_append(priv->list, ap_info);
 
        return EINA_TRUE;
 }
@@ -177,7 +227,7 @@ static void _wifi_scan_finished_cb(wifi_error_e err, void *data)
        _free_wifi_list(priv->list);
        priv->list = NULL;
 
-       r = wifi_foreach_found_aps(_wifi_found_ap_cb, &priv->list);
+       r = wifi_foreach_found_aps(_wifi_found_ap_cb, priv);
        if (r != WIFI_ERROR_NONE) {
                _ERR("wifi_foreach_found_aps failed.");
                return;
@@ -275,9 +325,6 @@ static void _wifi_connected_cb(wifi_error_e err, void *data)
 
                return;
        }
-
-       if (priv->event_cb)
-               priv->event_cb(EVENT_DATA_SELECT_DONE, priv->cb_data);
 }
 
 static void _wifi_connect_new_ap(struct _priv *priv)
index 6ed051b..889d0ae 100644 (file)
@@ -297,14 +297,12 @@ static void _data_event_cb(enum event_type type, void *data)
                break;
 
        case EVENT_DATA_SELECT_DONE:
-               /* FIXME: Currently, layout is refreshed when AP connected. */
-               if (!datamgr_update(priv->wirelessmgr)) {
-                       _ERR("Unavailable status for updating list.");
-                       return;
-               }
-
                elm_object_item_signal_emit(priv->selected_wireless_item,
                                SIG_LOADING_STOP, SRC_ELM);
+
+               if (!listmgr_update_list(priv->listmgr, LIST_WIRELESS))
+                       _ERR("Listmgr update list failed.");
+
                break;
 
        case EVENT_DATA_SELECT_FAIL: