location: removed unnecessary data manager from location gengrid 63/62563/4
authorBartlomiej Uliasz <b.uliasz@samsung.com>
Wed, 16 Mar 2016 13:26:54 +0000 (14:26 +0100)
committerBartlomiej Uliasz <b.uliasz@samsung.com>
Thu, 24 Mar 2016 16:49:23 +0000 (09:49 -0700)
Change-Id: Idd4546df44ae56f5036ec7e04ca91afc71178142
Signed-off-by: Bartlomiej Uliasz <b.uliasz@samsung.com>
include/common/favoritemgr.h
include/data/system/data_location.h
src/common/favoritemgr.c
src/common/menumgr.c
src/data/system/data_location.c
src/view/system/view_location.c

index 64391fe..299dfa0 100644 (file)
@@ -17,6 +17,8 @@
 #ifndef __AIR_SETTINGS_FAVORITEMGR_H__
 #define __AIR_SETTINGS_FAVORITEMGR_H__
 
+#include <Elementary.h>
+
 /**
 * @brief Sets the favorite star on or off on the object.
 *
index e858515..daad099 100644 (file)
@@ -31,13 +31,6 @@ struct country_info_s {
 /**
 * @brief 
 *
-* @return 
-*/
-struct data_class *get_location_data_class(void);
-
-/**
-* @brief 
-*
 * @param selected_item
 */
 void data_location_set_new_system_location(Elm_Object_Item *selected_item);
@@ -50,5 +43,6 @@ void data_location_set_new_system_location(Elm_Object_Item *selected_item);
 * @param lang
 */
 void data_location_fill_list_data(struct listmgr *list_mgr, Elm_Object_Item **get_country, const char *lang);
+void data_location_free_list_data();
 
 #endif /* __AIR_SETTINGS_DATA_LOCATION_H__ */
index b324b37..227a2ac 100644 (file)
@@ -24,7 +24,6 @@
 
 void set_favorite(Evas_Object *obj, Eina_Bool status)
 {
-       SETTING_TRACE_BEGIN;
        if(EINA_TRUE == status) {
                elm_object_signal_emit(obj, SIG_FAV_ADD, SRC_ELM);
        } else {
index 2515342..25f999e 100644 (file)
@@ -55,7 +55,6 @@ static void _mouse_move_cb(int id, void *data, Evas *e, Evas_Object *obj,
 static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
                Evas_Event_Key_Down *ev)
 {
-       SETTING_TRACE_BEGIN;
        struct menumgr *m = NULL;
 
        if (!data || !ev || !obj) {
@@ -123,7 +122,6 @@ static input_handler _handler = {
 
 void menumgr_update(struct menumgr *m)
 {
-       SETTING_TRACE_BEGIN;
        int i;
        char *str = NULL;
 
index dab0aaf..fda6082 100644 (file)
 #include <utils_i18n.h>
 
 #include "app_debug.h"
-#include "common/datamgr.h"
-#include "common/inputmgr.h"
 #include "data/system/data_location.h"
 
 #define DEFAULT_COUNTRY "US"
 #define MAX_COUNTRY_NAME_LENGTH 250
 
-struct _priv {
-       Eina_List *list;
-       void (*event_cb)(enum event_type type, void *data);
-       void *cb_data;
-};
+Eina_List *_country_list = NULL;
 
-static void *_create(void (*event_cb)(enum event_type type, void *data),
-               void *cb_data)
-{
-       struct _priv *priv = NULL;
-
-       priv = calloc(1, sizeof(*priv));
-       if (!priv) {
-               _ERR("Calloc failed.");
-               return NULL;
-       }
-
-       if (event_cb)
-               priv->event_cb = event_cb;
-
-       if (cb_data)
-               priv->cb_data = cb_data;
-
-       return priv;
-}
-
-static void _free_country_list(Eina_List *list)
+void data_location_free_list_data()
 {
        struct country_info_s *country_info = NULL;
 
-       EINA_LIST_FREE(list, country_info) {
+       EINA_LIST_FREE(_country_list, country_info) {
                if (!country_info)
                        continue;
                free(country_info->long_name);
                free(country_info);
-               country_info = NULL;
-       }
-}
-
-static bool _destroy(void *dclass_data)
-{
-       struct _priv *priv = dclass_data;
-
-       if (!priv) {
-               _ERR("Invalid argument.");
-               return false;
-       }
-
-       _free_country_list(priv->list);
-       priv->list = NULL;
-
-       free(priv);
-
-       return true;
-}
-
-static bool _select(void *dclass_data, Elm_Object_Item *it, void *data)
-{
-       struct _priv *priv = dclass_data;
-
-       if (!priv || !it) {
-               _ERR("Invalid argument.");
-               return false;
        }
-
-       if (priv->event_cb)
-               priv->event_cb(EVENT_DATA_SELECT_DONE, priv->cb_data);
-
-       return true;
-}
-
-static Eina_List *_get_data(void *dclass_data)
-{
-       struct _priv *priv = dclass_data;
-
-       if (!priv) {
-               _ERR("Invalid argument.");
-               return NULL;
-       }
-
-       return priv->list;
-}
-
-static struct data_class _dclass = {
-       .create = _create,
-       .destroy = _destroy,
-       .select = _select,
-       .get_data = _get_data,
-};
-
-struct data_class *get_location_data_class(void)
-{
-       return &_dclass;
+       _country_list = NULL;
 }
 
 void data_location_set_new_system_location(Elm_Object_Item *selected_item)
@@ -162,7 +80,6 @@ static char *_get_current_country()
 
 void data_location_fill_list_data(struct listmgr *list_mgr, Elm_Object_Item **get_country, const char *lang)
 {
-       Eina_List *list = NULL;
        struct country_info_s *country_info = NULL;
        struct country_info_s *select_first = NULL;
        char *current_country = NULL;
@@ -178,6 +95,9 @@ void data_location_fill_list_data(struct listmgr *list_mgr, Elm_Object_Item **ge
        }
        current_country = _get_current_country();
 
+       if (_country_list)
+               data_location_free_list_data();
+
        while (*code_tab) {
                fake_code[1] = (*code_tab)[0];
                fake_code[2] = (*code_tab)[1];
@@ -204,12 +124,12 @@ void data_location_fill_list_data(struct listmgr *list_mgr, Elm_Object_Item **ge
                if (current_country && (*code_tab)[0] == current_country[0] && (*code_tab)[1] == current_country[1]) {
                        select_first = country_info;
                }
-               list = eina_list_append(list, country_info);
+               _country_list = eina_list_append(_country_list, country_info);
                ++code_tab;
        }
        free(current_country);
 
-       if (!listmgr_fill_grid(list_mgr, LOCATION_LIST_ID, list, select_first, get_country)) {
+       if (!listmgr_fill_grid(list_mgr, LOCATION_LIST_ID, _country_list, select_first, get_country)) {
                _ERR("Fill location list failed.");
        }
        listmgr_set_list_next_focus(list_mgr, LOCATION_LIST_ID,
index 8d54297..ea470fd 100644 (file)
@@ -21,7 +21,6 @@
 #include "define.h"
 #include "layout.h"
 #include "layout/system.h"
-#include "common/datamgr.h"
 #include "common/inputmgr.h"
 #include "common/layoutmgr.h"
 #include "common/listmgr.h"
@@ -40,7 +39,6 @@ struct _priv {
        Evas_Object *_btn2;
 
        struct listmgr *list_mgr;
-       struct datamgr *data_mgr;
        Elm_Object_Item *selected_country_item;
        Elm_Object_Item *configured_country;
        char *language;
@@ -63,26 +61,6 @@ static input_handler _grid_input_handler = {
        .key_down = _btn_key_down_cb
 };
 
-static void _data_event_cb(enum event_type type, void *data)
-{
-       SETTING_TRACE_BEGIN;
-
-       struct _priv *priv = data;
-
-       if (!priv) {
-               _ERR("Invalid argument.");
-               return;
-       }
-
-       if (type == EVENT_DATA_SELECT_DONE) {
-               if (!listmgr_update_grid(priv->list_mgr, LOCATION_LIST_ID))
-                       _ERR("Listmgr update list failed.");
-       } else {
-               _ERR("Unhandled data event type.");
-               return;
-       }
-}
-
 static void _country_selected_cb(Elm_Object_Item *it, void *data)
 {
        SETTING_TRACE_BEGIN;
@@ -116,15 +94,12 @@ static void _country_selected_cb(Elm_Object_Item *it, void *data)
 
        priv->selected_country_item = it;
 
-       if (!datamgr_select(priv->data_mgr, it, NULL)) {
-               _ERR("Unavailable status for selecting country.");
-               return;
-       }
+       if (!listmgr_update_grid(priv->list_mgr, LOCATION_LIST_ID))
+               _ERR("Listmgr update list failed.");
 }
 
 static void _show_country_list(struct _priv *priv)
 {
-       SETTING_TRACE_BEGIN;
        char *lang = NULL;
 
        if (!priv->list_mgr) {
@@ -261,18 +236,9 @@ static Evas_Object *_create(Evas_Object *win, void *data)
                return NULL;
        }
 
-       priv->data_mgr = datamgr_create(get_location_data_class(), _data_event_cb, priv);
-       if (!priv->data_mgr) {
-               _ERR("Create datamgr failed.");
-               evas_object_del(priv->base);
-               free(priv);
-               return NULL;
-       }
-
        priv->list_mgr = listmgr_create(priv->base);
        if (!priv->list_mgr) {
                _ERR("Create listmgr failed.");
-               datamgr_destroy(priv->data_mgr);
                evas_object_del(priv->base);
                free(priv);
                return NULL;
@@ -282,7 +248,6 @@ static Evas_Object *_create(Evas_Object *win, void *data)
                                _country_selected_cb, priv)) {
                _ERR("Add location list failed.");
                listmgr_destroy(priv->list_mgr);
-               datamgr_destroy(priv->data_mgr);
                evas_object_del(priv->base);
                free(priv);
                return NULL;
@@ -292,13 +257,12 @@ static Evas_Object *_create(Evas_Object *win, void *data)
        if (!viewmgr_set_view_data(VIEW_LOCATION, priv)) {
                _ERR("Set view data failed.");
                listmgr_destroy(priv->list_mgr);
-               datamgr_destroy(priv->data_mgr);
                evas_object_del(priv->base);
                free(priv);
                return NULL;
        }
 
-       data_location_fill_list_data(priv->list_mgr, &priv->configured_country, NULL);
+//     data_location_fill_list_data(priv->list_mgr, &priv->configured_country, NULL);
 
        _draw_menu_area(priv);
 
@@ -347,7 +311,7 @@ static void _destroy(void *data)
                return;
        }
 
-       datamgr_destroy(priv->data_mgr);
+       data_location_free_list_data();
        listmgr_destroy(priv->list_mgr);
 
        layoutmgr_destroy(priv->ly_mgr);