[ug-wifi-direct]Sync with Tizen 2.4
[apps/native/ug-wifi-direct.git] / ug-wifidirect / src / wfd_ug_genlist.c
1 /*
2 *  WiFi-Direct UG
3 *
4 * Copyright 2012  Samsung Electronics Co., Ltd
5
6 * Licensed under the Flora License, Version 1.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9
10 * http://www.tizenopensource.org/license
11
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19
20 #include <libintl.h>
21 #include <glib.h>
22
23 #include <Elementary.h>
24 #include <vconf.h>
25 #include <ui-gadget-module.h>
26 #include <wifi-direct.h>
27
28 #include "wfd_ug.h"
29 #include "wfd_ug_view.h"
30 #include "wfd_client.h"
31
32 Elm_Gen_Item_Class device_name_title_itc;
33 #ifdef WFD_ON_OFF_GENLIST
34 Elm_Gen_Item_Class wfd_onoff_itc;
35 #endif
36 Elm_Gen_Item_Class device_name_itc;
37 Elm_Gen_Item_Class title_itc;
38 Elm_Gen_Item_Class multi_view_title_itc;
39 Elm_Gen_Item_Class peer_itc;
40 Elm_Gen_Item_Class title_no_device_itc;
41 Elm_Gen_Item_Class noitem_itc;
42 Elm_Gen_Item_Class title_available_itc;
43
44 Elm_Gen_Item_Class title_conn_itc;
45 Elm_Gen_Item_Class peer_conn_itc;
46
47 Elm_Gen_Item_Class title_busy_itc;
48 Elm_Gen_Item_Class peer_busy_itc;
49
50 Elm_Gen_Item_Class title_multi_connect_itc;
51 Elm_Gen_Item_Class peer_multi_connect_itc;
52 Elm_Gen_Item_Class select_all_multi_connect_itc;
53
54 Elm_Gen_Item_Class title_conn_failed_itc;
55 Elm_Gen_Item_Class peer_conn_failed_itc;
56
57 #ifdef WFD_ON_OFF_GENLIST
58 static char *_gl_wfd_onoff_text_get(void *data, Evas_Object *obj,
59                 const char *part)
60 {
61         __FUNC_ENTER__;
62
63         struct ug_data *ugd = (struct ug_data *) data;
64         DBG(LOG_INFO, "%s", part);
65         WFD_RETV_IF(ugd == NULL, NULL, "Incorrect parameter(NULL)\n");
66         wfd_get_vconf_device_name(ugd);
67         char *dev_name;
68
69         if (!g_strcmp0(part,"elm.text.main.left.bottom")) {
70                 DBG(LOG_INFO, "%s", ugd->dev_name);
71                 if (ugd->dev_name) {
72                         dev_name = elm_entry_utf8_to_markup(ugd->dev_name);
73                         if (NULL == dev_name) {
74                                 DBG(LOG_ERROR, "elm_entry_utf8_to_markup failed.\n");
75                                 __FUNC_EXIT__;
76                                 return NULL;
77                         }
78                         __FUNC_EXIT__;
79                         return dev_name;
80                 }
81         } else if (!g_strcmp0(part, "elm.text.sub.left.top")) {
82                 return g_strdup(_("IDS_ST_HEADER_MY_DEVICE_NAME"));
83         }
84         __FUNC_EXIT__;
85         return NULL;
86 }
87
88 static Evas_Object *_gl_wfd_onoff_content_get(void *data,Evas_Object *obj,
89                 const char *part)
90 {
91         __FUNC_ENTER__;
92
93         struct ug_data *ugd = (struct ug_data *) data;
94         WFD_RETV_IF(ugd == NULL, NULL, "Incorrect parameter(NULL)\n");
95         Evas_Object *btn = NULL;
96         Evas_Object *icon = NULL;
97         icon = elm_layout_add(obj);
98
99         if (g_strcmp0(part, "elm.icon.2")) {
100                 return NULL;
101         }
102         elm_layout_theme_set(icon, "layout", "list/C/type.3", "default");
103         btn = elm_check_add(icon);
104         /* Wi-Fi on indication button */
105         btn= elm_check_add(icon);
106         elm_object_style_set(btn, "on&off");
107         evas_object_propagate_events_set(btn, EINA_FALSE);
108         elm_check_state_set(btn, ugd->wfd_onoff);
109         evas_object_propagate_events_set(btn, EINA_FALSE);
110         evas_object_smart_callback_add(btn, "changed",_onoff_changed_cb, ugd);
111         ugd->on_off_check = btn;
112         evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
113         evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND,
114                         EVAS_HINT_EXPAND);
115         elm_layout_content_set(icon, "elm.swallow.content", btn);
116         __FUNC_EXIT__;
117         return icon;
118 }
119 #endif
120
121 /**
122  *      This function let the ug get the label of header
123  *      @return   the label of header
124  *      @param[in] data the pointer to the main data structure
125  *      @param[in] obj the pointer to the evas object
126  *      @param[in] part the pointer to the part of item
127  */
128 static char *_gl_device_name_label_get(void *data, Evas_Object *obj,
129                 const char *part)
130 {
131         __FUNC_ENTER__;
132
133         struct ug_data *ugd = (struct ug_data *) data;
134         DBG(LOG_INFO, "%s", part);
135         WFD_RETV_IF(ugd == NULL, NULL, "Incorrect parameter(NULL)\n");
136         wfd_get_vconf_device_name(ugd);
137         char *dev_name;
138
139         if (!g_strcmp0(part,"elm.text.main.left.bottom")) {
140                 DBG(LOG_INFO, "%s", ugd->dev_name);
141                 if (ugd->dev_name) {
142                         dev_name = elm_entry_utf8_to_markup(ugd->dev_name);
143                         if (NULL == dev_name) {
144                                 DBG(LOG_ERROR, "elm_entry_utf8_to_markup failed.\n");
145                                 __FUNC_EXIT__;
146                                 return NULL;
147                         }
148                         __FUNC_EXIT__;
149                         return dev_name;
150                 }
151         } else if (!g_strcmp0(part, "elm.text.sub.left.top")) {
152                 return g_strdup(_("IDS_ST_HEADER_MY_DEVICE_NAME"));
153         }
154         __FUNC_EXIT__;
155         return NULL;
156 }
157
158 /**
159  *      This function let the ug get the label of title
160  *      @return   the label of titile
161  *      @param[in] data the pointer to the main data structure
162  *      @param[in] obj the pointer to the evas object
163  *      @param[in] part the pointer to the part of item
164  */
165 static char *_gl_title_label_get(void *data, Evas_Object *obj, const char *part)
166 {
167         __FUNC_ENTER__;
168
169         WFD_RETV_IF(data == NULL, NULL, "Incorrect parameter(NULL)\n");
170         DBG(LOG_INFO, "%s", part);
171         if (!g_strcmp0(part, "elm.text.main")) {
172                 return g_strdup(_("IDS_WIFI_HEADER_AVAILABLE_DEVICES_ABB"));
173         }
174         __FUNC_EXIT__;
175         return NULL;
176 }
177
178
179 static char *_gl_title_no_device_label_get(void *data, Evas_Object *obj,
180                 const char *part)
181 {
182         __FUNC_ENTER__;
183
184         WFD_RETV_IF(data == NULL, NULL, "Incorrect parameter(NULL)\n");
185         DBG(LOG_INFO, "%s", part);
186         if (!g_strcmp0(part, "elm.text.main")) {
187                 return g_strdup(_("IDS_WIFI_HEADER_AVAILABLE_DEVICES_ABB"));
188         }
189
190         __FUNC_EXIT__;
191         return NULL;
192 }
193
194 static char *_gl_multi_title_label_get(void *data, Evas_Object *obj, const char *part)
195 {
196         __FUNC_ENTER__;
197
198         WFD_RETV_IF(data == NULL, NULL, "Incorrect parameter(NULL)\n");
199         if (!g_strcmp0(part, "elm.text.main")) {
200                 return g_strdup(_("IDS_WIFI_HEADER_AVAILABLE_DEVICES_ABB"));
201         }
202
203         __FUNC_EXIT__;
204         return NULL;
205 }
206
207 static Evas_Object *_gl_multi_title_content_get(void *data, Evas_Object *obj, const char *part)
208 {
209         __FUNC_ENTER__;
210
211         Evas_Object *progressbar = NULL;
212         struct ug_data *ugd = (struct ug_data *) data;
213         WFD_RETV_IF(ugd == NULL, NULL, "Incorrect parameter(NULL)\n");
214
215         if (!g_strcmp0(part, "elm.icon")) {
216                 if (TITLE_CONTENT_TYPE_SCANNING == ugd->title_content_mode) {
217                         progressbar = elm_progressbar_add(obj);
218                         elm_object_style_set(progressbar, "process_small");
219                         elm_progressbar_horizontal_set(progressbar, EINA_TRUE);
220                         elm_progressbar_pulse(progressbar, EINA_TRUE);
221                         evas_object_show(progressbar);
222                         return progressbar;
223                 }
224         }
225
226         __FUNC_EXIT__;
227         return NULL;
228 }
229
230 static char *_gl_available_title_label_get(void *data, Evas_Object *obj, const char *part)
231 {
232         __FUNC_ENTER__;
233
234         if (data == NULL) {
235                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
236                 return NULL;
237         }
238         DBG(LOG_INFO, "available- %s", part);
239         if (!g_strcmp0(part, "elm.text.main")) {
240                 return g_strdup(_("IDS_WIFI_HEADER_AVAILABLE_DEVICES_ABB"));
241         }
242
243         __FUNC_EXIT__;
244         return NULL;
245 }
246
247 /**
248  *      This function let the ug get the content of titile
249  *      @return   the content of titile
250  *      @param[in] data the pointer to the main data structure
251  *      @param[in] obj the pointer to the evas object
252  *      @param[in] part the pointer to the part of item
253  */
254 static Evas_Object *_gl_title_content_get(void *data, Evas_Object *obj, const char *part)
255 {
256         __FUNC_ENTER__;
257
258         Evas_Object *progressbar = NULL;
259         struct ug_data *ugd = (struct ug_data *) data;
260
261         if (data == NULL) {
262             DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
263             return NULL;
264         }
265
266         DBG(LOG_INFO, "Title content- %s", part);
267
268         if (!g_strcmp0(part, "elm.icon")) {
269                 if (TITLE_CONTENT_TYPE_SCANNING == ugd->title_content_mode) {
270                         progressbar = elm_progressbar_add(obj);
271                         elm_object_style_set(progressbar, "process_small");
272                         elm_progressbar_horizontal_set(progressbar, EINA_TRUE);
273                         elm_progressbar_pulse(progressbar, EINA_TRUE);
274                         evas_object_show(progressbar);
275                 } else {
276                         return NULL;
277                 }
278         }
279
280         __FUNC_EXIT__;
281         return progressbar;
282 }
283
284 /**
285  *      This function let the ug get the label of peer item
286  *      @return   the label of peer item
287  *      @param[in] data the pointer to the main data structure
288  *      @param[in] obj the pointer to the evas object
289  *      @param[in] part the pointer to the part of item
290  */
291 static char *_gl_peer_label_get(void *data, Evas_Object *obj, const char *part)
292 {
293         __FUNC_ENTER__;
294
295         assertm_if(NULL == obj, "NULL!!");
296         assertm_if(NULL == part, "NULL!!");
297         device_type_s *peer = (device_type_s *) data;
298         char buf[WFD_GLOBALIZATION_STR_LENGTH] = { 0, };
299         char *ssid;
300
301         DBG(LOG_INFO, "%s", part);
302
303         if (data == NULL) {
304                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
305                 return NULL;
306         }
307
308         if (!g_strcmp0(part, "elm.text.main.left.top")) {
309                 if (strlen(peer->ssid) != 0) {
310                         ssid = elm_entry_utf8_to_markup(peer->ssid);
311                         if (NULL == ssid) {
312                                 DBG(LOG_ERROR, "elm_entry_utf8_to_markup failed.\n");
313                                 __FUNC_EXIT__;
314                                 return NULL;
315                         }
316                         __FUNC_EXIT__;
317                         return ssid;
318                 }
319         } else if (!g_strcmp0(part, "elm.text.sub.left.bottom")) {
320                 switch (peer->conn_status) {
321                 case PEER_CONN_STATUS_DISCONNECTED:
322                         g_strlcpy(buf, _("IDS_CHATON_BODY_AVAILABLE"), WFD_GLOBALIZATION_STR_LENGTH);
323                         break;
324                 case PEER_CONN_STATUS_CONNECTING:
325                         g_strlcpy(buf, _("IDS_WIFI_BODY_CONNECTING_ING"), WFD_GLOBALIZATION_STR_LENGTH);
326                         break;
327                 case PEER_CONN_STATUS_CONNECTED:
328                         if (peer->is_group_owner == FALSE) {
329                                 g_strlcpy(buf, _("IDS_COM_BODY_CONNECTED_M_STATUS"), WFD_GLOBALIZATION_STR_LENGTH);
330                         } else {
331                                 g_strlcpy(buf, _("IDS_CHATON_BODY_AVAILABLE"), WFD_GLOBALIZATION_STR_LENGTH);
332                         }
333                         break;
334                 case PEER_CONN_STATUS_FAILED_TO_CONNECT:
335                         g_strlcpy(buf, _("IDS_CHATON_HEADER_CONNECTION_FAILED_ABB2"), WFD_GLOBALIZATION_STR_LENGTH);
336                         break;
337                 case PEER_CONN_STATUS_WAIT_FOR_CONNECT:
338                         g_strlcpy(buf, _("IDS_WIFI_BODY_WAITING_FOR_CONNECTION_M_STATUS_ABB"), WFD_GLOBALIZATION_STR_LENGTH);
339                         break;
340                 default:
341                         g_strlcpy(buf, _("IDS_CHATON_BODY_AVAILABLE"), WFD_GLOBALIZATION_STR_LENGTH);
342                         break;
343                 }
344         } else {
345                 __FUNC_EXIT__;
346                 return NULL;
347         }
348
349         __FUNC_EXIT__;
350         return g_strdup(buf);
351 }
352
353 /**
354  *      This function let the ug get the icon of peer item
355  *      @return   the icon of peer item
356  *      @param[in] data the pointer to the main data structure
357  *      @param[in] obj the pointer to the evas object
358  *      @param[in] part the pointer to the part of item
359  */
360 static Evas_Object *_gl_peer_icon_get(void *data, Evas_Object *obj, const char *part)
361 {
362         __FUNC_ENTER__;
363
364         assertm_if(NULL == obj, "NULL!!");
365         assertm_if(NULL == part, "NULL!!");
366         device_type_s *peer = (device_type_s *) data;
367         Evas_Object *icon = NULL;
368         Evas_Object *layout = NULL;
369
370         if (data == NULL) {
371                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
372                 return NULL;
373         }
374         DBG(LOG_INFO, "part = %s", part);
375         if (!g_strcmp0(part, "elm.icon.2")) {
376                 DBG(LOG_INFO, "elm.icon.2 - connection status [%d]\n", peer->conn_status);
377                 if (peer->conn_status == PEER_CONN_STATUS_CONNECTING) {
378                         layout = elm_layout_add(obj);
379                         elm_layout_theme_set(layout, "layout", "list/C/type.2", "default");
380                         icon = elm_progressbar_add(layout);
381                         elm_object_style_set(icon, "process_medium");
382                         elm_progressbar_pulse(icon, EINA_TRUE);
383                 } else if (peer->conn_status == PEER_CONN_STATUS_CONNECTED) {
384                         return NULL;
385                 }
386                 evas_object_show(icon);
387                 elm_layout_content_set(layout, "elm.swallow.content", icon);
388         } else if (!g_strcmp0(part, "elm.icon.1")) {
389                 DBG(LOG_INFO, "elm.icon.1 - category [%d]\n", peer->category);
390                 char *img_name = NULL;
391                 layout = elm_layout_add(obj);
392                 elm_layout_theme_set(layout, "layout", "list/B/type.3", "default");
393                 /*
394                 * the icon of connected device is
395                 * different from available and busy device
396                 */
397                 switch (peer->category) {
398                 case WFD_DEVICE_TYPE_COMPUTER:
399                         img_name = WFD_ICON_DEVICE_COMPUTER;
400                         break;
401                 case WFD_DEVICE_TYPE_INPUT_DEVICE:
402                         img_name = WFD_ICON_DEVICE_INPUT_DEVICE;
403                         break;
404                 case WFD_DEVICE_TYPE_PRINTER:
405                         img_name = WFD_ICON_DEVICE_PRINTER;
406                         break;
407                 case WFD_DEVICE_TYPE_CAMERA:
408                         img_name = WFD_ICON_DEVICE_CAMERA;
409                         break;
410                 case WFD_DEVICE_TYPE_STORAGE:
411                         img_name = WFD_ICON_DEVICE_STORAGE;
412                         break;
413                 case WFD_DEVICE_TYPE_NW_INFRA:
414                         img_name = WFD_ICON_DEVICE_NETWORK_INFRA;
415                         break;
416                 case WFD_DEVICE_TYPE_DISPLAYS:
417                         img_name = WFD_ICON_DEVICE_DISPLAY;
418                         break;
419                 case WFD_DEVICE_TYPE_MM_DEVICES:
420                         if (peer->sub_category == WIFI_DIRECT_SECONDARY_DEVICE_TYPE_MULTIMEDIA_STB) {
421                                 img_name = WFD_ICON_DEVICE_STB;
422                         } else if (peer->sub_category == WIFI_DIRECT_SECONDARY_DEVICE_TYPE_MULTIMEDIA_MS_MA_ME) {
423                                 img_name = WFD_ICON_DEVICE_DONGLE;
424                         } else if (peer->sub_category == WIFI_DIRECT_SECONDARY_DEVICE_TYPE_MULTIMEDIA_PVP) {
425                                 img_name = WFD_ICON_DEVICE_BD;
426                         } else {
427                                 img_name = WFD_ICON_DEVICE_MULTIMEDIA;
428                         }
429                         break;
430                 case WFD_DEVICE_TYPE_GAME_DEVICES:
431                         img_name = WFD_ICON_DEVICE_GAMING;
432                         break;
433                 case WFD_DEVICE_TYPE_TELEPHONE:
434                         img_name = WFD_ICON_DEVICE_TELEPHONE;
435                         break;
436                 case WFD_DEVICE_TYPE_AUDIO:
437                         if (peer->sub_category == WIFI_DIRECT_SECONDARY_DEVICE_TYPE_AUDIO_TUNER) {
438                                 img_name = WFD_ICON_DEVICE_HOME_THEATER;
439                         } else {
440                                 img_name = WFD_ICON_DEVICE_HEADSET;
441                         }
442                         break;
443                 default:
444                         img_name = WFD_ICON_DEVICE_UNKNOWN;
445                         break;
446                 }
447
448                 icon = elm_image_add(layout);
449                 elm_image_file_set(icon, WFD_UG_EDJ_PATH, img_name);
450                 evas_object_size_hint_align_set(icon, EVAS_HINT_FILL, EVAS_HINT_FILL);
451                 evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
452                 evas_object_color_set(icon, 2, 61, 132, 204);
453                 evas_object_show(icon);
454                 evas_object_propagate_events_set(icon, EINA_FALSE);
455                 elm_layout_content_set(layout, "elm.swallow.content", icon);
456         }
457
458         if (layout)
459                 evas_object_show(layout);
460         __FUNC_EXIT__;
461         return layout;
462 }
463
464 /**
465  *      This function let the ug get the icon of peer item
466  *      @return   the icon of peer item
467  *      @param[in] data the pointer to the main data structure
468  *      @param[in] obj the pointer to the evas object
469  *      @param[in] part the pointer to the part of item
470  */
471 static Evas_Object *_gl_conn_peer_icon_get(void *data, Evas_Object *obj, const char *part)
472 {
473         __FUNC_ENTER__;
474         assertm_if(NULL == obj, "NULL!!");
475         assertm_if(NULL == part, "NULL!!");
476         device_type_s *peer = (device_type_s *) data;
477         Evas_Object *icon = NULL;
478         Evas_Object *layout = NULL;
479
480         if (data == NULL) {
481                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
482                 return NULL;
483         }
484         DBG(LOG_INFO, "part[%s]\n", part);
485         if (!g_strcmp0(part, "elm.icon.1")) {
486                 DBG(LOG_INFO, "elm.icon.1 - category [%d]\n", peer->category);
487                 char *img_name = NULL;
488                 layout = elm_layout_add(obj);
489                 elm_layout_theme_set(layout, "layout", "list/B/type.3", "default");
490                 /*
491                 * the icon of connected device is
492                 * different from available and busy device
493                 */
494                 switch (peer->category) {
495                 case WFD_DEVICE_TYPE_COMPUTER:
496                         img_name = WFD_ICON_DEVICE_COMPUTER;
497                         break;
498                 case WFD_DEVICE_TYPE_INPUT_DEVICE:
499                         img_name = WFD_ICON_DEVICE_INPUT_DEVICE;
500                         break;
501                 case WFD_DEVICE_TYPE_PRINTER:
502                         img_name = WFD_ICON_DEVICE_PRINTER;
503                         break;
504                 case WFD_DEVICE_TYPE_CAMERA:
505                         img_name = WFD_ICON_DEVICE_CAMERA;
506                         break;
507                 case WFD_DEVICE_TYPE_STORAGE:
508                         img_name = WFD_ICON_DEVICE_STORAGE;
509                         break;
510                 case WFD_DEVICE_TYPE_NW_INFRA:
511                         img_name = WFD_ICON_DEVICE_NETWORK_INFRA;
512                         break;
513                 case WFD_DEVICE_TYPE_DISPLAYS:
514                         img_name = WFD_ICON_DEVICE_DISPLAY;
515                         break;
516                 case WFD_DEVICE_TYPE_MM_DEVICES:
517                         if (peer->sub_category == WIFI_DIRECT_SECONDARY_DEVICE_TYPE_MULTIMEDIA_STB) {
518                                 img_name = WFD_ICON_DEVICE_STB;
519                         } else if (peer->sub_category == WIFI_DIRECT_SECONDARY_DEVICE_TYPE_MULTIMEDIA_MS_MA_ME) {
520                                 img_name = WFD_ICON_DEVICE_DONGLE;
521                         } else if (peer->sub_category == WIFI_DIRECT_SECONDARY_DEVICE_TYPE_MULTIMEDIA_PVP) {
522                                 img_name = WFD_ICON_DEVICE_BD;
523                         } else {
524                                 img_name = WFD_ICON_DEVICE_MULTIMEDIA;
525                         }
526                         break;
527                 case WFD_DEVICE_TYPE_GAME_DEVICES:
528                         img_name = WFD_ICON_DEVICE_GAMING;
529                         break;
530                 case WFD_DEVICE_TYPE_TELEPHONE:
531                         img_name = WFD_ICON_DEVICE_TELEPHONE;
532                         break;
533                 case WFD_DEVICE_TYPE_AUDIO:
534                         if (peer->sub_category == WIFI_DIRECT_SECONDARY_DEVICE_TYPE_AUDIO_TUNER) {
535                                 img_name = WFD_ICON_DEVICE_HOME_THEATER;
536                         } else {
537                                 img_name = WFD_ICON_DEVICE_HEADSET;
538                         }
539                         break;
540                 default:
541                         img_name = WFD_ICON_DEVICE_UNKNOWN;
542                         break;
543                 }
544
545                 icon = elm_image_add(layout);
546                 elm_image_file_set(icon, WFD_UG_EDJ_PATH, img_name);
547                 evas_object_size_hint_align_set(icon, EVAS_HINT_FILL, EVAS_HINT_FILL);
548                 evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
549                 evas_object_color_set(icon, 2, 61, 132, 204);
550                 evas_object_show(icon);
551                 evas_object_propagate_events_set(icon, EINA_FALSE);
552                 elm_layout_content_set(layout, "elm.swallow.content", icon);
553         }
554         if (layout)
555                 evas_object_show(layout);
556         __FUNC_EXIT__;
557         return layout;
558 }
559
560 /**
561  *      This function let the ug get the text of no device item
562  *      @return   the text of no device item
563  *      @param[in] data the pointer to the main data structure
564  *      @param[in] obj the pointer to the evas object
565  *      @param[in] part the pointer to the part of item
566  */
567 static char *_gl_noitem_text_get(void *data, Evas_Object *obj, const char *part)
568 {
569         __FUNC_ENTER__;
570
571         if (data == NULL) {
572                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
573                 return NULL;
574         }
575
576         DBG(LOG_INFO,"part = %s",part);
577         if (!g_strcmp0(part, "elm.text.main.left")) {
578                 return g_strdup(_("IDS_BT_BODY_NO_DEVICES_FOUND_ABB"));
579         }
580         __FUNC_EXIT__;
581         return NULL;
582 }
583
584 /**
585  *      This function let the ug get the title label of connected device list
586  *      @return   the title label of connected device list
587  *      @param[in] data the pointer to the main data structure
588  *      @param[in] obj the pointer to the evas object
589  *      @param[in] part the pointer to the part of item
590  */
591 static char *_gl_conn_dev_title_label_get(void *data, Evas_Object *obj, const char *part)
592 {
593         __FUNC_ENTER__;
594
595         if (data == NULL) {
596                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
597                 return NULL;
598         }
599         DBG(LOG_INFO,"part = %s",part);
600         if (!g_strcmp0(part, "elm.text.main")) {
601                 return g_strdup(_("IDS_ST_HEADER_CONNECTED_DEVICES"));
602         }
603
604         __FUNC_EXIT__;
605         return NULL;
606 }
607
608 char* ConvertRGBAtoHex(int r, int g, int b, int a)
609 {
610         int hexcolor = 0;
611         char *string = NULL;
612         string = g_try_malloc0(sizeof(char )* 255);
613         if (string == NULL) {
614                 return string;
615         }
616         hexcolor = (r << 24) + (g << 16) + (b << 8) + a;
617         sprintf(string, "%08x", hexcolor );
618         return string;
619 }
620
621 /**
622  *      This function let the ug get the label of connected device
623  *      @return   the label of connected device
624  *      @param[in] data the pointer to the main data structure
625  *      @param[in] obj the pointer to the evas object
626  *      @param[in] part the pointer to the part of item
627  */
628 static char *_gl_peer_conn_dev_label_get(void *data, Evas_Object *obj, const char *part)
629 {
630         __FUNC_ENTER__;
631
632         assertm_if(NULL == obj, "NULL!!");
633         assertm_if(NULL == part, "NULL!!");
634         device_type_s *peer = (device_type_s *) data;
635         DBG(LOG_INFO, "%s", part);
636         char *det = NULL;
637         char *buf = NULL;
638         char *str = NULL;
639         char *ssid;
640         int r = 0, g = 0, b = 0, a = 0;
641
642         if (data == NULL) {
643                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
644                 return NULL;
645         }
646
647         if (!g_strcmp0(part, "elm.text.main.left.top")) {
648                 if (strlen(peer->ssid) != 0) {
649                         ssid = elm_entry_utf8_to_markup(peer->ssid);
650                         if (NULL == ssid) {
651                                 DBG(LOG_ERROR, "elm_entry_utf8_to_markup failed.\n");
652                                 __FUNC_EXIT__;
653                                 return NULL;
654                         }
655                         __FUNC_EXIT__;
656                         return ssid;
657                 }
658         } else if(!g_strcmp0(part, "elm.text.sub.left.bottom")){
659                 det = elm_entry_utf8_to_markup(_("IDS_COM_BODY_CONNECTED_M_STATUS"));
660                 edje_color_class_get("T024S",&r, &g, &b, &a,
661                         NULL, NULL, NULL, NULL,
662                         NULL, NULL, NULL, NULL);
663                 str = ConvertRGBAtoHex(r, g, b, a);
664                 buf = g_strdup_printf("<color=#%s>%s</color>",
665                         str, det);
666                 if (det != NULL) {
667                         g_free(det);
668                 }
669                 if (str != NULL) {
670                         g_free(str);
671                 }
672                 __FUNC_EXIT__;
673                 return buf;
674         }
675         __FUNC_EXIT__;
676         return NULL;
677 }
678
679 /**
680  *      This function let the ug get the title label of connected failed device list
681  *      @return   the label of connected device
682  *      @param[in] data the pointer to the main data structure
683  *      @param[in] obj the pointer to the evas object
684  *      @param[in] part the pointer to the part of item
685  */
686 static char *_gl_conn_failed_dev_title_label_get(void *data, Evas_Object *obj,
687                 const char *part)
688 {
689         __FUNC_ENTER__;
690
691         if (data == NULL) {
692                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
693                 return NULL;
694         }
695
696         if (!g_strcmp0(part, "elm.text")) {
697                 return g_strdup(_("IDS_WIFI_SBODY_NOT_CONNECTED_M_STATUS_ABB"));
698         }
699
700         __FUNC_EXIT__;
701         return NULL;
702 }
703
704 /**
705  *      This function let the ug get the label of connected failed device
706  *      @return   the label of connected device
707  *      @param[in] data the pointer to the main data structure
708  *      @param[in] obj the pointer to the evas object
709  *      @param[in] part the pointer to the part of item
710  */
711 static char *_gl_peer_conn_failed_dev_label_get(void *data, Evas_Object *obj, const char *part)
712 {
713         __FUNC_ENTER__;
714
715         assertm_if(NULL == obj, "NULL!!");
716         assertm_if(NULL == part, "NULL!!");
717         device_type_s *peer = (device_type_s *) data;
718         char buf[WFD_GLOBALIZATION_STR_LENGTH] = { 0, };
719         char *ssid;
720         DBG(LOG_INFO, "%s", part);
721
722         if (data == NULL) {
723                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
724                 return NULL;
725         }
726
727         if (!g_strcmp0(part, "elm.text.1")) {
728                 if (strlen(peer->ssid) != 0) {
729                         ssid = elm_entry_utf8_to_markup(peer->ssid);
730                         if (NULL == ssid) {
731                                 DBG(LOG_ERROR, "elm_entry_utf8_to_markup failed.\n");
732                                 __FUNC_EXIT__;
733                                 return NULL;
734                         }
735                         __FUNC_EXIT__;
736                         return ssid;
737                 }
738         } else {
739                 g_strlcpy(buf, _("IDS_CHATON_HEADER_CONNECTION_FAILED_ABB2"),
740                         WFD_GLOBALIZATION_STR_LENGTH);
741                 __FUNC_EXIT__;
742                 return g_strdup(buf);
743         }
744         return NULL;
745 }
746
747 /**
748  *      This function let the ug get the title label of multi connect list
749  *      @return   the label of connected device
750  *      @param[in] data the pointer to the main data structure
751  *      @param[in] obj the pointer to the evas object
752  *      @param[in] part the pointer to the part of item
753  */
754 static char *_gl_multi_connect_dev_title_label_get(void *data, Evas_Object *obj, const char *part)
755 {
756         __FUNC_ENTER__;
757         struct ug_data *ugd = wfd_get_ug_data();
758
759         if (data == NULL) {
760                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
761                 return NULL;
762         }
763         DBG(LOG_INFO, "%s", part);
764
765         if (!g_strcmp0(part, "elm.text.main")) {
766                 if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_IN_PROGRESS) {
767                         return g_strdup(_("IDS_WIFI_HEADER_AVAILABLE_DEVICES_ABB"));
768                 } else if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_COMPLETED) {
769                         return g_strdup(_("IDS_WIFI_SBODY_NOT_CONNECTED_M_STATUS_ABB"));
770                 }
771         }
772
773         __FUNC_EXIT__;
774         return NULL;
775 }
776
777 /**
778  *      This function let the ug get the title label of select all in multi connect
779  *      @return   the label of select all string
780  *      @param[in] data the pointer to the main data structure
781  *      @param[in] obj the pointer to the evas object
782  *      @param[in] part the pointer to the part of item
783  */
784 static char *_gl_multi_connect_select_all_title_label_get(void *data, Evas_Object *obj, const char *part)
785 {
786         __FUNC_ENTER__;
787
788         if (data == NULL) {
789                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
790                 return NULL;
791         }
792         DBG(LOG_INFO, "%s", part);
793
794         if (!g_strcmp0(part, "elm.text.main.left")) {
795                 __FUNC_EXIT__;
796                 return g_strdup(_("IDS_WIFI_BODY_SELECT_ALL"));
797         }
798         __FUNC_EXIT__;
799         return NULL;
800 }
801
802 /**
803  *      This function let the ug get the icon of select all genlist
804  *      @return   the icon of select all genlist
805  *      @param[in] data the pointer to the main data structure
806  *      @param[in] obj the pointer to the evas object
807  *      @param[in] part the pointer to the part of item
808  */
809 static Evas_Object *_wfd_gl_select_all_icon_get(void *data, Evas_Object *obj, const char *part)
810 {
811         __FUNC_ENTER__;
812
813         struct ug_data *ugd = (struct ug_data *) data;
814         Evas_Object *check = NULL;
815         Evas_Object *icon_layout = NULL;
816
817         DBG(LOG_INFO, "Part %s", part);
818
819         if (!g_strcmp0(part, "elm.icon.2")) {
820                 icon_layout = elm_layout_add(obj);
821                 elm_layout_theme_set(icon_layout, "layout", "list/C/type.2", "default");
822                 DBG(LOG_INFO, "Part %s", part);
823                 check = elm_check_add(icon_layout);
824                 ugd->select_all_icon = check;
825                 if (ugd->is_select_all_checked == EINA_TRUE) {
826                         elm_check_state_set(ugd->select_all_icon, TRUE);
827                 }
828                 elm_object_style_set(check, "default/genlist");
829                 evas_object_propagate_events_set(check, EINA_FALSE);
830                 evas_object_smart_callback_add(check, "changed",
831                         wfd_genlist_select_all_check_changed_cb, (void *)data);
832                 elm_layout_content_set(icon_layout, "elm.swallow.content", check);
833         }
834         __FUNC_EXIT__;
835         return icon_layout;
836 }
837
838 /**
839  *      This function let the ug get the title label of busy device list
840  *      @return   the label of connected device
841  *      @param[in] data the pointer to the main data structure
842  *      @param[in] obj the pointer to the evas object
843  *      @param[in] part the pointer to the part of item
844  */
845 static char *_gl_busy_dev_title_label_get(void *data, Evas_Object *obj,
846                 const char *part)
847 {
848         __FUNC_ENTER__;
849
850         if (data == NULL) {
851                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
852                 return NULL;
853         }
854         DBG(LOG_INFO, "%s", part);
855
856         if (!g_strcmp0(part,"elm.text.main")) {
857                 return g_strdup(_("IDS_ST_HEADER_BUSY_DEVICES"));
858         }
859
860         __FUNC_EXIT__;
861         return NULL;
862 }
863
864 /**
865  *      This function let the ug get the label of busy device
866  *      @return   the label of connected device
867  *      @param[in] data the pointer to the main data structure
868  *      @param[in] obj the pointer to the evas object
869  *      @param[in] part the pointer to the part of item
870  */
871 static char *_gl_peer_busy_dev_label_get(void *data, Evas_Object *obj, const char *part)
872 {
873         __FUNC_ENTER__;
874         assertm_if(NULL == obj, "NULL!!");
875         assertm_if(NULL == part, "NULL!!");
876         device_type_s *peer = (device_type_s *) data;
877         char buf[WFD_GLOBALIZATION_STR_LENGTH] = { 0, };
878         char *ssid;
879         DBG(LOG_INFO, "%s", part);
880
881         if (data == NULL) {
882                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
883                 return NULL;
884         }
885
886         DBG(LOG_INFO, "peer->ssid = %s", peer->ssid);
887
888         if (!g_strcmp0(part, "elm.text.main.left.top")) {
889                 if (strlen(peer->ssid) != 0) {
890                         ssid = elm_entry_utf8_to_markup(peer->ssid);
891                         if (NULL == ssid) {
892                                 DBG(LOG_ERROR, "elm_entry_utf8_to_markup failed.\n");
893                                 __FUNC_EXIT__;
894                                 return NULL;
895                         }
896                         __FUNC_EXIT__;
897                         return ssid;
898                 }
899         } else if (!g_strcmp0(part, "elm.text.sub.left.bottom")) {
900                 g_strlcpy(buf, _("IDS_ST_BODY_CONNECTED_WITH_ANOTHER_DEVICE_ABB"),
901                         WFD_GLOBALIZATION_STR_LENGTH);
902                 __FUNC_EXIT__;
903                 return g_strdup(buf);
904         }
905         return NULL;
906
907 }
908
909 /**
910  *      This function let the ug delete the peer item
911  *      @return   void
912  *      @param[in] data the pointer to the main data structure
913  *      @param[in] obj the pointer to the evas object
914  */
915 static void _gl_peer_del(void *data, Evas_Object *obj)
916 {
917         __FUNC_ENTER__;
918
919         assertm_if(NULL == obj, "NULL!!");
920         assertm_if(NULL == data, "NULL!!");
921
922         __FUNC_EXIT__;
923         return;
924 }
925
926 /**
927  *      This function let the ug initialize the items of genlist
928  *      @return   void
929  */
930 void initialize_gen_item_class()
931 {
932         elm_theme_extension_add(NULL, WFD_UG_EDJ_PATH);
933
934         device_name_itc.item_style = "dialogue/2text.2";
935         device_name_itc.func.text_get = NULL;
936         device_name_itc.func.content_get = NULL;
937         device_name_itc.func.state_get = NULL;
938
939 #ifdef WFD_ON_OFF_GENLIST
940         wfd_onoff_itc.item_style = "2line.bottom";
941         wfd_onoff_itc.func.text_get = _gl_wfd_onoff_text_get;
942         wfd_onoff_itc.func.content_get = _gl_wfd_onoff_content_get;
943         wfd_onoff_itc.func.state_get = NULL;
944         wfd_onoff_itc.func.del = NULL;
945 #endif
946
947
948         title_itc.item_style = "groupindex";
949         title_itc.func.text_get = _gl_title_label_get;
950         title_itc.func.content_get = _gl_title_content_get;
951         title_itc.func.state_get = NULL;
952         title_itc.func.del = NULL;
953
954         multi_view_title_itc.item_style = "groupindex";
955         multi_view_title_itc.func.text_get = _gl_multi_title_label_get;
956         multi_view_title_itc.func.content_get = _gl_multi_title_content_get;
957         multi_view_title_itc.func.state_get = NULL;
958         multi_view_title_itc.func.del = NULL;
959
960         title_no_device_itc.item_style = "groupindex";
961         title_no_device_itc.func.text_get = _gl_title_no_device_label_get;
962         title_no_device_itc.func.content_get = NULL;
963         title_no_device_itc.func.state_get = NULL;
964         title_no_device_itc.func.del = NULL;
965
966         title_available_itc.item_style = "groupindex";
967         title_available_itc.func.text_get = _gl_available_title_label_get;
968         title_available_itc.func.content_get = _gl_title_content_get;
969         title_available_itc.func.state_get = NULL;
970         title_available_itc.func.del = NULL;
971
972         peer_itc.item_style = "2line.top";
973         peer_itc.func.text_get = _gl_peer_label_get;
974         peer_itc.func.content_get = _gl_peer_icon_get;
975         peer_itc.func.state_get = NULL;
976         peer_itc.func.del = _gl_peer_del;
977
978         noitem_itc.item_style = "1line";
979         noitem_itc.func.text_get = _gl_noitem_text_get;
980         noitem_itc.func.content_get = NULL;
981         noitem_itc.func.state_get = NULL;
982         noitem_itc.func.del = NULL;
983
984         title_conn_itc.item_style = "groupindex";
985         title_conn_itc.func.text_get = _gl_conn_dev_title_label_get;
986         title_conn_itc.func.content_get = NULL;
987         title_conn_itc.func.state_get = NULL;
988         title_conn_itc.func.del = NULL;
989
990         peer_conn_itc.item_style = "2line.top";
991         peer_conn_itc.func.text_get = _gl_peer_conn_dev_label_get;
992         peer_conn_itc.func.content_get = _gl_conn_peer_icon_get;
993         peer_conn_itc.func.state_get = NULL;
994         peer_conn_itc.func.del = _gl_peer_del;
995
996         title_conn_failed_itc.item_style = "dialogue/title";
997         title_conn_failed_itc.func.text_get = _gl_conn_failed_dev_title_label_get;
998         title_conn_failed_itc.func.content_get = NULL;
999         title_conn_failed_itc.func.state_get = NULL;
1000         title_conn_failed_itc.func.del = NULL;
1001
1002         peer_conn_failed_itc.item_style = "dialogue/2text.2icon.3";
1003         peer_conn_failed_itc.func.text_get = _gl_peer_conn_failed_dev_label_get;
1004         peer_conn_failed_itc.func.content_get = _gl_peer_icon_get;
1005         peer_conn_failed_itc.func.state_get = NULL;
1006         peer_conn_failed_itc.func.del = _gl_peer_del;
1007
1008         title_busy_itc.item_style = "groupindex";
1009         title_busy_itc.func.text_get = _gl_busy_dev_title_label_get;
1010         title_busy_itc.func.content_get = NULL;
1011         title_busy_itc.func.state_get = NULL;
1012         title_busy_itc.func.del = NULL;
1013
1014         peer_busy_itc.item_style = "2line.top";
1015         peer_busy_itc.func.text_get = _gl_peer_busy_dev_label_get;
1016         peer_busy_itc.func.content_get = _gl_peer_icon_get;
1017         peer_busy_itc.func.state_get = NULL;
1018         peer_busy_itc.func.del = _gl_peer_del;
1019
1020         title_multi_connect_itc.item_style = "groupindex";
1021         title_multi_connect_itc.func.text_get = _gl_multi_connect_dev_title_label_get;
1022         title_multi_connect_itc.func.content_get = NULL;
1023         title_multi_connect_itc.func.state_get = NULL;
1024         title_multi_connect_itc.func.del = NULL;
1025
1026         select_all_multi_connect_itc.item_style = "1line";
1027         select_all_multi_connect_itc.func.text_get =
1028                 _gl_multi_connect_select_all_title_label_get;
1029         select_all_multi_connect_itc.func.content_get = _wfd_gl_select_all_icon_get;
1030         select_all_multi_connect_itc.func.state_get = NULL;
1031         select_all_multi_connect_itc.func.del = NULL;
1032 }