Apply device policy for wifi and wifi profile 81/72781/2 accepted/tizen/common/20160607.194729 accepted/tizen/ivi/20160607.235423 accepted/tizen/mobile/20160607.235400 accepted/tizen/tv/20160607.235414 accepted/tizen/wearable/20160607.235348 submit/tizen/20160607.090155
authorhyunuktak <hyunuk.tak@samsung.com>
Thu, 2 Jun 2016 10:44:22 +0000 (19:44 +0900)
committerhyunuktak <hyunuk.tak@samsung.com>
Tue, 7 Jun 2016 05:28:20 +0000 (14:28 +0900)
Change-Id: Ia6c8405d19d8eb6838baf266310a4450030dec7e
Signed-off-by: hyunuktak <hyunuk.tak@samsung.com>
sources/libraries/Common/common_ip_info.c
sources/libraries/Common/common_utils.c
sources/libraries/Common/include/common.h
sources/libraries/Common/include/common_ip_info.h [changed mode: 0644->0755]
sources/libraries/Common/include/common_utils.h
sources/libraries/WlanManager/WlanManager/wlan_manager.c [changed mode: 0644->0755]
sources/wearable/src/net/wifi_manager.c
sources/wearable/src/wearable-circle/app_main.c

index 1f26a20..673b438 100755 (executable)
@@ -28,6 +28,7 @@
 #define DEFAULT_PROXY_ADDR             "0.0.0.0:80"
 
 #define MAX_PORT_NUMBER                65535
+#define MAX_LABEL_LENGTH       512
 
 typedef struct {
        char* title;
@@ -114,14 +115,68 @@ static Evas_Object *_ip_info_detail_description_content_get(void *data,
        _view_detail_description_data_t* det =
                        (_view_detail_description_data_t*) data;
 
-       if (g_strcmp0(part, "elm.swallow.end") == 0) {
+       if (g_strcmp0(part, "elm.swallow.content") == 0) {
                Evas_Object *entry = NULL;
-
-               entry = elm_entry_add(obj);
-               elm_entry_single_line_set(entry, EINA_TRUE);
-               elm_entry_scrollable_set(entry, EINA_TRUE);
-               elm_object_domain_translatable_part_text_set(entry, "elm.guide",
-                               PACKAGE, det->description);
+               Evas_Object *box1 = NULL;
+               Evas_Object *box2 = NULL;
+               Evas_Object *tpad = NULL;
+               Evas_Object *lpad = NULL;
+               Evas_Object *label1 = NULL;
+               Evas_Object *label2 = NULL;
+               int height = 60;
+               char buf[MAX_LABEL_LENGTH] = {0, };
+
+               entry = elm_box_add(obj);
+               elm_box_align_set(entry, 0.0, 0.0);
+
+               tpad = evas_object_rectangle_add(entry);
+               evas_object_size_hint_min_set(tpad, 0, ELM_SCALE_SIZE(10));
+               evas_object_show(tpad);
+               elm_box_pack_end(entry, tpad);
+
+               box1 = elm_box_add(entry);
+               evas_object_size_hint_align_set(box1, 0.0, 0.0);
+               elm_box_horizontal_set(box1, EINA_TRUE);
+               elm_box_pack_end(entry, box1);
+               evas_object_show(box1);
+
+               lpad = evas_object_rectangle_add(box1);
+               evas_object_size_hint_min_set(lpad, ELM_SCALE_SIZE(15), 0);
+               evas_object_show(lpad);
+               elm_box_pack_end(box1, lpad);
+               evas_object_show(box1);
+
+               label1 = elm_label_add(box1);
+               snprintf(buf, MAX_LABEL_LENGTH, "<font_size=30>%s</font_size>",
+                       dgettext(PACKAGE, det->title));
+               elm_object_text_set(label1, buf);
+               evas_object_size_hint_align_set(label1, EVAS_HINT_FILL, EVAS_HINT_FILL);
+               evas_object_size_hint_weight_set(label1, 0.9, EVAS_HINT_EXPAND);
+               elm_box_pack_end(box1, label1);
+               evas_object_show(label1);
+
+               box2 = elm_box_add(entry);
+               evas_object_size_hint_align_set(box2, EVAS_HINT_FILL, EVAS_HINT_FILL);
+               elm_box_horizontal_set(box2, EINA_TRUE);
+               elm_box_pack_end(entry, box2);
+
+               elm_box_pack_end(box2, lpad);
+
+               label2 = elm_label_add(box2);
+               snprintf(buf, MAX_LABEL_LENGTH, "<font_size=40>%s</font_size>",
+                       dgettext(PACKAGE, det->description));
+               elm_object_text_set(label2, buf);
+               evas_object_size_hint_align_set(label2, EVAS_HINT_FILL, EVAS_HINT_FILL);
+               evas_object_size_hint_weight_set(label2, 0.9, EVAS_HINT_EXPAND);
+               elm_box_pack_end(box2, label2);
+               evas_object_show(label2);
+
+               evas_object_show(box2);
+               elm_box_pack_end(entry, box2);
+
+               evas_object_size_hint_min_set(entry, 0, ELM_SCALE_SIZE(height));
+               elm_object_focus_set(entry, EINA_FALSE);
+               evas_object_show(entry);
 
                return entry;
        }
@@ -417,12 +472,20 @@ static Evas_Object *_ip_info_entry_item_content_get(void *data, Evas_Object *obj
                return NULL;
        }
 
-       if (g_strcmp0(part, "elm.swallow.end") == 0) {
+       if (g_strcmp0(part, "elm.swallow.content") == 0) {
                Evas_Object *entry = NULL;
+               Evas_Object *box = NULL;
+               Evas_Object *tpad = NULL;
+               Evas_Object *lpad = NULL;
+               Evas_Object *label = NULL;
+               Evas_Object *layout = NULL;
+               Evas_Object *editfield = NULL;
                char *guide_txt = NULL;
                char *accepted = NULL;
                Elm_Input_Panel_Layout panel_type;
                int return_key_type;
+               int height = 60;
+               char buf[MAX_LABEL_LENGTH] = {0, };
 
                switch (entry_info->entry_id)
                {
@@ -453,30 +516,64 @@ static Evas_Object *_ip_info_entry_item_content_get(void *data, Evas_Object *obj
                        return NULL;
                }
 
-               entry = elm_entry_add(obj);
-               elm_entry_single_line_set(entry, EINA_TRUE);
-               elm_entry_scrollable_set(entry, EINA_TRUE);
+               entry = elm_box_add(obj);
+               elm_box_align_set(entry, 0.0, 0.0);
+
+               tpad = evas_object_rectangle_add(entry);
+               evas_object_size_hint_min_set(tpad, 0, ELM_SCALE_SIZE(10));
+               evas_object_show(tpad);
+               elm_box_pack_end(entry, tpad);
+
+               box = elm_box_add(entry);
+               evas_object_size_hint_align_set(box, 0.0, 0.0);
+               elm_box_horizontal_set(box, EINA_TRUE);
+               elm_box_pack_end(entry, box);
+               evas_object_show(box);
+
+               lpad = evas_object_rectangle_add(box);
+               evas_object_size_hint_min_set(lpad, ELM_SCALE_SIZE(15), 0);
+               evas_object_show(lpad);
+               elm_box_pack_end(box, lpad);
+               evas_object_show(box);
+
+               label = elm_label_add(box);
+               snprintf(buf, MAX_LABEL_LENGTH, "<font_size=30>%s</font_size>",
+                       dgettext(PACKAGE, entry_info->title_txt));
+               elm_object_text_set(label, buf);
+               evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
+               evas_object_size_hint_weight_set(label, 0.9, EVAS_HINT_EXPAND);
+               elm_box_pack_end(box, label);
+               evas_object_show(label);
+
+               layout = elm_layout_add(entry);
+               elm_layout_theme_set(layout, "layout", "editfield", "singleline");
+               evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
+               evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+               editfield = elm_entry_add(layout);
+               elm_entry_single_line_set(editfield, EINA_TRUE);
+               elm_entry_scrollable_set(editfield, EINA_TRUE);
 
                if (!g_strcmp0(entry_info->str_pkg_name, "wifi-qs")) {
-                       elm_entry_input_panel_imdata_set(entry, "type=systempopup", 16);
+                       elm_entry_input_panel_imdata_set(editfield, "type=systempopup", 16);
                }
-               elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT);
+               elm_entry_cnp_mode_set(editfield, ELM_CNP_MODE_PLAINTEXT);
 
-               elm_object_part_text_set(entry, "elm.guide", guide_txt);
+               elm_object_part_text_set(editfield, "elm.guide", guide_txt);
                if (entry_info->entry_txt && (strlen(entry_info->entry_txt) > 0) &&
                                g_strcmp0(entry_info->entry_txt, DEFAULT_GUIDE_IP) != 0) {
-                       elm_entry_entry_set(entry, entry_info->entry_txt);
+                       elm_entry_entry_set(editfield, entry_info->entry_txt);
                }
 
-               elm_entry_input_panel_layout_set(entry, panel_type);
+               elm_entry_input_panel_layout_set(editfield, panel_type);
 
                Elm_Entry_Filter_Accept_Set digits_filter_data;
                memset(&digits_filter_data, 0, sizeof(Elm_Entry_Filter_Accept_Set));
                digits_filter_data.accepted = accepted;
-               elm_entry_markup_filter_append(entry, elm_entry_filter_accept_set, &digits_filter_data);
+               elm_entry_markup_filter_append(editfield, elm_entry_filter_accept_set, &digits_filter_data);
 
                if (entry_info->input_panel_cb) {
-                       Ecore_IMF_Context *imf_ctxt = elm_entry_imf_context_get(entry);
+                       Ecore_IMF_Context *imf_ctxt = elm_entry_imf_context_get(editfield);
                        if (imf_ctxt) {
                                ecore_imf_context_input_panel_event_callback_add(
                                                imf_ctxt,
@@ -486,8 +583,21 @@ static Evas_Object *_ip_info_entry_item_content_get(void *data, Evas_Object *obj
                        }
                }
 
-               elm_entry_input_panel_return_key_type_set(entry, return_key_type);
-               _ip_info_entry_add_callbacks(entry, entry_info);
+               elm_entry_input_panel_return_key_type_set(editfield, return_key_type);
+               _ip_info_entry_add_callbacks(editfield, entry_info);
+               elm_object_part_content_set(layout, "elm.swallow.content", editfield);
+
+               if (!net_get_device_policy_wifi_profile())
+                       elm_object_disabled_set(editfield, EINA_TRUE);
+               else
+                       elm_object_disabled_set(editfield, EINA_FALSE);
+
+               evas_object_show(layout);
+               elm_box_pack_end(entry, layout);
+
+               evas_object_size_hint_min_set(entry, 0, ELM_SCALE_SIZE(height));
+               elm_object_focus_set(entry, EINA_FALSE);
+               evas_object_show(entry);
 
                return entry;
        }
@@ -841,6 +951,12 @@ static void __ip_info_toggle_item_sel_cb(void* data,
                return;
        }
 
+       if (!net_get_device_policy_wifi_profile()) {
+               SECURE_DEBUG_LOG(UG_NAME_NORMAL, "Wifi profile device policy restricts");
+               __COMMON_FUNC_EXIT__;
+               return;
+       }
+
        wifi_ap_h ap = ip_info_list_data->ap;
 
        object_type = evas_object_type_get(obj);
@@ -911,6 +1027,7 @@ static Evas_Object *_ip_info_iptoggle_content_get(void *data,
                toggle_btn = elm_check_add(obj);
                elm_object_style_set(toggle_btn, "on&off");
                elm_object_focus_allow_set(toggle_btn, EINA_FALSE);
+
                if (WIFI_IP_CONFIG_TYPE_STATIC == ip_info_list_data->ip_type) {
                        elm_check_state_set(toggle_btn, EINA_TRUE);
                } else {
@@ -922,11 +1039,19 @@ static Evas_Object *_ip_info_iptoggle_content_get(void *data,
                evas_object_size_hint_weight_set(toggle_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
                evas_object_smart_callback_add(toggle_btn, "changed",
                                __ip_info_toggle_item_sel_cb, ip_data);
+
+               if (!net_get_device_policy_wifi_profile())
+                       elm_object_disabled_set(toggle_btn, EINA_TRUE);
+               else
+                       elm_object_disabled_set(toggle_btn, EINA_FALSE);
        }
+
+
+
+       __COMMON_FUNC_EXIT__;
        return toggle_btn;
 }
 
-#if 0
 static void ip_info_print_values(wifi_ap_h ap)
 {
        char *txt;
@@ -994,7 +1119,6 @@ static void ip_info_print_values(wifi_ap_h ap)
        SECURE_DEBUG_LOG(UG_NAME_NORMAL, "* PROXY PORT [%s]", proxy_port);
        g_free(txt);
 }
-#endif
 
 void ip_info_delete_prev(prev_ip_info_t *prev_ip_info)
 {
@@ -1069,13 +1193,13 @@ full_ip_info_t *ip_info_append_items(wifi_ap_h ap, const char *pkg_name,
        ip_toggle_itc.func.state_get = NULL;
        ip_toggle_itc.func.del = NULL;
 
-       description_itc.item_style = WIFI_GENLIST_2LINE_BOTTOM_SWALLOW_STYLE;
+       description_itc.item_style = WIFI_GENLIST_FULL_STYLE;
        description_itc.func.text_get = _ip_info_detail_description_text_get;
        description_itc.func.content_get = _ip_info_detail_description_content_get;
        description_itc.func.state_get = NULL;
        description_itc.func.del = _ip_info_detail_description_del;
 
-       ip_entry_itc.item_style = WIFI_GENLIST_2LINE_BOTTOM_SWALLOW_STYLE;
+       ip_entry_itc.item_style = WIFI_GENLIST_FULL_STYLE;
        ip_entry_itc.func.text_get = _ip_info_entry_item_text_get;
        ip_entry_itc.func.content_get = _ip_info_entry_item_content_get;
        ip_entry_itc.func.state_get = NULL;
@@ -1325,7 +1449,7 @@ void ip_info_save_data(full_ip_info_t *ip_data)
                g_free((gpointer)txt);
        }
 
-       //ip_info_print_values(ap);
+       ip_info_print_values(ap);
 
        __COMMON_FUNC_EXIT__;
 }
index 51f5363..0516cb6 100755 (executable)
@@ -558,6 +558,24 @@ int common_utils_send_message_to_net_popup(const char *title,
        return ret;
 }
 
+int common_utils_send_restriction_to_net_popup(const char *title,
+               const char *type, const char *restriction)
+{
+       int ret = 0;
+       bundle *b = bundle_create();
+
+       bundle_add_str(b, "_SYSPOPUP_TITLE_", title);
+       bundle_add_str(b, "_SYSPOPUP_CONTENT_", "security restriction");
+       bundle_add_str(b, "_SYSPOPUP_TYPE_", type);
+       bundle_add_str(b, "_RESTRICTED_TYPE_", restriction);
+
+       ret = aul_launch_app("net.netpopup", b);
+
+       bundle_free(b);
+
+       return ret;
+}
+
 int common_util_set_system_registry(const char *key, int value)
 {
        __COMMON_FUNC_ENTER__;
index 93a71f6..29fc980 100755 (executable)
@@ -77,6 +77,7 @@ extern "C"
 #define WIFI_GENLIST_2LINE_BOTTOM_TEXT_ICON_STYLE "type2"
 #define WIFI_GENLIST_MULTILINE_TEXT_STYLE "multiline"
 #define WIFI_GENLIST_GROUP_INDEX_STYLE "group_index"
+#define WIFI_GENLIST_FULL_STYLE "full"
 
 /* Genlist new style for Tizen 3.0 */
 #define WIFI_GENLIST_2LINE_BOTTOM_SWALLOW_STYLE "type2"
@@ -105,26 +106,26 @@ typedef enum {
        FUNC_LOG(COMMON_NAME_FUNC, "[Quit/>]: %s() [%d]", __func__, __LINE__)
 
 #define FUNC_LOG(MID, format, args...) \
-       SLOG(LOG_INFO, MID, "\033[2m[%s:%d]\033[2m " format "\033[0m", __func__, __LINE__, ##args)
+       SLOG(LOG_INFO, MID, "[%s:%d] " format, __func__, __LINE__, ##args)
 #define DEBUG_LOG(MID, format, args...) \
-       SLOG(LOG_DEBUG, MID, "\033[42m[%s:%d]\033[0m\033[32m " format "\033[0m", __func__, __LINE__, ##args)
+       SLOG(LOG_DEBUG, MID, "[%s:%d] " format, __func__, __LINE__, ##args)
 #define INFO_LOG(MID, format, args...) \
-       SLOG(LOG_INFO, MID, "\033[0m[%s:%d]\033[0m " format, __func__, __LINE__, ##args)
+       SLOG(LOG_INFO, MID, "[%s:%d] " format, __func__, __LINE__, ##args)
 #define WARN_LOG(MID, format, args...) \
-       SLOG(LOG_WARN, MID, "\033[43m[%s:%d]\033[0m\033[33m " format "\033[0m", __func__, __LINE__, ##args)
+       SLOG(LOG_WARN, MID, "[%s:%d] " format, __func__, __LINE__, ##args)
 #define ERROR_LOG(MID, format, args...) \
-       SLOG(LOG_ERROR, MID, "\033[41m[%s:%d]\033[0m\033[31m " format "\033[0m", __func__, __LINE__, ##args)
+       SLOG(LOG_ERROR, MID, "[%s:%d] " format, __func__, __LINE__, ##args)
 
 #define SECURE_FUNC_LOG(MID, format, args...) \
-       SECURE_SLOG(LOG_INFO, MID, "\033[2m[%s:%d]\033[2m " format "\033[0m", __func__, __LINE__, ##args)
+       SECURE_SLOG(LOG_INFO, MID, "[%s:%d] " format, __func__, __LINE__, ##args)
 #define SECURE_DEBUG_LOG(MID, format, args...) \
-       SECURE_SLOG(LOG_DEBUG, MID, "\033[42m[%s:%d]\033[0m\033[32m " format "\033[0m", __func__, __LINE__, ##args)
+       SECURE_SLOG(LOG_DEBUG, MID, "[%s:%d] " format, __func__, __LINE__, ##args)
 #define SECURE_INFO_LOG(MID, format, args...) \
-       SECURE_SLOG(LOG_INFO, MID, "\033[0m[%s:%d]\033[0m " format, __func__, __LINE__, ##args)
+       SECURE_SLOG(LOG_INFO, MID, "[%s:%d] " format, __func__, __LINE__, ##args)
 #define SECURE_WARN_LOG(MID, format, args...) \
-       SECURE_SLOG(LOG_WARN, MID, "\033[43m[%s:%d]\033[0m\033[33m " format "\033[0m", __func__, __LINE__, ##args)
+       SECURE_SLOG(LOG_WARN, MID, "[%s:%d] " format, __func__, __LINE__, ##args)
 #define SECURE_ERROR_LOG(MID, format, args...) \
-       SECURE_SLOG(LOG_ERROR, MID, "\033[41m[%s:%d]\033[0m\033[31m " format "\033[0m", __func__, __LINE__, ##args)
+       SECURE_SLOG(LOG_ERROR, MID, "[%s:%d] " format, __func__, __LINE__, ##args)
 
 #define retm_if(expr) do { \
        if (expr) { \
old mode 100644 (file)
new mode 100755 (executable)
index e9466a1..7cb7e61
@@ -26,6 +26,7 @@ extern "C"
 #endif
 
 #include <Evas.h>
+#include <network-wifi-intf.h>
 
 #include "wlan_manager.h"
 #include "common_utils.h"
index 069d03e..ebc88c9 100755 (executable)
@@ -115,6 +115,8 @@ wlan_security_mode_type_t common_utils_get_sec_mode(
                wifi_security_type_e sec_type);
 int common_utils_send_message_to_net_popup(const char *title,
                const char *content, const char *type, const char *ssid);
+int common_utils_send_restriction_to_net_popup(const char *title,
+               const char *type, const char *restriction);
 
 int common_util_set_system_registry(const char *key, int value);
 int common_util_get_system_registry(const char *key);
old mode 100644 (file)
new mode 100755 (executable)
index 9d9f4b9..f486104
@@ -523,9 +523,12 @@ int wlan_manager_power_on(void)
        ret = wifi_activate(wlan_manager_network_event_cb, req_data);
        if (WIFI_ERROR_NONE != ret && WIFI_ERROR_ALREADY_EXISTS != ret) {
                ERROR_LOG(UG_NAME_REQ, "Power on request. Error Reason [%d]", ret);
-
                g_free(req_data);
 
+               if (WIFI_ERROR_SECURITY_RESTRICTED == ret)
+                       ret = common_utils_send_restriction_to_net_popup("Wi-Fi unavailable",
+                                       "toast_popup", "wifi");
+
                __COMMON_FUNC_EXIT__;
                return WLAN_MANAGER_ERR_UNKNOWN;
        }
index fbf1939..eac9b8f 100755 (executable)
@@ -127,7 +127,7 @@ static void __wifi_connection_state_changed_cb(wifi_connection_state_e state,
 
 static bool __wifi_config_list_cb(const wifi_config_h config, void *user_data)
 {
-    
+
     __WIFI_FUNC_ENTER__;
        wifi_manager_object *manager = user_data;
        wifi_config_object *config_obj;
@@ -163,14 +163,14 @@ static void _wifi_config_destory(gpointer data)
 
 static void _clear_wifi_config_list(wifi_manager_object *manager)
 {
-    
+
     __WIFI_FUNC_ENTER__;
        WIFI_RET_IF_FAIL(manager != NULL);
        WIFI_RET_IF_FAIL(manager->config_list != NULL);
 
        g_list_free_full(manager->config_list, _wifi_config_destory);
        manager->config_list = NULL;
-    
+
     __WIFI_FUNC_EXIT__;
 }
 
index 532fda7..85d8ce7 100755 (executable)
@@ -1746,7 +1746,7 @@ static void _popup_change_ap_show_use_ap(app_object *app_obj, wifi_ap_object *ap
         WIFI_LOG_INFO("selected_wifi_ap isn't null!!");
        } else
            WIFI_LOG_INFO("selected_wifi_ap is null!!");
-    
+
        popup_change_ap_set_destroy_cb(app_obj->popup_change_ap,
                                       __popup_change_ap_destroy_cb, app_obj);
        popup_change_ap_set_tap_ok_button_cb(app_obj->popup_change_ap,
@@ -3895,7 +3895,7 @@ static void __main_menu_power_tap_cb(void *data, Evas_Object *obj, void *event_i
                 wifi_error_to_string(err));
                        return;
                }
-         
+
        } else {
                WIFI_LOG_INFO("disable_for_wifi_power_on");
                        _main_menu_disable_for_wifi_power_on(app_obj);