summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSehong Na <sehong.na@samsung.com>2014-05-31 03:57:58 (GMT)
committerSehong Na <sehong.na@samsung.com>2014-05-31 03:57:58 (GMT)
commit331d162934ac346a137b6a3a17074d948a3c6c41 (patch)
treede2d8bd57e2c66aa58f0f2561fe8e79938142bf1
downloadphone-contacts-tizen_2.3.zip
phone-contacts-tizen_2.3.tar.gz
phone-contacts-tizen_2.3.tar.bz2
-rw-r--r--.gitignore1
-rwxr-xr-xCMakeLists.txt101
-rw-r--r--LICENSE.flora206
-rwxr-xr-xNOTICE3
-rwxr-xr-xbuild50
-rwxr-xr-xbuildAndDeploy.sh24
-rw-r--r--config/gdbscript_contacts_armv7l2
-rw-r--r--config/gdbscript_contacts_i5862
-rw-r--r--contacts-appservice/CMakeLists.txt30
-rwxr-xr-xcontacts-appservice/contacts-appservice.cpp375
-rw-r--r--contacts-appservice/icon_contacts-appservice.pngbin0 -> 7562 bytes
-rw-r--r--contacts-appservice/org.tizen.contacts-appservice.xml26
-rw-r--r--contacts-viewer/CMakeLists.txt27
-rwxr-xr-xcontacts-viewer/contacts-viewer.cpp621
-rw-r--r--contacts-viewer/icon_contacts-viewer.pngbin0 -> 7562 bytes
-rwxr-xr-xcontacts-viewer/org.tizen.contacts-viewer.xml33
-rw-r--r--contacts/CMakeLists.txt24
-rwxr-xr-xcontacts/contacts.cpp364
-rw-r--r--contacts/icon_contacts.pngbin0 -> 57662 bytes
-rwxr-xr-xcontacts/org.tizen.contacts.xml62
-rwxr-xr-xdeploy113
-rw-r--r--gbs/.gbs.conf37
-rwxr-xr-xinclude/contacts-ug.h268
-rwxr-xr-xinclude/phone-ug.h172
-rwxr-xr-xlib/CMakeLists.txt179
-rw-r--r--lib/common/Database/Database.cpp195
-rw-r--r--lib/common/Database/Database.h96
-rw-r--r--lib/common/Database/Listener.h54
-rw-r--r--lib/common/Front.cpp27
-rw-r--r--lib/common/Ui/Genlist/Genlist.cpp56
-rw-r--r--lib/common/Ui/Genlist/Item.cpp92
-rw-r--r--lib/common/Ui/Genlist/include/Genlist.h57
-rw-r--r--lib/common/Ui/Genlist/include/Item.h123
-rw-r--r--lib/common/Ui/Widget.cpp50
-rw-r--r--lib/common/Ui/include/Widget.h56
-rw-r--r--lib/common/Utils/NonCopyable.cpp34
-rw-r--r--lib/common/Utils/Tracer.cpp55
-rw-r--r--lib/common/Utils/include/NonCopyable.h42
-rw-r--r--lib/common/Utils/include/SharedPtr.h176
-rw-r--r--lib/common/Utils/include/Tracer.h37
-rw-r--r--lib/common/View.cpp173
-rw-r--r--lib/common/ViewData.cpp28
-rw-r--r--lib/common/ViewManager.cpp190
-rw-r--r--lib/common/ct-group-assign-popup.cpp431
-rwxr-xr-xlib/common/ct-group-input-view.cpp1653
-rwxr-xr-xlib/common/ct-list-detail.cpp631
-rwxr-xr-xlib/common/ct-list-view-common.cpp5523
-rw-r--r--lib/common/include/Contact.h49
-rw-r--r--lib/common/include/Front.h45
-rw-r--r--lib/common/include/View.h95
-rw-r--r--lib/common/include/ViewData.h50
-rw-r--r--lib/common/include/ViewManager.h104
-rw-r--r--lib/common/include/ct-group-assign-popup.h37
-rwxr-xr-xlib/common/include/ct-group.h30
-rw-r--r--lib/common/include/ct-list-view-common.h36
-rwxr-xr-xlib/common/include/phone-common.h1181
-rwxr-xr-xlib/common/include/phone-path.h137
-rwxr-xr-xlib/common/include/phone-text.h382
-rwxr-xr-xlib/common/include/phone.h123
-rwxr-xr-xlib/common/ph-common.cpp3667
-rwxr-xr-xlib/common/ph-detail-log.cpp530
-rwxr-xr-xlib/common/ph-dialer-speed.cpp187
-rwxr-xr-xlib/common/ph-text.cpp390
-rw-r--r--lib/common/ui/genlist/genlist.cpp31
-rw-r--r--lib/common/ui/genlist/genlist.h31
-rw-r--r--lib/common/ui/genlist/item.cpp29
-rw-r--r--lib/common/ui/genlist/item.h46
-rwxr-xr-xlib/ct-front/CMakeLists.txt14
-rw-r--r--lib/ct-front/contacts-tabui-efl.xml29
-rwxr-xr-xlib/ct-front/ct-front-main.cpp229
-rwxr-xr-xlib/ct-front/ct-front-view.cpp749
-rwxr-xr-xlib/ct-front/ct-front-view.h23
-rwxr-xr-xlib/ct-front/include/ct-front.h58
-rwxr-xr-xlib/details/CMakeLists.txt24
-rw-r--r--lib/details/base_addrbook0
-rw-r--r--lib/details/contacts-details-efl.xml41
-rwxr-xr-xlib/details/ct-detail-activity.cpp314
-rwxr-xr-xlib/details/ct-detail-activity.h26
-rwxr-xr-xlib/details/ct-detail-history.cpp1117
-rwxr-xr-xlib/details/ct-detail-history.h27
-rwxr-xr-xlib/details/ct-detail-main.cpp887
-rwxr-xr-xlib/details/ct-detail-utils.cpp2748
-rwxr-xr-xlib/details/ct-detail-utils.h97
-rw-r--r--lib/details/ct-detail-vibration-popup.cpp267
-rw-r--r--lib/details/ct-detail-vibration-popup.h41
-rw-r--r--lib/details/ct-detail-vibration.cpp66
-rw-r--r--lib/details/ct-detail-vibration.h34
-rwxr-xr-xlib/details/ct-detail-view.cpp3783
-rwxr-xr-xlib/details/ct-detail-view.h47
-rwxr-xr-xlib/details/ct-image-viewer.cpp430
-rwxr-xr-xlib/details/ct-image-viewer.h26
-rwxr-xr-xlib/details/ct-input-change-name.cpp202
-rwxr-xr-xlib/details/ct-input-change-name.h26
-rwxr-xr-xlib/details/ct-input-num-email.cpp1327
-rwxr-xr-xlib/details/ct-input-num-email.h25
-rwxr-xr-xlib/details/ct-input-utils.cpp1762
-rwxr-xr-xlib/details/ct-input-utils.h78
-rwxr-xr-xlib/details/ct-input-view.cpp3836
-rwxr-xr-xlib/details/ct-input-view.h33
-rwxr-xr-xlib/details/ct-share-info-ug.cpp1129
-rwxr-xr-xlib/details/include/ct-detail.h39
-rwxr-xr-xlib/dialer/CMakeLists.txt24
-rw-r--r--lib/dialer/KeypadTouchManager.cpp339
-rw-r--r--lib/dialer/Search/ContactData.cpp63
-rw-r--r--lib/dialer/Search/ContactData.h63
-rw-r--r--lib/dialer/Search/ContactItem.cpp60
-rw-r--r--lib/dialer/Search/ContactItem.h54
-rw-r--r--lib/dialer/Search/ContactLogRecord.cpp125
-rw-r--r--lib/dialer/Search/ContactLogRecord.h67
-rw-r--r--lib/dialer/Search/ContactNumberRecord.cpp135
-rw-r--r--lib/dialer/Search/ContactNumberRecord.h58
-rw-r--r--lib/dialer/Search/Controller.cpp128
-rw-r--r--lib/dialer/Search/Controller.h76
-rw-r--r--lib/dialer/Search/DataProvider.h56
-rw-r--r--lib/dialer/Search/DbDataProvider.cpp327
-rw-r--r--lib/dialer/Search/DbDataProvider.h84
-rw-r--r--lib/dialer/Search/Engine.cpp265
-rw-r--r--lib/dialer/Search/Engine.h202
-rw-r--r--lib/dialer/Search/Result.cpp113
-rw-r--r--lib/dialer/Search/Result.h112
-rw-r--r--lib/dialer/Search/ResultItem.cpp95
-rw-r--r--lib/dialer/Search/ResultItem.h76
-rw-r--r--lib/dialer/Search/ResultPopup.cpp159
-rw-r--r--lib/dialer/Search/ResultPopup.h96
-rw-r--r--lib/dialer/Search/ResultWidget.cpp151
-rw-r--r--lib/dialer/Search/ResultWidget.h103
-rw-r--r--lib/dialer/dialer-efl.desktop.in10
-rw-r--r--lib/dialer/dialer-efl.xml29
-rw-r--r--lib/dialer/include/KeypadTouchManager.h94
-rwxr-xr-xlib/dialer/include/phone-dialer.h148
-rwxr-xr-xlib/dialer/ph-dialer-main.cpp238
-rwxr-xr-xlib/dialer/ph-dialer-search.cpp39
-rwxr-xr-xlib/dialer/ph-dialer-search.h31
-rwxr-xr-xlib/dialer/ph-dialer-tapi.cpp533
-rwxr-xr-xlib/dialer/ph-dialer-tapi.h29
-rwxr-xr-xlib/dialer/ph-dialer-utils.cpp966
-rwxr-xr-xlib/dialer/ph-dialer-utils.h100
-rwxr-xr-xlib/dialer/ph-dialer-view.cpp2174
-rwxr-xr-xlib/dialer/ph-dialer-view.h45
-rwxr-xr-xlib/edc/contact_button.edc91
-rwxr-xr-xlib/edc/contacts.edc19
-rw-r--r--lib/edc/detail_theme.edc1732
-rwxr-xr-xlib/edc/dialer.edc1744
-rwxr-xr-xlib/edc/dialer_btn.edc113
-rwxr-xr-xlib/edc/dialer_theme.edc387
-rwxr-xr-xlib/edc/favorites_theme.edc570
-rwxr-xr-xlib/edc/group_theme.edc962
-rwxr-xr-xlib/edc/image_layout.edc115
-rwxr-xr-xlib/edc/input_theme.edc767
-rwxr-xr-xlib/edc/list.edc170
-rwxr-xr-xlib/edc/list_theme.edc766
-rw-r--r--lib/edc/log_item_icon.edc75
-rwxr-xr-xlib/edc/logdetail_theme.edc1485
-rwxr-xr-xlib/edc/nocontent_layout.edc109
-rwxr-xr-xlib/edc/progress.edc191
-rwxr-xr-xlib/edc/selectioninfo.edc81
-rwxr-xr-xlib/edc/speeddial_theme.edc157
-rwxr-xr-xlib/favor/CMakeLists.txt9
-rwxr-xr-xlib/favor/include/ct-favor.h76
-rwxr-xr-xlib/favor/ph-favorite-edit-view.cpp606
-rwxr-xr-xlib/favor/ph-favorite-edit-view.h54
-rwxr-xr-xlib/favor/ph-favorite-view.cpp2772
-rwxr-xr-xlib/favor/ph-favorite-view.h30
-rwxr-xr-xlib/images/contact_images/00_Nocontents_picture.pngbin0 -> 6530 bytes
-rwxr-xr-xlib/images/contact_images/00_check_checking.pngbin0 -> 3165 bytes
-rw-r--r--lib/images/contact_images/00_list_group_bg.pngbin0 -> 4162 bytes
-rw-r--r--lib/images/contact_images/01_controlbar_icon_add-to-bookmarks.pngbin0 -> 1478 bytes
-rw-r--r--lib/images/contact_images/01_controlbar_icon_add_account.pngbin0 -> 3695 bytes
-rw-r--r--lib/images/contact_images/01_controlbar_icon_add_to_contact.pngbin0 -> 4210 bytes
-rw-r--r--lib/images/contact_images/01_controlbar_icon_bluetooth_preview.pngbin0 -> 1920 bytes
-rw-r--r--lib/images/contact_images/01_controlbar_icon_close.pngbin0 -> 1076 bytes
-rw-r--r--lib/images/contact_images/01_controlbar_icon_exchangs_register.pngbin0 -> 4517 bytes
-rw-r--r--lib/images/contact_images/01_controlbar_icon_groups.pngbin0 -> 1195 bytes
-rw-r--r--lib/images/contact_images/01_controlbar_icon_more.pngbin0 -> 3061 bytes
-rw-r--r--lib/images/contact_images/01_controlbar_icon_next.pngbin0 -> 834 bytes
-rw-r--r--lib/images/contact_images/01_controlbar_icon_previous.pngbin0 -> 834 bytes
-rw-r--r--lib/images/contact_images/C02_account_00.pngbin0 -> 3058 bytes
-rw-r--r--lib/images/contact_images/C02_account_01.pngbin0 -> 3801 bytes
-rw-r--r--lib/images/contact_images/C02_account_02.pngbin0 -> 5247 bytes
-rw-r--r--lib/images/contact_images/C02_account_03.pngbin0 -> 4073 bytes
-rw-r--r--lib/images/contact_images/C02_account_04.pngbin0 -> 7110 bytes
-rw-r--r--lib/images/contact_images/C02_account_default.pngbin0 -> 7562 bytes
-rw-r--r--lib/images/contact_images/C02_account_sim.pngbin0 -> 3251 bytes
-rwxr-xr-xlib/images/contact_images/C02_caller_id_icon_camera.pngbin0 -> 12196 bytes
-rwxr-xr-xlib/images/contact_images/C02_caller_id_icon_camera_dim.pngbin0 -> 12030 bytes
-rwxr-xr-xlib/images/contact_images/C02_caller_id_icon_camera_press.pngbin0 -> 17168 bytes
-rwxr-xr-xlib/images/contact_images/C02_caller_id_icon_gallery.pngbin0 -> 12319 bytes
-rwxr-xr-xlib/images/contact_images/C02_caller_id_icon_gallery_dim.pngbin0 -> 12160 bytes
-rwxr-xr-xlib/images/contact_images/C02_caller_id_icon_gallery_press.pngbin0 -> 17179 bytes
-rwxr-xr-xlib/images/contact_images/C02_circle_button.pngbin0 -> 13968 bytes
-rwxr-xr-xlib/images/contact_images/C02_circle_button_press.pngbin0 -> 15848 bytes
-rwxr-xr-xlib/images/contact_images/C02_circle_icon_call.pngbin0 -> 5404 bytes
-rwxr-xr-xlib/images/contact_images/C02_circle_icon_call_press.pngbin0 -> 3763 bytes
-rwxr-xr-xlib/images/contact_images/C02_circle_icon_sms.pngbin0 -> 3875 bytes
-rwxr-xr-xlib/images/contact_images/C02_circle_icon_sms_press.pngbin0 -> 3311 bytes
-rwxr-xr-xlib/images/contact_images/C02_circle_icon_vt-call.pngbin0 -> 6726 bytes
-rwxr-xr-xlib/images/contact_images/C02_circle_icon_vt-call_press.pngbin0 -> 4260 bytes
-rwxr-xr-xlib/images/contact_images/C02_favorite_icon.pngbin0 -> 3440 bytes
-rw-r--r--lib/images/contact_images/C02_icon_add_group.pngbin0 -> 7328 bytes
-rw-r--r--lib/images/contact_images/C02_icon_favorite.pngbin0 -> 5068 bytes
-rw-r--r--lib/images/contact_images/C02_icon_favorite_on.pngbin0 -> 5584 bytes
-rw-r--r--lib/images/contact_images/C02_icon_reset.pngbin0 -> 3399 bytes
-rw-r--r--lib/images/contact_images/C04_icon_joyn.pngbin0 -> 3866 bytes
-rw-r--r--lib/images/contact_images/caller_ID_default_128x128.pngbin0 -> 5099 bytes
-rw-r--r--lib/images/contact_images/caller_ID_default_96x96.pngbin0 -> 4500 bytes
-rw-r--r--lib/images/contact_images/caller_ID_edit.pngbin0 -> 5162 bytes
-rwxr-xr-xlib/images/contact_images/email.pngbin0 -> 5948 bytes
-rw-r--r--lib/images/contact_images/message.pngbin0 -> 6073 bytes
-rwxr-xr-xlib/images/dialer_images/C01-3_button_01.pngbin0 -> 10879 bytes
-rwxr-xr-xlib/images/dialer_images/C01-3_button_01_dim.pngbin0 -> 10879 bytes
-rwxr-xr-xlib/images/dialer_images/C01-3_button_01_press.pngbin0 -> 13287 bytes
-rwxr-xr-xlib/images/dialer_images/C01-3_button_02.pngbin0 -> 10941 bytes
-rwxr-xr-xlib/images/dialer_images/C01-3_button_02_dim.pngbin0 -> 11006 bytes
-rwxr-xr-xlib/images/dialer_images/C01-3_button_02_press.pngbin0 -> 14438 bytes
-rwxr-xr-xlib/images/dialer_images/C01-3_dialer_button_01_press.pngbin0 -> 11587 bytes
-rwxr-xr-xlib/images/dialer_images/C01-3_icon_call.pngbin0 -> 3474 bytes
-rwxr-xr-xlib/images/dialer_images/C01-3_icon_call_dim.pngbin0 -> 4118 bytes
-rwxr-xr-xlib/images/dialer_images/C01-3_icon_call_press.pngbin0 -> 3474 bytes
-rwxr-xr-xlib/images/dialer_images/C01-3_icon_delete.pngbin0 -> 3564 bytes
-rwxr-xr-xlib/images/dialer_images/C01-3_icon_expand_01.pngbin0 -> 3062 bytes
-rwxr-xr-xlib/images/dialer_images/C01-3_icon_expand_02.pngbin0 -> 3007 bytes
-rwxr-xr-xlib/images/dialer_images/C01-3_icon_message.pngbin0 -> 4636 bytes
-rwxr-xr-xlib/images/dialer_images/C01-3_icon_message_dim.pngbin0 -> 3537 bytes
-rwxr-xr-xlib/images/dialer_images/C01-3_icon_message_press.pngbin0 -> 3694 bytes
-rwxr-xr-xlib/images/dialer_images/C01-3_icon_video_call.pngbin0 -> 5778 bytes
-rwxr-xr-xlib/images/dialer_images/C01-3_icon_video_call_dim.pngbin0 -> 5572 bytes
-rwxr-xr-xlib/images/dialer_images/C01-3_icon_video_call_press.pngbin0 -> 4512 bytes
-rwxr-xr-xlib/images/dialer_images/C01-3_keypad_bg.pngbin0 -> 84873 bytes
-rwxr-xr-xlib/images/dialer_images/C01-3_keypad_bg_reduction.pngbin0 -> 7861 bytes
-rwxr-xr-xlib/images/dialer_images/C01-3_keypad_press.pngbin0 -> 8381 bytes
-rwxr-xr-xlib/images/dialer_images/C01-3_search_bg_01.pngbin0 -> 45741 bytes
-rwxr-xr-xlib/images/dialer_images/C01-3_search_bg_02.pngbin0 -> 38978 bytes
-rwxr-xr-xlib/images/dialer_images/C01-3_search_field.pngbin0 -> 3311 bytes
-rwxr-xr-xlib/images/dialer_images/C01-3_search_icon.pngbin0 -> 5378 bytes
-rwxr-xr-xlib/images/dialer_images/C01-3_thumbnail_bg.pngbin0 -> 10710 bytes
-rwxr-xr-xlib/images/dialer_images/C01-3_title_divider.pngbin0 -> 2812 bytes
-rwxr-xr-xlib/images/dialer_images/keypad/C01-3_keypad_number_00.pngbin0 -> 4225 bytes
-rwxr-xr-xlib/images/dialer_images/keypad/C01-3_keypad_number_01.pngbin0 -> 1984 bytes
-rwxr-xr-xlib/images/dialer_images/keypad/C01-3_keypad_number_02.pngbin0 -> 3695 bytes
-rwxr-xr-xlib/images/dialer_images/keypad/C01-3_keypad_number_03.pngbin0 -> 4293 bytes
-rwxr-xr-xlib/images/dialer_images/keypad/C01-3_keypad_number_04.pngbin0 -> 2733 bytes
-rwxr-xr-xlib/images/dialer_images/keypad/C01-3_keypad_number_05.pngbin0 -> 3951 bytes
-rwxr-xr-xlib/images/dialer_images/keypad/C01-3_keypad_number_06.pngbin0 -> 4704 bytes
-rwxr-xr-xlib/images/dialer_images/keypad/C01-3_keypad_number_07.pngbin0 -> 2786 bytes
-rwxr-xr-xlib/images/dialer_images/keypad/C01-3_keypad_number_08.pngbin0 -> 4577 bytes
-rwxr-xr-xlib/images/dialer_images/keypad/C01-3_keypad_number_09.pngbin0 -> 4648 bytes
-rwxr-xr-xlib/images/dialer_images/keypad/C01-3_keypad_number_asterisk.pngbin0 -> 2922 bytes
-rwxr-xr-xlib/images/dialer_images/keypad/C01-3_keypad_number_auto_answer.pngbin0 -> 3389 bytes
-rwxr-xr-xlib/images/dialer_images/keypad/C01-3_keypad_number_mute.pngbin0 -> 3204 bytes
-rwxr-xr-xlib/images/dialer_images/keypad/C01-3_keypad_number_sharp.pngbin0 -> 3155 bytes
-rw-r--r--lib/images/phoneug_images/00_button_icon_expand_closed.pngbin0 -> 3204 bytes
-rw-r--r--lib/images/phoneug_images/00_button_icon_expand_opened.pngbin0 -> 3250 bytes
-rwxr-xr-xlib/images/phoneug_images/00_button_plus.pngbin0 -> 3119 bytes
-rw-r--r--lib/images/phoneug_images/01_controlbar_icon_contacts.pngbin0 -> 999 bytes
-rw-r--r--lib/images/phoneug_images/01_controlbar_icon_create.pngbin0 -> 742 bytes
-rw-r--r--lib/images/phoneug_images/01_controlbar_icon_dialer.pngbin0 -> 891 bytes
-rw-r--r--lib/images/phoneug_images/01_controlbar_icon_edit.pngbin0 -> 1262 bytes
-rw-r--r--lib/images/phoneug_images/01_controlbar_icon_favorite.pngbin0 -> 1136 bytes
-rw-r--r--lib/images/phoneug_images/01_controlbar_icon_logs.pngbin0 -> 1476 bytes
-rw-r--r--lib/images/phoneug_images/01_controlbar_icon_save.pngbin0 -> 1063 bytes
-rw-r--r--lib/images/phoneug_images/C01-4_btn_icon_call_dim.pngbin0 -> 3253 bytes
-rw-r--r--lib/images/phoneug_images/C01-4_btn_icon_message_dim.pngbin0 -> 3341 bytes
-rw-r--r--lib/images/phoneug_images/C01-4_btn_icon_video_call_dim.pngbin0 -> 3173 bytes
-rwxr-xr-xlib/images/phoneug_images/C01-4_circle_button.pngbin0 -> 13968 bytes
-rwxr-xr-xlib/images/phoneug_images/C01-4_circle_button_press.pngbin0 -> 15848 bytes
-rwxr-xr-xlib/images/phoneug_images/C01-4_controlbar_icon_all.pngbin0 -> 450 bytes
-rwxr-xr-xlib/images/phoneug_images/C01-4_controlbar_icon_create.pngbin0 -> 3625 bytes
-rwxr-xr-xlib/images/phoneug_images/C01-4_controlbar_icon_delete.pngbin0 -> 572 bytes
-rwxr-xr-xlib/images/phoneug_images/C01-4_controlbar_icon_missed_call.pngbin0 -> 774 bytes
-rwxr-xr-xlib/images/phoneug_images/C01-4_controlbar_icon_view_block.pngbin0 -> 4308 bytes
-rwxr-xr-xlib/images/phoneug_images/C01-4_controlbar_icon_view_contacts.pngbin0 -> 999 bytes
-rw-r--r--lib/images/phoneug_images/C01-4_icon_Blocked(Auto-rejected).pngbin0 -> 3237 bytes
-rwxr-xr-xlib/images/phoneug_images/C01-4_icon_Blocked.pngbin0 -> 4363 bytes
-rwxr-xr-xlib/images/phoneug_images/C01-4_icon_call_blocked.pngbin0 -> 978 bytes
-rw-r--r--lib/images/phoneug_images/C01-4_icon_dialed.pngbin0 -> 3055 bytes
-rwxr-xr-xlib/images/phoneug_images/C01-4_icon_message_blocked.pngbin0 -> 1423 bytes
-rw-r--r--lib/images/phoneug_images/C01-4_icon_missed-call.pngbin0 -> 3119 bytes
-rw-r--r--lib/images/phoneug_images/C01-4_icon_received.pngbin0 -> 3043 bytes
-rw-r--r--lib/images/phoneug_images/C01-4_icon_rejected.pngbin0 -> 3252 bytes
-rwxr-xr-xlib/images/phoneug_images/C01-4_list_icon_call.pngbin0 -> 3218 bytes
-rw-r--r--lib/images/phoneug_images/C01-4_list_icon_mms.pngbin0 -> 3355 bytes
-rw-r--r--lib/images/phoneug_images/C01-4_list_icon_sms.pngbin0 -> 3212 bytes
-rw-r--r--lib/images/phoneug_images/C01-4_list_icon_vt-call.pngbin0 -> 3094 bytes
-rwxr-xr-xlib/images/phoneug_images/C01-5_icon_voicecall.pngbin0 -> 3572 bytes
-rwxr-xr-xlib/images/phoneug_images/C02_button_icon_call.pngbin0 -> 3361 bytes
-rwxr-xr-xlib/images/phoneug_images/C02_button_icon_call_dim.pngbin0 -> 3357 bytes
-rwxr-xr-xlib/images/phoneug_images/C02_button_icon_call_press.pngbin0 -> 3332 bytes
-rwxr-xr-xlib/images/phoneug_images/C02_button_icon_delete.pngbin0 -> 3448 bytes
-rwxr-xr-xlib/images/phoneug_images/C02_button_icon_delete_dim.pngbin0 -> 3379 bytes
-rwxr-xr-xlib/images/phoneug_images/C02_button_icon_delete_press.pngbin0 -> 3448 bytes
-rwxr-xr-xlib/images/phoneug_images/C02_button_icon_message.pngbin0 -> 3132 bytes
-rwxr-xr-xlib/images/phoneug_images/C02_button_icon_message_dim.pngbin0 -> 3122 bytes
-rwxr-xr-xlib/images/phoneug_images/C02_button_icon_message_press.pngbin0 -> 3139 bytes
-rwxr-xr-xlib/images/phoneug_images/C02_button_icon_videocall.pngbin0 -> 3641 bytes
-rwxr-xr-xlib/images/phoneug_images/C02_button_icon_videocall_dim.pngbin0 -> 3677 bytes
-rwxr-xr-xlib/images/phoneug_images/C02_button_icon_videocall_press.pngbin0 -> 3670 bytes
-rwxr-xr-xlib/images/phoneug_images/C02_circle_icon_call.pngbin0 -> 5191 bytes
-rwxr-xr-xlib/images/phoneug_images/C02_circle_icon_call_press.pngbin0 -> 3763 bytes
-rwxr-xr-xlib/images/phoneug_images/C02_circle_icon_sms.pngbin0 -> 3686 bytes
-rwxr-xr-xlib/images/phoneug_images/C02_circle_icon_sms_press.pngbin0 -> 3311 bytes
-rwxr-xr-xlib/images/phoneug_images/C02_circle_icon_vt-call.pngbin0 -> 6325 bytes
-rwxr-xr-xlib/images/phoneug_images/C02_circle_icon_vt-call_press.pngbin0 -> 4260 bytes
-rw-r--r--lib/images/phoneug_images/C02_icon_call.pngbin0 -> 3294 bytes
-rw-r--r--lib/images/phoneug_images/C02_icon_chat_on.pngbin0 -> 3392 bytes
-rw-r--r--lib/images/phoneug_images/C02_icon_filetransfer.pngbin0 -> 3382 bytes
-rw-r--r--lib/images/phoneug_images/C02_icon_message.pngbin0 -> 3330 bytes
-rw-r--r--lib/images/phoneug_images/C02_icon_video_call.pngbin0 -> 3159 bytes
-rw-r--r--lib/images/phoneug_images/caller_ID_default_70x70_man.pngbin0 -> 5345 bytes
-rwxr-xr-xlib/images/phoneug_images/camera_mode_shutter_icon.pngbin0 -> 2249 bytes
-rw-r--r--lib/images/phoneug_images/phone.pngbin0 -> 8211 bytes
-rwxr-xr-xlib/list/CMakeLists.txt18
-rw-r--r--lib/list/contacts-list-efl.xml35
-rwxr-xr-xlib/list/ct-group-edit-view.h23
-rwxr-xr-xlib/list/ct-group-view.cpp1696
-rwxr-xr-xlib/list/ct-list-contact-view.cpp1264
-rwxr-xr-xlib/list/ct-list-contact-view.h31
-rwxr-xr-xlib/list/ct-list-edit-view.cpp1102
-rwxr-xr-xlib/list/ct-list-edit-view.h45
-rwxr-xr-xlib/list/ct-list-main.cpp994
-rwxr-xr-xlib/list/ct-list-utils.cpp1153
-rwxr-xr-xlib/list/ct-list-utils.h59
-rwxr-xr-xlib/list/ct-list-view-ug.cpp888
-rwxr-xr-xlib/list/ct-list-view-ug.h31
-rwxr-xr-xlib/list/include/ct-list.h320
-rwxr-xr-xlib/log/CMakeLists.txt20
-rw-r--r--lib/log/CallDurationCounter.cpp121
-rw-r--r--lib/log/CallDurationCounter.h104
-rw-r--r--lib/log/CallDurationItem.cpp57
-rw-r--r--lib/log/CallDurationItem.h64
-rw-r--r--lib/log/CallDurationView.cpp153
-rw-r--r--lib/log/CallDurationView.h73
-rwxr-xr-xlib/log/include/phone-log.h105
-rwxr-xr-xlib/log/ph-log-check-view.cpp425
-rwxr-xr-xlib/log/ph-log-check-view.h37
-rwxr-xr-xlib/log/ph-log-detail-view.cpp1441
-rwxr-xr-xlib/log/ph-log-detail-view.h42
-rwxr-xr-xlib/log/ph-log-main-view.cpp2727
-rwxr-xr-xlib/log/ph-log-main-view.h51
-rwxr-xr-xlib/log/ph-log-main.cpp320
-rwxr-xr-xlib/log/ph-log-utils.cpp58
-rwxr-xr-xlib/log/ph-log-utils.h25
-rwxr-xr-xlib/ph-front/CMakeLists.txt14
-rwxr-xr-xlib/ph-front/include/ph-front.h64
-rwxr-xr-xlib/ph-front/ph-front-main.cpp205
-rwxr-xr-xlib/ph-front/ph-front-view.cpp670
-rwxr-xr-xlib/ph-front/ph-front-view.h23
-rw-r--r--lib/ph-front/phone-tabui-efl.xml29
-rwxr-xr-xlib/settings/CMakeLists.txt13
-rw-r--r--lib/settings/contacts-settings-efl.xml29
-rwxr-xr-xlib/settings/ct-setting-main.cpp155
-rwxr-xr-xlib/settings/ct-setting-view.cpp1627
-rwxr-xr-xlib/settings/ct-setting-view.h65
-rw-r--r--lib/settings/mfc_option0
-rwxr-xr-xlib/speed/CMakeLists.txt16
-rwxr-xr-xlib/speed/include/phone-speed.h25
-rwxr-xr-xlib/speed/ph-speeddial-main.cpp226
-rwxr-xr-xlib/speed/ph-speeddial-view.cpp724
-rwxr-xr-xlib/speed/ph-speeddial-view.h37
-rw-r--r--lib/speed/speeddial-efl.xml29
-rw-r--r--libug-phone-efl.manifest11
-rw-r--r--org.tizen.contacts-appservice.manifest12
-rw-r--r--org.tizen.contacts-appservice.rule215
-rw-r--r--org.tizen.contacts-viewer.manifest13
-rw-r--r--org.tizen.contacts-viewer.rule215
-rw-r--r--org.tizen.contacts.manifest14
-rw-r--r--org.tizen.contacts.rule217
-rw-r--r--org.tizen.dialer.manifest12
-rw-r--r--org.tizen.phone.manifest13
-rw-r--r--org.tizen.phone.rule222
-rw-r--r--packaging/phone.changes3
-rwxr-xr-xpackaging/phone.spec212
-rw-r--r--phone/CMakeLists.txt13
-rw-r--r--phone/icon_phone.pngbin0 -> 57662 bytes
-rwxr-xr-xphone/org.tizen.phone.xml69
-rwxr-xr-xphone/phone.cpp354
-rwxr-xr-xpo/CMakeLists.txt23
-rwxr-xr-xpo/POTFILES.in2
-rw-r--r--po/ar.po1769
-rw-r--r--po/az.po1770
-rw-r--r--po/bg.po1772
-rw-r--r--po/ca.po1772
-rw-r--r--po/cs.po1770
-rw-r--r--po/da.po1770
-rw-r--r--po/de_DE.po1772
-rw-r--r--po/el_GR.po1773
-rw-r--r--po/en.po1766
-rw-r--r--po/en_PH.po1769
-rw-r--r--po/en_US.po1767
-rw-r--r--po/es_ES.po1771
-rw-r--r--po/es_US.po1759
-rw-r--r--po/et.po1770
-rw-r--r--po/eu.po1770
-rw-r--r--po/fi.po1772
-rw-r--r--po/fr_CA.po1768
-rw-r--r--po/fr_FR.po1770
-rw-r--r--po/ga.po1772
-rw-r--r--po/gl.po1770
-rw-r--r--po/hi.po1769
-rw-r--r--po/hr.po1769
-rw-r--r--po/hu.po1772
-rw-r--r--po/hy.po1770
-rw-r--r--po/is.po1768
-rw-r--r--po/it_IT.po1778
-rw-r--r--po/ja_JP.po1769
-rw-r--r--po/ka.po1771
-rw-r--r--po/kk.po1770
-rw-r--r--po/ko_KR.po1768
-rw-r--r--po/lt.po1770
-rw-r--r--po/lv.po1770
-rw-r--r--po/mk.po1770
-rw-r--r--po/nb.po1770
-rw-r--r--po/nl_NL.po1770
-rw-r--r--po/phone.pot771
-rw-r--r--po/pl.po1770
-rwxr-xr-xpo/poManager141
-rw-r--r--po/pt_BR.po1770
-rw-r--r--po/pt_PT.po1772
-rw-r--r--po/ro.po1770
-rw-r--r--po/ru_RU.po1772
-rw-r--r--po/sk.po1770
-rw-r--r--po/sl.po1770
-rw-r--r--po/sr.po1770
-rw-r--r--po/sv.po1770
-rw-r--r--po/tr_TR.po1772
-rw-r--r--po/uk.po1769
-rwxr-xr-xpo/update-po.sh59
-rw-r--r--po/uz.po1768
-rw-r--r--po/zh_CN.po1765
-rw-r--r--po/zh_HK.po1765
-rw-r--r--po/zh_SG.po1765
-rw-r--r--po/zh_TW.po1765
-rwxr-xr-xscripts/install.sh23
-rwxr-xr-xscripts/pull_binaries.sh8
-rwxr-xr-xscripts/push.sh28
-rwxr-xr-xscripts/run.sh3
-rw-r--r--test/CMakeLists.txt14
-rw-r--r--test/ReadMe.txt5
-rw-r--r--test/common.cpp22
438 files changed, 170137 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a8d7270
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/debugenv
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100755
index 0000000..67e6b56
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,101 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(phone CXX)
+
+SET(VENDOR "tizen")
+SET(PACKAGE ${PROJECT_NAME})
+SET(PKGNAME "org.${VENDOR}.${PACKAGE}")
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(BINDIR "${PREFIX}/bin")
+SET(RESDIR "${PREFIX}/res")
+SET(DATADIR "${PREFIX}/data")
+SET(LOCALEDIR "/usr/ug/res/locale")
+SET(EDC_SRC_DIR "${CMAKE_SOURCE_DIR}/lib/edc")
+SET(EDJDIR "/usr/ug/res/edje/ug-${PACKAGE}")
+SET(IMGDIR "/usr/ug/res/images/ug-${PACKAGE}")
+SET(VERSION_MAJOR 0)
+SET(VERSION "${VERSION_MAJOR}.6.63.29")
+
+SET(CMAKE_SKIP_BUILD_RPATH FALSE)
+SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
+SET(CMAKE_INSTALL_RPATH "/usr/ug/lib")
+SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+ SET(CMAKE_BUILD_TYPE "Release")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED
+ appcore-efl
+ ui-gadget-1
+ contacts-service2
+ ecore-x
+ evas
+ ecore
+ ecore-input
+ edje
+ eina
+ syspopup-caller
+ capi-appfw-application
+ capi-system-runtime-info
+ accounts-svc
+ capi-content-media-content
+ capi-appfw-app-manager
+ capi-system-info
+ notification
+ badge
+ efl-assist
+ icu-i18n
+)
+
+FOREACH(flag ${pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -fvisibility=hidden")
+SET(CMAKE_CXX_FLAGS_DEBUG "")
+SET(CMAKE_CXX_FLAGS_RELEASE "")
+
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--hash-style=both -Wl,--as-needed")
+SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--hash-style=both -Wl,--as-needed")
+
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+IF("${ARCH}" STREQUAL "arm")
+ ADD_DEFINITIONS("-DTARGET")
+ MESSAGE("add -DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_DEFINITIONS("-DVENDOR=\"${VENDOR}\"")
+ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"")
+ADD_DEFINITIONS("-DPACKAGE_NAME=\"${PKGNAME}\"")
+ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"")
+ADD_DEFINITIONS("-DEDJDIR=\"${EDJDIR}\"")
+ADD_DEFINITIONS("-DIMGDIR=\"${IMGDIR}\"")
+ADD_DEFINITIONS("-DUGDATADIR=\"${UGDATADIR}\"")
+
+INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/lib/images/phoneug_images/ DESTINATION ${IMGDIR})
+INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/lib/images/contact_images/ DESTINATION ${IMGDIR})
+INSTALL(DIRECTORY DESTINATION ${DATADIR})
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/org.tizen.phone.rule DESTINATION /opt/etc/smack/accesses.d)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/org.tizen.contacts.rule DESTINATION /opt/etc/smack/accesses.d)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/org.tizen.contacts-viewer.rule DESTINATION /opt/etc/smack/accesses.d)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/org.tizen.contacts-appservice.rule DESTINATION /opt/etc/smack/accesses.d)
+
+ADD_SUBDIRECTORY(lib)
+ADD_SUBDIRECTORY(phone)
+ADD_SUBDIRECTORY(contacts)
+ADD_SUBDIRECTORY(contacts-viewer)
+ADD_SUBDIRECTORY(contacts-appservice)
+
+# i18n
+ADD_SUBDIRECTORY(po)
+
+#test
+#if(DEFINED TEST)
+# add_subdirectory(test)
+#endif(DEFINED TEST)
diff --git a/LICENSE.flora b/LICENSE.flora
new file mode 100644
index 0000000..571fe79
--- /dev/null
+++ b/LICENSE.flora
@@ -0,0 +1,206 @@
+Flora License
+
+Version 1.1, April, 2013
+
+http://floralicense.org/license/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+"License" shall mean the terms and conditions for use, reproduction,
+and distribution as defined by Sections 1 through 9 of this document.
+
+"Licensor" shall mean the copyright owner or entity authorized by
+the copyright owner that is granting the License.
+
+"Legal Entity" shall mean the union of the acting entity and
+all other entities that control, are controlled by, or are
+under common control with that entity. For the purposes of
+this definition, "control" means (i) the power, direct or indirect,
+to cause the direction or management of such entity,
+whether by contract or otherwise, or (ii) ownership of fifty percent (50%)
+or more of the outstanding shares, or (iii) beneficial ownership of
+such entity.
+
+"You" (or "Your") shall mean an individual or Legal Entity
+exercising permissions granted by this License.
+
+"Source" form shall mean the preferred form for making modifications,
+including but not limited to software source code, documentation source,
+and configuration files.
+
+"Object" form shall mean any form resulting from mechanical
+transformation or translation of a Source form, including but
+not limited to compiled object code, generated documentation,
+and conversions to other media types.
+
+"Work" shall mean the work of authorship, whether in Source or Object form,
+made available under the License, as indicated by a copyright notice
+that is included in or attached to the work (an example is provided
+in the Appendix below).
+
+"Derivative Works" shall mean any work, whether in Source or Object form,
+that is based on (or derived from) the Work and for which the editorial
+revisions, annotations, elaborations, or other modifications represent,
+as a whole, an original work of authorship. For the purposes of this License,
+Derivative Works shall not include works that remain separable from,
+or merely link (or bind by name) to the interfaces of, the Work and
+Derivative Works thereof.
+
+"Contribution" shall mean any work of authorship, including the original
+version of the Work and any modifications or additions to that Work or
+Derivative Works thereof, that is intentionally submitted to Licensor
+for inclusion in the Work by the copyright owner or by an individual or
+Legal Entity authorized to submit on behalf of the copyright owner.
+For the purposes of this definition, "submitted" means any form of
+electronic, verbal, or written communication sent to the Licensor or
+its representatives, including but not limited to communication on
+electronic mailing lists, source code control systems, and issue
+tracking systems that are managed by, or on behalf of, the Licensor
+for the purpose of discussing and improving the Work, but excluding
+communication that is conspicuously marked or otherwise designated
+in writing by the copyright owner as "Not a Contribution."
+
+"Contributor" shall mean Licensor and any individual or Legal Entity
+on behalf of whom a Contribution has been received by Licensor and
+subsequently incorporated within the Work.
+
+"Tizen Certified Platform" shall mean a software platform that complies
+with the standards set forth in the Tizen Compliance Specification
+and passes the Tizen Compliance Tests as defined from time to time
+by the Tizen Technical Steering Group and certified by the Tizen
+Association or its designated agent.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+this License, each Contributor hereby grants to You a perpetual,
+worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+copyright license to reproduce, prepare Derivative Works of,
+publicly display, publicly perform, sublicense, and distribute the
+Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+this License, each Contributor hereby grants to You a perpetual,
+worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+(except as stated in this section) patent license to make, have made,
+use, offer to sell, sell, import, and otherwise transfer the Work
+solely as incorporated into a Tizen Certified Platform, where such
+license applies only to those patent claims licensable by such
+Contributor that are necessarily infringed by their Contribution(s)
+alone or by combination of their Contribution(s) with the Work solely
+as incorporated into a Tizen Certified Platform to which such
+Contribution(s) was submitted. If You institute patent litigation
+against any entity (including a cross-claim or counterclaim
+in a lawsuit) alleging that the Work or a Contribution incorporated
+within the Work constitutes direct or contributory patent infringement,
+then any patent licenses granted to You under this License for that
+Work shall terminate as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+Work or Derivative Works thereof pursuant to the copyright license
+above, in any medium, with or without modifications, and in Source or
+Object form, provided that You meet the following conditions:
+
+ 1. You must give any other recipients of the Work or Derivative Works
+ a copy of this License; and
+ 2. You must cause any modified files to carry prominent notices stating
+ that You changed the files; and
+ 3. You must retain, in the Source form of any Derivative Works that
+ You distribute, all copyright, patent, trademark, and attribution
+ notices from the Source form of the Work, excluding those notices
+ that do not pertain to any part of the Derivative Works; and
+ 4. If the Work includes a "NOTICE" text file as part of its distribution,
+ then any Derivative Works that You distribute must include a readable
+ copy of the attribution notices contained within such NOTICE file,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works, in at least one of the following places:
+ within a NOTICE text file distributed as part of the Derivative Works;
+ within the Source form or documentation, if provided along with the
+ Derivative Works; or, within a display generated by the Derivative Works,
+ if and wherever such third-party notices normally appear.
+ The contents of the NOTICE file are for informational purposes only
+ and do not modify the License. You may add Your own attribution notices
+ within Derivative Works that You distribute, alongside or as an addendum
+ to the NOTICE text from the Work, provided that such additional attribution
+ notices cannot be construed as modifying the License. You may add Your own
+ copyright statement to Your modifications and may provide additional or
+ different license terms and conditions for use, reproduction, or
+ distribution of Your modifications, or for any such Derivative Works
+ as a whole, provided Your use, reproduction, and distribution of
+ the Work otherwise complies with the conditions stated in this License
+ and your own copyright statement or terms and conditions do not conflict
+ the conditions stated in the License including section 3.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+any Contribution intentionally submitted for inclusion in the Work
+by You to the Licensor shall be under the terms and conditions of
+this License, without any additional terms or conditions.
+Notwithstanding the above, nothing herein shall supersede or modify
+the terms of any separate license agreement you may have executed
+with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+names, trademarks, service marks, or product names of the Licensor,
+except as required for reasonable and customary use in describing the
+origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+agreed to in writing, Licensor provides the Work (and each
+Contributor provides its Contributions) on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+implied, including, without limitation, any warranties or conditions
+of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+PARTICULAR PURPOSE. You are solely responsible for determining the
+appropriateness of using or redistributing the Work and assume any
+risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+whether in tort (including negligence), contract, or otherwise,
+unless required by applicable law (such as deliberate and grossly
+negligent acts) or agreed to in writing, shall any Contributor be
+liable to You for damages, including any direct, indirect, special,
+incidental, or consequential damages of any character arising as a
+result of this License or out of the use or inability to use the
+Work (including but not limited to damages for loss of goodwill,
+work stoppage, computer failure or malfunction, or any and all
+other commercial damages or losses), even if such Contributor
+has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+the Work or Derivative Works thereof, You may choose to offer,
+and charge a fee for, acceptance of support, warranty, indemnity,
+or other liability obligations and/or rights consistent with this
+License. However, in accepting such obligations, You may act only
+on Your own behalf and on Your sole responsibility, not on behalf
+of any other Contributor, and only if You agree to indemnify,
+defend, and hold each Contributor harmless for any liability
+incurred by, or claims asserted against, such Contributor by reason
+of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Flora License to your work
+
+To apply the Flora License to your work, attach the following
+boilerplate notice, with the fields enclosed by brackets "[]"
+replaced with your own identifying information. (Don't include
+the brackets!) The text should be enclosed in the appropriate
+comment syntax for the file format. We also recommend that a
+file or class name and description of purpose be included on the
+same "printed page" as the copyright notice for easier
+identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
+
diff --git a/NOTICE b/NOTICE
new file mode 100755
index 0000000..f93330b
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,3 @@
+Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Flora License, Version 1.1.
+Please, see the LICENSE.flora file for Flora License, Version 1.1 terms and conditions.
diff --git a/build b/build
new file mode 100755
index 0000000..cc0bf39
--- /dev/null
+++ b/build
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+usage()
+{
+ echo "Usage: `basename $0` [-h|--help] [-e|--emulator] | [-d|--device] [-i|--init] [-t|--test]
+ -h, --help Show this message.
+ -e, --emulator Build for emulator (i586, default).
+ -d, --device Build for device (armv7l).
+ -i, --init Build online (without --noinit).
+ -t, --test Build with tests."
+}
+
+ARCH="i586"
+NOINIT="--noinit"
+OPTS=$(getopt -o "edith" -l "emulator,device,init,test,help" -- "$@" 2> /dev/null)
+
+if [ $? -ne 0 ]
+then
+ usage
+ exit 1
+fi
+
+for opt in $OPTS
+do
+ case $opt in
+ -e|--emulator|--)
+ ;;
+ -d|--device)
+ ARCH="armv7l"
+ ;;
+ -i|--init)
+ NOINIT=""
+ ;;
+ -t|--test)
+ TEST=1
+ ;;
+ -h|--help)
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+if [ -z $TEST ]
+then
+ gbs build -A $ARCH --include-all --keep-packs $NOINIT
+else
+ gbs build -A $ARCH --include-all --keep-packs $NOINIT --define 'TEST ON'
+fi
+
diff --git a/buildAndDeploy.sh b/buildAndDeploy.sh
new file mode 100755
index 0000000..58c146c
--- /dev/null
+++ b/buildAndDeploy.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+# how to use
+# ./buildAndDeploy.sh i586 --clean
+# ./buildAndDeploy.sh armv7l
+
+architect=$1
+if [ -z "$1" ]; then
+ architect=i586
+fi
+
+echo "building ..."
+echo "gbs build -A $architect $2 --include-all --keep-packs"
+gbs build -A $architect $2 --include-all --keep-packs
+
+echo "build done"
+echo "installing ..."
+
+rm -rf debugenv
+cd "scripts"
+./push.sh /home/developer $architect
+./pull_binaries.sh
+cd "../"
+
diff --git a/config/gdbscript_contacts_armv7l b/config/gdbscript_contacts_armv7l
new file mode 100644
index 0000000..65dfae4
--- /dev/null
+++ b/config/gdbscript_contacts_armv7l
@@ -0,0 +1,2 @@
+set solib-absolute-prefix /home/andy/GBS-ROOT/local/BUILD-ROOTS/scratch.armv7l.0/
+symbol-file /home/andy/workspace/contacts/debugenv/contacts.debug
diff --git a/config/gdbscript_contacts_i586 b/config/gdbscript_contacts_i586
new file mode 100644
index 0000000..2680087
--- /dev/null
+++ b/config/gdbscript_contacts_i586
@@ -0,0 +1,2 @@
+set solib-absolute-prefix /home/andy/GBS-ROOT/local/BUILD-ROOTS/scratch.i586.0/
+symbol-file /home/andy/workspace/contacts/debugenv/contacts.debug
diff --git a/contacts-appservice/CMakeLists.txt b/contacts-appservice/CMakeLists.txt
new file mode 100644
index 0000000..4f0849f
--- /dev/null
+++ b/contacts-appservice/CMakeLists.txt
@@ -0,0 +1,30 @@
+SET(APPSERVICE contacts-appservice)
+
+SET(SRCS contacts-appservice.cpp)
+
+SET(APPSERVICE_PKGNAME "org.${VENDOR}.${APPSERVICE}")
+SET(APPSERVICE_PREFIX "/usr/apps/${APPSERVICE_PKGNAME}")
+SET(APPSERVICE_BINDIR "${APPSERVICE_PREFIX}/bin")
+SET(APPSERVICE_RESDIR "${APPSERVICE_PREFIX}/res")
+SET(APPSERVICE_DATADIR "${APPSERVICE_PREFIX}/data")
+
+ADD_DEFINITIONS("-DAPPSERVICE_PACKAGE=\"${APPSERVICE}\"")
+ADD_DEFINITIONS("-DAPPSERVICE_PACKAGE_NAME=\"${APPSERVICE_PKGNAME}\"")
+
+ADD_EXECUTABLE(${APPSERVICE} ${SRCS})
+SET_TARGET_PROPERTIES(${APPSERVICE} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS} -fpie")
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib/common/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib/common/Utils/include)
+
+pkg_check_modules(appservice_pkgs REQUIRED appcore-efl ecore-x capi-appfw-application ui-gadget-1 utilX)
+FOREACH(flag ${appservice_pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+TARGET_LINK_LIBRARIES(${APPSERVICE} ${appservice_pkgs_LDFLAGS})
+
+INSTALL(FILES ${CMAKE_BINARY_DIR}/contacts-appservice/org.tizen.contacts-appservice.xml DESTINATION "/usr/share/packages")
+INSTALL(TARGETS ${APPSERVICE} DESTINATION ${APPSERVICE_BINDIR})
+INSTALL(DIRECTORY DESTINATION ${APPSERVICE_DATADIR})
+
+# install icon
+INSTALL(FILES icon_${APPSERVICE}.png DESTINATION "/usr/share/icons/default/small" RENAME "${APPSERVICE_PKGNAME}.png")
diff --git a/contacts-appservice/contacts-appservice.cpp b/contacts-appservice/contacts-appservice.cpp
new file mode 100755
index 0000000..0a49443
--- /dev/null
+++ b/contacts-appservice/contacts-appservice.cpp
@@ -0,0 +1,375 @@
+/*
+ * 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.
+ */
+
+#include <stdio.h>
+#include <aul.h>
+#include <Ecore_X.h>
+#include <ui-gadget.h>
+#include <app.h>
+#include <utilX.h>
+
+#include "phone.h"
+
+#if !defined(APPSERVICE_PACKAGE)
+# define APPSERVICE_PACKAGE "contacts-appservice"
+#endif
+
+#define CONTACTS_LIST_UG "contacts-list-efl"
+#define CONTACTS_DETAILS_UG "contacts-details-efl"
+
+#define CT_LIST_UG_SELECT_CONTACT_ADD_TO_HOME "15"
+#define CT_LIST_UG_SELECT_GROUP_ADD_TO_HOME "16"
+#define CT_DETAILS_UG_REQUEST_ADD_WITH_NUM "22"
+#define CT_DETAILS_UG_REQUEST_DETAIL "0"
+
+#define CT_APPSERVICE_REQUEST_DETAIL 0
+#define CT_APPSERVICE_ADD_CONTACT_LIVEBOX 1
+#define CT_APPSERVICE_ADD_GROUP_LIVEBOX 2
+#define CT_APPSERVICE_ADD_WITH_NUM 22
+
+typedef struct
+{
+ Evas_Object *win;
+ Evas_Object *layout;
+ ui_gadget_h ug;
+ Ecore_Event_Handler *event_handler;
+} ct_app_service_data;
+
+static Evas_Object* appservice_create_win(const char *name)
+{
+ Evas_Object *eo;
+ int w, h;
+
+ eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
+ if (eo)
+ {
+ elm_win_title_set(eo, name);
+ elm_win_conformant_set(eo, EINA_TRUE);
+#ifdef _PHONE_CONTACTS_DESKTOP_MODE_
+#else
+ elm_win_borderless_set(eo, EINA_TRUE);
+#endif
+ ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
+ evas_object_resize(eo, w, h);
+ elm_win_indicator_mode_set(eo, ELM_WIN_INDICATOR_SHOW);
+ }
+
+ return eo;
+}
+
+static Eina_Bool __appservice_hard_key_down(void *data, int type,
+ void *event_info)
+{
+ Ecore_Event_Key *ev = (Ecore_Event_Key *) event_info;
+ if (0 == strcmp(ev->keyname, KEY_HOME))
+ elm_exit();
+ return ECORE_CALLBACK_DONE;
+}
+
+static void __appservice_grab_key(ct_app_service_data *cappservice_d)
+{
+ Ecore_X_Window xwin;
+ Ecore_X_Display *disp = NULL;
+
+ disp = ecore_x_display_get();
+ xwin = elm_win_xwindow_get(cappservice_d->win);
+ utilx_grab_key((Display *) disp, xwin, KEY_HOME, TOP_POSITION_GRAB);
+ cappservice_d->event_handler = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
+ __appservice_hard_key_down, cappservice_d);
+}
+
+static void __appservice_ungrab_key(ct_app_service_data *cappservice_d)
+{
+ Ecore_X_Window xwin;
+ Ecore_X_Display *disp = NULL;
+
+ disp = ecore_x_display_get();
+ xwin = elm_win_xwindow_get(cappservice_d->win);
+ utilx_ungrab_key((Display *) disp, xwin, KEY_HOME);
+ if (cappservice_d->event_handler)
+ {
+ ecore_event_handler_del(cappservice_d->event_handler);
+ cappservice_d->event_handler = NULL;
+ }
+}
+
+static bool appservice_create(void *data)
+{
+ PH_FN_CALL;
+ ct_app_service_data *cappservice_d = (ct_app_service_data *) data;
+ Evas_Object *win;
+
+ /* create window */
+ win = appservice_create_win(APPSERVICE_PACKAGE);
+ p_retvm_if(NULL == win, false, "ctapp_create_win() Failed");
+ cappservice_d->win = win;
+
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ evas_object_show(win);
+
+ UG_INIT_EFL(cappservice_d->win, UG_OPT_INDICATOR_ENABLE);
+ __appservice_grab_key(cappservice_d);
+
+ return true;
+}
+
+static void appservice_terminate(void *data)
+{
+ PH_FN_CALL;
+ ct_app_service_data *cappservice_d = (ct_app_service_data *) data;
+
+ __appservice_ungrab_key(cappservice_d);
+
+ if (cappservice_d->ug)
+ ug_destroy(cappservice_d->ug);
+
+ if (cappservice_d->win)
+ evas_object_del(cappservice_d->win);
+
+ return;
+}
+
+static void appservice_pause(void *data)
+{
+ PH_FN_CALL;
+ return;
+}
+
+static void appservice_resume(void *data)
+{
+ PH_FN_CALL;
+ return;
+}
+
+static void appservice_ug_layout_cb(ui_gadget_h ug, enum ug_mode mode,
+ void *priv)
+{
+ ct_app_service_data *cappservice_d = (ct_app_service_data *) priv;
+ Evas_Object *base;
+
+ if (!ug)
+ return;
+
+ base = (Evas_Object *) ug_get_layout(ug);
+ if (!base)
+ {
+ ERR("ug_get_layout() return NULL");
+ ug_destroy(ug);
+ return;
+ }
+ evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ ug_disable_effect(ug);
+ elm_object_content_set(cappservice_d->layout, base);
+ evas_object_show(base);
+}
+
+static void appservice_ug_destroy_cb(ui_gadget_h ug, void *priv)
+{
+ ct_app_service_data *cappservice_d = (ct_app_service_data *) priv;
+ p_retm_if(NULL == ug, "ug is NULL");
+
+ ug_destroy(ug);
+ cappservice_d->ug = NULL;
+
+ elm_exit();
+}
+
+static void appservice_lauch_list_ug(ct_app_service_data *cappservice_d,
+ int type)
+{
+ service_h service;
+ struct ug_cbs cbs = { 0 };
+
+ p_retm_if(NULL == cappservice_d, "parameter(cappservice_d) is NULL");
+
+ service_create(&service);
+
+ if (2 == type)
+ service_add_extra_data(service, "type",
+ CT_LIST_UG_SELECT_GROUP_ADD_TO_HOME);
+ else
+ service_add_extra_data(service, "type",
+ CT_LIST_UG_SELECT_CONTACT_ADD_TO_HOME);
+
+ cbs.layout_cb = appservice_ug_layout_cb;
+ cbs.result_cb = NULL;
+ cbs.destroy_cb = appservice_ug_destroy_cb;
+ cbs.priv = cappservice_d;
+
+ cappservice_d->ug = ug_create(NULL, CONTACTS_LIST_UG, UG_MODE_FULLVIEW,
+ service, &cbs);
+ service_destroy(service);
+}
+
+static void appservice_launch_details_ug(ct_app_service_data *cappservice_d,
+ int type, char *val)
+{
+ service_h service;
+ struct ug_cbs cbs = { 0 };
+
+ p_retm_if(NULL == cappservice_d, "parameter(cappservice_d) is NULL");
+
+ service_create(&service);
+ if (type == CT_APPSERVICE_REQUEST_DETAIL)
+ {
+ service_add_extra_data(service, "type", CT_DETAILS_UG_REQUEST_DETAIL);
+ PH_DBG("val=%s", val);
+ if (val && *val)
+ service_add_extra_data(service, "person_id", val);
+ }
+ else if (type == CT_APPSERVICE_ADD_WITH_NUM)
+ {
+ service_add_extra_data(service, "type",
+ CT_DETAILS_UG_REQUEST_ADD_WITH_NUM);
+ if (val && *val)
+ service_add_extra_data(service, "ct_num", val);
+ }
+
+ cbs.layout_cb = appservice_ug_layout_cb;
+ cbs.result_cb = NULL;
+ cbs.destroy_cb = appservice_ug_destroy_cb;
+ cbs.priv = cappservice_d;
+
+ cappservice_d->ug = ug_create(NULL, CONTACTS_DETAILS_UG, UG_MODE_FULLVIEW,
+ service, &cbs);
+ service_destroy(service);
+
+}
+
+static Evas_Object* __appservice_create_base_layout(Evas_Object *parent,
+ bool is_fullview)
+{
+ Evas_Object *base;
+
+ base = elm_layout_add(parent);
+ p_retvm_if(NULL == base, NULL, "elm_layout_add() Failed");
+ if (is_fullview)
+ elm_layout_theme_set(base, "layout", "application", "default");
+ else
+ elm_layout_theme_set(base, "layout", "application", "noindicator");
+ evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+ elm_object_content_set(parent, base);
+
+ return base;
+}
+
+static void __appservice_create_bg(Evas_Object *win)
+{
+ Evas_Object *bg;
+
+ bg = elm_bg_add(win);
+ p_retm_if(NULL == bg, "elm_bg_add() return NULL");
+ evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_object_part_content_set(win, "elm.swallow.bg", bg);
+ elm_win_resize_object_add(win, bg);
+ evas_object_show(bg);
+}
+
+static Evas_Object* __appservice_create_conformant(Evas_Object *win)
+{
+ Evas_Object *conform;
+
+ conform = elm_conformant_add(win);
+ p_retvm_if(NULL == conform, NULL, "elm_conformant_add() Failed");
+ evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(win, conform);
+ evas_object_show(conform);
+
+ return conform;
+}
+
+static void __appservice_create_content(ct_app_service_data *cappservice_data)
+{
+ Evas_Object *conform = NULL;
+
+ __appservice_create_bg(cappservice_data->win);
+ conform = __appservice_create_conformant(cappservice_data->win);
+ cappservice_data->layout = __appservice_create_base_layout(conform, true);
+}
+
+static void appservice_service(service_h service, void *data)
+{
+ PH_FN_CALL;
+ char *val = NULL;
+ int ret;
+ int type;
+ ct_app_service_data *cappservice_d = (ct_app_service_data *) data;
+
+ __appservice_create_content(cappservice_d);
+
+ ret = service_get_extra_data(service, "type", &val);
+ if (SERVICE_ERROR_NONE != ret)
+ {
+ ERR("service_get_operation is failed(%d)", ret);
+ elm_exit();
+ return;
+ }
+
+ if (val && *val)
+ {
+ char *extra_data = NULL;
+ type = atoi(val);
+ free(val);
+
+ if (type == CT_APPSERVICE_ADD_CONTACT_LIVEBOX
+ || type == CT_APPSERVICE_ADD_GROUP_LIVEBOX)
+ appservice_lauch_list_ug(cappservice_d, type);
+ else if (type == CT_APPSERVICE_REQUEST_DETAIL)
+ {
+ ret = service_get_extra_data(service, "person_id", &extra_data);
+ appservice_launch_details_ug(cappservice_d,
+ CT_APPSERVICE_REQUEST_DETAIL, extra_data);
+ free(extra_data);
+ }
+ else if (type == CT_APPSERVICE_ADD_WITH_NUM)
+ {
+ ret = service_get_extra_data(service, "ct_num", &extra_data);
+ appservice_launch_details_ug(cappservice_d,
+ CT_APPSERVICE_ADD_WITH_NUM, extra_data);
+ free(extra_data);
+ }
+ else
+ {
+ ERR("Invalid type(%d)", type);
+ elm_exit();
+ return;
+ }
+ }
+ elm_win_activate(cappservice_d->win);
+ return;
+}
+
+API int main(int argc, char *argv[])
+{
+ PH_FN_CALL;
+
+ ct_app_service_data ad = { 0 };
+ app_event_callback_s event_callback = { 0, };
+ event_callback.create = appservice_create;
+ event_callback.terminate = appservice_terminate;
+ event_callback.pause = appservice_pause;
+ event_callback.resume = appservice_resume;
+ event_callback.service = appservice_service;
+ event_callback.low_memory = NULL;
+ event_callback.low_battery = NULL;
+ event_callback.device_orientation = NULL;
+ event_callback.language_changed = NULL;
+ event_callback.region_format_changed = NULL;
+
+ return app_efl_main(&argc, &argv, &event_callback, &ad);
+}
diff --git a/contacts-appservice/icon_contacts-appservice.png b/contacts-appservice/icon_contacts-appservice.png
new file mode 100644
index 0000000..900dcde
--- /dev/null
+++ b/contacts-appservice/icon_contacts-appservice.png
Binary files differ
diff --git a/contacts-appservice/org.tizen.contacts-appservice.xml b/contacts-appservice/org.tizen.contacts-appservice.xml
new file mode 100644
index 0000000..6ee09a7
--- /dev/null
+++ b/contacts-appservice/org.tizen.contacts-appservice.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns="http://tizen.org/ns/packages" package="org.tizen.contacts-appservice" version="0.1.2" install-location="internal-only">
+ <label>Contacts-Appservice</label>
+ <author email="ensung.park@samsung.com" href="www.samsung.com">ensung park</author>
+ <description>Contacts-appservice Application</description>
+ <ui-application appid="org.tizen.contacts-appservice" exec="/usr/apps/org.tizen.contacts-appservice/bin/contacts-appservice" nodisplay="true" multiple="false" type="capp" taskmanage="true">
+ <icon>org.tizen.contacts.png</icon>
+ <label>Contacts-Appservice</label>
+ <label xml:lang="en-us">Contacts-Appservice</label>
+ <label xml:lang="nl-nl">Contacts-Appservice</label>
+ <label xml:lang="de-de">Contacts-Appservice</label>
+ <label xml:lang="en-gb">Contacts-Appservice</label>
+ <label xml:lang="zh-hk">Contacts-Appservice</label>
+ <label xml:lang="zh-cn">Contacts-Appservice</label>
+ <label xml:lang="ru-ru">Contacts-Appservice</label>
+ <label xml:lang="zh-tw">Contacts-Appservice</label>
+ <label xml:lang="ja-jp">Contacts-Appservice</label>
+ <label xml:lang="es-es">Contacts-Appservice</label>
+ <label xml:lang="el-gr">Contacts-Appservice</label>
+ <label xml:lang="it-it">Contacts-Appservice</label>
+ <label xml:lang="tr-tr">Contacts-Appservice</label>
+ <label xml:lang="pt-pt">Contacts-Appservice</label>
+ <label xml:lang="fr-fr">Contacts-Appservice</label>
+ <label xml:lang="ko-kr">Contacts-Appservice</label>
+ </ui-application>
+</manifest>
diff --git a/contacts-viewer/CMakeLists.txt b/contacts-viewer/CMakeLists.txt
new file mode 100644
index 0000000..32f3555
--- /dev/null
+++ b/contacts-viewer/CMakeLists.txt
@@ -0,0 +1,27 @@
+SET(VIEWER contacts-viewer)
+
+SET(SRCS contacts-viewer.cpp)
+
+SET(VV_PKGNAME "org.${VENDOR}.${VIEWER}")
+SET(VV_PREFIX "/usr/apps/${VV_PKGNAME}")
+SET(VV_BINDIR "${VV_PREFIX}/bin")
+SET(VV_RESDIR "${VV_PREFIX}/res")
+SET(VV_DATADIR "${VV_PREFIX}/data")
+
+ADD_DEFINITIONS("-DCV_PACKAGE=\"${VIEWER}\"")
+ADD_DEFINITIONS("-DCV_PACKAGE_NAME=\"${VV_PKGNAME}\"")
+
+ADD_EXECUTABLE(${VIEWER} ${SRCS})
+SET_TARGET_PROPERTIES(${VIEWER} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS} -fpie")
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib/common/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib/common/Utils/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib/details/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib/list/include)
+TARGET_LINK_LIBRARIES(${VIEWER} ug-contacts-details-efl ug-contacts-list-efl "-pie")
+
+INSTALL(FILES ${CMAKE_BINARY_DIR}/contacts-viewer/org.tizen.contacts-viewer.xml DESTINATION "/usr/share/packages")
+INSTALL(TARGETS ${VIEWER} DESTINATION ${VV_BINDIR})
+INSTALL(DIRECTORY DESTINATION ${VV_DATADIR})
+
+# install icon
+INSTALL(FILES icon_${VIEWER}.png DESTINATION "/usr/share/icons/default/small" RENAME "${VV_PKGNAME}.png")
diff --git a/contacts-viewer/contacts-viewer.cpp b/contacts-viewer/contacts-viewer.cpp
new file mode 100755
index 0000000..0b1451a
--- /dev/null
+++ b/contacts-viewer/contacts-viewer.cpp
@@ -0,0 +1,621 @@
+/*
+ * 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.
+ */
+
+#include <stdio.h>
+#include <aul.h>
+#include <Ecore_X.h>
+#include <ui-gadget.h>
+#include <app.h>
+
+#include "phone.h"
+#include "ct-detail.h"
+#include "ct-list.h"
+
+#if !defined(CV_PACKAGE)
+# define CV_PACKAGE "contacts-viewer"
+#endif
+
+typedef struct
+{
+ char *path;
+ Evas_Object *win;
+ Evas_Object *content;
+ Evas_Object *popup;
+ Eina_List *list;
+ ph_progress_info *p_info;
+#ifdef _PHONE_CONTACTS_DESKTOP_MODE_
+ Evas_Object *icon;
+ Evas_Object *prev_btn;
+#endif
+ int current_rotate;
+} ct_viewer_data;
+
+static void cv_win_del(void *data, Evas_Object *obj, void *event)
+{
+ elm_exit();
+}
+
+static Evas_Object* cv_create_win(const char *name)
+{
+ Evas_Object *eo;
+ int w, h;
+
+ eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
+ if (eo)
+ {
+ elm_win_title_set(eo, name);
+#ifdef _PHONE_CONTACTS_DESKTOP_MODE_
+#else
+ elm_win_borderless_set(eo, EINA_TRUE);
+#endif
+ evas_object_smart_callback_add(eo, "delete,request", cv_win_del, NULL);
+ ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
+ evas_object_resize(eo, w, h);
+ elm_win_indicator_mode_set(eo, ELM_WIN_INDICATOR_SHOW);
+ }
+ elm_win_conformant_set(eo, EINA_TRUE);
+ return eo;
+}
+
+#ifdef _PHONE_CONTACTS_DESKTOP_MODE_
+static Evas_Object* __set_win_icon(ct_viewer_data *ad)
+{
+ Evas_Object *image = evas_object_image_add(evas_object_evas_get(ad->win));
+ evas_object_image_file_set(image, "/usr/share/icons/default/small/org.tizen.contacts-viewer.png", NULL);
+ elm_win_icon_object_set(ad->win, image);
+
+ return image;
+}
+
+static void __win_profile_changed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ if(data == NULL)
+ return;
+
+ ct_viewer_data *ad = data;
+ Evas_Object *navi = evas_object_data_get(ad->win, "naviframe");
+ const char *profile = elm_config_profile_get();
+ if(!strcmp(profile, "desktop"))
+ {
+ Elm_Object_Item *navi_item = elm_naviframe_bottom_item_get(navi);
+ ad->prev_btn = elm_object_item_part_content_unset(navi_item, "prev_btn");
+ elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_HIDE);
+ if(!ad->icon)
+ ad->icon = __set_win_icon(ad);
+ }
+ else
+ {
+ Elm_Object_Item *navi_item = elm_naviframe_bottom_item_get(navi);
+ if (ad->prev_btn)
+ {
+ elm_object_item_part_content_set(navi_item, "prev_btn", ad->prev_btn);
+ ad->prev_btn = NULL;
+ }
+ elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW);
+ }
+}
+#endif // _PHONE_CONTACTS_DESKTOP_MODE_
+static void __viewer_rotate_cb(void *data, Evas_Object *obj, void *event)
+{
+ ct_viewer_data *cviewer_d = (ct_viewer_data *) data;
+ int changed_rotate = elm_win_rotation_get(obj);
+
+#ifndef _PHONE_CONTACTS_DESKTOP_MODE_
+ const char *config = elm_config_profile_get();
+ if (!strcmp(config, "desktop"))
+ return;
+#endif
+ p_retm_if(cviewer_d == NULL || cviewer_d->win == NULL, "Paramter is NULL");
+
+ if (changed_rotate != cviewer_d->current_rotate)
+ {
+ ERR("rotate changed %d", changed_rotate);
+ cviewer_d->current_rotate = changed_rotate;
+ switch (cviewer_d->current_rotate)
+ {
+ case 0:
+ ug_send_event (UG_EVENT_ROTATE_PORTRAIT);
+ break;
+ case 180:
+ ug_send_event (UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN);
+ break;
+ case 270:
+ ug_send_event (UG_EVENT_ROTATE_LANDSCAPE);
+ break;
+ case 90:
+ ug_send_event (UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN);
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+static bool viewer_create(void *data)
+{
+ int err = CONTACTS_ERROR_NONE;
+ ct_viewer_data *cviewer_d = (ct_viewer_data *) data;
+ Evas_Object *win;
+
+ err = contacts_connect2();
+ p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_connect2() Failed(%d)",
+ err);
+
+ /* create window */
+ win = cv_create_win(CV_PACKAGE);
+ p_retvm_if(NULL == win, false, "ctapp_create_win() Failed");
+ cviewer_d->win = win;
+#ifdef _PHONE_CONTACTS_DESKTOP_MODE_
+ evas_object_smart_callback_add(cviewer_d->win, "profile,changed", __win_profile_changed_cb, cviewer_d);
+#endif
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ evas_object_show(win);
+
+ if (elm_win_wm_rotation_supported_get(win))
+ {
+ int rotation[4] = { 0, 90, 180, 270 };
+ elm_win_wm_rotation_available_rotations_set(win,
+ (const int *) (&rotation), 4);
+ cviewer_d->current_rotate = elm_win_rotation_get(win);
+ ERR("rotate current %d", cviewer_d->current_rotate);
+ evas_object_smart_callback_add(win, "wm,rotation,changed",
+ __viewer_rotate_cb, cviewer_d);
+ }
+
+ UG_INIT_EFL(cviewer_d->win, UG_OPT_INDICATOR_PORTRAIT_ONLY);
+
+ return true;
+}
+
+static void viewer_terminate(void *data)
+{
+ int err = CONTACTS_ERROR_NONE;
+ ct_viewer_data *cviewer_d = (ct_viewer_data *) data;
+
+ if (cviewer_d->p_info)
+ {
+ cviewer_d->p_info->alive = false;
+ pthread_join(cviewer_d->p_info->thread, NULL);
+ ecore_timer_del(cviewer_d->p_info->timer);
+ free(cviewer_d->p_info);
+ }
+
+ free(cviewer_d->path);
+
+ if (cviewer_d->win)
+ {
+ evas_object_data_del(cviewer_d->win, "naviframe");
+ evas_object_del(cviewer_d->win);
+ cviewer_d->win = NULL;
+ }
+
+ err = contacts_disconnect2();
+ p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_disconnect2() Failed(%d)",
+ err);
+
+ return;
+}
+
+static void viewer_pause(void *data)
+{
+ return;
+}
+
+static void viewer_resume(void *data)
+{
+ return;
+}
+
+static bool viewer_load_vcard_foreach_cb(contacts_record_h record, void *data)
+{
+ ct_person_list *person_info = NULL;
+ ct_viewer_data *cviewer_d = (ct_viewer_data *) data;
+ int err = CONTACTS_ERROR_NONE;
+
+ if (NULL == cviewer_d)
+ {
+ ERR("Invalid parameter(cviewer_d is NULL)");
+ return false;
+ }
+
+ if (false == cviewer_d->p_info->alive)
+ return false;
+
+ person_info = (ct_person_list *) calloc(1, sizeof(ct_person_list));
+ if (NULL == person_info)
+ {
+ ERR("calloc() return NULL");
+ cviewer_d->p_info->result = FALSE;
+ if (cviewer_d->p_info->cnt == cviewer_d->p_info->cnt_checked_total)
+ cviewer_d->p_info->completed = true;
+ return false;
+ }
+
+ person_info->id = cviewer_d->p_info->cnt;
+ err = contacts_record_get_str(record, _contacts_contact.display_name,
+ &(person_info->display));
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_record_get_str() Failed(%d)", err);
+ person_info->img_loaded = true;
+
+ cviewer_d->list = eina_list_append(cviewer_d->list, person_info);
+ ++cviewer_d->p_info->cnt;
+ return true;
+
+}
+
+static PTHREAD_FN viewer_load_vcard_contacts_thread_fn(void* data)
+{
+ contacts_connect_on_thread();
+
+ int err = CONTACTS_ERROR_NONE;
+ ct_viewer_data *cviewer_d = (ct_viewer_data *) data;
+
+ err = contacts_vcard_parse_to_contact_foreach(cviewer_d->path,
+ viewer_load_vcard_foreach_cb, cviewer_d);
+ if (CONTACTS_ERROR_NONE != err)
+ {
+ cviewer_d->p_info->result = FALSE;
+ ERR("contacts_svc_vcard_foreach() Failed(%d)", err);
+ }
+ cviewer_d->p_info->completed = true;
+
+ contacts_disconnect_on_thread();
+
+ pthread_exit(NULL);
+}
+
+static inline void viewer_get_filename(char *fullpath, char *dest,
+ int size_dest)
+{
+ char* index;
+ index = strrchr(fullpath, '/');
+ snprintf(dest, size_dest, "%s", index + 1);
+}
+
+static Eina_Bool viewer_load_vcard_timer_cb(void *data)
+{
+ ct_viewer_data *cviewer_d = (ct_viewer_data *) data;
+
+ p_retvm_if(NULL == cviewer_d, ECORE_CALLBACK_CANCEL,
+ "parameter(ct_viewer_data) is NULL");
+ p_retvm_if(NULL == cviewer_d->p_info, ECORE_CALLBACK_CANCEL,
+ "parameter(ct_viewer_data->p_info) is NULL");
+
+ if (!cviewer_d->p_info->completed)
+ {
+ char count[PH_TEXT_SHORT_LEN];
+ char percent[PH_TEXT_SHORT_LEN];
+ double value = (double) cviewer_d->p_info->cnt
+ / (double) cviewer_d->p_info->cnt_checked_total;
+
+ if (!cviewer_d->p_info->alive)
+ {
+ cviewer_d->p_info->result = FALSE;
+ cviewer_d->p_info->completed = true;
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ elm_progressbar_value_set(cviewer_d->p_info->progressbar, value);
+ snprintf(percent, sizeof(percent), "%d%%",
+ (int) (100.0 * (double) cviewer_d->p_info->cnt
+ / (double) cviewer_d->p_info->cnt_checked_total));
+ snprintf(count, sizeof(count), "%d/%d", cviewer_d->p_info->cnt,
+ cviewer_d->p_info->cnt_checked_total);
+ edje_object_part_text_set(
+ elm_layout_edje_get(cviewer_d->p_info->layout),
+ "elm.text.subtext1", percent);
+ edje_object_part_text_set(
+ elm_layout_edje_get(cviewer_d->p_info->layout),
+ "elm.text.subtext2", count);
+
+ if (cviewer_d->p_info->cnt == cviewer_d->p_info->cnt_checked_total)
+ cviewer_d->p_info->completed = true;
+
+ return ECORE_CALLBACK_RENEW;
+ }
+ else
+ {
+ pthread_join(cviewer_d->p_info->thread, NULL);
+
+ evas_object_del(cviewer_d->popup);
+ cviewer_d->popup = NULL;
+
+ cviewer_d->p_info->timer = NULL;
+
+ if (!cviewer_d->p_info->result)
+ {
+ free(cviewer_d->p_info);
+ cviewer_d->p_info = NULL;
+ elm_exit();
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ cviewer_d->content = ctui_create_vcard_list_view(cviewer_d->win,
+ cviewer_d->list, cviewer_d->path);
+ p_retvm_if(NULL == cviewer_d->content, ECORE_CALLBACK_CANCEL,
+ "ctui_create_vcard_list_view() return NULL");
+
+ free(cviewer_d->p_info);
+ cviewer_d->p_info = NULL;
+
+ return ECORE_CALLBACK_CANCEL;
+ }
+}
+
+static int viewer_load_vcard_contact(ct_viewer_data *cviewer_d)
+{
+ Evas_Object *popup;
+
+ if (cviewer_d->path && *cviewer_d->path)
+ {
+ cviewer_d->content = ctui_contacts_viewer(cviewer_d->win, NULL, 0,
+ cviewer_d->path);
+ if (NULL == cviewer_d->content)
+ {
+ ERR("ctui_contacts_viewer() return NULL");
+ elm_exit();
+ return -1;
+ }
+ }
+ else
+ {
+ popup = phone_show_popup(cviewer_d->win, S_(CT_SYS_POP_ERROR), 1.5);
+ evas_object_smart_callback_add(popup, "timeout", cv_win_del, NULL);
+ }
+ return 0;
+}
+
+static int viewer_load_vcard_contacts(ct_viewer_data *cviewer_d, int cnt_vcard)
+{
+ int ret;
+ char title[PH_TEXT_MAX_LEN];
+ char filepath[PH_TEXT_MAX_LEN];
+ ph_progress_info *p_info;
+
+ p_info = (ph_progress_info *) calloc(1, sizeof(ph_progress_info));
+ if (NULL == p_info)
+ {
+ ERR("calloc() return NULL");
+ elm_exit();
+ return -1;
+ }
+
+ cviewer_d->p_info = p_info;
+ cviewer_d->list = NULL;
+
+ p_info->cnt = 0;
+ p_info->cnt_checked_total = cnt_vcard;
+ p_info->alive = true;
+ p_info->result = TRUE;
+ p_info->completed = false;
+
+ viewer_get_filename(cviewer_d->path, filepath, sizeof(filepath));
+ snprintf(title, sizeof(title), "%s<br>%s",
+ T_(CT_GET_TEXT_BASIC, CTTEXT_LOADING_VCARD), filepath);
+
+ ret = pthread_create(&p_info->thread, NULL,
+ viewer_load_vcard_contacts_thread_fn, cviewer_d);
+ if (0 != ret)
+ {
+ ERR("Thread creation failed(%d)", ret);
+ free(p_info);
+ cviewer_d->p_info = NULL;
+ elm_exit();
+ return -1;
+ }
+ p_info->timer = ecore_timer_add(0.2, viewer_load_vcard_timer_cb, cviewer_d);
+ if (NULL == p_info->timer)
+ {
+ ERR("ecore_timer_add() return NULL");
+
+ p_info->alive = false;
+ pthread_join(p_info->thread, NULL);
+
+ free(p_info);
+ cviewer_d->p_info = NULL;
+ elm_exit();
+ return -1;
+ }
+ cviewer_d->popup = phone_progressbar_popup(cviewer_d->win, p_info, title);
+ return 0;
+}
+
+static void viewer_popup_hide_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ elm_exit();
+}
+
+static bool __viewer_is_valid_person(int person_id)
+{
+ int err;
+ contacts_record_h record = NULL;
+ err = contacts_db_get_record(_contacts_person._uri, person_id, &record);
+ if (CONTACTS_ERROR_NONE != err)
+ {
+ contacts_record_destroy(record, true);
+ return false;
+ }
+ contacts_record_destroy(record, true);
+ return true;
+}
+
+static void viewer_service(service_h service, void *data)
+{
+ int ret;
+ int person_id;
+ char *val = NULL;
+ char val_vcard[PH_TEXT_MAX_LEN];
+ int err = CONTACTS_ERROR_NONE;
+ ct_viewer_data *cviewer_d = (ct_viewer_data *) data;
+
+ if (NULL == cviewer_d->win)
+ {
+ ERR("win is NULL");
+ elm_exit();
+ return;
+ }
+
+ if (cviewer_d->p_info)
+ {
+ cviewer_d->p_info->alive = false;
+ pthread_join(cviewer_d->p_info->thread, NULL);
+ ecore_timer_del(cviewer_d->p_info->timer);
+ free(cviewer_d->p_info);
+ cviewer_d->p_info = NULL;
+ }
+
+ if (cviewer_d->content)
+ {
+ evas_object_del(cviewer_d->content);
+ cviewer_d->content = NULL;
+ }
+
+ ret = service_get_extra_data(service, "person_id", &val);
+ p_warn_if(SERVICE_ERROR_NONE != ret, "service_get_operation is failed(%d)",
+ ret);
+
+ if (val && *val)
+ {
+ person_id = atoi(val);
+ if (person_id <= 0)
+ {
+ ERR("service value(person_id) is wrong(%d)", person_id);
+ }
+ else if (false == __viewer_is_valid_person(person_id))
+ {
+ Evas_Object *popup;
+ popup = elm_popup_add(cviewer_d->win);
+ evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ elm_object_text_set(popup, T_(CT_GET_TEXT_ERR, CTTEXT_NO_CONTACTS));
+ elm_popup_timeout_set(popup, 2.0);
+ evas_object_smart_callback_add(popup, "timeout",
+ viewer_popup_hide_cb, NULL);
+ evas_object_show(popup);
+ }
+ else
+ {
+ cviewer_d->content = ctui_contacts_viewer(cviewer_d->win, NULL,
+ person_id, NULL);
+ if (NULL == cviewer_d->content)
+ {
+ Evas_Object *popup;
+ ERR("ctui_contacts_viewer() return NULL");
+ popup = elm_popup_add(cviewer_d->win);
+ evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ elm_object_text_set(popup, S_(PH_SYS_POP_FAILED));
+ elm_popup_timeout_set(popup, 2.0);
+ evas_object_smart_callback_add(popup, "timeout",
+ viewer_popup_hide_cb, NULL);
+
+ evas_object_show(popup);
+ }
+ free(val);
+ }
+ }
+ else
+ {
+ int cnt_vcard = 0;
+ ret = service_get_uri(service, &val);
+ p_warn_if(SERVICE_ERROR_NONE != ret, "service_get_uri is failed(%d)",
+ ret);
+
+ val_vcard[0] = '\0';
+
+ if (val && *val)
+ {
+ if (0 == strncmp(val, "file://", 7))
+ snprintf(val_vcard, sizeof(val_vcard), "%s", val + 7);
+ else
+ snprintf(val_vcard, sizeof(val_vcard), "%s", val);
+ }
+ else
+ {
+ ret = service_get_extra_data(service, AUL_K_MIME_CONTENT, &val);
+ p_warn_if(SERVICE_ERROR_NONE != ret,
+ "service_get_extra_data is failed(%d)", ret);
+ if (val && *val)
+ snprintf(val_vcard, sizeof(val_vcard), "%s", val);
+ }
+ free(val);
+
+ if ('\0' == *val_vcard)
+ {
+ ERR("service value is NULL");
+ elm_exit();
+ return;
+ }
+
+ free(cviewer_d->path);
+ cviewer_d->path = strdup(val_vcard);
+ err = contacts_vcard_get_entity_count(cviewer_d->path, &cnt_vcard);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_vcard_get_entity_count() Failed(%d)", err);
+
+ if (cnt_vcard < 1)
+ {
+ ERR("invalid vcard(%s)", cviewer_d->path);
+ elm_exit();
+ return;
+ }
+ else if (1 == cnt_vcard)
+ {
+ ret = viewer_load_vcard_contact(cviewer_d);
+ if (0 != ret)
+ {
+ ERR("viewer_load_vcard_contact() Failed(%d)", ret);
+ elm_exit();
+ return;
+ }
+ }
+ else
+ {
+ ret = viewer_load_vcard_contacts(cviewer_d, cnt_vcard);
+ if (0 != ret)
+ {
+ ERR("viewer_load_vcard_contact() Failed(%d)", ret);
+ elm_exit();
+ return;
+ }
+ }
+ }
+ elm_win_activate(cviewer_d->win);
+ return;
+}
+
+API int main(int argc, char *argv[])
+{
+ ct_viewer_data ad = { 0 };
+ app_event_callback_s event_callback = { 0, };
+
+ //vibration engine set, guide by settings - temporary fix
+ elm_init(argc, argv);
+ elm_config_preferred_engine_set("opengl_x11");
+
+ event_callback.create = viewer_create;
+ event_callback.terminate = viewer_terminate;
+ event_callback.pause = viewer_pause;
+ event_callback.resume = viewer_resume;
+ event_callback.service = viewer_service;
+ event_callback.low_memory = NULL;
+ event_callback.low_battery = NULL;
+ event_callback.language_changed = NULL;
+ event_callback.region_format_changed = NULL;
+
+ return app_efl_main(&argc, &argv, &event_callback, &ad);
+}
diff --git a/contacts-viewer/icon_contacts-viewer.png b/contacts-viewer/icon_contacts-viewer.png
new file mode 100644
index 0000000..900dcde
--- /dev/null
+++ b/contacts-viewer/icon_contacts-viewer.png
Binary files differ
diff --git a/contacts-viewer/org.tizen.contacts-viewer.xml b/contacts-viewer/org.tizen.contacts-viewer.xml
new file mode 100755
index 0000000..8a55e80
--- /dev/null
+++ b/contacts-viewer/org.tizen.contacts-viewer.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns="http://tizen.org/ns/packages" package="org.tizen.contacts-viewer" version="0.1.2" install-location="internal-only">
+ <label>Contacts-Viewer</label>
+ <author email="ensung.park@samsung.com" href="www.samsung.com">ensung park</author>
+ <description>Contacts-Viewer Application</description>
+ <ui-application appid="org.tizen.contacts-viewer" exec="/usr/apps/org.tizen.contacts-viewer/bin/contacts-viewer" nodisplay="true" multiple="false" type="capp" taskmanage="true">
+ <icon>org.tizen.contacts.png</icon>
+ <label>Contacts-Viewer</label>
+ <label xml:lang="en-us">Contacts-Viewer</label>
+ <label xml:lang="nl-nl">Contacts-Viewer</label>
+ <label xml:lang="de-de">Contacts-Viewer</label>
+ <label xml:lang="en-gb">Contacts-Viewer</label>
+ <label xml:lang="zh-hk">Contacts-Viewer</label>
+ <label xml:lang="zh-cn">Contacts-Viewer</label>
+ <label xml:lang="ru-ru">Contacts-Viewer</label>
+ <label xml:lang="zh-tw">Contacts-Viewer</label>
+ <label xml:lang="ja-jp">Contacts-Viewer</label>
+ <label xml:lang="es-es">Contacts-Viewer</label>
+ <label xml:lang="el-gr">Contacts-Viewer</label>
+ <label xml:lang="it-it">Contacts-Viewer</label>
+ <label xml:lang="tr-tr">Contacts-Viewer</label>
+ <label xml:lang="pt-pt">Contacts-Viewer</label>
+ <label xml:lang="fr-fr">Contacts-Viewer</label>
+ <label xml:lang="ko-kr">Contacts-Viewer</label>
+ <application-service>
+ <operation name="http://tizen.org/appcontrol/operation/view"/>
+ <mime name="text/x-vcard"/>
+ <mime name="text/directory"/>
+ <mime name="text/vcard"/>
+ </application-service>
+
+ </ui-application>
+</manifest>
diff --git a/contacts/CMakeLists.txt b/contacts/CMakeLists.txt
new file mode 100644
index 0000000..0e9464e
--- /dev/null
+++ b/contacts/CMakeLists.txt
@@ -0,0 +1,24 @@
+SET(CONTACTS "contacts")
+SET(CONTACTS_PKGNAME "org.${VENDOR}.${CONTACTS}")
+
+SET(CONTACTS_SRCS contacts.cpp)
+
+ADD_DEFINITIONS("-DC_PACKAGE=\"${CONTACTS}\"")
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC")
+
+FOREACH(flag ${contacts_pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+ADD_EXECUTABLE(${CONTACTS} ${CONTACTS_SRCS})
+SET_TARGET_PROPERTIES(${CONTACTS} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS} -fpie")
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib/ct-front/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib/common/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib/common/Utils/include)
+TARGET_LINK_LIBRARIES(${CONTACTS} ${contacts_pkgs_LDFLAGS} common ug-contacts-tabui-efl "-pie")
+
+INSTALL(FILES ${CMAKE_BINARY_DIR}/${CONTACTS}/${CONTACTS_PKGNAME}.xml DESTINATION "/usr/share/packages")
+INSTALL(FILES icon_${CONTACTS}.png DESTINATION "/usr/share/icons/default/small" RENAME "${CONTACTS_PKGNAME}.png")
+INSTALL(TARGETS ${CONTACTS} DESTINATION /usr/apps/${CONTACTS_PKGNAME}/bin)
+INSTALL(DIRECTORY DESTINATION /usr/apps/${CONTACTS_PKGNAME}/data)
diff --git a/contacts/contacts.cpp b/contacts/contacts.cpp
new file mode 100755
index 0000000..46ecbea
--- /dev/null
+++ b/contacts/contacts.cpp
@@ -0,0 +1,364 @@
+/*
+ * 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.
+ */
+
+#include <app.h>
+#include <Ecore_X.h>
+#include <aul.h>
+#include <vconf.h>
+#include <vconf-keys.h>
+#include "phone.h"
+#include "phone-common.h"
+#include "ct-front.h"
+
+
+#include <iostream>
+
+#if !defined(C_PACKAGE)
+# define C_PACKAGE "contacts"
+#endif
+
+struct contact_data
+{
+ Evas_Object *win;
+ ct_front_data *cfront_d;
+ /* add more variables here */
+#ifdef _PHONE_CONTACTS_DESKTOP_MODE_
+ Evas_Object *icon;
+ Evas_Object *prev_btn;
+#endif
+ int current_rotate;
+
+ bool shouldStopOnStart;
+ public:
+ contact_data()
+ :
+ win(NULL),
+ cfront_d(NULL),
+#ifdef _PHONE_CONTACTS_DESKTOP_MODE_
+ icon(NULL),
+ prev_btn(NULL),
+#endif
+ current_rotate(0),
+ shouldStopOnStart(false)
+ {
+ }
+};
+
+extern "C" int appcore_set_open_cb(int (*cb) (void *), void *data);
+
+static void ctapp_win_del(void *data, Evas_Object *obj, void *event)
+{
+ PH_TRACE;
+ elm_exit();
+}
+
+static Evas_Object* ctapp_create_win(const char *name)
+{
+ PH_TRACE;
+ Evas_Object *eo;
+ int w, h;
+ eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
+ if (eo)
+ {
+ elm_win_title_set(eo, name);
+#ifdef _PHONE_CONTACTS_DESKTOP_MODE_
+#else
+ elm_win_borderless_set(eo, EINA_TRUE);
+#endif
+ evas_object_smart_callback_add(eo, "delete,request", ctapp_win_del,
+ NULL);
+ ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
+ evas_object_resize(eo, w, h);
+ elm_win_indicator_mode_set(eo, ELM_WIN_INDICATOR_SHOW);
+ }
+ elm_win_conformant_set(eo, EINA_TRUE);
+ return eo;
+}
+
+static void ctapp_region_changed(void *data)
+{
+ PH_TRACE;
+ struct contact_data *ad = (contact_data *) data;
+ ct_front_data *cfront_d = ad->cfront_d;
+ ctui_front_view_region_changed(cfront_d);
+ ug_send_event (UG_EVENT_REGION_CHANGE);
+ return;
+}
+
+static void ctapp_language_changed(void *data)
+{
+ PH_TRACE;
+ struct contact_data *ad = (contact_data *) data;
+ ct_front_data *cfront_d = ad->cfront_d;
+ ctui_front_view_language_changed(cfront_d);
+ ug_send_event (UG_EVENT_LANG_CHANGE);
+ return;
+}
+
+static int ctapp_open(void *data)
+{
+ PH_TRACE;
+ struct contact_data *ad = (contact_data *) data;
+ ct_front_data *cfront_d = ad->cfront_d;
+ if (EINA_FALSE == evas_object_visible_get(cfront_d->win))
+ {
+ evas_object_show(cfront_d->win);
+ if (CT_VIEW_NONE == cfront_d->select_tab)
+ ctui_front_view_reset(cfront_d, CT_VIEW_CONTACT, -1, NULL);
+ }
+ return 0;
+}
+
+#ifdef _PHONE_CONTACTS_DESKTOP_MODE_
+static Evas_Object* __set_win_icon(struct contact_data *ad)
+{
+ PH_TRACE;
+ Evas_Object *image = evas_object_image_add(evas_object_evas_get(ad->win));
+ evas_object_image_file_set(image, "/usr/share/icons/default/small/org.tizen.contacts.png", NULL);
+ elm_win_icon_object_set(ad->win, image);
+
+ return image;
+}
+
+static void __win_profile_changed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ if(data == NULL)
+ return;
+
+ struct contact_data *ad = (contact_data *) data;
+
+ const char *profile = elm_config_profile_get();
+ if(!strcmp(profile, "desktop"))
+ {
+ Elm_Object_Item *navi_item = elm_naviframe_bottom_item_get(ad->cfront_d->navi);
+ ad->prev_btn = elm_object_item_part_content_unset(navi_item, "prev_btn");
+ elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_HIDE);
+ if(!ad->icon)
+ ad->icon = __set_win_icon(ad);
+ }
+ else
+ {
+ Elm_Object_Item *navi_item = elm_naviframe_bottom_item_get(ad->cfront_d->navi);
+ if (ad->prev_btn)
+ {
+ elm_object_item_part_content_set(navi_item, "prev_btn", ad->prev_btn);
+ ad->prev_btn = NULL;
+ }
+ elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW);
+ }
+}
+#endif //_PHONE_CONTACTS_DESKTOP_MODE_
+static void __ctapp_rotate_cb(void *data, Evas_Object *obj, void *event)
+{
+ PH_TRACE;
+ struct contact_data *ad = (contact_data *) data;
+ int changed_rotate = elm_win_rotation_get(obj);
+ if (changed_rotate != ad->current_rotate)
+ {
+ ERR("rotate changed %d", changed_rotate);
+ ad->current_rotate = changed_rotate;
+
+#ifdef _PHONE_CONTACTS_DESKTOP_MODE_
+ const char *config = elm_config_profile_get();
+ if (!strcmp(config, "desktop"))
+ return;
+#endif
+
+ ctui_front_view_rotate(ad->cfront_d, ad->current_rotate);
+ }
+}
+
+static bool ctapp_create(void *data)
+{
+ PH_TRACE;
+ struct contact_data *ad = (contact_data *) data;
+ Evas_Object *win;
+ int err = CONTACTS_ERROR_NONE;
+
+ /* create window */
+ win = ctapp_create_win(C_PACKAGE);
+ p_retvm_if(NULL == win, false, "phapp_create_win() Failed");
+ ad->win = win;
+
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ err = contacts_connect2();
+ if (CONTACTS_ERROR_NONE != err)
+ {
+ Evas_Object *popup;
+ ERR("contacts_connect2() Failed(%d)", err);
+ evas_object_show(win);
+ popup = elm_popup_add(win);
+ evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ evas_object_show(popup);
+ elm_object_text_set(popup, T_(PH_GET_TEXT_BASIC, PHTEXT_INITIALIZING));
+ elm_popup_timeout_set(popup, 1.5);
+ evas_object_smart_callback_add(popup, "timeout", ctapp_win_del, NULL);
+ return true;
+ }
+
+ if(!has_emergency_contacts())
+ {
+ create_emergency_contacts_group();
+ }
+#ifdef _PHONE_CONTACTS_DESKTOP_MODE_
+ evas_object_smart_callback_add(ad->win, "profile,changed", __win_profile_changed_cb, ad);
+#endif
+
+ UG_INIT_EFL(ad->win, UG_OPT_INDICATOR_ENABLE);
+ ad->cfront_d = ctui_front_view_create(ad->win);
+
+ if (elm_win_wm_rotation_supported_get(win))
+ {
+ int rotation[4] = { 0, 90, 180, 270 };
+ elm_win_wm_rotation_available_rotations_set(win,
+ (const int *) (&rotation), 4);
+ ad->current_rotate = elm_win_rotation_get(win);
+ ERR("rotate current %d", ad->current_rotate);
+ evas_object_smart_callback_add(win, "wm,rotation,changed",
+ __ctapp_rotate_cb, ad);
+ }
+
+ appcore_set_open_cb(ctapp_open, data);
+ return true;
+}
+
+static void ctapp_terminate(void *data)
+{
+ PH_TRACE;
+ int err = CONTACTS_ERROR_NONE;
+ struct contact_data *ad = (contact_data *) data;
+
+ if (NULL != ad->win)
+ evas_object_del(ad->win);
+ //ug_destroy_all();
+ err = contacts_disconnect2();
+ p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_disconnect2() Failed(%d)",
+ err);
+ return;
+}
+
+static void ctapp_pause(void *data)
+{
+ PH_TRACE;
+ struct contact_data *ad = (contact_data *) data;
+ ctui_front_view_pause(ad->cfront_d);
+ ug_pause();
+ return;
+}
+
+static void ctapp_resume(void *data)
+{
+ PH_TRACE;
+ struct contact_data *ad = (contact_data *) data;
+ ct_front_data *cfront_d = ad->cfront_d;
+ if (CT_VIEW_NONE == cfront_d->select_tab)
+ ctui_front_view_reset(cfront_d, CT_VIEW_CONTACT, -1, NULL);
+ else
+ ctui_front_view_resume(ad->cfront_d);
+ ug_resume();
+ return;
+}
+
+static void ctapp_service(service_h service, void *data)
+{
+ PH_TRACE;
+ struct contact_data *ad = (contact_data *) data;
+ ct_front_data *cfront_d;
+ int ret;
+ char* val = NULL;
+
+ p_retm_if(NULL == ad || NULL == ad->cfront_d, "data is null");
+ cfront_d = ad->cfront_d;
+
+ ret = service_get_extra_data(service, "launch_type", &val);
+ p_warn_if(SERVICE_ERROR_NONE != ret, "service_get_extra_data is failed(%d)",
+ ret);
+
+ if (val && *val)
+ {
+ if (0 == strcmp(val, "favorite"))
+ ctui_front_view_reset(cfront_d, CT_VIEW_FAVORITE, -1, NULL);
+ else if (0 == strcmp(val, "groups"))
+ ctui_front_view_reset(cfront_d, CT_VIEW_GROUP, -1, NULL);
+ else if (0 == strcmp(val, "group_message"))
+ ctui_front_view_reset(cfront_d, CT_VIEW_GROUP,
+ CT_FRONT_GROUP_MESSAGE, service);
+ else if (0 == strcmp(val, "group_email"))
+ ctui_front_view_reset(cfront_d, CT_VIEW_GROUP, CT_FRONT_GROUP_EMAIL,
+ service);
+ else if (0 == strcmp(val, "group_detail"))
+ ctui_front_view_reset(cfront_d, CT_VIEW_GROUP,
+ CT_FRONT_GROUP_DETAIL, service);
+ else if (0 == strcmp(val, "new"))
+ ctui_front_view_reset(cfront_d, CT_VIEW_CONTACT,
+ CT_FRONT_CONTACT_NEW, NULL);
+ else if (0 == strcmp(val, "addrbook"))
+ ctui_front_view_reset(cfront_d, CT_VIEW_CONTACT,
+ CT_FRONT_CONTACT_ADDR, service);
+ else if (0 == strcmp(val, "booting"))
+ elm_win_lower(cfront_d->win);
+ free(val);
+ return;
+ }
+
+ ret = service_get_extra_data(service, "search_name", &val);
+ p_warn_if(SERVICE_ERROR_NONE != ret, "service_get_extra_data is failed(%d)",
+ ret);
+
+ if (val && *val)
+ {
+ ctui_front_view_reset(cfront_d, CT_VIEW_CONTACT,
+ CT_FRONT_CONTACT_SEARCH, service);
+ free(val);
+ return;
+ }
+
+ ctui_front_view_reset(cfront_d, CT_VIEW_CONTACT, -1, NULL);
+ return;
+}
+
+API int main(int argc, char *argv[])
+{
+ PH_TRACE;
+ contact_data ad;
+ app_event_callback_s event_callback = { 0, };
+
+ if (argc > 1)
+ {
+ if (strcmp(argv[1], "-debug") == 0)
+ {
+ ad.shouldStopOnStart = true;
+ std::cout << std::string("running in debug mode..") << std::endl;
+ std::cout << std::string("Press 'Enter' after attaching with debugger.") << std::endl;
+ getchar();
+ }
+ }
+
+ event_callback.create = ctapp_create;
+ event_callback.terminate = ctapp_terminate;
+ event_callback.pause = ctapp_pause;
+ event_callback.resume = ctapp_resume;
+ event_callback.service = ctapp_service;
+ event_callback.low_memory = NULL;
+ event_callback.low_battery = NULL;
+ event_callback.language_changed = ctapp_language_changed;
+ event_callback.region_format_changed = ctapp_region_changed;
+
+ return app_efl_main(&argc, &argv, &event_callback, &ad);
+}
+
diff --git a/contacts/icon_contacts.png b/contacts/icon_contacts.png
new file mode 100644
index 0000000..725edd1
--- /dev/null
+++ b/contacts/icon_contacts.png
Binary files differ
diff --git a/contacts/org.tizen.contacts.xml b/contacts/org.tizen.contacts.xml
new file mode 100755
index 0000000..b9cde90
--- /dev/null
+++ b/contacts/org.tizen.contacts.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns="http://tizen.org/ns/packages" package="org.tizen.contacts" version="0.1.2" install-location="internal-only">
+ <label>Contacts</label>
+ <author email="ensung.park@samsung.com" href="www.samsung.com">ensung park</author>
+ <description>Contacts Application</description>
+ <ui-application appid="org.tizen.contacts" exec="/usr/apps/org.tizen.contacts/bin/contacts" nodisplay="false" multiple="false" type="capp" taskmanage="true">
+ <icon>org.tizen.contacts.png</icon>
+ <label>Contacts</label>
+ <label xml:lang="hy-am">Կոնտակտներ</label>
+ <label xml:lang="az-az">Adlar</label>
+ <label xml:lang="eu-es">Kontaktuak</label>
+ <label xml:lang="bg-bg">Телефонен указател</label>
+ <label xml:lang="ca-es">Contactes</label>
+ <label xml:lang="zh-cn">联系人</label>
+ <label xml:lang="zh-hk">聯絡人</label>
+ <label xml:lang="zh-tw">聯絡人</label>
+ <label xml:lang="hr-hr">Imenik</label>
+ <label xml:lang="cs-cz">Kontakty</label>
+ <label xml:lang="da-dk">Kontakter</label>
+ <label xml:lang="nl-nl">Contacten</label>
+ <label xml:lang="en-gb">Contacts</label>
+ <label xml:lang="en-us">Contacts</label>
+ <label xml:lang="et-ee">Kontaktid</label>
+ <label xml:lang="fi-fi">Yhteystiedot</label>
+ <label xml:lang="fr-fr">Contacts</label>
+ <label xml:lang="gl-es">Contactos</label>
+ <label xml:lang="ka-ge">კონტაქტები</label>
+ <label xml:lang="de-de">Kontakte</label>
+ <label xml:lang="el-gr">Επαφές</label>
+ <label xml:lang="hu-hu">Névjegyek</label>
+ <label xml:lang="is-is">Tengiliðir</label>
+ <label xml:lang="ga-ie">Teagmhálaithe</label>
+ <label xml:lang="it-it">Rubrica</label>
+ <label xml:lang="ja-jp">電話帳</label>
+ <label xml:lang="kk-kz">Контактілер</label>
+ <label xml:lang="ko-kr">전화번호부</label>
+ <label xml:lang="lv-lv">Kontakti</label>
+ <label xml:lang="lt-lt">Adresatai</label>
+ <label xml:lang="mk-mk">Именик</label>
+ <label xml:lang="nb-no">Kontakter</label>
+ <label xml:lang="pl-pl">Kontakty</label>
+ <label xml:lang="pt-pt">Contactos</label>
+ <label xml:lang="pt-br">Contatos</label>
+ <label xml:lang="ro-ro">Contacte</label>
+ <label xml:lang="ru-ru">Контакты</label>
+ <label xml:lang="sr-rs">Kontakti</label>
+ <label xml:lang="sk-sk">Kontakty</label>
+ <label xml:lang="sl-si">Imenik</label>
+ <label xml:lang="es-es">Contactos</label>
+ <label xml:lang="es-us">Contactos</label>
+ <label xml:lang="sv-se">Kontakter</label>
+ <label xml:lang="tr-tr">Rehber</label>
+ <label xml:lang="uk-ua">Контакти</label>
+ <label xml:lang="uz-uz">Kontaktlar</label>
+ <label xml:lang="ar-ae">الأسماء</label>
+ <label xml:lang="zh-sg">"联系人</label>
+ <label xml:lang="hi-in">संपर्क</label>
+ <label xml:lang="en-ph">Contacts</label>
+ <label xml:lang="fr-ca">Contacts</label>
+ </ui-application>
+
+</manifest>
diff --git a/deploy b/deploy
new file mode 100755
index 0000000..1cc38e1
--- /dev/null
+++ b/deploy
@@ -0,0 +1,113 @@
+#!/bin/bash
+
+usage()
+{
+ echo "Usage: `basename $0` [-h|--help] [-e|--emulator] [-d|--device]
+ -h, --help Show this message.
+ -e, --emulator Install on emulator (default).
+ -d, --device Install on device."
+}
+
+DEVS=($(sdb devices | tail -n+2))
+
+if [ -z $DEVS ]
+then
+ echo "Please connect device or launch emulator."
+ exit 1
+fi
+
+if [ -z $1 ]
+then
+ DEV=e
+ ARCH=i586
+else
+ case $1 in
+ -e|--emulator)
+ DEV=e
+ ARCH=i586
+ ;;
+ -d|--device)
+ DEV=d
+ ARCH=armv7l
+ ;;
+ -h|--help)
+ ;&
+ *)
+ usage
+ exit 1
+ ;;
+ esac
+fi
+
+push()
+{
+ GBS=~/GBS-ROOT
+ ROOT=$GBS/local/BUILD-ROOTS/scratch.$ARCH.0
+
+ if [ ! -e $ROOT/*.conf ]
+ then
+ echo "Build root is not ready at $ROOT."
+ exit 1
+ fi
+
+ REPO=$(basename $ROOT/*.conf)
+ REPO=${REPO%.*}
+ RPMS=$GBS/local/repos/$REPO/$ARCH/RPMS
+
+ if [ ! -e "$RPMS/$1" ]
+ then
+ echo "Can't find $1 in $RPMS. Run build first."
+ exit 1
+ fi
+
+ echo "Pushing $1 into $2..."
+ sdb -$DEV push "$RPMS/$1" "$2" 2> /dev/null
+}
+
+install()
+{
+ echo "Installing $2..."
+ if [[ "$2" == lib* ]]
+ then
+ sdb -$DEV root on > /dev/null
+ sdb -$DEV shell rpm -i --force "$1/$2" > /dev/null
+ sdb -$DEV root off > /dev/null
+ else
+ sdb -$DEV shell pkgcmd -iqt rpm -p "$1/$2" > /dev/null
+ fi
+}
+
+deploy()
+{
+ push "$1" "$2"
+ install "$2" "$1"
+ sdb -$DEV shell rm "$2/$1" > /dev/null
+}
+
+DEST=/home/developer
+VER=$(grep Version: packaging/*.spec | awk '{print $2}')
+REL=$(grep Release: packaging/*.spec | awk '{print $2}')
+SUFFIX="$VER-$REL.$ARCH.rpm"
+PKGS=($(grep %package packaging/*.spec | awk '{print $3}'))
+
+if [ -z $PKGS ]
+then
+ PKG=$(grep Name: packaging/*.spec | awk '{print $2}')
+ deploy "$PKG-$SUFFIX" "$DEST"
+else
+ echo "Current package contains several sub-packages:"
+ for i in ${!PKGS[@]}
+ do
+ echo "$((i + 1)). ${PKGS[$i]}"
+ done
+
+ echo "Specify packages and order of installation (for example: 5 1):"
+ read NUMS
+
+ for i in $NUMS
+ do
+ deploy "${PKGS[$((i - 1))]}-$SUFFIX" "$DEST"
+ done
+fi
+echo "Done."
+
diff --git a/gbs/.gbs.conf b/gbs/.gbs.conf
new file mode 100644
index 0000000..8bfa7ba
--- /dev/null
+++ b/gbs/.gbs.conf
@@ -0,0 +1,37 @@
+[general]
+#Current profile name which should match a profile section name
+profile = profile.tizendev
+
+[profile.tizendev]
+#Common authentication info for whole profile
+#user =
+#CAUTION: please use the key name "passwd" to reset plaintext password
+#passwd =
+obs = obs.tizendev
+#Comma separated list of repositories
+repos = repo.tizendev_latest
+#repos = repo.tizendev_local,repo.tizendev_latest
+#repos = repo.tizendev_snapshot
+
+[obs.tizendev]
+#OBS API URL pointing to a remote OBS.
+url = https://api.tizendev.org
+#Optional user and password, set if differ from profile's user and password
+#user =
+#passwd =
+
+[repo.tizendev_latest]
+#Build against repo's URL
+url = https://download.tizendev.org/snapshots/tizen-2.2/common/latest
+#url = https://download.tizendev.org/snapshots/tizen-2.2/common/latest
+#Optional user and password, set if differ from profile's user and password
+user = %name%
+passwdx = %passwd%
+
+[repo.tizendev_snapshot]
+url = https://download.tizendev.org/snapshots/trunk/common/tizen_20120801.1
+
+[repo.tizendev_local]
+#repo for your local packages
+#url = /path_to_your_local_repo
+#url = http://local_server/path_to_repo
diff --git a/include/contacts-ug.h b/include/contacts-ug.h
new file mode 100755
index 0000000..ac56147
--- /dev/null
+++ b/include/contacts-ug.h
@@ -0,0 +1,268 @@
+/*
+* 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 __CONTACTS_UG_H__
+#define __CONTACTS_UG_H__
+
+/**
+ * @defgroup CONTACTS_UG Contacts UI-gadget
+ * @ingroup SLP_UG
+ * @addtogroup CONTACTS_UG
+ * @{
+ *
+ * Contacts UI-gadget
+ * \n This header file contains the declaration & description for Contacts UG.
+ *
+ * @section Header To use Them:
+ * @code
+ * #include <contacts-ug.h>
+ * @endcode
+ *
+ * @section example Example:
+ * @code
+ #include <stdio.h>
+ #include <ui-gadget.h>
+ #include <contacts-ug.h>
+
+ void contacts_detail_ug(int contact_id)
+ {
+ bundle *bd;
+ char buf[16];
+
+ bd = bundle_create();
+ if(NULL == bd) {
+ ERR("bundle_create() Failed");
+ return;
+ }
+
+ snprintf(buf, sizeof(buf), "%d", CT_UG_REQUEST_DETAIL);
+ bundle_add(bd, CT_UG_BUNDLE_TYPE, buf);
+ snprintf(buf, sizeof(buf), "%d", contact_id);
+ bundle_add(bd, CT_UG_BUNDLE_ID, buf);
+
+ cbs.layout_cb = ug_layout_cb;
+ cbs.result_cb = NULL;
+ cbs.destroy_cb = ug_destroy_cb;
+
+ ug = ug_create(NULL, UG_CONTACTS_DETAILS, UG_MODE_FULLVIEW, bd, &cbs);
+ if(NULL == ug)
+ ERR("ug_create() Failed");
+
+ bundle_free(bd);
+ }
+ * @endcode
+ *
+ */
+
+/**
+ * The name of details/new/edit UG
+ * @see #CT_UG_DETAILS_TYPES
+ */
+#define UG_CONTACTS_DETAILS "contacts-details-efl"
+
+/**
+ * The name of list UG
+ * @see #CT_UG_LIST_TYPES
+ */
+#define UG_CONTACTS_LIST "contacts-list-efl"
+
+/**
+ * The name of setting UG
+ */
+#define UG_CONTACTS_SETTINGS "contacts-settings-efl"
+
+/**
+ * types of #UG_CONTACTS_DETAILS
+ */
+enum CT_UG_DETAILS_TYPES
+{
+ CT_UG_REQUEST_DETAIL = 0,/**< . */
+
+ CT_UG_REQUEST_EDIT = 11,/**< . */
+
+ CT_UG_REQUEST_ADD = 21,/**< . */
+ CT_UG_REQUEST_ADD_WITH_NUM = 22,/**< . */
+ CT_UG_REQUEST_ADD_WITH_EMAIL = 23,/**< . */
+ CT_UG_REQUEST_ADD_WITH_WEB = 24, /**< . */
+};
+
+/**
+ * types of #UG_CONTACTS_LIST
+ */
+enum CT_UG_LIST_TYPES
+{
+ CT_UG_REQUEST_LIST = 0,/**< . */
+ CT_UG_REQUEST_LIST_WITH_BACK = 1,/**< . */
+
+ CT_UG_REQUEST_SELECT_PERSON = 11,/**< . */
+ CT_UG_REQUEST_SELECT_NUMBER = 12,/**< . */
+ CT_UG_REQUEST_SELECT_EMAIL = 13,/**< . */
+ CT_UG_REQUEST_SELECT_VCARD = 14,/**< . */
+ CT_UG_REQUEST_SELECT_CONTACT_ADD_TO_HOME = 15,/**< . */
+ CT_UG_REQUEST_SELECT_GROUP_ADD_TO_HOME = 16,/**< . */
+ CT_UG_REQUEST_SELECT_NUMBER_OR_EMAIL = 17,/**< . */
+ CT_UG_REQUEST_SELECT_GROUP = 18, /**< . */
+
+ CT_UG_REQUEST_UPDATE_CONTACT = 20,/**< . */
+ CT_UG_REQUEST_UPDATE_WITH_NUM = 21,/**< . */
+ CT_UG_REQUEST_UPDATE_WITH_EMAIL = 22,/**< . */
+ CT_UG_REQUEST_UPDATE_WITH_WEB = 23,/**< . */
+
+ CT_UG_REQUEST_CHECK = 31,/**< . */
+ CT_UG_REQUEST_CHECK_FOR_NUMBER = 32,/**< . */
+ CT_UG_REQUEST_CHECK_FOR_EMAIL = 33,/**< . */
+ CT_UG_REQUEST_CHECK_FOR_NUMBER_OR_EMAIL = 34,/**< . */
+
+ CT_UG_REQUEST_SAVE_IMG = 41,/**< . */
+ CT_UG_REQUEST_SAVE_RINGTONE = 42,/**< . */
+
+ CT_UG_REQUEST_SHARE_CONTACT_INFO = 61, /**< . */
+};
+
+#define CT_UG_BUNDLE_ACCOUNTID "account_id"
+#define CT_UG_BUNDLE_PERSON_ID "ct_person_id"
+
+/**
+ * The key of request bundle for type.
+ * \n Value : convert id to string by using \%d.
+ */
+#define CT_UG_BUNDLE_TYPE "type"
+
+/**
+ * The key of request bundle for contact index
+ * \n Value : convert id to string by using \%d
+ * \n Use on #CT_UG_REQUEST_DETAIL, #CT_UG_REQUEST_EDIT
+ */
+#define CT_UG_BUNDLE_ID "person_id"
+
+/**
+ * The key of request bundle for vcard stream.
+ * \n Value : vcard stream.(It is not a filepath.)
+ * \n Use only on #CT_UG_REQUEST_ADD.
+ */
+#define CT_UG_BUNDLE_VCARD "ct_vcard"
+
+/**
+ * The key of request bundle for number
+ * \n Use on #CT_UG_REQUEST_ADD_WITH_NUM, #CT_UG_REQUEST_UPDATE_WITH_NUM
+ * \n Value : (string)number
+ */
+#define CT_UG_BUNDLE_NUM "ct_num"
+
+/**
+ * The key of request bundle for email
+ * \n Use on #CT_UG_REQUEST_ADD_WITH_EMAIL, #CT_UG_REQUEST_UPDATE_WITH_EMAIL
+ * \n (string)email address
+ */
+#define CT_UG_BUNDLE_EMAIL "ct_email"
+
+/**
+ * The key of request bundle for web
+ * \n Use on #CT_UG_REQUEST_ADD_WITH_WEB, #CT_UG_REQUEST_UPDATE_WITH_WEB
+ * \n Value : (string)web address
+ */
+#define CT_UG_BUNDLE_WEB "ct_web"
+
+/**
+ * The key of request bundle for path(ringtone or img)
+ * \n Use on #CT_UG_REQUEST_SAVE_IMG, #CT_UG_REQUEST_SAVE_RINGTONE
+ * \n Value : (string)absolutely path
+ */
+#define CT_UG_BUNDLE_PATH "ct_path"
+
+/**
+ * The key of request bundle for maximum number to select.
+ * \n Use on #CT_UG_REQUEST_CHECK
+ * \n Value : convert maximum number to string by using \%d (0 is ALL)
+ */
+#define CT_UG_BUNDLE_MAX "ct_max"
+
+/**
+ * The key of result bundle for contact index
+ * \n The contact index on #CT_UG_REQUEST_ADD , CT_UG_REQUEST_ADD_XXX
+ * \n The contact index on #CT_UG_REQUEST_SELECT_PERSON
+ * \n Value : convert id to integer by using atoi()
+ * \n Recommends to destroy Contacts UG at ug_cbs.destroy_cb.(not ug_cbs.result_cb)
+ * \n In ug_cbs.result_cb, ug_destroy() should not be called.
+ */
+#define CT_UG_BUNDLE_RESULT_PERSON_ID "person_id"
+
+/**
+ * The key of result bundle for the index of number value
+ * \n The number value index on #CT_UG_REQUEST_SELECT_NUMBER
+ * \n Value : convert id to integer by using atoi()
+ * \n Recommends to destroy Contacts UG at ug_cbs.destroy_cb.(not ug_cbs.result_cb)
+ * \n In ug_cbs.result_cb, ug_destroy() should not be called.
+ */
+#define CT_UG_BUNDLE_RESULT_NUMBER_ID "num_id"
+
+/**
+ * The key of result bundle for the index of email value
+ * \n The email value index on #CT_UG_REQUEST_SELECT_EMAIL
+ * \n Value : convert id to integer by using atoi()
+ * \n Recommends to destroy Contacts UG at ug_cbs.destroy_cb.(not ug_cbs.result_cb)
+ * \n In ug_cbs.result_cb, ug_destroy() should not be called.
+ */
+#define CT_UG_BUNDLE_RESULT_EMAIL_ID "email_id"
+
+/**
+ * The key of result bundle for the index of group value
+ * \n The group value index on #CT_UG_REQUEST_SELECT_GROUP
+ * \n Value : convert id to integer by using atoi()
+ * \n Recommends to destroy Contacts UG at ug_cbs.destroy_cb.(not ug_cbs.result_cb)
+ * \n In ug_cbs.result_cb, ug_destroy() should not be called.
+ */
+#define CT_UG_BUNDLE_RESULT_GROUP_ID "group_id"
+
+/**
+ * The key of result bundle for a list of contact index
+ * \n The contact index on #CT_UG_REQUEST_CHECK
+ * \n Value : convert string to a integer array by using g_base64_decode()
+ * \n Recommends to destroy Contacts UG at ug_cbs.destroy_cb.(not ug_cbs.result_cb)
+ * \n In ug_cbs.result_cb, ug_destroy() should not be called.
+ * @par example
+ * @code
+ void contacts_result_cb(struct ui_gadget *ug, bundle *result, void *data)
+ {
+ if(NULL == ug || NULL == data)
+ return;
+
+ if(result) {
+ const char *val;
+ int *list, len, i;
+
+ val = bundle_get_val(result, CT_UG_BUNDLE_RESULT_PERSON_ID_LIST);
+ list = (int *)g_base64_decode(val, &len);
+
+ for(i=0;i<len/sizeof(int);i++)
+ printf("selected contact = %d", list[i]);
+
+ g_free(list);
+ }
+ }
+ *
+ * @endcode
+ */
+#define CT_UG_BUNDLE_RESULT_PERSON_ID_LIST "person_id_list"
+#define CT_UG_BUNDLE_RESULT_NUMBER_ID_LIST "num_id_list"
+#define CT_UG_BUNDLE_RESULT_EMAIL_ID_LIST "email_id_list"
+#define CT_UG_BUNDLE_RESULT_PERSON_INFO "person_info"
+/**
+ * @}
+ */
+
+#endif //__CONTACTS_UG_H__
diff --git a/include/phone-ug.h b/include/phone-ug.h
new file mode 100755
index 0000000..cc0f4a5
--- /dev/null
+++ b/include/phone-ug.h
@@ -0,0 +1,172 @@
+/*
+* 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_UG_H__
+#define __PHONE_UG_H__
+
+/**
+ * @defgroup PHONE_UG PHONE UI-gadget
+ * @ingroup SLP_UG
+ * @addtogroup PHONE_UG
+ * @{
+ *
+ * Phone UI-gadget (Just a helper-module that contains centralized names of user-gadgets and their properties)
+ * \n This header file contains the declaration & description for Phone UG.
+ *
+ * @section Header To use Them:
+ * @code
+ * #include <phone-ug.h>
+ * @endcode
+ *
+ * @section example Example:
+ * @code
+ #include <stdio.h>
+ #include <ui-gadget.h>
+ #include <phone-ug.h>
+ * @endcode
+ *
+ void phonelog_ug ()
+ {
+ bundle *bd;
+ char buf[16];
+
+ bd = bundle_create();
+ if(NULL == bd) {
+ ERR("bundle_create() Failed");
+ return;
+ }
+
+ snprintf(buf, sizeof(buf), "%d", PH_UG_REQUEST_LOG_CHECK);
+ bundle_add(bd, PH_UG_BUNDLE_TYPE, buf);
+
+ cbs.layout_cb = ug_layout_cb;
+ cbs.result_cb = NULL;
+ cbs.destroy_cb = ug_destroy_cb;
+
+ ug = ug_create(NULL, UG_PHONE_LOG, UG_MODE_FULLVIEW, bd, &cbs);
+ if(NULL == ug)
+ ERR("ug_create() Failed");
+
+ bundle_free(bd);
+ }
+ * @endcode
+ */
+
+/**
+ * The name of phonelog UG
+ */
+#define UG_DIALER_LOG "dialer-efl"
+
+/**
+ * The name of dialer UG
+ * @see #PH_UG_LOG_TYPES
+ */
+#define UG_PHONE_LOG "phonelog-efl"
+
+/**
+ * The name of phoneui UG
+ */
+#define UG_PHONEUI_LOG "phoneui-efl"
+
+/**
+ * types of #UG_PHONEUI
+ */
+enum PHUI_UG_LIST_TYPES
+{
+ PH_UG_REQUEST_SELECT = 11,/**< . */
+ PH_UG_REQUEST_SELECT_NUMBER = 12,/**< . */
+ PH_UG_REQUEST_SELECT_EMAIL = 13,/**< . */
+ PH_UG_REQUEST_SELECT_NUMBER_OR_EMAIL = 17,/**< . */
+
+ PH_UG_REQUEST_SET_WITH_NUM = 21,/**< . */
+ PH_UG_REQUEST_SET_WITH_EMAIL = 22,/**< . */
+ PH_UG_REQUEST_SET_WITH_WEB = 23,/**< . */
+ PH_UG_REQUEST_SET_WITH_IMG = 24,/**< . */
+ PH_UG_REQUEST_SET_WITH_RINGTONE = 25,/**< . */
+
+ PH_UG_REQUEST_CHECK = 31,/**< . */
+ PH_UG_REQUEST_CHECK_FOR_NUMBER = 32,/**< . */
+ PH_UG_REQUEST_CHECK_FOR_EMAIL = 33,/**< . */
+ PH_UG_REQUEST_CHECK_FOR_NUMBER_OR_EMAIL = 34,/**< . */
+
+ PH_UG_REQUEST_LAUNCH_VOICECALL = 51, /**< . */
+};
+
+/**
+ * The name of speeddial UG
+ */
+#define UG_SPEEDDIAL_LOG "speeddial-efl"
+
+/**
+ * types of #PH_UG_LOG_TYPES
+ */
+enum PH_UG_LOG_TYPES
+{
+ PH_UG_REQUEST_LOG_CHECK = 11,
+ PH_UG_REQUEST_LOG_SELECT = 12,
+};
+
+/**
+ * The key of request bundle for type.
+ * \n Value : convert id to string by using \%d.
+ */
+#define PH_UG_BUNDLE_TYPE "type"
+
+/**
+ * The key of result bundle for phonelog index
+ * \n The contact index on #PH_UG_REQUEST_LOG_SELECT
+ * \n Value : convert id to integer by using atoi()
+ * \n Recommends to destroy Phone UG at ug_cbs.destroy_cb.(not ug_cbs.result_cb)
+ * \n In ug_cbs.result_cb, ug_destroy() should not be called.
+ */
+#define PH_UG_BUNDLE_RESULT_PLOG_ID "plog_id"
+
+/**
+ * The key of result bundle for a list of phonelog index
+ * \n The phonelog index on #PH_UG_REQUEST_LOG_CHECK
+ * \n Value : convert string to a integer array by using g_base64_decode()
+ * \n Recommends to destroy Phone UG at ug_cbs.destroy_cb.(not ug_cbs.result_cb)
+ * \n In ug_cbs.result_cb, ug_destroy() should not be called.
+ * @par example
+ * @code
+ void phonelog_result_cb(struct ui_gadget *ug, bundle *result, void *data)
+ {
+ if(NULL == ug || NULL == data)
+ return;
+
+ if(result) {
+ const char *val;
+ int *list, len, i;
+
+ val = bundle_get_val(result, PH_UG_BUNDLE_RESULT_PLOG_ID_LIST);
+ list = (int *)g_base64_decode(val, &len);
+
+ for(i=0;i<len/sizeof(int);i++)
+ printf("selected contact = %d", list[i]);
+
+ g_free(list);
+ }
+ }
+ *
+ * @endcode
+ */
+#define PH_UG_BUNDLE_RESULT_PLOG_ID_LIST "get_select_list" // TODO : change to "plog_id_list"
+
+/**
+ * @}
+ */
+
+#endif //__PHONE_UG_H__
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
new file mode 100755
index 0000000..f379903
--- /dev/null
+++ b/lib/CMakeLists.txt
@@ -0,0 +1,179 @@
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/common/)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/common/include)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/common/Ui/include)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/common/Ui/Genlist/include)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/common/Utils/include)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/ct-front/include)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/details/include)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/dialer/include)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/favor/include)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/list/include)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/log/include)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/ph-front/include)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/speed/include)
+
+SET(COMMON_LIB common)
+SET(FAVOR_LIB favorite)
+SET(SPEEDDIAL ug-speeddial-efl)
+SET(PH_LOG ug-phonelog-efl)
+SET(CT_DETAILS ug-contacts-details-efl)
+SET(CT_LIST ug-contacts-list-efl)
+SET(CT_SETTING ug-contacts-settings-efl)
+SET(PH_DIALER ug-dialer-efl)
+SET(PH_FRONT ug-phone-tabui-efl)
+SET(CT_FRONT ug-contacts-tabui-efl)
+SET(UGLIBDIR "/usr/ug/lib")
+
+FILE(GLOB_RECURSE COMMON_SRCS common/*.cpp)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(ug_pkgs REQUIRED contacts-service2 msg-service efl-assist)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC")
+
+FOREACH(flag ${ug_pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(ug_pkgs_LDFLAGS "${pkgs_LDFLAGS} ${ug_pkgs_LDFLAGS}")
+
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/contact_button.edj
+ COMMAND edje_cc -id ${CMAKE_SOURCE_DIR}/lib/images/phoneug-images
+ ${EDC_SRC_DIR}/contact_button.edc ${CMAKE_BINARY_DIR}/contact_button.edj
+ DEPENDS ${EDC_SRC_DIR}/contact_button.edc
+ )
+
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/progress.edj
+ COMMAND edje_cc -id ${CMAKE_SOURCE_DIR}/lib/images
+ ${EDC_SRC_DIR}/progress.edc ${CMAKE_BINARY_DIR}/progress.edj
+ DEPENDS ${EDC_SRC_DIR}/progress.edc
+ )
+
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/dialer.edj
+ COMMAND edje_cc -id ${CMAKE_SOURCE_DIR}/lib/images
+ ${EDC_SRC_DIR}/dialer.edc ${CMAKE_BINARY_DIR}/dialer.edj
+ DEPENDS ${EDC_SRC_DIR}/dialer.edc
+ )
+
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/dialer_theme.edj
+ COMMAND edje_cc -id ${CMAKE_SOURCE_DIR}/lib/images
+ ${EDC_SRC_DIR}/dialer_theme.edc ${CMAKE_BINARY_DIR}/dialer_theme.edj
+ DEPENDS ${EDC_SRC_DIR}/dialer_theme.edc
+ )
+
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/speeddial_theme.edj
+ COMMAND edje_cc -id ${CMAKE_SOURCE_DIR}/lib/images
+ ${EDC_SRC_DIR}/speeddial_theme.edc ${CMAKE_BINARY_DIR}/speeddial_theme.edj
+ DEPENDS ${EDC_SRC_DIR}/speeddial_theme.edc
+ )
+
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/logdetail_theme.edj
+ COMMAND edje_cc -id ${CMAKE_SOURCE_DIR}/lib/images
+ ${EDC_SRC_DIR}/logdetail_theme.edc ${CMAKE_BINARY_DIR}/logdetail_theme.edj
+ DEPENDS ${EDC_SRC_DIR}/logdetail_theme.edc
+ )
+
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/contacts.edj
+ COMMAND edje_cc -id ${CMAKE_SOURCE_DIR}/lib/images/contact_images
+ ${EDC_SRC_DIR}/contacts.edc ${CMAKE_BINARY_DIR}/contacts.edj
+ DEPENDS ${EDC_SRC_DIR}/contacts.edc ${EDC_SRC_DIR}/list.edc ${EDC_SRC_DIR}/progress.edc
+ )
+
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/favorites_theme.edj
+ COMMAND edje_cc -id ${CMAKE_SOURCE_DIR}/lib/images
+ ${EDC_SRC_DIR}/favorites_theme.edc ${CMAKE_BINARY_DIR}/favorites_theme.edj
+ DEPENDS ${EDC_SRC_DIR}/favorites_theme.edc
+ )
+
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/group_theme.edj
+ COMMAND edje_cc -id ${CMAKE_SOURCE_DIR}/images
+ ${EDC_SRC_DIR}/group_theme.edc ${CMAKE_BINARY_DIR}/group_theme.edj
+ DEPENDS ${EDC_SRC_DIR}/group_theme.edc
+ )
+
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/image_layout.edj
+ COMMAND edje_cc -id ${CMAKE_SOURCE_DIR}/images
+ ${EDC_SRC_DIR}/image_layout.edc ${CMAKE_BINARY_DIR}/image_layout.edj
+ DEPENDS ${EDC_SRC_DIR}/image_layout.edc
+ )
+
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/list_theme.edj
+ COMMAND edje_cc -id ${CMAKE_SOURCE_DIR}/images
+ ${EDC_SRC_DIR}/list_theme.edc ${CMAKE_BINARY_DIR}/list_theme.edj
+ DEPENDS ${EDC_SRC_DIR}/list_theme.edc
+ )
+
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/detail_theme.edj
+ COMMAND edje_cc -id ${CMAKE_SOURCE_DIR}/lib/images
+ ${EDC_SRC_DIR}/detail_theme.edc ${CMAKE_BINARY_DIR}/detail_theme.edj
+ DEPENDS ${EDC_SRC_DIR}/detail_theme.edc
+ )
+
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/selectioninfo.edj
+ COMMAND edje_cc
+ ${EDC_SRC_DIR}/selectioninfo.edc ${CMAKE_BINARY_DIR}/selectioninfo.edj
+ DEPENDS ${EDC_SRC_DIR}/selectioninfo.edc
+ )
+
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/nocontent_layout.edj
+ COMMAND edje_cc -id ${CMAKE_SOURCE_DIR}/lib/images/
+ ${EDC_SRC_DIR}/nocontent_layout.edc ${CMAKE_BINARY_DIR}/nocontent_layout.edj
+ DEPENDS ${EDC_SRC_DIR}/nocontent_layout.edc
+ )
+
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/log_item_icon.edj
+ COMMAND edje_cc -id ${CMAKE_SOURCE_DIR}/lib/images/
+ ${EDC_SRC_DIR}/log_item_icon.edc ${CMAKE_BINARY_DIR}/log_item_icon.edj
+ DEPENDS ${EDC_SRC_DIR}/log_item_icon.edc
+ )
+
+ADD_CUSTOM_TARGET(contact_button_edj_build DEPENDS ${CMAKE_BINARY_DIR}/contact_button.edj)
+ADD_CUSTOM_TARGET(progress_edj_build DEPENDS ${CMAKE_BINARY_DIR}/progress.edj)
+ADD_CUSTOM_TARGET(dialer_theme_build DEPENDS ${CMAKE_BINARY_DIR}/dialer_theme.edj)
+ADD_CUSTOM_TARGET(dialer_edj_build DEPENDS ${CMAKE_BINARY_DIR}/dialer.edj)
+ADD_CUSTOM_TARGET(speeddial_theme_build DEPENDS ${CMAKE_BINARY_DIR}/speeddial_theme.edj)
+ADD_CUSTOM_TARGET(logdetail_theme_build DEPENDS ${CMAKE_BINARY_DIR}/logdetail_theme.edj)
+ADD_CUSTOM_TARGET(contacts_edj_build DEPENDS ${CMAKE_BINARY_DIR}/contacts.edj)
+ADD_CUSTOM_TARGET(favorites_theme_build DEPENDS ${CMAKE_BINARY_DIR}/favorites_theme.edj)
+ADD_CUSTOM_TARGET(group_theme_edj_build DEPENDS ${CMAKE_BINARY_DIR}/group_theme.edj)
+ADD_CUSTOM_TARGET(image_layout_edj_build DEPENDS ${CMAKE_BINARY_DIR}/image_layout.edj)
+ADD_CUSTOM_TARGET(list_theme_edj_build DEPENDS ${CMAKE_BINARY_DIR}/list_theme.edj)
+ADD_CUSTOM_TARGET(detail_theme_edj_build DEPENDS ${CMAKE_BINARY_DIR}/detail_theme.edj)
+ADD_CUSTOM_TARGET(selectioninfo_edj_build DEPENDS ${CMAKE_BINARY_DIR}/selectioninfo.edj)
+ADD_CUSTOM_TARGET(nocontent_layout_edj_build DEPENDS ${CMAKE_BINARY_DIR}/nocontent_layout.edj)
+ADD_CUSTOM_TARGET(log_item_icon_edj_build DEPENDS ${CMAKE_BINARY_DIR}/log_item_icon.edj)
+
+ADD_LIBRARY(${COMMON_LIB} STATIC ${COMMON_SRCS})
+SET_TARGET_PROPERTIES(${COMMON_LIB} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS})
+TARGET_LINK_LIBRARIES(${COMMON_LIB} ${ug_pkgs_LDFLAGS})
+ADD_DEPENDENCIES(${COMMON_LIB} selectioninfo_edj_build)
+ADD_DEPENDENCIES(${COMMON_LIB} nocontent_layout_edj_build)
+ADD_DEPENDENCIES(${COMMON_LIB} log_item_icon_edj_build)
+
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/phone-ug.h DESTINATION /usr/include)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/contacts-ug.h DESTINATION /usr/include)
+INSTALL(FILES ${CMAKE_BINARY_DIR}/contact_button.edj DESTINATION ${EDJDIR})
+INSTALL(FILES ${CMAKE_BINARY_DIR}/contacts.edj DESTINATION ${EDJDIR})
+INSTALL(FILES ${CMAKE_BINARY_DIR}/progress.edj DESTINATION ${EDJDIR})
+INSTALL(FILES ${CMAKE_BINARY_DIR}/dialer.edj DESTINATION ${EDJDIR})
+INSTALL(FILES ${CMAKE_BINARY_DIR}/dialer_theme.edj DESTINATION ${EDJDIR})
+INSTALL(FILES ${CMAKE_BINARY_DIR}/speeddial_theme.edj DESTINATION ${EDJDIR})
+INSTALL(FILES ${CMAKE_BINARY_DIR}/logdetail_theme.edj DESTINATION ${EDJDIR})
+INSTALL(FILES ${CMAKE_BINARY_DIR}/favorites_theme.edj DESTINATION ${EDJDIR})
+INSTALL(FILES ${CMAKE_BINARY_DIR}/group_theme.edj DESTINATION ${EDJDIR})
+INSTALL(FILES ${CMAKE_BINARY_DIR}/image_layout.edj DESTINATION ${EDJDIR})
+INSTALL(FILES ${CMAKE_BINARY_DIR}/list_theme.edj DESTINATION ${EDJDIR})
+INSTALL(FILES ${CMAKE_BINARY_DIR}/detail_theme.edj DESTINATION ${EDJDIR})
+INSTALL(FILES ${CMAKE_BINARY_DIR}/selectioninfo.edj DESTINATION ${EDJDIR})
+INSTALL(FILES ${CMAKE_BINARY_DIR}/nocontent_layout.edj DESTINATION ${EDJDIR})
+INSTALL(FILES ${CMAKE_BINARY_DIR}/log_item_icon.edj DESTINATION ${EDJDIR})
+
+ADD_SUBDIRECTORY(speed)
+ADD_SUBDIRECTORY(log)
+ADD_SUBDIRECTORY(dialer)
+ADD_SUBDIRECTORY(details)
+ADD_SUBDIRECTORY(list)
+ADD_SUBDIRECTORY(settings)
+ADD_SUBDIRECTORY(favor)
+ADD_SUBDIRECTORY(ph-front)
+ADD_SUBDIRECTORY(ct-front)
diff --git a/lib/common/Database/Database.cpp b/lib/common/Database/Database.cpp
new file mode 100644
index 0000000..2b4e47e
--- /dev/null
+++ b/lib/common/Database/Database.cpp
@@ -0,0 +1,195 @@
+/*
+ * Copyright 2012-2013 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.
+ */
+
+#include "Database/Database.h"
+
+#include <contacts.h>
+#include "phone.h"
+#include "Database/Listener.h"
+
+namespace Database
+{
+ Database::Database()
+ : m_IsConnected(false)
+ {
+ PH_TRACE;
+ }
+
+ Database::~Database()
+ {
+ PH_TRACE;
+ disconnect();
+ }
+
+ Database & Database::getInstance()
+ {
+ static Database instance;
+ return instance;
+ }
+
+ bool Database::connect()
+ {
+ PH_TRACE;
+ if(!m_IsConnected)
+ {
+ m_IsConnected = isSuccess(contacts_connect2());
+ }
+
+ return m_IsConnected;
+ }
+
+ bool Database::disconnect()
+ {
+ PH_TRACE;
+ if(m_IsConnected)
+ {
+ m_IsConnected = !isSuccess(contacts_disconnect2());
+ }
+
+ return !m_IsConnected;
+ }
+
+ bool Database::isConnected() const
+ {
+ return m_IsConnected;
+ }
+
+ bool Database::addListener(const char *uri, Listener *listener)
+ {
+ PH_TRACE;
+ return isSuccess(contacts_db_add_changed_cb_with_info(uri, onChange, listener));
+ }
+
+ bool Database::removeListener(const char *uri, Listener *listener)
+ {
+ PH_TRACE;
+ return isSuccess(contacts_db_remove_changed_cb_with_info(uri, onChange, listener));
+ }
+
+ bool Database::isSuccess(int result)
+ {
+#ifdef PH_DEBUGGING
+ if(result == CONTACTS_ERROR_NONE)
+ {
+ return true;
+ }
+ else
+ {
+ const char *error = NULL;
+ switch(result)
+ {
+ case CONTACTS_ERROR_OUT_OF_MEMORY:
+ error = "Out of memory";
+ break;
+ case CONTACTS_ERROR_INVALID_PARAMETER:
+ error = "Invalid parameter";
+ break;
+ case CONTACTS_ERROR_FILE_NO_SPACE:
+ error = "File system is full";
+ break;
+ case CONTACTS_ERROR_NO_DATA:
+ error = "Requested data does not exist";
+ break;
+ case CONTACTS_ERROR_PERMISSION_DENIED:
+ error = "Permission denied";
+ break;
+ case CONTACTS_ERROR_DB:
+ error = "Unknown DB error, make sure that connection was established";
+ break;
+ case CONTACTS_ERROR_IPC_NOT_AVALIABLE:
+ error = "IPC server is not available";
+ break;
+ case CONTACTS_ERROR_IPC:
+ error = "Unknown IPC error";
+ break;
+ case CONTACTS_ERROR_SYSTEM:
+ error = "System error";
+ break;
+ case CONTACTS_ERROR_INTERNAL:
+ error = "Internal error";
+ break;
+ default:
+ error = "Unknown error";
+ break;
+ }
+
+ ERR("Contacts database error %h: %s", result, error);
+ return false;
+ }
+#else
+ return result == CONTACTS_ERROR_NONE;
+#endif /* PH_DEBUGGING */
+ }
+
+ void Database::onChange(const char *uri, char *changes, void *data)
+ {
+ PH_TRACE;
+ if(!uri || !changes || !data)
+ {
+ return;
+ }
+
+ DBG("URI: %s", uri);
+ DBG("change: %s", changes);
+ /*
+ * The format of changes parameter is as follows:
+ * change:id,change:id...
+ *
+ * where "change" is a string representation of one of the the following values:
+ * - CONTACTS_CHANGE_INSERTED
+ * - CONTACTS_CHANGE_UPDATED
+ * - CONTACTS_CHANGE_DELETED
+ * and "id" is a string representation of database record ID
+ */
+
+ Listener *listener = static_cast<Listener*>(data);
+ char *p = changes;
+ while(*p)
+ {
+ int change = *p - '0';
+
+ if(*++p == ':')
+ {
+ ++p;
+ }
+
+ int id = atoi(p);
+ switch(change)
+ {
+ case CONTACTS_CHANGE_INSERTED:
+ DBG("change: INSERT, id: %d", id);
+ listener->onRecordInsert(uri, id);
+ break;
+ case CONTACTS_CHANGE_UPDATED:
+ DBG("change: UPDATE, id: %d", id);
+ listener->onRecordUpdate(uri, id);
+ break;
+ case CONTACTS_CHANGE_DELETED:
+ DBG("change: DELETE, id: %d", id);
+ listener->onRecordDelete(uri, id);
+ break;
+ }
+
+ while(*p && *p != ',')
+ ++p;
+
+ if(*p == ',')
+ {
+ ++p;
+ }
+ }
+ }
+}
diff --git a/lib/common/Database/Database.h b/lib/common/Database/Database.h
new file mode 100644
index 0000000..15324eb
--- /dev/null
+++ b/lib/common/Database/Database.h
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2012-2013 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 __DATABASE_DATABASE_H__
+#define __DATABASE_DATABASE_H__
+
+#include "NonCopyable.h"
+
+namespace Database
+{
+ class Listener;
+ /*
+ * @brief Contacts database connection class.
+ * @remarks Database connection is automatically closed on destruction.
+ */
+ class Database : public Utils::NonCopyable
+ {
+ public:
+ /*
+ * @return Database instance
+ */
+ static Database & getInstance();
+
+ /*
+ * @brief Connect to database.
+ * @return true on success, false otherwise
+ */
+ bool connect();
+
+ /*
+ * @brief Disconnect from database.
+ * @return true on success, false otherwise
+ */
+ bool disconnect();
+
+ /*
+ * @return true if connection is established, false otherwise
+ */
+ bool isConnected() const;
+
+ /*
+ * @brief Listen for changes in specified database view (table)
+ * @remarks Always remove added listeners by calling removeListener
+ *
+ * @param uri Database view URI
+ * @param listener Database listener
+ * @return true if listener successfully added, false otherwise
+ * @see Database::Listener
+ */
+ bool addListener(const char *uri, Listener *listener);
+
+ /*
+ * @brief Remove previously added database listener
+ * @warning Not removing listeners before their destruction
+ * can render your application not workable until contacts service restart
+ *
+ * @param uri Database view URI
+ * @param listener Database listener
+ * @return true if listener successfully removed, false otherwise
+ */
+ bool removeListener(const char *uri, Listener *listener);
+
+ /*
+ * @brief Determine whether result code indicates success.
+ * @remarks If result code indicates error,
+ * an error message will be written to logs.
+ *
+ * @param result Contacts database API error code
+ * @return true on success, false otherwise
+ */
+ static bool isSuccess(int result);
+
+ private:
+ Database();
+ ~Database();
+
+ static void onChange(const char *uri, char *changes, void *data);
+
+ bool m_IsConnected;
+ };
+}
+
+#endif /* __DATABASE_DATABASE_H__ */
diff --git a/lib/common/Database/Listener.h b/lib/common/Database/Listener.h
new file mode 100644
index 0000000..99c99eb
--- /dev/null
+++ b/lib/common/Database/Listener.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2012-2013 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 __DATABASE_LISTENER_H__
+#define __DATABASE_LISTENER_H__
+
+namespace Database
+{
+ /*
+ * @brief Database changes listener
+ * @details Implement this interface if you want to respond to changes happening in database
+ */
+ class Listener
+ {
+ public:
+ virtual ~Listener() { }
+
+ /*
+ * @brief Called whenever a new record was inserted into observed table(s)
+ * @param uri URI of changed view (table)
+ * @param id ID of newly inserted record
+ */
+ virtual void onRecordInsert(const char *uri, int id) { }
+
+ /*
+ * @brief Called whenever a record was updated in the observed table(s)
+ * @param uri URI of changed view (table)
+ * @param id ID of updated record
+ */
+ virtual void onRecordUpdate(const char *uri, int id) { }
+
+ /*
+ * @brief Called whenever a record was deleted from observed table(s)
+ * @param uri URI of changed view (table)
+ * @param id ID of deleted record
+ */
+ virtual void onRecordDelete(const char *uri, int id) { }
+ };
+}
+
+#endif /* __DATABASE_LISTENER_H__ */
diff --git a/lib/common/Front.cpp b/lib/common/Front.cpp
new file mode 100644
index 0000000..3719443
--- /dev/null
+++ b/lib/common/Front.cpp
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2012-2013 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.
+ */
+
+#include "Front.h"
+
+namespace Common
+{
+ Front::Front()
+ : win(NULL), navi(NULL), layout(NULL),
+ ug(NULL), ug_data(NULL), ug_request(0),
+ cnt_max(0), idler(NULL), timer(NULL)
+ {
+ }
+}
diff --git a/lib/common/Ui/Genlist/Genlist.cpp b/lib/common/Ui/Genlist/Genlist.cpp
new file mode 100644
index 0000000..5a9b779
--- /dev/null
+++ b/lib/common/Ui/Genlist/Genlist.cpp
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2012-2013 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.
+ */
+
+#include "Genlist.h"
+#include "phone.h"
+
+namespace Ui
+{
+ namespace Genlist
+ {
+ bool Genlist::create(Evas_Object *parent)
+ {
+ PH_TRACE;
+ if(parent && !getObject())
+ {
+ return setObject(elm_genlist_add(parent));
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ Elm_Object_Item * Genlist::append(Item *item, Elm_Object_Item *parent)
+ {
+ PH_TRACE;
+ check_if(!item, return NULL);
+ Elm_Object_Item *objItem = elm_genlist_item_append(getObject(), item->getClass(), item, parent, item->getType(), onItemSelect, item);
+ return objItem;
+ }
+
+ void Genlist::onItemSelect(void *data, Evas_Object *obj, void *event_info)
+ {
+ PH_TRACE;
+ if(data && event_info)
+ {
+ Item *item = static_cast<Item *>(data);
+ Elm_Object_Item *objItem = static_cast<Elm_Object_Item *>(event_info);
+ item->onSelect(*objItem);
+ }
+ }
+ }
+}
diff --git a/lib/common/Ui/Genlist/Item.cpp b/lib/common/Ui/Genlist/Item.cpp
new file mode 100644
index 0000000..c43982f
--- /dev/null
+++ b/lib/common/Ui/Genlist/Item.cpp
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2012-2013 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.
+ */
+
+#include "Item.h"
+#include "phone.h"
+
+namespace Ui
+{
+ namespace Genlist
+ {
+ Item::Item(Elm_Genlist_Item_Type type)
+ : m_Type(type)
+ {
+ PH_TRACE;
+ }
+
+ Item::~Item()
+ {
+ PH_TRACE;
+ }
+
+ Elm_Genlist_Item_Class * Item::createClass(const char *style, const char *decorateStyle, const char *editStyle)
+ {
+ PH_TRACE;
+ Elm_Genlist_Item_Class *itemClass = elm_genlist_item_class_new();
+ check_if(!itemClass, return NULL);
+ itemClass->item_style = style;
+ itemClass->decorate_item_style = decorateStyle;
+ itemClass->decorate_all_item_style = editStyle;
+ itemClass->func.text_get = Item::getText;
+ itemClass->func.content_get = Item::getContent;
+ itemClass->func.state_get = Item::getState;
+ itemClass->func.del = Item::onDestroy;
+ return itemClass;
+ }
+
+ char * Item::getText(void *data, Evas_Object *obj, const char *part)
+ {
+ PH_TRACE;
+ if(data)
+ {
+ return static_cast<Item *>(data)->getText(part);
+ }
+
+ return NULL;
+ }
+
+ Evas_Object * Item::getContent(void *data, Evas_Object *obj, const char *part)
+ {
+ PH_TRACE;
+ if(data)
+ {
+ return static_cast<Item *>(data)->getContent(part, obj);
+ }
+
+ return NULL;
+ }
+
+ Eina_Bool Item::getState(void *data, Evas_Object *obj, const char *part)
+ {
+ PH_TRACE;
+ if(data)
+ {
+ return static_cast<Item *>(data)->getState(part);
+ }
+
+ return EINA_FALSE;
+ }
+
+ void Genlist::Item::onDestroy(void *data, Evas_Object *obj)
+ {
+ PH_TRACE;
+ if(data)
+ {
+ delete static_cast<Item *>(data);
+ }
+ }
+ }
+}
diff --git a/lib/common/Ui/Genlist/include/Genlist.h b/lib/common/Ui/Genlist/include/Genlist.h
new file mode 100644
index 0000000..a3df78d
--- /dev/null
+++ b/lib/common/Ui/Genlist/include/Genlist.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2012-2013 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 __UI_GENLIST_GENLIST_H__
+#define __UI_GENLIST_GENLIST H__
+
+#include "Widget.h"
+#include "Item.h"
+
+namespace Ui
+{
+ namespace Genlist
+ {
+ /*
+ * \par Description:
+ * Genlist wrapper class.
+ */
+ class Genlist : public Widget
+ {
+ public:
+ /*
+ * \par Description:
+ * Create new genlist with @p parent as parent.
+ *
+ * @see Widget::create
+ */
+ bool create(Evas_Object *parent);
+
+ /*
+ * \par Description:
+ * Add item to the end of genlist.
+ *
+ * @return A handle to the item added or @c NULL if not possible
+ * @see elm_genlist_item_append
+ */
+ Elm_Object_Item * append(Item *item, Elm_Object_Item *parent = NULL);
+
+ private:
+ static void onItemSelect(void *data, Evas_Object *obj, void *event_info);
+ };
+ }
+}
+
+#endif /* __UI_GENLIST_GENLIST_H__ */
diff --git a/lib/common/Ui/Genlist/include/Item.h b/lib/common/Ui/Genlist/include/Item.h
new file mode 100644
index 0000000..28876ea
--- /dev/null
+++ b/lib/common/Ui/Genlist/include/Item.h
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2012-2013 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 __UI_GENLIST_ITEM_H__
+#define __UI_GENLIST_ITEM_H__
+
+#include <Elementary.h>
+#include "NonCopyable.h"
+
+namespace Ui
+{
+ namespace Genlist
+ {
+ /*
+ * \par Description:
+ * Wrapper class for genlist item. Redirects item's callbacks to virtual methods.
+ * Any instance of this class should be allocated with operator new.
+ * It will be automatically deleted by genlist when item is deleted.
+ */
+ class Item : public Utils::NonCopyable
+ {
+ public:
+ Item(Elm_Genlist_Item_Type type = ELM_GENLIST_ITEM_NONE);
+ virtual ~Item();
+
+ /*
+ * \par Description:
+ * Returned value should be individual for every derived class.
+ * This can be achieved by storing pointer to Elm_Genlist_Item_Class
+ * in a static variable inside overloaded method and initializing it using createClass.
+ * This way every derived class will have its own Elm_Genlist_Item_Class.
+ *
+ * @par example
+ * @code
+ *
+ * Elm_Genlist_Item_Class * getClass() const
+ * {
+ * static Elm_Genlist_Item_Class *itemClass = createClass("2text.1icon");
+ * return itemClass;
+ * }
+ *
+ * @endcode
+ */
+ virtual Elm_Genlist_Item_Class * getClass() const = 0;
+
+ /*
+ * \par Description:
+ * Called whenever any item's text part needs to be updated.
+ *
+ * @param[in] part Name of the part
+ * @return Allocated string with text for a specified part,
+ * it will be deallocated with free() by genlist
+ */
+ virtual char * getText(const char *part) const { return NULL; }
+
+ /*
+ * \par Description:
+ * Called whenever any item's content part needs to be updated.
+ *
+ * @param[in] part Name of the part
+ * @param[in] parent Parent genlist to use as a parent object for content
+ * @return Content for a specified part
+ */
+ virtual Evas_Object * getContent(const char *part, Evas_Object *parent) const { return NULL; }
+
+ /*
+ * \par Description:
+ * Called whenever any item's state part needs to be updated.
+ * Genlist will emit signal "elm,state,x,active" or "elm,state,x,passive"
+ * with part's name instead of 'x'.
+ *
+ * @param[in] part Name of the part
+ * @return true for active, false for passive
+ *
+ */
+ virtual bool getState(const char *part) const { return false; }
+
+ /*
+ * \par Description:
+ * Called when selection event occurs on the item.
+ *
+ * @param item Elm_Object_Item for selected item
+ */
+ virtual void onSelect(Elm_Object_Item &item) { }
+
+ /*
+ * @return Item type
+ * @see Elm_Genlist_Item_Type
+ */
+ Elm_Genlist_Item_Type getType() const { return m_Type; }
+
+ protected:
+ static Elm_Genlist_Item_Class * createClass(
+ const char *style,
+ const char *decorateStyle = NULL,
+ const char *editStyle = NULL
+ );
+
+ private:
+ Elm_Genlist_Item_Type m_Type;
+
+ static char * getText(void *data, Evas_Object *obj, const char *part);
+ static Evas_Object * getContent(void *data, Evas_Object *obj, const char *part);
+ static Eina_Bool getState(void *data, Evas_Object *obj, const char *part);
+ static void onDestroy(void *data, Evas_Object *obj);
+ };
+ }
+}
+
+#endif /* __UI_GENLIST_ITEM_H__ */
diff --git a/lib/common/Ui/Widget.cpp b/lib/common/Ui/Widget.cpp
new file mode 100644
index 0000000..92b2b60
--- /dev/null
+++ b/lib/common/Ui/Widget.cpp
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2012-2013 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.
+ */
+
+#include "Widget.h"
+#include "phone.h"
+
+namespace Ui
+{
+ Widget::Widget()
+ : m_Object(NULL)
+ {
+ PH_TRACE;
+ }
+
+ Widget::~Widget()
+ {
+ PH_TRACE;
+ if(m_Object)
+ {
+ evas_object_del(m_Object);
+ m_Object = NULL;
+ }
+ }
+
+ Evas_Object * Widget::getObject() const
+ {
+ PH_TRACE;
+ return m_Object;
+ }
+
+ bool Widget::setObject(Evas_Object *object)
+ {
+ PH_TRACE;
+ m_Object = object;
+ return m_Object != NULL;
+ }
+}
diff --git a/lib/common/Ui/include/Widget.h b/lib/common/Ui/include/Widget.h
new file mode 100644
index 0000000..9e712f3
--- /dev/null
+++ b/lib/common/Ui/include/Widget.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2012-2013 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 __UI_WIDGET_H__
+#define __UI_WIDGET_H__
+
+#include <Elementary.h>
+
+#include "NonCopyable.h"
+
+namespace Ui
+{
+ /*
+ * \par Description:
+ * Base wrapper class for all Evas objects.
+ */
+ class Widget : public Utils::NonCopyable
+ {
+ public:
+ virtual ~Widget();
+
+ /*
+ * \par Description create derived widget with @p parent as parent.
+ *
+ * @return true on success, false otherwise
+ */
+ virtual bool create(Evas_Object *parent) = 0;
+
+ /*
+ * @return Underlying Evas_Object.
+ */
+ Evas_Object * getObject() const;
+
+ protected:
+ Widget();
+ bool setObject(Evas_Object *object);
+
+ private:
+ Evas_Object *m_Object;
+ };
+}
+
+#endif /* __UI_WIDGET_H__ */
diff --git a/lib/common/Utils/NonCopyable.cpp b/lib/common/Utils/NonCopyable.cpp
new file mode 100644
index 0000000..276824c
--- /dev/null
+++ b/lib/common/Utils/NonCopyable.cpp
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2012-2013 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.
+ */
+
+/**
+ * @file NonCopyable.cpp.
+ * @brief implementation of NonCopyable class.
+ * @author Andrey Klimenko (and.klimenko@samsung.com)
+ */
+
+#include "NonCopyable.h"
+
+namespace Utils
+{
+ NonCopyable::NonCopyable()
+ {
+ }
+
+ NonCopyable::~NonCopyable()
+ {
+ }
+}
diff --git a/lib/common/Utils/Tracer.cpp b/lib/common/Utils/Tracer.cpp
new file mode 100644
index 0000000..2f644d6
--- /dev/null
+++ b/lib/common/Utils/Tracer.cpp
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2012-2013 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.
+ */
+
+#include "Tracer.h"
+#include <dlog.h>
+
+namespace Utils
+{
+ void substractTime(const timespec& a, const timespec& b, timespec& res)
+ {
+ static const size_t nanosecsInSecond(1000000000);
+
+ res.tv_sec = b.tv_sec - a.tv_sec;
+ res.tv_nsec = b.tv_nsec - a.tv_nsec;
+ if (res.tv_nsec < 0)
+ {
+ --res.tv_sec;
+ res.tv_nsec += nanosecsInSecond;
+ }
+ }
+
+ Tracer::Tracer(const char *tag, const char *file, int line, const char *func)
+ : m_Tag(tag), m_File(file), m_Func(func)
+ {
+ __dlog_print(LOG_ID_APPS, DLOG_DEBUG, m_Tag, "%s: %s(%d) <<< called", m_File, m_Func, line);
+ clock_gettime(CLOCK_REALTIME, &m_startTime);
+ }
+
+ Tracer::~Tracer()
+ {
+ timespec endTime;
+ clock_gettime(CLOCK_REALTIME, &endTime);
+
+ timespec res;
+ substractTime(m_startTime, endTime, res);
+
+ __dlog_print(LOG_ID_APPS, DLOG_DEBUG, m_Tag,
+ "%s: %s >>> returned in %d.%03d seconds",
+ m_File, m_Func, res.tv_sec, res.tv_nsec / 1000000
+ );
+ }
+}
diff --git a/lib/common/Utils/include/NonCopyable.h b/lib/common/Utils/include/NonCopyable.h
new file mode 100644
index 0000000..403fb3c
--- /dev/null
+++ b/lib/common/Utils/include/NonCopyable.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2012-2013 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.
+ */
+
+/**
+ * @file NonCopyable.h
+ * @brief Non-copyable base class.
+ * @author Andrey Klimenko (and.klimenko@samsung.com)
+ */
+
+#ifndef __UTILS_NONCOPYABLE_H__
+#define __UTILS_NONCOPYABLE_H__
+
+namespace Utils
+{
+ /**
+ * An util-like class to make easier restriction of copying or/and instancing for child classes
+ * */
+ class NonCopyable
+ {
+ protected:
+ NonCopyable();
+ ~NonCopyable();
+ private:
+ NonCopyable(const NonCopyable&);
+ const NonCopyable& operator=(const NonCopyable&);
+ };
+}
+
+#endif /* __UTILS_NONCOPYABLE_H__ */
diff --git a/lib/common/Utils/include/SharedPtr.h b/lib/common/Utils/include/SharedPtr.h
new file mode 100644
index 0000000..df8d0a5
--- /dev/null
+++ b/lib/common/Utils/include/SharedPtr.h
@@ -0,0 +1,176 @@
+/*
+ * Copyright 2012-2013 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 __UTILS_SHARED_PTR_H__
+#define __UTILS_SHARED_PTR_H__
+
+#include "phone.h"
+
+namespace Utils
+{
+ /*
+ * @brief Pointer wrapper for automatic memory management based on reference counting
+ * @remarks Use this pointer wrapper if you have to manage dynamically allocated objects
+ * that are being used by several objects and can't be tied to a single object's lifetime.
+ * @details Shared pointer maintains a pointer to type T and a counter.
+ * The counter is increased every time shared pointer is being copied and decreased upon it's destruction.
+ * When counter drops to zero the last copy of shared pointer destroys the object pointed by internal pointer
+ * and deallocates the counter.
+ */
+ template <typename T>
+ class SharedPtr
+ {
+ public:
+ SharedPtr();
+
+ /*
+ * @brief Create a shared pointer from simple pointer
+ * @remarks The counter is being set to 1.
+ * @param ptr Pointer to be shared
+ */
+ SharedPtr(T *ptr);
+
+ /*
+ * @brief Create from another shared pointer
+ * @remarks The counter is being incremented
+ * @param other Another shared pointer
+ */
+ SharedPtr(const SharedPtr &other);
+
+ ~SharedPtr();
+
+ /*
+ * @brief Release the ownership of underlying pointer
+ * and decrease the counter.
+ */
+ void reset();
+
+ /*
+ * @remarks Shared pointer that was default constructed
+ * and wasn't assigned another pointer SHOULD NOT be dereferenced
+ * as it doesn't point to anything (NULL)
+ * @return Dereferenced underlying pointer
+ */
+ T & operator*() const;
+
+ /*
+ * @return Underlying pointer
+ */
+ T * operator->() const;
+
+ /*
+ * @brief Test if pointer points to anything
+ * @return true if isn't NULL, false otherwise
+ */
+ operator bool() const;
+
+ SharedPtr & operator=(const SharedPtr &other);
+
+ private:
+ T *m_Ptr;
+ int *m_Count;
+ };
+
+ template <typename T>
+ SharedPtr<T>::SharedPtr()
+ : m_Ptr(NULL), m_Count(NULL)
+ {
+ }
+
+ template <typename T>
+ SharedPtr<T>::SharedPtr(T *ptr)
+ : m_Ptr(NULL), m_Count(NULL)
+ {
+ if(ptr)
+ {
+ m_Ptr = ptr;
+ m_Count = new int(1);
+ }
+ }
+
+ template <typename T>
+ SharedPtr<T>::SharedPtr(const SharedPtr &other)
+ : m_Ptr(NULL), m_Count(NULL)
+ {
+ if(other.m_Count)
+ {
+ m_Ptr = other.m_Ptr;
+ m_Count = other.m_Count;
+ ++(*m_Count);
+ DBG("count: %d", *m_Count);
+ }
+ }
+
+ template <typename T>
+ SharedPtr<T>::~SharedPtr()
+ {
+ reset();
+ }
+
+ template <typename T>
+ void SharedPtr<T>::reset()
+ {
+ if(m_Count)
+ {
+ --(*m_Count);
+ DBG("count: %d", *m_Count);
+
+ if(*m_Count == 0)
+ {
+ DBG("deleting");
+ delete m_Ptr;
+ delete m_Count;
+ }
+
+ m_Ptr = NULL;
+ m_Count = NULL;
+ }
+ }
+
+ template <typename T>
+ T & SharedPtr<T>::operator*() const
+ {
+ return *m_Ptr;
+ }
+
+ template <typename T>
+ T * SharedPtr<T>::operator->() const
+ {
+ return m_Ptr;
+ }
+
+ template <typename T>
+ SharedPtr<T>::operator bool() const
+ {
+ return m_Ptr != NULL;
+ }
+
+ template <typename T>
+ SharedPtr<T> & SharedPtr<T>::operator=(const SharedPtr &other)
+ {
+ if(other.m_Count && this != &other)
+ {
+ reset();
+ m_Ptr = other.m_Ptr;
+ m_Count = other.m_Count;
+ ++(*m_Count);
+ }
+
+ return *this;
+ }
+}
+
+#endif /* __UTILS_SHARED_PTR_H__ */
diff --git a/lib/common/Utils/include/Tracer.h b/lib/common/Utils/include/Tracer.h
new file mode 100644
index 0000000..898fcb1
--- /dev/null
+++ b/lib/common/Utils/include/Tracer.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2012-2013 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 __UTILS_TRACER_H__
+#define __UTILS_TRACER_H__
+
+#include <time.h>
+
+namespace Utils
+{
+ class Tracer
+ {
+ private:
+ const char * m_Tag;
+ const char * m_File;
+ const char * m_Func;
+ timespec m_startTime;
+ public:
+ Tracer(const char *tag, const char *file, int line, const char *func);
+ ~Tracer();
+ };
+}
+
+#endif /* __UTILS_TRACER_H__ */
diff --git a/lib/common/View.cpp b/lib/common/View.cpp
new file mode 100644
index 0000000..c441368
--- /dev/null
+++ b/lib/common/View.cpp
@@ -0,0 +1,173 @@
+/*
+ * Copyright 2012-2013 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.
+ */
+
+#include "View.h"
+
+#include <ui-gadget-module.h>
+
+#include "phone.h"
+
+namespace Common
+{
+ View::View()
+ : back_cb(NULL), menu_cb(NULL),
+ m_Parent(NULL), m_Content(NULL)
+ {
+ PH_TRACE;
+ }
+
+ View::View(const char *title)
+ : back_cb(NULL), menu_cb(NULL),
+ m_Title(title), m_Parent(NULL), m_Content(NULL)
+ {
+ PH_TRACE;
+ }
+
+ View::~View()
+ {
+ PH_TRACE;
+ // m_Content and its children are destroyed by naviframe pop
+ }
+
+ bool View::initialize(Evas_Object *parent)
+ {
+ PH_TRACE;
+ if(!parent || m_Parent)
+ {
+ return false;
+ }
+
+ m_Parent = parent;
+ m_Content = elm_layout_add(m_Parent);
+
+ if(!m_Content)
+ {
+ m_Parent = NULL;
+ return false;
+ }
+
+ elm_layout_theme_set(m_Content, "layout", "application", "default");
+ evas_object_size_hint_weight_set(m_Content, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+ Evas_Object *bg = elm_bg_add(m_Content);
+
+ if(!bg)
+ {
+ evas_object_del(m_Content);
+ m_Parent = NULL;
+ m_Content = NULL;
+ return false;
+ }
+
+ evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_object_part_content_set(m_Content, "elm.swallow.bg", bg);
+
+ return true;
+ }
+
+ const std::string & View::getTitle() const
+ {
+ PH_TRACE;
+ return m_Title;
+ }
+
+ Evas_Object * View::getContent() const
+ {
+ PH_TRACE;
+ return m_Content;
+ }
+
+ bool View::onBack()
+ {
+ PH_TRACE;
+ bool handled = false;
+
+ if (child_ug)
+ {
+ DBG("send to child ug");
+ ug_send_key_event (UG_KEY_EVENT_END);
+ handled = true;
+ }
+ else if (popup && evas_object_visible_get(popup)) //legacy popups
+ {
+ DBG("hide popup");
+ evas_object_hide(popup);
+ handled = true;
+ }
+ else if (m_ContextMenu && evas_object_visible_get(m_ContextMenu))
+ {
+ DBG("close contextual menu");
+ elm_ctxpopup_dismiss(m_ContextMenu);
+ handled = true;
+ }
+ else if (m_Menu && evas_object_visible_get(m_Menu))
+ {
+ DBG("close menu");
+ elm_ctxpopup_dismiss(m_Menu);
+ handled = true;
+ }
+ else if (m_Widget && elm_object_focus_get(m_Widget))
+ {
+ DBG("unfocus widget");
+ widget_back_cb(this);
+ handled = true;
+ }
+ else if (back_cb)
+ {
+ DBG("call back_cb");
+ back_cb(this);
+ handled = true;
+ }
+
+ return handled;
+ }
+
+ void View::onMenu()
+ {
+ PH_TRACE;
+ if(popup && evas_object_visible_get(popup))
+ {
+ // no menu should appear, when popup is opened
+ return;
+ }
+ if(m_ContextMenu)
+ {
+ if(evas_object_visible_get(m_ContextMenu))
+ {
+ DBG("close contextual menu");
+ elm_ctxpopup_dismiss(m_ContextMenu);
+ }
+ }
+ if(m_Menu)
+ {
+ if(evas_object_visible_get(m_Menu))
+ {
+ DBG("close menu");
+ elm_ctxpopup_dismiss(m_Menu);
+ }
+ else if(menu_cb)
+ {
+ DBG("call menu_cb");
+ menu_cb(this);
+ }
+ }
+ else if(menu_cb)
+ {
+ DBG("call menu_cb");
+ menu_cb(this);
+ }
+ }
+}
diff --git a/lib/common/ViewData.cpp b/lib/common/ViewData.cpp
new file mode 100644
index 0000000..be53cb4
--- /dev/null
+++ b/lib/common/ViewData.cpp
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2012-2013 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.
+ */
+
+#include "ViewData.h"
+
+namespace Common
+{
+ ViewData::ViewData()
+ : win(NULL), navi(NULL), layout(NULL),
+ popup(NULL), m_Menu(NULL), m_ContextMenu(NULL), m_Widget(NULL),
+ navi_item(NULL), th(NULL),
+ ug(NULL), child_ug(NULL)
+ {
+ }
+}
diff --git a/lib/common/ViewManager.cpp b/lib/common/ViewManager.cpp
new file mode 100644
index 0000000..ee211af
--- /dev/null
+++ b/lib/common/ViewManager.cpp
@@ -0,0 +1,190 @@
+/*
+ * Copyright 2012-2013 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.
+ */
+
+
+#include "ViewManager.h"
+
+#include <efl_assist.h>
+#include <ui-gadget-module.h>
+
+#include "phone.h"
+#include "View.h"
+
+namespace Common
+{
+ ViewManager::ViewManager()
+ : m_Layout(NULL)
+ {
+ PH_TRACE;
+ }
+
+ ViewManager::~ViewManager()
+ {
+ if(m_Layout)
+ {
+ evas_object_del(m_Layout);
+ m_Layout = NULL;
+ }
+ }
+
+ bool ViewManager::initialize(Evas_Object *win, Evas_Object *parent)
+ {
+ PH_TRACE;
+ if(!parent || m_Layout)
+ {
+ return false;
+ }
+
+ m_Layout = elm_layout_add(parent);
+ if(!m_Layout)
+ {
+ return false;
+ }
+
+ evas_object_size_hint_weight_set(m_Layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_layout_theme_set(m_Layout, "layout", "application", "default");
+ evas_object_show(m_Layout);
+
+ Evas_Object *bg = elm_bg_add(m_Layout);
+ if(!bg)
+ {
+ evas_object_del(m_Layout);
+ m_Layout = NULL;
+ return false;
+ }
+
+ evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_object_part_content_set(m_Layout, "elm.swallow.bg", bg);
+
+ navi = elm_naviframe_add(m_Layout);
+ if(!navi)
+ {
+ evas_object_del(m_Layout);
+ m_Layout = NULL;
+ return false;
+ }
+
+ elm_naviframe_prev_btn_auto_pushed_set(navi, EINA_FALSE);
+ elm_object_part_content_set(m_Layout, "elm.swallow.content", navi);
+ evas_object_data_set(navi, "ViewManager", this);
+ ea_object_event_callback_add(navi, EA_CALLBACK_BACK, &Common::ViewManager::onBack, win);
+ ea_object_event_callback_add(navi, EA_CALLBACK_MORE, &Common::ViewManager::onMenu, NULL);
+
+ return true;
+ }
+
+ Evas_Object * ViewManager::getContent() const
+ {
+ return m_Layout;
+ }
+
+ void ViewManager::push(View &view)
+ {
+ PH_TRACE;
+ Elm_Object_Item *item = elm_naviframe_item_push(navi, view.getTitle().c_str(), NULL, NULL, view.getContent(), NULL);
+ elm_object_item_data_set(item, &view);
+ evas_object_event_callback_add(view.getContent(), EVAS_CALLBACK_DEL, onViewDestroy, &view);
+ }
+
+ void ViewManager::pop()
+ {
+ PH_TRACE;
+ elm_naviframe_item_pop(navi);
+ }
+
+ void ViewManager::onBack(void *data, Evas_Object *obj, void *event)
+ {
+ PH_TRACE;
+ if(!obj)
+ {
+ return;
+ }
+
+ Elm_Object_Item *top = elm_naviframe_top_item_get(obj);
+
+ if(!top)
+ {
+ //naviframe is empty, nothing to handle
+ return;
+ }
+
+ View *view = static_cast<View *>(elm_object_item_data_get(top));
+ DBG("view = %p", view);
+
+ if (view && view->onBack())
+ {
+ DBG("onBack handled");
+ return;
+ }
+
+ //naviframe has only one item
+ if (top == elm_naviframe_bottom_item_get(obj))
+ {
+ if(view && view->ug)
+ {
+ DBG("destroy self, removing view-callbacks");
+ ea_object_event_callback_del(view->navi, EA_CALLBACK_BACK, &Common::ViewManager::onBack);
+ ea_object_event_callback_del(view->navi, EA_CALLBACK_MORE, &Common::ViewManager::onMenu);
+ ug_destroy_me(view->ug);
+ }
+ else if(data)
+ {
+ DBG("lower win");
+ elm_win_lower(static_cast<Evas_Object *>(data));
+ return;
+ }
+ }
+ else
+ {
+ DBG("pop item");
+ elm_naviframe_item_pop(obj);
+ return;
+ }
+ }
+
+ void ViewManager::onMenu(void *data, Evas_Object *obj, void *event)
+ {
+ PH_TRACE;
+ if(!obj)
+ {
+ return;
+ }
+
+ Elm_Object_Item *top = elm_naviframe_top_item_get(obj);
+
+ if(!top)
+ {
+ //naviframe is empty, nothing to handle
+ return;
+ }
+
+ View *view = static_cast<View *>(elm_object_item_data_get(top));
+
+ if (view)
+ {
+ view->onMenu();
+ }
+ }
+
+ void ViewManager::onViewDestroy(void *data, Evas *e, Evas_Object *obj, void *event_info)
+ {
+ PH_TRACE;
+ if(data)
+ {
+ delete static_cast<View *>(data);
+ }
+ }
+}
diff --git a/lib/common/ct-group-assign-popup.cpp b/lib/common/ct-group-assign-popup.cpp
new file mode 100644
index 0000000..1ffc47d
--- /dev/null
+++ b/lib/common/ct-group-assign-popup.cpp
@@ -0,0 +1,431 @@
+/*
+ * Copyright 2012-2013 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.
+ */
+
+#include "ct-group-assign-popup.h"
+
+#include <contacts.h>
+#include "ct-list.h"
+#include "phone.h"
+#include "phone-text.h"
+
+typedef struct
+{
+ int id;
+ const char *name;
+ Eina_Bool is_assigned;
+ Eina_Bool prev_assigned;
+} ct_group_assign_item;
+
+typedef struct
+{
+ Evas_Object *win;
+ Evas_Object *navi;
+ Evas_Object *popup;
+ Evas_Object *genlist;
+
+ contacts_record_h contact;
+ ct_assign_result_cb assign_cb;
+ void *assign_cb_data;
+
+ unsigned group_count;
+ contacts_list_h group_list;
+ ct_group_assign_item *items;
+} ct_group_assign_data;
+
+static void grp_assign_popup_destroy(ct_group_assign_data *cgassign_d);
+
+static contacts_list_h grp_assign_get_groups();
+static ct_group_assign_item * grp_assign_create_items(contacts_list_h groups, contacts_record_h contact);
+static void grp_assign_add_to_group(contacts_record_h contact, int group_id);
+static void grp_assign_remove_from_group(contacts_record_h contact, int group_id);
+
+static Evas_Object * grp_assign_create_popup(ct_group_assign_data *cgassign_d);
+static Evas_Object * grp_assign_create_genlist(ct_group_assign_data *cgassign_d);
+
+static void grp_assign_gl_fill(ct_group_assign_data *cgassign_d);
+static void grp_assign_gl_sel_cb(void *data, Evas_Object *obj, void *event_info);
+static char * grp_assign_gl_label_get(void *data, Evas_Object *obj, const char *part);
+static Evas_Object * grp_assign_gl_icon_get(void *data, Evas_Object *obj, const char *part);
+
+static void grp_assign_ok_cb(void *data, Evas_Object *obj, void *event_info);
+static void grp_assign_create_cb(void *data, Evas_Object *obj, void *event_info);
+static void grp_assign_group_created_cb(int group_id, void *data, bool changed);
+static void grp_assign_popup_destroy_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
+
+Evas_Object * ct_group_assign_popup_create(Evas_Object *win, Evas_Object *navi,
+ contacts_record_h contact, ct_assign_result_cb assign_cb, void *assign_cb_data)
+{
+ PH_TRACE;
+ p_retvm_if(NULL == win, NULL, "win is NULL");
+ p_retvm_if(NULL == navi, NULL, "navi is NULL");
+ p_retvm_if(NULL == contact, NULL, "contact is NULL");
+
+ unsigned count = 0;
+ contacts_list_h groups = NULL;
+ ct_group_assign_item *items = NULL;
+ ct_group_assign_data *cgassign_d = NULL;
+
+ groups = grp_assign_get_groups();
+ items = grp_assign_create_items(groups, contact);
+ if(!items)
+ {
+ if(groups)
+ {
+ contacts_list_destroy(groups, true);
+ }
+
+ return NULL;
+ }
+
+ contacts_list_get_count(groups, &count);
+
+ cgassign_d = (ct_group_assign_data *) calloc(1, sizeof(ct_group_assign_data));
+ cgassign_d->win = win;
+ cgassign_d->navi = navi;
+ cgassign_d->contact = contact;
+ cgassign_d->assign_cb = assign_cb;
+ cgassign_d->assign_cb_data = assign_cb_data;
+ cgassign_d->group_count = count;
+ cgassign_d->group_list = groups;
+ cgassign_d->items = items;
+
+ cgassign_d->popup = grp_assign_create_popup(cgassign_d);
+ if(!cgassign_d->popup)
+ {
+ grp_assign_popup_destroy(cgassign_d);
+ return NULL;
+ }
+
+ cgassign_d->genlist = grp_assign_create_genlist(cgassign_d);
+ if(!cgassign_d->genlist)
+ {
+ evas_object_del(cgassign_d->popup);
+ return NULL;
+ }
+
+ grp_assign_gl_fill(cgassign_d);
+
+ return cgassign_d->popup;
+}
+
+static void grp_assign_popup_destroy(ct_group_assign_data *cgassign_d)
+{
+ p_retm_if(NULL == cgassign_d, "cgassign_d is NULL");
+
+ if(cgassign_d->items)
+ {
+ free(cgassign_d->items);
+ }
+
+ if(cgassign_d->group_list)
+ {
+ contacts_list_destroy(cgassign_d->group_list, true);
+ }
+
+ free(cgassign_d);
+}
+
+static contacts_list_h grp_assign_get_groups()
+{
+ PH_TRACE;
+ static unsigned props[] =
+ {
+ _contacts_group.id,
+ _contacts_group.name,
+ _contacts_group.extra_data
+ };
+
+ contacts_query_h query = NULL;
+ contacts_list_h list = NULL;
+ if(contacts_query_create(_contacts_group._uri, &query) == CONTACTS_ERROR_NONE)
+ {
+ contacts_query_set_projection(query, props, ARRAY_SIZE(props));
+ contacts_db_get_records_with_query(query, 0, 0, &list);
+ contacts_query_destroy(query);
+ }
+
+ return list;
+}
+
+static ct_group_assign_item * grp_assign_create_items(contacts_list_h groups, contacts_record_h contact)
+{
+ PH_TRACE;
+ p_retvm_if(NULL == groups, NULL, "groups is NULL");
+ p_retvm_if(NULL == contact, NULL, "contact is NULL");
+
+ unsigned group_count = 0;
+ unsigned rel_count = 0;
+ contacts_record_h group = NULL;
+ ct_group_assign_item *items = NULL;
+ ct_group_assign_item *item = NULL;
+ int err = CONTACTS_ERROR_NONE;
+
+ err = contacts_list_get_count(groups, &group_count);
+ p_retvm_if(CONTACTS_ERROR_NONE != err, NULL,
+ "contacts_list_get_count() Failed(%d)", err);
+
+ err = contacts_record_get_child_record_count(contact,
+ _contacts_contact.group_relation, &rel_count);
+ p_retvm_if(CONTACTS_ERROR_NONE != err, NULL,
+ "contacts_record_get_child_record_count() Failed(%d)", err);
+
+ items = (ct_group_assign_item *) calloc(group_count, sizeof(ct_group_assign_item));
+ item = items;
+
+ CONTACTS_LIST_FOREACH(groups, group)
+ {
+ contacts_record_get_int(group, _contacts_group.id, &item->id);
+ item->name = phone_get_group_name(group);
+
+ for(unsigned i = 0; i < rel_count; ++i)
+ {
+ contacts_record_h rel = NULL;
+ int group_id = 0;
+
+ contacts_record_get_child_record_at_p(contact, _contacts_contact.group_relation, i, &rel);
+ contacts_record_get_int(rel, _contacts_group_relation.group_id, &group_id);
+ if(group_id == item->id)
+ {
+ item->prev_assigned = item->is_assigned = true;
+ break;
+ }
+ }
+
+ ++item;
+ }
+ contacts_list_first(groups);
+
+ return items;
+}
+
+static void grp_assign_add_to_group(contacts_record_h contact, int group_id)
+{
+ PH_TRACE;
+ p_retm_if(NULL == contact, "contact is NULL");
+ p_retm_if(group_id < 1, "invalid group ID");
+
+ contacts_record_h record = NULL;
+ int err = CONTACTS_ERROR_NONE;
+
+ err = contacts_record_create(_contacts_group_relation._uri, &record);
+ p_retm_if(CONTACTS_ERROR_NONE != err,
+ "contacts_record_create() Failed(%d)", err);
+
+ err = contacts_record_set_int(record, _contacts_group_relation.group_id,
+ group_id);
+ if(CONTACTS_ERROR_NONE != err)
+ {
+ ERR("contacts_record_set_int() Failed(%d)", err);
+ contacts_record_destroy(record, true);
+ return;
+ }
+
+ err = contacts_record_add_child_record(contact,
+ _contacts_contact.group_relation, record);
+ if(CONTACTS_ERROR_NONE != err)
+ {
+ ERR("contacts_record_add_child_record() Failed(%d)", err);
+ contacts_record_destroy(record, true);
+ return;
+ }
+}
+
+static void grp_assign_remove_from_group(contacts_record_h contact, int group_id)
+{
+ PH_TRACE;
+ p_retm_if(NULL == contact, "contact is NULL");
+ p_retm_if(group_id < 1, "invalid group ID");
+
+ unsigned rel_count = 0;
+ int err = CONTACTS_ERROR_NONE;
+
+ err = contacts_record_get_child_record_count(contact,
+ _contacts_contact.group_relation, &rel_count);
+ p_retm_if(CONTACTS_ERROR_NONE != err,
+ "contacts_record_get_child_record_count() Failed(%d)", err);
+
+ for(unsigned i = 0; i < rel_count; ++i)
+ {
+ contacts_record_h rel = NULL;
+ int id = 0;
+
+ contacts_record_get_child_record_at_p(contact, _contacts_contact.group_relation, i, &rel);
+ contacts_record_get_int(rel, _contacts_group_relation.group_id, &id);
+ if(id == group_id)
+ {
+ contacts_record_remove_child_record(contact, _contacts_contact.group_relation, rel);
+ break;
+ }
+ }
+}
+
+static Evas_Object * grp_assign_create_popup(ct_group_assign_data *cgassign_d)
+{
+ PH_TRACE;
+ p_retvm_if(NULL == cgassign_d, NULL, "cgassign_d is NULL");
+
+ Evas_Object *popup = elm_popup_add(cgassign_d->navi);
+ p_retvm_if(NULL == popup, NULL, "elm_popup_add() failed");
+
+ bool success = phone_popup_add_button(popup, S_(PH_SYS_SK_CANCEL),
+ NULL, NULL) != NULL
+ && phone_popup_add_button(popup, S_(PH_SYS_SK_OK),
+ grp_assign_ok_cb, cgassign_d) != NULL
+ && phone_popup_add_button(popup, S_(CT_SYS_BODY_CREATE),
+ grp_assign_create_cb, cgassign_d) != NULL;
+
+ if(!success)
+ {
+ evas_object_del(popup);
+ return NULL;
+ }
+
+ elm_object_style_set(popup, "content_no_vhpad");
+ evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL,
+ grp_assign_popup_destroy_cb, cgassign_d);
+ evas_object_show(popup);
+
+ return popup;
+}
+
+static Evas_Object * grp_assign_create_genlist(ct_group_assign_data *cgassign_d)
+{
+ PH_TRACE;
+ p_retvm_if(NULL == cgassign_d, NULL, "cgassign_d is NULL");
+
+ Evas_Object *genlist = elm_genlist_add(cgassign_d->popup);
+ p_retvm_if(NULL == genlist, NULL, "elm_genlist_add() failed");
+
+ elm_object_content_set(cgassign_d->popup, genlist);
+ evas_object_smart_callback_add(genlist, "selected", grp_assign_gl_sel_cb, cgassign_d);
+
+ return genlist;
+}
+
+static void grp_assign_gl_fill(ct_group_assign_data *cgassign_d)
+{
+ PH_TRACE;
+ Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
+ itc->item_style = "1text.1icon.2/popup";
+ itc->func.text_get = grp_assign_gl_label_get;
+ itc->func.content_get = grp_assign_gl_icon_get;
+
+ ct_group_assign_item *item = cgassign_d->items;
+ ct_group_assign_item *end = item + cgassign_d->group_count;
+ for(; item != end; ++item)
+ {
+ elm_genlist_item_append(cgassign_d->genlist, itc, item,
+ NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ }
+
+ elm_genlist_item_class_free(itc);
+}
+
+static void grp_assign_gl_sel_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ p_retm_if(NULL == event_info, "event_info is NULL");
+ Elm_Object_Item *item = (Elm_Object_Item *) event_info;
+ Evas_Object *check = elm_object_item_part_content_get(item, "elm.icon");
+
+ elm_check_state_set(check, !elm_check_state_get(check));
+ elm_genlist_item_selected_set(item, EINA_FALSE);
+}
+
+static char * grp_assign_gl_label_get(void *data, Evas_Object *obj, const char *part)
+{
+ PH_TRACE;
+ p_retvm_if(NULL == data, NULL, "data is NULL");
+ ct_group_assign_item *group = (ct_group_assign_item *) data;
+ return strdup(group->name);
+}
+
+static Evas_Object * grp_assign_gl_icon_get(void *data, Evas_Object *obj, const char *part)
+{
+ PH_TRACE;
+ p_retvm_if(NULL == data, NULL, "data is NULL");
+ ct_group_assign_item *group = (ct_group_assign_item *) data;
+
+ Evas_Object *check = elm_check_add(obj);
+ evas_object_propagate_events_set(check, EINA_FALSE);
+ elm_check_state_set(check, group->is_assigned);
+ elm_check_state_pointer_set(check, &group->is_assigned);
+ return check;
+}
+
+static void grp_assign_ok_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ p_retm_if(NULL == data, "data is NULL");
+ ct_group_assign_data *cgassign_d = (ct_group_assign_data *) data;
+
+ int contact_id = 0;
+ ct_group_assign_item *item = cgassign_d->items;
+ ct_group_assign_item *end = item + cgassign_d->group_count;
+
+ contacts_record_get_int(cgassign_d->contact, _contacts_contact.id, &contact_id);
+
+ for(; item != end; ++item)
+ {
+ if(item->is_assigned != item->prev_assigned)
+ {
+ if(item->is_assigned)
+ {
+ grp_assign_add_to_group(cgassign_d->contact, item->id);
+ }
+ else
+ {
+ grp_assign_remove_from_group(cgassign_d->contact, item->id);
+ }
+ }
+ }
+
+ if(cgassign_d->assign_cb)
+ {
+ cgassign_d->assign_cb(cgassign_d->assign_cb_data);
+ }
+}
+
+static void grp_assign_create_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ p_retm_if(NULL == data, "data is NULL");
+ ct_group_assign_data *cgassign_d = (ct_group_assign_data *) data;
+
+ ctui_create_group_input_view(cgassign_d->win, cgassign_d->navi, NULL,
+ grp_assign_group_created_cb, cgassign_d);
+}
+
+static void grp_assign_group_created_cb(int group_id, void *data, bool changed)
+{
+ PH_TRACE;
+ p_retm_if(NULL == data, "data is NULL");
+ ct_group_assign_data *cgassign_d = (ct_group_assign_data *) data;
+
+ grp_assign_add_to_group(cgassign_d->contact, group_id);
+ if(cgassign_d->assign_cb)
+ {
+ cgassign_d->assign_cb(cgassign_d->assign_cb_data);
+ }
+}
+
+static void grp_assign_popup_destroy_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ p_retm_if(NULL == data, "data is NULL");
+ ct_group_assign_data *cgassign_d = (ct_group_assign_data *) data;
+ grp_assign_popup_destroy(cgassign_d);
+}
diff --git a/lib/common/ct-group-input-view.cpp b/lib/common/ct-group-input-view.cpp
new file mode 100755
index 0000000..aae4615
--- /dev/null
+++ b/lib/common/ct-group-input-view.cpp
@@ -0,0 +1,1653 @@
+/*
+ * 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.
+ */
+
+#include <vconf.h>
+#include <vconf-keys.h>
+#include <Ecore_X.h>
+#include <unicode/ucol.h>
+#include <app_service.h>
+#include "phone.h"
+#include "phone-common.h"
+#include "ui/genlist/genlist.h"
+#include "ui/genlist/item.h"
+
+#include "ct-list.h"
+#include "ct-group.h"
+
+static const char *ELM_TEXT = "elm.text";
+static const char *ELM_ICON = "elm.icon";
+
+typedef struct : public Common::View
+{
+ Evas_Object *genlist;
+ Evas_Object *entry;
+ Elm_Object_Item *ab_gen_item;
+ Elm_Object_Item *vibration_gen_item;
+ Elm_Object_Item *ringtone_gen_item;
+ Elm_Object_Item *image_item;
+ Elm_Object_Item *group_member_item;
+ Evas_Object *done_button;
+ Evas_Object *navi_it_pop_to;
+ Ecore_Event_Handler *win_prop_change;
+ bool camera_service_launched;
+ ct_group_input_result_cb result_cb;
+ void *result_cb_data;
+ void *crop_ug;
+ int id_ab;
+ char *ab_name;
+ char *gname_old;
+ char *gname;
+ char *img;
+ char *ringtone;
+ char *vibration;
+ int id_grp;
+ bool editgroup;
+ bool err;
+ bool is_read_only;
+ Eina_List *member_list;
+} ct_group_input_data;
+
+enum GINPUT_ITC_TYPE
+{
+ GINPUT_ITC_GROUP_IMAGE,
+ GINPUT_ITC_GROUP_CREATE,
+ GINPUT_ITC_GROUP_VIBRATION,
+ GINPUT_ITC_GROUP_RINGTON,
+ GINPUT_ITC_ADDRBOOK,
+ GINPUT_ITC_LINE,
+ GINPUT_ITC_GROUP_MEMBERS,
+ GINPUT_ITC_GROUP_LIST_ITEM,
+};
+
+static Elm_Genlist_Item_Class group_input_itcs[] =
+{
+ {
+ 0, 0, 1, "image_layout", NULL, NULL,
+ {NULL, NULL, NULL, NULL},
+ },
+ {
+ 0, 0, 1, "dialogue/1icon", NULL, NULL,
+ {NULL, NULL, NULL, NULL},
+ },
+ {
+ 0, 0, 1, "dialogue/2text.3", NULL, NULL,
+ {NULL, NULL, NULL, NULL},
+ },
+ {
+ 0, 0, 1, "dialogue/2text.3", NULL, NULL,
+ {NULL, NULL, NULL, NULL},
+ },
+ {
+ 0, 0, 1, "dialogue/2text.3", NULL, NULL,
+ {NULL, NULL, NULL, NULL},
+ },
+ {
+ 0, 0, 1, "dialogue/separator/1/with_line", NULL, NULL,
+ {NULL, NULL, NULL, NULL},
+ },
+ {
+ 0, 0, 1, "1text.1icon", NULL, NULL,
+ {NULL, NULL, NULL, NULL},
+ },
+ {
+ 0, 0, 1, "dialogue/1text.1icon.2", NULL, NULL,
+ {NULL, NULL, NULL, NULL},
+ },
+};
+
+int group_input_get_member_list(int group_id, Eina_List **list);
+
+static int group_input_group_update(ct_group_input_data *cgroup_input_d)
+{
+ PH_TRACE;
+ int ret = CONTACTS_ERROR_NONE;
+ contacts_record_h record = NULL;
+ contacts_record_h group_record = NULL;
+ contacts_list_h group_list = NULL;
+ unsigned int count = 0;
+
+ ret = phone_cts_get_list(_contacts_group._uri,
+ _contacts_group.address_book_id, cgroup_input_d->id_ab,
+ &group_list);
+ p_retvm_if(CONTACTS_ERROR_NONE != ret, ret,
+ "phone_cts_get_list() Failed(%d)", ret);
+
+ ret = contacts_list_get_count(group_list, &count);
+ p_retvm_if(CONTACTS_ERROR_NONE != ret, ret,
+ "contacts_list_get_count() Failed(%d)", ret);
+ if (count > 0)
+ { //when default group removed error
+ if (cgroup_input_d->editgroup == false)
+ {
+ ret = contacts_list_get_current_record_p(group_list, &record);
+ p_retvm_if(CONTACTS_ERROR_NONE != ret, ret,
+ "contacts_list_get_current_record_p() Failed(%d)", ret);
+ while (record)
+ {
+ char* group_name = NULL;
+ ret = contacts_record_get_str_p(record, _contacts_group.name,
+ &group_name);
+ p_retvm_if(CONTACTS_ERROR_NONE != ret, ret,
+ "contacts_record_get_str_p() Failed(%d)", ret);
+ if (strcmp(cgroup_input_d->gname, group_name) == 0)
+ {
+ ret = -1;
+ contacts_list_destroy(group_list, true);
+ PH_DBG("create group :cgroup_input_d->id_grp =&d",
+ cgroup_input_d->id_grp);
+ return ret;
+ }
+ ret = contacts_list_next(group_list);
+ if (CONTACTS_ERROR_NO_DATA == ret)
+ break;
+ else
+ {
+ p_retvm_if(CONTACTS_ERROR_NONE != ret, ret,
+ "contacts_list_next() Failed(%d)", ret);
+ }
+ ret = contacts_list_get_current_record_p(group_list, &record);
+ p_retvm_if(CONTACTS_ERROR_NONE != ret, ret,
+ "contacts_list_get_current_record_p() Failed(%d)", ret);
+ }
+ }
+ else
+ {
+ ret = contacts_list_get_current_record_p(group_list, &record);
+ p_retvm_if(CONTACTS_ERROR_NONE != ret, ret,
+ "contacts_list_get_current_record_p() Failed(%d)", ret);
+ while (record)
+ {
+ char* group_name;
+ ret = contacts_record_get_str(record, _contacts_group.name,
+ &group_name);
+ p_retvm_if(CONTACTS_ERROR_NONE != ret, ret,
+ "contacts_record_get_str() Failed(%d)", ret);
+ if (strcmp(cgroup_input_d->gname, group_name) == 0)
+ {
+ int group_id;
+ ret = contacts_record_get_int(record, _contacts_group.id,
+ &group_id);
+ p_retvm_if(CONTACTS_ERROR_NONE != ret, ret,
+ "contacts_record_get_int() Failed(%d)", ret);
+ if (group_id != cgroup_input_d->id_grp)
+ {
+ ret = -1;
+ contacts_list_destroy(group_list, true);
+ PH_DBG("group id = %d,cgroup_input_d->id_grp =&d",
+ group_id, cgroup_input_d->id_grp);
+ return ret;
+ }
+ }
+ ret = contacts_list_next(group_list);
+ if (CONTACTS_ERROR_NONE != ret)
+ break;
+ ret = contacts_list_get_current_record_p(group_list, &record);
+ p_retvm_if(CONTACTS_ERROR_NONE != ret, ret,
+ "contacts_list_get_current_record_p() Failed(%d)", ret);
+
+ }
+ }
+ }
+ if (cgroup_input_d->editgroup == true)
+ {
+ ret = contacts_db_get_record(_contacts_group._uri,
+ cgroup_input_d->id_grp, &group_record);
+ p_retvm_if(CONTACTS_ERROR_NONE != ret, ret,
+ "contacts_db_get_record() Failed(%d)", ret);
+ }
+ else
+ {
+ ret = contacts_record_create(_contacts_group._uri, &group_record);
+ p_retvm_if(CONTACTS_ERROR_NONE != ret, ret,
+ "contacts_record_create() Failed(%d)", ret);
+ }
+
+ ret = contacts_record_set_str(group_record, _contacts_group.name,
+ cgroup_input_d->gname);
+ p_retvm_if(CONTACTS_ERROR_NONE != ret, ret,
+ "contacts_record_set_str() Failed(%d)", ret);
+
+ ret = contacts_record_set_str(group_record, _contacts_group.image_path,
+ cgroup_input_d->img);
+ p_retvm_if(CONTACTS_ERROR_NONE != ret, ret,
+ "contacts_record_set_str() Failed(%d)", ret);
+ PH_DBG("cgroup_input_d->img = %s", cgroup_input_d->img);
+
+ ret = contacts_record_set_str(group_record, _contacts_group.ringtone_path,
+ cgroup_input_d->ringtone);
+ p_retvm_if(CONTACTS_ERROR_NONE != ret, ret,
+ "contacts_record_set_str() Failed(%d)", ret);
+
+ ret = contacts_record_set_str(group_record, _contacts_group.vibration,
+ cgroup_input_d->vibration);
+ p_retvm_if(CONTACTS_ERROR_NONE != ret, ret,
+ "contacts_record_set_str() Failed(%d)", ret);
+
+ if (cgroup_input_d->editgroup == true)
+ {
+ ret = contacts_db_update_record(group_record);
+ PH_DBG("cgroup_input_d->id_grp = %d", cgroup_input_d->id_grp);
+ p_retvm_if(CONTACTS_ERROR_NONE != ret, ret,
+ "contacts_db_update_record() Failed(%d)", ret);
+ }
+ else
+ {
+ ret = contacts_db_insert_record(group_record, &cgroup_input_d->id_grp);
+ p_retvm_if(CONTACTS_ERROR_NONE != ret, ret,
+ "contacts_db_insert_record() Failed(%d)", ret);
+ }
+
+ Eina_List *remove_list = NULL;
+ group_input_get_member_list(cgroup_input_d->id_grp, &remove_list);
+
+ ctui_list_update_group_list_without_progressbar(cgroup_input_d->navi,
+ cgroup_input_d->id_grp, cgroup_input_d->member_list, remove_list);
+
+ ret = contacts_record_destroy(group_record, true);
+ p_retvm_if(CONTACTS_ERROR_NONE != ret, ret,
+ "contacts_record_destroy() Failed(%d)", ret);
+
+ ret = contacts_list_destroy(group_list, true);
+ p_retvm_if(CONTACTS_ERROR_NONE != ret, ret,
+ "contacts_list_destroy() Failed(%d)", ret);
+
+ return ret;
+
+}
+
+/**
+ * @brief handle error state when save button pressed
+ * @param[in] ret error code
+ * @param[in] text current text inside control.
+ * @param[out] cgroup_input_d structure with ui controls and current state, old text saved here.
+ */
+static void handle_save_btn_error(int ret, const char *text, ct_group_input_data *cgroup_input_d)
+{
+ PH_TRACE;
+ bool isCorrectParameters = (cgroup_input_d != NULL && cgroup_input_d->entry != NULL && text != NULL);
+
+ Evas_Object* entry = cgroup_input_d->entry ;
+
+ if (!isCorrectParameters)
+ {
+ PH_DBG("Error: incorrect parameters \n");
+ return;
+ }
+
+ std::string err_msg;
+
+ cgroup_input_d->err = true;
+ if (cgroup_input_d->gname_old)
+ {
+ FREEandSTRDUP(cgroup_input_d->gname_old, text);
+ }
+ else
+ {
+ cgroup_input_d->gname_old = strdup(text);
+ }
+
+ switch (ret)
+ {
+ case CONTACTS_ERROR_NO_DATA:
+ {
+ err_msg = T_(CT_GET_TEXT_ERR, CTTEXT_ERR_DB_LOCKED);
+ break;
+ }
+ case CONTACTS_ERROR_FILE_NO_SPACE:
+ {
+ err_msg = S_(CT_SYS_POP_NOT_ENOUGH_MEMORY);
+ break;
+ }
+ case -1:
+ {
+ err_msg = T_(CT_GET_TEXT_ERR, CTTEXT_ALREADY_EXIST);
+ break;
+ }
+ default:
+ {
+ err_msg = S_(PH_SYS_POP_FAILED);
+ break;
+ }
+ }
+
+
+ err_msg = "<color=#FF0000>" + err_msg + "</>";
+ elm_entry_entry_set(entry, err_msg.c_str());
+
+ if (NULL != cgroup_input_d->done_button)
+ {
+ elm_object_disabled_set(cgroup_input_d->done_button, EINA_TRUE);
+ }
+}
+
+
+static void group_input_save_btn_cb(void *data, Evas_Object *obj,
+ void *event_info)
+{
+ PH_TRACE;
+
+ ct_group_input_data *cgroup_input_d = (ct_group_input_data *) data;
+ bool isCorrectParameters = (NULL != cgroup_input_d && NULL != cgroup_input_d->entry);
+ p_retm_if(!isCorrectParameters, "incorrect parameters");
+
+ Evas_Object *entry = cgroup_input_d->entry;
+ char *text = ctui_entry_markup_to_utf8(elm_entry_entry_get(entry));
+ p_retm_if(NULL == text, "ctui_entry_markup_to_utf8() return NULL");
+ cgroup_input_d->gname = SAFE_STRDUP(text);
+
+ int ret = group_input_group_update(cgroup_input_d);
+ if (ret != CONTACTS_ERROR_NONE)
+ {
+ handle_save_btn_error(ret, text, cgroup_input_d);
+ free(text);
+ return;
+ }
+ free(text);
+
+ if (cgroup_input_d->result_cb)
+ cgroup_input_d->result_cb(cgroup_input_d->id_grp, cgroup_input_d->result_cb_data,
+ false);
+
+ Evas_Object *navi_it_pop_to = (Evas_Object *) evas_object_data_get(cgroup_input_d->navi, "navi_it_pop");
+ if (navi_it_pop_to)
+ { // group - create/edit - assign member
+ evas_object_data_del(cgroup_input_d->navi, "navi_it_pop");
+ }
+ else
+ { // group detail - add member
+ evas_object_data_del(cgroup_input_d->navi, "navi_it_pop");
+ }
+}
+
+static void group_input_popup_hide_cb(void *data, Evas_Object *obj,
+ void *event_info)
+{
+ PH_TRACE;
+ ct_group_input_data *cgroup_input_d = (ct_group_input_data *) data;
+ evas_object_del(cgroup_input_d->popup);
+ cgroup_input_d->popup = NULL;
+ elm_object_tree_focus_allow_set(cgroup_input_d->navi, EINA_TRUE);
+}
+
+static void group_input_ab_popup_item_sel_cb(void *data, Evas_Object *obj,
+ void *event_info)
+{
+ PH_TRACE;
+ ct_group_input_data *cgroup_input_d = (ct_group_input_data *) data;
+ ct_ab_popup_data *ab_popup_data;
+ char account_name[PH_TEXT_MAX_LEN + 1];
+ char temp[PH_TEXT_MAX_LEN + 1];
+
+ group_input_popup_hide_cb(cgroup_input_d, NULL, NULL);
+
+ ab_popup_data = (ct_ab_popup_data *) elm_object_item_data_get((const Elm_Object_Item *) event_info);
+ p_retm_if(NULL == ab_popup_data, "elm_object_item_data_get() return NULL");
+
+ if (cgroup_input_d->id_ab == ab_popup_data->id)
+ return;
+
+ cgroup_input_d->id_ab = ab_popup_data->id;
+
+ if (ab_popup_data->id)
+ {
+ ctui_get_addressbook_name(ab_popup_data->id, account_name,
+ sizeof(account_name));
+ snprintf(temp, sizeof(temp), "%s(%s)", account_name,
+ ab_popup_data->name);
+ }
+ else
+ {
+ snprintf(temp, sizeof(temp), "%s", T_(CT_GET_TEXT_BASIC, CTTEXT_PHONE));
+ }
+ free(cgroup_input_d->ab_name);
+ cgroup_input_d->ab_name = strdup(temp);
+ elm_genlist_item_update(cgroup_input_d->ab_gen_item);
+
+ // FIXME : push contact list view to select contacts added to the created group
+}
+
+static void group_input_gl_sel(void *data, Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ Evas_Object *popup;
+ Evas_Object *btn;
+ ct_group_input_data *cgroup_input_d = (ct_group_input_data *) data;
+ Elm_Object_Item *item = (Elm_Object_Item *) event_info;
+
+ if (elm_genlist_item_flip_get(item))
+ return;
+
+ elm_genlist_item_selected_set(item, EINA_FALSE);
+
+ popup = ctui_addrbook_popup(cgroup_input_d->win,
+ group_input_ab_popup_item_sel_cb, cgroup_input_d,
+ CT_AB_POPUP_TYPE_GINPUT_VIEW);
+ p_retm_if(NULL == popup, "ctui_addrbook_popup() return NULL");
+ elm_object_part_text_set(popup, "title,text",
+ T_(CT_GET_TEXT_BASE_OP, CTTEXT_SAVE_TO));
+
+ btn = elm_button_add(popup);
+ elm_object_text_set(btn, S_(PH_SYS_POP_CLOSE));
+ elm_object_part_content_set(popup, "button1", btn);
+ elm_object_style_set(btn, "popup_button/default");
+ evas_object_smart_callback_add(btn, CLICKED, group_input_popup_hide_cb,
+ cgroup_input_d);
+
+ elm_object_tree_focus_allow_set(cgroup_input_d->navi, EINA_FALSE);
+ cgroup_input_d->popup = popup;
+}
+static void group_input_setting_ringtone_result(ui_gadget_h ug, service_h service, void *data)
+{
+ PH_TRACE;
+ assert(ug);
+ assert(data);
+ if (NULL != ug && NULL != data)
+ {
+ ct_group_input_data *cgroup_input_d = static_cast<ct_group_input_data *>(data);
+
+ if (NULL != cgroup_input_d->done_button)
+ {
+ elm_object_disabled_set(cgroup_input_d->done_button, EINA_FALSE);
+ }
+
+ if (service)
+ {
+ char *val = NULL;
+ service_get_extra_data(service, "result", &val);
+ if (NULL != val)
+ {
+ FREEandSTRDUP(cgroup_input_d->ringtone, val);
+ free(val);
+ }
+ else
+ {
+ ERR("group_input_setting_ringtone_result() Failed: %s", "return value is NULL");
+ return;
+ }
+ }
+ elm_genlist_item_update(cgroup_input_d->ringtone_gen_item);
+ }
+ else
+ {
+ ERR("group_input_setting_ringtone_result() Failed: %s", "ug or data is NULL");
+ }
+}
+static void group_input_child_ug_destroy(ui_gadget_h ug, void *priv)
+{
+ PH_TRACE;
+ ct_group_input_data *cgroup_input_d = (ct_group_input_data *) priv;
+
+ p_retm_if(NULL == ug, "ug is NULL");
+
+ elm_object_tree_focus_allow_set(cgroup_input_d->navi, EINA_TRUE);
+
+ if (cgroup_input_d->child_ug)
+ {
+ ug_destroy(cgroup_input_d->child_ug);
+ cgroup_input_d->child_ug = NULL;
+ }
+}
+
+/*
+ static void group_input_gl_vibration_sel(void *data, Evas_Object *obj, void *event_info)
+ {
+ PH_TRACE;
+ //ToDo can not use a setting vibration view yet
+ return;
+ }
+ */
+
+static void group_input_gl_ringtone_sel(void *data, Evas_Object *obj,
+ void *event_info)
+{
+ PH_TRACE;
+ ct_group_input_data *cgroup_input_d = (ct_group_input_data *) data;
+ Elm_Object_Item *item = (Elm_Object_Item *) event_info;
+
+ if(cgroup_input_d->entry)
+ {
+ char* text = NULL;
+ text = ctui_entry_markup_to_utf8(elm_entry_entry_get(cgroup_input_d->entry));
+ if(text)
+ {
+ free(cgroup_input_d->gname);
+ cgroup_input_d->gname = text;
+ }
+ }
+
+ if (elm_genlist_item_flip_get(item))
+ return;
+
+ elm_genlist_item_selected_set(item, EINA_FALSE);
+ struct ug_cbs cbs = { 0 };
+
+ service_h service;
+
+ service_create(&service);
+ service_add_extra_data(service, "path", "/opt/share/settings/Ringtones");
+ service_add_extra_data(service, "select_type", "SINGLE_FILE");
+ service_add_extra_data(service, "file_type", "SOUND");
+ if (cgroup_input_d->ringtone)
+ service_add_extra_data(service, "marked_mode",
+ cgroup_input_d->ringtone);
+
+ cbs.result_cb = group_input_setting_ringtone_result;
+ cbs.destroy_cb = group_input_child_ug_destroy;
+ cbs.layout_cb = ug_common_layout_cb;
+ cbs.priv = cgroup_input_d;
+
+ cgroup_input_d->child_ug = ug_create(cgroup_input_d->ug, MYFILES_UG,
+ UG_MODE_FULLVIEW, service, &cbs);
+ p_warn_if(NULL == cgroup_input_d->child_ug, "ug_create() Failed");
+ elm_object_tree_focus_allow_set(cgroup_input_d->navi, EINA_FALSE);
+ service_destroy(service);
+}
+
+static void group_input_gl_group_list_item_on_realized(ui_genlist_item *item)
+{
+ PH_TRACE;
+ p_retm_if(NULL == item, "parameter(item) is NULL");
+ elm_object_item_signal_emit(item->object_item, "elm,state,edit,enabled", "");
+}
+
+static ui_genlist_item *group_input_gl_group_list_item_create(ct_person_list *person_info, Eina_List **group_list, Evas_Object *save_button)
+{
+ PH_TRACE;
+ bool isCorrectParameters = (NULL != person_info && NULL != group_list && NULL != *group_list);
+ p_retvm_if(!isCorrectParameters, NULL, "incorrect parameters");
+
+ ui_genlist_item *item = ui_genlist_item_create();
+ p_retvm_if(NULL == item, NULL, "item is NULL");
+ item->on_realized = group_input_gl_group_list_item_on_realized;
+ item->item_list = group_list;
+ item->data = person_info;
+ item->save_button = save_button;
+
+ return item;
+}
+
+static int group_input_list_sort_cb(const void *data1, const void *data2)
+{
+ PH_TRACE;
+ p_retvm_if(NULL == data1, UCOL_LESS, "parameter(data1) is NULL");
+ p_retvm_if(NULL == data2, UCOL_GREATER, "parameter(data2) is NULL");
+ ct_person_list *person_info = (ct_person_list *) data1;
+ ct_person_list *person_info2 = (ct_person_list *) data2;
+ p_retvm_if(NULL == person_info->display, UCOL_LESS, "person_info->display is NULL");
+ p_retvm_if(NULL == person_info2->display, UCOL_GREATER, "person_info2->display is NULL");
+
+ UErrorCode status = U_ZERO_ERROR;
+ int res = 0;
+ UCollator* collator = ucol_open("", &status);
+ if (U_SUCCESS(status))
+ {
+ UCharIterator iterA;
+ UCharIterator iterB;
+ uiter_setUTF8(&iterA, person_info->display, strlen(person_info->display));
+ uiter_setUTF8(&iterB, person_info2->display, strlen(person_info2->display));
+
+ res = ucol_strcollIter(collator, &iterA, &iterB, &status);
+ ucol_close(collator);
+ }
+ return res;
+}
+
+static Eina_Bool group_input_add_member_cb(void *data, Elm_Object_Item *it)
+{
+ PH_TRACE;
+ p_retvm_if(NULL == data, false, "data is NULL");
+ ct_group_input_data *cgroup_input_d = (ct_group_input_data *) data;
+
+ Elm_Object_Item *last_item = elm_genlist_last_item_get(cgroup_input_d->genlist);
+ while(cgroup_input_d->group_member_item != last_item)
+ {
+ elm_object_item_del(last_item);
+ last_item = elm_genlist_last_item_get(cgroup_input_d->genlist);
+ }
+
+ PH_DBG("cgroup_input_d->member_list = %p", cgroup_input_d->member_list);
+ if (cgroup_input_d->member_list)
+ {
+ cgroup_input_d->member_list = eina_list_sort(cgroup_input_d->member_list,
+ eina_list_count(cgroup_input_d->member_list), group_input_list_sort_cb);
+
+ Eina_List* l = NULL;
+ void *p_info = NULL;
+ EINA_LIST_FOREACH(cgroup_input_d->member_list, l, p_info)
+ {
+ ct_person_list *person_info = (ct_person_list *) p_info;
+ ui_genlist_item *item = group_input_gl_group_list_item_create(person_info,
+ &cgroup_input_d->member_list, cgroup_input_d->done_button);
+ item->object_item = elm_genlist_item_append(cgroup_input_d->genlist,
+ &group_input_itcs[GINPUT_ITC_GROUP_LIST_ITEM], item,
+ NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ elm_genlist_item_select_mode_set(item->object_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+ }
+ }
+
+ if (cgroup_input_d->gname)
+ {
+ if (*cgroup_input_d->gname)
+ {
+ elm_object_disabled_set(cgroup_input_d->done_button, false);
+ }
+ }
+ return true;
+}
+
+static void group_input_fill_genlist(ct_group_input_data *cgroup_input_d)
+{
+ PH_TRACE;
+ Elm_Object_Item * item;
+
+ item = elm_genlist_item_append(cgroup_input_d->genlist,
+ &group_input_itcs[GINPUT_ITC_GROUP_IMAGE], cgroup_input_d, NULL,
+ ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ cgroup_input_d->image_item = item;
+
+ item = elm_genlist_item_append(cgroup_input_d->genlist,
+ &group_input_itcs[GINPUT_ITC_LINE], cgroup_input_d, NULL,
+ ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+
+ item = elm_genlist_item_append(cgroup_input_d->genlist,
+ &group_input_itcs[GINPUT_ITC_GROUP_CREATE], cgroup_input_d, NULL,
+ ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+
+// item = elm_genlist_item_append(cgroup_input_d->genlist, &group_input_itcs[GINPUT_ITC_GROUP_VIBRATION], cgroup_input_d, NULL,
+// ELM_GENLIST_ITEM_NONE, group_input_gl_sel, cgroup_input_d);
+// cgroup_input_d->vibration_gen_item = item; can not use a setting vibration view yet.
+
+ item = elm_genlist_item_append(cgroup_input_d->genlist,
+ &group_input_itcs[GINPUT_ITC_GROUP_RINGTON], cgroup_input_d, NULL,
+ ELM_GENLIST_ITEM_NONE, group_input_gl_ringtone_sel, cgroup_input_d);
+ cgroup_input_d->ringtone_gen_item = item;
+
+ item = elm_genlist_item_append(cgroup_input_d->genlist,
+ &group_input_itcs[GINPUT_ITC_ADDRBOOK], cgroup_input_d, NULL,
+ ELM_GENLIST_ITEM_NONE, group_input_gl_sel, cgroup_input_d);
+ cgroup_input_d->ab_gen_item = item;
+ if (cgroup_input_d->is_read_only == true)
+ elm_object_item_disabled_set(item, EINA_TRUE);
+
+ cgroup_input_d->group_member_item = elm_genlist_item_append(cgroup_input_d->genlist,
+ &group_input_itcs[GINPUT_ITC_GROUP_MEMBERS], cgroup_input_d, NULL,
+ ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ elm_genlist_item_select_mode_set(cgroup_input_d->group_member_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+
+ group_input_add_member_cb(cgroup_input_d, NULL);
+}
+
+static char* group_input_gl_label_get(void *data, Evas_Object *obj,
+ const char *part)
+{
+ PH_TRACE;
+ ct_group_input_data *cgroup_input_d = (ct_group_input_data *) data;
+ const char *display;
+
+ if (!strcmp(part, "elm.text.1"))
+ return strdup(T_(CT_GET_TEXT_BASE_OP, CTTEXT_SAVE_TO));
+ else if (!strcmp(part, "elm.text.2"))
+ {
+ if (cgroup_input_d && 0 == cgroup_input_d->id_ab)
+ display = S_(CT_SYS_BODY_PHONE);
+ else if (cgroup_input_d && cgroup_input_d->ab_name)
+ display = cgroup_input_d->ab_name;
+ else
+ display = S_(PH_SYS_BODY_UNKNOWN);
+ return SAFE_STRDUP(display);
+ }
+ return NULL;
+}
+static char* group_input_gl_vibration_label_get(void *data, Evas_Object *obj,
+ const char *part)
+{
+ PH_TRACE;
+ ct_group_input_data *cgroup_input_d = (ct_group_input_data *) data;
+ const char *display;
+
+ if (!strcmp(part, "elm.text.1"))
+ return strdup(T_(CT_GET_TEXT_BASIC, CTTEXT_VIBRATION_PATTERN));
+ else if (!strcmp(part, "elm.text.2"))
+ {
+ if (cgroup_input_d && 0 == cgroup_input_d->id_ab)
+ display = T_(CT_GET_TEXT_BASIC, CTTEXT_DEFAULT);
+ else if (cgroup_input_d && cgroup_input_d->vibration)
+ display = strrchr(cgroup_input_d->vibration, '/') + 1;
+ else
+ display = S_(PH_SYS_BODY_UNKNOWN);
+ return SAFE_STRDUP(display);
+ }
+ return NULL;
+}
+static char* group_input_gl_ringtone_label_get(void *data, Evas_Object *obj,
+ const char *part)
+{
+ PH_TRACE;
+ ct_group_input_data *cgroup_input_d = (ct_group_input_data *) data;
+ const char *display;
+
+ if (!strcmp(part, "elm.text.1"))
+ return strdup(T_(CT_GET_TEXT_BASIC, CTTEXT_RINGTONE));
+ else if (!strcmp(part, "elm.text.2"))
+ {
+ if (cgroup_input_d && cgroup_input_d->ringtone == NULL)
+ display = T_(CT_GET_TEXT_BASIC, CTTEXT_DEFAULT);
+ else if (cgroup_input_d && cgroup_input_d->ringtone)
+ {
+ display = strrchr(cgroup_input_d->ringtone, '/') + 1;
+ }
+ else
+ display = S_(PH_SYS_BODY_UNKNOWN);
+ return SAFE_STRDUP(display);
+ }
+ return NULL;
+}
+static void group_input_entry_changed_cb(void *data, Evas_Object *obj,
+ void *event_info)
+{
+ PH_TRACE;
+ char *text;
+ ct_group_input_data *cgroup_input_d = (ct_group_input_data *) data;
+
+ p_retm_if(NULL == cgroup_input_d || NULL == obj, "group_input_entry_changed_cb incorrect params");
+
+ text = ctui_entry_markup_to_utf8(elm_entry_entry_get(obj));
+ p_retm_if(NULL == text, "ctui_entry_markup_to_utf8() return NULL");
+
+ if (cgroup_input_d->err)
+ {
+ elm_entry_entry_set(cgroup_input_d->entry, "");
+ cgroup_input_d->err = false;
+ free(text);
+ return;
+ }
+
+ if (*text)
+ {
+ elm_object_disabled_set(cgroup_input_d->done_button, EINA_FALSE);
+ }
+ else
+ {
+ elm_object_disabled_set(cgroup_input_d->done_button, EINA_TRUE);
+ }
+ free(text);
+}
+
+static void group_input_entry_clicked_cb(void *data, Evas_Object *obj,
+ void *event_info)
+{
+ PH_TRACE;
+ ct_group_input_data *cgroup_input_d = (ct_group_input_data *) data;
+
+ if (NULL != cgroup_input_d->child_ug)
+ elm_object_tree_focus_allow_set(cgroup_input_d->navi, EINA_FALSE);
+ p_retm_if(NULL == cgroup_input_d->gname_old,
+ "cgroup_input_d->gname_old is NULL");
+
+ if (cgroup_input_d->err == true)
+ {
+ ctui_entry_entry_set(obj, cgroup_input_d->gname_old);
+ cgroup_input_d->err = false;
+ }
+
+ elm_entry_cursor_end_set(obj);
+}
+
+static void group_input_src_ug_destroy(ui_gadget_h ug, void *priv)
+{
+ PH_TRACE;
+ ct_group_input_data *cgroup_input_d = (ct_group_input_data *) priv;
+
+ p_retm_if(NULL == ug, "ug is NULL");
+
+ elm_object_tree_focus_allow_set(cgroup_input_d->navi, EINA_TRUE);
+
+ if (NULL == cgroup_input_d->crop_ug)
+ {
+ ug_destroy(cgroup_input_d->child_ug);
+ cgroup_input_d->child_ug = NULL;
+ }
+}
+
+static void group_input_crop_ug_destroy(ui_gadget_h ug, void *priv)
+{
+ PH_TRACE;
+ ct_group_input_data *cgroup_input_d = (ct_group_input_data *) priv;
+
+ p_retm_if(NULL == ug, "ug is NULL");
+
+ elm_object_tree_focus_allow_set(cgroup_input_d->navi, EINA_TRUE);
+
+ if (cgroup_input_d->crop_ug)
+ {
+ ug_destroy(ug);
+ cgroup_input_d->crop_ug = NULL;
+ }
+ if (cgroup_input_d->child_ug)
+ {
+ ug_destroy(cgroup_input_d->child_ug);
+ cgroup_input_d->child_ug = NULL;
+ }
+}
+
+static void group_input_image_crop_result(ui_gadget_h ug, service_h service,
+ void *data)
+{
+ PH_TRACE;
+ char *img = NULL;
+ ct_group_input_data *cgroup_input_d = (ct_group_input_data *) data;
+
+ p_retm_if(NULL == ug || NULL == data, "ug or data is NULL");
+
+ if (service)
+ {
+ service_get_extra_data(service, "crop_image_path", &img);
+ p_retm_if(!img, "return value is NULL.\n");
+ PH_DBG("img = %s", img);
+ FREEandSTRDUP(cgroup_input_d->img, img);
+ free(img);
+ elm_genlist_item_update(cgroup_input_d->image_item);
+ }
+
+ elm_object_tree_focus_allow_set(cgroup_input_d->navi, EINA_TRUE);
+}
+
+static void group_input_image_delete_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ assert(data);
+ if (NULL != data)
+ {
+ ct_group_input_data *cgroup_input_d = static_cast<ct_group_input_data *>(data);
+ if (NULL != cgroup_input_d->done_button)
+ {
+ elm_object_disabled_set(cgroup_input_d->done_button, EINA_FALSE);
+ }
+ group_input_popup_hide_cb(cgroup_input_d, NULL, NULL);
+ free(cgroup_input_d->img);
+ cgroup_input_d->img = NULL;
+ elm_genlist_item_update(cgroup_input_d->image_item);
+ }
+ else
+ {
+ ERR("group_input_image_delete_cb() Failed: %s", "data is NULL");
+ }
+}
+
+static void group_input_image_gallery_result(ui_gadget_h ug, service_h service, void *data)
+{
+ PH_TRACE;
+ assert(ug);
+ assert(data);
+ if (NULL != ug && NULL != data)
+ {
+ ct_group_input_data *cgroup_input_d = static_cast<ct_group_input_data *>(data);
+
+ if (NULL != cgroup_input_d->done_button)
+ {
+ elm_object_disabled_set(cgroup_input_d->done_button, EINA_FALSE);
+ }
+
+ if (service)
+ {
+ char *val = NULL;
+ service_get_extra_data(service, "path", &val);
+ if (NULL != val)
+ {
+ struct ug_cbs cbs = { 0 };
+ cbs.result_cb = group_input_image_crop_result;
+ cbs.destroy_cb = group_input_crop_ug_destroy;
+ cbs.priv = cgroup_input_d;
+ cgroup_input_d->crop_ug = phone_image_crop_ug(cgroup_input_d->ug, val, &cbs);
+ free(val);
+ }
+ else
+ {
+ ERR("group_input_image_gallery_result() Failed: %s", "return value is NULL");
+ return;
+ }
+ }
+ }
+ else
+ {
+ ERR("group_input_image_gallery_result() Failed: %s", "ug or data is NULL");
+ }
+}
+
+static void group_input_camera_result(service_h service, service_h reply, service_result_e result, void* user_data)
+{
+ PH_TRACE;
+ assert(user_data);
+ if (NULL != user_data)
+ {
+ ct_group_input_data *cgroup_input_d = static_cast<ct_group_input_data *>(user_data);
+ cgroup_input_d->camera_service_launched = false;
+ elm_object_tree_focus_allow_set(cgroup_input_d->navi, EINA_TRUE);
+
+ if (NULL != cgroup_input_d->done_button)
+ {
+ elm_object_disabled_set(cgroup_input_d->done_button, EINA_FALSE);
+ }
+
+ if (reply)
+ {
+ char *img = NULL;
+ service_get_extra_data(reply, "crop_image_path", &img);
+ if (NULL != img)
+ {
+ FREEandSTRDUP(cgroup_input_d->img, img);
+ free(img);
+ }
+ else
+ {
+ ERR("group_input_camera_result() Failed: %s", "return value is NULL");
+ return;
+ }
+ elm_genlist_item_update(cgroup_input_d->image_item);
+ }
+ }
+ else
+ {
+ ERR("group_input_camera_result() Failed: %s", "user_data is NULL");
+ }
+}
+
+static void __group_input_gallery(ct_group_input_data *cgroup_input_d)
+{
+ PH_TRACE;
+ service_h service;
+ struct ug_cbs cbs = { 0 };
+
+ group_input_popup_hide_cb(cgroup_input_d, NULL, NULL);
+ elm_object_tree_focus_allow_set(cgroup_input_d->navi, EINA_FALSE);
+
+ service_create(&service);
+ service_add_extra_data(service, "launch-type", "select-one");
+ service_add_extra_data(service, "file-type", "image");
+
+ cbs.result_cb = group_input_image_gallery_result;
+ cbs.destroy_cb = group_input_src_ug_destroy;
+ cbs.layout_cb = ug_common_layout_cb;
+ cbs.priv = cgroup_input_d;
+
+ cgroup_input_d->child_ug = ug_create(cgroup_input_d->ug, GALLERY_UG,
+ UG_MODE_FULLVIEW, service, &cbs);
+ p_warn_if(NULL == cgroup_input_d->child_ug, "ug_create() Failed");
+
+ service_destroy(service);
+}
+
+static void __group_input_camera(ct_group_input_data *cgroup_input_d)
+{
+ PH_TRACE;
+ service_h service;
+ p_ret_if(cgroup_input_d->camera_service_launched);
+ group_input_popup_hide_cb(cgroup_input_d, NULL, NULL);
+ elm_object_tree_focus_allow_set(cgroup_input_d->navi, EINA_FALSE);
+
+ service_create(&service);
+ service_set_window(service, elm_win_xwindow_get(cgroup_input_d->win));
+ service_set_operation(service, SERVICE_OPERATION_CREATE_CONTENT);
+ service_set_mime(service, "image/jpg");
+ service_add_extra_data(service, "CALLER", "contacts");
+ service_send_launch_request(service, group_input_camera_result,
+ cgroup_input_d);
+ cgroup_input_d->camera_service_launched = true;
+ service_destroy(service);
+}
+
+static void __group_input_gallery_mouse_up(void *data, Evas *e,
+ Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ ct_group_input_data *cgroup_input_d = (ct_group_input_data *) data;
+
+ Evas_Event_Mouse_Up *ev = (Evas_Event_Mouse_Up *) event_info;
+ if (ev == NULL)
+ {
+ ERR("ev is null!!!");
+ return;
+ }
+
+ int x, y, w, h;
+
+ if (cgroup_input_d->img && *cgroup_input_d->img)
+ {
+ elm_image_file_set(obj, cgroup_input_d->img, NULL);
+ }
+ else
+ elm_image_file_set(obj, CTUI_IMG_INPUT_GALLERY, NULL);
+
+ if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
+ return;
+
+ evas_object_geometry_get(obj, &x, &y, &w, &h);
+ if (ev->output.y < y || y + h < ev->output.y)
+ return;
+
+ __group_input_gallery(cgroup_input_d);
+}
+
+static void __group_input_gallery_mouse_down(void *data, Evas *e,
+ Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ ct_group_input_data *cgroup_input_d = (ct_group_input_data *) data;
+
+ if (cgroup_input_d->img && *cgroup_input_d->img)
+ {
+ elm_image_file_set(obj, cgroup_input_d->img, NULL);
+ }
+ else
+ elm_image_file_set(obj, CTUI_IMG_INPUT_GALLERY_PRESSED, NULL);
+}
+
+static void __group_input_camera_mouse_up(void *data, Evas *e, Evas_Object *obj,
+ void *event_info)
+{
+ PH_TRACE;
+ ct_group_input_data *cgroup_input_d = (ct_group_input_data *) data;
+ int x, y, w, h;
+ Evas_Event_Mouse_Up *ev = (Evas_Event_Mouse_Up *) event_info;
+ if (ev == NULL)
+ {
+ ERR("ev is null!!!");
+ return;
+ }
+ elm_image_file_set(obj, CTUI_IMG_INPUT_CAMERA, NULL);
+
+ if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
+ return;
+
+ evas_object_geometry_get(obj, &x, &y, &w, &h);
+ if (ev->output.y < y || y + h < ev->output.y)
+ return;
+
+ __group_input_camera(cgroup_input_d);
+
+}
+static void __group_input_camera_mouse_down(void *data, Evas *e,
+ Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ elm_image_file_set(obj, CTUI_IMG_INPUT_CAMERA_PRESSED, NULL);
+}
+
+static Evas_Object* group_input_gl_create_icon_get(void *data, Evas_Object *obj,
+ const char *part)
+{
+ PH_TRACE;
+ ct_group_input_data *cgroup_input_d = (ct_group_input_data *) data;
+ p_retvm_if(NULL== data, NULL, "The parameter(data) is NULL");
+
+ if (0 == strcmp(part, ELM_ICON))
+ {
+ static Elm_Entry_Filter_Limit_Size limit_filter_data;
+ Evas_Object *edit_field;
+ Evas_Object *entry;
+
+ edit_field = ctui_create_editfield(obj,
+ T_(CT_GET_TEXT_BASIC, CTTEXT_GROUP_NAME), NULL, false);
+ evas_object_propagate_events_set(edit_field, EINA_FALSE);
+
+ entry = elm_object_part_content_get(edit_field, "elm.swallow.content");
+ elm_object_signal_emit(edit_field, "elm,state,guidetext,hide", "elm");
+ evas_object_data_set(obj, "entry", entry);
+ cgroup_input_d->entry = entry;
+
+ limit_filter_data.max_char_count = CT_EDITFIELD_MAX_CHAR;
+ elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size,
+ &limit_filter_data);
+ evas_object_smart_callback_add(entry, "changed,user",
+ group_input_entry_changed_cb, cgroup_input_d);
+ evas_object_smart_callback_add(entry, "preedit,changed",
+ group_input_entry_changed_cb, cgroup_input_d);
+ evas_object_smart_callback_add(entry, CLICKED,
+ group_input_entry_clicked_cb, cgroup_input_d);
+
+ if (cgroup_input_d->editgroup == true)
+ ctui_entry_entry_set(entry, cgroup_input_d->gname);
+
+ if (cgroup_input_d->is_read_only == true)
+ elm_object_disabled_set(entry, EINA_TRUE);
+
+ if(cgroup_input_d->gname)
+ {
+ elm_entry_entry_set(entry, cgroup_input_d->gname);
+ }
+
+ evas_object_show(entry);
+
+ return edit_field;
+ }
+ return NULL;
+}
+
+static Evas_Object* group_input_gl_icon_get(void *data, Evas_Object *obj,
+ const char *part)
+{
+ PH_TRACE;
+ ct_group_input_data *cgroup_input_d = (ct_group_input_data *) data;
+ p_retvm_if(NULL== data, NULL, "The parameter(data) is NULL");
+
+ if (0 == strcmp(part, ELM_ICON))
+ {
+ Evas_Object *icon;
+ if (cgroup_input_d->img && *cgroup_input_d->img)
+ {
+ PH_DBG("img : %s", cgroup_input_d->img);
+ icon = elm_icon_add(obj);
+ p_retvm_if(NULL == icon, NULL, "elm_icon_add() return NULL");
+ elm_image_file_set(icon, cgroup_input_d->img, NULL);
+ evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_NONE, 1,
+ 1);
+ evas_object_size_hint_align_set(icon, 0.5, EVAS_HINT_FILL);
+ }
+ else
+ {
+ icon = elm_icon_add(obj);
+ p_retvm_if(NULL == icon, NULL, "elm_icon_add() return NULL");
+ elm_image_file_set(icon, CTUI_IMG_INPUT_GALLERY, NULL);
+ elm_image_resizable_set(icon, EINA_FALSE, EINA_FALSE);
+ }
+ evas_object_event_callback_add(icon, EVAS_CALLBACK_MOUSE_DOWN,
+ __group_input_gallery_mouse_down, cgroup_input_d);
+ evas_object_event_callback_add(icon, EVAS_CALLBACK_MOUSE_UP,
+ __group_input_gallery_mouse_up, cgroup_input_d);
+ return icon;
+ }
+ if (0 == strcmp(part, "elm.icon3"))
+ {
+ Evas_Object *icon = NULL;
+
+ icon = elm_icon_add(obj);
+ p_retvm_if(NULL == icon, NULL, "elm_icon_add() return NULL");
+ elm_image_file_set(icon, CTUI_IMG_INPUT_CAMERA, NULL);
+ evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_NONE, 1, 1);
+ evas_object_size_hint_align_set(icon, 0.5, EVAS_HINT_FILL);
+ evas_object_propagate_events_set(icon, EINA_FALSE);
+ evas_object_color_set(icon, 255, 255, 255, 255);
+ evas_object_event_callback_add(icon, EVAS_CALLBACK_MOUSE_DOWN,
+ __group_input_camera_mouse_down, cgroup_input_d);
+ evas_object_event_callback_add(icon, EVAS_CALLBACK_MOUSE_UP,
+ __group_input_camera_mouse_up, cgroup_input_d);
+ //evas_object_smart_callback_add(icon, CLICKED, group_input_image_camera_cb, cgroup_input_d);
+ return icon;
+ }
+ if (0 == strcmp(part, "elm.icon4"))
+ {
+ Evas_Object *btn_minus;
+ if (cgroup_input_d->img && *cgroup_input_d->img)
+ {
+ btn_minus = elm_button_add(obj);
+ p_retvm_if(NULL == btn_minus, NULL, "elm_button_add() return NULL");
+ elm_object_style_set(btn_minus, "icon_minus");
+ evas_object_size_hint_aspect_set(btn_minus,
+ EVAS_ASPECT_CONTROL_NONE, 1, 1);
+ evas_object_size_hint_align_set(btn_minus, 0.5, EVAS_HINT_FILL);
+ evas_object_smart_callback_add(btn_minus, CLICKED,
+ group_input_image_delete_cb, cgroup_input_d);
+ return btn_minus;
+ }
+ else
+ return NULL;
+ }
+ return NULL;
+}
+
+int group_input_get_member_list(int group_id, Eina_List **list)
+{
+ PH_TRACE;
+ int ret;
+ int person_id;
+ contacts_record_h record = NULL;
+ contacts_list_h person_list = NULL;
+
+ ret = phone_cts_get_list(_contacts_person_grouprel._uri,
+ _contacts_person_grouprel.group_id, group_id, &person_list);
+ p_retvm_if(CONTACTS_ERROR_NONE != ret, ret,
+ "phone_cts_get_list() Failed(%d)", ret);
+ ret = contacts_list_get_current_record_p(person_list, &record);
+ p_retvm_if(CONTACTS_ERROR_NONE != ret, ret,
+ "contacts_list_get_current_record_p() Failed(%d)", ret);
+ while (record)
+ {
+ ct_person_list *person_info;
+ char *display_name = NULL;
+ char *addressbook_ids = NULL;
+
+ ret = contacts_record_get_int(record, _contacts_person.id, &person_id);
+ p_retvm_if(CONTACTS_ERROR_NONE != ret, ret,
+ "contacts_record_get_int() Failed(%d)", ret);
+
+ person_info = (ct_person_list *) calloc(1, sizeof(ct_person_list));
+ person_info->id = person_id;
+ ret = contacts_record_get_str_p(record, _contacts_person.display_name,
+ &display_name);
+ p_retvm_if(CONTACTS_ERROR_NONE != ret, ret,
+ "contacts_record_get_str_p() Failed(%d)", ret);
+ person_info->display = SAFE_STRDUP(display_name);
+
+ ret = contacts_record_get_int(record, _contacts_person.link_count,
+ &(person_info->link_count));
+ p_retvm_if(CONTACTS_ERROR_NONE != ret, ret,
+ "contacts_record_get_int() Failed(%d)", ret);
+
+ ret = contacts_record_get_str(record, _contacts_person.addressbook_ids,
+ &addressbook_ids);
+ p_retvm_if(CONTACTS_ERROR_NONE != ret, ret,
+ "contacts_record_get_int() Failed(%d)", ret);
+ person_info->addressbook_id_list = ctui_get_addressbook_id_list(
+ addressbook_ids, " ");
+
+ *list = eina_list_append(*list, person_info);
+
+ ret = contacts_list_next(person_list);
+ p_retvm_if(CONTACTS_ERROR_NONE != ret, ret,
+ "contacts_list_next() Failed(%d)", ret);
+ ret = contacts_list_get_current_record_p(person_list, &record);
+ p_retvm_if(CONTACTS_ERROR_NONE != ret, ret,
+ "contacts_list_get_current_record_p() Failed(%d)", ret);
+ }
+ ret = contacts_list_destroy(person_list, true);
+ p_retvm_if(CONTACTS_ERROR_NONE != ret, ret,
+ "contacts_list_destroy() Failed(%d)", ret);
+
+ return ret;
+}
+
+void group_input_group_name_set(ct_group_input_data *cgroup_input_d)
+{
+ PH_TRACE;
+ bool isCorrectParameters = (NULL != cgroup_input_d && NULL != cgroup_input_d->entry);
+ p_retm_if(!isCorrectParameters, "incorrect parameters");
+
+ Evas_Object *entry = cgroup_input_d->entry;
+ char *text = ctui_entry_markup_to_utf8(elm_entry_entry_get(entry));
+ p_retm_if(NULL == text, "ctui_entry_markup_to_utf8() return NULL");
+ PH_DBG("text = %s", text);
+
+ FREEandSTRDUP(cgroup_input_d->gname, text);
+ free(text);
+}
+
+static void group_input_add_member_clicked_cb(void *data, Evas_Object *obj,
+ void *event_info)
+{
+ PH_TRACE;
+ p_retm_if(NULL == data, "parameter(data) is NULL");
+ ct_group_input_data *cgroup_input_d = (ct_group_input_data *) data;
+
+ group_input_group_name_set(cgroup_input_d);
+ Elm_Object_Item *navi_item = ctui_create_gadd_list_select_view(cgroup_input_d->win, cgroup_input_d->navi,
+ cgroup_input_d->id_grp, cgroup_input_d->id_ab,
+ &cgroup_input_d->member_list, false);
+ elm_naviframe_item_pop_cb_set(navi_item, group_input_add_member_cb, cgroup_input_d);
+}
+
+static char *group_input_gl_group_list_item_label_get(void *data, Evas_Object *obj,
+ const char *part)
+{
+ PH_TRACE;
+ p_retvm_if(NULL == data, NULL, "parameter(data) is NULL");
+ p_retvm_if(NULL == part, NULL, "parameter(part) is NULL");
+
+ ui_genlist_item *item = (ui_genlist_item *) data;
+ ct_person_list *person_info = (ct_person_list *)item->data;
+ p_retvm_if(NULL == person_info, NULL, "person_info is NULL");
+
+ if (0 == strcmp(part, ELM_TEXT))
+ {
+ PH_DBG("person_info->display = %s", person_info->display);
+ return SAFE_STRDUP(person_info->display);
+ }
+ return NULL;
+}
+
+void group_input_gl_group_list_item_remove_cb(void *data, Evas_Object *obj,
+ void *event_info)
+{
+ PH_TRACE;
+ p_retm_if(NULL == data, "parameter(data) is NULL");
+ ui_genlist_item *item = (ui_genlist_item *) data;
+
+ if (item->item_list && *item->item_list)
+ {
+ *item->item_list = eina_list_remove(*item->item_list, (void *) item->data);
+ free(item->data);
+ item->data = NULL;
+ }
+
+ if (item->save_button)
+ {
+ elm_object_disabled_set(item->save_button, false);
+ }
+
+ if (item->object_item)
+ {
+ elm_object_item_del(item->object_item);
+ item->object_item = NULL;
+ }
+}
+
+static char *group_input_gl_group_members_label_get(void *data, Evas_Object *obj,
+ const char *part)
+{
+ PH_TRACE;
+ p_retvm_if(NULL == part, NULL, "parameter(part) is NULL");
+ const char *GROUP_MEMBERS = "Group members";
+
+ if (0 == strcmp(part, ELM_TEXT))
+ {
+ return SAFE_STRDUP(GROUP_MEMBERS);
+ }
+ return NULL;
+}
+
+static Evas_Object *group_input_gl_group_members_icon_get(void *data, Evas_Object *obj,
+ const char *part)
+{
+ PH_TRACE;
+ p_retvm_if(NULL == part, NULL, "parameter(part) is NULL");
+ p_retvm_if(NULL == data, NULL, "parameter(data) is NULL");
+ ct_group_input_data *cgroup_input_d = (ct_group_input_data *) data;
+ Evas_Object *ret_obj = NULL;
+
+ const char *BUTTON_STYLE_PLUS = "plus";
+ const char *BUTTON_PART_ICON = "icon";
+
+ if (0 == strcmp(part, ELM_ICON))
+ {
+ Evas_Object *btn = elm_button_add(obj);
+ p_retvm_if(NULL == btn, NULL, "ctui_create_btn() return NULL");
+ elm_object_style_set(btn, BUTTON_STYLE_PLUS);
+ evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+ evas_object_smart_callback_add(btn, CLICKED, group_input_add_member_clicked_cb, cgroup_input_d);
+
+ Evas_Object *icon = elm_icon_add(obj);
+ elm_icon_standard_set(icon, PH_IMG_ICON_ADD);
+ elm_object_part_content_set(btn, BUTTON_PART_ICON, icon);
+
+ ret_obj = btn;
+ }
+ return ret_obj;
+}
+
+static Evas_Object *group_input_gl_group_list_item_icon_get(void *data, Evas_Object *obj,
+ const char *part)
+{
+ PH_TRACE;
+ p_retvm_if(NULL == data, NULL, "parameter(data) is NULL");
+ p_retvm_if(NULL == part, NULL, "parameter(part) is NULL");
+
+ Evas_Object *ret_obj = NULL;
+ ui_genlist_item *item = (ui_genlist_item *) data;
+ ct_person_list *person_info = (ct_person_list *)item->data;
+ p_retvm_if(NULL == person_info, NULL, "person_info is NULL");
+
+ const char *BUTTON_STYLE_MINUS = "minus";
+ const char *ELM_ICON_EDIT = "elm.icon.edit";
+
+ if (0 == strcmp(part, ELM_ICON))
+ {
+ if (person_info->id)
+ {
+ contacts_record_h record = NULL;
+
+ int err = contacts_db_get_record(_contacts_person._uri, person_info->id, &record);
+ p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_db_get_record() Failed(%d)", err);
+
+ free(person_info->img_path);
+ err = contacts_record_get_str(record, _contacts_person.image_thumbnail_path,
+ &(person_info->img_path));
+ p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_get_str() Failed(%d)", err);
+
+ err = contacts_record_destroy(record, true);
+ p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_destroy() Failed(%d)", err);
+ }
+
+ Evas_Object *icon = elm_icon_add(obj);
+ p_retvm_if(NULL == icon, NULL, "elm_icon_add() return NULL");
+ elm_image_prescale_set(icon, CT_LIST_ICON_SIZE);
+ if (NULL != person_info->img_path)
+ {
+ elm_image_file_set(icon, person_info->img_path, NULL);
+ }
+ else
+ {
+ elm_image_file_set(icon, IMG_DEFAULT, NULL);
+ }
+ evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
+ evas_object_show(icon);
+ ret_obj = icon;
+ }
+ else if (0 == strcmp(part, ELM_ICON_EDIT))
+ {
+ Evas_Object *btn = elm_button_add(obj);
+ p_retvm_if(NULL == btn, NULL, "elm_button_add() return NULL");
+ elm_object_style_set(btn, BUTTON_STYLE_MINUS);
+ evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_smart_callback_add(btn, CLICKED, group_input_gl_group_list_item_remove_cb, item);
+ evas_object_show(btn);
+
+ ret_obj = btn;
+ }
+ return ret_obj;
+}
+
+static void group_input_genlist_style_set(void)
+{
+ PH_TRACE;
+ group_input_itcs[GINPUT_ITC_GROUP_IMAGE].func.content_get =
+ group_input_gl_icon_get;
+ group_input_itcs[GINPUT_ITC_GROUP_CREATE].func.content_get =
+ group_input_gl_create_icon_get;
+ group_input_itcs[GINPUT_ITC_GROUP_VIBRATION].func.text_get =
+ group_input_gl_vibration_label_get;
+ group_input_itcs[GINPUT_ITC_GROUP_RINGTON].func.text_get =
+ group_input_gl_ringtone_label_get;
+ group_input_itcs[GINPUT_ITC_ADDRBOOK].func.text_get =
+ group_input_gl_label_get;
+
+ group_input_itcs[GINPUT_ITC_GROUP_MEMBERS].func.text_get =
+ group_input_gl_group_members_label_get;
+ group_input_itcs[GINPUT_ITC_GROUP_MEMBERS].func.content_get =
+ group_input_gl_group_members_icon_get;
+
+ group_input_itcs[GINPUT_ITC_GROUP_LIST_ITEM].func.text_get =
+ group_input_gl_group_list_item_label_get;
+ group_input_itcs[GINPUT_ITC_GROUP_LIST_ITEM].func.content_get =
+ group_input_gl_group_list_item_icon_get;
+ group_input_itcs[GINPUT_ITC_GROUP_LIST_ITEM].func.del =
+ ui_genlist_item_destroy;
+}
+
+static void group_input_view_delete_cb(void *data, Evas *e, Evas_Object *obj,
+ void *event_info)
+{
+ PH_TRACE;
+ ct_group_input_data *cgroup_input_d = (ct_group_input_data *) data;
+
+ if (cgroup_input_d->popup)
+ evas_object_del(cgroup_input_d->popup);
+ if (cgroup_input_d->th)
+ {
+ elm_theme_extension_del(cgroup_input_d->th, IMAGE_LAYOUT_EDJ);
+ elm_theme_free(cgroup_input_d->th);
+ }
+
+ if (cgroup_input_d->child_ug)
+ ug_destroy(cgroup_input_d->child_ug);
+
+ if (cgroup_input_d->crop_ug)
+ ug_destroy((ui_gadget_h) cgroup_input_d->crop_ug);
+
+ if (cgroup_input_d->win_prop_change)
+ ecore_event_handler_del(cgroup_input_d->win_prop_change);
+
+ evas_object_data_del(cgroup_input_d->navi, "navi_it_pop_to");
+ ctui_list_free_contacts(cgroup_input_d->member_list);
+ free(cgroup_input_d->ab_name);
+ free(cgroup_input_d->gname_old);
+ free(cgroup_input_d->gname);
+ free(cgroup_input_d->img);
+ free(cgroup_input_d->ringtone);
+ free(cgroup_input_d->vibration);
+ free(cgroup_input_d);
+}
+
+static void group_input_get_data(ct_group_input_data *cgroup_input_d)
+{
+ PH_TRACE;
+ char *img = NULL;
+ char *vibration = NULL;
+ char *ringtone = NULL;
+ bool is_read_only = false;
+ contacts_error_e err = CONTACTS_ERROR_NONE;
+ contacts_record_h record = NULL;
+
+ err = (contacts_error_e) contacts_db_get_record(_contacts_group._uri, cgroup_input_d->id_grp,
+ &record);
+ p_retm_if(CONTACTS_ERROR_NONE != err, "contacts_db_get_record() Failed(%d)",
+ err);
+ err = (contacts_error_e) contacts_record_get_str_p(record, _contacts_group.image_path, &img);
+ p_retm_if(CONTACTS_ERROR_NONE != err,
+ "contacts_record_get_str_p() Failed(%d)", err);
+ cgroup_input_d->img = SAFE_STRDUP(img);
+
+ err = (contacts_error_e) contacts_record_get_str_p(record, _contacts_group.vibration,
+ &vibration);
+ p_retm_if(CONTACTS_ERROR_NONE != err,
+ "contacts_record_get_str_p() Failed(%d)", err);
+ cgroup_input_d->vibration = SAFE_STRDUP(vibration);
+
+ err = (contacts_error_e) contacts_record_get_str_p(record, _contacts_group.ringtone_path,
+ &ringtone);
+ p_retm_if(CONTACTS_ERROR_NONE != err,
+ "contacts_record_get_str_p() Failed(%d)", err);
+ cgroup_input_d->ringtone = SAFE_STRDUP(ringtone);
+
+ cgroup_input_d->gname = SAFE_STRDUP(phone_get_group_name(record));
+ cgroup_input_d->gname_old = SAFE_STRDUP(cgroup_input_d->gname_old);
+
+ err = (contacts_error_e) contacts_record_get_bool(record, _contacts_group.is_read_only,
+ &is_read_only);
+ p_retm_if(CONTACTS_ERROR_NONE != err,
+ "contacts_record_get_bool() Failed(%d)", err);
+ cgroup_input_d->is_read_only = is_read_only;
+
+ err = (contacts_error_e) contacts_record_destroy(record, true);
+ p_retm_if(CONTACTS_ERROR_NONE != err,
+ "contacts_record_destroy() Failed(%d)", err);
+}
+
+void ctui_create_group_input_view(Evas_Object *win, Evas_Object *navi,
+ ct_group_list *info, ct_group_input_result_cb result_cb, void *cb_data)
+{
+ PH_TRACE;
+ ct_group_input_data *cgroup_input_d;
+ Evas_Object *layout;
+ Evas_Object *bg;
+ Elm_Theme *th;
+
+ cgroup_input_d = (ct_group_input_data *) calloc(1, sizeof(ct_group_input_data));
+ p_retm_if(NULL == cgroup_input_d, "calloc() return NULL");
+
+ if (info != NULL)
+ {
+ cgroup_input_d->id_grp = info->id_grp;
+
+ cgroup_input_d->id_ab = info->id_ab;
+ group_input_get_data(cgroup_input_d);
+ cgroup_input_d->editgroup = true;
+ group_input_get_member_list(cgroup_input_d->id_grp,
+ &cgroup_input_d->member_list);
+ PH_DBG("cgroup_input_d->id_grp : %d", cgroup_input_d->id_grp);
+ }
+ else
+ {
+ cgroup_input_d->editgroup = false;
+ cgroup_input_d->id_ab = 0;
+ }
+ cgroup_input_d->win = win;
+ cgroup_input_d->navi = navi;
+ cgroup_input_d->result_cb = result_cb;
+ cgroup_input_d->result_cb_data = cb_data;
+
+ layout = phone_create_base_layout(cgroup_input_d->navi, false);
+ bg = phone_create_bg(layout);
+ if (NULL == bg)
+ {
+ ERR("phone_create_bg() return NULL");
+ free(cgroup_input_d);
+ evas_object_del(layout);
+ return;
+ }
+
+ if (cgroup_input_d->editgroup == true)
+ {
+ cgroup_input_d->navi_item = elm_naviframe_item_push(cgroup_input_d->navi,
+ T_(CT_GET_TEXT_BASE_OP, CTTEXT_EDIT_GROUP), NULL, NULL,
+ layout, NULL);
+ }
+ else
+ {
+ cgroup_input_d->navi_item = elm_naviframe_item_push(cgroup_input_d->navi,
+ T_(CT_GET_TEXT_BASE_OP, CTTEXT_CREATE_GROUP), NULL, NULL,
+ layout, NULL);
+ }
+
+ evas_object_data_set(cgroup_input_d->navi, "navi_it_pop",
+ cgroup_input_d->navi_item);
+
+ phone_navi_item_reset(cgroup_input_d->navi_item, cgroup_input_d);
+
+ cgroup_input_d->done_button = elm_button_add(cgroup_input_d->navi);
+ elm_object_style_set(cgroup_input_d->done_button, "naviframe/title_text");
+ elm_object_text_set(cgroup_input_d->done_button, "Save");
+ evas_object_smart_callback_add(cgroup_input_d->done_button, "clicked",
+ group_input_save_btn_cb, cgroup_input_d);
+ elm_object_item_part_content_set(cgroup_input_d->navi_item, "title_right_btn",
+ cgroup_input_d->done_button);
+
+ elm_win_conformant_set(cgroup_input_d->win, EINA_TRUE);
+ cgroup_input_d->genlist = elm_genlist_add(layout);
+ elm_object_style_set(cgroup_input_d->genlist, "dialogue");
+ elm_object_style_set(cgroup_input_d->genlist, "no_effect");
+ evas_object_smart_callback_add(cgroup_input_d->genlist, "realized", ui_genlist_on_realized, cgroup_input_d);
+ th = elm_theme_new();
+ elm_theme_ref_set(th, NULL);
+ elm_theme_extension_add(th, IMAGE_LAYOUT_EDJ);
+ cgroup_input_d->th = th;
+ elm_object_theme_set(cgroup_input_d->genlist, cgroup_input_d->th);
+ group_input_genlist_style_set();
+ evas_object_size_hint_weight_set(cgroup_input_d->genlist, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(cgroup_input_d->genlist, EVAS_HINT_FILL,
+ EVAS_HINT_FILL);
+ evas_object_show(cgroup_input_d->genlist);
+ elm_object_part_content_set(layout, "elm.swallow.content",
+ cgroup_input_d->genlist);
+ group_input_fill_genlist(cgroup_input_d);
+
+ elm_object_disabled_set(cgroup_input_d->done_button, EINA_TRUE);
+
+ evas_object_event_callback_add(layout, EVAS_CALLBACK_DEL,
+ group_input_view_delete_cb, cgroup_input_d);
+}
diff --git a/lib/common/ct-list-detail.cpp b/lib/common/ct-list-detail.cpp
new file mode 100755
index 0000000..372cecc
--- /dev/null
+++ b/lib/common/ct-list-detail.cpp
@@ -0,0 +1,631 @@
+/*
+ * 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.
+ */
+
+#include <aul.h>
+#include <ui-gadget-module.h>
+
+#include "phone.h"
+#include "phone-common.h"
+
+#include "ct-list.h"
+
+void ctui_ld_to_dd(ct_list_data *clist_d, ct_detail_data *cdetail_d)
+{
+ PH_TRACE;
+ cdetail_d->win = clist_d->win;
+ cdetail_d->navi = clist_d->navi;
+ cdetail_d->base_grp = clist_d->base_grp;
+ cdetail_d->base_ab = clist_d->base_ab;
+ cdetail_d->ug = clist_d->ug;
+ cdetail_d->prev_navi_item = clist_d->navi_item;
+ cdetail_d->prev_view_data = clist_d;
+}
+
+void ctui_get_number_type_str(contacts_record_h record, int number_type,
+ char *dest, int dest_len)
+{
+ PH_TRACE;
+ contacts_error_e err = CONTACTS_ERROR_NONE;
+ const char* type_str;
+ char *custom = NULL;
+
+ if (number_type & CONTACTS_NUMBER_TYPE_CUSTOM)
+ {
+ err = (contacts_error_e) contacts_record_get_str_p(record,
+ _contacts_number.label, &custom);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_record_get_str_p() Failed(%d)", err);
+ if (NULL == custom || '\0' == custom[0])
+ type_str = T_(CT_GET_TEXT_NUM_TYPE, CTTEXT_TYPE_OTHER);
+ else
+ {
+ snprintf(dest, dest_len, "%s", custom);
+ return;
+ }
+ }
+ else if (number_type & CONTACTS_NUMBER_TYPE_CELL)
+ {
+ if (number_type & CONTACTS_NUMBER_TYPE_HOME)
+ type_str = T_(CT_GET_TEXT_NUM_TYPE, CTTEXT_TYPE_HOME2);
+ else if (number_type & CONTACTS_NUMBER_TYPE_WORK)
+ type_str = T_(CT_GET_TEXT_NUM_TYPE, CTTEXT_TYPE_WORK2);
+ else
+ type_str = T_(CT_GET_TEXT_NUM_TYPE, CTTEXT_TYPE_MOBILE);
+ }
+ else if (number_type & CONTACTS_NUMBER_TYPE_VOICE)
+ {
+ if (number_type & CONTACTS_NUMBER_TYPE_HOME)
+ type_str = T_(CT_GET_TEXT_NUM_TYPE, CTTEXT_TYPE_HOME);
+ else if (number_type & CONTACTS_NUMBER_TYPE_WORK)
+ type_str = T_(CT_GET_TEXT_NUM_TYPE, CTTEXT_TYPE_WORK);
+ else
+ type_str = T_(CT_GET_TEXT_NUM_TYPE, CTTEXT_TYPE_TELEPHONE);
+ }
+ else if (number_type & CONTACTS_NUMBER_TYPE_FAX)
+ {
+ if (number_type & CONTACTS_NUMBER_TYPE_HOME)
+ type_str = T_(CT_GET_TEXT_NUM_TYPE, CTTEXT_TYPE_FAX_HOME);
+ else if (number_type & CONTACTS_NUMBER_TYPE_WORK)
+ type_str = T_(CT_GET_TEXT_NUM_TYPE, CTTEXT_TYPE_FAX_WORK);
+ else
+ type_str = T_(CT_GET_TEXT_NUM_TYPE, CTTEXT_TYPE_FAX);
+ }
+ else if (number_type & CONTACTS_NUMBER_TYPE_PAGER)
+ type_str = T_(CT_GET_TEXT_NUM_TYPE, CTTEXT_TYPE_PAGER);
+ else if (number_type & CONTACTS_NUMBER_TYPE_CAR)
+ type_str = T_(CT_GET_TEXT_NUM_TYPE, CTTEXT_TYPE_CAR);
+ else if (number_type & CONTACTS_NUMBER_TYPE_ASSISTANT)
+ type_str = T_(CT_GET_TEXT_NUM_TYPE, CTTEXT_TYPE_ASSISTANT);
+ else
+ {
+ if (number_type == CONTACTS_NUMBER_TYPE_HOME)
+ type_str = T_(CT_GET_TEXT_NUM_TYPE, CTTEXT_TYPE_HOME);
+ else if (number_type == CONTACTS_NUMBER_TYPE_WORK)
+ type_str = T_(CT_GET_TEXT_NUM_TYPE, CTTEXT_TYPE_WORK);
+ else
+ type_str = T_(CT_GET_TEXT_NUM_TYPE, CTTEXT_TYPE_OTHER);
+ }
+
+ snprintf(dest, dest_len, "%s", type_str);
+}
+
+const char* ctui_get_default_contact_img(int view_type)
+{
+ PH_TRACE;
+ switch (view_type)
+ {
+ case CT_VIEW_DETAIL:
+ return CTUI_IMG_DEFAULT_PHOTO_BIG;
+
+ case CT_VIEW_INPUT:
+ return CTUI_IMG_PHOTO_EDIT;
+
+ case CT_VIEW_ETC:
+ default:
+ return CTUI_IMG_DEFAULT_PHOTO_SMALL;
+ }
+}
+
+Evas_Object* ctui_create_btn(Evas_Object *parent, const char *label)
+{
+ PH_TRACE;
+ Evas_Object *btn;
+
+ btn = elm_button_add(parent);
+ p_retvm_if(NULL == btn, NULL, "elm_button_add() return NULL");
+
+ elm_object_text_set(btn, label);
+ evas_object_propagate_events_set(btn, EINA_FALSE);
+ evas_object_show(btn);
+
+ return btn;
+}
+
+void ctui_destroy_child_ug(void *data)
+{
+ PH_TRACE;
+ void **child = (void **) data;
+ *child = NULL;
+}
+
+ui_gadget_h ctui_msg_ug(ui_gadget_h parent, const char *number,
+ const char *attach, void (*destroy_cb)(void*), void *cb_param)
+{
+ PH_TRACE;
+ struct ug_cbs cbs = { 0 };
+ ui_gadget_h ug;
+ struct ug_priv_data *priv_data;
+ service_h service;
+
+ priv_data = (ug_priv_data *) calloc(1, sizeof(struct ug_priv_data));
+ p_retvm_if(NULL == priv_data, NULL, "calloc is failed");
+ priv_data->destroy_cb = destroy_cb;
+ priv_data->cb_param = cb_param;
+
+ service_create(&service);
+
+ if (number)
+ {
+ service_add_extra_data(service, "TO", number);
+ }
+
+ if (attach)
+ {
+ service_add_extra_data(service, "ATTACHFILE", attach);
+ service_add_extra_data(service, "SUBJECT", "Contacts name card");
+ }
+
+ cbs.layout_cb = ug_common_layout_cb;
+ cbs.result_cb = NULL;
+ cbs.destroy_cb = ug_common_destroy_cb;
+ cbs.priv = priv_data;
+
+ ug = ug_create(parent, MSG_COMPOSER_UG, UG_MODE_FULLVIEW, service, &cbs);
+ p_warn_if(NULL == ug, "ug_create() Failed");
+
+ service_destroy(service);
+ return ug;
+}
+
+ui_gadget_h ctui_predefined_body_msg_ug(ui_gadget_h parent, const char *number, const int person_id, const char *bodyText, void (*destroy_cb)(void*), void *cb_param)
+{
+ PH_TRACE;
+ ui_gadget_h ug = NULL;
+ struct ug_priv_data *priv_data;
+ priv_data = (ug_priv_data *) calloc(1, sizeof(struct ug_priv_data));
+ if (NULL != priv_data)
+ {
+ priv_data->destroy_cb = destroy_cb;
+ priv_data->cb_param = cb_param;
+
+ service_h service;
+ service_create(&service);
+
+ if (number && person_id)
+ {
+ char temp[PH_TEXT_MAX_LEN + 1] = { 0, };
+ snprintf(temp, sizeof(temp), "%s/%d", number, person_id);
+ service_add_extra_data(service, "number/index", temp);
+ }
+ else if (number)
+ {
+ service_add_extra_data(service, "TO", number);
+ }
+
+ if (bodyText)
+ {
+ service_add_extra_data(service, "BODY", bodyText);
+ }
+
+ struct ug_cbs cbs = { 0 };
+ cbs.layout_cb = ug_common_layout_cb;
+ cbs.result_cb = NULL;
+ cbs.destroy_cb = ug_common_destroy_cb;
+ cbs.priv = priv_data;
+
+ ug = ug_create(parent, MSG_COMPOSER_UG, UG_MODE_FULLVIEW, service, &cbs);
+ if (NULL != ug)
+ service_destroy(service);
+ else
+ ERR("ug_create() Failed");
+ }
+ else
+ {
+ ERR("%s", "calloc is failed");
+ }
+ return ug;
+}
+
+void ctui_entry_limit_size_set(Evas_Object *entry)
+{
+ PH_TRACE;
+ static Elm_Entry_Filter_Limit_Size filter;
+ p_retm_if(NULL == entry, "parameter(entry) is NULL");
+
+ filter.max_char_count = CT_EDITFIELD_MAX_CHAR;
+ elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size, &filter);
+}
+
+void ctui_genlist_append_separator_10px(Evas_Object *genlist)
+{
+ PH_TRACE;
+ static Elm_Genlist_Item_Class itc;
+ itc.item_style = "dialogue/separator/10";
+
+ Elm_Object_Item * item;
+ item = elm_genlist_item_append(genlist, &itc, NULL, NULL,
+ ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+}
+
+void ctui_genlist_append_separator_20px(Evas_Object *genlist)
+{
+ PH_TRACE;
+ static Elm_Genlist_Item_Class itc;
+ itc.item_style = "dialogue/separator/20";
+
+ Elm_Object_Item * item;
+ item = elm_genlist_item_append(genlist, &itc, NULL, NULL,
+ ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+}
+
+void ctui_navi_btn_disabled_set(Evas_Object *navi, Eina_Bool disabled)
+{
+ PH_TRACE;
+ Evas_Object *done_button, *delete_item, *share_button;
+
+ p_retm_if(NULL == navi, "parameter(navi) is NULL");
+
+ done_button = (Evas_Object *) evas_object_data_get(navi, "done_button");
+ delete_item = (Evas_Object *) evas_object_data_get(navi, "delete_button");
+ share_button = (Evas_Object *) evas_object_data_get(navi, "share_button");
+
+ if (done_button)
+ elm_object_disabled_set(done_button, disabled);
+ if (delete_item )
+ elm_object_disabled_set(delete_item, disabled);
+ if (share_button)
+ elm_object_disabled_set(share_button, disabled);
+}
+
+char* ctui_entry_markup_to_utf8_without_spaces(const char *s)
+{
+ PH_TRACE;
+ unsigned int i;
+ char *ret = elm_entry_markup_to_utf8(s);
+
+ if (ret)
+ {
+ unsigned int size = strlen(ret);
+ if (!size)
+ {
+ ret[0] = '\0';
+ return ret;
+ }
+
+ if (isspace(ret[0]))
+ {
+ std::string number_display;
+ for (i = 1; i < size; ++i)
+ {
+ if (!isspace(ret[i]) || !isspace(ret[i - 1]))
+ {
+ number_display.push_back(ret[i]);
+ }
+ }
+ free(ret);
+ ret = strdup(number_display.c_str());
+ }
+ }
+ return ret;
+}
+
+char* ctui_entry_markup_to_utf8(const char *s)
+{
+ PH_TRACE;
+ unsigned int i;
+ char *ret;
+
+ ret = elm_entry_markup_to_utf8(s);
+ p_retvm_if(NULL == ret, NULL, "elm_entry_markup_to_utf8() return NULL");
+
+ for (i = 0; i < strlen(ret); i++)
+ if (' ' != ret[i])
+ return ret;
+
+ ret[0] = '\0';
+ return ret;
+}
+
+void ctui_entry_entry_set(Evas_Object *entry, const char *s)
+{
+ PH_TRACE;
+ char *s_markup;
+ s_markup = elm_entry_utf8_to_markup(s);
+ elm_entry_entry_set(entry, s_markup);
+ free(s_markup);
+}
+
+enum LIST_DETAIL_ITC_TYPE
+{
+ LIST_DETAIL_ITC_ADDRBOOK,
+ LIST_DETAIL_ITC_ADDRBOOK_EDIT,
+ LIST_DETAIL_ITC_ADDRBOOK_NAME,
+ LIST_DETAIL_ITC_ADDRBOOK_NAME_EDIT,
+ LIST_DETAIL_ITC_MAX,
+};
+
+static Elm_Genlist_Item_Class list_detail_itcs[] =
+{
+ {
+ 0, 0, 1, "2text.1icon.9", NULL, NULL,
+ {NULL, NULL, NULL, NULL},
+ },
+ {
+ 0, 0, 1, "2text.2icon.5", NULL, NULL,
+ {NULL, NULL, NULL, NULL},
+ },
+ {
+ 0, 0, 1, "1text.1icon.2", NULL, NULL,
+ {NULL, NULL, NULL, NULL},
+ },
+ {
+ 0, 0, 1, "1text.2icon.2", NULL, NULL,
+ {NULL, NULL, NULL, NULL},
+ },
+};
+
+static void list_detail_addrbook_gl_del(void *data, Evas_Object *obj)
+{
+ PH_TRACE;
+ ct_ab_popup_data *info = (ct_ab_popup_data *) data;
+ p_retm_if(NULL == info, "data is NULL");
+ free(info->name);
+ free(info);
+}
+
+static char* list_detail_addrbook_gl_label_get(void *data, Evas_Object *obj,
+ const char *part)
+{
+ PH_TRACE;
+ ct_ab_popup_data *ab_popup_data = (ct_ab_popup_data *) data;
+ p_retvm_if(NULL == ab_popup_data, NULL, "parameter(ab_popup_data) is NULL");
+
+ if (0 == strcmp(part, "elm.text") || 0 == strcmp(part, "elm.text.2"))
+ {
+ if (0 == ab_popup_data->id)
+ return strdup(T_(CT_GET_TEXT_BASIC, CTTEXT_PHONE));
+ else
+ return SAFE_STRDUP(ab_popup_data->name);
+ }
+ else if (0 == strcmp(part, "elm.text.1"))
+ {
+ char buf[PH_TEXT_MAX_LEN + 1];
+ buf[0] = '\0';
+ ctui_get_account_name_by_address_book_id(ab_popup_data->id, buf,
+ sizeof(buf));
+ if (*buf)
+ return strdup(buf);
+ }
+ return NULL;
+}
+
+static Evas_Object* list_detail_addrbook_gl_icon_get(void *data,
+ Evas_Object *obj, const char *part)
+{
+ PH_TRACE;
+ int selected_id;
+ Evas_Object *radio;
+ Evas_Object *radio_main;
+
+ ct_ab_popup_data *ab_popup_data = (ct_ab_popup_data *) data;
+ p_retvm_if(NULL == ab_popup_data, NULL, "parameter(ab_popup_data) is NULL");
+
+ if (0 == strcmp(part, "elm.icon.1")
+ || ab_popup_data->all_contacts_item == true)
+ {
+ radio = elm_radio_add(obj);
+ p_retvm_if(NULL == radio, NULL, "elm_radio_add() return NULL");
+
+ selected_id = (int) evas_object_data_get(obj, "selected_id");
+ if (-1 == ab_popup_data->id)
+ {
+ evas_object_data_set(obj, "radio_main", radio);
+ }
+ else
+ {
+ radio_main = (Evas_Object *) evas_object_data_get(obj,
+ "radio_main");
+ p_retvm_if(NULL == radio_main, NULL,
+ "evas_object_data_get() return NULL");
+ elm_radio_group_add(radio, radio_main);
+ }
+
+ elm_radio_state_value_set(radio, ab_popup_data->id);
+ if (selected_id == ab_popup_data->id)
+ elm_radio_value_set(radio, selected_id);
+
+ evas_object_size_hint_weight_set(radio, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(radio, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_propagate_events_set(radio, EINA_FALSE);
+
+ return radio;
+ }
+ else if (0 == strcmp(part, "elm.icon") || 0 == strcmp(part, "elm.icon.2"))
+ {
+ char *icon_path;
+ Evas_Object *icon;
+ icon_path = ctui_get_addressbook_icon_path(ab_popup_data->id);
+
+ if (icon_path && *icon_path)
+ {
+ icon = elm_icon_add(obj);
+ p_retvm_if(NULL == icon, NULL, "elm_icon_add() return NULL");
+
+ elm_image_file_set(icon, icon_path, NULL);
+ evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL,
+ 1, 1);
+ free(icon_path);
+ return icon;
+ }
+ }
+ return NULL;
+}
+
+static inline void list_detail_create_itcs()
+{
+ PH_TRACE;
+ list_detail_itcs[LIST_DETAIL_ITC_ADDRBOOK].func.text_get =
+ list_detail_addrbook_gl_label_get;
+ list_detail_itcs[LIST_DETAIL_ITC_ADDRBOOK].func.content_get =
+ list_detail_addrbook_gl_icon_get;
+ list_detail_itcs[LIST_DETAIL_ITC_ADDRBOOK].func.del =
+ list_detail_addrbook_gl_del;
+
+ list_detail_itcs[LIST_DETAIL_ITC_ADDRBOOK_EDIT].func.text_get =
+ list_detail_addrbook_gl_label_get;
+ list_detail_itcs[LIST_DETAIL_ITC_ADDRBOOK_EDIT].func.content_get =
+ list_detail_addrbook_gl_icon_get;
+ list_detail_itcs[LIST_DETAIL_ITC_ADDRBOOK_EDIT].func.del =
+ list_detail_addrbook_gl_del;
+
+ list_detail_itcs[LIST_DETAIL_ITC_ADDRBOOK_NAME].func.text_get =
+ list_detail_addrbook_gl_label_get;
+ list_detail_itcs[LIST_DETAIL_ITC_ADDRBOOK_NAME].func.content_get =
+ list_detail_addrbook_gl_icon_get;
+ list_detail_itcs[LIST_DETAIL_ITC_ADDRBOOK_NAME].func.del =
+ list_detail_addrbook_gl_del;
+
+ list_detail_itcs[LIST_DETAIL_ITC_ADDRBOOK_NAME_EDIT].func.text_get =
+ list_detail_addrbook_gl_label_get;
+ list_detail_itcs[LIST_DETAIL_ITC_ADDRBOOK_NAME_EDIT].func.content_get =
+ list_detail_addrbook_gl_icon_get;
+ list_detail_itcs[LIST_DETAIL_ITC_ADDRBOOK_NAME_EDIT].func.del =
+ list_detail_addrbook_gl_del;
+}
+
+Evas_Object* ctui_addrbook_popup(Evas_Object *parent, Evas_Smart_Cb item_sel_cb,
+ void *sel_cb_data, ct_addrbook_popup_type ab_type)
+{
+ PH_TRACE;
+ int addressbook_id;
+ int addressbook_mode;
+ char *addressbook_name;
+ Evas_Object *genlist;
+ Evas_Object *popup;
+ Elm_Object_Item * item = NULL;
+ ct_ab_popup_data *ab_popup_data;
+ Elm_Genlist_Item_Class *itc, *itc_name, *itc_all_contacts;
+ contacts_error_e err = CONTACTS_ERROR_NONE;
+ contacts_list_h list = NULL;
+
+ list_detail_create_itcs();
+
+ popup = elm_popup_add(parent);
+ p_retvm_if(NULL == popup, NULL, "elm_popup_add() return NULL");
+ elm_object_style_set(popup, "liststyle");
+
+ genlist = elm_genlist_add(popup);
+ p_retvm_if(NULL == genlist, NULL, "elm_genlist_add() return NULL");
+ evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ if (CT_AB_POPUP_TYPE_LIST_VIEW == ab_type)
+ {
+ ct_list_data *clist_d = (ct_list_data *) sel_cb_data;
+
+ itc = &list_detail_itcs[LIST_DETAIL_ITC_ADDRBOOK_EDIT];
+ itc_name = &list_detail_itcs[LIST_DETAIL_ITC_ADDRBOOK_NAME_EDIT];
+ itc_all_contacts = &list_detail_itcs[LIST_DETAIL_ITC_ADDRBOOK_NAME];
+
+ if (CT_GET_LIST_PERSON_OF_ADDRBOOK_ID == clist_d->list_op)
+ evas_object_data_set(genlist, "selected_id",
+ (void *) clist_d->base_ab);
+ else
+ evas_object_data_set(genlist, "selected_id", (void *) -1);
+
+ /* All contacts */
+ ab_popup_data = (ct_ab_popup_data *) calloc(1,
+ sizeof(ct_ab_popup_data));
+ p_retvm_if(NULL == ab_popup_data, NULL, "calloc() return NULL");
+ ab_popup_data->id = -1;
+ ab_popup_data->name = strdup(
+ T_(CT_GET_TEXT_BASIC, CTTEXT_ALL_CONTACTS));
+ ab_popup_data->all_contacts_item = true;
+
+ item = elm_genlist_item_append(genlist, itc_all_contacts, ab_popup_data,
+ NULL, ELM_GENLIST_ITEM_NONE, item_sel_cb, sel_cb_data);
+ ab_popup_data->item = item;
+
+ }
+ else
+ {
+ itc = &list_detail_itcs[LIST_DETAIL_ITC_ADDRBOOK];
+ itc_name = &list_detail_itcs[LIST_DETAIL_ITC_ADDRBOOK_NAME];
+ }
+
+ err = (contacts_error_e) contacts_db_get_all_records(
+ _contacts_address_book._uri, 0, 0, &list);
+ while (CONTACTS_ERROR_NONE == err)
+ {
+ phone_cts_get_int_from_list(list, _contacts_address_book.mode,
+ &addressbook_mode);
+ if (addressbook_mode == CONTACTS_ADDRESS_BOOK_MODE_READONLY
+ && CT_AB_POPUP_TYPE_LIST_VIEW != ab_type)
+ {
+ err = (contacts_error_e) contacts_list_next(list);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_list_next() Failed(%d)", err);
+ continue;
+ }
+
+ ab_popup_data = (ct_ab_popup_data *) calloc(1,
+ sizeof(ct_ab_popup_data));
+ if (NULL == ab_popup_data)
+ {
+ ERR("calloc() return NULL");
+ continue;
+ }
+
+ err = phone_cts_get_int_from_list(list, _contacts_address_book.id,
+ &addressbook_id);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "phone_cts_get_int_from_list() Failed(%d)", err);
+ err = phone_cts_get_str_from_list(list, _contacts_address_book.name,
+ &addressbook_name);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "phone_cts_get_int_from_list() Failed(%d)", err);
+
+ ab_popup_data->id = addressbook_id;
+ ab_popup_data->mode = addressbook_mode;
+ ab_popup_data->name = addressbook_name;
+
+ if (0 == ab_popup_data->id)
+ {
+ item = elm_genlist_item_append(genlist, itc_name, ab_popup_data,
+ NULL, ELM_GENLIST_ITEM_NONE, item_sel_cb, sel_cb_data);
+ }
+ else
+ {
+ item = elm_genlist_item_append(genlist, itc, ab_popup_data, NULL,
+ ELM_GENLIST_ITEM_NONE, item_sel_cb, sel_cb_data);
+ }
+
+ ab_popup_data->item = item;
+
+ err = (contacts_error_e) contacts_list_next(list);
+ p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_list_next() Failed(%d)",
+ err);
+ }
+
+ err = (contacts_error_e) contacts_list_destroy(list, true);
+ p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_list_destroy() Failed(%d)",
+ err);
+
+ elm_object_content_set(popup, genlist);
+ evas_object_show(popup);
+ return popup;
+}
+
+void ctui_list_ug_hide_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ ug_destroy_me((ui_gadget_h) data);
+}
+
diff --git a/lib/common/ct-list-view-common.cpp b/lib/common/ct-list-view-common.cpp
new file mode 100755
index 0000000..5f3898c
--- /dev/null
+++ b/lib/common/ct-list-view-common.cpp
@@ -0,0 +1,5523 @@
+/*
+ * 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 _GNU_SOURCE
+#define _GNU_SOURCE // for strcasestr
+#endif
+
+#include <aul.h>
+#include <string.h>
+#include <ui-gadget-module.h>
+#include <unicode/ulocdata.h>
+#include <unicode/uset.h>
+#include <unicode/ustring.h>
+#include <vconf.h>
+#include <vconf-keys.h>
+#include <efl_assist.h>
+#include "ct-list.h"
+
+#include "ct-list-view-common.h"
+#include "ct-group-assign-popup.h"
+#include "phone.h"
+#include "phone-common.h"
+#include "ct-list.h"
+#include <string>
+
+
+#define DEFAULT "default"
+#define NUMBER_LIST "number list"
+#define PERSON_INFO "person_info"
+#define DEFAULT_NUMBER "Default number"
+#define SEND_NAMECARD "Send namecard"
+#define CHANGED "changed"
+#define CONTACTS_NAME_CARD "Contacts name card"
+#define SCROLL_DRAG_START "scroll,drag,start"
+#define SCROLL_DRAG_STOP "scroll,drag,stop"
+#define LONGPRESSED "longpressed"
+#define NO_INIT 0
+
+#define POPUP_CLOSING_DELAY 0.5
+
+static char pre_search_str[CT_LIST_MAX_SEARCH_STR];
+
+static void list_get_number_str(int id, char *buf, int buf_len);
+void list_searchbar_data_set(void *data);
+void list_searchbar_back_button_cb(void *data);
+bool find_number_person_list(ct_person_list *person_info,const std::string &search_str);
+static void list_update_person_info_check_status(Eina_List *list,Eina_List *list_check);
+void ctui_list_searchbar_cancel_cb(void *data, Evas_Object *obj,void *event_info);
+void disable_count_item(ct_list_data *clist_d);
+void clear_genlist_info(ct_list_data &clist_d);
+static void ct_clear_contacts_text_data(ct_send_as_text_data* p_contact_text_data);
+void show_fast_index(ct_list_data *clist_d)
+{
+ PH_TRACE;
+ if (clist_d->fast_index)
+ {
+ evas_object_show(clist_d->fast_index);
+ elm_object_disabled_set(clist_d->fast_index, EINA_FALSE);
+ }
+}
+void hide_fast_index(ct_list_data *clist_d)
+{
+ PH_TRACE;
+ if (clist_d->fast_index)
+ {
+ evas_object_hide(clist_d->fast_index);
+ elm_object_disabled_set(clist_d->fast_index, EINA_TRUE);
+ }
+}
+void clear_fast_index(ct_list_data *clist_d)
+{
+ PH_TRACE;
+ elm_index_item_clear(clist_d->fast_index);
+}
+
+ct_person_list *find_info_in_list_by_id(Eina_List *check_list, int person_id)
+{
+ PH_TRACE;
+ Eina_List *l = NULL;
+ void *v_person_info = NULL;
+
+ EINA_LIST_FOREACH(check_list, l, v_person_info)
+ {
+ ct_person_list *person_info = (ct_person_list *) v_person_info;
+ if (NULL != person_info && person_info->id == person_id)
+ {
+ return person_info;
+ }
+ }
+ return NULL;
+}
+
+static void ctui_list_free_person_info(ct_person_list *person_info)
+{
+ PH_TRACE;
+
+ p_retm_if(!person_info, "person_info is NULL");
+ eina_list_free(person_info->addressbook_id_list);
+ free(person_info->img_path);
+ free(person_info->display);
+ free(person_info->display_index);
+ free(person_info->number);
+ free(person_info->status_str);
+ if (person_info->number_list)
+ {
+ ctui_free_record_list(person_info->number_list);
+ }
+ if (person_info->email_list)
+ {
+ ctui_free_record_list(person_info->email_list);
+ }
+ if (person_info->contact)
+ {
+ contacts_record_destroy(person_info->contact, true);
+ }
+ free(person_info);
+}
+
+void ctui_list_free_contacts(Eina_List* list)
+{
+ PH_TRACE;
+
+ Eina_List* l;
+ void *info;
+ if (!list)
+ {
+ return;
+ }
+
+ EINA_LIST_FOREACH(list, l, info)
+ {
+ ct_person_list *person_info = (ct_person_list *) info;
+ if (person_info)
+ {
+ ctui_list_free_person_info(person_info);
+ }
+ }
+ eina_list_free(list);
+}
+
+void list_set_person_info(Eina_List* list, Eina_List ** list_search)
+{
+ PH_TRACE;
+ if (list == NULL || list_search == NULL)
+ {
+ return;
+ }
+
+ Eina_List* l;
+ void *info;
+
+ EINA_LIST_FOREACH(list, l, info)
+ {
+ ct_person_list *person_info_list = (ct_person_list *) info;
+ if (person_info_list != NULL)
+ {
+ *list_search = eina_list_append(*list_search,(void *) person_info_list);
+ }
+ }
+}
+
+void ctui_list_free_index(Eina_List* list)
+{
+ PH_TRACE;
+ Eina_List* l;
+ void *v_data;
+
+ EINA_LIST_FOREACH(list, l, v_data)
+ {
+ ct_list_index_data *data = (ct_list_index_data *) v_data;
+ if (data)
+ {
+ free(data);
+ }
+ }
+ eina_list_free(list);
+}
+
+static inline int list_get_grp_person_id(Eina_List *list)
+{
+ PH_TRACE;
+ ct_person_list *person_info;
+ if (NULL == list)
+ return 0;
+ person_info = (ct_person_list *) list->data;
+ return person_info->id;
+}
+
+static contacts_filter_h list_create_filter_int(contacts_filter_h filter,
+ const char *view_uri, int property_id, contacts_match_int_flag_e flag,
+ int match_value)
+{
+ PH_TRACE;
+ contacts_error_e err = CONTACTS_ERROR_NONE;
+
+ if (NULL == filter)
+ {
+ err = (contacts_error_e) contacts_filter_create(view_uri, &filter);
+ p_retvm_if(CONTACTS_ERROR_NONE != err, NULL,
+ "contacts_filter_create() Failed(%d)", err);
+ }
+ else
+ {
+ err = (contacts_error_e) contacts_filter_add_operator(filter,
+ CONTACTS_FILTER_OPERATOR_AND);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_filter_add_operator() Failed(%d)", err);
+ }
+
+ err = (contacts_error_e) contacts_filter_add_int(filter, property_id, flag,
+ match_value);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_filter_add_int() Failed(%d)", err);
+
+ return filter;
+}
+
+static contacts_filter_h list_create_filter_bool(contacts_filter_h filter,
+ const char *view_uri, int property_id, contacts_match_int_flag_e flag,
+ bool match_value)
+{
+ PH_TRACE;
+ contacts_error_e err = CONTACTS_ERROR_NONE;
+
+ if (NULL == filter)
+ {
+ err = (contacts_error_e) contacts_filter_create(view_uri, &filter);
+ p_retvm_if(CONTACTS_ERROR_NONE != err, NULL,
+ "contacts_filter_create() Failed(%d)", err);
+ }
+ else
+ {
+ err = (contacts_error_e) contacts_filter_add_operator(filter,
+ CONTACTS_FILTER_OPERATOR_AND);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_filter_add_operator() Failed(%d)", err);
+ }
+
+ err = (contacts_error_e) contacts_filter_add_bool(filter, property_id,
+ match_value);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_filter_add_int() Failed(%d)", err);
+
+ return filter;
+}
+
+//TODO: requires decomposition
+int ct_list_get_contacts(ct_list_data *clist_d, Eina_List **list_out)
+{
+ PH_TRACE;
+ unsigned int count = 0;
+ int person_id;
+ int grp_person_id;
+
+ unsigned int person_contact_projection[] = {
+ _contacts_person_contact.person_id, _contacts_person_contact.status,
+ _contacts_person_contact.display_name,
+ _contacts_person_contact.display_name_index,
+ _contacts_person_contact.addressbook_ids, };
+ unsigned int person_grouprel_projection[] = {
+ _contacts_person_grouprel.person_id,
+ _contacts_person_grouprel.status,
+ _contacts_person_grouprel.display_name,
+ _contacts_person_grouprel.display_name_index,
+ _contacts_person_grouprel.addressbook_ids, };
+ unsigned int person_projection[] = { _contacts_person.id,
+ _contacts_person.status, _contacts_person.display_name,
+ _contacts_person.display_name_index,
+ _contacts_person.addressbook_ids, };
+
+ const char *view_uri = NULL;
+ contacts_error_e err = CONTACTS_ERROR_NONE;
+ contacts_list_h list = NULL;
+ contacts_query_h query = NULL;
+ contacts_filter_h filter = NULL;
+ contacts_filter_h filter2 = NULL;
+
+ Eina_List *result = NULL;
+
+ p_retvm_if(NULL == list_out, CONTACTS_ERROR_INTERNAL,
+ "parameter(list_out) is NULL");
+ *list_out = NULL;
+
+ PH_DBG("clist_d->list_op : %d", clist_d->list_op);
+ switch (clist_d->list_op)
+ {
+ case CT_GET_LIST_ALL_PERSON:
+ view_uri = _contacts_person._uri;
+ if (clist_d->search_str && *clist_d->search_str)
+ {
+ err = (contacts_error_e) contacts_db_search_records(
+ _contacts_person._uri, clist_d->search_str, 0, 0,
+ &list);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_db_search_records() Failed(%d)", err);
+ }
+ else
+ {
+ err = (contacts_error_e) contacts_db_get_all_records(
+ _contacts_person._uri, 0, 0, &list);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_db_get_all_records() Failed(%d)", err);
+ }
+ break;
+ case CT_GET_LIST_ALL_PERSON_HAD_NUMBER:
+ view_uri = _contacts_person._uri;
+
+ err = (contacts_error_e) contacts_query_create(
+ _contacts_person._uri, &query);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+ do
+ {
+ filter = list_create_filter_bool(filter, _contacts_person._uri,
+ _contacts_person.has_phonenumber, CONTACTS_MATCH_EQUAL,
+ true);
+ if (CONTACTS_ERROR_NONE
+ != (err = (contacts_error_e) contacts_query_set_filter(
+ query, filter)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_query_set_projection(
+ query, person_projection,
+ sizeof(person_projection) / sizeof(int))))
+ break;
+ if (clist_d->search_str && *clist_d->search_str)
+ {
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_db_search_records_with_query(
+ query, clist_d->search_str, 0, 0,
+ &list)))
+ break;
+ }
+ else
+ {
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_db_get_records_with_query(
+ query, 0, 0, &list)))
+ break;
+ }
+ }
+ while (0);
+
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+ contacts_filter_destroy(filter);
+ contacts_query_destroy(query);
+
+ break;
+ case CT_GET_LIST_ALL_PERSON_HAD_EMAIL:
+ view_uri = _contacts_person._uri;
+
+ err = (contacts_error_e) contacts_query_create(
+ _contacts_person._uri, &query);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+
+ do
+ {
+ filter = list_create_filter_bool(filter, _contacts_person._uri,
+ _contacts_person.has_email, CONTACTS_MATCH_EQUAL, true);
+ if (CONTACTS_ERROR_NONE
+ != (err = (contacts_error_e) contacts_query_set_filter(
+ query, filter)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_query_set_projection(
+ query, person_projection,
+ sizeof(person_projection) / sizeof(int))))
+ break;
+ if (clist_d->search_str && *clist_d->search_str)
+ {
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_db_search_records_with_query(
+ query, clist_d->search_str, 0, 0,
+ &list)))
+ break;
+ }
+ else
+ {
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_db_get_records_with_query(
+ query, 0, 0, &list)))
+ break;
+ }
+ }
+ while (0);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+
+ contacts_filter_destroy(filter);
+ contacts_query_destroy(query);
+
+ break;
+
+ case CT_GET_LIST_ALL_PERSON_HAD_NUMBER_OR_EMAIL:
+ view_uri = _contacts_person._uri;
+
+ err = (contacts_error_e) contacts_query_create(
+ _contacts_person._uri, &query);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+
+ do
+ {
+ filter = list_create_filter_bool(filter, _contacts_person._uri,
+ _contacts_person.has_phonenumber, CONTACTS_MATCH_EQUAL,
+ true);
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_filter_add_operator(
+ filter, CONTACTS_FILTER_OPERATOR_OR)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err = (contacts_error_e) contacts_filter_add_bool(
+ filter, _contacts_person.has_email, true)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err = (contacts_error_e) contacts_query_set_filter(
+ query, filter)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_query_set_projection(
+ query, person_projection,
+ sizeof(person_projection) / sizeof(int))))
+ break;
+ if (clist_d->search_str && *clist_d->search_str)
+ {
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_db_search_records_with_query(
+ query, clist_d->search_str, 0, 0,
+ &list)))
+ break;
+ }
+ else
+ {
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_db_get_records_with_query(
+ query, 0, 0, &list)))
+ break;
+ }
+ }
+ while (0);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+
+ contacts_filter_destroy(filter);
+ contacts_query_destroy(query);
+
+ break;
+ case CT_GET_LIST_PERSON_OF_ADDRBOOK_ID:
+ view_uri = _contacts_person_contact._uri;
+
+ err = (contacts_error_e) contacts_query_create(
+ _contacts_person_contact._uri, &query);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+
+ do
+ {
+ filter = list_create_filter_int(NULL,
+ _contacts_person_contact._uri,
+ _contacts_person_contact.address_book_id,
+ CONTACTS_MATCH_EQUAL, clist_d->base_ab);
+ if (CONTACTS_ERROR_NONE
+ != (err = (contacts_error_e) contacts_query_set_filter(
+ query, filter)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_query_set_distinct(
+ query, true)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_query_set_projection(
+ query, person_contact_projection,
+ sizeof(person_contact_projection)
+ / sizeof(int))))
+ break;
+ if (clist_d->search_str && *clist_d->search_str)
+ {
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_db_search_records_with_query(
+ query, clist_d->search_str, 0, 0,
+ &list)))
+ break;
+ }
+ else
+ {
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_db_get_records_with_query(
+ query, 0, 0, &list)))
+ break;
+ }
+ }
+ while (0);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+
+ contacts_filter_destroy(filter);
+ contacts_query_destroy(query);
+
+ break;
+
+ case CT_GET_LIST_PERSON_OF_WRITABLE_ADDRBOOK_ID:
+ view_uri = _contacts_person_contact._uri;
+
+ err = (contacts_error_e) contacts_query_create(
+ _contacts_person_contact._uri, &query);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+
+ do
+ {
+ filter = list_create_filter_int(NULL,
+ _contacts_person_contact._uri,
+ _contacts_person_contact.address_book_mode,
+ CONTACTS_MATCH_EQUAL, CONTACTS_ADDRESS_BOOK_MODE_NONE);
+ if (CONTACTS_ERROR_NONE
+ != (err = (contacts_error_e) contacts_query_set_filter(
+ query, filter)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_query_set_distinct(
+ query, true)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_query_set_projection(
+ query, person_contact_projection,
+ sizeof(person_contact_projection)
+ / sizeof(int))))
+ break;
+ if (clist_d->search_str && *clist_d->search_str)
+ {
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_db_search_records_with_query(
+ query, clist_d->search_str, 0, 0,
+ &list)))
+ break;
+ }
+ else
+ {
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_db_get_records_with_query(
+ query, 0, 0, &list)))
+ break;
+ }
+ }
+ while (0);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+
+ contacts_filter_destroy(filter);
+ contacts_query_destroy(query);
+
+ break;
+
+ case CT_GET_LIST_PERSON_HAD_NUMBER_OF_ADDRBOOK_ID:
+ view_uri = _contacts_person_contact._uri;
+
+ err = (contacts_error_e) contacts_query_create(
+ _contacts_person_contact._uri, &query);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+
+ do
+ {
+ filter = list_create_filter_int(NULL,
+ _contacts_person_contact._uri,
+ _contacts_person_contact.address_book_id,
+ CONTACTS_MATCH_EQUAL, clist_d->base_ab);
+ filter = list_create_filter_bool(filter,
+ _contacts_person_contact._uri,
+ _contacts_person_contact.has_phonenumber,
+ CONTACTS_MATCH_EQUAL, true);
+ if (CONTACTS_ERROR_NONE
+ != (err = (contacts_error_e) contacts_query_set_filter(
+ query, filter)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_query_set_distinct(
+ query, true)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_query_set_projection(
+ query, person_contact_projection,
+ sizeof(person_contact_projection)
+ / sizeof(int))))
+ break;
+ if (clist_d->search_str && *clist_d->search_str)
+ {
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_db_search_records_with_query(
+ query, clist_d->search_str, 0, 0,
+ &list)))
+ break;
+ }
+ else
+ {
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_db_get_records_with_query(
+ query, 0, 0, &list)))
+ break;
+ }
+ }
+ while (0);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+ contacts_filter_destroy(filter);
+ contacts_query_destroy(query);
+
+ break;
+ case CT_GET_LIST_PERSON_HAD_EMAIL_OF_ADDRBOOK_ID:
+ view_uri = _contacts_person_contact._uri;
+
+ err = (contacts_error_e) contacts_query_create(
+ _contacts_person_contact._uri, &query);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+
+ do
+ {
+ filter = list_create_filter_int(NULL,
+ _contacts_person_contact._uri,
+ _contacts_person_contact.address_book_id,
+ CONTACTS_MATCH_EQUAL, clist_d->base_ab);
+ filter = list_create_filter_bool(filter,
+ _contacts_person_contact._uri,
+ _contacts_person_contact.has_email,
+ CONTACTS_MATCH_EQUAL, true);
+ if (CONTACTS_ERROR_NONE
+ != (err = (contacts_error_e) contacts_query_set_filter(
+ query, filter)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_query_set_distinct(
+ query, true)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_query_set_projection(
+ query, person_contact_projection,
+ sizeof(person_contact_projection)
+ / sizeof(int))))
+ break;
+ if (clist_d->search_str && *clist_d->search_str)
+ {
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_db_search_records_with_query(
+ query, clist_d->search_str, 0, 0,
+ &list)))
+ break;
+ }
+ else
+ {
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_db_get_records_with_query(
+ query, 0, 0, &list)))
+ break;
+ }
+ }
+ while (0);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+ contacts_filter_destroy(filter);
+ contacts_query_destroy(query);
+ break;
+ case CT_GET_LIST_PERSON_HAD_NUMBER_OR_EMAIL_OF_ADDRBOOK_ID:
+ view_uri = _contacts_person_contact._uri;
+
+ err = (contacts_error_e) contacts_query_create(
+ _contacts_person_contact._uri, &query);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+
+ do
+ {
+ filter = list_create_filter_int(NULL,
+ _contacts_person_contact._uri,
+ _contacts_person_contact.address_book_id,
+ CONTACTS_MATCH_EQUAL, clist_d->base_ab);
+ filter2 = list_create_filter_bool(NULL,
+ _contacts_person_contact._uri,
+ _contacts_person_contact.has_phonenumber,
+ CONTACTS_MATCH_EQUAL, true);
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_filter_add_operator(
+ filter2, CONTACTS_FILTER_OPERATOR_OR)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err = (contacts_error_e) contacts_filter_add_bool(
+ filter2, _contacts_person_contact.has_email,
+ true)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_filter_add_operator(
+ filter, CONTACTS_FILTER_OPERATOR_AND)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err = (contacts_error_e) contacts_filter_add_filter(
+ filter, filter2)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err = (contacts_error_e) contacts_query_set_filter(
+ query, filter)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_query_set_projection(
+ query, person_contact_projection,
+ sizeof(person_contact_projection)
+ / sizeof(int))))
+ break;
+
+ if (clist_d->search_str && *clist_d->search_str)
+ {
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_db_search_records_with_query(
+ query, clist_d->search_str, 0, 0,
+ &list)))
+ break;
+ }
+ else
+ {
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_db_get_records_with_query(
+ query, 0, 0, &list)))
+ break;
+ }
+ }
+ while (0);
+
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+ contacts_filter_destroy(filter);
+ contacts_filter_destroy(filter2);
+ contacts_query_destroy(query);
+
+ break;
+ case CT_GET_LIST_PERSON_OF_GROUP_ID:
+ view_uri = _contacts_person_grouprel._uri;
+
+ err = (contacts_error_e) contacts_query_create(
+ _contacts_person_grouprel._uri, &query);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+
+ do
+ {
+ filter = list_create_filter_int(filter,
+ _contacts_person_grouprel._uri,
+ _contacts_person_grouprel.group_id,
+ CONTACTS_MATCH_EQUAL, clist_d->base_grp);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+ if (CONTACTS_ERROR_NONE
+ != (err = (contacts_error_e) contacts_query_set_filter(
+ query, filter)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_query_set_distinct(
+ query, true)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_query_set_projection(
+ query, person_grouprel_projection,
+ sizeof(person_grouprel_projection)
+ / sizeof(int))))
+ break;
+ if (clist_d->search_str && *clist_d->search_str)
+ {
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_db_search_records_with_query(
+ query, clist_d->search_str, 0, 0,
+ &list)))
+ break;
+ }
+ else
+ {
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_db_get_records_with_query(
+ query, 0, 0, &list)))
+ break;
+ }
+ }
+ while (0);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+
+ contacts_filter_destroy(filter);
+ contacts_query_destroy(query);
+
+ break;
+
+ case CT_GET_LIST_PERSON_HAD_NUMBER_OF_GROUP_ID:
+ view_uri = _contacts_person_grouprel._uri;
+
+ err = (contacts_error_e) contacts_query_create(
+ _contacts_person_grouprel._uri, &query);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+
+ do
+ {
+ filter = list_create_filter_int(NULL,
+ _contacts_person_grouprel._uri,
+ _contacts_person_grouprel.group_id,
+ CONTACTS_MATCH_EQUAL, clist_d->base_grp);
+ filter = list_create_filter_bool(filter,
+ _contacts_person_grouprel._uri,
+ _contacts_person_grouprel.has_phonenumber,
+ CONTACTS_MATCH_EQUAL, true);
+ if (CONTACTS_ERROR_NONE
+ != (err = (contacts_error_e) contacts_query_set_filter(
+ query, filter)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_query_set_distinct(
+ query, true)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_query_set_projection(
+ query, person_grouprel_projection,
+ sizeof(person_grouprel_projection)
+ / sizeof(int))))
+ break;
+ if (clist_d->search_str && *clist_d->search_str)
+ {
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_db_search_records_with_query(
+ query, clist_d->search_str, 0, 0,
+ &list)))
+ break;
+ }
+ else
+ {
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_db_get_records_with_query(
+ query, 0, 0, &list)))
+ break;
+ }
+ }
+ while (0);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+
+ contacts_filter_destroy(filter);
+ contacts_query_destroy(query);
+
+ break;
+ case CT_GET_LIST_PERSON_HAD_EMAIL_OF_GROUP_ID:
+ view_uri = _contacts_person_grouprel._uri;
+
+ err = (contacts_error_e) contacts_query_create(
+ _contacts_person_grouprel._uri, &query);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+
+ do
+ {
+ filter = list_create_filter_int(NULL,
+ _contacts_person_grouprel._uri,
+ _contacts_person_grouprel.group_id,
+ CONTACTS_MATCH_EQUAL, clist_d->base_grp);
+ filter = list_create_filter_bool(filter,
+ _contacts_person_grouprel._uri,
+ _contacts_person_grouprel.has_email,
+ CONTACTS_MATCH_EQUAL, true);
+ if (CONTACTS_ERROR_NONE
+ != (err = (contacts_error_e) contacts_query_set_filter(
+ query, filter)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_query_set_distinct(
+ query, true)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_query_set_projection(
+ query, person_grouprel_projection,
+ sizeof(person_grouprel_projection)
+ / sizeof(int))))
+ break;
+ if (clist_d->search_str && *clist_d->search_str)
+ {
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_db_search_records_with_query(
+ query, clist_d->search_str, 0, 0,
+ &list)))
+ break;
+ }
+ else
+ {
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_db_get_records_with_query(
+ query, 0, 0, &list)))
+ break;
+ }
+ }
+ while (0);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+
+ contacts_filter_destroy(filter);
+ contacts_query_destroy(query);
+
+ break;
+
+ case CT_GET_LIST_PERSON_HAD_NUMBER_OR_EMAIL_OF_GROUP_ID:
+ view_uri = _contacts_person_grouprel._uri;
+
+ err = (contacts_error_e) contacts_query_create(
+ _contacts_person_grouprel._uri, &query);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+
+ do
+ {
+ filter = list_create_filter_int(NULL,
+ _contacts_person_grouprel._uri,
+ _contacts_person_grouprel.group_id,
+ CONTACTS_MATCH_EQUAL, clist_d->base_grp);
+ filter2 = list_create_filter_bool(NULL,
+ _contacts_person_grouprel._uri,
+ _contacts_person_grouprel.has_phonenumber,
+ CONTACTS_MATCH_EQUAL, true);
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_filter_add_operator(
+ filter2, CONTACTS_FILTER_OPERATOR_OR)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err = (contacts_error_e) contacts_filter_add_bool(
+ filter2, _contacts_person_grouprel.has_email,
+ true)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_filter_add_operator(
+ filter, CONTACTS_FILTER_OPERATOR_AND)))
+ break;
+
+ if (CONTACTS_ERROR_NONE
+ != (err = (contacts_error_e) contacts_filter_add_filter(
+ filter, filter2)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err = (contacts_error_e) contacts_query_set_filter(
+ query, filter)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_query_set_distinct(
+ query, true)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_query_set_projection(
+ query, person_grouprel_projection,
+ sizeof(person_grouprel_projection)
+ / sizeof(int))))
+ break;
+ if (clist_d->search_str && *clist_d->search_str)
+ {
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_db_search_records_with_query(
+ query, clist_d->search_str, 0, 0,
+ &list)))
+ break;
+ }
+ else
+ {
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_db_get_records_with_query(
+ query, 0, 0, &list)))
+ break;
+ }
+ }
+ while (0);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+
+ contacts_filter_destroy(filter);
+ contacts_filter_destroy(filter2);
+ contacts_query_destroy(query);
+
+ break;
+
+ case CT_GET_LIST_PERSON_NOT_ASSIGNED_OF_ADDRBOOK_ID:
+ view_uri = _contacts_person_grouprel._uri;
+
+ err = (contacts_error_e) contacts_query_create(
+ _contacts_person_grouprel._uri, &query);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+
+ do
+ {
+ filter = list_create_filter_int(NULL,
+ _contacts_person_grouprel._uri,
+ _contacts_person_grouprel.address_book_id,
+ CONTACTS_MATCH_EQUAL, clist_d->base_ab);
+ filter = list_create_filter_int(filter,
+ _contacts_person_grouprel._uri,
+ _contacts_person_grouprel.group_id, CONTACTS_MATCH_NONE,
+ 0);
+ if (CONTACTS_ERROR_NONE
+ != (err = (contacts_error_e) contacts_query_set_filter(
+ query, filter)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_query_set_distinct(
+ query, true)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_query_set_projection(
+ query, person_grouprel_projection,
+ sizeof(person_grouprel_projection)
+ / sizeof(int))))
+ break;
+ if (clist_d->search_str && *clist_d->search_str)
+ {
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_db_search_records_with_query(
+ query, clist_d->search_str, 0, 0,
+ &list)))
+ break;
+ }
+ else
+ {
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_db_get_records_with_query(
+ query, 0, 0, &list)))
+ break;
+ }
+
+ }
+ while (0);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+ contacts_filter_destroy(filter);
+ contacts_query_destroy(query);
+ break;
+
+ case CT_GET_LIST_PERSON_NOT_ASSIGNED_HAD_NUMBER_OR_EMAIL_OF_ADDRBOOK_ID:
+ view_uri = _contacts_person_grouprel._uri;
+
+ err = (contacts_error_e) contacts_query_create(
+ _contacts_person_grouprel._uri, &query);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+
+ do
+ {
+ filter = list_create_filter_int(NULL,
+ _contacts_person_grouprel._uri,
+ _contacts_person_grouprel.address_book_id,
+ CONTACTS_MATCH_EQUAL, clist_d->base_ab);
+ filter = list_create_filter_int(filter,
+ _contacts_person_grouprel._uri,
+ _contacts_person_grouprel.group_id, CONTACTS_MATCH_NONE,
+ 0);
+ filter2 = list_create_filter_bool(NULL,
+ _contacts_person_grouprel._uri,
+ _contacts_person_grouprel.has_phonenumber,
+ CONTACTS_MATCH_EQUAL, true);
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_filter_add_operator(
+ filter2, CONTACTS_FILTER_OPERATOR_OR)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err = (contacts_error_e) contacts_filter_add_bool(
+ filter2, _contacts_person_grouprel.has_email,
+ true)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_filter_add_operator(
+ filter, CONTACTS_FILTER_OPERATOR_AND)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err = (contacts_error_e) contacts_filter_add_filter(
+ filter, filter2)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err = (contacts_error_e) contacts_query_set_filter(
+ query, filter)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_query_set_distinct(
+ query, true)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_query_set_projection(
+ query, person_grouprel_projection,
+ sizeof(person_grouprel_projection)
+ / sizeof(int))))
+ break;
+ if (clist_d->search_str && *clist_d->search_str)
+ {
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_db_search_records_with_query(
+ query, clist_d->search_str, 0, 0,
+ &list)))
+ break;
+ }
+ else
+ {
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_db_get_records_with_query(
+ query, 0, 0, &list)))
+ break;
+ }
+ }
+ while (0);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+
+ contacts_filter_destroy(filter);
+ contacts_filter_destroy(filter2);
+ contacts_query_destroy(query);
+
+ break;
+ case CT_GET_LIST_PERSON_NOT_ASSIGNED_HAD_EMAIL_OF_ADDRBOOK_ID:
+ view_uri = _contacts_person_grouprel._uri;
+
+ err = (contacts_error_e) contacts_query_create(
+ _contacts_person_grouprel._uri, &query);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+
+ do
+ {
+ filter = list_create_filter_int(NULL,
+ _contacts_person_grouprel._uri,
+ _contacts_person_grouprel.address_book_id,
+ CONTACTS_MATCH_EQUAL, clist_d->base_ab);
+ filter = list_create_filter_int(filter,
+ _contacts_person_grouprel._uri,
+ _contacts_person_grouprel.group_id, CONTACTS_MATCH_NONE,
+ 0);
+ filter = list_create_filter_bool(filter,
+ _contacts_person_grouprel._uri,
+ _contacts_person_grouprel.has_email,
+ CONTACTS_MATCH_EQUAL, true);
+ if (CONTACTS_ERROR_NONE
+ != (err = (contacts_error_e) contacts_query_set_filter(
+ query, filter)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_query_set_distinct(
+ query, true)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_query_set_projection(
+ query, person_grouprel_projection,
+ sizeof(person_grouprel_projection)
+ / sizeof(int))))
+ break;
+ if (clist_d->search_str && *clist_d->search_str)
+ {
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_db_search_records_with_query(
+ query, clist_d->search_str, 0, 0,
+ &list)))
+ break;
+ }
+ else
+ {
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_db_get_records_with_query(
+ query, 0, 0, &list)))
+ break;
+ }
+ }
+ while (0);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+
+ contacts_filter_destroy(filter);
+ contacts_query_destroy(query);
+
+ break;
+ case CT_GET_LIST_PERSON_NOT_ASSIGNED_HAD_NUMBER_OF_ADDRBOOK_ID:
+ view_uri = _contacts_person_grouprel._uri;
+
+ err = (contacts_error_e) contacts_query_create(
+ _contacts_person_grouprel._uri, &query);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+
+ do
+ {
+ filter = list_create_filter_int(NULL,
+ _contacts_person_grouprel._uri,
+ _contacts_person_grouprel.address_book_id,
+ CONTACTS_MATCH_EQUAL, clist_d->base_ab);
+ filter = list_create_filter_int(filter,
+ _contacts_person_grouprel._uri,
+ _contacts_person_grouprel.group_id, CONTACTS_MATCH_NONE,
+ 0);
+ filter = list_create_filter_bool(filter,
+ _contacts_person_grouprel._uri,
+ _contacts_person_grouprel.has_phonenumber,
+ CONTACTS_MATCH_EQUAL, true);
+ if (CONTACTS_ERROR_NONE
+ != (err = (contacts_error_e) contacts_query_set_filter(
+ query, filter)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_query_set_distinct(
+ query, true)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_query_set_projection(
+ query, person_grouprel_projection,
+ sizeof(person_grouprel_projection)
+ / sizeof(int))))
+ break;
+ if (clist_d->search_str && *clist_d->search_str)
+ {
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_db_search_records_with_query(
+ query, clist_d->search_str, 0, 0,
+ &list)))
+ break;
+ }
+ else
+ {
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_db_get_records_with_query(
+ query, 0, 0, &list)))
+ break;
+ }
+ }
+ while (0);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_query_create() Failed(%d)", err);
+
+ contacts_filter_destroy(filter);
+ contacts_query_destroy(query);
+ break;
+ default:
+ ERR("Invalid op");
+ return CONTACTS_ERROR_INTERNAL;
+ }
+ PH_DBG("end cotnacts_db_get_list, start while");
+
+ clist_d->cnt_list_total = 0;
+
+ // group - add member
+ p_retvm_if(NULL == list, CONTACTS_ERROR_INTERNAL, "list is NULL");
+
+ err = (contacts_error_e) contacts_list_get_count(list, &count);
+ p_retvm_if(CONTACTS_ERROR_NONE != err, CONTACTS_ERROR_INTERNAL,
+ "contacts_list_get_count() Failed(%d)", err);
+ p_retvm_if(0 == count, CONTACTS_ERROR_NO_DATA, "list is empty");
+
+ while (err == (contacts_error_e) CONTACTS_ERROR_NONE)
+ {
+ ct_person_list *person_info;
+ char *temp_addressbooks = NULL;
+
+ if (0 == strcmp(_contacts_person_contact._uri, view_uri))
+ err = (contacts_error_e) phone_cts_get_int_from_list(list,
+ _contacts_person_contact.person_id, &person_id);
+ else
+ err = (contacts_error_e) phone_cts_get_int_from_list(list,
+ _contacts_person.id, &person_id);
+
+ if (person_id == clist_d->selected_person_id)
+ {
+ contacts_list_next(list);
+ continue;
+ }
+
+ Eina_List *l = NULL;
+ Eina_List *list_grp_person = NULL;
+ if (clist_d->list_grp_person && *clist_d->list_grp_person)
+ {
+ list_grp_person = *clist_d->list_grp_person;
+ }
+ bool check = false;
+ void *v_data = NULL;
+
+ EINA_LIST_FOREACH(list_grp_person, l, v_data)
+ {
+ ct_person_list *data = (ct_person_list *) v_data;
+ if (data)
+ {
+ grp_person_id = data->id;
+ PH_DBG("add member : grp_person_id =%d,person_id =%d",
+ grp_person_id, person_id);
+ if (grp_person_id && grp_person_id == person_id)
+ {
+ contacts_list_next(list);
+ check = true;
+ break;
+ }
+ }
+ else
+ ERR("list_grp_person' data is null");
+ }
+ if (check)
+ continue;
+
+ person_info = (ct_person_list*) calloc(1, sizeof(ct_person_list));
+ if (NULL == person_info)
+ {
+ ERR("calloc() return NULL");
+ break;
+ }
+ person_info->id = person_id;
+ if (0 == strcmp(_contacts_person_contact._uri, view_uri))
+ {
+ err = (contacts_error_e) phone_cts_get_str_from_list(list,
+ _contacts_person_contact.status,
+ &(person_info->status_str));
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "phone_cts_get_str_from_list() Failed(%d)", err);
+ err = (contacts_error_e) phone_cts_get_str_from_list(list,
+ _contacts_person_contact.display_name,
+ &(person_info->display));
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "phone_cts_get_str_from_list() Failed(%d)", err);
+ err = (contacts_error_e) phone_cts_get_str_from_list(list,
+ _contacts_person_contact.display_name_index,
+ &(person_info->display_index));
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "phone_cts_get_str_from_list() Failed(%d)", err);
+ err = (contacts_error_e) phone_cts_get_str_from_list(list,
+ _contacts_person_contact.addressbook_ids,
+ &temp_addressbooks);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "phone_cts_get_str_from_list() Failed(%d)", err);
+ person_info->addressbook_id_list = ctui_get_addressbook_id_list(
+ temp_addressbooks, " ");
+ }
+ else
+ {
+ err = (contacts_error_e) phone_cts_get_str_from_list(list,
+ _contacts_person.status, &(person_info->status_str));
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "phone_cts_get_str_from_list() Failed(%d)", err);
+ err = (contacts_error_e) phone_cts_get_str_from_list(list,
+ _contacts_person.display_name, &(person_info->display));
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "phone_cts_get_str_from_list() Failed(%d)", err);
+ err = (contacts_error_e) phone_cts_get_int_from_list(list,
+ _contacts_person.link_count, &(person_info->link_count));
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "phone_cts_get_int_from_list() Failed(%d)", err);
+ err = (contacts_error_e) phone_cts_get_str_from_list(list,
+ _contacts_person.display_name_index,
+ &(person_info->display_index));
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "phone_cts_get_str_from_list() Failed(%d)", err);
+ err = (contacts_error_e) phone_cts_get_str_from_list(list,
+ _contacts_person.addressbook_ids, &temp_addressbooks);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "phone_cts_get_str_from_list() Failed(%d)", err);
+ person_info->addressbook_id_list = ctui_get_addressbook_id_list(
+ temp_addressbooks, " ");
+ err = (contacts_error_e) phone_cts_get_bool_from_list(list,
+ _contacts_person.is_favorite, &person_info->is_favourite);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "phone_cts_get_bool_from_list() Failed(%d)", err);
+ }
+
+ result = eina_list_append(result, person_info);
+ clist_d->cnt_list_total++;
+ err = (contacts_error_e) contacts_list_next(list);
+ }
+ *list_out = result;
+ if (CONTACTS_ERROR_NO_DATA != err)
+ {
+ ERR("contacts_list_next() Failed(%d)", err);
+ return err;
+ }
+ return 0;
+}
+
+static inline int list_check_utf8(char c)
+{
+ PH_TRACE;
+ if (c < 128)
+ return 1;
+ else if ((c & 0xe0) == 0xc0)
+ return 2;
+ else if ((c & 0xf0) == 0xe0)
+ return 3;
+ else if ((c & 0xf8) == 0xf0)
+ return 4;
+ else if ((c & 0xfc) == 0xf8)
+ return 5;
+ else if ((c & 0xfe) == 0xfc)
+ return 6;
+ else
+ return CONTACTS_ERROR_INTERNAL;
+}
+
+void ct_list_init_account_data(ct_list_data *clist_d)
+{
+ PH_TRACE;
+ int i = 0;
+ int addressbook_id = 0;
+ bool addressbook_exist = false;
+ ct_ab_map acc_types[CT_MAX_ADDRBOOK];
+ contacts_error_e err = CONTACTS_ERROR_NONE;
+ contacts_list_h list = NULL;
+ char addressbook_name[PH_TEXT_MAX_LEN] = { 0, };
+
+ addressbook_id = ctui_get_view_mode();
+
+ err = (contacts_error_e) contacts_db_get_all_records(
+ _contacts_address_book._uri, 0, 0, &list);
+ while (CONTACTS_ERROR_NONE == err)
+ {
+ err = phone_cts_get_int_from_list(list, _contacts_address_book.id,
+ &(acc_types[i].id));
+ if (CONTACTS_ERROR_NONE != err)
+ {
+ ERR("phone_cts_get_int_from_list() Failed(%d)", err);
+ break;
+ }
+ err = phone_cts_get_int_from_list(list,
+ _contacts_address_book.account_id, &(acc_types[i].account_id));
+ if (CONTACTS_ERROR_NONE != err)
+ {
+ ERR("phone_cts_get_int_from_list() Failed(%d)", err);
+ break;
+ }
+
+ acc_types[i].icon_path = ctui_get_addressbook_icon_path(
+ acc_types[i].id);
+ PH_DBG("icon_path = %s", acc_types[i].icon_path);
+ if (acc_types[i].id == addressbook_id)
+ addressbook_exist = true;
+
+ ctui_get_addressbook_name(acc_types[i].id, addressbook_name,
+ sizeof(addressbook_name));
+ acc_types[i].addressbook_name = strdup(addressbook_name);
+
+ if (++i == sizeof(acc_types) / sizeof(*acc_types))
+ break;
+
+ err = (contacts_error_e) contacts_list_next(list);
+ if (CONTACTS_ERROR_NONE != err)
+ {
+ ERR("contacts_list_next() Failed(%d)", err);
+ break;
+ }
+ }
+ err = (contacts_error_e) contacts_list_destroy(list, true);
+ p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_list_destroy() Failed(%d)",
+ err);
+
+ if (addressbook_exist == false)
+ ctui_set_view_mode(-1);
+
+ if (!clist_d->ug /*&& CT_GET_LIST_ALL_PERSON != clist_d->list_op*/)
+ {
+ addressbook_id = ctui_get_view_mode();
+ if (addressbook_id == -1 && clist_d->list_op > CT_GET_LIST_ALL_PERSON)
+ {
+ clist_d->list_op = CT_GET_LIST_ALL_PERSON;
+ clist_d->base_ab = -1;
+ }
+ }
+
+ if (i == sizeof(acc_types) / sizeof(*acc_types))
+ {
+ ERR("addressbook are too many");
+ i--;
+ }
+ clist_d->acc_types = (ct_ab_map *) realloc(clist_d->acc_types, i * sizeof(ct_ab_map));
+ p_retm_if(NULL == clist_d->acc_types, "realloc() return NULL");
+
+ memcpy(clist_d->acc_types, acc_types, i * sizeof(ct_ab_map));
+ clist_d->acc_count = i;
+}
+
+void ct_list_get_addrbook_icon_path(ct_list_data *clist_d, int addressbook_id,
+ char *dest, int dest_len)
+{
+ PH_TRACE;
+ int i = 0;
+ bool not_found;
+
+ p_retm_if(NULL == dest, "parameter(dest) is NULL");
+ dest[0] = '\0';
+ if (0 == addressbook_id)
+ return;
+ p_retm_if(NULL == clist_d->acc_types, "clist_d->acc_types is NULL");
+
+ not_found = true;
+
+ int count = clist_d->acc_count;
+ for (i = 0; i < count; i++)
+ {
+ if (addressbook_id == clist_d->acc_types[i].account_id)
+ {
+ not_found = false;
+ break;
+ }
+ }
+ p_retm_if(not_found, "invalid id_ab(%d)", addressbook_id);
+
+ if (clist_d->acc_types[i].icon_path && *clist_d->acc_types[i].icon_path)
+ snprintf(dest, dest_len, "%s", clist_d->acc_types[i].icon_path);
+}
+
+static inline void list_clean_ecore_task(ct_list_data *clist_d)
+{
+ PH_TRACE;
+ if (clist_d->list_idler)
+ {
+ ecore_idler_del(clist_d->list_idler);
+ clist_d->list_idler = NULL;
+ }
+
+}
+
+static void list_searchbar_entry_clicked_cb(void *data, Evas_Object *obj,
+ void *event_info)
+{
+ PH_TRACE;
+ ct_list_data *clist_d = (ct_list_data *) data;
+ p_retm_if(NULL == clist_d, "parameter(clist_d) is NULL");
+
+ ctui_list_set_unsweep(clist_d);
+}
+
+static void list_searchbar_clicked_cb(void *data, Evas_Object *obj,
+ const char *emission, const char *source)
+{
+ PH_TRACE;
+ ct_list_data *clist = static_cast<ct_list_data *>(data);
+
+ if (clist == NULL)
+ {
+ return;
+ }
+ list_searchbar_entry_clicked_cb(clist, NULL, NULL);
+}
+
+static char *list_group_label_get(void *data, Evas_Object *obj,
+ const char *part)
+{
+ PH_TRACE;
+ char *group_index = (char *) data;
+ if (0 == strcmp(part, "elm.text") && group_index && *group_index)
+ return strdup(group_index);
+ else
+ return NULL;
+}
+
+static Elm_Genlist_Item_Class group_index =
+{
+ group_index.version,
+ group_index.refcount,
+ group_index.delete_me,
+ group_index.item_style = "grouptitle",
+ group_index.decorate_item_style,
+ group_index.decorate_all_item_style,
+ {group_index.func.text_get = list_group_label_get, },
+};
+
+static Elm_Object_Item *create_item_fast_index(ct_list_data *clist_d,ct_person_list *person_info)
+{
+ PH_TRACE;
+ if (person_info)
+ {
+ ct_list_index_data * index_data = (ct_list_index_data *) calloc(1, sizeof(ct_list_index_data));
+ snprintf(index_data->index, sizeof(index_data->index), "%s", person_info->display_index);
+ index_data->item = elm_index_item_append(clist_d->fast_index, index_data->index, NULL, NULL);
+ clist_d->list_index = eina_list_append(clist_d->list_index, index_data);
+ elm_index_level_go(clist_d->fast_index, 0);
+ return index_data->item;
+ }
+ return NULL;
+}
+void create_fast_index_list_index(ct_list_data *clist_d, ct_person_list *person_info)
+{
+ PH_TRACE;
+ if (person_info)
+ {
+ char cur_index[10] = { 0, };
+
+ if (!person_info->display)
+ snprintf(cur_index, sizeof(cur_index), "#");
+ else
+ snprintf(cur_index, sizeof(cur_index), "%s",person_info->display_index);
+
+ if (strcmp(clist_d->group_index, cur_index))
+ {
+ strcpy(clist_d->group_index, cur_index);
+ Elm_Object_Item *item = elm_genlist_item_append(clist_d->genlist, &group_index, strdup(cur_index), NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
+ elm_genlist_item_select_mode_set(item,ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+ snprintf(clist_d->group_index, sizeof(clist_d->group_index), "%s",cur_index);
+ clist_d->group_item = item;
+
+ Elm_Object_Item * item_index_data = create_item_fast_index(clist_d,person_info);
+ elm_object_item_data_set(item_index_data, item);
+ }
+ }
+}
+static void list_append_item(ct_list_data *clist_d, ct_person_list *person_info)
+{
+ PH_TRACE;
+ Elm_Object_Item * item = NULL;
+
+ if (CT_GET_LIST_VCARD != clist_d->list_op && !(clist_d->search_str && *clist_d->search_str))
+ create_fast_index_list_index(clist_d, person_info);
+
+ contacts_error_e err = CONTACTS_ERROR_NONE;
+ contacts_record_h record = NULL;
+ bool has_phonenumber = false;
+
+ if (!clist_d->vcard_path)
+ {
+ err = (contacts_error_e) contacts_db_get_record(_contacts_person._uri,
+ person_info->id, &record);
+ p_retm_if(CONTACTS_ERROR_NONE != err,
+ "contacts_db_get_record() Failed(%d)", err);
+ err = (contacts_error_e) contacts_record_get_bool(record,
+ _contacts_person.has_phonenumber, &has_phonenumber);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_record_get_bool() Failed(%d)", err);
+ err = (contacts_error_e) contacts_record_destroy(record, true);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_record_destroy() Failed(%d)", err);
+ }
+
+ if (clist_d->search_str && *clist_d->search_str)
+ {
+ if (person_info->phone_number_found == false)
+ item = elm_genlist_item_append(clist_d->genlist,
+ &clist_d->itcs[CT_LIST_ITEM_SEARCH_NO_NUMBER], person_info,
+ NULL, ELM_GENLIST_ITEM_NONE, clist_d->gl_sel,
+ clist_d->gl_sel_data);
+ else
+ item = elm_genlist_item_append(clist_d->genlist,
+ &clist_d->itcs[CT_LIST_ITEM_SEARCH], person_info, NULL,
+ ELM_GENLIST_ITEM_NONE, clist_d->gl_sel,
+ clist_d->gl_sel_data);
+ }
+ else
+ {
+
+ if (person_info->phone_number_found == false)
+ {
+ item = elm_genlist_item_append(clist_d->genlist,
+ &clist_d->itcs[CT_LIST_ITEM_NO_NUMBER], person_info,
+ clist_d->group_item, ELM_GENLIST_ITEM_NONE, clist_d->gl_sel,
+ clist_d->gl_sel_data);
+ }
+ else
+ {
+ item = elm_genlist_item_append(clist_d->genlist,
+ &clist_d->itcs[CT_LIST_ITEM], person_info,
+ clist_d->group_item, ELM_GENLIST_ITEM_NONE, clist_d->gl_sel,
+ clist_d->gl_sel_data);
+ }
+ }
+ person_info->item = item;
+}
+
+#define N 20
+static Eina_Bool list_append_part(void *user_data)
+{
+ PH_TRACE;
+ int i = 0;
+ Eina_List *cursor;
+ ct_list_data *clist_d = (ct_list_data *) user_data;
+ void *info;
+
+ cursor = eina_list_nth_list(clist_d->list, clist_d->readed_n);
+ EINA_LIST_FOREACH(cursor, cursor, info)
+ {
+ ct_person_list *person_info = (ct_person_list *) info;
+ if (i++ == N)
+ break;
+ list_append_item(clist_d, person_info);
+ }
+ if (N < i)
+ {
+ clist_d->readed_n += N;
+ return ECORE_CALLBACK_RENEW;
+ }
+ else
+ {
+ clist_d->list_idler = NULL;
+ disable_count_item(clist_d);
+ clist_d->list_idler = NULL;
+ return ECORE_CALLBACK_CANCEL;
+ }
+}
+
+static bool __list_get_addressbook_name(int addressbook_id, char *buf,
+ int buf_size)
+{
+ PH_TRACE;
+ int addressbook_mode = CONTACTS_ADDRESS_BOOK_MODE_NONE;
+ char *cur_ab;
+ char cur_account_name[200] = { 0, };
+ contacts_error_e err = CONTACTS_ERROR_NONE;
+ contacts_record_h record = NULL;
+
+ p_retvm_if(buf == NULL, false, "out_name in null");
+
+ ctui_get_account_name_by_address_book_id(addressbook_id, cur_account_name,
+ sizeof(cur_account_name));
+ if (addressbook_id > 0)
+ {
+ err = (contacts_error_e) contacts_db_get_record(
+ _contacts_address_book._uri, addressbook_id, &record);
+ p_retvm_if(CONTACTS_ERROR_NONE != err, false,
+ "contacts_db_get_record() Failed(%d)", err);
+
+ err = (contacts_error_e) contacts_record_get_str_p(record,
+ _contacts_address_book.name, &cur_ab);
+ if (err != CONTACTS_ERROR_NONE)
+ {
+ err = (contacts_error_e) contacts_record_destroy(record, true);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_record_destroy() Failed(%d)", err);
+ return false;
+ }
+
+ err = (contacts_error_e) contacts_record_get_int(record,
+ _contacts_address_book.mode, &addressbook_mode);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_record_get_int() Failed(%d)", err);
+
+ if (CONTACTS_ADDRESS_BOOK_MODE_READONLY == addressbook_mode)
+ snprintf(buf, buf_size, "%s", cur_account_name);
+ else
+ snprintf(buf, buf_size, "%s %s", cur_account_name, cur_ab);
+
+ err = (contacts_error_e) contacts_record_destroy(record, true);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_record_destroy() Failed(%d)", err);
+ }
+ else
+ {
+ snprintf(buf, buf_size, "%s", T_(CT_GET_TEXT_BASIC, CTTEXT_PHONE));
+ }
+
+ return true;
+}
+
+void ctui_list_handle_search(ct_list_data &clist_d)
+{
+ PH_TRACE;
+ int i = 0;
+ int readed = 0;
+ Eina_List *cursor;
+ char group_title[PH_TEXT_MAX_LEN];
+ char addressbook_name[PH_TEXT_MAX_LEN];
+ void *info;
+
+ clear_genlist_info(clist_d);
+
+ if (clist_d.list_idler)
+ {
+ ecore_idler_del(clist_d.list_idler);
+ clist_d.list_idler = NULL;
+ }
+
+ if (__list_get_addressbook_name(clist_d.base_ab, addressbook_name,
+ sizeof(addressbook_name)) == true)
+ snprintf(group_title, sizeof(group_title), "%s (%d)", addressbook_name,
+ eina_list_count(clist_d.list));
+ else
+ snprintf(group_title, sizeof(group_title), "%s (%d)",
+ S_(PH_SYS_BODY_CONTACTS), eina_list_count(clist_d.list));
+ DBG("addressbook_name = %s,group_title = %s",addressbook_name,group_title);
+ clist_d.search_group_item = elm_genlist_item_append(clist_d.genlist,
+ &group_index, strdup(group_title), NULL, ELM_GENLIST_ITEM_GROUP,
+ NULL, NULL);
+ elm_genlist_item_select_mode_set(clist_d.search_group_item,
+ ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+
+ list_update_person_info_check_status(clist_d.list,clist_d.list_check_info);
+ clist_d.cnt_checked = eina_list_count(clist_d.list_check_info);
+
+ EINA_LIST_FOREACH(clist_d.list, cursor, info)
+ {
+ ct_person_list *person_info = (ct_person_list *) info;
+
+ if ((clist_d.search_str && *clist_d.search_str))
+ {
+ std::string search_str(clist_d.search_str);
+ person_info->phone_number_found = find_number_person_list(person_info,search_str);
+ }
+
+ if (i++ == N)
+ break;
+ list_append_item(&clist_d, person_info);
+ readed++;
+ }
+ if (N < i)
+ {
+ clist_d.readed_n = readed;
+ clist_d.list_idler = ecore_idler_add(list_append_part, &clist_d);
+ }
+ else
+ {
+ if (!(clist_d.search_str && *clist_d.search_str))
+ disable_count_item(&clist_d);
+ }
+}
+
+static void list_append_all(ct_list_data *clist_d)
+{
+ PH_TRACE;
+ int i = 0;
+ Eina_List *cursor;
+ void *info;
+
+ if (clist_d->list_idler)
+ {
+ ecore_idler_del(clist_d->list_idler);
+ clist_d->list_idler = NULL;
+ }
+
+ if (clist_d->base_ab > -1)
+ {
+ contacts_error_e err = CONTACTS_ERROR_NONE;
+ contacts_record_h record = NULL;
+ Elm_Object_Item * item;
+ int addressbook_mode;
+ char title[400] = { 0, };
+ char cur_account_name[200] = { 0, };
+ char *cur_ab;
+
+ ctui_get_account_name_by_address_book_id(clist_d->base_ab,
+ cur_account_name, sizeof(cur_account_name));
+ if (clist_d->base_ab > 0)
+ {
+ err = (contacts_error_e) contacts_db_get_record(
+ _contacts_address_book._uri, clist_d->base_ab, &record);
+ p_retm_if(CONTACTS_ERROR_NONE != err,
+ "contacts_db_get_record() Failed(%d)", err);
+
+ err = (contacts_error_e) contacts_record_get_str_p(record,
+ _contacts_address_book.name, &cur_ab);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_record_get_str_p() Failed(%d)", err);
+
+ err = (contacts_error_e) contacts_record_get_int(record,
+ _contacts_address_book.mode, &addressbook_mode);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_record_get_int() Failed(%d)", err);
+
+ if (CONTACTS_ADDRESS_BOOK_MODE_READONLY == addressbook_mode)
+ snprintf(title, sizeof(title), "%s", cur_account_name);
+ else
+ snprintf(title, sizeof(title), "%s %s", cur_account_name,
+ cur_ab);
+
+ err = (contacts_error_e) contacts_record_destroy(record, true);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_record_destroy() Failed(%d)", err);
+ }
+ else
+ {
+ snprintf(title, sizeof(title), "%s",
+ T_(CT_GET_TEXT_BASIC, CTTEXT_PHONE));
+ }
+
+ item = elm_genlist_item_append(clist_d->genlist, &group_index,
+ strdup(title), NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
+ elm_genlist_item_select_mode_set(item,
+ ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+ }
+ list_update_person_info_check_status(clist_d->list,clist_d->list_check_info);
+ clist_d->cnt_checked = eina_list_count(clist_d->list_check_info);
+ EINA_LIST_FOREACH(clist_d->list, cursor, info)
+ {
+ ct_person_list *person_info = (ct_person_list *) info;
+ if (i++ == N)
+ break;
+ list_append_item(clist_d, person_info);
+ }
+ if (N < i)
+ {
+ clist_d->readed_n = N;
+ clist_d->list_idler = ecore_idler_add(list_append_part, clist_d);
+ }
+ else
+ disable_count_item(clist_d);
+}
+#undef N
+void clear_genlist_info(ct_list_data &clist_d)
+{
+ elm_genlist_clear(clist_d.genlist);
+ clear_fast_index(&clist_d);
+ clist_d.group_index[0] = '\0';
+ clist_d.group_item = NULL;
+}
+
+void ctui_list_refresh_genlist(ct_list_data *clist_d)
+{
+ PH_TRACE;
+ clear_genlist_info(*clist_d);
+ list_append_all(clist_d);
+}
+
+static void remove_favorite_contacts(Eina_List **list)
+{
+ PH_TRACE;
+ Eina_List *l = NULL;
+ void *info = NULL;
+
+ if (list && *list)
+ {
+ EINA_LIST_FOREACH(*list, l, info)
+ {
+ ct_person_list *person_info = (ct_person_list *) info;
+ if (person_info != NULL && person_info->is_favourite == EINA_TRUE)
+ {
+ *list = eina_list_remove(*list, (void *) person_info);
+ free(person_info);
+ }
+ }
+ }
+}
+
+static void list_update_person_info_check_status(Eina_List *list,
+ Eina_List *list_check)
+{
+ PH_TRACE;
+ void *data = NULL;
+ Eina_List *l = NULL;
+ Eina_List *l_temp = NULL;
+ void *info = NULL;
+
+ p_retm_if(NULL == list, "parameter(list_person) is NULL");
+ p_retm_if(NULL == list_check, "parameter(list_check) is NULL");
+
+ EINA_LIST_FOREACH(list, l, info)
+ {
+ ct_person_list *person_search = (ct_person_list *) info;
+
+ EINA_LIST_FOREACH(list_check, l_temp, data)
+ {
+ ct_person_list *person_info = (ct_person_list *) data;
+ if (person_search != NULL && person_info != NULL && person_search->id == person_info->id)
+ {
+ person_search->checked = true;
+ break;
+ }
+ }
+ }
+}
+
+bool find_number_person_list(ct_person_list *person_info,const std::string &search_str)
+{
+ PH_TRACE;
+ contacts_record_h record = NULL;
+ contacts_record_h record_number = NULL;
+ int recort_id = 0;
+ char *number = NULL;
+ std::string number_display;
+
+ if(person_info == NULL)
+ {
+ return false;
+ }
+
+ if(CONTACTS_ERROR_NONE == (contacts_error_e)contacts_db_get_record(_contacts_person._uri,person_info->id, &record))
+ {
+ if(CONTACTS_ERROR_NONE == (contacts_error_e)contacts_record_get_int(record, _contacts_person.display_contact_id, &recort_id))
+ {
+ contacts_record_destroy(record, true);
+ record = NULL;
+
+ if(CONTACTS_ERROR_NONE == (contacts_error_e)contacts_db_get_record(_contacts_contact._uri, recort_id, &record))
+ {
+ int index = 0;
+ while (CONTACTS_ERROR_NONE == (contacts_error_e)contacts_record_get_child_record_at_p(record,_contacts_contact.number,index++, &record_number))
+ {
+ if(CONTACTS_ERROR_NONE == (contacts_error_e)contacts_record_get_str_p(record_number,_contacts_number.number, &number))
+ {
+ if(number != NULL)
+ {
+ number_display.assign(number);
+ if(number_display.find(search_str) != std::string::npos)
+ {
+ person_info->number_display = strdup(number_display.c_str());
+ contacts_record_destroy(record, true);
+ record = NULL;
+ return true;
+ }
+ }
+ }
+ }
+ }
+ contacts_record_destroy(record, true);
+ record = NULL;
+ }
+ }
+
+ return false;
+}
+
+static void list_searchbar_changed_cb(void *data, Evas_Object *obj,
+ void *event_info)
+{
+ PH_TRACE;
+ Evas_Object *en;
+ Evas_Object *sb = (Evas_Object *) data;
+ ct_list_data *clist_d;
+ char *search_str;
+
+ clist_d = (ct_list_data *) evas_object_data_get(sb, "clist_d");
+ p_retm_if(NULL == sb, "evas_object_data_get() return NULL");
+
+ en = elm_object_part_content_get(sb, "elm.swallow.content");
+ p_retm_if(NULL == en, "elm_object_part_content_get() return NULL");
+
+ p_retm_if(NULL == clist_d->navi, "clist_d->navi() return NULL");
+ ct_list_data *clist_favorite = (ct_list_data *) evas_object_data_get(
+ clist_d->navi, "favor_list_d");
+
+ if (!elm_entry_is_empty(en))
+ elm_object_signal_emit(sb, "elm,state,guidetext,hide", "elm");
+
+ if (elm_object_focus_get(sb))
+ {
+ if (elm_entry_is_empty(en))
+ elm_object_signal_emit(sb, "elm,state,eraser,hide", "elm");
+ else
+ elm_object_signal_emit(sb, "elm,state,eraser,show", "elm");
+ }
+ else
+ {
+ if (elm_entry_is_empty(en))
+ {
+ elm_object_signal_emit(sb, "elm,state,guidetext,show", "elm");
+ elm_object_signal_emit(sb, "elm,state,eraser,hide", "elm");
+ }
+ }
+ search_str = ctui_entry_markup_to_utf8_without_spaces(elm_entry_entry_get(en));
+ p_retm_if(NULL == search_str, "ctui_entry_markup_to_utf8_without_spaces() return NULL");
+
+ if (strlen(search_str) > 0)
+ {
+ if (NULL != clist_d->select_all_layout)
+ {
+ elm_box_unpack(clist_d->box, clist_d->select_all_layout);
+ evas_object_del(clist_d->select_all_layout);
+ clist_d->select_all_layout = NULL;
+ }
+ }
+ else
+ {
+ ctui_list_set_selectall(clist_d);
+ }
+ if (search_str && clist_d->search_str)
+ {
+ if (pre_search_str[0] == '\0' && search_str[0] == '\0')
+ {
+ ct_list_get_contacts(clist_d, &clist_d->list);
+ if (clist_favorite && clist_favorite->list)
+ {
+ remove_favorite_contacts(&clist_d->list);
+ }
+ clist_d->search_str = NULL;
+ elm_genlist_homogeneous_set(clist_d->genlist, EINA_TRUE);
+ elm_genlist_mode_set(clist_d->genlist, ELM_LIST_SCROLL);
+ ctui_list_refresh_genlist(clist_d);
+ }
+ else
+ {
+ if (0 == strcmp(search_str, clist_d->search_str))
+ {
+ free(search_str);
+ return;
+ }
+ }
+ }
+ if ('\0' == search_str[0] && NULL == clist_d->search_str)
+ {
+ if (elm_genlist_decorate_mode_get(clist_d->genlist)&& clist_d->edit_sel_update)
+ clist_d->edit_sel_update(clist_d);
+ free(search_str);
+ return;
+ }
+
+ free(clist_d->search_str);
+ clist_d->search_str = search_str;
+
+ if (strcmp(pre_search_str, search_str))
+ {
+ ct_list_get_contacts(clist_d, &clist_d->list);
+ if (clist_favorite && clist_favorite->list)
+ {
+ remove_favorite_contacts(&clist_d->list);
+ }
+ if (*search_str)
+ {
+ elm_genlist_mode_set(clist_d->genlist, ELM_LIST_COMPRESS);
+ ctui_list_handle_search(*clist_d);
+ }
+ else
+ {
+ elm_genlist_homogeneous_set(clist_d->genlist, EINA_TRUE);
+ elm_genlist_mode_set(clist_d->genlist, ELM_LIST_SCROLL);
+ ctui_list_refresh_genlist(clist_d);
+ }
+
+ }
+
+ snprintf(pre_search_str, sizeof(pre_search_str), "%s", search_str);
+
+ if (elm_genlist_decorate_mode_get(clist_d->genlist)
+ && clist_d->edit_sel_update)
+ clist_d->edit_sel_update(clist_d);
+
+}
+
+void list_searchbar_back_button_cb(void *data)
+{
+ PH_TRACE;
+ ct_list_data *clist = static_cast<ct_list_data *>(data);
+ if (clist && clist->search_layout && clist->genlist)
+ {
+ Evas_Object *entry = elm_object_part_content_get(clist->search_layout,"elm.swallow.content");
+ if (entry && clist->navi)
+ {
+ free(clist->search_str);
+ clist->search_str = NULL;
+ const char * text = elm_entry_entry_get(entry);
+ if (text && *text)
+ {
+ elm_entry_entry_set(entry, NULL);
+ }
+ elm_object_focus_set(entry, EINA_FALSE);
+ pre_search_str[0] = '\0';
+ elm_genlist_homogeneous_set(clist->genlist, EINA_TRUE);
+ elm_genlist_mode_set(clist->genlist, ELM_LIST_SCROLL);
+ elm_object_focus_set(clist->genlist, EINA_TRUE);
+ ct_list_get_contacts(clist, &clist->list);
+ ct_list_data *clist_favorite = (ct_list_data *) evas_object_data_get(clist->navi,"favor_list_d");
+ if (clist_favorite && clist_favorite->list)
+ {
+ remove_favorite_contacts(&clist->list);
+ }
+ ctui_list_refresh_genlist(clist);
+ ctui_list_update_selection_info(clist);
+ }
+ }
+}
+
+void list_searchbar_data_set(void *data)
+{
+ PH_TRACE;
+ ct_list_data * pClistD = static_cast<ct_list_data *>(data);
+ if (pClistD)
+ {
+ pClistD->widget_back_cb = list_searchbar_back_button_cb;
+ }
+}
+
+static void list_searchbar_focused_cb(void *data, Evas_Object *obj,
+ void *event_info)
+{
+ PH_TRACE;
+
+ if(data != NULL)
+ {
+ Evas_Object *pLayout = static_cast<Evas_Object *>(data);
+ evas_object_smart_callback_add((Evas_Object *) evas_object_data_get(pLayout, "button_cancel"), CLICKED,ctui_list_searchbar_cancel_cb, pLayout);
+ elm_object_focus_set(pLayout, EINA_TRUE);
+ elm_object_signal_emit(pLayout, "elm,state,guidetext,hide","elm");
+ elm_object_signal_emit(pLayout, "cancel,show", "");
+ if (elm_entry_is_empty(obj))
+ elm_object_signal_emit(pLayout, "elm,state,eraser,hide","elm");
+ else
+ elm_object_signal_emit(pLayout, "elm,state,eraser,show","elm");
+ list_searchbar_data_set(evas_object_data_get(pLayout, "clist_d"));
+ }
+}
+
+static void list_searchbar_unfocused_cb(void *data, Evas_Object *obj,
+ void *event_info)
+{
+ PH_TRACE;
+
+ if(data != NULL)
+ {
+ Evas_Object *pLayout = static_cast<Evas_Object *>(data);
+ evas_object_smart_callback_del((Evas_Object *) evas_object_data_get(pLayout, "button_cancel"), CLICKED,ctui_list_searchbar_cancel_cb);
+ if (elm_entry_is_empty(obj))
+ {
+ elm_object_signal_emit(pLayout, "elm,state,guidetext,show","elm");
+ }
+ else
+ elm_object_signal_emit(pLayout, "elm,state,guidetext,hide","elm");
+ elm_object_signal_emit(pLayout, "elm,state,eraser,hide","elm");
+ elm_object_signal_emit(pLayout, "cancel,hide", "");
+ }
+}
+
+int ctui_list_checked_cnt_get(Eina_List *list)
+{
+ PH_TRACE;
+ int cnt = 0;
+ Eina_List *l;
+ void *info;
+
+ EINA_LIST_FOREACH(list, l, info)
+ {
+ ct_person_list *person_info = (ct_person_list *) info;
+ if (NULL == person_info)
+ continue;
+ if (person_info->checked)
+ cnt++;
+ }
+ return cnt;
+}
+
+void ctui_list_update_selection_info(void *data)
+{
+ PH_TRACE;
+ ct_list_data *clist_d = (ct_list_data *) data;
+ int checked_cnt = 0;
+ char buf[PH_TEXT_SHORT_LEN];
+
+ if (CT_LIST_MODE_EDIT != clist_d->list_mode)
+ return;
+
+ if (clist_d->ug_request && NULL == clist_d->select_all_layout)
+ {
+ checked_cnt = ctui_list_checked_cnt_get(clist_d->list);
+ }
+ else
+ {
+ Evas_Object *check = elm_object_part_content_get(
+ clist_d->select_all_layout, "elm.icon");
+ if (check)
+ {
+ if (0 != clist_d->cnt_list_total
+ && clist_d->cnt_checked == clist_d->cnt_list_total)
+ elm_check_state_set(check, EINA_TRUE);
+ else if (0 == clist_d->cnt_list_total
+ || clist_d->cnt_checked != clist_d->cnt_list_total)
+ elm_check_state_set(check, EINA_FALSE);
+ }
+ checked_cnt = clist_d->cnt_checked;
+ }
+ if (0 == clist_d->cnt_list_total)
+ {
+ phone_hide_notify(clist_d->base_layout);
+ ctui_navi_btn_disabled_set(clist_d->navi, EINA_TRUE);
+ }
+ else
+ {
+ if (0 == checked_cnt)
+ {
+ phone_show_notify(clist_d->base_layout,
+ T_(CT_GET_TEXT_BASIC, CTTEXT_SELECT_CONTACTS));
+ ctui_navi_btn_disabled_set(clist_d->navi, EINA_TRUE);
+ }
+ else
+ {
+ ctui_navi_btn_disabled_set(clist_d->navi, EINA_FALSE);
+ if (clist_d->cnt_max_check)
+ snprintf(buf, sizeof(buf), "%s (%d/%d)",
+ S_(PH_SYS_POP_SELECTED), clist_d->cnt_checked,
+ clist_d->cnt_max_check);
+ else
+ snprintf(buf, sizeof(buf), "%s (%d)", S_(PH_SYS_POP_SELECTED),
+ clist_d->cnt_checked);
+ phone_show_notify(clist_d->base_layout, buf);
+ }
+ }
+}
+
+void ctui_list_searchbar_cancel_cb(void *data, Evas_Object *obj,void *event_info)
+{
+ PH_TRACE;
+ ct_list_data *clist = (ct_list_data *) evas_object_data_get((Evas_Object *) data, "clist_d");
+ if (clist && clist->search_layout && clist->genlist)
+ {
+ Evas_Object *entry = elm_object_part_content_get(clist->search_layout,"elm.swallow.content");
+ if (entry && clist->navi)
+ {
+ free(clist->search_str);
+ clist->search_str = NULL;
+ const char * text = elm_entry_entry_get(entry);
+ if (text && *text)
+ {
+ elm_entry_entry_set(entry, NULL);
+ }
+ elm_object_focus_set(entry, EINA_FALSE);
+ pre_search_str[0] = '\0';
+ elm_genlist_homogeneous_set(clist->genlist, EINA_TRUE);
+ elm_genlist_mode_set(clist->genlist, ELM_LIST_SCROLL);
+ elm_object_focus_set(clist->genlist, EINA_TRUE);
+ ct_list_get_contacts(clist, &clist->list);
+ ct_list_data *clist_favorite = (ct_list_data *) evas_object_data_get(clist->navi,"favor_list_d");
+ if (clist_favorite && clist_favorite->list)
+ {
+ remove_favorite_contacts(&clist->list);
+ }
+ ctui_list_refresh_genlist(clist);
+ ctui_list_update_selection_info(clist);
+ }
+ }
+}
+
+static void list_searchbar_eraser_cb(void *data, Evas_Object *obj,
+ const char *emission, const char *source)
+{
+ PH_TRACE;
+ elm_entry_entry_set((Evas_Object *) data, "");
+ pre_search_str[0] = '\0';
+ elm_entry_text_style_user_push((Evas_Object *) data, "DEFAULT='align=left font=Tizen:style=Thin text_class=tizen font_size=36 color=#5D61BC'");
+ elm_entry_entry_set((Evas_Object *) data, T_(PH_GET_TEXT_BASIC,CTTEXT_ENTRY_SEARCH));
+}
+static bool message_mode_state(int ug_request, int list_mode)
+{
+ PH_TRACE;
+ bool state = (CT_LIST_MODE_EDIT == list_mode)
+ || (CT_UG_REQUEST_CHECK == ug_request)
+ || (CT_UG_REQUEST_CHECK_FOR_NUMBER == ug_request)
+ || (CT_UG_REQUEST_CHECK_FOR_EMAIL == ug_request)
+ || (CT_UG_REQUEST_CHECK_FOR_NUMBER_OR_EMAIL == ug_request);
+ return state;
+}
+
+void ctui_list_create_searchbar(Evas_Object* parent,
+ ct_list_data *clist_d)
+{
+ PH_TRACE;
+
+ if (parent == NULL || clist_d == NULL)
+ {
+ return;
+ }
+ Evas_Object *pLayout_search = elm_layout_add(parent);
+ if (pLayout_search == NULL)
+ {
+ return;
+ }
+ elm_layout_file_set(pLayout_search, CONTACTS_EDJ, "search_layout_list");
+ evas_object_size_hint_weight_set(pLayout_search, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(pLayout_search, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ clist_d->searchbar = pLayout_search;
+
+ Evas_Object *pLayout = elm_layout_add(pLayout_search);
+ if (pLayout == NULL)
+ {
+ return;
+ }
+ if (message_mode_state(clist_d->ug_request, clist_d->list_mode))
+ elm_object_part_content_set(pLayout_search,
+ "add_button_hide_swall_search", pLayout);
+ else
+ elm_object_part_content_set(pLayout_search,
+ "add_button_show_swall_search", pLayout);
+ evas_object_data_set(pLayout, "clist_d", clist_d);
+ evas_object_size_hint_weight_set(pLayout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(pLayout, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_layout_theme_set(pLayout, "layout", "searchbar", "cancel_button");
+ clist_d->search_layout = pLayout;
+ evas_object_show(pLayout);
+
+ Evas_Object * pSearchBar = ea_editfield_add(pLayout,EA_EDITFIELD_SEARCHBAR);
+ if (pSearchBar != NULL)
+ {
+ elm_object_part_content_set(pLayout, "elm.swallow.content", pSearchBar);
+ elm_object_domain_translatable_part_text_set(pSearchBar, "elm.guide", NULL, T_(PH_GET_TEXT_BASIC,CTTEXT_ENTRY_SEARCH));
+ clist_d->m_Widget = pSearchBar;
+ }
+
+ Evas_Object *pCancelBtn = elm_button_add(pLayout);
+ if (pCancelBtn != NULL)
+ {
+ elm_object_part_content_set(pLayout, "button_cancel", pCancelBtn);
+ elm_object_style_set(pCancelBtn, "searchbar/default");
+ elm_object_text_set(pCancelBtn, S_(PH_SYS_SK_CANCEL));
+ }
+
+ evas_object_smart_callback_add(pSearchBar, "focused",
+ list_searchbar_focused_cb, pLayout);
+ evas_object_smart_callback_add(pSearchBar, "unfocused",
+ list_searchbar_unfocused_cb, pLayout);
+ evas_object_smart_callback_add(pSearchBar, CHANGED,
+ list_searchbar_changed_cb, pLayout);
+ evas_object_smart_callback_add(pSearchBar, "preedit,changed",
+ list_searchbar_changed_cb, pLayout);
+ elm_object_signal_callback_add(pLayout, "elm,bg,clicked", "elm",
+ list_searchbar_clicked_cb, clist_d);
+ elm_object_signal_callback_add(pLayout, "elm,eraser,clicked", "elm",
+ list_searchbar_eraser_cb, pSearchBar);
+ evas_object_smart_callback_add(pCancelBtn, CLICKED,
+ ctui_list_searchbar_cancel_cb, pLayout);
+
+ elm_object_part_content_set(clist_d->layout, "searchbar_layout", pLayout_search);
+ evas_object_show(pLayout_search);
+ clist_d->searchbar = pLayout_search;
+}
+
+static Evas_Object* list_create_navi_content_genlist(Evas_Object* parent)
+{
+ PH_TRACE;
+ Evas_Object *genlist = elm_genlist_add(parent);
+
+ elm_scroller_policy_set(genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
+ elm_genlist_block_count_set(genlist, 20);
+ elm_genlist_homogeneous_set(genlist, EINA_TRUE);
+
+ evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ return genlist;
+}
+
+static void list_fast_delayed_changed(void *data, Evas_Object *obj,
+ void *event_info)
+{
+ PH_TRACE;
+ // called on a change but delayed in case multiple changes happen in a
+ // short timespan
+ elm_genlist_item_bring_in(
+ (Elm_Object_Item *) elm_object_item_data_get(
+ (const Elm_Object_Item *) event_info),
+ ELM_GENLIST_ITEM_SCROLLTO_TOP);
+}
+
+static void list_fast_selected(void *data, Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ // called on final select
+ elm_genlist_item_bring_in(
+ (Elm_Object_Item *) elm_object_item_data_get(
+ (const Elm_Object_Item *) event_info),
+ ELM_GENLIST_ITEM_SCROLLTO_TOP);
+}
+
+static void list_get_number_str(int id, char *buf, int buf_len)
+{
+ PH_TRACE;
+ contacts_record_h record_default_number;
+ int err = phone_cts_get_default_number(id, &record_default_number);
+ if (CONTACTS_ERROR_NONE == err)
+ {
+ char *number = NULL;
+ contacts_record_get_str(record_default_number, _contacts_number.number, &number);
+ {
+ if (number && *number)
+ {
+ strncpy(buf, number, buf_len);
+ }
+ }
+ free(number);
+ err = contacts_record_destroy(record_default_number, true);
+ p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_destroy() Failed(%d)", err);
+ }
+}
+
+static void list_gl_sweep(void *data, Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ assert(data);
+ assert(event_info);
+ if (NULL != data && NULL != event_info)
+ {
+ ct_list_data *clist_d = static_cast<ct_list_data*>(data);
+
+ Elm_Object_Item *item = static_cast<Elm_Object_Item*>(event_info);
+ p_ret_if(!item);
+ p_ret_if(CT_GET_LIST_VCARD == clist_d->list_op);
+ p_ret_if(CT_LIST_MODE_EDIT == clist_d->list_mode);
+
+ Elm_Genlist_Item_Type type = elm_genlist_item_type_get(item);
+ p_ret_if(ELM_GENLIST_ITEM_GROUP == type);
+ p_ret_if( &clist_d->itcs[CT_LIST_ITEM_COUNT] == elm_genlist_item_item_class_get(item));
+
+ ct_person_list *person_info = NULL;
+ person_info = static_cast<ct_person_list*>(elm_object_item_data_get(item));
+ p_retm_if(NULL == person_info, "ct_person_list is null");
+ if (!person_info->number_loaded)
+ {
+ char buf[PH_TEXT_MAX_LEN];
+ buf[0] = '\0';
+ list_get_number_str(person_info->id, buf, sizeof(buf));
+ if (*buf)
+ person_info->number = strdup(buf);
+ person_info->number_loaded = true;
+ }
+
+ Elm_Genlist_Item_Class *itc = NULL;
+ itc = (Elm_Genlist_Item_Class *) elm_genlist_item_item_class_get(item);
+ p_retm_if(NULL == itc, "item class is null");
+
+ if ((NULL == person_info->number || '\0' == *person_info->number) && strcmp(itc->decorate_item_style, clist_d->itcs[CT_LIST_ITEM].decorate_item_style))
+ {
+ if (clist_d->search_str && *clist_d->search_str)
+ elm_genlist_item_item_class_update(item, &clist_d->itcs[CT_LIST_ITEM_SEARCH]);
+ else
+ elm_genlist_item_item_class_update(item, &clist_d->itcs[CT_LIST_ITEM]);
+ }
+ else if ((person_info->number && *person_info->number) && strcmp(itc->decorate_item_style, clist_d->itcs[CT_LIST_ITEM_NO_NUMBER].decorate_item_style))
+ {
+ if (clist_d->search_str && *clist_d->search_str)
+ elm_genlist_item_item_class_update(item, &clist_d->itcs[CT_LIST_ITEM_SEARCH_NO_NUMBER]);
+ else
+ elm_genlist_item_item_class_update(item, &clist_d->itcs[CT_LIST_ITEM_NO_NUMBER]);
+ }
+
+ hide_fast_index(clist_d);
+
+ // hide sweeped item
+ Elm_Object_Item *lastItem = clist_d->last_sweep_item;
+
+ if (NULL != lastItem)
+ {
+ elm_genlist_item_decorate_mode_set(lastItem, "slide", EINA_FALSE);
+ elm_genlist_item_select_mode_set(lastItem, ELM_OBJECT_SELECT_MODE_DEFAULT);
+ clist_d->last_sweep_item = NULL;
+ }
+
+ clist_d->last_sweep_item = item;
+ elm_genlist_item_decorate_mode_set(item, "slide", EINA_TRUE);
+ elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_NONE);
+ }
+}
+
+static void list_gl_unsweep(void *data, Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ assert(data);
+ if (NULL != data)
+ {
+ ct_list_data *clist_d = static_cast<ct_list_data*>(data);
+ if (NULL != clist_d->last_sweep_item)
+ {
+ elm_genlist_item_decorate_mode_set(clist_d->last_sweep_item, "slide", EINA_FALSE);
+ elm_genlist_item_select_mode_set(clist_d->last_sweep_item, ELM_OBJECT_SELECT_MODE_DEFAULT);
+ show_fast_index(clist_d);
+ clist_d->last_sweep_item = NULL;
+ }
+ }
+}
+
+void ctui_list_set_unsweep(ct_list_data *clist_d)
+{
+ PH_TRACE;
+ assert(clist_d);
+ if (NULL != clist_d)
+ {
+ elm_genlist_item_decorate_mode_set(clist_d->last_sweep_item, "slide", EINA_FALSE);
+ elm_genlist_item_select_mode_set(clist_d->last_sweep_item, ELM_OBJECT_SELECT_MODE_DEFAULT);
+ show_fast_index(clist_d);
+ }
+}
+
+void list_destroy_child_ug(void *data)
+{
+ PH_TRACE;
+ p_retm_if(NULL == data, "data is null");
+ ct_list_data *pListData = static_cast<ct_list_data *>(data);
+ ug_destroy(pListData->child_ug);
+ pListData->child_ug = NULL;
+}
+
+Eina_Bool list_hide_popup_cb(void *data)
+{
+ PH_TRACE;
+ p_retvm_if(NULL == data, ECORE_CALLBACK_CANCEL, "data is null");
+ ct_list_data *pListData = static_cast<ct_list_data *>(data);
+
+ if (pListData->popup)
+ {
+ evas_object_del(pListData->popup);
+ pListData->popup = NULL;
+ }
+ return ECORE_CALLBACK_CANCEL;
+}
+
+char* list_get_person_name(int id)
+{
+ p_retvm_if(NO_INIT >= id, NULL, "incorrect id");
+ char* contact_name = NULL;
+ contacts_record_h person = NULL;
+
+ if (contacts_db_get_record(_contacts_person._uri, id, &person) == CONTACTS_ERROR_NONE)
+ {
+ if(contacts_record_get_str(person, _contacts_person.display_name, &contact_name) != CONTACTS_ERROR_NONE)
+ {
+ ERR("getting contact name failed");
+ free(contact_name);
+ contact_name = NULL;
+ }
+ contacts_record_destroy(person, true);
+ }
+ PH_DBG("contact_name: %s", contact_name);
+ return contact_name;
+}
+
+void list_hide_popup_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ p_retm_if(NULL == data, "data is null");
+ list_hide_popup_cb(data);
+}
+
+void list_edit_item_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ p_retm_if(NULL == data, "data is null");
+ ct_list_data *pListData = static_cast<ct_list_data *>(data);
+ list_hide_popup_cb(data);
+ pListData->child_ug = phone_launch_contact_edit_ug(pListData->ug, pListData->personId,
+ list_destroy_child_ug, pListData);
+}
+
+Elm_Genlist_Item_Class *list_create_class(const char *style, Elm_Gen_Item_Text_Get_Cb getText)
+{
+ PH_TRACE;
+ Elm_Genlist_Item_Class *itemClass = elm_genlist_item_class_new();
+ p_retvm_if(NULL == itemClass, NULL, "itemClass is null");
+
+ itemClass->item_style = style;
+ itemClass->func.text_get = getText;
+ itemClass->func.content_get = NULL;
+ itemClass->func.state_get = NULL;
+ itemClass->func.del = NULL;
+ return itemClass;
+}
+
+char *list_get_item_text_cb(void *data, Evas_Object *obj, const char *part)
+{
+ PH_TRACE;
+ p_retvm_if(NULL == data, NULL, "data is null");
+ return strdup((const char *) data);
+}
+
+bool list_make_vcard(ct_list_data &pListData, char *filePath, int length)
+{
+ PH_TRACE;
+ p_retvm_if((NULL == pListData.genlist), FALSE, "pListData->genlist is null");
+
+ if (!ctui_list_make_vcard(pListData.personId, filePath, length))
+ {
+ ERR("detail_make_vcard() Failed");
+ if (pListData.win)
+ {
+ phone_show_popup(pListData.win, T_(CT_GET_TEXT_ERR,
+ CTTEXT_UNABLE_TO_SEND_NAME_CARDS), 1.5);
+ }
+ return FALSE;
+ }
+ return TRUE;
+}
+
+void list_send_namecard_via_msg(void *data, Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ p_retm_if(NULL == data, "data is null");
+ ct_list_data *pListData = static_cast<ct_list_data *>(data);
+ char filePath[FILENAME_MAX];
+
+ list_hide_popup_cb(pListData);
+ if(list_make_vcard(*pListData, filePath, FILENAME_MAX))
+ {
+ pListData->child_ug = ctui_msg_ug(pListData->ug, NULL,
+ filePath, list_destroy_child_ug, pListData);
+ }
+}
+
+void list_send_namecard_via_email(void *data, Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ p_retm_if(NULL == data, "data is null");
+ ct_list_data *pListData = static_cast<ct_list_data *>(data);
+ char filePath[FILENAME_MAX];
+
+ list_hide_popup_cb(pListData);
+ if (list_make_vcard(*pListData, filePath, FILENAME_MAX))
+ {
+ service_h service;
+ Ecore_X_Window win_id = elm_win_xwindow_get(pListData->win);
+ service_create(&service);
+ service_set_operation(service, SERVICE_OPERATION_SEND);
+ service_set_uri(service, filePath);
+ service_set_app_id(service, EMAIL_COMPOSER_PKG);
+ service_add_extra_data(service, SERVICE_DATA_SUBJECT, CONTACTS_NAME_CARD);
+
+ service_set_window(service, win_id);
+ service_send_launch_request(service, NULL, NULL);
+ service_destroy(service);
+ }
+}
+
+void list_send_namecard_via_bluetooth(void *data, Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ p_retm_if(NULL == data, "data is null");
+ ct_list_data *pListData = static_cast<ct_list_data *>(data);
+ char filePath[FILENAME_MAX];
+
+ list_hide_popup_cb(pListData);
+ if (list_make_vcard(*pListData, filePath, FILENAME_MAX))
+ {
+ pListData->child_ug = phone_launch_bluetooth_ug(pListData->ug,
+ filePath, list_destroy_child_ug, pListData);
+ }
+}
+
+void list_create_popup_with_cancel_button(ct_list_data &pListData, const char *label)
+{
+ PH_TRACE;
+
+ list_hide_popup_cb(&pListData);
+
+ Evas_Object *pPopup = elm_popup_add(pListData.navi);
+ p_retm_if(NULL == pPopup, "pPopup is null");
+ p_retm_if(NULL == label, "label is null");
+ pListData.popup = pPopup;
+ elm_object_style_set(pPopup, "content_no_vhpad");
+ elm_object_part_text_set(pPopup,TITLE_TEXT, label);
+ evas_object_size_hint_weight_set(pPopup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+ Evas_Object *pCancelButton = elm_button_add(pPopup);
+ p_retm_if(NULL == pCancelButton, "pCancelButton is null");
+ elm_object_style_set(pCancelButton, "popup_button/default");
+ elm_object_text_set(pCancelButton, S_(PH_SYS_SK_CANCEL));
+ elm_object_part_content_set(pPopup, BUTTON1, pCancelButton);
+ evas_object_smart_callback_add(pCancelButton, CLICKED, list_hide_popup_cb, &pListData);
+
+ evas_object_show(pPopup);
+}
+
+void list_send_namecard_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ p_retm_if(NULL == data, "data is null");
+ ct_list_data *pListData = static_cast<ct_list_data *>(data);
+
+ list_create_popup_with_cancel_button(*pListData, SEND_NAMECARD);
+ Elm_Genlist_Item_Class *namecard_itc = list_create_class("1text/popup", list_get_item_text_cb);
+
+ Evas_Object *pGenlist = elm_genlist_add(pListData->popup);
+ p_retm_if(NULL == pGenlist, "pGenlist is null");
+ evas_object_size_hint_weight_set(pGenlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(pGenlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ elm_genlist_item_append(pGenlist, namecard_itc, S_(PH_SYS_BODY_MESSAGE), NULL,
+ ELM_GENLIST_ITEM_NONE, list_send_namecard_via_msg, pListData);
+ elm_genlist_item_append(pGenlist, namecard_itc, S_(CT_SYS_BODY_EMAIL), NULL,
+ ELM_GENLIST_ITEM_NONE, list_send_namecard_via_email, pListData);
+ elm_genlist_item_append(pGenlist, namecard_itc, S_(CT_SYS_BODY_BLUETOOTH), NULL,
+ ELM_GENLIST_ITEM_NONE, list_send_namecard_via_bluetooth, pListData);
+
+ elm_object_content_set(pListData->popup, pGenlist);
+
+ elm_genlist_item_class_free(namecard_itc);
+}
+
+void list_radio_check_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ p_retm_if(NULL == data, "data is null");
+ ct_list_data *pListData = static_cast<ct_list_data *>(data);
+
+ int err = contacts_person_set_default_property(CONTACTS_PERSON_PROPERTY_NUMBER, pListData->personId,
+ pListData->radioGroupValue);
+ p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_person_set_default_property() Failed(%d)", err);
+
+ ecore_timer_add(POPUP_CLOSING_DELAY, list_hide_popup_cb, static_cast<void *>(pListData));
+}
+
+Evas_Object *list_create_radio_button(ct_list_data &pListData, contacts_record_h record,
+ int defaultNumberId)
+{
+ PH_TRACE;
+
+ int numberId = 0;
+ int type = 0;
+ char *number = NULL;
+ char buf[PH_TEXT_MAX_LEN + 1] = { 0, };
+
+ contacts_record_h recordNumber = record;
+
+ int err = contacts_record_get_int(recordNumber, _contacts_number.id, &numberId);
+ p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err);
+
+ err = contacts_record_get_int(recordNumber, _contacts_number.type, &type);
+ p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err);
+
+ ctui_get_number_type_str(recordNumber, type, buf, (PH_TEXT_MAX_LEN + 1));
+
+ err = contacts_record_get_str_p(recordNumber, _contacts_number.number, &number);
+ p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() Failed(%d)", err);
+
+ std::string numberAndType;
+ numberAndType.append(number);
+ numberAndType.append(" (");
+ numberAndType.append(buf);
+ numberAndType.append(")");
+
+ Evas_Object *pRadio = elm_radio_add(pListData.popup);
+ elm_object_text_set(pRadio, numberAndType.c_str());
+ elm_radio_state_value_set(pRadio, numberId);
+ elm_radio_value_pointer_set(pRadio, &pListData.radioGroupValue);
+ evas_object_size_hint_weight_set(pRadio, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(pRadio, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_show(pRadio);
+ evas_object_smart_callback_add(pRadio, CHANGED, list_radio_check_cb, &pListData);
+ return pRadio;
+}
+
+void list_default_number_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ p_retm_if(NULL == data, "data is null");
+
+ ct_list_data *pListData = static_cast<ct_list_data *>(data);
+ contacts_record_h recordDefaultNumber = NULL;
+ int defaultNumberId = 0;
+ Eina_List *pCursor = NULL;
+ void *pVRecordNumber = NULL;
+ Evas_Object* pGroup = NULL;
+
+ list_create_popup_with_cancel_button(*pListData, DEFAULT_NUMBER);
+
+ Evas_Object *pScroller = elm_scroller_add(pListData->popup);
+ elm_scroller_policy_set(pScroller, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_AUTO);
+ evas_object_show (pScroller);
+
+ Evas_Object *pBox = elm_box_add(pScroller);
+ evas_object_size_hint_weight_set(pBox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(pBox, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_win_resize_object_add(pListData->popup, pBox);
+
+ int err = phone_cts_get_default_number(pListData->personId, &recordDefaultNumber);
+ p_warn_if(CONTACTS_ERROR_NONE != err, "phone_cts_get_default_number() Failed(%d)", err);
+
+ err = contacts_record_get_int(recordDefaultNumber, _contacts_number.id, &defaultNumberId);
+ p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_get_int() Failed(%d)", err);
+
+ err = contacts_record_destroy(recordDefaultNumber, true);
+ p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_destroy() Failed(%d)", err);
+
+ Eina_List *pListNumber = static_cast<Eina_List *>( evas_object_data_get(
+ pListData->genlist, NUMBER_LIST));
+ EINA_LIST_FOREACH(pListNumber, pCursor, pVRecordNumber)
+ {
+
+ Evas_Object * pRadio = list_create_radio_button(*pListData, static_cast<contacts_record_h>(pVRecordNumber),
+ defaultNumberId);
+
+ elm_box_pack_end(pBox, pRadio);
+ elm_radio_group_add(pRadio, pGroup);
+
+ if (!pGroup)
+ {
+ pGroup = pRadio;
+ elm_radio_value_set(pGroup, defaultNumberId);
+ }
+ }
+
+ elm_object_content_set(pScroller, pBox);
+ elm_object_content_set(pListData->popup, pScroller);
+ evas_object_show(pBox);
+}
+
+/**
+ * @brief Gets count of multiple child tables for contact record
+ * @param[in] contact_record Handle to record
+ * @return Count of records if success, max size_t value if failed
+ */
+static size_t ct_get_field_count(contacts_record_h contact_record)
+{
+ PH_TRACE;
+ size_t count(0);
+ size_t temp_count(0);
+ unsigned int array_of_ids[] =
+ {
+ _contacts_contact.name,
+ _contacts_contact.nickname,
+ _contacts_contact.company,//company
+ _contacts_contact.company,//job title
+ _contacts_contact.number,
+ _contacts_contact.email,
+ _contacts_contact.address,
+ _contacts_contact.messenger,
+ _contacts_contact.url,
+ _contacts_contact.relationship,
+ _contacts_contact.event,
+ _contacts_contact.note
+ };
+ if(contact_record)
+ {
+ size_t array_size = (sizeof(array_of_ids) / sizeof(unsigned int));
+ for(size_t i = 0; i < array_size; ++i)
+ {
+ if(contacts_record_get_child_record_count(contact_record, array_of_ids[i], &temp_count)
+ == CONTACTS_ERROR_NONE)
+ {
+ count += temp_count;
+ }
+ else
+ {
+ ERR("error getting child count");
+ count = -1;
+ break;
+ }
+ }
+ }
+ return count;
+}
+
+/**
+ * @brief Convert date as integer to string
+ * @remark The returned value must be destroyed with free by you
+ * @param[in] formatter Represent format of the date
+ * @param[in] date Date as integer
+ * @return new string on success, otherwise NULL
+ */
+static char* ct_convert_int_date_to_str(UDateFormat* formatter, int date)
+{
+ PH_TRACE;
+ char* result = NULL;
+ if(formatter)
+ {
+ int day, month, year;
+ day = date % 100;
+ month = (date % 10000) / 100;
+ year = date / 10000;
+ result = phone_get_datetime_str(formatter, year, month, day);
+ }
+ return result;
+}
+
+/**
+ * @brief Gets field "type" as string for multiple child tables
+ * @remark If type is custom, function return value from field "label"
+ * @remark The return value must not be destroyed by you
+ * @param[in] child_record Child record of contact table
+ * @param[in] type_field_id ID of field "type"
+ * @param[in] label_field_id ID of field "label"
+ * @param[in] table_type CT_GET_TEXT_NUM_TYPE, CT_GET_TEXT_EMAIL_TYPE etc
+ * @return Type as string on success, otherwise NULL
+ */
+static char* ct_get_type_as_str(contacts_record_h child_record, unsigned int type_field_id,
+ unsigned int label_field_id, int table_type)
+{
+ PH_TRACE;
+ const int custom_type = 1;
+ char* result = NULL;
+ int temp_type = 0;
+ bool is_custom_field(false);
+ char* temp_label = NULL;
+ if(child_record)
+ {
+ int type_of_field = 0;
+ if(contacts_record_get_int(child_record, type_field_id, &type_of_field)
+ == CONTACTS_ERROR_NONE)
+ {
+ switch(table_type)
+ {
+ case CT_GET_TEXT_NUM_TYPE:
+ {
+ for (temp_type = CTTEXT_TYPE_CUSTOM; temp_type <= CTTEXT_TYPE_OTHER; temp_type++)
+ {
+ if (type_of_field == phone_get_number_type_index(temp_type))
+ break;
+ }
+ is_custom_field = (CONTACTS_NUMBER_TYPE_CUSTOM == type_of_field);
+ break;
+ }
+ case CT_GET_TEXT_EMAIL_TYPE:
+ {
+ temp_type = ctui_get_email_type_index(type_of_field);
+ is_custom_field = (custom_type == temp_type);
+ break;
+ }
+ case CT_GET_TEXT_POSTAL_TYPE:
+ {
+ temp_type = phone_get_address_type_index(type_of_field);
+ is_custom_field = (custom_type == temp_type);
+ break;
+ }
+ case CT_GET_TEXT_WEBSITE_TYPE:
+ {
+ temp_type = phone_get_website_type_index(type_of_field);
+ is_custom_field = (custom_type == temp_type);
+ break;
+ }
+ case CT_GET_TEXT_IM_TYPE:
+ {
+ temp_type = type_of_field;
+ is_custom_field = (CONTACTS_MESSENGER_TYPE_CUSTOM == temp_type);
+ break;
+ }
+ case CT_GET_TEXT_RELATIONSHIP_TYPE:
+ {
+ temp_type = type_of_field;
+ is_custom_field = (CTTEXT_REL_CUSTOM == temp_type);
+ break;
+ }
+ case CT_GET_TEXT_EVENT_TYPE:
+ {
+ temp_type = type_of_field;
+ is_custom_field = (CONTACTS_EVENT_TYPE_CUSTOM == temp_type);
+ break;
+ }
+ default:
+ {
+ ERR("unknown type of table");
+ return NULL;
+ }
+ }
+ if( is_custom_field
+ && (contacts_record_get_str_p(child_record, label_field_id, &temp_label) == CONTACTS_ERROR_NONE)
+ && (temp_label)
+ && (*temp_label))
+ {
+ result = temp_label;
+ }
+ else
+ {
+ result = (char*)T_(table_type, temp_type);
+ }
+ }
+ }
+ return result;
+}
+
+/**
+ * @brief Gets string from one of child record of _contacts_contact table
+ * @remark The returned value must be destroyed with free by you
+ * @param[in] p_contact_text_data Pointer to structure with data of contact
+ * @param[in] child_table_id ID of child table. E.g. _contacts_contact.number
+ * @param[in] record_index Index of record
+ * @param[in] str_field_id ID of field. E.g. _contacts_number.number
+ */
+static char* ct_get_str_from_child_record(ct_send_as_text_data* p_contact_text_data, unsigned int child_table_id,
+ int record_index, unsigned int str_field_id)
+{
+ PH_TRACE;
+ char* temp_str = NULL;
+ contacts_record_h child_record = NULL;
+ if(p_contact_text_data && p_contact_text_data->contact_record)
+ {
+ if(contacts_record_get_child_record_at_p(p_contact_text_data->contact_record, child_table_id, record_index, &child_record)
+ == CONTACTS_ERROR_NONE)
+ {
+ if(contacts_record_get_str(child_record, str_field_id, &temp_str)
+ != CONTACTS_ERROR_NONE)
+ {
+ free(temp_str);
+ temp_str = NULL;
+ }
+ }
+ }
+ return temp_str;
+}
+
+/**
+ * @brief Gets event as string from _contacts_event
+ * @remark The returned value must be destroyed with free by you
+ * @remark Some parameters are not using. Function interface just match p_get_str_from_child_record
+ * @param[in] p_contact_text_data Pointer to structure with data of contact
+ * @param[in] child_table_id Not using.
+ * @param[in] record_index Index of record
+ * @param[in] field_id Not using.
+ */
+static char* ct_get_event_from_child_record(ct_send_as_text_data* p_contact_text_data, unsigned int child_table_id,
+ int record_index, unsigned int field_id)
+{
+ PH_TRACE;
+ char* result = NULL;
+ contacts_record_h child_record = NULL;
+ if(p_contact_text_data)
+ {
+ if(contacts_record_get_child_record_at_p(p_contact_text_data->contact_record, _contacts_contact.event, record_index, &child_record)
+ == CONTACTS_ERROR_NONE)
+ {
+ int temp_date = 0;
+ if(contacts_record_get_int(child_record, _contacts_event.date, &temp_date)
+ == CONTACTS_ERROR_NONE)
+ {
+ if(p_contact_text_data->formatter)
+ {
+ result = ct_convert_int_date_to_str(p_contact_text_data->formatter, temp_date);
+ }
+ }
+ }
+ }
+ return result;
+}
+
+/**
+ * @brief Gets address as string from _contacts_address
+ * @remark The returned value must be destroyed with free by you
+ * @remark Some parameters are not using. Function interface just match p_get_str_from_child_record
+ * @param[in] p_contact_text_data Pointer to structure with data of contact
+ * @param[in] child_table_id Not using.
+ * @param[in] record_index Index of record
+ * @param[in] field_id Not using.
+ */
+static char* ct_get_address_from_child_record(ct_send_as_text_data* p_contact_text_data, unsigned int child_table_id,
+int record_index, unsigned int field_id)
+{
+ PH_TRACE;
+ char* result = NULL;
+ char* code = NULL;
+ char* extended = NULL;
+ char* postbox = NULL;
+ char* street = NULL;
+ char* locality = NULL;
+ char* region = NULL;
+ char* country = NULL;
+ contacts_record_h child_record = NULL;
+ if(p_contact_text_data)
+ {
+ if(contacts_record_get_child_record_at_p(p_contact_text_data->contact_record, _contacts_contact.address, record_index, &child_record)
+ == CONTACTS_ERROR_NONE)
+ {
+ if( contacts_record_get_str_p(child_record, _contacts_address.postal_code, &code) == CONTACTS_ERROR_NONE
+ && contacts_record_get_str_p(child_record, _contacts_address.extended, &extended) == CONTACTS_ERROR_NONE
+ && contacts_record_get_str_p(child_record, _contacts_address.postbox, &postbox) == CONTACTS_ERROR_NONE
+ && contacts_record_get_str_p(child_record, _contacts_address.street, &street) == CONTACTS_ERROR_NONE
+ && contacts_record_get_str_p(child_record, _contacts_address.locality, &locality) == CONTACTS_ERROR_NONE
+ && contacts_record_get_str_p(child_record, _contacts_address.region, &region) == CONTACTS_ERROR_NONE
+ && contacts_record_get_str_p(child_record, _contacts_address.country, &country) == CONTACTS_ERROR_NONE)
+ {
+ size_t size = SAFE_STRLEN(code) + SAFE_STRLEN(extended) + SAFE_STRLEN(postbox) + SAFE_STRLEN(street)
+ + SAFE_STRLEN(locality) + SAFE_STRLEN(region) + SAFE_STRLEN(country);
+ if(size > 0)
+ {
+ ++size;
+ result = (char*)calloc(size, sizeof(char));
+ snprintf(result, size, "%s%s%s%s%s%s%s%s%s%s%s%s%s",
+ SAFE_STR(code), STR_BLANK(code, extended), STR_BLANK(extended, postbox),
+ STR_BLANK(postbox, street), STR_BLANK(street, locality), STR_BLANK(locality, region), STR_BLANK(region, country));
+ }
+ }
+ }
+ }
+ return result;
+}
+
+/**
+ * @brief Fill contact data to @a p_text_as_data
+ * @param[in] child_table_id ID of child table. E.g. _contacts_contact.number
+ * @param[in] field_id ID of field. E.g. _contacts_number.number
+ * @param[in] p_contact_text_data Pointer to structure with data of contact
+ * @param[in] str_getter Function receives the string data from the @a field_id field
+ * @param[out] p_current_index Current index of string with data in @a p_text_as_data structure
+ * return true if success, otherwise false
+ */
+static bool ct_fill_info_field_to_text_data(unsigned int child_table_id, unsigned int field_id,
+ ct_send_as_text_data* p_contact_text_data, p_get_str_from_child_record str_getter, size_t* p_current_index)
+{
+ PH_TRACE;
+ bool result(false);
+ char* temp_str = NULL;
+ unsigned int child_count = 0;
+ if(p_contact_text_data && str_getter)
+ {
+ if(contacts_record_get_child_record_count(p_contact_text_data->contact_record, child_table_id, &child_count)
+ == CONTACTS_ERROR_NONE)
+ {
+ if(0 == child_count)
+ {
+ result = true;
+ }
+ else
+ {
+ for(int i = 0; i < (int)child_count; ++i)
+ {
+ temp_str = (*str_getter)(p_contact_text_data, child_table_id, i, field_id);
+ if(temp_str && (*p_current_index < p_contact_text_data->fields_count))
+ {
+ p_contact_text_data->strings_of_data[*p_current_index] = temp_str;
+ ++(*p_current_index);
+ result = true;
+ }
+ else
+ {
+ free(temp_str);
+ result = false;
+ break;
+ }
+ }
+ }
+ }
+ }
+ return result;
+}
+
+/**
+ * @brief Fill names of "type" fields to @a p_text_as_data
+ * @param[in] child_table_id ID of child table. E.g. _contacts_contact.number
+ * @param[in] type_field_id ID of field "type"
+ * @param[in] label_field_id ID of field "label"
+ * @param[in] p_contact_text_data Pointer to structure with data of contact
+ * @param[in] kind_of_table CT_GET_TEXT_NUM_TYPE, CT_GET_TEXT_EMAIL_TYPE etc
+ * @param[out] p_current_index Current index of string with names in @a p_text_as_data structure
+ * return true if success, otherwise false
+ */
+static bool ct_fill_name_for_text_data(unsigned int child_table_id, unsigned int type_field_id,
+ unsigned int label_field_id, ct_send_as_text_data* p_contact_text_data,
+ int kind_of_table, size_t* p_current_index)
+{
+ PH_TRACE;
+ bool result(false);
+ char* temp_str = NULL;
+ unsigned int child_count = 0;
+ contacts_record_h child_record = NULL;
+ if(p_contact_text_data && p_current_index)
+ {
+ if(contacts_record_get_child_record_count(p_contact_text_data->contact_record, child_table_id, &child_count)
+ == CONTACTS_ERROR_NONE)
+ {
+ if(0 == child_count)
+ {
+ result = true;
+ }
+ else
+ {
+ for(int i = 0; i < (int)child_count; ++i)
+ {
+ if(contacts_record_get_child_record_at_p(p_contact_text_data->contact_record, child_table_id, i, &child_record)
+ == CONTACTS_ERROR_NONE)
+ {
+ temp_str = ct_get_type_as_str(child_record, type_field_id, label_field_id, kind_of_table);
+ if(temp_str && (*p_current_index < p_contact_text_data->fields_count))
+ {
+ p_contact_text_data->field_names[*p_current_index] = strdup(temp_str);
+ ++(*p_current_index);
+ result = true;
+ }
+ else
+ {
+ result = false;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ return result;
+}
+
+/**
+ * @brief Fill name of contact to @a p_text_as_data structure
+ * @param[in] p_contact_text_data Pointer to structure with data of contact
+ * @param[out] p_current_name_index Current index of string with name of type
+ * @param[out] p_current_data_index Current index of string with info
+ * @return true if success, otherwise false
+ */
+static bool ct_fill_display_name(ct_send_as_text_data* p_contact_text_data, size_t* p_current_name_index, size_t* p_current_data_index)
+{
+ PH_TRACE;
+ if(p_contact_text_data && p_current_name_index && p_current_data_index)
+ {
+ char* temp_str = NULL;
+ if(contacts_record_get_str_p(p_contact_text_data->contact_record, _contacts_contact.display_name, &temp_str)
+ == CONTACTS_ERROR_NONE)
+ {
+ p_contact_text_data->strings_of_data[(*p_current_data_index)++] = strdup(temp_str);
+ }
+ if(*p_current_data_index > *p_current_name_index)
+ {
+ p_contact_text_data->field_names[(*p_current_name_index)++] = strdup(S_(CT_SYS_BODY_NAME));
+ }
+ }
+ return *p_current_name_index == *p_current_data_index;
+}
+
+/**
+ * @brief Fill nickname of contact to @a p_text_as_data structure
+ * @param[in] p_contact_text_data Pointer to structure with data of contact
+ * @param[out] p_current_name_index Current index of string with name of type
+ * @param[out] p_current_data_index Current index of string with info
+ * @return true if success, otherwise false
+ */
+static bool ct_fill_nickname(ct_send_as_text_data* p_contact_text_data, size_t* p_current_name_index, size_t* p_current_data_index)
+{
+ PH_TRACE;
+ if(p_contact_text_data && p_current_name_index && p_current_data_index)
+ {
+ ct_fill_info_field_to_text_data(_contacts_contact.nickname, _contacts_nickname.name,
+ p_contact_text_data, ct_get_str_from_child_record, p_current_data_index);
+ if(*p_current_data_index > *p_current_name_index)
+ {
+ p_contact_text_data->field_names[(*p_current_name_index)++] = strdup(T_(CT_GET_TEXT_BASIC, CTTEXT_NICKNAME));
+ }
+ }
+ return *p_current_name_index == *p_current_data_index;
+}
+
+/**
+ * @brief Fill contact company name to @a p_text_as_data structure
+ * @param[in] p_contact_text_data Pointer to structure with data of contact
+ * @param[out] p_current_name_index Current index of string with name of type
+ * @param[out] p_current_data_index Current index of string with info
+ * @return true if success, otherwise false
+ */
+static bool ct_fill_company(ct_send_as_text_data* p_contact_text_data, size_t* p_current_name_index, size_t* p_current_data_index)
+{
+ PH_TRACE;
+ if(p_contact_text_data && p_current_name_index && p_current_data_index)
+ {
+ ct_fill_info_field_to_text_data(_contacts_contact.company, _contacts_company.name,
+ p_contact_text_data, ct_get_str_from_child_record, p_current_data_index);
+ if(*p_current_data_index > *p_current_name_index)
+ {
+ p_contact_text_data->field_names[(*p_current_name_index)++] = strdup(T_(CT_GET_TEXT_BASIC, CTTEXT_COMPANY));
+ }
+ }
+ return *p_current_name_index == *p_current_data_index;
+}
+
+/**
+ * @brief Fill job title of contact to @a p_text_as_data structure
+ * @param[in] p_contact_text_data Pointer to structure with data of contact
+ * @param[out] p_current_name_index Current index of string with name of type
+ * @param[out] p_current_data_index Current index of string with info
+ * @return true if success, otherwise false
+ */
+static bool ct_fill_job_title(ct_send_as_text_data* p_contact_text_data, size_t* p_current_name_index, size_t* p_current_data_index)
+{
+ PH_TRACE;
+ if(p_contact_text_data && p_current_name_index && p_current_data_index)
+ {
+ ct_fill_info_field_to_text_data(_contacts_contact.company, _contacts_company.job_title,
+ p_contact_text_data, ct_get_str_from_child_record, p_current_data_index);
+ if(*p_current_data_index > *p_current_name_index)
+ {
+ p_contact_text_data->field_names[(*p_current_name_index)++] = strdup(T_(CT_GET_TEXT_BASIC, CTTEXT_JOB_TITLE));
+ }
+ }
+ return *p_current_name_index == *p_current_data_index;
+}
+
+/**
+ * @brief Fill numbers of contact to @a p_text_as_data structure
+ * @param[in] p_contact_text_data Pointer to structure with data of contact
+ * @param[out] p_current_name_index Current index of string with name of type
+ * @param[out] p_current_data_index Current index of string with info
+ * @return true if success, otherwise false
+ */
+static bool ct_fill_number(ct_send_as_text_data* p_contact_text_data, size_t* p_current_name_index, size_t* p_current_data_index)
+{
+ PH_TRACE;
+ if(p_contact_text_data && p_current_name_index && p_current_data_index)
+ {
+ ct_fill_name_for_text_data(_contacts_contact.number, _contacts_number.type, _contacts_number.label,
+ p_contact_text_data, CT_GET_TEXT_NUM_TYPE, p_current_name_index);
+ ct_fill_info_field_to_text_data(_contacts_contact.number, _contacts_number.number,
+ p_contact_text_data, ct_get_str_from_child_record, p_current_data_index);
+ }
+ return *p_current_name_index == *p_current_data_index;
+}
+
+/**
+ * @brief Fill mails of contact to @a p_text_as_data structure
+ * @param[in] p_contact_text_data Pointer to structure with data of contact
+ * @param[out] p_current_name_index Current index of string with name of type
+ * @param[out] p_current_data_index Current index of string with info
+ * @return true if success, otherwise false
+ */
+static bool ct_fill_email(ct_send_as_text_data* p_contact_text_data, size_t* p_current_name_index, size_t* p_current_data_index)
+{
+ PH_TRACE;
+ if(p_contact_text_data && p_current_name_index && p_current_data_index)
+ {
+ ct_fill_name_for_text_data(_contacts_contact.email, _contacts_email.type, _contacts_email.label,
+ p_contact_text_data, CT_GET_TEXT_EMAIL_TYPE, p_current_name_index);
+ ct_fill_info_field_to_text_data(_contacts_contact.email, _contacts_email.email,
+ p_contact_text_data, ct_get_str_from_child_record, p_current_data_index);
+ }
+ return *p_current_name_index == *p_current_data_index;
+}
+
+/**
+ * @brief Fill addresses of contact to @a p_text_as_data structure
+ * @param[in] p_contact_text_data Pointer to structure with data of contact
+ * @param[out] p_current_name_index Current index of string with name of type
+ * @param[out] p_current_data_index Current index of string with info
+ * @return true if success, otherwise false
+ */
+static bool ct_fill_address(ct_send_as_text_data* p_contact_text_data, size_t* p_current_name_index, size_t* p_current_data_index)
+{
+ PH_TRACE;
+ if(p_contact_text_data && p_current_name_index && p_current_data_index)
+ {
+ ct_fill_name_for_text_data(_contacts_contact.address, _contacts_address.type, _contacts_address.label,
+ p_contact_text_data, CT_GET_TEXT_POSTAL_TYPE, p_current_name_index);
+ ct_fill_info_field_to_text_data(_contacts_contact.address, 0,
+ p_contact_text_data, ct_get_address_from_child_record, p_current_data_index);
+ }
+ return *p_current_name_index == *p_current_data_index;
+}
+
+/**
+ * @brief Fill instant messengers of contact to @a p_text_as_data structure
+ * @param[in] p_contact_text_data Pointer to structure with data of contact
+ * @param[out] p_current_name_index Current index of string with name of type
+ * @param[out] p_current_data_index Current index of string with info
+ * @return true if success, otherwise false
+ */
+static bool ct_fill_instant_messenger(ct_send_as_text_data* p_contact_text_data, size_t* p_current_name_index, size_t* p_current_data_index)
+{
+ PH_TRACE;
+ if(p_contact_text_data && p_current_name_index && p_current_data_index)
+ {
+ ct_fill_name_for_text_data(_contacts_contact.messenger, _contacts_messenger.type, _contacts_messenger.label,
+ p_contact_text_data, CT_GET_TEXT_IM_TYPE, p_current_name_index);
+ ct_fill_info_field_to_text_data(_contacts_contact.messenger, _contacts_messenger.im_id,
+ p_contact_text_data, ct_get_str_from_child_record, p_current_data_index);
+ }
+ return *p_current_name_index == *p_current_data_index;
+}
+
+/**
+ * @brief Fill websites of contact to @a p_text_as_data structure
+ * @param[in] p_contact_text_data Pointer to structure with data of contact
+ * @param[out] p_current_name_index Current index of string with name of type
+ * @param[out] p_current_data_index Current index of string with info
+ * @return true if success, otherwise false
+ */
+static bool ct_fill_website(ct_send_as_text_data* p_contact_text_data, size_t* p_current_name_index, size_t* p_current_data_index)
+{
+ PH_TRACE;
+ if(p_contact_text_data && p_current_name_index && p_current_data_index)
+ {
+ ct_fill_name_for_text_data(_contacts_contact.url, _contacts_url.type, _contacts_url.label,
+ p_contact_text_data, CT_GET_TEXT_WEBSITE_TYPE, p_current_name_index);
+ ct_fill_info_field_to_text_data(_contacts_contact.url, _contacts_url.url,
+ p_contact_text_data, ct_get_str_from_child_record, p_current_data_index);
+ }
+ return *p_current_name_index == *p_current_data_index;
+}
+
+/**
+ * @brief Fill relationships of contact to @a p_text_as_data structure
+ * @param[in] p_contact_text_data Pointer to structure with data of contact
+ * @param[out] p_current_name_index Current index of string with name of type
+ * @param[out] p_current_data_index Current index of string with info
+ * @return true if success, otherwise false
+ */
+static bool ct_fill_relationship(ct_send_as_text_data* p_contact_text_data, size_t* p_current_name_index, size_t* p_current_data_index)
+{
+ PH_TRACE;
+ if(p_contact_text_data && p_current_name_index && p_current_data_index)
+ {
+ ct_fill_name_for_text_data(_contacts_contact.relationship, _contacts_relationship.type, _contacts_relationship.label,
+ p_contact_text_data, CT_GET_TEXT_RELATIONSHIP_TYPE, p_current_name_index);
+ ct_fill_info_field_to_text_data(_contacts_contact.relationship, _contacts_relationship.name,
+ p_contact_text_data, ct_get_str_from_child_record, p_current_data_index);
+ }
+ return *p_current_name_index == *p_current_data_index;
+}
+
+/**
+ * @brief Fill events of contact to @a p_text_as_data structure
+ * @param[in] p_contact_text_data Pointer to structure with data of contact
+ * @param[out] p_current_name_index Current index of string with name of type
+ * @param[out] p_current_data_index Current index of string with info
+ * @return true if success, otherwise false
+ */
+static bool ct_fill_event(ct_send_as_text_data* p_contact_text_data, size_t* p_current_name_index, size_t* p_current_data_index)
+{
+ PH_TRACE;
+ if(p_contact_text_data && p_current_name_index && p_current_data_index)
+ {
+ ct_fill_name_for_text_data(_contacts_contact.event, _contacts_event.type, _contacts_event.label,
+ p_contact_text_data, CT_GET_TEXT_EVENT_TYPE, p_current_name_index);
+ ct_fill_info_field_to_text_data(_contacts_contact.event, 0,
+ p_contact_text_data, ct_get_event_from_child_record, p_current_data_index);
+ }
+ return *p_current_name_index == *p_current_data_index;
+}
+
+/**
+ * @brief Fill note of contact to @a p_text_as_data structure
+ * @param[in] p_contact_text_data Pointer to structure with data of contact
+ * @param[out] p_current_name_index Current index of string with name of type
+ * @param[out] p_current_data_index Current index of string with info
+ * @return true if success, otherwise false
+ */
+static bool ct_fill_note(ct_send_as_text_data* p_contact_text_data, size_t* p_current_name_index, size_t* p_current_data_index)
+{
+ PH_TRACE;
+ if(p_contact_text_data && p_current_name_index && p_current_data_index)
+ {
+ ct_fill_info_field_to_text_data(_contacts_contact.note, _contacts_note.note,
+ p_contact_text_data, ct_get_str_from_child_record, p_current_data_index);
+ if(*p_current_data_index > *p_current_name_index)
+ {
+ p_contact_text_data->field_names[(*p_current_name_index)++] = strdup(T_(CT_GET_TEXT_BASIC, CTTEXT_NOTE));
+ }
+ }
+ return *p_current_name_index == *p_current_data_index;
+}
+
+/**
+ * @brief Fill contact information as text to @a p_text_as_data structure
+ * @param[in] p_contact_text_data Pointer to structure with data of contact
+ * return true if at least one field filled, otherwise false
+ */
+static bool ct_fill_as_text(ct_send_as_text_data* p_contact_text_data)
+{
+ PH_TRACE;
+ p_retvm_if(NULL == p_contact_text_data, false, "p_contact_text_data is null");
+ size_t temp_name_index(0);
+ size_t temp_data_index(0);
+ size_t current_name_index(0);
+ size_t current_data_index(0);
+ ct_fill_function* fill_functions[] =
+ {
+ ct_fill_display_name,
+ ct_fill_nickname,
+ ct_fill_company,
+ ct_fill_job_title,
+ ct_fill_number,
+ ct_fill_email,
+ ct_fill_address,
+ ct_fill_instant_messenger,
+ ct_fill_website,
+ ct_fill_relationship,
+ ct_fill_event,
+ ct_fill_note
+ };
+ size_t functions_count = (sizeof(fill_functions) / sizeof(ct_fill_function*));
+ for(size_t i = 0; i < functions_count; ++i)
+ {
+ temp_name_index = current_name_index;
+ temp_data_index = current_data_index;
+ if((*fill_functions[i])(p_contact_text_data, &temp_name_index, &temp_data_index))
+ {
+ current_name_index = temp_name_index;
+ current_data_index = temp_data_index;
+ }
+ }
+ return (p_contact_text_data->fields_count > 0);
+}
+
+/**
+ * @brief Gets contact record
+ * @param[in] id ID of contact
+ * @return handle to record if success, otherwise false
+ */
+static contacts_record_h ct_get_contact_record_by_id(unsigned int id)
+{
+ PH_TRACE;
+ contacts_record_h record = NULL;
+ if(contacts_db_get_record(_contacts_contact._uri, id, &record)
+ != CONTACTS_ERROR_NONE)
+ {
+ ERR("error getting contact record");
+ record = NULL;
+ }
+ return record;
+}
+
+/**
+ * @brief Free array of strings and assign a NULL value to @a ptr
+ * @param[in] ptr Pointer to array of arrays
+ * @param[in] size Size of array
+ */
+static void ct_free_array_of_strings(char** ptr, size_t size)
+{
+ PH_TRACE;
+ for(size_t i = 0; i < size; ++i)
+ {
+ free(ptr[i]);
+ }
+ free(ptr);
+}
+
+/**
+ * @brief Destroy all data in @a p_text_as_data structure
+ * @param[in] p_contact_text_data Pointer to structure with data of contact
+ */
+static void ct_clear_contacts_text_data(ct_send_as_text_data* p_contact_text_data)
+{
+ PH_TRACE;
+ p_retm_if(NULL == p_contact_text_data, "p_contact_text_data is null");
+ p_contact_text_data->contact_id = 0;
+ if(p_contact_text_data->contact_record)
+ {
+ if(contacts_record_destroy(p_contact_text_data->contact_record, true) != CONTACTS_ERROR_NONE)
+ {
+ ERR("Freeing contact_record failed");
+ }
+ p_contact_text_data->contact_record = NULL;
+ }
+ ct_free_array_of_strings(p_contact_text_data->field_names, p_contact_text_data->fields_count);
+ p_contact_text_data->field_names = NULL;
+ ct_free_array_of_strings(p_contact_text_data->strings_of_data, p_contact_text_data->fields_count);
+ p_contact_text_data->strings_of_data = NULL;
+ free(p_contact_text_data->checked_items);
+ p_contact_text_data->checked_items = NULL;
+ phone_destroy_confirm_popup_data(p_contact_text_data->p_popup_data);
+ p_contact_text_data->p_popup_data = NULL;
+ if(p_contact_text_data->genlist)
+ {
+ if(p_contact_text_data->box)
+ {
+ elm_box_unpack(p_contact_text_data->box, p_contact_text_data->genlist);
+ }
+ elm_genlist_clear(p_contact_text_data->genlist);
+ evas_object_del(p_contact_text_data->genlist);
+ p_contact_text_data->genlist = NULL;
+ }
+ if(p_contact_text_data->genlist_item_class)
+ {
+ elm_genlist_item_class_free(p_contact_text_data->genlist_item_class);
+ p_contact_text_data->genlist_item_class = NULL;
+ }
+ if(p_contact_text_data->select_all_layout)
+ {
+ if(p_contact_text_data->box)
+ {
+ elm_box_unpack(p_contact_text_data->box, p_contact_text_data->select_all_layout);
+ }
+ evas_object_del(p_contact_text_data->select_all_layout);
+ p_contact_text_data->select_all_layout = NULL;
+ }
+ if(p_contact_text_data->box)
+ {
+ evas_object_del(p_contact_text_data->box);
+ p_contact_text_data->box = NULL;
+ }
+ if(p_contact_text_data->formatter)
+ {
+ udat_close(p_contact_text_data->formatter);
+ p_contact_text_data->formatter = NULL;
+ }
+ p_contact_text_data->fields_count = 0;
+ p_contact_text_data->ug = NULL;
+ p_contact_text_data->child_ug = NULL;
+}
+
+void ct_destroy_contact_as_text_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ p_retm_if(NULL == data, "p_popup is null");
+ ct_clear_contacts_text_data((ct_send_as_text_data*)data);
+}
+
+/**
+ * @brief Merge two arrays of strings in one string
+ * @remark return value must be destroy with free by you
+ * @param[in] lhs Left hand side array of strings
+ * @param[in] rhs Right hand side array of strings
+ * @param[in] array_size Size of each array
+ * @param[in] separator Separator between each merged strings (optional)
+ * @param[in] string_picking_pattern Array of boolean values to pick certain strings (optional)
+ * @return merged string on success, otherwise NULL
+ */
+static char* ct_merge_two_arrays_of_strings(char** lhs, char** rhs, size_t arrays_size,
+ const char* separator = NULL, bool* string_picking_pattern = NULL)
+{
+ PH_TRACE;
+ char* result = NULL;
+ p_retvm_if(!lhs || !rhs, NULL, "some of arrays is NULL");
+ size_t size_to_reserve(0);
+ for(size_t i = 0; i < arrays_size; ++i)
+ {
+ if( (!string_picking_pattern)
+ || (string_picking_pattern && string_picking_pattern[i]))
+ {
+ size_t temp_size = SAFE_STRLEN(lhs[i]) + SAFE_STRLEN(rhs[i]) + SAFE_STRLEN(separator);
+ if(temp_size > 0)
+ {
+ size_to_reserve += (temp_size + strlen("\n"));
+ }
+ }
+ }
+ if(size_to_reserve > 0)
+ {
+ ++size_to_reserve;
+ result = (char*)calloc(size_to_reserve, sizeof(char));
+ for(size_t i = 0; i < arrays_size; ++i)
+ {
+ if( (!string_picking_pattern)
+ || (string_picking_pattern && string_picking_pattern[i]))
+ {
+ if(lhs[i] && rhs[i])
+ {
+ strcat(result, lhs[i]);
+ if(separator)
+ {
+ strcat(result, separator);
+ }
+ strcat(result, rhs[i]);
+ strcat(result, "\n");
+ }
+ }
+ }
+ }
+ return result;
+}
+
+void ct_destroy_ug_cb(void* data)
+{
+ PH_TRACE;
+ p_retm_if(NULL == data, "data is null");
+ ui_gadget_h* ug = (ui_gadget_h*)data;
+ p_retm_if(NULL == *ug, "ug is null");
+ ug_destroy(*ug);
+ *ug = NULL;
+}
+
+void ct_send_contact_as_text_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ const char* separator = " ";
+ p_retm_if(NULL == data, "data is null");
+ ct_send_as_text_data* p_contact_text_data = (ct_send_as_text_data*)data;
+ p_retm_if(NULL == p_contact_text_data->p_popup_data->popup, "popup is null");
+
+ char* message_text = ct_merge_two_arrays_of_strings(p_contact_text_data->field_names, p_contact_text_data->strings_of_data,
+ p_contact_text_data->fields_count, separator, p_contact_text_data->checked_items);
+ p_contact_text_data->child_ug = ctui_predefined_body_msg_ug(p_contact_text_data->ug, NULL, 0, message_text,
+ ct_destroy_ug_cb, &p_contact_text_data->child_ug);
+ free(message_text);
+
+ ct_destroy_contact_as_text_cb(p_contact_text_data, NULL, NULL);
+}
+
+/**
+ * @brief Create and initiate ct_confirm_popup_data structure
+ * @remark return value must be destroy with phone_destroy_confirm_popup_data by you
+ * @param[in] parent Parent for popup
+ * @param[in] p_contact_text_data Pointer to structure with data of contact
+ * @return pointer to newly created ct_confirm_popup_data structure if success, otherwise NULL
+ */
+static ct_confirm_popup_data* ct_create_popup_data_for_send_contact_as_text(Evas_Object* parent, ct_send_as_text_data* p_contact_text_data)
+{
+ PH_TRACE;
+ bool isOk(false);
+ ct_confirm_popup_data* inner_popup_as_data = NULL;
+ inner_popup_as_data = (ct_confirm_popup_data*)calloc(1, sizeof(ct_confirm_popup_data));
+ if(p_contact_text_data && inner_popup_as_data)
+ {
+ inner_popup_as_data->parent = parent;
+ inner_popup_as_data->popup = NULL;
+ inner_popup_as_data->button1 = NULL;
+ inner_popup_as_data->button2 = NULL;
+ inner_popup_as_data->popup_label = phone_get_contact_name(p_contact_text_data->contact_id);
+ inner_popup_as_data->button1_label = strdup(S_(PH_SYS_SK_OK));
+ inner_popup_as_data->button2_label = strdup(S_(PH_SYS_SK_CANCEL));
+ if( inner_popup_as_data->popup_label
+ && inner_popup_as_data->button1_label
+ && inner_popup_as_data->button2_label)
+ {
+ inner_popup_as_data->button1_cb = ct_send_contact_as_text_cb;
+ inner_popup_as_data->button2_cb = ct_destroy_contact_as_text_cb;
+ inner_popup_as_data->button1_data = p_contact_text_data;
+ inner_popup_as_data->button2_data = p_contact_text_data;
+ isOk = true;
+ }
+ }
+ if(!isOk)
+ {
+ phone_destroy_confirm_popup_data(inner_popup_as_data);
+ }
+ return inner_popup_as_data;
+}
+
+static char* ct_get_text_as_data_item_text_cb(void* data, Evas_Object* obj, const char* part)
+{
+ PH_TRACE;
+ char* result = NULL;
+ p_retvm_if(NULL == data, NULL, "invalid data");
+ ct_send_as_text_with_additional_info* p_additional_info = (ct_send_as_text_with_additional_info*)data;
+ p_retvm_if(NULL == p_additional_info->p_contact_text_data, NULL, "text as data is null");
+ p_retvm_if(NULL == p_additional_info->p_contact_text_data->field_names, NULL, "names is null");
+ p_retvm_if(NULL == p_additional_info->p_contact_text_data->strings_of_data, NULL, "strings of data is null");
+ p_retvm_if(p_additional_info->p_contact_text_data->fields_count < p_additional_info->current_index, NULL, "incorrect current index");
+ if(0 == strcmp(part, "elm.text.1"))
+ {
+ result = strdup(p_additional_info->p_contact_text_data->strings_of_data[p_additional_info->current_index]);
+ }
+ else if(0 == strcmp(part, "elm.text.2"))
+ {
+ result = strdup(p_additional_info->p_contact_text_data->field_names[p_additional_info->current_index]);
+ }
+ return result;
+}
+
+static Evas_Object* ct_get_text_as_data_item_content_cb(void* data, Evas_Object* obj,
+ const char* part)
+{
+ PH_TRACE;
+ p_retvm_if(NULL == data, NULL, "data is null");
+ ct_send_as_text_with_additional_info* p_additional_info = (ct_send_as_text_with_additional_info*)data;
+ p_retvm_if(NULL == p_additional_info->p_contact_text_data, NULL, "text as data is null");
+ p_retvm_if(NULL == p_additional_info->p_contact_text_data->checked_items, NULL, "checked items is null");
+ p_retvm_if(NULL == obj, NULL, "item is null");
+ Eina_Bool checked = p_additional_info->p_contact_text_data->checked_items[p_additional_info->current_index];
+ Evas_Object *check = NULL;
+
+ if(0 == strcmp(part, "elm.edit.icon.1"))
+ {
+ check = elm_check_add(obj);
+ if(check)
+ {
+ evas_object_propagate_events_set(check, EINA_TRUE);
+ p_retvm_if(NULL == check, NULL, "elm_check_add() return NULL");
+ elm_check_state_pointer_set(check, &checked);
+ }
+ }
+ return check;
+}
+
+void ct_data_deletion_func_cb(void *data, Evas_Object *obj)
+{
+ PH_TRACE;
+ free(data);
+}
+
+void ct_contact_as_text_select_all_cb(void *data, Eina_Bool checked)
+{
+ PH_TRACE;
+ p_retm_if(NULL == data, "data is null");
+ ct_send_as_text_data* p_contact_text_data = (ct_send_as_text_data*)data;
+ p_retm_if(NULL == p_contact_text_data->checked_items, "checked items is null");
+ p_retm_if(NULL == p_contact_text_data->genlist, "genlist is null");
+ for(size_t i = 0; i < p_contact_text_data->fields_count; ++i)
+ {
+ p_contact_text_data->checked_items[i] = checked;
+ }
+ elm_genlist_realized_items_update(p_contact_text_data->genlist);
+ if( p_contact_text_data->p_popup_data
+ && p_contact_text_data->p_popup_data->button1)
+ {
+ elm_object_disabled_set(p_contact_text_data->p_popup_data->button1, !checked);
+ }
+}
+
+/**
+ * @brief Initialise popup for ct_send_as_text_data structure
+ * @param[in] parent Parent for popup
+ * @param[in] p_contact_text_data Pointer to structure with data of contact
+ * @return true if success, otherwise false
+ */
+static bool ct_init_popup_for_contact_text_data(Evas_Object* parent, ct_send_as_text_data* p_contact_text_data)
+{
+ PH_TRACE;
+ bool result(false);
+ p_retvm_if(NULL == parent, false, "parent is null");
+ p_retvm_if(NULL == p_contact_text_data, false, "text data is null");
+ ct_confirm_popup_data* p_popup_data = ct_create_popup_data_for_send_contact_as_text(parent, p_contact_text_data);
+ if(p_popup_data)
+ {
+ if(phone_fill_confirm_popup_data(p_popup_data))
+ {
+ elm_object_disabled_set(p_popup_data->button1, EINA_TRUE);
+ p_contact_text_data->genlist_item_class = phone_create_item_class("2text.3/popup",
+ NULL, "edit_default",
+ ct_get_text_as_data_item_text_cb, ct_get_text_as_data_item_content_cb, NULL, ct_data_deletion_func_cb);
+ if(p_contact_text_data->genlist_item_class)
+ {
+ p_contact_text_data->box = elm_box_add(p_popup_data->popup);
+ if(p_contact_text_data->box)
+ {
+ elm_object_style_set(p_popup_data->popup, "content_no_vhpad");
+ elm_object_content_set(p_popup_data->popup,
+ p_contact_text_data->box);
+ p_contact_text_data->select_all_layout = phone_create_select_all(p_contact_text_data->box,
+ S_(PH_SYS_BODY_SELECT_ALL), ct_contact_as_text_select_all_cb, p_contact_text_data);
+ if(p_contact_text_data->select_all_layout)
+ {
+ evas_object_size_hint_align_set(p_contact_text_data->select_all_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_box_pack_end(p_contact_text_data->box, p_contact_text_data->select_all_layout);
+ p_contact_text_data->genlist = elm_genlist_add(p_contact_text_data->box);
+ if(p_contact_text_data->genlist)
+ {
+ evas_object_size_hint_weight_set(p_contact_text_data->genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(p_contact_text_data->genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_box_pack_end(p_contact_text_data->box, p_contact_text_data->genlist);
+ evas_object_show(p_contact_text_data->box);
+ evas_object_show(p_contact_text_data->select_all_layout);
+ evas_object_show(p_contact_text_data->genlist);
+ p_contact_text_data->p_popup_data = p_popup_data;
+ result = true;
+ }
+ }
+ }
+ }
+ }
+ }
+ if(!result)
+ {
+ ERR("ct_init_visual_part_for_text_as_data failed");
+ }
+ return result;
+}
+
+/**
+ * @brief Initialise @a p_text_as_data structure
+ * @remark returned @a p_text_as_data structure must be destroyed with ct_clear_contacts_text_data by you
+ * @param[in] id ID of contact
+ * @param[in] parent Parent for popup
+ * @param[in] current_ug Current user gadget
+ * @param[out] p_contact_text_data Pointer to structure with data of contact
+ * return true if success, otherwise false
+ */
+static bool ct_init_text_as_data(int id, Evas_Object* parent, ui_gadget_h current_ug, ct_send_as_text_data** p_contact_text_data)
+{
+ PH_TRACE;
+ bool result(false);
+ ct_send_as_text_data* inner_contact_text_data = NULL;
+ inner_contact_text_data = (ct_send_as_text_data*)calloc(1, sizeof(ct_send_as_text_data));
+ inner_contact_text_data->contact_id = id;
+ if(inner_contact_text_data)
+ {
+ inner_contact_text_data->contact_record = ct_get_contact_record_by_id(id);
+ if(inner_contact_text_data->contact_record)
+ {
+ inner_contact_text_data->fields_count = ct_get_field_count(inner_contact_text_data->contact_record);
+ if(inner_contact_text_data->fields_count > 0)
+ {
+ inner_contact_text_data->field_names = (char**)calloc(inner_contact_text_data->fields_count, sizeof(char*));
+ inner_contact_text_data->strings_of_data = (char**)calloc(inner_contact_text_data->fields_count, sizeof(char*));
+ inner_contact_text_data->checked_items = (bool*) calloc(inner_contact_text_data->fields_count, sizeof(bool));
+ if( inner_contact_text_data->field_names
+ && inner_contact_text_data->strings_of_data
+ && inner_contact_text_data->checked_items)
+ {
+ inner_contact_text_data->formatter = phone_init_time_formatter();
+ if(inner_contact_text_data->formatter)
+ {
+ if(parent)
+ {
+ if(ct_init_popup_for_contact_text_data(parent, inner_contact_text_data))
+ {
+ inner_contact_text_data->ug = current_ug;
+ inner_contact_text_data->child_ug = NULL;
+ result = true;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ if(result)
+ {
+ if(*p_contact_text_data)
+ {
+ free(*p_contact_text_data);
+ }
+ *p_contact_text_data = inner_contact_text_data;
+ }
+ else
+ {
+ ERR("Initialising text_as_data failed");
+ ct_clear_contacts_text_data(inner_contact_text_data);
+ }
+ return result;
+}
+
+/**
+ * @brief Concatenate @a lhs and @a rhs and return a newly allocated string
+ * @remark Returned value must be destroyed with free by you
+ * @param[in] lhs Lhs string
+ * @param[in] rhs Rhs string
+ * @param[in] separator Separator between strings (optional)
+ *
+ */
+static char* ct_concatenate_strings(const char* lhs, const char* rhs, const char* separator = NULL)
+{
+ PH_TRACE;
+ char* result = NULL;
+ p_retvm_if(!lhs || !rhs, NULL, "some of strings is NULL");
+ size_t strings_size = strlen(lhs) + strlen(rhs) + SAFE_STRLEN(separator);
+ if(strings_size > 0)
+ {
+ ++strings_size;
+ result = (char*)calloc(strings_size, sizeof(char));
+ strcpy(result, lhs);
+ if(separator)
+ {
+ strcat(result, separator);
+ }
+ strcat(result, rhs);
+ }
+ return result;
+}
+
+/**
+ * @brief Checks whether any item checked
+ * @param[in] p_contact_text_data Pointer to structure with data of contact
+ * @return true if any item checked, otherwise false
+ */
+static bool ct_is_any_contact_item_checked(ct_send_as_text_data* p_contact_text_data)
+{
+ PH_TRACE;
+ p_retvm_if(NULL == p_contact_text_data, false, "text data is null");
+ bool result(false);
+ for(size_t i = 0; i < p_contact_text_data->fields_count; ++i)
+ {
+ result = p_contact_text_data->checked_items[i];
+ if(result)
+ {
+ break;
+ }
+ }
+ return result;
+}
+
+/**
+ * @brief Checks whether all item checked
+ * @param[in] p_contact_text_data Pointer to structure with data of contact
+ * @return true if all item checked, otherwise false
+ */
+static bool ct_is_all_contact_item_checked(ct_send_as_text_data* p_contact_text_data)
+{
+ PH_TRACE;
+ p_retvm_if(NULL == p_contact_text_data, false, "text data is null");
+ bool result(false);
+ for(size_t i = 0; i < p_contact_text_data->fields_count; ++i)
+ {
+ result = p_contact_text_data->checked_items[i];
+ if(!result)
+ {
+ break;
+ }
+ }
+ return result;
+}
+
+/**
+ * @brief Update state of @a select_all_layout
+ * @param[in] select_all_layout Layout with check and label
+ * @param[in] checked New state for check in @a select_all_layout
+ */
+static void ct_update_select_all_state(Evas_Object* select_all_layout, bool checked)
+{
+ if (select_all_layout)
+ {
+ Evas_Object *check = elm_object_part_content_get(select_all_layout, "elm.icon");
+ if (check)
+ {
+ elm_check_state_set(check, checked);
+ }
+ }
+}
+
+void ct_send_as_text_genlist_item_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ p_retm_if(NULL == data, "data is NULL");
+ p_retm_if(NULL == event_info, "event_info is NULL");
+ Elm_Object_Item* item = (Elm_Object_Item*)event_info;
+ ct_send_as_text_with_additional_info* p_additional_info =
+ (ct_send_as_text_with_additional_info*)data;
+ p_retm_if(NULL == p_additional_info->p_contact_text_data, "text data is null");
+ p_retm_if(p_additional_info->p_contact_text_data->fields_count
+ < p_additional_info->current_index, "incorrect current index");
+ p_retm_if(NULL == p_additional_info->p_contact_text_data->select_all_layout, "select all layout is null");
+
+ if( p_additional_info->p_contact_text_data
+ && p_additional_info->p_contact_text_data->fields_count > p_additional_info->current_index
+ && p_additional_info->p_contact_text_data->checked_items)
+ {
+ p_additional_info->p_contact_text_data->checked_items[p_additional_info->current_index] =
+ !p_additional_info->p_contact_text_data->checked_items[p_additional_info->current_index];
+ }
+ elm_genlist_item_selected_set(item, EINA_FALSE);
+ elm_genlist_item_fields_update(item, "elm.edit.icon.1", ELM_GENLIST_ITEM_FIELD_CONTENT);
+
+ bool select_all_checked = ct_is_all_contact_item_checked(p_additional_info->p_contact_text_data);
+ ct_update_select_all_state(p_additional_info->p_contact_text_data->select_all_layout, select_all_checked);
+ bool is_any_item_checked = ct_is_any_contact_item_checked(p_additional_info->p_contact_text_data);
+ if( p_additional_info->p_contact_text_data->p_popup_data
+ && p_additional_info->p_contact_text_data->p_popup_data->button1)
+ {
+ elm_object_disabled_set(p_additional_info->p_contact_text_data->p_popup_data->button1, !is_any_item_checked);
+ }
+}
+
+static bool ct_fill_genlist(ct_send_as_text_data* p_contact_text_data)
+{
+ PH_TRACE;
+ p_retvm_if(NULL == p_contact_text_data, false, "p_text_as_data is null");
+ bool result(false);
+ if(p_contact_text_data->genlist && p_contact_text_data->genlist_item_class)
+ {
+ for(size_t i = 0; i < p_contact_text_data->fields_count; ++i)
+ {
+ ct_send_as_text_with_additional_info* p_send_as_text_additional_info =
+ (ct_send_as_text_with_additional_info*)malloc(sizeof(ct_send_as_text_with_additional_info));
+ if(p_send_as_text_additional_info)
+ {
+ p_send_as_text_additional_info->current_index = i;
+ p_send_as_text_additional_info->p_contact_text_data = p_contact_text_data;
+
+ result = (elm_genlist_item_append(p_contact_text_data->genlist, p_contact_text_data->genlist_item_class,
+ p_send_as_text_additional_info, NULL, ELM_GENLIST_ITEM_NONE,
+ ct_send_as_text_genlist_item_cb, p_send_as_text_additional_info) != NULL);
+ if(!result)
+ {
+ break;
+ }
+ }
+ }
+ }
+ return result;
+}
+
+void ct_process_send_contact_as_text(int contact_id, int person_id, Evas_Object* navi, ui_gadget_h ug, ui_gadget_h* p_child_ug)
+{
+ PH_TRACE;
+ p_retm_if(NULL == p_child_ug, "p_child_ug is null");
+ if(*p_child_ug)
+ {
+ ct_destroy_ug_cb(p_child_ug);
+ }
+ ct_send_as_text_data* p_contact_text_data = NULL;
+ if(ct_init_text_as_data(contact_id, navi, ug, &p_contact_text_data))
+ {
+ if(ct_fill_as_text(p_contact_text_data))
+ {
+ if(p_contact_text_data->fields_count == 1)
+ {
+
+ const char* separator = " ";
+ char* message_text = ct_concatenate_strings(p_contact_text_data->field_names[0], p_contact_text_data->strings_of_data[0], separator);
+ *p_child_ug = ctui_predefined_body_msg_ug(ug, NULL, person_id, message_text,
+ ct_destroy_ug_cb, p_child_ug);
+ free(message_text);
+ }
+ else
+ {
+ if(p_contact_text_data->p_popup_data && p_contact_text_data->p_popup_data->popup)
+ {
+ evas_object_show(p_contact_text_data->p_popup_data->popup);
+ ct_fill_genlist(p_contact_text_data);
+ elm_genlist_decorate_mode_set(p_contact_text_data->genlist, EINA_TRUE);
+ }
+ }
+ }
+ }
+}
+
+void list_send_contact_as_text_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ p_retm_if(NULL == data, "data is null");
+ ct_list_data *clist_d = (ct_list_data *) data;
+ ct_person_list *person_info = (ct_person_list *) evas_object_data_get(
+ clist_d->popup, PERSON_INFO);
+
+ list_hide_popup_cb(clist_d);
+ p_retm_if(NULL == person_info, "person_info is NULL");
+
+ int contact_id = phone_get_contact_id_by_person_id(person_info->id);
+ ct_process_send_contact_as_text(contact_id, person_info->id, clist_d->navi, clist_d->ug, &clist_d->child_ug);
+}
+
+bool ct_list_str_to_bool(const std::string& strVal)
+{
+ PH_TRACE;
+ return !(strVal == "0");
+}
+
+std::string ct_list_bool_to_str(bool bVal)
+{
+ PH_TRACE;
+ return bVal == false ? "0" : "1";
+}
+
+bool ct_list_insert_extension(contacts_record_h extensionRec,
+ unsigned int extensionField, int contactId, const std::string& strValue)
+{
+ PH_TRACE;
+ bool result(false);
+ if (contacts_record_set_str(extensionRec, extensionField, strValue.c_str())
+ == CONTACTS_ERROR_NONE)
+ {
+ if (contacts_record_set_int(extensionRec,
+ _contacts_extension.contact_id, contactId)
+ == CONTACTS_ERROR_NONE)
+ {
+ int extId(0);
+ if (contacts_db_insert_record(extensionRec, &extId)
+ == CONTACTS_ERROR_NONE)
+ {
+ result = true;
+ }
+ }
+ }
+ return result;
+}
+
+bool ct_list_toggle_blocked(contacts_record_h contactRec,
+ contacts_record_h extensionRec)
+{
+ PH_TRACE;
+ bool result(false);
+ if (contacts_record_get_child_record_at_p(contactRec,
+ _contacts_contact.extension, 0, &extensionRec)
+ == CONTACTS_ERROR_NONE)
+ {
+ char* strIsBlocked = NULL;
+ if (contacts_record_get_str(extensionRec, _contacts_extension.data2,
+ &strIsBlocked) == CONTACTS_ERROR_NONE)
+ {
+ bool bIsBlocked = ct_list_str_to_bool(strIsBlocked);
+ std::string newStrVal = ct_list_bool_to_str(!bIsBlocked);
+ if (contacts_record_set_str(extensionRec, _contacts_extension.data2,
+ newStrVal.c_str()) == CONTACTS_ERROR_NONE)
+ {
+ if (contacts_db_update_record(contactRec)
+ == CONTACTS_ERROR_NONE)
+ {
+ result = true;
+ }
+ }
+ }
+ if (strIsBlocked)
+ {
+ free(strIsBlocked);
+ }
+ }
+ return result;
+}
+
+void list_block_contact_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ p_retm_if(NULL == data, "data is null");
+ ct_list_data *clist_d = (ct_list_data *) data;
+ ct_person_list *person_info = (ct_person_list *) evas_object_data_get(
+ clist_d->popup, PERSON_INFO);
+
+ list_hide_popup_cb(clist_d);
+ p_retm_if(NULL == person_info, "person_info is NULL");
+
+ clist_d->popup = phone_create_block_contact_popup(clist_d->navi, phone_get_contact_id_by_person_id(clist_d->personId));
+}
+
+static void list_toggle_favorite_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ p_retm_if(NULL == data, "data is NULL");
+
+ ct_list_data *clist_d = (ct_list_data *) data;
+ ct_person_list *person_info = (ct_person_list *) evas_object_data_get(
+ clist_d->popup, PERSON_INFO);
+ contacts_record_h person_record = NULL;
+
+ list_hide_popup_cb(clist_d);
+ p_retm_if(NULL == person_info, "person_info is NULL");
+
+ int err = contacts_db_get_record(_contacts_person._uri, person_info->id, &person_record);
+ p_retm_if(CONTACTS_ERROR_NONE != err,
+ "contacts_db_get_record() Failed(%d)", err);
+
+ err = contacts_record_set_bool(person_record, _contacts_person.is_favorite,
+ !person_info->is_favourite);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_record_set_bool() Failed(%d)", err);
+
+ err = contacts_db_update_record(person_record);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_db_update_record() Failed(%d)", err);
+
+ if(CONTACTS_ERROR_NONE == err)
+ {
+ person_info->is_favourite = !person_info->is_favourite;
+ phone_show_tickernoti(T_(CT_GET_TEXT_BASE_OP, person_info->is_favourite ?
+ CTTEXT_ADDED_TO_FAVOURITES : CTTEXT_REMOVED_FROM_FAVOURITES));
+ }
+ else
+ {
+ phone_show_tickernoti(S_(PH_SYS_POP_FAILED));
+ }
+
+ err = contacts_record_destroy(person_record, true);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_record_destroy() Failed(%d)", err);
+}
+
+static void list_link_contacts_sel_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ p_retm_if(NULL == data, "data is NULL");
+ p_retm_if(NULL == event_info, "event_info is NULL");
+
+ ct_list_data *clist_d = (ct_list_data *) data;
+ Elm_Object_Item *item = (Elm_Object_Item *) event_info;
+ ct_person_list *person_info = (ct_person_list *) elm_object_item_data_get(item);
+ bool success = false;
+
+ elm_genlist_item_selected_set(item, EINA_FALSE);
+
+ if(person_info)
+ {
+ int err = contacts_person_link_person(clist_d->personId, person_info->id);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_person_link_person() Failed(%d)", err);
+ success = CONTACTS_ERROR_NONE == err;
+ }
+
+ phone_show_tickernoti(S_(success ?
+ CT_SYS_POP_SUCCESS : PH_SYS_POP_FAILED));
+ elm_naviframe_item_pop(clist_d->navi);
+}
+
+static void list_link_contacts_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ p_retm_if(NULL == data, "data is NULL");
+ ct_list_data *clist_d = (ct_list_data *) data;
+ ct_person_list *person_info = (ct_person_list *) evas_object_data_get(
+ clist_d->popup, PERSON_INFO);
+
+ list_hide_popup_cb(clist_d);
+ p_retm_if(NULL == person_info, "person_info is NULL");
+
+ ctui_create_list_single_select_view(clist_d->win, clist_d->navi,
+ list_link_contacts_sel_cb, clist_d, person_info->id);
+}
+
+static void ct_group_assign_result_cb(void *data)
+{
+ PH_TRACE;
+ p_retm_if(NULL == data, "data is NULL");
+ ct_person_list *person_info = (ct_person_list *) data;
+ int err = contacts_db_update_record(person_info->contact);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_db_update_record() Failed(%d)", err);
+}
+
+static void list_add_to_group_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ p_retm_if(NULL == data, "data is NULL");
+ ct_list_data *clist_d = (ct_list_data *) data;
+ ct_person_list *person_info = (ct_person_list *) evas_object_data_get(
+ clist_d->popup, PERSON_INFO);
+
+ list_hide_popup_cb(clist_d);
+ p_retm_if(NULL == person_info, "person_info is NULL");
+
+ if(!person_info->contact)
+ {
+ int contact_id = phone_get_contact_id_by_person_id(person_info->id);
+ int err = contacts_db_get_record(_contacts_contact._uri, contact_id,
+ &person_info->contact);
+ p_retm_if(CONTACTS_ERROR_NONE != err,
+ "contacts_db_get_record() Failed(%d)", err);
+ }
+
+ clist_d->popup = ct_group_assign_popup_create(clist_d->win, clist_d->navi,
+ person_info->contact, ct_group_assign_result_cb, person_info);
+}
+
+void list_create_longpressed_popup(ct_person_list *person_info, ct_list_data *clist_d)
+{
+ PH_TRACE;
+ p_retm_if(NULL == clist_d, "clist_d is null");
+ list_create_popup_with_cancel_button(*clist_d, person_info->display);
+
+ Evas_Object *genlist = elm_genlist_add(clist_d->popup);
+ p_retm_if(NULL == genlist, "genlist is null");
+ Elm_Genlist_Item_Class *longpress_item_class = list_create_class("1text/popup",
+ list_get_item_text_cb);
+
+ if (!person_info->number_list)
+ {
+ Eina_List *contact_list = ctui_person_get_contact_list(person_info->id);
+ person_info->number_list = ctui_person_get_number_list(contact_list);
+ eina_list_free(contact_list);
+ }
+
+ unsigned number_count = eina_list_count(person_info->number_list);
+ evas_object_data_set(clist_d->popup, PERSON_INFO, person_info);
+ evas_object_data_set(clist_d->genlist, NUMBER_LIST, person_info->number_list);
+
+ //Edit
+ elm_genlist_item_append(genlist, longpress_item_class,
+ S_(PH_SYS_SK_EDIT),
+ NULL, ELM_GENLIST_ITEM_NONE, list_edit_item_cb, clist_d);
+
+ //Add to group
+ elm_genlist_item_append(genlist, longpress_item_class,
+ T_(CT_GET_TEXT_BASE_OP, CTTEXT_ADD_TO_GROUP),
+ NULL, ELM_GENLIST_ITEM_NONE, list_add_to_group_cb, clist_d);
+
+ //Add to favourites
+ elm_genlist_item_append(genlist, longpress_item_class,
+ T_(CT_GET_TEXT_BASE_OP, person_info->is_favourite ?
+ CTTEXT_REMOVE_FROM_FAVOURITES : CTTEXT_ADD_TO_FAVOURITES),
+ NULL, ELM_GENLIST_ITEM_NONE, list_toggle_favorite_cb, clist_d);
+
+ //Link contact
+ elm_genlist_item_append(genlist, longpress_item_class,
+ T_(CT_GET_TEXT_BASE_OP, CTTEXT_LINK_CONTACTS),
+ NULL, ELM_GENLIST_ITEM_NONE, list_link_contacts_cb, clist_d);
+
+ if (number_count > 0)
+ {
+ //Block contact
+ elm_genlist_item_append(genlist, longpress_item_class,
+ T_(PH_GET_TEXT_BASIC, PHTEXT_EDIT_BLOCK_CONTACT),
+ NULL, ELM_GENLIST_ITEM_NONE,
+ list_block_contact_cb, clist_d);
+
+ //Default number
+ if (number_count > 1)
+ {
+ elm_genlist_item_append(genlist, longpress_item_class,
+ T_(PH_GET_TEXT_BASIC, PHTEXT_DEFAULT_NUMBER),
+ NULL, ELM_GENLIST_ITEM_NONE,
+ list_default_number_cb, clist_d);
+ }
+
+ //Send namecard
+ elm_genlist_item_append(genlist, longpress_item_class,
+ T_(CT_GET_TEXT_BASE_OP, CTTEXT_SEND_NAME_CARD),
+ NULL, ELM_GENLIST_ITEM_NONE,
+ list_send_namecard_cb, clist_d);
+
+ //Send contact as text
+ elm_genlist_item_append(genlist, longpress_item_class,
+ T_(PH_GET_TEXT_BASIC, PHTEXT_SEND_CONTACTC_AS_TEXT),
+ NULL, ELM_GENLIST_ITEM_NONE,
+ list_send_contact_as_text_cb, clist_d);
+ }
+
+ elm_object_content_set(clist_d->popup, genlist);
+
+ elm_genlist_item_class_free(longpress_item_class);
+}
+
+void list_gl_longpressed(void *data, Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ p_retm_if(NULL == data, "data is null");
+ p_retm_if(NULL == event_info, "event_info is null");
+
+ ct_list_data *clist_d = (ct_list_data *) data;
+ ct_person_list *person_info = (ct_person_list *)
+ elm_object_item_data_get((Elm_Object_Item *) event_info);
+ p_retm_if(NULL == person_info, "person_info is null");
+
+ if(NULL == clist_d->last_sweep_item)
+ {
+ clist_d->personId = person_info->id;
+ list_create_longpressed_popup(person_info, clist_d);
+ }
+}
+
+void list_gl_scroll_start_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ p_retm_if(NULL == obj, "obj is null");
+ evas_object_smart_callback_del(obj, LONGPRESSED, list_gl_longpressed);
+}
+void list_gl_scroll_end_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ PH_TRACE;
+ p_retm_if(NULL == obj, "obj is null");
+ p_retm_if(NULL == data, "data is null");
+ ct_list_data *pListData = static_cast<ct_list_data *>(data);
+ evas_object_smart_callback_add(obj, LONGPRESSED, list_gl_longpressed,
+ pListData);
+}
+
+static void update_list_searchbar(ct_list_data &clist_d)
+{
+ PH_TRACE;
+ phone_set_searchbar_add_button_visible(clist_d,
+ !message_mode_state(clist_d.ug_request, clist_d.list_mode));
+}
+
+static Evas_Object* list_create_contact_list(Evas_Object *parent,
+ ct_list_data *clist_d)
+{
+ PH_TRACE;
+ if (clist_d == NULL || parent == NULL)
+ {
+ return NULL;
+ }
+
+ elm_win_conformant_set(clist_d->win, EINA_TRUE);
+
+ if(!clist_d->layout)
+ {
+ Evas_Object *layout = elm_layout_add(parent);
+ if (CT_GET_LIST_VCARD == clist_d->list_op)
+ elm_layout_file_set(layout, CONTACTS_EDJ, "genlist_no_searchbar");
+ else
+ elm_layout_file_set(layout, CONTACTS_EDJ, "genlist");
+ evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ clist_d->layout = layout;
+ }
+
+ if (CT_GET_LIST_VCARD != clist_d->list_op)
+ {
+ if(clist_d->searchbar)
+ {
+ update_list_searchbar(*clist_d);
+ }
+ else
+ {
+ ctui_list_create_searchbar(clist_d->layout, clist_d);
+ }
+ }
+
+ clist_d->box = elm_box_add(clist_d->layout);
+ evas_object_size_hint_weight_set(clist_d->box, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ evas_object_show(clist_d->box);
+ elm_object_part_content_set(clist_d->layout, "content", clist_d->box);
+
+ // Create genlist
+ Evas_Object *genlist = list_create_navi_content_genlist(clist_d->box);
+ evas_object_show(genlist);
+ elm_object_theme_set(genlist, clist_d->th);
+
+ evas_object_smart_callback_add(genlist, "drag,start,right", list_gl_sweep,
+ clist_d);
+ evas_object_smart_callback_add(genlist, "drag,start,left", list_gl_unsweep,
+ clist_d);
+ evas_object_smart_callback_add(genlist, "drag,start,up", list_gl_unsweep,
+ clist_d);
+ evas_object_smart_callback_add(genlist, "drag,start,down", list_gl_unsweep,
+ clist_d);
+ evas_object_smart_callback_add(genlist, SCROLL_DRAG_START,
+ list_gl_scroll_start_cb, clist_d);
+ evas_object_smart_callback_add(genlist, SCROLL_DRAG_STOP,
+ list_gl_scroll_end_cb, clist_d);
+ evas_object_smart_callback_add(genlist, LONGPRESSED, list_gl_longpressed,
+ clist_d);
+
+ clist_d->genlist = genlist;
+
+ elm_box_pack_end(clist_d->box, genlist);
+ evas_object_data_set(genlist, "clist_d", clist_d);
+ elm_object_focus_set(genlist, EINA_TRUE);
+
+ if (CT_GET_LIST_VCARD != clist_d->list_op)
+ {
+ // Create fast scroll
+ Evas_Object *fast_index = elm_index_add(clist_d->layout);
+ elm_object_part_content_set(clist_d->layout, "fastscroll", fast_index);
+ evas_object_show(fast_index);
+ clist_d->fast_index = fast_index;
+ evas_object_smart_callback_add(fast_index, "delay,changed",
+ list_fast_delayed_changed, fast_index);
+ evas_object_smart_callback_add(fast_index, "selected",
+ list_fast_selected, NULL);
+ elm_index_level_go(fast_index, 0);
+ }
+
+ // Genlist item append
+ pre_search_str[0] = '\0';
+
+ evas_object_show(clist_d->layout);
+
+ return clist_d->layout;
+}
+
+static void list_resize_contact_view(void *data, Evas_Object *obj,
+ void *event_info)
+{
+ PH_TRACE;
+ Evas_Object *scroller;
+ Evas_Object *box;
+ ct_list_data *clist_d = (ct_list_data *) data;
+ int changed_rotate = elm_win_rotation_get(clist_d->win);
+
+ if (clist_d->list || clist_d->search_str)
+ return;
+
+ if (clist_d->current_rotate != changed_rotate)
+ clist_d->current_rotate = changed_rotate;
+ else
+ return;
+
+ if (0 == changed_rotate || 180 == changed_rotate)
+ {
+ scroller = elm_object_part_content_get(clist_d->content_layout,
+ "elm.swallow.content");
+ p_retm_if(NULL == scroller,
+ "elm_object_part_content_get() return NULL");
+ box = elm_object_content_get(scroller);
+ p_retm_if(NULL == box, "elm_object_content_get() return NULL");
+ elm_box_unpack(box, clist_d->nocontent);
+ p_retm_if(NULL == clist_d->nocontent, "elm_box_unpack() return NULL");
+ evas_object_size_hint_weight_set(clist_d->nocontent, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(clist_d->nocontent, EVAS_HINT_FILL,
+ 0.2);
+ elm_box_pack_end(box, clist_d->nocontent);
+ elm_object_content_set(scroller, box);
+ evas_object_size_hint_min_set(box, 720, 650);
+ elm_object_part_content_set(clist_d->content_layout,
+ "elm.swallow.content", scroller);
+ }
+ else
+ {
+ scroller = elm_object_part_content_get(clist_d->content_layout,
+ "elm.swallow.content");
+ p_retm_if(NULL == scroller,
+ "elm_object_part_content_get() return NULL");
+ box = elm_object_content_get(scroller);
+ p_retm_if(NULL == box, "elm_object_content_get() return NULL");
+ elm_box_unpack(box, clist_d->nocontent);
+ p_retm_if(NULL == clist_d->nocontent, "elm_box_unpack() return NULL");
+ evas_object_size_hint_weight_set(clist_d->nocontent, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(clist_d->nocontent, EVAS_HINT_FILL,
+ 0.0);
+ elm_box_pack_end(box, clist_d->nocontent);
+ elm_object_content_set(scroller, box);
+ evas_object_size_hint_min_set(box, 720, 650);
+ elm_object_part_content_set(clist_d->content_layout,
+ "elm.swallow.content", scroller);
+ }
+
+}
+void create_no_content_layout(ct_list_data *clist_d, Evas_Object *parent)
+{
+ PH_TRACE;
+ if(clist_d && parent)
+ {
+ elm_win_conformant_set(clist_d->win, EINA_TRUE);
+ Evas_Object *layout_search = elm_layout_add(parent);
+ elm_layout_file_set(layout_search, CONTACTS_EDJ, "genlist");
+ evas_object_size_hint_weight_set(layout_search, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ clist_d->layout = layout_search;
+
+ ctui_list_create_searchbar(layout_search, clist_d);
+ elm_object_part_content_set(parent, "elm.swallow.content",
+ layout_search);
+ elm_object_disabled_set(clist_d->searchbar, EINA_TRUE);
+
+ char buf[PH_TEXT_MAX_LEN] = { 0, };
+ Evas_Object * base = elm_layout_add(layout_search);
+ evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(base, EVAS_HINT_FILL, 0.2);
+ elm_layout_file_set(base, NOCONTENT_LAYOUT_EDJ, "nocontent_layout");
+ snprintf(buf, sizeof(buf), "%s<br>%s",
+ T_(CT_GET_TEXT_ERR, CTTEXT_NO_CONTACTS),
+ T_(CT_GET_TEXT_ERR, CTTEXT_NO_CONTACTS_HELP_TEXT));
+ elm_object_part_text_set(base, "elm.text", buf);
+ evas_object_show(base);
+ clist_d->nocontent = base;
+ clist_d->current_rotate = elm_win_rotation_get(clist_d->win);
+
+ elm_object_part_content_set(clist_d->layout, "content", base);
+
+ clear_genlist_info(*clist_d);
+ clist_d->list = NULL;
+ }
+}
+
+static void list_fill_contact_view(Evas_Object *parent, ct_list_data &clist_d)
+{
+ PH_TRACE;
+ Evas_Object *content = NULL;
+
+ if (clist_d.list || clist_d.search_str)
+ {
+ if (NULL == clist_d.genlist)
+ {
+ content = list_create_contact_list(parent, &clist_d);
+ list_append_all(&clist_d);
+
+ if (CT_LIST_MODE_EDIT == clist_d.list_mode)
+ ctui_list_edit_mode_start(&clist_d);
+ elm_object_part_content_set(parent, "elm.swallow.content", content);
+ }
+ else
+ {
+ if (clist_d.search_str && *clist_d.search_str)
+ ctui_list_handle_search(clist_d);
+ else
+ ctui_list_refresh_genlist(&clist_d);
+ }
+ evas_object_smart_callback_del(clist_d.win, "wm,rotation,changed",
+ list_resize_contact_view);
+ }
+ else
+ {
+ clist_d.list_mode = CT_LIST_MODE_DEFAULT;
+ create_no_content_layout(&clist_d, parent);
+ }
+}
+
+API Eina_Bool ctui_list_genlist_update(void *data)
+{
+ PH_TRACE;
+ char buf[PH_TEXT_MAX_LEN + 1];
+ Evas_Object *content;
+ ct_list_data *clist_d = (ct_list_data *) data;
+ if(!clist_d)
+ {
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if (clist_d->update_timer)
+ {
+ ecore_timer_del(clist_d->update_timer);
+ clist_d->update_timer = NULL;
+ }
+
+ p_retvm_if(NULL == clist_d->navi_item, ECORE_CALLBACK_CANCEL,
+ "navi_item is NULL");
+
+ ctui_list_free_contacts(clist_d->list);
+ clist_d->list = NULL;
+ ct_list_get_contacts(clist_d, &clist_d->list);
+
+ if (CT_LIST_IN_MULTI_TAB != clist_d->tab_mode
+ && CT_UG_REQUEST_SELECT_PERSON <= clist_d->ug_request)
+ {
+ snprintf(buf, sizeof(buf), "%s (%d)", clist_d->title,
+ clist_d->cnt_list_total);
+ elm_object_item_text_set(clist_d->navi_item, buf);
+ }
+
+ content = clist_d->content_layout;
+ list_fill_contact_view(content, *clist_d);
+ if (clist_d->list_navi_item_update_fn)
+ clist_d->list_navi_item_update_fn(clist_d);
+
+ clist_d->update_timer = NULL;
+ return ECORE_CALLBACK_CANCEL;
+}
+
+void ct_list_clear_pdata(ct_list_data *clist_d)
+{
+ PH_TRACE;
+ p_ret_if(NULL == clist_d);
+ p_ret_if(NULL == clist_d->p_info);
+
+ clist_d->p_info->alive = false;
+ pthread_join(clist_d->p_info->thread, NULL);
+
+ ecore_timer_del(clist_d->p_info->timer);
+
+ if (clist_d->popup)
+ {
+ evas_object_del(clist_d->popup);
+ clist_d->popup = NULL;
+ }
+
+ free(clist_d->p_info);
+ clist_d->p_info = NULL;
+}
+
+static void list_addrbook_changed(const char *view_uri, void *user_data)
+{
+ PH_TRACE;
+ ct_list_data *clist_d = (ct_list_data *) user_data;
+ ct_list_init_account_data(clist_d);
+ ctui_list_lazy_update(_contacts_person._uri, clist_d);
+}
+
+static void list_set_group_index_item(Eina_List *list_index,
+ const char *cur_index, Elm_Object_Item *cur_item)
+{
+ PH_TRACE;
+ Eina_List* l;
+ void *v_data;
+
+ EINA_LIST_FOREACH(list_index, l, v_data)
+ {
+ ct_list_index_data *data = (ct_list_index_data *) v_data;
+ if (0 == strcmp(cur_index, data->index))
+ {
+ //PH_DBG("list_append_item - %s mapping to %s", data->index, cur_index);
+ elm_object_item_data_set(data->item, cur_item);
+ break;
+ }
+ }
+}
+
+static Elm_Object_Item* list_genlist_update_group_item_get(
+ ct_list_data *clist_d, Elm_Object_Item *item, const char *cur_index)
+{
+ PH_TRACE;
+ int cmp;
+ char *item_index;
+ Elm_Object_Item *next_item;
+ Elm_Object_Item *item_ret;
+
+ if (NULL == item)
+ {
+ item_ret = elm_genlist_item_append(clist_d->genlist, &group_index,
+ strdup(cur_index), NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
+ elm_genlist_item_select_mode_set(item_ret,
+ ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+ list_set_group_index_item(clist_d->list_index, cur_index, item_ret);
+ return item_ret;
+ }
+ if (ELM_GENLIST_ITEM_GROUP != elm_genlist_item_type_get(item))
+ {
+ next_item = elm_genlist_item_next_get(item);
+ item_ret = list_genlist_update_group_item_get(clist_d, next_item,
+ cur_index);
+ elm_object_item_del(item);
+ return item_ret;
+ }
+
+ item_index = (char *) elm_object_item_data_get(item);
+ cmp = strcmp(item_index, cur_index);
+
+ if (0 == cmp)
+ {
+ return item;
+ }
+ else if (0 < cmp)
+ {
+ item_ret = elm_genlist_item_insert_before(clist_d->genlist,
+ &group_index, strdup(cur_index), NULL, item,
+ ELM_GENLIST_ITEM_GROUP, NULL, NULL);
+ elm_genlist_item_select_mode_set(item_ret,
+ ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+ list_set_group_index_item(clist_d->list_index, cur_index, item_ret);
+ return item_ret;
+ }
+ else
+ {
+ next_item = elm_genlist_item_next_get(item);
+ item_ret = list_genlist_update_group_item_get(clist_d, next_item,
+ cur_index);
+ elm_object_item_del(item);
+ return item_ret;
+ }
+}
+
+static void ct_list_update_checked_contacts(ct_list_data* contactListData)
+{
+ PH_TRACE;
+ p_retm_if(contactListData == NULL, "contact person is NULL");
+ p_retm_if(contactListData->list == NULL, "contact person list is NULL");
+ p_retm_if(contactListData->list_check_info == NULL,
+ "contact person list_check is NULL");
+
+ Eina_List* tempList = NULL;
+ void* tempData = NULL;
+ EINA_LIST_FOREACH(contactListData->list, tempList, tempData)
+ {
+ if (tempData)
+ {
+ ct_person_list* personList = static_cast<ct_person_list*>(tempData);
+ ct_person_list* personInfo = find_info_in_list_by_id(
+ contactListData->list_check_info, personList->id);
+ if (personInfo)
+ {
+ personList->checked = personInfo->checked;
+ }
+ }
+ }
+}
+void disable_count_item(ct_list_data *clist_d)
+{
+ PH_TRACE;
+ if (clist_d)
+ {
+ if (EINA_FALSE == elm_genlist_decorate_mode_get(clist_d->genlist))
+ {
+ clist_d->count_item = elm_genlist_item_append(clist_d->genlist,
+ &clist_d->itcs[CT_LIST_ITEM_COUNT],
+ (void *) clist_d->cnt_list_total, NULL,
+ ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ elm_object_item_disabled_set(clist_d->count_item, EINA_TRUE);
+ }
+ }
+}
+
+static void ctui_list_refresh_searchbar(ct_list_data *clist_d, Eina_List *list_new)
+{
+ PH_TRACE;
+ if(clist_d && clist_d->searchbar)
+ {
+ if ((!list_new && !clist_d->search_str) || NULL == clist_d->genlist)
+ {
+ elm_object_disabled_set(clist_d->searchbar, EINA_TRUE);
+ }
+ else
+ {
+ elm_object_disabled_set(clist_d->searchbar, EINA_FALSE);
+ }
+ }
+}
+
+static Eina_Bool list_genlist_update(void *data)
+{
+ PH_TRACE;
+ int ret;
+ char buf[PH_TEXT_MAX_LEN] = { 0, };
+ char group_letter[10] __attribute__ ((unused)) = { 0, };
+ Eina_List *list_new;
+ Eina_List *l;
+ Elm_Object_Item *item_cur = NULL;
+ Elm_Object_Item *item_second = NULL;
+ ct_person_list *person_info;
+ ct_list_data *clist_d = (ct_list_data *) data;
+ void * info;
+
+ if (clist_d->list_idler)
+ {
+ ecore_idler_del(clist_d->list_idler);
+ clist_d->list_idler = NULL;
+ }
+
+ if (clist_d->update_timer)
+ {
+ ecore_timer_del(clist_d->update_timer);
+ clist_d->update_timer = NULL;
+ }
+
+ p_retvm_if(NULL == clist_d->navi_item, ECORE_CALLBACK_CANCEL,
+ "navi_item is NULL");
+
+ list_new = NULL;
+ ret = ct_list_get_contacts(clist_d, &list_new);
+ if (0 != ret && ret != CONTACTS_ERROR_NO_DATA)
+ {
+ ERR("ct_list_get_contacts() Failed(%d)", ret);
+ ctui_list_free_contacts(list_new);
+ clist_d->need_update = true;
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ ctui_list_refresh_searchbar(clist_d, list_new);
+
+ if (!list_new && !clist_d->search_str)
+ {
+ update_list_searchbar(*clist_d);
+ clear_genlist_info(*clist_d);
+ }
+ else
+ {
+ Evas_Object *content = NULL;
+ content = list_create_contact_list(clist_d->content_layout, clist_d);
+ if (CT_LIST_MODE_EDIT == clist_d->list_mode)
+ ctui_list_edit_mode_start(clist_d);
+ elm_object_part_content_set(clist_d->content_layout, "elm.swallow.content", content);
+ ctui_list_set_unsweep(clist_d);
+
+ if (clist_d->count_item)
+ elm_object_item_del(clist_d->count_item);
+
+ evas_object_smart_callback_del(clist_d->win, "wm,rotation,changed",
+ list_resize_contact_view);
+
+ show_fast_index(clist_d);
+
+ clist_d->group_index[0] = '\0';
+ clist_d->group_item = NULL;
+
+ item_cur = elm_genlist_first_item_get(clist_d->genlist);
+ if (item_cur)
+ item_second = elm_genlist_item_next_get(item_cur);
+ else
+ {
+ if (clist_d->base_ab > -1)
+ {
+ contacts_error_e err = CONTACTS_ERROR_NONE;
+ contacts_record_h record = NULL;
+ Elm_Object_Item * item;
+ int addressbook_mode;
+ char title[400] = { 0, };
+ char cur_account_name[200] = { 0, };
+ char *cur_ab;
+
+ ctui_get_account_name_by_address_book_id(clist_d->base_ab,
+ cur_account_name, sizeof(cur_account_name));
+ if (clist_d->base_ab > 0)
+ {
+ err = (contacts_error_e) contacts_db_get_record(
+ _contacts_address_book._uri, clist_d->base_ab,
+ &record);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_db_get_record() Failed(%d)", err);
+
+ do
+ {
+ if (CONTACTS_ERROR_NONE!= (err =(contacts_error_e) contacts_record_get_str_p(record,_contacts_address_book.name, &cur_ab)))
+ break;
+ if (CONTACTS_ERROR_NONE
+ != (err =
+ (contacts_error_e) contacts_record_get_int(
+ record,
+ _contacts_address_book.mode,
+ &addressbook_mode)))
+ break;
+ }
+ while (0);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_record_get_value() Failed(%d)", err);
+
+ err = (contacts_error_e) contacts_record_destroy(record,
+ true);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_record_destroy() Failed(%d)", err);
+
+ if (CONTACTS_ADDRESS_BOOK_MODE_READONLY == addressbook_mode)
+ snprintf(title, sizeof(title), "%s", cur_account_name);
+ else
+ snprintf(title, sizeof(title), "%s %s",
+ cur_account_name, cur_ab);
+ }
+ else
+ {
+ snprintf(title, sizeof(title), "%s",
+ T_(CT_GET_TEXT_BASIC, CTTEXT_PHONE));
+ }
+
+ item = elm_genlist_item_append(clist_d->genlist, &group_index,
+ strdup(title), NULL, ELM_GENLIST_ITEM_GROUP, NULL,
+ NULL);
+ elm_genlist_item_select_mode_set(item,
+ ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+ }
+ }
+
+ group_letter[0] = '\0';
+
+ if (ELM_GENLIST_ITEM_GROUP == elm_genlist_item_type_get(item_second))
+ item_cur = item_second;
+
+ if (clist_d->search_str && *clist_d->search_str)
+ item_cur = elm_genlist_item_next_get(clist_d->search_group_item);
+
+ ctui_list_free_index(clist_d->list_index);
+ clist_d->list_index = NULL;
+ clear_fast_index(clist_d);
+ elm_genlist_clear(clist_d->genlist);
+
+ EINA_LIST_FOREACH(list_new, l, info)
+ {
+ person_info = (ct_person_list *) info;
+ if(person_info)
+ list_append_item(clist_d, person_info);
+ }
+
+ if (clist_d->search_str && *clist_d->search_str)
+ {
+ if (clist_d->search_group_item)
+ {
+ char group_title[PH_TEXT_MAX_LEN];
+ snprintf(group_title, sizeof(group_title), "%s (%d)", S_(PH_SYS_BODY_CONTACTS), eina_list_count(list_new));
+ elm_object_item_data_set(clist_d->search_group_item,
+ strdup(group_title));
+ elm_genlist_item_update(clist_d->search_group_item);
+ }
+ }
+
+ if (CT_LIST_IN_MULTI_TAB != clist_d->tab_mode
+ && CT_UG_REQUEST_SELECT_PERSON <= clist_d->ug_request)
+ {
+ snprintf(buf, sizeof(buf), "%s (%d)", clist_d->title, clist_d->cnt_list_total);
+ elm_object_item_text_set(clist_d->navi_item, buf);
+ }
+ }
+
+ ctui_list_free_contacts(clist_d->list);
+ clist_d->list = list_new;
+
+ ct_list_update_checked_contacts(clist_d);
+
+ if (clist_d->genlist)
+ {
+ elm_genlist_realized_items_update(clist_d->genlist);
+ if (!(clist_d->search_str && *clist_d->search_str))
+ disable_count_item(clist_d);
+ }
+ if (clist_d->list_navi_item_update_fn)
+ clist_d->list_navi_item_update_fn(clist_d);
+
+ if (clist_d->base_grp)
+ ctui_list_navi_set(CT_LIST_MODE_DEFAULT, clist_d);
+
+ if (clist_d->genlist)
+ elm_object_focus_set(clist_d->genlist, EINA_TRUE);
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static Eina_Bool list_genlist_update_queue_timer_cb(void *data)
+{
+ PH_TRACE;
+ ct_list_data *clist_d = (ct_list_data *) data;
+ p_retvm_if(NULL == clist_d, ECORE_CALLBACK_CANCEL,
+ "parameter(clist_d) is NULL");
+
+ if (clist_d->need_update)
+ {
+ clist_d->need_update = false;
+ list_genlist_update(clist_d);
+ return ECORE_CALLBACK_RENEW;
+ }
+ clist_d->update_queue_timer = NULL;
+ return ECORE_CALLBACK_CANCEL;
+}
+
+void ctui_list_lazy_update(const char *view_uri, void *data)
+{
+ PH_TRACE;
+ int ui_updated;
+ ct_list_data *clist_d = (ct_list_data *) data;
+
+ if (clist_d->updating)
+ return;
+ PH_DBG("ctui_list_lazy_update");
+ if (clist_d->update_timer)
+ {
+ ecore_timer_del(clist_d->update_timer);
+ clist_d->update_timer = NULL;
+ }
+
+ PH_DBG("is_background = %d", clist_d->is_background);
+
+ if (clist_d->is_background)
+ {
+ clist_d->need_update = false;
+ clist_d->update_timer = ecore_timer_add(3.0, list_genlist_update,
+ clist_d);
+ return;
+ }
+
+ ui_updated = (int) evas_object_data_del(clist_d->navi, "ct_list_update_ui");
+ if (0 == ui_updated && clist_d->update_queue_timer)
+ {
+ clist_d->need_update = true;
+ }
+ else
+ {
+ list_genlist_update(clist_d);
+ clist_d->update_queue_timer = ecore_timer_add(1.0,
+ list_genlist_update_queue_timer_cb, clist_d);
+ p_warn_if(NULL == clist_d->update_queue_timer,
+ "ecore_timer_add() return NULL");
+ }
+}
+
+static void list_view_delete_cb(void *data, Evas *e, Evas_Object *obj,
+ void *event_info)
+{
+ PH_TRACE;
+ int i;
+ contacts_error_e err = CONTACTS_ERROR_NONE;
+ ct_list_data *clist_d = (ct_list_data *) data;
+
+ ct_list_clear_pdata(clist_d);
+ list_clean_ecore_task(clist_d);
+
+ // TODO: Fixme BS when destroy a contact ug
+ if (clist_d->genlist)
+ {
+ evas_object_del(clist_d->genlist);
+ clist_d->genlist = NULL;
+ }
+
+ evas_object_smart_callback_del(clist_d->win, "wm,rotation,changed",
+ list_resize_contact_view);
+
+ if (CT_GET_LIST_PERSON_OF_GROUP_ID == clist_d->list_op)
+ {
+ err = (contacts_error_e) contacts_db_remove_changed_cb(
+ _contacts_contact._uri, ctui_list_lazy_update, clist_d);
+ p_warn_if(CONTACTS_ERROR_NONE,
+ "contacts_db_remove_changed_cb() Failed(%d)", err);
+ }
+
+ // if (clist_d->gl_sel_data != clist_d) - 1. Input > Relationship, 2. Details > Link
+ if (CT_GET_LIST_VCARD != clist_d->list_op
+ && clist_d->gl_sel_data == clist_d)
+ {
+ err = (contacts_error_e) contacts_db_remove_changed_cb(
+ _contacts_person._uri, ctui_list_lazy_update, clist_d);
+ p_warn_if(CONTACTS_ERROR_NONE,
+ "contacts_db_remove_changed_cb() Failed(%d)", err);
+
+ err = (contacts_error_e) contacts_db_remove_changed_cb(
+ _contacts_address_book._uri, list_addrbook_changed, clist_d);
+ p_warn_if(CONTACTS_ERROR_NONE,
+ "contacts_db_remove_changed_cb() Failed(%d)", err);
+
+ }
+
+ if (clist_d->list)
+ {
+ if (clist_d->list_grp_person)
+ {
+ Eina_List* l = NULL;
+ void *info = NULL;
+ EINA_LIST_FOREACH(clist_d->list, l, info)
+ {
+ ct_person_list *person_info = (ct_person_list *) info;
+ if (person_info)
+ {
+ if (!person_info->is_in_group)
+ {
+ ctui_list_free_person_info(person_info);
+ }
+ }
+ }
+ }
+ else
+ {
+ ctui_list_free_contacts(clist_d->list);
+ clist_d->list = NULL;
+ }
+ }
+ if (clist_d->list_check_info)
+ {
+ ctui_list_free_contacts(clist_d->list_check_info);
+ clist_d->list_check_info = NULL;
+ }
+ if (clist_d->list_index)
+ {
+ ctui_list_free_index(clist_d->list_index);
+ clist_d->list_index = NULL;
+ }
+
+ if (clist_d->update_timer)
+ {
+ ecore_timer_del(clist_d->update_timer);
+ clist_d->update_timer = NULL;
+ }
+
+ if (clist_d->update_queue_timer)
+ {
+ ecore_timer_del(clist_d->update_queue_timer);
+ clist_d->update_queue_timer = NULL;
+ }
+
+ if (clist_d->popup)
+ {
+ evas_object_del(clist_d->popup);
+ clist_d->popup = NULL;
+ }
+
+ if (clist_d->nocontent)
+ {
+ evas_object_del(clist_d->nocontent);
+ clist_d->nocontent = NULL;
+ }
+
+ if (clist_d->th)
+ {
+ elm_theme_extension_del(clist_d->th, CONTACTS_EDJ);
+ elm_theme_free(clist_d->th);
+ clist_d->th = NULL;
+ }
+
+ if (clist_d->child_ug)
+ {
+ ug_destroy(clist_d->child_ug);
+ clist_d->child_ug = NULL;
+ }
+
+ evas_object_data_del(clist_d->navi, "gadd_list_d");
+ evas_object_data_del(clist_d->navi, "favor_list_d");
+
+ if (clist_d->acc_types)
+ {
+ int count = clist_d->acc_count;
+ for (i = 0; i < count; i++)
+ free(clist_d->acc_types[i].icon_path);
+ free(clist_d->acc_types);
+ clist_d->acc_types = NULL;
+ }
+
+ if (clist_d->search_str)
+ {
+ free(clist_d->search_str);
+ clist_d->search_str = NULL;
+ }
+ if (clist_d->sub_title)
+ {
+ free(clist_d->sub_title);
+ clist_d->sub_title = NULL;
+ }
+ if (clist_d->title)
+ {
+ free(clist_d->title);
+ clist_d->title = NULL;
+ }
+
+ if (!clist_d->ug)
+ {
+ PH_DBG("no ug");
+ free(clist_d);
+ }
+ else
+ {
+ PH_DBG("view destroy called earlier than ug destroy");
+ clist_d->ug = NULL;
+ }
+}
+
+char* ctui_list_get_highlight_text(ct_list_data *clist_d, const char *src)
+{
+ PH_TRACE;
+ char display[PH_TEXT_MAX_LEN] = { 0, };
+ p_retvm_if(NULL == clist_d, NULL, "parameter(clist_d) is NULL");
+
+ if (NULL == clist_d->search_str || '\0' == clist_d->search_str[0])
+ {
+ return elm_entry_utf8_to_markup(src);
+ }
+
+ int len_search = strlen(clist_d->search_str);
+ char *pos = (char *) strcasestr(src, clist_d->search_str);
+
+ if (0 < pos)
+ {
+ char first[PH_TEXT_MAX_LEN] = { 0 };
+ char middle[PH_TEXT_MAX_LEN] = { 0 };
+
+ snprintf(first, (int) (pos - src) + 1, "%s", src);
+ snprintf(middle, len_search + 1, "%s", (char *) pos);
+
+ char *first_markup = elm_entry_utf8_to_markup(first);
+ char *midle_markup = elm_entry_utf8_to_markup(middle);
+ char *end_murkup = elm_entry_utf8_to_markup((char *) (pos + len_search));
+ snprintf(display, sizeof(display), "%s<match>%s</>%s", first_markup,
+ midle_markup, end_murkup);
+ free(first_markup);
+ free(midle_markup);
+ free(end_murkup);
+ return strdup(display);
+ }
+ return elm_entry_utf8_to_markup(src);
+}
+
+char* ct_list_gl_label_get(void *data, Evas_Object *obj, const char *part)
+{
+ PH_TRACE;
+ ct_person_list *person_info = (ct_person_list *) data;
+ p_retvm_if(NULL == person_info, NULL, "The parameter(data) is NULL");
+ p_retvm_if(NULL == part, NULL, "The parameter(data) is NULL");
+
+ if (0 == strcmp(part, "elm.text.2"))
+ {
+ if (person_info->number_display && *person_info->number_display)
+ {
+ ct_list_data *clist_d = (ct_list_data *) evas_object_data_get(obj,
+ "clist_d");
+ p_retvm_if(NULL == clist_d, strdup(person_info->number_display),
+ "evas_object_data_get() return NULL");
+ return ctui_list_get_highlight_text(clist_d,
+ person_info->number_display);
+ }
+ }
+ if (0 == strcmp(part, "elm.text.1") || 0 == strcmp(part, "elm.text"))
+ {
+ ct_list_data *clist_d = (ct_list_data *) evas_object_data_get(obj,
+ "clist_d");
+ p_retvm_if(NULL == clist_d, strdup(person_info->display),
+ "evas_object_data_get() return NULL");
+ return ctui_list_get_highlight_text(clist_d, person_info->display);
+ }
+ else
+ return strdup(T_(CT_GET_TEXT_ERR, CTTEXT_NONAME));
+
+ return NULL;
+}
+
+char* ct_list_count_gl_label_get(void *data, Evas_Object *obj, const char *part)
+{
+ PH_TRACE;
+ char buf[PH_TEXT_SHORT_LEN];
+ int count = (int) data;
+ if (count == 1)
+ return strdup(T_(CT_GET_TEXT_BASIC,CTTEXT_1_CONTACT));
+ else
+ {
+ snprintf(buf, sizeof(buf), T_(CT_GET_TEXT_BASIC, CTTEXT_COUNT_CONTACTS),
+ count);
+ return strdup(buf);
+ }
+}
+
+Evas_Object* ct_list_create_contact_layout(ct_list_data *clist_d)
+{
+ PH_TRACE;
+ Elm_Theme *th = NULL;
+ Evas_Object *base = NULL;
+ Evas_Object *layout = NULL;
+ contacts_error_e err = CONTACTS_ERROR_NONE;
+
+ if(clist_d)
+ {
+ th = elm_theme_new();
+ elm_theme_ref_set(th, NULL);
+ elm_theme_extension_add(th, LIST_THEME_EDJ);
+ clist_d->th = th;
+
+ base = elm_layout_add(clist_d->navi);
+ p_retvm_if(NULL == base, NULL, "elm_layout_add() return NULL");
+ elm_layout_file_set(base, SELECTION_INFO_EDJ, "selectioninfo_layout");
+
+ layout = phone_create_base_layout(base, true);
+ clist_d->content_layout = layout;
+ elm_object_part_content_set(base, "contents", layout);
+ list_fill_contact_view(layout, *clist_d);
+
+ // if (clist_d->gl_sel_data != clist_d) - 1. Input > Relationship, 2. Details > Link
+ if (CT_GET_LIST_VCARD != clist_d->list_op
+ && clist_d->gl_sel_data == clist_d)
+ {
+ err = (contacts_error_e) contacts_db_add_changed_cb(
+ _contacts_person._uri, ctui_list_lazy_update, clist_d);
+
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_db_add_changed_cb() Failed(%d)", err);
+
+ err = (contacts_error_e) contacts_db_add_changed_cb(
+ _contacts_address_book._uri, list_addrbook_changed,
+ clist_d);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_db_add_changed_cb() Failed(%d)", err);
+
+ if (CT_GET_LIST_PERSON_OF_GROUP_ID == clist_d->list_op)
+ {
+ err = (contacts_error_e) contacts_db_add_changed_cb(
+ _contacts_contact._uri, ctui_list_lazy_update, clist_d);
+ p_warn_if(CONTACTS_ERROR_NONE != err,
+ "contacts_db_add_changed_cb() Failed(%d)", err);
+ }
+ }
+ evas_object_event_callback_add(base, EVAS_CALLBACK_DEL,
+ list_view_delete_cb, clist_d);
+ }
+
+ PH_DBG("##### [TSP_TEST] lauching contact application #####");
+ return base;
+}
diff --git a/lib/common/include/Contact.h b/lib/common/include/Contact.h
new file mode 100644
index 0000000..9d95d71
--- /dev/null
+++ b/lib/common/include/Contact.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2012-2013 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 __COMMON_CONTACT_H__
+#define __COMMON_CONTACT_H__
+
+#include <string>
+
+namespace Common
+{
+ /*
+ * @brief Common interface for contact
+ */
+ class Contact
+ {
+ public:
+ virtual ~Contact() { }
+
+ /*
+ * @return Contact's name as it is displayed in Contact list
+ */
+ virtual const std::string & getName() const = 0;
+
+ /*
+ * @return Default phone number
+ */
+ virtual const std::string & getNumber() const = 0;
+
+ /*
+ * @return Contact image path
+ */
+ virtual const std::string & getImagePath() const = 0;
+ };
+}
+
+#endif /* __COMMON_CONTACT_H__ */
diff --git a/lib/common/include/Front.h b/lib/common/include/Front.h
new file mode 100644
index 0000000..1978b37
--- /dev/null
+++ b/lib/common/include/Front.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2012-2013 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 __COMMON_FRONT_H__
+#define __COMMON_FRONT_H__
+
+#include <Elementary.h>
+#include "NonCopyable.h"
+
+namespace Common
+{
+ /*
+ * \par Description:
+ * Members for legacy front views (ph-front and ct-front).
+ */
+ struct Front : public Utils::NonCopyable
+ {
+ Evas_Object *win;
+ Evas_Object *navi;
+ Evas_Object *layout;
+ void *ug;
+ char *ug_data;
+ int ug_request;
+ int cnt_max;
+ Ecore_Idler *idler;
+ Ecore_Timer *timer;
+
+ Front();
+ };
+}
+
+#endif /* __COMMON_FRONT_H__ */
diff --git a/lib/common/include/View.h b/lib/common/include/View.h
new file mode 100644
index 0000000..38d182e
--- /dev/null
+++ b/lib/common/include/View.h
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2012-2013 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 __COMMON_VIEW_H__
+#define __COMMON_VIEW_H__
+
+#include <string>
+
+#include "ViewData.h"
+
+namespace Common
+{
+ /*
+ * \par Description:
+ * View is a base class for all views that can be pushed into ViewManager (see ViewManager.h).
+ * Views can have several mode (normal, selection, etc...).
+ * Concrete views should be designed according to the State pattern with each mode as a state.
+ */
+
+
+ class View : public ViewData
+ {
+ public:
+ View();
+ /*
+ * @param title Title for a view to be displayed in naviframe item header.
+ */
+ View(const char *title);
+ virtual ~View();
+
+ /*
+ * \par Description:
+ * Creates view basic layout.
+ * Any derived class that overrides this method should call
+ * base method as well before performing its own initialization.
+ *
+ * @param parent Parent for the main view's layout
+ * @return true on success, false otherwise
+ */
+ virtual bool initialize(Evas_Object *parent);
+
+ /*
+ * @return View title.
+ */
+ const std::string & getTitle() const;
+
+ /*
+ * @return Main view layout.
+ */
+ Evas_Object * getContent() const;
+
+ /*
+ * \par Description:
+ * Receives the Back-button event from ViewManager and dispatches it to the current State.
+ *
+ * @return true if handled, false for default processing by ViewManager
+ */
+ bool onBack();
+
+ /*
+ * \par Description:
+ * Receives the Menu-button event from ViewManager and dispatches it to the current State.
+ */
+ void onMenu();
+
+ public:
+ /*
+ * Back and Menu strategies for the current State.
+ * In the future should be replaced with a State object.
+ */
+ void(*back_cb)(void *);
+ void(*menu_cb)(void *);
+ void(*widget_back_cb)(void *);
+
+ protected:
+ std::string m_Title;
+ Evas_Object *m_Parent;
+ Evas_Object *m_Content;
+ };
+}
+
+#endif /* __COMMON_VIEW_H__ */
diff --git a/lib/common/include/ViewData.h b/lib/common/include/ViewData.h
new file mode 100644
index 0000000..3973d30
--- /dev/null
+++ b/lib/common/include/ViewData.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2012-2013 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 __COMMON_VIEW_DATA_H__
+#define __COMMON_VIEW_DATA_H__
+
+#include <Elementary.h>
+#include "NonCopyable.h"
+
+typedef struct ui_gadget_s *ui_gadget_h;
+
+namespace Common
+{
+ /*
+ * \par Description:
+ * Members for legacy code support.
+ * Any new views shouldn't use these members.
+ */
+ struct ViewData : public Utils::NonCopyable
+ {
+ Evas_Object *win;
+ Evas_Object *navi;
+ Evas_Object *layout;
+ Evas_Object *popup;
+ Evas_Object *m_Menu;
+ Evas_Object *m_ContextMenu;
+ Evas_Object *m_Widget;
+ Elm_Object_Item *navi_item;
+ Elm_Theme *th;
+ ui_gadget_h ug;
+ ui_gadget_h child_ug;
+
+ ViewData();
+ };
+}
+
+#endif /* __COMMON_VIEW_DATA_H__ */
diff --git a/lib/common/include/ViewManager.h b/lib/common/include/ViewManager.h
new file mode 100644
index 0000000..a69b62a
--- /dev/null
+++ b/lib/common/include/ViewManager.h
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2012-2013 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 __COMMON_VIEW_MANAGER_H__
+#define __COMMON_VIEW_MANAGER_H__
+
+#include "Front.h"
+
+namespace Common
+{
+ class View;
+
+ /*
+ * \par Description:
+ * ViewManager is a wrapper around naviframe and a manager of View objects.
+ * Views should be pushed into ViewManager.
+ * Views that create other Views should push them into ViewManager.
+ */
+ class ViewManager : public Front
+ {
+ public:
+ ViewManager();
+ virtual ~ViewManager();
+
+ /*
+ * @param win Parent window object
+ * @param parent Parent layout for ViewManager
+ */
+ bool initialize(Evas_Object *win, Evas_Object *parent);
+
+ /*
+ * @return Base layout
+ */
+ Evas_Object * getContent() const;
+
+ /*
+ * \par Description:
+ * Pushes view's layout to the internal naviframe.
+ * The method uses view->getTitle and view->getContent
+ * to get title and layout for a new naviframe item.
+ */
+ void push(View &view);
+
+ /*
+ * \par Description:
+ * Deletes the topmost item of internal naviframe.
+ */
+ void pop();
+
+ /*
+ * \par Description:
+ * Hardware keys handlers.
+ * Dispatch key events to concrete Views and performs default processing if necessary.
+ * TODO: move to private section once naviframe creation is moved to ViewManager class.
+ */
+ static void onBack(void *data, Evas_Object *obj, void *event);
+ static void onMenu(void *data, Evas_Object *obj, void *event);
+
+ private:
+ Evas_Object *m_Layout;
+
+ static void onViewDestroy(void *data, Evas *e, Evas_Object *obj, void *event_info);
+ };
+
+ /*
+ * TabbedView is a wrapper around tab bar and tabs.
+ * In the future TabbedView should be decoupled from the ViewManager and should inherit from View.
+ * TabbedView should be pushed into ViewManager as a first View.
+ * TabbedView itself should contain other Views as its tabs.
+ */
+ template <int TabCount>
+ class TabbedView : public Common::ViewManager
+ {
+ public:
+ Evas_Object *tabbar;
+ Evas_Object *sub_view[TabCount];
+ Elm_Object_Item *item[TabCount];
+ bool view_visible[TabCount];
+ int select_tab;
+
+ TabbedView()
+ : tabbar(0), select_tab(0)
+ {
+ memset(sub_view, 0, sizeof(sub_view));
+ memset(item, 0, sizeof(item));
+ memset(view_visible, 0, sizeof(view_visible));
+ }
+ };
+}
+
+#endif /* __COMMON_VIEW_MANAGER_H__ */
diff --git a/lib/common/include/ct-group-assign-popup.h b/lib/common/include/ct-group-assign-popup.h
new file mode 100644
index 0000000..e05d670
--- /dev/null
+++ b/lib/common/include/ct-group-assign-popup.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2012-2013 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 __CONTACTS_ASSIGN_GROUP_POPUP_H__
+#define __CONTACTS_ASSIGN_GROUP_POPUP_H__
+
+#include <contacts.h>
+#include <Elementary.h>
+
+typedef void (*ct_assign_result_cb)(void *data);
+
+/**
+ * @brief Create assign group popup for contact
+ * @param[in] win Applicaton window
+ * @param[in] navi Main naviframe
+ * @param[out] contact _contacts_contact record to assign groups
+ * @param[in] assign_cb Called when groups are assigned
+ * @param[in] assign_cb_data Data to pass to assign_cb
+ * @return popup on success, otherwise NULL
+ */
+Evas_Object * ct_group_assign_popup_create(Evas_Object *win, Evas_Object *navi,
+ contacts_record_h contact, ct_assign_result_cb assign_cb, void *assign_cb_data);
+
+#endif /* CT_ASSIGN_GROUP_POPUP_H_ */
diff --git a/lib/common/include/ct-group.h b/lib/common/include/ct-group.h
new file mode 100755
index 0000000..a43aa3d
--- /dev/null
+++ b/lib/common/include/ct-group.h
@@ -0,0 +1,30 @@
+/*
+ * 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 __CT_GROUP_H__
+#define __CT_GROUP_H__
+
+Evas_Object* phone_create_group_view(ph_view_info *view_info);
+Evas_Object* phone_create_group_view_ug(ui_gadget_h ug, Evas_Object *parent,
+ int ug_request);
+void phone_group_set_navi(Evas_Object *layout);
+void phone_group_view_reset(Evas_Object *base);
+void phone_group_view_language_changed(Evas_Object *navi);
+void phone_group_set_background(Evas_Object *obj, bool is_background);
+void phone_group_email_result_cb(void *data, int *list, int cnt);
+void phone_group_message_result_cb(void *data, int *list, int cnt);
+
+#endif /* __CT_GROUP_H__ */
diff --git a/lib/common/include/ct-list-view-common.h b/lib/common/include/ct-list-view-common.h
new file mode 100644
index 0000000..9bde245
--- /dev/null
+++ b/lib/common/include/ct-list-view-common.h
@@ -0,0 +1,36 @@
+/*
+* Copyright 2012-2013 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.
+*/
+
+/**
+* @file ct-list-view-common.h
+* @author Sergei Kobec (s.kobec@samsung.com)
+* @date Created Mar 27, 2014 14:10
+*/
+
+#ifndef __CT_LIS_VIEW_COMMON_H__
+#define __CT_LIS_VIEW_COMMON_H__
+
+/**
+ * @brief Starts process of sending contact as text
+ * @param[in] contact_id ID of contact
+ * @param[in] person_id ID of person
+ * @param[in] navi Naviframe
+ * @param[in] ug Current user gadget
+ * @param[out] p_child_ug Child user gadget (in this case for message composer)
+ */
+void ct_process_send_contact_as_text(int contact_id, int person_id, Evas_Object* navi, ui_gadget_h ug, ui_gadget_h* p_child_ug);
+
+#endif//__CT_LIS_VIEW_COMMON_H__
diff --git a/lib/common/include/phone-common.h b/lib/common/include/phone-common.h
new file mode 100755
index 0000000..3fbb06d
--- /dev/null
+++ b/lib/common/include/phone-common.h
@@ -0,0 +1,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__
diff --git a/lib/common/include/phone-path.h b/lib/common/include/phone-path.h
new file mode 100755
index 0000000..7fdaed5
--- /dev/null
+++ b/lib/common/include/phone-path.h
@@ -0,0 +1,137 @@
+/*
+ * 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_PATH_H__
+#define __PHONE_PATH_H__
+
+#if !defined(IMGDIR)
+# define IMGDIR "/usr/ug/res/images/ug-"PACKAGE
+#endif
+
+#if !defined(EDJDIR)
+# define EDJDIR "/usr/ug/res/edje/ug-"PACKAGE
+#endif
+
+#if !defined(UGDATAIDR)
+# define UGDATAIDR "/opt/usr/ug/data/ug-"PACKAGE
+#endif
+
+#define PROGRESS_EDJ EDJDIR"/progress.edj"
+#define DIALER_EDJ EDJDIR"/dialer.edj"
+#define DIALER_THEME_EDJ EDJDIR"/dialer_theme.edj"
+#define LOGDETAIL_THEME_EDJ EDJDIR"/logdetail_theme.edj"
+#define SPEEDDIAL_THEME_EDJ EDJDIR"/speeddial_theme.edj"
+#define CONTACTS_EDJ EDJDIR"/contacts.edj"
+#define FAVORITES_THEME_EDJ EDJDIR"/favorites_theme.edj"
+#define GROUP_THEME_EDJ EDJDIR"/group_theme.edj"
+#define CONTACT_BUTTON_THEME_EDJ EDJDIR"/contact_button.edj"
+#define IMAGE_LAYOUT_EDJ EDJDIR"/image_layout.edj"
+#define LIST_THEME_EDJ EDJDIR"/list_theme.edj"
+#define DETAIL_THEME_EDJ EDJDIR"/detail_theme.edj"
+#define SELECTION_INFO_EDJ EDJDIR"/selectioninfo.edj"
+#define NOCONTENT_LAYOUT_EDJ EDJDIR"/nocontent_layout.edj"
+#define LOG_ITEM_ICON_EDJ EDJDIR"/log_item_icon.edj"
+
+#define IMG_DEFAULT IMGDIR"/caller_ID_default_70x70_man.png"
+#define IMG_VOICEMAIL_ICON IMGDIR"/C01-5_icon_voicecall.png"
+
+#define IMG_ALL_BLOCKED_ICON IMGDIR"/C01-4_icon_Blocked.png"
+#define IMG_CALL_BLOCKED_ICON IMGDIR"/C01-4_icon_call_blocked.png"
+#define IMG_MESSAGE_BLOCKED_ICON IMGDIR"/C01-4_icon_message_blocked.png"
+#define IMG_MESSAGE_ICON IMGDIR"/C02_icon_message.png"
+
+
+#define PH_IMG_ICON_DIALER IMGDIR"/01_controlbar_icon_dialer.png"
+#define PH_IMG_ICON_CONTACTS IMGDIR"/01_controlbar_icon_contacts.png"
+#define PH_IMG_ICON_LOGS IMGDIR"/01_controlbar_icon_logs.png"
+#define PH_IMG_ICON_GROUP IMGDIR"/01_controlbar_icon_groups.png"
+#define PH_IMG_ICON_FAVORITE IMGDIR"/01_controlbar_icon_favorite.png"
+#define PH_IMG_ICON_DONE IMGDIR"/01_controlbar_icon_save.png"
+#define PH_IMG_ICON_EDIT IMGDIR"/01_controlbar_icon_edit.png"
+#define PH_IMG_ICON_ADD IMGDIR"/01_controlbar_icon_create.png"
+#define PH_IMG_ICON_MORE IMGDIR"/01_controlbar_icon_more.png"
+#define PH_IMG_ICON_PHONE IMGDIR"/phone.png"
+#define PH_IMG_ICON_CALL IMGDIR"/C02_button_icon_call.png"
+#define PH_IMG_ICON_CALL_PRESS IMGDIR"/C02_button_icon_call_press.png"
+#define PH_IMG_ICON_CALL_DIM IMGDIR"/C02_button_icon_call_dim.png"
+#define PH_IMG_ICON_MESSAGE IMGDIR"/C02_button_icon_message.png"
+#define PH_IMG_ICON_MESSAGE_PRESS IMGDIR"/C02_button_icon_message_press.png"
+#define PH_IMG_ICON_MESSAGE_DIM IMGDIR"/C02_button_icon_messagedim.png"
+#define PH_IMG_ICON_VIDEOCALL IMGDIR"/C02_button_icon_videocall.png"
+#define PH_IMG_ICON_VIDEOCALL_PRESS IMGDIR"/C02_button_icon_videocall_press.png"
+#define PH_IMG_ICON_VIDEOCALL_DIM IMGDIR"/C02_button_icon_videocall_call_dim.png"
+#define PH_IMG_ICON_CHAT_ON IMGDIR"/C02_icon_chat_on.png"
+#define PH_IMG_ICON_FILETRANSFER IMGDIR"/C02_icon_filetransfer.png"
+
+#define PH_IMG_CIRCLE_ICON_CALL IMGDIR"/C02_circle_icon_call.png"
+#define PH_IMG_ICON_CALL_PRESSED IMGDIR"/C02_circle_icon_call_press.png"
+#define PH_IMG_ICON_SMS IMGDIR"/C02_circle_icon_sms.png"
+#define PH_IMG_ICON_SMS_PRESSED IMGDIR"/C02_circle_icon_sms_press.png"
+#define PH_IMG_ICON_VCALL IMGDIR"/C02_circle_icon_vt-call.png"
+#define PH_IMG_ICON_VCALL_PRESSED IMGDIR"/C02_circle_icon_vt-call_press.png"
+
+#define PH_IMG_ICON_LOGTYPE_MISSED IMGDIR"/C01-4_controlbar_icon_missed_call.png"
+#define PH_IMG_ICON_LOGTYPE_ALL IMGDIR"/C01-4_controlbar_icon_all.png"
+#define PH_IMG_ICON_CREATE_CONTACT IMGDIR"/C01-4_controlbar_icon_create.png"
+#define PH_IMG_ICON_DELETE IMGDIR"/C02_button_icon_delete.png"
+#define PH_IMG_ICON_SET_BLOCK IMGDIR"/C01-4_controlbar_icon_view_block.png"
+#define PH_IMG_ICON_VIEW_CONTACT IMGDIR"/C01-4_controlbar_icon_view_contacts.png"
+
+#define CTUI_IMG_ICON_ADD_ACCOUNTS IMGDIR"/01_controlbar_icon_add_account.png"
+#define CTUI_IMG_ICON_ADD_FAVORITE IMGDIR"/01_controlbar_icon_add-to-bookmarks.png"
+#define CTUI_IMG_ICON_CREATE_GROUP IMGDIR"/01_controlbar_icon_exchangs_register.png"
+#define CTUI_IMG_ICON_ADD_TO_CONTACTS IMGDIR"/01_controlbar_icon_add_to_contact.png"
+#define CTUI_IMG_ICON_CLOSE IMGDIR"/01_controlbar_icon_close.png"
+#define CTUI_IMG_ICON_EXPAND_OPENED IMGDIR"/00_button_icon_expand_opened.png"
+#define CTUI_IMG_ICON_EXPAND_CLOSED IMGDIR"/00_button_icon_expand_closed.png"
+#define CTUI_IMG_ICON_VIEW IMGDIR"/01_controlbar_icon_bluetooth_preview.png"
+#define CTUI_IMG_ICON_RESET IMGDIR"/C02_icon_reset.png"
+#define CTUI_IMG_ICON_ADD_GROUP IMGDIR"/C02_icon_add_group.png"
+#define CTUI_IMG_ICON_FAVORITE IMGDIR"/C02_favorite_icon.png"
+#define CTUI_IMG_ICON_CIRCLE IMGDIR"/C02_circle_button.png"
+#define CTUI_IMG_ICON_CIRCLE_PRESSED IMGDIR"/C02_circle_button_press.png"
+#define CTUI_IMG_ICON_CALL IMGDIR"/C02_circle_icon_call.png"
+#define CTUI_IMG_ICON_CALL_PRESSED IMGDIR"/C02_circle_icon_call_press.png"
+#define CTUI_IMG_ICON_SMS IMGDIR"/C02_circle_icon_sms.png"
+#define CTUI_IMG_ICON_SMS_PRESSED IMGDIR"/C02_circle_icon_sms_press.png"
+#define CTUI_IMG_ICON_VCALL IMGDIR"/C02_circle_icon_vt-call.png"
+#define CTUI_IMG_ICON_VCALL_PRESSED IMGDIR"/C02_circle_icon_vt-call_press.png"
+#define CTUI_IMG_ICON_PREVIOUS IMGDIR"/01_controlbar_icon_previous.png"
+#define CTUI_IMG_ICON_NEXT IMGDIR"/01_controlbar_icon_next.png"
+
+#define CTUI_IMG_ICON_EMAIL IMGDIR"/email.png"
+#define CTUI_IMG_ICON_MESSAGE IMGDIR"/message.png"
+#define CTUI_IMG_ICON_MESSAGE_PRESS IMGDIR"/C01-3_icon_message_press.png"
+
+#define CTUI_IMG_CHECK IMGDIR"/00_check_checking.png"
+#define CTUI_IMG_DEFAULT_PHOTO_SMALL IMGDIR"/caller_ID_default_96x96.png"
+#define CTUI_IMG_DEFAULT_PHOTO_BIG IMGDIR"/caller_ID_default_128x128.png"
+#define CTUI_IMG_PHOTO_EDIT IMGDIR"/caller_ID_edit.png"
+#define CTUI_IMG_INPUT_PLUS IMGDIR"/00_button_plus.png"
+#define CTUI_IMG_INPUT_GALLERY IMGDIR"/C02_caller_id_icon_gallery.png"
+#define CTUI_IMG_INPUT_GALLERY_PRESSED IMGDIR"/C02_caller_id_icon_gallery_press.png"
+#define CTUI_IMG_INPUT_CAMERA IMGDIR"/C02_caller_id_icon_camera.png"
+#define CTUI_IMG_INPUT_CAMERA_PRESSED IMGDIR"/C02_caller_id_icon_camera_press.png"
+
+#define CTUI_IMG_ACC_PHONE IMGDIR"/C02_account_00.png"
+#define CTUI_IMG_ACC_GOOGLE IMGDIR"/C02_account_01.png"
+#define CTUI_IMG_ACC_FACEBOOK IMGDIR"/C02_account_02.png"
+#define CTUI_IMG_ACC_YAHOO IMGDIR"/C02_account_03.png"
+#define CTUI_IMG_ACC_EXCHANGE IMGDIR"/C02_account_04.png"
+#define CTUI_IMG_ACC_DEFAULT IMGDIR"/C02_account_default.png"
+#define CTUI_IMG_ACC_RCS IMGDIR"/C04_icon_joyn.png"
+#define CTUI_IMG_ACC_SIM IMGDIR"/C02_account_sim.png"
+#endif //__PHONE_PATH_H__
diff --git a/lib/common/include/phone-text.h b/lib/common/include/phone-text.h
new file mode 100755
index 0000000..d782b1f
--- /dev/null
+++ b/lib/common/include/phone-text.h
@@ -0,0 +1,382 @@
+/*
+ * 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_TEXT_H__
+#define __PHONE_TEXT_H__
+
+#include <libintl.h>
+
+#define gettext_noop(String) (String)
+#define N_(String) gettext_noop (String)
+
+enum
+{
+ PHTEXT_KEYPAD,
+ PHTEXT_FAVORITES,
+ PHTEXT_SPEEDDIAL,
+ PHTEXT_VOICE_MAIL,
+ PHTEXT_LOGS,
+ PHTEXT_SPEED_DIAL_REQUEST,
+ PHTEXT_REQUEST_FAIL,
+ PHTEXT_REQUEST_SUCCESS,
+ PHTEXT_EMERGENCY_CALL,
+ PHTEXT_NO_LOGS,
+ PHTEXT_NO_FAVORITES,
+ PHTEXT_NOT_EXIST_MESSAGE,
+ PHTEXT_EXCEED_NUM_MAX_LENGTH,
+ PHTEXT_DELETING_LOGS,
+ PHTEXT_DELETING_FAVORITES,
+ PHTEXT_INITIALIZING,
+ PHTEXT_SOUND_OFF,
+ PHTEXT_SOUND_ON,
+ PHTEXT_PREVIOUS_SCREEN_ABB,
+ PHTEXT_BACK_TO_CALL,
+ PHTEXT_INCOMMING_CALL,
+ PHTEXT_OUTGOING_CALL,
+ PHTEXT_MISSED_CALL,
+ PHTEXT_SENT_MESSAGE,
+ PHTEXT_RECEIVED_MESSAGE,
+ PHTEXT_REJECTED_CALL_ABB,
+ PHTEXT_BLOCKED_CALL_ABB,
+ PHTEXT_EDIT_NUMBER_BEFORE_CALL,
+ PHTEXT_ADD_TO_CONTACTS,
+ PHTEXT_SETTINGS,
+ PHTEXT_CALL_DURATION,
+ PHTEXT_EDIT_BLOCK_CONTACT,
+ PHTEXT_EDIT_SEND_NUMBER,
+ PHTEXT_EDIT_COPY_TO_DIALING_SCREEN,
+ PHTEXT_UNSAVED,
+ PHTEXT_CONTACTS_MENU_CONTACTS_TO_DISPLAY,
+ PHTEXT_CONTACTS_MENU_SETTINGS,
+ PHTEXT_CONTACTS_POP_DELETE,
+ PHTEXT_CONTACTS_POP_CONTACTS,
+ PHTEXT_CONTACTS_BUTTON_DELETE,
+ PHTEXT_CONTACTS_BUTTON_CANCEL,
+ PHTEXT_LOGS_DURATION_RESET,
+ PHTEXT_LOGS_DURATION_LAST,
+ PHTEXT_LOGS_DURATION_DIALED,
+ PHTEXT_LOGS_DURATION_RECEIVED,
+ PHTEXT_LOGS_DURATION_ALL,
+ PHTEXT_DELETING_N_LOGS,
+ CTTEXT_ENTRY_SEARCH,
+ CTTEXT_REMOVE,
+ CTTEXT_CREATE_CONTACT,
+ PHTEXT_CHANGE_ORDER,
+ PHTEXT_MESSAGE,
+ PHTEXT_EMAIL,
+ PHTEXT_DEFAULT_NUMBER,
+ PHTEXT_SEND_CONTACTC_AS_TEXT,
+ PHTEXT_CALLS,
+ PHTEXT_MESSAGES,
+ PHTEXT_SEPARATE_CONTACTS,
+ PHTEXT_LINK_CONTACTS_WITH,
+ PHTEXT_SEPARATE_CONTACTS_FROM,
+ PHTEXT_SEND_EMAIL,
+ PHTEXT_SEND_MESSAGE,
+ PHTEXT_SEND_MESSAGE_EMAIL,
+ PHTEXT_IMPORT_EXPORT,
+ PHTEXT_ACCOUNTS
+};
+//PH_GET_TEXT_BASIC
+enum
+{
+ CTTEXT_ALL_CONTACTS,
+ CTTEXT_NOT_ASSIGNED,
+ CTTEXT_SDN,
+ CTTEXT_PHONE,
+ CTTEXT_GROUP,
+ CTTEXT_DEFAULT,
+ CTTEXT_RINGTONE,
+ CTTEXT_URL,
+ CTTEXT_INSTANT_MESSENGER,
+ CTTEXT_EMAIL,
+ CTTEXT_NUMBER,
+ CTTEXT_NOTE,
+ CTTEXT_POSTAL_ADDRESS,
+ CTTEXT_DETAILS,
+ CTTEXT_COMPANY,
+ CTTEXT_ORDER_DISPLAY_NAME,
+ CTTEXT_OWN_NUMBER,
+ CTTEXT_FIRSTNAME,
+ CTTEXT_LASTNAME,
+ CTTEXT_MIDDLE,
+ CTTEXT_SUFFIX,
+ CTTEXT_NICKNAME,
+ CTTEXT_SELECT_EXPORT_ADDRBOOK,
+ CTTEXT_SELECT_CONTACTS,
+ CTTEXT_POSTAL_CODE,
+ CTTEXT_COUNTRY,
+ CTTEXT_PROVINCE,
+ CTTEXT_CITY,
+ CTTEXT_STREET,
+ CTTEXT_SAVED_IN,
+ CTTEXT_MOST_FREQUENT_CONTACTS,
+ CTTEXT_COPIED,
+ CTTEXT_EXPORTED,
+ CTTEXT_DELETING_CONTACTS,
+ CTTEXT_MOVING_CONTACTS,
+ CTTEXT_COPYING_CONTACTS,
+ CTTEXT_IMPORTING_SIM_CONTACTS,
+ CTTEXT_IMPORTING_SD_CONTACTS,
+ CTTEXT_EXPORTING_CONTACTS_TO,
+ CTTEXT_VCARD_CONTACTS,
+ CTTEXT_LOADING_VCARD,
+ CTTEXT_IMPORTED,
+ CTTEXT_NA,
+ CTTEXT_ALL_LINKED_CONTACTS,
+ CTTEXT_LINKED_CONTACTS,
+ CTTEXT_MORE_INFORMATION,
+ CTTEXT_JOB_TITLE,
+ CTTEXT_DEPARTMENT,
+ CTTEXT_GROUP_NAME,
+ CTTEXT_ADD_ACCOUNT,
+ CTTEXT_ADDING_MEMBERS_TO_GROUP,
+ CTTEXT_VIEW,
+ CTTEXT_VIEW_BY,
+ CTTEXT_COUNT_CONTACTS,
+ CTTEXT_RENAME,
+ CTTEXT_RELATIONSHIP,
+ CTTEXT_NO_HISTORIES,
+ CTTEXT_NO_ACTIVITIES,
+ CTTEXT_ADDING_ING,
+ CTTEXT_CUSTOM,
+ CTTEXT_ADDITIONAL_INFO,
+ CTTEXT_PO_BOX,
+ CTTEXT_STATE,
+ CTTEXT_FRIENDS,
+ CTTEXT_FAMILY,
+ CTTEXT_CO_WORKERS,
+ CTTEXT_EMERGENCY_CONTACTS,
+ CTTEXT_WORK,
+ CTTEXT_VIBRATION_PATTERN,
+ CTTEXT_SET_DEFAULT,
+ CTTEXT_EVENT,
+ CTTEXT_SHARE_CONTACT_INFO,
+ CTTEXT_1_CONTACT,
+ CTTEXT_WI_FI_DIRECT,
+ CTTEXT_EXPORT_TO_SIM_CARD,
+ CTTEXT_INFO,
+ CTTEXT_HISTORY,
+ CTTEXT_ACTIVITIES,
+ CTTEXT_GROUP_MESSAGE,
+ CTTEXT_GROUP_EMAIL,
+ CTTEXT_ORGANIZATION,
+ CTTEXT_MY_PHONE,
+ CTTEXT_RINGTONES,
+ CTTEXT_MY_FILES
+};
+//CT_GET_TEXT_BASIC
+
+enum
+{
+ CTTEXT_NONAME,
+ CTTEXT_INVALID_EMAIL,
+ CTTEXT_SAVE_FAIL,
+ CTTEXT_ERR_DB_LOCKED,
+ CTTEXT_ADD_FAIL_EXIST,
+ CTTEXT_ALREADY_EXIST,
+ CTTEXT_NO_GROUP,
+ CTTEXT_NO_NUMBER,
+ CTTEXT_NO_EMAIL,
+ CTTEXT_NO_CONTACTS,
+ CTTEXT_IMPORT_SIM_NO_DATA,
+ CTTEXT_EXCEED_LIMIT,
+ CTTEXT_DATA_NOT_EXIST,
+ CTTEXT_INVALID_NUMBER,
+ CTTEXT_SIM_MEMORY_FULL,
+ CTTEXT_NO_CONTACTS_HELP_TEXT,
+ CTTEXT_NO_HISTORIES_HELP_TEXT,
+ CTTEXT_UNABLE_TO_SEND_NAME_CARDS
+};
+//CT_GET_TEXT_ERR
+
+enum
+{
+ PHTEXT_SELECT_LOGS,
+ PHTEXT_SELECT_SPEED_DIAL_CONTACTS,
+ PHTEXT_UNBLOCK,
+ PHTEXT_CHANGE_CONTACT,
+ PHTEXT_ADD_PAUSE,
+ PHTEXT_ADD_WAIT,
+ PHTEXT_MISSED,
+ PHTEXT_EXIT
+};
+// PH_GET_TEXT_BASE_OP
+
+enum
+{
+ PHTEXT_BODY_SUNDAY,
+ PHTEXT_BODY_MONDAY,
+ PHTEXT_BODY_TUESDAY,
+ PHTEXT_BODY_WEDNESDAY,
+ PHTEXT_BODY_THURSDAY,
+ PHTEXT_BODY_FRIDAY,
+ PHTEXT_BODY_SATURDAY
+};
+// PH_GET_TEXT_DAY
+
+enum
+{
+ CTTEXT_SET_DEFAULT_NUMBER,
+ CTTEXT_SET_DEFAULT_EMAIL,
+ CTTEXT_IMAGE,
+ CTTEXT_TAKE_A_PHOTO,
+ CTTEXT_DELETE_PHOTO,
+ CTTEXT_ADD_TO_HOME,
+ CTTEXT_SAVE_CONTACT_TO,
+ CTTEXT_SAVE_TO,
+ CTTEXT_IMPORT_SIM_CONTACTS,
+ CTTEXT_FIRSTLAST,
+ CTTEXT_LASTFIRST,
+ CTTEXT_SHOW,
+ CTTEXT_HIDE,
+ CTTEXT_SEND_NAME_CARD,
+ CTTEXT_CREATE_GROUP,
+ CTTEXT_SELECT_GROUP,
+ CTTEXT_EXPORT_CONTACTS,
+ CTTEXT_IMPORT_CONTACTS,
+ CTTEXT_LINK_CONTACTS,
+ CTTEXT_UNLINK,
+ CTTEXT_ALL_LINKED_CONTACTS_WILL_BE_DELETED,
+ CTTEXT_ADD_TO_FAVOURITES,
+ CTTEXT_EDIT_GROUP,
+ CTTEXT_ADD_MEMBER,
+ CTTEXT_ADD_TO_GROUP,
+ CTTEXT_ADDED_TO_FAVOURITES,
+ CTTEXT_REMOVE_FROM_FAVOURITES,
+ CTTEXT_REMOVED_FROM_FAVOURITES
+};
+//CT_GET_TEXT_BASE_OP
+
+enum
+{
+ CTTEXT_REL_NONE,
+ CTTEXT_REL_ASSISTANT,
+ CTTEXT_REL_BROTHER,
+ CTTEXT_REL_CHILD,
+ CTTEXT_REL_DOMESTIC_PARTNER,
+ CTTEXT_REL_FATHER,
+ CTTEXT_REL_FRIEND,
+ CTTEXT_REL_MANAGER,
+ CTTEXT_REL_MOTHER,
+ CTTEXT_REL_PARENT,
+ CTTEXT_REL_PARTNER,
+ CTTEXT_REL_REFERRED_BY,
+ CTTEXT_REL_RELATIVE,
+ CTTEXT_REL_SISTER,
+ CTTEXT_REL_SPOUSE,
+ CTTEXT_REL_CUSTOM
+};
+//CT_GET_TEXT_RELATIONSHIP_TYPE
+
+enum
+{
+ CTTEXT_VIBRATION_DEFAULT,
+ CTTEXT_VIBRATION_HEARTBEAT,
+ CTTEXT_VIBRATION_JINGLEBELL,
+ CTTEXT_VIBRATION_TICKTOCK,
+ CTTEXT_VIBRATION_WALTZ,
+ CTTEXT_VIBRATION_ZIGZIGZIG,
+ CTTEXT_VIBRATION_MAX
+};
+//CT_GET_TEXT_VIBRATION
+
+enum
+{
+ PH_GET_TEXT_BASIC,
+ PH_GET_TEXT_BASE_OP,
+ PH_GET_TEXT_DAY,
+ CT_GET_TEXT_BASIC,
+ CT_GET_TEXT_ERR,
+ CT_GET_TEXT_BASE_OP,
+ CT_GET_TEXT_NUM_TYPE,
+ CT_GET_TEXT_EMAIL_TYPE,
+ CT_GET_TEXT_WEBSITE_TYPE,
+ CT_GET_TEXT_POSTAL_TYPE,
+ CT_GET_TEXT_EVENT_TYPE,
+ CT_GET_TEXT_IM_TYPE,
+ CT_GET_TEXT_MONTH,
+ CT_GET_TEXT_RELATIONSHIP_TYPE,
+ CT_GET_TEXT_VIBRATION
+};
+
+const char* phone_get_text(int op, int type);
+#define T_(op, type) phone_get_text(op, type)
+
+enum
+{
+ PH_SYS_SK_OK,
+ CT_SYS_SK_SAVE,
+ CT_SYS_SK_DONE,
+ PH_SYS_SK_EDIT,
+ PH_SYS_SK_DELETE,
+ PH_SYS_SK_CANCEL,
+ PH_SYS_SK3_BLOCK,
+ PH_SYS_SK_NO,
+ PH_SYS_SK_YES,
+ CT_SYS_SK_ADD,
+ CT_SYS_SK_MORE,
+ CT_SYS_SK_NEXT,
+ PH_SYS_BODY_CALL,
+ PH_SYS_BODY_MESSAGE,
+ PH_SYS_BODY_VIDEO_CALL,
+ PH_SYS_BODY_UNKNOWN,
+ PH_SYS_BODY_SELECT_ALL,
+ PH_SYS_BODY_CONTACTS,
+ PH_SYS_BODY_DETAILS,
+ PH_SYS_BODY_REMOVE,
+ PH_SYS_BODY_TODAY,
+ PH_SYS_BODY_YESTERDAY,
+ PH_SYS_BODY_PREVIOUS,
+ PH_SYS_BODY_NONAME,
+ CT_SYS_BODY_CREATE,
+ CT_SYS_BODY_MOVE,
+ CT_SYS_BODY_COPY,
+ CT_SYS_BODY_PHONE,
+ CT_SYS_BODY_SEARCH,
+ CT_SYS_BODY_BLUETOOTH,
+ CT_SYS_BODY_EMAIL,
+ CT_SYS_BODY_SIM,
+ CT_SYS_BODY_MEMORYCARD,
+ CT_SYS_BODY_NAME,
+ PH_SYS_BODY_ALL,
+ PH_SYS_POP_FAIL,
+ PH_SYS_POP_FAILED,
+ PH_SYS_POP_CLOSE,
+ PH_SYS_POP_REMOVED,
+ PH_SYS_POP_DELETED,
+ PH_SYS_POP_INCORRECT_PASSWORD,
+ PH_SYS_POP_ALREDY_EXISTS,
+ PH_SYS_POP_SELECTED,
+ CT_SYS_POP_SUCCESS,
+ CT_SYS_POP_ERROR,
+ CT_SYS_POP_MOVED,
+ CT_SYS_POP_ADDED,
+ CT_SYS_POP_NOT_ENOUGH_MEMORY,
+ CT_SYS_POP_NOTHING_SELECTED,
+ CT_SYS_POP_FILE_NOT_FOUND,
+ CT_SYS_POP_ADDRESS,
+ PH_SYS_OPT_ADD_TO_CONTACTS,
+ PH_SYS_BODY_SELECTED_DATA_NOT_FOUND,
+ PH_SYS_POP_DELETE_Q,
+ CT_SYS_SK_SET,
+ CT_SYS_SK_RESET,
+};
+
+const char* phone_get_system_string(int type);
+#define S_(text) phone_get_system_string(text)
+
+#endif //__PHONE_TEXT_H__
diff --git a/lib/common/include/phone.h b/lib/common/include/phone.h
new file mode 100755
index 0000000..9c57375
--- /dev/null
+++ b/lib/common/include/phone.h
@@ -0,0 +1,123 @@
+/*
+ * 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_APP_H__
+#define __PHONE_APP_H__
+
+#include <Elementary.h>
+#include <assert.h>
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#if !defined(PACKAGE)
+# define PACKAGE "phone"
+#endif
+
+#define PHONE_PKG "org.tizen.phone"
+
+#define _EDJ(obj) (Evas_Object *)elm_layout_edje_get(obj)
+
+#define PH_DLOG_OUT
+#define PH_DEBUGGING
+
+#ifdef PH_DLOG_OUT
+#define LOG_TAG "PHONE"
+#include <dlog.h>
+#define DLOG(prio, fmt, arg...) ALOG(prio, LOG_TAG, fmt, ##arg)
+#define INFO(fmt, arg...) ALOGI(fmt, ##arg)
+#define ERR(fmt, arg...) ALOGE(fmt, ##arg)
+#define DBG(fmt, arg...) ALOGD(fmt, ##arg)
+#else //PH_DLOG_OUT
+#define PRT(prio, fmt, arg...) \
+ do { fprintf((prio?stderr:stdout), "[Phone]" fmt"\n", ##arg); } while (0)
+#define INFO(fmt, arg...) PRT(0, fmt, ##arg)
+#define ERR(fmt, arg...) PRT(1, "%s :" fmt, __FUNCTION__, ##arg)
+#define DBG(fmt, arg...) \
+ do { \
+ printf("\x1b[105;37m[Phone]\x1b[0m(%s)" fmt "\n", __FUNCTION__, ##arg); \
+ } while (0)
+#endif //PH_DLOG_OUT
+#ifdef PH_DEBUGGING
+#include "Tracer.h"
+#define PH_TRACE Utils::Tracer tracer(LOG_TAG, __MODULE__, __LINE__, __FUNCTION__)
+#define PH_FN_CALL DBG(">>>>>>>> called")
+#define PH_FN_END DBG("<<<<<<<< ended")
+#define PH_DBG(fmt, arg...) DBG(fmt, ##arg)
+#else /* PH_DEBUGGING */
+#define PH_TRACE
+#define PH_FN_CALL
+#define PH_FN_END
+#define PH_DBG(...)
+#endif /* PH_DEBUGGING */
+
+#define check_if(expr, then) \
+assert(!(expr)); \
+if(expr) \
+{ \
+ then; \
+}
+
+#define p_warn_if(expr, fmt, arg...) do { \
+ if (expr) { \
+ ERR(fmt, ##arg); \
+ } \
+} while (0)
+#define p_ret_if(expr) do { \
+ if (expr) { \
+ ERR("(%s)", #expr); \
+ return; \
+ } \
+} while (0)
+#define p_retv_if(expr, val) do { \
+ if (expr) { \
+ ERR("(%s)", #expr); \
+ return (val); \
+ } \
+} while (0)
+#define p_retm_if_free(expr, fmt, free_val, arg...) do { \
+ if (expr) { \
+ ERR(fmt, ##arg); \
+ free(*free_val); \
+ *free_val = NULL; \
+ return; \
+ } \
+} while (0)
+#define p_retm_if(expr, fmt, arg...) do { \
+ if (expr) { \
+ ERR(fmt, ##arg); \
+ return; \
+ } \
+} while (0)
+#define p_retvm_if(expr, val, fmt, arg...) do { \
+ if (expr) { \
+ ERR(fmt, ##arg); \
+ return (val); \
+ } \
+} while (0)
+
+#define SAFE_STRLEN(str) ((str)?strlen(str):strlen(""))
+#define SAFE_STR(src) ((src)?src:"")
+#define STR_BLANK(str, src) (str && src)?" ":"", SAFE_STR(src)
+#define SAFE_STRDUP(src) ((src)?strdup(src):NULL)
+#define FREEandSTRDUP(dest, src) \
+ do{ \
+ free(dest); dest=NULL;\
+ if (src) dest = strdup(src); \
+ }while(false)
+
+#endif //__PHONE_APP_H__
diff --git a/lib/common/ph-common.cpp b/lib/common/ph-common.cpp
new file mode 100755
index 0000000..23951dc
--- /dev/null
+++ b/lib/common/ph-common.cpp
@@ -0,0 +1,3667 @@
+/*
+ * 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.
+ */
+
+#include <app.h>
+#include <fcntl.h>
+#include <ui-gadget-module.h>
+#include <account-types.h>
+#include <syspopup_caller.h>
+#include <account.h>
+#include <notification.h>
+#include <cctype>
+#include <algorithm>
+#include <unicode/ustring.h>
+#include <unicode/udatpg.h>
+#include <msg.h>
+#include <msg_types.h>
+
+#include "phone.h"
+#include "phone-common.h"
+
+#include <badge.h>
+
+#define CT_CBAR_ITEM_MAX 4
+#define LAUNCH_TYPE "launch-type"
+#define SEND "send"
+#define EMERGENCY "emergency"
+#define FILES "files"
+#define FILECOUNT 1
+#define DEF_MAX_FILTER_LEN (40)
+#define DEF_BUF_LEN (512)
+#define CALL_APP "org.tizen.call"
+
+std::string ct_make_uppercase_string(const std::string& inputStr)
+{
+ std::string retStr;
+ retStr.reserve(inputStr.size());
+ std::transform(inputStr.begin(), inputStr.end(), std::back_inserter(retStr), toupper);
+ return retStr;
+}
+
+/**
+ * @brief Overloaded function for adding string filter
+ * @param filter DB filter handle
+ * @param filterField Link to field
+ * @param strVal The string value to which filtering is performed
+ * @return Returns true if filter was added, otherwise false
+ */
+bool add_filter_field(contacts_filter_h filter, unsigned int filterField, const std::string& strVal)
+{
+ PH_TRACE;
+ return (contacts_filter_add_str(filter, filterField, CONTACTS_MATCH_ENDSWITH, strVal.c_str()) == CONTACTS_ERROR_NONE);
+}
+
+/**
+ * @brief Overloaded function for adding integer filter
+ * @param filter DB filter handle
+ * @param filterField Link to field
+ * @param intVal The integer value to which filtering is performed
+ * @return Returns true if filter was added, otherwise false
+ */
+bool add_filter_field(contacts_filter_h filter, unsigned int filterField, int intVal)
+{
+ PH_TRACE;
+ return (contacts_filter_add_int(filter, filterField, CONTACTS_MATCH_EQUAL, intVal) == CONTACTS_ERROR_NONE);
+}
+
+template < typename FilterFieldType>
+bool get_records_list(const std::string& tableUri, unsigned int filterField,
+ FilterFieldType filterVal, contacts_list_h* list)
+{
+ PH_TRACE;
+ contacts_query_h query = NULL;
+ contacts_filter_h filter = NULL;
+ contacts_list_h innerList = NULL;
+ bool result(false);
+
+ if(contacts_query_create(tableUri.c_str(), &query) == CONTACTS_ERROR_NONE)
+ {
+ if(contacts_filter_create(tableUri.c_str(), &filter) == CONTACTS_ERROR_NONE)
+ {
+ if(add_filter_field(filter, filterField, filterVal))
+ {
+ if(contacts_query_set_filter(query, filter) == CONTACTS_ERROR_NONE)
+ {
+ if(contacts_db_get_records_with_query(query, 0, 0, &innerList) == CONTACTS_ERROR_NONE)
+ {
+ unsigned int count(0);
+ contacts_list_get_count(innerList, &count);
+ if(count > 0)
+ {
+ result = true;
+ }
+ }
+ }
+ }
+ }
+ }
+ result &= contacts_query_destroy(query) == CONTACTS_ERROR_NONE;
+ result &= contacts_filter_destroy(filter) == CONTACTS_ERROR_NONE;
+ if(result)
+ {
+ if(*list)
+ {
+ contacts_list_destroy(*list, true);
+ }
+ *list = innerList;
+ }
+ else
+ {
+ contacts_list_destroy(innerList, true);
+ ERR("List of records is not obtained");
+ }
+
+ return result;
+}
+
+bool phone_toggle_blocked_contact_for_calls(int contactId)
+{
+ PH_TRACE;
+ bool result(false);
+ if (contactId > notRelatedToContactId)
+ {
+ contacts_list_h recList = NULL;
+ if (get_records_list(_contacts_contact._uri, _contacts_contact.id, contactId, &recList))
+ {
+ contacts_record_h contactRec = NULL;
+ contacts_record_h extensionRec = NULL;
+ if (contacts_list_get_current_record_p(recList, &contactRec) == CONTACTS_ERROR_NONE)
+ {
+ if (contacts_record_create(_contacts_extension._uri, &extensionRec) == CONTACTS_ERROR_NONE)
+ {
+ unsigned int extensionsCount(0);