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)
363 error_code = account_connect();
364 if (error_code != ACCOUNT_ERROR_NONE)
365 MYACCOUNT_ERROR("account_connect: Failed \n");
367 account_foreach_account_from_db(_myaccount_account_list_account_info_cb,
368 &ad->account_info_list);
369 error_code = account_disconnect();
370 if (error_code != ACCOUNT_ERROR_NONE)
371 MYACCOUNT_ERROR("account_disconnect: Failed \n");
373 ad->sorted_account_list = g_list_sort(ad->account_info_list, (GCompareFunc)_myaccount_ug_account_list_compare);
374 count = g_list_length(ad->sorted_account_list);
379 Eina_Bool myaccount_account_list_quit_cb(void *data, Elm_Object_Item *it)
382 myaccount_appdata *priv = (myaccount_appdata*)data;
384 MYACCOUNT_DBUG("account list view quit\n");
387 MYACCOUNT_ERROR("myaccount_account_list_quit_cb callback user data is null!!!\n");
391 if(priv->popup != NULL)
393 evas_object_del(priv->popup);
397 myaccount_account_list_free_priv_data(priv);
402 ui_gadget_h ug = priv->ug;
403 error_code = ug_destroy_me(ug);
404 MYACCOUNT_SLOGD("myaccount_account_list_quit_cb callback : return = %d!!!\n",
411 void myaccount_account_list_back_key_cb(void *data, Evas_Object *obj, void *event_info)
413 elm_naviframe_item_pop(obj);
416 static void __myaccount_account_list_addaccount_cb( void *data,
417 Evas_Object *obj, void *event_info )
419 myaccount_appdata *priv = (myaccount_appdata*)data;
420 myaccount_addaccount_create_view(priv);
421 if(priv->popup != NULL)
423 evas_object_del(priv->popup);
428 static char *__myaccount_account_list_gl_label_get(void *data,
429 Evas_Object *obj, const char *part)
431 myaccount_list_priv *account_info_item = (myaccount_list_priv*)data;
432 char domain_name_lower[128] = {0,};
434 if (!account_info_item) {
435 MYACCOUNT_ERROR(" __myaccount_account_list_gl_label_get: Data is NULL\n");
439 if (!strcmp(part, "elm.text.main.left.top")) {
440 myaccount_common_lowercase(account_info_item->domain_name,
443 if (strlen(account_info_item->display_name) > 0)
444 return strdup(account_info_item->display_name);
445 else if (strlen(account_info_item->email_address) > 0)
446 return strdup(account_info_item->email_address);
447 else if (strlen(account_info_item->username) > 0)
448 return strdup(account_info_item->username);
450 return strdup("Unknown");
451 } else if (!strcmp(part, "elm.text.sub.left.bottom")) {
452 if (strlen(account_info_item->capability) <=0 )
453 return strdup(dgettext(MA_UG_NAME, "IDS_MA_BODY_SIGNED_IN"));
455 return strdup(account_info_item->capability);
462 static Evas_Object *__myaccount_account_list_gl_icon_get(void *data,
463 Evas_Object *obj, const char *part)
465 char tempbuf[PATH_MAX];
466 Evas_Object *icon = NULL;
467 int auto_sync_status = -1;
468 myaccount_list_priv *account_info_item = (myaccount_list_priv*)data;
470 Evas_Object *ic = NULL;
472 if (!account_info_item) {
473 MYACCOUNT_ERROR("__myaccount_account_list_gl_icon_get: Data is NULL\n");
476 memset(tempbuf, 0, sizeof(char)*PATH_MAX);
478 if (!strcmp(part, "elm.icon.1")) {
479 if (strlen(account_info_item->icon_path) > 0) {
480 MA_SNPRINTF(tempbuf, sizeof(tempbuf), "%s", account_info_item->icon_path);
482 MA_SNPRINTF(tempbuf, sizeof(tempbuf), "%s", "A01_2_Icon_default.png");
485 ic = elm_layout_add(obj);
486 elm_layout_theme_set(ic, "layout", "list/B/type.2", "default");
488 icon = elm_image_add(obj);
489 if (strstr(tempbuf, "/"))
490 elm_image_file_set(icon, tempbuf, NULL);
492 elm_image_file_set(icon, MA_IMAGE_EDJ_NAME, tempbuf);
494 elm_layout_content_set(ic, "elm.swallow.content", icon);
497 if (!strcmp(part, "elm.icon.2")) {
498 if (account_info_item->sync_status == ACCOUNT_SYNC_NOT_SUPPORT)
500 if (vconf_get_int(VCONFKEY_ACCOUNT_AUTO_SYNC_STATUS_INT,
501 &auto_sync_status) < 0) {
502 MYACCOUNT_ERROR("Fail to getVCONFKEY_ACCOUNT_AUTO_SYNC_STATUS_INT\n");
504 MA_SNPRINTF(tempbuf, sizeof(tempbuf), "%s", "account_icon_syncing.png");
507 MYACCOUNT_DBUG("color:[%s]",color);
508 if(strlen(tempbuf) > 0) {
509 ic = elm_layout_add(obj);
510 elm_layout_theme_set(ic, "layout", "list/C/type.3", "default");
512 icon = elm_image_add(obj);
513 if (strstr(tempbuf, "/"))
514 elm_image_file_set(icon, tempbuf, NULL);
516 elm_image_file_set(icon, MA_IMAGE_EDJ_NAME, tempbuf);
520 ret = ea_theme_object_color_set(icon, color);
521 MYACCOUNT_DBUG("ret[%d]", ret);
523 elm_layout_content_set(ic, "elm.swallow.content", icon);
530 static void _myaccount_ug_account_list_layout_cb(ui_gadget_h ug,
531 enum ug_mode mode, void *priv)
534 myaccount_appdata *ad;
537 MYACCOUNT_ERROR("layout cb error ug=%p, priv=%p\n", ug, priv);
540 ad = (myaccount_appdata*)priv;
541 base = ug_get_layout(ug);
543 MYACCOUNT_ERROR("layout cb base is null\n");
546 case UG_MODE_FRAMEVIEW:
547 elm_object_part_content_set (ad->layout_main, "content", base);
549 case UG_MODE_FULLVIEW:
550 evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND,
552 //elm_win_resize_object_add(ad->win_main, base);
553 evas_object_show(base);
560 static void _myaccount_ug_account_list_result_cb(ui_gadget_h ug,
561 app_control_h app_control, void *priv)
563 //MYACCOUNT_VERBOSE("_myaccount_ug_account_list_result_cb\n");
566 static void _myaccount_ug_account_list_destroy_cb(ui_gadget_h ug,
569 myaccount_appdata *mydata = (myaccount_appdata*)priv;
572 MYACCOUNT_ERROR("destroy cb error ug=%p, priv=%p\n", ug, mydata);
575 myaccount_common_set_item_selected_state(false);
578 MYACCOUNT_SLOGD("_myaccount_ug_account_list_destroy_cb");
580 myaccount_common_handle_notification(NULL);
584 static void __myaccount_accountlist_set_ug_cbs(struct ug_cbs *cbs,
585 myaccount_appdata *priv)
588 MYACCOUNT_ERROR("__myaccount_addaccount_ug_create_email: Invalid param cbs=%p, priv=%p\n",
592 cbs->layout_cb = _myaccount_ug_account_list_layout_cb;
593 cbs->result_cb = _myaccount_ug_account_list_result_cb;
594 cbs->destroy_cb = _myaccount_ug_account_list_destroy_cb;
595 cbs->priv = (void *)priv;
598 static void __myaccount_ug_list_call_ug(void *data, myaccount_list_priv *account)
600 myaccount_appdata *ad = (myaccount_appdata*)data;
601 MyAccountProviderType sp_type;
602 ui_gadget_h ug = NULL;
603 struct ug_cbs cbs = {0,};
604 app_control_h app_control;
605 __attribute__((__unused__)) int ret = APP_CONTROL_ERROR_NONE;
608 MYACCOUNT_ERROR("__myaccount_ug_list_call_ug : account info NULL\n");
612 __myaccount_accountlist_set_ug_cbs(&cbs, ad);
614 sp_type = myaccount_common_get_provider_type(account->package_name);
615 ret = app_control_create(&app_control);
618 // case MYACCOUNT_TYPE_MSN :
619 case MYACCOUNT_TYPE_GOOGLE :
620 case MYACCOUNT_TYPE_OTHER :
621 // case MYACCOUNT_TYPE_FACEBOOK :
622 ret = myaccount_common_launch_application(MYACCOUNT_REQUEST_VIEW,
623 strdup(account->package_name),
624 strdup(account->username),
630 case MYACCOUNT_TYPE_EXCHANGE :
631 ret = myaccount_common_launch_application(MYACCOUNT_REQUEST_VIEW,
632 strdup("activesync-ui"),
633 strdup(account->username),
639 case MYACCOUNT_TYPE_SAMSUNG :
640 ret = myaccount_common_launch_application(MYACCOUNT_REQUEST_VIEW,
641 strdup("com.samsung.samsung-account-front"),
642 strdup(account->username),
648 case MYACCOUNT_TYPE_PICASA :
649 case MYACCOUNT_TYPE_YOUTUBE :
651 ret = myaccount_common_launch_application(MYACCOUNT_REQUEST_VIEW,
652 strdup(account->package_name),
653 strdup(account->username),
662 app_control_destroy(app_control);
666 static void __myaccount_account_list_gl_sel(void *data,
667 Evas_Object *obj, void *event_info)
669 myaccount_appdata *ad = myaccount_get_appdata();
670 if( myaccount_common_get_item_selected_state() ) {
671 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
674 myaccount_common_set_item_selected_state(true);
675 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
677 MYACCOUNT_SLOGD("__myaccount_account_list_gl_sel data=%p, obj=%p, event_info=%p\n",
678 data, obj, event_info);
679 myaccount_list_priv *account = (myaccount_list_priv*)data;
680 MYACCOUNT_SLOGD("__myaccount_account_list_gl_sel : account name : %s\n",
681 account->domain_name);
684 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
686 __myaccount_ug_list_call_ug((myaccount_appdata*)ad, account);
690 static void __myaccount_account_list_item_selected(void *data,
691 Evas_Object *obj, void *event_info)
693 //MYACCOUNT_VERBOSE("__myaccount_account_list_item_selected \n");
696 static void __myaccount_account_list_append_genlist(myaccount_appdata *ad,
699 MYACCOUNT_SLOGD ("\n count received in __myaccount_account_list_append_genlist = %d \n",
701 bool supported = false;
705 for(iter=ad->sorted_account_list;iter!=NULL;iter=g_list_next(iter)) {
706 myaccount_list_priv* tmp = (myaccount_list_priv*)iter->data;
708 if (tmp->secret == ACCOUNT_SECRECY_VISIBLE) {
709 if (ad->capability_filter) {
711 myaccount_list_priv *acc_info = NULL;
714 /* Tizen email exception */
715 if(!strcmp("http://tizen.org/account/capability/tizen_email", ad->capability_filter)){
716 if(tmp->b_tizen_email) {
720 for (siter = acc_info->capablity_list; siter != NULL; siter = g_slist_next(siter)) {
721 myaccount_capability_data *cap_data = (myaccount_capability_data*)siter->data;
723 if (!strcmp(cap_data->type, ad->capability_filter)) {
731 elm_genlist_item_append(ad->account_genlist,
734 ELM_GENLIST_ITEM_NONE,
735 __myaccount_account_list_gl_sel,
740 elm_genlist_item_append(ad->account_genlist,
743 ELM_GENLIST_ITEM_NONE,
744 __myaccount_account_list_gl_sel,
751 myaccount_addaccount_create_view(ad);
756 static void _myaccount_ug_account_gl_realized(void *data, Evas_Object *obj, void *ei)
758 Elm_Object_Item *it = NULL;
762 // char buf[2048]={0,};
763 // char bufdomain[2048]={0,};
766 MYACCOUNT_ERROR("Realized event info is NULL!!! \n");
770 it = (Elm_Object_Item *)ei;
772 total_count = elm_genlist_items_count(obj);
773 index = elm_genlist_item_index_get(it);
775 if(index > 2 && index < total_count)
777 /*Add account items. index 1 and last are the seperators*/
779 myaccount_list_priv *account_info_item = (myaccount_list_priv*)elm_object_item_data_get(it);
781 if(account_info_item){
782 memset(buf, 0, 2048);
783 memset(bufdomain, 0, 2048);
785 if (strlen(account_info_item->domain_name) > 0)
786 g_snprintf(bufdomain, 1024, "Logged into %s with user id ", account_info_item->domain_name);
788 g_snprintf(bufdomain, 1024, "Service unknown user id ");
790 if (strlen(account_info_item->display_name) > 0)
791 g_snprintf(buf, 1024, "%s%s", bufdomain, account_info_item->display_name);
792 else if (strlen(account_info_item->email_address) > 0)
793 g_snprintf(buf, 1024, "%s%s", bufdomain, account_info_item->email_address);
794 else if (strlen(account_info_item->username) > 0)
795 g_snprintf(buf, 1024, "%s%s", bufdomain, account_info_item->username);
797 g_snprintf(buf, 1024, "%sUnknown", account_info_item->domain_name);
799 ao = elm_object_item_access_object_get(it);
800 elm_access_info_set(ao, ELM_ACCESS_INFO, buf);
804 } else if (index == 2) {
805 //ao = elm_object_item_access_object_get(it);
806 //elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, "Turn Auto Sync on or off");
807 } else if (index == 3) {
808 //ao = elm_object_item_access_object_get(it);
809 //elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, "Below is the list of all logged in accounts");
811 /*Remove access for seperators*/
812 //elm_object_item_access_unregister(ei);
817 //MYACCOUNT_INFO("DO NOTHING only one account exist, total_count(%d) index(%d) !!! \n", total_count, index);
820 } else if (index == 2) {
821 elm_object_item_signal_emit(ei, "elm,state,top", "");
822 } else if (index == (total_count-2)) {
823 elm_object_item_signal_emit(ei, "elm,state,bottom", "");
825 elm_object_item_signal_emit(ei, "elm,state,center", "");
830 static Evas_Object *__myaccount_account_list_create_genlist(
831 myaccount_appdata *ad)
833 Evas_Object *genlist;
836 MYACCOUNT_ERROR("__myaccount_account_list_create_genlist returns NULL\n");
840 int account_count = 0;
841 account_count = __myaccount_account_list_populate_account_info(ad);
843 account_list_itc.item_style = "2line.top";
844 account_list_itc.func.text_get = __myaccount_account_list_gl_label_get;
845 account_list_itc.func.content_get = __myaccount_account_list_gl_icon_get;
846 account_list_itc.func.state_get = NULL;
847 account_list_itc.func.del = NULL;
849 ad->account_genlist = genlist = elm_genlist_add(ad->navi_bar);
850 evas_object_smart_callback_add(genlist, "realized", _myaccount_ug_account_gl_realized, NULL);
851 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
852 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
853 elm_genlist_mode_set(genlist, EINA_TRUE);
855 evas_object_smart_callback_add(genlist, "selected",
856 __myaccount_account_list_item_selected,
857 (myaccount_appdata*) ad);
859 __myaccount_account_list_append_genlist(ad, account_count);
864 static void __move_more_ctxpopup(myaccount_appdata *ad)
866 MYACCOUNT_DBUG("__move_more_ctxpopup");
871 elm_win_screen_size_get(ad->win_main, NULL, NULL, &w, &h);
872 int pos = elm_win_rotation_get(ad->win_main);
877 evas_object_move(ad->popup, (w / 2), h);
880 evas_object_move(ad->popup, (h / 2), w);
883 evas_object_move(ad->popup, (h / 2), w);
890 static void __rotate_more_ctxpopup_cb(void *data, Evas_Object *obj, void *event_info)
892 MYACCOUNT_DBUG("__rotate_more_ctxpopup_cb");
893 myaccount_appdata *ad = data;
895 __move_more_ctxpopup(ad);
897 static void _delete_ctxpopup_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
899 MYACCOUNT_DBUG("_delete_toolbar_ctxpopup_cb");
900 myaccount_appdata *ad = data;
901 if (elm_win_wm_rotation_supported_get(ad->win_main)) {
903 evas_object_smart_callback_del(elm_object_top_widget_get(ad->popup), "wm,rotation,changed", __rotate_more_ctxpopup_cb);
907 ea_object_event_callback_del(ad->popup, EA_CALLBACK_BACK, ea_ctxpopup_back_cb);
908 ea_object_event_callback_del(ad->popup, EA_CALLBACK_MORE, ea_ctxpopup_back_cb);
909 evas_object_event_callback_del(ad->popup, EVAS_CALLBACK_DEL, _delete_ctxpopup_cb);
913 static void __create_more_ctxpopup(myaccount_appdata *ad)
915 MYACCOUNT_DBUG("__create_more_ctxpopup");
917 Evas_Object *popup = elm_ctxpopup_add(ad->navi_bar);
920 elm_object_style_set(popup, "more/default");
921 elm_ctxpopup_auto_hide_disabled_set(popup, EINA_TRUE);
922 if (elm_win_wm_rotation_supported_get(ad->win_main)) {
923 evas_object_smart_callback_add(elm_object_top_widget_get(popup), "wm,rotation,changed", __rotate_more_ctxpopup_cb, ad);
925 evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, _delete_ctxpopup_cb, ad);
926 ea_object_event_callback_add(popup, EA_CALLBACK_BACK, ea_ctxpopup_back_cb, popup);
927 ea_object_event_callback_add(popup, EA_CALLBACK_MORE, ea_ctxpopup_back_cb, popup);
929 elm_ctxpopup_item_append(popup, dgettext(MA_UG_NAME,"IDS_PB_BODY_ADD_ACCOUNT"), NULL, __myaccount_account_list_addaccount_cb, ad);
931 elm_ctxpopup_direction_priority_set(popup, ELM_CTXPOPUP_DIRECTION_UP,
932 ELM_CTXPOPUP_DIRECTION_LEFT,
933 ELM_CTXPOPUP_DIRECTION_RIGHT,
934 ELM_CTXPOPUP_DIRECTION_DOWN);
936 __move_more_ctxpopup(ad);
937 evas_object_show(popup);
940 static void __delete_more_cb(void *data)
942 MYACCOUNT_DBUG("__delete_more_cb");
943 myaccount_appdata *ad = data;
945 evas_object_del(ad->popup);
950 static void __more_cb(void *data, Elm_Object_Item *it, const char *emission, const char *source)
952 MYACCOUNT_DBUG("__more_cb");
953 myaccount_appdata *ad = data;
954 __delete_more_cb(data);
955 __create_more_ctxpopup(ad);
958 void myaccount_ug_account_list_create(void *data)
960 myaccount_appdata *ad = data;
961 Evas_Object *genlist = NULL;
965 MYACCOUNT_ERROR("myaccount_ug_account_list_create myaccount_appdata is null\n");
969 layout = elm_layout_add(ad->navi_bar);
970 elm_layout_file_set(layout,
971 "/usr/apps/setting-myaccount-efl/res/edje/setting-myaccount-efl/myaccount.edj",
973 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
974 evas_object_size_hint_align_set( layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
975 edje_object_signal_emit(_EDJ(layout), "elm,state,show,content", "elm");
976 elm_object_style_set(ad->bg, "group_list");
978 evas_object_show(layout);
980 genlist = __myaccount_account_list_create_genlist(ad);
982 elm_object_part_content_set (layout, "accountlist.genlist", genlist);
984 ad->nf_it = elm_naviframe_item_push(ad->navi_bar,
986 "IDS_ST_BODY_ACCOUNT_LIST"),
987 NULL, NULL, layout, NULL);
988 elm_naviframe_item_pop_cb_set(ad->nf_it, myaccount_account_list_quit_cb, (void*)ad);
991 count = myaccount_common_get_account_type_count(ad->capability_filter);
993 MYACCOUNT_DBUG("TOTAL avaiable sp count %d\n", count);
995 ea_object_event_callback_add(ad->navi_bar, EA_CALLBACK_MORE, ea_naviframe_more_cb, NULL);
996 elm_object_item_signal_callback_add(ad->nf_it, "elm,action,more_event", "", __more_cb, ad);
1000 static Evas_Object *__myaccount_account_list_create_bg(Evas_Object *parent)
1002 Evas_Object *bg = elm_bg_add(parent);
1003 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1004 //elm_win_resize_object_add(parent, bg);
1005 evas_object_show(bg);
1009 static Evas_Object *__myaccount_account_list_create_main_layout(
1010 Evas_Object *parent,
1013 Evas_Object *layout;
1015 layout = elm_layout_add(parent);
1016 elm_layout_theme_set(layout, "layout", "application", "default");
1017 evas_object_size_hint_weight_set( layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1018 edje_object_signal_emit(_EDJ(layout), "elm,state,show,indicator", "elm");
1019 edje_object_signal_emit(_EDJ(layout), "elm,state,show,content", "elm");
1020 elm_object_part_content_set ( layout, "elm.swallow.bg", bg);
1022 evas_object_show( layout );
1027 static Evas_Object *__myaccount_account_list_create_navi_layout(
1028 Evas_Object *parent)
1030 Evas_Object *navi_bar;
1032 navi_bar = elm_naviframe_add(parent);
1033 elm_object_part_content_set ( parent, "elm.swallow.content", navi_bar );
1034 evas_object_show(navi_bar);
1039 static void __myaccount_account_list_init_main_view(myaccount_appdata *ad)
1041 //elm_win_indicator_mode_set(ad->win_main, ELM_WIN_INDICATOR_SHOW);
1042 ad->bg = __myaccount_account_list_create_bg(ad->win_main);
1043 ad->layout_main = __myaccount_account_list_create_main_layout(ad->win_main, ad->bg);
1044 // ea_theme_object_style_set(ad->layout_main, EA_THEME_STYLE_DARK);
1045 // ea_theme_object_style_set(ad->layout_main, EA_THEME_STYLE_LIGHT);
1047 ad->base = ad->layout_main;
1050 void myaccount_list_navi_create(myaccount_appdata *ad)
1052 ad->navi_bar = __myaccount_account_list_create_navi_layout(ad->layout_main);
1054 ea_object_event_callback_add(ad->navi_bar, EA_CALLBACK_BACK, myaccount_account_list_back_key_cb, (void*)ad);
1057 void myaccount_list_view_create(myaccount_appdata *priv)
1059 /*struct ug_cbs cbs = {0,};*/
1060 __attribute__((__unused__)) struct ug_cbs cbs = {0,};
1061 cbs.layout_cb = _myaccount_ug_account_list_layout_cb;
1062 cbs.result_cb = _myaccount_ug_account_list_result_cb;
1063 cbs.destroy_cb = _myaccount_ug_account_list_destroy_cb;
1064 cbs.priv = (void *)priv;
1066 MYACCOUNT_DBUG("Account list start\n");
1067 __myaccount_account_list_init_main_view(priv);
1070 void myaccount_list_refresh_item_list(myaccount_appdata *ad)
1075 MYACCOUNT_ERROR("no appdata!\n");
1079 if(!ad->account_genlist) {
1080 MYACCOUNT_ERROR("no genlist!\n");
1084 MYACCOUNT_DBUG("Account list start\n");
1086 elm_genlist_clear(ad->account_genlist);
1088 myaccount_account_list_free_priv_data(ad);
1091 count = __myaccount_account_list_populate_account_info(ad);
1093 __myaccount_account_list_append_genlist(ad, count);