Modified NOTICE file and license version
[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.1 (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
362         if (data == NULL) {
363                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
364                 return NULL;
365         }
366         DBG(LOG_INFO, "part = %s", part);
367
368         if (!strcmp("elm.swallow.icon", part)) {
369                 char *img_name = NULL;
370                 DBG(LOG_INFO, "elm.swallow.icon - category [%d]\n", peer->category);
371                 /*
372                 * the icon of connected device is
373                 * different from available and busy device
374                 */
375                 switch (peer->category) {
376                 case WFD_DEVICE_TYPE_COMPUTER:
377                         img_name = WFD_ICON_DEVICE_COMPUTER;
378                         break;
379                 case WFD_DEVICE_TYPE_INPUT_DEVICE:
380                         img_name = WFD_ICON_DEVICE_INPUT_DEVICE;
381                         break;
382                 case WFD_DEVICE_TYPE_PRINTER:
383                         img_name = WFD_ICON_DEVICE_PRINTER;
384                         break;
385                 case WFD_DEVICE_TYPE_CAMERA:
386                         img_name = WFD_ICON_DEVICE_CAMERA;
387                         break;
388                 case WFD_DEVICE_TYPE_STORAGE:
389                         img_name = WFD_ICON_DEVICE_STORAGE;
390                         break;
391                 case WFD_DEVICE_TYPE_NW_INFRA:
392                         img_name = WFD_ICON_DEVICE_NETWORK_INFRA;
393                         break;
394                 case WFD_DEVICE_TYPE_DISPLAYS:
395                         img_name = WFD_ICON_DEVICE_DISPLAY;
396                         break;
397                 case WFD_DEVICE_TYPE_MM_DEVICES:
398                         if (peer->sub_category == WIFI_DIRECT_SECONDARY_DEVICE_TYPE_MULTIMEDIA_STB)
399                                 img_name = WFD_ICON_DEVICE_STB;
400                         else if (peer->sub_category == WIFI_DIRECT_SECONDARY_DEVICE_TYPE_MULTIMEDIA_MS_MA_ME)
401                                 img_name = WFD_ICON_DEVICE_DONGLE;
402                         else if (peer->sub_category == WIFI_DIRECT_SECONDARY_DEVICE_TYPE_MULTIMEDIA_PVP)
403                                 img_name = WFD_ICON_DEVICE_BD;
404                         else
405                                 img_name = WFD_ICON_DEVICE_MULTIMEDIA;
406                         break;
407                 case WFD_DEVICE_TYPE_GAME_DEVICES:
408                         img_name = WFD_ICON_DEVICE_GAMING;
409                         break;
410                 case WFD_DEVICE_TYPE_TELEPHONE:
411                         img_name = WFD_ICON_DEVICE_TELEPHONE;
412                         break;
413                 case WFD_DEVICE_TYPE_AUDIO:
414                         if (peer->sub_category == WIFI_DIRECT_SECONDARY_DEVICE_TYPE_AUDIO_TUNER)
415                                 img_name = WFD_ICON_DEVICE_HOME_THEATER;
416                         else
417                                 img_name = WFD_ICON_DEVICE_HEADSET;
418                         break;
419                 default:
420                         img_name = WFD_ICON_DEVICE_UNKNOWN;
421                         break;
422                 }
423
424                 icon = elm_image_add(obj);
425                 elm_image_file_set(icon, WFD_UG_EDJ_PATH, img_name);
426                 evas_object_size_hint_min_set(icon, ELM_SCALE_SIZE(WFD_UG_EDJ_ICON_SIZE),
427                                 ELM_SCALE_SIZE(WFD_UG_EDJ_ICON_SIZE));
428                 evas_object_color_set(icon, 2, 61, 132, 204);
429                 if(img_name)
430                         DBG(LOG_INFO, "img_name = %s", img_name);
431
432         } else if (!strcmp("elm.swallow.end", part)) {
433                 DBG(LOG_INFO, "elm.icon.2 - connection status [%d]\n", peer->conn_status);
434                 if (peer->conn_status == PEER_CONN_STATUS_CONNECTING) {
435                         icon = elm_progressbar_add(obj);
436                         elm_object_style_set(icon, "process_medium");
437                         elm_progressbar_pulse(icon, EINA_TRUE);
438                 } else if (peer->conn_status == PEER_CONN_STATUS_CONNECTED) {
439                         return NULL;
440                 }
441         }
442
443         __FUNC_EXIT__;
444
445         return icon;
446 }
447
448 /**
449  *      This function let the ug get the icon of peer item
450  *      @return   the icon of peer item
451  *      @param[in] data the pointer to the main data structure
452  *      @param[in] obj the pointer to the evas object
453  *      @param[in] part the pointer to the part of item
454  */
455 static Evas_Object *_gl_conn_peer_icon_get(void *data, Evas_Object *obj, const char *part)
456 {
457         __FUNC_ENTER__;
458         assertm_if(NULL == obj, "NULL!!");
459         assertm_if(NULL == part, "NULL!!");
460         device_type_s *peer = (device_type_s *) data;
461         Evas_Object *icon = NULL;
462
463         if (data == NULL) {
464                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
465                 return NULL;
466         }
467
468         DBG(LOG_INFO, "part[%s]\n", part);
469         if (!strcmp("elm.swallow.icon", part)) {
470                 DBG(LOG_INFO, "elm.swallow.icon - category [%d]\n", peer->category);
471                 char *img_name = NULL;
472                 /*
473                 * the icon of connected device is
474                 * different from available and busy device
475                 */
476                 switch (peer->category) {
477                 case WFD_DEVICE_TYPE_COMPUTER:
478                         img_name = WFD_ICON_DEVICE_COMPUTER;
479                         break;
480                 case WFD_DEVICE_TYPE_INPUT_DEVICE:
481                         img_name = WFD_ICON_DEVICE_INPUT_DEVICE;
482                         break;
483                 case WFD_DEVICE_TYPE_PRINTER:
484                         img_name = WFD_ICON_DEVICE_PRINTER;
485                         break;
486                 case WFD_DEVICE_TYPE_CAMERA:
487                         img_name = WFD_ICON_DEVICE_CAMERA;
488                         break;
489                 case WFD_DEVICE_TYPE_STORAGE:
490                         img_name = WFD_ICON_DEVICE_STORAGE;
491                         break;
492                 case WFD_DEVICE_TYPE_NW_INFRA:
493                         img_name = WFD_ICON_DEVICE_NETWORK_INFRA;
494                         break;
495                 case WFD_DEVICE_TYPE_DISPLAYS:
496                         img_name = WFD_ICON_DEVICE_DISPLAY;
497                         break;
498                 case WFD_DEVICE_TYPE_MM_DEVICES:
499                         if (peer->sub_category == WIFI_DIRECT_SECONDARY_DEVICE_TYPE_MULTIMEDIA_STB)
500                                 img_name = WFD_ICON_DEVICE_STB;
501                         else if (peer->sub_category == WIFI_DIRECT_SECONDARY_DEVICE_TYPE_MULTIMEDIA_MS_MA_ME)
502                                 img_name = WFD_ICON_DEVICE_DONGLE;
503                         else if (peer->sub_category == WIFI_DIRECT_SECONDARY_DEVICE_TYPE_MULTIMEDIA_PVP)
504                                 img_name = WFD_ICON_DEVICE_BD;
505                         else
506                                 img_name = WFD_ICON_DEVICE_MULTIMEDIA;
507                         break;
508                 case WFD_DEVICE_TYPE_GAME_DEVICES:
509                         img_name = WFD_ICON_DEVICE_GAMING;
510                         break;
511                 case WFD_DEVICE_TYPE_TELEPHONE:
512                         img_name = WFD_ICON_DEVICE_TELEPHONE;
513                         break;
514                 case WFD_DEVICE_TYPE_AUDIO:
515                         if (peer->sub_category == WIFI_DIRECT_SECONDARY_DEVICE_TYPE_AUDIO_TUNER)
516                                 img_name = WFD_ICON_DEVICE_HOME_THEATER;
517                         else
518                                 img_name = WFD_ICON_DEVICE_HEADSET;
519                         break;
520                 default:
521                         img_name = WFD_ICON_DEVICE_UNKNOWN;
522                         break;
523                 }
524
525                 icon = elm_image_add(obj);
526                 elm_image_file_set(icon, WFD_UG_EDJ_PATH, img_name);
527                 evas_object_size_hint_min_set(icon, ELM_SCALE_SIZE(WFD_UG_EDJ_ICON_SIZE),
528                                 ELM_SCALE_SIZE(WFD_UG_EDJ_ICON_SIZE));
529                 evas_object_color_set(icon, 2, 61, 132, 204);
530         }
531
532         __FUNC_EXIT__;
533         return icon;
534 }
535
536 /**
537  *      This function let the ug get the text of no device item
538  *      @return   the text of no device item
539  *      @param[in] data the pointer to the main data structure
540  *      @param[in] obj the pointer to the evas object
541  *      @param[in] part the pointer to the part of item
542  */
543 static char *_gl_noitem_text_get(void *data, Evas_Object *obj, const char *part)
544 {
545         __FUNC_ENTER__;
546
547         if (data == NULL) {
548                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
549                 return NULL;
550         }
551
552         DBG(LOG_INFO, "part = %s", part);
553         if (!strcmp("elm.text", part))
554                 return g_strdup(D_("IDS_BT_BODY_NO_DEVICES_FOUND_ABB"));
555
556         __FUNC_EXIT__;
557         return NULL;
558 }
559
560 /**
561  *      This function let the ug get the title label of connected device list
562  *      @return   the title label of connected device list
563  *      @param[in] data the pointer to the main data structure
564  *      @param[in] obj the pointer to the evas object
565  *      @param[in] part the pointer to the part of item
566  */
567 static char *_gl_conn_dev_title_label_get(void *data, Evas_Object *obj, const char *part)
568 {
569         __FUNC_ENTER__;
570
571         if (data == NULL) {
572                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
573                 return NULL;
574         }
575         DBG(LOG_INFO, "part = %s", part);
576         if (!strcmp("elm.text", part))
577                 return g_strdup(D_("IDS_ST_HEADER_CONNECTED_DEVICES"));
578
579         __FUNC_EXIT__;
580         return NULL;
581 }
582
583 char* ConvertRGBAtoHex(int r, int g, int b, int a)
584 {
585         int hexcolor = 0;
586         char *string = NULL;
587         string = g_try_malloc0(MAX_HEX_COLOR_LENGTH);
588         if (string == NULL)
589                 return string;
590
591         hexcolor = (r << 24) + (g << 16) + (b << 8) + a;
592         snprintf(string, MAX_HEX_COLOR_LENGTH, "%08x", hexcolor);
593         return string;
594 }
595
596 /**
597  *      This function let the ug get the label of connected device
598  *      @return   the label of connected device
599  *      @param[in] data the pointer to the main data structure
600  *      @param[in] obj the pointer to the evas object
601  *      @param[in] part the pointer to the part of item
602  */
603 static char *_gl_peer_conn_dev_label_get(void *data, Evas_Object *obj, const char *part)
604 {
605         __FUNC_ENTER__;
606
607         assertm_if(NULL == obj, "NULL!!");
608         assertm_if(NULL == part, "NULL!!");
609         device_type_s *peer = (device_type_s *) data;
610         DBG(LOG_INFO, "%s", part);
611         char *det = NULL;
612         char *buf = NULL;
613         char *ssid;
614         char *convertedColor = NULL;
615
616         if (data == NULL) {
617                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
618                 return NULL;
619         }
620
621         if (!strcmp("elm.text", part)) {
622                 if (strlen(peer->ssid) != 0) {
623                         ssid = elm_entry_utf8_to_markup(peer->ssid);
624                         if (NULL == ssid) {
625                                 DBG(LOG_ERROR, "elm_entry_utf8_to_markup failed.\n");
626                                 __FUNC_EXIT__;
627                                 return NULL;
628                         }
629                         __FUNC_EXIT__;
630                         return ssid;
631                 }
632         } else if (!strcmp("elm.text.sub", part)) {
633                 det = elm_entry_utf8_to_markup(D_("IDS_COM_BODY_CONNECTED_M_STATUS"));
634                 convertedColor = ConvertRGBAtoHex(2, 61, 132, 255);
635                 buf = g_strdup_printf("<color=#%s>%s</color>",
636                         convertedColor, det);
637                 WFD_IF_FREE_MEM(det);
638                 g_free(convertedColor);
639                 __FUNC_EXIT__;
640                 return buf;
641         }
642         __FUNC_EXIT__;
643         return NULL;
644 }
645
646 /**
647  *      This function let the ug get the title label of connected failed device list
648  *      @return   the label of connected device
649  *      @param[in] data the pointer to the main data structure
650  *      @param[in] obj the pointer to the evas object
651  *      @param[in] part the pointer to the part of item
652  */
653 static char *_gl_conn_failed_dev_title_label_get(void *data, Evas_Object *obj,
654                 const char *part)
655 {
656         __FUNC_ENTER__;
657
658         if (data == NULL) {
659                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
660                 return NULL;
661         }
662
663         if (!strcmp("elm.text", part))
664                 return g_strdup(D_("IDS_WIFI_SBODY_NOT_CONNECTED_M_STATUS_ABB"));
665
666         __FUNC_EXIT__;
667         return NULL;
668 }
669
670 /**
671  *      This function let the ug get the label of connected failed device
672  *      @return   the label of connected device
673  *      @param[in] data the pointer to the main data structure
674  *      @param[in] obj the pointer to the evas object
675  *      @param[in] part the pointer to the part of item
676  */
677 static char *_gl_peer_conn_failed_dev_label_get(void *data, Evas_Object *obj, const char *part)
678 {
679         __FUNC_ENTER__;
680
681         assertm_if(NULL == obj, "NULL!!");
682         assertm_if(NULL == part, "NULL!!");
683         device_type_s *peer = (device_type_s *) data;
684         char buf[WFD_GLOBALIZATION_STR_LENGTH] = { 0, };
685         char *ssid;
686         DBG(LOG_INFO, "%s", part);
687
688         if (data == NULL) {
689                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
690                 return NULL;
691         }
692
693         if (!strcmp("elm.text", part)) {
694                 if (strlen(peer->ssid) != 0) {
695                         ssid = elm_entry_utf8_to_markup(peer->ssid);
696                         if (NULL == ssid) {
697                                 DBG(LOG_ERROR, "elm_entry_utf8_to_markup failed.\n");
698                                 __FUNC_EXIT__;
699                                 return NULL;
700                         }
701                         __FUNC_EXIT__;
702                         return ssid;
703                 }
704         } else if (!strcmp("elm.text.sub", part)) {
705                 g_strlcpy(buf, D_("IDS_CHATON_HEADER_CONNECTION_FAILED_ABB2"),
706                         WFD_GLOBALIZATION_STR_LENGTH);
707                 __FUNC_EXIT__;
708                 return g_strdup(buf);
709         }
710         return NULL;
711 }
712
713 /**
714  *      This function let the ug get the title label of multi connect list
715  *      @return   the label of connected device
716  *      @param[in] data the pointer to the main data structure
717  *      @param[in] obj the pointer to the evas object
718  *      @param[in] part the pointer to the part of item
719  */
720 static char *_gl_multi_connect_dev_title_label_get(void *data, Evas_Object *obj, const char *part)
721 {
722         __FUNC_ENTER__;
723         struct ug_data *ugd = wfd_get_ug_data();
724
725         if (data == NULL) {
726                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
727                 return NULL;
728         }
729         DBG(LOG_INFO, "%s", part);
730
731         if (!strcmp("elm.text", part) && ugd) {
732                 if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_IN_PROGRESS)
733                         return g_strdup(D_("IDS_WIFI_HEADER_AVAILABLE_DEVICES_ABB"));
734                 else if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_COMPLETED)
735                         return g_strdup(D_("IDS_WIFI_SBODY_NOT_CONNECTED_M_STATUS_ABB"));
736         }
737
738         __FUNC_EXIT__;
739         return NULL;
740 }
741
742 /**
743  *      This function let the ug get the title label of select all in multi connect
744  *      @return   the label of select all string
745  *      @param[in] data the pointer to the main data structure
746  *      @param[in] obj the pointer to the evas object
747  *      @param[in] part the pointer to the part of item
748  */
749 static char *_gl_multi_connect_select_all_title_label_get(void *data, Evas_Object *obj, const char *part)
750 {
751         __FUNC_ENTER__;
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                 __FUNC_EXIT__;
761                 return g_strdup(D_("IDS_WIFI_BODY_SELECT_ALL"));
762         }
763         __FUNC_EXIT__;
764         return NULL;
765 }
766
767 /**
768  *      This function let the ug get the icon of select all genlist
769  *      @return   the icon of select all genlist
770  *      @param[in] data the pointer to the main data structure
771  *      @param[in] obj the pointer to the evas object
772  *      @param[in] part the pointer to the part of item
773  */
774 static Evas_Object *_wfd_gl_select_all_icon_get(void *data, Evas_Object *obj, const char *part)
775 {
776         __FUNC_ENTER__;
777
778         struct ug_data *ugd = (struct ug_data *) data;
779         Evas_Object *check = NULL;
780         Evas_Object *icon_layout = NULL;
781
782         DBG(LOG_INFO, "Part %s", part);
783
784         if (!strcmp("elm.swallow.end", part)) {
785                 icon_layout = elm_layout_add(obj);
786                 elm_layout_theme_set(icon_layout, "layout", "list/C/type.2", "default");
787                 DBG(LOG_INFO, "Part %s", part);
788                 check = elm_check_add(icon_layout);
789                 ugd->select_all_icon = check;
790                 if (ugd->is_select_all_checked == EINA_TRUE)
791                         elm_check_state_set(ugd->select_all_icon, TRUE);
792
793                 elm_object_style_set(check, "default/genlist");
794                 evas_object_propagate_events_set(check, EINA_FALSE);
795                 evas_object_smart_callback_add(check, "changed",
796                         wfd_genlist_select_all_check_changed_cb, (void *)data);
797                 elm_layout_content_set(icon_layout, "elm.swallow.content", check);
798         }
799         __FUNC_EXIT__;
800         return icon_layout;
801 }
802
803 /**
804  *      This function let the ug get the title label of busy device list
805  *      @return   the label of connected device
806  *      @param[in] data the pointer to the main data structure
807  *      @param[in] obj the pointer to the evas object
808  *      @param[in] part the pointer to the part of item
809  */
810 static char *_gl_busy_dev_title_label_get(void *data, Evas_Object *obj,
811                 const char *part)
812 {
813         __FUNC_ENTER__;
814
815         if (data == NULL) {
816                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
817                 return NULL;
818         }
819         DBG(LOG_INFO, "%s", part);
820
821         if (!strcmp("elm.text", part))
822                 return g_strdup(D_("IDS_ST_HEADER_BUSY_DEVICES"));
823
824         __FUNC_EXIT__;
825         return NULL;
826 }
827
828 /**
829  *      This function let the ug get the label of busy device
830  *      @return   the label of connected device
831  *      @param[in] data the pointer to the main data structure
832  *      @param[in] obj the pointer to the evas object
833  *      @param[in] part the pointer to the part of item
834  */
835 static char *_gl_peer_busy_dev_label_get(void *data, Evas_Object *obj, const char *part)
836 {
837         __FUNC_ENTER__;
838         assertm_if(NULL == obj, "NULL!!");
839         assertm_if(NULL == part, "NULL!!");
840         device_type_s *peer = (device_type_s *) data;
841         char buf[WFD_GLOBALIZATION_STR_LENGTH] = { 0, };
842         char *ssid;
843         DBG(LOG_INFO, "%s", part);
844
845         if (data == NULL) {
846                 DBG(LOG_ERROR, "Incorrect parameter(NULL)\n");
847                 return NULL;
848         }
849
850         DBG(LOG_INFO, "peer->ssid = %s", peer->ssid);
851
852         if (!strcmp("elm.text", part)) {
853                 if (strlen(peer->ssid) != 0) {
854                         ssid = elm_entry_utf8_to_markup(peer->ssid);
855                         if (NULL == ssid) {
856                                 DBG(LOG_ERROR, "elm_entry_utf8_to_markup failed.\n");
857                                 __FUNC_EXIT__;
858                                 return NULL;
859                         }
860                         __FUNC_EXIT__;
861                         return ssid;
862                 }
863         } else if (!strcmp("elm.text.sub", part)) {
864                 g_strlcpy(buf, D_("IDS_ST_BODY_CONNECTED_WITH_ANOTHER_DEVICE_ABB"),
865                         WFD_GLOBALIZATION_STR_LENGTH);
866                 __FUNC_EXIT__;
867                 return g_strdup(buf);
868         }
869
870         return NULL;
871 }
872
873 /**
874  *      This function let the ug delete the peer item
875  *      @return   void
876  *      @param[in] data the pointer to the main data structure
877  *      @param[in] obj the pointer to the evas object
878  */
879 static void _gl_peer_del(void *data, Evas_Object *obj)
880 {
881         __FUNC_ENTER__;
882
883         assertm_if(NULL == obj, "NULL!!");
884         assertm_if(NULL == data, "NULL!!");
885
886         __FUNC_EXIT__;
887         return;
888 }
889
890 /**
891  *      This function let the ug initialize the items of genlist
892  *      @return   void
893  */
894 void initialize_gen_item_class()
895 {
896         elm_theme_extension_add(NULL, WFD_UG_EDJ_PATH);
897
898         device_name_itc.item_style = WFD_GENLIST_MULTILINE_TEXT_STYLE;
899         device_name_itc.func.text_get = _gl_device_name_label_get;
900         device_name_itc.func.content_get = NULL;
901         device_name_itc.func.state_get = NULL;
902
903 #ifdef WFD_ON_OFF_GENLIST
904         wfd_onoff_itc.item_style = WFD_GENLIST_2LINE_BOTTOM_TEXT_ICON_STYLE;
905         wfd_onoff_itc.func.text_get = _gl_wfd_onoff_text_get;
906         wfd_onoff_itc.func.content_get = _gl_wfd_onoff_content_get;
907         wfd_onoff_itc.func.state_get = NULL;
908         wfd_onoff_itc.func.del = NULL;
909 #endif
910
911         title_itc.item_style = WFD_GENLIST_GROUP_INDEX_STYLE;
912         title_itc.func.text_get = _gl_title_label_get;
913         title_itc.func.content_get = _gl_title_content_get;
914         title_itc.func.state_get = NULL;
915         title_itc.func.del = NULL;
916
917         multi_view_title_itc.item_style = WFD_GENLIST_GROUP_INDEX_STYLE;
918         multi_view_title_itc.func.text_get = _gl_multi_title_label_get;
919         multi_view_title_itc.func.content_get = _gl_multi_title_content_get;
920         multi_view_title_itc.func.state_get = NULL;
921         multi_view_title_itc.func.del = NULL;
922
923         title_no_device_itc.item_style = WFD_GENLIST_GROUP_INDEX_STYLE;
924         title_no_device_itc.func.text_get = _gl_title_no_device_label_get;
925         title_no_device_itc.func.content_get = NULL;
926         title_no_device_itc.func.state_get = NULL;
927         title_no_device_itc.func.del = NULL;
928
929         title_available_itc.item_style = WFD_GENLIST_GROUP_INDEX_STYLE;
930         title_available_itc.func.text_get = _gl_available_title_label_get;
931         title_available_itc.func.content_get = _gl_title_content_get;
932         title_available_itc.func.state_get = NULL;
933         title_available_itc.func.del = NULL;
934
935         peer_itc.item_style = WFD_GENLIST_2LINE_TOP_TEXT_ICON_STYLE;
936         peer_itc.func.text_get = _gl_peer_label_get;
937         peer_itc.func.content_get = _gl_peer_icon_get;
938         peer_itc.func.state_get = NULL;
939         peer_itc.func.del = _gl_peer_del;
940
941         noitem_itc.item_style = WFD_GENLIST_1LINE_TEXT_STYLE;
942         noitem_itc.func.text_get = _gl_noitem_text_get;
943         noitem_itc.func.content_get = NULL;
944         noitem_itc.func.state_get = NULL;
945         noitem_itc.func.del = NULL;
946
947         title_conn_itc.item_style = WFD_GENLIST_GROUP_INDEX_STYLE;
948         title_conn_itc.func.text_get = _gl_conn_dev_title_label_get;
949         title_conn_itc.func.content_get = NULL;
950         title_conn_itc.func.state_get = NULL;
951         title_conn_itc.func.del = NULL;
952
953         peer_conn_itc.item_style = WFD_GENLIST_2LINE_TOP_TEXT_ICON_STYLE;
954         peer_conn_itc.func.text_get = _gl_peer_conn_dev_label_get;
955         peer_conn_itc.func.content_get = _gl_conn_peer_icon_get;
956         peer_conn_itc.func.state_get = NULL;
957         peer_conn_itc.func.del = _gl_peer_del;
958
959         title_conn_failed_itc.item_style = WFD_GENLIST_1LINE_TEXT_STYLE;
960         title_conn_failed_itc.func.text_get = _gl_conn_failed_dev_title_label_get;
961         title_conn_failed_itc.func.content_get = NULL;
962         title_conn_failed_itc.func.state_get = NULL;
963         title_conn_failed_itc.func.del = NULL;
964
965         peer_conn_failed_itc.item_style = WFD_GENLIST_2LINE_TOP_TEXT_ICON_STYLE;
966         peer_conn_failed_itc.func.text_get = _gl_peer_conn_failed_dev_label_get;
967         peer_conn_failed_itc.func.content_get = _gl_peer_icon_get;
968         peer_conn_failed_itc.func.state_get = NULL;
969         peer_conn_failed_itc.func.del = _gl_peer_del;
970
971         title_busy_itc.item_style = WFD_GENLIST_GROUP_INDEX_STYLE;
972         title_busy_itc.func.text_get = _gl_busy_dev_title_label_get;
973         title_busy_itc.func.content_get = NULL;
974         title_busy_itc.func.state_get = NULL;
975         title_busy_itc.func.del = NULL;
976
977         peer_busy_itc.item_style = WFD_GENLIST_2LINE_TOP_TEXT_ICON_STYLE;
978         peer_busy_itc.func.text_get = _gl_peer_busy_dev_label_get;
979         peer_busy_itc.func.content_get = _gl_peer_icon_get;
980         peer_busy_itc.func.state_get = NULL;
981         peer_busy_itc.func.del = _gl_peer_del;
982
983         title_multi_connect_itc.item_style = WFD_GENLIST_GROUP_INDEX_STYLE;
984         title_multi_connect_itc.func.text_get = _gl_multi_connect_dev_title_label_get;
985         title_multi_connect_itc.func.content_get = NULL;
986         title_multi_connect_itc.func.state_get = NULL;
987         title_multi_connect_itc.func.del = NULL;
988
989         select_all_multi_connect_itc.item_style = WFD_GENLIST_1LINE_TEXT_ICON_STYLE;
990         select_all_multi_connect_itc.func.text_get =
991                 _gl_multi_connect_select_all_title_label_get;
992         select_all_multi_connect_itc.func.content_get = _wfd_gl_select_all_icon_get;
993         select_all_multi_connect_itc.func.state_get = NULL;
994         select_all_multi_connect_itc.func.del = NULL;
995 }