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