30b8c2384d455879d100b4a9dbe34db64a806fef
[apps/home/ug-wifi-efl.git] / sources / wifi-syspopup / viewer-popups / view-alerts.c
1 /*
2   * Copyright 2012  Samsung Electronics Co., Ltd
3   *
4   * Licensed under the Flora License, Version 1.0 (the "License");
5   * you may not use this file except in compliance with the License.
6   * You may obtain a copy of the License at
7   *
8   *    http://www.tizenopensource.org/license
9   *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16
17
18
19 #include "common.h"
20 #include "wifi-syspopup.h"
21 #include "view-alerts.h"
22 #include "i18nmanager.h"
23
24 extern wifi_object* app_state;
25
26 static void _timeout_cb(void *data, Evas_Object *obj, void *event_info)
27 {
28         if (obj)
29                 evas_object_del(obj);
30 }
31
32 int view_alerts_powering_on_show(void)
33 {
34         __COMMON_FUNC_ENTER__;
35         if(WIFI_SYSPOPUP_SUPPORT_QUICKPANEL == app_state->wifi_syspopup_support){
36                 __COMMON_FUNC_EXIT__;
37                 return TRUE;
38         }
39         if(NULL != app_state->alertpopup) {
40                 evas_object_del(app_state->alertpopup);
41                 app_state->alertpopup = NULL;
42         }
43
44         Evas_Object *conformant = NULL;
45         conformant = elm_conformant_add(app_state->win_main);
46         elm_win_conformant_set(app_state->win_main, EINA_TRUE);
47         elm_win_resize_object_add(app_state->win_main, conformant);
48         evas_object_size_hint_weight_set(conformant, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
49         evas_object_size_hint_align_set(conformant, EVAS_HINT_FILL, EVAS_HINT_FILL);
50         evas_object_show(conformant);
51
52         Evas_Object *content = elm_layout_add(conformant);
53         elm_object_content_set(conformant, content);
54         app_state->alertpopup = elm_popup_add(content);
55
56         Evas_Object *box = elm_box_add(app_state->alertpopup);
57         evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
58         evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
59         evas_object_show(box);
60
61         Evas_Object *progressbar = elm_progressbar_add(box);
62         elm_object_style_set(progressbar, "list_process");
63         evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
64         evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, EVAS_HINT_FILL);
65         elm_progressbar_pulse(progressbar, EINA_TRUE);
66         evas_object_show(progressbar);
67         elm_box_pack_end(box, progressbar);
68
69         Evas_Object *label = elm_label_add(box);
70         elm_object_style_set(label, "popup/default");
71         evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
72         evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
73         elm_object_text_set(label, sc(PACKAGE, I18N_TYPE_Activating));
74         evas_object_show(label);
75         elm_box_pack_end(box, label);
76
77         elm_object_content_set(app_state->alertpopup, box);
78         evas_object_size_hint_weight_set(app_state->alertpopup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
79         evas_object_show(app_state->alertpopup);
80
81         __COMMON_FUNC_EXIT__;
82
83         return TRUE;
84 }
85
86 int view_alerts_connection_fail_show(void)
87 {
88         __COMMON_FUNC_ENTER__;
89
90         if (WIFI_SYSPOPUP_SUPPORT_QUICKPANEL == app_state->wifi_syspopup_support) {
91                 __COMMON_FUNC_EXIT__;
92
93                 return TRUE;
94         }
95
96         if (NULL != app_state->alertpopup) {
97                 evas_object_del(app_state->alertpopup);
98                 app_state->alertpopup = NULL;
99         }
100
101         app_state->alertpopup = elm_popup_add(app_state->win_main);
102         elm_object_text_set(app_state->alertpopup, "Connection attempt failed.<br>Try again.");
103         elm_popup_timeout_set(app_state->alertpopup, 2.0f);
104         evas_object_smart_callback_add(app_state->alertpopup, "timeout", _timeout_cb, NULL);
105         evas_object_size_hint_weight_set(app_state->alertpopup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
106         evas_object_show(app_state->alertpopup);
107
108         __COMMON_FUNC_EXIT__;
109
110         return TRUE;
111 }
112
113 int view_alerts_connection_fail_timeout_show(void)
114 {
115         __COMMON_FUNC_ENTER__;
116
117         if (WIFI_SYSPOPUP_SUPPORT_QUICKPANEL == app_state->wifi_syspopup_support) {
118                 __COMMON_FUNC_EXIT__;
119
120                 return TRUE;
121         }
122
123         if (NULL != app_state->alertpopup) {
124                 evas_object_del(app_state->alertpopup);
125                 app_state->alertpopup = NULL;
126         }
127
128         app_state->alertpopup = elm_popup_add(app_state->win_main);
129         elm_object_text_set(app_state->alertpopup, "No response from AP");
130         elm_popup_timeout_set(app_state->alertpopup, 2.0f);
131         evas_object_smart_callback_add(app_state->alertpopup, "timeout", _timeout_cb, NULL);
132
133         evas_object_size_hint_weight_set(app_state->alertpopup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
134         evas_object_show(app_state->alertpopup);
135
136         __COMMON_FUNC_EXIT__;
137
138         return TRUE;
139 }
140
141 int view_alerts_password_length_error_show(void)
142 {
143         __COMMON_FUNC_ENTER__;
144
145         if (WIFI_SYSPOPUP_SUPPORT_QUICKPANEL == app_state->wifi_syspopup_support) {
146                 __COMMON_FUNC_EXIT__;
147
148                 return TRUE;
149         }
150
151         if (NULL != app_state->alertpopup) {
152                 evas_object_del(app_state->alertpopup);
153                 app_state->alertpopup = NULL;
154         }
155
156         app_state->alertpopup = elm_popup_add(app_state->win_main);
157         elm_object_text_set(app_state->alertpopup, "WPA2 requires 8 - 63 letters for a password.<br>Please, check your input.");
158         elm_popup_timeout_set(app_state->alertpopup, 2.0f);
159         evas_object_smart_callback_add(app_state->alertpopup, "timeout", _timeout_cb, NULL);
160
161         evas_object_size_hint_weight_set(app_state->alertpopup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
162         evas_object_show(app_state->alertpopup);
163
164         __COMMON_FUNC_EXIT__;
165
166         return TRUE;
167 }