summaryrefslogtreecommitdiff
path: root/lib/common/include/phone-common.h
blob: 3fbb06d04b1dda6e0bbf6c7f4b2e85a048135654 (plain)
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
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
/*
 * Copyright 2012 Samsung Electronics Co., Ltd
 *
 * Licensed under the Flora License, Version 1.1 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://floralicense.org/license/
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef __PHONE_COMMON_H__
#define __PHONE_COMMON_H__

#include <time.h>
#include <libintl.h>
#include <ui-gadget.h>
#include <contacts.h>
#include <unicode/udat.h>
#include <bundle.h>
#include "phone-ug.h"
#include "phone-path.h"
#include "phone-text.h"
#include "contacts-ug.h"
#include "View.h"

extern "C" int appcore_set_open_cb(int (*cb) (void *), void *data);

#if !defined(LOCALEDIR)
#  define LOCALEDIR "/usr/ug/res/locale"
#endif

#ifndef STRLEN
#define STRLEN(str) (((str) == NULL) ? 0: strlen(str))
#endif

#define PH_TEXT_MAX_LEN 1024
#define PH_TEXT_SHORT_LEN 256
#define CT_EDITFIELD_MAX_CHAR 1000
#define PH_BLOCK_MSG_MAX_LEN 40

#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
#define CONTACTS_LIST_FOREACH(list, record) \
    for(bool success = (contacts_list_get_current_record_p(list, &record) == CONTACTS_ERROR_NONE); \
            success; \
            success = ( \
                    (contacts_list_next(list) == CONTACTS_ERROR_NONE) \
                 && (contacts_list_get_current_record_p(list, &record) == CONTACTS_ERROR_NONE) \
            ) \
        )

#define MSG_COMPOSER_UG "msg-composer-efl"
#define MYFILES_UG "myfile-efl"
#define VIBRATION_UG "setting-profile-efl"
#define ACCOUNT_UG "setting-myaccount-efl"
#define IMG_VIEWER_UG "image-viewer-efl"
#define GALLERY_UG "gallery-efl"
#define BLUETOOTH_UG "setting-bluetooth-efl"
#define WIFI_DIRECT_UG "fileshare-efl"
#define CALL_SETTINGS_UG "setting-call-efl"
#define CONTACTS_SETTINGS_UG "contacts-settings-efl"

#define EMAIL_COMPOSER_PKG "email-composer-efl"
#define VOICECALL_PKG "org.tizen.call"
#define VIDEOCALL_PKG "org.tizen.vtmain"
#define DIALER_PKG "org.tizen.phone"
#define CONTACTS_VIEWER_PKG "org.tizen.contacts-viewer"
#define BROWSER_UI_PKG "org.tizen.browser"

#define SETTING_MFC_PATH "/opt/usr/ug/data/ug-phone/mfc_option"
#define VIEW_MODE_PATH "/opt/usr/ug/data/ug-phone/view_mode"

#define CT_OPERATION_SOCIAL_ADD "http://tizen.org/appcontrol/operation/social/add"
#define CT_OPERATION_SOCIAL_EDIT "http://tizen.org/appcontrol/operation/social/edit"
#define CT_OPERATION_SOCIAL_CHOOSE "http://tizen.org/appcontrol/operation/social/choose"
#define CT_OPERATION_SOCIAL_PICK "http://tizen.org/appcontrol/operation/social/pick"
#define CT_OPERATION_SOCIAL_VIEW "http://tizen.org/appcontrol/operation/social/view"
#define CT_OPERATION_VIEW "http://tizen.org/appcontrol/operation/view"

#define CT_OPERATION_ITEM_TYPE "http://tizen.org/appcontrol/data/social/item_type"
#define CT_OPERATION_PHONE "http://tizen.org/appcontrol/data/social/phone"
#define CT_OPERATION_EMAIL "http://tizen.org/appcontrol/data/social/email"
#define CT_OPERATION_URL "http://tizen.org/appcontrol/data/social/url"
#define CT_OPERATION_ITEM_ID "http://tizen.org/appcontrol/data/social/item_id"
#define CT_OPERATION_RESULT_TYPE "http://tizen.org/appcontrol/data/social/result_type"
#define CT_OPERATION_PATH "http://tizen.org/appcontrol/data/path"
#define CT_OPERATION_RETURN_RESULT "http://tizen.org/appcontrol/data/social/return_result"
#define CT_OPERATION_SELECTION_MODE "http://tizen.org/appcontrol/data/selection_mode"

#define CT_OPERATION_ITEM_TYPE_PERSON "person"
#define CT_OPERATION_ITEM_TYPE_CONTACT "contact"
#define CT_OPERATION_SELECTION_MODE_SINGLE "single"
#define CT_OPERATION_SELECTION_MODE_MULTIPLE "multiple"
#define CT_OPERATION_RESULT_TYPE_PHONE "phone"
#define CT_OPERATION_RESULT_TYPE_EMAIL "email"
#define CT_OPERATION_RESULT_TYPE_ITEM_ID "item_id"
#define CT_OPERATION_RESULT_TYPE_VCARD "vcard"

#define CT_GROUP_INDEX_TODAY -1
#define CT_GROUP_INDEX_YESTERDAY -2

#define TITLE_TEXT "title,text"
#define BUTTON1 "button1"
#define BUTTON2 "button2"
#define CLICKED "clicked"

const int incorrectId(-1);
const int notRelatedToContactId(0);

typedef enum date_style
{
    PH_LOG_TIME_ONLY,
    PH_LOG_DATE_ONLY,
} date_style;

typedef enum
{
    LOG_TYPE_CALL = 0,
    LOG_TYPE_VIDEO_CALL,
    LOG_TYPE_SMS_MESSAGE,
    LOG_TYPE_MMS_MESSAGE,
    LOG_TYPE_MAX
} Log_Type;

typedef enum
{
    LOG_ACTION_DIALLED = 0,
    LOG_ACTION_MISSED,
    LOG_ACTION_RECEIVED,
    LOG_ACTION_REJECTED,
    LOG_ACTION_BLOCKED,
    LOG_ACTION_MAX
} Log_Action;

enum
{
    CTTEXT_TYPE_CUSTOM,
    CTTEXT_TYPE_MOBILE,
    CTTEXT_TYPE_HOME,
    CTTEXT_TYPE_WORK,
    CTTEXT_TYPE_FAX_HOME,
    CTTEXT_TYPE_FAX_WORK,
    CTTEXT_TYPE_ASSISTANT,
    CTTEXT_TYPE_PAGER,
    CTTEXT_TYPE_OTHER,
    CTTEXT_TYPE_TELEPHONE,
    CTTEXT_TYPE_FAX,
    CTTEXT_TYPE_CAR,
    CTTEXT_TYPE_HOME2,
    CTTEXT_TYPE_WORK2,
    CTTEXT_TYPE_COMPANY_MAIN,
    CTTEXT_TYPE_RADIO,
};
//CT_GET_TEXT_NUM_TYPE

enum
{
    CT_VIEW_DETAIL,
    CT_VIEW_INPUT,
    CT_VIEW_ETC,
};

enum
{
    CT_LIST_NORMAL = 0x00,
    CT_LIST_NORMAL_CONTACT = 0x01,
    CT_LIST_NORMAL_FAVORITE = 0x02,
    CT_LIST_NORMAL_MEMBER = 0x03,
    CT_LIST_NORMAL_SDN = 0x04,

    CT_LIST_SINGLE = 0x30,
    CT_LIST_SINGLE_LINK = 0x31,
    CT_LIST_SINGLE_RELATION = 0x32,

    CT_LIST_SINGLE_UG = 0x50,

    CT_LIST_MULTI = 0x70,
    CT_LIST_MULTI_DELETE = 0x71,
    CT_LIST_MULTI_ADD_MEMBER = 0x72,
    CT_LIST_MULTI_REMOVE_MEMBER = 0x73,
    CT_LIST_MULTI_ADD_FAVORITE = 0x74,
    CT_LIST_MULTI_REMOVE_FAVORITE = 0x75,
    CT_LIST_MULTI_EXPORT_TO_SIM = 0x76,
    CT_LIST_MULTI_EXPORT_TO_VCARD = 0x77,
    CT_LIST_MULTI_IMPORT_FROM_SIM = 0x78,
    CT_LIST_MULTI_IMPORT_FROM_VCARD = 0x79,
    CT_LIST_MULTI_RECIPIENT_MESSAGE_INGROUP = 0x7A,
    CT_LIST_MULTI_RECIPIENT_EMAIL_INGROUP = 0x7B,
    CT_LIST_MULTI_SHARE_MESSAGE = 0x7C,
    CT_LIST_MULTI_SHARE_EMAIL = 0x7D,
    CT_LIST_MULTI_SHARE_BT = 0x7E,
    CT_LIST_MULTI_REORDER_FAVORITE = 0x7F,

    CT_LIST_MULTI_UG = 0xA0,
};

enum
{
    CTUG_MSG_INVALID = 0,
    CTUG_MSG_KEY_END = 1,
};

struct opq_msg_svc_s;
typedef struct opq_msg_svc_s* msg_handle_t;

typedef void* PTHREAD_FN;

/**
 * A callback that used by filling list-control specified inside of passed data-param.
 * @param data that contains a reference to list-control to be filled
 * @param list a list of contact-id in contacts-db
 * @param cnt is a size of list.
 */
typedef void (*ct_select_result_cb)(void *data, int *list, int cnt);

typedef void (*ct_contact_add_cb)(Evas_Object *win, Evas_Object *navi, int cnt);
typedef void (*ct_change_name_cb)(void *data, char *str);
typedef void (*selectall_changed_cb)(void *data, Eina_Bool checked);
typedef void (*ct_list_navi_item_update_fn)(void *data);
typedef void (*ct_group_rename_update_cb)(void *data, bool changed);
typedef void (*ct_person_changed_cb)(void *data);
typedef void (*ct_group_input_result_cb)(int grp_id, void *data, bool changed);

typedef struct
{
        Evas_Object *win;
        Evas_Object *navi;
        ui_gadget_h ug;
        int ug_request;
        int ug_cnt_max;
        char *ug_data; // update contact info
} ph_view_info;

typedef struct
{
        int cnt;
        int cnt_checked_total;
        int result;
        bool alive;
        bool completed;
        bool without_cancel_btn;
        pthread_t thread;
        Ecore_Timer *timer;
        Evas_Object *layout;
        Evas_Object *progressbar;
        Evas_Object *popup;

        int *update_ids;
        contacts_list_h update_list;
        bool next_job;
} ph_progress_info;

typedef struct
{
        char *plog_display;
        char *plog_img_path;
        char *plog_number;

        int id;
        int plog_ct_id;
        int plog_num_type;
        int plog_log_time;
        int plog_log_type;
        int plog_duration;

        int grouped_count;
        Eina_Bool checked; //for check genlist
        int group_index; //it's used as group index value.
        int group_base_id;
        Elm_Object_Item *item;

} ph_log_info;

typedef struct
{
        int id;
        char *img_path;
        char *display;
        char *number;
        char* numtype_label;
        int number_type;
        char *normal_name;
} ph_contact_d;

typedef struct
{
        int person_id;
        int id_ret;
        int id_ret_type;
        char *display;
        char *img_path;
        char *number;
        bool img_loaded;
        bool number_loaded;
        Eina_List *contact_list;
        Eina_List *number_list;
        Eina_List *email_list;

        Eina_Bool checked;
        Elm_Object_Item *item;
} ph_favor_info;

typedef struct
{
        char *display;
        char *img_path;
        char *ph_number;
        char *numtype_label;
        int number_type;
        int contact_id;
        int dial_number;
        Eina_Bool is_checked;
} ph_speeddial_info;

struct ug_priv_data
{
        void (*result_cb)(void*, void*);
        void (*destroy_cb)(void*);
        void *cb_param;
};

typedef struct
{
        int position;
        int skipped_count;
        char index[10];
        char prev_index[4];
        Elm_Object_Item *item;
} ct_list_index_data;

typedef struct
{
        void *user_data;
        Evas_Smart_Cb cb;
        char *icon_path;
} ctr_btn_info;

typedef struct
{
        Evas_Object *win;
        Evas_Object *entry;
        Elm_Object_Item *navi_it;
        Elm_Object_Item *btn_op;
        char *name_old;
        void *info;
        ct_group_rename_update_cb result_cb;
        void *fn_data;
} ct_group_edit_data;

typedef struct
{
        int id;
        char *icon_path;
        char *addressbook_name;
        int account_id;
} ct_ab_map;

typedef struct
{
        void *person;
        contacts_record_h contact;
        Elm_Object_Item *item;
        bool img_loaded;
        bool number_loaded;
        Eina_Bool checked;
        char *img_path;
        char *number;
        char *number_display;
        char *display;
        char *status_str;
        char *display_index;
        int id;
        int id_ret;
        int id_ret_type;
        int link_count;
        bool is_in_group;
        bool is_favourite;
        bool phone_number_found;
        int mode_ab;
        Eina_List *addressbook_id_list;

        Eina_List *number_list;
        Eina_List *email_list;
} ct_person_list;

typedef struct : public Common::View
{
        Evas_Object *box;
        Evas_Object *base_layout;
        Evas_Object *content_layout;
        Evas_Object *search_layout;
        Evas_Object *nocontent;
        Evas_Object *searchbar;
        Evas_Object *genlist;
        Evas_Object *fast_index;
        Evas_Object *select_all_layout;
        Elm_Object_Item *count_item;
        Elm_Object_Item *last_sweep_item;
        Elm_Object_Item *search_group_item;
        Evas_Object *ctrl_button;

        Elm_Genlist_Item_Class itcs[5];
        void (*gl_sel)(void *data, Evas_Object *obj, void *event_info);
        void *gl_sel_data;
        void (*edit_sel_update)(void *data);

        char group_index[4];
        Elm_Object_Item *group_item;

        char *ug_data;
        service_h service_operation;

        bool updating;
        bool is_background;
        bool need_update;
        int list_mode; //will be removed.
        int view_id;
        int tab_mode;
        int ug_request;
        int list_op;
        int base_ab;
        int base_ab_mode;
        int base_grp;
        int readed_n;
        int selected_person_id;
        int cnt_list_total;
        int cnt_checked;
        int cnt_max_check;
        int cnt_import_total;
        int cnt_import;
        char *title;
        char *sub_title;
        char *search_str;
        contacts_name_display_order_e order_display;
        int acc_count;
        ct_ab_map *acc_types;

        ct_list_navi_item_update_fn list_navi_item_update_fn;

        contacts_list_h import_list;
        contacts_list_h update_add_list;
        contacts_list_h update_delete_list;
        Eina_List *list;
        Eina_List *list_index;
        Eina_List *list_check_info;
        Eina_List **list_grp_person;
        Eina_List *list_delete_records;
        Eina_List *list_import_records;

        Ecore_Idler *list_idler;
        Ecore_Timer *update_timer;
        Ecore_Timer *update_queue_timer;

        int idx_vcard;
        const char *vcard_path;

        ph_progress_info *p_info;
        ct_select_result_cb select_result_cb;
        ct_contact_add_cb contact_add_cb;
        void *select_result_cb_data;

        int current_rotate;
        int radioGroupValue;
        int personId;
} ct_list_data;

typedef struct : public Common::View
{
        Elm_Object_Item *titem;
        Elm_Object_Item *prev_navi_item;
        Evas_Object *ctrl_button;
        Evas_Object *layout_link;
        Elm_Object_Item *base_info_item;
        Elm_Object_Item *base_item;
        Elm_Object_Item *util_item;
        Elm_Object_Item *number_util_item;

        Evas_Object *genlist;
        Evas_Object *genlist_link;
        Ecore_Idler *idler;

        Elm_Object_Item *link_item;
        Elm_Object_Item *group_item;
        Elm_Object_Item *ringtone_item;
        Elm_Object_Item *vibration_item;

        int order_display;

        Eina_List *list_number;
        Eina_List *list_email;
        Eina_List *list_postal;
        Eina_List *list_relationship;
        Eina_List *list_event;
        Eina_List *list_messenger;
        Eina_List *list_website;
        Eina_List *list_nickname;
        Eina_List *list_note;

        bool updated;
        bool updating;
        bool is_shortcut;
        bool has_detail;
        bool has_input;
        bool ug_detail;
        bool has_number;
        int touch_x;
        int touch_y;
        int base_grp;
        int base_ab;
        int base_ab_mode;
        int view_mode;
        char *base_ab_name;
        char* vcard_path;
        int ug_request;
        int view_create_version;
        service_h service_operation;

        int person_id;
        contacts_record_h person;
        contacts_record_h contact;
        Eina_List *list_contacts;
        Eina_List *list_activity;
        Eina_List *list_unlink;

        void *prev_view_data;
        UDateFormat* formatter;
        Evas_Object *genlist_unlink;
        ph_progress_info *p_info;
        bool only_input;
        bool view_destroying;

        bool touch_block;

} ct_detail_data;

typedef struct : public Common::View
{
        Evas_Object *noc;
        Evas_Object *scroller;
        Evas_Object *history_genlist;
        Evas_Object *ctrl_button;
        Evas_Object* select_all_layout;
        Elm_Object_Item *select_all_item;
        Eina_List *list;
        Ecore_Idler *idler;
        int person_id;
        int list_count;
        int pre_date_type;
        UDateFormat* hformatter[5];
        UDateFormat* formatter;
        int cnt_checked;
        int view_mode;
        bool updated;
        bool updating;
        ph_progress_info *p_info;
} ct_history_data;

typedef struct
{
        Elm_Theme *th;
        Evas_Object *win;
        Evas_Object *navi;
        Evas_Object *layout;
        Evas_Object *activity_genlist;
        Evas_Object *ctrl_button;
        Elm_Object_Item *navi_item;
        Eina_List *list;
        int person_id;
        int pre_date_type;
        UDateFormat* hformatter[5];
        UDateFormat* formatter;
        ct_ab_map *acc_types;
        int acc_cnt;
} ct_activity_data;

typedef struct : public Common::View
{
        Evas_Object *box;
        Evas_Object *scroller;
        Evas_Object *save_button;
        Elm_Object_Item *pre_item;
        Ecore_Event_Handler* win_prop_change;

        bool add_job_title;
        bool add_department;
        bool add_organization;

        Evas_Object *ly_image;
        Evas_Object *ly_basic_info;
        Evas_Object *ly_basic_info_middle_name;
        Evas_Object *ly_basic_info_last_name;
        Evas_Object *ly_basic_info_suffix;
        Evas_Object *ly_basic_info_nickname;
        Evas_Object *ly_basic_info_job_title;
        Evas_Object *ly_basic_info_department;
        Evas_Object *ly_basic_info_company;
        Evas_Object *ly_number_first;
        Evas_Object *ly_number_last;
        Evas_Object *ly_number_default;
        Evas_Object *ly_number_set_default_separator_before;
        Evas_Object *ly_number_set_default;
        Evas_Object *ly_number_set_default_separator_after;
        Evas_Object *ly_number_base;
        Evas_Object *ly_email_first;
        Evas_Object *ly_email_last;
        Evas_Object *ly_email_default;
        Evas_Object *ly_email_set_default;
        Evas_Object *ly_email_base;
        Evas_Object *ly_addr_first;
        Evas_Object *ly_addr_last;

        Evas_Object *ly_seperator_more;
        Evas_Object *ly_seperator_basic_info;
        Evas_Object *ly_messenger_first;
        Evas_Object *ly_messenger_last;
        Evas_Object *ly_url_first;
        Evas_Object *ly_url_last;
        Evas_Object *ly_relationship_first;
        Evas_Object *ly_relationship_last;
        Evas_Object *ly_event_first;
        Evas_Object *ly_event_last;
        Evas_Object *ly_note;

        Evas_Object *ly_group;
        Evas_Object *ly_ringtone;
        Evas_Object *ly_vibration;
        Evas_Object *ly_address_book;
        Evas_Object *ly_moreinfo;

        bool saved;
        Eina_Bool save_disable;
        int view_create_ver;
        int cnt_addr;
        int cnt_num;
        int idx_append;

        int base_ab;
        int base_ab_mode;
        char *name_old;
        char *base_ab_name;

        int contact_id;
        contacts_record_h contact;
        ct_detail_data *cdetail_d;

        bool camera_service_launched;
        ui_gadget_h crop_ug;
        bool keypad_on;
} ct_input_data;

typedef struct
{
        Evas_Object *ly_content;
        contacts_record_h record;
        Evas_Object *data;
        const char *view_uri;
} ct_input_typed_data;

typedef enum
{
    CT_AB_POPUP_TYPE_INPUT_VIEW,
    CT_AB_POPUP_TYPE_GINPUT_VIEW,
    CT_AB_POPUP_TYPE_LIST_VIEW,
} ct_addrbook_popup_type;

typedef struct
{
        int id;
        int mode;
        char *name;
        bool all_contacts_item;
        Elm_Object_Item *item;
} ct_ab_popup_data;

typedef struct
{
    Evas_Object* parent;
    Evas_Object* popup;
    Evas_Object* button1;
    Evas_Object* button2;
    char* popup_label;
    char* button1_label;
    char* button2_label;
    Evas_Smart_Cb button1_cb;
    Evas_Smart_Cb button2_cb;
    void* button1_data;
    void* button2_data;
} ct_confirm_popup_data;

typedef struct
{
    int contact_id;
    contacts_record_h contact_record;
    char** field_names;
    char** strings_of_data;
    bool* checked_items;

    ct_confirm_popup_data* p_popup_data;
    Evas_Object* box;
    Evas_Object* select_all_layout;
    Evas_Object* genlist;
    Elm_Genlist_Item_Class* genlist_item_class;

    UDateFormat* formatter;
    size_t fields_count;

    ui_gadget_h ug;
    ui_gadget_h child_ug;
} ct_send_as_text_data;

typedef struct
{
    size_t current_index;
    ct_send_as_text_data* p_contact_text_data;
} ct_send_as_text_with_additional_info;

typedef struct
{
    ct_confirm_popup_data* p_popup_data;
    msg_handle_t msg_handle;

    int contact_id;

    Evas_Object* genlist;

    //Previous values
    bool is_blocked_calls;
    bool is_blocked_messages;
    //Values related to check boxes
    bool block_calls;
    bool block_messages;
} ct_contact_block_data;

typedef struct
{
    const char* item_caption;
    bool* is_checked;
} ct_contact_block_item_data;

/**
 * Typedef for function that add/delete number to/from spam list for messages
 */
typedef bool (*number_handler_for_spam_messages)(msg_handle_t msg_handle, const char* number);

/**
 * Typedef for functions that gets string from any child record of _contacts_contact
 */
typedef char* p_get_str_from_child_record(ct_send_as_text_data* p_text_as_data, unsigned int child_table_id,
    int record_index, unsigned int str_field_id);

/**
 * Typedef for functions that fill numbers, mails... etc. of contact
 */
typedef bool ct_fill_function(ct_send_as_text_data* p_text_as_data,
    size_t* current_name_index, size_t* current_data_index);

void phone_free_contacts(Eina_List *list);
Eina_List * phone_load_speeddial_data(int *ref_count);
void phone_free_speeddial_data(Eina_List *list);
char *phone_get_voice_mail_number(void);
int speed_set_speeddial(int spdial_num, int number_id);

ui_gadget_h phone_launch_msg_composer_ug(ui_gadget_h parent_ug, char *data, int msg_id,
        void (*destroy_cb)(void*), void *cb_param);
ui_gadget_h phone_launch_contact_list_ug(ui_gadget_h parent_ug, int request,
        void (*result_cb)(void*, void*), void (*destroy_cb)(void*),
        void *cb_param);
ui_gadget_h phone_launch_contact_detail_ug(ui_gadget_h parent_ug, int contact_index,
        void (*destroy_cb)(void*), void *cb_param);
ui_gadget_h phone_launch_contact_add_list_edit_ug(ui_gadget_h parent_ug, char *data,
        void (*destroy_cb)(void*), void *cb_param);

/**
 * @brief launch contact edit UI gadget
 * @param[in]   parent_ug   parent's UI gadget.
 * @param[in]   data        person id.
 * @param[in]   destroy_cb  callback for destroying UI gadget.
 * @param[in]   cb_param    data for destroy_cb.
 * @return  The pointer of UI gadget
 */
ui_gadget_h phone_launch_contact_edit_ug(ui_gadget_h parent_ug, int data,
        void (*destroy_cb)(void *), void *cb_param);

/**
 * @brief launch bluetooth UI gadget
 * @param[in]   parent_ug   parent's UI gadget.
 * @param[in]   attach      path of the file which will be attached.
 * @param[in]   destroy_cb  callback for destroying UI gadget.
 * @param[in]   cb_param    data for destroy_cb.
 * @return  The pointer of UI gadget
 */
ui_gadget_h phone_launch_bluetooth_ug(ui_gadget_h parent_ug, const char *attach,
        void (*destroy_cb)(void *), void *cb_param);

ui_gadget_h phone_image_crop_ug(ui_gadget_h parent, const char *photo,
        struct ug_cbs *cbs);
ui_gadget_h ctui_msg_ug(ui_gadget_h parent, const char *number,
        const char *attach, void (*destroy_cb)(void*), void *cb_param);
ui_gadget_h ctui_predefined_body_msg_ug(ui_gadget_h parent, const char *number, const int idx,
        const char *attach, void (*destroy_cb)(void*), void *cb_param);
ui_gadget_h ctui_account_ug(ui_gadget_h data, Evas_Object *obj, void *event_info,
        void (*destroy_cb)(void*), void *cb_param);
ui_gadget_h phone_launch_settings_ug(ui_gadget_h parent_ug, const char* ug_name,
        void (*destroy_cb)(void*), void *cb_param);

void ug_common_destroy_cb(ui_gadget_h ug, void *priv);
void ug_common_layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv);
void ctui_destroy_child_ug(void *data);

void phone_launch_voice_call(const int id, const char* number);

Evas_Object *phone_create_base_layout(Evas_Object *parent, bool is_fullview);
Evas_Object *phone_show_popup(Evas_Object *parent, const char *desc,
        double timeout);
Evas_Object *phone_create_confirm_popup(Evas_Object **popup, Evas_Object *win,
        const char* description,
        void (*btn_clicked_cb)(void *, Evas_Object *, void *), void *cb_data);
Evas_Object *phone_create_list_sweep_btn(Evas_Object *parent, const char *fullpath);
Evas_Object *phone_create_bg(Evas_Object *parent);
Evas_Object *phone_create_icon_with_img(Evas_Object *parent, const char *full_path);
Evas_Object *phone_create_navi_btn(Evas_Object *parent, const char *style);

/**
 * Set visibility of add_button && searchbar.
 * * @param[in]   clist_d      Value to get searchbar && add_button.
 *   @param[in]   visible      state of visibility.
 * */
void phone_set_searchbar_add_button_visible(ct_list_data &clist_d, bool visible);

Evas_Object *phone_progressbar_popup(Evas_Object *parent,
        ph_progress_info *p_info, const char *title);
Evas_Object *phone_get_notify(Evas_Object *parent);
void phone_show_notify(Evas_Object *parent, const char *msg);
void phone_hide_notify(Evas_Object *parent);
void phone_show_tickernoti(const char *);
void phone_navi_item_reset(Elm_Object_Item *item, void *data);
void phone_set_view_info(ph_view_info *view_info, Evas_Object *win,
        Evas_Object *navi, void *ug, int ug_request, int cnt_max,
        char *ug_data);

void phone_service_reply_simple(service_h service, service_result_e result);
void phone_list_ug_return_ids(ui_gadget_h ug, int *result_list, int cnt,
        const char *bd_key);
void phone_list_ug_return_values(service_h service, int *result_list, int cnt,
        const char *result_type);
void phone_list_ug_return_number_email_ids(ui_gadget_h ug,
        int *result_number_list, int number_list_count, int *result_email_list,
        int email_list_count);
void phone_ug_return_id(ui_gadget_h ug, int ct_id, int num_id, int email_id);
void phone_ug_return_value(service_h service, int ct_id, int num_id,
        int email_id, int result_id);
void phone_ug_return_vcard(ui_gadget_h ug, int ct_id, char *vcard);
void phone_ug_operation_return_vcard(service_h service, int ct_id, char *vcard);
Evas_Object* phone_create_nocontents(Evas_Object *parent, const char* label);
void phone_toolbar_disabled_item_append(Evas_Object *toolbar, int cnt);

char* ctui_get_addressbook_icon_path(int addressbook_id);
const char* ctui_get_default_contact_img(int view_type);
void ctui_get_number_type_str(contacts_record_h record, int CTS_NUMBER_type,
        char *dest, int dest_len);
void ctui_ld_to_dd(ct_list_data *clist_d, ct_detail_data *cdetail_d);

Evas_Object* ctui_addrbook_popup(Evas_Object *parent, Evas_Smart_Cb item_sel_cb,
        void *sel_cb_data, ct_addrbook_popup_type ab_type);
void ctui_entry_limit_size_set(Evas_Object *entry);
Evas_Object* ctui_create_btn(Evas_Object *parent, const char *label);
void ctui_genlist_append_separator_10px(Evas_Object *genlist);
void ctui_genlist_append_separator_20px(Evas_Object *genlist);
void ctui_navi_btn_disabled_set(Evas_Object *navi, Eina_Bool disabled);
char* ctui_entry_markup_to_utf8(const char *s);
char* ctui_entry_markup_to_utf8_without_spaces(const char *s);
void ctui_entry_entry_set(Evas_Object *entry, const char *s);
Evas_Object* ctui_create_editfield(Evas_Object *parent, const char *title,
        const char *guide, bool multiline);
void ctui_genlist_append_separator_20px_with_line(Evas_Object *genlist);
void ctui_genlist_append_separator_8px_with_line(Evas_Object *genlist);
void ctui_list_ug_hide_cb(void *data, Evas_Object *obj, void *event_info);
Evas_Object* phone_create_select_all(Evas_Object *box,
        const char *selectall_text, selectall_changed_cb cb, void *cb_data);
void ctui_list_free_contacts(Eina_List* list);
void ctui_list_refresh_genlist(ct_list_data *clist_d);
void ctui_list_handle_search(ct_list_data *clist_d);
int phone_detail_log_is_call_ing_type(int type);
int phone_detail_log_is_mms_type(int type);
int phone_detail_log_is_sms_type(int type);
int phone_detail_log_is_email_type(int type);
char* phone_detail_log_get_icon_type(int log_type);
char* phone_detail_log_get_duration_from_number(int number);
void phone_detail_log_init_time_format(void);
void phone_detail_log_generate_date_format(UDateFormat **formatter);
char* phone_detail_log_get_icon_path_with_action(int log_type);
char* phone_detail_log_get_date(UDateFormat ** formatter, int log_time);
char* phone_detail_log_get_time(UDateFormat ** formatter, int log_time);
int phone_detail_log_get_date_type(int log_time, int log_duration);
void phone_detail_log_delete_date_format(UDateFormat **formatter);
int phone_detail_log_get_phonenumber_type(int CTS_NUMBER_type);
char *ph_log_util_get_formatted_date(UDateFormat **formatter, int log_time,
        date_style style);
void ct_list_clear_pdata(ct_list_data *clist_d);
void phone_move_ctxpopup(Evas_Object *popup, Evas_Object *item);
void phone_resize_notify(Evas_Object *parent, int rotate);
void ctui_get_addressbook_name(int addressbook_id, char *dest, int dest_len);
Eina_List* ctui_person_get_writable_contact_list(int person_id);
Eina_List* ctui_person_get_number_list(Eina_List *contact_list);
Eina_List* ctui_person_get_email_list(Eina_List *contact_list);
Eina_List* ctui_person_get_contact_list(int person_id);
void ctui_free_record_list(Eina_List *contact_list);
int ctui_get_email_type_index(int type);
int ctui_get_mfc_option(void);
ct_person_list *find_info_in_list_by_id(Eina_List *check_list,int person_id);

int ctui_get_view_mode(void);
void ctui_set_view_mode(int addressbook_id);

contacts_error_e phone_cts_get_list(const char *view_uri, int property_id,
        int match_value, contacts_list_h *out_list);
void phone_cts_free_list(contacts_list_h list);
contacts_error_e phone_cts_get_int_from_list(contacts_list_h list,
        int property_id, int *out_int);
contacts_error_e phone_cts_get_str_from_list(contacts_list_h list,
        int property_id, char **out_str);
contacts_error_e phone_cts_get_bool_from_list(contacts_list_h list,
        int property_id, bool *out_bool);
contacts_error_e phone_cts_get_default_number(int person_id,
        contacts_record_h *record_clone);
contacts_error_e phone_cts_get_default_email(int person_id,
        contacts_record_h *record_clone);
void ctui_get_account_name_by_address_book_id(int address_book_id, char *dest,
        int dest_len);
bool ctui_list_make_vcard(int contactid, char *path, int path_length);
void ctui_list_lazy_update(const char *view_uri, void *data);
char* ctui_list_get_highlight_text(ct_list_data *clist_d, const char *src);
Evas_Object *phone_create_toolbar_btn(Evas_Object *parent, const char *text,
        Evas_Smart_Cb func, void *data);
void ctui_input_data_popup_hide_cb(void *data, Evas_Object *obj, void *event_info);
void ctui_detail_data_popup_hide_cb(void *data, Evas_Object *obj, void *event_info);
void create_no_content_layout(ct_list_data *clist_d,Evas_Object *parent);

int ctui_list_checked_cnt_get(Eina_List *list);
void ctui_list_update_selection_info(void *data);
void ctui_list_set_unsweep(ct_list_data *clist_d);

/**
 * Removes badge if current package(DIALER_PKG) has it.
 * @return true if badge exists, false otherwise.
 * */
bool removeBadge();

/**
 * Checks if badge exists for current package(DIALER_PKG)
 * @return true if badge exists false otherwise
 * */
bool hasBadge();

inline bool is_unknown_contact(const char *pPhoneNumber)
{
    return (NULL == pPhoneNumber || '\0' == pPhoneNumber[0]);
}

contacts_record_h ctui_get_record_image(contacts_record_h record_contact);

int ctui_get_addressbook_id_by_index(Eina_List *list, unsigned int index);
Eina_List* ctui_get_addressbook_id_list(const char *ori_string,
        const char *sep);
void ctui_list_edit_navi_pop(void *data, Evas_Object *obj, void *event_info);
int ctui_get_addressbook_id(char* addressbook_name);

void ctui_create_contacts_error_popup(Evas_Object *parent, int err);

void create_emergency_contacts_group();

bool has_emergency_contacts();

void ctui_list_searchbar_cancel_cb(void *data, Evas_Object *obj,
        void *event_info);

/**
 * Create searchbar.
 * * @param[in]   parent       Layout to create searchbar.
 *   @param[in]   clist_d      Value to keep searchbar.
 * */
void ctui_list_create_searchbar(Evas_Object* parent,
        ct_list_data *clist_d);

/**
 * @brief Convert string to bool
 * @param[in]   strVal      Value to be converted
 * @return  Bool value
 */
bool ct_list_str_to_bool(const std::string& strVal);

/**
 * @brief Convert bool to string
 * @param[in]   bVal        Value to be converted
 * @return  String value
 */
std::string ct_list_bool_to_str(bool bVal);

/**
 * @brief Insert a record in _contacts_extension table
 * @param[in]   extensionRec    Record associated to table
 * @param[in]   extensionField  Field to set the @a strValue
 * @param[in]   contactId       Id of contact with that need to be associated
 * @param[in]   strValue        String value that assigned
 * @return  True if success, otherwise false
 */
bool ct_list_insert_extension(contacts_record_h extensionRec, unsigned int extensionField, int contactId,
        const std::string& strValue);

/**
 * @brief Updates a record in _contacts_extension table
 * @param[in]   contactRec      Record associated to _contacts_contact table
 * @param[in]   extensionRec    Record associated to _contacts_extension table
 * @return true if success, otherwise false
 */
bool ct_list_toggle_blocked(contacts_record_h contactRec, contacts_record_h extensionRec);

/**
 * @brief Convert string to uppercase
 * @param[in]   str     Incoming string
 * @return Uppercased string
 */
std::string ct_make_uppercase_string(const std::string& str);

/**
 * @brief Gets extension id related to @a contactId
 * @param   contactId   Id of contact
 * @return ID of extension related to @a contactId if exist, otherwise -1
 */
int phone_get_extension_id(int contactId);

/**
 * @brief Provides information if contact blocked or not base on id
 * @param[in]   contact_id  Id of contact
 * @return  true if contact is blocked, otherwise false
 */
bool phone_is_blocked_contact_for_calls(int contact_id);

/**
 * @brief   Gets list of records
 * @remarks If function returns true @a list must be destroyed with contacts_list_destroy() by you.
 * @tparam      FilterFieldType     Type of field for filter
 * @param[in]   tableUri            Uri to table to which the request is made
 * @param[in]   filterField         Field by the value which the search is conducted
 * @param[in]   filterVal           Value of filtered field
 * @param[out]  list                List of records that satisfy the query
 * @return true if success, otherwise false.
 */
template < typename FilterFieldType>
bool get_records_list(const std::string& tableUri, unsigned int filterField,
        FilterFieldType filterVal, contacts_list_h* list);

/**
 * @brief   This function makes blocked/unblocked contact
 * @param[in]   contactId   ID of contact
 * @return true if success, otherwise false
 */
bool phone_toggle_blocked_contact_for_calls(int contactId);

/**
 * @brief This function copy @a number to dialing screen
 * @param[in]   number  Tel. number
 * @return true if success, otherwise false
 */
bool phone_copy_to_dialing_screen(const std::string& number);

/**
 * @brief Gets date and time as string
 * @remark return value must be destroyed with free by you
 * @param[in]   formatter   Formatter of date and time
 * @param[in]   year        Year
 * @param[in]   month       Month
 * @param[in]   day         Day
 * @return date and time as string
 */
char* phone_get_datetime_str(UDateFormat* formatter, int year, int month, int day);

/**
 * @brief Initiatialise date and time formatter
 * @return formatter
 */
UDateFormat* phone_init_time_formatter(void);

/**
 * @brief Gets index of address types for localisation strings
 * @param[in]   type    Index of type
 * @return Index for localisation
 */
int phone_get_address_type_index(int type);

/**
 * @brief Gets index of website types for localisation strings
 * @param[in]   type    Index of type
 * @return Index for localisation
 */
int phone_get_website_type_index(int type);

/**
 * @brief Gets index of number types for localisation strings
 * @param[in]   type    Index of type
 * @return Index for localisation
 */
int phone_get_number_type_index(int ct_num_type);

/**
 * @brief Destroy @a ct_confirm_popup_data structure
 * @param[in]   p_popup_data        Popup data
 */
void phone_destroy_confirm_popup_data(ct_confirm_popup_data* p_popup_data);

/**
 * @brief Fill @a ct_confirm_popup_data structure
 * @param[in]   p_popup_data        Popup data
 * @return true if success, otherwise false
 */
bool phone_fill_confirm_popup_data(ct_confirm_popup_data* p_popup_data);

/**
 * @brief Gets contact ID by person ID
 * @param[in]   personId    ID of person
 * @return  ID of contact on success, otherwise 0
 */
int phone_get_contact_id_by_person_id(int personId);

/**
 * @brief Get group localized name
 * @param[in]   group_record    _contacts_group view record
 * @return  Group name or localized name for one of the default groups
 */
const char * phone_get_group_name(contacts_record_h group_record);

/**
 * @brief Add button to popup
 * @remarks Added button automatically hides popup when clicked so you don't
 *          need to hide it in your callback and create callbacks for cancel buttons.
 * @param[in]   popup   Popup widget
 * @param[in]   text    Button text
 * @param[in]   func    Button click callback
 * @param[in]   data    Data to pass to func
 * @return true button on success, otherwise NULL
 */
Evas_Object * phone_popup_add_button(Evas_Object *popup, const char *text,
        Evas_Smart_Cb func, void *data);

/**
 * @brief Get contact name by ID
 * @remark return value must be destroy with free by you
 * @param[in]   id      Contact ID
 * @return contact name on success, otherwise false
 */
char* phone_get_contact_name(int id);

/**
 * @brief Create new class for genlist item
 * @remark return value must be destroyed with elm_genlist_item_class_free by you
 * @param[in]   style               Style of item
 * @param[in]   decorate_style      Style of item if item in decorate mode
 * @param[in]   decoreate_all_style Style of item if genlist in decorate mode
 * @param[in]   get_text            Text fetching function for genlist item
 * @param[in]   get_content         Content fetching function for genlist item
 * @param[in]   get_state           State fetching function for genlist item
 * @param[in]   del_func            Deletion function for genlist item
 * @return new genlist item class if success, otherwise false
 */
Elm_Genlist_Item_Class* phone_create_item_class(const char* style, const char* decorate_style, const char* decorate_all_style,
        Elm_Gen_Item_Text_Get_Cb get_text, Elm_Gen_Item_Content_Get_Cb get_content,
        Elm_Gen_Item_State_Get_Cb get_state, Elm_Gen_Item_Del_Cb del_func);

/**
 *@brief Create block contact confirm popup
 *@param[in]    parent                  Parent layout
 *@param[in]    contact_id              Contact ID
 *@return popup
 */
Evas_Object* phone_create_block_contact_popup(Evas_Object* parent, int contact_id);
#endif //__PHONE_COMMON_H__