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