1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
|
/*
* Copyright (c) 2000-2015 Samsung Electronics Co., Ltd All Rights Reserved
*
* PROPRIETARY/CONFIDENTIAL
*
* This software is the confidential and proprietary information of
* SAMSUNG ELECTRONICS ("Confidential Information").
* You shall not disclose such Confidential Information and shall
* use it only in accordance with the terms of the license agreement
* you entered into with SAMSUNG ELECTRONICS.
* SAMSUNG make no representations or warranties about the suitability
* of the software, either express or implied, including but not
* limited to the implied warranties of merchantability, fitness for
* a particular purpose, or non-infringement.
* SAMSUNG shall not be liable for any damages suffered by licensee as
* a result of using, modifying or distributing this software or its derivatives.
*/
#include <app.h>
#include <vconf.h>
#include <app_control.h>
#include <account.h>
#include <account-types.h>
#include <account-error.h>
#include <account_internal.h>
#include "my-account-view.h"
#include "my-account-main.h"
#include "my-account-debug.h"
#include "my-account-util.h"
#include "my-account-ui-widget.h"
static void lang_changed(appdata *ad)
{
if (!ad) {
MA_DEBUG_ERR("lang_changed ### appdata=%p\n", ad);
return ;
}
char* language = NULL;
language = vconf_get_str(VCONFKEY_LANGSET);
if (language) {
char tmp_buf[6] = {0,};
MA_STRNCPY(tmp_buf, language, 6);
MA_MEM_FREE(ad->current_language);
MA_MEM_STRNDUP(ad->current_language, tmp_buf, 6);
}
MA_MEM_FREE(language);
/* To Do: refresh account items */
/* elm_object_item_text_set (ad->nf_it, dgettext(MA_UG_NAME, "IDS_MA_HEADER_ACCOUNTS"));
myaccount_list_refresh_item_list(ugd); */
if (ad->main_genlist) {
/* To Do: title text update */
/* elm_object_item_text_set (ugd->add_nf_it, dgettext(MA_UG_NAME, "IDS_MA_HEADER_ADD_ACCOUNT"));
myaccount_addaccount_refresh_item_list(ugd); */
} else {
MA_DEBUG("lang_changed ### ugd->main_genlist is NULL\n");
}
}
static void __gl_account_list_clicked_cb(void *data, Evas_Object *obj, void *event_info)
{
MA_DEBUG("__gl_account_list_clicked_cb start");
char id_buf[64] = { 0, };
app_control_h service = NULL;
myaccount_account_info *account_info = (myaccount_account_info *)data;
if (account_info == NULL) {
MA_DEBUG_ERR("__gl_account_list_cliecked_cb error, data is NULL");
return;
}
if (event_info == NULL) {
MA_DEBUG_ERR("__gl_account_list_cliecked_cb error, event_info is NULL");
return;
}
elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
app_control_create(&service);
app_control_set_app_id(service, account_info->package_name);
MA_SNPRINTF(id_buf, sizeof(id_buf), "%d", account_info->account_id);
app_control_add_extra_data(service, ACCOUNT_DATA_ID, id_buf);
app_control_set_operation(service, ACCOUNT_OPERATION_VIEW);
app_control_add_extra_data(service, ACCOUNT_DATA_USERNAME, account_info->user_name);
app_control_set_launch_mode(service, APP_CONTROL_LAUNCH_MODE_GROUP);
int ret = app_control_send_launch_request(service, NULL, NULL);
if (ret != APP_CONTROL_ERROR_NONE)
MA_DEBUG_ERR("app_control_send_launch_request fail, ret = %d\n", ret);
app_control_destroy(service);
MA_DEBUG("__gl_account_list_clicked_cb end");
}
/* for item class */
/*
static Evas_Object *__gl_content_get_account_list(void *data, Evas_Object *obj, const char *part)
{
if (!strcmp(part, "elm.icon")) {
Evas_Object *check;
check = elm_check_add(obj);
retv_if(check == NULL, NULL);
elm_access_object_unregister(check);
elm_object_style_set(check, "on&off/list");
evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_propagate_events_set(check, EINA_FALSE);
evas_object_repeat_events_set(check, EINA_TRUE);
return check;
} else {
return NULL;
}
}
*/
/*
static Evas_Object *__gl_content_get_on_off(void *data, Evas_Object *obj, const char *part)
{
if (!strcmp(part, "elm.icon")) {
Evas_Object *check;
check = elm_check_add(obj);
retv_if(check == NULL, NULL);
elm_access_object_unregister(check);
elm_object_style_set(check, "on&off/list");
if (nfc_manager_is_activated())
elm_check_state_set(check, EINA_TRUE);
else
elm_check_state_set(check, EINA_FALSE);
evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_propagate_events_set(check, EINA_FALSE);
evas_object_repeat_events_set(check, EINA_TRUE);
return check;
} else {
return NULL;
}
}
*/
static char *__gl_text_get_account_list_label(void *data, Evas_Object *obj, const char *part)
{
myaccount_account_info *account_info = (myaccount_account_info *)data;
/* char domain_name_lower[128] = {0,}; */
MA_DEBUG("__gl_text_get_account_list_label start");
if (!account_info) {
MA_DEBUG_ERR("__gl_text_get_account_list_label: Data is NULL\n");
return NULL;
}
if (!strcmp(part, "elm.text")) {
/* myaccount_common_lowercase(account_info->domain_name, domain_name_lower); */
MA_DEBUG("__gl_text_get_account_list_label elm.text");
if (strlen(account_info->display_name) > 0)
return strdup(account_info->display_name);
else if (strlen(account_info->email_address) > 0)
return strdup(account_info->email_address);
else if (strlen(account_info->user_name) > 0)
return strdup(account_info->user_name);
else
return strdup("Unknown");
} else if (!strcmp(part, "elm.text.1")) {
MA_DEBUG("__gl_text_get_account_list_labeli elm.text.1");
if (strlen(account_info->service_name) > 0)
return strdup(account_info->service_name);
/*else if (strlen(account_info->capability) > 0)
return strdup(account_info->capability);
else
return strdup(dgettext(MA_UG_NAME, "IDS_MA_BODY_SIGNED_IN")); */
else
return strdup("Signed in.");
} else {
return NULL;
}
}
int _myaccount_release_capability_data(myaccount_capability_data *data)
{
if (!data)
return -1;
MA_MEM_FREE(data->type);
MA_MEM_FREE(data);
return 0;
}
int _myaccount_release_glist_capability_data(GList *list)
{
if (!list)
return -1;
GList* iter;
for (iter = list; iter != NULL; iter = g_list_next(iter)) {
myaccount_capability_data *capability = (myaccount_capability_data *)iter->data;
_myaccount_release_capability_data(capability);
}
g_list_free(list);
list = NULL;
return 0;
}
int myaccount_release_account_info(myaccount_account_info *data)
{
if (!data)
return -1;
_myaccount_release_glist_capability_data(data->capability_list);
MA_MEM_FREE(data);
return 0;
}
static void __gl_account_list_del(void *data, Evas_Object *obj)
{
myaccount_account_info *account = (myaccount_account_info *)data;
myaccount_release_account_info(account);
}
static char *__myaccount_get_capablity_string_value(const char* capability_type)
{
if (!strcmp(capability_type, "http://tizen.org/account/capability/contact"))
return dgettext(MA_UG_NAME, "IDS_PB_TAB_CONTACTS");
else if (!strcmp(capability_type, "http://tizen.org/account/capability/calendar"))
return dgettext("sys_string", "IDS_COM_BODY_S_PLANNER");
else if (!strcmp(capability_type, "http://tizen.org/account/capability/photo"))
return dgettext(MA_UG_NAME, "IDS_COM_BODY_GALLERY");
else if (!strcmp(capability_type, "http://tizen.org/account/capability/video"))
return dgettext(MA_UG_NAME, "IDS_ST_BODY_VIDEOS");
else if (!strcmp(capability_type, "http://tizen.org/account/capability/email"))
return dgettext(MA_UG_NAME, "IDS_COM_BODY_EMAIL");
else if (!strcmp(capability_type, "http://tizen.org/account/capability/music"))
return dgettext("sys_string", "IDS_COM_BODY_MUSIC");
else if (!strcmp(capability_type, "http://tizen.org/account/capability/message"))
return dgettext(MA_UG_NAME, "IDS_COM_BODY_MESSAGES");
else
return NULL; /* return dgettext(MA_UG_NAME, "IDS_COM_POP_UNKNOWN"); */
}
static myaccount_account_info* __myaccount_create_account_info()
{
myaccount_account_info* account_info = NULL;
account_info = (myaccount_account_info*)calloc(1, sizeof(myaccount_account_info));
retv_if(!account_info, NULL);
return account_info;
}
void myaccount_common_lowercase(char *src, char *dest)
{
int i;
int src_len = 0;
if (!src || !dest) {
MA_DEBUG_ERR("myaccount_common_lowercase src=%p, dest=%p\n", src, dest);
return;
}
src_len = strlen(src);
for (i = 0; i < src_len; i++)
dest[i] = tolower(src[i]);
dest[i] = '\0';
}
void myaccount_common_get_icon_by_name(char *domain_name, char *icon_path)
{
if (!domain_name) {
MA_DEBUG_ERR("\n !!! domain_name is NULL \n");
return;
}
char tmp_domain_name[64] = { 0, };
myaccount_common_lowercase(domain_name, tmp_domain_name);
if (!icon_path) {
MA_DEBUG_ERR("\n !!! icon_path is NULL \n");
return;
}
MA_SNPRINTF(icon_path, 1024, "%s", "A01_2_Icon_default.png");
}
bool __myaccount_get_capablity_cb(const char* capability_type, account_capability_state_e capability_state, void *user_data)
{
myaccount_account_info *account_info = (myaccount_account_info*)user_data;
retv_if(!account_info, false);
myaccount_capability_data *cap_data = (myaccount_capability_data*)malloc(sizeof(myaccount_capability_data));
if (!cap_data) {
MA_DEBUG_ERR("malloc failed\n");
return true;
}
memset(cap_data, 0, sizeof(myaccount_capability_data));
cap_data->type = strdup(capability_type);
cap_data->state = capability_state;
account_info->capability_list = g_list_append(account_info->capability_list, (gpointer)cap_data);
if (capability_state == ACCOUNT_CAPABILITY_ENABLED) {
char *capability_textbuf = account_info->capability;
char *capability_string = NULL;
capability_string = __myaccount_get_capablity_string_value(capability_type);
if (capability_string != NULL) {
if (strlen(capability_textbuf) > 0) {
char *temp2 = strdup(capability_textbuf);
if (!temp2) {
MA_DEBUG_ERR("strdup returns NULL\n");
return false;
}
MA_SNPRINTF(capability_textbuf, 127, "%s, %s", temp2, capability_string);
MA_MEM_FREE(temp2);
} else {
MA_SNPRINTF(capability_textbuf, 127, "%s%s", capability_textbuf, capability_string);
}
}
}
return true;
}
void myaccount_accountlist_set_service_name(myaccount_account_info* account_info, appdata *ad)
{
MA_DEBUG("myaccount_accountlist_set_service_name() start");
if (ad == NULL)
return;
GList* iter;
for (iter = ad->account_app_list; iter != NULL; iter = g_list_next(iter)) {
myaccount_account_app_info* account_app_info = (myaccount_account_app_info*)iter->data;
MA_DEBUG("iter start");
if (!strcmp(account_app_info->package_name, account_info->package_name)) {
MA_DEBUG("find same package_name");
MA_STRNCPY(account_info->service_name, account_app_info->service_name, sizeof(account_info->service_name));
break;
}
MA_DEBUG("iter end");
}
MA_DEBUG("myaccount_accountlist_set_service_name() end");
}
bool __myaccount_get_account_list_info_cb(account_h account, void *user_data)
{
int ret = -1;
int id = -1;
appdata *ad = (appdata *)user_data;
/* GList **account_info_list = (GList **)user_data; */
myaccount_account_info *account_info = NULL;
char *tmp_str = NULL;
account_secrecy_state_e secret = -1;
MA_DEBUG("__myaccount_get_account_list_info_cb() start");
retv_if(!account, false);
account_info = __myaccount_create_account_info();
retv_if(!account_info, false);
ret = account_get_account_id(account, &id);
if (ret != ACCOUNT_ERROR_NONE)
MA_DEBUG_ERR("account_get_account_id: Failed \n");
else if (id > 0)
account_info->account_id = id;
ret = account_get_user_name(account, &tmp_str);
if (ret != ACCOUNT_ERROR_NONE)
MA_DEBUG_ERR("account_get_user_name: Failed \n");
else if (tmp_str && strlen(tmp_str))
MA_STRNCPY(account_info->user_name, tmp_str, sizeof(account_info->user_name));
MA_MEM_FREE(tmp_str);
ret = account_get_display_name(account, &tmp_str);
if (ret != ACCOUNT_ERROR_NONE)
MA_DEBUG_ERR("account_get_display_name: Failed \n");
else if (tmp_str && strlen(tmp_str))
MA_STRNCPY(account_info->display_name, tmp_str, sizeof(account_info->display_name));
MA_MEM_FREE(tmp_str);
ret = account_get_email_address(account, &tmp_str);
if (ret != ACCOUNT_ERROR_NONE)
MA_DEBUG_ERR("account_get_email_address: Failed \n");
else if (tmp_str && strlen(tmp_str))
MA_STRNCPY(account_info->email_address, tmp_str, sizeof(account_info->email_address));
MA_MEM_FREE(tmp_str);
ret = account_get_package_name(account, &tmp_str);
if (ret != ACCOUNT_ERROR_NONE)
MA_DEBUG_ERR("account_get_package_name: Failed \n");
else if (tmp_str && strlen(tmp_str))
MA_STRNCPY(account_info->package_name, tmp_str, sizeof(account_info->package_name));
MA_MEM_FREE(tmp_str);
ret = account_get_secret(account, &secret);
if (ret != ACCOUNT_ERROR_NONE)
MA_DEBUG_ERR("account_get_secret: Failed \n");
else if (secret >= ACCOUNT_SECRECY_INVALID && secret < ACCOUNT_SECRECY_MAX)
account_info->secret = secret;
else
account_info->secret = ACCOUNT_SECRECY_INVALID;
ret = account_get_domain_name(account, &tmp_str);
if (ret != ACCOUNT_ERROR_NONE)
MA_DEBUG_ERR("account_get_domain_name: Failed \n");
else if (tmp_str && strlen(tmp_str))
MA_STRNCPY(account_info->domain_name, tmp_str, sizeof(account_info->domain_name));
MA_MEM_FREE(tmp_str);
ret = account_get_icon_path(account, &tmp_str);
if (ret != ACCOUNT_ERROR_NONE) {
MA_DEBUG_ERR("account_get_icon_path: Failed \n");
} else if (tmp_str && strlen(tmp_str)) {
MA_STRNCPY(account_info->icon_path, tmp_str, sizeof(account_info->icon_path));
} else {
account_type_h account_type = NULL;
ret = account_type_create(&account_type);
if (ret == ACCOUNT_ERROR_NONE) {
ret = account_type_query_by_app_id((const char*)account_info->package_name, &account_type);
if (ret == ACCOUNT_ERROR_NONE) {
char* provider_icon = NULL;
ret = account_type_get_icon_path(account_type, &provider_icon);
if (ret != ACCOUNT_ERROR_NONE) {
MA_DEBUG_ERR("account provider icon get Failed \n");
} else if (provider_icon && strlen(provider_icon)) {
MA_STRNCPY(account_info->icon_path, provider_icon, sizeof(account_info->icon_path));
} else {
MA_DEBUG("account provider icon is not set \n");
}
MA_MEM_FREE(provider_icon);
}
ret = account_type_destroy(account_type);
if (ret != ACCOUNT_ERROR_NONE)
MA_DEBUG_ERR("type_destroy destroy Failed \n");
}
}
MA_MEM_FREE(tmp_str);
if (!strlen(account_info->icon_path))
myaccount_common_get_icon_by_name(account_info->domain_name , account_info->icon_path);
ret = account_get_sync_support(account, (account_sync_state_e *)&(account_info->sync_status));
if (ret != ACCOUNT_ERROR_NONE)
MA_DEBUG_ERR("account_get_sync_support: Failed \n");
ret = account_get_capability_all(account, __myaccount_get_capablity_cb, (void *)account_info);
if (ret != ACCOUNT_ERROR_NONE)
MA_DEBUG_ERR("account_get_capability: Failed \n");
myaccount_accountlist_set_service_name(account_info, ad);
/* No need to sort, sort as the order user register */
/* Left below sorting value(service_sname) for future use */
/* MA_SNPRINTF(account_info->service_sname, sizeof(account_info->service_sname), "%s", "3_"); */
ad->account_list = g_list_append(ad->account_list, (void*)account_info);
MA_DEBUG("__myaccount_get_account_list_info_cb() end");
return true;
}
void __myaccount_genlist_account_list_item_append(appdata *ad, Evas_Object *genlist)
{
MA_DEBUG("__myaccount_genlist_account_list_item_append() start");
GList* iter;
for (iter = ad->account_list; iter != NULL; iter = g_list_next(iter)) {
myaccount_account_info* tmp = (myaccount_account_info*)iter->data;
MA_DEBUG("iter start");
if (tmp->secret == ACCOUNT_SECRECY_VISIBLE) {
MA_DEBUG("into ACCOUNT_SECRECY_VISIBLE");
Elm_Genlist_Item_Class *itc_account = NULL;
Elm_Object_Item *item_account = NULL;
itc_account = elm_genlist_item_class_new();
itc_account->item_style = "2text";
itc_account->func.text_get = __gl_text_get_account_list_label;
itc_account->func.del = __gl_account_list_del;
item_account = elm_genlist_item_append(genlist, itc_account, tmp, NULL, ELM_GENLIST_ITEM_NONE, __gl_account_list_clicked_cb, tmp);
ad->item_list_account = g_list_append(ad->item_list_account, (void*)item_account);
elm_genlist_item_class_free(itc_account);
}
MA_DEBUG("iter end");
}
MA_DEBUG("__myaccount_genlist_account_list_item_append() end");
}
static char *__gl_text_get_registered_account_list_title(void *data, Evas_Object *obj, const char *part)
{
if (!strcmp(part, "elm.text"))
return strdup(dgettext(MA_UG_NAME, "IDS_MA_HEADER_ACCOUNTS"));
else
return NULL;
}
static char *__gl_text_get_add_account_title(void *data, Evas_Object *obj, const char *part)
{
if (!strcmp(part, "elm.text"))
return strdup(dgettext(MA_UG_NAME, "WDS_MA_HEADER_ADD_ACCOUNTS_ABB"));
else
return NULL;
}
static char *__gl_text_get_add_account_label(void *data, Evas_Object *obj, const char *part)
{
myaccount_account_app_info *account_app_info = (myaccount_account_app_info *)data;
/* char domain_name_lower[128] = {0,}; */
MA_DEBUG("__gl_text_get_add_account_label start");
if (!account_app_info) {
MA_DEBUG_ERR("__gl_text_get_add_account_label: Data is NULL\n");
return NULL;
}
if (!strcmp(part, "elm.text")) {
/* myaccount_common_lowercase(account_info->domain_name, domain_name_lower); */
MA_DEBUG("__gl_text_get_add_account_label elm.text");
return elm_entry_utf8_to_markup(account_app_info->service_name);
} else
return NULL;
}
static void __gl_add_account_del(void *data, Evas_Object *obj)
{
myaccount_account_app_info *account_app = (myaccount_account_app_info *)data;
MA_MEM_FREE(account_app);
/* To Do : ad->account_app_list = NULL; */
}
static void __gl_add_account_clicked_cb(void *data, Evas_Object *obj, void *event_info)
{
MA_DEBUG("__gl_add_account_clicked_cb start");
app_control_h service;
myaccount_account_app_info *account_app_info = (myaccount_account_app_info *)data;
if (account_app_info == NULL) {
MA_DEBUG_ERR("__gl_add_account_cliecked_cb error, data is NULL");
return;
}
if (event_info == NULL) {
MA_DEBUG_ERR("__gl_add_account_cliecked_cb error, data is NULL");
return;
}
elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
app_control_create(&service);
app_control_set_app_id(service, account_app_info->package_name);
app_control_set_operation(service, ACCOUNT_OPERATION_SIGNIN);
app_control_set_launch_mode(service, APP_CONTROL_LAUNCH_MODE_GROUP);
int ret = app_control_send_launch_request(service, NULL, NULL);
if (ret != APP_CONTROL_ERROR_NONE)
MA_DEBUG_ERR("app_control_send_launch_request fail, ret = %d\n", ret);
app_control_destroy(service);
MA_DEBUG("__gl_add_account_clicked_cb end");
}
void __myaccount_genlist_add_account_item_append(appdata *ad, Evas_Object *genlist)
{
MA_DEBUG("__myaccount_genlist_add_account_item_append() start");
GList* iter;
for (iter = ad->account_app_list; iter != NULL; iter = g_list_next(iter)) {
myaccount_account_app_info* tmp = (myaccount_account_app_info*)iter->data;
MA_DEBUG("iter start");
Elm_Genlist_Item_Class *itc_account_app = NULL;
Elm_Object_Item *item_account_app = NULL;
itc_account_app = elm_genlist_item_class_new();
itc_account_app->item_style = "1text";
itc_account_app->func.text_get = __gl_text_get_add_account_label;
itc_account_app->func.del = __gl_add_account_del;
item_account_app = elm_genlist_item_append(genlist, itc_account_app, tmp, NULL, ELM_GENLIST_ITEM_NONE, __gl_add_account_clicked_cb, tmp);
ad->item_list_account = g_list_append(ad->item_list_account, (void*)item_account_app);
elm_genlist_item_class_free(itc_account_app);
MA_DEBUG("iter end");
}
MA_DEBUG("__myaccount_genlist_add_account_item_append() end");
}
static myaccount_account_app_info* __myaccount_create_account_app_info()
{
myaccount_account_app_info* account_app_info = NULL;
account_app_info = (myaccount_account_app_info*)calloc(1, sizeof(myaccount_account_app_info));
retv_if(!account_app_info, NULL);
memset(account_app_info, 0, sizeof(myaccount_account_app_info));
return account_app_info;
}
bool myaccount_add_account_by_package_name_cb(account_h account, void *user_data)
{
return false;
}
static bool __myaccount_get_account_app_info_cb(account_type_h account_type, void *user_data)
{
appdata *ad = (appdata *)user_data;
char* type_buf = NULL;
int type_int = -1, ret = -1;
myaccount_account_app_info* app_info = NULL;
if (ad == NULL)
MA_DEBUG_ERR("app data is null\n");
if (account_type == NULL) {
MA_DEBUG_ERR(" account type handle is NULL \n");
return FALSE;
}
app_info = __myaccount_create_account_app_info();
if (app_info == NULL) {
MA_DEBUG_ERR(" app_info is NULL \n");
return FALSE;
}
ret = account_type_get_app_id(account_type, &type_buf);
if (ret == ACCOUNT_ERROR_NONE) {
if (type_buf) {
MA_STRNCPY(app_info->package_name, type_buf, sizeof(app_info->package_name));
} else {
MA_DEBUG_ERR("No appid available\n");
}
} else {
MA_DEBUG_ERR("account_type_get_app_id return(%x)\n", ret);
}
MA_MEM_FREE(type_buf);
ret = account_type_get_icon_path(account_type, &type_buf);
if (ret == ACCOUNT_ERROR_NONE) {
if (type_buf) {
MA_STRNCPY(app_info->icon_path, type_buf, sizeof(app_info->icon_path));
} else {
MA_DEBUG_ERR("No icon path available\n");
}
} else {
MA_DEBUG_ERR("account_type_get_app_id return(%x)\n", ret);
}
MA_MEM_FREE(type_buf);
char* provider_name = NULL;
if (ad && ad->current_language) {
if (!strcmp(ad->current_language, "en_US"))
ret = account_type_get_label_by_locale(account_type, "en_GB", &provider_name);
else
ret = account_type_get_label_by_locale(account_type, ad->current_language, &provider_name);
}
if (ret != ACCOUNT_ERROR_NONE) {
/* fallback scenario */
ret = account_type_get_label_by_locale(account_type, "default", &provider_name);
if (ret != ACCOUNT_ERROR_NONE) {
MA_DEBUG("No service name(%s)\n", app_info->package_name);
MA_MEM_FREE(app_info);
return TRUE;
}
}
MA_STRNCPY(app_info->service_name, provider_name, sizeof(app_info->service_name));
MA_MEM_FREE(provider_name);
/* Left below sorting value(service_sname) for future use */
/* MA_SNPRINTF(app_info->service_sname, sizeof(app_info->service_sname), "%s%s", SORT_PRIOR_3, app_info->service_name); */
account_type_get_multiple_account_support(account_type, &type_int);
app_info->multiple_account_support = type_int;
if (type_int == FALSE
&& account_query_account_by_package_name(myaccount_add_account_by_package_name_cb, app_info->package_name, NULL) == ACCOUNT_ERROR_NONE) {
MA_MEM_FREE(app_info);
return TRUE;
}
if (ad == NULL) {
MA_MEM_FREE(app_info);
return FALSE;
}
ad->account_app_list = g_list_append(ad->account_app_list, (void*)app_info);
return TRUE;
}
static char *__gl_text_get_no_content_label(void *data, Evas_Object *obj, const char *part)
{
MA_DEBUG("__gl_text_get_no_content_label start");
if (!strcmp(part, "elm.text")) {
MA_DEBUG("__gl_text_get_no_content_label elm.text");
return strdup(dgettext(MA_UG_NAME, "IDS_MA_NPBODY_NO_ACCOUNT_PROVIDER_APPS_INSTALLED"));
} else {
return NULL;
}
MA_DEBUG("__gl_text_get_no_content_label end");
}
void __myaccount_genlist_no_content_item_append(appdata *ad, Evas_Object *genlist)
{
MA_DEBUG("__myaccount_genlist_no_content_item_append() start");
Elm_Genlist_Item_Class *itc_no_content = NULL;
Elm_Object_Item *item_no_content = NULL;
itc_no_content = elm_genlist_item_class_new();
itc_no_content->item_style = "1text";
itc_no_content->func.text_get = __gl_text_get_no_content_label;
item_no_content = elm_genlist_item_append(genlist, itc_no_content, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
elm_genlist_item_class_free(itc_no_content);
ad->item_no_content = item_no_content;
MA_DEBUG("__myaccount_genlist_no_content_item_append() end");
}
int _myaccount_get_accounts_total_count(void)
{
int account_cnt = -1;
int ret = account_get_total_count_from_db_ex(&account_cnt);
if (ret != ACCOUNT_ERROR_NONE) {
MA_DEBUG_ERR("myaccount account_get_total_count_from_db_ex fail error=[%d]", ret);
} else {
if (account_cnt > 0)
MA_DEBUG("myaccount account_cnt > 0, count = [%d]", account_cnt);
else if (account_cnt <= 0)
MA_DEBUG("myaccount account_cnt <= 0, count = [%d]", account_cnt);
}
return account_cnt;
}
static Eina_Bool naviframe_pop_cb(void *data, Elm_Object_Item *it)
{
appdata *ad = data;
int account_cnt = _myaccount_get_accounts_total_count();
if (account_cnt != previous_cnt) {
MA_DEBUG("account_cnt is changed from [%d]", previous_cnt);
_myaccount_view_main_create(ad);
elm_win_activate(ad->main_win);
}
return EINA_TRUE;
}
void __create_genlist_add_account(void *data, Evas_Object *obj, void *event_info)
{
appdata *ad = data;
/* set account mode as adding accounts */
ad->current_view = VIEW_ADD_ACCOUNTS;
ad->mode = MYACCOUNT_ADD_ACCOUNT_MODE;
Evas_Object *genlist;
Evas_Object *circle_obj;
Elm_Genlist_Item_Class *itc_title, *itc_padding;
/* make genlist */
genlist = elm_genlist_add(ad->navi_frame);
/* set genlist property */
elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
circle_obj = eext_circle_object_genlist_add(genlist, ad->circle_surface);
eext_circle_object_genlist_scroller_policy_set(circle_obj, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
eext_rotary_object_event_activated_set(circle_obj, EINA_TRUE);
/* create genlist class + */
itc_title = elm_genlist_item_class_new();
itc_title->item_style = "title";
itc_title->func.text_get = __gl_text_get_add_account_title;
elm_genlist_item_append(genlist, itc_title, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
elm_genlist_item_class_free(itc_title);
/* To Do : free account_app_list */
ad->account_app_list = NULL;
account_type_foreach_account_type_from_db(__myaccount_get_account_app_info_cb, ad);
if (ad->account_app_list == NULL)
__myaccount_genlist_no_content_item_append(ad, genlist);
else
__myaccount_genlist_add_account_item_append(ad, genlist);
itc_padding = elm_genlist_item_class_new();
itc_padding->item_style = "padding";
elm_genlist_item_append(genlist, itc_padding, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
elm_genlist_item_class_free(itc_padding);
evas_object_show(genlist);
elm_naviframe_item_push(ad->navi_frame, dgettext(MA_UG_NAME, "WDS_MA_HEADER_ADD_ACCOUNTS_ABB"), NULL, NULL, genlist, "empty");
elm_naviframe_item_pop_cb_set(ad->navi_frame, naviframe_pop_cb, ad);
}
static Evas_Object *__create_genlist_account_list(void *data)
{
appdata *ad = data;
/* set account mode as showing account list */
ad->current_view = VIEW_MAIN;
ad->mode = MYACCOUNT_ACCOUNT_LIST_MODE;
Evas_Object *genlist;
Evas_Object *circle_obj;
Evas_Object *add_button;
Elm_Genlist_Item_Class *itc_title, *itc_padding;
/* make genlist */
genlist = elm_genlist_add(ad->navi_frame);
/* set genlist property */
elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
circle_obj = eext_circle_object_genlist_add(genlist, ad->circle_surface);
eext_circle_object_genlist_scroller_policy_set(circle_obj, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
eext_rotary_object_event_activated_set(circle_obj, EINA_TRUE);
/* create genlist class */
itc_title = elm_genlist_item_class_new();
itc_title->item_style = "title";
itc_title->func.text_get = __gl_text_get_registered_account_list_title;
elm_genlist_item_append(genlist, itc_title, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
elm_genlist_item_class_free(itc_title);
/* get account app info */
account_type_foreach_account_type_from_db(__myaccount_get_account_app_info_cb, ad);
/* To Do : free account_list */
ad->account_list = NULL;
account_foreach_account_from_db(__myaccount_get_account_list_info_cb, ad);
__myaccount_genlist_account_list_item_append(ad, genlist);
itc_padding = elm_genlist_item_class_new();
itc_padding->item_style = "padding";
elm_genlist_item_append(genlist, itc_padding, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
elm_genlist_item_class_free(itc_padding);
/* add button "ADD" */
elm_layout_theme_set(genlist, "layout", "bottom_button", "default");
add_button = elm_button_add(genlist);
elm_object_style_set(add_button, "bottom");
elm_object_text_set(add_button, dgettext(MA_UG_NAME, "WDS_MA_ACBUTTON_ADD_M_ACCOUNT_ABB"));
elm_object_part_content_set(genlist, "elm.swallow.button", add_button);
evas_object_smart_callback_add(add_button, "clicked", __create_genlist_add_account, ad);
evas_object_show(genlist);
evas_object_show(add_button);
previous_cnt = _myaccount_get_accounts_total_count();
return genlist;
}
bool _myaccount_view_main_create(void *data)
{
appdata *ad = data;
retv_if(ad == NULL, false);
retv_if(!(ad->mode == MYACCOUNT_ADD_ACCOUNT_MODE || ad->mode == MYACCOUNT_ACCOUNT_LIST_MODE), false);
lang_changed(ad);
/* Draw UI */
ad->main_genlist = __create_genlist_account_list(ad);
elm_naviframe_item_push(ad->navi_frame, dgettext(MA_UG_NAME, "IDS_MA_HEADER_ACCOUNTS"), NULL, NULL, ad->main_genlist, "empty");
return true;
}
|