4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Wonyoung Lee <wy1115.lee@samsung.com>, Tarun Kumar <tarun.kr@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
24 #include "myaccount_ug_account_list.h"
25 #include "myaccount_ug_addaccount.h"
26 #include "myaccount_ug_common.h"
28 #define SORT_PRIOR_1 "1_"
29 #define SORT_PRIOR_2 "2_"
30 #define SORT_PRIOR_3 "3_"
32 static Elm_Genlist_Item_Class account_list_itc;
34 static int account_index = 0;
36 #define TOOLBAR_HEIGHT 0
38 //static void _myaccount_account_list_free_capdata(gpointer data, gpointer user_data);
39 static void __myaccount_account_list_addaccount_cb( void *data,
40 Evas_Object *obj, void* event_info );
41 static void _myaccount_ug_account_list_layout_cb(ui_gadget_h ug,
42 enum ug_mode mode, void *priv);
43 static void _myaccount_ug_account_list_result_cb(ui_gadget_h ug,
44 app_control_h app_control, void *priv);
45 static void _myaccount_ug_account_list_destroy_cb(ui_gadget_h ug,
47 static void __myaccount_account_list_append_genlist(myaccount_appdata *ad,
49 static void __rotate_more_ctxpopup_cb(void *data, Evas_Object *obj, void *event_info);
51 static char *__myaccount_account_list_get_capablity_string_value(const char* capability_type)
53 if (!strcmp(capability_type, "http://tizen.org/account/capability/contact"))
54 return dgettext(MA_UG_NAME, "IDS_PB_TAB_CONTACTS");
55 else if (!strcmp(capability_type, "http://tizen.org/account/capability/calendar"))
56 return dgettext("sys_string", "IDS_COM_BODY_S_PLANNER");
57 else if (!strcmp(capability_type ,"http://tizen.org/account/capability/photo"))
58 return dgettext(MA_UG_NAME, "IDS_COM_BODY_GALLERY");
59 else if (!strcmp(capability_type ,"http://tizen.org/account/capability/video"))
60 return dgettext(MA_UG_NAME, "IDS_ST_BODY_VIDEOS");
61 else if (!strcmp(capability_type ,"http://tizen.org/account/capability/email"))
62 return dgettext(MA_UG_NAME, "IDS_COM_BODY_EMAIL");
63 else if (!strcmp(capability_type ,"http://tizen.org/account/capability/post"))
64 return dgettext(MA_UG_NAME, "IDS_TW_BODY_POST_TWITTER");
65 else if (!strcmp(capability_type ,"http://tizen.org/account/capability/voip"))
66 return dgettext(MA_UG_NAME, "IDS_COM_BODY_VOIP_CALL");
67 else if (!strcmp(capability_type ,"http://tizen.org/account/capability/samsungapps"))
68 return dgettext(MA_UG_NAME, "IDS_COM_BODY_SAMSUNG_APPS_T_MAINMENU");
69 else if (!strcmp(capability_type ,"http://tizen.org/account/capability/mobiletracker"))
70 return dgettext(MA_UG_NAME, "IDS_ST_BODY_MOBILE_TRACKER");
71 else if (!strcmp(capability_type ,"http://tizen.org/account/capability/task"))
72 return dgettext(MA_UG_NAME, "IDS_COM_BODY_TASK");
73 #ifdef _FEATURE_SMEMO_ENABLE
74 else if (!strcmp(capability_type ,"http://tizen.org/account/capability/memo"))
75 return dgettext(MA_UG_NAME, "IDS_COM_OPT_S_MEMO");
77 else if (!strcmp(capability_type ,"http://tizen.org/account/capability/memo"))
80 else if (!strcmp(capability_type ,"http://tizen.org/account/capability/synchronise"))
81 return dgettext(MA_UG_NAME, "IDS_SYNCML_BODY_SYNC_SERVER");
82 else if (!strcmp(capability_type ,"http://tizen.org/account/capability/docomo"))
83 return dgettext(MA_UG_NAME, "IDS_COM_BODY_CALENDAR_T_MAINMENU_ABB2");
84 else if (!strcmp(capability_type ,"http://tizen.org/account/capability/music"))
85 return dgettext("sys_string", "IDS_COM_BODY_MUSIC");
86 else if (!strcmp(capability_type ,"http://tizen.org/account/capability/internet"))
87 return dgettext(MA_UG_NAME, "IDS_COM_BODY_INTERNET");
88 else if (!strcmp(capability_type ,"http://tizen.org/account/capability/message"))
89 return dgettext(MA_UG_NAME, "IDS_COM_BODY_MESSAGES");
91 return NULL;//return dgettext(MA_UG_NAME, "IDS_COM_POP_UNKNOWN");
95 static void _myaccount_account_list_free_capdata(gpointer data, gpointer user_data)
99 myaccount_capability_data * cap_data= (myaccount_capability_data*)data;
101 MA_MEMFREE(cap_data->type);
102 MA_MEMFREE(cap_data);
106 bool _myaccount_account_list_get_capablity_text(const char* capability_type,
107 account_capability_state_e capability_state,
110 /* get capabilities of the account*/
111 char *capability_string = NULL;
112 myaccount_list_priv *account_info = (myaccount_list_priv*)user_data;
113 char *capability_textbuf = account_info->capability;
119 myaccount_capability_data *cap_data = (myaccount_capability_data*)malloc(sizeof(myaccount_capability_data));
121 MYACCOUNT_ERROR("malloc failed\n");
124 memset(cap_data, 0, sizeof(myaccount_capability_data));
126 cap_data->type = strdup(capability_type);
127 cap_data->state = capability_state;
129 account_info->capablity_list = g_slist_append(account_info->capablity_list, (gpointer)cap_data);
131 if (capability_state == ACCOUNT_CAPABILITY_ENABLED) {
132 capability_string = __myaccount_account_list_get_capablity_string_value(
135 /* Synchronise capability string exception, wylee */
136 if(!strcmp(account_info->package_name, "setting-synchronise-efl")){
137 MA_SNPRINTF(capability_textbuf, 127, "%s", dgettext(MA_UG_NAME, "IDS_SYNCML_BODY_SYNC_SERVER"));
139 if (capability_string != NULL) {
140 if(strlen(capability_textbuf) > 0) {
141 char *temp2 = strdup(capability_textbuf);
143 MYACCOUNT_ERROR("strdup returns NULL\n");
146 MA_SNPRINTF(capability_textbuf, 127, "%s, %s", temp2, capability_string);
149 MA_SNPRINTF(capability_textbuf, 127, "%s%s", capability_textbuf,
159 void myaccount_account_list_free_priv_data(myaccount_appdata *appdata)
162 myaccount_appdata *ad = (myaccount_appdata *)appdata;
165 MYACCOUNT_ERROR("No appdata!!\n");
169 for(it=ad->sorted_account_list;it!=NULL;it=g_list_next(it)) {
170 myaccount_list_priv* tmp = (myaccount_list_priv*)it->data;
174 if(ad->account_info_list) {
175 g_list_free(ad->account_info_list);
176 ad->account_info_list = NULL;
179 ad->sorted_account_list = NULL;
183 static myaccount_list_priv*
184 _myaccount_account_list_create_priv_item()
186 myaccount_list_priv* account_info = NULL;
187 account_info = (myaccount_list_priv*)calloc(1,sizeof(myaccount_list_priv));
189 MYACCOUNT_ERROR("memory allocation fail\n");
195 bool _myaccount_account_list_account_info_cb(account_h account,
198 GList **account_info_list = (GList **)user_data;
200 myaccount_list_priv* account_info = NULL;
203 MYACCOUNT_ERROR("_myaccount_account_list_account_info_cb:account handle is NULL\n");
207 account_info = _myaccount_account_list_create_priv_item();
208 if ( account_info == NULL ) {
209 MYACCOUNT_ERROR("_myaccount_account_list_create_priv_item fail\n");
213 char *temptxt = NULL;
215 account_secrecy_state_e secret;
217 error_code = account_get_user_name(account, &temptxt);
218 if (error_code != ACCOUNT_ERROR_NONE) {
219 MYACCOUNT_ERROR("account_get_user_name: Failed \n");
220 } else if (temptxt && strlen(temptxt)) {
221 MA_STRNCPY(account_info->username, temptxt,
222 sizeof(account_info->username));
225 error_code = account_get_display_name(account, &temptxt);
226 if (error_code != ACCOUNT_ERROR_NONE) {
227 MYACCOUNT_ERROR("account_get_display_name: Failed \n");
228 } else if (temptxt && strlen(temptxt)) {
229 MA_STRNCPY(account_info->display_name, temptxt,
230 sizeof(account_info->display_name));
233 error_code = account_get_email_address(account, &temptxt);
234 if (error_code != ACCOUNT_ERROR_NONE) {
235 MYACCOUNT_ERROR("account_get_email_address: Failed \n");
236 } else if (temptxt && strlen(temptxt)) {
237 MA_STRNCPY(account_info->email_address, temptxt,
238 sizeof(account_info->email_address));
242 error_code = account_get_package_name(account, &temptxt);
243 if (error_code != ACCOUNT_ERROR_NONE) {
244 MYACCOUNT_ERROR("account_get_package_name: Failed \n");
245 } else if (temptxt && strlen(temptxt)) {
246 MA_STRNCPY(account_info->package_name, temptxt,
247 sizeof(account_info->package_name));
248 if(!strcmp(temptxt, TIZEN_EMAIL_APPID) || !strcmp(temptxt, EXCHANGE_UI_APPID) ||!strcmp(temptxt, GOOGLE_ACCOUNT_APPID)){
249 account_info->b_tizen_email = TRUE;
251 account_info->b_tizen_email = FALSE;
256 error_code = account_get_account_id(account, &id);
257 if (error_code != ACCOUNT_ERROR_NONE) {
258 MYACCOUNT_ERROR("account_get_account_id: Failed \n");
260 account_info->account_id = id;
262 error_code = account_get_secret(account, &secret);
263 if (error_code != ACCOUNT_ERROR_NONE) {
264 MYACCOUNT_ERROR("account_get_secret: Failed \n");
266 account_info->secret = secret;
268 error_code = account_get_domain_name(account, &temptxt);
269 if (error_code != ACCOUNT_ERROR_NONE) {
270 MYACCOUNT_ERROR("account_get_domain_name: Failed \n");
271 } else if (temptxt && strlen(temptxt)) {
272 MA_STRNCPY(account_info->domain_name, temptxt,
273 sizeof(account_info->domain_name));
277 error_code = account_get_icon_path(account, &temptxt);
278 if (error_code != ACCOUNT_ERROR_NONE) {
279 MYACCOUNT_ERROR("account_get_icon_path: Failed \n");
280 } else if (temptxt && strlen(temptxt)) {
281 MA_STRNCPY(account_info->icon_path, temptxt, sizeof(account_info->icon_path));
284 account_type_h account_type = NULL;
286 error_code = account_type_create(&account_type);
288 if(error_code == ACCOUNT_ERROR_NONE){
290 error_code = account_type_query_by_app_id((const char*)account_info->package_name, &account_type);
292 if(error_code == ACCOUNT_ERROR_NONE){
293 char* provider_icon = NULL;
294 error_code = account_type_get_icon_path(account_type, &provider_icon);
296 if(error_code != ACCOUNT_ERROR_NONE){
297 MYACCOUNT_ERROR("account provider icon get Failed \n");
298 } else if (provider_icon && strlen(provider_icon)) {
299 MA_STRNCPY(account_info->icon_path, provider_icon, sizeof(account_info->icon_path));
301 MYACCOUNT_DBUG("account provider icon is not set \n");
303 MA_MEMFREE(provider_icon);
306 error_code = account_type_destroy(account_type);
307 if(error_code != ACCOUNT_ERROR_NONE){
308 MYACCOUNT_ERROR("type_destroy destroy Failed \n");
314 if(!strlen(account_info->icon_path))
315 myaccount_common_get_icon_by_name(account_info->domain_name ,
316 account_info->icon_path);
318 error_code = account_get_sync_support(account,
319 (account_sync_state_e *)&(account_info->sync_status));
320 if (error_code != ACCOUNT_ERROR_NONE) {
321 MYACCOUNT_ERROR("account_get_sync_support: Failed \n");
324 error_code = account_get_capability_all(account,
325 _myaccount_account_list_get_capablity_text,
326 (void *)account_info);
327 if (error_code != ACCOUNT_ERROR_NONE)
328 MYACCOUNT_ERROR("account_get_capability: Failed \n");
330 /* for SA(01), TA(02) sorting */
331 MYACCOUNT_DBUG("(%s)\n", strchr(account_info->package_name, '.'));
332 if(!strcmp(account_info->package_name, SAMSUNG_ACCOUNT_APPID)) {
333 MA_SNPRINTF(account_info->service_sname,
334 sizeof(account_info->service_sname), "%s%s", SORT_PRIOR_1, strchr(account_info->package_name, '.'));
335 } else if(!strcmp(account_info->package_name, TIZEN_ACCOUNT_APPID)){
336 MA_SNPRINTF(account_info->service_sname,
337 sizeof(account_info->service_sname), "%s%s", SORT_PRIOR_1, strchr(account_info->package_name, '.'));
339 /* No need to sort, sort as the order user register */
340 MA_SNPRINTF(account_info->service_sname,
341 sizeof(account_info->service_sname), "%s", SORT_PRIOR_3);
344 *account_info_list = g_list_append(*account_info_list, (void*)account_info);
350 static int _myaccount_ug_account_list_compare(gconstpointer a, gconstpointer b)
352 myaccount_list_priv* account_info_a = (myaccount_list_priv*)a;
353 myaccount_list_priv* account_info_b = (myaccount_list_priv*)b;
355 return g_ascii_strcasecmp(account_info_a->service_sname, account_info_b->service_sname);
358 static int __myaccount_account_list_populate_account_info(myaccount_appdata *ad)
362 account_foreach_account_from_db(_myaccount_account_list_account_info_cb,
363 &ad->account_info_list);
365 ad->sorted_account_list = g_list_sort(ad->account_info_list, (GCompareFunc)_myaccount_ug_account_list_compare);
366 count = g_list_length(ad->sorted_account_list);
371 Eina_Bool myaccount_account_list_quit_cb(void *data, Elm_Object_Item *it)
374 myaccount_appdata *priv = (myaccount_appdata*)data;
376 MYACCOUNT_DBUG("account list view quit\n");
379 MYACCOUNT_ERROR("myaccount_account_list_quit_cb callback user data is null!!!\n");
383 if(priv->popup != NULL)
385 evas_object_del(priv->popup);
389 myaccount_account_list_free_priv_data(priv);
394 ui_gadget_h ug = priv->ug;
395 error_code = ug_destroy_me(ug);
396 MYACCOUNT_SLOGD("myaccount_account_list_quit_cb callback : return = %d!!!\n",
403 void myaccount_account_list_back_key_cb(void *data, Evas_Object *obj, void *event_info)
405 myaccount_appdata *ad = (myaccount_appdata*)data;
406 elm_naviframe_item_pop(ad->navi_bar);
409 static void __myaccount_account_list_addaccount_cb( void *data,
410 Evas_Object *obj, void *event_info )
412 myaccount_appdata *priv = (myaccount_appdata*)data;
413 myaccount_addaccount_create_view(priv);
414 if(priv->popup != NULL)
416 evas_object_del(priv->popup);
421 static char *__myaccount_account_list_gl_label_get(void *data,
422 Evas_Object *obj, const char *part)
424 myaccount_list_priv *account_info_item = (myaccount_list_priv*)data;
425 char domain_name_lower[128] = {0,};
427 if (!account_info_item) {
428 MYACCOUNT_ERROR(" __myaccount_account_list_gl_label_get: Data is NULL\n");
432 if (!strcmp(part, "elm.text")) {
433 myaccount_common_lowercase(account_info_item->domain_name,
436 if (strlen(account_info_item->display_name) > 0)
437 return strdup(account_info_item->display_name);
438 else if (strlen(account_info_item->email_address) > 0)
439 return strdup(account_info_item->email_address);
440 else if (strlen(account_info_item->username) > 0)
441 return strdup(account_info_item->username);
443 return strdup("Unknown");
444 } else if (!strcmp(part, "elm.text.sub")) {
445 if (strlen(account_info_item->capability) <=0 )
446 return strdup(dgettext(MA_UG_NAME, "IDS_MA_BODY_SIGNED_IN"));
448 return strdup(account_info_item->capability);
455 static Evas_Object *__myaccount_account_list_gl_icon_get(void *data,
456 Evas_Object *obj, const char *part)
458 char tempbuf[PATH_MAX];
459 Evas_Object *icon = NULL;
460 myaccount_list_priv *account_info_item = (myaccount_list_priv*)data;
461 Evas_Object *ic = NULL;
463 if (!account_info_item) {
464 MYACCOUNT_ERROR("__myaccount_account_list_gl_icon_get: Data is NULL\n");
467 memset(tempbuf, 0, sizeof(char)*PATH_MAX);
469 if (!strcmp(part, "elm.swallow.icon")) {
470 if (strlen(account_info_item->icon_path) > 0) {
471 MA_SNPRINTF(tempbuf, sizeof(tempbuf), "%s", account_info_item->icon_path);
473 MA_SNPRINTF(tempbuf, sizeof(tempbuf), "%s", "A01_2_Icon_default.png");
476 ic = elm_layout_add(obj);
477 elm_layout_theme_set(ic, "layout", "list/B/type.2", "default");
479 icon = elm_image_add(obj);
480 if (strstr(tempbuf, "/"))
481 elm_image_file_set(icon, tempbuf, NULL);
483 elm_image_file_set(icon, MA_IMAGE_EDJ_NAME, tempbuf);
485 elm_layout_content_set(ic, "elm.swallow.content", icon);
488 if (!strcmp(part, "elm.swallow.end")) {
489 if (account_info_item->sync_status == ACCOUNT_SYNC_NOT_SUPPORT)
491 MA_SNPRINTF(tempbuf, sizeof(tempbuf), "%s", "account_icon_syncing.png");
493 if(strlen(tempbuf) > 0) {
494 ic = elm_layout_add(obj);
495 elm_layout_theme_set(ic, "layout", "list/C/type.3", "default");
497 icon = elm_image_add(obj);
498 if (strstr(tempbuf, "/"))
499 elm_image_file_set(icon, tempbuf, NULL);
501 elm_image_file_set(icon, MA_IMAGE_EDJ_NAME, tempbuf);
503 evas_object_color_set(icon, 67, 116, 217, 255);
504 elm_layout_content_set(ic, "elm.swallow.content", icon);
511 static void _myaccount_ug_account_list_layout_cb(ui_gadget_h ug,
512 enum ug_mode mode, void *priv)
515 myaccount_appdata *ad;
518 MYACCOUNT_ERROR("layout cb error ug=%p, priv=%p\n", ug, priv);
521 ad = (myaccount_appdata*)priv;
522 base = ug_get_layout(ug);
524 MYACCOUNT_ERROR("layout cb base is null\n");
527 case UG_MODE_FRAMEVIEW:
528 elm_object_part_content_set (ad->layout_main, "content", base);
530 case UG_MODE_FULLVIEW:
531 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND,
533 //elm_win_resize_object_add(ad->win_main, base);
534 evas_object_show(base);
541 static void _myaccount_ug_account_list_result_cb(ui_gadget_h ug,
542 app_control_h app_control, void *priv)
544 //MYACCOUNT_VERBOSE("_myaccount_ug_account_list_result_cb\n");
547 static void _myaccount_ug_account_list_destroy_cb(ui_gadget_h ug,
550 myaccount_appdata *mydata = (myaccount_appdata*)priv;
553 MYACCOUNT_ERROR("destroy cb error ug=%p, priv=%p\n", ug, mydata);
556 myaccount_common_set_item_selected_state(false);
559 MYACCOUNT_SLOGD("_myaccount_ug_account_list_destroy_cb");
561 myaccount_common_handle_notification(NULL);
565 static void __myaccount_accountlist_set_ug_cbs(struct ug_cbs *cbs,
566 myaccount_appdata *priv)
569 MYACCOUNT_ERROR("__myaccount_addaccount_ug_create_email: Invalid param cbs=%p, priv=%p\n",
573 cbs->layout_cb = _myaccount_ug_account_list_layout_cb;
574 cbs->result_cb = _myaccount_ug_account_list_result_cb;
575 cbs->destroy_cb = _myaccount_ug_account_list_destroy_cb;
576 cbs->priv = (void *)priv;
579 static void __myaccount_ug_list_call_ug(void *data, myaccount_list_priv *account)
581 myaccount_appdata *ad = (myaccount_appdata*)data;
582 MyAccountProviderType sp_type;
583 ui_gadget_h ug = NULL;
584 struct ug_cbs cbs = {0,};
585 app_control_h app_control;
586 __attribute__((__unused__)) int ret = APP_CONTROL_ERROR_NONE;
589 MYACCOUNT_ERROR("__myaccount_ug_list_call_ug : account info NULL\n");
593 __myaccount_accountlist_set_ug_cbs(&cbs, ad);
595 sp_type = myaccount_common_get_provider_type(account->package_name);
596 ret = app_control_create(&app_control);
599 // case MYACCOUNT_TYPE_MSN :
600 case MYACCOUNT_TYPE_GOOGLE :
601 case MYACCOUNT_TYPE_OTHER :
602 // case MYACCOUNT_TYPE_FACEBOOK :
603 ret = myaccount_common_launch_application(MYACCOUNT_REQUEST_VIEW,
604 strdup(account->package_name),
605 strdup(account->username),
611 case MYACCOUNT_TYPE_EXCHANGE :
612 ret = myaccount_common_launch_application(MYACCOUNT_REQUEST_VIEW,
613 strdup("activesync-ui"),
614 strdup(account->username),
620 case MYACCOUNT_TYPE_SAMSUNG :
621 ret = myaccount_common_launch_application(MYACCOUNT_REQUEST_VIEW,
622 strdup("com.samsung.samsung-account-front"),
623 strdup(account->username),
629 case MYACCOUNT_TYPE_PICASA :
630 case MYACCOUNT_TYPE_YOUTUBE :
632 ret = myaccount_common_launch_application(MYACCOUNT_REQUEST_VIEW,
633 strdup(account->package_name),
634 strdup(account->username),
643 app_control_destroy(app_control);
647 static void __myaccount_account_list_gl_sel(void *data,
648 Evas_Object *obj, void *event_info)
650 myaccount_appdata *ad = myaccount_get_appdata();
651 if( myaccount_common_get_item_selected_state() ) {
652 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
655 myaccount_common_set_item_selected_state(true);
656 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
658 MYACCOUNT_SLOGD("__myaccount_account_list_gl_sel data=%p, obj=%p, event_info=%p\n",
659 data, obj, event_info);
660 myaccount_list_priv *account = (myaccount_list_priv*)data;
661 MYACCOUNT_SLOGD("__myaccount_account_list_gl_sel : account name : %s\n",
662 account->domain_name);
665 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
667 __myaccount_ug_list_call_ug((myaccount_appdata*)ad, account);
671 static void __myaccount_account_list_item_selected(void *data,
672 Evas_Object *obj, void *event_info)
674 //MYACCOUNT_VERBOSE("__myaccount_account_list_item_selected \n");
677 static void __myaccount_account_list_append_genlist(myaccount_appdata *ad,
680 MYACCOUNT_SLOGD ("\n count received in __myaccount_account_list_append_genlist = %d \n",
682 bool supported = false;
686 for(iter=ad->sorted_account_list;iter!=NULL;iter=g_list_next(iter)) {
687 myaccount_list_priv* tmp = (myaccount_list_priv*)iter->data;
689 if (tmp->secret == ACCOUNT_SECRECY_VISIBLE) {
690 if (ad->capability_filter) {
692 myaccount_list_priv *acc_info = NULL;
695 /* Tizen email exception */
696 if(!strcmp("http://tizen.org/account/capability/tizen_email", ad->capability_filter)){
697 if(tmp->b_tizen_email) {
701 for (siter = acc_info->capablity_list; siter != NULL; siter = g_slist_next(siter)) {
702 myaccount_capability_data *cap_data = (myaccount_capability_data*)siter->data;
704 if (!strcmp(cap_data->type, ad->capability_filter)) {
712 elm_genlist_item_append(ad->account_genlist,
715 ELM_GENLIST_ITEM_NONE,
716 __myaccount_account_list_gl_sel,
721 elm_genlist_item_append(ad->account_genlist,
724 ELM_GENLIST_ITEM_NONE,
725 __myaccount_account_list_gl_sel,
732 myaccount_addaccount_create_view(ad);
737 static void _myaccount_ug_account_gl_realized(void *data, Evas_Object *obj, void *ei)
739 Elm_Object_Item *it = NULL;
743 // char buf[2048]={0,};
744 // char bufdomain[2048]={0,};
747 MYACCOUNT_ERROR("Realized event info is NULL!!! \n");
751 it = (Elm_Object_Item *)ei;
753 total_count = elm_genlist_items_count(obj);
754 index = elm_genlist_item_index_get(it);
756 if(index > 2 && index < total_count)
758 /*Add account items. index 1 and last are the seperators*/
760 myaccount_list_priv *account_info_item = (myaccount_list_priv*)elm_object_item_data_get(it);
762 if(account_info_item){
763 memset(buf, 0, 2048);
764 memset(bufdomain, 0, 2048);
766 if (strlen(account_info_item->domain_name) > 0)
767 g_snprintf(bufdomain, 1024, "Logged into %s with user id ", account_info_item->domain_name);
769 g_snprintf(bufdomain, 1024, "Service unknown user id ");
771 if (strlen(account_info_item->display_name) > 0)
772 g_snprintf(buf, 1024, "%s%s", bufdomain, account_info_item->display_name);
773 else if (strlen(account_info_item->email_address) > 0)
774 g_snprintf(buf, 1024, "%s%s", bufdomain, account_info_item->email_address);
775 else if (strlen(account_info_item->username) > 0)
776 g_snprintf(buf, 1024, "%s%s", bufdomain, account_info_item->username);
778 g_snprintf(buf, 1024, "%sUnknown", account_info_item->domain_name);
780 ao = elm_object_item_access_object_get(it);
781 elm_access_info_set(ao, ELM_ACCESS_INFO, buf);
785 } else if (index == 2) {
786 //ao = elm_object_item_access_object_get(it);
787 //elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, "Turn Auto Sync on or off");
788 } else if (index == 3) {
789 //ao = elm_object_item_access_object_get(it);
790 //elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, "Below is the list of all logged in accounts");
792 /*Remove access for seperators*/
793 //elm_object_item_access_unregister(ei);
798 //MYACCOUNT_INFO("DO NOTHING only one account exist, total_count(%d) index(%d) !!! \n", total_count, index);
801 } else if (index == 2) {
802 elm_object_item_signal_emit(ei, "elm,state,top", "");
803 } else if (index == (total_count-2)) {
804 elm_object_item_signal_emit(ei, "elm,state,bottom", "");
806 elm_object_item_signal_emit(ei, "elm,state,center", "");
811 static Evas_Object *__myaccount_account_list_create_genlist(
812 myaccount_appdata *ad)
814 Evas_Object *genlist;
817 MYACCOUNT_ERROR("__myaccount_account_list_create_genlist returns NULL\n");
821 int account_count = 0;
822 account_count = __myaccount_account_list_populate_account_info(ad);
824 account_list_itc.item_style = "type1";
825 account_list_itc.func.text_get = __myaccount_account_list_gl_label_get;
826 account_list_itc.func.content_get = __myaccount_account_list_gl_icon_get;
827 account_list_itc.func.state_get = NULL;
828 account_list_itc.func.del = NULL;
830 ad->account_genlist = genlist = elm_genlist_add(ad->navi_bar);
831 evas_object_smart_callback_add(genlist, "realized", _myaccount_ug_account_gl_realized, NULL);
832 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
833 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
834 elm_genlist_mode_set(genlist, EINA_TRUE);
836 evas_object_smart_callback_add(genlist, "selected",
837 __myaccount_account_list_item_selected,
838 (myaccount_appdata*) ad);
840 __myaccount_account_list_append_genlist(ad, account_count);
845 static void __move_more_ctxpopup(myaccount_appdata *ad)
847 MYACCOUNT_DBUG("__move_more_ctxpopup");
852 elm_win_screen_size_get(ad->win_main, NULL, NULL, &w, &h);
853 int pos = elm_win_rotation_get(ad->win_main);
858 evas_object_move(ad->popup, (w / 2), h);
861 evas_object_move(ad->popup, (h / 2), w);
864 evas_object_move(ad->popup, (h / 2), w);
871 static void __rotate_more_ctxpopup_cb(void *data, Evas_Object *obj, void *event_info)
873 MYACCOUNT_DBUG("__rotate_more_ctxpopup_cb");
874 myaccount_appdata *ad = data;
876 __move_more_ctxpopup(ad);
878 static void _delete_ctxpopup_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
880 MYACCOUNT_DBUG("_delete_toolbar_ctxpopup_cb");
881 myaccount_appdata *ad = data;
882 if (elm_win_wm_rotation_supported_get(ad->win_main)) {
884 evas_object_smart_callback_del(elm_object_top_widget_get(ad->popup), "wm,rotation,changed", __rotate_more_ctxpopup_cb);
888 eext_object_event_callback_del(ad->popup, EEXT_CALLBACK_BACK, eext_ctxpopup_back_cb);
889 eext_object_event_callback_del(ad->popup, EEXT_CALLBACK_MORE, eext_ctxpopup_back_cb);
891 evas_object_event_callback_del(ad->popup, EVAS_CALLBACK_DEL, _delete_ctxpopup_cb);
895 static void __create_more_ctxpopup(myaccount_appdata *ad)
897 MYACCOUNT_DBUG("__create_more_ctxpopup");
899 Evas_Object *popup = elm_ctxpopup_add(ad->navi_bar);
902 elm_object_style_set(popup, "more/default");
903 elm_ctxpopup_auto_hide_disabled_set(popup, EINA_TRUE);
904 if (elm_win_wm_rotation_supported_get(ad->win_main)) {
905 evas_object_smart_callback_add(elm_object_top_widget_get(popup), "wm,rotation,changed", __rotate_more_ctxpopup_cb, ad);
907 evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, _delete_ctxpopup_cb, ad);
909 eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, eext_ctxpopup_back_cb, popup);
910 eext_object_event_callback_add(popup, EEXT_CALLBACK_MORE, eext_ctxpopup_back_cb, popup);
912 elm_ctxpopup_item_append(popup, dgettext(MA_UG_NAME,"IDS_PB_BODY_ADD_ACCOUNT"), NULL, __myaccount_account_list_addaccount_cb, ad);
914 elm_ctxpopup_direction_priority_set(popup, ELM_CTXPOPUP_DIRECTION_UP,
915 ELM_CTXPOPUP_DIRECTION_LEFT,
916 ELM_CTXPOPUP_DIRECTION_RIGHT,
917 ELM_CTXPOPUP_DIRECTION_DOWN);
919 __move_more_ctxpopup(ad);
920 evas_object_show(popup);
923 static void __delete_more_cb(void *data)
925 MYACCOUNT_DBUG("__delete_more_cb");
926 myaccount_appdata *ad = data;
928 evas_object_del(ad->popup);
933 static void __more_cb(void *data, Evas_Object *obj, void *event_info)
935 MYACCOUNT_DBUG("__more_cb");
936 myaccount_appdata *ad = data;
937 __delete_more_cb(data);
938 __create_more_ctxpopup(ad);
941 void myaccount_ug_account_list_create(void *data)
943 myaccount_appdata *ad = data;
944 Evas_Object *genlist = NULL;
945 Evas_Object *back_btn = NULL;
946 Evas_Object *layout = NULL;
947 Evas_Object *more_button = NULL;
950 MYACCOUNT_ERROR("myaccount_ug_account_list_create myaccount_appdata is null\n");
954 layout = elm_layout_add(ad->navi_bar);
955 elm_layout_file_set(layout,
956 "/usr/apps/setting-myaccount-efl/res/edje/setting-myaccount-efl/myaccount.edj",
958 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
959 evas_object_size_hint_align_set( layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
960 edje_object_signal_emit(_EDJ(layout), "elm,state,show,content", "elm");
961 elm_object_style_set(ad->bg, "group_list");
963 evas_object_show(layout);
965 genlist = __myaccount_account_list_create_genlist(ad);
967 elm_object_part_content_set (layout, "accountlist.genlist", genlist);
969 back_btn = elm_button_add(ad->navi_bar);
970 elm_object_style_set(back_btn, "naviframe/back_btn/default");
971 evas_object_smart_callback_add(back_btn, "clicked", myaccount_account_list_back_key_cb, ad);
973 ad->nf_it = elm_naviframe_item_push(ad->navi_bar,
975 "IDS_ST_BODY_ACCOUNT_LIST"),
976 back_btn, NULL, layout, NULL);
978 elm_naviframe_item_pop_cb_set(ad->nf_it, myaccount_account_list_quit_cb, (void*)ad);
981 count = myaccount_common_get_account_type_count(ad->capability_filter);
983 MYACCOUNT_DBUG("TOTAL avaiable sp count %d\n", count);
985 eext_object_event_callback_add(ad->navi_bar, EEXT_CALLBACK_MORE, eext_naviframe_more_cb, NULL);
987 more_button = elm_button_add(ad->navi_bar);
988 elm_object_style_set(more_button, "naviframe/more/default");
989 evas_object_smart_callback_add(more_button, "clicked", __more_cb, ad);
990 elm_object_item_part_content_set(ad->nf_it, "toolbar_more_btn", more_button);
995 static Evas_Object *__myaccount_account_list_create_bg(Evas_Object *parent)
997 Evas_Object *bg = elm_bg_add(parent);
998 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
999 //elm_win_resize_object_add(parent, bg);
1000 evas_object_show(bg);
1004 static Evas_Object *__myaccount_account_list_create_main_layout(
1005 Evas_Object *parent,
1008 Evas_Object *layout;
1010 layout = elm_layout_add(parent);
1011 elm_layout_theme_set(layout, "layout", "application", "default");
1012 evas_object_size_hint_weight_set( layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1013 edje_object_signal_emit(_EDJ(layout), "elm,state,show,indicator", "elm");
1014 edje_object_signal_emit(_EDJ(layout), "elm,state,show,content", "elm");
1015 elm_object_part_content_set ( layout, "elm.swallow.bg", bg);
1017 evas_object_show( layout );
1022 static Evas_Object *__myaccount_account_list_create_navi_layout(
1023 Evas_Object *parent)
1025 Evas_Object *navi_bar;
1027 navi_bar = elm_naviframe_add(parent);
1028 elm_object_part_content_set ( parent, "elm.swallow.content", navi_bar );
1029 evas_object_show(navi_bar);
1034 static void __myaccount_account_list_init_main_view(myaccount_appdata *ad)
1036 //elm_win_indicator_mode_set(ad->win_main, ELM_WIN_INDICATOR_SHOW);
1037 ad->bg = __myaccount_account_list_create_bg(ad->win_main);
1038 ad->layout_main = __myaccount_account_list_create_main_layout(ad->win_main, ad->bg);
1039 ad->base = ad->layout_main;
1042 void myaccount_list_navi_create(myaccount_appdata *ad)
1044 ad->navi_bar = __myaccount_account_list_create_navi_layout(ad->layout_main);
1046 eext_object_event_callback_add(ad->navi_bar, EEXT_CALLBACK_BACK, myaccount_account_list_back_key_cb, (void*)ad);
1049 void myaccount_list_view_create(myaccount_appdata *priv)
1051 /*struct ug_cbs cbs = {0,};*/
1052 __attribute__((__unused__)) struct ug_cbs cbs = {0,};
1053 cbs.layout_cb = _myaccount_ug_account_list_layout_cb;
1054 cbs.result_cb = _myaccount_ug_account_list_result_cb;
1055 cbs.destroy_cb = _myaccount_ug_account_list_destroy_cb;
1056 cbs.priv = (void *)priv;
1058 MYACCOUNT_DBUG("Account list start\n");
1059 __myaccount_account_list_init_main_view(priv);
1062 void myaccount_list_refresh_item_list(myaccount_appdata *ad)
1067 MYACCOUNT_ERROR("no appdata!\n");
1071 if(!ad->account_genlist) {
1072 MYACCOUNT_ERROR("no genlist!\n");
1076 MYACCOUNT_DBUG("Account list start\n");
1078 elm_genlist_clear(ad->account_genlist);
1080 myaccount_account_list_free_priv_data(ad);
1083 count = __myaccount_account_list_populate_account_info(ad);
1085 __myaccount_account_list_append_genlist(ad, count);