Merge branch 'master' into tizen_2.1
[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://floralicense.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
22 #include <assert.h>
23 #include <glib.h>
24
25 #include <Elementary.h>
26 #include <vconf.h>
27 #include <ui-gadget-module.h>
28 #include <wifi-direct.h>
29
30 #include "wfd_ug.h"
31 #include "wfd_ug_view.h"
32 #include "wfd_client.h"
33
34 Elm_Gen_Item_Class head_itc;
35 Elm_Gen_Item_Class name_itc;
36 Elm_Gen_Item_Class title_itc;
37 Elm_Gen_Item_Class peer_itc;
38 Elm_Gen_Item_Class noitem_itc;
39 Elm_Gen_Item_Class button_itc;
40
41 Elm_Gen_Item_Class title_conn_itc;
42 Elm_Gen_Item_Class peer_conn_itc;
43
44 Elm_Gen_Item_Class title_busy_itc;
45 Elm_Gen_Item_Class peer_busy_itc;
46
47 Elm_Gen_Item_Class title_multi_connect_itc;
48 Elm_Gen_Item_Class peer_multi_connect_itc;
49
50 Elm_Gen_Item_Class title_conn_failed_itc;
51 Elm_Gen_Item_Class peer_conn_failed_itc;
52
53 /**
54  *      This function let the ug get the label of header
55  *      @return   the label of header
56  *      @param[in] data the pointer to the main data structure
57  *      @param[in] obj the pointer to the evas object
58  *      @param[in] part the pointer to the part of item
59  */
60 static char *_gl_header_label_get(void *data, Evas_Object *obj, const char *part)
61 {
62         __WDUG_LOG_FUNC_ENTER__;
63         struct ug_data *ugd = (struct ug_data *) data;
64         WDUG_LOGI("%s", part);
65
66         if (data == NULL) {
67                 WDUG_LOGE("Incorrect parameter(NULL)\n");
68                 return NULL;
69         }
70
71         if (!strcmp(part, "elm.text.1")) {
72                 WDUG_LOGI("Current text mode [%d]\n", ugd->head_text_mode);
73                 switch (ugd->head_text_mode) {
74                 case HEAD_TEXT_TYPE_DIRECT:
75                 case HEAD_TEXT_TYPE_ACTIVATED:
76                 case HEAD_TEXT_TYPE_SCANING:
77                         return strdup(dgettext("sys_string", "IDS_COM_OPT1_WI_FI_DIRECT"));
78                         break;
79                 case HEAD_TEXT_TYPE_DEACTIVATING:
80                         return strdup(_("IDS_WFD_BODY_DEACTIVATING"));
81                         break;
82                 case HEAD_TEXT_TYPE_ACTIVATING:
83                         return strdup(_("IDS_WFD_BODY_ACTIVATING"));
84                         break;
85                 default:
86                         break;
87                 }
88         } else if (!strcmp(part, "elm.text.1")) {
89                 return strdup(dgettext("sys_string", "IDS_COM_OPT1_WI_FI_DIRECT"));
90         } else if (!strcmp(part, "elm.text.2")) {
91                 return strdup(ugd->dev_name);
92         }
93
94         __WDUG_LOG_FUNC_EXIT__;
95         return NULL;
96 }
97
98 /**
99  *  This function let the ug call it when click header
100  *  @return   void
101  *  @param[in] data the pointer to the main data structure
102  *  @param[in] obj the pointer to the evas object
103  *  @param[in] event_info the pointer to the event information
104  */
105 static void _gl_header_sel(void *data, Evas_Object *obj, void *event_info)
106 {
107         __WDUG_LOG_FUNC_ENTER__;
108         struct ug_data *ugd = (struct ug_data *) data;
109
110         Elm_Object_Item *item = (Elm_Object_Item *)event_info;
111         if (item != NULL)
112                 elm_genlist_item_selected_set(item, EINA_FALSE);
113
114         if (ugd == NULL)
115                 WDUG_LOGE("Incorrect parameter(NULL)\n");
116         else {
117                 if(!ugd->wfd_onoff) {
118                         WDUG_LOGD("Wi-Fi direct switch on\n");
119                         wfd_client_switch_on(ugd);
120                 } else {
121                         WDUG_LOGD("Wi-Fi direct switch off\n");
122                         wfd_client_switch_off(ugd);
123                 }
124         }
125         __WDUG_LOG_FUNC_EXIT__;
126 }
127
128 /**
129  *      This function let the ug get the icon of header
130  *      @return   the icon of header
131  *      @param[in] data the pointer to the main data structure
132  *      @param[in] obj the pointer to the evas object
133  *      @param[in] part the pointer to the part of item
134  */
135 static Evas_Object *_gl_header_icon_get(void *data, Evas_Object *obj, const char *part)
136 {
137         __WDUG_LOG_FUNC_ENTER__;
138         struct ug_data *ugd = (struct ug_data *) data;
139         Evas_Object *onoff = NULL;
140
141         if (data == NULL) {
142                 WDUG_LOGE("Incorrect parameter(NULL)\n");
143                 return NULL;
144         }
145
146         if (ugd->head_text_mode == HEAD_TEXT_TYPE_ACTIVATING ||
147                 ugd->head_text_mode == HEAD_TEXT_TYPE_DEACTIVATING) {
148                 return NULL;
149         }
150
151         if (!strcmp(part, "elm.icon")) {
152                 onoff = elm_check_add(obj);
153                 elm_object_style_set(onoff, "on&off");
154                 elm_check_state_set(onoff, ugd->wfd_onoff);
155                 evas_object_smart_callback_add(onoff, "changed", _gl_header_sel , ugd);
156                 evas_object_show(onoff);
157         }
158
159         __WDUG_LOG_FUNC_EXIT__;
160         return onoff;
161 }
162
163 /**
164  *      This function let the ug get the label of about item
165  *      @return   the label of about item
166  *      @param[in] data the pointer to the main data structure
167  *      @param[in] obj the pointer to the evas object
168  *      @param[in] part the pointer to the part of item
169  */
170 static char *_gl_name_label_get(void *data, Evas_Object *obj, const char *part)
171 {
172         __WDUG_LOG_FUNC_ENTER__;
173         struct ug_data *ugd = (struct ug_data *) data;
174
175         if (data == NULL) {
176                 WDUG_LOGE("Incorrect parameter(NULL)\n");
177                 return NULL;
178         }
179
180         WDUG_LOGI("%s", part);
181
182         if (!strcmp(part, "elm.text")) {
183                 return strdup(IDS_WFD_TITLE_ABOUT_WIFI_DIRECT);
184         } else if (!strcmp(part, "elm.text.2")) {
185                 return strdup(ugd->dev_name);
186         }
187
188         __WDUG_LOG_FUNC_EXIT__;
189         return NULL;
190 }
191
192 /**
193  *      This function let the ug get the label of titile
194  *      @return   the label of titile
195  *      @param[in] data the pointer to the main data structure
196  *      @param[in] obj the pointer to the evas object
197  *      @param[in] part the pointer to the part of item
198  */
199 static char *_gl_title_label_get(void *data, Evas_Object *obj, const char *part)
200 {
201         __WDUG_LOG_FUNC_ENTER__;
202         struct ug_data *ugd = (struct ug_data *) data;
203
204         if (data == NULL) {
205                 WDUG_LOGE("Incorrect parameter(NULL)\n");
206                 return NULL;
207         }
208
209         if (!strcmp(part, "elm.text")) {
210                 if (ugd->multiconn_view_genlist != NULL) {
211                         // It's called at Multi connect view...
212                         if (ugd->gl_available_dev_cnt_at_multiconn_view > 0) {
213                                 return strdup(_("IDS_WFD_BODY_AVAILABLE_DEVICES"));
214                         } else {
215                                 return strdup(_("IDS_WFD_BODY_WIFI_DIRECT_DEVICES"));
216                         }
217                 } else {
218                         // It's called at Main View
219                         if (ugd->gl_available_peer_cnt > 0) {
220                                 return strdup(_("IDS_WFD_BODY_AVAILABLE_DEVICES"));
221                         } else {
222                                 return strdup(_("IDS_WFD_BODY_WIFI_DIRECT_DEVICES"));
223                         }
224                 }
225         }
226
227         __WDUG_LOG_FUNC_EXIT__;
228         return NULL;
229 }
230
231 /**
232  *      This function let the ug get the content of titile
233  *      @return   the content of titile
234  *      @param[in] data the pointer to the main data structure
235  *      @param[in] obj the pointer to the evas object
236  *      @param[in] part the pointer to the part of item
237  */
238 static Evas_Object *_gl_title_content_get(void *data, Evas_Object *obj, const char *part)
239 {
240         Evas_Object *progressbar = NULL;
241         struct ug_data *ugd = (struct ug_data *) data;
242
243         if (data == NULL) {
244             WDUG_LOGE("Incorrect parameter(NULL)\n");
245             return NULL;
246         }
247
248         if (!strcmp(part, "elm.icon")) {
249                 if (HEAD_TEXT_TYPE_SCANING == ugd->head_text_mode) {
250                         progressbar = elm_progressbar_add(obj);
251                         elm_object_style_set(progressbar, "list_process_small");
252                         elm_progressbar_horizontal_set(progressbar, EINA_TRUE);
253                         elm_progressbar_pulse(progressbar, EINA_TRUE);
254                         evas_object_show(progressbar);
255                 } else {
256                         return NULL;
257                 }
258         }
259
260         return progressbar;
261 }
262
263 /**
264  *      This function let the ug get the label of peer item
265  *      @return   the label of peer item
266  *      @param[in] data the pointer to the main data structure
267  *      @param[in] obj the pointer to the evas object
268  *      @param[in] part the pointer to the part of item
269  */
270 static char *_gl_peer_label_get(void *data, Evas_Object *obj, const char *part)
271 {
272         __WDUG_LOG_FUNC_ENTER__;
273         assertm_if(NULL == obj, "NULL!!");
274         assertm_if(NULL == part, "NULL!!");
275         device_type_s *peer = (device_type_s *) data;
276         char buf[WFD_GLOBALIZATION_STR_LENGTH] = { 0, };
277         WDUG_LOGI("%s", part);
278
279         if (data == NULL) {
280                 WDUG_LOGE("Incorrect parameter(NULL)\n");
281                 return NULL;
282         }
283
284         if (!strcmp(part, "elm.text.1")) {
285                 __WDUG_LOG_FUNC_EXIT__;
286                 return strdup(peer->ssid);
287         } else if (!strcmp(part, "elm.text.2")) {
288                 switch (peer->conn_status) {
289                 case PEER_CONN_STATUS_DISCONNECTED:
290                         g_strlcpy(buf, _("IDS_WFD_TAP_TO_CONNECT"), WFD_GLOBALIZATION_STR_LENGTH);
291                         break;
292                 case PEER_CONN_STATUS_CONNECTING:
293                         g_strlcpy(buf, _("IDS_WFD_CONNECTING"), WFD_GLOBALIZATION_STR_LENGTH);
294                         break;
295                 case PEER_CONN_STATUS_CONNECTED:
296                         if (peer->is_group_owner == FALSE) {
297                                 g_strlcpy(buf, _("IDS_WFD_CONNECTED"), WFD_GLOBALIZATION_STR_LENGTH);
298                         } else {
299                                 g_strlcpy(buf, _("IDS_WFD_TAP_TO_CONNECT"), WFD_GLOBALIZATION_STR_LENGTH);
300                         }
301                         break;
302                 case PEER_CONN_STATUS_FAILED_TO_CONNECT:
303                         g_strlcpy(buf, _("IDS_WFD_FAILED_TO_CONNECT"), WFD_GLOBALIZATION_STR_LENGTH);
304                         break;
305                 case PEER_CONN_STATUS_WAIT_FOR_CONNECT:
306                         g_strlcpy(buf, _("IDS_WFD_WAITING_FOR_CONNECT"), WFD_GLOBALIZATION_STR_LENGTH);
307                         break;
308                 default:
309                         g_strlcpy(buf, _("IDS_WFD_TAP_TO_CONNECT"), WFD_GLOBALIZATION_STR_LENGTH);
310                         break;
311                 }
312         } else {
313                 __WDUG_LOG_FUNC_EXIT__;
314                 return NULL;
315         }
316
317         __WDUG_LOG_FUNC_EXIT__;
318         return strdup(buf);
319 }
320
321 /**
322  *      This function let the ug get the icon of peer item
323  *      @return   the icon of peer item
324  *      @param[in] data the pointer to the main data structure
325  *      @param[in] obj the pointer to the evas object
326  *      @param[in] part the pointer to the part of item
327  */
328 static Evas_Object *_gl_peer_icon_get(void *data, Evas_Object *obj, const char *part)
329 {
330         __WDUG_LOG_FUNC_ENTER__;
331         assertm_if(NULL == obj, "NULL!!");
332         assertm_if(NULL == part, "NULL!!");
333         device_type_s *peer = (device_type_s *) data;
334         Evas_Object *icon = NULL;
335         struct ug_data *ugd = wfd_get_ug_data();
336
337         if (data == NULL) {
338                 WDUG_LOGE("Incorrect parameter(NULL)\n");
339                 return NULL;
340         }
341
342         if (!strcmp(part, "elm.icon.2")) {
343                 WDUG_LOGI("elm.icon.2 - connection status [%d]\n", peer->conn_status);
344                 if (peer->conn_status == PEER_CONN_STATUS_CONNECTING) {
345                         icon = elm_progressbar_add(obj);
346                         elm_object_style_set(icon, "list_process");
347                         elm_progressbar_pulse(icon, EINA_TRUE);
348                 } else if (peer->conn_status == PEER_CONN_STATUS_CONNECTED) {
349                         return NULL;
350                 }
351
352                 evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
353                 elm_icon_resizable_set(icon, 1, 1);
354                 evas_object_show(icon);
355         } else if (!strcmp(part, "elm.icon.1")) {
356                 WDUG_LOGI("elm.icon.1 - category [%d]\n", peer->category);
357                 char *img_path = NULL;
358                 int status = -1;
359
360                 status = wfd_get_device_status(ugd, peer);
361
362                 /*
363                 * the icon of connected device is
364                 * different from available and busy device
365                 */
366                 switch (peer->category) {
367                 case WFD_DEVICE_TYPE_COMPUTER:
368                         if (1 == status) {
369                                 img_path = WFD_ICON_DEVICE_COMPUTER_CONNECT;
370                         } else {
371                                 img_path = WFD_ICON_DEVICE_COMPUTER;
372                         }
373                         break;
374                 case WFD_DEVICE_TYPE_INPUT_DEVICE:
375                         if (1 == status) {
376                                 img_path = WFD_ICON_DEVICE_INPUT_DEVICE_CONNECT;
377                         } else {
378                                 img_path = WFD_ICON_DEVICE_INPUT_DEVICE;
379                         }
380                         break;
381                 case WFD_DEVICE_TYPE_PRINTER:
382                         if (1 == status) {
383                                 img_path = WFD_ICON_DEVICE_PRINTER_CONNECT;
384                         } else {
385                                 img_path = WFD_ICON_DEVICE_PRINTER;
386                         }
387                         break;
388                 case WFD_DEVICE_TYPE_CAMERA:
389                         if (1 == status) {
390                                 img_path = WFD_ICON_DEVICE_CAMERA_CONNECT;
391                         } else {
392                                 img_path = WFD_ICON_DEVICE_CAMERA;
393                         }
394                         break;
395                 case WFD_DEVICE_TYPE_STORAGE:
396                         if (1 == status) {
397                                 img_path = WFD_ICON_DEVICE_STORAGE_CONNECT;
398                         } else {
399                                 img_path = WFD_ICON_DEVICE_STORAGE;
400                         }
401                         break;
402                 case WFD_DEVICE_TYPE_NW_INFRA:
403                         if (1 == status) {
404                                 img_path = WFD_ICON_DEVICE_NETWORK_INFRA_CONNECT;
405                         } else {
406                                 img_path = WFD_ICON_DEVICE_NETWORK_INFRA;
407                         }
408                         break;
409                 case WFD_DEVICE_TYPE_DISPLAYS:
410                         if (1 == status) {
411                                 img_path = WFD_ICON_DEVICE_DISPLAY_CONNECT;
412                         } else {
413                                 img_path = WFD_ICON_DEVICE_DISPLAY;
414                         }
415                         break;
416                 case WFD_DEVICE_TYPE_MM_DEVICES:
417                         if (1 == status) {
418                                 img_path = WFD_ICON_DEVICE_MULTIMEDIA_DEVICE_CONNECT;
419                         } else {
420                                 img_path = WFD_ICON_DEVICE_MULTIMEDIA_DEVICE;
421                         }
422                         break;
423                 case WFD_DEVICE_TYPE_GAME_DEVICES:
424                         if (1 == status) {
425                                 img_path = WFD_ICON_DEVICE_GAMING_DEVICE_CONNECT;
426                         } else {
427                                 img_path = WFD_ICON_DEVICE_GAMING_DEVICE;
428                         }
429                         break;
430                 case WFD_DEVICE_TYPE_TELEPHONE:
431                         if (1 == status) {
432                                 img_path = WFD_ICON_DEVICE_TELEPHONE_CONNECT;
433                         } else {
434                                 img_path = WFD_ICON_DEVICE_TELEPHONE;
435                         }
436                         break;
437                 case WFD_DEVICE_TYPE_AUDIO:
438                         if (1 == status) {
439                                 img_path = WFD_ICON_DEVICE_AUDIO_DEVICE_CONNECT;
440                         } else {
441                                 img_path = WFD_ICON_DEVICE_AUDIO_DEVICE;
442                         }
443                         break;
444                 default:
445                         if (1 == status) {
446                                 img_path = WFD_ICON_DEVICE_COMPUTER_CONNECT;
447                         } else {
448                                 img_path = WFD_ICON_DEVICE_COMPUTER;
449                         }
450                         break;
451                 }
452
453                 icon = elm_icon_add(obj);
454                 elm_icon_file_set(icon, img_path, NULL);
455                 evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
456                 elm_icon_resizable_set(icon, 1, 1);
457                 evas_object_show(icon);
458         }
459
460         __WDUG_LOG_FUNC_EXIT__;
461         return icon;
462 }
463
464 /**
465  *      This function let the ug get the text of no device item
466  *      @return   the text of no device item
467  *      @param[in] data the pointer to the main data structure
468  *      @param[in] obj the pointer to the evas object
469  *      @param[in] part the pointer to the part of item
470  */
471 static char *_gl_noitem_text_get(void *data, Evas_Object *obj, const char *part)
472 {
473         __WDUG_LOG_FUNC_ENTER__;
474
475         if (data == NULL) {
476                 WDUG_LOGE("Incorrect parameter(NULL)\n");
477                 return NULL;
478         }
479
480         __WDUG_LOG_FUNC_EXIT__;
481         return strdup(_("IDS_WFD_NOCONTENT"));
482 }
483
484 /**
485  *      This function let the ug get the multi connect button
486  *      @return   the multi connect button
487  *      @param[in] data the pointer to the main data structure
488  *      @param[in] obj the pointer to the evas object
489  *      @param[in] part the pointer to the part of item
490  */
491 static Evas_Object *_gl_button_get(void *data, Evas_Object *obj, const char *part)
492 {
493         __WDUG_LOG_FUNC_ENTER__;
494         struct ug_data *ugd = (struct ug_data *) data;
495
496         WDUG_LOGI("%s", part);
497         ugd->multi_btn = elm_button_add(obj);
498         wfd_refresh_wifi_direct_state(ugd);
499
500         if (ugd->wfd_status == WIFI_DIRECT_STATE_CONNECTING) {
501                 elm_object_text_set(ugd->multi_btn, _("IDS_WFD_BUTTON_CANCEL"));
502                 WDUG_LOGI("button: Cancel connect\n");
503         } else {
504                 if (ugd->gl_connected_peer_cnt > 1) {
505                         elm_object_text_set(ugd->multi_btn, _("IDS_WFD_BUTTON_DISCONNECT_ALL"));
506                         WDUG_LOGI("button: Disconnect All\n");
507                 } else if (ugd->gl_connected_peer_cnt == 1) {
508                         elm_object_text_set(ugd->multi_btn, _("IDS_WFD_BUTTON_DISCONNECT"));
509                         WDUG_LOGI("button: Disconnect\n");
510                 } else {
511                         elm_object_text_set(ugd->multi_btn, _("IDS_WFD_BUTTON_MULTI"));
512                         WDUG_LOGI("button: Multi connect\n");
513                 }
514         }
515
516         evas_object_smart_callback_add(ugd->multi_btn, "clicked", _wifid_create_multibutton_cb, ugd);
517         evas_object_show(ugd->multi_btn);
518
519         __WDUG_LOG_FUNC_EXIT__;
520         return ugd->multi_btn;
521 }
522
523 /**
524  *      This function let the ug get the title label of connected device list
525  *      @return   the title label of connected device list
526  *      @param[in] data the pointer to the main data structure
527  *      @param[in] obj the pointer to the evas object
528  *      @param[in] part the pointer to the part of item
529  */
530 static char *_gl_conn_dev_title_label_get(void *data, Evas_Object *obj, const char *part)
531 {
532         __WDUG_LOG_FUNC_ENTER__;
533
534         if (data == NULL) {
535                 WDUG_LOGE("Incorrect parameter(NULL)\n");
536                 return NULL;
537         }
538
539         if (!strcmp(part, "elm.text")) {
540                 return strdup(_("IDS_WFD_BODY_CONNECTED_DEVICES"));
541         }
542
543         __WDUG_LOG_FUNC_EXIT__;
544         return NULL;
545 }
546
547 /**
548  *      This function let the ug get the label of connected device
549  *      @return   the label of connected device
550  *      @param[in] data the pointer to the main data structure
551  *      @param[in] obj the pointer to the evas object
552  *      @param[in] part the pointer to the part of item
553  */
554 static char *_gl_peer_conn_dev_label_get(void *data, Evas_Object *obj, const char *part)
555 {
556         __WDUG_LOG_FUNC_ENTER__;
557         assertm_if(NULL == obj, "NULL!!");
558         assertm_if(NULL == part, "NULL!!");
559         device_type_s *peer = (device_type_s *) data;
560         char buf[WFD_GLOBALIZATION_STR_LENGTH] = { 0, };
561         WDUG_LOGI("%s", part);
562
563         if (data == NULL) {
564                 WDUG_LOGE("Incorrect parameter(NULL)\n");
565                 return NULL;
566         }
567
568         if (!strcmp(part, "elm.text.1")) {
569                 return strdup(peer->ssid);
570         } else {
571                 g_strlcpy(buf, _("IDS_WFD_CONNECTED"), WFD_GLOBALIZATION_STR_LENGTH);
572                 __WDUG_LOG_FUNC_EXIT__;
573                 return strdup(buf);
574         }
575 }
576
577 /**
578  *      This function let the ug get the title label of connected failed device list
579  *      @return   the label of connected device
580  *      @param[in] data the pointer to the main data structure
581  *      @param[in] obj the pointer to the evas object
582  *      @param[in] part the pointer to the part of item
583  */
584 static char *_gl_conn_failed_dev_title_label_get(void *data, Evas_Object *obj,
585                 const char *part)
586 {
587         __WDUG_LOG_FUNC_ENTER__;
588
589         if (data == NULL) {
590                 WDUG_LOGE("Incorrect parameter(NULL)\n");
591                 return NULL;
592         }
593
594         if (!strcmp(part, "elm.text")) {
595                 return strdup(IDS_WFD_BODY_FAILED_DEVICES);
596         }
597
598         __WDUG_LOG_FUNC_EXIT__;
599         return NULL;
600 }
601
602 /**
603  *      This function let the ug get the label of connected failed device
604  *      @return   the label of connected device
605  *      @param[in] data the pointer to the main data structure
606  *      @param[in] obj the pointer to the evas object
607  *      @param[in] part the pointer to the part of item
608  */
609 static char *_gl_peer_conn_failed_dev_label_get(void *data, Evas_Object *obj, const char *part)
610 {
611         __WDUG_LOG_FUNC_ENTER__;
612         assertm_if(NULL == obj, "NULL!!");
613         assertm_if(NULL == part, "NULL!!");
614         device_type_s *peer = (device_type_s *) data;
615         char buf[WFD_GLOBALIZATION_STR_LENGTH] = { 0, };
616         WDUG_LOGI("%s", part);
617
618         if (data == NULL) {
619                 WDUG_LOGE("Incorrect parameter(NULL)\n");
620                 return NULL;
621         }
622
623         if (!strcmp(part, "elm.text.1")) {
624                 return strdup(peer->ssid);
625         } else {
626                 g_strlcpy(buf, _("IDS_WFD_FAILED_TO_CONNECT"), WFD_GLOBALIZATION_STR_LENGTH);
627                 __WDUG_LOG_FUNC_EXIT__;
628                 return strdup(buf);
629         }
630 }
631
632 /**
633  *      This function let the ug get the title label of multi connect list
634  *      @return   the label of connected device
635  *      @param[in] data the pointer to the main data structure
636  *      @param[in] obj the pointer to the evas object
637  *      @param[in] part the pointer to the part of item
638  */
639 static char *_gl_multi_connect_dev_title_label_get(void *data, Evas_Object *obj, const char *part)
640 {
641         __WDUG_LOG_FUNC_ENTER__;
642         struct ug_data *ugd = wfd_get_ug_data();
643
644         if (data == NULL) {
645                 WDUG_LOGE("Incorrect parameter(NULL)\n");
646                 return NULL;
647         }
648
649         if (!strcmp(part, "elm.text")) {
650                 if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_IN_PROGRESS) {
651                         return strdup(_("IDS_WFD_BODY_AVAILABLE_DEVICES"));
652                 } else if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_COMPLETED) {
653                         return strdup(IDS_WFD_BODY_FAILED_DEVICES);
654                 }
655         }
656
657         __WDUG_LOG_FUNC_EXIT__;
658         return NULL;
659 }
660
661 /**
662  *      This function let the ug get the title label of busy device list
663  *      @return   the label of connected device
664  *      @param[in] data the pointer to the main data structure
665  *      @param[in] obj the pointer to the evas object
666  *      @param[in] part the pointer to the part of item
667  */
668 static char *_gl_busy_dev_title_label_get(void *data, Evas_Object *obj,
669                 const char *part)
670 {
671         __WDUG_LOG_FUNC_ENTER__;
672
673         if (data == NULL) {
674                 WDUG_LOGE("Incorrect parameter(NULL)\n");
675                 return NULL;
676         }
677
678         if (!strcmp(part, "elm.text")) {
679                 return strdup(_("IDS_WFD_BODY_BUSY_DEVICES"));
680         }
681
682         __WDUG_LOG_FUNC_EXIT__;
683         return NULL;
684 }
685
686 /**
687  *      This function let the ug get the label of busy device
688  *      @return   the label of connected device
689  *      @param[in] data the pointer to the main data structure
690  *      @param[in] obj the pointer to the evas object
691  *      @param[in] part the pointer to the part of item
692  */
693 static char *_gl_peer_busy_dev_label_get(void *data, Evas_Object *obj, const char *part)
694 {
695         __WDUG_LOG_FUNC_ENTER__;
696         assertm_if(NULL == obj, "NULL!!");
697         assertm_if(NULL == part, "NULL!!");
698         device_type_s *peer = (device_type_s *) data;
699         char buf[WFD_GLOBALIZATION_STR_LENGTH] = { 0, };
700         WDUG_LOGI("%s", part);
701
702         if (data == NULL) {
703                 WDUG_LOGE("Incorrect parameter(NULL)\n");
704                 return NULL;
705         }
706
707         WDUG_LOGI("peer->ssid = %s", peer->ssid);
708
709         if (!strcmp(part, "elm.text.1")) {
710                 return strdup(peer->ssid);
711         } else {
712                 g_strlcpy(buf, _("IDS_WFD_CONNECTED_WITH_OTHER_DEVICE"), WFD_GLOBALIZATION_STR_LENGTH);
713                 __WDUG_LOG_FUNC_EXIT__;
714                 return strdup(buf);
715         }
716 }
717
718 /**
719  *      This function let the ug delete the peer item
720  *      @return   void
721  *      @param[in] data the pointer to the main data structure
722  *      @param[in] obj the pointer to the evas object
723  */
724 static void _gl_peer_del(void *data, Evas_Object *obj)
725 {
726         __WDUG_LOG_FUNC_ENTER__;
727         assertm_if(NULL == obj, "NULL!!");
728         assertm_if(NULL == data, "NULL!!");
729
730         __WDUG_LOG_FUNC_EXIT__;
731         return;
732 }
733
734 /**
735  *      This function let the ug initialize the items of genlist
736  *      @return   void
737  */
738 void initialize_gen_item_class()
739 {
740         __WDUG_LOG_FUNC_ENTER__;
741         head_itc.item_style = "dialogue/2text.1icon.10";
742         head_itc.func.text_get = _gl_header_label_get;
743         head_itc.func.content_get = _gl_header_icon_get;
744         head_itc.func.state_get = NULL;
745
746         name_itc.item_style = "dialogue/1text";
747         name_itc.func.text_get = _gl_name_label_get;
748         name_itc.func.content_get = NULL;
749         name_itc.func.state_get = NULL;
750         name_itc.func.del = NULL;
751
752         title_itc.item_style = "dialogue/title";
753         title_itc.func.text_get = _gl_title_label_get;
754         title_itc.func.content_get = _gl_title_content_get;
755         title_itc.func.state_get = NULL;
756         title_itc.func.del = NULL;
757
758         peer_itc.item_style = "dialogue/2text.2icon.3";
759         peer_itc.func.text_get = _gl_peer_label_get;
760         peer_itc.func.content_get = _gl_peer_icon_get;
761         peer_itc.func.state_get = NULL;
762         peer_itc.func.del = _gl_peer_del;
763
764         noitem_itc.item_style = "dialogue/1text";
765         noitem_itc.func.text_get = _gl_noitem_text_get;
766         noitem_itc.func.content_get = NULL;
767         noitem_itc.func.state_get = NULL;
768         noitem_itc.func.del = NULL;
769
770         button_itc.item_style = "1icon";
771         button_itc.func.text_get = NULL;
772         button_itc.func.content_get = _gl_button_get;
773         button_itc.func.state_get = NULL;
774         button_itc.func.del = NULL;
775
776         title_conn_itc.item_style = "dialogue/title";
777         title_conn_itc.func.text_get = _gl_conn_dev_title_label_get;
778         title_conn_itc.func.content_get = NULL;
779         title_conn_itc.func.state_get = NULL;
780         title_conn_itc.func.del = NULL;
781
782         peer_conn_itc.item_style = "dialogue/2text.2icon.3";
783         peer_conn_itc.func.text_get = _gl_peer_conn_dev_label_get;
784         peer_conn_itc.func.content_get = _gl_peer_icon_get;
785         peer_conn_itc.func.state_get = NULL;
786         peer_conn_itc.func.del = _gl_peer_del;
787
788         title_conn_failed_itc.item_style = "dialogue/title";
789         title_conn_failed_itc.func.text_get = _gl_conn_failed_dev_title_label_get;
790         title_conn_failed_itc.func.content_get = NULL;
791         title_conn_failed_itc.func.state_get = NULL;
792         title_conn_failed_itc.func.del = NULL;
793
794         peer_conn_failed_itc.item_style = "dialogue/2text.2icon.3";
795         peer_conn_failed_itc.func.text_get = _gl_peer_conn_failed_dev_label_get;
796         peer_conn_failed_itc.func.content_get = _gl_peer_icon_get;
797         peer_conn_failed_itc.func.state_get = NULL;
798         peer_conn_failed_itc.func.del = _gl_peer_del;
799
800         title_busy_itc.item_style = "dialogue/title";
801         title_busy_itc.func.text_get = _gl_busy_dev_title_label_get;
802         title_busy_itc.func.content_get = NULL;
803         title_busy_itc.func.state_get = NULL;
804         title_busy_itc.func.del = NULL;
805
806         peer_busy_itc.item_style = "dialogue/2text.2icon.3";
807         peer_busy_itc.func.text_get = _gl_peer_busy_dev_label_get;
808         peer_busy_itc.func.content_get = _gl_peer_icon_get;
809         peer_busy_itc.func.state_get = NULL;
810         peer_busy_itc.func.del = _gl_peer_del;
811
812         title_multi_connect_itc.item_style = "dialogue/title";
813         title_multi_connect_itc.func.text_get = _gl_multi_connect_dev_title_label_get;
814         title_multi_connect_itc.func.content_get = NULL;
815         title_multi_connect_itc.func.state_get = NULL;
816         title_multi_connect_itc.func.del = NULL;
817
818         __WDUG_LOG_FUNC_EXIT__;
819
820 }