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