c0db0da48c7a5acef3413d8d32cf5ff99a066024
[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                 if (det != NULL) {
664                         g_free(det);
665                 }
666                 __FUNC_EXIT__;
667                 return buf;
668         }
669         __FUNC_EXIT__;
670         return NULL;
671 }
672
673 /**
674  *      This function let the ug get the title label of connected failed device list
675  *      @return   the label of connected device
676  *      @param[in] data the pointer to the main data structure
677  *      @param[in] obj the pointer to the evas object
678  *      @param[in] part the pointer to the part of item
679  */
680 static char *_gl_conn_failed_dev_title_label_get(void *data, Evas_Object *obj,
681                 const char *part)
682 {
683         __FUNC_ENTER__;
684
685         if (data == NULL) {
686                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
687                 return NULL;
688         }
689
690         if (!strcmp("elm.text", part)) {
691                 return g_strdup(D_("IDS_WIFI_SBODY_NOT_CONNECTED_M_STATUS_ABB"));
692         }
693
694         __FUNC_EXIT__;
695         return NULL;
696 }
697
698 /**
699  *      This function let the ug get the label of connected failed device
700  *      @return   the label of connected device
701  *      @param[in] data the pointer to the main data structure
702  *      @param[in] obj the pointer to the evas object
703  *      @param[in] part the pointer to the part of item
704  */
705 static char *_gl_peer_conn_failed_dev_label_get(void *data, Evas_Object *obj, const char *part)
706 {
707         __FUNC_ENTER__;
708
709         assertm_if(NULL == obj, "NULL!!");
710         assertm_if(NULL == part, "NULL!!");
711         device_type_s *peer = (device_type_s *) data;
712         char buf[WFD_GLOBALIZATION_STR_LENGTH] = { 0, };
713         char *ssid;
714         DBG(LOG_INFO, "%s", part);
715
716         if (data == NULL) {
717                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
718                 return NULL;
719         }
720
721         if (!strcmp("elm.text", part)) {
722                 if (strlen(peer->ssid) != 0) {
723                         ssid = elm_entry_utf8_to_markup(peer->ssid);
724                         if (NULL == ssid) {
725                                 DBG(LOG_ERROR, "elm_entry_utf8_to_markup failed.\n");
726                                 __FUNC_EXIT__;
727                                 return NULL;
728                         }
729                         __FUNC_EXIT__;
730                         return ssid;
731                 }
732         } else if (!strcmp("elm.text.sub", part)) {
733                 g_strlcpy(buf, D_("IDS_CHATON_HEADER_CONNECTION_FAILED_ABB2"),
734                         WFD_GLOBALIZATION_STR_LENGTH);
735                 __FUNC_EXIT__;
736                 return g_strdup(buf);
737         }
738         return NULL;
739 }
740
741 /**
742  *      This function let the ug get the title label of multi connect list
743  *      @return   the label of connected device
744  *      @param[in] data the pointer to the main data structure
745  *      @param[in] obj the pointer to the evas object
746  *      @param[in] part the pointer to the part of item
747  */
748 static char *_gl_multi_connect_dev_title_label_get(void *data, Evas_Object *obj, const char *part)
749 {
750         __FUNC_ENTER__;
751         struct ug_data *ugd = wfd_get_ug_data();
752
753         if (data == NULL) {
754                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
755                 return NULL;
756         }
757         DBG(LOG_INFO, "%s", part);
758
759         if (!strcmp("elm.text", part)) {
760                 if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_IN_PROGRESS) {
761                         return g_strdup(D_("IDS_WIFI_HEADER_AVAILABLE_DEVICES_ABB"));
762                 } else if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_COMPLETED) {
763                         return g_strdup(D_("IDS_WIFI_SBODY_NOT_CONNECTED_M_STATUS_ABB"));
764                 }
765         }
766
767         __FUNC_EXIT__;
768         return NULL;
769 }
770
771 /**
772  *      This function let the ug get the title label of select all in multi connect
773  *      @return   the label of select all string
774  *      @param[in] data the pointer to the main data structure
775  *      @param[in] obj the pointer to the evas object
776  *      @param[in] part the pointer to the part of item
777  */
778 static char *_gl_multi_connect_select_all_title_label_get(void *data, Evas_Object *obj, const char *part)
779 {
780         __FUNC_ENTER__;
781
782         if (data == NULL) {
783                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
784                 return NULL;
785         }
786         DBG(LOG_INFO, "%s", part);
787
788         if (!strcmp("elm.text", part)) {
789                 __FUNC_EXIT__;
790                 return g_strdup(D_("IDS_WIFI_BODY_SELECT_ALL"));
791         }
792         __FUNC_EXIT__;
793         return NULL;
794 }
795
796 /**
797  *      This function let the ug get the icon of select all genlist
798  *      @return   the icon of select all genlist
799  *      @param[in] data the pointer to the main data structure
800  *      @param[in] obj the pointer to the evas object
801  *      @param[in] part the pointer to the part of item
802  */
803 static Evas_Object *_wfd_gl_select_all_icon_get(void *data, Evas_Object *obj, const char *part)
804 {
805         __FUNC_ENTER__;
806
807         struct ug_data *ugd = (struct ug_data *) data;
808         Evas_Object *check = NULL;
809         Evas_Object *icon_layout = NULL;
810
811         DBG(LOG_INFO, "Part %s", part);
812
813         if (!strcmp("elm.swallow.end", part)) {
814                 icon_layout = elm_layout_add(obj);
815                 elm_layout_theme_set(icon_layout, "layout", "list/C/type.2", "default");
816                 DBG(LOG_INFO, "Part %s", part);
817                 check = elm_check_add(icon_layout);
818                 ugd->select_all_icon = check;
819                 if (ugd->is_select_all_checked == EINA_TRUE) {
820                         elm_check_state_set(ugd->select_all_icon, TRUE);
821                 }
822                 elm_object_style_set(check, "default/genlist");
823                 evas_object_propagate_events_set(check, EINA_FALSE);
824                 evas_object_smart_callback_add(check, "changed",
825                         wfd_genlist_select_all_check_changed_cb, (void *)data);
826                 elm_layout_content_set(icon_layout, "elm.swallow.content", check);
827         }
828         __FUNC_EXIT__;
829         return icon_layout;
830 }
831
832 /**
833  *      This function let the ug get the title label of busy device list
834  *      @return   the label of connected device
835  *      @param[in] data the pointer to the main data structure
836  *      @param[in] obj the pointer to the evas object
837  *      @param[in] part the pointer to the part of item
838  */
839 static char *_gl_busy_dev_title_label_get(void *data, Evas_Object *obj,
840                 const char *part)
841 {
842         __FUNC_ENTER__;
843
844         if (data == NULL) {
845                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
846                 return NULL;
847         }
848         DBG(LOG_INFO, "%s", part);
849
850         if (!strcmp("elm.text", part)) {
851                 return g_strdup(D_("IDS_ST_HEADER_BUSY_DEVICES"));
852         }
853
854         __FUNC_EXIT__;
855         return NULL;
856 }
857
858 /**
859  *      This function let the ug get the label of busy device
860  *      @return   the label of connected device
861  *      @param[in] data the pointer to the main data structure
862  *      @param[in] obj the pointer to the evas object
863  *      @param[in] part the pointer to the part of item
864  */
865 static char *_gl_peer_busy_dev_label_get(void *data, Evas_Object *obj, const char *part)
866 {
867         __FUNC_ENTER__;
868         assertm_if(NULL == obj, "NULL!!");
869         assertm_if(NULL == part, "NULL!!");
870         device_type_s *peer = (device_type_s *) data;
871         char buf[WFD_GLOBALIZATION_STR_LENGTH] = { 0, };
872         char *ssid;
873         DBG(LOG_INFO, "%s", part);
874
875         if (data == NULL) {
876                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
877                 return NULL;
878         }
879
880         DBG(LOG_INFO, "peer->ssid = %s", peer->ssid);
881
882         if (!strcmp("elm.text", part)) {
883                 if (strlen(peer->ssid) != 0) {
884                         ssid = elm_entry_utf8_to_markup(peer->ssid);
885                         if (NULL == ssid) {
886                                 DBG(LOG_ERROR, "elm_entry_utf8_to_markup failed.\n");
887                                 __FUNC_EXIT__;
888                                 return NULL;
889                         }
890                         __FUNC_EXIT__;
891                         return ssid;
892                 }
893         } else if (!strcmp("elm.text.sub", part)) {
894                 g_strlcpy(buf, D_("IDS_ST_BODY_CONNECTED_WITH_ANOTHER_DEVICE_ABB"),
895                         WFD_GLOBALIZATION_STR_LENGTH);
896                 __FUNC_EXIT__;
897                 return g_strdup(buf);
898         }
899
900         return NULL;
901 }
902
903 /**
904  *      This function let the ug delete the peer item
905  *      @return   void
906  *      @param[in] data the pointer to the main data structure
907  *      @param[in] obj the pointer to the evas object
908  */
909 static void _gl_peer_del(void *data, Evas_Object *obj)
910 {
911         __FUNC_ENTER__;
912
913         assertm_if(NULL == obj, "NULL!!");
914         assertm_if(NULL == data, "NULL!!");
915
916         __FUNC_EXIT__;
917         return;
918 }
919
920 /**
921  *      This function let the ug initialize the items of genlist
922  *      @return   void
923  */
924 void initialize_gen_item_class()
925 {
926         elm_theme_extension_add(NULL, WFD_UG_EDJ_PATH);
927
928         device_name_itc.item_style = WFD_GENLIST_MULTILINE_TEXT_STYLE;
929         device_name_itc.func.text_get = _gl_device_name_label_get;
930         device_name_itc.func.content_get = NULL;
931         device_name_itc.func.state_get = NULL;
932
933 #ifdef WFD_ON_OFF_GENLIST
934         wfd_onoff_itc.item_style = WFD_GENLIST_2LINE_BOTTOM_TEXT_ICON_STYLE;
935         wfd_onoff_itc.func.text_get = _gl_wfd_onoff_text_get;
936         wfd_onoff_itc.func.content_get = _gl_wfd_onoff_content_get;
937         wfd_onoff_itc.func.state_get = NULL;
938         wfd_onoff_itc.func.del = NULL;
939 #endif
940
941         title_itc.item_style = WFD_GENLIST_GROUP_INDEX_STYLE;
942         title_itc.func.text_get = _gl_title_label_get;
943         title_itc.func.content_get = _gl_title_content_get;
944         title_itc.func.state_get = NULL;
945         title_itc.func.del = NULL;
946
947         multi_view_title_itc.item_style = WFD_GENLIST_GROUP_INDEX_STYLE;
948         multi_view_title_itc.func.text_get = _gl_multi_title_label_get;
949         multi_view_title_itc.func.content_get = _gl_multi_title_content_get;
950         multi_view_title_itc.func.state_get = NULL;
951         multi_view_title_itc.func.del = NULL;
952
953         title_no_device_itc.item_style = WFD_GENLIST_GROUP_INDEX_STYLE;
954         title_no_device_itc.func.text_get = _gl_title_no_device_label_get;
955         title_no_device_itc.func.content_get = NULL;
956         title_no_device_itc.func.state_get = NULL;
957         title_no_device_itc.func.del = NULL;
958
959         title_available_itc.item_style = WFD_GENLIST_GROUP_INDEX_STYLE;
960         title_available_itc.func.text_get = _gl_available_title_label_get;
961         title_available_itc.func.content_get = _gl_title_content_get;
962         title_available_itc.func.state_get = NULL;
963         title_available_itc.func.del = NULL;
964
965         peer_itc.item_style = WFD_GENLIST_2LINE_TOP_TEXT_ICON_STYLE;
966         peer_itc.func.text_get = _gl_peer_label_get;
967         peer_itc.func.content_get = _gl_peer_icon_get;
968         peer_itc.func.state_get = NULL;
969         peer_itc.func.del = _gl_peer_del;
970
971         noitem_itc.item_style = WFD_GENLIST_1LINE_TEXT_STYLE;
972         noitem_itc.func.text_get = _gl_noitem_text_get;
973         noitem_itc.func.content_get = NULL;
974         noitem_itc.func.state_get = NULL;
975         noitem_itc.func.del = NULL;
976
977         title_conn_itc.item_style = WFD_GENLIST_GROUP_INDEX_STYLE;
978         title_conn_itc.func.text_get = _gl_conn_dev_title_label_get;
979         title_conn_itc.func.content_get = NULL;
980         title_conn_itc.func.state_get = NULL;
981         title_conn_itc.func.del = NULL;
982
983         peer_conn_itc.item_style = WFD_GENLIST_2LINE_TOP_TEXT_ICON_STYLE;
984         peer_conn_itc.func.text_get = _gl_peer_conn_dev_label_get;
985         peer_conn_itc.func.content_get = _gl_conn_peer_icon_get;
986         peer_conn_itc.func.state_get = NULL;
987         peer_conn_itc.func.del = _gl_peer_del;
988
989         title_conn_failed_itc.item_style = WFD_GENLIST_1LINE_TEXT_STYLE;
990         title_conn_failed_itc.func.text_get = _gl_conn_failed_dev_title_label_get;
991         title_conn_failed_itc.func.content_get = NULL;
992         title_conn_failed_itc.func.state_get = NULL;
993         title_conn_failed_itc.func.del = NULL;
994
995         peer_conn_failed_itc.item_style = WFD_GENLIST_2LINE_TOP_TEXT_ICON_STYLE;
996         peer_conn_failed_itc.func.text_get = _gl_peer_conn_failed_dev_label_get;
997         peer_conn_failed_itc.func.content_get = _gl_peer_icon_get;
998         peer_conn_failed_itc.func.state_get = NULL;
999         peer_conn_failed_itc.func.del = _gl_peer_del;
1000
1001         title_busy_itc.item_style = WFD_GENLIST_GROUP_INDEX_STYLE;
1002         title_busy_itc.func.text_get = _gl_busy_dev_title_label_get;
1003         title_busy_itc.func.content_get = NULL;
1004         title_busy_itc.func.state_get = NULL;
1005         title_busy_itc.func.del = NULL;
1006
1007         peer_busy_itc.item_style = WFD_GENLIST_2LINE_TOP_TEXT_ICON_STYLE;
1008         peer_busy_itc.func.text_get = _gl_peer_busy_dev_label_get;
1009         peer_busy_itc.func.content_get = _gl_peer_icon_get;
1010         peer_busy_itc.func.state_get = NULL;
1011         peer_busy_itc.func.del = _gl_peer_del;
1012
1013         title_multi_connect_itc.item_style = WFD_GENLIST_GROUP_INDEX_STYLE;
1014         title_multi_connect_itc.func.text_get = _gl_multi_connect_dev_title_label_get;
1015         title_multi_connect_itc.func.content_get = NULL;
1016         title_multi_connect_itc.func.state_get = NULL;
1017         title_multi_connect_itc.func.del = NULL;
1018
1019         select_all_multi_connect_itc.item_style = WFD_GENLIST_1LINE_TEXT_ICON_STYLE;
1020         select_all_multi_connect_itc.func.text_get =
1021                 _gl_multi_connect_select_all_title_label_get;
1022         select_all_multi_connect_itc.func.content_get = _wfd_gl_select_all_icon_get;
1023         select_all_multi_connect_itc.func.state_get = NULL;
1024         select_all_multi_connect_itc.func.del = NULL;
1025 }