From 157a18ce8d157aa02376d2540005536d8c8e7e1a Mon Sep 17 00:00:00 2001 From: Evgen Servetnik Date: Fri, 28 Jul 2017 13:50:56 +0300 Subject: [PATCH] TizenRefApp-8953 Replace whitespaces to tabs Change-Id: If5481a7a6c4e77cdc3db9c32ca1dd066a708940c Signed-off-by: Evgen Servetnik --- inc/Resource.h | 64 +- src/Common/AppControl/inc/AppControlCommand.h | 58 +- src/Common/AppControl/inc/AppControlCompose.h | 158 +- src/Common/AppControl/inc/AppControlDefault.h | 70 +- .../AppControl/inc/AppControlLauncher.h | 130 +- src/Common/AppControl/inc/AppControlParser.h | 8 +- src/Common/AppControl/inc/AppControlUtils.h | 56 +- src/Common/AppControl/inc/ContactEditor.h | 52 +- src/Common/AppControl/inc/ContactViewer.h | 48 +- src/Common/AppControl/inc/FileViewer.h | 20 +- src/Common/AppControl/inc/Share.h | 32 +- src/Common/AppControl/inc/VoiceCall.h | 32 +- .../AppControl/src/AppControlCommand.cpp | 8 +- .../AppControl/src/AppControlCompose.cpp | 270 +-- .../AppControl/src/AppControlDefault.cpp | 98 +- .../AppControl/src/AppControlLauncher.cpp | 104 +- .../AppControl/src/AppControlParser.cpp | 74 +- src/Common/AppControl/src/AppControlUtils.cpp | 98 +- src/Common/AppControl/src/ContactEditor.cpp | 44 +- src/Common/AppControl/src/ContactViewer.cpp | 36 +- src/Common/AppControl/src/FileViewer.cpp | 56 +- src/Common/AppControl/src/Share.cpp | 46 +- src/Common/AppControl/src/VoiceCall.cpp | 26 +- src/Common/ContactManager/inc/Contact.h | 94 +- .../ContactManager/inc/ContactAddress.h | 48 +- src/Common/ContactManager/inc/ContactList.h | 88 +- .../ContactManager/inc/ContactManager.h | 318 +-- .../ContactManager/inc/ContactMyProfile.h | 62 +- .../inc/ContactMyProfileEmail.h | 144 +- .../inc/ContactMyProfileNumber.h | 144 +- .../ContactManager/inc/ContactPersonEmail.h | 128 +- .../ContactManager/inc/ContactPersonNumber.h | 128 +- .../inc/ContactPersonPhoneLog.h | 72 +- src/Common/ContactManager/inc/ContactRecord.h | 172 +- .../ContactManager/src/ContactManager.cpp | 758 +++---- .../ContactManager/src/ContactRecord.cpp | 12 +- .../src/ContactVCardGenerator.cpp | 76 +- .../ContactManager/src/ContactVCardParser.cpp | 36 +- src/Common/Controller/inc/App.h | 116 +- src/Common/Controller/inc/BaseController.h | 74 +- src/Common/Controller/inc/FrameController.h | 42 +- src/Common/Controller/inc/MbeRecipients.h | 68 +- .../Controller/inc/NaviFrameController.h | 94 +- src/Common/Controller/inc/SaveAttachments.h | 66 +- .../Controller/inc/SaveAttachmentsListItem.h | 26 +- src/Common/Controller/inc/ViewController.h | 16 +- .../Controller/inc/ViewItemController.h | 16 +- src/Common/Controller/src/App.cpp | 140 +- src/Common/Controller/src/BaseController.cpp | 16 +- src/Common/Controller/src/FrameController.cpp | 62 +- src/Common/Controller/src/MbeRecipients.cpp | 114 +- .../Controller/src/NaviFrameController.cpp | 146 +- src/Common/Controller/src/SaveAttachments.cpp | 234 +-- .../src/SaveAttachmentsListItem.cpp | 24 +- src/Common/Controller/src/ViewController.cpp | 4 +- .../Controller/src/ViewItemController.cpp | 4 +- src/Common/MsgEngine/inc/MediaType.h | 508 ++--- src/Common/MsgEngine/inc/Message.h | 334 ++-- src/Common/MsgEngine/inc/MessageMms.h | 30 +- src/Common/MsgEngine/inc/MessageSMS.h | 20 +- src/Common/MsgEngine/inc/MsgAddress.h | 116 +- src/Common/MsgEngine/inc/MsgAttachment.h | 26 +- src/Common/MsgEngine/inc/MsgComposer.h | 36 +- src/Common/MsgEngine/inc/MsgConvMedia.h | 26 +- .../MsgEngine/inc/MsgConversationItem.h | 190 +- src/Common/MsgEngine/inc/MsgEngine.h | 130 +- src/Common/MsgEngine/inc/MsgList.h | 86 +- src/Common/MsgEngine/inc/MsgMedia.h | 84 +- src/Common/MsgEngine/inc/MsgPage.h | 74 +- src/Common/MsgEngine/inc/MsgReport.h | 60 +- src/Common/MsgEngine/inc/MsgSettings.h | 160 +- src/Common/MsgEngine/inc/MsgStorage.h | 522 ++--- src/Common/MsgEngine/inc/MsgThreadItem.h | 100 +- src/Common/MsgEngine/inc/MsgTransport.h | 116 +- src/Common/MsgEngine/inc/MsgTypes.h | 162 +- src/Common/MsgEngine/inc/MsgUtils.h | 34 +- src/Common/MsgEngine/src/MsgEngine.cpp | 676 +++---- src/Common/MsgEngine/src/MsgPage.cpp | 2 +- src/Common/MsgEngine/src/MsgSettings.cpp | 18 +- src/Common/MsgEngine/src/MsgStorage.cpp | 42 +- src/Common/MsgEngine/src/MsgTransport.cpp | 6 +- src/Common/MsgEngine/src/MsgUtils.cpp | 168 +- .../src/private/MessageMmsPrivate.cpp | 162 +- .../MsgEngine/src/private/MessageMmsPrivate.h | 68 +- .../MsgEngine/src/private/MessagePrivate.cpp | 136 +- .../MsgEngine/src/private/MessagePrivate.h | 66 +- .../src/private/MessageSMSPrivate.cpp | 10 +- .../MsgEngine/src/private/MessageSMSPrivate.h | 24 +- .../src/private/MsgAddressPrivate.cpp | 30 +- .../MsgEngine/src/private/MsgAddressPrivate.h | 40 +- .../src/private/MsgAttachmentPrivate.cpp | 40 +- .../src/private/MsgAttachmentPrivate.h | 34 +- .../src/private/MsgComposerPrivate.cpp | 124 +- .../src/private/MsgComposerPrivate.h | 24 +- .../src/private/MsgConvMediaPrivate.cpp | 16 +- .../src/private/MsgConvMediaPrivate.h | 28 +- .../private/MsgConversationItemPrivate.cpp | 82 +- .../src/private/MsgConversationItemPrivate.h | 56 +- .../MsgEngine/src/private/MsgDefPrivate.h | 48 +- .../src/private/MsgListHandlePrivate.h | 118 +- .../MsgEngine/src/private/MsgMediaPrivate.cpp | 54 +- .../MsgEngine/src/private/MsgMediaPrivate.h | 34 +- .../MsgEngine/src/private/MsgPagePrivate.cpp | 30 +- .../MsgEngine/src/private/MsgPagePrivate.h | 32 +- .../src/private/MsgReportPrivate.cpp | 30 +- .../MsgEngine/src/private/MsgReportPrivate.h | 28 +- .../src/private/MsgSettingsPrivate.cpp | 236 +-- .../src/private/MsgSettingsPrivate.h | 120 +- .../src/private/MsgStoragePrivate.cpp | 518 ++--- .../MsgEngine/src/private/MsgStoragePrivate.h | 102 +- .../src/private/MsgStructListPrivate.h | 144 +- .../MsgEngine/src/private/MsgStructPrivate.h | 60 +- .../src/private/MsgThreadItemPrivate.cpp | 44 +- .../src/private/MsgThreadItemPrivate.h | 34 +- .../src/private/MsgTransportPrivate.cpp | 82 +- .../src/private/MsgTransportPrivate.h | 28 +- .../MsgEngine/src/private/MsgUtilsPrivate.cpp | 502 ++--- .../MsgEngine/src/private/MsgUtilsPrivate.h | 50 +- .../inc/SystemSettingsManager.h | 164 +- .../src/SystemSettingsManager.cpp | 124 +- src/Common/Utils/inc/BidirectUtils.h | 66 +- src/Common/Utils/inc/CallbackAssist.h | 28 +- src/Common/Utils/inc/FileUtils.h | 244 +-- src/Common/Utils/inc/HwButtonListener.h | 14 +- src/Common/Utils/inc/LangUtils.h | 154 +- src/Common/Utils/inc/Logger.h | 14 +- src/Common/Utils/inc/LoggerImpl.h | 48 +- src/Common/Utils/inc/MediaUtils.h | 22 +- src/Common/Utils/inc/PathUtils.h | 68 +- src/Common/Utils/inc/PhoneNumberUtils.h | 20 +- src/Common/Utils/inc/TextDecorator.h | 94 +- src/Common/Utils/inc/ThumbnailMaker.h | 86 +- src/Common/Utils/inc/TimeUtils.h | 52 +- src/Common/Utils/inc/VCalendarParser.h | 46 +- src/Common/Utils/src/FileUtils.cpp | 322 +-- src/Common/Utils/src/HwButtonListener.cpp | 20 +- src/Common/Utils/src/LoggerImpl.cpp | 34 +- src/Common/Utils/src/MediaUtils.cpp | 482 ++--- src/Common/Utils/src/PathUtils.cpp | 118 +- src/Common/Utils/src/PhoneNumberUtils.cpp | 26 +- src/Common/Utils/src/TextDecorator.cpp | 136 +- src/Common/Utils/src/ThumbnailMaker.cpp | 254 +-- src/Common/Utils/src/TimeUtils.cpp | 332 +-- src/Common/Utils/src/VCalendarParser.cpp | 110 +- .../View/inc/AtspiAccessibleInterface.h | 186 +- src/Common/View/inc/BaseView.h | 26 +- src/Common/View/inc/Box.h | 236 +-- src/Common/View/inc/ContextPopup.h | 102 +- src/Common/View/inc/DefaultLayout.h | 24 +- src/Common/View/inc/ListItem.h | 344 ++-- src/Common/View/inc/ListView.h | 608 +++--- src/Common/View/inc/MbeRecipientViewItem.h | 184 +- src/Common/View/inc/MbeRecipientsView.h | 152 +- src/Common/View/inc/NaviFrameItem.h | 452 ++--- src/Common/View/inc/NaviFrameView.h | 170 +- src/Common/View/inc/NoContentLayout.h | 24 +- src/Common/View/inc/Popup.h | 102 +- src/Common/View/inc/PopupAttachmentListItem.h | 28 +- src/Common/View/inc/PopupList.h | 96 +- src/Common/View/inc/PopupListItem.h | 92 +- src/Common/View/inc/PopupManager.h | 204 +- src/Common/View/inc/Scroller.h | 24 +- src/Common/View/inc/SelectAllListItem.h | 22 +- src/Common/View/inc/StandardWindow.h | 34 +- src/Common/View/inc/View.h | 1058 +++++----- src/Common/View/inc/ViewItem.h | 448 ++--- src/Common/View/inc/Window.h | 28 +- src/Common/View/src/Box.cpp | 6 +- src/Common/View/src/ContextPopup.cpp | 108 +- src/Common/View/src/DefaultLayout.cpp | 30 +- src/Common/View/src/ListItem.cpp | 188 +- src/Common/View/src/ListView.cpp | 266 +-- src/Common/View/src/MbeRecipientsView.cpp | 98 +- src/Common/View/src/NaviFrameItem.cpp | 404 ++-- src/Common/View/src/NaviFrameView.cpp | 194 +- src/Common/View/src/NoContentLayout.cpp | 14 +- src/Common/View/src/Popup.cpp | 202 +- .../View/src/PopupAttachmentListItem.cpp | 8 +- src/Common/View/src/PopupList.cpp | 56 +- src/Common/View/src/PopupListItem.cpp | 36 +- src/Common/View/src/PopupManager.cpp | 62 +- src/Common/View/src/Scroller.cpp | 12 +- src/Common/View/src/SelectAllListItem.cpp | 16 +- src/Common/View/src/StandardWindow.cpp | 62 +- src/Common/View/src/View.cpp | 152 +- src/Common/View/src/ViewItem.cpp | 30 +- src/Conversation/AppControl/inc/AttachPanel.h | 56 +- .../AppControl/inc/ContactPicker.h | 74 +- .../AppControl/inc/SettingsNetwork.h | 12 +- .../AppControl/src/AttachPanel.cpp | 118 +- .../AppControl/src/ContactPicker.cpp | 88 +- .../AppControl/src/SettingsNetwork.cpp | 4 +- src/Conversation/Body/Controller/inc/Body.h | 198 +- src/Conversation/Body/Controller/src/Body.cpp | 562 +++--- src/Conversation/Body/View/inc/BodyView.h | 52 +- src/Conversation/Body/View/src/BodyView.cpp | 166 +- .../Controller/inc/ContactListItem.h | 38 +- .../Controller/inc/ConvContactList.h | 64 +- .../Controller/src/ContactListItem.cpp | 30 +- .../Controller/src/ConvContactList.cpp | 88 +- .../View/inc/ContactListViewItem.h | 30 +- .../View/inc/ConvContactListView.h | 28 +- .../View/src/ContactListViewItem.cpp | 42 +- .../View/src/ConvContactListView.cpp | 54 +- .../Controller/inc/BubbleAudioEntity.h | 20 +- .../ConvList/Controller/inc/BubbleBgEntity.h | 52 +- .../Controller/inc/BubbleCalEventEntity.h | 20 +- .../Controller/inc/BubbleContactEntity.h | 26 +- .../inc/BubbleDownloadButtonEntity.h | 68 +- .../ConvList/Controller/inc/BubbleEntity.h | 134 +- .../Controller/inc/BubbleEntityFactory.h | 42 +- .../Controller/inc/BubbleImageEntity.h | 48 +- .../Controller/inc/BubbleTextEntity.h | 54 +- .../Controller/inc/BubbleUnknownFileEntity.h | 18 +- .../Controller/inc/BubbleVideoEntity.h | 20 +- .../ConvList/Controller/inc/ComposeListItem.h | 68 +- .../ConvList/Controller/inc/ConvList.h | 382 ++-- .../ConvList/Controller/inc/ConvListItem.h | 254 +-- .../ConvList/Controller/inc/DateLineItem.h | 20 +- .../ConvList/Controller/inc/MsgDetailsPopup.h | 44 +- .../Controller/src/BubbleAudioEntity.cpp | 28 +- .../Controller/src/BubbleCalEventEntity.cpp | 32 +- .../Controller/src/BubbleContactEntity.cpp | 52 +- .../Controller/src/BubbleEntityFactory.cpp | 88 +- .../src/BubbleUnknownFileEntity.cpp | 10 +- .../Controller/src/BubbleVideoEntity.cpp | 18 +- .../Controller/src/ComposeListItem.cpp | 116 +- .../ConvList/Controller/src/ConvList.cpp | 556 +++--- .../ConvList/Controller/src/ConvListItem.cpp | 630 +++--- .../ConvList/Controller/src/DateLineItem.cpp | 10 +- .../Controller/src/MsgDetailsPopup.cpp | 94 +- .../ConvList/View/inc/BubbleAudioViewItem.h | 28 +- .../ConvList/View/inc/BubbleBgViewItem.h | 66 +- .../View/inc/BubbleCalEventViewItem.h | 28 +- .../ConvList/View/inc/BubbleContactViewItem.h | 26 +- .../View/inc/BubbleDownloadButtonViewItem.h | 18 +- .../View/inc/BubbleIconTextLayoutItem.h | 52 +- .../ConvList/View/inc/BubbleImageViewItem.h | 16 +- .../ConvList/View/inc/BubbleItemContainer.h | 16 +- .../ConvList/View/inc/BubbleTextViewItem.h | 16 +- .../View/inc/BubbleUnknownFileViewItem.h | 28 +- .../ConvList/View/inc/BubbleVideoViewItem.h | 16 +- .../ConvList/View/inc/BubbleViewItem.h | 70 +- .../ConvList/View/inc/ComposeListViewItem.h | 34 +- .../ConvList/View/inc/ConvListLayout.h | 24 +- .../ConvList/View/inc/ConvListViewItem.h | 76 +- .../ConvList/View/inc/ConvSelectAll.h | 32 +- .../ConvList/View/inc/DateLineViewItem.h | 26 +- .../ConvList/View/src/BubbleBgViewItem.cpp | 80 +- .../View/src/BubbleDownloadButtonViewItem.cpp | 22 +- .../View/src/BubbleIconTextLayoutItem.cpp | 54 +- .../ConvList/View/src/BubbleImageViewItem.cpp | 44 +- .../ConvList/View/src/BubbleItemContainer.cpp | 40 +- .../ConvList/View/src/BubbleTextViewItem.cpp | 36 +- .../ConvList/View/src/BubbleVideoViewItem.cpp | 42 +- .../ConvList/View/src/BubbleViewItem.cpp | 136 +- .../ConvList/View/src/ComposeListViewItem.cpp | 26 +- .../ConvList/View/src/ConvListLayout.cpp | 20 +- .../ConvList/View/src/ConvListViewItem.cpp | 220 +- .../ConvList/View/src/ConvSelectAll.cpp | 44 +- .../ConvList/View/src/DateLineViewItem.cpp | 22 +- .../Main/Controller/inc/Conversation.h | 392 ++-- .../Controller/inc/PopupRecipientListItem.h | 70 +- .../Main/Controller/src/Conversation.cpp | 1778 ++++++++--------- .../Controller/src/PopupRecipientListItem.cpp | 34 +- .../Main/View/inc/ConversationLayout.h | 48 +- .../Main/View/inc/MessageInputPanel.h | 74 +- .../Main/View/src/ConversationLayout.cpp | 54 +- .../Main/View/src/MessageInputPanel.cpp | 142 +- .../Controller/inc/ConvRecipientsPanel.h | 128 +- .../Controller/src/ConvRecipientsPanel.cpp | 358 ++-- .../View/inc/ConvRecipientsPanelView.h | 210 +- .../View/src/ConvRecipientsPanelView.cpp | 568 +++--- .../Utils/inc/AttachmentHandler.h | 76 +- .../Utils/inc/MessageDetailContent.h | 38 +- src/Conversation/Utils/inc/WorkingDir.h | 56 +- .../Utils/src/AttachmentHandler.cpp | 156 +- .../Utils/src/MessageDetailContent.cpp | 522 ++--- src/Conversation/Utils/src/WorkingDir.cpp | 148 +- src/MainApp/MainApp.cpp | 226 +-- src/MainApp/MainApp.h | 66 +- src/MainApp/main.cpp | 10 +- .../Controller/inc/BaseThreadListItem.h | 62 +- .../Controller/inc/MsgSearchListItem.h | 22 +- src/MsgThread/Controller/inc/MsgThread.h | 176 +- src/MsgThread/Controller/inc/ThreadList.h | 118 +- src/MsgThread/Controller/inc/ThreadListItem.h | 32 +- .../Controller/inc/ThreadSearchList.h | 82 +- .../Controller/inc/ThreadSearchListItem.h | 22 +- .../Controller/src/BaseThreadListItem.cpp | 90 +- .../Controller/src/MsgSearchListItem.cpp | 18 +- src/MsgThread/Controller/src/MsgThread.cpp | 412 ++-- src/MsgThread/Controller/src/ThreadList.cpp | 398 ++-- .../Controller/src/ThreadListItem.cpp | 72 +- .../Controller/src/ThreadSearchList.cpp | 172 +- .../Controller/src/ThreadSearchListItem.cpp | 16 +- src/MsgThread/View/inc/FloatingButton.h | 50 +- src/MsgThread/View/inc/MsgThreadLayout.h | 34 +- src/MsgThread/View/inc/MsgThreadSearchPanel.h | 72 +- src/MsgThread/View/inc/ThreadListViewItem.h | 72 +- src/MsgThread/View/src/FloatingButton.cpp | 28 +- src/MsgThread/View/src/MsgThreadLayout.cpp | 32 +- .../View/src/MsgThreadSearchPanel.cpp | 144 +- src/MsgThread/View/src/ThreadListViewItem.cpp | 120 +- src/Settings/Controller/inc/MsgOnSimCard.h | 154 +- src/Settings/Controller/inc/Settings.h | 204 +- .../Controller/inc/SettingsListItem.h | 66 +- src/Settings/Controller/inc/SettingsSound.h | 52 +- src/Settings/Controller/inc/SimListViewItem.h | 72 +- src/Settings/Controller/src/MsgOnSimCard.cpp | 384 ++-- src/Settings/Controller/src/Settings.cpp | 370 ++-- src/Settings/Controller/src/SettingsSound.cpp | 100 +- .../Controller/src/SimListViewItem.cpp | 56 +- .../View/inc/SettingsGroupListViewItem.h | 36 +- src/Settings/View/inc/SettingsListViewItem.h | 196 +- src/Settings/View/inc/SimMsgLayout.h | 76 +- .../View/src/SettingsGroupListViewItem.cpp | 14 +- .../View/src/SettingsListViewItem.cpp | 108 +- src/Settings/View/src/SimMsgLayout.cpp | 26 +- src/Viewer/Controller/inc/SmilPage.h | 94 +- src/Viewer/Controller/inc/SmilPlayer.h | 134 +- src/Viewer/Controller/inc/Viewer.h | 196 +- src/Viewer/Controller/src/SmilPage.cpp | 316 +-- src/Viewer/Controller/src/SmilPlayer.cpp | 362 ++-- src/Viewer/Controller/src/Viewer.cpp | 446 ++--- src/Viewer/Utils/inc/MediaPlayer.h | 84 +- src/Viewer/Utils/src/MediaPlayer.cpp | 194 +- src/Viewer/View/inc/PlayerControl.h | 74 +- src/Viewer/View/inc/SmilAttachmentItemView.h | 102 +- src/Viewer/View/inc/SmilAudioItemView.h | 14 +- src/Viewer/View/inc/SmilImageItemView.h | 26 +- src/Viewer/View/inc/SmilPageLayout.h | 26 +- src/Viewer/View/inc/SmilPlayerView.h | 18 +- src/Viewer/View/inc/SmilTextItemView.h | 16 +- src/Viewer/View/inc/SmilVideoItemView.h | 22 +- src/Viewer/View/inc/SubjectLayout.h | 26 +- src/Viewer/View/inc/ViewerLayout.h | 60 +- src/Viewer/View/src/PlayerControl.cpp | 104 +- .../View/src/SmilAttachmentItemView.cpp | 190 +- src/Viewer/View/src/SmilAudioItemView.cpp | 8 +- src/Viewer/View/src/SmilImageItemView.cpp | 46 +- src/Viewer/View/src/SmilPageLayout.cpp | 40 +- src/Viewer/View/src/SmilPlayerView.cpp | 40 +- src/Viewer/View/src/SmilTextItemView.cpp | 32 +- src/Viewer/View/src/SmilVideoItemView.cpp | 76 +- src/Viewer/View/src/SubjectLayout.cpp | 26 +- src/Viewer/View/src/ViewerLayout.cpp | 106 +- test/TC/ContactUtils.cpp | 212 +- test/TC/ContactUtils.h | 34 +- test/TC/TestAppControlUtils.cpp | 84 +- test/TC/TestContactManager.cpp | 90 +- test/TC/TestMessageSender.cpp | 54 +- test/TC/TestMsgUtils.cpp | 60 +- test/TC/TestTextDecorator.cpp | 44 +- test/TC/TestTimeUtils.cpp | 62 +- 355 files changed, 20276 insertions(+), 20276 deletions(-) diff --git a/inc/Resource.h b/inc/Resource.h index f4cd38a8..29bc5a84 100644 --- a/inc/Resource.h +++ b/inc/Resource.h @@ -21,45 +21,45 @@ #define IMAGE_PATH "images" // Res images: -#define CONV_SEND_IMG "messages_btn_send.png" -#define CONV_ADD_IMG "btn_conversation_add.png" -#define CONTACT_IMG "messages_add_contact.png" -#define ADD_PLUS_ICON "core_button_add.png" -#define ATTACH_MUSIC_ICON "messages_attach_ic_music.png" -#define ATTACH_CAL_ICON "messages_attach_ic_calendar.png" -#define ATTACH_CONTACT_ICON "messages_attach_ic_contact.png" -#define ATTACH_UNKNOWN_ICON "messages_attach_ic_others.png" +#define CONV_SEND_IMG "messages_btn_send.png" +#define CONV_ADD_IMG "btn_conversation_add.png" +#define CONTACT_IMG "messages_add_contact.png" +#define ADD_PLUS_ICON "core_button_add.png" +#define ATTACH_MUSIC_ICON "messages_attach_ic_music.png" +#define ATTACH_CAL_ICON "messages_attach_ic_calendar.png" +#define ATTACH_CONTACT_ICON "messages_attach_ic_contact.png" +#define ATTACH_UNKNOWN_ICON "messages_attach_ic_others.png" // Edj: -#define ICONS_EDJ_PATH EDJ_PATH"/icons.edj" -#define IMAGES_EDJ_PATH EDJ_PATH"/images.edj" -#define BUTTON_THEME_EDJ_PATH EDJ_PATH"/button_theme.edj" -#define THREAD_THEME_EDJ_PATH EDJ_PATH"/thread_genlist_theme.edj" +#define ICONS_EDJ_PATH EDJ_PATH"/icons.edj" +#define IMAGES_EDJ_PATH EDJ_PATH"/images.edj" +#define BUTTON_THEME_EDJ_PATH EDJ_PATH"/button_theme.edj" +#define THREAD_THEME_EDJ_PATH EDJ_PATH"/thread_genlist_theme.edj" -#define CONV_GENLIST_THEME_EDJ_PATH EDJ_PATH"/conv_genlist_theme.edj" -#define CONV_LABEL_THEME_EDJ_PATH EDJ_PATH"/conv_label_theme.edj" -#define MSG_INPUT_PANEL_EDJ_PATH EDJ_PATH"/msg_input_panel.edj" -#define RECIPIENT_PANEL_EDJ_PATH EDJ_PATH"/recipient_panel.edj" +#define CONV_GENLIST_THEME_EDJ_PATH EDJ_PATH"/conv_genlist_theme.edj" +#define CONV_LABEL_THEME_EDJ_PATH EDJ_PATH"/conv_label_theme.edj" +#define MSG_INPUT_PANEL_EDJ_PATH EDJ_PATH"/msg_input_panel.edj" +#define RECIPIENT_PANEL_EDJ_PATH EDJ_PATH"/recipient_panel.edj" -#define MSG_THREAD_EDJ_PATH EDJ_PATH"/msg_thread.edj" -#define CONTACTS_SEARCH_EDJ_PATH EDJ_PATH"/contact_search.edj" -#define THUMBNAIL_EDJ_PATH EDJ_PATH"/msg_thumbnail.edj" -#define MSG_TITLE_EDJ_PATH EDJ_PATH"/msg_title.edj" -#define SELECT_ALL_EDJ_PATH EDJ_PATH"/select_all.edj" -#define VIEWER_LAYOUT_EDJ_PATH EDJ_PATH"/viewer_layout.edj" -#define VIEWER_PALYER_EDJ_PATH EDJ_PATH"/viewer_player.edj" -#define VIEWER_SUBJECT_LAYOUT_EDJ_PATH EDJ_PATH"/viewer_subject_layout.edj" -#define SMIL_ITEM_EDJ_PATH EDJ_PATH"/smil_item.edj" -#define CONV_LIST_BUBBLE_EDJ_PATH EDJ_PATH"/conv_list_bubble.edj" +#define MSG_THREAD_EDJ_PATH EDJ_PATH"/msg_thread.edj" +#define CONTACTS_SEARCH_EDJ_PATH EDJ_PATH"/contact_search.edj" +#define THUMBNAIL_EDJ_PATH EDJ_PATH"/msg_thumbnail.edj" +#define MSG_TITLE_EDJ_PATH EDJ_PATH"/msg_title.edj" +#define SELECT_ALL_EDJ_PATH EDJ_PATH"/select_all.edj" +#define VIEWER_LAYOUT_EDJ_PATH EDJ_PATH"/viewer_layout.edj" +#define VIEWER_PALYER_EDJ_PATH EDJ_PATH"/viewer_player.edj" +#define VIEWER_SUBJECT_LAYOUT_EDJ_PATH EDJ_PATH"/viewer_subject_layout.edj" +#define SMIL_ITEM_EDJ_PATH EDJ_PATH"/smil_item.edj" +#define CONV_LIST_BUBBLE_EDJ_PATH EDJ_PATH"/conv_list_bubble.edj" -#define CONV_LIST_EDJ_PATH EDJ_PATH"/conv_list.edj" -#define CONV_LAYOUT_EDJ_PATH EDJ_PATH"/conv_layout.edj" -#define CONV_CONTACT_LIST_LAYOUT EDJ_PATH"/conv_contact_list_layout.edj" +#define CONV_LIST_EDJ_PATH EDJ_PATH"/conv_list.edj" +#define CONV_LAYOUT_EDJ_PATH EDJ_PATH"/conv_layout.edj" +#define CONV_CONTACT_LIST_LAYOUT EDJ_PATH"/conv_contact_list_layout.edj" // Images(res): -#define THUMB_CONTACT_IMG_PATH IMAGE_PATH"/messages_list_thumb_image_single.png" -#define THUMB_GROUP_IMG_PATH IMAGE_PATH"/messages_list_thumb_image_multi.png" -#define MSG_THREAD_FLOATING_BTN_ICON IMAGE_PATH"/message_floating_button_icon.png" +#define THUMB_CONTACT_IMG_PATH IMAGE_PATH"/messages_list_thumb_image_single.png" +#define THUMB_GROUP_IMG_PATH IMAGE_PATH"/messages_list_thumb_image_multi.png" +#define MSG_THREAD_FLOATING_BTN_ICON IMAGE_PATH"/message_floating_button_icon.png" #endif /* RESOURCE_H_ */ diff --git a/src/Common/AppControl/inc/AppControlCommand.h b/src/Common/AppControl/inc/AppControlCommand.h index dce36c54..1e785806 100644 --- a/src/Common/AppControl/inc/AppControlCommand.h +++ b/src/Common/AppControl/inc/AppControlCommand.h @@ -22,35 +22,35 @@ #include namespace Msg { - class AppControlCommand; - typedef std::shared_ptr AppControlCommandRef; - - class AppControlCommand { - public: - enum OperationType { - OpUnknown, - OpDefault, - OpComposeFamily /** For operations Compose, Share, MultiShare and ShareText */ - }; - - public: - AppControlCommand(const std::string &opMsg, OperationType type); - virtual ~AppControlCommand(); - - /** - *@brief Get raw operation string. - */ - const std::string &getOperationMsg() const; - - /** - *@brief Get operation type. - */ - OperationType getOperationType() const; - - private: - std::string m_OperationMsg; - OperationType m_OperationType; - }; + class AppControlCommand; + typedef std::shared_ptr AppControlCommandRef; + + class AppControlCommand { + public: + enum OperationType { + OpUnknown, + OpDefault, + OpComposeFamily /** For operations Compose, Share, MultiShare and ShareText */ + }; + + public: + AppControlCommand(const std::string &opMsg, OperationType type); + virtual ~AppControlCommand(); + + /** + *@brief Get raw operation string. + */ + const std::string &getOperationMsg() const; + + /** + *@brief Get operation type. + */ + OperationType getOperationType() const; + + private: + std::string m_OperationMsg; + OperationType m_OperationType; + }; } #endif /* AppControlCommand_h_ */ diff --git a/src/Common/AppControl/inc/AppControlCompose.h b/src/Common/AppControl/inc/AppControlCompose.h index 31d44c60..12a7ec60 100644 --- a/src/Common/AppControl/inc/AppControlCompose.h +++ b/src/Common/AppControl/inc/AppControlCompose.h @@ -23,85 +23,85 @@ #include namespace Msg { - class AppControlCompose; - typedef std::shared_ptr AppControlComposeRef; - - struct VcfInfo { - std::list contactsIdList; - bool isMyProfile; - }; - - class AppControlCompose - : public AppControlCommand { - public: - typedef std::list RecipientList; - typedef std::list FileList; - - enum OpComposeType { - OpUnknown, - OpCompose, /** APP_CONTROL_OPERATION_COMPOSE */ - OpShare, /** APP_CONTROL_OPERATION_SHARE */ - OpMultiShare, /** APP_CONTROL_OPERATION_MULTI_SHARE */ - OpShareText /** APP_CONTROL_OPERATION_SHARE_TEXT */ - }; - - public: - AppControlCompose(const std::string &opMsg, app_control_h handle); - virtual ~AppControlCompose(); - - /** - *@brief Gets compose type. - */ - OpComposeType getComposeType() const; - - /** - *@brief Gets data from APP_CONTROL_DATA_TO or URI(if exists). - */ - const RecipientList &getRecipientList() const; - - /** - *@brief Checks if is MMS. - */ - bool isMms() const; - - /** - *@brief Gets data from APP_CONTROL_DATA_TEXT. - */ - const std::string &getMessageText() const; - - /** - *@brief Gets data from APP_CONTROL_DATA_SUBJECT. - */ - const std::string &getMessageSubject() const; - - /** - *@brief Gets data from APP_CONTROL_DATA_PATH or URI(if exists). - */ - const FileList &getFileList() const; - - /** - *@brief Gets vcf info from APP_CONTROL_DATA_ID - */ - const VcfInfo &getVcfInfo() const; - - private: - bool parseUriCompose(app_control_h handle); - bool parseUriShare(app_control_h handle); - - void createComposeOp(app_control_h handle); - void createShareOp(app_control_h handle); - void createMultiShareOp(app_control_h handle); - void createShareTextOp(app_control_h handle); - - private: - OpComposeType m_ComposeType; - RecipientList m_RecipientList; - bool m_isMms; - FileList m_FileList; - std::string m_MessageText; - std::string m_Subject; - VcfInfo m_VcfInfo; - }; + class AppControlCompose; + typedef std::shared_ptr AppControlComposeRef; + + struct VcfInfo { + std::list contactsIdList; + bool isMyProfile; + }; + + class AppControlCompose + : public AppControlCommand { + public: + typedef std::list RecipientList; + typedef std::list FileList; + + enum OpComposeType { + OpUnknown, + OpCompose, /** APP_CONTROL_OPERATION_COMPOSE */ + OpShare, /** APP_CONTROL_OPERATION_SHARE */ + OpMultiShare, /** APP_CONTROL_OPERATION_MULTI_SHARE */ + OpShareText /** APP_CONTROL_OPERATION_SHARE_TEXT */ + }; + + public: + AppControlCompose(const std::string &opMsg, app_control_h handle); + virtual ~AppControlCompose(); + + /** + *@brief Gets compose type. + */ + OpComposeType getComposeType() const; + + /** + *@brief Gets data from APP_CONTROL_DATA_TO or URI(if exists). + */ + const RecipientList &getRecipientList() const; + + /** + *@brief Checks if is MMS. + */ + bool isMms() const; + + /** + *@brief Gets data from APP_CONTROL_DATA_TEXT. + */ + const std::string &getMessageText() const; + + /** + *@brief Gets data from APP_CONTROL_DATA_SUBJECT. + */ + const std::string &getMessageSubject() const; + + /** + *@brief Gets data from APP_CONTROL_DATA_PATH or URI(if exists). + */ + const FileList &getFileList() const; + + /** + *@brief Gets vcf info from APP_CONTROL_DATA_ID + */ + const VcfInfo &getVcfInfo() const; + + private: + bool parseUriCompose(app_control_h handle); + bool parseUriShare(app_control_h handle); + + void createComposeOp(app_control_h handle); + void createShareOp(app_control_h handle); + void createMultiShareOp(app_control_h handle); + void createShareTextOp(app_control_h handle); + + private: + OpComposeType m_ComposeType; + RecipientList m_RecipientList; + bool m_isMms; + FileList m_FileList; + std::string m_MessageText; + std::string m_Subject; + VcfInfo m_VcfInfo; + }; } #endif /* AppControlCompose_h_ */ diff --git a/src/Common/AppControl/inc/AppControlDefault.h b/src/Common/AppControl/inc/AppControlDefault.h index e7e9886e..30c3389d 100644 --- a/src/Common/AppControl/inc/AppControlDefault.h +++ b/src/Common/AppControl/inc/AppControlDefault.h @@ -23,41 +23,41 @@ #include namespace Msg { - class AppControlDefault; - typedef std::shared_ptr AppControlDefaultRef; - - class AppControlDefault - : public AppControlCommand { - public: - enum DefaultType { - UnknownType, - MainType, //Type from home screen - ReplyType, //Type for reply message button clicked from Active Notification - ViewType, //Type for view message button clicked from Active Notification - NotificationType, //Type from notification panel - SendFailedType //Send failed message type from notification panel - }; - - public: - AppControlDefault(const std::string &opMsg, app_control_h handle); - virtual ~AppControlDefault(); - - MsgId getMessageId() const; - DefaultType getDefaultType() const; - const std::string& getReplyText() const; - - private: - bool isNotificationPanel(app_control_h handle) const; - void parse(app_control_h handle); - void replyMessage(app_control_h handle); - void viewMessage(app_control_h handle); - void makeReplyText(app_control_h handle); - - private: - MsgId m_MsgId; - DefaultType m_DefaultType; - std::string m_ReplyText; - }; + class AppControlDefault; + typedef std::shared_ptr AppControlDefaultRef; + + class AppControlDefault + : public AppControlCommand { + public: + enum DefaultType { + UnknownType, + MainType, //Type from home screen + ReplyType, //Type for reply message button clicked from Active Notification + ViewType, //Type for view message button clicked from Active Notification + NotificationType, //Type from notification panel + SendFailedType //Send failed message type from notification panel + }; + + public: + AppControlDefault(const std::string &opMsg, app_control_h handle); + virtual ~AppControlDefault(); + + MsgId getMessageId() const; + DefaultType getDefaultType() const; + const std::string& getReplyText() const; + + private: + bool isNotificationPanel(app_control_h handle) const; + void parse(app_control_h handle); + void replyMessage(app_control_h handle); + void viewMessage(app_control_h handle); + void makeReplyText(app_control_h handle); + + private: + MsgId m_MsgId; + DefaultType m_DefaultType; + std::string m_ReplyText; + }; } #endif /* AppControlDefault_h_ */ diff --git a/src/Common/AppControl/inc/AppControlLauncher.h b/src/Common/AppControl/inc/AppControlLauncher.h index a1ae4443..7544273d 100644 --- a/src/Common/AppControl/inc/AppControlLauncher.h +++ b/src/Common/AppControl/inc/AppControlLauncher.h @@ -22,71 +22,71 @@ #include namespace Msg { - class AppControlLauncher; - class AppControlHandle { - friend class AppControlLauncher; - - public: - AppControlHandle(app_control_launch_mode_e launchMode = APP_CONTROL_LAUNCH_MODE_GROUP); - virtual ~AppControlHandle(); - - /** - *@brief Terminate launch request related with this handle. - */ - void terminate(); - - /** - *@brief Returns internal handle to app_control_h - */ - operator app_control_h(); - - protected: - virtual void onReply(app_control_h request, app_control_h reply, app_control_result_e result) {}; - - AppControlHandle(const AppControlHandle&) = delete; - AppControlHandle& operator=(AppControlHandle) = delete; - - protected: - app_control_h m_Handle; - }; - - class AppControlLauncher { - friend class AppControlHandle; - - public: - static AppControlLauncher &getInst(); - - /** - *@brief Launch application by AppControlHandle - *@param handle for launch - *@return true if launch is success, false otherwise - */ - bool launch(AppControlHandle &handle); - - /** - *@brief Terminate current launch request. - */ - void terminate(); - - /** - *@brief Gets current launch status - *@return true if launch process in progress, false otherwise - */ - bool isLaunchInProgress() const; - - private: - AppControlLauncher(); - ~AppControlLauncher(); - AppControlLauncher(const AppControlLauncher&) = delete; - AppControlLauncher& operator=(const AppControlLauncher&) = delete; - - void onReply(app_control_h request, app_control_h reply, app_control_result_e result); - - private: - bool m_LaunchInProgress; - Ecore_Timer *m_pTimer; - AppControlHandle *m_pHandle; - }; + class AppControlLauncher; + class AppControlHandle { + friend class AppControlLauncher; + + public: + AppControlHandle(app_control_launch_mode_e launchMode = APP_CONTROL_LAUNCH_MODE_GROUP); + virtual ~AppControlHandle(); + + /** + *@brief Terminate launch request related with this handle. + */ + void terminate(); + + /** + *@brief Returns internal handle to app_control_h + */ + operator app_control_h(); + + protected: + virtual void onReply(app_control_h request, app_control_h reply, app_control_result_e result) {}; + + AppControlHandle(const AppControlHandle&) = delete; + AppControlHandle& operator=(AppControlHandle) = delete; + + protected: + app_control_h m_Handle; + }; + + class AppControlLauncher { + friend class AppControlHandle; + + public: + static AppControlLauncher &getInst(); + + /** + *@brief Launch application by AppControlHandle + *@param handle for launch + *@return true if launch is success, false otherwise + */ + bool launch(AppControlHandle &handle); + + /** + *@brief Terminate current launch request. + */ + void terminate(); + + /** + *@brief Gets current launch status + *@return true if launch process in progress, false otherwise + */ + bool isLaunchInProgress() const; + + private: + AppControlLauncher(); + ~AppControlLauncher(); + AppControlLauncher(const AppControlLauncher&) = delete; + AppControlLauncher& operator=(const AppControlLauncher&) = delete; + + void onReply(app_control_h request, app_control_h reply, app_control_result_e result); + + private: + bool m_LaunchInProgress; + Ecore_Timer *m_pTimer; + AppControlHandle *m_pHandle; + }; } #endif /* AppControlLauncher_h_ */ diff --git a/src/Common/AppControl/inc/AppControlParser.h b/src/Common/AppControl/inc/AppControlParser.h index 0e5e27f2..86bb9f0f 100644 --- a/src/Common/AppControl/inc/AppControlParser.h +++ b/src/Common/AppControl/inc/AppControlParser.h @@ -21,10 +21,10 @@ #include namespace Msg { - class AppControlParser { - public: - static AppControlCommandRef parse(app_control_h handle); - }; + class AppControlParser { + public: + static AppControlCommandRef parse(app_control_h handle); + }; } #endif /* AppControlParser_h_ */ diff --git a/src/Common/AppControl/inc/AppControlUtils.h b/src/Common/AppControl/inc/AppControlUtils.h index 12ae9d3a..19cafc3e 100644 --- a/src/Common/AppControl/inc/AppControlUtils.h +++ b/src/Common/AppControl/inc/AppControlUtils.h @@ -22,37 +22,37 @@ #include #define APP_CONTROL_RES_CALLBACK(ClassName, method) [](app_control_h request, app_control_h reply, app_control_result_e result, void *data)\ -{ \ - return static_cast(data)->method(request, reply, result);\ +{ \ + return static_cast(data)->method(request, reply, result);\ } namespace Msg { - struct AppControlUtils { - /** - *@brief Gets a single string from given app-control handle by a key specified - */ - static std::string getExtraData(app_control_h handle, const std::string &key); - - /** - *@brief Gets a string-array from given app-control handle by a key specified - */ - static void getExtraDataArray(app_control_h handle, const std::string &key, std::list &outArray); - - /** - *@brief Gets a single int number from given app-control handle by a key specified. - */ - static int getExtraDataInt(app_control_h handle, const std::string &key); - - /** - *@brief Gets an int-array from given app-control handle by a key specified. - */ - static void getExtraDataIntArray(app_control_h handle, const std::string &key, std::list &outArray); - - /** - *@brief Gets a single mime type string from given app-control handle. - */ - static std::string getMimeType(app_control_h handle); - }; + struct AppControlUtils { + /** + *@brief Gets a single string from given app-control handle by a key specified + */ + static std::string getExtraData(app_control_h handle, const std::string &key); + + /** + *@brief Gets a string-array from given app-control handle by a key specified + */ + static void getExtraDataArray(app_control_h handle, const std::string &key, std::list &outArray); + + /** + *@brief Gets a single int number from given app-control handle by a key specified. + */ + static int getExtraDataInt(app_control_h handle, const std::string &key); + + /** + *@brief Gets an int-array from given app-control handle by a key specified. + */ + static void getExtraDataIntArray(app_control_h handle, const std::string &key, std::list &outArray); + + /** + *@brief Gets a single mime type string from given app-control handle. + */ + static std::string getMimeType(app_control_h handle); + }; } #endif /* AppControlUtils_h_ */ diff --git a/src/Common/AppControl/inc/ContactEditor.h b/src/Common/AppControl/inc/ContactEditor.h index c874ca8b..7235a17f 100644 --- a/src/Common/AppControl/inc/ContactEditor.h +++ b/src/Common/AppControl/inc/ContactEditor.h @@ -22,32 +22,32 @@ #include namespace Msg { - class IContactEditorListener; - - /** - *@brief An utility-class aimed to launch contacts-application with add-operation and edit-operation passed via app-control. - */ - class ContactEditor - : public AppControlHandle { - public: - enum Operation { - EditOp, - CreateOp - }; - - public: - ContactEditor(); - virtual ~ContactEditor(); - - /** - * @brief Launches add-operation. - * @param[in] address number or email - * @return true in case of success, otherwise returns false. - */ - bool launch(const std::string &address, Operation operation); - private: - bool launch(const std::string &address, const char *operation, const char *addressType); - }; + class IContactEditorListener; + + /** + *@brief An utility-class aimed to launch contacts-application with add-operation and edit-operation passed via app-control. + */ + class ContactEditor + : public AppControlHandle { + public: + enum Operation { + EditOp, + CreateOp + }; + + public: + ContactEditor(); + virtual ~ContactEditor(); + + /** + * @brief Launches add-operation. + * @param[in] address number or email + * @return true in case of success, otherwise returns false. + */ + bool launch(const std::string &address, Operation operation); + private: + bool launch(const std::string &address, const char *operation, const char *addressType); + }; } #endif /* ContactEditor */ diff --git a/src/Common/AppControl/inc/ContactViewer.h b/src/Common/AppControl/inc/ContactViewer.h index 83d166fc..f0160330 100644 --- a/src/Common/AppControl/inc/ContactViewer.h +++ b/src/Common/AppControl/inc/ContactViewer.h @@ -21,33 +21,33 @@ #include "ContactAddress.h" namespace Msg { - /** - *@brief An utility-class aimed to launch contacts-application with view-operation passed via app-control. - */ - class ContactViewer - : public AppControlHandle { - public: - ContactViewer(); - virtual ~ContactViewer(); + /** + *@brief An utility-class aimed to launch contacts-application with view-operation passed via app-control. + */ + class ContactViewer + : public AppControlHandle { + public: + ContactViewer(); + virtual ~ContactViewer(); - /** - * @brief Launches view-operation. - * @param[in] id Contact person id or MyProfile id - * @param[in] ownerType PersonType or MyProfileType - * @return true in case of success, otherwise returns false. - */ - bool launch(int id, ContactAddress::OwnerType ownerType); + /** + * @brief Launches view-operation. + * @param[in] id Contact person id or MyProfile id + * @param[in] ownerType PersonType or MyProfileType + * @return true in case of success, otherwise returns false. + */ + bool launch(int id, ContactAddress::OwnerType ownerType); - /** - * @brief Launches view-operation. - * @param[in] address reference to ContactAddress object. - * @return true in case of success, otherwise returns false. - */ - bool launch(const ContactAddress &address); + /** + * @brief Launches view-operation. + * @param[in] address reference to ContactAddress object. + * @return true in case of success, otherwise returns false. + */ + bool launch(const ContactAddress &address); - private: - const char *toStr(ContactAddress::OwnerType type); - }; + private: + const char *toStr(ContactAddress::OwnerType type); + }; } #endif /* ContactViewer_h_ */ diff --git a/src/Common/AppControl/inc/FileViewer.h b/src/Common/AppControl/inc/FileViewer.h index 1b01b253..785e9ab8 100644 --- a/src/Common/AppControl/inc/FileViewer.h +++ b/src/Common/AppControl/inc/FileViewer.h @@ -20,18 +20,18 @@ #include "AppControlLauncher.h" namespace Msg { - class FileViewer - : public AppControlHandle { - public: - FileViewer(); - virtual ~FileViewer(); + class FileViewer + : public AppControlHandle { + public: + FileViewer(); + virtual ~FileViewer(); - bool launch(const std::string &file); - bool launchWithCopy(const std::string &file); + bool launch(const std::string &file); + bool launchWithCopy(const std::string &file); - private: - std::string m_FilePath; - }; + private: + std::string m_FilePath; + }; } #endif /* FileViewer_h_ */ diff --git a/src/Common/AppControl/inc/Share.h b/src/Common/AppControl/inc/Share.h index ca972b19..d0deda3f 100644 --- a/src/Common/AppControl/inc/Share.h +++ b/src/Common/AppControl/inc/Share.h @@ -23,22 +23,22 @@ #include namespace Msg { - class Share - : public AppControlHandle { - public: - Share(); - virtual ~Share(); - - bool launch(const std::list &files); - bool launch(const std::string &text); - - private: - void removeFiles(); - void addFiles(const std::list &files); - - private: - std::list m_FileList; - }; + class Share + : public AppControlHandle { + public: + Share(); + virtual ~Share(); + + bool launch(const std::list &files); + bool launch(const std::string &text); + + private: + void removeFiles(); + void addFiles(const std::list &files); + + private: + std::list m_FileList; + }; } #endif /* Share_h_ */ diff --git a/src/Common/AppControl/inc/VoiceCall.h b/src/Common/AppControl/inc/VoiceCall.h index 8a6877b0..0ec4dd34 100644 --- a/src/Common/AppControl/inc/VoiceCall.h +++ b/src/Common/AppControl/inc/VoiceCall.h @@ -21,24 +21,24 @@ #include namespace Msg { - /** - * @brief An utility-class aimed to make voice call passed via app-control. - */ - class VoiceCall { - public: - VoiceCall(); + /** + * @brief An utility-class aimed to make voice call passed via app-control. + */ + class VoiceCall { + public: + VoiceCall(); - /** - * @brief Launches call by number - * @param[in] number Contact person number - * @return true in case of success, otherwise returns false. - */ - static bool launch(const std::string &number); + /** + * @brief Launches call by number + * @param[in] number Contact person number + * @return true in case of success, otherwise returns false. + */ + static bool launch(const std::string &number); - private: - VoiceCall(const VoiceCall&) = delete; - VoiceCall& operator=(const VoiceCall&) = delete; - }; + private: + VoiceCall(const VoiceCall&) = delete; + VoiceCall& operator=(const VoiceCall&) = delete; + }; } #endif /* VoiceCall_h_ */ diff --git a/src/Common/AppControl/src/AppControlCommand.cpp b/src/Common/AppControl/src/AppControlCommand.cpp index 9dbefb74..25f02c1c 100644 --- a/src/Common/AppControl/src/AppControlCommand.cpp +++ b/src/Common/AppControl/src/AppControlCommand.cpp @@ -19,8 +19,8 @@ using namespace Msg; AppControlCommand::AppControlCommand(const std::string &opMsg, OperationType type) - : m_OperationMsg(opMsg) - , m_OperationType(type) + : m_OperationMsg(opMsg) + , m_OperationType(type) { } @@ -30,10 +30,10 @@ AppControlCommand::~AppControlCommand() const std::string &AppControlCommand::getOperationMsg() const { - return m_OperationMsg; + return m_OperationMsg; } AppControlCommand::OperationType AppControlCommand::getOperationType() const { - return m_OperationType; + return m_OperationType; } diff --git a/src/Common/AppControl/src/AppControlCompose.cpp b/src/Common/AppControl/src/AppControlCompose.cpp index 54803cce..0f939ef4 100644 --- a/src/Common/AppControl/src/AppControlCompose.cpp +++ b/src/Common/AppControl/src/AppControlCompose.cpp @@ -24,52 +24,52 @@ using namespace Msg; namespace { - const std::string mimeContact = "application/vnd.tizen.contact"; - const std::string myProfileDataType = "my_profile"; + const std::string mimeContact = "application/vnd.tizen.contact"; + const std::string myProfileDataType = "my_profile"; - typedef std::unordered_map OperationMap; + typedef std::unordered_map OperationMap; - const OperationMap operationMap = - { - {APP_CONTROL_OPERATION_COMPOSE, AppControlCompose::OpCompose}, - {APP_CONTROL_OPERATION_SHARE, AppControlCompose::OpShare}, - {APP_CONTROL_OPERATION_MULTI_SHARE, AppControlCompose::OpMultiShare}, - {APP_CONTROL_OPERATION_SHARE_TEXT, AppControlCompose::OpShareText} - }; + const OperationMap operationMap = + { + {APP_CONTROL_OPERATION_COMPOSE, AppControlCompose::OpCompose}, + {APP_CONTROL_OPERATION_SHARE, AppControlCompose::OpShare}, + {APP_CONTROL_OPERATION_MULTI_SHARE, AppControlCompose::OpMultiShare}, + {APP_CONTROL_OPERATION_SHARE_TEXT, AppControlCompose::OpShareText} + }; - AppControlCompose::OpComposeType getOperation(const std::string &op) - { - auto it = operationMap.find(op); - return it != operationMap.end() ? it->second : AppControlCompose::OpUnknown; - }; + AppControlCompose::OpComposeType getOperation(const std::string &op) + { + auto it = operationMap.find(op); + return it != operationMap.end() ? it->second : AppControlCompose::OpUnknown; + }; } AppControlCompose::AppControlCompose(const std::string &opMsg, app_control_h handle) - : AppControlCommand(opMsg, OpComposeFamily) - , m_ComposeType(getOperation(opMsg)) - , m_isMms(false) + : AppControlCommand(opMsg, OpComposeFamily) + , m_ComposeType(getOperation(opMsg)) + , m_isMms(false) { - MSG_LOG("ComposeType: ", m_ComposeType); - - if (handle) { - switch (m_ComposeType) { - case OpCompose: - createComposeOp(handle); - break; - case OpShare: - createShareOp(handle); - break; - case OpMultiShare: - createMultiShareOp(handle); - break; - case OpShareText: - createShareTextOp(handle); - break; - case OpUnknown: - MSG_LOG_ERROR("Invalid op-type") - break; - } - } + MSG_LOG("ComposeType: ", m_ComposeType); + + if (handle) { + switch (m_ComposeType) { + case OpCompose: + createComposeOp(handle); + break; + case OpShare: + createShareOp(handle); + break; + case OpMultiShare: + createMultiShareOp(handle); + break; + case OpShareText: + createShareTextOp(handle); + break; + case OpUnknown: + MSG_LOG_ERROR("Invalid op-type") + break; + } + } } AppControlCompose::~AppControlCompose() @@ -78,150 +78,150 @@ AppControlCompose::~AppControlCompose() void AppControlCompose::createComposeOp(app_control_h handle) { - parseUriCompose(handle); - if (m_RecipientList.empty()) - AppControlUtils::getExtraDataArray(handle, APP_CONTROL_DATA_TO, m_RecipientList); + parseUriCompose(handle); + if (m_RecipientList.empty()) + AppControlUtils::getExtraDataArray(handle, APP_CONTROL_DATA_TO, m_RecipientList); - m_MessageText = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_TEXT); - m_Subject = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_SUBJECT); - AppControlUtils::getExtraDataArray(handle, APP_CONTROL_DATA_PATH, m_FileList); + m_MessageText = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_TEXT); + m_Subject = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_SUBJECT); + AppControlUtils::getExtraDataArray(handle, APP_CONTROL_DATA_PATH, m_FileList); } void AppControlCompose::createShareOp(app_control_h handle) { - parseUriShare(handle); + parseUriShare(handle); - if (mimeContact == AppControlUtils::getMimeType(handle)) { - std::string idStr = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_ID); - if (!idStr.empty()) { - std::string dataType = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_TYPE); - m_VcfInfo.isMyProfile = (dataType == myProfileDataType); - m_VcfInfo.contactsIdList.push_back(atoi(idStr.c_str())); - } - } + if (mimeContact == AppControlUtils::getMimeType(handle)) { + std::string idStr = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_ID); + if (!idStr.empty()) { + std::string dataType = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_TYPE); + m_VcfInfo.isMyProfile = (dataType == myProfileDataType); + m_VcfInfo.contactsIdList.push_back(atoi(idStr.c_str())); + } + } - if (m_FileList.empty()) { - std::string path = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_PATH); - if (!path.empty()) - m_FileList.push_back(std::move(path)); - } + if (m_FileList.empty()) { + std::string path = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_PATH); + if (!path.empty()) + m_FileList.push_back(std::move(path)); + } } void AppControlCompose::createMultiShareOp(app_control_h handle) { - if (mimeContact == AppControlUtils::getMimeType(handle)) { - std::list contactsList; - AppControlUtils::getExtraDataArray(handle, APP_CONTROL_DATA_ID, contactsList); - for (auto it : contactsList) - m_VcfInfo.contactsIdList.push_back(atoi(it.c_str())); - } + if (mimeContact == AppControlUtils::getMimeType(handle)) { + std::list contactsList; + AppControlUtils::getExtraDataArray(handle, APP_CONTROL_DATA_ID, contactsList); + for (auto it : contactsList) + m_VcfInfo.contactsIdList.push_back(atoi(it.c_str())); + } - AppControlUtils::getExtraDataArray(handle, APP_CONTROL_DATA_PATH, m_FileList); - parseUriShare(handle); + AppControlUtils::getExtraDataArray(handle, APP_CONTROL_DATA_PATH, m_FileList); + parseUriShare(handle); } void AppControlCompose::createShareTextOp(app_control_h handle) { - parseUriShare(handle); - m_MessageText = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_TEXT); - m_Subject = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_SUBJECT); - AppControlUtils::getExtraDataArray(handle, APP_CONTROL_DATA_PATH, m_FileList); + parseUriShare(handle); + m_MessageText = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_TEXT); + m_Subject = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_SUBJECT); + AppControlUtils::getExtraDataArray(handle, APP_CONTROL_DATA_PATH, m_FileList); } AppControlCompose::OpComposeType AppControlCompose::getComposeType() const { - return m_ComposeType; + return m_ComposeType; } const AppControlCompose::RecipientList &AppControlCompose::getRecipientList() const { - return m_RecipientList; + return m_RecipientList; } bool AppControlCompose::isMms() const { - return m_isMms; + return m_isMms; } const std::string &AppControlCompose::getMessageText() const { - return m_MessageText; + return m_MessageText; } const std::string &AppControlCompose::getMessageSubject() const { - return m_Subject; + return m_Subject; } const AppControlCompose::FileList &AppControlCompose::getFileList() const { - return m_FileList; + return m_FileList; } const VcfInfo &AppControlCompose::getVcfInfo() const { - return m_VcfInfo; + return m_VcfInfo; } bool AppControlCompose::parseUriCompose(app_control_h handle) { - TRACE; - bool res = false; - char *uri = nullptr; - - if (APP_CONTROL_ERROR_NONE == app_control_get_uri(handle, &uri)) { - if (uri) { - MSG_LOG("uri = ", uri); - std::string uriToParse(uri); - std::istringstream is(uriToParse); - - std::string cur; - std::getline(is, cur, ':'); - MSG_LOG("cur = ", cur.c_str()); - - if (cur == "sms" || cur == "mmsto") { - m_isMms = (cur == "mmsto"); - for (; std::getline(is, cur, ',');) { - m_RecipientList.push_back(cur); - } - res = true; - } - } - free(uri); - } - - return res; + TRACE; + bool res = false; + char *uri = nullptr; + + if (APP_CONTROL_ERROR_NONE == app_control_get_uri(handle, &uri)) { + if (uri) { + MSG_LOG("uri = ", uri); + std::string uriToParse(uri); + std::istringstream is(uriToParse); + + std::string cur; + std::getline(is, cur, ':'); + MSG_LOG("cur = ", cur.c_str()); + + if (cur == "sms" || cur == "mmsto") { + m_isMms = (cur == "mmsto"); + for (; std::getline(is, cur, ',');) { + m_RecipientList.push_back(cur); + } + res = true; + } + } + free(uri); + } + + return res; } bool AppControlCompose::parseUriShare(app_control_h handle) { - TRACE; - bool res = false; - char *uri = nullptr; - - if (APP_CONTROL_ERROR_NONE == app_control_get_uri(handle, &uri)) { - if (uri) { - MSG_LOG("uri = ", uri); - std::string uriToParse(uri); - std::istringstream is(uriToParse); - - std::string cur; - std::getline(is, cur, ':'); - MSG_LOG("cur = ", cur.c_str()); - - if (cur == "sms" || cur == "mmsto" || cur == "file") { - m_isMms = (cur == "mmsto" || cur == "file"); - if (cur == "file" && m_FileList.empty()) { - std::string prefix("file://"); - m_FileList.push_back(uriToParse.erase(0, prefix.length())); - } - res = true; - } else { - auto it = std::find(m_FileList.begin(), m_FileList.end(), uriToParse); - if (it == m_FileList.end()) - m_FileList.push_back(uriToParse); // no prefix, uri is a path to file itself - } - } - free(uri); - } - - return res; + TRACE; + bool res = false; + char *uri = nullptr; + + if (APP_CONTROL_ERROR_NONE == app_control_get_uri(handle, &uri)) { + if (uri) { + MSG_LOG("uri = ", uri); + std::string uriToParse(uri); + std::istringstream is(uriToParse); + + std::string cur; + std::getline(is, cur, ':'); + MSG_LOG("cur = ", cur.c_str()); + + if (cur == "sms" || cur == "mmsto" || cur == "file") { + m_isMms = (cur == "mmsto" || cur == "file"); + if (cur == "file" && m_FileList.empty()) { + std::string prefix("file://"); + m_FileList.push_back(uriToParse.erase(0, prefix.length())); + } + res = true; + } else { + auto it = std::find(m_FileList.begin(), m_FileList.end(), uriToParse); + if (it == m_FileList.end()) + m_FileList.push_back(uriToParse); // no prefix, uri is a path to file itself + } + } + free(uri); + } + + return res; } diff --git a/src/Common/AppControl/src/AppControlDefault.cpp b/src/Common/AppControl/src/AppControlDefault.cpp index 8c0519d6..92da104b 100644 --- a/src/Common/AppControl/src/AppControlDefault.cpp +++ b/src/Common/AppControl/src/AppControlDefault.cpp @@ -20,19 +20,19 @@ using namespace Msg; namespace { - const char *notificationPanel = "http://tizen.org/appcontrol/data/notification"; - const char *keyType = "type"; - const char *valueNewMsg = "new_msg"; - const char *valueSendFailed = "send_failed_msg"; - const char *keyMsgId = "msgId"; + const char *notificationPanel = "http://tizen.org/appcontrol/data/notification"; + const char *keyType = "type"; + const char *valueNewMsg = "new_msg"; + const char *valueSendFailed = "send_failed_msg"; + const char *keyMsgId = "msgId"; } AppControlDefault::AppControlDefault(const std::string &opMsg, app_control_h handle) - : AppControlCommand(opMsg, OpDefault) - , m_MsgId() - , m_DefaultType(UnknownType) + : AppControlCommand(opMsg, OpDefault) + , m_MsgId() + , m_DefaultType(UnknownType) { - parse(handle); + parse(handle); } AppControlDefault::~AppControlDefault() @@ -41,68 +41,68 @@ AppControlDefault::~AppControlDefault() MsgId AppControlDefault::getMessageId() const { - return m_MsgId; + return m_MsgId; } AppControlDefault::DefaultType AppControlDefault::getDefaultType() const { - return m_DefaultType; + return m_DefaultType; } const std::string& AppControlDefault::getReplyText() const { - return m_ReplyText; + return m_ReplyText; } void AppControlDefault::parse(app_control_h handle) { - char *key = nullptr; - app_control_get_extra_data(handle, keyType, &key); - if (!key) { - m_DefaultType = MainType; - return; - } - - std::string type = key; - free(key); - if (type == valueNewMsg) - viewMessage(handle); - else if (type == valueSendFailed) - m_DefaultType = SendFailedType; - else - MSG_LOG("Unknown type!"); - - char *msgIdStr = nullptr; - app_control_get_extra_data(handle, keyMsgId, &msgIdStr); - if (!msgIdStr) - return; - - m_MsgId = atoi(msgIdStr); - free(msgIdStr); + char *key = nullptr; + app_control_get_extra_data(handle, keyType, &key); + if (!key) { + m_DefaultType = MainType; + return; + } + + std::string type = key; + free(key); + if (type == valueNewMsg) + viewMessage(handle); + else if (type == valueSendFailed) + m_DefaultType = SendFailedType; + else + MSG_LOG("Unknown type!"); + + char *msgIdStr = nullptr; + app_control_get_extra_data(handle, keyMsgId, &msgIdStr); + if (!msgIdStr) + return; + + m_MsgId = atoi(msgIdStr); + free(msgIdStr); } bool AppControlDefault::isNotificationPanel(app_control_h handle) const { - char *keyVal = nullptr; - app_control_get_extra_data(handle, notificationPanel, &keyVal); - if (keyVal) { - free(keyVal); - return true; - } - - return false; + char *keyVal = nullptr; + app_control_get_extra_data(handle, notificationPanel, &keyVal); + if (keyVal) { + free(keyVal); + return true; + } + + return false; } void AppControlDefault::viewMessage(app_control_h handle) { - makeReplyText(handle); - if (isNotificationPanel(handle)) - m_DefaultType = NotificationType; - else - m_DefaultType = m_ReplyText.empty() ? ViewType : ReplyType; + makeReplyText(handle); + if (isNotificationPanel(handle)) + m_DefaultType = NotificationType; + else + m_DefaultType = m_ReplyText.empty() ? ViewType : ReplyType; } void AppControlDefault::makeReplyText(app_control_h handle) { - m_ReplyText = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_TEXT); + m_ReplyText = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_TEXT); } diff --git a/src/Common/AppControl/src/AppControlLauncher.cpp b/src/Common/AppControl/src/AppControlLauncher.cpp index 0638be6f..ef51a428 100644 --- a/src/Common/AppControl/src/AppControlLauncher.cpp +++ b/src/Common/AppControl/src/AppControlLauncher.cpp @@ -20,99 +20,99 @@ using namespace Msg; AppControlHandle::AppControlHandle(app_control_launch_mode_e launchMode) - : m_Handle() + : m_Handle() { - app_control_create(&m_Handle); - if (m_Handle) - app_control_set_launch_mode(m_Handle, launchMode); + app_control_create(&m_Handle); + if (m_Handle) + app_control_set_launch_mode(m_Handle, launchMode); } AppControlHandle::~AppControlHandle() { - if (m_Handle) { - terminate(); - app_control_destroy(m_Handle); - } + if (m_Handle) { + terminate(); + app_control_destroy(m_Handle); + } } AppControlHandle::operator app_control_h() { - return m_Handle; + return m_Handle; } void AppControlHandle::terminate() { - if (m_Handle && AppControlLauncher::getInst().m_pHandle == this) - AppControlLauncher::getInst().terminate(); + if (m_Handle && AppControlLauncher::getInst().m_pHandle == this) + AppControlLauncher::getInst().terminate(); } AppControlLauncher::AppControlLauncher() - : m_LaunchInProgress(false) - , m_pTimer(nullptr) - , m_pHandle(nullptr) + : m_LaunchInProgress(false) + , m_pTimer(nullptr) + , m_pHandle(nullptr) { } AppControlLauncher::~AppControlLauncher() { - if (m_pTimer) - ecore_timer_del(m_pTimer); + if (m_pTimer) + ecore_timer_del(m_pTimer); } AppControlLauncher &AppControlLauncher::getInst() { - static AppControlLauncher inst; - return inst; + static AppControlLauncher inst; + return inst; } bool AppControlLauncher::launch(AppControlHandle &handle) { - if (isLaunchInProgress() || !handle) - return false; - - terminate(); - m_LaunchInProgress = true; - m_pHandle = &handle; - app_control_enable_app_started_result_event(handle); - int ret = app_control_send_launch_request(handle, APP_CONTROL_RES_CALLBACK(AppControlLauncher, onReply), this); - MSG_LOG("Launch result = ", ret); - m_LaunchInProgress = ret == 0; - if (ret != 0) - m_pHandle = nullptr; - return ret == 0; + if (isLaunchInProgress() || !handle) + return false; + + terminate(); + m_LaunchInProgress = true; + m_pHandle = &handle; + app_control_enable_app_started_result_event(handle); + int ret = app_control_send_launch_request(handle, APP_CONTROL_RES_CALLBACK(AppControlLauncher, onReply), this); + MSG_LOG("Launch result = ", ret); + m_LaunchInProgress = ret == 0; + if (ret != 0) + m_pHandle = nullptr; + return ret == 0; } bool AppControlLauncher::isLaunchInProgress() const { - return m_LaunchInProgress; + return m_LaunchInProgress; } void AppControlLauncher::terminate() { - m_LaunchInProgress = false; - if (m_pHandle && m_pHandle->m_Handle) - app_control_send_terminate_request(*m_pHandle); - m_pHandle = nullptr; + m_LaunchInProgress = false; + if (m_pHandle && m_pHandle->m_Handle) + app_control_send_terminate_request(*m_pHandle); + m_pHandle = nullptr; } void AppControlLauncher::onReply(app_control_h request, app_control_h reply, app_control_result_e result) { - MSG_LOG("Result = ", result); - - if (m_pHandle) - m_pHandle->onReply(request, reply, result); - - if (m_LaunchInProgress) { - m_pTimer = ecore_timer_add(1.2, // Extra time for application startup. - [](void *data)->Eina_Bool - { - auto *self = (AppControlLauncher*)data; - self->m_LaunchInProgress = false; - self->m_pTimer = nullptr; - return false; // Delete timer. - }, - this); - } + MSG_LOG("Result = ", result); + + if (m_pHandle) + m_pHandle->onReply(request, reply, result); + + if (m_LaunchInProgress) { + m_pTimer = ecore_timer_add(1.2, // Extra time for application startup. + [](void *data)->Eina_Bool + { + auto *self = (AppControlLauncher*)data; + self->m_LaunchInProgress = false; + self->m_pTimer = nullptr; + return false; // Delete timer. + }, + this); + } } diff --git a/src/Common/AppControl/src/AppControlParser.cpp b/src/Common/AppControl/src/AppControlParser.cpp index 6dff899b..b529f743 100644 --- a/src/Common/AppControl/src/AppControlParser.cpp +++ b/src/Common/AppControl/src/AppControlParser.cpp @@ -28,53 +28,53 @@ using namespace Msg; namespace { - typedef std::unordered_map OperationMap; + typedef std::unordered_map OperationMap; - const OperationMap operationMap = - { - {APP_CONTROL_OPERATION_DEFAULT, AppControlCommand::OpDefault}, - {APP_CONTROL_OPERATION_MAIN, AppControlCommand::OpDefault}, - {APP_CONTROL_OPERATION_COMPOSE, AppControlCommand::OpComposeFamily}, - {APP_CONTROL_OPERATION_SHARE, AppControlCommand::OpComposeFamily}, - {APP_CONTROL_OPERATION_MULTI_SHARE, AppControlCommand::OpComposeFamily}, - {APP_CONTROL_OPERATION_SHARE_TEXT, AppControlCommand::OpComposeFamily} - }; + const OperationMap operationMap = + { + {APP_CONTROL_OPERATION_DEFAULT, AppControlCommand::OpDefault}, + {APP_CONTROL_OPERATION_MAIN, AppControlCommand::OpDefault}, + {APP_CONTROL_OPERATION_COMPOSE, AppControlCommand::OpComposeFamily}, + {APP_CONTROL_OPERATION_SHARE, AppControlCommand::OpComposeFamily}, + {APP_CONTROL_OPERATION_MULTI_SHARE, AppControlCommand::OpComposeFamily}, + {APP_CONTROL_OPERATION_SHARE_TEXT, AppControlCommand::OpComposeFamily} + }; - AppControlCommand::OperationType getOperation(const char *op) - { - auto it = operationMap.find(op); - return it != operationMap.end() ? it->second : AppControlCommand::OpUnknown; - }; + AppControlCommand::OperationType getOperation(const char *op) + { + auto it = operationMap.find(op); + return it != operationMap.end() ? it->second : AppControlCommand::OpUnknown; + }; } AppControlCommandRef AppControlParser::parse(app_control_h handle) { - AppControlCommandRef cmd; - char *opStr = nullptr; + AppControlCommandRef cmd; + char *opStr = nullptr; - app_control_get_operation(handle, &opStr); + app_control_get_operation(handle, &opStr); - if (!opStr) { - MSG_LOG_WARN("app_control operation is null"); - return cmd; - } + if (!opStr) { + MSG_LOG_WARN("app_control operation is null"); + return cmd; + } - AppControlCommand::OperationType opType = getOperation(opStr); + AppControlCommand::OperationType opType = getOperation(opStr); - switch (opType) { - case AppControlCommand::OpDefault: - cmd = std::make_shared(opStr, handle); - break; + switch (opType) { + case AppControlCommand::OpDefault: + cmd = std::make_shared(opStr, handle); + break; - case AppControlCommand::OpComposeFamily: - cmd = std::make_shared(opStr, handle); - break; - default: - case AppControlCommand::OpUnknown: - cmd = std::make_shared(opStr, opType); - break; - } + case AppControlCommand::OpComposeFamily: + cmd = std::make_shared(opStr, handle); + break; + default: + case AppControlCommand::OpUnknown: + cmd = std::make_shared(opStr, opType); + break; + } - free(opStr); - return cmd; + free(opStr); + return cmd; } diff --git a/src/Common/AppControl/src/AppControlUtils.cpp b/src/Common/AppControl/src/AppControlUtils.cpp index e047d906..08a6725c 100644 --- a/src/Common/AppControl/src/AppControlUtils.cpp +++ b/src/Common/AppControl/src/AppControlUtils.cpp @@ -20,69 +20,69 @@ using namespace Msg; std::string AppControlUtils::getExtraData(app_control_h handle, const std::string &key) { - std::string res; - char *val = nullptr; - if (APP_CONTROL_ERROR_NONE == app_control_get_extra_data(handle, key.c_str(), &val)) { - if (val) { - res = val; - free(val); - } - } - return res; + std::string res; + char *val = nullptr; + if (APP_CONTROL_ERROR_NONE == app_control_get_extra_data(handle, key.c_str(), &val)) { + if (val) { + res = val; + free(val); + } + } + return res; } void AppControlUtils::getExtraDataArray(app_control_h handle, const std::string &key, std::list &outArray) { - int arrayLength = 0; - char **pArrayVal = nullptr; - if (APP_CONTROL_ERROR_NONE == app_control_get_extra_data_array(handle, key.c_str(), &pArrayVal, &arrayLength)) { - for (int i = 0; i < arrayLength; ++i) { - outArray.push_back(pArrayVal[i]); - free(pArrayVal[i]); - } - free(pArrayVal); - } + int arrayLength = 0; + char **pArrayVal = nullptr; + if (APP_CONTROL_ERROR_NONE == app_control_get_extra_data_array(handle, key.c_str(), &pArrayVal, &arrayLength)) { + for (int i = 0; i < arrayLength; ++i) { + outArray.push_back(pArrayVal[i]); + free(pArrayVal[i]); + } + free(pArrayVal); + } } int AppControlUtils::getExtraDataInt(app_control_h handle, const std::string &key) { - char *val = nullptr; - int parsed = 0; - if (APP_CONTROL_ERROR_NONE == app_control_get_extra_data(handle, key.c_str(), &val) && val) { - parsed = atoi(val); - free(val); - } - return parsed; + char *val = nullptr; + int parsed = 0; + if (APP_CONTROL_ERROR_NONE == app_control_get_extra_data(handle, key.c_str(), &val) && val) { + parsed = atoi(val); + free(val); + } + return parsed; } void AppControlUtils::getExtraDataIntArray(app_control_h handle, const std::string &key, std::list &outArray) { - int arrayLength = 0; - char **pArrayVal = nullptr; - if (APP_CONTROL_ERROR_NONE == app_control_get_extra_data_array(handle, key.c_str(), &pArrayVal, &arrayLength) - && pArrayVal) { - std::string::size_type sz; - for (int i = 0; i < arrayLength; ++i) { - if (pArrayVal[i]) { - std::string s(pArrayVal[i] ? pArrayVal[i] : ""); - free(pArrayVal[i]); - int parsed = std::stoi(s, &sz); - if (sz == s.length()) - outArray.push_back(parsed); - } - } - free(pArrayVal); - } + int arrayLength = 0; + char **pArrayVal = nullptr; + if (APP_CONTROL_ERROR_NONE == app_control_get_extra_data_array(handle, key.c_str(), &pArrayVal, &arrayLength) + && pArrayVal) { + std::string::size_type sz; + for (int i = 0; i < arrayLength; ++i) { + if (pArrayVal[i]) { + std::string s(pArrayVal[i] ? pArrayVal[i] : ""); + free(pArrayVal[i]); + int parsed = std::stoi(s, &sz); + if (sz == s.length()) + outArray.push_back(parsed); + } + } + free(pArrayVal); + } } std::string AppControlUtils::getMimeType(app_control_h handle) { - char *mime = nullptr; - std::string result; - app_control_get_mime(handle, &mime); - if (mime) { - result = mime; - free(mime); - } - return result; + char *mime = nullptr; + std::string result; + app_control_get_mime(handle, &mime); + if (mime) { + result = mime; + free(mime); + } + return result; } diff --git a/src/Common/AppControl/src/ContactEditor.cpp b/src/Common/AppControl/src/ContactEditor.cpp index acd7fbe5..7a41bd5e 100644 --- a/src/Common/AppControl/src/ContactEditor.cpp +++ b/src/Common/AppControl/src/ContactEditor.cpp @@ -22,42 +22,42 @@ using namespace Msg; namespace { - const char* mimeContact = "application/vnd.tizen.contact"; + const char* mimeContact = "application/vnd.tizen.contact"; } ContactEditor::ContactEditor() { - app_control_set_mime(m_Handle, mimeContact); + app_control_set_mime(m_Handle, mimeContact); } ContactEditor::~ContactEditor() { - terminate(); + terminate(); } bool ContactEditor::launch(const std::string &address, Operation operation) { - bool res = false; - if (!address.empty()) { - const char *op = nullptr; - if (operation == EditOp) - op = APP_CONTROL_OPERATION_EDIT; - else if (operation == CreateOp) - op = APP_CONTROL_OPERATION_ADD; - - if (op) { - if (MsgUtils::isValidNumber(address)) - res = launch(address, op, APP_CONTROL_DATA_PHONE); - else if (MsgUtils::isValidEmail(address)) - res = launch(address, op, APP_CONTROL_DATA_EMAIL); - } - } - return res; + bool res = false; + if (!address.empty()) { + const char *op = nullptr; + if (operation == EditOp) + op = APP_CONTROL_OPERATION_EDIT; + else if (operation == CreateOp) + op = APP_CONTROL_OPERATION_ADD; + + if (op) { + if (MsgUtils::isValidNumber(address)) + res = launch(address, op, APP_CONTROL_DATA_PHONE); + else if (MsgUtils::isValidEmail(address)) + res = launch(address, op, APP_CONTROL_DATA_EMAIL); + } + } + return res; } bool ContactEditor::launch(const std::string &address, const char *operation, const char *addressType) { - app_control_set_operation(m_Handle, operation); - app_control_add_extra_data(m_Handle, addressType, address.c_str()); - return AppControlLauncher::getInst().launch(*this); + app_control_set_operation(m_Handle, operation); + app_control_add_extra_data(m_Handle, addressType, address.c_str()); + return AppControlLauncher::getInst().launch(*this); } diff --git a/src/Common/AppControl/src/ContactViewer.cpp b/src/Common/AppControl/src/ContactViewer.cpp index 26cfd57f..4595dc19 100644 --- a/src/Common/AppControl/src/ContactViewer.cpp +++ b/src/Common/AppControl/src/ContactViewer.cpp @@ -23,15 +23,15 @@ using namespace Msg; namespace { - const char *mimeContact = "application/vnd.tizen.contact"; - const char *personContactTypeStr = "person"; - const char *myProfileTypeStr = "my_profile"; + const char *mimeContact = "application/vnd.tizen.contact"; + const char *personContactTypeStr = "person"; + const char *myProfileTypeStr = "my_profile"; } ContactViewer::ContactViewer() { - app_control_set_operation(m_Handle, APP_CONTROL_OPERATION_VIEW); - app_control_set_mime(m_Handle, mimeContact); + app_control_set_operation(m_Handle, APP_CONTROL_OPERATION_VIEW); + app_control_set_mime(m_Handle, mimeContact); } ContactViewer::~ContactViewer() @@ -40,26 +40,26 @@ ContactViewer::~ContactViewer() bool ContactViewer::launch(int id, ContactAddress::OwnerType ownerType) { - app_control_add_extra_data(m_Handle, APP_CONTROL_DATA_TYPE, toStr(ownerType)); - app_control_add_extra_data(m_Handle, APP_CONTROL_DATA_ID, std::to_string(id).c_str()); - return AppControlLauncher::getInst().launch(*this); + app_control_add_extra_data(m_Handle, APP_CONTROL_DATA_TYPE, toStr(ownerType)); + app_control_add_extra_data(m_Handle, APP_CONTROL_DATA_ID, std::to_string(id).c_str()); + return AppControlLauncher::getInst().launch(*this); } bool ContactViewer::launch(const ContactAddress &address) { - return launch(address.getOwnerId(), address.getOwnerType()); + return launch(address.getOwnerId(), address.getOwnerType()); } const char *ContactViewer::toStr(ContactAddress::OwnerType type) { - switch (type) { - case ContactAddress::PersonType: - return personContactTypeStr; - case ContactAddress::MyProfileType: - return myProfileTypeStr; - default: - MSG_LOG_ERROR("Unknown ContactType"); - }; - return ""; + switch (type) { + case ContactAddress::PersonType: + return personContactTypeStr; + case ContactAddress::MyProfileType: + return myProfileTypeStr; + default: + MSG_LOG_ERROR("Unknown ContactType"); + }; + return ""; } diff --git a/src/Common/AppControl/src/FileViewer.cpp b/src/Common/AppControl/src/FileViewer.cpp index 219c54b9..239e30cd 100644 --- a/src/Common/AppControl/src/FileViewer.cpp +++ b/src/Common/AppControl/src/FileViewer.cpp @@ -23,52 +23,52 @@ using namespace Msg; FileViewer::FileViewer() { - app_control_set_operation(m_Handle, APP_CONTROL_OPERATION_VIEW); + app_control_set_operation(m_Handle, APP_CONTROL_OPERATION_VIEW); } FileViewer::~FileViewer() { - if (!m_FilePath.empty()) - FileUtils::remove(m_FilePath); + if (!m_FilePath.empty()) + FileUtils::remove(m_FilePath); } bool FileViewer::launch(const std::string &file) { - if (AppControlLauncher::getInst().isLaunchInProgress()) - return false; + if (AppControlLauncher::getInst().isLaunchInProgress()) + return false; - bool res = false; - std::string mime = FileUtils::getMimeType(file); + bool res = false; + std::string mime = FileUtils::getMimeType(file); - MSG_LOG("File path: ", file); - MSG_LOG("MIME type: ", mime); + MSG_LOG("File path: ", file); + MSG_LOG("MIME type: ", mime); - if (mime.empty() || file.empty()) - return false; + if (mime.empty() || file.empty()) + return false; - if (m_Handle) { - app_control_set_mime(m_Handle, mime.c_str()); - std::string uri = "file://" + file; - app_control_set_uri(m_Handle, uri.c_str()); - res = AppControlLauncher::getInst().launch(*this); - } + if (m_Handle) { + app_control_set_mime(m_Handle, mime.c_str()); + std::string uri = "file://" + file; + app_control_set_uri(m_Handle, uri.c_str()); + res = AppControlLauncher::getInst().launch(*this); + } - return res; + return res; } bool FileViewer::launchWithCopy(const std::string &file) { - bool res = false; + bool res = false; - if (!AppControlLauncher::getInst().isLaunchInProgress()) { - // Remove previous file (correct only for APP_CONTROL_LAUNCH_MODE_GROUP) - if (!m_FilePath.empty()) - FileUtils::remove(m_FilePath); + if (!AppControlLauncher::getInst().isLaunchInProgress()) { + // Remove previous file (correct only for APP_CONTROL_LAUNCH_MODE_GROUP) + if (!m_FilePath.empty()) + FileUtils::remove(m_FilePath); - m_FilePath = FileUtils::addFileToDataDir(file); - if (!m_FilePath.empty()) - res = launch(m_FilePath); - } - return res; + m_FilePath = FileUtils::addFileToDataDir(file); + if (!m_FilePath.empty()) + res = launch(m_FilePath); + } + return res; } diff --git a/src/Common/AppControl/src/Share.cpp b/src/Common/AppControl/src/Share.cpp index 7ee75210..546bf5e3 100644 --- a/src/Common/AppControl/src/Share.cpp +++ b/src/Common/AppControl/src/Share.cpp @@ -30,48 +30,48 @@ Share::Share() Share::~Share() { - removeFiles(); + removeFiles(); } void Share::removeFiles() { - for (auto &&file : m_FileList) - FileUtils::remove(file); + for (auto &&file : m_FileList) + FileUtils::remove(file); - m_FileList.clear(); + m_FileList.clear(); } void Share::addFiles(const std::list &files) { - removeFiles(); - for (auto &&file : files) - m_FileList.push_back(FileUtils::addFileToDataDir(file)); + removeFiles(); + for (auto &&file : files) + m_FileList.push_back(FileUtils::addFileToDataDir(file)); } bool Share::launch(const std::list &files) { - if (files.empty() || AppControlLauncher::getInst().isLaunchInProgress()) - return false; + if (files.empty() || AppControlLauncher::getInst().isLaunchInProgress()) + return false; - addFiles(files); - std::vector nativePaths; - for (const std::string &file : m_FileList) { - if (!file.empty()) - nativePaths.push_back(file.c_str()); - } + addFiles(files); + std::vector nativePaths; + for (const std::string &file : m_FileList) { + if (!file.empty()) + nativePaths.push_back(file.c_str()); + } - app_control_set_operation(m_Handle, APP_CONTROL_OPERATION_MULTI_SHARE); - app_control_add_extra_data_array(m_Handle, APP_CONTROL_DATA_PATH, nativePaths.data(), nativePaths.size()); - return AppControlLauncher::getInst().launch(*this); + app_control_set_operation(m_Handle, APP_CONTROL_OPERATION_MULTI_SHARE); + app_control_add_extra_data_array(m_Handle, APP_CONTROL_DATA_PATH, nativePaths.data(), nativePaths.size()); + return AppControlLauncher::getInst().launch(*this); } bool Share::launch(const std::string &text) { - if (text.empty() || AppControlLauncher::getInst().isLaunchInProgress()) - return false; + if (text.empty() || AppControlLauncher::getInst().isLaunchInProgress()) + return false; - app_control_set_operation(m_Handle, APP_CONTROL_OPERATION_SHARE_TEXT); - app_control_add_extra_data(m_Handle, APP_CONTROL_DATA_TEXT, text.c_str()); - return AppControlLauncher::getInst().launch(*this); + app_control_set_operation(m_Handle, APP_CONTROL_OPERATION_SHARE_TEXT); + app_control_add_extra_data(m_Handle, APP_CONTROL_DATA_TEXT, text.c_str()); + return AppControlLauncher::getInst().launch(*this); } diff --git a/src/Common/AppControl/src/VoiceCall.cpp b/src/Common/AppControl/src/VoiceCall.cpp index 86e026a3..07b015bf 100644 --- a/src/Common/AppControl/src/VoiceCall.cpp +++ b/src/Common/AppControl/src/VoiceCall.cpp @@ -21,7 +21,7 @@ using namespace Msg; namespace { - const std::string tel = "tel:"; + const std::string tel = "tel:"; } VoiceCall::VoiceCall() @@ -30,18 +30,18 @@ VoiceCall::VoiceCall() bool VoiceCall::launch(const std::string &number) { - bool res = false; - app_control_h svcHandle = nullptr; + bool res = false; + app_control_h svcHandle = nullptr; - if (APP_CONTROL_ERROR_NONE == app_control_create(&svcHandle)) { - app_control_set_operation(svcHandle, APP_CONTROL_OPERATION_CALL); - std::string phoneNumber = tel + number; + if (APP_CONTROL_ERROR_NONE == app_control_create(&svcHandle)) { + app_control_set_operation(svcHandle, APP_CONTROL_OPERATION_CALL); + std::string phoneNumber = tel + number; - app_control_set_uri(svcHandle, phoneNumber.c_str()); - int ret = app_control_send_launch_request(svcHandle, nullptr, nullptr); - MSG_LOG("Result code: ", ret); - res = ret == APP_CONTROL_ERROR_NONE; - app_control_destroy(svcHandle); - } - return res; + app_control_set_uri(svcHandle, phoneNumber.c_str()); + int ret = app_control_send_launch_request(svcHandle, nullptr, nullptr); + MSG_LOG("Result code: ", ret); + res = ret == APP_CONTROL_ERROR_NONE; + app_control_destroy(svcHandle); + } + return res; } diff --git a/src/Common/ContactManager/inc/Contact.h b/src/Common/ContactManager/inc/Contact.h index 65f8efd8..44490c89 100644 --- a/src/Common/ContactManager/inc/Contact.h +++ b/src/Common/ContactManager/inc/Contact.h @@ -24,61 +24,61 @@ #include namespace Msg { - class Contact; - typedef std::shared_ptr ContactRef; + class Contact; + typedef std::shared_ptr ContactRef; - class Contact - : public ContactRecord { - public: - Contact(bool release, contacts_record_h record = nullptr); + class Contact + : public ContactRecord { + public: + Contact(bool release, contacts_record_h record = nullptr); - std::string getDispName() const; - std::string getPhoneNumber() const; - std::string getEmail() const; - std::string getThumb() const; - std::string getAddress() const; - }; + std::string getDispName() const; + std::string getPhoneNumber() const; + std::string getEmail() const; + std::string getThumb() const; + std::string getAddress() const; + }; - inline Contact::Contact(bool release, contacts_record_h record) - : ContactRecord(release, record) - { - } + inline Contact::Contact(bool release, contacts_record_h record) + : ContactRecord(release, record) + { + } - inline std::string Contact::getDispName() const - { - return getStr(_contacts_contact.display_name); - } + inline std::string Contact::getDispName() const + { + return getStr(_contacts_contact.display_name); + } - inline std::string Contact::getPhoneNumber() const - { - std::string res; - int count = getChildCount(_contacts_contact.number); - if (count > 0) - res = getStr(getChildP(_contacts_contact.number, 0), _contacts_number.number); - return res; - } + inline std::string Contact::getPhoneNumber() const + { + std::string res; + int count = getChildCount(_contacts_contact.number); + if (count > 0) + res = getStr(getChildP(_contacts_contact.number, 0), _contacts_number.number); + return res; + } - inline std::string Contact::getEmail() const - { - std::string res; - int count = getChildCount(_contacts_contact.email); - if (count > 0) - res = getStr(getChildP(_contacts_contact.number, 0), _contacts_email.email); - return res; - } + inline std::string Contact::getEmail() const + { + std::string res; + int count = getChildCount(_contacts_contact.email); + if (count > 0) + res = getStr(getChildP(_contacts_contact.number, 0), _contacts_email.email); + return res; + } - inline std::string Contact::getThumb() const - { - return getStr(_contacts_contact.image_thumbnail_path); - } + inline std::string Contact::getThumb() const + { + return getStr(_contacts_contact.image_thumbnail_path); + } - inline std::string Contact::getAddress() const - { - std::string address = getPhoneNumber(); - if (address.empty()) - address = getEmail(); - return address; - } + inline std::string Contact::getAddress() const + { + std::string address = getPhoneNumber(); + if (address.empty()) + address = getEmail(); + return address; + } } #endif /* __Contact_h__ */ diff --git a/src/Common/ContactManager/inc/ContactAddress.h b/src/Common/ContactManager/inc/ContactAddress.h index f0ff88e7..d794b8aa 100644 --- a/src/Common/ContactManager/inc/ContactAddress.h +++ b/src/Common/ContactManager/inc/ContactAddress.h @@ -20,30 +20,30 @@ #include "MsgUtils.h" namespace Msg { - class ContactAddress; - typedef std::shared_ptr ContactAddressRef; - - class ContactAddress { - public: - enum AddressType { - EmailType, - NumberType - }; - - enum OwnerType { - PersonType, - MyProfileType - }; - - public: - virtual ~ContactAddress() {}; - virtual AddressType getAddressType() const = 0; - virtual OwnerType getOwnerType() const = 0; - virtual int getOwnerId() const = 0; - virtual std::string getDispName() const = 0; - virtual std::string getAddress() const = 0; // Email or Number - virtual std::string getThumbnailPath() const = 0; - }; + class ContactAddress; + typedef std::shared_ptr ContactAddressRef; + + class ContactAddress { + public: + enum AddressType { + EmailType, + NumberType + }; + + enum OwnerType { + PersonType, + MyProfileType + }; + + public: + virtual ~ContactAddress() {}; + virtual AddressType getAddressType() const = 0; + virtual OwnerType getOwnerType() const = 0; + virtual int getOwnerId() const = 0; + virtual std::string getDispName() const = 0; + virtual std::string getAddress() const = 0; // Email or Number + virtual std::string getThumbnailPath() const = 0; + }; } diff --git a/src/Common/ContactManager/inc/ContactList.h b/src/Common/ContactManager/inc/ContactList.h index 5a2dc8b5..9ae6641a 100644 --- a/src/Common/ContactManager/inc/ContactList.h +++ b/src/Common/ContactManager/inc/ContactList.h @@ -20,59 +20,59 @@ #include namespace Msg { - class ContactManager; + class ContactManager; - template - class ContactList { - friend class ContactManager; + template + class ContactList { + friend class ContactManager; - public: - ContactList(contacts_list_h list) - : m_List(list) - , m_Record(false) - { - } + public: + ContactList(contacts_list_h list) + : m_List(list) + , m_Record(false) + { + } - ~ContactList() - { - if (m_List) - contacts_list_destroy(m_List, true); - } + ~ContactList() + { + if (m_List) + contacts_list_destroy(m_List, true); + } - bool next() - { - return contacts_list_next(m_List) == 0; - } + bool next() + { + return contacts_list_next(m_List) == 0; + } - bool prev() - { - return contacts_list_prev(m_List) == 0; - } + bool prev() + { + return contacts_list_prev(m_List) == 0; + } - T &get() - { - contacts_record_h rec = nullptr; - contacts_list_get_current_record_p(m_List, &rec); - m_Record.set(rec); - return m_Record; - } + T &get() + { + contacts_record_h rec = nullptr; + contacts_list_get_current_record_p(m_List, &rec); + m_Record.set(rec); + return m_Record; + } - int getCount() const - { - int count = 0; - contacts_list_get_count(m_List, &count); - return count; - } + int getCount() const + { + int count = 0; + contacts_list_get_count(m_List, &count); + return count; + } - bool isEmpty() const - { - return getCount() <= 0; - } + bool isEmpty() const + { + return getCount() <= 0; + } - private: - contacts_list_h m_List; - T m_Record; - }; + private: + contacts_list_h m_List; + T m_Record; + }; } #endif /* __ContactList_H__ */ diff --git a/src/Common/ContactManager/inc/ContactManager.h b/src/Common/ContactManager/inc/ContactManager.h index daf1b338..1e0bdafe 100644 --- a/src/Common/ContactManager/inc/ContactManager.h +++ b/src/Common/ContactManager/inc/ContactManager.h @@ -34,165 +34,165 @@ #include "Contact.h" namespace Msg { - /* - *@brief A listener to be notified after contact-information will be changed in contacts-db - */ - class IContactManagerListener; - /* - *@brief Class that work with contacts database. - *@brief Search contacts, add listeners, register callback on changes in database. - */ - class ContactManager { - public: - ContactManager(); - ~ContactManager(); - ContactManager(ContactManager&) = delete; - ContactManager &operator=(ContactManager&) = delete; - - public: - /** - *@brief Return what kind of error occurred - *@param[in] error - number of error - *@return kind of error - */ - static std::string whatError(int error); - /** - * @brief Looks for contact information based on a given keyword - * @param keyword - search keyword - */ - template - std::shared_ptr> search(const std::string &keyword); - - /** - *@brief Search by email and phone and return ContactAddress record - *@param[in] address - email or number - *@return Reference to ContactAddress - */ - ContactAddressRef getContactAddress(const std::string &address); - - /** - *@brief Search for contacts-id, name, phone-number and thumbnail path based on phone-number id - *@param[in] phoneId - identifier of phone-number in contacts-database - *@return Reference to ContactPersonNumber - */ - ContactPersonNumberRef getContactPersonNumber(int phoneId); - - /** - *@brief Search for email-id, name, email and thumbnail path - *@param[in] emailId - identifier of email in contacts-database - *@return Reference to ContactPersonEmail - */ - ContactPersonEmailRef getContactPersonEmail(int emailId); - - /** - *@brief Search by email address ContactPersonEmail record - *@param[in] email - email address - *@return Reference to ContactPersonEmail - */ - ContactPersonEmailRef getContactPersonEmail(const std::string &email); - - /** - *@brief Search by number address ContactMyProfileNumber record - *@param[in] number - phone number - *@return Reference to ContactMyProfileNumber - */ - ContactMyProfileNumberRef getContactMyProfileNumber(const std::string &number); - - /** - *@brief Search by email address ContactMyProfileEmailRef record - *@param[in] email - email address - *@return Reference to ContactMyProfileEmailR - */ - ContactMyProfileEmailRef getContactMyProfileEmail(const std::string &email); - - /** - *@brief Return owner's ContactPersonAddress record - *@return Reference to ContactPersonAddress - */ - ContactMyProfileRef getOwnerProfile(); - - /** - *@brief Add listener on contacts database - *@param[in] listener - */ - void addListener(IContactManagerListener &listener); - - /** - *@brief Remove listener - *@param[in] listener - listener to be remove - */ - void removeListener(IContactManagerListener &listener); - - /** - *@brief Create content of contact by it`s id - *@param[in] personId - contact id - *@param[in] myProfile - is app control my_profile data type - *@return Content with all info about one contact - */ - std::string makeVcard(const int personId, bool myProfile); - - /** -- *@brief Create content of contact by id list - *@param[in] personId - contact id - *@return Content with all info about contacts - */ - std::string makeVcard(const std::list &idList); - - /** - *@brief Parse vCard file - *@param[in] filePath Path to file - *@return list of Contacts - */ - std::list parseVcard(const std::string &filePath); - - private: - typedef std::unordered_map AddressMap; - - private: - /** - *@brief A callback passed to contacts_db_add_changed_cb() to get notifications - about contacts modifications from contact service - *@param[in] view_uri - The view URI of records whose changes are monitored - *@param[in] user_data - the user data passed from the callback registration function - */ - static void contactChangedCb(const char *view_uri, void *user_data); - static void contactDisplayOrderChangedCb(contacts_name_display_order_e name_display_order, void *user_data); - - /** - * @brief Generic search for basic contact attributes based on custom filter passed from above - * @param[in] filter to be used for db-request. DO NOT destroy filter manually, it will be destroyed insithe this method. - */ - ContactPersonNumberRef getContactPersonNumber(contacts_filter_h filter); - ContactPersonEmailRef getContactPersonEmail(contacts_filter_h filter); - - /** - *@brief Search by phone number ContactPersonNumber record - *@param[in] number - phone number - *@return Reference to ContactPersonNumber - */ - ContactPersonNumberRef getContactPersonNumber(const std::string &number); - - - void invalidateCache(); - ContactAddressRef getAddress(const std::string &address); - - std::string createContactContent(contacts_record_h record, bool myProfile); - std::string createContentForContactList(int personId); - - private: - std::list m_Listeners; - AddressMap m_AddressMap; - ContactMyProfileRef m_OwnerProfile; - }; - - class IContactManagerListener { - public: - virtual ~IContactManagerListener() {} - /* - *@brief A method called when changing of some contact-record has been occurred - */ - virtual void onContactChanged() {}; - }; + /* + *@brief A listener to be notified after contact-information will be changed in contacts-db + */ + class IContactManagerListener; + /* + *@brief Class that work with contacts database. + *@brief Search contacts, add listeners, register callback on changes in database. + */ + class ContactManager { + public: + ContactManager(); + ~ContactManager(); + ContactManager(ContactManager&) = delete; + ContactManager &operator=(ContactManager&) = delete; + + public: + /** + *@brief Return what kind of error occurred + *@param[in] error - number of error + *@return kind of error + */ + static std::string whatError(int error); + /** + * @brief Looks for contact information based on a given keyword + * @param keyword - search keyword + */ + template + std::shared_ptr> search(const std::string &keyword); + + /** + *@brief Search by email and phone and return ContactAddress record + *@param[in] address - email or number + *@return Reference to ContactAddress + */ + ContactAddressRef getContactAddress(const std::string &address); + + /** + *@brief Search for contacts-id, name, phone-number and thumbnail path based on phone-number id + *@param[in] phoneId - identifier of phone-number in contacts-database + *@return Reference to ContactPersonNumber + */ + ContactPersonNumberRef getContactPersonNumber(int phoneId); + + /** + *@brief Search for email-id, name, email and thumbnail path + *@param[in] emailId - identifier of email in contacts-database + *@return Reference to ContactPersonEmail + */ + ContactPersonEmailRef getContactPersonEmail(int emailId); + + /** + *@brief Search by email address ContactPersonEmail record + *@param[in] email - email address + *@return Reference to ContactPersonEmail + */ + ContactPersonEmailRef getContactPersonEmail(const std::string &email); + + /** + *@brief Search by number address ContactMyProfileNumber record + *@param[in] number - phone number + *@return Reference to ContactMyProfileNumber + */ + ContactMyProfileNumberRef getContactMyProfileNumber(const std::string &number); + + /** + *@brief Search by email address ContactMyProfileEmailRef record + *@param[in] email - email address + *@return Reference to ContactMyProfileEmailR + */ + ContactMyProfileEmailRef getContactMyProfileEmail(const std::string &email); + + /** + *@brief Return owner's ContactPersonAddress record + *@return Reference to ContactPersonAddress + */ + ContactMyProfileRef getOwnerProfile(); + + /** + *@brief Add listener on contacts database + *@param[in] listener + */ + void addListener(IContactManagerListener &listener); + + /** + *@brief Remove listener + *@param[in] listener - listener to be remove + */ + void removeListener(IContactManagerListener &listener); + + /** + *@brief Create content of contact by it`s id + *@param[in] personId - contact id + *@param[in] myProfile - is app control my_profile data type + *@return Content with all info about one contact + */ + std::string makeVcard(const int personId, bool myProfile); + + /** +- *@brief Create content of contact by id list + *@param[in] personId - contact id + *@return Content with all info about contacts + */ + std::string makeVcard(const std::list &idList); + + /** + *@brief Parse vCard file + *@param[in] filePath Path to file + *@return list of Contacts + */ + std::list parseVcard(const std::string &filePath); + + private: + typedef std::unordered_map AddressMap; + + private: + /** + *@brief A callback passed to contacts_db_add_changed_cb() to get notifications + about contacts modifications from contact service + *@param[in] view_uri - The view URI of records whose changes are monitored + *@param[in] user_data - the user data passed from the callback registration function + */ + static void contactChangedCb(const char *view_uri, void *user_data); + static void contactDisplayOrderChangedCb(contacts_name_display_order_e name_display_order, void *user_data); + + /** + * @brief Generic search for basic contact attributes based on custom filter passed from above + * @param[in] filter to be used for db-request. DO NOT destroy filter manually, it will be destroyed insithe this method. + */ + ContactPersonNumberRef getContactPersonNumber(contacts_filter_h filter); + ContactPersonEmailRef getContactPersonEmail(contacts_filter_h filter); + + /** + *@brief Search by phone number ContactPersonNumber record + *@param[in] number - phone number + *@return Reference to ContactPersonNumber + */ + ContactPersonNumberRef getContactPersonNumber(const std::string &number); + + + void invalidateCache(); + ContactAddressRef getAddress(const std::string &address); + + std::string createContactContent(contacts_record_h record, bool myProfile); + std::string createContentForContactList(int personId); + + private: + std::list m_Listeners; + AddressMap m_AddressMap; + ContactMyProfileRef m_OwnerProfile; + }; + + class IContactManagerListener { + public: + virtual ~IContactManagerListener() {} + /* + *@brief A method called when changing of some contact-record has been occurred + */ + virtual void onContactChanged() {}; + }; } #endif /* __ContactManager_h__ */ diff --git a/src/Common/ContactManager/inc/ContactMyProfile.h b/src/Common/ContactManager/inc/ContactMyProfile.h index ce183e87..04be25f7 100644 --- a/src/Common/ContactManager/inc/ContactMyProfile.h +++ b/src/Common/ContactManager/inc/ContactMyProfile.h @@ -20,37 +20,37 @@ #include "ContactRecord.h" namespace Msg { - class ContactMyProfile; - typedef std::shared_ptr ContactMyProfileRef; - - class ContactMyProfile - : public ContactRecord { - public: - ContactMyProfile(bool release, contacts_record_h record = nullptr); - int getId() const; - std::string getThumbnailPath() const; - std::string getDispName() const; - }; - - inline ContactMyProfile::ContactMyProfile(bool release, contacts_record_h record) - : ContactRecord(release, record) - { - } - - inline int ContactMyProfile::getId() const - { - return getInt(_contacts_my_profile.id); - } - - inline std::string ContactMyProfile::getThumbnailPath() const - { - return getStr(_contacts_my_profile.image_thumbnail_path); - } - - inline std::string ContactMyProfile::getDispName() const - { - return getStr(_contacts_my_profile.display_name); - } + class ContactMyProfile; + typedef std::shared_ptr ContactMyProfileRef; + + class ContactMyProfile + : public ContactRecord { + public: + ContactMyProfile(bool release, contacts_record_h record = nullptr); + int getId() const; + std::string getThumbnailPath() const; + std::string getDispName() const; + }; + + inline ContactMyProfile::ContactMyProfile(bool release, contacts_record_h record) + : ContactRecord(release, record) + { + } + + inline int ContactMyProfile::getId() const + { + return getInt(_contacts_my_profile.id); + } + + inline std::string ContactMyProfile::getThumbnailPath() const + { + return getStr(_contacts_my_profile.image_thumbnail_path); + } + + inline std::string ContactMyProfile::getDispName() const + { + return getStr(_contacts_my_profile.display_name); + } } #endif /* ContactMyProfile_h_ */ diff --git a/src/Common/ContactManager/inc/ContactMyProfileEmail.h b/src/Common/ContactManager/inc/ContactMyProfileEmail.h index 7b1063ee..714df13a 100644 --- a/src/Common/ContactManager/inc/ContactMyProfileEmail.h +++ b/src/Common/ContactManager/inc/ContactMyProfileEmail.h @@ -22,78 +22,78 @@ #include "ContactMyProfile.h" namespace Msg { - class ContactMyProfileEmail; - typedef std::shared_ptr ContactMyProfileEmailRef; - - class ContactMyProfileEmail - : public ContactAddress - , public ContactRecord { - public: - ContactMyProfileEmail(bool release, const ContactMyProfile &myProfile, contacts_record_h record = nullptr); - static const char *getUri(); - int getId() const; - - // ContactAddress: - virtual AddressType getAddressType() const; - virtual OwnerType getOwnerType() const; - virtual int getOwnerId() const; - virtual std::string getDispName() const; - virtual std::string getAddress() const; - virtual std::string getThumbnailPath() const; - - private: - int m_MyProfileId; - std::string m_ThumbnailPath; - std::string m_DispName; - }; - - inline ContactMyProfileEmail::ContactMyProfileEmail(bool release, const ContactMyProfile &myProfile, contacts_record_h record) - : ContactRecord(release, record) - , m_MyProfileId(myProfile.getId()) - , m_ThumbnailPath(myProfile.getThumbnailPath()) - , m_DispName(myProfile.getDispName()) - { - } - - inline int ContactMyProfileEmail::getId() const - { - return getInt(_contacts_email.id); - } - - inline int ContactMyProfileEmail::getOwnerId() const - { - return m_MyProfileId; - } - - inline std::string ContactMyProfileEmail::getDispName() const - { - return m_DispName; - } - - inline std::string ContactMyProfileEmail::getAddress() const - { - return getStr(_contacts_email.email); - } - - inline std::string ContactMyProfileEmail::getThumbnailPath() const - { - return m_ThumbnailPath; - } - - inline const char *ContactMyProfileEmail::getUri() - { - return _contacts_email._uri; - } - - inline ContactMyProfileNumber::OwnerType ContactMyProfileEmail::getOwnerType() const - { - return MyProfileType; - } - - inline ContactMyProfileNumber::AddressType ContactMyProfileEmail::getAddressType() const - { - return EmailType; - } + class ContactMyProfileEmail; + typedef std::shared_ptr ContactMyProfileEmailRef; + + class ContactMyProfileEmail + : public ContactAddress + , public ContactRecord { + public: + ContactMyProfileEmail(bool release, const ContactMyProfile &myProfile, contacts_record_h record = nullptr); + static const char *getUri(); + int getId() const; + + // ContactAddress: + virtual AddressType getAddressType() const; + virtual OwnerType getOwnerType() const; + virtual int getOwnerId() const; + virtual std::string getDispName() const; + virtual std::string getAddress() const; + virtual std::string getThumbnailPath() const; + + private: + int m_MyProfileId; + std::string m_ThumbnailPath; + std::string m_DispName; + }; + + inline ContactMyProfileEmail::ContactMyProfileEmail(bool release, const ContactMyProfile &myProfile, contacts_record_h record) + : ContactRecord(release, record) + , m_MyProfileId(myProfile.getId()) + , m_ThumbnailPath(myProfile.getThumbnailPath()) + , m_DispName(myProfile.getDispName()) + { + } + + inline int ContactMyProfileEmail::getId() const + { + return getInt(_contacts_email.id); + } + + inline int ContactMyProfileEmail::getOwnerId() const + { + return m_MyProfileId; + } + + inline std::string ContactMyProfileEmail::getDispName() const + { + return m_DispName; + } + + inline std::string ContactMyProfileEmail::getAddress() const + { + return getStr(_contacts_email.email); + } + + inline std::string ContactMyProfileEmail::getThumbnailPath() const + { + return m_ThumbnailPath; + } + + inline const char *ContactMyProfileEmail::getUri() + { + return _contacts_email._uri; + } + + inline ContactMyProfileNumber::OwnerType ContactMyProfileEmail::getOwnerType() const + { + return MyProfileType; + } + + inline ContactMyProfileNumber::AddressType ContactMyProfileEmail::getAddressType() const + { + return EmailType; + } } diff --git a/src/Common/ContactManager/inc/ContactMyProfileNumber.h b/src/Common/ContactManager/inc/ContactMyProfileNumber.h index 31fbc081..06a83809 100644 --- a/src/Common/ContactManager/inc/ContactMyProfileNumber.h +++ b/src/Common/ContactManager/inc/ContactMyProfileNumber.h @@ -22,78 +22,78 @@ #include "ContactMyProfile.h" namespace Msg { - class ContactMyProfileNumber; - typedef std::shared_ptr ContactMyProfileNumberRef; - - class ContactMyProfileNumber - : public ContactAddress - , public ContactRecord { - public: - ContactMyProfileNumber(bool release, const ContactMyProfile &myProfile, contacts_record_h record = nullptr); - static const char *getUri(); - int getId() const; - - // ContactAddress: - virtual AddressType getAddressType() const; - virtual OwnerType getOwnerType() const; - virtual int getOwnerId() const; - virtual std::string getDispName() const; - virtual std::string getAddress() const; - virtual std::string getThumbnailPath() const; - - private: - int m_MyProfileId; - std::string m_ThumbnailPath; - std::string m_DispName; - }; - - inline ContactMyProfileNumber::ContactMyProfileNumber(bool release, const ContactMyProfile &myProfile, contacts_record_h record) - : ContactRecord(release, record) - , m_MyProfileId(myProfile.getId()) - , m_ThumbnailPath(myProfile.getThumbnailPath()) - , m_DispName(myProfile.getDispName()) - { - } - - inline int ContactMyProfileNumber::getId() const - { - return getInt(_contacts_number.id); - } - - inline int ContactMyProfileNumber::getOwnerId() const - { - return m_MyProfileId; - } - - inline std::string ContactMyProfileNumber::getDispName() const - { - return m_DispName; - } - - inline std::string ContactMyProfileNumber::getAddress() const - { - return getStr(_contacts_number.number); - } - - inline std::string ContactMyProfileNumber::getThumbnailPath() const - { - return m_ThumbnailPath; - } - - inline const char *ContactMyProfileNumber::getUri() - { - return _contacts_number._uri; - } - - inline ContactMyProfileNumber::OwnerType ContactMyProfileNumber::getOwnerType() const - { - return MyProfileType; - } - - inline ContactMyProfileNumber::AddressType ContactMyProfileNumber::getAddressType() const - { - return NumberType; - } + class ContactMyProfileNumber; + typedef std::shared_ptr ContactMyProfileNumberRef; + + class ContactMyProfileNumber + : public ContactAddress + , public ContactRecord { + public: + ContactMyProfileNumber(bool release, const ContactMyProfile &myProfile, contacts_record_h record = nullptr); + static const char *getUri(); + int getId() const; + + // ContactAddress: + virtual AddressType getAddressType() const; + virtual OwnerType getOwnerType() const; + virtual int getOwnerId() const; + virtual std::string getDispName() const; + virtual std::string getAddress() const; + virtual std::string getThumbnailPath() const; + + private: + int m_MyProfileId; + std::string m_ThumbnailPath; + std::string m_DispName; + }; + + inline ContactMyProfileNumber::ContactMyProfileNumber(bool release, const ContactMyProfile &myProfile, contacts_record_h record) + : ContactRecord(release, record) + , m_MyProfileId(myProfile.getId()) + , m_ThumbnailPath(myProfile.getThumbnailPath()) + , m_DispName(myProfile.getDispName()) + { + } + + inline int ContactMyProfileNumber::getId() const + { + return getInt(_contacts_number.id); + } + + inline int ContactMyProfileNumber::getOwnerId() const + { + return m_MyProfileId; + } + + inline std::string ContactMyProfileNumber::getDispName() const + { + return m_DispName; + } + + inline std::string ContactMyProfileNumber::getAddress() const + { + return getStr(_contacts_number.number); + } + + inline std::string ContactMyProfileNumber::getThumbnailPath() const + { + return m_ThumbnailPath; + } + + inline const char *ContactMyProfileNumber::getUri() + { + return _contacts_number._uri; + } + + inline ContactMyProfileNumber::OwnerType ContactMyProfileNumber::getOwnerType() const + { + return MyProfileType; + } + + inline ContactMyProfileNumber::AddressType ContactMyProfileNumber::getAddressType() const + { + return NumberType; + } } diff --git a/src/Common/ContactManager/inc/ContactPersonEmail.h b/src/Common/ContactManager/inc/ContactPersonEmail.h index 692e3172..e227f9f6 100644 --- a/src/Common/ContactManager/inc/ContactPersonEmail.h +++ b/src/Common/ContactManager/inc/ContactPersonEmail.h @@ -21,70 +21,70 @@ #include "ContactRecord.h" namespace Msg { - class ContactPersonEmail; - typedef std::shared_ptr ContactPersonEmailRef; - - class ContactPersonEmail - : public ContactAddress - , public ContactRecord { - public: - ContactPersonEmail(bool release, contacts_record_h record = nullptr); - static const char *getUri(); - int getEmailId() const; - - // ContactAddress: - virtual OwnerType getOwnerType() const; - virtual AddressType getAddressType() const; - virtual int getOwnerId() const; - virtual std::string getDispName() const; - virtual std::string getAddress() const; - virtual std::string getThumbnailPath() const; - }; - - inline ContactPersonEmail::ContactPersonEmail(bool release, contacts_record_h record) - : ContactRecord(release, record) - { - } - - inline int ContactPersonEmail::getEmailId() const - { - return getInt(_contacts_person_email.email_id); - } - - inline int ContactPersonEmail::getOwnerId() const - { - return getInt(_contacts_person_email.person_id); - } - - inline std::string ContactPersonEmail::getDispName() const - { - return getStr(_contacts_person_email.display_name); - } - - inline std::string ContactPersonEmail::getAddress() const - { - return getStr(_contacts_person_email.email); - } - - inline std::string ContactPersonEmail::getThumbnailPath() const - { - return getStr(_contacts_person_email.image_thumbnail_path); - } - - inline const char *ContactPersonEmail::getUri() - { - return _contacts_person_email._uri; - } - - inline ContactPersonEmail::OwnerType ContactPersonEmail::getOwnerType() const - { - return PersonType; - } - - inline ContactPersonEmail::AddressType ContactPersonEmail::getAddressType() const - { - return EmailType; - } + class ContactPersonEmail; + typedef std::shared_ptr ContactPersonEmailRef; + + class ContactPersonEmail + : public ContactAddress + , public ContactRecord { + public: + ContactPersonEmail(bool release, contacts_record_h record = nullptr); + static const char *getUri(); + int getEmailId() const; + + // ContactAddress: + virtual OwnerType getOwnerType() const; + virtual AddressType getAddressType() const; + virtual int getOwnerId() const; + virtual std::string getDispName() const; + virtual std::string getAddress() const; + virtual std::string getThumbnailPath() const; + }; + + inline ContactPersonEmail::ContactPersonEmail(bool release, contacts_record_h record) + : ContactRecord(release, record) + { + } + + inline int ContactPersonEmail::getEmailId() const + { + return getInt(_contacts_person_email.email_id); + } + + inline int ContactPersonEmail::getOwnerId() const + { + return getInt(_contacts_person_email.person_id); + } + + inline std::string ContactPersonEmail::getDispName() const + { + return getStr(_contacts_person_email.display_name); + } + + inline std::string ContactPersonEmail::getAddress() const + { + return getStr(_contacts_person_email.email); + } + + inline std::string ContactPersonEmail::getThumbnailPath() const + { + return getStr(_contacts_person_email.image_thumbnail_path); + } + + inline const char *ContactPersonEmail::getUri() + { + return _contacts_person_email._uri; + } + + inline ContactPersonEmail::OwnerType ContactPersonEmail::getOwnerType() const + { + return PersonType; + } + + inline ContactPersonEmail::AddressType ContactPersonEmail::getAddressType() const + { + return EmailType; + } } diff --git a/src/Common/ContactManager/inc/ContactPersonNumber.h b/src/Common/ContactManager/inc/ContactPersonNumber.h index ec19f2f1..cda20a0e 100644 --- a/src/Common/ContactManager/inc/ContactPersonNumber.h +++ b/src/Common/ContactManager/inc/ContactPersonNumber.h @@ -21,70 +21,70 @@ #include "ContactRecord.h" namespace Msg { - class ContactPersonNumber; - typedef std::shared_ptr ContactPersonNumberRef; - - class ContactPersonNumber - : public ContactAddress - , public ContactRecord { - public: - ContactPersonNumber(bool release, contacts_record_h record = nullptr); - static const char *getUri(); - int getNumberId() const; - - // ContactAddress: - virtual OwnerType getOwnerType() const; - virtual AddressType getAddressType() const; - virtual int getOwnerId() const; - virtual std::string getDispName() const; - virtual std::string getAddress() const; - virtual std::string getThumbnailPath() const; - }; - - inline ContactPersonNumber::ContactPersonNumber(bool release, contacts_record_h record) - : ContactRecord(release, record) - { - } - - inline int ContactPersonNumber::getNumberId() const - { - return getInt(_contacts_person_number.number_id); - } - - inline int ContactPersonNumber::getOwnerId() const - { - return getInt(_contacts_person_number.person_id); - } - - inline std::string ContactPersonNumber::getDispName() const - { - return getStr(_contacts_person_number.display_name); - } - - inline std::string ContactPersonNumber::getAddress() const - { - return getStr(_contacts_person_number.number); - } - - inline std::string ContactPersonNumber::getThumbnailPath() const - { - return getStr(_contacts_person_number.image_thumbnail_path); - } - - inline const char *ContactPersonNumber::getUri() - { - return _contacts_person_number._uri; - } - - inline ContactPersonNumber::OwnerType ContactPersonNumber::getOwnerType() const - { - return PersonType; - } - - inline ContactPersonNumber::AddressType ContactPersonNumber::getAddressType() const - { - return NumberType; - } + class ContactPersonNumber; + typedef std::shared_ptr ContactPersonNumberRef; + + class ContactPersonNumber + : public ContactAddress + , public ContactRecord { + public: + ContactPersonNumber(bool release, contacts_record_h record = nullptr); + static const char *getUri(); + int getNumberId() const; + + // ContactAddress: + virtual OwnerType getOwnerType() const; + virtual AddressType getAddressType() const; + virtual int getOwnerId() const; + virtual std::string getDispName() const; + virtual std::string getAddress() const; + virtual std::string getThumbnailPath() const; + }; + + inline ContactPersonNumber::ContactPersonNumber(bool release, contacts_record_h record) + : ContactRecord(release, record) + { + } + + inline int ContactPersonNumber::getNumberId() const + { + return getInt(_contacts_person_number.number_id); + } + + inline int ContactPersonNumber::getOwnerId() const + { + return getInt(_contacts_person_number.person_id); + } + + inline std::string ContactPersonNumber::getDispName() const + { + return getStr(_contacts_person_number.display_name); + } + + inline std::string ContactPersonNumber::getAddress() const + { + return getStr(_contacts_person_number.number); + } + + inline std::string ContactPersonNumber::getThumbnailPath() const + { + return getStr(_contacts_person_number.image_thumbnail_path); + } + + inline const char *ContactPersonNumber::getUri() + { + return _contacts_person_number._uri; + } + + inline ContactPersonNumber::OwnerType ContactPersonNumber::getOwnerType() const + { + return PersonType; + } + + inline ContactPersonNumber::AddressType ContactPersonNumber::getAddressType() const + { + return NumberType; + } } diff --git a/src/Common/ContactManager/inc/ContactPersonPhoneLog.h b/src/Common/ContactManager/inc/ContactPersonPhoneLog.h index 4f7d3062..ebc7eaa5 100644 --- a/src/Common/ContactManager/inc/ContactPersonPhoneLog.h +++ b/src/Common/ContactManager/inc/ContactPersonPhoneLog.h @@ -20,49 +20,49 @@ #include "ContactRecord.h" namespace Msg { - class ContactPersonPhoneLog; - typedef std::shared_ptr ContactPersonPhoneLogRef; + class ContactPersonPhoneLog; + typedef std::shared_ptr ContactPersonPhoneLogRef; - class ContactPersonPhoneLog - : public ContactRecord { - public: - ContactPersonPhoneLog(bool release, contacts_record_h record = nullptr); - static const char *getUri(); - virtual int getId() const; - int getPersonId() const; - std::string getAddress() const; - std::string getDispName() const; - }; + class ContactPersonPhoneLog + : public ContactRecord { + public: + ContactPersonPhoneLog(bool release, contacts_record_h record = nullptr); + static const char *getUri(); + virtual int getId() const; + int getPersonId() const; + std::string getAddress() const; + std::string getDispName() const; + }; - inline ContactPersonPhoneLog::ContactPersonPhoneLog(bool release, contacts_record_h record) - : ContactRecord(release, record) - { - } + inline ContactPersonPhoneLog::ContactPersonPhoneLog(bool release, contacts_record_h record) + : ContactRecord(release, record) + { + } - inline int ContactPersonPhoneLog::getId() const - { - return getInt(_contacts_person_phone_log.log_id); - } + inline int ContactPersonPhoneLog::getId() const + { + return getInt(_contacts_person_phone_log.log_id); + } - inline int ContactPersonPhoneLog::getPersonId() const - { - return getInt(_contacts_person_phone_log.person_id); - } + inline int ContactPersonPhoneLog::getPersonId() const + { + return getInt(_contacts_person_phone_log.person_id); + } - inline std::string ContactPersonPhoneLog::getDispName() const - { - return getStr(_contacts_person_phone_log.display_name); - } + inline std::string ContactPersonPhoneLog::getDispName() const + { + return getStr(_contacts_person_phone_log.display_name); + } - inline std::string ContactPersonPhoneLog::getAddress() const - { - return getStr(_contacts_person_phone_log.address); - } + inline std::string ContactPersonPhoneLog::getAddress() const + { + return getStr(_contacts_person_phone_log.address); + } - inline const char *ContactPersonPhoneLog::getUri() - { - return _contacts_person_phone_log._uri; - } + inline const char *ContactPersonPhoneLog::getUri() + { + return _contacts_person_phone_log._uri; + } } diff --git a/src/Common/ContactManager/inc/ContactRecord.h b/src/Common/ContactManager/inc/ContactRecord.h index c8bcaf04..45f34b0b 100644 --- a/src/Common/ContactManager/inc/ContactRecord.h +++ b/src/Common/ContactManager/inc/ContactRecord.h @@ -22,92 +22,92 @@ #include namespace Msg { - class ContactRecord; - typedef std::shared_ptr ContactRecordRef; - - class ContactRecord { - public: - ContactRecord(bool release, contacts_record_h record = nullptr); - virtual ~ContactRecord(); - ContactRecord(ContactRecord&) = delete; - ContactRecord& operator=(ContactRecord&) = delete; - - void set(contacts_record_h record); - contacts_record_h getRecord() const; - - protected: - std::string getStr(unsigned propertyId) const; - int getInt(unsigned propertyId) const; - int getChildCount(unsigned propertyId) const; - contacts_record_h getChildP(unsigned propertyId, int index) const; - - static std::string getStr(contacts_record_h rec, unsigned propertyId); - static int getInt(contacts_record_h rec, unsigned propertyId); - static int getChildCount(contacts_record_h rec, unsigned propertyId); - static contacts_record_h getChildP(contacts_record_h rec, unsigned propertyId, int index); - - private: - contacts_record_h m_Record; - bool m_Release; - }; - - inline void ContactRecord::set(contacts_record_h record) - { - m_Record = record; - } - - inline contacts_record_h ContactRecord::getRecord() const - { - return m_Record; - } - - inline std::string ContactRecord::getStr(contacts_record_h rec, unsigned propertyId) - { - char *str = nullptr; - contacts_record_get_str_p(rec, propertyId, &str); - return str ? str : std::string(); - } - - inline int ContactRecord::getChildCount(contacts_record_h rec, unsigned propertyId) - { - int count = 0; - contacts_record_get_child_record_count(rec, propertyId, &count); - return count; - } - - inline contacts_record_h ContactRecord::getChildP(contacts_record_h rec, unsigned propertyId, int index) - { - contacts_record_h res = {}; - contacts_record_get_child_record_at_p(rec, propertyId, index, &res); - return res; - } - - inline int ContactRecord::getInt(contacts_record_h rec, unsigned propertyId) - { - int val = 0; - contacts_record_get_int(rec, propertyId, &val); - return val; - } - - inline std::string ContactRecord::getStr(unsigned propertyId) const - { - return getStr(m_Record, propertyId); - } - - inline int ContactRecord::getChildCount(unsigned propertyId) const - { - return getChildCount(m_Record, propertyId); - } - - inline contacts_record_h ContactRecord::getChildP(unsigned propertyId, int index) const - { - return getChildP(m_Record, propertyId, index); - } - - inline int ContactRecord::getInt(unsigned propertyId) const - { - return getInt(m_Record, propertyId); - } + class ContactRecord; + typedef std::shared_ptr ContactRecordRef; + + class ContactRecord { + public: + ContactRecord(bool release, contacts_record_h record = nullptr); + virtual ~ContactRecord(); + ContactRecord(ContactRecord&) = delete; + ContactRecord& operator=(ContactRecord&) = delete; + + void set(contacts_record_h record); + contacts_record_h getRecord() const; + + protected: + std::string getStr(unsigned propertyId) const; + int getInt(unsigned propertyId) const; + int getChildCount(unsigned propertyId) const; + contacts_record_h getChildP(unsigned propertyId, int index) const; + + static std::string getStr(contacts_record_h rec, unsigned propertyId); + static int getInt(contacts_record_h rec, unsigned propertyId); + static int getChildCount(contacts_record_h rec, unsigned propertyId); + static contacts_record_h getChildP(contacts_record_h rec, unsigned propertyId, int index); + + private: + contacts_record_h m_Record; + bool m_Release; + }; + + inline void ContactRecord::set(contacts_record_h record) + { + m_Record = record; + } + + inline contacts_record_h ContactRecord::getRecord() const + { + return m_Record; + } + + inline std::string ContactRecord::getStr(contacts_record_h rec, unsigned propertyId) + { + char *str = nullptr; + contacts_record_get_str_p(rec, propertyId, &str); + return str ? str : std::string(); + } + + inline int ContactRecord::getChildCount(contacts_record_h rec, unsigned propertyId) + { + int count = 0; + contacts_record_get_child_record_count(rec, propertyId, &count); + return count; + } + + inline contacts_record_h ContactRecord::getChildP(contacts_record_h rec, unsigned propertyId, int index) + { + contacts_record_h res = {}; + contacts_record_get_child_record_at_p(rec, propertyId, index, &res); + return res; + } + + inline int ContactRecord::getInt(contacts_record_h rec, unsigned propertyId) + { + int val = 0; + contacts_record_get_int(rec, propertyId, &val); + return val; + } + + inline std::string ContactRecord::getStr(unsigned propertyId) const + { + return getStr(m_Record, propertyId); + } + + inline int ContactRecord::getChildCount(unsigned propertyId) const + { + return getChildCount(m_Record, propertyId); + } + + inline contacts_record_h ContactRecord::getChildP(unsigned propertyId, int index) const + { + return getChildP(m_Record, propertyId, index); + } + + inline int ContactRecord::getInt(unsigned propertyId) const + { + return getInt(m_Record, propertyId); + } } #endif /* __ContactRecord_h__ */ diff --git a/src/Common/ContactManager/src/ContactManager.cpp b/src/Common/ContactManager/src/ContactManager.cpp index 4d89b7cc..41708491 100644 --- a/src/Common/ContactManager/src/ContactManager.cpp +++ b/src/Common/ContactManager/src/ContactManager.cpp @@ -23,384 +23,384 @@ #include namespace Msg { - const int mapReservSize = 512; - - ContactManager::ContactManager() - { - MSG_LOG(""); - m_AddressMap.reserve(mapReservSize); - int error = contacts_connect(); - if (error != 0) { - MSG_LOG_ERROR(whatError(error)); - } - - contacts_db_add_changed_cb(_contacts_contact._uri, contactChangedCb, this); - contacts_db_add_changed_cb(_contacts_my_profile._uri, contactChangedCb, this); - contacts_setting_add_name_display_order_changed_cb(contactDisplayOrderChangedCb, this); - } - - ContactManager::~ContactManager() - { - MSG_LOG(""); - int error = contacts_db_remove_changed_cb(_contacts_contact._uri, contactChangedCb, this); - if (error != 0) - MSG_LOG_ERROR(whatError(error)); - - error = contacts_disconnect(); - if (error != 0) - MSG_LOG_ERROR(whatError(error)); - } - - std::string ContactManager::whatError(int error) - { - switch (error) { - case CONTACTS_ERROR_NONE: - return "CONTACTS_ERROR_NONE"; - case CONTACTS_ERROR_OUT_OF_MEMORY: - return "CONTACTS_ERROR_OUT_OF_MEMORY"; - case CONTACTS_ERROR_INVALID_PARAMETER: - return "CONTACTS_ERROR_INVALID_PARAMETER"; - case CONTACTS_ERROR_FILE_NO_SPACE: - return "CONTACTS_ERROR_FILE_NO_SPACE"; - case CONTACTS_ERROR_PERMISSION_DENIED: - return "CONTACTS_ERROR_PERMISSION_DENIED"; - case CONTACTS_ERROR_NOT_SUPPORTED: - return "CONTACTS_ERROR_NOT_SUPPORTED"; - case CONTACTS_ERROR_NO_DATA: - return "CONTACTS_ERROR_NO_DATA"; - case CONTACTS_ERROR_DB_LOCKED: - return "CONTACTS_ERROR_DB_LOCKED"; - case CONTACTS_ERROR_DB: - return "CONTACTS_ERROR_DB"; - case CONTACTS_ERROR_IPC_NOT_AVALIABLE: - return "CONTACTS_ERROR_IPC_NOT_AVALIABLE"; - case CONTACTS_ERROR_IPC: - return "CONTACTS_ERROR_IPC"; - case CONTACTS_ERROR_SYSTEM: - return "CONTACTS_ERROR_SYSTEM"; - case CONTACTS_ERROR_INTERNAL: - return "CONTACTS_ERROR_INTERNAL"; - } - - return "Unknown error"; - } - - template <> - std::shared_ptr> ContactManager::search(const std::string &keyword) - { - contacts_query_h query = nullptr; - contacts_filter_h filter = nullptr; - contacts_list_h list = nullptr; - - contacts_query_create(_contacts_person_phone_log._uri, &query); - contacts_filter_create(_contacts_person_phone_log._uri, &filter); - contacts_filter_add_str(filter, _contacts_person_phone_log.address, CONTACTS_MATCH_CONTAINS, keyword.c_str()); - contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND); - contacts_filter_add_int(filter, _contacts_person_phone_log.person_id, CONTACTS_MATCH_NONE, 0); - contacts_query_set_filter(query, filter); - - /* set projection */ - unsigned int numberProjection[] = { - _contacts_person_phone_log.person_id, - _contacts_person_phone_log.address, - _contacts_person_phone_log.display_name - }; - - contacts_query_set_projection(query, numberProjection, sizeof(numberProjection)/sizeof(unsigned int)); - contacts_query_set_distinct(query, true); - - contacts_db_get_records_with_query(query, 0, 0, &list); - contacts_filter_destroy(filter); - contacts_query_destroy(query); - - return list ? std::make_shared>(list) : nullptr; - } - - template<> - std::shared_ptr> ContactManager::search(const std::string &keyword) - { - contacts_list_h list = nullptr; - contacts_db_search_records_with_range(ContactPersonNumber::getUri(), keyword.c_str(), - 0, 0, CONTACTS_SEARCH_RANGE_NAME | CONTACTS_SEARCH_RANGE_NUMBER, &list); - return list ? std::make_shared>(list) : nullptr; - } - - template<> - std::shared_ptr> ContactManager::search(const std::string &keyword) - { - contacts_list_h list = nullptr; - contacts_db_search_records_with_range(ContactPersonEmail::getUri(), keyword.c_str(), - 0, 0, CONTACTS_SEARCH_RANGE_NAME | CONTACTS_SEARCH_RANGE_EMAIL, &list); - return list ? std::make_shared>(list) : nullptr; - } - - ContactPersonNumberRef ContactManager::getContactPersonNumber(int phoneNumId) - { - contacts_filter_h filter = nullptr; - contacts_filter_create(_contacts_contact_number._uri, &filter); - contacts_filter_add_int(filter, _contacts_person_number.number_id, CONTACTS_MATCH_EQUAL, phoneNumId); - return filter ? getContactPersonNumber(filter) : nullptr; - } - - ContactPersonEmailRef ContactManager::getContactPersonEmail(int emailId) - { - contacts_filter_h filter = nullptr; - contacts_filter_create(_contacts_contact_email._uri, &filter); - contacts_filter_add_int(filter, _contacts_person_email.email_id, CONTACTS_MATCH_EQUAL, emailId); - return filter ? getContactPersonEmail(filter) : nullptr; - } - - ContactPersonNumberRef ContactManager::getContactPersonNumber(const std::string &number) - { - contacts_filter_h filter = nullptr; - contacts_filter_create(_contacts_contact_number._uri, &filter); - contacts_filter_add_str(filter, _contacts_person_number.number_filter, CONTACTS_MATCH_EXACTLY, number.c_str()); - return filter ? getContactPersonNumber(filter) : nullptr; - } - - ContactPersonEmailRef ContactManager::getContactPersonEmail(const std::string &email) - { - contacts_filter_h filter = nullptr; - contacts_filter_create(_contacts_person_email._uri, &filter); - contacts_filter_add_str(filter, _contacts_person_email.email, CONTACTS_MATCH_EXACTLY, email.c_str()); - return filter ? getContactPersonEmail(filter) : nullptr; - } - - ContactMyProfileNumberRef ContactManager::getContactMyProfileNumber(const std::string &number) - { - auto myProfile = getOwnerProfile(); - if (!myProfile) - return nullptr; - - contacts_record_h rec = myProfile->getRecord(); - - int count = 0; - contacts_record_get_child_record_count(rec, _contacts_my_profile.number, &count); - std::string normalizedNumber = PhoneNumberUtils::getInst().getNormalizedNumber(number); - - for (int i =0; i < count; ++i) { - contacts_record_h child = nullptr; - contacts_record_get_child_record_at_p(rec, _contacts_my_profile.number, i, &child); - if (child) { - char *num = nullptr; - contacts_record_get_str_p(child, _contacts_number.number, &num); - if (num) { - std::string curNum = PhoneNumberUtils::getInst().getNormalizedNumber(num); - if (normalizedNumber == curNum) { - contacts_record_h clonedRec = nullptr; - contacts_record_clone(child, &clonedRec); - if (clonedRec) - return std::make_shared(true, *myProfile, clonedRec); - } - } - } - } - return nullptr; - } - - ContactMyProfileEmailRef ContactManager::getContactMyProfileEmail(const std::string &email) - { - auto myProfile = getOwnerProfile(); - if (!myProfile) - return nullptr; - - contacts_record_h rec = myProfile->getRecord(); - - int count = 0; - contacts_record_get_child_record_count(rec, _contacts_my_profile.email, &count); - - for (int i =0; i < count; ++i) { - contacts_record_h child = nullptr; - contacts_record_get_child_record_at_p(rec, _contacts_my_profile.email, i, &child); - if (child) { - char *curEmail = nullptr; - contacts_record_get_str_p(child, _contacts_email.email, &curEmail); - if (curEmail) { - if (strcasecmp(email.c_str(), curEmail) == 0) { - contacts_record_h clonedRec = nullptr; - contacts_record_clone(child, &clonedRec); - if (clonedRec) - return std::make_shared(true, *myProfile, clonedRec); - } - } - } - } - return nullptr; - } - - ContactAddressRef ContactManager::getContactAddress(const std::string &address) - { - return getAddress(address); - } - - ContactMyProfileRef ContactManager::getOwnerProfile() - { - if (!m_OwnerProfile) - { - contacts_list_h list = nullptr; - contacts_record_h myProfile = nullptr; - contacts_db_get_all_records(_contacts_my_profile._uri, 0, 1, &list); - if (list) - { - contacts_list_get_current_record_p(list, &myProfile); - contacts_list_destroy(list, false); - } - if (myProfile) - m_OwnerProfile.reset(new ContactMyProfile(true, myProfile)); - } - return m_OwnerProfile; - } - - void ContactManager::contactChangedCb(const char *view_uri, void *user_data) - { - ContactManager *self = static_cast(user_data); - self->invalidateCache(); - for (auto listener : self->m_Listeners) - listener->onContactChanged(); - } - - void ContactManager::contactDisplayOrderChangedCb(contacts_name_display_order_e name_display_order, void *user_data) - { - ContactManager *self = static_cast(user_data); - self->invalidateCache(); - for (auto listener : self->m_Listeners) - listener->onContactChanged(); - } - - void ContactManager::addListener(IContactManagerListener &listener) - { - auto found = std::find(m_Listeners.begin(), m_Listeners.end(), &listener); - if (found == m_Listeners.end()) - m_Listeners.push_back(&listener); - } - - void ContactManager::removeListener(IContactManagerListener &listener) - { - auto found = std::find(m_Listeners.begin(), m_Listeners.end(), &listener); - if (found != m_Listeners.end()) - m_Listeners.erase(found); - } - - ContactPersonNumberRef ContactManager::getContactPersonNumber(contacts_filter_h filter) - { - contacts_query_h query = nullptr; - contacts_list_h list = nullptr; - contacts_record_h crValue = nullptr; - contacts_record_h cResValue = nullptr; - - contacts_query_create(_contacts_person_number._uri, &query); - contacts_query_set_filter(query, filter); - - unsigned int numberProjection[] = - { - _contacts_person_number.person_id, - _contacts_person_number.number, - _contacts_person_number.display_name, - _contacts_person_number.image_thumbnail_path - }; - - int ctRrr = contacts_query_set_projection(query, numberProjection, sizeof(numberProjection) / sizeof(unsigned int)); - if (ctRrr == CONTACTS_ERROR_NONE) - ctRrr = contacts_db_get_records_with_query(query, 0, 0, &list); - - contacts_filter_destroy(filter); - contacts_query_destroy(query); - - while (ctRrr == CONTACTS_ERROR_NONE) { - int contactId = 0; - - contacts_list_get_current_record_p(list, &crValue); - if (crValue) { - contacts_record_get_int(crValue, _contacts_person_number.person_id, &contactId); - if (contactId > 0) - cResValue = crValue; - else - contacts_record_destroy(crValue, true); - } - ctRrr = contacts_list_next(list); - } - - contacts_list_destroy(list, false); - return cResValue ? std::make_shared(true, cResValue) : nullptr; - } - - ContactPersonEmailRef ContactManager::getContactPersonEmail(contacts_filter_h filter) - { - contacts_query_h query = nullptr; - contacts_list_h list = nullptr; - contacts_record_h crValue = nullptr; - contacts_record_h cResValue = nullptr; - - contacts_query_create(_contacts_person_email._uri, &query); - contacts_query_set_filter(query, filter); - - unsigned int numberProjection[] = - { - _contacts_person_email.person_id, - _contacts_person_email.email, - _contacts_person_email.display_name, - _contacts_person_email.image_thumbnail_path - }; - - int ctRrr = contacts_query_set_projection(query, numberProjection, sizeof(numberProjection) / sizeof(unsigned int)); - if (ctRrr == CONTACTS_ERROR_NONE) - ctRrr = contacts_db_get_records_with_query(query, 0, 0, &list); - - contacts_filter_destroy(filter); - contacts_query_destroy(query); - - while (ctRrr == CONTACTS_ERROR_NONE) { - int contactId = 0; - - contacts_list_get_current_record_p(list, &crValue); - if (crValue) { - contacts_record_get_int(crValue, _contacts_person_email.person_id, &contactId); - if (contactId > 0) - cResValue = crValue; - else - contacts_record_destroy(crValue, true); - } - ctRrr = contacts_list_next(list); - } - - contacts_list_destroy(list, false); - return cResValue ? std::make_shared(true, cResValue) : nullptr; - } - - ContactAddressRef ContactManager::getAddress(const std::string &address) - { - auto it = m_AddressMap.find(address); - if (m_AddressMap.end() == it) { - bool isNumber = MsgUtils::isValidNumber(address); - - // ContactPerson: - ContactAddressRef contactAddress; - if (isNumber) - contactAddress = getContactPersonNumber(address); - else - contactAddress = getContactPersonEmail(address); - - // MyProfile: - #if (0) - if (!contactAddress) { - if (isNumber) - contactAddress = getContactMyProfileNumber(address); - else - contactAddress = getContactMyProfileEmail(address); - } - #endif - - m_AddressMap[address] = contactAddress; - return contactAddress; - } - return it->second; - } - - void ContactManager::invalidateCache() - { - MSG_LOG(""); - m_AddressMap.clear(); - m_OwnerProfile.reset(); - } + const int mapReservSize = 512; + + ContactManager::ContactManager() + { + MSG_LOG(""); + m_AddressMap.reserve(mapReservSize); + int error = contacts_connect(); + if (error != 0) { + MSG_LOG_ERROR(whatError(error)); + } + + contacts_db_add_changed_cb(_contacts_contact._uri, contactChangedCb, this); + contacts_db_add_changed_cb(_contacts_my_profile._uri, contactChangedCb, this); + contacts_setting_add_name_display_order_changed_cb(contactDisplayOrderChangedCb, this); + } + + ContactManager::~ContactManager() + { + MSG_LOG(""); + int error = contacts_db_remove_changed_cb(_contacts_contact._uri, contactChangedCb, this); + if (error != 0) + MSG_LOG_ERROR(whatError(error)); + + error = contacts_disconnect(); + if (error != 0) + MSG_LOG_ERROR(whatError(error)); + } + + std::string ContactManager::whatError(int error) + { + switch (error) { + case CONTACTS_ERROR_NONE: + return "CONTACTS_ERROR_NONE"; + case CONTACTS_ERROR_OUT_OF_MEMORY: + return "CONTACTS_ERROR_OUT_OF_MEMORY"; + case CONTACTS_ERROR_INVALID_PARAMETER: + return "CONTACTS_ERROR_INVALID_PARAMETER"; + case CONTACTS_ERROR_FILE_NO_SPACE: + return "CONTACTS_ERROR_FILE_NO_SPACE"; + case CONTACTS_ERROR_PERMISSION_DENIED: + return "CONTACTS_ERROR_PERMISSION_DENIED"; + case CONTACTS_ERROR_NOT_SUPPORTED: + return "CONTACTS_ERROR_NOT_SUPPORTED"; + case CONTACTS_ERROR_NO_DATA: + return "CONTACTS_ERROR_NO_DATA"; + case CONTACTS_ERROR_DB_LOCKED: + return "CONTACTS_ERROR_DB_LOCKED"; + case CONTACTS_ERROR_DB: + return "CONTACTS_ERROR_DB"; + case CONTACTS_ERROR_IPC_NOT_AVALIABLE: + return "CONTACTS_ERROR_IPC_NOT_AVALIABLE"; + case CONTACTS_ERROR_IPC: + return "CONTACTS_ERROR_IPC"; + case CONTACTS_ERROR_SYSTEM: + return "CONTACTS_ERROR_SYSTEM"; + case CONTACTS_ERROR_INTERNAL: + return "CONTACTS_ERROR_INTERNAL"; + } + + return "Unknown error"; + } + + template <> + std::shared_ptr> ContactManager::search(const std::string &keyword) + { + contacts_query_h query = nullptr; + contacts_filter_h filter = nullptr; + contacts_list_h list = nullptr; + + contacts_query_create(_contacts_person_phone_log._uri, &query); + contacts_filter_create(_contacts_person_phone_log._uri, &filter); + contacts_filter_add_str(filter, _contacts_person_phone_log.address, CONTACTS_MATCH_CONTAINS, keyword.c_str()); + contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND); + contacts_filter_add_int(filter, _contacts_person_phone_log.person_id, CONTACTS_MATCH_NONE, 0); + contacts_query_set_filter(query, filter); + + /* set projection */ + unsigned int numberProjection[] = { + _contacts_person_phone_log.person_id, + _contacts_person_phone_log.address, + _contacts_person_phone_log.display_name + }; + + contacts_query_set_projection(query, numberProjection, sizeof(numberProjection)/sizeof(unsigned int)); + contacts_query_set_distinct(query, true); + + contacts_db_get_records_with_query(query, 0, 0, &list); + contacts_filter_destroy(filter); + contacts_query_destroy(query); + + return list ? std::make_shared>(list) : nullptr; + } + + template<> + std::shared_ptr> ContactManager::search(const std::string &keyword) + { + contacts_list_h list = nullptr; + contacts_db_search_records_with_range(ContactPersonNumber::getUri(), keyword.c_str(), + 0, 0, CONTACTS_SEARCH_RANGE_NAME | CONTACTS_SEARCH_RANGE_NUMBER, &list); + return list ? std::make_shared>(list) : nullptr; + } + + template<> + std::shared_ptr> ContactManager::search(const std::string &keyword) + { + contacts_list_h list = nullptr; + contacts_db_search_records_with_range(ContactPersonEmail::getUri(), keyword.c_str(), + 0, 0, CONTACTS_SEARCH_RANGE_NAME | CONTACTS_SEARCH_RANGE_EMAIL, &list); + return list ? std::make_shared>(list) : nullptr; + } + + ContactPersonNumberRef ContactManager::getContactPersonNumber(int phoneNumId) + { + contacts_filter_h filter = nullptr; + contacts_filter_create(_contacts_contact_number._uri, &filter); + contacts_filter_add_int(filter, _contacts_person_number.number_id, CONTACTS_MATCH_EQUAL, phoneNumId); + return filter ? getContactPersonNumber(filter) : nullptr; + } + + ContactPersonEmailRef ContactManager::getContactPersonEmail(int emailId) + { + contacts_filter_h filter = nullptr; + contacts_filter_create(_contacts_contact_email._uri, &filter); + contacts_filter_add_int(filter, _contacts_person_email.email_id, CONTACTS_MATCH_EQUAL, emailId); + return filter ? getContactPersonEmail(filter) : nullptr; + } + + ContactPersonNumberRef ContactManager::getContactPersonNumber(const std::string &number) + { + contacts_filter_h filter = nullptr; + contacts_filter_create(_contacts_contact_number._uri, &filter); + contacts_filter_add_str(filter, _contacts_person_number.number_filter, CONTACTS_MATCH_EXACTLY, number.c_str()); + return filter ? getContactPersonNumber(filter) : nullptr; + } + + ContactPersonEmailRef ContactManager::getContactPersonEmail(const std::string &email) + { + contacts_filter_h filter = nullptr; + contacts_filter_create(_contacts_person_email._uri, &filter); + contacts_filter_add_str(filter, _contacts_person_email.email, CONTACTS_MATCH_EXACTLY, email.c_str()); + return filter ? getContactPersonEmail(filter) : nullptr; + } + + ContactMyProfileNumberRef ContactManager::getContactMyProfileNumber(const std::string &number) + { + auto myProfile = getOwnerProfile(); + if (!myProfile) + return nullptr; + + contacts_record_h rec = myProfile->getRecord(); + + int count = 0; + contacts_record_get_child_record_count(rec, _contacts_my_profile.number, &count); + std::string normalizedNumber = PhoneNumberUtils::getInst().getNormalizedNumber(number); + + for (int i =0; i < count; ++i) { + contacts_record_h child = nullptr; + contacts_record_get_child_record_at_p(rec, _contacts_my_profile.number, i, &child); + if (child) { + char *num = nullptr; + contacts_record_get_str_p(child, _contacts_number.number, &num); + if (num) { + std::string curNum = PhoneNumberUtils::getInst().getNormalizedNumber(num); + if (normalizedNumber == curNum) { + contacts_record_h clonedRec = nullptr; + contacts_record_clone(child, &clonedRec); + if (clonedRec) + return std::make_shared(true, *myProfile, clonedRec); + } + } + } + } + return nullptr; + } + + ContactMyProfileEmailRef ContactManager::getContactMyProfileEmail(const std::string &email) + { + auto myProfile = getOwnerProfile(); + if (!myProfile) + return nullptr; + + contacts_record_h rec = myProfile->getRecord(); + + int count = 0; + contacts_record_get_child_record_count(rec, _contacts_my_profile.email, &count); + + for (int i =0; i < count; ++i) { + contacts_record_h child = nullptr; + contacts_record_get_child_record_at_p(rec, _contacts_my_profile.email, i, &child); + if (child) { + char *curEmail = nullptr; + contacts_record_get_str_p(child, _contacts_email.email, &curEmail); + if (curEmail) { + if (strcasecmp(email.c_str(), curEmail) == 0) { + contacts_record_h clonedRec = nullptr; + contacts_record_clone(child, &clonedRec); + if (clonedRec) + return std::make_shared(true, *myProfile, clonedRec); + } + } + } + } + return nullptr; + } + + ContactAddressRef ContactManager::getContactAddress(const std::string &address) + { + return getAddress(address); + } + + ContactMyProfileRef ContactManager::getOwnerProfile() + { + if (!m_OwnerProfile) + { + contacts_list_h list = nullptr; + contacts_record_h myProfile = nullptr; + contacts_db_get_all_records(_contacts_my_profile._uri, 0, 1, &list); + if (list) + { + contacts_list_get_current_record_p(list, &myProfile); + contacts_list_destroy(list, false); + } + if (myProfile) + m_OwnerProfile.reset(new ContactMyProfile(true, myProfile)); + } + return m_OwnerProfile; + } + + void ContactManager::contactChangedCb(const char *view_uri, void *user_data) + { + ContactManager *self = static_cast(user_data); + self->invalidateCache(); + for (auto listener : self->m_Listeners) + listener->onContactChanged(); + } + + void ContactManager::contactDisplayOrderChangedCb(contacts_name_display_order_e name_display_order, void *user_data) + { + ContactManager *self = static_cast(user_data); + self->invalidateCache(); + for (auto listener : self->m_Listeners) + listener->onContactChanged(); + } + + void ContactManager::addListener(IContactManagerListener &listener) + { + auto found = std::find(m_Listeners.begin(), m_Listeners.end(), &listener); + if (found == m_Listeners.end()) + m_Listeners.push_back(&listener); + } + + void ContactManager::removeListener(IContactManagerListener &listener) + { + auto found = std::find(m_Listeners.begin(), m_Listeners.end(), &listener); + if (found != m_Listeners.end()) + m_Listeners.erase(found); + } + + ContactPersonNumberRef ContactManager::getContactPersonNumber(contacts_filter_h filter) + { + contacts_query_h query = nullptr; + contacts_list_h list = nullptr; + contacts_record_h crValue = nullptr; + contacts_record_h cResValue = nullptr; + + contacts_query_create(_contacts_person_number._uri, &query); + contacts_query_set_filter(query, filter); + + unsigned int numberProjection[] = + { + _contacts_person_number.person_id, + _contacts_person_number.number, + _contacts_person_number.display_name, + _contacts_person_number.image_thumbnail_path + }; + + int ctRrr = contacts_query_set_projection(query, numberProjection, sizeof(numberProjection) / sizeof(unsigned int)); + if (ctRrr == CONTACTS_ERROR_NONE) + ctRrr = contacts_db_get_records_with_query(query, 0, 0, &list); + + contacts_filter_destroy(filter); + contacts_query_destroy(query); + + while (ctRrr == CONTACTS_ERROR_NONE) { + int contactId = 0; + + contacts_list_get_current_record_p(list, &crValue); + if (crValue) { + contacts_record_get_int(crValue, _contacts_person_number.person_id, &contactId); + if (contactId > 0) + cResValue = crValue; + else + contacts_record_destroy(crValue, true); + } + ctRrr = contacts_list_next(list); + } + + contacts_list_destroy(list, false); + return cResValue ? std::make_shared(true, cResValue) : nullptr; + } + + ContactPersonEmailRef ContactManager::getContactPersonEmail(contacts_filter_h filter) + { + contacts_query_h query = nullptr; + contacts_list_h list = nullptr; + contacts_record_h crValue = nullptr; + contacts_record_h cResValue = nullptr; + + contacts_query_create(_contacts_person_email._uri, &query); + contacts_query_set_filter(query, filter); + + unsigned int numberProjection[] = + { + _contacts_person_email.person_id, + _contacts_person_email.email, + _contacts_person_email.display_name, + _contacts_person_email.image_thumbnail_path + }; + + int ctRrr = contacts_query_set_projection(query, numberProjection, sizeof(numberProjection) / sizeof(unsigned int)); + if (ctRrr == CONTACTS_ERROR_NONE) + ctRrr = contacts_db_get_records_with_query(query, 0, 0, &list); + + contacts_filter_destroy(filter); + contacts_query_destroy(query); + + while (ctRrr == CONTACTS_ERROR_NONE) { + int contactId = 0; + + contacts_list_get_current_record_p(list, &crValue); + if (crValue) { + contacts_record_get_int(crValue, _contacts_person_email.person_id, &contactId); + if (contactId > 0) + cResValue = crValue; + else + contacts_record_destroy(crValue, true); + } + ctRrr = contacts_list_next(list); + } + + contacts_list_destroy(list, false); + return cResValue ? std::make_shared(true, cResValue) : nullptr; + } + + ContactAddressRef ContactManager::getAddress(const std::string &address) + { + auto it = m_AddressMap.find(address); + if (m_AddressMap.end() == it) { + bool isNumber = MsgUtils::isValidNumber(address); + + // ContactPerson: + ContactAddressRef contactAddress; + if (isNumber) + contactAddress = getContactPersonNumber(address); + else + contactAddress = getContactPersonEmail(address); + + // MyProfile: + #if (0) + if (!contactAddress) { + if (isNumber) + contactAddress = getContactMyProfileNumber(address); + else + contactAddress = getContactMyProfileEmail(address); + } + #endif + + m_AddressMap[address] = contactAddress; + return contactAddress; + } + return it->second; + } + + void ContactManager::invalidateCache() + { + MSG_LOG(""); + m_AddressMap.clear(); + m_OwnerProfile.reset(); + } } diff --git a/src/Common/ContactManager/src/ContactRecord.cpp b/src/Common/ContactManager/src/ContactRecord.cpp index ee35b39f..a582d3d4 100644 --- a/src/Common/ContactManager/src/ContactRecord.cpp +++ b/src/Common/ContactManager/src/ContactRecord.cpp @@ -19,15 +19,15 @@ using namespace Msg; ContactRecord::ContactRecord(bool release, contacts_record_h record) - : m_Record(record) - , m_Release(release) + : m_Record(record) + , m_Release(release) { } ContactRecord::~ContactRecord() { - if (m_Record && m_Release) { - contacts_record_destroy(m_Record, true); - m_Record = nullptr; - } + if (m_Record && m_Release) { + contacts_record_destroy(m_Record, true); + m_Record = nullptr; + } } diff --git a/src/Common/ContactManager/src/ContactVCardGenerator.cpp b/src/Common/ContactManager/src/ContactVCardGenerator.cpp index d07ed358..a42dba68 100644 --- a/src/Common/ContactManager/src/ContactVCardGenerator.cpp +++ b/src/Common/ContactManager/src/ContactVCardGenerator.cpp @@ -24,65 +24,65 @@ using namespace Msg; namespace { - const int avgLengthOfContent = 2048; + const int avgLengthOfContent = 2048; } std::string ContactManager::makeVcard(const int personId, bool myProfile) { - contacts_record_h record = nullptr; - std::string vcardContent; + contacts_record_h record = nullptr; + std::string vcardContent; - if (contacts_db_get_record((myProfile ? _contacts_my_profile._uri : _contacts_person._uri), personId, &record) != CONTACTS_ERROR_NONE) { - MSG_LOG_ERROR("contacts_db_get_record() failed"); - record = nullptr; - return std::string(); - } - vcardContent = createContactContent(record, myProfile); + if (contacts_db_get_record((myProfile ? _contacts_my_profile._uri : _contacts_person._uri), personId, &record) != CONTACTS_ERROR_NONE) { + MSG_LOG_ERROR("contacts_db_get_record() failed"); + record = nullptr; + return std::string(); + } + vcardContent = createContactContent(record, myProfile); - if (record) - contacts_record_destroy(record, true); + if (record) + contacts_record_destroy(record, true); - return vcardContent; + return vcardContent; } std::string ContactManager::makeVcard(const std::list &idList) { - std::string vcardContent; - vcardContent.reserve(idList.size() * avgLengthOfContent); - for (auto it : idList) - vcardContent += createContentForContactList(it); + std::string vcardContent; + vcardContent.reserve(idList.size() * avgLengthOfContent); + for (auto it : idList) + vcardContent += createContentForContactList(it); - return vcardContent; + return vcardContent; } std::string ContactManager::createContactContent(contacts_record_h record, bool myProfile) { - char *vcardBuff = nullptr; + char *vcardBuff = nullptr; - myProfile ? contacts_vcard_make_from_my_profile(record, &vcardBuff) : contacts_vcard_make_from_person(record, &vcardBuff); + myProfile ? contacts_vcard_make_from_my_profile(record, &vcardBuff) : contacts_vcard_make_from_person(record, &vcardBuff); - if (!vcardBuff) { - MSG_LOG_ERROR("vcardBuff is NULL"); - return std::string(); - } + if (!vcardBuff) { + MSG_LOG_ERROR("vcardBuff is NULL"); + return std::string(); + } - std::string result(vcardBuff); - free(vcardBuff); - return result; + std::string result(vcardBuff); + free(vcardBuff); + return result; } std::string ContactManager::createContentForContactList(int personId) { - contacts_record_h record = nullptr; - if (contacts_db_get_record(_contacts_person._uri, personId, &record) != CONTACTS_ERROR_NONE) { - MSG_LOG_ERROR("contacts_db_get_record() failed!"); - record = nullptr; - return std::string(); - } - std::string result = createContactContent(record, false); - - if (record) - contacts_record_destroy(record, true); - - return result; + contacts_record_h record = nullptr; + if (contacts_db_get_record(_contacts_person._uri, personId, &record) != CONTACTS_ERROR_NONE) { + MSG_LOG_ERROR("contacts_db_get_record() failed!"); + record = nullptr; + return std::string(); + } + std::string result = createContactContent(record, false); + + if (record) + contacts_record_destroy(record, true); + + return result; } diff --git a/src/Common/ContactManager/src/ContactVCardParser.cpp b/src/Common/ContactManager/src/ContactVCardParser.cpp index 370d0530..50f673a3 100644 --- a/src/Common/ContactManager/src/ContactVCardParser.cpp +++ b/src/Common/ContactManager/src/ContactVCardParser.cpp @@ -27,25 +27,25 @@ using namespace Msg; std::list ContactManager::parseVcard(const std::string &filePath) { - std::list res; + std::list res; - if (filePath.empty()) - return res; + if (filePath.empty()) + return res; - int parseRes = contacts_vcard_parse_to_contact_foreach - ( - filePath.c_str(), - [](contacts_record_h record, void *user_data)->bool - { - contacts_record_h recordClone = {}; - contacts_record_clone(record, &recordClone); - auto *list = (std::list*)user_data; - auto recRef = std::make_shared(true, recordClone); - list->emplace_back(recRef); - return true; - }, - &res); + int parseRes = contacts_vcard_parse_to_contact_foreach + ( + filePath.c_str(), + [](contacts_record_h record, void *user_data)->bool + { + contacts_record_h recordClone = {}; + contacts_record_clone(record, &recordClone); + auto *list = (std::list*)user_data; + auto recRef = std::make_shared(true, recordClone); + list->emplace_back(recRef); + return true; + }, + &res); - MSG_LOG("Parse result: ", parseRes); - return res; + MSG_LOG("Parse result: ", parseRes); + return res; } diff --git a/src/Common/Controller/inc/App.h b/src/Common/Controller/inc/App.h index 3ddae32f..3c4d487f 100644 --- a/src/Common/Controller/inc/App.h +++ b/src/Common/Controller/inc/App.h @@ -26,64 +26,64 @@ #include namespace Msg { - class MsgEngine; - class ContactManager; - class IAppListener; - - class App { - public: - App(); - virtual ~App(); - - virtual Window &getWindow() = 0; - virtual const Window &getWindow() const = 0; - - PopupManager &getPopupManager(); - const PopupManager &getPopupManager() const; - - MsgEngine &getMsgEngine(); - const MsgEngine &getMsgEngine() const; - - ContactManager &getContactManager(); - const ContactManager &getContactManager() const; - - ThumbnailMaker &getThumbnailMaker(); - const ThumbnailMaker &getThumbnailMaker() const; - - SystemSettingsManager &getSysSettingsManager(); - const SystemSettingsManager &getSysSettingsManager() const; - - void exit(); - void addListener(IAppListener &l); - void removeListener(IAppListener &l); - bool isPause() const; - - void updateActiveNotifPolicy(); - - protected: - bool init(); - void pause(); - void resume(); - - private: - virtual void terminate() = 0; - - private: - MsgEngine m_Engine; - ContactManager *m_pContactManager; - PopupManager *m_pPopupManager; - ThumbnailMaker *m_pThumbnailMaker; - SystemSettingsManager *m_pSysSettingsManager; - std::list m_Listeners; - bool m_IsPause; - }; - - class IAppListener { - public: - virtual ~IAppListener() {} - virtual void onAppPause() {}; - virtual void onAppResume() {}; - }; + class MsgEngine; + class ContactManager; + class IAppListener; + + class App { + public: + App(); + virtual ~App(); + + virtual Window &getWindow() = 0; + virtual const Window &getWindow() const = 0; + + PopupManager &getPopupManager(); + const PopupManager &getPopupManager() const; + + MsgEngine &getMsgEngine(); + const MsgEngine &getMsgEngine() const; + + ContactManager &getContactManager(); + const ContactManager &getContactManager() const; + + ThumbnailMaker &getThumbnailMaker(); + const ThumbnailMaker &getThumbnailMaker() const; + + SystemSettingsManager &getSysSettingsManager(); + const SystemSettingsManager &getSysSettingsManager() const; + + void exit(); + void addListener(IAppListener &l); + void removeListener(IAppListener &l); + bool isPause() const; + + void updateActiveNotifPolicy(); + + protected: + bool init(); + void pause(); + void resume(); + + private: + virtual void terminate() = 0; + + private: + MsgEngine m_Engine; + ContactManager *m_pContactManager; + PopupManager *m_pPopupManager; + ThumbnailMaker *m_pThumbnailMaker; + SystemSettingsManager *m_pSysSettingsManager; + std::list m_Listeners; + bool m_IsPause; + }; + + class IAppListener { + public: + virtual ~IAppListener() {} + virtual void onAppPause() {}; + virtual void onAppResume() {}; + }; } #endif /* Application_h_ */ diff --git a/src/Common/Controller/inc/BaseController.h b/src/Common/Controller/inc/BaseController.h index f245a9b8..7837cd63 100644 --- a/src/Common/Controller/inc/BaseController.h +++ b/src/Common/Controller/inc/BaseController.h @@ -20,43 +20,43 @@ #include "BaseView.h" namespace Msg { - class App; - class MsgEngine; - - class BaseController { - public: - BaseController(App &app); - BaseController(BaseController *parent); - virtual ~BaseController(); - - virtual BaseController &getParent(); - inline App &getApp(); - inline const App &getApp() const; - MsgEngine &getMsgEngine(); - const MsgEngine &getMsgEngine() const; - - protected: - virtual void onPause(); - virtual void onResume(); - - private: - BaseController(const BaseController&) = delete; - BaseController& operator=(BaseController&) = delete; - - private: - App &m_App; - BaseController *m_pParent; - }; - - inline App &BaseController::getApp() - { - return m_App; - } - - inline const App &BaseController::getApp() const - { - return m_App; - } + class App; + class MsgEngine; + + class BaseController { + public: + BaseController(App &app); + BaseController(BaseController *parent); + virtual ~BaseController(); + + virtual BaseController &getParent(); + inline App &getApp(); + inline const App &getApp() const; + MsgEngine &getMsgEngine(); + const MsgEngine &getMsgEngine() const; + + protected: + virtual void onPause(); + virtual void onResume(); + + private: + BaseController(const BaseController&) = delete; + BaseController& operator=(BaseController&) = delete; + + private: + App &m_App; + BaseController *m_pParent; + }; + + inline App &BaseController::getApp() + { + return m_App; + } + + inline const App &BaseController::getApp() const + { + return m_App; + } } #endif /* BaseController_h_ */ diff --git a/src/Common/Controller/inc/FrameController.h b/src/Common/Controller/inc/FrameController.h index 926db51c..f5e0de01 100644 --- a/src/Common/Controller/inc/FrameController.h +++ b/src/Common/Controller/inc/FrameController.h @@ -23,33 +23,33 @@ #include "MsgAddress.h" namespace Msg { - class NaviFrameController; + class NaviFrameController; - class FrameController - : public ViewItemController - , public NaviFrameItem { - public: - FrameController(NaviFrameController &parent); - virtual ~FrameController(); + class FrameController + : public ViewItemController + , public NaviFrameItem { + public: + FrameController(NaviFrameController &parent); + virtual ~FrameController(); - virtual NaviFrameController &getParent(); - void pop(); + virtual NaviFrameController &getParent(); + void pop(); - void pause(); - void resume(); - bool isPause() const; + void pause(); + void resume(); + bool isPause() const; - protected: - void setNaviBarTitle(const MsgAddressList &addressList); + protected: + void setNaviBarTitle(const MsgAddressList &addressList); - // NaviFrameItem - virtual void onAttached(ViewItem &item); - virtual void onPause() {}; - virtual void onResume() {}; + // NaviFrameItem + virtual void onAttached(ViewItem &item); + virtual void onPause() {}; + virtual void onResume() {}; - private: - bool m_IsPause; - }; + private: + bool m_IsPause; + }; } #endif /* FrameController */ diff --git a/src/Common/Controller/inc/MbeRecipients.h b/src/Common/Controller/inc/MbeRecipients.h index 8746ff94..d6c7ebe2 100644 --- a/src/Common/Controller/inc/MbeRecipients.h +++ b/src/Common/Controller/inc/MbeRecipients.h @@ -24,46 +24,46 @@ #include "App.h" namespace Msg { - class MbeRecipients - : public MbeRecipientsView - , private IContactManagerListener { - public: - enum AppendItemStatus { - SuccessStatus, - DuplicatedStatus, - InvalidRecipStatus, - InvalidSomeRecipStatus, - InvalidAllRecipStatus, - TooManyRecipStatus - }; + class MbeRecipients + : public MbeRecipientsView + , private IContactManagerListener { + public: + enum AppendItemStatus { + SuccessStatus, + DuplicatedStatus, + InvalidRecipStatus, + InvalidSomeRecipStatus, + InvalidAllRecipStatus, + TooManyRecipStatus + }; - public: - MbeRecipients(Evas_Object *parent, App &app); - virtual ~MbeRecipients(); + public: + MbeRecipients(Evas_Object *parent, App &app); + virtual ~MbeRecipients(); - void update(ThreadId threadId); - void update(const MsgAddressList &addressList); - AppendItemStatus appendItem(const std::string &address, MsgAddress::AddressType addressType = MsgAddress::UnknownAddressType); - AppendItemStatus appendItem(const std::string &address, const std::string &dispName, - MsgAddress::AddressType addressType = MsgAddress::UnknownAddressType); + void update(ThreadId threadId); + void update(const MsgAddressList &addressList); + AppendItemStatus appendItem(const std::string &address, MsgAddress::AddressType addressType = MsgAddress::UnknownAddressType); + AppendItemStatus appendItem(const std::string &address, const std::string &dispName, + MsgAddress::AddressType addressType = MsgAddress::UnknownAddressType); - private: - // IContactManagerListener: - virtual void onContactChanged(); + private: + // IContactManagerListener: + virtual void onContactChanged(); - private: - void updateItemsDispName(); - std::string getDispName(const std::string &address) const; - bool isRecipientExists(const std::string& address) const; - void showRecipPopup(const std::string &title); + private: + void updateItemsDispName(); + std::string getDispName(const std::string &address) const; + bool isRecipientExists(const std::string& address) const; + void showRecipPopup(const std::string &title); - void onMakeVoiceItemPressed(PopupListItem &item); - void onCreateContactItemPressed(PopupListItem &item); - void onUpdateContactItemPressed(PopupListItem &item); + void onMakeVoiceItemPressed(PopupListItem &item); + void onCreateContactItemPressed(PopupListItem &item); + void onUpdateContactItemPressed(PopupListItem &item); - private: - App &m_App; - }; + private: + App &m_App; + }; } #endif /* MbeRecipients_h_ */ diff --git a/src/Common/Controller/inc/NaviFrameController.h b/src/Common/Controller/inc/NaviFrameController.h index 6556c818..f1ab2a85 100644 --- a/src/Common/Controller/inc/NaviFrameController.h +++ b/src/Common/Controller/inc/NaviFrameController.h @@ -26,64 +26,64 @@ #include "App.h" namespace Msg { - class FrameController; + class FrameController; - class NaviFrameController - : public ViewController - , public NaviFrameView - , private IHwButtonListener - , private IAppListener { - public: - NaviFrameController(App &app); - virtual ~NaviFrameController(); + class NaviFrameController + : public ViewController + , public NaviFrameView + , private IHwButtonListener + , private IAppListener { + public: + NaviFrameController(App &app); + virtual ~NaviFrameController(); - /** - * @brief Pops last frame. Exit from app if frame count reaches zero. - * @param[in] frame FrameController for pop - */ - void pop(FrameController &frame); - using NaviFrameView::pop; + /** + * @brief Pops last frame. Exit from app if frame count reaches zero. + * @param[in] frame FrameController for pop + */ + void pop(FrameController &frame); + using NaviFrameView::pop; - /** - * @brief Executes app control command of default type. - */ - void execCmd(const AppControlDefaultRef &cmd); + /** + * @brief Executes app control command of default type. + */ + void execCmd(const AppControlDefaultRef &cmd); - /** - * @brief Executes app control command of compose type. This is Compose, Share, MultiShare, ShareText. - */ - void execCmd(const AppControlComposeRef &cmd); + /** + * @brief Executes app control command of compose type. This is Compose, Share, MultiShare, ShareText. + */ + void execCmd(const AppControlComposeRef &cmd); - /** - * @brief Destroys naviframe. Note, than this doesn't close app. - */ - void destroy(); + /** + * @brief Destroys naviframe. Note, than this doesn't close app. + */ + void destroy(); - private: - template - T *getTopFrame() const; - FrameController *getTopFrame() const; - bool prepare(const AppControlCommand &cmd); - void registerHWButtonEvent(); + private: + template + T *getTopFrame() const; + FrameController *getTopFrame() const; + bool prepare(const AppControlCommand &cmd); + void registerHWButtonEvent(); - bool isUnreadNotificationSingle(AppControlDefault::DefaultType type) const; + bool isUnreadNotificationSingle(AppControlDefault::DefaultType type) const; - // H/W buttons: - virtual void onHwBackButtonClicked(); - virtual void onHwMoreButtonClicked(); + // H/W buttons: + virtual void onHwBackButtonClicked(); + virtual void onHwMoreButtonClicked(); - // NaviFrameView: - virtual void onPause(NaviFrameItem &item); - virtual void onResume(NaviFrameItem &item); - virtual void onBeforeDelete(View &view); + // NaviFrameView: + virtual void onPause(NaviFrameItem &item); + virtual void onResume(NaviFrameItem &item); + virtual void onBeforeDelete(View &view); - // App: - virtual void onAppPause(); - virtual void onAppResume(); + // App: + virtual void onAppPause(); + virtual void onAppResume(); - using BaseController::onPause; - using BaseController::onResume; - }; + using BaseController::onPause; + using BaseController::onResume; + }; } #endif /* NaviFrameController_h_ */ diff --git a/src/Common/Controller/inc/SaveAttachments.h b/src/Common/Controller/inc/SaveAttachments.h index 8d98fa91..db52fd7f 100644 --- a/src/Common/Controller/inc/SaveAttachments.h +++ b/src/Common/Controller/inc/SaveAttachments.h @@ -24,46 +24,46 @@ #include "MsgStorage.h" namespace Msg { - class SaveAttachments - : public FrameController - , private IHwButtonListener - , private IListViewListener { - public: - SaveAttachments(NaviFrameController &parent, MsgId id); - virtual ~SaveAttachments(); + class SaveAttachments + : public FrameController + , private IHwButtonListener + , private IListViewListener { + public: + SaveAttachments(NaviFrameController &parent, MsgId id); + virtual ~SaveAttachments(); - private: - void create(); - void createList(); - void fillList(); - void appendItem(const std::string &text, const std::string &path, PopupListItemPressedCb cb, void *userData); + private: + void create(); + void createList(); + void fillList(); + void appendItem(const std::string &text, const std::string &path, PopupListItemPressedCb cb, void *userData); - void updateSelectItemsTitle(); - void showSelectAllItem(); + void updateSelectItemsTitle(); + void showSelectAllItem(); - // NaviFrameItem: - virtual void onButtonClicked(NaviFrameItem &item, NaviButtonId buttonId); - virtual void onAttached(ViewItem &item); + // NaviFrameItem: + virtual void onButtonClicked(NaviFrameItem &item, NaviButtonId buttonId); + virtual void onAttached(ViewItem &item); - // IHwButtonListener: - virtual void onHwBackButtonClicked(); + // IHwButtonListener: + virtual void onHwBackButtonClicked(); - virtual void onListItemChecked(ListItem &listItem); - void checkSelectAllItem(SelectAllListItem &item); - void checkItem(ListItem &item); - void updateSelectAllItem(); - bool areAllItemsChecked() const; - int getAttachmentsCheckedCount() const; - bool shouldEnableSaveBtn() const; + virtual void onListItemChecked(ListItem &listItem); + void checkSelectAllItem(SelectAllListItem &item); + void checkItem(ListItem &item); + void updateSelectAllItem(); + bool areAllItemsChecked() const; + int getAttachmentsCheckedCount() const; + bool shouldEnableSaveBtn() const; - void onNaviOkButtonClicked(); - bool saveCheckedItems(); - void showSavingFailedPopup(); + void onNaviOkButtonClicked(); + bool saveCheckedItems(); + void showSavingFailedPopup(); - private: - ListView *m_pList; - MsgId m_Id; - }; + private: + ListView *m_pList; + MsgId m_Id; + }; } #endif /* SaveAttachments_h_h */ diff --git a/src/Common/Controller/inc/SaveAttachmentsListItem.h b/src/Common/Controller/inc/SaveAttachmentsListItem.h index 19d4df7d..e1346c59 100644 --- a/src/Common/Controller/inc/SaveAttachmentsListItem.h +++ b/src/Common/Controller/inc/SaveAttachmentsListItem.h @@ -21,22 +21,22 @@ #include namespace Msg { - class SaveAttachmentsListItem - : public ListItem { - public: - SaveAttachmentsListItem(const std::string &text, const std::string &path); - virtual ~SaveAttachmentsListItem(); + class SaveAttachmentsListItem + : public ListItem { + public: + SaveAttachmentsListItem(const std::string &text, const std::string &path); + virtual ~SaveAttachmentsListItem(); - const std::string &getFilePath() const; + const std::string &getFilePath() const; - private: - virtual const char *getCheckPart(ListItem &item); - virtual std::string getText(ListItem &item, const char *part); + private: + virtual const char *getCheckPart(ListItem &item); + virtual std::string getText(ListItem &item, const char *part); - private: - std::string m_FileName; - std::string m_FilePath; - }; + private: + std::string m_FileName; + std::string m_FilePath; + }; } #endif // SaveAttachmentsListItem_h_ diff --git a/src/Common/Controller/inc/ViewController.h b/src/Common/Controller/inc/ViewController.h index c1eb5c21..9b5f66d1 100644 --- a/src/Common/Controller/inc/ViewController.h +++ b/src/Common/Controller/inc/ViewController.h @@ -21,15 +21,15 @@ #include namespace Msg { - class App; + class App; - class ViewController - : public BaseController { - public: - ViewController(App &app); - ViewController(BaseController *parent); - virtual ~ViewController(); - }; + class ViewController + : public BaseController { + public: + ViewController(App &app); + ViewController(BaseController *parent); + virtual ~ViewController(); + }; } #endif /* ViewController_h_ */ diff --git a/src/Common/Controller/inc/ViewItemController.h b/src/Common/Controller/inc/ViewItemController.h index 05eedcbf..9e5b2517 100644 --- a/src/Common/Controller/inc/ViewItemController.h +++ b/src/Common/Controller/inc/ViewItemController.h @@ -21,15 +21,15 @@ #include "ViewItem.h" namespace Msg { - class App; + class App; - class ViewItemController - : public BaseController { - public: - ViewItemController(App &app); - ViewItemController(BaseController *parent); - virtual ~ViewItemController(); - }; + class ViewItemController + : public BaseController { + public: + ViewItemController(App &app); + ViewItemController(BaseController *parent); + virtual ~ViewItemController(); + }; } #endif /* ViewItemController_h_ */ diff --git a/src/Common/Controller/src/App.cpp b/src/Common/Controller/src/App.cpp index 3cde9267..b53cedc7 100644 --- a/src/Common/Controller/src/App.cpp +++ b/src/Common/Controller/src/App.cpp @@ -27,157 +27,157 @@ using namespace Msg; App::App() - : m_pContactManager(nullptr) - , m_pPopupManager(nullptr) - , m_pThumbnailMaker(nullptr) - , m_pSysSettingsManager(nullptr) - , m_IsPause(true) + : m_pContactManager(nullptr) + , m_pPopupManager(nullptr) + , m_pThumbnailMaker(nullptr) + , m_pSysSettingsManager(nullptr) + , m_IsPause(true) { - int serviceResult = m_Engine.openService(); - if (serviceResult != MESSAGES_ERROR_NONE) { - MSG_ENGINE_WHAT_ERROR(serviceResult); - MSG_LOG_ERROR("Service handle open error = ", serviceResult); - } + int serviceResult = m_Engine.openService(); + if (serviceResult != MESSAGES_ERROR_NONE) { + MSG_ENGINE_WHAT_ERROR(serviceResult); + MSG_LOG_ERROR("Service handle open error = ", serviceResult); + } } App::~App() { - delete m_pThumbnailMaker; - delete m_pContactManager; - delete m_pPopupManager; - delete m_pSysSettingsManager; + delete m_pThumbnailMaker; + delete m_pContactManager; + delete m_pPopupManager; + delete m_pSysSettingsManager; } bool App::init() { - getSysSettingsManager(); - getContactManager(); - getMsgEngine(); - getThumbnailMaker(); + getSysSettingsManager(); + getContactManager(); + getMsgEngine(); + getThumbnailMaker(); - std::string imagesPath = PathUtils::getResourcePath(IMAGES_EDJ_PATH); - elm_theme_extension_add(nullptr, imagesPath.c_str()); + std::string imagesPath = PathUtils::getResourcePath(IMAGES_EDJ_PATH); + elm_theme_extension_add(nullptr, imagesPath.c_str()); - std::string convGenlistThemePath = PathUtils::getResourcePath(CONV_GENLIST_THEME_EDJ_PATH); - elm_theme_extension_add(nullptr, convGenlistThemePath.c_str()); + std::string convGenlistThemePath = PathUtils::getResourcePath(CONV_GENLIST_THEME_EDJ_PATH); + elm_theme_extension_add(nullptr, convGenlistThemePath.c_str()); - std::string buttonThemePath = PathUtils::getResourcePath(BUTTON_THEME_EDJ_PATH); - elm_theme_extension_add(nullptr, buttonThemePath.c_str()); + std::string buttonThemePath = PathUtils::getResourcePath(BUTTON_THEME_EDJ_PATH); + elm_theme_extension_add(nullptr, buttonThemePath.c_str()); - std::string threadThemePath = PathUtils::getResourcePath(THREAD_THEME_EDJ_PATH); - elm_theme_extension_add(nullptr, threadThemePath.c_str()); + std::string threadThemePath = PathUtils::getResourcePath(THREAD_THEME_EDJ_PATH); + elm_theme_extension_add(nullptr, threadThemePath.c_str()); - std::string convLabelThemePath = PathUtils::getResourcePath(CONV_LABEL_THEME_EDJ_PATH); - elm_theme_extension_add(nullptr, convLabelThemePath.c_str()); + std::string convLabelThemePath = PathUtils::getResourcePath(CONV_LABEL_THEME_EDJ_PATH); + elm_theme_extension_add(nullptr, convLabelThemePath.c_str()); - return true; + return true; } MsgEngine &App::getMsgEngine() { - return m_Engine; + return m_Engine; } const MsgEngine &App::getMsgEngine() const { - return m_Engine; + return m_Engine; } ContactManager &App::getContactManager() { - if (!m_pContactManager) - m_pContactManager = new ContactManager; - return *m_pContactManager; + if (!m_pContactManager) + m_pContactManager = new ContactManager; + return *m_pContactManager; } const ContactManager &App::getContactManager() const { - return const_cast(this)->getContactManager(); + return const_cast(this)->getContactManager(); } PopupManager &App::getPopupManager() { - if (!m_pPopupManager) - m_pPopupManager = new PopupManager(getWindow()); - return *m_pPopupManager; + if (!m_pPopupManager) + m_pPopupManager = new PopupManager(getWindow()); + return *m_pPopupManager; } const PopupManager &App::getPopupManager() const { - return const_cast(this)->getPopupManager(); + return const_cast(this)->getPopupManager(); } ThumbnailMaker &App::getThumbnailMaker() { - if (!m_pThumbnailMaker) - m_pThumbnailMaker = new ThumbnailMaker(*this); - return *m_pThumbnailMaker; + if (!m_pThumbnailMaker) + m_pThumbnailMaker = new ThumbnailMaker(*this); + return *m_pThumbnailMaker; } const ThumbnailMaker &App::getThumbnailMaker() const { - return const_cast(this)->getThumbnailMaker(); + return const_cast(this)->getThumbnailMaker(); } SystemSettingsManager &App::getSysSettingsManager() { - if (!m_pSysSettingsManager) - m_pSysSettingsManager = new SystemSettingsManager; - return *m_pSysSettingsManager; + if (!m_pSysSettingsManager) + m_pSysSettingsManager = new SystemSettingsManager; + return *m_pSysSettingsManager; } const SystemSettingsManager &App::getSysSettingsManager() const { - return const_cast(this)->getSysSettingsManager(); + return const_cast(this)->getSysSettingsManager(); } void App::exit() { - terminate(); + terminate(); } void App::addListener(IAppListener &l) { - auto found = std::find(m_Listeners.begin(), m_Listeners.end(), &l); - if (found == m_Listeners.end()) - m_Listeners.push_back(&l); + auto found = std::find(m_Listeners.begin(), m_Listeners.end(), &l); + if (found == m_Listeners.end()) + m_Listeners.push_back(&l); } void App::removeListener(IAppListener &l) { - auto found = std::find(m_Listeners.begin(), m_Listeners.end(), &l); - if (found != m_Listeners.end()) - m_Listeners.erase(found); + auto found = std::find(m_Listeners.begin(), m_Listeners.end(), &l); + if (found != m_Listeners.end()) + m_Listeners.erase(found); } bool App::isPause() const { - return m_IsPause; + return m_IsPause; } void App::pause() { - if (!m_IsPause) { - m_IsPause = true; - for (IAppListener *l : m_Listeners) - l->onAppPause(); - updateActiveNotifPolicy(); - getPopupManager().onPause(); - } + if (!m_IsPause) { + m_IsPause = true; + for (IAppListener *l : m_Listeners) + l->onAppPause(); + updateActiveNotifPolicy(); + getPopupManager().onPause(); + } } void App::resume() { - if (m_IsPause) { - m_IsPause = false; - updateActiveNotifPolicy(); - for (IAppListener *l : m_Listeners) - l->onAppResume(); - } + if (m_IsPause) { + m_IsPause = false; + updateActiveNotifPolicy(); + for (IAppListener *l : m_Listeners) + l->onAppResume(); + } } void App::updateActiveNotifPolicy() { - MsgSettings::ActiveNotifPolicy policy = isPause() ? MsgSettings::AppBackgroundPolicy :MsgSettings::AppForegroundPolicy; - getMsgEngine().getSettings().setActiveNotifPolicy(policy); + MsgSettings::ActiveNotifPolicy policy = isPause() ? MsgSettings::AppBackgroundPolicy :MsgSettings::AppForegroundPolicy; + getMsgEngine().getSettings().setActiveNotifPolicy(policy); } diff --git a/src/Common/Controller/src/BaseController.cpp b/src/Common/Controller/src/BaseController.cpp index e91fd2af..7a302757 100644 --- a/src/Common/Controller/src/BaseController.cpp +++ b/src/Common/Controller/src/BaseController.cpp @@ -22,15 +22,15 @@ using namespace Msg; BaseController::BaseController(App &app) - : m_App(app) - , m_pParent(nullptr) + : m_App(app) + , m_pParent(nullptr) { } BaseController::BaseController(BaseController *parent) - : m_App(parent->getApp()) - , m_pParent(parent) + : m_App(parent->getApp()) + , m_pParent(parent) { } @@ -40,8 +40,8 @@ BaseController::~BaseController() BaseController &BaseController::getParent() { - MSG_ASSERT(m_pParent, "Parent is null pointer"); - return *m_pParent; + MSG_ASSERT(m_pParent, "Parent is null pointer"); + return *m_pParent; } void BaseController::onPause() @@ -54,12 +54,12 @@ void BaseController::onResume() MsgEngine &BaseController::getMsgEngine() { - return m_App.getMsgEngine(); + return m_App.getMsgEngine(); } const MsgEngine &BaseController::getMsgEngine() const { - return m_App.getMsgEngine(); + return m_App.getMsgEngine(); } diff --git a/src/Common/Controller/src/FrameController.cpp b/src/Common/Controller/src/FrameController.cpp index 2b564ffe..69fbad34 100644 --- a/src/Common/Controller/src/FrameController.cpp +++ b/src/Common/Controller/src/FrameController.cpp @@ -24,9 +24,9 @@ using namespace Msg; FrameController::FrameController(NaviFrameController &parent) - : ViewItemController(&parent) - , NaviFrameItem(parent) - , m_IsPause(true) + : ViewItemController(&parent) + , NaviFrameItem(parent) + , m_IsPause(true) { } @@ -36,58 +36,58 @@ FrameController::~FrameController() NaviFrameController &FrameController::getParent() { - return static_cast(ViewItemController::getParent()); + return static_cast(ViewItemController::getParent()); } void FrameController::onAttached(ViewItem &item) { - NaviFrameItem::onAttached(item); + NaviFrameItem::onAttached(item); } void FrameController::pop() { - getParent().pop(*this); + getParent().pop(*this); } void FrameController::setNaviBarTitle(const MsgAddressList &addressList) { - std::string title; - if (!addressList.isEmpty()) { - std::string firstAddress = addressList[0].getAddress(); - ContactAddressRef contactPersonAddress = getApp().getContactManager().getContactAddress(firstAddress); - if (contactPersonAddress) - title = contactPersonAddress->getDispName(); + std::string title; + if (!addressList.isEmpty()) { + std::string firstAddress = addressList[0].getAddress(); + ContactAddressRef contactPersonAddress = getApp().getContactManager().getContactAddress(firstAddress); + if (contactPersonAddress) + title = contactPersonAddress->getDispName(); - if (title.empty()) - title = firstAddress; + if (title.empty()) + title = firstAddress; - int hidenAddresses = addressList.getLength() - 1; - if (hidenAddresses > 0) { - title += " + " + std::to_string(hidenAddresses); - getNaviBar().showButton(NaviExpandButtonId, true); - } - } - getNaviBar().showButton(NaviCenterButtonId, true); - getNaviBar().setButtonText(NaviCenterButtonId, title); + int hidenAddresses = addressList.getLength() - 1; + if (hidenAddresses > 0) { + title += " + " + std::to_string(hidenAddresses); + getNaviBar().showButton(NaviExpandButtonId, true); + } + } + getNaviBar().showButton(NaviCenterButtonId, true); + getNaviBar().setButtonText(NaviCenterButtonId, title); } void FrameController::pause() { - if (!m_IsPause) { - m_IsPause = true; - onPause(); - } + if (!m_IsPause) { + m_IsPause = true; + onPause(); + } } void FrameController::resume() { - if (m_IsPause && !getApp().isPause()) { - m_IsPause = false; - onResume(); - } + if (m_IsPause && !getApp().isPause()) { + m_IsPause = false; + onResume(); + } } bool FrameController::isPause() const { - return m_IsPause; + return m_IsPause; } diff --git a/src/Common/Controller/src/MbeRecipients.cpp b/src/Common/Controller/src/MbeRecipients.cpp index 71f14ad3..12c407d9 100644 --- a/src/Common/Controller/src/MbeRecipients.cpp +++ b/src/Common/Controller/src/MbeRecipients.cpp @@ -22,100 +22,100 @@ using namespace Msg; MbeRecipients::MbeRecipients(Evas_Object *parent, App &app) - : MbeRecipientsView(parent) - , m_App(app) + : MbeRecipientsView(parent) + , m_App(app) { - m_App.getContactManager().addListener(*this); + m_App.getContactManager().addListener(*this); } MbeRecipients::~MbeRecipients() { - m_App.getContactManager().removeListener(*this); + m_App.getContactManager().removeListener(*this); } std::string MbeRecipients::getDispName(const std::string &address) const { - std::string dispName; - ContactAddressRef contactAddress = m_App.getContactManager().getContactAddress(address); - if (contactAddress) - dispName = contactAddress->getDispName(); - if (dispName.empty()) - dispName = address; - return dispName; + std::string dispName; + ContactAddressRef contactAddress = m_App.getContactManager().getContactAddress(address); + if (contactAddress) + dispName = contactAddress->getDispName(); + if (dispName.empty()) + dispName = address; + return dispName; } void MbeRecipients::updateItemsDispName() { - auto items = getItems(); - for (MbeRecipientItem *item: items) - item->setDispName(getDispName(item->getAddress())); + auto items = getItems(); + for (MbeRecipientItem *item: items) + item->setDispName(getDispName(item->getAddress())); } void MbeRecipients::update(const MsgAddressList &addressList) { - clear(); - int addrListLen = addressList.getLength(); - for (int i = 0; i < addrListLen; i++) { - const MsgAddress &addr = addressList.at(i); - appendItem(addr.getAddress(), addr.getAddressType()); - } + clear(); + int addrListLen = addressList.getLength(); + for (int i = 0; i < addrListLen; i++) { + const MsgAddress &addr = addressList.at(i); + appendItem(addr.getAddress(), addr.getAddressType()); + } } void MbeRecipients::update(ThreadId threadId) { - clear(); - if (threadId.isValid()) { - MsgAddressListRef addrList = m_App.getMsgEngine().getStorage().getAddressList(threadId); - if (addrList) - update(*addrList); - } + clear(); + if (threadId.isValid()) { + MsgAddressListRef addrList = m_App.getMsgEngine().getStorage().getAddressList(threadId); + if (addrList) + update(*addrList); + } } MbeRecipients::AppendItemStatus MbeRecipients::appendItem(const std::string &address, MsgAddress::AddressType addressType) { - return appendItem(address, getDispName(address), addressType); + return appendItem(address, getDispName(address), addressType); } MbeRecipients::AppendItemStatus MbeRecipients::appendItem(const std::string &address, const std::string &dispName, MsgAddress::AddressType addressType) { - if (getItemsCount() >= m_App.getMsgEngine().getSettings().getMaxRecipientCount()) - return TooManyRecipStatus; - - AppendItemStatus result = SuccessStatus; - if (!isRecipientExists(address)) { - if (addressType == MsgAddress::UnknownAddressType) - addressType = MsgUtils::getAddressType(address); - - if (addressType == MsgAddress::Phone || addressType == MsgAddress::Email) { - result = SuccessStatus; - MbeRecipientItem *item = new MbeRecipientItem(address, dispName, addressType); - MbeRecipientsView::appendItem(*item); - } else { - result = InvalidRecipStatus; - MSG_LOG("invalid recipient: ", address); - } - } else { - result = DuplicatedStatus; - } - return result; + if (getItemsCount() >= m_App.getMsgEngine().getSettings().getMaxRecipientCount()) + return TooManyRecipStatus; + + AppendItemStatus result = SuccessStatus; + if (!isRecipientExists(address)) { + if (addressType == MsgAddress::UnknownAddressType) + addressType = MsgUtils::getAddressType(address); + + if (addressType == MsgAddress::Phone || addressType == MsgAddress::Email) { + result = SuccessStatus; + MbeRecipientItem *item = new MbeRecipientItem(address, dispName, addressType); + MbeRecipientsView::appendItem(*item); + } else { + result = InvalidRecipStatus; + MSG_LOG("invalid recipient: ", address); + } + } else { + result = DuplicatedStatus; + } + return result; } bool MbeRecipients::isRecipientExists(const std::string& address) const { - auto recipientList = getItems(); - for (auto pViewItem : recipientList) { - MbeRecipientItem *pItem = dynamic_cast(pViewItem); - if (pItem && pItem->getAddress() == address) - return true; - } - - return false; + auto recipientList = getItems(); + for (auto pViewItem : recipientList) { + MbeRecipientItem *pItem = dynamic_cast(pViewItem); + if (pItem && pItem->getAddress() == address) + return true; + } + + return false; } void MbeRecipients::onContactChanged() { - MSG_LOG(""); - updateItemsDispName(); + MSG_LOG(""); + updateItemsDispName(); } diff --git a/src/Common/Controller/src/NaviFrameController.cpp b/src/Common/Controller/src/NaviFrameController.cpp index f01b8e3a..8d291e00 100644 --- a/src/Common/Controller/src/NaviFrameController.cpp +++ b/src/Common/Controller/src/NaviFrameController.cpp @@ -29,111 +29,111 @@ using namespace Msg; NaviFrameController::NaviFrameController(App &app) - : ViewController(app) - , NaviFrameView(app.getWindow()) + : ViewController(app) + , NaviFrameView(app.getWindow()) { - setHwButtonListener(getEo(), this); - getApp().addListener(*this); + setHwButtonListener(getEo(), this); + getApp().addListener(*this); } NaviFrameController::~NaviFrameController() { - MSG_LOG("Destructor: ", this); + MSG_LOG("Destructor: ", this); } void NaviFrameController::pop(FrameController &frame) { - if (isLastFrame()) { - getApp().exit(); - } else { - getApp().getPopupManager().reset(); - NaviFrameView::pop(frame); - } + if (isLastFrame()) { + getApp().exit(); + } else { + getApp().getPopupManager().reset(); + NaviFrameView::pop(frame); + } } void NaviFrameController::destroy() { - NaviFrameView::destroy(); + NaviFrameView::destroy(); } bool NaviFrameController::prepare(const AppControlCommand &cmd) { - MSG_LOG("Execute app. control command: ", cmd.getOperationMsg()); - std::string errorMsg; - if (!getMsgEngine().isReady(errorMsg)) { - notification_status_message_post(errorMsg.c_str()); - return false; - } - return true; + MSG_LOG("Execute app. control command: ", cmd.getOperationMsg()); + std::string errorMsg; + if (!getMsgEngine().isReady(errorMsg)) { + notification_status_message_post(errorMsg.c_str()); + return false; + } + return true; } void NaviFrameController::execCmd(const AppControlDefaultRef &cmd) { - if (prepare(*cmd)) { - AppControlDefault::DefaultType type = cmd->getDefaultType(); - MsgThread *thread = getTopFrame(); // Check if thread is open - if (!thread) - insertToBottom(*new MsgThread(*this)); // Push thread list to the bottom - - auto *conv = getTopFrame(); // Check if conversation is open - MessageRef msg = getMsgEngine().getStorage().getMessage(cmd->getMessageId()); //To avoid opening conversation if MsgId is invalid - if (type != AppControlDefault::MainType && msg != nullptr) { - if (conv) { - AppControlLauncher::getInst().terminate(); - promote(*conv); - conv->execCmd(cmd); - } else if (type == AppControlDefault::ViewType || type == AppControlDefault::ReplyType || isUnreadNotificationSingle(type)) { - AppControlLauncher::getInst().terminate(); - conv = new Conversation(*this); - push(*conv); - conv->execCmd(cmd); - } - } - } + if (prepare(*cmd)) { + AppControlDefault::DefaultType type = cmd->getDefaultType(); + MsgThread *thread = getTopFrame(); // Check if thread is open + if (!thread) + insertToBottom(*new MsgThread(*this)); // Push thread list to the bottom + + auto *conv = getTopFrame(); // Check if conversation is open + MessageRef msg = getMsgEngine().getStorage().getMessage(cmd->getMessageId()); //To avoid opening conversation if MsgId is invalid + if (type != AppControlDefault::MainType && msg != nullptr) { + if (conv) { + AppControlLauncher::getInst().terminate(); + promote(*conv); + conv->execCmd(cmd); + } else if (type == AppControlDefault::ViewType || type == AppControlDefault::ReplyType || isUnreadNotificationSingle(type)) { + AppControlLauncher::getInst().terminate(); + conv = new Conversation(*this); + push(*conv); + conv->execCmd(cmd); + } + } + } } void NaviFrameController::execCmd(const AppControlComposeRef &cmd) { - if (prepare(*cmd)) { - AppControlLauncher::getInst().terminate(); - auto *conv = getTopFrame(); - if (conv) { - promote(*conv); - } else { - conv = new Conversation(*this); - push(*conv); - } - conv->execCmd(cmd); - } + if (prepare(*cmd)) { + AppControlLauncher::getInst().terminate(); + auto *conv = getTopFrame(); + if (conv) { + promote(*conv); + } else { + conv = new Conversation(*this); + push(*conv); + } + conv->execCmd(cmd); + } } template T *NaviFrameController::getTopFrame() const { - auto items = getItems(); - for (auto item = items.rbegin(); item != items.rend(); ++item) { - T *frame = dynamic_cast(*item); - if (frame) - return frame; - } - return nullptr; + auto items = getItems(); + for (auto item = items.rbegin(); item != items.rend(); ++item) { + T *frame = dynamic_cast(*item); + if (frame) + return frame; + } + return nullptr; } FrameController *NaviFrameController::getTopFrame() const { - return static_cast(NaviFrameView::getTopFrame()); + return static_cast(NaviFrameView::getTopFrame()); } bool NaviFrameController::isUnreadNotificationSingle(AppControlDefault::DefaultType type) const { - return type == AppControlDefault::NotificationType && getMsgEngine().getStorage().getUnreadThreadCount() == 1; + return type == AppControlDefault::NotificationType && getMsgEngine().getStorage().getUnreadThreadCount() == 1; } void NaviFrameController::onHwBackButtonClicked() { - auto *top = getTopFrame(); - if (top) - pop(*top); + auto *top = getTopFrame(); + if (top) + pop(*top); } void NaviFrameController::onHwMoreButtonClicked() @@ -142,31 +142,31 @@ void NaviFrameController::onHwMoreButtonClicked() void NaviFrameController::onPause(NaviFrameItem &item) { - static_cast(item).pause(); + static_cast(item).pause(); } void NaviFrameController::onResume(NaviFrameItem &item) { - static_cast(item).resume(); + static_cast(item).resume(); } void NaviFrameController::onAppPause() { - auto *top = getTopFrame(); - if (top) - top->pause(); + auto *top = getTopFrame(); + if (top) + top->pause(); } void NaviFrameController::onAppResume() { - auto *top = getTopFrame(); - if (top) - top->resume(); + auto *top = getTopFrame(); + if (top) + top->resume(); } void NaviFrameController::onBeforeDelete(View &view) { - NaviFrameView::onBeforeDelete(view); - getApp().removeListener(*this); + NaviFrameView::onBeforeDelete(view); + getApp().removeListener(*this); } diff --git a/src/Common/Controller/src/SaveAttachments.cpp b/src/Common/Controller/src/SaveAttachments.cpp index 3a6ff3b5..e0a662b6 100644 --- a/src/Common/Controller/src/SaveAttachments.cpp +++ b/src/Common/Controller/src/SaveAttachments.cpp @@ -28,11 +28,11 @@ using namespace Msg; SaveAttachments::SaveAttachments(NaviFrameController &parent, MsgId id) - : FrameController(parent) - , m_pList(nullptr) - , m_Id(id) + : FrameController(parent) + , m_pList(nullptr) + , m_Id(id) { - create(); + create(); } SaveAttachments::~SaveAttachments() @@ -41,204 +41,204 @@ SaveAttachments::~SaveAttachments() void SaveAttachments::create() { - createList(); + createList(); - NaviBar &naviBar = getNaviBar(); - updateSelectItemsTitle(); - naviBar.showButton(NaviOkButtonId, true); - naviBar.setButtonText(NaviOkButtonId, msgt("IDS_MSG_ACBUTTON_DONE_ABB")); - naviBar.disabledButton(NaviOkButtonId, true); - naviBar.showButton(NaviCancelButtonId, true); + NaviBar &naviBar = getNaviBar(); + updateSelectItemsTitle(); + naviBar.showButton(NaviOkButtonId, true); + naviBar.setButtonText(NaviOkButtonId, msgt("IDS_MSG_ACBUTTON_DONE_ABB")); + naviBar.disabledButton(NaviOkButtonId, true); + naviBar.showButton(NaviCancelButtonId, true); } void SaveAttachments::onAttached(ViewItem &item) { - MSG_LOG(""); - FrameController::onAttached(item); - setContent(*m_pList); + MSG_LOG(""); + FrameController::onAttached(item); + setContent(*m_pList); } void SaveAttachments::createList() { - m_pList = new ListView(getParent()); - m_pList->setListener(this); - m_pList->expand(); - m_pList->setMultiSelection(false); - m_pList->setMode(ELM_LIST_COMPRESS); - m_pList->setCheckMode(true); - m_pList->show(); + m_pList = new ListView(getParent()); + m_pList->setListener(this); + m_pList->expand(); + m_pList->setMultiSelection(false); + m_pList->setMode(ELM_LIST_COMPRESS); + m_pList->setCheckMode(true); + m_pList->show(); - fillList(); - if (m_pList->getItemsCount() > 1) - showSelectAllItem(); + fillList(); + if (m_pList->getItemsCount() > 1) + showSelectAllItem(); - m_pList->checkAllItems(false); + m_pList->checkAllItems(false); } void SaveAttachments::fillList() { - MessageMmsRef mms = std::dynamic_pointer_cast(getMsgEngine().getStorage().getMessage(m_Id)); - const MsgPageList &pageList = mms->getPageList(); - for (int i = 0; i < pageList.getLength(); ++i) { - const MsgMediaList &mediaList = pageList.at(i).getMediaList(); - for (int j = 0; j < mediaList.getLength(); ++j) { - MsgMedia::Type type = mediaList.at(j).getType(); - if (type != MsgMedia::TextType && type != MsgMedia::UnknownType) - appendItem(mediaList.at(j).getFileName(), mediaList.at(j).getFilePath(), nullptr, this); - } - } + MessageMmsRef mms = std::dynamic_pointer_cast(getMsgEngine().getStorage().getMessage(m_Id)); + const MsgPageList &pageList = mms->getPageList(); + for (int i = 0; i < pageList.getLength(); ++i) { + const MsgMediaList &mediaList = pageList.at(i).getMediaList(); + for (int j = 0; j < mediaList.getLength(); ++j) { + MsgMedia::Type type = mediaList.at(j).getType(); + if (type != MsgMedia::TextType && type != MsgMedia::UnknownType) + appendItem(mediaList.at(j).getFileName(), mediaList.at(j).getFilePath(), nullptr, this); + } + } - const MsgAttachmentList &attachmentList = mms->getAttachmentList(); - for (int i = 0; i < attachmentList.getLength(); ++i) - appendItem(attachmentList.at(i).getFileName(), attachmentList.at(i).getFilePath(), nullptr, this); + const MsgAttachmentList &attachmentList = mms->getAttachmentList(); + for (int i = 0; i < attachmentList.getLength(); ++i) + appendItem(attachmentList.at(i).getFileName(), attachmentList.at(i).getFilePath(), nullptr, this); } void SaveAttachments::appendItem(const std::string &text, const std::string &path, PopupListItemPressedCb cb, void *userData) { - m_pList->appendItem(*new SaveAttachmentsListItem(text, path)); + m_pList->appendItem(*new SaveAttachmentsListItem(text, path)); } void SaveAttachments::updateSelectItemsTitle() { - int checked = getAttachmentsCheckedCount(); - if (checked > 0) - getNaviBar().setTitle(msgArgs("IDS_MSG_HEADER_PD_SELECTED_ABB3", checked)); - else - getNaviBar().setTitle(msgt("IDS_MSG_HEADER_SELECT_ITEMS_ABB3")); + int checked = getAttachmentsCheckedCount(); + if (checked > 0) + getNaviBar().setTitle(msgArgs("IDS_MSG_HEADER_PD_SELECTED_ABB3", checked)); + else + getNaviBar().setTitle(msgt("IDS_MSG_HEADER_SELECT_ITEMS_ABB3")); } int SaveAttachments::getAttachmentsCheckedCount() const { - auto items = m_pList->getItems(); - int count = 0; - for (SaveAttachmentsListItem *item : items) { - if (item->isCheckable() && item->getCheckedState()) - ++count; - } - return count; + auto items = m_pList->getItems(); + int count = 0; + for (SaveAttachmentsListItem *item : items) { + if (item->isCheckable() && item->getCheckedState()) + ++count; + } + return count; } void SaveAttachments::showSelectAllItem() { - SelectAllListItem *item = dynamic_cast(m_pList->getFirstItem()); - if (!item) - item = new SelectAllListItem; - m_pList->prependItem(*item); + SelectAllListItem *item = dynamic_cast(m_pList->getFirstItem()); + if (!item) + item = new SelectAllListItem; + m_pList->prependItem(*item); } void SaveAttachments::onButtonClicked(NaviFrameItem &item, NaviButtonId buttonId) { - switch (buttonId) { - case NaviCancelButtonId: - onHwBackButtonClicked(); - break; + switch (buttonId) { + case NaviCancelButtonId: + onHwBackButtonClicked(); + break; - case NaviOkButtonId: - onNaviOkButtonClicked(); - break; + case NaviOkButtonId: + onNaviOkButtonClicked(); + break; - default: - MSG_LOG_ERROR("Invalid buttonId: ", buttonId); - break; - } + default: + MSG_LOG_ERROR("Invalid buttonId: ", buttonId); + break; + } } void SaveAttachments::onNaviOkButtonClicked() { - MSG_LOG(""); + MSG_LOG(""); - bool result = saveCheckedItems(); + bool result = saveCheckedItems(); - if (result) - notification_status_message_post(msg("IDS_MSG_TPOP_ATTACHMENTS_SAVED_IN_MY_FILES_DOWNLOADS").cStr()); - else - showSavingFailedPopup(); + if (result) + notification_status_message_post(msg("IDS_MSG_TPOP_ATTACHMENTS_SAVED_IN_MY_FILES_DOWNLOADS").cStr()); + else + showSavingFailedPopup(); - pop(); + pop(); } void SaveAttachments::onHwBackButtonClicked() { - pop(); + pop(); } void SaveAttachments::onListItemChecked(ListItem &listItem) { - MSG_LOG(""); - if (SelectAllListItem *it = dynamic_cast(&listItem)) - checkSelectAllItem(*it); - else - checkItem(listItem); + MSG_LOG(""); + if (SelectAllListItem *it = dynamic_cast(&listItem)) + checkSelectAllItem(*it); + else + checkItem(listItem); - updateSelectItemsTitle(); + updateSelectItemsTitle(); } void SaveAttachments::checkSelectAllItem(SelectAllListItem &item) { - bool checked = item.getCheckedState(); - m_pList->checkAllItems(checked); - getNaviBar().disabledButton(NaviOkButtonId, !checked); + bool checked = item.getCheckedState(); + m_pList->checkAllItems(checked); + getNaviBar().disabledButton(NaviOkButtonId, !checked); } void SaveAttachments::checkItem(ListItem &item) { - updateSelectAllItem(); - getNaviBar().disabledButton(NaviOkButtonId, !shouldEnableSaveBtn()); + updateSelectAllItem(); + getNaviBar().disabledButton(NaviOkButtonId, !shouldEnableSaveBtn()); } void SaveAttachments::updateSelectAllItem() { - if (m_pList->getItems().size() > 1) { - bool allChecked = areAllItemsChecked(); + if (m_pList->getItems().size() > 1) { + bool allChecked = areAllItemsChecked(); - SelectAllListItem *selectAllItem = dynamic_cast(m_pList->getFirstItem()); - if (selectAllItem) - selectAllItem->setCheckedState(allChecked, true); - } + SelectAllListItem *selectAllItem = dynamic_cast(m_pList->getFirstItem()); + if (selectAllItem) + selectAllItem->setCheckedState(allChecked, true); + } } bool SaveAttachments::areAllItemsChecked() const { - ListItemCollection items = m_pList->getItems(); + ListItemCollection items = m_pList->getItems(); - auto item = items.empty() ? items.begin() : ++items.begin(); - for (; item != items.end(); ++item) { - if ((*item)->isCheckable() && !(*item)->getCheckedState()) - return false; - } - return true; + auto item = items.empty() ? items.begin() : ++items.begin(); + for (; item != items.end(); ++item) { + if ((*item)->isCheckable() && !(*item)->getCheckedState()) + return false; + } + return true; } bool SaveAttachments::shouldEnableSaveBtn() const { - ListItemCollection items = m_pList->getItems(); - for (auto *item : items) { - if (item->isCheckable() && item->getCheckedState()) - return true; - } - return false; + ListItemCollection items = m_pList->getItems(); + for (auto *item : items) { + if (item->isCheckable() && item->getCheckedState()) + return true; + } + return false; } bool SaveAttachments::saveCheckedItems() { - std::string filePathDst; - std::string dowloadPath = PathUtils::getDownloadPath(); + std::string filePathDst; + std::string dowloadPath = PathUtils::getDownloadPath(); - auto items = m_pList->getItems(); - std::list files; + auto items = m_pList->getItems(); + std::list files; - for (auto *item : items) { - if (item->isCheckable() && item->getCheckedState()) - files.push_back(item->getFilePath()); - } + for (auto *item : items) { + if (item->isCheckable() && item->getCheckedState()) + files.push_back(item->getFilePath()); + } - return FileUtils::saveFilesToStorage(files); + return FileUtils::saveFilesToStorage(files); } void SaveAttachments::showSavingFailedPopup() { - Popup &popup = getApp().getPopupManager().getPopup(); - popup.setContent(msgt("IDS_MSGF_POP_SAVING_FAILED")); - popup.setTimeOut(1.0); - popup.show(); + Popup &popup = getApp().getPopupManager().getPopup(); + popup.setContent(msgt("IDS_MSGF_POP_SAVING_FAILED")); + popup.setTimeOut(1.0); + popup.show(); } diff --git a/src/Common/Controller/src/SaveAttachmentsListItem.cpp b/src/Common/Controller/src/SaveAttachmentsListItem.cpp index 42b13a5e..8692d490 100644 --- a/src/Common/Controller/src/SaveAttachmentsListItem.cpp +++ b/src/Common/Controller/src/SaveAttachmentsListItem.cpp @@ -25,16 +25,16 @@ using namespace Msg; namespace { - ListItemStyleRef ItemStyle = ListItemStyle::create("type1"); - Elm_Genlist_Item_Type type = ELM_GENLIST_ITEM_NONE; - const char *namePart = "elm.text"; - const char *checkBoxPart = "elm.swallow.end"; + ListItemStyleRef ItemStyle = ListItemStyle::create("type1"); + Elm_Genlist_Item_Type type = ELM_GENLIST_ITEM_NONE; + const char *namePart = "elm.text"; + const char *checkBoxPart = "elm.swallow.end"; } SaveAttachmentsListItem::SaveAttachmentsListItem(const std::string &text, const std::string &path) - : ListItem(ItemStyle, type) - , m_FileName(text) - , m_FilePath(path) + : ListItem(ItemStyle, type) + , m_FileName(text) + , m_FilePath(path) { } @@ -44,18 +44,18 @@ SaveAttachmentsListItem::~SaveAttachmentsListItem() std::string SaveAttachmentsListItem::getText(ListItem &item, const char *part) { - if (!strcmp(part, namePart)) - return m_FileName; + if (!strcmp(part, namePart)) + return m_FileName; - return ""; + return ""; } const char *SaveAttachmentsListItem::getCheckPart(ListItem &item) { - return checkBoxPart; + return checkBoxPart; } const std::string &SaveAttachmentsListItem::getFilePath() const { - return m_FilePath; + return m_FilePath; } diff --git a/src/Common/Controller/src/ViewController.cpp b/src/Common/Controller/src/ViewController.cpp index c0256f6c..14065b37 100644 --- a/src/Common/Controller/src/ViewController.cpp +++ b/src/Common/Controller/src/ViewController.cpp @@ -19,12 +19,12 @@ using namespace Msg; ViewController::ViewController(App &app) - : BaseController(app) + : BaseController(app) { } ViewController::ViewController(BaseController *parent) - : BaseController(parent) + : BaseController(parent) { } diff --git a/src/Common/Controller/src/ViewItemController.cpp b/src/Common/Controller/src/ViewItemController.cpp index 74415b9d..9be3d7a8 100644 --- a/src/Common/Controller/src/ViewItemController.cpp +++ b/src/Common/Controller/src/ViewItemController.cpp @@ -19,12 +19,12 @@ using namespace Msg; ViewItemController::ViewItemController(App &app) - : BaseController(app) + : BaseController(app) { } ViewItemController::ViewItemController(BaseController *parent) - : BaseController(parent) + : BaseController(parent) { } diff --git a/src/Common/MsgEngine/inc/MediaType.h b/src/Common/MsgEngine/inc/MediaType.h index 573a31ec..823cb8dd 100644 --- a/src/Common/MsgEngine/inc/MediaType.h +++ b/src/Common/MsgEngine/inc/MediaType.h @@ -27,275 +27,275 @@ #include namespace Msg { - struct MediaTypeData { - MediaTypeData(const char *aMime, MsgMedia::Type aType) - : mime(aMime) - , type(aType) - { - } - std::string mime; - MsgMedia::Type type; - }; + struct MediaTypeData { + MediaTypeData(const char *aMime, MsgMedia::Type aType) + : mime(aMime) + , type(aType) + { + } + std::string mime; + MsgMedia::Type type; + }; - const std::unordered_multimap mediaTypeByExtMap = - { - // Sound: - {"aac", {"audio/aac", MsgMedia::AudioType}}, - {"amr", {"audio/amr", MsgMedia::AudioType}}, - {"amr", {"audio/x-amr", MsgMedia::AudioType}}, - {"amr", {"audio/amr-wb", MsgMedia::AudioType}}, - {"imy", {"audio/imelody", MsgMedia::AudioType}}, - {"imy", {"audio/imy", MsgMedia::AudioType}}, - {"imy", {"audio/iMelody", MsgMedia::AudioType}}, - {"imy", {"audio/melody", MsgMedia::AudioType}}, - {"imy", {"audio/x-iMelody", MsgMedia::AudioType}}, - {"imy", {"text/iMelody", MsgMedia::AudioType}}, - {"imy", {"text/x-iMelody", MsgMedia::AudioType}}, - {"imy", {"text/x-imelody", MsgMedia::AudioType}}, - {"mid", {"audio/mid", MsgMedia::AudioType}}, - {"mid", {"audio/midi", MsgMedia::AudioType}}, - {"mid", {"audio/x-mid", MsgMedia::AudioType}}, - {"mid", {"audio/x-midi", MsgMedia::AudioType}}, - {"midi", {"audio/mid", MsgMedia::AudioType}}, - {"mmf", {"application/vnd.smaf", MsgMedia::AudioType}}, - {"mmf", {"application/x-smaf", MsgMedia::AudioType}}, - {"mmf", {"audio/mmf", MsgMedia::AudioType}}, - {"mmf", {"audio/smaf", MsgMedia::AudioType}}, - {"mmf", {"audio/x-mmf", MsgMedia::AudioType}}, - {"mmf", {"audio/x-smaf", MsgMedia::AudioType}}, - {"mp3", {"audio/mpeg", MsgMedia::AudioType}}, - {"mp3", {"audio/mp3", MsgMedia::AudioType}}, - {"mp3", {"audio/mpg3", MsgMedia::AudioType}}, - {"mp3", {"audio/mpeg3", MsgMedia::AudioType}}, - {"mp3", {"audio/mpg", MsgMedia::AudioType}}, - {"mp3", {"audio/x-mp3", MsgMedia::AudioType}}, - {"mp3", {"audio/x-mpeg", MsgMedia::AudioType}}, - {"mp3", {"audio/x-mpeg3", MsgMedia::AudioType}}, - {"mp3", {"audio/x-mpegaudio", MsgMedia::AudioType}}, - {"mp3", {"audio/x-mpg", MsgMedia::AudioType}}, - {"mpg", {"audio/x-mpeg", MsgMedia::AudioType}}, - {"m4a", {"audio/m4a", MsgMedia::AudioType}}, - {"ra", {"audio/x-pn-realaudio", MsgMedia::AudioType}}, - {"rm", {"audio/vnd.rn-realaudio", MsgMedia::AudioType}}, - {"rm", {"audio/x-pn-multirate-realaudio", MsgMedia::AudioType}}, - {"rm", {"audio/x-pn-multirate-realaudio-live", MsgMedia::AudioType}}, - {"spm", {"audio/sp-midi", MsgMedia::AudioType}}, - {"wav", {"audio/wav", MsgMedia::AudioType}}, - {"wav", {"audio/wave", MsgMedia::AudioType}}, - {"wav", {"audio/x-wav", MsgMedia::AudioType}}, - {"wav", {"audio/x-wave", MsgMedia::AudioType}}, - {"wma", {"audio/wma", MsgMedia::AudioType}}, - {"wma", {"audio/x-ms-wma", MsgMedia::AudioType}}, - {"xmf", {"audio/mobile-xmf", MsgMedia::AudioType}}, - {"xmf", {"audio/xmf", MsgMedia::AudioType}}, - {"xmf", {"audio/x-xmf", MsgMedia::AudioType}}, - {"3gp", {"audio/3gpp", MsgMedia::AudioType}}, - {"mp4", {"audio/mp4", MsgMedia::AudioType}}, - {"mp4", {"audio/MP4A-LATM", MsgMedia::AudioType}}, - {"mp4", {"audio/mpeg4", MsgMedia::AudioType}}, + const std::unordered_multimap mediaTypeByExtMap = + { + // Sound: + {"aac", {"audio/aac", MsgMedia::AudioType}}, + {"amr", {"audio/amr", MsgMedia::AudioType}}, + {"amr", {"audio/x-amr", MsgMedia::AudioType}}, + {"amr", {"audio/amr-wb", MsgMedia::AudioType}}, + {"imy", {"audio/imelody", MsgMedia::AudioType}}, + {"imy", {"audio/imy", MsgMedia::AudioType}}, + {"imy", {"audio/iMelody", MsgMedia::AudioType}}, + {"imy", {"audio/melody", MsgMedia::AudioType}}, + {"imy", {"audio/x-iMelody", MsgMedia::AudioType}}, + {"imy", {"text/iMelody", MsgMedia::AudioType}}, + {"imy", {"text/x-iMelody", MsgMedia::AudioType}}, + {"imy", {"text/x-imelody", MsgMedia::AudioType}}, + {"mid", {"audio/mid", MsgMedia::AudioType}}, + {"mid", {"audio/midi", MsgMedia::AudioType}}, + {"mid", {"audio/x-mid", MsgMedia::AudioType}}, + {"mid", {"audio/x-midi", MsgMedia::AudioType}}, + {"midi", {"audio/mid", MsgMedia::AudioType}}, + {"mmf", {"application/vnd.smaf", MsgMedia::AudioType}}, + {"mmf", {"application/x-smaf", MsgMedia::AudioType}}, + {"mmf", {"audio/mmf", MsgMedia::AudioType}}, + {"mmf", {"audio/smaf", MsgMedia::AudioType}}, + {"mmf", {"audio/x-mmf", MsgMedia::AudioType}}, + {"mmf", {"audio/x-smaf", MsgMedia::AudioType}}, + {"mp3", {"audio/mpeg", MsgMedia::AudioType}}, + {"mp3", {"audio/mp3", MsgMedia::AudioType}}, + {"mp3", {"audio/mpg3", MsgMedia::AudioType}}, + {"mp3", {"audio/mpeg3", MsgMedia::AudioType}}, + {"mp3", {"audio/mpg", MsgMedia::AudioType}}, + {"mp3", {"audio/x-mp3", MsgMedia::AudioType}}, + {"mp3", {"audio/x-mpeg", MsgMedia::AudioType}}, + {"mp3", {"audio/x-mpeg3", MsgMedia::AudioType}}, + {"mp3", {"audio/x-mpegaudio", MsgMedia::AudioType}}, + {"mp3", {"audio/x-mpg", MsgMedia::AudioType}}, + {"mpg", {"audio/x-mpeg", MsgMedia::AudioType}}, + {"m4a", {"audio/m4a", MsgMedia::AudioType}}, + {"ra", {"audio/x-pn-realaudio", MsgMedia::AudioType}}, + {"rm", {"audio/vnd.rn-realaudio", MsgMedia::AudioType}}, + {"rm", {"audio/x-pn-multirate-realaudio", MsgMedia::AudioType}}, + {"rm", {"audio/x-pn-multirate-realaudio-live", MsgMedia::AudioType}}, + {"spm", {"audio/sp-midi", MsgMedia::AudioType}}, + {"wav", {"audio/wav", MsgMedia::AudioType}}, + {"wav", {"audio/wave", MsgMedia::AudioType}}, + {"wav", {"audio/x-wav", MsgMedia::AudioType}}, + {"wav", {"audio/x-wave", MsgMedia::AudioType}}, + {"wma", {"audio/wma", MsgMedia::AudioType}}, + {"wma", {"audio/x-ms-wma", MsgMedia::AudioType}}, + {"xmf", {"audio/mobile-xmf", MsgMedia::AudioType}}, + {"xmf", {"audio/xmf", MsgMedia::AudioType}}, + {"xmf", {"audio/x-xmf", MsgMedia::AudioType}}, + {"3gp", {"audio/3gpp", MsgMedia::AudioType}}, + {"mp4", {"audio/mp4", MsgMedia::AudioType}}, + {"mp4", {"audio/MP4A-LATM", MsgMedia::AudioType}}, + {"mp4", {"audio/mpeg4", MsgMedia::AudioType}}, - // Image: - {"bmp", {"image/bmp", MsgMedia::ImageType}}, - {"bmp", {"image/x-bmp", MsgMedia::ImageType}}, - {"gif", {"image/gif", MsgMedia::ImageType}}, - {"GIF", {"image/gif", MsgMedia::ImageType}}, - {"gif", {"image/vnd.tmo.my5-gif", MsgMedia::ImageType}}, - {"jpg", {"image/jpg", MsgMedia::ImageType}}, - {"jpg", {"image/jpeg", MsgMedia::ImageType}}, - {"jpg", {"image/vnd.tmo.my5-jpg", MsgMedia::ImageType}}, - {"jpeg", {"image/jpeg", MsgMedia::ImageType}}, - {"JPG", {"image/jpeg", MsgMedia::ImageType}}, - {"jpg", {"image/pjpeg", MsgMedia::ImageType}}, - {"jpe", {"image/jpeg", MsgMedia::ImageType}}, - {"png", {"image/png", MsgMedia::ImageType}}, - {"wbmp", {"image/vnd.wap.wbmp", MsgMedia::ImageType}}, - {"wbmp", {"image/wbmp", MsgMedia::ImageType}}, - {"swf", {"application/x-shockwave-flash", MsgMedia::UnknownType}}, - {"tif", {"image/tiff", MsgMedia::ImageType}}, - {"tif", {"image/tif", MsgMedia::ImageType}}, - {"pmd", {"audio/pmd", MsgMedia::ImageType}}, + // Image: + {"bmp", {"image/bmp", MsgMedia::ImageType}}, + {"bmp", {"image/x-bmp", MsgMedia::ImageType}}, + {"gif", {"image/gif", MsgMedia::ImageType}}, + {"GIF", {"image/gif", MsgMedia::ImageType}}, + {"gif", {"image/vnd.tmo.my5-gif", MsgMedia::ImageType}}, + {"jpg", {"image/jpg", MsgMedia::ImageType}}, + {"jpg", {"image/jpeg", MsgMedia::ImageType}}, + {"jpg", {"image/vnd.tmo.my5-jpg", MsgMedia::ImageType}}, + {"jpeg", {"image/jpeg", MsgMedia::ImageType}}, + {"JPG", {"image/jpeg", MsgMedia::ImageType}}, + {"jpg", {"image/pjpeg", MsgMedia::ImageType}}, + {"jpe", {"image/jpeg", MsgMedia::ImageType}}, + {"png", {"image/png", MsgMedia::ImageType}}, + {"wbmp", {"image/vnd.wap.wbmp", MsgMedia::ImageType}}, + {"wbmp", {"image/wbmp", MsgMedia::ImageType}}, + {"swf", {"application/x-shockwave-flash", MsgMedia::UnknownType}}, + {"tif", {"image/tiff", MsgMedia::ImageType}}, + {"tif", {"image/tif", MsgMedia::ImageType}}, + {"pmd", {"audio/pmd", MsgMedia::ImageType}}, - // Video: - {"3gp", {"video/3gpp", MsgMedia::VideoType}}, - {"3gp", {"video/3gp", MsgMedia::VideoType}}, - {"3gp", {"video/h263", MsgMedia::VideoType}}, - {"3gp", {"video/mp4v-es", MsgMedia::VideoType}}, - {"asf", {"audio/x-ms-asf", MsgMedia::VideoType}}, - {"asf", {"video/x-ms-asf", MsgMedia::VideoType}}, - {"asx", {"video/x-ms-asf", MsgMedia::VideoType}}, - {"avi", {"video/avi", MsgMedia::VideoType}}, - {"mp2", {"video/mpeg", MsgMedia::VideoType}}, - {"mp4", {"video/mp4", MsgMedia::VideoType}}, - {"mp4", {"video/mpeg4", MsgMedia::VideoType}}, - {"mp4", {"video/x-mp4", MsgMedia::VideoType}}, - {"mp4", {"video/x-pv-mp4", MsgMedia::VideoType}}, - {"mpg", {"video/mpeg", MsgMedia::VideoType}}, - {"mpeg", {"video/mpeg", MsgMedia::VideoType}}, - {"rm", {"video/x-pn-multirate-realvideo", MsgMedia::VideoType}}, - {"rm", {"video/vnd.rn-realmedia", MsgMedia::VideoType}}, - {"rm", {"video/vnd.rn-realvideo", MsgMedia::VideoType}}, - {"rv", {"video/x-pn-realvideo", MsgMedia::VideoType}}, - {"sdp", {"application/sdp", MsgMedia::VideoType}}, - {"sdp", {"video/sdp", MsgMedia::VideoType}}, - {"wmv", {"video/x-ms-wmv", MsgMedia::VideoType}}, + // Video: + {"3gp", {"video/3gpp", MsgMedia::VideoType}}, + {"3gp", {"video/3gp", MsgMedia::VideoType}}, + {"3gp", {"video/h263", MsgMedia::VideoType}}, + {"3gp", {"video/mp4v-es", MsgMedia::VideoType}}, + {"asf", {"audio/x-ms-asf", MsgMedia::VideoType}}, + {"asf", {"video/x-ms-asf", MsgMedia::VideoType}}, + {"asx", {"video/x-ms-asf", MsgMedia::VideoType}}, + {"avi", {"video/avi", MsgMedia::VideoType}}, + {"mp2", {"video/mpeg", MsgMedia::VideoType}}, + {"mp4", {"video/mp4", MsgMedia::VideoType}}, + {"mp4", {"video/mpeg4", MsgMedia::VideoType}}, + {"mp4", {"video/x-mp4", MsgMedia::VideoType}}, + {"mp4", {"video/x-pv-mp4", MsgMedia::VideoType}}, + {"mpg", {"video/mpeg", MsgMedia::VideoType}}, + {"mpeg", {"video/mpeg", MsgMedia::VideoType}}, + {"rm", {"video/x-pn-multirate-realvideo", MsgMedia::VideoType}}, + {"rm", {"video/vnd.rn-realmedia", MsgMedia::VideoType}}, + {"rm", {"video/vnd.rn-realvideo", MsgMedia::VideoType}}, + {"rv", {"video/x-pn-realvideo", MsgMedia::VideoType}}, + {"sdp", {"application/sdp", MsgMedia::VideoType}}, + {"sdp", {"video/sdp", MsgMedia::VideoType}}, + {"wmv", {"video/x-ms-wmv", MsgMedia::VideoType}}, - // Text: - {"txt", {"text/plain", MsgMedia::TextType}}, - {"text", {"text/plain", MsgMedia::UnknownType}}, - {"html", {"text/html", MsgMedia::UnknownType}}, - {"htm", {"text/html", MsgMedia::UnknownType}}, - {"wml", {"text/vnd.wap.wml", MsgMedia::UnknownType}}, - {"xml", {"text/xml", MsgMedia::UnknownType}}, + // Text: + {"txt", {"text/plain", MsgMedia::TextType}}, + {"text", {"text/plain", MsgMedia::UnknownType}}, + {"html", {"text/html", MsgMedia::UnknownType}}, + {"htm", {"text/html", MsgMedia::UnknownType}}, + {"wml", {"text/vnd.wap.wml", MsgMedia::UnknownType}}, + {"xml", {"text/xml", MsgMedia::UnknownType}}, - // vObject: - {"vbm", {"text/x-vbookmark", MsgMedia::UnknownType}}, - {"vcf", {"text/x-vcard", MsgMedia::UnknownType}}, - {"vcs", {"text/x-vCalendar", MsgMedia::UnknownType}}, - {"vnt", {"text/x-vnote", MsgMedia::UnknownType}}, + // vObject: + {"vbm", {"text/x-vbookmark", MsgMedia::UnknownType}}, + {"vcf", {"text/x-vcard", MsgMedia::UnknownType}}, + {"vcs", {"text/x-vCalendar", MsgMedia::UnknownType}}, + {"vnt", {"text/x-vnote", MsgMedia::UnknownType}}, - // Doc: - {"doc", {"application/msword", MsgMedia::UnknownType}}, - {"doc", {"applcation/vnd.ms-word", MsgMedia::UnknownType}}, - {"xls", {"application/vnd.ms-excel", MsgMedia::UnknownType}}, - {"xls", {"application/x-msexcel", MsgMedia::UnknownType}}, - {"ppt", {"application/vnd.ms-powerpoint", MsgMedia::UnknownType}}, - {"ppt", {"application/x-mspowerpoint", MsgMedia::UnknownType}}, - {"pdf", {"application/pdf", MsgMedia::UnknownType}}, + // Doc: + {"doc", {"application/msword", MsgMedia::UnknownType}}, + {"doc", {"applcation/vnd.ms-word", MsgMedia::UnknownType}}, + {"xls", {"application/vnd.ms-excel", MsgMedia::UnknownType}}, + {"xls", {"application/x-msexcel", MsgMedia::UnknownType}}, + {"ppt", {"application/vnd.ms-powerpoint", MsgMedia::UnknownType}}, + {"ppt", {"application/x-mspowerpoint", MsgMedia::UnknownType}}, + {"pdf", {"application/pdf", MsgMedia::UnknownType}}, - // Etc: - {"rm ", {"application/vnd.rn-realmedia", MsgMedia::UnknownType}}, - {"smi", {"application/smil", MsgMedia::UnknownType}}, - {"smil", {"application/smil", MsgMedia::UnknownType}}, - {"xml", {"application/vnd.oma.drm.roap-pdu+xml", MsgMedia::UnknownType}}, - {"xml", {"application/vnd.oma.drm.roap-trigger+xml", MsgMedia::UnknownType}}, - {"xxx", {"application/octet-stream", MsgMedia::UnknownType}}, - }; + // Etc: + {"rm ", {"application/vnd.rn-realmedia", MsgMedia::UnknownType}}, + {"smi", {"application/smil", MsgMedia::UnknownType}}, + {"smil", {"application/smil", MsgMedia::UnknownType}}, + {"xml", {"application/vnd.oma.drm.roap-pdu+xml", MsgMedia::UnknownType}}, + {"xml", {"application/vnd.oma.drm.roap-trigger+xml", MsgMedia::UnknownType}}, + {"xxx", {"application/octet-stream", MsgMedia::UnknownType}}, + }; - const std::unordered_multimap mediaTypeByMimeMap = - { - // Sound: - {"audio/aac", MsgMedia::AudioType}, - {"audio/amr", MsgMedia::AudioType}, - {"audio/x-amr", MsgMedia::AudioType}, - {"audio/amr-wb", MsgMedia::AudioType}, - {"audio/imelody", MsgMedia::AudioType}, - {"audio/imy", MsgMedia::AudioType}, - {"audio/iMelody", MsgMedia::AudioType}, - {"audio/melody", MsgMedia::AudioType}, - {"audio/x-iMelody", MsgMedia::AudioType}, - {"text/iMelody", MsgMedia::AudioType}, - {"text/x-iMelody", MsgMedia::AudioType}, - {"text/x-imelody", MsgMedia::AudioType}, - {"audio/mid", MsgMedia::AudioType}, - {"audio/midi", MsgMedia::AudioType}, - {"audio/x-mid", MsgMedia::AudioType}, - {"audio/x-midi", MsgMedia::AudioType}, - {"audio/mid", MsgMedia::AudioType}, - {"application/vnd.smaf", MsgMedia::AudioType}, - {"application/x-smaf", MsgMedia::AudioType}, - {"audio/mmf", MsgMedia::AudioType}, - {"audio/smaf", MsgMedia::AudioType}, - {"audio/x-mmf", MsgMedia::AudioType}, - {"audio/x-smaf", MsgMedia::AudioType}, - {"audio/mpeg", MsgMedia::AudioType}, - {"audio/mp3", MsgMedia::AudioType}, - {"audio/mpg3", MsgMedia::AudioType}, - {"audio/mpeg3", MsgMedia::AudioType}, - {"audio/mpg", MsgMedia::AudioType}, - {"audio/x-mp3", MsgMedia::AudioType}, - {"audio/x-mpeg", MsgMedia::AudioType}, - {"audio/x-mpeg3", MsgMedia::AudioType}, - {"audio/x-mpegaudio", MsgMedia::AudioType}, - {"audio/x-mpg", MsgMedia::AudioType}, - {"audio/x-mpeg", MsgMedia::AudioType}, - {"audio/m4a", MsgMedia::AudioType}, - {"audio/x-pn-realaudio", MsgMedia::AudioType}, - {"audio/vnd.rn-realaudio", MsgMedia::AudioType}, - {"audio/x-pn-multirate-realaudio", MsgMedia::AudioType}, - {"audio/x-pn-multirate-realaudio-live", MsgMedia::AudioType}, - {"audio/sp-midi", MsgMedia::AudioType}, - {"audio/wav", MsgMedia::AudioType}, - {"audio/wave", MsgMedia::AudioType}, - {"audio/x-wav", MsgMedia::AudioType}, - {"audio/x-wave", MsgMedia::AudioType}, - {"audio/wma", MsgMedia::AudioType}, - {"audio/x-ms-wma", MsgMedia::AudioType}, - {"audio/mobile-xmf", MsgMedia::AudioType}, - {"audio/xmf", MsgMedia::AudioType}, - {"audio/x-xmf", MsgMedia::AudioType}, - {"audio/3gpp", MsgMedia::AudioType}, - {"audio/mp4", MsgMedia::AudioType}, - {"audio/MP4A-LATM", MsgMedia::AudioType}, - {"audio/mpeg4", MsgMedia::AudioType}, + const std::unordered_multimap mediaTypeByMimeMap = + { + // Sound: + {"audio/aac", MsgMedia::AudioType}, + {"audio/amr", MsgMedia::AudioType}, + {"audio/x-amr", MsgMedia::AudioType}, + {"audio/amr-wb", MsgMedia::AudioType}, + {"audio/imelody", MsgMedia::AudioType}, + {"audio/imy", MsgMedia::AudioType}, + {"audio/iMelody", MsgMedia::AudioType}, + {"audio/melody", MsgMedia::AudioType}, + {"audio/x-iMelody", MsgMedia::AudioType}, + {"text/iMelody", MsgMedia::AudioType}, + {"text/x-iMelody", MsgMedia::AudioType}, + {"text/x-imelody", MsgMedia::AudioType}, + {"audio/mid", MsgMedia::AudioType}, + {"audio/midi", MsgMedia::AudioType}, + {"audio/x-mid", MsgMedia::AudioType}, + {"audio/x-midi", MsgMedia::AudioType}, + {"audio/mid", MsgMedia::AudioType}, + {"application/vnd.smaf", MsgMedia::AudioType}, + {"application/x-smaf", MsgMedia::AudioType}, + {"audio/mmf", MsgMedia::AudioType}, + {"audio/smaf", MsgMedia::AudioType}, + {"audio/x-mmf", MsgMedia::AudioType}, + {"audio/x-smaf", MsgMedia::AudioType}, + {"audio/mpeg", MsgMedia::AudioType}, + {"audio/mp3", MsgMedia::AudioType}, + {"audio/mpg3", MsgMedia::AudioType}, + {"audio/mpeg3", MsgMedia::AudioType}, + {"audio/mpg", MsgMedia::AudioType}, + {"audio/x-mp3", MsgMedia::AudioType}, + {"audio/x-mpeg", MsgMedia::AudioType}, + {"audio/x-mpeg3", MsgMedia::AudioType}, + {"audio/x-mpegaudio", MsgMedia::AudioType}, + {"audio/x-mpg", MsgMedia::AudioType}, + {"audio/x-mpeg", MsgMedia::AudioType}, + {"audio/m4a", MsgMedia::AudioType}, + {"audio/x-pn-realaudio", MsgMedia::AudioType}, + {"audio/vnd.rn-realaudio", MsgMedia::AudioType}, + {"audio/x-pn-multirate-realaudio", MsgMedia::AudioType}, + {"audio/x-pn-multirate-realaudio-live", MsgMedia::AudioType}, + {"audio/sp-midi", MsgMedia::AudioType}, + {"audio/wav", MsgMedia::AudioType}, + {"audio/wave", MsgMedia::AudioType}, + {"audio/x-wav", MsgMedia::AudioType}, + {"audio/x-wave", MsgMedia::AudioType}, + {"audio/wma", MsgMedia::AudioType}, + {"audio/x-ms-wma", MsgMedia::AudioType}, + {"audio/mobile-xmf", MsgMedia::AudioType}, + {"audio/xmf", MsgMedia::AudioType}, + {"audio/x-xmf", MsgMedia::AudioType}, + {"audio/3gpp", MsgMedia::AudioType}, + {"audio/mp4", MsgMedia::AudioType}, + {"audio/MP4A-LATM", MsgMedia::AudioType}, + {"audio/mpeg4", MsgMedia::AudioType}, - // Image: - {"image/bmp", MsgMedia::ImageType}, - {"image/x-bmp", MsgMedia::ImageType}, - {"image/gif", MsgMedia::ImageType}, - {"image/gif", MsgMedia::ImageType}, - {"image/vnd.tmo.my5-gif", MsgMedia::ImageType}, - {"image/jpg", MsgMedia::ImageType}, - {"image/jpeg", MsgMedia::ImageType}, - {"image/vnd.tmo.my5-jpg", MsgMedia::ImageType}, - {"image/jpeg", MsgMedia::ImageType}, - {"image/jpeg", MsgMedia::ImageType}, - {"image/pjpeg", MsgMedia::ImageType}, - {"image/jpeg", MsgMedia::ImageType}, - {"image/png", MsgMedia::ImageType}, - {"image/vnd.wap.wbmp", MsgMedia::ImageType}, - {"image/wbmp", MsgMedia::ImageType}, - {"application/x-shockwave-flash", MsgMedia::UnknownType}, - {"image/tiff", MsgMedia::ImageType}, - {"image/tif", MsgMedia::ImageType}, - {"audio/pmd", MsgMedia::ImageType}, + // Image: + {"image/bmp", MsgMedia::ImageType}, + {"image/x-bmp", MsgMedia::ImageType}, + {"image/gif", MsgMedia::ImageType}, + {"image/gif", MsgMedia::ImageType}, + {"image/vnd.tmo.my5-gif", MsgMedia::ImageType}, + {"image/jpg", MsgMedia::ImageType}, + {"image/jpeg", MsgMedia::ImageType}, + {"image/vnd.tmo.my5-jpg", MsgMedia::ImageType}, + {"image/jpeg", MsgMedia::ImageType}, + {"image/jpeg", MsgMedia::ImageType}, + {"image/pjpeg", MsgMedia::ImageType}, + {"image/jpeg", MsgMedia::ImageType}, + {"image/png", MsgMedia::ImageType}, + {"image/vnd.wap.wbmp", MsgMedia::ImageType}, + {"image/wbmp", MsgMedia::ImageType}, + {"application/x-shockwave-flash", MsgMedia::UnknownType}, + {"image/tiff", MsgMedia::ImageType}, + {"image/tif", MsgMedia::ImageType}, + {"audio/pmd", MsgMedia::ImageType}, - // Video: - {"video/3gpp", MsgMedia::VideoType}, - {"video/3gp", MsgMedia::VideoType}, - {"video/h263", MsgMedia::VideoType}, - {"video/mp4v-es", MsgMedia::VideoType}, - {"audio/x-ms-asf", MsgMedia::VideoType}, - {"video/x-ms-asf", MsgMedia::VideoType}, - {"video/x-ms-asf", MsgMedia::VideoType}, - {"video/avi", MsgMedia::VideoType}, - {"video/mpeg", MsgMedia::VideoType}, - {"video/mp4", MsgMedia::VideoType}, - {"video/mpeg4", MsgMedia::VideoType}, - {"video/x-mp4", MsgMedia::VideoType}, - {"video/x-pv-mp4", MsgMedia::VideoType}, - {"video/mpeg", MsgMedia::VideoType}, - {"video/mpeg", MsgMedia::VideoType}, - {"video/x-pn-multirate-realvideo", MsgMedia::VideoType}, - {"video/vnd.rn-realmedia", MsgMedia::VideoType}, - {"video/vnd.rn-realvideo", MsgMedia::VideoType}, - {"video/x-pn-realvideo", MsgMedia::VideoType}, - {"application/sdp", MsgMedia::VideoType}, - {"video/sdp", MsgMedia::VideoType}, - {"video/x-ms-wmv", MsgMedia::VideoType}, + // Video: + {"video/3gpp", MsgMedia::VideoType}, + {"video/3gp", MsgMedia::VideoType}, + {"video/h263", MsgMedia::VideoType}, + {"video/mp4v-es", MsgMedia::VideoType}, + {"audio/x-ms-asf", MsgMedia::VideoType}, + {"video/x-ms-asf", MsgMedia::VideoType}, + {"video/x-ms-asf", MsgMedia::VideoType}, + {"video/avi", MsgMedia::VideoType}, + {"video/mpeg", MsgMedia::VideoType}, + {"video/mp4", MsgMedia::VideoType}, + {"video/mpeg4", MsgMedia::VideoType}, + {"video/x-mp4", MsgMedia::VideoType}, + {"video/x-pv-mp4", MsgMedia::VideoType}, + {"video/mpeg", MsgMedia::VideoType}, + {"video/mpeg", MsgMedia::VideoType}, + {"video/x-pn-multirate-realvideo", MsgMedia::VideoType}, + {"video/vnd.rn-realmedia", MsgMedia::VideoType}, + {"video/vnd.rn-realvideo", MsgMedia::VideoType}, + {"video/x-pn-realvideo", MsgMedia::VideoType}, + {"application/sdp", MsgMedia::VideoType}, + {"video/sdp", MsgMedia::VideoType}, + {"video/x-ms-wmv", MsgMedia::VideoType}, - // Text: - {"text/plain", MsgMedia::TextType} - }; + // Text: + {"text/plain", MsgMedia::TextType} + }; - inline static const MediaTypeData getMsgMediaTypeByFileExt(const std::string &filePath) - { - std::string base; - std::string name; - std::string ext; + inline static const MediaTypeData getMsgMediaTypeByFileExt(const std::string &filePath) + { + std::string base; + std::string name; + std::string ext; - FileUtils::splitPath(filePath, base, name, ext); - std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower); - auto it = mediaTypeByExtMap.find(ext); - return it != mediaTypeByExtMap.end() ? it->second : MediaTypeData("", MsgMedia::UnknownType); - } + FileUtils::splitPath(filePath, base, name, ext); + std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower); + auto it = mediaTypeByExtMap.find(ext); + return it != mediaTypeByExtMap.end() ? it->second : MediaTypeData("", MsgMedia::UnknownType); + } - inline static MsgMedia::Type getMsgMediaTypeByMime(std::string mime) - { - std::transform(mime.begin(), mime.end(), mime.begin(), ::tolower); + inline static MsgMedia::Type getMsgMediaTypeByMime(std::string mime) + { + std::transform(mime.begin(), mime.end(), mime.begin(), ::tolower); - auto it = mediaTypeByMimeMap.find(mime); - return it != mediaTypeByMimeMap.end() ? it->second : MsgMedia::UnknownType; - } + auto it = mediaTypeByMimeMap.find(mime); + return it != mediaTypeByMimeMap.end() ? it->second : MsgMedia::UnknownType; + } } #endif /* BodyMediaType_h_ */ diff --git a/src/Common/MsgEngine/inc/Message.h b/src/Common/MsgEngine/inc/Message.h index 754c19b4..d1d24ad4 100644 --- a/src/Common/MsgEngine/inc/Message.h +++ b/src/Common/MsgEngine/inc/Message.h @@ -25,173 +25,173 @@ #include "MsgList.h" namespace Msg { - class Message; - typedef std::shared_ptr MessageRef; - typedef MsgList MessageList; - typedef std::shared_ptr> MessageListRef; - - /** - * @brief An abstraction that represents message-entity stored in message-service. - */ - class Message { - public: - /** - * @brief Each message can be sent or received, and this enum is used to distinguish the kind of every message. - */ - enum Direction { - MD_Sent = 0, /**< Outgoing message.*/ - MD_Received /**< Incoming message.*/ - }; - - /** - * @brief A type of every message. - */ - enum Type { - MT_Unknown, /**< Unknown type of message. If you got it something bad has happened.*/ - MT_SMS, /**< Text message - sms.*/ - MT_MMS, /**< Multimedia message - mms.*/ - MT_MMS_Noti /**< Depending on message-settings mms can be downloaded by demand. This type of message is aimed to notify user about new incoming mms is available to download.*/ - }; - - /** - * @brief Status of every message. - */ - enum NetworkStatus { - NS_Unknown = -1, /**< Attempt to get message status has failed.*/ - NS_Not_Send, /**< Message is a draft for now.*/ - NS_Sending, /**< message is in progress of sending.*/ - NS_Send_Success, /**< Message was successfully sent.*/ - NS_Send_Fail, /**< Message was failed to sent.*/ - NS_Deliver_Success, /**< Status of successfully sent delivery report.*/ - NS_Deliver_Fail, /**< Status of delivery report sending failure.*/ - NS_Received, /**< Incoming message.*/ - NS_Req_Cancelled, /**< Message network status request canceled.*/ - NS_Retrieving, /**< Message is in progress of retrieving. */ - NS_Retrieve_Success,/**< Message was successfully retrieved.*/ - NS_Retrieve_Fail, /**< Message was failed to retrieve.*/ - NS_Deliver_Pending, /**< Message delivery is pending.*/ - NS_Deliver_Expired, /**< Message delivery is expired.*/ - NS_Send_Pending /**< Message send is pending. */ - }; - - /** - * @brief Defines a storage for messages. - */ - enum MessageStorageType { - MS_Unknown, /**< Unknown storage.*/ - MS_Phone, /**< Phone's internal storage used for regular messages.*/ - MS_Sim /**< Sim-card storage used for messages on SIM.*/ - }; - - public: - virtual ~Message(); - - /** - * @brief Gets type of message. - * @return message type. - */ - virtual Type getType() const = 0; - - /** - * @brief Gets id of message. - * @return message id. - */ - virtual MsgId getId() const = 0; - - /** - * @brief Gets id of thread this message belongs to. - * @return thread id. - */ - virtual ThreadId getThreadId() const = 0; - - /** - * @brief Gets time when message was send\received. - * @return time. - */ - virtual time_t getTime() const = 0; - - /** - * @brief Gets list of addresses this message should be delivered to. - * @return recipients - */ - virtual const MsgAddressList &getAddressList() const = 0; - - /** - * @brief Adds one more recipient address into message. - * @return address added. - */ - virtual MsgAddress &addAddress() = 0; - - /** - * @brief Adds multiple recipient addresses into message. - */ - virtual void addAddresses(const MsgAddressList &list) = 0; - - /** - * @brief Gets message text. - * @return text. - */ - virtual std::string getText() const = 0; - - /** - * @brief Sets text into message - * @param[in] text message text. - */ - virtual void setText(const std::string &text) = 0; - - /** - * @brief Figures out whether message is outgoing or incoming. - * @return direction(in\out). - */ - virtual Message::Direction getDirection() const = 0; - - /** - * @brief Gets message network status. - * @return network status. - */ - virtual NetworkStatus getNetworkStatus() const = 0; - - /** - * @brief Returns message size, - * @return size. - */ - virtual int getSize() const = 0; - - /** - * @brief Gets message's subject if there's any. - * @return a subject string. - */ - virtual std::string getSubject() const = 0; - - /** - * @brief Adds subject-string into a message or replacing old one if message the subject. - * @param[in] text a new subject - */ - virtual void setSubject(const std::string &text) = 0; - - /** - * @brief Changes message's storage type. - * @param[in] msgStorage new storage type. - */ - virtual void setMessageStorageType(Message::MessageStorageType msgStorage) = 0; - - /** - * @brief Gets type of storage that contains this message. - */ - virtual Message::MessageStorageType getMessageStorageType() const = 0; - - /** - * @brief Checks whether this message is mms or not. - * @return true in case of mms, false otherwise. - */ - virtual bool isMms() const = 0; - - /** - * @brief Checks whether this message is restricted by DPM policy. - * @return true in case of restriction, false otherwise. - */ - virtual bool isRestrictedByDpm() const = 0; - }; + class Message; + typedef std::shared_ptr MessageRef; + typedef MsgList MessageList; + typedef std::shared_ptr> MessageListRef; + + /** + * @brief An abstraction that represents message-entity stored in message-service. + */ + class Message { + public: + /** + * @brief Each message can be sent or received, and this enum is used to distinguish the kind of every message. + */ + enum Direction { + MD_Sent = 0, /**< Outgoing message.*/ + MD_Received /**< Incoming message.*/ + }; + + /** + * @brief A type of every message. + */ + enum Type { + MT_Unknown, /**< Unknown type of message. If you got it something bad has happened.*/ + MT_SMS, /**< Text message - sms.*/ + MT_MMS, /**< Multimedia message - mms.*/ + MT_MMS_Noti /**< Depending on message-settings mms can be downloaded by demand. This type of message is aimed to notify user about new incoming mms is available to download.*/ + }; + + /** + * @brief Status of every message. + */ + enum NetworkStatus { + NS_Unknown = -1, /**< Attempt to get message status has failed.*/ + NS_Not_Send, /**< Message is a draft for now.*/ + NS_Sending, /**< message is in progress of sending.*/ + NS_Send_Success, /**< Message was successfully sent.*/ + NS_Send_Fail, /**< Message was failed to sent.*/ + NS_Deliver_Success, /**< Status of successfully sent delivery report.*/ + NS_Deliver_Fail, /**< Status of delivery report sending failure.*/ + NS_Received, /**< Incoming message.*/ + NS_Req_Cancelled, /**< Message network status request canceled.*/ + NS_Retrieving, /**< Message is in progress of retrieving. */ + NS_Retrieve_Success,/**< Message was successfully retrieved.*/ + NS_Retrieve_Fail, /**< Message was failed to retrieve.*/ + NS_Deliver_Pending, /**< Message delivery is pending.*/ + NS_Deliver_Expired, /**< Message delivery is expired.*/ + NS_Send_Pending /**< Message send is pending. */ + }; + + /** + * @brief Defines a storage for messages. + */ + enum MessageStorageType { + MS_Unknown, /**< Unknown storage.*/ + MS_Phone, /**< Phone's internal storage used for regular messages.*/ + MS_Sim /**< Sim-card storage used for messages on SIM.*/ + }; + + public: + virtual ~Message(); + + /** + * @brief Gets type of message. + * @return message type. + */ + virtual Type getType() const = 0; + + /** + * @brief Gets id of message. + * @return message id. + */ + virtual MsgId getId() const = 0; + + /** + * @brief Gets id of thread this message belongs to. + * @return thread id. + */ + virtual ThreadId getThreadId() const = 0; + + /** + * @brief Gets time when message was send\received. + * @return time. + */ + virtual time_t getTime() const = 0; + + /** + * @brief Gets list of addresses this message should be delivered to. + * @return recipients + */ + virtual const MsgAddressList &getAddressList() const = 0; + + /** + * @brief Adds one more recipient address into message. + * @return address added. + */ + virtual MsgAddress &addAddress() = 0; + + /** + * @brief Adds multiple recipient addresses into message. + */ + virtual void addAddresses(const MsgAddressList &list) = 0; + + /** + * @brief Gets message text. + * @return text. + */ + virtual std::string getText() const = 0; + + /** + * @brief Sets text into message + * @param[in] text message text. + */ + virtual void setText(const std::string &text) = 0; + + /** + * @brief Figures out whether message is outgoing or incoming. + * @return direction(in\out). + */ + virtual Message::Direction getDirection() const = 0; + + /** + * @brief Gets message network status. + * @return network status. + */ + virtual NetworkStatus getNetworkStatus() const = 0; + + /** + * @brief Returns message size, + * @return size. + */ + virtual int getSize() const = 0; + + /** + * @brief Gets message's subject if there's any. + * @return a subject string. + */ + virtual std::string getSubject() const = 0; + + /** + * @brief Adds subject-string into a message or replacing old one if message the subject. + * @param[in] text a new subject + */ + virtual void setSubject(const std::string &text) = 0; + + /** + * @brief Changes message's storage type. + * @param[in] msgStorage new storage type. + */ + virtual void setMessageStorageType(Message::MessageStorageType msgStorage) = 0; + + /** + * @brief Gets type of storage that contains this message. + */ + virtual Message::MessageStorageType getMessageStorageType() const = 0; + + /** + * @brief Checks whether this message is mms or not. + * @return true in case of mms, false otherwise. + */ + virtual bool isMms() const = 0; + + /** + * @brief Checks whether this message is restricted by DPM policy. + * @return true in case of restriction, false otherwise. + */ + virtual bool isRestrictedByDpm() const = 0; + }; } #endif /* __MESSAGE_H__ */ diff --git a/src/Common/MsgEngine/inc/MessageMms.h b/src/Common/MsgEngine/inc/MessageMms.h index 89ac7791..920b6bae 100644 --- a/src/Common/MsgEngine/inc/MessageMms.h +++ b/src/Common/MsgEngine/inc/MessageMms.h @@ -25,23 +25,23 @@ #include namespace Msg { - class MessageMms; - typedef std::shared_ptr MessageMmsRef; - typedef MsgList MessageMmsList; - typedef std::shared_ptr> MessageMmsListRef; + class MessageMms; + typedef std::shared_ptr MessageMmsRef; + typedef MsgList MessageMmsList; + typedef std::shared_ptr> MessageMmsListRef; - class MessageMms: - public virtual Message { - public: - virtual ~MessageMms(); + class MessageMms: + public virtual Message { + public: + virtual ~MessageMms(); - virtual const MsgPageList &getPageList() const = 0; - virtual MsgPage &addPage() = 0; - virtual const MsgAttachmentList &getAttachmentList() const = 0; - virtual MsgAttachment &addAttachment() = 0; - virtual int getMediaCount() const = 0; - virtual time_t getExpired() const = 0; - }; + virtual const MsgPageList &getPageList() const = 0; + virtual MsgPage &addPage() = 0; + virtual const MsgAttachmentList &getAttachmentList() const = 0; + virtual MsgAttachment &addAttachment() = 0; + virtual int getMediaCount() const = 0; + virtual time_t getExpired() const = 0; + }; } #endif /* _MESSAGE_MMS_H__ */ diff --git a/src/Common/MsgEngine/inc/MessageSMS.h b/src/Common/MsgEngine/inc/MessageSMS.h index d74321c2..092895fe 100644 --- a/src/Common/MsgEngine/inc/MessageSMS.h +++ b/src/Common/MsgEngine/inc/MessageSMS.h @@ -23,17 +23,17 @@ #include namespace Msg { - class MessageSMS; - typedef std::shared_ptr MessageSMSRef; - typedef MsgList MessageSMSList; - typedef std::shared_ptr> MessageSMSListRef; + class MessageSMS; + typedef std::shared_ptr MessageSMSRef; + typedef MsgList MessageSMSList; + typedef std::shared_ptr> MessageSMSListRef; - class MessageSMS: - public virtual Message { - public: - MessageSMS(); - virtual ~MessageSMS(); - }; + class MessageSMS: + public virtual Message { + public: + MessageSMS(); + virtual ~MessageSMS(); + }; } #endif /* _MESSAGE_SMS_H__ */ diff --git a/src/Common/MsgEngine/inc/MsgAddress.h b/src/Common/MsgEngine/inc/MsgAddress.h index 65b42350..76b2a57d 100644 --- a/src/Common/MsgEngine/inc/MsgAddress.h +++ b/src/Common/MsgEngine/inc/MsgAddress.h @@ -23,73 +23,73 @@ #include namespace Msg { - class MsgAddress; - typedef MsgList MsgAddressList; - typedef std::shared_ptr> MsgAddressListRef; + class MsgAddress; + typedef MsgList MsgAddressList; + typedef std::shared_ptr> MsgAddressListRef; - /** - * @brief Basic abstraction that represents a recipient's address message should be delivered to. - */ - class MsgAddress { - public: - /** - * @brief Type of address. - */ - enum AddressType { - Phone, /**< Phone number*/ - Email, /**< Email address*/ - UnknownAddressType /**< Unknown address, you get it if phone number format or email-format validations has failed to parce address.*/ - }; + /** + * @brief Basic abstraction that represents a recipient's address message should be delivered to. + */ + class MsgAddress { + public: + /** + * @brief Type of address. + */ + enum AddressType { + Phone, /**< Phone number*/ + Email, /**< Email address*/ + UnknownAddressType /**< Unknown address, you get it if phone number format or email-format validations has failed to parce address.*/ + }; - /** - * @brief A kind of recipient that defines a way how message should be delivered to this address. - */ - enum RecipientType { - To, /**< Primary recipient, messages are sent directly to this address.*/ - Cc, /**< "Carbon copy", secondary recipient. This address gets a message as a copy of original message sent to other "TO"-recipient.*/ - Bcc, /**< "Blind carbon copy" to tertiary recipients who receive the message. The primary and secondary recipients cannot see the tertiary recipients.*/ - UnknownRecipientType - }; + /** + * @brief A kind of recipient that defines a way how message should be delivered to this address. + */ + enum RecipientType { + To, /**< Primary recipient, messages are sent directly to this address.*/ + Cc, /**< "Carbon copy", secondary recipient. This address gets a message as a copy of original message sent to other "TO"-recipient.*/ + Bcc, /**< "Blind carbon copy" to tertiary recipients who receive the message. The primary and secondary recipients cannot see the tertiary recipients.*/ + UnknownRecipientType + }; - public: - virtual ~MsgAddress() {}; + public: + virtual ~MsgAddress() {}; - /** - * @brief Gets address string. - * @return address string. - **/ - virtual std::string getAddress() const = 0; + /** + * @brief Gets address string. + * @return address string. + **/ + virtual std::string getAddress() const = 0; - /** - * @brief Gets address type. - * @return address type. - **/ - virtual AddressType getAddressType() const = 0; + /** + * @brief Gets address type. + * @return address type. + **/ + virtual AddressType getAddressType() const = 0; - /** - * @brief Gets recipient type. - * @return recipient type. - **/ - virtual RecipientType getRecipientType() const = 0; + /** + * @brief Gets recipient type. + * @return recipient type. + **/ + virtual RecipientType getRecipientType() const = 0; - /** - * @brief Sets address-string. - * @param[in] address address string. - */ - virtual void setAddress(const std::string &address) = 0; + /** + * @brief Sets address-string. + * @param[in] address address string. + */ + virtual void setAddress(const std::string &address) = 0; - /** - * @brief Sets type of address. - * @param[in] type address type. - */ - virtual void setAddressType(AddressType type) = 0; + /** + * @brief Sets type of address. + * @param[in] type address type. + */ + virtual void setAddressType(AddressType type) = 0; - /** - * @brief Sets recipient type. - * @param[in] type recipient type. - */ - virtual void setRecipientType(RecipientType type) = 0; - }; + /** + * @brief Sets recipient type. + * @param[in] type recipient type. + */ + virtual void setRecipientType(RecipientType type) = 0; + }; } diff --git a/src/Common/MsgEngine/inc/MsgAttachment.h b/src/Common/MsgEngine/inc/MsgAttachment.h index 6e314bbe..56c3ba7a 100644 --- a/src/Common/MsgEngine/inc/MsgAttachment.h +++ b/src/Common/MsgEngine/inc/MsgAttachment.h @@ -21,20 +21,20 @@ #include namespace Msg { - class MsgAttachment; - typedef std::shared_ptr MsgAttachmentRef; - typedef MsgList MsgAttachmentList; - typedef std::shared_ptr> MsgAttachmentListRef; + class MsgAttachment; + typedef std::shared_ptr MsgAttachmentRef; + typedef MsgList MsgAttachmentList; + typedef std::shared_ptr> MsgAttachmentListRef; - class MsgAttachment { - public: - virtual ~MsgAttachment() {}; - virtual std::string getFilePath() const = 0; - virtual std::string getFileName() const = 0; - virtual int getFileSize() const = 0; - virtual std::string getMime() const = 0; - virtual void setFilePath(const std::string &path) = 0; - }; + class MsgAttachment { + public: + virtual ~MsgAttachment() {}; + virtual std::string getFilePath() const = 0; + virtual std::string getFileName() const = 0; + virtual int getFileSize() const = 0; + virtual std::string getMime() const = 0; + virtual void setFilePath(const std::string &path) = 0; + }; } #endif /* _MSG_ATTACHMENT_H__ */ diff --git a/src/Common/MsgEngine/inc/MsgComposer.h b/src/Common/MsgEngine/inc/MsgComposer.h index 9f9a3aa2..3242495d 100644 --- a/src/Common/MsgEngine/inc/MsgComposer.h +++ b/src/Common/MsgEngine/inc/MsgComposer.h @@ -23,29 +23,29 @@ #include "Logger.h" namespace Msg { - class MsgComposer { - public: - virtual ~MsgComposer() {}; + class MsgComposer { + public: + virtual ~MsgComposer() {}; - virtual MessageSMSRef createSms() = 0; - virtual MessageMmsRef createMms() = 0; + virtual MessageSMSRef createSms() = 0; + virtual MessageMmsRef createMms() = 0; - MessageRef createMessage(Message::Type type); - }; + MessageRef createMessage(Message::Type type); + }; - inline MessageRef MsgComposer::createMessage(Message::Type type) - { - MessageRef msg; + inline MessageRef MsgComposer::createMessage(Message::Type type) + { + MessageRef msg; - if (MsgUtils::isSms(type)) - msg = createSms(); - else if (MsgUtils::isMms(type)) - msg = createMms(); - else - MSG_LOG_WARN("Unknown message type"); + if (MsgUtils::isSms(type)) + msg = createSms(); + else if (MsgUtils::isMms(type)) + msg = createMms(); + else + MSG_LOG_WARN("Unknown message type"); - return msg; - } + return msg; + } } #endif /* __MSG_COMPOSER_H__ */ diff --git a/src/Common/MsgEngine/inc/MsgConvMedia.h b/src/Common/MsgEngine/inc/MsgConvMedia.h index 9f6be5f6..aeb73c98 100644 --- a/src/Common/MsgEngine/inc/MsgConvMedia.h +++ b/src/Common/MsgEngine/inc/MsgConvMedia.h @@ -23,21 +23,21 @@ #include namespace Msg { - class MsgConvMedia; - typedef MsgList MsgConvMediaList; - typedef std::shared_ptr> MsgConvMediaListRef; + class MsgConvMedia; + typedef MsgList MsgConvMediaList; + typedef std::shared_ptr> MsgConvMediaListRef; - class MsgConvMedia { - public: - virtual ~MsgConvMedia() {}; + class MsgConvMedia { + public: + virtual ~MsgConvMedia() {}; - virtual std::string getMime() const = 0; - virtual std::string getName() const = 0; - virtual std::string getPath() const = 0; - virtual std::string getThumbPath() const = 0; - virtual std::string getContentId() const = 0; - virtual std::string getContentLocation() const = 0; - }; + virtual std::string getMime() const = 0; + virtual std::string getName() const = 0; + virtual std::string getPath() const = 0; + virtual std::string getThumbPath() const = 0; + virtual std::string getContentId() const = 0; + virtual std::string getContentLocation() const = 0; + }; } #endif /* MSGCONVMEDIA_H_ */ diff --git a/src/Common/MsgEngine/inc/MsgConversationItem.h b/src/Common/MsgEngine/inc/MsgConversationItem.h index 95f55cf1..e6acca07 100644 --- a/src/Common/MsgEngine/inc/MsgConversationItem.h +++ b/src/Common/MsgEngine/inc/MsgConversationItem.h @@ -26,101 +26,101 @@ #include namespace Msg { - class MsgConversationItem; - typedef std::shared_ptr MsgConversationItemRef; - typedef std::shared_ptr> MsgConversationListRef; - - /** - * @brief An interface that provides basic information about conversation-list item. - */ - class MsgConversationItem { - public: - virtual ~MsgConversationItem(); - - /** - * @brief Gets id of thread this conversation-item belongs to. - * @return thread id. - */ - virtual ThreadId getThreadId() const = 0; - - /** - * @brief Gets id of message this conversation-item is related with. - * @return message id. - */ - virtual MsgId getMsgId() const = 0; - - /** - * @brief Gets message-text displayed in conversation-item. - * @return message text. - */ - virtual std::string getText() const = 0; - - /** - * @brief Gets subject-string. - * @brief subject. - */ - virtual std::string getSubject() const = 0; - - /** - * @brief Gets a time when message status was updated last time(it could happen after sending\receiving\editing draft/etc). - * @return time. - */ - virtual time_t getTime() const = 0; - - /** - * @brief Gets message direction. - * @return direction: Outgoing or Incoming - */ - virtual Message::Direction getDirection() const = 0; - - /** - * @brief Gets message type. - * @return message type. - */ - virtual Message::Type getType() const = 0; - - /** - * @brief Gets message network status. - * @return message network status. - */ - virtual Message::NetworkStatus getNetworkStatus() const = 0; - - /** - * @brief Checks whether conversation-item is related to draft message or not. - * @return true if message is draft, false otherwise. - */ - virtual bool isDraft() const = 0; - - /** - * @brief Checks whether conversation-item is related to read message or not. - * @return true if message is read, false otherwise. - */ - virtual bool isRead() const = 0; - - /** - * @brief Gets the count of pages message related to this conversation item contains. - * @return number of pages. - */ - virtual int getPagesCount() const = 0; - - /** - * @brief Gets the count of attachments message related to this conversation item contains. - * @return number of attachments. - */ - virtual int getAttachCount() const = 0; - - /** - * @brief Gets media-files list. - * @return media-files list. - */ - virtual const MsgConvMediaList &getMediaList() const = 0; - - /** - * @brief Checks whether this message is restricted by DPM policy. - * @return true in case of restriction, false otherwise. - */ - virtual bool isRestrictedByDpm() const = 0; - }; + class MsgConversationItem; + typedef std::shared_ptr MsgConversationItemRef; + typedef std::shared_ptr> MsgConversationListRef; + + /** + * @brief An interface that provides basic information about conversation-list item. + */ + class MsgConversationItem { + public: + virtual ~MsgConversationItem(); + + /** + * @brief Gets id of thread this conversation-item belongs to. + * @return thread id. + */ + virtual ThreadId getThreadId() const = 0; + + /** + * @brief Gets id of message this conversation-item is related with. + * @return message id. + */ + virtual MsgId getMsgId() const = 0; + + /** + * @brief Gets message-text displayed in conversation-item. + * @return message text. + */ + virtual std::string getText() const = 0; + + /** + * @brief Gets subject-string. + * @brief subject. + */ + virtual std::string getSubject() const = 0; + + /** + * @brief Gets a time when message status was updated last time(it could happen after sending\receiving\editing draft/etc). + * @return time. + */ + virtual time_t getTime() const = 0; + + /** + * @brief Gets message direction. + * @return direction: Outgoing or Incoming + */ + virtual Message::Direction getDirection() const = 0; + + /** + * @brief Gets message type. + * @return message type. + */ + virtual Message::Type getType() const = 0; + + /** + * @brief Gets message network status. + * @return message network status. + */ + virtual Message::NetworkStatus getNetworkStatus() const = 0; + + /** + * @brief Checks whether conversation-item is related to draft message or not. + * @return true if message is draft, false otherwise. + */ + virtual bool isDraft() const = 0; + + /** + * @brief Checks whether conversation-item is related to read message or not. + * @return true if message is read, false otherwise. + */ + virtual bool isRead() const = 0; + + /** + * @brief Gets the count of pages message related to this conversation item contains. + * @return number of pages. + */ + virtual int getPagesCount() const = 0; + + /** + * @brief Gets the count of attachments message related to this conversation item contains. + * @return number of attachments. + */ + virtual int getAttachCount() const = 0; + + /** + * @brief Gets media-files list. + * @return media-files list. + */ + virtual const MsgConvMediaList &getMediaList() const = 0; + + /** + * @brief Checks whether this message is restricted by DPM policy. + * @return true in case of restriction, false otherwise. + */ + virtual bool isRestrictedByDpm() const = 0; + }; } #endif /* __MSG_CONVERSATION_ITEM_H__ */ diff --git a/src/Common/MsgEngine/inc/MsgEngine.h b/src/Common/MsgEngine/inc/MsgEngine.h index 44932ffb..2df9175e 100644 --- a/src/Common/MsgEngine/inc/MsgEngine.h +++ b/src/Common/MsgEngine/inc/MsgEngine.h @@ -34,74 +34,74 @@ #include "MsgTypes.h" namespace Msg { - /** - * @brief Core-instance of whole mechanism that interacts with message-service. - */ - class MsgEngine { - public: - MsgEngine(); - ~MsgEngine(); - - /** - * @brief Initiates connection to message-service. - * @returns msg-service specific success code in case of success, otherwise returns error-code. - */ - int openService(); - - /** - * @brief Closes connection to message-service. - * @returns msg-service specific success code in case of success, otherwise returns error-code. - */ - int closeService(); - - /** - * @brief Checks whether message-service opened is ready to operate(was openService() called before or not). - * @param[out] error-message string filled if no connection to message service was opened. - * @result true if message-service is already opened, otherwise false. - */ - bool isReady(std::string &errorMsg) const; - - MsgStorage &getStorage(); - const MsgStorage &getStorage() const; - - MsgTransport &getTransport(); - const MsgTransport &getTransport() const; - - MsgSettings &getSettings(); - const MsgSettings &getSettings() const; - - MsgComposer &getComposer(); - const MsgComposer &getComposer() const; - - /** - * @brief Converts msg-service error codes into a string representation. - * @param[in] error an msg-service side error code - * @result msg-service define name string, e.g "MESSAGES_ERROR_NONE" for MESSAGES_ERROR_NONE code. - */ - static std::string whatError(int error); - - /** - * @brief Calculates input text length by encode type. - * @param[in] text input text. - * @param[out] text metric. - **/ - static void calculateTextMetric(const std::string &text, MsgTextMetric &textMetric); - - private: - std::unique_ptr m_Storage; - std::unique_ptr m_Transport; - std::unique_ptr m_Settings; - std::unique_ptr m_Composer; - #ifdef TIZEN_PRIVATE_API - msg_handle_t m_MsgHandle; - #else - messages_service_h m_MsgHandle; - #endif - }; + /** + * @brief Core-instance of whole mechanism that interacts with message-service. + */ + class MsgEngine { + public: + MsgEngine(); + ~MsgEngine(); + + /** + * @brief Initiates connection to message-service. + * @returns msg-service specific success code in case of success, otherwise returns error-code. + */ + int openService(); + + /** + * @brief Closes connection to message-service. + * @returns msg-service specific success code in case of success, otherwise returns error-code. + */ + int closeService(); + + /** + * @brief Checks whether message-service opened is ready to operate(was openService() called before or not). + * @param[out] error-message string filled if no connection to message service was opened. + * @result true if message-service is already opened, otherwise false. + */ + bool isReady(std::string &errorMsg) const; + + MsgStorage &getStorage(); + const MsgStorage &getStorage() const; + + MsgTransport &getTransport(); + const MsgTransport &getTransport() const; + + MsgSettings &getSettings(); + const MsgSettings &getSettings() const; + + MsgComposer &getComposer(); + const MsgComposer &getComposer() const; + + /** + * @brief Converts msg-service error codes into a string representation. + * @param[in] error an msg-service side error code + * @result msg-service define name string, e.g "MESSAGES_ERROR_NONE" for MESSAGES_ERROR_NONE code. + */ + static std::string whatError(int error); + + /** + * @brief Calculates input text length by encode type. + * @param[in] text input text. + * @param[out] text metric. + **/ + static void calculateTextMetric(const std::string &text, MsgTextMetric &textMetric); + + private: + std::unique_ptr m_Storage; + std::unique_ptr m_Transport; + std::unique_ptr m_Settings; + std::unique_ptr m_Composer; + #ifdef TIZEN_PRIVATE_API + msg_handle_t m_MsgHandle; + #else + messages_service_h m_MsgHandle; + #endif + }; } #define MSG_ENGINE_WHAT_ERROR(error)\ - MSG_LOG_INFO("Error = ", MsgEngine::whatError(error)) + MSG_LOG_INFO("Error = ", MsgEngine::whatError(error)) #endif /* __MSG_ENGINE_H__ */ diff --git a/src/Common/MsgEngine/inc/MsgList.h b/src/Common/MsgEngine/inc/MsgList.h index 39b00419..8f94cc84 100644 --- a/src/Common/MsgEngine/inc/MsgList.h +++ b/src/Common/MsgEngine/inc/MsgList.h @@ -19,56 +19,56 @@ namespace Msg { - /** - * @brief Generic container for message-objects. - */ - template - class MsgList { - public: - typedef T Type; + /** + * @brief Generic container for message-objects. + */ + template + class MsgList { + public: + typedef T Type; - public: - virtual ~MsgList() {} + public: + virtual ~MsgList() {} - /** - * @brief Constant getter by index.. - * @param[in] i index. - * @return message-object. - */ - virtual const T &at(int i) const = 0; + /** + * @brief Constant getter by index.. + * @param[in] i index. + * @return message-object. + */ + virtual const T &at(int i) const = 0; - /** - * @brief Nonconstant getter by index.. - * @param[in] i index. - * @return message-object. - */ - virtual T &at(int i) = 0; + /** + * @brief Nonconstant getter by index.. + * @param[in] i index. + * @return message-object. + */ + virtual T &at(int i) = 0; - /** - * @brief Gets count of message-objects list contains. - * @return list size. - */ - virtual int getLength() const = 0; + /** + * @brief Gets count of message-objects list contains. + * @return list size. + */ + virtual int getLength() const = 0; - inline const T &operator[](int i) const - { - return at(i); - } + inline const T &operator[](int i) const + { + return at(i); + } - inline const T &operator[](int i) - { - return at(i); - } + inline const T &operator[](int i) + { + return at(i); + } - /** - * @brief Checks if list is empty or not. - * @return true if list is empty, false otherwise. - */ - inline bool isEmpty() const - { - return getLength() <= 0; - } - }; + /** + * @brief Checks if list is empty or not. + * @return true if list is empty, false otherwise. + */ + inline bool isEmpty() const + { + return getLength() <= 0; + } + }; } #endif /* MsgList_H_ */ diff --git a/src/Common/MsgEngine/inc/MsgMedia.h b/src/Common/MsgEngine/inc/MsgMedia.h index 7fafa8ce..c68556ed 100644 --- a/src/Common/MsgEngine/inc/MsgMedia.h +++ b/src/Common/MsgEngine/inc/MsgMedia.h @@ -21,54 +21,54 @@ #include namespace Msg { - class MsgMedia; - typedef std::shared_ptr MsgMediaRef; - typedef MsgList MsgMediaList; - typedef std::shared_ptr> MsgMediaListRef; + class MsgMedia; + typedef std::shared_ptr MsgMediaRef; + typedef MsgList MsgMediaList; + typedef std::shared_ptr> MsgMediaListRef; - /** - * @brief represents a file to be attached to message. - */ - class MsgMedia { - public: - /** - * @brief Attacment-type. - */ - enum Type { - UnknownType = 0, /**< File type unsupported by smil-player, can't be played by smil-player. Attached as unknown filetype.*/ - ImageType, /**< Image file. Can be played with smil-player.*/ - AudioType, /**< Audio file. Can be played with smil-player.*/ - VideoType, /**< Video file. Can be played with smil-player.*/ - TextType, /**< Text-section of page.*/ - }; + /** + * @brief represents a file to be attached to message. + */ + class MsgMedia { + public: + /** + * @brief Attacment-type. + */ + enum Type { + UnknownType = 0, /**< File type unsupported by smil-player, can't be played by smil-player. Attached as unknown filetype.*/ + ImageType, /**< Image file. Can be played with smil-player.*/ + AudioType, /**< Audio file. Can be played with smil-player.*/ + VideoType, /**< Video file. Can be played with smil-player.*/ + TextType, /**< Text-section of page.*/ + }; - public: - virtual ~MsgMedia() {}; + public: + virtual ~MsgMedia() {}; - /** - * @brief Gets type of media. - * @return media type. - */ - virtual Type getType() const = 0; + /** + * @brief Gets type of media. + * @return media type. + */ + virtual Type getType() const = 0; - /** - * @brief Gets path to file. - * @return path. - */ - virtual std::string getFilePath() const = 0; + /** + * @brief Gets path to file. + * @return path. + */ + virtual std::string getFilePath() const = 0; - /** - * @brief Gets filename. - * @return filename. - */ - virtual std::string getFileName() const = 0; + /** + * @brief Gets filename. + * @return filename. + */ + virtual std::string getFileName() const = 0; - /** - * @brief Sets path to file. - * @param[in] path. - */ - virtual void setFilePath(const std::string &path) = 0; - }; + /** + * @brief Sets path to file. + * @param[in] path. + */ + virtual void setFilePath(const std::string &path) = 0; + }; } #endif /* _MSG_MEDIA_H__ */ diff --git a/src/Common/MsgEngine/inc/MsgPage.h b/src/Common/MsgEngine/inc/MsgPage.h index a3279711..90e73013 100644 --- a/src/Common/MsgEngine/inc/MsgPage.h +++ b/src/Common/MsgEngine/inc/MsgPage.h @@ -20,49 +20,49 @@ #include "MsgMedia.h" namespace Msg { - class MsgPage; - typedef std::shared_ptr MsgPageRef; - typedef MsgList MsgPageList; - typedef std::shared_ptr> MsgPageListRef; + class MsgPage; + typedef std::shared_ptr MsgPageRef; + typedef MsgList MsgPageList; + typedef std::shared_ptr> MsgPageListRef; - /** - * @brief An abstraction that represents a concept of "page". - * This is a part of MMS that contains one previewable attachment(video or image) and a number of attachments that have no preview(documents, audio-files etc). - */ - class MsgPage { - public: - virtual ~MsgPage(); + /** + * @brief An abstraction that represents a concept of "page". + * This is a part of MMS that contains one previewable attachment(video or image) and a number of attachments that have no preview(documents, audio-files etc). + */ + class MsgPage { + public: + virtual ~MsgPage(); - /** - * @brief Non-constant getter of media-attachment list. - * @return list of media-attachments. - */ - virtual MsgMediaList &getMediaList() = 0; + /** + * @brief Non-constant getter of media-attachment list. + * @return list of media-attachments. + */ + virtual MsgMediaList &getMediaList() = 0; - /** - * @brief Constant getter of media-attachment list. - * @return read-only media-attachment list. - */ - const MsgMediaList &getMediaList() const; + /** + * @brief Constant getter of media-attachment list. + * @return read-only media-attachment list. + */ + const MsgMediaList &getMediaList() const; - /** - * @brief Adds media to pages. - * @return media-structure that was added. - */ - virtual MsgMedia &addMedia() = 0; + /** + * @brief Adds media to pages. + * @return media-structure that was added. + */ + virtual MsgMedia &addMedia() = 0; - /** - * @brief Sets page duration. - * @param[in] duration page duration in milliseconds. - */ - virtual void setPageDuration(int duration) = 0; + /** + * @brief Sets page duration. + * @param[in] duration page duration in milliseconds. + */ + virtual void setPageDuration(int duration) = 0; - /** - * @brief Gets page duration. - * @return duration page duration in milliseconds. - */ - virtual int getPageDuration() const = 0; - }; + /** + * @brief Gets page duration. + * @return duration page duration in milliseconds. + */ + virtual int getPageDuration() const = 0; + }; } #endif /* _MSG_PAGE_H__ */ diff --git a/src/Common/MsgEngine/inc/MsgReport.h b/src/Common/MsgEngine/inc/MsgReport.h index 7a2f0296..08bd0202 100644 --- a/src/Common/MsgEngine/inc/MsgReport.h +++ b/src/Common/MsgEngine/inc/MsgReport.h @@ -23,41 +23,41 @@ #include namespace Msg { - class MsgReport; - typedef MsgList MsgReportList; - typedef std::shared_ptr> MsgReportListRef; + class MsgReport; + typedef MsgList MsgReportList; + typedef std::shared_ptr> MsgReportListRef; - class MsgReport { - public: - enum DeliveryStatus { - StatusNone, - StatusExpired, - StatusSuccess, - StatusRejected - }; + class MsgReport { + public: + enum DeliveryStatus { + StatusNone, + StatusExpired, + StatusSuccess, + StatusRejected + }; - enum ReadStatus { - ReadStatusNone, - ReadStatusIsRead, - ReadStatusIsDeleted, - ReadStatusRejectByUser - }; + enum ReadStatus { + ReadStatusNone, + ReadStatusIsRead, + ReadStatusIsDeleted, + ReadStatusRejectByUser + }; - enum Type { - TypeDelivery, - TypeRead, - TypeReadReportSent - }; + enum Type { + TypeDelivery, + TypeRead, + TypeReadReportSent + }; - public: - virtual ~MsgReport() {}; + public: + virtual ~MsgReport() {}; - virtual std::string getAddress() const = 0; - virtual DeliveryStatus getDeliveryStatus() const = 0; - virtual ReadStatus getReadStatus() const = 0; - virtual Type getType() const = 0; - virtual time_t getTime() const = 0; - }; + virtual std::string getAddress() const = 0; + virtual DeliveryStatus getDeliveryStatus() const = 0; + virtual ReadStatus getReadStatus() const = 0; + virtual Type getType() const = 0; + virtual time_t getTime() const = 0; + }; } diff --git a/src/Common/MsgEngine/inc/MsgSettings.h b/src/Common/MsgEngine/inc/MsgSettings.h index 8584979a..5585b0c6 100644 --- a/src/Common/MsgEngine/inc/MsgSettings.h +++ b/src/Common/MsgEngine/inc/MsgSettings.h @@ -23,86 +23,86 @@ #include namespace Msg { - class IMsgSettingsListener; - - class MsgSettings { - public: - enum ActiveNotifPolicy { - AppBackgroundPolicy, // App is not running or on background. - AppForegroundPolicy // App is running and on foreground, but not in conversation. - }; - - enum RingtoneType { - DefaultRingtone, - SilentRingtone, - UserRingtone - }; - - public: - MsgSettings(); - virtual ~MsgSettings(); - - void addListener(IMsgSettingsListener &listener); - void removeListener(IMsgSettingsListener &listener); - - int getMessageTextMaxChar() const; - int getMessageMaxPage() const; - int getAttachmentsMaxCount() const; - virtual int getAddressMaxLen() const = 0; - virtual int getPhoneNumberMaxLen() const = 0; - virtual int getAddressMaxCount() const = 0; - virtual int getSubjectMaxLen() const = 0; - virtual int getDisplayNameMaxLen() const = 0; - virtual int getMaxRecipientCount() const = 0; - virtual int getMaxMmsSize() const = 0; - virtual int getMaxMsgTextLen() const = 0; - - virtual void setAlerts(bool value) = 0; - virtual bool getAlerts() const = 0; - - virtual void setRingtoneType(RingtoneType type) = 0; - virtual RingtoneType getRingtoneType() const = 0; - virtual void setRingtone(const std::string &soundPath) = 0; - virtual std::string getRingtone() const = 0; - - virtual void setVibration(bool value) = 0; - virtual bool getVibration() const = 0; - - virtual void setSmsDelivReport(bool value) = 0; - virtual bool getSmsDelivReport() const = 0; - - virtual void setMmsDelivReport(bool value) = 0; - virtual bool getMmsDelivReport() const = 0; - - virtual void setMmsReadReport(bool value) = 0; - virtual bool getMmsReadReport() const = 0; - - virtual void setMmsAutoRetr(bool value) = 0; - virtual bool getMmsAutoRetr() const = 0; - - virtual void setMmsAutoRetrRoaming(bool value) = 0; - virtual bool getMmsAutoRetrRoaming() const = 0; - - virtual void setActiveNotifPolicy(ActiveNotifPolicy type) = 0; - virtual void setActiveNotifPolicy(ThreadId id) = 0; - - protected: - typedef std::vector MsgSettingsListeners; - - protected: - MsgSettingsListeners m_Listeners; - - private: - MsgSettings(MsgSettings&) = delete; - MsgSettings& operator=(MsgSettings&) = delete; - }; - - class IMsgSettingsListener - { - public: - virtual ~IMsgSettingsListener() {} - virtual void onRingtoneChanged(MsgSettings &msgSetting) {}; - }; + class IMsgSettingsListener; + + class MsgSettings { + public: + enum ActiveNotifPolicy { + AppBackgroundPolicy, // App is not running or on background. + AppForegroundPolicy // App is running and on foreground, but not in conversation. + }; + + enum RingtoneType { + DefaultRingtone, + SilentRingtone, + UserRingtone + }; + + public: + MsgSettings(); + virtual ~MsgSettings(); + + void addListener(IMsgSettingsListener &listener); + void removeListener(IMsgSettingsListener &listener); + + int getMessageTextMaxChar() const; + int getMessageMaxPage() const; + int getAttachmentsMaxCount() const; + virtual int getAddressMaxLen() const = 0; + virtual int getPhoneNumberMaxLen() const = 0; + virtual int getAddressMaxCount() const = 0; + virtual int getSubjectMaxLen() const = 0; + virtual int getDisplayNameMaxLen() const = 0; + virtual int getMaxRecipientCount() const = 0; + virtual int getMaxMmsSize() const = 0; + virtual int getMaxMsgTextLen() const = 0; + + virtual void setAlerts(bool value) = 0; + virtual bool getAlerts() const = 0; + + virtual void setRingtoneType(RingtoneType type) = 0; + virtual RingtoneType getRingtoneType() const = 0; + virtual void setRingtone(const std::string &soundPath) = 0; + virtual std::string getRingtone() const = 0; + + virtual void setVibration(bool value) = 0; + virtual bool getVibration() const = 0; + + virtual void setSmsDelivReport(bool value) = 0; + virtual bool getSmsDelivReport() const = 0; + + virtual void setMmsDelivReport(bool value) = 0; + virtual bool getMmsDelivReport() const = 0; + + virtual void setMmsReadReport(bool value) = 0; + virtual bool getMmsReadReport() const = 0; + + virtual void setMmsAutoRetr(bool value) = 0; + virtual bool getMmsAutoRetr() const = 0; + + virtual void setMmsAutoRetrRoaming(bool value) = 0; + virtual bool getMmsAutoRetrRoaming() const = 0; + + virtual void setActiveNotifPolicy(ActiveNotifPolicy type) = 0; + virtual void setActiveNotifPolicy(ThreadId id) = 0; + + protected: + typedef std::vector MsgSettingsListeners; + + protected: + MsgSettingsListeners m_Listeners; + + private: + MsgSettings(MsgSettings&) = delete; + MsgSettings& operator=(MsgSettings&) = delete; + }; + + class IMsgSettingsListener + { + public: + virtual ~IMsgSettingsListener() {} + virtual void onRingtoneChanged(MsgSettings &msgSetting) {}; + }; } diff --git a/src/Common/MsgEngine/inc/MsgStorage.h b/src/Common/MsgEngine/inc/MsgStorage.h index fb823fc9..697d2ba7 100644 --- a/src/Common/MsgEngine/inc/MsgStorage.h +++ b/src/Common/MsgEngine/inc/MsgStorage.h @@ -29,267 +29,267 @@ #include "MsgReport.h" namespace Msg { - class IMsgStorageListener; - class MsgDataContainer; - - /** - * @brief Instance responsible for interaction with message-service internal message-storage. - */ - class MsgStorage { - public: - /** - * @brief Possible results message storage could cause to. - */ - enum StorageResult { - StorageSuccess = 0, /**< Storage successful.*/ - StorageFail = -1, /**< Storage failure.*/ - StorageSimFull = -2, /**< SIM storage is full.*/ - }; - - public: - MsgStorage(); - virtual ~MsgStorage(); - - /** - * @brief Adds a subscriber to be notified about message-storage events. - * @param[in] listener object listening message-storage events. - */ - void addListener(IMsgStorageListener &listener); - - /** - * @brief Removes a subscriber if it was added before. If no such subscriber was added nothing happens. - * @param[in] listener a subscriber to be removed. - */ - void removeListener(IMsgStorageListener &listener); - - // Thread: - /** - * @brief Gets list of threads existing in message-storage. - * @return list of threads - */ - virtual MsgThreadListRef getThreadList() = 0; - - /** - * @brief Gets thread by a specified id. - * @param[in] id a thread-id - * @return thread with id specified - */ - virtual MsgThreadItemRef getThread(ThreadId id) = 0; - - /** - * @brief Gets thread by a specified address-list. - * @param[in] addressList a list of recipient-addresses unique for each thread - * @return thread with id specified - */ - virtual ThreadId getThreadId(const MsgAddressList &addressList) = 0; - - /** - * @brief Gets thread by a specified address-list. - * @param[in] list of recipient-addresses unique for each thread packed packed in std::list. - * @return thread with id specified - */ - virtual ThreadId getThreadId(const std::list &addressList) = 0; - - /** - * @brief Gets thread by a specified message-id. - * @param[in] id unique message-id this thread contains. - * @return thread with id specified - */ - virtual ThreadId getThreadId(MsgId id) = 0; - - /** - * @brief Deletes thread with specified id. - * @param[in] id id of thread to be removed. - * @return true in case of success, otherwise false. - */ - virtual bool deleteThread(ThreadId id) = 0; - - /** - * @brief Gets address-list of a thread with specified id. - * @param[in] id id of thread that contains address list to be removed. - * @return list of addresses for specified thread. - */ - virtual MsgAddressListRef getAddressList(ThreadId id) = 0; - - /** - * @brief Performs a search by specified keyword. - * @param[in] word a search keyword. - * @return list of threads that contain messages with text matched with a keyword. - */ - virtual MsgThreadListRef searchThread(const std::string &word) = 0; - - /** - * @brief Marks thread with specified id as read. - * @param[in] id id of thread to mark as read. - */ - virtual void setReadStatus(ThreadId id) = 0; - - /** - * @brief Gets number of threads with unread messages. - * @return number of unread threads. - */ - virtual int getUnreadThreadCount() const = 0; - - /** - * @brief Checks whether thread with specified id has email in it's address-list. - * @param[in] id an id of thread. - * @return true if thread has email in it's address-list, otharwise false. - */ - bool hasEmail(ThreadId id); - - // Message: - /** - * @brief Gets a list of messages on SIM. - * @return list messages on SIM. - */ - virtual MessageSMSListRef getSimMsgList() = 0; - - /** - * @brief Gets message by specified message-id. - * @param[in] id id of message to be found. - * @return found message if it's exists or empty MessageRef if search fails. - */ - virtual MessageRef getMessage(MsgId id) = 0; - - /** - * @brief Commits edited message into message-storage in two optional way: - * -# save existing message - * -# create a copy of source message - * @param[in] msg message to be saved. - * @param[in] a updateExisting flag that defines a saving strategy. If true the existing message is saved, otherwise a new message-copy is created. - * @param[out] result of storage operation. - * @return id of saved message. - */ - virtual MsgId saveMessage(Message &msg, bool updateExisting, StorageResult *result = nullptr) = 0; - - /** - * @brief Deletes single message with specified id. - * @param[in] id an id of message to be removed. - * @return true in case of successful deletion, otherwise false. - */ - virtual bool deleteMessage(MsgId id) = 0; - - /** - * @brief Deletes multiple messages with specified ids. - * @param[in] idList list of message-id to be removed. - * @return true in case of successful deletion, otherwise false. Also returns false if idList is empty. - */ - virtual bool deleteMessages(const MsgIdList &idList) = 0; - - /** - * @brief Performs search of a message based on a keyword. - * @param[in] word a search keyword. - * @return list of messages with text matched with a keyword. - */ - virtual MessageListRef searchMessage(const std::string &word) = 0; - - /** - * @brief Marks message with specified id as read. - * @param[in] id id of message to mark as read - * @param[in] new read-status a status of message. Set @c true if the message is read, otherwise set @c false if the message is not read - */ - virtual void setReadStatus(MsgId id, bool status) = 0; - - /** - * @brief Gets list of reports(Delivery/Read) relevand for mwssage with specified id. - * @param[in] msgId message-id. - * @return list of reports. - */ - virtual MsgReportListRef getMsgReportList(MsgId msgId) = 0; - - /** - * @brief Gets whether it requests read report or not - * @param[in] msgId message-id. - * @return true requests, false otherwise. - */ - virtual bool isReadReportChecked(MsgId msgId) = 0; - - /** - * @brief Gets whether it requests delivery report or not - * @param[in] msgId message-id. - * @return true requests, false otherwise. - */ - virtual bool isDeliverReportChecked(MsgId msgId) = 0; - - // Conversation: - /** - * @brief Gets conversation-list that belongs to thread with specified id. - * @param[in] id thread id. - * @return List of messages from thread. - */ - virtual MsgConversationListRef getConversationList(ThreadId id) = 0; - - /** - * @brief Gets an item from conversation-list corresponded to message with specified id. - * @param[in] id message id. - * @return Conversation-list item. - */ - virtual MsgConversationItemRef getConversationItem(MsgId id) = 0; - - protected: - typedef std::vector MsgStorageListeners; - - protected: - MsgStorageListeners m_Listeners; - }; - - - /** - * @brief A listener aimed to notify subscribers about message-storage events. - */ - class IMsgStorageListener - { - public: - virtual ~IMsgStorageListener() {}; - - /** - * @brief Message-storage updates for the given messages. - * @param[in] msgIdList list of message identifiers relevant to this notification. - */ - virtual void onMsgStorageUpdate(const MsgIdList &msgIdList) {}; - - /** - * @brief Notification about new messages addition. - * @param[in] msgIdList list of message identifiers relevant to this notification. - */ - virtual void onMsgStorageInsert(const MsgIdList &msgIdList) {}; - - /** - * @brief Notification about new messages deletion. - * @param[in] msgIdList list of message identifiers relevant to this notification. - */ - virtual void onMsgStorageDelete(const MsgIdList &msgIdList) {}; - - /** - * @brief Notifies that recipient stored in contacts was updated. - * @param[in] msgIdList list of message identifiers relevant to this notification. - */ - virtual void onMsgStorageContact(const MsgIdList &msgIdList) {}; - - /** - * @brief Message-storage updates for the given thread. - * @param[in] threadId Id of updated conversation. - */ - virtual void onMsgStorageThreadUpdate(const ThreadId &threadId) {}; - - /** - * @brief Notification about new thread addition. - * @param[in] threadId Id of created conversation. - */ - virtual void onMsgStorageThreadInsert(const ThreadId &threadId) {}; - - /** - * @brief Notification about thread deletion. - * @param[in] threadId Id of deleted conversation. - */ - virtual void onMsgStorageThreadDelete(const ThreadId &threadId) {}; - - /** - * @brief Notifies that recipient stored in contacts was updated. - * @param[in] threadId Id of conversation identifier relevant to this notification. - */ - virtual void onMsgStorageThreadContact(const ThreadId &threadId) {}; - }; + class IMsgStorageListener; + class MsgDataContainer; + + /** + * @brief Instance responsible for interaction with message-service internal message-storage. + */ + class MsgStorage { + public: + /** + * @brief Possible results message storage could cause to. + */ + enum StorageResult { + StorageSuccess = 0, /**< Storage successful.*/ + StorageFail = -1, /**< Storage failure.*/ + StorageSimFull = -2, /**< SIM storage is full.*/ + }; + + public: + MsgStorage(); + virtual ~MsgStorage(); + + /** + * @brief Adds a subscriber to be notified about message-storage events. + * @param[in] listener object listening message-storage events. + */ + void addListener(IMsgStorageListener &listener); + + /** + * @brief Removes a subscriber if it was added before. If no such subscriber was added nothing happens. + * @param[in] listener a subscriber to be removed. + */ + void removeListener(IMsgStorageListener &listener); + + // Thread: + /** + * @brief Gets list of threads existing in message-storage. + * @return list of threads + */ + virtual MsgThreadListRef getThreadList() = 0; + + /** + * @brief Gets thread by a specified id. + * @param[in] id a thread-id + * @return thread with id specified + */ + virtual MsgThreadItemRef getThread(ThreadId id) = 0; + + /** + * @brief Gets thread by a specified address-list. + * @param[in] addressList a list of recipient-addresses unique for each thread + * @return thread with id specified + */ + virtual ThreadId getThreadId(const MsgAddressList &addressList) = 0; + + /** + * @brief Gets thread by a specified address-list. + * @param[in] list of recipient-addresses unique for each thread packed packed in std::list. + * @return thread with id specified + */ + virtual ThreadId getThreadId(const std::list &addressList) = 0; + + /** + * @brief Gets thread by a specified message-id. + * @param[in] id unique message-id this thread contains. + * @return thread with id specified + */ + virtual ThreadId getThreadId(MsgId id) = 0; + + /** + * @brief Deletes thread with specified id. + * @param[in] id id of thread to be removed. + * @return true in case of success, otherwise false. + */ + virtual bool deleteThread(ThreadId id) = 0; + + /** + * @brief Gets address-list of a thread with specified id. + * @param[in] id id of thread that contains address list to be removed. + * @return list of addresses for specified thread. + */ + virtual MsgAddressListRef getAddressList(ThreadId id) = 0; + + /** + * @brief Performs a search by specified keyword. + * @param[in] word a search keyword. + * @return list of threads that contain messages with text matched with a keyword. + */ + virtual MsgThreadListRef searchThread(const std::string &word) = 0; + + /** + * @brief Marks thread with specified id as read. + * @param[in] id id of thread to mark as read. + */ + virtual void setReadStatus(ThreadId id) = 0; + + /** + * @brief Gets number of threads with unread messages. + * @return number of unread threads. + */ + virtual int getUnreadThreadCount() const = 0; + + /** + * @brief Checks whether thread with specified id has email in it's address-list. + * @param[in] id an id of thread. + * @return true if thread has email in it's address-list, otharwise false. + */ + bool hasEmail(ThreadId id); + + // Message: + /** + * @brief Gets a list of messages on SIM. + * @return list messages on SIM. + */ + virtual MessageSMSListRef getSimMsgList() = 0; + + /** + * @brief Gets message by specified message-id. + * @param[in] id id of message to be found. + * @return found message if it's exists or empty MessageRef if search fails. + */ + virtual MessageRef getMessage(MsgId id) = 0; + + /** + * @brief Commits edited message into message-storage in two optional way: + * -# save existing message + * -# create a copy of source message + * @param[in] msg message to be saved. + * @param[in] a updateExisting flag that defines a saving strategy. If true the existing message is saved, otherwise a new message-copy is created. + * @param[out] result of storage operation. + * @return id of saved message. + */ + virtual MsgId saveMessage(Message &msg, bool updateExisting, StorageResult *result = nullptr) = 0; + + /** + * @brief Deletes single message with specified id. + * @param[in] id an id of message to be removed. + * @return true in case of successful deletion, otherwise false. + */ + virtual bool deleteMessage(MsgId id) = 0; + + /** + * @brief Deletes multiple messages with specified ids. + * @param[in] idList list of message-id to be removed. + * @return true in case of successful deletion, otherwise false. Also returns false if idList is empty. + */ + virtual bool deleteMessages(const MsgIdList &idList) = 0; + + /** + * @brief Performs search of a message based on a keyword. + * @param[in] word a search keyword. + * @return list of messages with text matched with a keyword. + */ + virtual MessageListRef searchMessage(const std::string &word) = 0; + + /** + * @brief Marks message with specified id as read. + * @param[in] id id of message to mark as read + * @param[in] new read-status a status of message. Set @c true if the message is read, otherwise set @c false if the message is not read + */ + virtual void setReadStatus(MsgId id, bool status) = 0; + + /** + * @brief Gets list of reports(Delivery/Read) relevand for mwssage with specified id. + * @param[in] msgId message-id. + * @return list of reports. + */ + virtual MsgReportListRef getMsgReportList(MsgId msgId) = 0; + + /** + * @brief Gets whether it requests read report or not + * @param[in] msgId message-id. + * @return true requests, false otherwise. + */ + virtual bool isReadReportChecked(MsgId msgId) = 0; + + /** + * @brief Gets whether it requests delivery report or not + * @param[in] msgId message-id. + * @return true requests, false otherwise. + */ + virtual bool isDeliverReportChecked(MsgId msgId) = 0; + + // Conversation: + /** + * @brief Gets conversation-list that belongs to thread with specified id. + * @param[in] id thread id. + * @return List of messages from thread. + */ + virtual MsgConversationListRef getConversationList(ThreadId id) = 0; + + /** + * @brief Gets an item from conversation-list corresponded to message with specified id. + * @param[in] id message id. + * @return Conversation-list item. + */ + virtual MsgConversationItemRef getConversationItem(MsgId id) = 0; + + protected: + typedef std::vector MsgStorageListeners; + + protected: + MsgStorageListeners m_Listeners; + }; + + + /** + * @brief A listener aimed to notify subscribers about message-storage events. + */ + class IMsgStorageListener + { + public: + virtual ~IMsgStorageListener() {}; + + /** + * @brief Message-storage updates for the given messages. + * @param[in] msgIdList list of message identifiers relevant to this notification. + */ + virtual void onMsgStorageUpdate(const MsgIdList &msgIdList) {}; + + /** + * @brief Notification about new messages addition. + * @param[in] msgIdList list of message identifiers relevant to this notification. + */ + virtual void onMsgStorageInsert(const MsgIdList &msgIdList) {}; + + /** + * @brief Notification about new messages deletion. + * @param[in] msgIdList list of message identifiers relevant to this notification. + */ + virtual void onMsgStorageDelete(const MsgIdList &msgIdList) {}; + + /** + * @brief Notifies that recipient stored in contacts was updated. + * @param[in] msgIdList list of message identifiers relevant to this notification. + */ + virtual void onMsgStorageContact(const MsgIdList &msgIdList) {}; + + /** + * @brief Message-storage updates for the given thread. + * @param[in] threadId Id of updated conversation. + */ + virtual void onMsgStorageThreadUpdate(const ThreadId &threadId) {}; + + /** + * @brief Notification about new thread addition. + * @param[in] threadId Id of created conversation. + */ + virtual void onMsgStorageThreadInsert(const ThreadId &threadId) {}; + + /** + * @brief Notification about thread deletion. + * @param[in] threadId Id of deleted conversation. + */ + virtual void onMsgStorageThreadDelete(const ThreadId &threadId) {}; + + /** + * @brief Notifies that recipient stored in contacts was updated. + * @param[in] threadId Id of conversation identifier relevant to this notification. + */ + virtual void onMsgStorageThreadContact(const ThreadId &threadId) {}; + }; } #endif /* __MSG_STORAGE_H__ */ diff --git a/src/Common/MsgEngine/inc/MsgThreadItem.h b/src/Common/MsgEngine/inc/MsgThreadItem.h index 42a49177..279273c7 100644 --- a/src/Common/MsgEngine/inc/MsgThreadItem.h +++ b/src/Common/MsgEngine/inc/MsgThreadItem.h @@ -24,65 +24,65 @@ #include namespace Msg { - class MsgThreadItem; - typedef std::shared_ptr MsgThreadItemRef; - typedef std::shared_ptr> MsgThreadListRef; + class MsgThreadItem; + typedef std::shared_ptr MsgThreadItemRef; + typedef std::shared_ptr> MsgThreadListRef; - /** - * @brief An interface that should be implemented by data-structure responsible for accessing basic thread information. - */ - class MsgThreadItem { - public: - virtual ~MsgThreadItem(); + /** + * @brief An interface that should be implemented by data-structure responsible for accessing basic thread information. + */ + class MsgThreadItem { + public: + virtual ~MsgThreadItem(); - /** - * @brief Gets thread-id. - * @return thread-id. - */ - virtual ThreadId getId() const = 0; + /** + * @brief Gets thread-id. + * @return thread-id. + */ + virtual ThreadId getId() const = 0; - /** - * @brief Gets thread-name. - * @return thread-name. - */ - virtual std::string getName() const = 0; + /** + * @brief Gets thread-name. + * @return thread-name. + */ + virtual std::string getName() const = 0; - /** - * @brief Gets text of the latest message in the thread. - * @return text of last message. - */ - virtual std::string getLastMessage() const = 0; + /** + * @brief Gets text of the latest message in the thread. + * @return text of last message. + */ + virtual std::string getLastMessage() const = 0; - /** - * @brief Gets time when last message was updated\sent\received. - * @return thread's last message update/send/received time. - */ - virtual time_t getTime() const = 0; + /** + * @brief Gets time when last message was updated\sent\received. + * @return thread's last message update/send/received time. + */ + virtual time_t getTime() const = 0; - /** - * @brief Checks whether thread has draft message or not. - * @return true if there's draft message, otherwise false. - */ - virtual bool hasDraftMessage() const = 0; + /** + * @brief Checks whether thread has draft message or not. + * @return true if there's draft message, otherwise false. + */ + virtual bool hasDraftMessage() const = 0; - /** - * @brief Checks whether thread has failed message or not. - * @return true if there's failed message, otherwise false. - */ - virtual bool hasFailedMessage() const = 0; + /** + * @brief Checks whether thread has failed message or not. + * @return true if there's failed message, otherwise false. + */ + virtual bool hasFailedMessage() const = 0; - /** - * @brief Checks whether thread has message in progress of sending or not. - * @return false if no message from thread is sending now, otherwise trtue. - */ - virtual bool isSending() const = 0; + /** + * @brief Checks whether thread has message in progress of sending or not. + * @return false if no message from thread is sending now, otherwise trtue. + */ + virtual bool isSending() const = 0; - /** - * @brief Gets number of unread messages in thread. - * @return number of unread messages. - */ - virtual int getUnreadCount() const = 0; - }; + /** + * @brief Gets number of unread messages in thread. + * @return number of unread messages. + */ + virtual int getUnreadCount() const = 0; + }; } #endif /* __IMSG_THREAD_ITEM_H__ */ diff --git a/src/Common/MsgEngine/inc/MsgTransport.h b/src/Common/MsgEngine/inc/MsgTransport.h index 148bb304..1d55d218 100644 --- a/src/Common/MsgEngine/inc/MsgTransport.h +++ b/src/Common/MsgEngine/inc/MsgTransport.h @@ -23,71 +23,71 @@ #include "MsgReport.h" namespace Msg { - /** - * @brief Manages sending(receiving) messages activity. - */ - class MsgTransport { - public: - /** - * @brief Possible results message sending could cause to. - */ - enum SendResult { - SendSuccess = 0, /**< Sending successful.*/ - SendFail = -1, /**< Sending failure.*/ - SendNoSIM = -2, /**< No SIM was found.*/ - SendDPMRestricted = -3, /**< Sending message is restricted by DPM.*/ - SendReadReportNotReq = -4, /**< Read report not requested.*/ - SendReadReportAlreadySent = -5, /**< Read report already dent.*/ - }; + /** + * @brief Manages sending(receiving) messages activity. + */ + class MsgTransport { + public: + /** + * @brief Possible results message sending could cause to. + */ + enum SendResult { + SendSuccess = 0, /**< Sending successful.*/ + SendFail = -1, /**< Sending failure.*/ + SendNoSIM = -2, /**< No SIM was found.*/ + SendDPMRestricted = -3, /**< Sending message is restricted by DPM.*/ + SendReadReportNotReq = -4, /**< Read report not requested.*/ + SendReadReportAlreadySent = -5, /**< Read report already dent.*/ + }; - public: - MsgTransport(); - virtual ~MsgTransport(); + public: + MsgTransport(); + virtual ~MsgTransport(); - /** - * @brief Message-service specific implementation of sending message of any type(sms or mms). - * @param[in, out] msg a message to be sent. - * @param[out] threadId an id of thread the sent message belongs to. - * @return result-code. - */ - virtual SendResult sendMessage(Message &msg, ThreadId *threadId = nullptr) = 0; + /** + * @brief Message-service specific implementation of sending message of any type(sms or mms). + * @param[in, out] msg a message to be sent. + * @param[out] threadId an id of thread the sent message belongs to. + * @return result-code. + */ + virtual SendResult sendMessage(Message &msg, ThreadId *threadId = nullptr) = 0; - /** - * @brief General(for calling by client) implementation of sending message of any type(sms or mms). - * @param[in, out] msg a message to be sent. - * @param[out] threadId an id of thread the sent message belongs to. - * @return result-code. - */ - SendResult sendMessage(MessageRef &msg, ThreadId *threadId = nullptr); + /** + * @brief General(for calling by client) implementation of sending message of any type(sms or mms). + * @param[in, out] msg a message to be sent. + * @param[out] threadId an id of thread the sent message belongs to. + * @return result-code. + */ + SendResult sendMessage(MessageRef &msg, ThreadId *threadId = nullptr); - /** - * @brief Sending MMS. - * @param[in, out] msg a message to be sent. - * @param[out] threadId an id of thread the sent message belongs to. - * @return result-code. - */ - SendResult sendMessage(MessageMmsRef &msg, ThreadId *threadId = nullptr); + /** + * @brief Sending MMS. + * @param[in, out] msg a message to be sent. + * @param[out] threadId an id of thread the sent message belongs to. + * @return result-code. + */ + SendResult sendMessage(MessageMmsRef &msg, ThreadId *threadId = nullptr); - /** - * @brief Sending SMS. - * @param[in, out] msg a message to be sent. - * @param[out] threadId an id of thread the sent message belongs to. - * @return result-code. - */ - SendResult sendMessage(MessageSMSRef &msg, ThreadId *threadId = nullptr); + /** + * @brief Sending SMS. + * @param[in, out] msg a message to be sent. + * @param[out] threadId an id of thread the sent message belongs to. + * @return result-code. + */ + SendResult sendMessage(MessageSMSRef &msg, ThreadId *threadId = nullptr); - /** - * @brief Manually downloads MMS by demand. - * @param[in] msgId id of message to be downloaded. - */ - virtual SendResult retrieveMessage(MsgId msgId) = 0; + /** + * @brief Manually downloads MMS by demand. + * @param[in] msgId id of message to be downloaded. + */ + virtual SendResult retrieveMessage(MsgId msgId) = 0; - /** - * @brief Send read report (for MMS only) - * @param[in] msgId id of message (MMS) - */ - virtual SendResult sendReadReport(MsgId msgId, MsgReport::ReadStatus status) = 0; - }; + /** + * @brief Send read report (for MMS only) + * @param[in] msgId id of message (MMS) + */ + virtual SendResult sendReadReport(MsgId msgId, MsgReport::ReadStatus status) = 0; + }; } #endif /* _BASE_MSG_TRANSPORT_H__ */ diff --git a/src/Common/MsgEngine/inc/MsgTypes.h b/src/Common/MsgEngine/inc/MsgTypes.h index 8e373bec..100456d4 100644 --- a/src/Common/MsgEngine/inc/MsgTypes.h +++ b/src/Common/MsgEngine/inc/MsgTypes.h @@ -20,87 +20,87 @@ #include namespace Msg { - class BaseMsgId { - public: - typedef unsigned Type; - static const Type invalidId = 0; - - BaseMsgId() - : value(invalidId) - { - } - - BaseMsgId(Type id) - : value(id) - { - } - - BaseMsgId(const BaseMsgId &obj) - : value(obj.value) - { - } - - operator Type() const - { - return value; - } - - BaseMsgId &operator=(Type id) - { - value = id; - return *this; - } - - bool isValid() const - { - return value > 0; - } - - void reset() - { - value = 0; - } - - Type value; // implementation - }; - - class ThreadId - : public BaseMsgId { - using BaseMsgId::BaseMsgId; - }; - - class MsgId - : public BaseMsgId { - using BaseMsgId::BaseMsgId; - }; - - typedef std::vector MsgIdList; - - struct MsgTextMetric { - MsgTextMetric(); - void reset(); - - unsigned charsLeft; // Only for SMS - unsigned segmentsCount; // Only for SMS - unsigned bytes; // Only for SMS - bool isMms; - }; - - inline MsgTextMetric::MsgTextMetric() - : charsLeft(0) - , segmentsCount(0) - , bytes(0) - , isMms(false) - { - } - - inline void MsgTextMetric::reset() - { - charsLeft = 0; - segmentsCount = 0; - bytes = 0; - isMms = false; - } + class BaseMsgId { + public: + typedef unsigned Type; + static const Type invalidId = 0; + + BaseMsgId() + : value(invalidId) + { + } + + BaseMsgId(Type id) + : value(id) + { + } + + BaseMsgId(const BaseMsgId &obj) + : value(obj.value) + { + } + + operator Type() const + { + return value; + } + + BaseMsgId &operator=(Type id) + { + value = id; + return *this; + } + + bool isValid() const + { + return value > 0; + } + + void reset() + { + value = 0; + } + + Type value; // implementation + }; + + class ThreadId + : public BaseMsgId { + using BaseMsgId::BaseMsgId; + }; + + class MsgId + : public BaseMsgId { + using BaseMsgId::BaseMsgId; + }; + + typedef std::vector MsgIdList; + + struct MsgTextMetric { + MsgTextMetric(); + void reset(); + + unsigned charsLeft; // Only for SMS + unsigned segmentsCount; // Only for SMS + unsigned bytes; // Only for SMS + bool isMms; + }; + + inline MsgTextMetric::MsgTextMetric() + : charsLeft(0) + , segmentsCount(0) + , bytes(0) + , isMms(false) + { + } + + inline void MsgTextMetric::reset() + { + charsLeft = 0; + segmentsCount = 0; + bytes = 0; + isMms = false; + } } #endif /* MSGTYPES_H_ */ diff --git a/src/Common/MsgEngine/inc/MsgUtils.h b/src/Common/MsgEngine/inc/MsgUtils.h index fc119ec5..b8850bb1 100644 --- a/src/Common/MsgEngine/inc/MsgUtils.h +++ b/src/Common/MsgEngine/inc/MsgUtils.h @@ -26,24 +26,24 @@ #include namespace Msg { - struct TokenizedRecipients { - std::list> validResults; - std::string invalidResult; - }; + struct TokenizedRecipients { + std::list> validResults; + std::string invalidResult; + }; - class MsgUtils { - public: - static TokenizedRecipients tokenizeRecipients(const std::string &inputText); - static bool isValidNumber(const std::string &address); - static bool isValidEmail(const std::string &address); - static bool isValidAddress(const std::string &address); - static MsgAddress::AddressType getAddressType(const std::string &address); - static std::string makeNormalizedNumber(const std::string &number); - static std::string makeCleanedNumber(const std::string &number); - static bool isMms(Message::Type type); - static bool isSms(Message::Type type); - static std::string makeKbStr(long long bytes); - }; + class MsgUtils { + public: + static TokenizedRecipients tokenizeRecipients(const std::string &inputText); + static bool isValidNumber(const std::string &address); + static bool isValidEmail(const std::string &address); + static bool isValidAddress(const std::string &address); + static MsgAddress::AddressType getAddressType(const std::string &address); + static std::string makeNormalizedNumber(const std::string &number); + static std::string makeCleanedNumber(const std::string &number); + static bool isMms(Message::Type type); + static bool isSms(Message::Type type); + static std::string makeKbStr(long long bytes); + }; } #endif /* MsgUtils_H_ */ diff --git a/src/Common/MsgEngine/src/MsgEngine.cpp b/src/Common/MsgEngine/src/MsgEngine.cpp index ee3b41b9..f8a85f00 100644 --- a/src/Common/MsgEngine/src/MsgEngine.cpp +++ b/src/Common/MsgEngine/src/MsgEngine.cpp @@ -34,33 +34,33 @@ const std::string handleIsNullStr = "MsgHandle is null!"; const std::string notImplPublicStr = "Msg. public API is not implemented"; MsgEngine::MsgEngine() - : m_MsgHandle(nullptr) + : m_MsgHandle(nullptr) { } MsgEngine::~MsgEngine() { - closeService(); + closeService(); } int MsgEngine::openService() { - TRACE; - if (m_MsgHandle) { - MSG_LOG_ERROR("Handle already has been opened"); - } - int result = 0; + TRACE; + if (m_MsgHandle) { + MSG_LOG_ERROR("Handle already has been opened"); + } + int result = 0; #ifdef TIZEN_PRIVATE_API - result = msg_open_msg_handle(&m_MsgHandle); - MSG_LOG("handle open error = ", result); + result = msg_open_msg_handle(&m_MsgHandle); + MSG_LOG("handle open error = ", result); - m_Storage.reset(new MsgStoragePrivate(m_MsgHandle)); - m_Transport.reset(new MsgTransportPrivate(m_MsgHandle)); - m_Composer.reset(new MsgComposerPrivate()); + m_Storage.reset(new MsgStoragePrivate(m_MsgHandle)); + m_Transport.reset(new MsgTransportPrivate(m_MsgHandle)); + m_Composer.reset(new MsgComposerPrivate()); #else - // TODO: impl for public API + // TODO: impl for public API result = messages_open_service(&m_MsgHandle); @@ -70,391 +70,391 @@ int MsgEngine::openService() }*/ #endif - return result; + return result; } int MsgEngine::closeService() { - int result = 0; - if (m_MsgHandle) { + int result = 0; + if (m_MsgHandle) { #ifdef TIZEN_PRIVATE_API - result = msg_close_msg_handle(&m_MsgHandle); + result = msg_close_msg_handle(&m_MsgHandle); #else - result = messages_close_service(m_MsgHandle); + result = messages_close_service(m_MsgHandle); #endif - m_MsgHandle = nullptr; - } - return result; + m_MsgHandle = nullptr; + } + return result; } bool MsgEngine::isReady(std::string &errorMsg) const { #ifdef TIZEN_PRIVATE_API - if (!m_MsgHandle) { - errorMsg = handleIsNullStr; - return false; - } + if (!m_MsgHandle) { + errorMsg = handleIsNullStr; + return false; + } #else - errorMsg = notImplPublicStr; - return false; + errorMsg = notImplPublicStr; + return false; #endif - return true; + return true; } MsgStorage &MsgEngine::getStorage() { - assert(m_Storage.get()); - return *m_Storage; + assert(m_Storage.get()); + return *m_Storage; } const MsgStorage &MsgEngine::getStorage() const { - assert(m_Storage.get()); - return *m_Storage; + assert(m_Storage.get()); + return *m_Storage; } MsgTransport &MsgEngine::getTransport() { - assert(m_Transport.get()); - return *m_Transport; + assert(m_Transport.get()); + return *m_Transport; } const MsgTransport &MsgEngine::getTransport() const { - assert(m_Transport.get()); - return *m_Transport; + assert(m_Transport.get()); + return *m_Transport; } MsgSettings &MsgEngine::getSettings() { - if (!m_Settings.get()) - m_Settings.reset(new MsgSettingsPrivate(m_MsgHandle)); - return *m_Settings; + if (!m_Settings.get()) + m_Settings.reset(new MsgSettingsPrivate(m_MsgHandle)); + return *m_Settings; } const MsgSettings &MsgEngine::getSettings() const { - return const_cast(this)->getSettings(); + return const_cast(this)->getSettings(); } MsgComposer &MsgEngine::getComposer() { - assert(m_Composer.get()); - return *m_Composer; + assert(m_Composer.get()); + return *m_Composer; } const MsgComposer &MsgEngine::getComposer() const { - assert(m_Composer.get()); - return *m_Composer; + assert(m_Composer.get()); + return *m_Composer; } std::string MsgEngine::whatError(int error) { #ifdef TIZEN_PRIVATE_API - switch (error) { - case MSG_SUCCESS: - return "MSG_SUCCESS"; - break; - case MSG_ERR_NULL_MSGHANDLE: - return "MSG_ERR_NULL_MSGHANDLE"; - break; - case MSG_ERR_NULL_POINTER: - return "MSG_ERR_NULL_POINTER"; - break; - case MSG_ERR_NULL_MESSAGE: - return "MSG_ERR_NULL_MESSAGE"; - break; - case MSG_ERR_INVALID_STORAGE_ID: - return "MSG_ERR_INVALID_STORAGE_ID"; - break; - case MSG_ERR_INVALID_MSG_TYPE: - return "MSG_ERR_INVALID_MSG_TYPE"; - break; - case MSG_ERR_INVALID_STORAGE_REG: - return "MSG_ERR_INVALID_STORAGE_REG"; - break; - case MSG_ERR_INVALID_MESSAGE_ID: - return "MSG_ERR_INVALID_MESSAGE_ID"; - break; - case MSG_ERR_INVALID_MSGHANDLE: - return "MSG_ERR_INVALID_MSGHANDLE"; - break; - case MSG_ERR_INVALID_PARAMETER: - return "MSG_ERR_INVALID_PARAMETER"; - break; - case MSG_ERR_INVALID_MESSAGE: - return "MSG_ERR_INVALID_MESSAGE"; - break; - case MSG_ERR_INVALID_PLUGIN_HANDLE: - return "MSG_ERR_INVALID_PLUGIN_HANDLE"; - break; - case MSG_ERR_MEMORY_ERROR: - return "MSG_ERR_MEMORY_ERROR"; - break; - case MSG_ERR_COMMUNICATION_ERROR: - return "MSG_ERR_COMMUNICATION_ERROR"; - break; - case MSG_ERR_SIM_STORAGE_FULL: - return "MSG_ERR_SIM_STORAGE_FULL"; - break; - case MSG_ERR_TRANSPORT_ERROR: - return "MSG_ERR_TRANSPORT_ERROR"; - break; - case MSG_ERR_CALLBACK_ERROR: - return "MSG_ERR_CALLBACK_ERROR"; - break; - case MSG_ERR_STORAGE_ERROR: - return "MSG_ERR_STORAGE_ERROR"; - break; - case MSG_ERR_FILTER_ERROR: - return "MSG_ERR_FILTER_ERROR"; - break; - case MSG_ERR_MMS_ERROR: - return "MSG_ERR_MMS_ERROR"; - break; - case MSG_ERR_MMPLAYER_CREATE: - return "MSG_ERR_MMPLAYER_CREATE"; - break; - case MSG_ERR_MMPLAYER_SET_ATTRS: - return "MSG_ERR_MMPLAYER_SET_ATTRS"; - break; - case MSG_ERR_MMPLAYER_REALIZE: - return "MSG_ERR_MMPLAYER_REALIZE"; - break; - case MSG_ERR_MMPLAYER_PLAY: - return "MSG_ERR_MMPLAYER_PLAY"; - break; - case MSG_ERR_MMPLAYER_STOP: - return "MSG_ERR_MMPLAYER_STOP"; - break; - case MSG_ERR_MMPLAYER_DESTROY: - return "MSG_ERR_MMPLAYER_DESTROY"; - break; - case MSG_ERR_UNKNOWN: - return "MSG_ERR_UNKNOWN"; - break; - case MSG_ERR_DB_CONNECT: - return "MSG_ERR_DB_CONNECT"; - break; - case MSG_ERR_DB_DISCONNECT: - return "MSG_ERR_DB_DISCONNECT"; - break; - case MSG_ERR_DB_EXEC: - return "MSG_ERR_DB_EXEC"; - break; - case MSG_ERR_DB_GETTABLE: - return "MSG_ERR_DB_GETTABLE"; - break; - case MSG_ERR_DB_PREPARE: - return "MSG_ERR_DB_PREPARE"; - break; - case MSG_ERR_DB_STEP: - return "MSG_ERR_DB_STEP"; - break; - case MSG_ERR_DB_NORECORD: - return "MSG_ERR_DB_NORECORD"; - break; - case MSG_ERR_DB_STORAGE_INIT: - return "MSG_ERR_DB_STORAGE_INIT"; - break; - case MSG_ERR_DB_MAKE_DIR: - return "MSG_ERR_DB_MAKE_DIR"; - break; - case MSG_ERR_DB_ROW: - return "MSG_ERR_DB_ROW"; - break; - case MSG_ERR_DB_DONE: - return "MSG_ERR_DB_DONE"; - break; - case MSG_ERR_DB_GENERIC: - return "MSG_ERR_DB_GENERIC"; - break; - case MSG_ERR_DB_END: - return "MSG_ERR_DB_END"; - break; - case MSG_ERR_SET_SETTING: - return "MSG_ERR_SET_SETTING"; - break; - case MSG_ERR_SET_SIM_SET: - return "MSG_ERR_SET_SIM_SET"; - break; - case MSG_ERR_SET_READ_ERROR: - return "MSG_ERR_SET_READ_ERROR"; - break; - case MSG_ERR_SET_WRITE_ERROR: - return "MSG_ERR_SET_WRITE_ERROR"; - break; - case MSG_ERR_SET_DELETE_ERROR: - return "MSG_ERR_SET_DELETE_ERROR"; - break; - case MSG_ERR_PLUGIN_TAPIINIT: - return "MSG_ERR_PLUGIN_TAPIINIT"; - break; - case MSG_ERR_PLUGIN_REGEVENT: - return "MSG_ERR_PLUGIN_REGEVENT"; - break; - case MSG_ERR_PLUGIN_TRANSPORT: - return "MSG_ERR_PLUGIN_TRANSPORT"; - break; - case MSG_ERR_PLUGIN_STORAGE: - return "MSG_ERR_PLUGIN_STORAGE"; - break; - case MSG_ERR_PLUGIN_SETTING: - return "MSG_ERR_PLUGIN_SETTING"; - break; - case MSG_ERR_PLUGIN_WAPDECODE: - return "MSG_ERR_PLUGIN_WAPDECODE"; - break; - case MSG_ERR_PLUGIN_TAPI_FAILED: - return "MSG_ERR_PLUGIN_TAPI_FAILED"; - break; - case MSG_ERR_PLUGIN_SIM_MSG_FULL: - return "MSG_ERR_PLUGIN_SIM_MSG_FULL"; - break; - case MSG_ERR_MESSAGE_COUNT_FULL: - return "MSG_ERR_MESSAGE_COUNT_FULL"; - break; - case MSG_ERR_READREPORT_NOT_REQUESTED: - return "MSG_ERR_READREPORT_NOT_REQUESTED"; - break; - case MSG_ERR_READREPORT_ALEADY_SENT: - return "MSG_ERR_READREPORT_ALEADY_SENT"; - break; - case MSG_ERR_FILTER_DUPLICATED: - return "MSG_ERR_FILTER_DUPLICATED"; - break; - case MSG_ERR_PERMISSION_DENIED: - return "MSG_ERR_PERMISSION_DENIED"; - break; - case MSG_ERR_NO_SIM: - return "MSG_ERR_NO_SIM"; - break; - case MSG_ERR_SERVER_NOT_READY: - return "MSG_ERR_SERVER_NOT_READY"; - break; - case MSG_ERR_STORE_RESTRICT: - return "MSG_ERR_STORE_RESTRICT"; - break; - case MSG_ERR_DB_BUSY: - return "MSG_ERR_DB_BUSY"; - break; - case MSG_ERR_NOT_SUPPORTED: - return "MSG_ERR_NOT_SUPPORTED"; - break; - case MSG_ERR_NOT_ALLOWED_ZONE: - return "MSG_ERR_NOT_ALLOWED_ZONE"; - break; - case MSG_ERR_DPM_RESTRICT: - return "MSG_ERR_DPM_RESTRICT"; - break; - default: - return "SOME ANOTHER ERROR"; - break; - } + switch (error) { + case MSG_SUCCESS: + return "MSG_SUCCESS"; + break; + case MSG_ERR_NULL_MSGHANDLE: + return "MSG_ERR_NULL_MSGHANDLE"; + break; + case MSG_ERR_NULL_POINTER: + return "MSG_ERR_NULL_POINTER"; + break; + case MSG_ERR_NULL_MESSAGE: + return "MSG_ERR_NULL_MESSAGE"; + break; + case MSG_ERR_INVALID_STORAGE_ID: + return "MSG_ERR_INVALID_STORAGE_ID"; + break; + case MSG_ERR_INVALID_MSG_TYPE: + return "MSG_ERR_INVALID_MSG_TYPE"; + break; + case MSG_ERR_INVALID_STORAGE_REG: + return "MSG_ERR_INVALID_STORAGE_REG"; + break; + case MSG_ERR_INVALID_MESSAGE_ID: + return "MSG_ERR_INVALID_MESSAGE_ID"; + break; + case MSG_ERR_INVALID_MSGHANDLE: + return "MSG_ERR_INVALID_MSGHANDLE"; + break; + case MSG_ERR_INVALID_PARAMETER: + return "MSG_ERR_INVALID_PARAMETER"; + break; + case MSG_ERR_INVALID_MESSAGE: + return "MSG_ERR_INVALID_MESSAGE"; + break; + case MSG_ERR_INVALID_PLUGIN_HANDLE: + return "MSG_ERR_INVALID_PLUGIN_HANDLE"; + break; + case MSG_ERR_MEMORY_ERROR: + return "MSG_ERR_MEMORY_ERROR"; + break; + case MSG_ERR_COMMUNICATION_ERROR: + return "MSG_ERR_COMMUNICATION_ERROR"; + break; + case MSG_ERR_SIM_STORAGE_FULL: + return "MSG_ERR_SIM_STORAGE_FULL"; + break; + case MSG_ERR_TRANSPORT_ERROR: + return "MSG_ERR_TRANSPORT_ERROR"; + break; + case MSG_ERR_CALLBACK_ERROR: + return "MSG_ERR_CALLBACK_ERROR"; + break; + case MSG_ERR_STORAGE_ERROR: + return "MSG_ERR_STORAGE_ERROR"; + break; + case MSG_ERR_FILTER_ERROR: + return "MSG_ERR_FILTER_ERROR"; + break; + case MSG_ERR_MMS_ERROR: + return "MSG_ERR_MMS_ERROR"; + break; + case MSG_ERR_MMPLAYER_CREATE: + return "MSG_ERR_MMPLAYER_CREATE"; + break; + case MSG_ERR_MMPLAYER_SET_ATTRS: + return "MSG_ERR_MMPLAYER_SET_ATTRS"; + break; + case MSG_ERR_MMPLAYER_REALIZE: + return "MSG_ERR_MMPLAYER_REALIZE"; + break; + case MSG_ERR_MMPLAYER_PLAY: + return "MSG_ERR_MMPLAYER_PLAY"; + break; + case MSG_ERR_MMPLAYER_STOP: + return "MSG_ERR_MMPLAYER_STOP"; + break; + case MSG_ERR_MMPLAYER_DESTROY: + return "MSG_ERR_MMPLAYER_DESTROY"; + break; + case MSG_ERR_UNKNOWN: + return "MSG_ERR_UNKNOWN"; + break; + case MSG_ERR_DB_CONNECT: + return "MSG_ERR_DB_CONNECT"; + break; + case MSG_ERR_DB_DISCONNECT: + return "MSG_ERR_DB_DISCONNECT"; + break; + case MSG_ERR_DB_EXEC: + return "MSG_ERR_DB_EXEC"; + break; + case MSG_ERR_DB_GETTABLE: + return "MSG_ERR_DB_GETTABLE"; + break; + case MSG_ERR_DB_PREPARE: + return "MSG_ERR_DB_PREPARE"; + break; + case MSG_ERR_DB_STEP: + return "MSG_ERR_DB_STEP"; + break; + case MSG_ERR_DB_NORECORD: + return "MSG_ERR_DB_NORECORD"; + break; + case MSG_ERR_DB_STORAGE_INIT: + return "MSG_ERR_DB_STORAGE_INIT"; + break; + case MSG_ERR_DB_MAKE_DIR: + return "MSG_ERR_DB_MAKE_DIR"; + break; + case MSG_ERR_DB_ROW: + return "MSG_ERR_DB_ROW"; + break; + case MSG_ERR_DB_DONE: + return "MSG_ERR_DB_DONE"; + break; + case MSG_ERR_DB_GENERIC: + return "MSG_ERR_DB_GENERIC"; + break; + case MSG_ERR_DB_END: + return "MSG_ERR_DB_END"; + break; + case MSG_ERR_SET_SETTING: + return "MSG_ERR_SET_SETTING"; + break; + case MSG_ERR_SET_SIM_SET: + return "MSG_ERR_SET_SIM_SET"; + break; + case MSG_ERR_SET_READ_ERROR: + return "MSG_ERR_SET_READ_ERROR"; + break; + case MSG_ERR_SET_WRITE_ERROR: + return "MSG_ERR_SET_WRITE_ERROR"; + break; + case MSG_ERR_SET_DELETE_ERROR: + return "MSG_ERR_SET_DELETE_ERROR"; + break; + case MSG_ERR_PLUGIN_TAPIINIT: + return "MSG_ERR_PLUGIN_TAPIINIT"; + break; + case MSG_ERR_PLUGIN_REGEVENT: + return "MSG_ERR_PLUGIN_REGEVENT"; + break; + case MSG_ERR_PLUGIN_TRANSPORT: + return "MSG_ERR_PLUGIN_TRANSPORT"; + break; + case MSG_ERR_PLUGIN_STORAGE: + return "MSG_ERR_PLUGIN_STORAGE"; + break; + case MSG_ERR_PLUGIN_SETTING: + return "MSG_ERR_PLUGIN_SETTING"; + break; + case MSG_ERR_PLUGIN_WAPDECODE: + return "MSG_ERR_PLUGIN_WAPDECODE"; + break; + case MSG_ERR_PLUGIN_TAPI_FAILED: + return "MSG_ERR_PLUGIN_TAPI_FAILED"; + break; + case MSG_ERR_PLUGIN_SIM_MSG_FULL: + return "MSG_ERR_PLUGIN_SIM_MSG_FULL"; + break; + case MSG_ERR_MESSAGE_COUNT_FULL: + return "MSG_ERR_MESSAGE_COUNT_FULL"; + break; + case MSG_ERR_READREPORT_NOT_REQUESTED: + return "MSG_ERR_READREPORT_NOT_REQUESTED"; + break; + case MSG_ERR_READREPORT_ALEADY_SENT: + return "MSG_ERR_READREPORT_ALEADY_SENT"; + break; + case MSG_ERR_FILTER_DUPLICATED: + return "MSG_ERR_FILTER_DUPLICATED"; + break; + case MSG_ERR_PERMISSION_DENIED: + return "MSG_ERR_PERMISSION_DENIED"; + break; + case MSG_ERR_NO_SIM: + return "MSG_ERR_NO_SIM"; + break; + case MSG_ERR_SERVER_NOT_READY: + return "MSG_ERR_SERVER_NOT_READY"; + break; + case MSG_ERR_STORE_RESTRICT: + return "MSG_ERR_STORE_RESTRICT"; + break; + case MSG_ERR_DB_BUSY: + return "MSG_ERR_DB_BUSY"; + break; + case MSG_ERR_NOT_SUPPORTED: + return "MSG_ERR_NOT_SUPPORTED"; + break; + case MSG_ERR_NOT_ALLOWED_ZONE: + return "MSG_ERR_NOT_ALLOWED_ZONE"; + break; + case MSG_ERR_DPM_RESTRICT: + return "MSG_ERR_DPM_RESTRICT"; + break; + default: + return "SOME ANOTHER ERROR"; + break; + } #else - switch (error) { - case MESSAGES_ERROR_NONE: - return "MESSAGES_ERROR_NONE"; - break; - case MESSAGES_ERROR_OUT_OF_MEMORY: - return "MESSAGES_ERROR_OUT_OF_MEMORY"; - break; - case MESSAGES_ERROR_INVALID_PARAMETER: - return "MESSAGES_ERROR_INVALID_PARAMETER"; - break; - case MESSAGES_ERROR_SERVER_NOT_READY: - return "MESSAGES_ERROR_SERVER_NOT_READY"; - break; - case MESSAGES_ERROR_COMMUNICATION_WITH_SERVER_FAILED: - return "MESSAGES_ERROR_COMMUNICATION_WITH_SERVER_FAILED"; - break; - case MESSAGES_ERROR_OUT_OF_RANGE: - return "MESSAGES_ERROR_OUT_OF_RANGE"; - break; - case MESSAGES_ERROR_SENDING_FAILED: - return "MESSAGES_ERROR_SENDING_FAILED"; - break; - case MESSAGES_ERROR_OPERATION_FAILED: - return "MESSAGES_ERROR_OPERATION_FAILED"; - break; - case MESSAGES_ERROR_NO_SIM_CARD: - return "MESSAGES_ERROR_NO_SIM_CARD"; - break; - case MESSAGES_ERROR_NO_DATA: - return "MESSAGES_ERROR_NO_DATA"; - break; - case MESSAGES_ERROR_PERMISSION_DENIED: - return "MESSAGES_ERROR_PERMISSION_DENIED"; - break; - case MESSAGES_ERROR_NOT_SUPPORTED: - return "MESSAGES_ERROR_NOT_SUPPORTED"; - break; - default: - return "SOME ANOTHER ERROR"; - break; - } + switch (error) { + case MESSAGES_ERROR_NONE: + return "MESSAGES_ERROR_NONE"; + break; + case MESSAGES_ERROR_OUT_OF_MEMORY: + return "MESSAGES_ERROR_OUT_OF_MEMORY"; + break; + case MESSAGES_ERROR_INVALID_PARAMETER: + return "MESSAGES_ERROR_INVALID_PARAMETER"; + break; + case MESSAGES_ERROR_SERVER_NOT_READY: + return "MESSAGES_ERROR_SERVER_NOT_READY"; + break; + case MESSAGES_ERROR_COMMUNICATION_WITH_SERVER_FAILED: + return "MESSAGES_ERROR_COMMUNICATION_WITH_SERVER_FAILED"; + break; + case MESSAGES_ERROR_OUT_OF_RANGE: + return "MESSAGES_ERROR_OUT_OF_RANGE"; + break; + case MESSAGES_ERROR_SENDING_FAILED: + return "MESSAGES_ERROR_SENDING_FAILED"; + break; + case MESSAGES_ERROR_OPERATION_FAILED: + return "MESSAGES_ERROR_OPERATION_FAILED"; + break; + case MESSAGES_ERROR_NO_SIM_CARD: + return "MESSAGES_ERROR_NO_SIM_CARD"; + break; + case MESSAGES_ERROR_NO_DATA: + return "MESSAGES_ERROR_NO_DATA"; + break; + case MESSAGES_ERROR_PERMISSION_DENIED: + return "MESSAGES_ERROR_PERMISSION_DENIED"; + break; + case MESSAGES_ERROR_NOT_SUPPORTED: + return "MESSAGES_ERROR_NOT_SUPPORTED"; + break; + default: + return "SOME ANOTHER ERROR"; + break; + } #endif - return "SOME ANOTHER ERROR"; + return "SOME ANOTHER ERROR"; } void MsgEngine::calculateTextMetric(const std::string &text, MsgTextMetric &textMetric) { #ifdef TIZEN_PRIVATE_API - const int maxSegments = 3; - const int maxGsm7Len = 160; - const int maxUnicodeLen = 70; - - msg_encode_type_t encode = MSG_ENCODE_GSM7BIT; - unsigned textLen = 0; - unsigned segmentLen = 0; - int bytesInChar = 1; - textMetric.reset(); - - if (!text.empty()) { - if (msg_util_calculate_text_length(text.c_str(), MSG_ENCODE_AUTO, &textLen, &segmentLen, &encode) != 0) { - MSG_LOG_ERROR("msg_util_calculate_text_length returns error"); - } - - textMetric.bytes = textLen; - - switch (encode) { - case MSG_ENCODE_UCS2: - bytesInChar = 2; - break; - - case MSG_ENCODE_GSM7BIT: - case MSG_ENCODE_AUTO: - bytesInChar = 1; - break; - - default: - MSG_LOG_ERROR("Unknown encode type: ", encode); - break; - } - - textLen /= bytesInChar; - segmentLen /= bytesInChar; - } - - if (segmentLen == 0) - segmentLen = encode == MSG_ENCODE_UCS2 ? maxUnicodeLen : maxGsm7Len; - - if (textLen == 0) - textLen = text.length() / bytesInChar; - - textMetric.segmentsCount = (int)ceil((float)textLen / segmentLen); - if (textMetric.segmentsCount == 0) - textMetric.segmentsCount = 1; - - if (textLen > 0) - textMetric.charsLeft = (textMetric.segmentsCount * segmentLen) - textLen; - else - textMetric.charsLeft = maxGsm7Len; - - textMetric.isMms = textMetric.segmentsCount > maxSegments; + const int maxSegments = 3; + const int maxGsm7Len = 160; + const int maxUnicodeLen = 70; + + msg_encode_type_t encode = MSG_ENCODE_GSM7BIT; + unsigned textLen = 0; + unsigned segmentLen = 0; + int bytesInChar = 1; + textMetric.reset(); + + if (!text.empty()) { + if (msg_util_calculate_text_length(text.c_str(), MSG_ENCODE_AUTO, &textLen, &segmentLen, &encode) != 0) { + MSG_LOG_ERROR("msg_util_calculate_text_length returns error"); + } + + textMetric.bytes = textLen; + + switch (encode) { + case MSG_ENCODE_UCS2: + bytesInChar = 2; + break; + + case MSG_ENCODE_GSM7BIT: + case MSG_ENCODE_AUTO: + bytesInChar = 1; + break; + + default: + MSG_LOG_ERROR("Unknown encode type: ", encode); + break; + } + + textLen /= bytesInChar; + segmentLen /= bytesInChar; + } + + if (segmentLen == 0) + segmentLen = encode == MSG_ENCODE_UCS2 ? maxUnicodeLen : maxGsm7Len; + + if (textLen == 0) + textLen = text.length() / bytesInChar; + + textMetric.segmentsCount = (int)ceil((float)textLen / segmentLen); + if (textMetric.segmentsCount == 0) + textMetric.segmentsCount = 1; + + if (textLen > 0) + textMetric.charsLeft = (textMetric.segmentsCount * segmentLen) - textLen; + else + textMetric.charsLeft = maxGsm7Len; + + textMetric.isMms = textMetric.segmentsCount > maxSegments; #endif } diff --git a/src/Common/MsgEngine/src/MsgPage.cpp b/src/Common/MsgEngine/src/MsgPage.cpp index 0ef3fbfc..807b3992 100644 --- a/src/Common/MsgEngine/src/MsgPage.cpp +++ b/src/Common/MsgEngine/src/MsgPage.cpp @@ -25,5 +25,5 @@ MsgPage::~MsgPage() const MsgMediaList &MsgPage::getMediaList() const { - return const_cast(*this).getMediaList(); + return const_cast(*this).getMediaList(); } diff --git a/src/Common/MsgEngine/src/MsgSettings.cpp b/src/Common/MsgEngine/src/MsgSettings.cpp index f5f9fb73..47481208 100644 --- a/src/Common/MsgEngine/src/MsgSettings.cpp +++ b/src/Common/MsgEngine/src/MsgSettings.cpp @@ -34,30 +34,30 @@ MsgSettings::~MsgSettings() int MsgSettings::getMessageTextMaxChar() const { - return defaultSmsGsm7MaxLen; + return defaultSmsGsm7MaxLen; } int MsgSettings::getMessageMaxPage() const { - return defaultSmsMaxPage; + return defaultSmsMaxPage; } int MsgSettings::getAttachmentsMaxCount() const { - return defaultMaxAttachmentsCount; + return defaultMaxAttachmentsCount; } void MsgSettings::addListener(IMsgSettingsListener &listener) { - auto itr = std::find(m_Listeners.begin(), m_Listeners.end(), &listener); - if (itr == m_Listeners.end()) - m_Listeners.push_back(&listener); + auto itr = std::find(m_Listeners.begin(), m_Listeners.end(), &listener); + if (itr == m_Listeners.end()) + m_Listeners.push_back(&listener); } void MsgSettings::removeListener(IMsgSettingsListener &listener) { - auto itr = std::find(m_Listeners.begin(), m_Listeners.end(), &listener); - if (itr != m_Listeners.end()) - m_Listeners.erase(itr); + auto itr = std::find(m_Listeners.begin(), m_Listeners.end(), &listener); + if (itr != m_Listeners.end()) + m_Listeners.erase(itr); } diff --git a/src/Common/MsgEngine/src/MsgStorage.cpp b/src/Common/MsgEngine/src/MsgStorage.cpp index 73d41b30..4f129738 100644 --- a/src/Common/MsgEngine/src/MsgStorage.cpp +++ b/src/Common/MsgEngine/src/MsgStorage.cpp @@ -23,7 +23,7 @@ using namespace Msg; MsgStorage::MsgStorage() { - TRACE; + TRACE; } MsgStorage::~MsgStorage() @@ -32,32 +32,32 @@ MsgStorage::~MsgStorage() void MsgStorage::addListener(IMsgStorageListener &listener) { - auto itr = std::find(m_Listeners.begin(), m_Listeners.end(), &listener); - if (itr == m_Listeners.end()) - m_Listeners.push_back(&listener); + auto itr = std::find(m_Listeners.begin(), m_Listeners.end(), &listener); + if (itr == m_Listeners.end()) + m_Listeners.push_back(&listener); } void MsgStorage::removeListener(IMsgStorageListener &listener) { - auto itr = std::find(m_Listeners.begin(), m_Listeners.end(), &listener); - if (itr != m_Listeners.end()) - m_Listeners.erase(itr); + auto itr = std::find(m_Listeners.begin(), m_Listeners.end(), &listener); + if (itr != m_Listeners.end()) + m_Listeners.erase(itr); } bool MsgStorage::hasEmail(ThreadId id) { - if (!id.isValid()) - return false; - - const MsgAddressListRef addressList = getAddressList(id); - if (addressList) { - for (int i = 0; i < addressList->getLength(); ++i) { - const MsgAddress &msgAddr = addressList->at(i); - if (msgAddr.getAddressType() == MsgAddress::Email) - return true; - else if (MsgUtils::isValidEmail(msgAddr.getAddress())) - return true; - } - } - return false; + if (!id.isValid()) + return false; + + const MsgAddressListRef addressList = getAddressList(id); + if (addressList) { + for (int i = 0; i < addressList->getLength(); ++i) { + const MsgAddress &msgAddr = addressList->at(i); + if (msgAddr.getAddressType() == MsgAddress::Email) + return true; + else if (MsgUtils::isValidEmail(msgAddr.getAddress())) + return true; + } + } + return false; } diff --git a/src/Common/MsgEngine/src/MsgTransport.cpp b/src/Common/MsgEngine/src/MsgTransport.cpp index c922d893..63ab1134 100644 --- a/src/Common/MsgEngine/src/MsgTransport.cpp +++ b/src/Common/MsgEngine/src/MsgTransport.cpp @@ -28,15 +28,15 @@ MsgTransport::~MsgTransport() MsgTransport::SendResult MsgTransport::sendMessage(MessageRef &msg, ThreadId *threadId) { - return msg ? sendMessage(*msg, threadId) : MsgTransport::SendFail; + return msg ? sendMessage(*msg, threadId) : MsgTransport::SendFail; } MsgTransport::SendResult MsgTransport::sendMessage(MessageMmsRef &msg, ThreadId *threadId) { - return msg ? sendMessage(*msg, threadId) : MsgTransport::SendFail; + return msg ? sendMessage(*msg, threadId) : MsgTransport::SendFail; } MsgTransport::SendResult MsgTransport::sendMessage(MessageSMSRef &msg, ThreadId *threadId) { - return msg ? sendMessage(*msg, threadId) : MsgTransport::SendFail; + return msg ? sendMessage(*msg, threadId) : MsgTransport::SendFail; } diff --git a/src/Common/MsgEngine/src/MsgUtils.cpp b/src/Common/MsgEngine/src/MsgUtils.cpp index 4ebd43df..2c94c4b9 100644 --- a/src/Common/MsgEngine/src/MsgUtils.cpp +++ b/src/Common/MsgEngine/src/MsgUtils.cpp @@ -26,130 +26,130 @@ using namespace Msg; namespace { - unsigned emailAddrLenMax = 256; - const char *delimiters = ",;"; - const char *numberRegex = "\\+?([[:digit:]][ *\\(\\)-]*){2,14}[[:digit:]]$"; - const char *emailRegex = "(?:(?:[^<>()\\[\\].,;:\\s@\"]+(?:\\.[^<>()\\[\\].,;:\\s@\"]+)*)|\".+\")@(?:(?:[^<>()‌​\\[\\].,;:\\s@\"]+\\.)+[^<>()\\[\\].,;:\\s@\"]{2,})"; + unsigned emailAddrLenMax = 256; + const char *delimiters = ",;"; + const char *numberRegex = "\\+?([[:digit:]][ *\\(\\)-]*){2,14}[[:digit:]]$"; + const char *emailRegex = "(?:(?:[^<>()\\[\\].,;:\\s@\"]+(?:\\.[^<>()\\[\\].,;:\\s@\"]+)*)|\".+\")@(?:(?:[^<>()‌​\\[\\].,;:\\s@\"]+\\.)+[^<>()\\[\\].,;:\\s@\"]{2,})"; } TokenizedRecipients MsgUtils::tokenizeRecipients(const std::string &inputText) { - TokenizedRecipients result; - std::string::size_type begin = inputText.find_first_not_of(delimiters); - std::string::size_type end = inputText.find_first_of(delimiters, begin); - std::string token; - MsgAddress::AddressType addressType = MsgAddress::UnknownAddressType; - - while (begin != end) { - if (begin != std::string::npos) { - token = inputText.substr(begin, end != std::string::npos ? end-begin : std::string::npos); - begin = inputText.find_first_not_of(delimiters, end); - result.invalidResult.append(token); - addressType = getAddressType(result.invalidResult); - if (addressType != MsgAddress::UnknownAddressType) { - result.validResults.push_back(std::make_pair(result.invalidResult, addressType)); - result.invalidResult.clear(); - } else if (end != std::string::npos) { - result.invalidResult.append(inputText.substr(end, begin != std::string::npos ? begin-end : std::string::npos)); - } - end = inputText.find_first_of(delimiters, begin); - } - } - - return result; + TokenizedRecipients result; + std::string::size_type begin = inputText.find_first_not_of(delimiters); + std::string::size_type end = inputText.find_first_of(delimiters, begin); + std::string token; + MsgAddress::AddressType addressType = MsgAddress::UnknownAddressType; + + while (begin != end) { + if (begin != std::string::npos) { + token = inputText.substr(begin, end != std::string::npos ? end-begin : std::string::npos); + begin = inputText.find_first_not_of(delimiters, end); + result.invalidResult.append(token); + addressType = getAddressType(result.invalidResult); + if (addressType != MsgAddress::UnknownAddressType) { + result.validResults.push_back(std::make_pair(result.invalidResult, addressType)); + result.invalidResult.clear(); + } else if (end != std::string::npos) { + result.invalidResult.append(inputText.substr(end, begin != std::string::npos ? begin-end : std::string::npos)); + } + end = inputText.find_first_of(delimiters, begin); + } + } + + return result; } bool MsgUtils::isValidNumber(const std::string &address) { - if (address.empty()) - return false; - try { - std::regex numTemplate(numberRegex); - return std::regex_match(address, numTemplate); - } catch (const std::regex_error& e) { - MSG_LOG_ERROR("std::regex_error"); - return false; - } + if (address.empty()) + return false; + try { + std::regex numTemplate(numberRegex); + return std::regex_match(address, numTemplate); + } catch (const std::regex_error& e) { + MSG_LOG_ERROR("std::regex_error"); + return false; + } } bool MsgUtils::isValidEmail(const std::string &address) { - if (address.empty() || address.length() > emailAddrLenMax) - return false; - - try { - std::regex emailTemplate(emailRegex); - return std::regex_match(address, emailTemplate); - } catch (const std::regex_error& e) { - MSG_LOG_ERROR("std::regex_error"); - return false; - } + if (address.empty() || address.length() > emailAddrLenMax) + return false; + + try { + std::regex emailTemplate(emailRegex); + return std::regex_match(address, emailTemplate); + } catch (const std::regex_error& e) { + MSG_LOG_ERROR("std::regex_error"); + return false; + } } bool MsgUtils::isValidAddress(const std::string &address) { - return isValidNumber(address) || isValidEmail(address); + return isValidNumber(address) || isValidEmail(address); } MsgAddress::AddressType MsgUtils::getAddressType(const std::string &address) { - if (isValidNumber(address)) - return MsgAddress::Phone; + if (isValidNumber(address)) + return MsgAddress::Phone; - if (isValidEmail(address)) - return MsgAddress::Email; + if (isValidEmail(address)) + return MsgAddress::Email; - return MsgAddress::UnknownAddressType; + return MsgAddress::UnknownAddressType; } std::string MsgUtils::makeNormalizedNumber(const std::string &number) { - std::string normalizedNumber; - for (auto symbol : number) { - if (isdigit(symbol) || symbol == '*' || symbol == '#' || symbol == '+') - normalizedNumber += symbol; - } - return normalizedNumber; + std::string normalizedNumber; + for (auto symbol : number) { + if (isdigit(symbol) || symbol == '*' || symbol == '#' || symbol == '+') + normalizedNumber += symbol; + } + return normalizedNumber; } std::string MsgUtils::makeCleanedNumber(const std::string &number) { - std::string cleanedNumber; - for (auto symbol : number) { - if (isdigit(symbol)) - cleanedNumber += symbol; - } - return cleanedNumber; + std::string cleanedNumber; + for (auto symbol : number) { + if (isdigit(symbol)) + cleanedNumber += symbol; + } + return cleanedNumber; } bool MsgUtils::isMms(Message::Type type) { - switch (type) { - case Message::MT_MMS: - case Message::MT_MMS_Noti: - return true; - default: - return false; - } + switch (type) { + case Message::MT_MMS: + case Message::MT_MMS_Noti: + return true; + default: + return false; + } } bool MsgUtils::isSms(Message::Type type) { - return type == Message::MT_SMS; + return type == Message::MT_SMS; } std::string MsgUtils::makeKbStr(long long bytes) { - const long long kb = 1024; // Bytes in kb - long long sizeKb = 0; - if (bytes <= kb) { - sizeKb = 1; - } else { - sizeKb = bytes / kb; - long long sizeB = bytes % kb; - if (sizeB >= (kb / 2)) - ++sizeKb; - } - - return std::to_string(sizeKb) + " " + (std::string)msg("IDS_MSGF_BODY_MSGSIZE_KB"); + const long long kb = 1024; // Bytes in kb + long long sizeKb = 0; + if (bytes <= kb) { + sizeKb = 1; + } else { + sizeKb = bytes / kb; + long long sizeB = bytes % kb; + if (sizeB >= (kb / 2)) + ++sizeKb; + } + + return std::to_string(sizeKb) + " " + (std::string)msg("IDS_MSGF_BODY_MSGSIZE_KB"); } diff --git a/src/Common/MsgEngine/src/private/MessageMmsPrivate.cpp b/src/Common/MsgEngine/src/private/MessageMmsPrivate.cpp index d71eaa35..c13f44e4 100644 --- a/src/Common/MsgEngine/src/private/MessageMmsPrivate.cpp +++ b/src/Common/MsgEngine/src/private/MessageMmsPrivate.cpp @@ -23,142 +23,142 @@ using namespace Msg; MessageMmsPrivate::MessageMmsPrivate(bool release, msg_struct_t msgStruct, msg_struct_t mmsStruct) - : MessagePrivate(release, msgStruct) - , MessageMms() - , m_MmsStruct(mmsStruct) - , m_PageList(false) - , m_AttachmentList(false) - , m_Page(false) - , m_Attachment(false) + : MessagePrivate(release, msgStruct) + , MessageMms() + , m_MmsStruct(mmsStruct) + , m_PageList(false) + , m_AttachmentList(false) + , m_Page(false) + , m_Attachment(false) { - if (!m_MmsStruct) { - m_MmsStruct = msg_create_struct(MSG_STRUCT_MMS); - if (msgStruct) - msg_get_mms_struct(m_MsgStruct, m_MmsStruct); - } + if (!m_MmsStruct) { + m_MmsStruct = msg_create_struct(MSG_STRUCT_MMS); + if (msgStruct) + msg_get_mms_struct(m_MsgStruct, m_MmsStruct); + } } void MessageMmsPrivate::set(msg_struct_t msgStruct) { - MessagePrivate::set(msgStruct); - msg_get_mms_struct(m_MsgStruct, m_MmsStruct); + MessagePrivate::set(msgStruct); + msg_get_mms_struct(m_MsgStruct, m_MmsStruct); } void MessageMmsPrivate::commit() { - msg_set_mms_struct(m_MsgStruct, m_MmsStruct); + msg_set_mms_struct(m_MsgStruct, m_MmsStruct); } msg_struct_t MessageMmsPrivate::getMmsStruct() const { - return m_MmsStruct; + return m_MmsStruct; } MessageMmsPrivate::~MessageMmsPrivate() { - if (m_MmsStruct) - msg_release_struct(&m_MmsStruct); + if (m_MmsStruct) + msg_release_struct(&m_MmsStruct); } MessageMmsPrivate::Type MessageMmsPrivate::getType() const { - int nativeType = MSG_TYPE_INVALID; - msg_get_int_value(m_MsgStruct, MSG_MESSAGE_TYPE_INT, &nativeType); - return MsgUtilsPrivate::nativeToMessageType(nativeType); + int nativeType = MSG_TYPE_INVALID; + msg_get_int_value(m_MsgStruct, MSG_MESSAGE_TYPE_INT, &nativeType); + return MsgUtilsPrivate::nativeToMessageType(nativeType); } void MessageMmsPrivate::setText(const std::string &text) { - MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MESSAGE_MMS_TEXT_STR, text); + MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MESSAGE_MMS_TEXT_STR, text); } std::string MessageMmsPrivate::getText() const { - const MsgPageList &pageList = getPageList(); - std::string result; - int size = pageList.getLength(); - - for (int i = 0; i < size; ++i) { - const MsgMediaList &mediaList = pageList.at(i).getMediaList(); - - int sizeList = mediaList.getLength(); - for (int j = 0; j < sizeList; ++j) { - if (mediaList[j].getType() == MsgMedia::TextType) { - std::string str = FileUtils::readTextFile(mediaList[j].getFilePath()); - if (!str.empty()) { - if (i > 0 && !result.empty()) - result.append("\n"); - - result += std::move(str); - } - } - } - } - return result; + const MsgPageList &pageList = getPageList(); + std::string result; + int size = pageList.getLength(); + + for (int i = 0; i < size; ++i) { + const MsgMediaList &mediaList = pageList.at(i).getMediaList(); + + int sizeList = mediaList.getLength(); + for (int j = 0; j < sizeList; ++j) { + if (mediaList[j].getType() == MsgMedia::TextType) { + std::string str = FileUtils::readTextFile(mediaList[j].getFilePath()); + if (!str.empty()) { + if (i > 0 && !result.empty()) + result.append("\n"); + + result += std::move(str); + } + } + } + } + return result; } int MessageMmsPrivate::getMediaCount() const { - const MsgPageList &pageList = getPageList(); - int result = 0; - - int size = pageList.getLength(); - for (int i = 0; i < size; ++i) { - const MsgMediaList &mediaList = pageList.at(i).getMediaList(); - - int sizeList = mediaList.getLength(); - for (int j = 0; j < sizeList; ++j) { - if (mediaList[j].getType() != MsgMedia::TextType && mediaList[j].getType() != MsgMedia::UnknownType) - ++result; - } - } - return result; + const MsgPageList &pageList = getPageList(); + int result = 0; + + int size = pageList.getLength(); + for (int i = 0; i < size; ++i) { + const MsgMediaList &mediaList = pageList.at(i).getMediaList(); + + int sizeList = mediaList.getLength(); + for (int j = 0; j < sizeList; ++j) { + if (mediaList[j].getType() != MsgMedia::TextType && mediaList[j].getType() != MsgMedia::UnknownType) + ++result; + } + } + return result; } const MsgPageListHandlePrivate &MessageMmsPrivate::getPageList() const { - msg_list_handle_t list = nullptr; - msg_get_list_handle(m_MmsStruct, MSG_MMS_PAGE_LIST_HND, (void **)&list); - m_PageList.set(list); - return m_PageList; + msg_list_handle_t list = nullptr; + msg_get_list_handle(m_MmsStruct, MSG_MMS_PAGE_LIST_HND, (void **)&list); + m_PageList.set(list); + return m_PageList; } MsgPagePrivate &MessageMmsPrivate::addPage() { - msg_struct_t page = nullptr; - msg_list_add_item(m_MmsStruct, MSG_STRUCT_MMS_PAGE, &page); - m_Page.set(page); - return m_Page; + msg_struct_t page = nullptr; + msg_list_add_item(m_MmsStruct, MSG_STRUCT_MMS_PAGE, &page); + m_Page.set(page); + return m_Page; } const MsgAttachmentListHandlePrivate &MessageMmsPrivate::getAttachmentList() const { - msg_list_handle_t list = nullptr; - msg_get_list_handle(m_MmsStruct, MSG_MMS_ATTACH_LIST_HND, (void **)&list); - m_AttachmentList.set(list); - return m_AttachmentList; + msg_list_handle_t list = nullptr; + msg_get_list_handle(m_MmsStruct, MSG_MMS_ATTACH_LIST_HND, (void **)&list); + m_AttachmentList.set(list); + return m_AttachmentList; } MsgAttachmentPrivate &MessageMmsPrivate::addAttachment() { - msg_struct_t attach = nullptr; - msg_list_add_item(m_MmsStruct, MSG_STRUCT_MMS_ATTACH, &attach); - m_Attachment.set(attach); - return m_Attachment; + msg_struct_t attach = nullptr; + msg_list_add_item(m_MmsStruct, MSG_STRUCT_MMS_ATTACH, &attach); + m_Attachment.set(attach); + return m_Attachment; } time_t MessageMmsPrivate::getExpired() const { - int msgExpiry = 0; - msg_get_int_value(m_MmsStruct, MSG_MMS_HEADER_EXPIRY_TIME_INT, &msgExpiry); - return msgExpiry; + int msgExpiry = 0; + msg_get_int_value(m_MmsStruct, MSG_MMS_HEADER_EXPIRY_TIME_INT, &msgExpiry); + return msgExpiry; } int MessageMmsPrivate::getSize() const { - int msgSize = 0; - int res = msg_get_int_value(m_MmsStruct, MSG_MMS_HEADER_SIZE_INT, &msgSize); // Size in bytes - if (res != MSG_SUCCESS || msgSize <= 0) - msgSize = MessagePrivate::getSize(); - return msgSize; + int msgSize = 0; + int res = msg_get_int_value(m_MmsStruct, MSG_MMS_HEADER_SIZE_INT, &msgSize); // Size in bytes + if (res != MSG_SUCCESS || msgSize <= 0) + msgSize = MessagePrivate::getSize(); + return msgSize; } diff --git a/src/Common/MsgEngine/src/private/MessageMmsPrivate.h b/src/Common/MsgEngine/src/private/MessageMmsPrivate.h index a7ec5438..88d0bb66 100644 --- a/src/Common/MsgEngine/src/private/MessageMmsPrivate.h +++ b/src/Common/MsgEngine/src/private/MessageMmsPrivate.h @@ -23,40 +23,40 @@ #include "MsgAttachmentPrivate.h" namespace Msg { - class MessageMmsPrivate - : public MessagePrivate - , public MessageMms { - public: - MessageMmsPrivate(bool release, msg_struct_t msgStruct = nullptr, msg_struct_t mmsStruct = nullptr); - virtual ~MessageMmsPrivate(); - - virtual void setText(const std::string &text); - virtual std::string getText() const; - virtual Type getType() const; - virtual int getSize() const; - - virtual const MsgPageListHandlePrivate &getPageList() const; - virtual MsgPagePrivate &addPage(); - - virtual const MsgAttachmentListHandlePrivate &getAttachmentList() const; - virtual MsgAttachmentPrivate &addAttachment(); - virtual time_t getExpired() const; - - virtual void commit(); - int getMediaCount() const; - void set(msg_struct_t msgStruct); - msg_struct_t getMmsStruct() const; - - private: - msg_struct_t m_MmsStruct; - mutable MsgPageListHandlePrivate m_PageList; - mutable MsgAttachmentListHandlePrivate m_AttachmentList; - MsgPagePrivate m_Page; - MsgAttachmentPrivate m_Attachment; - }; - - typedef class MsgListHandlePrivate MmsListHandlePrivate; - typedef class MsgStructListPrivate MmsStructListPrivate; + class MessageMmsPrivate + : public MessagePrivate + , public MessageMms { + public: + MessageMmsPrivate(bool release, msg_struct_t msgStruct = nullptr, msg_struct_t mmsStruct = nullptr); + virtual ~MessageMmsPrivate(); + + virtual void setText(const std::string &text); + virtual std::string getText() const; + virtual Type getType() const; + virtual int getSize() const; + + virtual const MsgPageListHandlePrivate &getPageList() const; + virtual MsgPagePrivate &addPage(); + + virtual const MsgAttachmentListHandlePrivate &getAttachmentList() const; + virtual MsgAttachmentPrivate &addAttachment(); + virtual time_t getExpired() const; + + virtual void commit(); + int getMediaCount() const; + void set(msg_struct_t msgStruct); + msg_struct_t getMmsStruct() const; + + private: + msg_struct_t m_MmsStruct; + mutable MsgPageListHandlePrivate m_PageList; + mutable MsgAttachmentListHandlePrivate m_AttachmentList; + MsgPagePrivate m_Page; + MsgAttachmentPrivate m_Attachment; + }; + + typedef class MsgListHandlePrivate MmsListHandlePrivate; + typedef class MsgStructListPrivate MmsStructListPrivate; } #endif /* _MESSAGE_MMS_PRIVATE_H__ */ diff --git a/src/Common/MsgEngine/src/private/MessagePrivate.cpp b/src/Common/MsgEngine/src/private/MessagePrivate.cpp index fd59d816..0ee56446 100644 --- a/src/Common/MsgEngine/src/private/MessagePrivate.cpp +++ b/src/Common/MsgEngine/src/private/MessagePrivate.cpp @@ -26,10 +26,10 @@ using namespace Msg; MessagePrivate::MessagePrivate(bool release, msg_struct_t msgStruct) - : Message() - , MsgStructPrivate(release, msgStruct) - , m_Address(false) - , m_AddressList(false) + : Message() + , MsgStructPrivate(release, msgStruct) + , m_Address(false) + , m_AddressList(false) { } @@ -39,131 +39,131 @@ MessagePrivate::~MessagePrivate() void MessagePrivate::set(msg_struct_t msgStruct) { - MsgStructPrivate::set(msgStruct); + MsgStructPrivate::set(msgStruct); } const MsgAddressListHandlePrivate &MessagePrivate::getAddressList() const { - msg_list_handle_t addrList = nullptr; - msg_get_list_handle(m_MsgStruct, MSG_MESSAGE_ADDR_LIST_HND, (void **)&addrList); - m_AddressList.set(addrList); - return m_AddressList; + msg_list_handle_t addrList = nullptr; + msg_get_list_handle(m_MsgStruct, MSG_MESSAGE_ADDR_LIST_HND, (void **)&addrList); + m_AddressList.set(addrList); + return m_AddressList; } MsgAddressPrivate &MessagePrivate::addAddress() { - msg_struct_t addr = nullptr; - msg_list_add_item(m_MsgStruct, MSG_MESSAGE_ADDR_LIST_HND, &addr); - m_Address.set(addr); - return m_Address; + msg_struct_t addr = nullptr; + msg_list_add_item(m_MsgStruct, MSG_MESSAGE_ADDR_LIST_HND, &addr); + m_Address.set(addr); + return m_Address; } void MessagePrivate::addAddresses(const MsgAddressList &list) { - int len = list.getLength(); - for (int i = 0; i < len; ++i) { - MsgAddressPrivate &newAddr = MessagePrivate::addAddress(); - newAddr.setFields(list[i]); - } + int len = list.getLength(); + for (int i = 0; i < len; ++i) { + MsgAddressPrivate &newAddr = MessagePrivate::addAddress(); + newAddr.setFields(list[i]); + } } MsgId MessagePrivate::getId() const { - int id = MsgId::invalidId; - msg_get_int_value(m_MsgStruct, MSG_MESSAGE_ID_INT, &id); - return id; + int id = MsgId::invalidId; + msg_get_int_value(m_MsgStruct, MSG_MESSAGE_ID_INT, &id); + return id; } void MessagePrivate::setId(MsgId id) { - msg_set_int_value(m_MsgStruct, MSG_MESSAGE_ID_INT, id); + msg_set_int_value(m_MsgStruct, MSG_MESSAGE_ID_INT, id); } ThreadId MessagePrivate::getThreadId() const { - int threadId = ThreadId::invalidId; - msg_get_int_value(m_MsgStruct, MSG_MESSAGE_THREAD_ID_INT, &threadId); - return threadId; + int threadId = ThreadId::invalidId; + msg_get_int_value(m_MsgStruct, MSG_MESSAGE_THREAD_ID_INT, &threadId); + return threadId; } time_t MessagePrivate::getTime() const { - int time = 0; - msg_get_int_value(m_MsgStruct, MSG_MESSAGE_DISPLAY_TIME_INT, &time); - return time; + int time = 0; + msg_get_int_value(m_MsgStruct, MSG_MESSAGE_DISPLAY_TIME_INT, &time); + return time; } void MessagePrivate::setText(const std::string &text) { - int field = isMms() ? MSG_MESSAGE_MMS_TEXT_STR : MSG_MESSAGE_SMS_DATA_STR; - MsgUtilsPrivate::setStr(m_MsgStruct, field, text); + int field = isMms() ? MSG_MESSAGE_MMS_TEXT_STR : MSG_MESSAGE_SMS_DATA_STR; + MsgUtilsPrivate::setStr(m_MsgStruct, field, text); } std::string MessagePrivate::getText() const { - if (isMms()) - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MESSAGE_MMS_TEXT_STR, MAX_MSG_TEXT_LEN); - else - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MESSAGE_SMS_DATA_STR, MAX_MSG_DATA_LEN); + if (isMms()) + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MESSAGE_MMS_TEXT_STR, MAX_MSG_TEXT_LEN); + else + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MESSAGE_SMS_DATA_STR, MAX_MSG_DATA_LEN); } Message::Direction MessagePrivate::getDirection() const { - int direction = 0; - msg_get_int_value(m_MsgStruct, MSG_MESSAGE_DIRECTION_INT, &direction); - return MsgUtilsPrivate::nativeToDirection(direction); + int direction = 0; + msg_get_int_value(m_MsgStruct, MSG_MESSAGE_DIRECTION_INT, &direction); + return MsgUtilsPrivate::nativeToDirection(direction); } Message::Type MessagePrivate::getType() const { - return MT_Unknown; + return MT_Unknown; } MessagePrivate::NetworkStatus MessagePrivate::getNetworkStatus() const { - int status = 0; - int err = msg_get_int_value(m_MsgStruct, MSG_MESSAGE_NETWORK_STATUS_INT, &status); - return err == 0 ? MsgUtilsPrivate::nativeToNetworkStatus(status) : NS_Unknown; + int status = 0; + int err = msg_get_int_value(m_MsgStruct, MSG_MESSAGE_NETWORK_STATUS_INT, &status); + return err == 0 ? MsgUtilsPrivate::nativeToNetworkStatus(status) : NS_Unknown; } int MessagePrivate::getSize() const { - int msgSize = 0; - msg_get_int_value(m_MsgStruct, MSG_MESSAGE_DATA_SIZE_INT, &msgSize); // Size in bytes - return msgSize; + int msgSize = 0; + msg_get_int_value(m_MsgStruct, MSG_MESSAGE_DATA_SIZE_INT, &msgSize); // Size in bytes + return msgSize; } std::string MessagePrivate::getSubject() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MESSAGE_SUBJECT_STR, MAX_SUBJECT_LEN); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MESSAGE_SUBJECT_STR, MAX_SUBJECT_LEN); } void MessagePrivate::setSubject(const std::string &text) { - MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MESSAGE_SUBJECT_STR, text); + MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MESSAGE_SUBJECT_STR, text); } void MessagePrivate::setMessageStorageType(Message::MessageStorageType msgStorage) { - switch (msgStorage) { - case Message::MS_Phone: - msg_set_int_value(m_MsgStruct, MSG_MESSAGE_STORAGE_ID_INT, MSG_STORAGE_PHONE); - break; - case Message::MS_Sim: - msg_set_int_value(m_MsgStruct, MSG_MESSAGE_STORAGE_ID_INT, MSG_STORAGE_SIM); - break; - case Message::MS_Unknown: - default: - MSG_LOG_ERROR("Unknown storage type!") - break; - } + switch (msgStorage) { + case Message::MS_Phone: + msg_set_int_value(m_MsgStruct, MSG_MESSAGE_STORAGE_ID_INT, MSG_STORAGE_PHONE); + break; + case Message::MS_Sim: + msg_set_int_value(m_MsgStruct, MSG_MESSAGE_STORAGE_ID_INT, MSG_STORAGE_SIM); + break; + case Message::MS_Unknown: + default: + MSG_LOG_ERROR("Unknown storage type!") + break; + } } Message::MessageStorageType MessagePrivate::getMessageStorageType() const { - int id = -1; - msg_get_int_value(m_MsgStruct, MSG_MESSAGE_STORAGE_ID_INT, &id); - return MsgUtilsPrivate::nativeToMessageStorage(id); + int id = -1; + msg_get_int_value(m_MsgStruct, MSG_MESSAGE_STORAGE_ID_INT, &id); + return MsgUtilsPrivate::nativeToMessageStorage(id); } void MessagePrivate::commit() @@ -172,15 +172,15 @@ void MessagePrivate::commit() bool MessagePrivate::isMms() const { - int nativeType = MSG_TYPE_INVALID; - msg_get_int_value(m_MsgStruct, MSG_MESSAGE_TYPE_INT, &nativeType); - Message::Type messageType = MsgUtilsPrivate::nativeToMessageType(nativeType); - return MsgUtils::isMms(messageType); + int nativeType = MSG_TYPE_INVALID; + msg_get_int_value(m_MsgStruct, MSG_MESSAGE_TYPE_INT, &nativeType); + Message::Type messageType = MsgUtilsPrivate::nativeToMessageType(nativeType); + return MsgUtils::isMms(messageType); } bool MessagePrivate::isRestrictedByDpm() const { - bool restricted = false; - msg_get_bool_value(m_MsgStruct, MSG_MESSAGE_DPM_RESTRICTED_BOOL, &restricted); - return restricted; + bool restricted = false; + msg_get_bool_value(m_MsgStruct, MSG_MESSAGE_DPM_RESTRICTED_BOOL, &restricted); + return restricted; } diff --git a/src/Common/MsgEngine/src/private/MessagePrivate.h b/src/Common/MsgEngine/src/private/MessagePrivate.h index 497bb248..44f71a1d 100644 --- a/src/Common/MsgEngine/src/private/MessagePrivate.h +++ b/src/Common/MsgEngine/src/private/MessagePrivate.h @@ -24,44 +24,44 @@ #include namespace Msg { - class MessagePrivate - : public virtual Message - , public MsgStructPrivate { - public: - MessagePrivate(bool release, msg_struct_t msgStruct = nullptr); - virtual ~MessagePrivate(); + class MessagePrivate + : public virtual Message + , public MsgStructPrivate { + public: + MessagePrivate(bool release, msg_struct_t msgStruct = nullptr); + virtual ~MessagePrivate(); - virtual MsgId getId() const; - virtual ThreadId getThreadId() const; - virtual time_t getTime() const; - virtual const MsgAddressListHandlePrivate &getAddressList() const; - virtual MsgAddressPrivate &addAddress(); - virtual void addAddresses(const MsgAddressList &list); - virtual void setText(const std::string &text); - virtual std::string getText() const; - Message::Direction getDirection() const; - virtual Type getType() const; - virtual NetworkStatus getNetworkStatus() const; + virtual MsgId getId() const; + virtual ThreadId getThreadId() const; + virtual time_t getTime() const; + virtual const MsgAddressListHandlePrivate &getAddressList() const; + virtual MsgAddressPrivate &addAddress(); + virtual void addAddresses(const MsgAddressList &list); + virtual void setText(const std::string &text); + virtual std::string getText() const; + Message::Direction getDirection() const; + virtual Type getType() const; + virtual NetworkStatus getNetworkStatus() const; - virtual int getSize() const; - virtual std::string getSubject() const; - virtual void setSubject(const std::string &text); - virtual void setMessageStorageType(Message::MessageStorageType msgStorage); - virtual Message::MessageStorageType getMessageStorageType() const; - virtual bool isMms() const; - virtual bool isRestrictedByDpm() const; + virtual int getSize() const; + virtual std::string getSubject() const; + virtual void setSubject(const std::string &text); + virtual void setMessageStorageType(Message::MessageStorageType msgStorage); + virtual Message::MessageStorageType getMessageStorageType() const; + virtual bool isMms() const; + virtual bool isRestrictedByDpm() const; - void setId(MsgId id); - void set(msg_struct_t msgStruct); - virtual void commit(); + void setId(MsgId id); + void set(msg_struct_t msgStruct); + virtual void commit(); - protected: - mutable MsgAddressPrivate m_Address; - mutable MsgAddressListHandlePrivate m_AddressList; - }; + protected: + mutable MsgAddressPrivate m_Address; + mutable MsgAddressListHandlePrivate m_AddressList; + }; - typedef class MsgListHandlePrivate MessageListHandlePrivate; - typedef class MsgStructListPrivate MessageStructListPrivate; + typedef class MsgListHandlePrivate MessageListHandlePrivate; + typedef class MsgStructListPrivate MessageStructListPrivate; } #endif /* _MESSAGE_PRIVATE_H__ */ diff --git a/src/Common/MsgEngine/src/private/MessageSMSPrivate.cpp b/src/Common/MsgEngine/src/private/MessageSMSPrivate.cpp index 8aabfad3..8f8ec449 100644 --- a/src/Common/MsgEngine/src/private/MessageSMSPrivate.cpp +++ b/src/Common/MsgEngine/src/private/MessageSMSPrivate.cpp @@ -28,8 +28,8 @@ using namespace Msg; MessageSMSPrivate::MessageSMSPrivate(bool release, msg_struct_t msgStruct) - : MessagePrivate(release, msgStruct) - , MessageSMS() + : MessagePrivate(release, msgStruct) + , MessageSMS() { } @@ -39,15 +39,15 @@ MessageSMSPrivate::~MessageSMSPrivate() MessageSMSPrivate::Type MessageSMSPrivate::getType() const { - return MT_SMS; + return MT_SMS; } void MessageSMSPrivate::setText(const std::string &text) { - msg_set_str_value(m_MsgStruct, MSG_MESSAGE_SMS_DATA_STR, text.c_str(), text.length()); + msg_set_str_value(m_MsgStruct, MSG_MESSAGE_SMS_DATA_STR, text.c_str(), text.length()); } std::string MessageSMSPrivate::getText() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MESSAGE_SMS_DATA_STR, MAX_MSG_DATA_LEN); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MESSAGE_SMS_DATA_STR, MAX_MSG_DATA_LEN); } diff --git a/src/Common/MsgEngine/src/private/MessageSMSPrivate.h b/src/Common/MsgEngine/src/private/MessageSMSPrivate.h index 7561fb80..d7b73f79 100644 --- a/src/Common/MsgEngine/src/private/MessageSMSPrivate.h +++ b/src/Common/MsgEngine/src/private/MessageSMSPrivate.h @@ -23,20 +23,20 @@ #include "MsgStructListPrivate.h" namespace Msg { - class MessageSMSPrivate - : public MessagePrivate - , public MessageSMS { - public: - MessageSMSPrivate(bool release, msg_struct_t msgStruct = nullptr); - virtual ~MessageSMSPrivate(); + class MessageSMSPrivate + : public MessagePrivate + , public MessageSMS { + public: + MessageSMSPrivate(bool release, msg_struct_t msgStruct = nullptr); + virtual ~MessageSMSPrivate(); - virtual Type getType() const; - virtual void setText(const std::string &text); - virtual std::string getText() const; - }; + virtual Type getType() const; + virtual void setText(const std::string &text); + virtual std::string getText() const; + }; - typedef class MsgListHandlePrivate SmsListHandlePrivate; - typedef class MsgStructListPrivate SmsStructListPrivate; + typedef class MsgListHandlePrivate SmsListHandlePrivate; + typedef class MsgStructListPrivate SmsStructListPrivate; } #endif /* _MESSAGE_SMS_PRIVATE_H__ */ diff --git a/src/Common/MsgEngine/src/private/MsgAddressPrivate.cpp b/src/Common/MsgEngine/src/private/MsgAddressPrivate.cpp index 88a2a141..bb6c5bc3 100644 --- a/src/Common/MsgEngine/src/private/MsgAddressPrivate.cpp +++ b/src/Common/MsgEngine/src/private/MsgAddressPrivate.cpp @@ -22,8 +22,8 @@ using namespace Msg; MsgAddressPrivate::MsgAddressPrivate(bool release, msg_struct_t msgStruct) - : MsgStructPrivate(release, msgStruct) - , MsgAddress() + : MsgStructPrivate(release, msgStruct) + , MsgAddress() { } @@ -33,41 +33,41 @@ MsgAddressPrivate::~MsgAddressPrivate() std::string MsgAddressPrivate::getAddress() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, MAX_ADDRESS_VAL_LEN); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, MAX_ADDRESS_VAL_LEN); } MsgAddressPrivate::AddressType MsgAddressPrivate::getAddressType() const { - int nativeType = MSG_ADDRESS_TYPE_UNKNOWN; - msg_get_int_value(m_MsgStruct, MSG_ADDRESS_INFO_ADDRESS_TYPE_INT, &nativeType); - return MsgUtilsPrivate::nativeToAddressType(nativeType); + int nativeType = MSG_ADDRESS_TYPE_UNKNOWN; + msg_get_int_value(m_MsgStruct, MSG_ADDRESS_INFO_ADDRESS_TYPE_INT, &nativeType); + return MsgUtilsPrivate::nativeToAddressType(nativeType); } MsgAddressPrivate::RecipientType MsgAddressPrivate::getRecipientType() const { - int nativeType = MSG_RECIPIENTS_TYPE_UNKNOWN; - msg_get_int_value(m_MsgStruct, MSG_ADDRESS_INFO_RECIPIENT_TYPE_INT, &nativeType); - return MsgUtilsPrivate::nativeToRecipientType(nativeType); + int nativeType = MSG_RECIPIENTS_TYPE_UNKNOWN; + msg_get_int_value(m_MsgStruct, MSG_ADDRESS_INFO_RECIPIENT_TYPE_INT, &nativeType); + return MsgUtilsPrivate::nativeToRecipientType(nativeType); } void MsgAddressPrivate::setAddress(const std::string &address) { - msg_set_str_value(m_MsgStruct, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, address.c_str(), address.length()); + msg_set_str_value(m_MsgStruct, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, address.c_str(), address.length()); } void MsgAddressPrivate::setAddressType(AddressType type) { - msg_set_int_value(m_MsgStruct, MSG_ADDRESS_INFO_ADDRESS_TYPE_INT, MsgUtilsPrivate::addressTypeToNative(type)); + msg_set_int_value(m_MsgStruct, MSG_ADDRESS_INFO_ADDRESS_TYPE_INT, MsgUtilsPrivate::addressTypeToNative(type)); } void MsgAddressPrivate::setRecipientType(RecipientType type) { - msg_set_int_value(m_MsgStruct, MSG_ADDRESS_INFO_RECIPIENT_TYPE_INT, MsgUtilsPrivate::recipientTypeToNative(type)); + msg_set_int_value(m_MsgStruct, MSG_ADDRESS_INFO_RECIPIENT_TYPE_INT, MsgUtilsPrivate::recipientTypeToNative(type)); } void MsgAddressPrivate::setFields(const MsgAddress &addr) { - setAddress(addr.getAddress()); - setAddressType(addr.getAddressType()); - setRecipientType(addr.getRecipientType()); + setAddress(addr.getAddress()); + setAddressType(addr.getAddressType()); + setRecipientType(addr.getRecipientType()); } diff --git a/src/Common/MsgEngine/src/private/MsgAddressPrivate.h b/src/Common/MsgEngine/src/private/MsgAddressPrivate.h index dc593c64..4d061522 100644 --- a/src/Common/MsgEngine/src/private/MsgAddressPrivate.h +++ b/src/Common/MsgEngine/src/private/MsgAddressPrivate.h @@ -23,26 +23,26 @@ #include "MsgStructPrivate.h" namespace Msg { - class MsgAddressPrivate - : public MsgStructPrivate - , public MsgAddress { - public: - MsgAddressPrivate(bool release, msg_struct_t msgStruct = nullptr); - virtual ~MsgAddressPrivate(); - - virtual std::string getAddress() const; - virtual AddressType getAddressType() const; - virtual RecipientType getRecipientType() const; - - virtual void setAddress(const std::string &address); - virtual void setAddressType(AddressType type); - virtual void setRecipientType(RecipientType type); - - void setFields(const MsgAddress &addr); - }; - - typedef class MsgListHandlePrivate MsgAddressListHandlePrivate; - typedef class MsgStructListPrivate MsgAddressStructListPrivate; + class MsgAddressPrivate + : public MsgStructPrivate + , public MsgAddress { + public: + MsgAddressPrivate(bool release, msg_struct_t msgStruct = nullptr); + virtual ~MsgAddressPrivate(); + + virtual std::string getAddress() const; + virtual AddressType getAddressType() const; + virtual RecipientType getRecipientType() const; + + virtual void setAddress(const std::string &address); + virtual void setAddressType(AddressType type); + virtual void setRecipientType(RecipientType type); + + void setFields(const MsgAddress &addr); + }; + + typedef class MsgListHandlePrivate MsgAddressListHandlePrivate; + typedef class MsgStructListPrivate MsgAddressStructListPrivate; } #endif /* MsgAddressPrivate_h_ */ diff --git a/src/Common/MsgEngine/src/private/MsgAttachmentPrivate.cpp b/src/Common/MsgEngine/src/private/MsgAttachmentPrivate.cpp index 63673b6b..6f79b657 100644 --- a/src/Common/MsgEngine/src/private/MsgAttachmentPrivate.cpp +++ b/src/Common/MsgEngine/src/private/MsgAttachmentPrivate.cpp @@ -22,8 +22,8 @@ using namespace Msg; MsgAttachmentPrivate::MsgAttachmentPrivate(bool release, msg_struct_t msgStruct) - : MsgStructPrivate(release, msgStruct) - , MsgAttachment() + : MsgStructPrivate(release, msgStruct) + , MsgAttachment() { } @@ -33,54 +33,54 @@ MsgAttachmentPrivate::~MsgAttachmentPrivate() std::string MsgAttachmentPrivate::getFilePath() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_ATTACH_FILEPATH_STR, MSG_FILEPATH_LEN_MAX); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_ATTACH_FILEPATH_STR, MSG_FILEPATH_LEN_MAX); } std::string MsgAttachmentPrivate::getFileName() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_ATTACH_FILENAME_STR, MSG_FILENAME_LEN_MAX); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_ATTACH_FILENAME_STR, MSG_FILENAME_LEN_MAX); } int MsgAttachmentPrivate::getFileSize() const { - int size = 0; - msg_get_int_value(m_MsgStruct, MSG_MMS_ATTACH_FILESIZE_INT, &size); + int size = 0; + msg_get_int_value(m_MsgStruct, MSG_MMS_ATTACH_FILESIZE_INT, &size); - if (size == 0) { - MSG_LOG_WARN("File ", getFilePath(), " size = 0, trying to get real file size"); - size = (int)FileUtils::getFileSize(getFilePath()); - MSG_LOG("Real file size = ", size); - } + if (size == 0) { + MSG_LOG_WARN("File ", getFilePath(), " size = 0, trying to get real file size"); + size = (int)FileUtils::getFileSize(getFilePath()); + MSG_LOG("Real file size = ", size); + } - return size; + return size; } std::string MsgAttachmentPrivate::getMime() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_ATTACH_CONTENT_TYPE_STR, MAX_MIME_TYPE_LEN); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_ATTACH_CONTENT_TYPE_STR, MAX_MIME_TYPE_LEN); } void MsgAttachmentPrivate::setFilePath(const std::string &path) { - MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_ATTACH_FILEPATH_STR, path); - setFileName(FileUtils::getFileName(path)); - setFileSize(FileUtils::getFileSize(path)); - setMime(FileUtils::getMimeType(path)); + MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_ATTACH_FILEPATH_STR, path); + setFileName(FileUtils::getFileName(path)); + setFileSize(FileUtils::getFileSize(path)); + setMime(FileUtils::getMimeType(path)); } void MsgAttachmentPrivate::setFileName(const std::string &fileName) { - MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_ATTACH_FILENAME_STR, fileName); + MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_ATTACH_FILENAME_STR, fileName); } void MsgAttachmentPrivate::setFileSize(int size) const { - msg_set_int_value(m_MsgStruct, MSG_MMS_ATTACH_FILESIZE_INT, size); + msg_set_int_value(m_MsgStruct, MSG_MMS_ATTACH_FILESIZE_INT, size); } void MsgAttachmentPrivate::setMime(const std::string &mime) { - MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_ATTACH_CONTENT_TYPE_STR, mime); + MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_ATTACH_CONTENT_TYPE_STR, mime); } diff --git a/src/Common/MsgEngine/src/private/MsgAttachmentPrivate.h b/src/Common/MsgEngine/src/private/MsgAttachmentPrivate.h index 3ed3814c..6b9a2643 100644 --- a/src/Common/MsgEngine/src/private/MsgAttachmentPrivate.h +++ b/src/Common/MsgEngine/src/private/MsgAttachmentPrivate.h @@ -23,26 +23,26 @@ #include "MsgStructListPrivate.h" namespace Msg { - class MsgAttachmentPrivate - : public MsgStructPrivate - , public MsgAttachment { - public: - MsgAttachmentPrivate(bool release, msg_struct_t msgStruct = nullptr); - virtual ~MsgAttachmentPrivate(); + class MsgAttachmentPrivate + : public MsgStructPrivate + , public MsgAttachment { + public: + MsgAttachmentPrivate(bool release, msg_struct_t msgStruct = nullptr); + virtual ~MsgAttachmentPrivate(); - virtual std::string getFilePath() const; - virtual std::string getFileName() const; - virtual int getFileSize() const; - virtual std::string getMime() const; + virtual std::string getFilePath() const; + virtual std::string getFileName() const; + virtual int getFileSize() const; + virtual std::string getMime() const; - virtual void setFilePath(const std::string &path); - void setFileName(const std::string &fileName); - void setFileSize(int size) const; - void setMime(const std::string &mime); - }; + virtual void setFilePath(const std::string &path); + void setFileName(const std::string &fileName); + void setFileSize(int size) const; + void setMime(const std::string &mime); + }; - typedef class MsgListHandlePrivate MsgAttachmentListHandlePrivate; - typedef class MsgStructListPrivate MsgAttachmentStructListPrivate; + typedef class MsgListHandlePrivate MsgAttachmentListHandlePrivate; + typedef class MsgStructListPrivate MsgAttachmentStructListPrivate; } #endif /* _MSG_ATTACHMENT_PRIVATE_H__ */ diff --git a/src/Common/MsgEngine/src/private/MsgComposerPrivate.cpp b/src/Common/MsgEngine/src/private/MsgComposerPrivate.cpp index 82dc2a4f..52a82408 100644 --- a/src/Common/MsgEngine/src/private/MsgComposerPrivate.cpp +++ b/src/Common/MsgEngine/src/private/MsgComposerPrivate.cpp @@ -35,74 +35,74 @@ MsgComposerPrivate::~MsgComposerPrivate() MessageSMSRef MsgComposerPrivate::createSms() { - MessageSMSRef smsRef; - msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); - if (msgInfo) { - msg_set_int_value(msgInfo, MSG_MESSAGE_TYPE_INT, MSG_TYPE_SMS); - - MessageSMSPrivate *sms = new MessageSMSPrivate(true, msgInfo); - smsRef.reset(sms); - } - return smsRef; + MessageSMSRef smsRef; + msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); + if (msgInfo) { + msg_set_int_value(msgInfo, MSG_MESSAGE_TYPE_INT, MSG_TYPE_SMS); + + MessageSMSPrivate *sms = new MessageSMSPrivate(true, msgInfo); + smsRef.reset(sms); + } + return smsRef; } MessageMmsRef MsgComposerPrivate::createMms() { - MessageMmsRef mmsRef; - msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); - if (msgInfo) { - msg_set_int_value(msgInfo, MSG_MESSAGE_TYPE_INT, MSG_TYPE_MMS); - msg_struct_t mmsStruct = msg_create_struct(MSG_STRUCT_MMS); - - setSmilHeader(mmsStruct, false); // BodyView support only Image after Text layout order isTextTop = false - - MessageMmsPrivate *mms = new MessageMmsPrivate(true, msgInfo, mmsStruct); - mmsRef.reset(mms); - } - return mmsRef; + MessageMmsRef mmsRef; + msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); + if (msgInfo) { + msg_set_int_value(msgInfo, MSG_MESSAGE_TYPE_INT, MSG_TYPE_MMS); + msg_struct_t mmsStruct = msg_create_struct(MSG_STRUCT_MMS); + + setSmilHeader(mmsStruct, false); // BodyView support only Image after Text layout order isTextTop = false + + MessageMmsPrivate *mms = new MessageMmsPrivate(true, msgInfo, mmsStruct); + mmsRef.reset(mms); + } + return mmsRef; } void MsgComposerPrivate::setSmilHeader(msg_struct_t mms, bool isTextTop) { - msg_struct_t textRegion = NULL; - msg_struct_t imageRegion = NULL; - - /************ make rootlayout ***************/ - msg_set_int_value(mms, MSG_MMS_ROOTLAYOUT_WIDTH_INT, smilScreenWidthP); - msg_set_int_value(mms, MSG_MMS_ROOTLAYOUT_HEIGHT_INT, smilScreenHeightP); - - msg_set_bool_value(mms, MSG_MMS_ROOTLAYOUT_WIDTH_PERCENT_BOOL, true); - msg_set_bool_value(mms, MSG_MMS_ROOTLAYOUT_HEIGHT_PERCENT_BOOL, true); - /************ make region ********************/ - /* 1. add text region */ - msg_list_add_item(mms, MSG_STRUCT_MMS_REGION, &textRegion); - MsgUtilsPrivate::setStr(textRegion, MSG_MMS_REGION_ID_STR, textRegionId); - msg_set_int_value(textRegion, MSG_MMS_REGION_LENGTH_LEFT_INT, smilPosLeft); - msg_set_bool_value(textRegion, MSG_MMS_REGION_LENGTH_LEFT_PERCENT_BOOL, true); - - int textVertPos = isTextTop ? smilPosTop : smilPosBottom; - msg_set_int_value(textRegion, MSG_MMS_REGION_LENGTH_TOP_INT, textVertPos); - - msg_set_bool_value(textRegion, MSG_MMS_REGION_LENGTH_TOP_PERCENT_BOOL, true); - - msg_set_int_value(textRegion, MSG_MMS_REGION_LENGTH_WIDTH_INT, smilRegionWidth); - msg_set_bool_value(textRegion, MSG_MMS_REGION_LENGTH_WIDTH_PERCENT_BOOL, true); - - msg_set_int_value(textRegion, MSG_MMS_REGION_LENGTH_HEIGHT_INT, smilRegionHeight); - msg_set_bool_value(textRegion, MSG_MMS_REGION_LENGTH_HEIGHT_PERCENT_BOOL, true); - - /* 2. image(video) region */ - msg_list_add_item(mms, MSG_STRUCT_MMS_REGION, &imageRegion); - MsgUtilsPrivate::setStr(imageRegion, MSG_MMS_REGION_ID_STR, imageRegionId); - msg_set_int_value(imageRegion, MSG_MMS_REGION_LENGTH_LEFT_INT, smilPosLeft); - msg_set_bool_value(imageRegion, MSG_MMS_REGION_LENGTH_LEFT_PERCENT_BOOL, true); - - int imgVertPos = isTextTop ? smilPosBottom : smilPosTop; - msg_set_int_value(imageRegion, MSG_MMS_REGION_LENGTH_TOP_INT, imgVertPos); - - msg_set_bool_value(imageRegion, MSG_MMS_REGION_LENGTH_TOP_PERCENT_BOOL, true); - msg_set_int_value(imageRegion, MSG_MMS_REGION_LENGTH_WIDTH_INT, smilRegionWidth); - msg_set_bool_value(imageRegion, MSG_MMS_REGION_LENGTH_WIDTH_PERCENT_BOOL, true); - msg_set_int_value(imageRegion, MSG_MMS_REGION_LENGTH_HEIGHT_INT, smilRegionHeight); - msg_set_bool_value(imageRegion, MSG_MMS_REGION_LENGTH_HEIGHT_PERCENT_BOOL, true); + msg_struct_t textRegion = NULL; + msg_struct_t imageRegion = NULL; + + /************ make rootlayout ***************/ + msg_set_int_value(mms, MSG_MMS_ROOTLAYOUT_WIDTH_INT, smilScreenWidthP); + msg_set_int_value(mms, MSG_MMS_ROOTLAYOUT_HEIGHT_INT, smilScreenHeightP); + + msg_set_bool_value(mms, MSG_MMS_ROOTLAYOUT_WIDTH_PERCENT_BOOL, true); + msg_set_bool_value(mms, MSG_MMS_ROOTLAYOUT_HEIGHT_PERCENT_BOOL, true); + /************ make region ********************/ + /* 1. add text region */ + msg_list_add_item(mms, MSG_STRUCT_MMS_REGION, &textRegion); + MsgUtilsPrivate::setStr(textRegion, MSG_MMS_REGION_ID_STR, textRegionId); + msg_set_int_value(textRegion, MSG_MMS_REGION_LENGTH_LEFT_INT, smilPosLeft); + msg_set_bool_value(textRegion, MSG_MMS_REGION_LENGTH_LEFT_PERCENT_BOOL, true); + + int textVertPos = isTextTop ? smilPosTop : smilPosBottom; + msg_set_int_value(textRegion, MSG_MMS_REGION_LENGTH_TOP_INT, textVertPos); + + msg_set_bool_value(textRegion, MSG_MMS_REGION_LENGTH_TOP_PERCENT_BOOL, true); + + msg_set_int_value(textRegion, MSG_MMS_REGION_LENGTH_WIDTH_INT, smilRegionWidth); + msg_set_bool_value(textRegion, MSG_MMS_REGION_LENGTH_WIDTH_PERCENT_BOOL, true); + + msg_set_int_value(textRegion, MSG_MMS_REGION_LENGTH_HEIGHT_INT, smilRegionHeight); + msg_set_bool_value(textRegion, MSG_MMS_REGION_LENGTH_HEIGHT_PERCENT_BOOL, true); + + /* 2. image(video) region */ + msg_list_add_item(mms, MSG_STRUCT_MMS_REGION, &imageRegion); + MsgUtilsPrivate::setStr(imageRegion, MSG_MMS_REGION_ID_STR, imageRegionId); + msg_set_int_value(imageRegion, MSG_MMS_REGION_LENGTH_LEFT_INT, smilPosLeft); + msg_set_bool_value(imageRegion, MSG_MMS_REGION_LENGTH_LEFT_PERCENT_BOOL, true); + + int imgVertPos = isTextTop ? smilPosBottom : smilPosTop; + msg_set_int_value(imageRegion, MSG_MMS_REGION_LENGTH_TOP_INT, imgVertPos); + + msg_set_bool_value(imageRegion, MSG_MMS_REGION_LENGTH_TOP_PERCENT_BOOL, true); + msg_set_int_value(imageRegion, MSG_MMS_REGION_LENGTH_WIDTH_INT, smilRegionWidth); + msg_set_bool_value(imageRegion, MSG_MMS_REGION_LENGTH_WIDTH_PERCENT_BOOL, true); + msg_set_int_value(imageRegion, MSG_MMS_REGION_LENGTH_HEIGHT_INT, smilRegionHeight); + msg_set_bool_value(imageRegion, MSG_MMS_REGION_LENGTH_HEIGHT_PERCENT_BOOL, true); } diff --git a/src/Common/MsgEngine/src/private/MsgComposerPrivate.h b/src/Common/MsgEngine/src/private/MsgComposerPrivate.h index 8f6cda48..1e33bd86 100644 --- a/src/Common/MsgEngine/src/private/MsgComposerPrivate.h +++ b/src/Common/MsgEngine/src/private/MsgComposerPrivate.h @@ -21,20 +21,20 @@ #include namespace Msg { - class MsgComposerPrivate - : public MsgComposer { - public: - MsgComposerPrivate(); - MsgComposerPrivate(MsgComposerPrivate&) = delete; - MsgComposerPrivate &operator=(MsgComposerPrivate&) = delete; - virtual ~MsgComposerPrivate(); + class MsgComposerPrivate + : public MsgComposer { + public: + MsgComposerPrivate(); + MsgComposerPrivate(MsgComposerPrivate&) = delete; + MsgComposerPrivate &operator=(MsgComposerPrivate&) = delete; + virtual ~MsgComposerPrivate(); - virtual MessageSMSRef createSms(); - virtual MessageMmsRef createMms(); + virtual MessageSMSRef createSms(); + virtual MessageMmsRef createMms(); - private: - void setSmilHeader(msg_struct_t mms, bool isTextTop); - }; + private: + void setSmilHeader(msg_struct_t mms, bool isTextTop); + }; } #endif /* __MSG_COMPOSER_PRIVATE_H__ */ diff --git a/src/Common/MsgEngine/src/private/MsgConvMediaPrivate.cpp b/src/Common/MsgEngine/src/private/MsgConvMediaPrivate.cpp index 8b342649..905949b7 100644 --- a/src/Common/MsgEngine/src/private/MsgConvMediaPrivate.cpp +++ b/src/Common/MsgEngine/src/private/MsgConvMediaPrivate.cpp @@ -20,8 +20,8 @@ using namespace Msg; MsgConvMediaPrivate::MsgConvMediaPrivate(bool release, msg_struct_t msgStruct) - : MsgStructPrivate(release, msgStruct) - , MsgConvMedia() + : MsgStructPrivate(release, msgStruct) + , MsgConvMedia() { } @@ -31,30 +31,30 @@ MsgConvMediaPrivate::~MsgConvMediaPrivate() std::string MsgConvMediaPrivate::getMime() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MULTIPART_CONTENT_TYPE_STR, MAX_MIME_TYPE_LEN); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MULTIPART_CONTENT_TYPE_STR, MAX_MIME_TYPE_LEN); } std::string MsgConvMediaPrivate::getName() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MULTIPART_NAME_STR, MSG_FILENAME_LEN_MAX); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MULTIPART_NAME_STR, MSG_FILENAME_LEN_MAX); } std::string MsgConvMediaPrivate::getPath() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MULTIPART_FILEPATH_STR, MSG_FILEPATH_LEN_MAX); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MULTIPART_FILEPATH_STR, MSG_FILEPATH_LEN_MAX); } std::string MsgConvMediaPrivate::getThumbPath() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MULTIPART_THUMBNAIL_FILEPATH_STR, MSG_FILEPATH_LEN_MAX); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MULTIPART_THUMBNAIL_FILEPATH_STR, MSG_FILEPATH_LEN_MAX); } std::string MsgConvMediaPrivate::getContentId() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MULTIPART_CONTENT_ID_STR, MMS_MSG_ID_LEN); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MULTIPART_CONTENT_ID_STR, MMS_MSG_ID_LEN); } std::string MsgConvMediaPrivate::getContentLocation() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MULTIPART_CONTENT_LOCATION_STR, MMS_LOCATION_LEN); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MULTIPART_CONTENT_LOCATION_STR, MMS_LOCATION_LEN); } diff --git a/src/Common/MsgEngine/src/private/MsgConvMediaPrivate.h b/src/Common/MsgEngine/src/private/MsgConvMediaPrivate.h index 2f1fc09d..8e2f3f4d 100644 --- a/src/Common/MsgEngine/src/private/MsgConvMediaPrivate.h +++ b/src/Common/MsgEngine/src/private/MsgConvMediaPrivate.h @@ -22,22 +22,22 @@ #include "MsgStructPrivate.h" namespace Msg { - class MsgConvMediaPrivate - : public MsgStructPrivate - , public MsgConvMedia { - public: - MsgConvMediaPrivate(bool release, msg_struct_t msgStruct = nullptr); - virtual ~MsgConvMediaPrivate(); + class MsgConvMediaPrivate + : public MsgStructPrivate + , public MsgConvMedia { + public: + MsgConvMediaPrivate(bool release, msg_struct_t msgStruct = nullptr); + virtual ~MsgConvMediaPrivate(); - virtual std::string getMime() const; - virtual std::string getName() const; - virtual std::string getPath() const; - virtual std::string getThumbPath() const; - virtual std::string getContentId() const; - virtual std::string getContentLocation() const; - }; + virtual std::string getMime() const; + virtual std::string getName() const; + virtual std::string getPath() const; + virtual std::string getThumbPath() const; + virtual std::string getContentId() const; + virtual std::string getContentLocation() const; + }; - typedef class MsgListHandlePrivate MsgConvMediaListHandlePrivate; + typedef class MsgListHandlePrivate MsgConvMediaListHandlePrivate; } #endif /* MSGCONVMEDIAPRIVATE_H_ */ diff --git a/src/Common/MsgEngine/src/private/MsgConversationItemPrivate.cpp b/src/Common/MsgEngine/src/private/MsgConversationItemPrivate.cpp index 2981a96f..19630e79 100644 --- a/src/Common/MsgEngine/src/private/MsgConversationItemPrivate.cpp +++ b/src/Common/MsgEngine/src/private/MsgConversationItemPrivate.cpp @@ -24,8 +24,8 @@ using namespace Msg; MsgConversationItemPrivate::MsgConversationItemPrivate(bool release, msg_struct_t msgStruct) - : MsgStructPrivate(release, msgStruct) - , m_MultipartList(false) + : MsgStructPrivate(release, msgStruct) + , m_MultipartList(false) { } @@ -35,95 +35,95 @@ MsgConversationItemPrivate::~MsgConversationItemPrivate() MsgId MsgConversationItemPrivate::getMsgId() const { - int id = MsgId::invalidId; - msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_ID_INT, &id); - return id; + int id = MsgId::invalidId; + msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_ID_INT, &id); + return id; } ThreadId MsgConversationItemPrivate::getThreadId() const { - int id = ThreadId::invalidId; - msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_THREAD_ID_INT, &id); - return id; + int id = ThreadId::invalidId; + msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_THREAD_ID_INT, &id); + return id; } std::string MsgConversationItemPrivate::getText() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_CONV_MSG_TEXT_STR, MAX_MSG_TEXT_LEN); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_CONV_MSG_TEXT_STR, MAX_MSG_TEXT_LEN); } std::string MsgConversationItemPrivate::getSubject() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_CONV_MSG_SUBJECT_STR, MAX_SUBJECT_LEN); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_CONV_MSG_SUBJECT_STR, MAX_SUBJECT_LEN); } time_t MsgConversationItemPrivate::getTime() const { - int time = 0; - msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_DISPLAY_TIME_INT, &time); - return time; + int time = 0; + msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_DISPLAY_TIME_INT, &time); + return time; } Message::Direction MsgConversationItemPrivate::getDirection() const { - int direction = 0; - msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_DIRECTION_INT, &direction); - return MsgUtilsPrivate::nativeToDirection(direction); + int direction = 0; + msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_DIRECTION_INT, &direction); + return MsgUtilsPrivate::nativeToDirection(direction); } Message::Type MsgConversationItemPrivate::getType() const { - int type = 0; - msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_TYPE_INT, &type); - return MsgUtilsPrivate::nativeToMessageType(type); + int type = 0; + msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_TYPE_INT, &type); + return MsgUtilsPrivate::nativeToMessageType(type); } Message::NetworkStatus MsgConversationItemPrivate::getNetworkStatus() const { - int status = 0; - int err = msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_NETWORK_STATUS_INT, &status); - return err == 0 ? MsgUtilsPrivate::nativeToNetworkStatus(status) : Message::NS_Unknown; + int status = 0; + int err = msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_NETWORK_STATUS_INT, &status); + return err == 0 ? MsgUtilsPrivate::nativeToNetworkStatus(status) : Message::NS_Unknown; } bool MsgConversationItemPrivate::isDraft() const { - int folder = 0; - msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_FOLDER_ID_INT, &folder); - return (folder == MSG_DRAFT_ID); + int folder = 0; + msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_FOLDER_ID_INT, &folder); + return (folder == MSG_DRAFT_ID); } bool MsgConversationItemPrivate::isRead() const { - bool read = 0; - msg_get_bool_value(m_MsgStruct, MSG_CONV_MSG_READ_BOOL, &read); - return read; + bool read = 0; + msg_get_bool_value(m_MsgStruct, MSG_CONV_MSG_READ_BOOL, &read); + return read; } int MsgConversationItemPrivate::getPagesCount() const { - int pages = 0; - msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_PAGE_COUNT_INT, &pages); - return pages; + int pages = 0; + msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_PAGE_COUNT_INT, &pages); + return pages; } int MsgConversationItemPrivate::getAttachCount() const { - int attachments = 0; - msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_ATTACH_COUNT_INT, &attachments); - return attachments; + int attachments = 0; + msg_get_int_value(m_MsgStruct, MSG_CONV_MSG_ATTACH_COUNT_INT, &attachments); + return attachments; } const MsgConvMediaListHandlePrivate &MsgConversationItemPrivate::getMediaList() const { - msg_list_handle_t multipartList = nullptr; - msg_get_list_handle(m_MsgStruct, MSG_CONV_MSG_MULTIPART_HND, (void **)&multipartList); - m_MultipartList.set(multipartList); - return m_MultipartList; + msg_list_handle_t multipartList = nullptr; + msg_get_list_handle(m_MsgStruct, MSG_CONV_MSG_MULTIPART_HND, (void **)&multipartList); + m_MultipartList.set(multipartList); + return m_MultipartList; } bool MsgConversationItemPrivate::isRestrictedByDpm() const { - bool restricted = false; - msg_get_bool_value(m_MsgStruct, MSG_CONV_MSG_DPM_RESTRICTED_BOOL, &restricted); - return restricted; + bool restricted = false; + msg_get_bool_value(m_MsgStruct, MSG_CONV_MSG_DPM_RESTRICTED_BOOL, &restricted); + return restricted; } diff --git a/src/Common/MsgEngine/src/private/MsgConversationItemPrivate.h b/src/Common/MsgEngine/src/private/MsgConversationItemPrivate.h index b1e55d85..57d3c91a 100644 --- a/src/Common/MsgEngine/src/private/MsgConversationItemPrivate.h +++ b/src/Common/MsgEngine/src/private/MsgConversationItemPrivate.h @@ -24,37 +24,37 @@ #include "MsgConvMediaPrivate.h" namespace Msg { - /** - * @brief Implementation of MsgConversationItem with msg-service private API usage. - */ - class MsgConversationItemPrivate - : public MsgStructPrivate - , public MsgConversationItem { - public: - MsgConversationItemPrivate(bool release, msg_struct_t msgStruct = nullptr); - virtual ~MsgConversationItemPrivate(); + /** + * @brief Implementation of MsgConversationItem with msg-service private API usage. + */ + class MsgConversationItemPrivate + : public MsgStructPrivate + , public MsgConversationItem { + public: + MsgConversationItemPrivate(bool release, msg_struct_t msgStruct = nullptr); + virtual ~MsgConversationItemPrivate(); - virtual MsgId getMsgId() const; - virtual ThreadId getThreadId() const; - virtual std::string getText() const; - virtual std::string getSubject() const; - virtual time_t getTime() const; - virtual Message::Direction getDirection() const; - virtual Message::Type getType() const; - virtual Message::NetworkStatus getNetworkStatus() const; - virtual bool isDraft() const; - virtual bool isRead() const; - virtual int getPagesCount() const; - virtual int getAttachCount() const; - virtual const MsgConvMediaListHandlePrivate &getMediaList() const; - virtual bool isRestrictedByDpm() const; + virtual MsgId getMsgId() const; + virtual ThreadId getThreadId() const; + virtual std::string getText() const; + virtual std::string getSubject() const; + virtual time_t getTime() const; + virtual Message::Direction getDirection() const; + virtual Message::Type getType() const; + virtual Message::NetworkStatus getNetworkStatus() const; + virtual bool isDraft() const; + virtual bool isRead() const; + virtual int getPagesCount() const; + virtual int getAttachCount() const; + virtual const MsgConvMediaListHandlePrivate &getMediaList() const; + virtual bool isRestrictedByDpm() const; - protected: - mutable MsgConvMediaListHandlePrivate m_MultipartList; - }; + protected: + mutable MsgConvMediaListHandlePrivate m_MultipartList; + }; - typedef class MsgListHandlePrivate MsgConversationListHandlePrivate; - typedef class MsgStructListPrivate MsgConversationStructListPrivate; + typedef class MsgListHandlePrivate MsgConversationListHandlePrivate; + typedef class MsgStructListPrivate MsgConversationStructListPrivate; } #endif /* __MSG_CONVERSATION_ITEM_PRIVATE_H__ */ diff --git a/src/Common/MsgEngine/src/private/MsgDefPrivate.h b/src/Common/MsgEngine/src/private/MsgDefPrivate.h index 38e06709..31e39fa2 100644 --- a/src/Common/MsgEngine/src/private/MsgDefPrivate.h +++ b/src/Common/MsgEngine/src/private/MsgDefPrivate.h @@ -20,30 +20,30 @@ #include namespace Msg { - // SMIL layout: - const int smilScreenWidthP = 100; - const int smilScreenHeightP = 100; - - const int smilPosTop = 1; - const int smilPosBottom = 50; - const int smilPosLeft = 0; - - const int smilRegionWidth = 100; - const int smilRegionHeight = 50; - - // Text style: - const int smilDefaultBgColor = 0xFF000000; - const int smilDefaultFontColor = 0xFFFFFFFF; - const int smilDefaultFontSize = 30; - const bool smilDefaultBold = false; - const bool smilDefaultUnderline = false; - - // Region id: - const std::string textRegionId = "Text"; - const std::string imageRegionId = "Image"; - - // Mime: - const std::string mimeText = "text/plain"; + // SMIL layout: + const int smilScreenWidthP = 100; + const int smilScreenHeightP = 100; + + const int smilPosTop = 1; + const int smilPosBottom = 50; + const int smilPosLeft = 0; + + const int smilRegionWidth = 100; + const int smilRegionHeight = 50; + + // Text style: + const int smilDefaultBgColor = 0xFF000000; + const int smilDefaultFontColor = 0xFFFFFFFF; + const int smilDefaultFontSize = 30; + const bool smilDefaultBold = false; + const bool smilDefaultUnderline = false; + + // Region id: + const std::string textRegionId = "Text"; + const std::string imageRegionId = "Image"; + + // Mime: + const std::string mimeText = "text/plain"; } diff --git a/src/Common/MsgEngine/src/private/MsgListHandlePrivate.h b/src/Common/MsgEngine/src/private/MsgListHandlePrivate.h index 5645b97c..84249f71 100644 --- a/src/Common/MsgEngine/src/private/MsgListHandlePrivate.h +++ b/src/Common/MsgEngine/src/private/MsgListHandlePrivate.h @@ -22,75 +22,75 @@ #include namespace Msg { - // class T : public BaseT {} - template - class MsgListHandlePrivate - : public MsgList { // implement interface - public: - MsgListHandlePrivate(bool release, msg_list_handle_t list = nullptr) - : m_List(list) - , m_Object(false) - , m_Release(release) - { - } + // class T : public BaseT {} + template + class MsgListHandlePrivate + : public MsgList { // implement interface + public: + MsgListHandlePrivate(bool release, msg_list_handle_t list = nullptr) + : m_List(list) + , m_Object(false) + , m_Release(release) + { + } - virtual ~MsgListHandlePrivate() - { - if (m_Release && m_List) - msg_list_free(m_List); - } + virtual ~MsgListHandlePrivate() + { + if (m_Release && m_List) + msg_list_free(m_List); + } - virtual BaseT &at(int i) - { - msg_struct_t msgStruct = msg_list_nth_data(m_List, i); - m_Object.set(msgStruct); - return m_Object; - } + virtual BaseT &at(int i) + { + msg_struct_t msgStruct = msg_list_nth_data(m_List, i); + m_Object.set(msgStruct); + return m_Object; + } - virtual const BaseT &at(int i) const - { - msg_struct_t msgStruct = msg_list_nth_data(m_List, i); - m_Object.set(msgStruct); - return m_Object; - } + virtual const BaseT &at(int i) const + { + msg_struct_t msgStruct = msg_list_nth_data(m_List, i); + m_Object.set(msgStruct); + return m_Object; + } - virtual int getLength() const - { - return msg_list_length(m_List); - } + virtual int getLength() const + { + return msg_list_length(m_List); + } - inline void set(msg_list_handle_t list) - { - m_List = list; - } + inline void set(msg_list_handle_t list) + { + m_List = list; + } - inline operator msg_list_handle_t &() - { - return m_List; - } + inline operator msg_list_handle_t &() + { + return m_List; + } - inline operator const msg_list_handle_t &() const - { - return m_List; - } + inline operator const msg_list_handle_t &() const + { + return m_List; + } - inline const msg_list_handle_t &get() const - { - return m_List; - } + inline const msg_list_handle_t &get() const + { + return m_List; + } - inline msg_list_handle_t &get() - { - return m_List; - } - MsgListHandlePrivate(MsgListHandlePrivate&) = delete; - MsgListHandlePrivate &operator=(MsgListHandlePrivate&) = delete; + inline msg_list_handle_t &get() + { + return m_List; + } + MsgListHandlePrivate(MsgListHandlePrivate&) = delete; + MsgListHandlePrivate &operator=(MsgListHandlePrivate&) = delete; - protected: - mutable msg_list_handle_t m_List; - mutable T m_Object; - bool m_Release; - }; + protected: + mutable msg_list_handle_t m_List; + mutable T m_Object; + bool m_Release; + }; } #endif /* _MsgListHandlePrivate_H__ */ diff --git a/src/Common/MsgEngine/src/private/MsgMediaPrivate.cpp b/src/Common/MsgEngine/src/private/MsgMediaPrivate.cpp index e5d5ebb1..2d3c12d4 100644 --- a/src/Common/MsgEngine/src/private/MsgMediaPrivate.cpp +++ b/src/Common/MsgEngine/src/private/MsgMediaPrivate.cpp @@ -26,7 +26,7 @@ using namespace Msg; MsgMediaPrivate::MsgMediaPrivate(bool release, msg_struct_t msgStruct) - : MsgStructPrivate(release, msgStruct) + : MsgStructPrivate(release, msgStruct) { } @@ -36,59 +36,59 @@ MsgMediaPrivate::~MsgMediaPrivate() MsgMediaPrivate::Type MsgMediaPrivate::getType() const { - int type = UnknownType; - msg_get_int_value(m_MsgStruct, MSG_MMS_MEDIA_TYPE_INT, &type); - return MsgUtilsPrivate::nativeToSmilType(type); + int type = UnknownType; + msg_get_int_value(m_MsgStruct, MSG_MMS_MEDIA_TYPE_INT, &type); + return MsgUtilsPrivate::nativeToSmilType(type); } std::string MsgMediaPrivate::getFileName() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MEDIA_FILENAME_STR, MSG_FILENAME_LEN_MAX); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MEDIA_FILENAME_STR, MSG_FILENAME_LEN_MAX); } std::string MsgMediaPrivate::getFilePath() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MEDIA_FILEPATH_STR, MSG_FILEPATH_LEN_MAX); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MEDIA_FILEPATH_STR, MSG_FILEPATH_LEN_MAX); } std::string MsgMediaPrivate::getMime() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MEDIA_CONTENT_TYPE_STR, MAX_MIME_TYPE_LEN); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_MMS_MEDIA_CONTENT_TYPE_STR, MAX_MIME_TYPE_LEN); } void MsgMediaPrivate::setType(Type type) { - msg_set_int_value(m_MsgStruct, MSG_MMS_MEDIA_TYPE_INT, MsgUtilsPrivate::smilTypeToNative(type)); + msg_set_int_value(m_MsgStruct, MSG_MMS_MEDIA_TYPE_INT, MsgUtilsPrivate::smilTypeToNative(type)); - switch (type) { - case ImageType: - case VideoType: - MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_MEDIA_REGION_ID_STR, imageRegionId); - break; - case AudioType: - break; - case TextType: - MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_MEDIA_REGION_ID_STR, textRegionId); - break; - default: - MSG_ASSERT(false, "Wrong SMIL type:", type); - } + switch (type) { + case ImageType: + case VideoType: + MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_MEDIA_REGION_ID_STR, imageRegionId); + break; + case AudioType: + break; + case TextType: + MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_MEDIA_REGION_ID_STR, textRegionId); + break; + default: + MSG_ASSERT(false, "Wrong SMIL type:", type); + } } void MsgMediaPrivate::setMime(const std::string &mime) { - MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_MEDIA_CONTENT_TYPE_STR, mime); + MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_MEDIA_CONTENT_TYPE_STR, mime); } void MsgMediaPrivate::setFilePath(const std::string &path) { - MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_MEDIA_FILEPATH_STR, path); - MediaTypeData mediaData = getMsgMediaTypeByFileExt(path); - setType(mediaData.type); - setFileName(FileUtils::getFileName(path)); + MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_MEDIA_FILEPATH_STR, path); + MediaTypeData mediaData = getMsgMediaTypeByFileExt(path); + setType(mediaData.type); + setFileName(FileUtils::getFileName(path)); } void MsgMediaPrivate::setFileName(const std::string &name) { - MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_MEDIA_FILENAME_STR, name); + MsgUtilsPrivate::setStr(m_MsgStruct, MSG_MMS_MEDIA_FILENAME_STR, name); } diff --git a/src/Common/MsgEngine/src/private/MsgMediaPrivate.h b/src/Common/MsgEngine/src/private/MsgMediaPrivate.h index bffa366f..6e25153b 100644 --- a/src/Common/MsgEngine/src/private/MsgMediaPrivate.h +++ b/src/Common/MsgEngine/src/private/MsgMediaPrivate.h @@ -23,26 +23,26 @@ #include "MsgStructListPrivate.h" namespace Msg { - class MsgMediaPrivate - : public MsgStructPrivate - , public MsgMedia { - public: - MsgMediaPrivate(bool release, msg_struct_t msgStruct = nullptr); - virtual ~MsgMediaPrivate(); + class MsgMediaPrivate + : public MsgStructPrivate + , public MsgMedia { + public: + MsgMediaPrivate(bool release, msg_struct_t msgStruct = nullptr); + virtual ~MsgMediaPrivate(); - virtual Type getType() const; - virtual std::string getFilePath() const; - virtual std::string getFileName() const; - virtual void setFilePath(const std::string &path); + virtual Type getType() const; + virtual std::string getFilePath() const; + virtual std::string getFileName() const; + virtual void setFilePath(const std::string &path); - std::string getMime() const; - void setFileName(const std::string &name); - void setMime(const std::string &mime); - void setType(Type type); - }; + std::string getMime() const; + void setFileName(const std::string &name); + void setMime(const std::string &mime); + void setType(Type type); + }; - typedef class MsgListHandlePrivate MsgMediaListHandlePrivate; - typedef class MsgStructListPrivate MsgMediaStructListPrivate; + typedef class MsgListHandlePrivate MsgMediaListHandlePrivate; + typedef class MsgStructListPrivate MsgMediaStructListPrivate; } #endif /* _MSG_MEDIA_PRIVATE_H__ */ diff --git a/src/Common/MsgEngine/src/private/MsgPagePrivate.cpp b/src/Common/MsgEngine/src/private/MsgPagePrivate.cpp index b7ae9a8c..e034c68e 100644 --- a/src/Common/MsgEngine/src/private/MsgPagePrivate.cpp +++ b/src/Common/MsgEngine/src/private/MsgPagePrivate.cpp @@ -19,9 +19,9 @@ using namespace Msg; MsgPagePrivate::MsgPagePrivate(bool release, msg_struct_t msgStruct) - : MsgStructPrivate(release, msgStruct) - , m_MediaList(false) - , m_Media(false) + : MsgStructPrivate(release, msgStruct) + , m_MediaList(false) + , m_Media(false) { } @@ -31,29 +31,29 @@ MsgPagePrivate::~MsgPagePrivate() MsgMediaListHandlePrivate &MsgPagePrivate::getMediaList() { - msg_list_handle_t mediaList = nullptr; - msg_get_list_handle(m_MsgStruct, MSG_MMS_PAGE_MEDIA_LIST_HND, (void **)&mediaList); - m_MediaList.set(mediaList); - return m_MediaList; + msg_list_handle_t mediaList = nullptr; + msg_get_list_handle(m_MsgStruct, MSG_MMS_PAGE_MEDIA_LIST_HND, (void **)&mediaList); + m_MediaList.set(mediaList); + return m_MediaList; } MsgMediaPrivate &MsgPagePrivate::addMedia() { - msg_struct_t media = nullptr; - msg_list_add_item(m_MsgStruct, MSG_STRUCT_MMS_MEDIA, &media); - m_Media.set(media); - return m_Media; + msg_struct_t media = nullptr; + msg_list_add_item(m_MsgStruct, MSG_STRUCT_MMS_MEDIA, &media); + m_Media.set(media); + return m_Media; } void MsgPagePrivate::setPageDuration(int duration) { - msg_set_int_value(m_MsgStruct, MSG_MMS_PAGE_PAGE_DURATION_INT, duration); + msg_set_int_value(m_MsgStruct, MSG_MMS_PAGE_PAGE_DURATION_INT, duration); } int MsgPagePrivate::getPageDuration() const { - int duration = 0; - msg_get_int_value(m_MsgStruct, MSG_MMS_PAGE_PAGE_DURATION_INT, &duration); - return duration; + int duration = 0; + msg_get_int_value(m_MsgStruct, MSG_MMS_PAGE_PAGE_DURATION_INT, &duration); + return duration; } diff --git a/src/Common/MsgEngine/src/private/MsgPagePrivate.h b/src/Common/MsgEngine/src/private/MsgPagePrivate.h index 8e676b95..c0df9b51 100644 --- a/src/Common/MsgEngine/src/private/MsgPagePrivate.h +++ b/src/Common/MsgEngine/src/private/MsgPagePrivate.h @@ -21,25 +21,25 @@ #include "MsgMediaPrivate.h" namespace Msg { - class MsgPagePrivate - : public MsgStructPrivate - , public MsgPage { - public: - MsgPagePrivate(bool release, msg_struct_t msgStruct = nullptr); - virtual ~MsgPagePrivate(); + class MsgPagePrivate + : public MsgStructPrivate + , public MsgPage { + public: + MsgPagePrivate(bool release, msg_struct_t msgStruct = nullptr); + virtual ~MsgPagePrivate(); - virtual MsgMediaListHandlePrivate &getMediaList(); - virtual MsgMediaPrivate &addMedia(); - virtual void setPageDuration(int duration); - virtual int getPageDuration() const; + virtual MsgMediaListHandlePrivate &getMediaList(); + virtual MsgMediaPrivate &addMedia(); + virtual void setPageDuration(int duration); + virtual int getPageDuration() const; - private: - MsgMediaListHandlePrivate m_MediaList; - MsgMediaPrivate m_Media; - }; + private: + MsgMediaListHandlePrivate m_MediaList; + MsgMediaPrivate m_Media; + }; - typedef class MsgListHandlePrivate MsgPageListHandlePrivate; - typedef class MsgStructListPrivate MsgPageStructListPrivate; + typedef class MsgListHandlePrivate MsgPageListHandlePrivate; + typedef class MsgStructListPrivate MsgPageStructListPrivate; } #endif /* _MSG_PAGE_PRIVATE_H__ */ diff --git a/src/Common/MsgEngine/src/private/MsgReportPrivate.cpp b/src/Common/MsgEngine/src/private/MsgReportPrivate.cpp index 4c0a20c5..b2baf963 100644 --- a/src/Common/MsgEngine/src/private/MsgReportPrivate.cpp +++ b/src/Common/MsgEngine/src/private/MsgReportPrivate.cpp @@ -22,8 +22,8 @@ using namespace Msg; MsgReportPrivate::MsgReportPrivate(bool release, msg_struct_t msgStruct) - : MsgStructPrivate(release, msgStruct) - , MsgReport() + : MsgStructPrivate(release, msgStruct) + , MsgReport() { } @@ -33,33 +33,33 @@ MsgReportPrivate::~MsgReportPrivate() std::string MsgReportPrivate::getAddress() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_REPORT_ADDRESS_STR, MAX_ADDRESS_VAL_LEN); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_REPORT_ADDRESS_STR, MAX_ADDRESS_VAL_LEN); } MsgReport::DeliveryStatus MsgReportPrivate::getDeliveryStatus() const { - int nativeType = MSG_DELIVERY_REPORT_NONE; - msg_get_int_value(m_MsgStruct, MSG_REPORT_STATUS_INT, &nativeType); - return MsgUtilsPrivate::nativeToReportDeliveryStatus(nativeType); + int nativeType = MSG_DELIVERY_REPORT_NONE; + msg_get_int_value(m_MsgStruct, MSG_REPORT_STATUS_INT, &nativeType); + return MsgUtilsPrivate::nativeToReportDeliveryStatus(nativeType); } MsgReport::ReadStatus MsgReportPrivate::getReadStatus() const { - int nativeType = MSG_READ_REPORT_NONE; - msg_get_int_value(m_MsgStruct, MSG_REPORT_STATUS_INT, (int *)&nativeType); - return MsgUtilsPrivate::nativeToReportReadStatus(nativeType); + int nativeType = MSG_READ_REPORT_NONE; + msg_get_int_value(m_MsgStruct, MSG_REPORT_STATUS_INT, (int *)&nativeType); + return MsgUtilsPrivate::nativeToReportReadStatus(nativeType); } MsgReport::Type MsgReportPrivate::getType() const { - int nativeType = MSG_REPORT_TYPE_DELIVERY; - msg_get_int_value(m_MsgStruct, MSG_REPORT_TYPE_INT, &nativeType); - return MsgUtilsPrivate::nativeToReportType(nativeType); + int nativeType = MSG_REPORT_TYPE_DELIVERY; + msg_get_int_value(m_MsgStruct, MSG_REPORT_TYPE_INT, &nativeType); + return MsgUtilsPrivate::nativeToReportType(nativeType); } time_t MsgReportPrivate::getTime() const { - int time = 0; - msg_get_int_value(m_MsgStruct, MSG_REPORT_TIME_INT, &time); - return (time_t)time; + int time = 0; + msg_get_int_value(m_MsgStruct, MSG_REPORT_TIME_INT, &time); + return (time_t)time; } diff --git a/src/Common/MsgEngine/src/private/MsgReportPrivate.h b/src/Common/MsgEngine/src/private/MsgReportPrivate.h index daaff40a..f7b60774 100644 --- a/src/Common/MsgEngine/src/private/MsgReportPrivate.h +++ b/src/Common/MsgEngine/src/private/MsgReportPrivate.h @@ -23,22 +23,22 @@ #include "MsgStructPrivate.h" namespace Msg { - class MsgReportPrivate - : public MsgStructPrivate - , public MsgReport { - public: - MsgReportPrivate(bool release, msg_struct_t msgStruct = nullptr); - virtual ~MsgReportPrivate(); + class MsgReportPrivate + : public MsgStructPrivate + , public MsgReport { + public: + MsgReportPrivate(bool release, msg_struct_t msgStruct = nullptr); + virtual ~MsgReportPrivate(); - virtual std::string getAddress() const; - virtual DeliveryStatus getDeliveryStatus() const; - virtual ReadStatus getReadStatus() const; - virtual Type getType() const; - virtual time_t getTime() const; - }; + virtual std::string getAddress() const; + virtual DeliveryStatus getDeliveryStatus() const; + virtual ReadStatus getReadStatus() const; + virtual Type getType() const; + virtual time_t getTime() const; + }; - typedef class MsgListHandlePrivate MsgReportListHandlePrivate; - typedef class MsgStructListPrivate MsgReportStructListPrivate; + typedef class MsgListHandlePrivate MsgReportListHandlePrivate; + typedef class MsgStructListPrivate MsgReportStructListPrivate; } #endif /* MsgReportPrivate_h_ */ diff --git a/src/Common/MsgEngine/src/private/MsgSettingsPrivate.cpp b/src/Common/MsgEngine/src/private/MsgSettingsPrivate.cpp index 8b4a75d1..8ecaf1a4 100644 --- a/src/Common/MsgEngine/src/private/MsgSettingsPrivate.cpp +++ b/src/Common/MsgEngine/src/private/MsgSettingsPrivate.cpp @@ -28,257 +28,257 @@ using namespace Msg; MsgSettingsPrivate::MsgSettingsPrivate(msg_handle_t serviceHandle) - : MsgSettings() - , m_ServiceHandle(serviceHandle) - , m_GeneralOpt() - , m_SmsSendOpt() - , m_MmsSendOpt() - , m_MmsRecvOpt() - , m_pActiveNotifJob(nullptr) - , m_ActiveNotifValue(0) + : MsgSettings() + , m_ServiceHandle(serviceHandle) + , m_GeneralOpt() + , m_SmsSendOpt() + , m_MmsSendOpt() + , m_MmsRecvOpt() + , m_pActiveNotifJob(nullptr) + , m_ActiveNotifValue(0) { - init(); + init(); } MsgSettingsPrivate::~MsgSettingsPrivate() { - finit(); + finit(); } void MsgSettingsPrivate::init() { - m_GeneralOpt = msg_create_struct(MSG_STRUCT_SETTING_GENERAL_OPT); - msg_get_general_opt(m_ServiceHandle, m_GeneralOpt); + m_GeneralOpt = msg_create_struct(MSG_STRUCT_SETTING_GENERAL_OPT); + msg_get_general_opt(m_ServiceHandle, m_GeneralOpt); - m_SmsSendOpt = msg_create_struct(MSG_STRUCT_SETTING_SMS_SEND_OPT); - msg_get_sms_send_opt(m_ServiceHandle, m_SmsSendOpt); + m_SmsSendOpt = msg_create_struct(MSG_STRUCT_SETTING_SMS_SEND_OPT); + msg_get_sms_send_opt(m_ServiceHandle, m_SmsSendOpt); - m_MmsSendOpt = msg_create_struct(MSG_STRUCT_SETTING_MMS_SEND_OPT); - msg_get_mms_send_opt(m_ServiceHandle, m_MmsSendOpt); + m_MmsSendOpt = msg_create_struct(MSG_STRUCT_SETTING_MMS_SEND_OPT); + msg_get_mms_send_opt(m_ServiceHandle, m_MmsSendOpt); - m_MmsRecvOpt = msg_create_struct(MSG_STRUCT_SETTING_MMS_RECV_OPT); - msg_get_mms_recv_opt(m_ServiceHandle, m_MmsRecvOpt); + m_MmsRecvOpt = msg_create_struct(MSG_STRUCT_SETTING_MMS_RECV_OPT); + msg_get_mms_recv_opt(m_ServiceHandle, m_MmsRecvOpt); } void MsgSettingsPrivate::finit() { - if (m_pActiveNotifJob) { - ecore_job_del(m_pActiveNotifJob); - m_pActiveNotifJob = nullptr; - vconf_set_int(VCONFKEY_MESSAGE_ACTIVATED_CONVERSATION_ID, m_ActiveNotifValue); - MSG_LOG("ActiveNotifValue = ", m_ActiveNotifValue); - } - msg_release_struct(&m_MmsRecvOpt); - msg_release_struct(&m_MmsSendOpt); - msg_release_struct(&m_SmsSendOpt); - msg_release_struct(&m_GeneralOpt); + if (m_pActiveNotifJob) { + ecore_job_del(m_pActiveNotifJob); + m_pActiveNotifJob = nullptr; + vconf_set_int(VCONFKEY_MESSAGE_ACTIVATED_CONVERSATION_ID, m_ActiveNotifValue); + MSG_LOG("ActiveNotifValue = ", m_ActiveNotifValue); + } + msg_release_struct(&m_MmsRecvOpt); + msg_release_struct(&m_MmsSendOpt); + msg_release_struct(&m_SmsSendOpt); + msg_release_struct(&m_GeneralOpt); } int MsgSettingsPrivate::getAddressMaxLen() const { - return MAX_ADDRESS_VAL_LEN; + return MAX_ADDRESS_VAL_LEN; } int MsgSettingsPrivate::getPhoneNumberMaxLen() const { - return MAX_PHONE_NUMBER_LEN; + return MAX_PHONE_NUMBER_LEN; } int MsgSettingsPrivate::getAddressMaxCount() const { - return MAX_TO_ADDRESS_CNT; + return MAX_TO_ADDRESS_CNT; } int MsgSettingsPrivate::getSubjectMaxLen() const { - return MAX_SUBJECT_LEN; + return MAX_SUBJECT_LEN; } int MsgSettingsPrivate::getDisplayNameMaxLen() const { - return MAX_DISPLAY_NAME_LEN; + return MAX_DISPLAY_NAME_LEN; } int MsgSettingsPrivate::getMaxRecipientCount() const { - return MAX_TO_ADDRESS_CNT; + return MAX_TO_ADDRESS_CNT; } int MsgSettingsPrivate::getMaxMmsSize() const { - int res = 0; - msg_struct_t setting = msg_create_struct(MSG_STRUCT_SETTING_MSGSIZE_OPT); - if (msg_get_msgsize_opt(m_ServiceHandle, setting) == 0) - msg_get_int_value(setting, MSG_MESSAGE_SIZE_INT, &res); - msg_release_struct(&setting); + int res = 0; + msg_struct_t setting = msg_create_struct(MSG_STRUCT_SETTING_MSGSIZE_OPT); + if (msg_get_msgsize_opt(m_ServiceHandle, setting) == 0) + msg_get_int_value(setting, MSG_MESSAGE_SIZE_INT, &res); + msg_release_struct(&setting); - // Standard MMS has size 307200 bytes - const int kb = 1024; + // Standard MMS has size 307200 bytes + const int kb = 1024; - if (res > 0) { - res *= kb; - res -= 5 * kb; // header size - } else { - res = MAX_MSG_DATA_LEN * kb; - } + if (res > 0) { + res *= kb; + res -= 5 * kb; // header size + } else { + res = MAX_MSG_DATA_LEN * kb; + } - return res; + return res; } int MsgSettingsPrivate::getMaxMsgTextLen() const { - return MAX_MSG_TEXT_LEN; + return MAX_MSG_TEXT_LEN; } void MsgSettingsPrivate::setAlerts(bool value) { - msg_set_bool_value(m_GeneralOpt, MSG_GENERAL_MSG_NOTIFICATION_BOOL, value); - msg_set_general_opt(m_ServiceHandle, m_GeneralOpt); + msg_set_bool_value(m_GeneralOpt, MSG_GENERAL_MSG_NOTIFICATION_BOOL, value); + msg_set_general_opt(m_ServiceHandle, m_GeneralOpt); } bool MsgSettingsPrivate::getAlerts() const { - bool res = false; - msg_get_bool_value(m_GeneralOpt, MSG_GENERAL_MSG_NOTIFICATION_BOOL, &res); - return res; + bool res = false; + msg_get_bool_value(m_GeneralOpt, MSG_GENERAL_MSG_NOTIFICATION_BOOL, &res); + return res; } void MsgSettingsPrivate::setRingtoneType(RingtoneType type) { - msg_set_int_value(m_GeneralOpt, MSG_GENERAL_RINGTONE_TYPE_INT, MsgUtilsPrivate::ringtoneTypeToNative(type)); - msg_set_general_opt(m_ServiceHandle, m_GeneralOpt); - for (auto listener: m_Listeners) - listener->onRingtoneChanged(*this); + msg_set_int_value(m_GeneralOpt, MSG_GENERAL_RINGTONE_TYPE_INT, MsgUtilsPrivate::ringtoneTypeToNative(type)); + msg_set_general_opt(m_ServiceHandle, m_GeneralOpt); + for (auto listener: m_Listeners) + listener->onRingtoneChanged(*this); } MsgSettingsPrivate::RingtoneType MsgSettingsPrivate::getRingtoneType() const { - int type = MSG_RINGTONE_TYPE_DEFAULT; - msg_get_int_value(m_GeneralOpt, MSG_GENERAL_RINGTONE_TYPE_INT, &type); - return MsgUtilsPrivate::nativeToRingtoneType(type); + int type = MSG_RINGTONE_TYPE_DEFAULT; + msg_get_int_value(m_GeneralOpt, MSG_GENERAL_RINGTONE_TYPE_INT, &type); + return MsgUtilsPrivate::nativeToRingtoneType(type); } void MsgSettingsPrivate::setRingtone(const std::string &soundPath) { - MsgUtilsPrivate::setStr(m_GeneralOpt, MSG_GENERAL_RINGTONE_PATH_STR, soundPath); - msg_set_general_opt(m_ServiceHandle, m_GeneralOpt); - for (auto listener: m_Listeners) - listener->onRingtoneChanged(*this); + MsgUtilsPrivate::setStr(m_GeneralOpt, MSG_GENERAL_RINGTONE_PATH_STR, soundPath); + msg_set_general_opt(m_ServiceHandle, m_GeneralOpt); + for (auto listener: m_Listeners) + listener->onRingtoneChanged(*this); } std::string MsgSettingsPrivate::getRingtone() const { - return MsgUtilsPrivate::getStr(m_GeneralOpt, MSG_GENERAL_RINGTONE_PATH_STR, MSG_FILEPATH_LEN_MAX); + return MsgUtilsPrivate::getStr(m_GeneralOpt, MSG_GENERAL_RINGTONE_PATH_STR, MSG_FILEPATH_LEN_MAX); } void MsgSettingsPrivate::setVibration(bool value) { - msg_set_bool_value(m_GeneralOpt, MSG_GENERAL_MSG_VIBRATION_BOOL, value); - msg_set_general_opt(m_ServiceHandle, m_GeneralOpt); + msg_set_bool_value(m_GeneralOpt, MSG_GENERAL_MSG_VIBRATION_BOOL, value); + msg_set_general_opt(m_ServiceHandle, m_GeneralOpt); } bool MsgSettingsPrivate::getVibration() const { - bool res = false; - msg_get_bool_value(m_GeneralOpt, MSG_GENERAL_MSG_VIBRATION_BOOL, &res); - return res; + bool res = false; + msg_get_bool_value(m_GeneralOpt, MSG_GENERAL_MSG_VIBRATION_BOOL, &res); + return res; } void MsgSettingsPrivate::setSmsDelivReport(bool value) { - msg_set_bool_value(m_SmsSendOpt, MSG_SMS_SENDOPT_DELIVERY_REPORT_BOOL, value); - msg_set_sms_send_opt(m_ServiceHandle, m_SmsSendOpt); + msg_set_bool_value(m_SmsSendOpt, MSG_SMS_SENDOPT_DELIVERY_REPORT_BOOL, value); + msg_set_sms_send_opt(m_ServiceHandle, m_SmsSendOpt); } bool MsgSettingsPrivate::getSmsDelivReport() const { - bool res = false; - msg_get_bool_value(m_SmsSendOpt, MSG_SMS_SENDOPT_DELIVERY_REPORT_BOOL, &res); - return res; + bool res = false; + msg_get_bool_value(m_SmsSendOpt, MSG_SMS_SENDOPT_DELIVERY_REPORT_BOOL, &res); + return res; } void MsgSettingsPrivate::setMmsDelivReport(bool value) { - msg_set_bool_value(m_MmsSendOpt, MSG_MMS_SENDOPT_DELIVERY_REPORT_BOOL, value); - msg_set_mms_send_opt(m_ServiceHandle, m_MmsSendOpt); + msg_set_bool_value(m_MmsSendOpt, MSG_MMS_SENDOPT_DELIVERY_REPORT_BOOL, value); + msg_set_mms_send_opt(m_ServiceHandle, m_MmsSendOpt); } bool MsgSettingsPrivate::getMmsDelivReport() const { - bool res = false; - msg_get_bool_value(m_MmsSendOpt, MSG_MMS_SENDOPT_DELIVERY_REPORT_BOOL, &res); - return res; + bool res = false; + msg_get_bool_value(m_MmsSendOpt, MSG_MMS_SENDOPT_DELIVERY_REPORT_BOOL, &res); + return res; } void MsgSettingsPrivate::setMmsReadReport(bool value) { - msg_set_bool_value(m_MmsSendOpt, MSG_MMS_SENDOPT_READ_REPLY_BOOL, value); - msg_set_mms_send_opt(m_ServiceHandle, m_MmsSendOpt); + msg_set_bool_value(m_MmsSendOpt, MSG_MMS_SENDOPT_READ_REPLY_BOOL, value); + msg_set_mms_send_opt(m_ServiceHandle, m_MmsSendOpt); } bool MsgSettingsPrivate::getMmsReadReport() const { - bool res = false; - msg_get_bool_value(m_MmsSendOpt, MSG_MMS_SENDOPT_READ_REPLY_BOOL, &res); - return res; + bool res = false; + msg_get_bool_value(m_MmsSendOpt, MSG_MMS_SENDOPT_READ_REPLY_BOOL, &res); + return res; } void MsgSettingsPrivate::setMmsAutoRetr(bool value) { - int retrType = value ? MSG_HOME_AUTO_DOWNLOAD : MSG_HOME_MANUAL; - msg_set_int_value(m_MmsRecvOpt, MSG_MMS_RECVOPT_HOME_RETRIEVE_TYPE_INT, retrType); - msg_set_mms_recv_opt(m_ServiceHandle, m_MmsRecvOpt); + int retrType = value ? MSG_HOME_AUTO_DOWNLOAD : MSG_HOME_MANUAL; + msg_set_int_value(m_MmsRecvOpt, MSG_MMS_RECVOPT_HOME_RETRIEVE_TYPE_INT, retrType); + msg_set_mms_recv_opt(m_ServiceHandle, m_MmsRecvOpt); } bool MsgSettingsPrivate::getMmsAutoRetr() const { - bool res = false; - int retrType = 0; - msg_get_int_value(m_MmsRecvOpt, MSG_MMS_RECVOPT_HOME_RETRIEVE_TYPE_INT, &retrType); - res = retrType == MSG_HOME_AUTO_DOWNLOAD; - return res; + bool res = false; + int retrType = 0; + msg_get_int_value(m_MmsRecvOpt, MSG_MMS_RECVOPT_HOME_RETRIEVE_TYPE_INT, &retrType); + res = retrType == MSG_HOME_AUTO_DOWNLOAD; + return res; } void MsgSettingsPrivate::setMmsAutoRetrRoaming(bool value) { - int retrType = value ? MSG_ABROAD_AUTO_DOWNLOAD : MSG_ABROAD_MANUAL; - msg_set_int_value(m_MmsRecvOpt, MSG_MMS_RECVOPT_ABROAD_RETRIEVE_TYPE_INT, retrType); - msg_set_mms_recv_opt(m_ServiceHandle, m_MmsRecvOpt); + int retrType = value ? MSG_ABROAD_AUTO_DOWNLOAD : MSG_ABROAD_MANUAL; + msg_set_int_value(m_MmsRecvOpt, MSG_MMS_RECVOPT_ABROAD_RETRIEVE_TYPE_INT, retrType); + msg_set_mms_recv_opt(m_ServiceHandle, m_MmsRecvOpt); } bool MsgSettingsPrivate::getMmsAutoRetrRoaming() const { - bool res = false; - int retrType = 0; - msg_get_int_value(m_MmsRecvOpt, MSG_MMS_RECVOPT_ABROAD_RETRIEVE_TYPE_INT, &retrType); - res = retrType == MSG_ABROAD_AUTO_DOWNLOAD; - return res; + bool res = false; + int retrType = 0; + msg_get_int_value(m_MmsRecvOpt, MSG_MMS_RECVOPT_ABROAD_RETRIEVE_TYPE_INT, &retrType); + res = retrType == MSG_ABROAD_AUTO_DOWNLOAD; + return res; } void MsgSettingsPrivate::setActiveNotifPolicy(ActiveNotifPolicy type) { - int value = MsgUtilsPrivate::activeNotifPolicyToNative(type); - addJobSetActiveNotifPolicy(value); + int value = MsgUtilsPrivate::activeNotifPolicyToNative(type); + addJobSetActiveNotifPolicy(value); } void MsgSettingsPrivate::setActiveNotifPolicy(ThreadId id) { - addJobSetActiveNotifPolicy(id); + addJobSetActiveNotifPolicy(id); } void MsgSettingsPrivate::addJobSetActiveNotifPolicy(int value) { - m_ActiveNotifValue = value; - if (!m_pActiveNotifJob) { - m_pActiveNotifJob = ecore_job_add - ( - [](void *data) - { - auto *self =(MsgSettingsPrivate*)data; - self->m_pActiveNotifJob = nullptr; - vconf_set_int(VCONFKEY_MESSAGE_ACTIVATED_CONVERSATION_ID, self->m_ActiveNotifValue); - MSG_LOG("ActiveNotifValue = ", self->m_ActiveNotifValue); - }, - this); - } + m_ActiveNotifValue = value; + if (!m_pActiveNotifJob) { + m_pActiveNotifJob = ecore_job_add + ( + [](void *data) + { + auto *self =(MsgSettingsPrivate*)data; + self->m_pActiveNotifJob = nullptr; + vconf_set_int(VCONFKEY_MESSAGE_ACTIVATED_CONVERSATION_ID, self->m_ActiveNotifValue); + MSG_LOG("ActiveNotifValue = ", self->m_ActiveNotifValue); + }, + this); + } } diff --git a/src/Common/MsgEngine/src/private/MsgSettingsPrivate.h b/src/Common/MsgEngine/src/private/MsgSettingsPrivate.h index f3ea3f3f..3be16218 100644 --- a/src/Common/MsgEngine/src/private/MsgSettingsPrivate.h +++ b/src/Common/MsgEngine/src/private/MsgSettingsPrivate.h @@ -23,66 +23,66 @@ #include namespace Msg { - class MsgSettingsPrivate - : public MsgSettings { - public: - MsgSettingsPrivate(msg_handle_t serviceHandle); - MsgSettingsPrivate(MsgSettingsPrivate&) = delete; - MsgSettingsPrivate &operator=(MsgSettingsPrivate&) = delete; - virtual ~MsgSettingsPrivate(); - - virtual int getAddressMaxLen() const; - virtual int getPhoneNumberMaxLen() const; - virtual int getAddressMaxCount() const; - virtual int getSubjectMaxLen() const; - virtual int getDisplayNameMaxLen() const; - virtual int getMaxRecipientCount() const; - virtual int getMaxMmsSize() const; - virtual int getMaxMsgTextLen() const; - - virtual void setAlerts(bool value); - virtual bool getAlerts() const; - - virtual void setRingtoneType(RingtoneType type); - virtual RingtoneType getRingtoneType() const; - virtual void setRingtone(const std::string &soundPath); - virtual std::string getRingtone() const; - - virtual void setVibration(bool value); - virtual bool getVibration() const; - - virtual void setSmsDelivReport(bool value); - virtual bool getSmsDelivReport() const; - - virtual void setMmsDelivReport(bool value); - virtual bool getMmsDelivReport() const ; - - virtual void setMmsReadReport(bool value); - virtual bool getMmsReadReport() const; - - virtual void setMmsAutoRetr(bool value); - virtual bool getMmsAutoRetr() const; - - virtual void setMmsAutoRetrRoaming(bool value); - virtual bool getMmsAutoRetrRoaming() const; - - virtual void setActiveNotifPolicy(ActiveNotifPolicy type); - virtual void setActiveNotifPolicy(ThreadId id); - - private: - void init(); - void finit(); - void addJobSetActiveNotifPolicy(int value); - - private: - msg_handle_t m_ServiceHandle; - msg_struct_t m_GeneralOpt; - msg_struct_t m_SmsSendOpt; - msg_struct_t m_MmsSendOpt; - msg_struct_t m_MmsRecvOpt; - Ecore_Job *m_pActiveNotifJob; - int m_ActiveNotifValue; - }; + class MsgSettingsPrivate + : public MsgSettings { + public: + MsgSettingsPrivate(msg_handle_t serviceHandle); + MsgSettingsPrivate(MsgSettingsPrivate&) = delete; + MsgSettingsPrivate &operator=(MsgSettingsPrivate&) = delete; + virtual ~MsgSettingsPrivate(); + + virtual int getAddressMaxLen() const; + virtual int getPhoneNumberMaxLen() const; + virtual int getAddressMaxCount() const; + virtual int getSubjectMaxLen() const; + virtual int getDisplayNameMaxLen() const; + virtual int getMaxRecipientCount() const; + virtual int getMaxMmsSize() const; + virtual int getMaxMsgTextLen() const; + + virtual void setAlerts(bool value); + virtual bool getAlerts() const; + + virtual void setRingtoneType(RingtoneType type); + virtual RingtoneType getRingtoneType() const; + virtual void setRingtone(const std::string &soundPath); + virtual std::string getRingtone() const; + + virtual void setVibration(bool value); + virtual bool getVibration() const; + + virtual void setSmsDelivReport(bool value); + virtual bool getSmsDelivReport() const; + + virtual void setMmsDelivReport(bool value); + virtual bool getMmsDelivReport() const ; + + virtual void setMmsReadReport(bool value); + virtual bool getMmsReadReport() const; + + virtual void setMmsAutoRetr(bool value); + virtual bool getMmsAutoRetr() const; + + virtual void setMmsAutoRetrRoaming(bool value); + virtual bool getMmsAutoRetrRoaming() const; + + virtual void setActiveNotifPolicy(ActiveNotifPolicy type); + virtual void setActiveNotifPolicy(ThreadId id); + + private: + void init(); + void finit(); + void addJobSetActiveNotifPolicy(int value); + + private: + msg_handle_t m_ServiceHandle; + msg_struct_t m_GeneralOpt; + msg_struct_t m_SmsSendOpt; + msg_struct_t m_MmsSendOpt; + msg_struct_t m_MmsRecvOpt; + Ecore_Job *m_pActiveNotifJob; + int m_ActiveNotifValue; + }; } #endif /* __MsgSettingsPrivate_h__ */ diff --git a/src/Common/MsgEngine/src/private/MsgStoragePrivate.cpp b/src/Common/MsgEngine/src/private/MsgStoragePrivate.cpp index bcdd4505..361483c4 100644 --- a/src/Common/MsgEngine/src/private/MsgStoragePrivate.cpp +++ b/src/Common/MsgEngine/src/private/MsgStoragePrivate.cpp @@ -32,69 +32,69 @@ using namespace Msg; MsgStoragePrivate::MsgStoragePrivate(msg_handle_t serviceHandle) - : MsgStorage() - , m_ServiceHandle(serviceHandle) + : MsgStorage() + , m_ServiceHandle(serviceHandle) { - TRACE; - msg_reg_storage_change_callback(m_ServiceHandle, msg_storage_change_cb, this); - msg_reg_thread_change_callback(m_ServiceHandle, msg_thread_change_cb, this); + TRACE; + msg_reg_storage_change_callback(m_ServiceHandle, msg_storage_change_cb, this); + msg_reg_thread_change_callback(m_ServiceHandle, msg_thread_change_cb, this); } template void MsgStoragePrivate::notifyListeners(const T& delta, ListenerMethod method) { - for (auto listener: m_Listeners) - (listener->*method)(delta); + for (auto listener: m_Listeners) + (listener->*method)(delta); } void MsgStoragePrivate::msg_storage_change_cb(msg_handle_t handle, msg_storage_change_type_t storageChangeType, msg_id_list_s *pMsgIdList, void *user_param) { - TRACE; - MsgStoragePrivate *self = static_cast(user_param); - MsgIdList msgIdList; - - int count = pMsgIdList->nCount; - msgIdList.reserve(count); - - for (int i = 0; i < count; ++i) - msgIdList.push_back(pMsgIdList->msgIdList[i]); - - switch (storageChangeType) { - case MSG_STORAGE_CHANGE_UPDATE: - self->notifyListeners(msgIdList, &IMsgStorageListener::onMsgStorageUpdate); - break; - case MSG_STORAGE_CHANGE_INSERT: - self->notifyListeners(msgIdList, &IMsgStorageListener::onMsgStorageInsert); - break; - case MSG_STORAGE_CHANGE_DELETE: - self->notifyListeners(msgIdList, &IMsgStorageListener::onMsgStorageDelete); - break; - case MSG_STORAGE_CHANGE_CONTACT: - self->notifyListeners(msgIdList, &IMsgStorageListener::onMsgStorageContact); - break; - } + TRACE; + MsgStoragePrivate *self = static_cast(user_param); + MsgIdList msgIdList; + + int count = pMsgIdList->nCount; + msgIdList.reserve(count); + + for (int i = 0; i < count; ++i) + msgIdList.push_back(pMsgIdList->msgIdList[i]); + + switch (storageChangeType) { + case MSG_STORAGE_CHANGE_UPDATE: + self->notifyListeners(msgIdList, &IMsgStorageListener::onMsgStorageUpdate); + break; + case MSG_STORAGE_CHANGE_INSERT: + self->notifyListeners(msgIdList, &IMsgStorageListener::onMsgStorageInsert); + break; + case MSG_STORAGE_CHANGE_DELETE: + self->notifyListeners(msgIdList, &IMsgStorageListener::onMsgStorageDelete); + break; + case MSG_STORAGE_CHANGE_CONTACT: + self->notifyListeners(msgIdList, &IMsgStorageListener::onMsgStorageContact); + break; + } } void MsgStoragePrivate::msg_thread_change_cb(msg_handle_t handle, msg_storage_change_type_t storageChangeType, msg_thread_id_t threadId, void *user_param) { - TRACE; - MsgStoragePrivate *self = static_cast(user_param); - ThreadId tId = static_cast(threadId); - - switch (storageChangeType) { - case MSG_STORAGE_CHANGE_UPDATE: - self->notifyListeners(tId, &IMsgStorageListener::onMsgStorageThreadUpdate); - break; - case MSG_STORAGE_CHANGE_INSERT: - self->notifyListeners(tId, &IMsgStorageListener::onMsgStorageThreadInsert); - break; - case MSG_STORAGE_CHANGE_DELETE: - self->notifyListeners(tId, &IMsgStorageListener::onMsgStorageThreadDelete); - break; - case MSG_STORAGE_CHANGE_CONTACT: - self->notifyListeners(tId, &IMsgStorageListener::onMsgStorageThreadContact); - break; - } + TRACE; + MsgStoragePrivate *self = static_cast(user_param); + ThreadId tId = static_cast(threadId); + + switch (storageChangeType) { + case MSG_STORAGE_CHANGE_UPDATE: + self->notifyListeners(tId, &IMsgStorageListener::onMsgStorageThreadUpdate); + break; + case MSG_STORAGE_CHANGE_INSERT: + self->notifyListeners(tId, &IMsgStorageListener::onMsgStorageThreadInsert); + break; + case MSG_STORAGE_CHANGE_DELETE: + self->notifyListeners(tId, &IMsgStorageListener::onMsgStorageThreadDelete); + break; + case MSG_STORAGE_CHANGE_CONTACT: + self->notifyListeners(tId, &IMsgStorageListener::onMsgStorageThreadContact); + break; + } } MsgStoragePrivate::~MsgStoragePrivate() @@ -104,326 +104,326 @@ MsgStoragePrivate::~MsgStoragePrivate() MsgThreadListRef MsgStoragePrivate::getThreadList() { - MsgThreadListRef res; - msg_struct_list_s msgList = {}; - msg_struct_t sortRule = msg_create_struct(MSG_STRUCT_SORT_RULE); - msg_set_int_value(sortRule, MSG_SORT_RULE_SORT_TYPE_INT, MSG_SORT_BY_THREAD_DATE); - msg_set_bool_value(sortRule, MSG_SORT_RULE_ACSCEND_BOOL, false); - int error = msg_get_thread_view_list(m_ServiceHandle, sortRule, &msgList); - msg_release_struct(&sortRule); - - if (error == 0) - res.reset(new MsgThreadStructListPrivate(true, msgList)); - - return res; + MsgThreadListRef res; + msg_struct_list_s msgList = {}; + msg_struct_t sortRule = msg_create_struct(MSG_STRUCT_SORT_RULE); + msg_set_int_value(sortRule, MSG_SORT_RULE_SORT_TYPE_INT, MSG_SORT_BY_THREAD_DATE); + msg_set_bool_value(sortRule, MSG_SORT_RULE_ACSCEND_BOOL, false); + int error = msg_get_thread_view_list(m_ServiceHandle, sortRule, &msgList); + msg_release_struct(&sortRule); + + if (error == 0) + res.reset(new MsgThreadStructListPrivate(true, msgList)); + + return res; } MessageSMSListRef MsgStoragePrivate::getSimMsgList() { - MessageSMSListRef res; + MessageSMSListRef res; - msg_struct_list_s msgList; + msg_struct_list_s msgList; - msg_struct_t listCond = msg_create_struct(MSG_STRUCT_MSG_LIST_CONDITION); - msg_set_int_value(listCond, MSG_LIST_CONDITION_FOLDER_ID_INT, MSG_ALLBOX_ID); - msg_set_int_value(listCond, MSG_LIST_CONDITION_MSGTYPE_INT, MSG_TYPE_SMS); - msg_set_int_value(listCond, MSG_LIST_CONDITION_SIM_INDEX_INT, 1); - msg_set_int_value(listCond, MSG_LIST_CONDITION_STORAGE_ID_INT, MSG_STORAGE_SIM); + msg_struct_t listCond = msg_create_struct(MSG_STRUCT_MSG_LIST_CONDITION); + msg_set_int_value(listCond, MSG_LIST_CONDITION_FOLDER_ID_INT, MSG_ALLBOX_ID); + msg_set_int_value(listCond, MSG_LIST_CONDITION_MSGTYPE_INT, MSG_TYPE_SMS); + msg_set_int_value(listCond, MSG_LIST_CONDITION_SIM_INDEX_INT, 1); + msg_set_int_value(listCond, MSG_LIST_CONDITION_STORAGE_ID_INT, MSG_STORAGE_SIM); - if (msg_get_message_list2(m_ServiceHandle, listCond, &msgList) == 0) - res.reset(new SmsStructListPrivate(true, msgList)); + if (msg_get_message_list2(m_ServiceHandle, listCond, &msgList) == 0) + res.reset(new SmsStructListPrivate(true, msgList)); - msg_release_struct(&listCond); - return res; + msg_release_struct(&listCond); + return res; } ThreadId MsgStoragePrivate::getThreadId(const MsgAddressList &addressList) { - msg_thread_id_t id = ThreadId::invalidId; - - if (const MsgAddressListHandlePrivate *privateList = dynamic_cast(&addressList)) { - msg_list_handle_t handleList = *privateList; - msg_get_thread_id_by_address2(m_ServiceHandle, handleList, &id); - } else if (const MsgAddressStructListPrivate *privateList = dynamic_cast(&addressList)) { - msg_struct_list_s msgStructList = *privateList; - msg_get_thread_id_by_address(m_ServiceHandle, &msgStructList, &id); - } else { - assert(false); - } - - return (ThreadId)id; + msg_thread_id_t id = ThreadId::invalidId; + + if (const MsgAddressListHandlePrivate *privateList = dynamic_cast(&addressList)) { + msg_list_handle_t handleList = *privateList; + msg_get_thread_id_by_address2(m_ServiceHandle, handleList, &id); + } else if (const MsgAddressStructListPrivate *privateList = dynamic_cast(&addressList)) { + msg_struct_list_s msgStructList = *privateList; + msg_get_thread_id_by_address(m_ServiceHandle, &msgStructList, &id); + } else { + assert(false); + } + + return (ThreadId)id; } ThreadId MsgStoragePrivate::getThreadId(const std::list &addressList) { - msg_thread_id_t tid = ThreadId::invalidId; - msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); - - if (msgInfo) { - for (auto &addr : addressList) { - MsgAddress::AddressType type = MsgUtils::getAddressType(addr); - msg_struct_t tmpAddr = nullptr; - - if (msg_list_add_item(msgInfo, MSG_MESSAGE_ADDR_LIST_HND, &tmpAddr) == MSG_SUCCESS) { - msg_set_int_value(tmpAddr, MSG_ADDRESS_INFO_ADDRESS_TYPE_INT, MsgUtilsPrivate::addressTypeToNative(type)); - msg_set_int_value(tmpAddr, MSG_ADDRESS_INFO_RECIPIENT_TYPE_INT, MSG_RECIPIENTS_TYPE_TO); - MsgUtilsPrivate::setStr(tmpAddr, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, addr); - } - } - - msg_list_handle_t addrList = nullptr; - msg_get_list_handle(msgInfo, MSG_MESSAGE_ADDR_LIST_HND, (void **)&addrList); - if (addrList) - msg_get_thread_id_by_address2(m_ServiceHandle, addrList, &tid); - - msg_release_struct(&msgInfo); - } - - return (ThreadId)tid; + msg_thread_id_t tid = ThreadId::invalidId; + msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); + + if (msgInfo) { + for (auto &addr : addressList) { + MsgAddress::AddressType type = MsgUtils::getAddressType(addr); + msg_struct_t tmpAddr = nullptr; + + if (msg_list_add_item(msgInfo, MSG_MESSAGE_ADDR_LIST_HND, &tmpAddr) == MSG_SUCCESS) { + msg_set_int_value(tmpAddr, MSG_ADDRESS_INFO_ADDRESS_TYPE_INT, MsgUtilsPrivate::addressTypeToNative(type)); + msg_set_int_value(tmpAddr, MSG_ADDRESS_INFO_RECIPIENT_TYPE_INT, MSG_RECIPIENTS_TYPE_TO); + MsgUtilsPrivate::setStr(tmpAddr, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, addr); + } + } + + msg_list_handle_t addrList = nullptr; + msg_get_list_handle(msgInfo, MSG_MESSAGE_ADDR_LIST_HND, (void **)&addrList); + if (addrList) + msg_get_thread_id_by_address2(m_ServiceHandle, addrList, &tid); + + msg_release_struct(&msgInfo); + } + + return (ThreadId)tid; } MsgAddressListRef MsgStoragePrivate::getAddressList(ThreadId id) { - MsgAddressStructListPrivate *result = new MsgAddressStructListPrivate(true); - msg_get_address_list(m_ServiceHandle, id, &result->get()); - return MsgAddressListRef(result); + MsgAddressStructListPrivate *result = new MsgAddressStructListPrivate(true); + msg_get_address_list(m_ServiceHandle, id, &result->get()); + return MsgAddressListRef(result); } MsgThreadListRef MsgStoragePrivate::searchThread(const std::string &word) { - MsgThreadListRef res; - msg_struct_list_s searchList = {}; + MsgThreadListRef res; + msg_struct_list_s searchList = {}; - msg_error_t error = msg_search_message_for_thread_view(m_ServiceHandle, word.c_str(), &searchList); - if (error != 0) { - MSG_LOG_ERROR("msg_search_message_for_thread_view error ", error); - } + msg_error_t error = msg_search_message_for_thread_view(m_ServiceHandle, word.c_str(), &searchList); + if (error != 0) { + MSG_LOG_ERROR("msg_search_message_for_thread_view error ", error); + } - if (error == 0) - res.reset(new MsgThreadStructListPrivate(true, searchList)); + if (error == 0) + res.reset(new MsgThreadStructListPrivate(true, searchList)); - return res; + return res; } int MsgStoragePrivate::getUnreadThreadCount() const { - msg_struct_t sortRule = msg_create_struct(MSG_STRUCT_SORT_RULE); - msg_struct_list_s peerList; + msg_struct_t sortRule = msg_create_struct(MSG_STRUCT_SORT_RULE); + msg_struct_list_s peerList; - int unreadThreadCount = 0; + int unreadThreadCount = 0; - msg_set_int_value(sortRule, MSG_SORT_RULE_SORT_TYPE_INT, MSG_SORT_BY_READ_STATUS); - msg_set_bool_value(sortRule, MSG_SORT_RULE_ACSCEND_BOOL, false); + msg_set_int_value(sortRule, MSG_SORT_RULE_SORT_TYPE_INT, MSG_SORT_BY_READ_STATUS); + msg_set_bool_value(sortRule, MSG_SORT_RULE_ACSCEND_BOOL, false); - msg_get_thread_view_list(m_ServiceHandle, sortRule, &peerList); - msg_release_struct(&sortRule); + msg_get_thread_view_list(m_ServiceHandle, sortRule, &peerList); + msg_release_struct(&sortRule); - for (int i = 0; i < peerList.nCount; i++) { - int unreadCnt = 0; - msg_get_int_value(peerList.msg_struct_info[i], MSG_THREAD_UNREAD_COUNT_INT, &unreadCnt); + for (int i = 0; i < peerList.nCount; i++) { + int unreadCnt = 0; + msg_get_int_value(peerList.msg_struct_info[i], MSG_THREAD_UNREAD_COUNT_INT, &unreadCnt); - if (unreadCnt > 0) - unreadThreadCount++; - } + if (unreadCnt > 0) + unreadThreadCount++; + } - return unreadThreadCount; + return unreadThreadCount; } MsgThreadItemRef MsgStoragePrivate::getThread(ThreadId id) { - MsgThreadItemRef res; - msg_struct_t thread = msg_create_struct(MSG_STRUCT_THREAD_INFO); - if (msg_get_thread(m_ServiceHandle, id, thread) == 0) - res.reset(new MsgThreadItemPrivate(true, thread)); + MsgThreadItemRef res; + msg_struct_t thread = msg_create_struct(MSG_STRUCT_THREAD_INFO); + if (msg_get_thread(m_ServiceHandle, id, thread) == 0) + res.reset(new MsgThreadItemPrivate(true, thread)); - return res; + return res; } bool MsgStoragePrivate::deleteThread(ThreadId id) { - return msg_delete_thread_message_list(m_ServiceHandle, id, true) == 0; + return msg_delete_thread_message_list(m_ServiceHandle, id, true) == 0; } MsgConversationListRef MsgStoragePrivate::getConversationList(ThreadId id) { - MsgConversationListRef res; - msg_struct_list_s convList = {}; - int error = msg_get_conversation_view_list(m_ServiceHandle, id, &convList); + MsgConversationListRef res; + msg_struct_list_s convList = {}; + int error = msg_get_conversation_view_list(m_ServiceHandle, id, &convList); - if (error == 0) - res.reset(new MsgConversationStructListPrivate(true, convList)); + if (error == 0) + res.reset(new MsgConversationStructListPrivate(true, convList)); - return res; + return res; } MsgConversationItemRef MsgStoragePrivate::getConversationItem(MsgId id) { - MsgConversationItemRef res; - msg_struct_t convItem = msg_create_struct(MSG_STRUCT_CONV_INFO); - if (msg_get_conversation(m_ServiceHandle, id, convItem) == 0) { - res.reset(new MsgConversationItemPrivate(true, convItem)); - } else { - msg_release_struct(&convItem); - } - - return res; + MsgConversationItemRef res; + msg_struct_t convItem = msg_create_struct(MSG_STRUCT_CONV_INFO); + if (msg_get_conversation(m_ServiceHandle, id, convItem) == 0) { + res.reset(new MsgConversationItemPrivate(true, convItem)); + } else { + msg_release_struct(&convItem); + } + + return res; } MessageRef MsgStoragePrivate::getMessage(MsgId id) { - MessageRef msgRef; - msg_struct_t msg = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); - msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT); - - if (msg_get_message(m_ServiceHandle, id, msg, sendOpt) == 0) { - int nativeType = MSG_TYPE_INVALID; - msg_get_int_value(msg, MSG_MESSAGE_TYPE_INT, &nativeType); - Message::Type type = MsgUtilsPrivate::nativeToMessageType(nativeType); - - if (MsgUtils::isMms(type)) - msgRef = std::make_shared(true, msg); - else - msgRef = std::make_shared(true, msg); - } else { - msg_release_struct(&msg); - } - msg_release_struct(&sendOpt); - return msgRef; + MessageRef msgRef; + msg_struct_t msg = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); + msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT); + + if (msg_get_message(m_ServiceHandle, id, msg, sendOpt) == 0) { + int nativeType = MSG_TYPE_INVALID; + msg_get_int_value(msg, MSG_MESSAGE_TYPE_INT, &nativeType); + Message::Type type = MsgUtilsPrivate::nativeToMessageType(nativeType); + + if (MsgUtils::isMms(type)) + msgRef = std::make_shared(true, msg); + else + msgRef = std::make_shared(true, msg); + } else { + msg_release_struct(&msg); + } + msg_release_struct(&sendOpt); + return msgRef; } MsgId MsgStoragePrivate::saveMessage(Message &msg, bool updateExisting, StorageResult *result) { - if (result) - *result = StorageFail; - - MsgId newMsgId; - MessagePrivate &msgPriv = dynamic_cast(msg); - - msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT); - msg_set_bool_value(sendOpt, MSG_SEND_OPT_SETTING_BOOL, false); - - msgPriv.commit(); - if (msgPriv.getId().isValid() && updateExisting) { - int err = msg_update_message(m_ServiceHandle, msgPriv, sendOpt); - if (result) - *result = MsgUtilsPrivate::nativeToStorageResult(err); - if (err == MSG_SUCCESS) - newMsgId = msg.getId(); - } else { - newMsgId = msg_add_message(m_ServiceHandle, msgPriv, sendOpt); - if (newMsgId > 0) { - int err = msg_move_msg_to_storage(m_ServiceHandle, newMsgId, msg.getMessageStorageType()); - if (result) - *result = MsgUtilsPrivate::nativeToStorageResult(err); - if (err != MSG_SUCCESS) { - MSG_LOG_WARN("Can't move msg to storage, error = ", MsgEngine::whatError(err)); - deleteMessage(newMsgId); - newMsgId.reset(); - } - } - } - msg_release_struct(&sendOpt); - return newMsgId; + if (result) + *result = StorageFail; + + MsgId newMsgId; + MessagePrivate &msgPriv = dynamic_cast(msg); + + msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT); + msg_set_bool_value(sendOpt, MSG_SEND_OPT_SETTING_BOOL, false); + + msgPriv.commit(); + if (msgPriv.getId().isValid() && updateExisting) { + int err = msg_update_message(m_ServiceHandle, msgPriv, sendOpt); + if (result) + *result = MsgUtilsPrivate::nativeToStorageResult(err); + if (err == MSG_SUCCESS) + newMsgId = msg.getId(); + } else { + newMsgId = msg_add_message(m_ServiceHandle, msgPriv, sendOpt); + if (newMsgId > 0) { + int err = msg_move_msg_to_storage(m_ServiceHandle, newMsgId, msg.getMessageStorageType()); + if (result) + *result = MsgUtilsPrivate::nativeToStorageResult(err); + if (err != MSG_SUCCESS) { + MSG_LOG_WARN("Can't move msg to storage, error = ", MsgEngine::whatError(err)); + deleteMessage(newMsgId); + newMsgId.reset(); + } + } + } + msg_release_struct(&sendOpt); + return newMsgId; } bool MsgStoragePrivate::deleteMessage(MsgId id) { - return msg_delete_message(m_ServiceHandle, id) == 0; + return msg_delete_message(m_ServiceHandle, id) == 0; } bool MsgStoragePrivate::deleteMessages(const MsgIdList &idList) { - msg_id_list_s internalIdList; + msg_id_list_s internalIdList; - internalIdList.nCount = idList.size(); - if (internalIdList.nCount <= 0) - return false; + internalIdList.nCount = idList.size(); + if (internalIdList.nCount <= 0) + return false; - msg_message_id_t ids[internalIdList.nCount]; - std::copy(idList.begin(), idList.end(), ids); - internalIdList.msgIdList = ids; + msg_message_id_t ids[internalIdList.nCount]; + std::copy(idList.begin(), idList.end(), ids); + internalIdList.msgIdList = ids; - return msg_delete_msgs_by_list(m_ServiceHandle, &internalIdList) == 0; + return msg_delete_msgs_by_list(m_ServiceHandle, &internalIdList) == 0; } MessageListRef MsgStoragePrivate::searchMessage(const std::string &word) { - MessageListRef res; - msg_struct_list_s searchList = {}; + MessageListRef res; + msg_struct_list_s searchList = {}; - msg_struct_t listCond = msg_create_struct(MSG_STRUCT_MSG_LIST_CONDITION); - msg_set_int_value(listCond, MSG_LIST_CONDITION_FOLDER_ID_INT, MSG_ALLBOX_ID); - msg_set_int_value(listCond, MSG_LIST_CONDITION_STORAGE_ID_INT, MSG_STORAGE_PHONE); - msg_set_str_value(listCond, MSG_LIST_CONDITION_TEXT_VALUE_STR, word.c_str(), word.length()); + msg_struct_t listCond = msg_create_struct(MSG_STRUCT_MSG_LIST_CONDITION); + msg_set_int_value(listCond, MSG_LIST_CONDITION_FOLDER_ID_INT, MSG_ALLBOX_ID); + msg_set_int_value(listCond, MSG_LIST_CONDITION_STORAGE_ID_INT, MSG_STORAGE_PHONE); + msg_set_str_value(listCond, MSG_LIST_CONDITION_TEXT_VALUE_STR, word.c_str(), word.length()); - msg_error_t error = msg_get_message_list2(m_ServiceHandle, listCond, &searchList); - msg_release_struct(&listCond); + msg_error_t error = msg_get_message_list2(m_ServiceHandle, listCond, &searchList); + msg_release_struct(&listCond); - if (error == 0) - res.reset(new MessageStructListPrivate(true, searchList)); + if (error == 0) + res.reset(new MessageStructListPrivate(true, searchList)); - return res; + return res; } void MsgStoragePrivate::setReadStatus(ThreadId id) { - msg_set_conversation_to_read(m_ServiceHandle, id); + msg_set_conversation_to_read(m_ServiceHandle, id); } void MsgStoragePrivate::setReadStatus(MsgId id, bool status) { - msg_update_read_status(m_ServiceHandle, id, status); + msg_update_read_status(m_ServiceHandle, id, status); } MsgReportListRef MsgStoragePrivate::getMsgReportList(MsgId msgId) { - MsgReportStructListPrivate *result = new MsgReportStructListPrivate(true); - msg_get_report_status(m_ServiceHandle, msgId, &result->get()); - return MsgReportListRef(result); + MsgReportStructListPrivate *result = new MsgReportStructListPrivate(true); + msg_get_report_status(m_ServiceHandle, msgId, &result->get()); + return MsgReportListRef(result); } bool MsgStoragePrivate::isReadReportChecked(MsgId msgId) { - bool readFlag = false; - msg_struct_t mmsSendOpt = nullptr; - msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT); - msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); - - msg_get_message(m_ServiceHandle, msgId, msgInfo, sendOpt); - msg_get_struct_handle(sendOpt, MSG_SEND_OPT_MMS_OPT_HND, &mmsSendOpt); - if (mmsSendOpt) - msg_get_bool_value(mmsSendOpt, MSG_MMS_SENDOPTION_READ_REQUEST_BOOL, &readFlag); - - msg_release_struct(&msgInfo); - msg_release_struct(&sendOpt); - return readFlag; + bool readFlag = false; + msg_struct_t mmsSendOpt = nullptr; + msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT); + msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); + + msg_get_message(m_ServiceHandle, msgId, msgInfo, sendOpt); + msg_get_struct_handle(sendOpt, MSG_SEND_OPT_MMS_OPT_HND, &mmsSendOpt); + if (mmsSendOpt) + msg_get_bool_value(mmsSendOpt, MSG_MMS_SENDOPTION_READ_REQUEST_BOOL, &readFlag); + + msg_release_struct(&msgInfo); + msg_release_struct(&sendOpt); + return readFlag; } bool MsgStoragePrivate::isDeliverReportChecked(MsgId msgId) { - bool deliverFlag = false; - msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT); - msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); + bool deliverFlag = false; + msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT); + msg_struct_t msgInfo = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); - msg_get_message(m_ServiceHandle, msgId, msgInfo, sendOpt); - msg_get_bool_value(sendOpt, MSG_SEND_OPT_DELIVER_REQ_BOOL, &deliverFlag); + msg_get_message(m_ServiceHandle, msgId, msgInfo, sendOpt); + msg_get_bool_value(sendOpt, MSG_SEND_OPT_DELIVER_REQ_BOOL, &deliverFlag); - msg_release_struct(&msgInfo); - msg_release_struct(&sendOpt); - return deliverFlag; + msg_release_struct(&msgInfo); + msg_release_struct(&sendOpt); + return deliverFlag; } ThreadId MsgStoragePrivate::getThreadId(MsgId id) { - int threadId = ThreadId::invalidId; - msg_struct_t msg = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); - msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT); + int threadId = ThreadId::invalidId; + msg_struct_t msg = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); + msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT); - if (msg_get_message(m_ServiceHandle, id, msg, sendOpt) == 0) - msg_get_int_value(msg, MSG_MESSAGE_THREAD_ID_INT, &threadId); + if (msg_get_message(m_ServiceHandle, id, msg, sendOpt) == 0) + msg_get_int_value(msg, MSG_MESSAGE_THREAD_ID_INT, &threadId); - msg_release_struct(&msg); - msg_release_struct(&sendOpt); + msg_release_struct(&msg); + msg_release_struct(&sendOpt); - return threadId; + return threadId; } diff --git a/src/Common/MsgEngine/src/private/MsgStoragePrivate.h b/src/Common/MsgEngine/src/private/MsgStoragePrivate.h index 6154bb0b..fbcda148 100644 --- a/src/Common/MsgEngine/src/private/MsgStoragePrivate.h +++ b/src/Common/MsgEngine/src/private/MsgStoragePrivate.h @@ -24,66 +24,66 @@ #include namespace Msg { - class MsgStoragePrivate - : public MsgStorage { - public: - MsgStoragePrivate(msg_handle_t serviceHandle); - MsgStoragePrivate(MsgStoragePrivate&) = delete; - MsgStoragePrivate &operator=(MsgStoragePrivate&) = delete; - virtual ~MsgStoragePrivate(); + class MsgStoragePrivate + : public MsgStorage { + public: + MsgStoragePrivate(msg_handle_t serviceHandle); + MsgStoragePrivate(MsgStoragePrivate&) = delete; + MsgStoragePrivate &operator=(MsgStoragePrivate&) = delete; + virtual ~MsgStoragePrivate(); - // Thread: - virtual MsgThreadListRef getThreadList(); - virtual MsgThreadItemRef getThread(ThreadId id); - virtual ThreadId getThreadId(const MsgAddressList &addressList); - virtual ThreadId getThreadId(const std::list &addressList); - virtual ThreadId getThreadId(MsgId id); - virtual bool deleteThread(ThreadId id); - virtual MsgAddressListRef getAddressList(ThreadId id); - virtual MsgThreadListRef searchThread(const std::string &word); - virtual void setReadStatus(ThreadId id); - virtual int getUnreadThreadCount() const; + // Thread: + virtual MsgThreadListRef getThreadList(); + virtual MsgThreadItemRef getThread(ThreadId id); + virtual ThreadId getThreadId(const MsgAddressList &addressList); + virtual ThreadId getThreadId(const std::list &addressList); + virtual ThreadId getThreadId(MsgId id); + virtual bool deleteThread(ThreadId id); + virtual MsgAddressListRef getAddressList(ThreadId id); + virtual MsgThreadListRef searchThread(const std::string &word); + virtual void setReadStatus(ThreadId id); + virtual int getUnreadThreadCount() const; - // Message: - virtual MessageSMSListRef getSimMsgList(); - virtual MessageRef getMessage(MsgId id); + // Message: + virtual MessageSMSListRef getSimMsgList(); + virtual MessageRef getMessage(MsgId id); - /** - *@brief Return id of new message or of updated message - *@param[in] msg - message that we need to save - *@param[in] updateExisting - true if we need to update our message id DB, - * false if we need to save message with new id - *@param[out] result of storage operation. - *@return MessageId - */ - virtual MsgId saveMessage(Message &msg, bool updateExisting, StorageResult *result); - virtual bool deleteMessage(MsgId id); - virtual bool deleteMessages(const MsgIdList &idList); - virtual MessageListRef searchMessage(const std::string &word); - virtual void setReadStatus(MsgId id, bool status); - virtual MsgReportListRef getMsgReportList(MsgId msgId); - virtual bool isReadReportChecked(MsgId msgId); - virtual bool isDeliverReportChecked(MsgId msgId); + /** + *@brief Return id of new message or of updated message + *@param[in] msg - message that we need to save + *@param[in] updateExisting - true if we need to update our message id DB, + * false if we need to save message with new id + *@param[out] result of storage operation. + *@return MessageId + */ + virtual MsgId saveMessage(Message &msg, bool updateExisting, StorageResult *result); + virtual bool deleteMessage(MsgId id); + virtual bool deleteMessages(const MsgIdList &idList); + virtual MessageListRef searchMessage(const std::string &word); + virtual void setReadStatus(MsgId id, bool status); + virtual MsgReportListRef getMsgReportList(MsgId msgId); + virtual bool isReadReportChecked(MsgId msgId); + virtual bool isDeliverReportChecked(MsgId msgId); - // Conversation: - virtual MsgConversationListRef getConversationList(ThreadId id); - virtual MsgConversationItemRef getConversationItem(MsgId id); + // Conversation: + virtual MsgConversationListRef getConversationList(ThreadId id); + virtual MsgConversationItemRef getConversationItem(MsgId id); - private: - template - using ListenerMethod = void (IMsgStorageListener::*)(const T&); + private: + template + using ListenerMethod = void (IMsgStorageListener::*)(const T&); - template - void notifyListeners(const T& delta, ListenerMethod method); + template + void notifyListeners(const T& delta, ListenerMethod method); - static void msg_storage_change_cb(msg_handle_t handle, msg_storage_change_type_t storageChangeType, msg_id_list_s *pMsgIdList, void *user_param); - static void msg_thread_change_cb(msg_handle_t handle, msg_storage_change_type_t storageChangeType, msg_thread_id_t threadId, void *user_param); + static void msg_storage_change_cb(msg_handle_t handle, msg_storage_change_type_t storageChangeType, msg_id_list_s *pMsgIdList, void *user_param); + static void msg_thread_change_cb(msg_handle_t handle, msg_storage_change_type_t storageChangeType, msg_thread_id_t threadId, void *user_param); - MessageSMS *createSms(); + MessageSMS *createSms(); - private: - msg_handle_t m_ServiceHandle; - }; + private: + msg_handle_t m_ServiceHandle; + }; } #endif /* __MSG_STORAGE_PRIVATE_H__ */ diff --git a/src/Common/MsgEngine/src/private/MsgStructListPrivate.h b/src/Common/MsgEngine/src/private/MsgStructListPrivate.h index cd24a92c..762a18a0 100644 --- a/src/Common/MsgEngine/src/private/MsgStructListPrivate.h +++ b/src/Common/MsgEngine/src/private/MsgStructListPrivate.h @@ -22,78 +22,78 @@ #include namespace Msg { - static msg_struct_list_s emptyStructList; - - // class T : public BaseT {} - template - class MsgStructListPrivate - : public MsgList { // implement interface - public: - MsgStructListPrivate(bool release, const msg_struct_list_s &list = emptyStructList) - : m_List(list) - , m_Object(false) // release = false - , m_Release(release) - { - } - - virtual ~MsgStructListPrivate() - { - if (m_Release && m_List.nCount) - msg_release_list_struct(&m_List); - } - - virtual BaseT &at(int i) - { - msg_struct_t msgStruct = m_List.msg_struct_info[i]; - m_Object.set(msgStruct); - return m_Object; - } - - virtual const BaseT &at(int i) const - { - msg_struct_t msgStruct = m_List.msg_struct_info[i]; - m_Object.set(msgStruct); - return m_Object; - } - - virtual int getLength() const - { - return m_List.nCount; - } - - inline void set(msg_struct_list_s &list) - { - m_List = list; - } - - inline operator msg_struct_list_s &() - { - return m_List; - } - - inline operator const msg_struct_list_s &() const - { - return m_List; - } - - inline msg_struct_list_s &get() - { - return m_List; - } - - inline const msg_struct_list_s &get() const - { - return m_List; - } - - MsgStructListPrivate(MsgStructListPrivate&) = delete; - MsgStructListPrivate &operator=(MsgStructListPrivate&) = delete; - - protected: - mutable msg_struct_list_s m_List; - mutable T m_Object; - bool m_Release; - }; + static msg_struct_list_s emptyStructList; + + // class T : public BaseT {} + template + class MsgStructListPrivate + : public MsgList { // implement interface + public: + MsgStructListPrivate(bool release, const msg_struct_list_s &list = emptyStructList) + : m_List(list) + , m_Object(false) // release = false + , m_Release(release) + { + } + + virtual ~MsgStructListPrivate() + { + if (m_Release && m_List.nCount) + msg_release_list_struct(&m_List); + } + + virtual BaseT &at(int i) + { + msg_struct_t msgStruct = m_List.msg_struct_info[i]; + m_Object.set(msgStruct); + return m_Object; + } + + virtual const BaseT &at(int i) const + { + msg_struct_t msgStruct = m_List.msg_struct_info[i]; + m_Object.set(msgStruct); + return m_Object; + } + + virtual int getLength() const + { + return m_List.nCount; + } + + inline void set(msg_struct_list_s &list) + { + m_List = list; + } + + inline operator msg_struct_list_s &() + { + return m_List; + } + + inline operator const msg_struct_list_s &() const + { + return m_List; + } + + inline msg_struct_list_s &get() + { + return m_List; + } + + inline const msg_struct_list_s &get() const + { + return m_List; + } + + MsgStructListPrivate(MsgStructListPrivate&) = delete; + MsgStructListPrivate &operator=(MsgStructListPrivate&) = delete; + + protected: + mutable msg_struct_list_s m_List; + mutable T m_Object; + bool m_Release; + }; } #endif /* _MsgStructListPrivate_H__ */ diff --git a/src/Common/MsgEngine/src/private/MsgStructPrivate.h b/src/Common/MsgEngine/src/private/MsgStructPrivate.h index 99138306..1323504b 100644 --- a/src/Common/MsgEngine/src/private/MsgStructPrivate.h +++ b/src/Common/MsgEngine/src/private/MsgStructPrivate.h @@ -23,42 +23,42 @@ #include namespace Msg { - class MsgStructPrivate { - public: - inline MsgStructPrivate(bool release, msg_struct_t msgStruct = nullptr); - inline virtual ~MsgStructPrivate(); - inline void set(msg_struct_t msgStruct); - inline operator msg_struct_t() const; + class MsgStructPrivate { + public: + inline MsgStructPrivate(bool release, msg_struct_t msgStruct = nullptr); + inline virtual ~MsgStructPrivate(); + inline void set(msg_struct_t msgStruct); + inline operator msg_struct_t() const; - MsgStructPrivate(MsgStructPrivate&) = delete; - MsgStructPrivate &operator=(MsgStructPrivate&) = delete; + MsgStructPrivate(MsgStructPrivate&) = delete; + MsgStructPrivate &operator=(MsgStructPrivate&) = delete; - protected: - msg_struct_t m_MsgStruct; - bool m_Release; - }; + protected: + msg_struct_t m_MsgStruct; + bool m_Release; + }; - inline MsgStructPrivate::MsgStructPrivate(bool release, msg_struct_t msgStruct) - : m_MsgStruct(msgStruct) - , m_Release(release) - { - } + inline MsgStructPrivate::MsgStructPrivate(bool release, msg_struct_t msgStruct) + : m_MsgStruct(msgStruct) + , m_Release(release) + { + } - inline MsgStructPrivate::~MsgStructPrivate() - { - if (m_Release && m_MsgStruct) - msg_release_struct(&m_MsgStruct); - } + inline MsgStructPrivate::~MsgStructPrivate() + { + if (m_Release && m_MsgStruct) + msg_release_struct(&m_MsgStruct); + } - inline void MsgStructPrivate::set(msg_struct_t msgStruct) - { - m_MsgStruct = msgStruct; - } + inline void MsgStructPrivate::set(msg_struct_t msgStruct) + { + m_MsgStruct = msgStruct; + } - inline MsgStructPrivate::operator msg_struct_t() const - { - return m_MsgStruct; - } + inline MsgStructPrivate::operator msg_struct_t() const + { + return m_MsgStruct; + } } #endif /* _MsgStructPrivate_H__ */ diff --git a/src/Common/MsgEngine/src/private/MsgThreadItemPrivate.cpp b/src/Common/MsgEngine/src/private/MsgThreadItemPrivate.cpp index b906f03a..3fa549d5 100644 --- a/src/Common/MsgEngine/src/private/MsgThreadItemPrivate.cpp +++ b/src/Common/MsgEngine/src/private/MsgThreadItemPrivate.cpp @@ -25,8 +25,8 @@ using namespace Msg; MsgThreadItemPrivate::MsgThreadItemPrivate(bool release, msg_struct_t msgStruct) - : MsgStructPrivate(release, msgStruct) - , MsgThreadItem() + : MsgStructPrivate(release, msgStruct) + , MsgThreadItem() { } @@ -36,53 +36,53 @@ MsgThreadItemPrivate::~MsgThreadItemPrivate() ThreadId MsgThreadItemPrivate::getId() const { - int id = ThreadId::invalidId; - msg_get_int_value(m_MsgStruct, MSG_THREAD_ID_INT, &id); - return id; + int id = ThreadId::invalidId; + msg_get_int_value(m_MsgStruct, MSG_THREAD_ID_INT, &id); + return id; } std::string MsgThreadItemPrivate::getName() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_THREAD_NAME_STR, MAX_DISPLAY_NAME_LEN); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_THREAD_NAME_STR, MAX_DISPLAY_NAME_LEN); } std::string MsgThreadItemPrivate::getLastMessage() const { - return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_THREAD_MSG_DATA_STR, MAX_MSG_TEXT_LEN); + return MsgUtilsPrivate::getStr(m_MsgStruct, MSG_THREAD_MSG_DATA_STR, MAX_MSG_TEXT_LEN); } time_t MsgThreadItemPrivate::getTime() const { - int time = 0; - msg_get_int_value(m_MsgStruct, MSG_THREAD_MSG_TIME_INT, &time); - return time; + int time = 0; + msg_get_int_value(m_MsgStruct, MSG_THREAD_MSG_TIME_INT, &time); + return time; } bool MsgThreadItemPrivate::hasDraftMessage() const { - bool val = false; - msg_get_bool_value(m_MsgStruct, MSG_THREAD_DRAFT_BOOL, &val); - return val; + bool val = false; + msg_get_bool_value(m_MsgStruct, MSG_THREAD_DRAFT_BOOL, &val); + return val; } bool MsgThreadItemPrivate::hasFailedMessage() const { - bool val = false; - msg_get_bool_value(m_MsgStruct, MSG_THREAD_SEND_FAILED_BOOL, &val); - return val; + bool val = false; + msg_get_bool_value(m_MsgStruct, MSG_THREAD_SEND_FAILED_BOOL, &val); + return val; } bool MsgThreadItemPrivate::isSending() const { - bool val = false; - msg_get_bool_value(m_MsgStruct, MSG_THREAD_SENDING_BOOL, &val); - return val; + bool val = false; + msg_get_bool_value(m_MsgStruct, MSG_THREAD_SENDING_BOOL, &val); + return val; } int MsgThreadItemPrivate::getUnreadCount() const { - int unread = 0; - msg_get_int_value(m_MsgStruct, MSG_THREAD_UNREAD_COUNT_INT, &unread); - return unread; + int unread = 0; + msg_get_int_value(m_MsgStruct, MSG_THREAD_UNREAD_COUNT_INT, &unread); + return unread; } diff --git a/src/Common/MsgEngine/src/private/MsgThreadItemPrivate.h b/src/Common/MsgEngine/src/private/MsgThreadItemPrivate.h index dfe3ede0..1ee33083 100644 --- a/src/Common/MsgEngine/src/private/MsgThreadItemPrivate.h +++ b/src/Common/MsgEngine/src/private/MsgThreadItemPrivate.h @@ -23,25 +23,25 @@ #include "MsgStructPrivate.h" namespace Msg { - class MsgThreadItemPrivate - : public MsgStructPrivate - , public MsgThreadItem { - public: - MsgThreadItemPrivate(bool release, msg_struct_t msgStruct = nullptr); - virtual ~MsgThreadItemPrivate(); + class MsgThreadItemPrivate + : public MsgStructPrivate + , public MsgThreadItem { + public: + MsgThreadItemPrivate(bool release, msg_struct_t msgStruct = nullptr); + virtual ~MsgThreadItemPrivate(); - virtual ThreadId getId() const; - virtual std::string getName() const; - virtual std::string getLastMessage() const; - virtual time_t getTime() const; - virtual bool hasDraftMessage() const; - virtual bool hasFailedMessage() const; - virtual bool isSending() const; - virtual int getUnreadCount() const; - }; + virtual ThreadId getId() const; + virtual std::string getName() const; + virtual std::string getLastMessage() const; + virtual time_t getTime() const; + virtual bool hasDraftMessage() const; + virtual bool hasFailedMessage() const; + virtual bool isSending() const; + virtual int getUnreadCount() const; + }; - typedef class MsgListHandlePrivate MsgThreadListHandlePrivate; - typedef class MsgStructListPrivate MsgThreadStructListPrivate; + typedef class MsgListHandlePrivate MsgThreadListHandlePrivate; + typedef class MsgStructListPrivate MsgThreadStructListPrivate; } #endif /* __MSG_THREAD_ITEM_H__ */ diff --git a/src/Common/MsgEngine/src/private/MsgTransportPrivate.cpp b/src/Common/MsgEngine/src/private/MsgTransportPrivate.cpp index 74ca55f9..3c56584c 100644 --- a/src/Common/MsgEngine/src/private/MsgTransportPrivate.cpp +++ b/src/Common/MsgEngine/src/private/MsgTransportPrivate.cpp @@ -23,8 +23,8 @@ using namespace Msg; MsgTransportPrivate::MsgTransportPrivate(msg_handle_t serviceHandle) - : MsgTransport() - , m_ServiceHandle(serviceHandle) + : MsgTransport() + , m_ServiceHandle(serviceHandle) { } @@ -34,62 +34,62 @@ MsgTransportPrivate::~MsgTransportPrivate() MsgTransport::SendResult MsgTransportPrivate::sendMessage(Message &msg, ThreadId *threadId) { - msg_struct_t req = msg_create_struct(MSG_STRUCT_REQUEST_INFO); - int err = MSG_SUCCESS; + msg_struct_t req = msg_create_struct(MSG_STRUCT_REQUEST_INFO); + int err = MSG_SUCCESS; - msg_struct_t sendOpt = nullptr; - msg_get_struct_handle(req, MSG_REQUEST_SENDOPT_HND, &sendOpt); - msg_set_bool_value(sendOpt, MSG_SEND_OPT_SETTING_BOOL, false); + msg_struct_t sendOpt = nullptr; + msg_get_struct_handle(req, MSG_REQUEST_SENDOPT_HND, &sendOpt); + msg_set_bool_value(sendOpt, MSG_SEND_OPT_SETTING_BOOL, false); - MessagePrivate &privMsg = dynamic_cast(msg); - privMsg.commit(); + MessagePrivate &privMsg = dynamic_cast(msg); + privMsg.commit(); - msg_set_struct_handle(req, MSG_REQUEST_MESSAGE_HND, privMsg); + msg_set_struct_handle(req, MSG_REQUEST_MESSAGE_HND, privMsg); - if (privMsg.isMms()) { - MSG_LOG("Sending MMS"); - err = msg_mms_send_message(m_ServiceHandle, req); - } else { - MSG_LOG("Sending SMS"); - err = msg_sms_send_message(m_ServiceHandle, req); - } + if (privMsg.isMms()) { + MSG_LOG("Sending MMS"); + err = msg_mms_send_message(m_ServiceHandle, req); + } else { + MSG_LOG("Sending SMS"); + err = msg_sms_send_message(m_ServiceHandle, req); + } - if (threadId) - msg_get_thread_id_by_address2(m_ServiceHandle, privMsg.getAddressList(), (msg_thread_id_t*)threadId); - msg_release_struct(&req); + if (threadId) + msg_get_thread_id_by_address2(m_ServiceHandle, privMsg.getAddressList(), (msg_thread_id_t*)threadId); + msg_release_struct(&req); - MsgTransport::SendResult sendRes = MsgUtilsPrivate::nativeToSendResult(err); - MSG_LOG("Send result: ", sendRes); - return sendRes; + MsgTransport::SendResult sendRes = MsgUtilsPrivate::nativeToSendResult(err); + MSG_LOG("Send result: ", sendRes); + return sendRes; } MsgTransport::SendResult MsgTransportPrivate::retrieveMessage(MsgId msgId) { - MSG_LOG("Msg id = ", msgId); + MSG_LOG("Msg id = ", msgId); - msg_struct_t req = msg_create_struct(MSG_STRUCT_REQUEST_INFO); - msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT); - msg_struct_t retrieveMsg = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); + msg_struct_t req = msg_create_struct(MSG_STRUCT_REQUEST_INFO); + msg_struct_t sendOpt = msg_create_struct(MSG_STRUCT_SENDOPT); + msg_struct_t retrieveMsg = msg_create_struct(MSG_STRUCT_MESSAGE_INFO); - msg_get_message(m_ServiceHandle, msgId, retrieveMsg, sendOpt); - msg_set_struct_handle(req, MSG_REQUEST_MESSAGE_HND, retrieveMsg); - msg_set_struct_handle(req, MSG_REQUEST_SENDOPT_HND, sendOpt); + msg_get_message(m_ServiceHandle, msgId, retrieveMsg, sendOpt); + msg_set_struct_handle(req, MSG_REQUEST_MESSAGE_HND, retrieveMsg); + msg_set_struct_handle(req, MSG_REQUEST_SENDOPT_HND, sendOpt); - msg_error_t err = msg_mms_retrieve_message(m_ServiceHandle, req); - MSG_LOG("Retrieve message result: ", err); + msg_error_t err = msg_mms_retrieve_message(m_ServiceHandle, req); + MSG_LOG("Retrieve message result: ", err); - msg_release_struct(&retrieveMsg); - msg_release_struct(&sendOpt); - msg_release_struct(&req); + msg_release_struct(&retrieveMsg); + msg_release_struct(&sendOpt); + msg_release_struct(&req); - MsgTransport::SendResult sendRes = MsgUtilsPrivate::nativeToSendResult(err); - return sendRes; + MsgTransport::SendResult sendRes = MsgUtilsPrivate::nativeToSendResult(err); + return sendRes; } MsgTransport::SendResult MsgTransportPrivate::sendReadReport(MsgId msgId, MsgReport::ReadStatus status) { - msg_error_t err = msg_mms_send_read_report(m_ServiceHandle, msgId, MsgUtilsPrivate::reportReadReportStatusToNative(status)); - MsgTransport::SendResult sendRes = MsgUtilsPrivate::nativeToSendResult(err); - MSG_LOG("Send result: ", sendRes); - return sendRes; + msg_error_t err = msg_mms_send_read_report(m_ServiceHandle, msgId, MsgUtilsPrivate::reportReadReportStatusToNative(status)); + MsgTransport::SendResult sendRes = MsgUtilsPrivate::nativeToSendResult(err); + MSG_LOG("Send result: ", sendRes); + return sendRes; } diff --git a/src/Common/MsgEngine/src/private/MsgTransportPrivate.h b/src/Common/MsgEngine/src/private/MsgTransportPrivate.h index b58a3e08..15d92439 100644 --- a/src/Common/MsgEngine/src/private/MsgTransportPrivate.h +++ b/src/Common/MsgEngine/src/private/MsgTransportPrivate.h @@ -24,22 +24,22 @@ #include namespace Msg { - /** - * @brief Private msg-service API specific implementation of sending messages routine. - */ - class MsgTransportPrivate - : public MsgTransport { - public: - MsgTransportPrivate(msg_handle_t serviceHandle); - virtual ~MsgTransportPrivate(); + /** + * @brief Private msg-service API specific implementation of sending messages routine. + */ + class MsgTransportPrivate + : public MsgTransport { + public: + MsgTransportPrivate(msg_handle_t serviceHandle); + virtual ~MsgTransportPrivate(); - virtual SendResult sendMessage(Message &msg, ThreadId *threadId); - virtual SendResult retrieveMessage(MsgId msgId); - virtual SendResult sendReadReport(MsgId msgId, MsgReport::ReadStatus status); + virtual SendResult sendMessage(Message &msg, ThreadId *threadId); + virtual SendResult retrieveMessage(MsgId msgId); + virtual SendResult sendReadReport(MsgId msgId, MsgReport::ReadStatus status); - private: - msg_handle_t m_ServiceHandle; - }; + private: + msg_handle_t m_ServiceHandle; + }; } #endif /* _MSG_TRANSPORT_PRIVATE_H__ */ diff --git a/src/Common/MsgEngine/src/private/MsgUtilsPrivate.cpp b/src/Common/MsgEngine/src/private/MsgUtilsPrivate.cpp index 01d3c6f0..44b95e78 100644 --- a/src/Common/MsgEngine/src/private/MsgUtilsPrivate.cpp +++ b/src/Common/MsgEngine/src/private/MsgUtilsPrivate.cpp @@ -21,344 +21,344 @@ using namespace Msg; int MsgUtilsPrivate::directionToNative(Message::Direction direction) { - switch (direction) { - case Message::MD_Sent: - return MSG_DIRECTION_TYPE_MO; - case Message::MD_Received: - return MSG_DIRECTION_TYPE_MT; - } - assert(false); - return MSG_DIRECTION_TYPE_MO; + switch (direction) { + case Message::MD_Sent: + return MSG_DIRECTION_TYPE_MO; + case Message::MD_Received: + return MSG_DIRECTION_TYPE_MT; + } + assert(false); + return MSG_DIRECTION_TYPE_MO; } Message::Direction MsgUtilsPrivate::nativeToDirection(int direction) { - switch (direction) { - case MSG_DIRECTION_TYPE_MO: - return Message::MD_Sent; - case MSG_DIRECTION_TYPE_MT: - return Message::MD_Received; - } - assert(false); - return Message::MD_Sent; + switch (direction) { + case MSG_DIRECTION_TYPE_MO: + return Message::MD_Sent; + case MSG_DIRECTION_TYPE_MT: + return Message::MD_Received; + } + assert(false); + return Message::MD_Sent; } Message::MessageStorageType MsgUtilsPrivate::nativeToMessageStorage(int id) { - switch (id) { - case MSG_STORAGE_PHONE: - return Message::MS_Phone; - case MSG_STORAGE_SIM: - return Message::MS_Sim; - } - assert(false); - return Message::MS_Unknown; + switch (id) { + case MSG_STORAGE_PHONE: + return Message::MS_Phone; + case MSG_STORAGE_SIM: + return Message::MS_Sim; + } + assert(false); + return Message::MS_Unknown; } int MsgUtilsPrivate::addressTypeToNative(MsgAddress::AddressType type) { - switch (type) { - case MsgAddress::Phone: - return MSG_ADDRESS_TYPE_PLMN; - case MsgAddress::Email: - return MSG_ADDRESS_TYPE_EMAIL; - default: - case MsgAddress::UnknownAddressType: - return MSG_ADDRESS_TYPE_UNKNOWN; - } + switch (type) { + case MsgAddress::Phone: + return MSG_ADDRESS_TYPE_PLMN; + case MsgAddress::Email: + return MSG_ADDRESS_TYPE_EMAIL; + default: + case MsgAddress::UnknownAddressType: + return MSG_ADDRESS_TYPE_UNKNOWN; + } } MsgAddress::AddressType MsgUtilsPrivate::nativeToAddressType(int type) { - switch (type) { - case MSG_ADDRESS_TYPE_PLMN: - return MsgAddress::Phone; - case MSG_ADDRESS_TYPE_EMAIL: - return MsgAddress::Email; - default: - case MSG_ADDRESS_TYPE_UNKNOWN: - return MsgAddress::UnknownAddressType; - } + switch (type) { + case MSG_ADDRESS_TYPE_PLMN: + return MsgAddress::Phone; + case MSG_ADDRESS_TYPE_EMAIL: + return MsgAddress::Email; + default: + case MSG_ADDRESS_TYPE_UNKNOWN: + return MsgAddress::UnknownAddressType; + } } MsgReport::DeliveryStatus MsgUtilsPrivate::nativeToReportDeliveryStatus(int status) { - switch (status) { - case MSG_DELIVERY_REPORT_SUCCESS: - return MsgReport::StatusSuccess; - case MSG_DELIVERY_REPORT_EXPIRED: - return MsgReport::StatusExpired; - case MSG_DELIVERY_REPORT_REJECTED: - return MsgReport::StatusRejected; - default: - case MSG_DELIVERY_REPORT_NONE: - return MsgReport::StatusNone; - } + switch (status) { + case MSG_DELIVERY_REPORT_SUCCESS: + return MsgReport::StatusSuccess; + case MSG_DELIVERY_REPORT_EXPIRED: + return MsgReport::StatusExpired; + case MSG_DELIVERY_REPORT_REJECTED: + return MsgReport::StatusRejected; + default: + case MSG_DELIVERY_REPORT_NONE: + return MsgReport::StatusNone; + } } MsgReport::ReadStatus MsgUtilsPrivate::nativeToReportReadStatus(int status) { - switch (status) { - case MSG_READ_REPORT_IS_READ: - return MsgReport::ReadStatusIsRead; - case MSG_READ_REPORT_IS_DELETED: - return MsgReport::ReadStatusIsDeleted; - case MSG_READ_REPORT_REJECT_BY_USER: - return MsgReport::ReadStatusRejectByUser; - default: - case MSG_READ_REPORT_NONE: - return MsgReport::ReadStatusNone; - } + switch (status) { + case MSG_READ_REPORT_IS_READ: + return MsgReport::ReadStatusIsRead; + case MSG_READ_REPORT_IS_DELETED: + return MsgReport::ReadStatusIsDeleted; + case MSG_READ_REPORT_REJECT_BY_USER: + return MsgReport::ReadStatusRejectByUser; + default: + case MSG_READ_REPORT_NONE: + return MsgReport::ReadStatusNone; + } } int MsgUtilsPrivate::reportReadReportStatusToNative(MsgReport::ReadStatus status) { - switch (status) { - case MsgReport::ReadStatusIsRead: - return MSG_READ_REPORT_IS_READ; - case MsgReport::ReadStatusIsDeleted: - return MSG_READ_REPORT_IS_DELETED; - case MsgReport::ReadStatusRejectByUser: - return MSG_READ_REPORT_REJECT_BY_USER; - default: - case MsgReport::ReadStatusNone: - return MSG_READ_REPORT_NONE; - } + switch (status) { + case MsgReport::ReadStatusIsRead: + return MSG_READ_REPORT_IS_READ; + case MsgReport::ReadStatusIsDeleted: + return MSG_READ_REPORT_IS_DELETED; + case MsgReport::ReadStatusRejectByUser: + return MSG_READ_REPORT_REJECT_BY_USER; + default: + case MsgReport::ReadStatusNone: + return MSG_READ_REPORT_NONE; + } } MsgReport::Type MsgUtilsPrivate::nativeToReportType(int type) { - switch (type) { - case MSG_REPORT_TYPE_READ: - return MsgReport::TypeRead; - case MSG_REPORT_TYPE_READ_REPORT_SENT: - return MsgReport::TypeReadReportSent; - default: - case MSG_REPORT_TYPE_DELIVERY: - return MsgReport::TypeDelivery; - } + switch (type) { + case MSG_REPORT_TYPE_READ: + return MsgReport::TypeRead; + case MSG_REPORT_TYPE_READ_REPORT_SENT: + return MsgReport::TypeReadReportSent; + default: + case MSG_REPORT_TYPE_DELIVERY: + return MsgReport::TypeDelivery; + } } int MsgUtilsPrivate::recipientTypeToNative(MsgAddress::RecipientType type) { - switch (type) { - case MsgAddress::To: - return MSG_RECIPIENTS_TYPE_TO; - case MsgAddress::Cc: - return MSG_RECIPIENTS_TYPE_CC; - case MsgAddress::Bcc: - return MSG_RECIPIENTS_TYPE_BCC; - default: - case MsgAddress::UnknownRecipientType: - return MSG_RECIPIENTS_TYPE_UNKNOWN; - } + switch (type) { + case MsgAddress::To: + return MSG_RECIPIENTS_TYPE_TO; + case MsgAddress::Cc: + return MSG_RECIPIENTS_TYPE_CC; + case MsgAddress::Bcc: + return MSG_RECIPIENTS_TYPE_BCC; + default: + case MsgAddress::UnknownRecipientType: + return MSG_RECIPIENTS_TYPE_UNKNOWN; + } } MsgAddress::RecipientType MsgUtilsPrivate::nativeToRecipientType(int type) { - switch (type) { - case MSG_RECIPIENTS_TYPE_TO: - return MsgAddress::To; - case MSG_RECIPIENTS_TYPE_CC: - return MsgAddress::Cc; - case MSG_RECIPIENTS_TYPE_BCC: - return MsgAddress::Bcc; - default: - case MSG_RECIPIENTS_TYPE_UNKNOWN: - return MsgAddress::UnknownRecipientType; - } + switch (type) { + case MSG_RECIPIENTS_TYPE_TO: + return MsgAddress::To; + case MSG_RECIPIENTS_TYPE_CC: + return MsgAddress::Cc; + case MSG_RECIPIENTS_TYPE_BCC: + return MsgAddress::Bcc; + default: + case MSG_RECIPIENTS_TYPE_UNKNOWN: + return MsgAddress::UnknownRecipientType; + } } Message::Type MsgUtilsPrivate::nativeToMessageType(int type) { - switch (type) { - case MSG_TYPE_SMS: - case MSG_TYPE_SMS_CB: - case MSG_TYPE_SMS_JAVACB: - case MSG_TYPE_SMS_WAPPUSH: - case MSG_TYPE_SMS_MWI: - case MSG_TYPE_SMS_SYNCML: - case MSG_TYPE_SMS_REJECT: - case MSG_TYPE_SMS_ETWS_PRIMARY: - case MSG_TYPE_SMS_ETWS_SECONDARY: - case MSG_TYPE_SMS_CMAS_PRESIDENTIAL: - case MSG_TYPE_SMS_CMAS_EXTREME: - case MSG_TYPE_SMS_CMAS_SEVERE: - case MSG_TYPE_SMS_CMAS_AMBER: - case MSG_TYPE_SMS_CMAS_TEST: - case MSG_TYPE_SMS_CMAS_EXERCISE: - case MSG_TYPE_SMS_CMAS_OPERATOR_DEFINED: - return Message::MT_SMS; + switch (type) { + case MSG_TYPE_SMS: + case MSG_TYPE_SMS_CB: + case MSG_TYPE_SMS_JAVACB: + case MSG_TYPE_SMS_WAPPUSH: + case MSG_TYPE_SMS_MWI: + case MSG_TYPE_SMS_SYNCML: + case MSG_TYPE_SMS_REJECT: + case MSG_TYPE_SMS_ETWS_PRIMARY: + case MSG_TYPE_SMS_ETWS_SECONDARY: + case MSG_TYPE_SMS_CMAS_PRESIDENTIAL: + case MSG_TYPE_SMS_CMAS_EXTREME: + case MSG_TYPE_SMS_CMAS_SEVERE: + case MSG_TYPE_SMS_CMAS_AMBER: + case MSG_TYPE_SMS_CMAS_TEST: + case MSG_TYPE_SMS_CMAS_EXERCISE: + case MSG_TYPE_SMS_CMAS_OPERATOR_DEFINED: + return Message::MT_SMS; - case MSG_TYPE_MMS: - case MSG_TYPE_MMS_JAVA: - return Message::MT_MMS; + case MSG_TYPE_MMS: + case MSG_TYPE_MMS_JAVA: + return Message::MT_MMS; - case MSG_TYPE_MMS_NOTI: - return Message::MT_MMS_Noti; + case MSG_TYPE_MMS_NOTI: + return Message::MT_MMS_Noti; - default: - return Message::MT_Unknown; - } + default: + return Message::MT_Unknown; + } } MsgMedia::Type MsgUtilsPrivate::nativeToSmilType(int type) { - switch (type) { - case MMS_SMIL_MEDIA_IMG: - return MsgMedia::ImageType; - case MMS_SMIL_MEDIA_AUDIO: - return MsgMedia::AudioType; - case MMS_SMIL_MEDIA_VIDEO: - return MsgMedia::VideoType; - case MMS_SMIL_MEDIA_TEXT: - return MsgMedia::TextType; - } - return MsgMedia::UnknownType; + switch (type) { + case MMS_SMIL_MEDIA_IMG: + return MsgMedia::ImageType; + case MMS_SMIL_MEDIA_AUDIO: + return MsgMedia::AudioType; + case MMS_SMIL_MEDIA_VIDEO: + return MsgMedia::VideoType; + case MMS_SMIL_MEDIA_TEXT: + return MsgMedia::TextType; + } + return MsgMedia::UnknownType; } int MsgUtilsPrivate::smilTypeToNative(MsgMedia::Type type) { - switch (type) { - case MsgMedia::ImageType: - return MMS_SMIL_MEDIA_IMG; - case MsgMedia::AudioType: - return MMS_SMIL_MEDIA_AUDIO; - case MsgMedia::VideoType: - return MMS_SMIL_MEDIA_VIDEO; - case MsgMedia::TextType: - return MMS_SMIL_MEDIA_TEXT; - case MsgMedia::UnknownType: - break; - } - return MMS_SMIL_MEDIA_INVALID; + switch (type) { + case MsgMedia::ImageType: + return MMS_SMIL_MEDIA_IMG; + case MsgMedia::AudioType: + return MMS_SMIL_MEDIA_AUDIO; + case MsgMedia::VideoType: + return MMS_SMIL_MEDIA_VIDEO; + case MsgMedia::TextType: + return MMS_SMIL_MEDIA_TEXT; + case MsgMedia::UnknownType: + break; + } + return MMS_SMIL_MEDIA_INVALID; } std::string MsgUtilsPrivate::getStr(msg_struct_t msgStruct, int field, int maxStrLen) { - std::string res; - char buf[maxStrLen + 1]; - if (msg_get_str_value(msgStruct, field, buf, maxStrLen) == 0) - res.assign(buf); + std::string res; + char buf[maxStrLen + 1]; + if (msg_get_str_value(msgStruct, field, buf, maxStrLen) == 0) + res.assign(buf); - return res; + return res; } int MsgUtilsPrivate::setStr(msg_struct_t msgStruct, int field, const std::string &text) { - return msg_set_str_value(msgStruct, field, text.c_str(), text.length()); + return msg_set_str_value(msgStruct, field, text.c_str(), text.length()); } Message::NetworkStatus MsgUtilsPrivate::nativeToNetworkStatus(int status) { - switch (status) { - case MSG_NETWORK_NOT_SEND: - return Message::NS_Not_Send; - case MSG_NETWORK_SENDING: - return Message::NS_Sending; - case MSG_NETWORK_SEND_SUCCESS: - return Message::NS_Send_Success; - case MSG_NETWORK_SEND_FAIL: - case MSG_NETWORK_SEND_TIMEOUT: - case MSG_NETWORK_SEND_FAIL_MANDATORY_INFO_MISSING: - case MSG_NETWORK_SEND_FAIL_TEMPORARY: - case MSG_NETWORK_SEND_FAIL_BY_MO_CONTROL_WITH_MOD: - case MSG_NETWORK_SEND_FAIL_BY_MO_CONTROL_NOT_ALLOWED: - return Message::NS_Send_Fail; - case MSG_NETWORK_DELIVER_SUCCESS: - return Message::NS_Deliver_Success; - case MSG_NETWORK_DELIVER_FAIL: - return Message::NS_Deliver_Fail; - case MSG_NETWORK_RECEIVED: - return Message::NS_Received; - case MSG_NETWORK_REQ_CANCELLED: - return Message::NS_Req_Cancelled; - case MSG_NETWORK_RETRIEVING: - return Message::NS_Retrieving; - case MSG_NETWORK_RETRIEVE_SUCCESS: - return Message::NS_Retrieve_Success; - case MSG_NETWORK_RETRIEVE_FAIL: - return Message::NS_Retrieve_Fail; - case MSG_NETWORK_DELIVER_PENDING: - return Message::NS_Deliver_Pending; - case MSG_NETWORK_DELIVER_EXPIRED: - return Message::NS_Deliver_Expired; - case MSG_NETWORK_SEND_PENDING: - return Message::NS_Send_Pending; - default: - break; - }; - return Message::NS_Unknown; + switch (status) { + case MSG_NETWORK_NOT_SEND: + return Message::NS_Not_Send; + case MSG_NETWORK_SENDING: + return Message::NS_Sending; + case MSG_NETWORK_SEND_SUCCESS: + return Message::NS_Send_Success; + case MSG_NETWORK_SEND_FAIL: + case MSG_NETWORK_SEND_TIMEOUT: + case MSG_NETWORK_SEND_FAIL_MANDATORY_INFO_MISSING: + case MSG_NETWORK_SEND_FAIL_TEMPORARY: + case MSG_NETWORK_SEND_FAIL_BY_MO_CONTROL_WITH_MOD: + case MSG_NETWORK_SEND_FAIL_BY_MO_CONTROL_NOT_ALLOWED: + return Message::NS_Send_Fail; + case MSG_NETWORK_DELIVER_SUCCESS: + return Message::NS_Deliver_Success; + case MSG_NETWORK_DELIVER_FAIL: + return Message::NS_Deliver_Fail; + case MSG_NETWORK_RECEIVED: + return Message::NS_Received; + case MSG_NETWORK_REQ_CANCELLED: + return Message::NS_Req_Cancelled; + case MSG_NETWORK_RETRIEVING: + return Message::NS_Retrieving; + case MSG_NETWORK_RETRIEVE_SUCCESS: + return Message::NS_Retrieve_Success; + case MSG_NETWORK_RETRIEVE_FAIL: + return Message::NS_Retrieve_Fail; + case MSG_NETWORK_DELIVER_PENDING: + return Message::NS_Deliver_Pending; + case MSG_NETWORK_DELIVER_EXPIRED: + return Message::NS_Deliver_Expired; + case MSG_NETWORK_SEND_PENDING: + return Message::NS_Send_Pending; + default: + break; + }; + return Message::NS_Unknown; } int MsgUtilsPrivate::activeNotifPolicyToNative(MsgSettings::ActiveNotifPolicy policy) { - switch (policy) { - case MsgSettings::AppBackgroundPolicy: - return -1; - case MsgSettings::AppForegroundPolicy: - return 0; - default: - assert(false); - } - return 0; + switch (policy) { + case MsgSettings::AppBackgroundPolicy: + return -1; + case MsgSettings::AppForegroundPolicy: + return 0; + default: + assert(false); + } + return 0; } MsgTransport::SendResult MsgUtilsPrivate::nativeToSendResult(int sendRes) { - switch (sendRes) { - case MSG_SUCCESS: - return MsgTransport::SendSuccess; - case MSG_ERR_NO_SIM: - return MsgTransport::SendNoSIM; - case MSG_ERR_DPM_RESTRICT: - return MsgTransport::SendDPMRestricted; - case MSG_ERR_READREPORT_NOT_REQUESTED: - return MsgTransport::SendReadReportNotReq; - case MSG_ERR_READREPORT_ALEADY_SENT: - return MsgTransport::SendReadReportAlreadySent; - default: - return MsgTransport::SendFail; - } + switch (sendRes) { + case MSG_SUCCESS: + return MsgTransport::SendSuccess; + case MSG_ERR_NO_SIM: + return MsgTransport::SendNoSIM; + case MSG_ERR_DPM_RESTRICT: + return MsgTransport::SendDPMRestricted; + case MSG_ERR_READREPORT_NOT_REQUESTED: + return MsgTransport::SendReadReportNotReq; + case MSG_ERR_READREPORT_ALEADY_SENT: + return MsgTransport::SendReadReportAlreadySent; + default: + return MsgTransport::SendFail; + } } MsgSettings::RingtoneType MsgUtilsPrivate::nativeToRingtoneType(int type) { - switch (type) { - case MSG_RINGTONE_TYPE_SILENT: - return MsgSettings::SilentRingtone; - case MSG_RINGTONE_TYPE_USER: - return MsgSettings::UserRingtone; - case MSG_RINGTONE_TYPE_DEFAULT: - return MsgSettings::DefaultRingtone; - } - return MsgSettings::DefaultRingtone; + switch (type) { + case MSG_RINGTONE_TYPE_SILENT: + return MsgSettings::SilentRingtone; + case MSG_RINGTONE_TYPE_USER: + return MsgSettings::UserRingtone; + case MSG_RINGTONE_TYPE_DEFAULT: + return MsgSettings::DefaultRingtone; + } + return MsgSettings::DefaultRingtone; } int MsgUtilsPrivate::ringtoneTypeToNative(MsgSettings::RingtoneType type) { - switch (type) { - case MsgSettings::SilentRingtone: - return MSG_RINGTONE_TYPE_SILENT; - case MsgSettings::UserRingtone: - return MSG_RINGTONE_TYPE_USER; - default: - break; - } - return MSG_RINGTONE_TYPE_DEFAULT; + switch (type) { + case MsgSettings::SilentRingtone: + return MSG_RINGTONE_TYPE_SILENT; + case MsgSettings::UserRingtone: + return MSG_RINGTONE_TYPE_USER; + default: + break; + } + return MSG_RINGTONE_TYPE_DEFAULT; } MsgStorage::StorageResult MsgUtilsPrivate::nativeToStorageResult(int resultCode) { - MsgStorage::StorageResult res = MsgStorage::StorageFail; - switch (resultCode) { - case MSG_SUCCESS: - res = MsgStorage::StorageSuccess; - break; - case MSG_ERR_SIM_STORAGE_FULL: - res = MsgStorage::StorageSimFull; - break; - } - return res; + MsgStorage::StorageResult res = MsgStorage::StorageFail; + switch (resultCode) { + case MSG_SUCCESS: + res = MsgStorage::StorageSuccess; + break; + case MSG_ERR_SIM_STORAGE_FULL: + res = MsgStorage::StorageSimFull; + break; + } + return res; } diff --git a/src/Common/MsgEngine/src/private/MsgUtilsPrivate.h b/src/Common/MsgEngine/src/private/MsgUtilsPrivate.h index ea77284d..1b35568a 100644 --- a/src/Common/MsgEngine/src/private/MsgUtilsPrivate.h +++ b/src/Common/MsgEngine/src/private/MsgUtilsPrivate.h @@ -32,32 +32,32 @@ #include namespace Msg { - class MsgUtilsPrivate { - public: - static int directionToNative(Message::Direction direction); - static int addressTypeToNative(MsgAddress::AddressType type); - static int recipientTypeToNative(MsgAddress::RecipientType type); - static Message::Direction nativeToDirection(int direction); - static Message::MessageStorageType nativeToMessageStorage(int id); - static MsgAddress::AddressType nativeToAddressType(int type); - static MsgAddress::RecipientType nativeToRecipientType(int type); - static MsgReport::DeliveryStatus nativeToReportDeliveryStatus(int status); - static MsgReport::ReadStatus nativeToReportReadStatus(int status); - static int reportReadReportStatusToNative(MsgReport::ReadStatus status); - static MsgReport::Type nativeToReportType(int type); - static Message::Type nativeToMessageType(int type); - static MsgMedia::Type nativeToSmilType(int type); - static int smilTypeToNative(MsgMedia::Type type); - static Message::NetworkStatus nativeToNetworkStatus(int status); - static int activeNotifPolicyToNative(MsgSettings::ActiveNotifPolicy policy); - static MsgTransport::SendResult nativeToSendResult(int sendRes); - static MsgSettings::RingtoneType nativeToRingtoneType(int type); - static int ringtoneTypeToNative(MsgSettings::RingtoneType type); - static MsgStorage::StorageResult nativeToStorageResult(int resultCode); + class MsgUtilsPrivate { + public: + static int directionToNative(Message::Direction direction); + static int addressTypeToNative(MsgAddress::AddressType type); + static int recipientTypeToNative(MsgAddress::RecipientType type); + static Message::Direction nativeToDirection(int direction); + static Message::MessageStorageType nativeToMessageStorage(int id); + static MsgAddress::AddressType nativeToAddressType(int type); + static MsgAddress::RecipientType nativeToRecipientType(int type); + static MsgReport::DeliveryStatus nativeToReportDeliveryStatus(int status); + static MsgReport::ReadStatus nativeToReportReadStatus(int status); + static int reportReadReportStatusToNative(MsgReport::ReadStatus status); + static MsgReport::Type nativeToReportType(int type); + static Message::Type nativeToMessageType(int type); + static MsgMedia::Type nativeToSmilType(int type); + static int smilTypeToNative(MsgMedia::Type type); + static Message::NetworkStatus nativeToNetworkStatus(int status); + static int activeNotifPolicyToNative(MsgSettings::ActiveNotifPolicy policy); + static MsgTransport::SendResult nativeToSendResult(int sendRes); + static MsgSettings::RingtoneType nativeToRingtoneType(int type); + static int ringtoneTypeToNative(MsgSettings::RingtoneType type); + static MsgStorage::StorageResult nativeToStorageResult(int resultCode); - static std::string getStr(msg_struct_t msgStruct, int field, int maxStrLen); - static int setStr(msg_struct_t msgStruct, int field, const std::string &text); - }; + static std::string getStr(msg_struct_t msgStruct, int field, int maxStrLen); + static int setStr(msg_struct_t msgStruct, int field, const std::string &text); + }; } #endif /* _MESSAGE_UTILS_PRIVATE_H__ */ diff --git a/src/Common/SystemSettingsManager/inc/SystemSettingsManager.h b/src/Common/SystemSettingsManager/inc/SystemSettingsManager.h index e10de89e..83b51485 100644 --- a/src/Common/SystemSettingsManager/inc/SystemSettingsManager.h +++ b/src/Common/SystemSettingsManager/inc/SystemSettingsManager.h @@ -22,88 +22,88 @@ #include namespace Msg { - class ISystemSettingsManager; - - /** - * @brief Monitors changing of time format and system language. Also reads telephony settings. - */ - class SystemSettingsManager { - public: - /** - * @brief A constructor initializes telephony handle to make system settings manager instance to read telephony settings. - */ - SystemSettingsManager(); - ~SystemSettingsManager(); - - /** - * @brief Adds a subscriber on system settings change events. - * @param[in] l a listener. - */ - void addListener(ISystemSettingsManager &l); - - /** - * @brief Removes system settings changes listener. - * @param[in] l a listener to be removed. - */ - void removeListener(ISystemSettingsManager&l); - - /** - * @brief Checks whether SIM is inserted or not. - * @return true if SIM is inserted, false otherwise. - */ - bool isSimInserted() const; - - /** - * @brief Checks whether network service is available or not. - * @return true if network service available, false otherwise(service is unavailable or only emergency calls are available). - */ - bool isSimActive() const; - - /** - * @brief Checks whether mobile data is enabled or not. - * @return true if 3g mobile data is enabled, false otherwise. - */ - bool isMobileDataEnabled() const; - - /** - * @brief Checks whether DPM policy restricts usage of text/multimedia messages. - * @return true if DPM policy restricts usage of text/multimedia messages. - */ - bool isMessagingRestrictedByDpm() const; - - private: - SystemSettingsManager(SystemSettingsManager&) = delete; - SystemSettingsManager &operator =(const SystemSettingsManager&) = delete; - - void onTimeFormatChanged(); - void onLanguageChanged(); - void prepareTel(); - void initDpmHandle() const; - void deinitDpmHandle(); - - private: - std::vector m_Listeners; - telephony_handle_list_s m_TelHandleList; - mutable device_policy_manager_h m_DpmHandle; - }; - - /** - * @brief A listener-interface that should be implemented by subscriber in order to be notified about time format or nsystem language change. - */ - class ISystemSettingsManager { - public: - virtual ~ISystemSettingsManager() {} - - /** - * @brief Notification about change of time format. - */ - virtual void onTimeFormatChanged() {}; - - /** - * @brief Notification about change of system language. - */ - virtual void onLanguageChanged() {}; - }; + class ISystemSettingsManager; + + /** + * @brief Monitors changing of time format and system language. Also reads telephony settings. + */ + class SystemSettingsManager { + public: + /** + * @brief A constructor initializes telephony handle to make system settings manager instance to read telephony settings. + */ + SystemSettingsManager(); + ~SystemSettingsManager(); + + /** + * @brief Adds a subscriber on system settings change events. + * @param[in] l a listener. + */ + void addListener(ISystemSettingsManager &l); + + /** + * @brief Removes system settings changes listener. + * @param[in] l a listener to be removed. + */ + void removeListener(ISystemSettingsManager&l); + + /** + * @brief Checks whether SIM is inserted or not. + * @return true if SIM is inserted, false otherwise. + */ + bool isSimInserted() const; + + /** + * @brief Checks whether network service is available or not. + * @return true if network service available, false otherwise(service is unavailable or only emergency calls are available). + */ + bool isSimActive() const; + + /** + * @brief Checks whether mobile data is enabled or not. + * @return true if 3g mobile data is enabled, false otherwise. + */ + bool isMobileDataEnabled() const; + + /** + * @brief Checks whether DPM policy restricts usage of text/multimedia messages. + * @return true if DPM policy restricts usage of text/multimedia messages. + */ + bool isMessagingRestrictedByDpm() const; + + private: + SystemSettingsManager(SystemSettingsManager&) = delete; + SystemSettingsManager &operator =(const SystemSettingsManager&) = delete; + + void onTimeFormatChanged(); + void onLanguageChanged(); + void prepareTel(); + void initDpmHandle() const; + void deinitDpmHandle(); + + private: + std::vector m_Listeners; + telephony_handle_list_s m_TelHandleList; + mutable device_policy_manager_h m_DpmHandle; + }; + + /** + * @brief A listener-interface that should be implemented by subscriber in order to be notified about time format or nsystem language change. + */ + class ISystemSettingsManager { + public: + virtual ~ISystemSettingsManager() {} + + /** + * @brief Notification about change of time format. + */ + virtual void onTimeFormatChanged() {}; + + /** + * @brief Notification about change of system language. + */ + virtual void onLanguageChanged() {}; + }; } #endif /* __SystemSettingsManager_h__ */ diff --git a/src/Common/SystemSettingsManager/src/SystemSettingsManager.cpp b/src/Common/SystemSettingsManager/src/SystemSettingsManager.cpp index e1cf548b..4d1577bc 100644 --- a/src/Common/SystemSettingsManager/src/SystemSettingsManager.cpp +++ b/src/Common/SystemSettingsManager/src/SystemSettingsManager.cpp @@ -24,122 +24,122 @@ using namespace Msg; namespace { - const char *sim1Id = "sim1"; + const char *sim1Id = "sim1"; } #define CALLBACK(method) [](system_settings_key_e key, void *user_data) \ -{ \ - static_cast(user_data)->method(); \ +{ \ + static_cast(user_data)->method(); \ } SystemSettingsManager::SystemSettingsManager() - : m_TelHandleList() - , m_DpmHandle(nullptr) + : m_TelHandleList() + , m_DpmHandle(nullptr) { - system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, CALLBACK(onTimeFormatChanged), this); - system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, CALLBACK(onLanguageChanged), this); + system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, CALLBACK(onTimeFormatChanged), this); + system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, CALLBACK(onLanguageChanged), this); } SystemSettingsManager::~SystemSettingsManager() { - if (m_TelHandleList.handle != nullptr) - telephony_deinit(&m_TelHandleList); + if (m_TelHandleList.handle != nullptr) + telephony_deinit(&m_TelHandleList); - deinitDpmHandle(); + deinitDpmHandle(); } void SystemSettingsManager::prepareTel() { - if (m_TelHandleList.handle != nullptr) - return; - int err = telephony_init(&m_TelHandleList); - MSG_LOG("telephony_init = ", err); + if (m_TelHandleList.handle != nullptr) + return; + int err = telephony_init(&m_TelHandleList); + MSG_LOG("telephony_init = ", err); } void SystemSettingsManager::addListener(ISystemSettingsManager &l) { - auto it = std::find(m_Listeners.begin(), m_Listeners.end(), &l); - if (it == m_Listeners.end()) - m_Listeners.push_back(&l); + auto it = std::find(m_Listeners.begin(), m_Listeners.end(), &l); + if (it == m_Listeners.end()) + m_Listeners.push_back(&l); } void SystemSettingsManager::removeListener(ISystemSettingsManager&l) { - auto it = std::find(m_Listeners.begin(), m_Listeners.end(), &l); - if (it != m_Listeners.end()) - m_Listeners.erase(it); + auto it = std::find(m_Listeners.begin(), m_Listeners.end(), &l); + if (it != m_Listeners.end()) + m_Listeners.erase(it); } bool SystemSettingsManager::isSimInserted() const { - bool res = false; - const_cast(this)->prepareTel(); - - if (m_TelHandleList.count > 0) { - telephony_h handle = m_TelHandleList.handle[0]; - telephony_sim_state_e simState = TELEPHONY_SIM_STATE_UNAVAILABLE; - telephony_sim_get_state(handle, &simState); - res = simState != TELEPHONY_SIM_STATE_UNAVAILABLE && - simState != TELEPHONY_SIM_STATE_UNKNOWN; - } - - return res; + bool res = false; + const_cast(this)->prepareTel(); + + if (m_TelHandleList.count > 0) { + telephony_h handle = m_TelHandleList.handle[0]; + telephony_sim_state_e simState = TELEPHONY_SIM_STATE_UNAVAILABLE; + telephony_sim_get_state(handle, &simState); + res = simState != TELEPHONY_SIM_STATE_UNAVAILABLE && + simState != TELEPHONY_SIM_STATE_UNKNOWN; + } + + return res; } bool SystemSettingsManager::isSimActive() const { - bool res = false; - const_cast(this)->prepareTel(); - - if (m_TelHandleList.count > 0) { - telephony_h telHandle = m_TelHandleList.handle[0]; - telephony_network_service_state_e servState; - if (telephony_network_get_service_state(telHandle, &servState) == TELEPHONY_ERROR_NONE) { - res = (servState == TELEPHONY_NETWORK_SERVICE_STATE_IN_SERVICE); - MSG_LOG("servState = ", servState); - } - } - - return res; + bool res = false; + const_cast(this)->prepareTel(); + + if (m_TelHandleList.count > 0) { + telephony_h telHandle = m_TelHandleList.handle[0]; + telephony_network_service_state_e servState; + if (telephony_network_get_service_state(telHandle, &servState) == TELEPHONY_ERROR_NONE) { + res = (servState == TELEPHONY_NETWORK_SERVICE_STATE_IN_SERVICE); + MSG_LOG("servState = ", servState); + } + } + + return res; } bool SystemSettingsManager::isMobileDataEnabled() const { - bool res = false; - system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, &res); - return res; + bool res = false; + system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_3G_DATA_NETWORK_ENABLED, &res); + return res; } void SystemSettingsManager::onTimeFormatChanged() { - for (ISystemSettingsManager *it : m_Listeners) - it->onTimeFormatChanged(); + for (ISystemSettingsManager *it : m_Listeners) + it->onTimeFormatChanged(); } void SystemSettingsManager::onLanguageChanged() { - for (ISystemSettingsManager *it : m_Listeners) - it->onLanguageChanged(); + for (ISystemSettingsManager *it : m_Listeners) + it->onLanguageChanged(); } bool SystemSettingsManager::isMessagingRestrictedByDpm() const { - initDpmHandle(); - int val = false; - dpm_restriction_get_messaging_state(m_DpmHandle, sim1Id, &val); - return val == 0; + initDpmHandle(); + int val = false; + dpm_restriction_get_messaging_state(m_DpmHandle, sim1Id, &val); + return val == 0; } void SystemSettingsManager::initDpmHandle() const { - if (!m_DpmHandle) - m_DpmHandle = dpm_manager_create(); + if (!m_DpmHandle) + m_DpmHandle = dpm_manager_create(); } void SystemSettingsManager::deinitDpmHandle() { - if (m_DpmHandle) { - dpm_manager_destroy(m_DpmHandle); - m_DpmHandle = nullptr; - } + if (m_DpmHandle) { + dpm_manager_destroy(m_DpmHandle); + m_DpmHandle = nullptr; + } } diff --git a/src/Common/Utils/inc/BidirectUtils.h b/src/Common/Utils/inc/BidirectUtils.h index 8ee152f0..45cd50c0 100644 --- a/src/Common/Utils/inc/BidirectUtils.h +++ b/src/Common/Utils/inc/BidirectUtils.h @@ -20,39 +20,39 @@ #include namespace Msg { - class BidiUtils { - public: - static constexpr const char *lrmChar = "\u200E"; - static constexpr const char *rlmChar = "\u200F"; - - static std::string lrm(const std::string &str); // Left-to-right zero-width character - static std::string lrm(std::string &&str); - - static std::string rlm(const std::string &str); // Right-to-left zero-width non-Arabic character - static std::string rlm(std::string &&str); - }; - - inline std::string BidiUtils::lrm(const std::string &str) - { - return lrmChar + str; - } - - inline std::string BidiUtils::lrm(std::string &&str) - { - str.insert(0, lrmChar); - return std::move(str); - } - - inline std::string BidiUtils::rlm(const std::string &str) - { - return rlmChar + str; - } - - inline std::string BidiUtils::rlm(std::string &&str) - { - str.insert(0, rlmChar); - return std::move(str); - } + class BidiUtils { + public: + static constexpr const char *lrmChar = "\u200E"; + static constexpr const char *rlmChar = "\u200F"; + + static std::string lrm(const std::string &str); // Left-to-right zero-width character + static std::string lrm(std::string &&str); + + static std::string rlm(const std::string &str); // Right-to-left zero-width non-Arabic character + static std::string rlm(std::string &&str); + }; + + inline std::string BidiUtils::lrm(const std::string &str) + { + return lrmChar + str; + } + + inline std::string BidiUtils::lrm(std::string &&str) + { + str.insert(0, lrmChar); + return std::move(str); + } + + inline std::string BidiUtils::rlm(const std::string &str) + { + return rlmChar + str; + } + + inline std::string BidiUtils::rlm(std::string &&str) + { + str.insert(0, rlmChar); + return std::move(str); + } } #endif /* BidirectUtils_h_ */ diff --git a/src/Common/Utils/inc/CallbackAssist.h b/src/Common/Utils/inc/CallbackAssist.h index 98c61f02..e2cc9150 100644 --- a/src/Common/Utils/inc/CallbackAssist.h +++ b/src/Common/Utils/inc/CallbackAssist.h @@ -21,38 +21,38 @@ #include #define SMART_CALLBACK(ClassName, method) [](void *data, Evas_Object *obj, void *event_info) \ -{ \ - static_cast(data)->method(obj, event_info); \ +{ \ + static_cast(data)->method(obj, event_info); \ } #define EVAS_EVENT_CALLBACK(ClassName, method) [](void *data, Evas *e, Evas_Object *obj, void *event_info) \ -{ \ - static_cast(data)->method(obj, event_info); \ +{ \ + static_cast(data)->method(obj, event_info); \ } #define MBE_ITEM_FILTER_CALLBACK(ClassName, method) [](Evas_Object *obj, const char *item_label, const void *item_data, const void *data)->Eina_Bool \ -{ \ - return static_cast((data*)data)->method(obj, item_label, item_data); \ +{ \ + return static_cast((data*)data)->method(obj, item_label, item_data); \ } #define ECORE_TACK_CALLBACK(ClassName, method) [](void *data)->Eina_Bool \ -{ \ - return static_cast(data)->method(); \ +{ \ + return static_cast(data)->method(); \ } #define APP_EVENT_CALLBACK(ClassName, method) [](app_event_info_h event_info, void *data)\ -{ \ - return static_cast(data)->method(event_info); \ +{ \ + return static_cast(data)->method(event_info); \ } #define EDJE_SIGNAL_CALLBACK(ClassName, method) [](void *data, Evas_Object *obj, const char *emission, const char *source) \ -{ \ - static_cast(data)->method(obj, emission, source); \ +{ \ + static_cast(data)->method(obj, emission, source); \ } #define ECORE_CALLBACK(ClassName, method) [](void *data) \ -{ \ - static_cast(data)->method(); \ +{ \ + static_cast(data)->method(); \ } #endif /* CallBackAssist_h_ */ diff --git a/src/Common/Utils/inc/FileUtils.h b/src/Common/Utils/inc/FileUtils.h index 71a9091a..5dffd733 100755 --- a/src/Common/Utils/inc/FileUtils.h +++ b/src/Common/Utils/inc/FileUtils.h @@ -21,128 +21,128 @@ #include namespace Msg { - class FileUtils { - public: - /** - * @brief Get file size. - * @param[in] path to file - * @retval file size - */ - static long long getFileSize(const std::string &file); - - /** - * @brief Check file existing. - * @param[in] path to file - * @retval Returns true if file exist, else false - */ - static bool isExists(const std::string &file); - - /** - * @brief Copy file. - * @param[in] src Source - * @param[in] dst dst - * @retval Returns true if file exist, else false - */ - static bool copy(const std::string &src, const std::string &dst); - - /** - * @brief Add file to data dir, if file not exists in data dir. - * @param[in] source file path - * @return new path in data dir - */ - static std::string addFileToDataDir(const std::string &path); - - /** - * @brief Make Directory. - * @param[in] path to directory - * @retval Returns true if directory created, else false - */ - static bool makeDir(const std::string &dir); - - /** - * @brief Check directory. - * @param[in] file File Directory - * @retval Returns true if file is directory, else false - */ - static bool isDir(const std::string &file); - - /** - * @brief Strip file extension. - * @param[in] path File Path - * @retval Returns file without extension. - */ - static std::string stripExtension(const std::string &path); - - /** - * @brief Split file path (base-path + file-name + file-extension). - * @param[in] file path name - * @param[out] base path(with '/' at end) - * @param[out] file name - * @param[out] extension(without dot) - */ - static void splitPath(const std::string &path, std::string &basePath, - std::string &fileName, std::string &extension); - - /** - * @brief Get file name with extension - * @param[in] file path name - * @retval Returns file name with extension - */ - static std::string getFileName(const std::string &path); - - /** - * @brief Remove recursive files and directories. - * @param[in] path File or directory - * @param[in] true - remove current dir, false - otherwise - * @retval Returns true if all success, false otherwise - */ - static bool remove(const std::string &path, bool removeCurrentDir = true); - - /** - * @brief Read text file - * @param[in] file path name - * @retval Returns text content - */ - static std::string readTextFile(const std::string &path); - - /** - * @brief Write text file - * @param[in] file path name - * @param[in] text content - * @return Returns true if all success, false otherwise - */ - static bool writeTextFile(const std::string &path, const std::string &text); - - /** - * @brief Generate new file path - * @param[in] storage path - * @param[in] file path name - * @return Returns unique file path in storage directory - */ - static std::string genUniqueFilePath(const std::string &storagePath, const std::string &filePath); - - /** - * @brief Gets the MIME type by file ptah/name(with extension) - * @param[in] filePath - * @return Returns The MIME type is 'application/octet-stream' if - * the given file extension is not associated with specific file formats - */ - static std::string getMimeType(const std::string &filePath); - - /** - * @brief Save files to default storage directory - * @param[in] file list of file path - * @return Returns true if all ok, false otherwise - */ - static bool saveFilesToStorage(const std::list &files); - - /** - * @brief Save file to default storage directory - * @param[in] file path - * @return Returns true if all ok, false otherwise - */ - static bool saveFileToStorage(const std::string &file); - }; + class FileUtils { + public: + /** + * @brief Get file size. + * @param[in] path to file + * @retval file size + */ + static long long getFileSize(const std::string &file); + + /** + * @brief Check file existing. + * @param[in] path to file + * @retval Returns true if file exist, else false + */ + static bool isExists(const std::string &file); + + /** + * @brief Copy file. + * @param[in] src Source + * @param[in] dst dst + * @retval Returns true if file exist, else false + */ + static bool copy(const std::string &src, const std::string &dst); + + /** + * @brief Add file to data dir, if file not exists in data dir. + * @param[in] source file path + * @return new path in data dir + */ + static std::string addFileToDataDir(const std::string &path); + + /** + * @brief Make Directory. + * @param[in] path to directory + * @retval Returns true if directory created, else false + */ + static bool makeDir(const std::string &dir); + + /** + * @brief Check directory. + * @param[in] file File Directory + * @retval Returns true if file is directory, else false + */ + static bool isDir(const std::string &file); + + /** + * @brief Strip file extension. + * @param[in] path File Path + * @retval Returns file without extension. + */ + static std::string stripExtension(const std::string &path); + + /** + * @brief Split file path (base-path + file-name + file-extension). + * @param[in] file path name + * @param[out] base path(with '/' at end) + * @param[out] file name + * @param[out] extension(without dot) + */ + static void splitPath(const std::string &path, std::string &basePath, + std::string &fileName, std::string &extension); + + /** + * @brief Get file name with extension + * @param[in] file path name + * @retval Returns file name with extension + */ + static std::string getFileName(const std::string &path); + + /** + * @brief Remove recursive files and directories. + * @param[in] path File or directory + * @param[in] true - remove current dir, false - otherwise + * @retval Returns true if all success, false otherwise + */ + static bool remove(const std::string &path, bool removeCurrentDir = true); + + /** + * @brief Read text file + * @param[in] file path name + * @retval Returns text content + */ + static std::string readTextFile(const std::string &path); + + /** + * @brief Write text file + * @param[in] file path name + * @param[in] text content + * @return Returns true if all success, false otherwise + */ + static bool writeTextFile(const std::string &path, const std::string &text); + + /** + * @brief Generate new file path + * @param[in] storage path + * @param[in] file path name + * @return Returns unique file path in storage directory + */ + static std::string genUniqueFilePath(const std::string &storagePath, const std::string &filePath); + + /** + * @brief Gets the MIME type by file ptah/name(with extension) + * @param[in] filePath + * @return Returns The MIME type is 'application/octet-stream' if + * the given file extension is not associated with specific file formats + */ + static std::string getMimeType(const std::string &filePath); + + /** + * @brief Save files to default storage directory + * @param[in] file list of file path + * @return Returns true if all ok, false otherwise + */ + static bool saveFilesToStorage(const std::list &files); + + /** + * @brief Save file to default storage directory + * @param[in] file path + * @return Returns true if all ok, false otherwise + */ + static bool saveFileToStorage(const std::string &file); + }; } #endif /* __MSG_FILE_UTIL_H__ */ diff --git a/src/Common/Utils/inc/HwButtonListener.h b/src/Common/Utils/inc/HwButtonListener.h index 279183cb..286a4a74 100644 --- a/src/Common/Utils/inc/HwButtonListener.h +++ b/src/Common/Utils/inc/HwButtonListener.h @@ -21,14 +21,14 @@ #include namespace Msg { - class IHwButtonListener { - public: - virtual ~IHwButtonListener() {}; - virtual void onHwBackButtonClicked() {}; - virtual void onHwMoreButtonClicked() {}; + class IHwButtonListener { + public: + virtual ~IHwButtonListener() {}; + virtual void onHwBackButtonClicked() {}; + virtual void onHwMoreButtonClicked() {}; - static void setHwButtonListener(Evas_Object *obj, IHwButtonListener *listener); - }; + static void setHwButtonListener(Evas_Object *obj, IHwButtonListener *listener); + }; } #endif /* HwButtonListener_h_ */ diff --git a/src/Common/Utils/inc/LangUtils.h b/src/Common/Utils/inc/LangUtils.h index d3ad1160..69940cf2 100644 --- a/src/Common/Utils/inc/LangUtils.h +++ b/src/Common/Utils/inc/LangUtils.h @@ -26,83 +26,83 @@ #include namespace Msg { - // Translatable Text - struct TText { - explicit TText(const char *stringId, const char *domainName) - : m_pDomain(domainName) - , m_pMsg(stringId) - { - }; - - const char *getMsg() const - { - return m_pMsg; - } - - const char *getDomain() const - { - return m_pDomain; - } - - private: - TText(TText&) = delete; - TText operator =(TText&) = delete; - - const char *m_pDomain; - const char *m_pMsg; - }; - - // dgettext - struct DText { - explicit DText(const char *stringId, const char *domainName) - { - m_pMsg = dgettext(domainName, stringId); - } - - explicit DText(const std::string &stringId, const char *domainName) - { - m_pMsg = dgettext(domainName, stringId.c_str()); - } - - explicit DText(char dummyArg, const char *stringId, const char *domainName, ...) - : m_pMsg(m_Buf) - { - va_list args; - va_start(args, domainName); - vsnprintf(m_Buf, maxBufSize, dgettext(domainName, stringId), args); - va_end(args); - } - - const char *get() const - { - return m_pMsg; - } - - const char* cStr() const - { - return m_pMsg; - } - - operator std::string() const - { - return m_pMsg; - } - - private: - DText(DText&) = delete; - DText operator =(DText&) = delete; - - static const int maxBufSize = 1024; - char m_Buf[maxBufSize]; - const char *m_pMsg; - }; - - #define msgt(strId) TText(strId, MSG_DOMAIN) - #define msg(strId) DText(strId, MSG_DOMAIN) - #define msgArgs(strId, ...) DText(0, strId, MSG_DOMAIN, __VA_ARGS__) - #define sys(strId) DText(strId, SYS_DOMAIN) - #define syst(strId) TText(strId, SYS_DOMAIN) - #define sysArgs(strId, ...) DText(0, strId, SYS_DOMAIN, __VA_ARGS__) + // Translatable Text + struct TText { + explicit TText(const char *stringId, const char *domainName) + : m_pDomain(domainName) + , m_pMsg(stringId) + { + }; + + const char *getMsg() const + { + return m_pMsg; + } + + const char *getDomain() const + { + return m_pDomain; + } + + private: + TText(TText&) = delete; + TText operator =(TText&) = delete; + + const char *m_pDomain; + const char *m_pMsg; + }; + + // dgettext + struct DText { + explicit DText(const char *stringId, const char *domainName) + { + m_pMsg = dgettext(domainName, stringId); + } + + explicit DText(const std::string &stringId, const char *domainName) + { + m_pMsg = dgettext(domainName, stringId.c_str()); + } + + explicit DText(char dummyArg, const char *stringId, const char *domainName, ...) + : m_pMsg(m_Buf) + { + va_list args; + va_start(args, domainName); + vsnprintf(m_Buf, maxBufSize, dgettext(domainName, stringId), args); + va_end(args); + } + + const char *get() const + { + return m_pMsg; + } + + const char* cStr() const + { + return m_pMsg; + } + + operator std::string() const + { + return m_pMsg; + } + + private: + DText(DText&) = delete; + DText operator =(DText&) = delete; + + static const int maxBufSize = 1024; + char m_Buf[maxBufSize]; + const char *m_pMsg; + }; + + #define msgt(strId) TText(strId, MSG_DOMAIN) + #define msg(strId) DText(strId, MSG_DOMAIN) + #define msgArgs(strId, ...) DText(0, strId, MSG_DOMAIN, __VA_ARGS__) + #define sys(strId) DText(strId, SYS_DOMAIN) + #define syst(strId) TText(strId, SYS_DOMAIN) + #define sysArgs(strId, ...) DText(0, strId, SYS_DOMAIN, __VA_ARGS__) } #endif /* LangUtils_h_ */ diff --git a/src/Common/Utils/inc/Logger.h b/src/Common/Utils/inc/Logger.h index a0ab67ac..15787c98 100644 --- a/src/Common/Utils/inc/Logger.h +++ b/src/Common/Utils/inc/Logger.h @@ -26,22 +26,22 @@ #endif #define TRACE\ - LoggerImpl __tmp_logger_unique(LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__);\ + LoggerImpl __tmp_logger_unique(LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__);\ #define MSG_LOG(...)\ - loggerImpl(LogPriority::INFO, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); + loggerImpl(LogPriority::INFO, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); #define MSG_LOG_INFO(...)\ - loggerImpl(LogPriority::INFO, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); + loggerImpl(LogPriority::INFO, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); #define MSG_LOG_ERROR(...)\ - loggerImpl(LogPriority::ERROR, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); + loggerImpl(LogPriority::ERROR, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); #define MSG_LOG_WARN(...)\ - loggerImpl(LogPriority::WARN, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); + loggerImpl(LogPriority::WARN, LOGGER_TAG, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); #define MSG_ASSERT(expr, ...)\ - if (!(expr)) { MSG_LOG_ERROR(__VA_ARGS__); } \ - assert(expr) + if (!(expr)) { MSG_LOG_ERROR(__VA_ARGS__); } \ + assert(expr) #endif /* LOGGER_H_ */ diff --git a/src/Common/Utils/inc/LoggerImpl.h b/src/Common/Utils/inc/LoggerImpl.h index 6e864a1a..bf634502 100644 --- a/src/Common/Utils/inc/LoggerImpl.h +++ b/src/Common/Utils/inc/LoggerImpl.h @@ -22,40 +22,40 @@ #include enum class LogPriority { - DEFAULT = DLOG_DEFAULT, - VERBOSE = DLOG_VERBOSE, /**< Verbose */ - DEBUG = DLOG_DEBUG, /**< Debug */ - INFO = DLOG_INFO, /**< Info */ - WARN = DLOG_WARN, /**< Warning */ - ERROR = DLOG_ERROR, /**< Error */ - FATAL = DLOG_FATAL, /**< Fatal */ - SILEN = DLOG_SILENT, /**< Silent */ - MAX = DLOG_PRIO_MAX /**< Keep this always at the end. */ + DEFAULT = DLOG_DEFAULT, + VERBOSE = DLOG_VERBOSE, /**< Verbose */ + DEBUG = DLOG_DEBUG, /**< Debug */ + INFO = DLOG_INFO, /**< Info */ + WARN = DLOG_WARN, /**< Warning */ + ERROR = DLOG_ERROR, /**< Error */ + FATAL = DLOG_FATAL, /**< Fatal */ + SILEN = DLOG_SILENT, /**< Silent */ + MAX = DLOG_PRIO_MAX /**< Keep this always at the end. */ }; template void loggerImpl(LogPriority prior - , const char *tag - , const char *file, const char *function, int line - , Tail... msg) + , const char *tag + , const char *file, const char *function, int line + , Tail... msg) { - std::ostringstream messageStr; - (void)std::initializer_list { (messageStr << msg, true)... }; - dlog_print(static_cast(prior) - , tag, "%s: %s(%d) -> %s", file, function, line - , messageStr.str().c_str()); + std::ostringstream messageStr; + (void)std::initializer_list { (messageStr << msg, true)... }; + dlog_print(static_cast(prior) + , tag, "%s: %s(%d) -> %s", file, function, line + , messageStr.str().c_str()); } class LoggerImpl { - public: - LoggerImpl(const char *tag, const char *file, const char *function, int line); - ~LoggerImpl(); + public: + LoggerImpl(const char *tag, const char *file, const char *function, int line); + ~LoggerImpl(); - private: - const std::string m_Tag; - const std::string m_File; - const std::string m_Function; + private: + const std::string m_Tag; + const std::string m_File; + const std::string m_Function; }; #endif /* LOGGERIMPL_H_ */ diff --git a/src/Common/Utils/inc/MediaUtils.h b/src/Common/Utils/inc/MediaUtils.h index f5abdb88..1e0e244c 100644 --- a/src/Common/Utils/inc/MediaUtils.h +++ b/src/Common/Utils/inc/MediaUtils.h @@ -20,17 +20,17 @@ #include namespace Msg { - class MediaUtils { - public: - static std::string getTitle(const std::string &path); - static int getDuration(const std::string &uri); // msec; - static int getDurationSec(const std::string &uri); // sec; - static bool getVideoFrame(const std::string &videoFilePath, const std::string &imageFilePath); - static bool getFrameSize(const std::string &videoFilePath, int &width, int &height); - static long long downgradeImageQuality(const std::string &imagePath); - static bool hasAudio(const std::string &path); - static bool hasVideo(const std::string &path); - }; + class MediaUtils { + public: + static std::string getTitle(const std::string &path); + static int getDuration(const std::string &uri); // msec; + static int getDurationSec(const std::string &uri); // sec; + static bool getVideoFrame(const std::string &videoFilePath, const std::string &imageFilePath); + static bool getFrameSize(const std::string &videoFilePath, int &width, int &height); + static long long downgradeImageQuality(const std::string &imagePath); + static bool hasAudio(const std::string &path); + static bool hasVideo(const std::string &path); + }; } #endif /* MediaUtils_h_ */ diff --git a/src/Common/Utils/inc/PathUtils.h b/src/Common/Utils/inc/PathUtils.h index 7d842e47..d8cbb738 100644 --- a/src/Common/Utils/inc/PathUtils.h +++ b/src/Common/Utils/inc/PathUtils.h @@ -21,40 +21,40 @@ #include "Resource.h" namespace Msg { - class PathUtils { - public: - /** - * @brief Gets the absolute path to file in the application resource directory. - * @param[in] path to file in res. dir (without slash at begin/end) - * @return absolute path to file - */ - static std::string getResourcePath(const std::string &filePath); - - /** - * @brief Gets the absolute path to file in data directory which is used to store private data of the application. - * @param[in] path to file in data dir (without slash at begin/end) - * @return absolute path to file - */ - static std::string getDataPath(const std::string &filePath); - - /** - * @brief Gets absolute path to application's resource-directory - * @return absolute path in case of success, or empty string otherwise - */ - static std::string getResourcePath(); - - /** - * @brief Gets absolute path to application's locale-directory - * @return absolute path in case of success, or empty string otherwise - */ - static std::string getLocalePath(); - - /** - * @brief Gets absolute path to Dowloads directory - * @return absolute path in case of success, or empty string otherwise - */ - static const std::string &getDownloadPath(); - }; + class PathUtils { + public: + /** + * @brief Gets the absolute path to file in the application resource directory. + * @param[in] path to file in res. dir (without slash at begin/end) + * @return absolute path to file + */ + static std::string getResourcePath(const std::string &filePath); + + /** + * @brief Gets the absolute path to file in data directory which is used to store private data of the application. + * @param[in] path to file in data dir (without slash at begin/end) + * @return absolute path to file + */ + static std::string getDataPath(const std::string &filePath); + + /** + * @brief Gets absolute path to application's resource-directory + * @return absolute path in case of success, or empty string otherwise + */ + static std::string getResourcePath(); + + /** + * @brief Gets absolute path to application's locale-directory + * @return absolute path in case of success, or empty string otherwise + */ + static std::string getLocalePath(); + + /** + * @brief Gets absolute path to Dowloads directory + * @return absolute path in case of success, or empty string otherwise + */ + static const std::string &getDownloadPath(); + }; } #endif /* PathUtils_h_ */ diff --git a/src/Common/Utils/inc/PhoneNumberUtils.h b/src/Common/Utils/inc/PhoneNumberUtils.h index b86fbd5c..f5cd3f8f 100644 --- a/src/Common/Utils/inc/PhoneNumberUtils.h +++ b/src/Common/Utils/inc/PhoneNumberUtils.h @@ -20,17 +20,17 @@ #include namespace Msg { - class PhoneNumberUtils { - public: - static PhoneNumberUtils &getInst(); - std::string getNormalizedNumber(const std::string &number) const; + class PhoneNumberUtils { + public: + static PhoneNumberUtils &getInst(); + std::string getNormalizedNumber(const std::string &number) const; - private: - PhoneNumberUtils(); - ~PhoneNumberUtils(); - PhoneNumberUtils& operator=(PhoneNumberUtils&) = delete; - PhoneNumberUtils(PhoneNumberUtils&) = delete; - }; + private: + PhoneNumberUtils(); + ~PhoneNumberUtils(); + PhoneNumberUtils& operator=(PhoneNumberUtils&) = delete; + PhoneNumberUtils(PhoneNumberUtils&) = delete; + }; } #endif /* __PhoneNumberUtils_H__ */ diff --git a/src/Common/Utils/inc/TextDecorator.h b/src/Common/Utils/inc/TextDecorator.h index 54a29cac..d9a38574 100644 --- a/src/Common/Utils/inc/TextDecorator.h +++ b/src/Common/Utils/inc/TextDecorator.h @@ -20,60 +20,60 @@ #include namespace Msg { - enum class TextAlign { - None, - Left, - Center, - Right - }; + enum class TextAlign { + None, + Left, + Center, + Right + }; - class TextStyle { - public: - static const char *defaultColor; - static const char *whiteColor; - static const int defaultFontSize; + class TextStyle { + public: + static const char *defaultColor; + static const char *whiteColor; + static const int defaultFontSize; - public: - TextStyle(); - TextStyle(int size, const std::string &color, TextAlign align = TextAlign::None); - ~TextStyle(); + public: + TextStyle(); + TextStyle(int size, const std::string &color, TextAlign align = TextAlign::None); + ~TextStyle(); - void setColor(const std::string &color); - void setSize(int size); - void setAlign(TextAlign align); + void setColor(const std::string &color); + void setSize(int size); + void setAlign(TextAlign align); - const std::string &getColor() const; - int getSize() const; - TextAlign getAlign() const; + const std::string &getColor() const; + int getSize() const; + TextAlign getAlign() const; - private: - std::string m_Color; - TextAlign m_Align; - int m_Size; - }; + private: + std::string m_Color; + TextAlign m_Align; + int m_Size; + }; - /** - * @brief Class with text decorator utils - */ - class TextDecorator { - public: - static std::string make(const std::string &text, const TextStyle &style); - static std::string make(const std::string &text, const std::string &color); - static std::string make(const std::string &text, - int size = TextStyle::defaultFontSize, - const std::string &color = TextStyle::defaultColor, - TextAlign align = TextAlign::None); - static std::string makePlainText(const std::string &text); + /** + * @brief Class with text decorator utils + */ + class TextDecorator { + public: + static std::string make(const std::string &text, const TextStyle &style); + static std::string make(const std::string &text, const std::string &color); + static std::string make(const std::string &text, + int size = TextStyle::defaultFontSize, + const std::string &color = TextStyle::defaultColor, + TextAlign align = TextAlign::None); + static std::string makePlainText(const std::string &text); - /** - * @brief Search first keyword and highlight it - * @param[in] str text with keyword - * @param[in] searchWord word for highlight - * @param[out] true if search word found, false otherwise - * @retval text with highlighted keyword if keyword found, input text otherwise - */ - static std::string highlightKeyword(std::string str, const std::string &searchWord, bool *foundRes = nullptr); - }; + /** + * @brief Search first keyword and highlight it + * @param[in] str text with keyword + * @param[in] searchWord word for highlight + * @param[out] true if search word found, false otherwise + * @retval text with highlighted keyword if keyword found, input text otherwise + */ + static std::string highlightKeyword(std::string str, const std::string &searchWord, bool *foundRes = nullptr); + }; } #endif /* TextDecorator_h_ */ diff --git a/src/Common/Utils/inc/ThumbnailMaker.h b/src/Common/Utils/inc/ThumbnailMaker.h index 6ee4d6d5..0d7c0b9c 100644 --- a/src/Common/Utils/inc/ThumbnailMaker.h +++ b/src/Common/Utils/inc/ThumbnailMaker.h @@ -24,57 +24,57 @@ #include "ContactManager.h" namespace Msg { - class App; - typedef long ThumbId; - const ThumbId invalidThumbId = -1; + class App; + typedef long ThumbId; + const ThumbId invalidThumbId = -1; - class ThumbnailMaker - : public IContactManagerListener { - public: - enum DefaultThumbs { - SingleThumb = 0, // Static thumb - GroupThumb, // Static thumb - OwnerThumb, // Mutable thumb - MaxDefaultThumb - }; + class ThumbnailMaker + : public IContactManagerListener { + public: + enum DefaultThumbs { + SingleThumb = 0, // Static thumb + GroupThumb, // Static thumb + OwnerThumb, // Mutable thumb + MaxDefaultThumb + }; - public: - ThumbnailMaker(App &app); - virtual ~ThumbnailMaker(); - ThumbnailMaker(ThumbnailMaker&) = delete; - ThumbnailMaker &operator=(ThumbnailMaker&) = delete; + public: + ThumbnailMaker(App &app); + virtual ~ThumbnailMaker(); + ThumbnailMaker(ThumbnailMaker&) = delete; + ThumbnailMaker &operator=(ThumbnailMaker&) = delete; - ThumbId getThumbId(const MsgAddress &address); - ThumbId getThumbId(const std::string &address); - ThumbId getThumbId(DefaultThumbs thumb); - Evas_Object *getThumb(Evas_Object *parent, ThumbId id, int thumbSize); - Evas_Object *getThumb(Evas_Object *parent, const std::string &path, int thumbSize); + ThumbId getThumbId(const MsgAddress &address); + ThumbId getThumbId(const std::string &address); + ThumbId getThumbId(DefaultThumbs thumb); + Evas_Object *getThumb(Evas_Object *parent, ThumbId id, int thumbSize); + Evas_Object *getThumb(Evas_Object *parent, const std::string &path, int thumbSize); - private: - typedef std::unordered_map ContactsMap; - typedef std::unordered_map OriginsMap; + private: + typedef std::unordered_map ContactsMap; + typedef std::unordered_map OriginsMap; - private: - void invalidate(); - ThumbId getThumbIdFromFile(const std::string &path); - Evas_Object *makeMask(Evas_Object *parent, int size); - Evas_Object *makeImage(Evas_Object *parent, const std::string &path, int size); - Evas_Object *makeOriginThumb(Evas_Object *parent, const std::string &path); - Evas_Object *makeDefaultOriginThumb(Evas_Object *parent, const std::string &path); - const std::string &defaultThumbsToStr(DefaultThumbs thumb); - std::string defaultThumbsToPath(DefaultThumbs thumb); + private: + void invalidate(); + ThumbId getThumbIdFromFile(const std::string &path); + Evas_Object *makeMask(Evas_Object *parent, int size); + Evas_Object *makeImage(Evas_Object *parent, const std::string &path, int size); + Evas_Object *makeOriginThumb(Evas_Object *parent, const std::string &path); + Evas_Object *makeDefaultOriginThumb(Evas_Object *parent, const std::string &path); + const std::string &defaultThumbsToStr(DefaultThumbs thumb); + std::string defaultThumbsToPath(DefaultThumbs thumb); - //IContactManagerListener - virtual void onContactChanged(); + //IContactManagerListener + virtual void onContactChanged(); - private: - const int maxStaticThumbId = GroupThumb; + private: + const int maxStaticThumbId = GroupThumb; - App &m_App; - ContactsMap m_ContactsMap; - OriginsMap m_OriginsMap; - ThumbId m_CurrentId; - }; + App &m_App; + ContactsMap m_ContactsMap; + OriginsMap m_OriginsMap; + ThumbId m_CurrentId; + }; } #endif /* ThumbnailMaker_h_ */ diff --git a/src/Common/Utils/inc/TimeUtils.h b/src/Common/Utils/inc/TimeUtils.h index 819164f3..83b49693 100644 --- a/src/Common/Utils/inc/TimeUtils.h +++ b/src/Common/Utils/inc/TimeUtils.h @@ -21,35 +21,35 @@ #include namespace Msg { - class TimeUtils { - enum TimeFormat { - TimeFormatUnknown, - TimeFormat24H, - TimeFormat12H - }; + class TimeUtils { + enum TimeFormat { + TimeFormatUnknown, + TimeFormat24H, + TimeFormat12H + }; - public: - static std::string makeThreadTimeString(time_t msgTime); - static std::string makeBubbleTimeString(time_t msgTime); - static std::string makeBubbleDateLineString(time_t msgTime); - static std::string makeDateTimeString(time_t msgTime); - static std::string makeDateString(time_t msgTime); - static std::string makeSmsReportTimeString(time_t msgTime); - static std::string makeMmsReportTimeString(time_t msgTime); - static std::string makeCalEventString(time_t time); - static std::string makeCalEventString(int year, int month, int mday, int hour, int min, const char *timezone = nullptr); + public: + static std::string makeThreadTimeString(time_t msgTime); + static std::string makeBubbleTimeString(time_t msgTime); + static std::string makeBubbleDateLineString(time_t msgTime); + static std::string makeDateTimeString(time_t msgTime); + static std::string makeDateString(time_t msgTime); + static std::string makeSmsReportTimeString(time_t msgTime); + static std::string makeMmsReportTimeString(time_t msgTime); + static std::string makeCalEventString(time_t time); + static std::string makeCalEventString(int year, int month, int mday, int hour, int min, const char *timezone = nullptr); - protected: - //made protected to allow inheritance of this class in tests - static const std::string &getDefaultLocale(); - static std::string getDateBestPattern(const std::string &locale, const std::string &skeleton); - static std::string getFormattedDate(const std::string &locale, const std::string &bestPattern, time_t time, const char *timezone = nullptr); + protected: + //made protected to allow inheritance of this class in tests + static const std::string &getDefaultLocale(); + static std::string getDateBestPattern(const std::string &locale, const std::string &skeleton); + static std::string getFormattedDate(const std::string &locale, const std::string &bestPattern, time_t time, const char *timezone = nullptr); - private: - static int getTimeFormat(); - static std::string getTimezone(); - static i18n_udate_format_h getDateFormat(const std::string &locale, const i18n_uchar *pattern, int *status); - }; + private: + static int getTimeFormat(); + static std::string getTimezone(); + static i18n_udate_format_h getDateFormat(const std::string &locale, const i18n_uchar *pattern, int *status); + }; } #endif /* __MSG_TIME_UTIL_H__ */ diff --git a/src/Common/Utils/inc/VCalendarParser.h b/src/Common/Utils/inc/VCalendarParser.h index db6fb0fb..b29cd421 100644 --- a/src/Common/Utils/inc/VCalendarParser.h +++ b/src/Common/Utils/inc/VCalendarParser.h @@ -22,29 +22,29 @@ #include namespace Msg { - class CalendarEvent { - public: - CalendarEvent(calendar_record_h record); - - const std::string &getSummary() const; - const std::string &getStartDate() const; - - private: - std::string m_Summary; - std::string m_StartDate; - }; - - class VCalendarParser { - public: - static VCalendarParser &getInst(); - static std::list parse(const std::string &filePath); - - private: - VCalendarParser(); - ~VCalendarParser(); - VCalendarParser& operator=(VCalendarParser&) = delete; - VCalendarParser(VCalendarParser&) = delete; - }; + class CalendarEvent { + public: + CalendarEvent(calendar_record_h record); + + const std::string &getSummary() const; + const std::string &getStartDate() const; + + private: + std::string m_Summary; + std::string m_StartDate; + }; + + class VCalendarParser { + public: + static VCalendarParser &getInst(); + static std::list parse(const std::string &filePath); + + private: + VCalendarParser(); + ~VCalendarParser(); + VCalendarParser& operator=(VCalendarParser&) = delete; + VCalendarParser(VCalendarParser&) = delete; + }; } #endif /* VCardParser_h_ */ diff --git a/src/Common/Utils/src/FileUtils.cpp b/src/Common/Utils/src/FileUtils.cpp index a0b75ec3..0c7b92fa 100755 --- a/src/Common/Utils/src/FileUtils.cpp +++ b/src/Common/Utils/src/FileUtils.cpp @@ -36,251 +36,251 @@ using namespace Msg; long long FileUtils::getFileSize(const std::string &file) { - long long size = 0; + long long size = 0; - struct stat st = {}; - if (stat(file.c_str(), &st) == 0) - size = st.st_size; + struct stat st = {}; + if (stat(file.c_str(), &st) == 0) + size = st.st_size; - return size; + return size; } bool FileUtils::isExists(const std::string &file) { - bool res = false; - struct stat st = {}; - res = stat(file.c_str(), &st) == 0 || file == "/"; - return res; + bool res = false; + struct stat st = {}; + res = stat(file.c_str(), &st) == 0 || file == "/"; + return res; } bool FileUtils::copy(const std::string &src, const std::string &dst) { - FILE *f1 = nullptr; - FILE *f2 = nullptr; + FILE *f1 = nullptr; + FILE *f2 = nullptr; - const size_t bufSize = 4 * 1024; - char buf[bufSize]; + const size_t bufSize = 4 * 1024; + char buf[bufSize]; - size_t num = 0; - bool ret = true; + size_t num = 0; + bool ret = true; - f1 = fopen(src.c_str(), "rb"); - if (!f1) - return false; + f1 = fopen(src.c_str(), "rb"); + if (!f1) + return false; - f2 = fopen(dst.c_str(), "wb"); - if (!f2) { - fclose(f1); - return false; - } + f2 = fopen(dst.c_str(), "wb"); + if (!f2) { + fclose(f1); + return false; + } - while ((num = fread(buf, 1, sizeof(buf), f1)) > 0) { - if (fwrite(buf, 1, num, f2) != num) { - ret = false; - } - } + while ((num = fread(buf, 1, sizeof(buf), f1)) > 0) { + if (fwrite(buf, 1, num, f2) != num) { + ret = false; + } + } - fclose(f1); - fclose(f2); + fclose(f1); + fclose(f2); - return ret; + return ret; } bool FileUtils::makeDir(const std::string &dir) { - bool res = false; + bool res = false; - mode_t mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; - res = mkdir(dir.c_str(), mode) == 0; + mode_t mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; + res = mkdir(dir.c_str(), mode) == 0; - return res; + return res; } std::string FileUtils::addFileToDataDir(const std::string &path) { - std::string newPath; - if (isExists(path)) { - std::string dataPath = PathUtils::getDataPath(""); - if (path.find(dataPath) != std::string::npos) { - newPath = path; - MSG_LOG("File is already exists: ", newPath); - } else { - newPath = FileUtils::genUniqueFilePath(dataPath, path); - if (!copy(path, newPath)) - newPath.clear(); - } - } - - return newPath; + std::string newPath; + if (isExists(path)) { + std::string dataPath = PathUtils::getDataPath(""); + if (path.find(dataPath) != std::string::npos) { + newPath = path; + MSG_LOG("File is already exists: ", newPath); + } else { + newPath = FileUtils::genUniqueFilePath(dataPath, path); + if (!copy(path, newPath)) + newPath.clear(); + } + } + + return newPath; } bool FileUtils::isDir(const std::string &file) { - bool res = false; + bool res = false; - struct stat st = {}; - if (stat(file.c_str(), &st) == 0) - res = S_ISDIR(st.st_mode); + struct stat st = {}; + if (stat(file.c_str(), &st) == 0) + res = S_ISDIR(st.st_mode); - return res; + return res; } std::string FileUtils::stripExtension(const std::string &path) { - auto pos = path.find_last_of("."); - return pos == std::string::npos ? path : path.substr(0, pos); + auto pos = path.find_last_of("."); + return pos == std::string::npos ? path : path.substr(0, pos); } void FileUtils::splitPath(const std::string &path, std::string &basePath, - std::string &fileName, std::string &extension) + std::string &fileName, std::string &extension) { - auto pos = path.find_last_of('/'); - - if (pos != std::string::npos) - basePath = path.substr(0, pos + 1); - - std::string name; - name = path.substr(pos + 1); - - pos = name.find_last_of('.'); - if (pos != std::string::npos) { - extension = name.substr(pos + 1); - if (pos != 0) - fileName = name.substr(0, pos); - } else { - fileName = name; - } + auto pos = path.find_last_of('/'); + + if (pos != std::string::npos) + basePath = path.substr(0, pos + 1); + + std::string name; + name = path.substr(pos + 1); + + pos = name.find_last_of('.'); + if (pos != std::string::npos) { + extension = name.substr(pos + 1); + if (pos != 0) + fileName = name.substr(0, pos); + } else { + fileName = name; + } } std::string FileUtils::getFileName(const std::string &path) { - auto pos = path.find_last_of('/'); - return pos != std::string::npos ? path.substr(pos + 1) : path; + auto pos = path.find_last_of('/'); + return pos != std::string::npos ? path.substr(pos + 1) : path; } bool FileUtils::remove(const std::string &path, bool removeCurrentDir) { - bool res = true; - struct dirent ep; - struct dirent *dirData = nullptr; - DIR *dp = opendir(path.c_str()); - - if (dp) { - while (true) { - dirData = nullptr; - readdir_r(dp, &ep, &dirData); - - if (dirData == nullptr) - break; - - if (strcmp(dirData->d_name, ".") != 0 && strcmp(dirData->d_name, "..") != 0) { - std::string child = path + "/" + dirData->d_name; - res &= remove(child, true); - } - } - - closedir(dp); - if (removeCurrentDir) - res &= rmdir(path.c_str()) == 0; - } else { - res &= unlink(path.c_str()) == 0; - } - - return res; + bool res = true; + struct dirent ep; + struct dirent *dirData = nullptr; + DIR *dp = opendir(path.c_str()); + + if (dp) { + while (true) { + dirData = nullptr; + readdir_r(dp, &ep, &dirData); + + if (dirData == nullptr) + break; + + if (strcmp(dirData->d_name, ".") != 0 && strcmp(dirData->d_name, "..") != 0) { + std::string child = path + "/" + dirData->d_name; + res &= remove(child, true); + } + } + + closedir(dp); + if (removeCurrentDir) + res &= rmdir(path.c_str()) == 0; + } else { + res &= unlink(path.c_str()) == 0; + } + + return res; } std::string FileUtils::readTextFile(const std::string &path) { - std::ifstream fs(path, std::ifstream::in | std::ifstream::binary); - return fs.is_open() ? std::string(std::istreambuf_iterator(fs), std::istreambuf_iterator()) : ""; + std::ifstream fs(path, std::ifstream::in | std::ifstream::binary); + return fs.is_open() ? std::string(std::istreambuf_iterator(fs), std::istreambuf_iterator()) : ""; } bool FileUtils::writeTextFile(const std::string &path, const std::string &text) { - std::ofstream file(path, std::ofstream::trunc | std::ofstream::binary | std::ofstream::out); - if (file.is_open()) - file << text; - return file.is_open() && file.good(); + std::ofstream file(path, std::ofstream::trunc | std::ofstream::binary | std::ofstream::out); + if (file.is_open()) + file << text; + return file.is_open() && file.good(); } std::string FileUtils::genUniqueFilePath(const std::string &storagePath, const std::string &filePath) { - std::string res = filePath; - std::string base; - std::string name; - std::string ext; - splitPath(filePath, base, name, ext); - - unsigned i = 0; - do { - res = storagePath; - if (res.back() != '/') - res += '/'; - - res += name; - if (i > 0) - res += "-" + std::to_string(i); - if (!ext.empty()) - res += '.' + ext; - ++i; - } while (isExists(res)); - return res; + std::string res = filePath; + std::string base; + std::string name; + std::string ext; + splitPath(filePath, base, name, ext); + + unsigned i = 0; + do { + res = storagePath; + if (res.back() != '/') + res += '/'; + + res += name; + if (i > 0) + res += "-" + std::to_string(i); + if (!ext.empty()) + res += '.' + ext; + ++i; + } while (isExists(res)); + return res; } std::string FileUtils::getMimeType(const std::string &filePath) { - std::string res; - std::string base; - std::string name; - std::string ext; - splitPath(filePath, base, name, ext); - if (!ext.empty()) { - char *mime = nullptr; - mime_type_get_mime_type(ext.c_str(), &mime); - if (mime) { - res = mime; - std::transform(res.begin(), res.end(), res.begin(), ::tolower); - free(mime); - } - } - return res; + std::string res; + std::string base; + std::string name; + std::string ext; + splitPath(filePath, base, name, ext); + if (!ext.empty()) { + char *mime = nullptr; + mime_type_get_mime_type(ext.c_str(), &mime); + if (mime) { + res = mime; + std::transform(res.begin(), res.end(), res.begin(), ::tolower); + free(mime); + } + } + return res; } static bool saveFileToStoragePrivate(const std::string &file) { - bool res = false; + bool res = false; - std::string dowloadPath = PathUtils::getDownloadPath(); - std::string filePathDst = FileUtils::genUniqueFilePath(dowloadPath, file); + std::string dowloadPath = PathUtils::getDownloadPath(); + std::string filePathDst = FileUtils::genUniqueFilePath(dowloadPath, file); - if (FileUtils::copy(file, filePathDst)) - res = media_content_scan_file(filePathDst.c_str()) == MEDIA_CONTENT_ERROR_NONE; + if (FileUtils::copy(file, filePathDst)) + res = media_content_scan_file(filePathDst.c_str()) == MEDIA_CONTENT_ERROR_NONE; - return res; + return res; } bool FileUtils::saveFilesToStorage(const std::list &files) { - bool res = true; - if (media_content_connect() != 0) - return false; + bool res = true; + if (media_content_connect() != 0) + return false; - for (const std::string &file : files) - res &= saveFileToStoragePrivate(file); + for (const std::string &file : files) + res &= saveFileToStoragePrivate(file); - media_content_disconnect(); - return res; + media_content_disconnect(); + return res; } bool FileUtils::saveFileToStorage(const std::string &file) { - if (media_content_connect() != 0) - return false; + if (media_content_connect() != 0) + return false; - bool res = saveFileToStoragePrivate(file); + bool res = saveFileToStoragePrivate(file); - media_content_disconnect(); - return res; + media_content_disconnect(); + return res; } diff --git a/src/Common/Utils/src/HwButtonListener.cpp b/src/Common/Utils/src/HwButtonListener.cpp index 8edf6988..2fa35068 100644 --- a/src/Common/Utils/src/HwButtonListener.cpp +++ b/src/Common/Utils/src/HwButtonListener.cpp @@ -23,23 +23,23 @@ using namespace Msg; static void back_event_cb(void *data, Evas_Object *obj, void *event_info) { - static_cast(data)->onHwBackButtonClicked(); + static_cast(data)->onHwBackButtonClicked(); } static void more_event_cb(void *data, Evas_Object *obj, void *event_info) { - static_cast(data)->onHwMoreButtonClicked(); + static_cast(data)->onHwMoreButtonClicked(); } void IHwButtonListener::setHwButtonListener(Evas_Object * obj, IHwButtonListener *listener) { - if (listener) { - setHwButtonListener(obj, nullptr); - eext_object_event_callback_add(obj, EEXT_CALLBACK_MORE, more_event_cb, listener); - eext_object_event_callback_add(obj, EEXT_CALLBACK_BACK, back_event_cb, listener); - } else { - eext_object_event_callback_del(obj, EEXT_CALLBACK_MORE, more_event_cb); - eext_object_event_callback_del(obj, EEXT_CALLBACK_BACK, back_event_cb); - } + if (listener) { + setHwButtonListener(obj, nullptr); + eext_object_event_callback_add(obj, EEXT_CALLBACK_MORE, more_event_cb, listener); + eext_object_event_callback_add(obj, EEXT_CALLBACK_BACK, back_event_cb, listener); + } else { + eext_object_event_callback_del(obj, EEXT_CALLBACK_MORE, more_event_cb); + eext_object_event_callback_del(obj, EEXT_CALLBACK_BACK, back_event_cb); + } } diff --git a/src/Common/Utils/src/LoggerImpl.cpp b/src/Common/Utils/src/LoggerImpl.cpp index 5cfb1fd1..845c6fff 100644 --- a/src/Common/Utils/src/LoggerImpl.cpp +++ b/src/Common/Utils/src/LoggerImpl.cpp @@ -17,29 +17,29 @@ #include "LoggerImpl.h" namespace { - const std::string enterFraseFormat = "%s: %s(%d) -> [ENTER]"; - const std::string leaveFraseFormat = "%s: %s -> [LEAVE]"; - const log_priority defaultPriority = DLOG_DEBUG; + const std::string enterFraseFormat = "%s: %s(%d) -> [ENTER]"; + const std::string leaveFraseFormat = "%s: %s -> [LEAVE]"; + const log_priority defaultPriority = DLOG_DEBUG; } LoggerImpl::LoggerImpl(const char *tag, const char *file, const char *function, int line) - : m_Tag(tag) - , m_File(file) - , m_Function(function) + : m_Tag(tag) + , m_File(file) + , m_Function(function) { - dlog_print(defaultPriority - , m_Tag.c_str() - , enterFraseFormat.c_str() - , m_File.c_str() - , m_Function.c_str() - , line); + dlog_print(defaultPriority + , m_Tag.c_str() + , enterFraseFormat.c_str() + , m_File.c_str() + , m_Function.c_str() + , line); } LoggerImpl::~LoggerImpl() { - dlog_print(defaultPriority - , m_Tag.c_str() - , leaveFraseFormat.c_str() - , m_File.c_str() - , m_Function.c_str()); + dlog_print(defaultPriority + , m_Tag.c_str() + , leaveFraseFormat.c_str() + , m_File.c_str() + , m_Function.c_str()); } diff --git a/src/Common/Utils/src/MediaUtils.cpp b/src/Common/Utils/src/MediaUtils.cpp index 7bf8f152..8eb0f9c0 100644 --- a/src/Common/Utils/src/MediaUtils.cpp +++ b/src/Common/Utils/src/MediaUtils.cpp @@ -27,287 +27,287 @@ using namespace Msg; namespace { - const int QUALITY = 50; - const unsigned char EXIF_HEADER[] = { 0xff, 0xd8, 0xff, 0xe1 }; - const unsigned int EXIF_HEADER_LEN = sizeof(EXIF_HEADER); - const unsigned int JPEG_HEADER_OFFSET = 20; - class MetadataExtractor { - public: - MetadataExtractor(const std::string &path) - : m_Metadata() - { - if (FileUtils::isExists(path)) { - metadata_extractor_create(&m_Metadata); - if (metadata_extractor_set_path(m_Metadata, path.c_str()) != 0) { - metadata_extractor_destroy(m_Metadata); - m_Metadata = nullptr; - } - } - } - - ~MetadataExtractor() - { - if (m_Metadata) - metadata_extractor_destroy(m_Metadata); - } - - bool isValid() const - { - return m_Metadata != nullptr; - } - - int getInt(metadata_extractor_attr_e attr) const - { - std::string str = getStr(attr); - return str.empty() ? 0 : atoi(str.c_str()); - } - - int getBool(metadata_extractor_attr_e attr) const - { - std::string str = getStr(attr); - return str == "1"; - } - - std::string getStr(metadata_extractor_attr_e attr) const - { - std::string res; - char *cStr = nullptr; - metadata_extractor_get_metadata(m_Metadata, attr, &cStr); - if (cStr) { - res = cStr; - free(cStr); - } - return res; - } - - bool getFrame(void **frame, int *size) const - { - return metadata_extractor_get_frame(m_Metadata, frame, size) == 0; - } - - private: - metadata_extractor_h m_Metadata; - }; + const int QUALITY = 50; + const unsigned char EXIF_HEADER[] = { 0xff, 0xd8, 0xff, 0xe1 }; + const unsigned int EXIF_HEADER_LEN = sizeof(EXIF_HEADER); + const unsigned int JPEG_HEADER_OFFSET = 20; + class MetadataExtractor { + public: + MetadataExtractor(const std::string &path) + : m_Metadata() + { + if (FileUtils::isExists(path)) { + metadata_extractor_create(&m_Metadata); + if (metadata_extractor_set_path(m_Metadata, path.c_str()) != 0) { + metadata_extractor_destroy(m_Metadata); + m_Metadata = nullptr; + } + } + } + + ~MetadataExtractor() + { + if (m_Metadata) + metadata_extractor_destroy(m_Metadata); + } + + bool isValid() const + { + return m_Metadata != nullptr; + } + + int getInt(metadata_extractor_attr_e attr) const + { + std::string str = getStr(attr); + return str.empty() ? 0 : atoi(str.c_str()); + } + + int getBool(metadata_extractor_attr_e attr) const + { + std::string str = getStr(attr); + return str == "1"; + } + + std::string getStr(metadata_extractor_attr_e attr) const + { + std::string res; + char *cStr = nullptr; + metadata_extractor_get_metadata(m_Metadata, attr, &cStr); + if (cStr) { + res = cStr; + free(cStr); + } + return res; + } + + bool getFrame(void **frame, int *size) const + { + return metadata_extractor_get_frame(m_Metadata, frame, size) == 0; + } + + private: + metadata_extractor_h m_Metadata; + }; } std::string MediaUtils::getTitle(const std::string &path) { - std::string fileName = FileUtils::getFileName(path); + std::string fileName = FileUtils::getFileName(path); - MetadataExtractor extractor(path); - if (!extractor.isValid()) - return fileName; + MetadataExtractor extractor(path); + if (!extractor.isValid()) + return fileName; - std::string title = extractor.getStr(METADATA_TITLE); - return title.empty() ? fileName : title; + std::string title = extractor.getStr(METADATA_TITLE); + return title.empty() ? fileName : title; } int MediaUtils::getDuration(const std::string &uri) { - MetadataExtractor extractor(uri); - int duration = 0; - if (extractor.isValid()) { - duration = extractor.getInt(METADATA_DURATION); - MSG_LOG("Duration msec: ", duration); - } - return duration; + MetadataExtractor extractor(uri); + int duration = 0; + if (extractor.isValid()) { + duration = extractor.getInt(METADATA_DURATION); + MSG_LOG("Duration msec: ", duration); + } + return duration; } int MediaUtils::getDurationSec(const std::string &uri) { - double sec = ceil(getDuration(uri) / 1000.0); + double sec = ceil(getDuration(uri) / 1000.0); - MSG_LOG("File: ", uri); - MSG_LOG("Duration sec: ", sec); + MSG_LOG("File: ", uri); + MSG_LOG("Duration sec: ", sec); - if (sec < 0) - return 0; + if (sec < 0) + return 0; - return sec; + return sec; } bool MediaUtils::getVideoFrame(const std::string &videoFilePath, const std::string &imageFilePath) { - MetadataExtractor extractor(videoFilePath); - if (!extractor.isValid()) - return false; - - int videoW = extractor.getInt(METADATA_VIDEO_WIDTH); - int videoH = extractor.getInt(METADATA_VIDEO_HEIGHT); - - int thumbSize = 0; - void *thumbnail = nullptr; - extractor.getFrame(&thumbnail, &thumbSize); - - MSG_LOG("File: ", videoFilePath); - MSG_LOG("Frame: width = ", videoW, " height = ", videoH, " size = ", thumbSize); - - if (thumbnail) { - const int quality = 90; // JPEG image quality(1 ~ 100) - image_util_encode_h encode_h = {}; - bool isOk = false; - isOk = image_util_encode_create(IMAGE_UTIL_JPEG, &encode_h) == IMAGE_UTIL_ERROR_NONE; - if (!isOk) { - free(thumbnail); - return false; - } - - isOk &= image_util_encode_set_resolution(encode_h, videoW, videoH) == IMAGE_UTIL_ERROR_NONE; - isOk &= image_util_encode_set_colorspace(encode_h, IMAGE_UTIL_COLORSPACE_RGB888) == IMAGE_UTIL_ERROR_NONE; - isOk &= image_util_encode_set_quality(encode_h, quality) == IMAGE_UTIL_ERROR_NONE; - isOk &= image_util_encode_set_input_buffer(encode_h, (unsigned char *)thumbnail) == IMAGE_UTIL_ERROR_NONE; - isOk &= image_util_encode_set_output_path(encode_h, imageFilePath.c_str()) == IMAGE_UTIL_ERROR_NONE; - if (!isOk) { - image_util_encode_destroy(encode_h); - free(thumbnail); - return false; - } - - isOk = image_util_encode_run(encode_h, nullptr) == IMAGE_UTIL_ERROR_NONE; - image_util_encode_destroy(encode_h); - free(thumbnail); - return isOk; - } - return false; + MetadataExtractor extractor(videoFilePath); + if (!extractor.isValid()) + return false; + + int videoW = extractor.getInt(METADATA_VIDEO_WIDTH); + int videoH = extractor.getInt(METADATA_VIDEO_HEIGHT); + + int thumbSize = 0; + void *thumbnail = nullptr; + extractor.getFrame(&thumbnail, &thumbSize); + + MSG_LOG("File: ", videoFilePath); + MSG_LOG("Frame: width = ", videoW, " height = ", videoH, " size = ", thumbSize); + + if (thumbnail) { + const int quality = 90; // JPEG image quality(1 ~ 100) + image_util_encode_h encode_h = {}; + bool isOk = false; + isOk = image_util_encode_create(IMAGE_UTIL_JPEG, &encode_h) == IMAGE_UTIL_ERROR_NONE; + if (!isOk) { + free(thumbnail); + return false; + } + + isOk &= image_util_encode_set_resolution(encode_h, videoW, videoH) == IMAGE_UTIL_ERROR_NONE; + isOk &= image_util_encode_set_colorspace(encode_h, IMAGE_UTIL_COLORSPACE_RGB888) == IMAGE_UTIL_ERROR_NONE; + isOk &= image_util_encode_set_quality(encode_h, quality) == IMAGE_UTIL_ERROR_NONE; + isOk &= image_util_encode_set_input_buffer(encode_h, (unsigned char *)thumbnail) == IMAGE_UTIL_ERROR_NONE; + isOk &= image_util_encode_set_output_path(encode_h, imageFilePath.c_str()) == IMAGE_UTIL_ERROR_NONE; + if (!isOk) { + image_util_encode_destroy(encode_h); + free(thumbnail); + return false; + } + + isOk = image_util_encode_run(encode_h, nullptr) == IMAGE_UTIL_ERROR_NONE; + image_util_encode_destroy(encode_h); + free(thumbnail); + return isOk; + } + return false; } bool MediaUtils::getFrameSize(const std::string &videoFilePath, int &width, int &height) { - MetadataExtractor extractor(videoFilePath); - if (!extractor.isValid()) - return false; + MetadataExtractor extractor(videoFilePath); + if (!extractor.isValid()) + return false; - width = extractor.getInt(METADATA_VIDEO_WIDTH); - height = extractor.getInt(METADATA_VIDEO_HEIGHT); - int orient = extractor.getInt(METADATA_ROTATE); - if (orient == 90 || orient == 270) - std::swap(width, height); + width = extractor.getInt(METADATA_VIDEO_WIDTH); + height = extractor.getInt(METADATA_VIDEO_HEIGHT); + int orient = extractor.getInt(METADATA_ROTATE); + if (orient == 90 || orient == 270) + std::swap(width, height); - MSG_LOG("File: ", videoFilePath); - MSG_LOG("Frame: width = ", width, " height = ", height); + MSG_LOG("File: ", videoFilePath); + MSG_LOG("Frame: width = ", width, " height = ", height); - return true; + return true; } bool MediaUtils::hasAudio(const std::string &path) { - MetadataExtractor extractor(path); - if (!extractor.isValid()) - return false; + MetadataExtractor extractor(path); + if (!extractor.isValid()) + return false; - return extractor.getBool(METADATA_HAS_AUDIO); + return extractor.getBool(METADATA_HAS_AUDIO); } bool MediaUtils::hasVideo(const std::string &path) { - MetadataExtractor extractor(path); - if (!extractor.isValid()) - return false; + MetadataExtractor extractor(path); + if (!extractor.isValid()) + return false; - return extractor.getBool(METADATA_HAS_VIDEO); + return extractor.getBool(METADATA_HAS_VIDEO); } long long MediaUtils::downgradeImageQuality(const std::string &imagePath) { - image_util_decode_h decode_h = {}; - image_util_encode_h encode_h = {}; - unsigned char *buffer = nullptr; - unsigned long width = 0; - unsigned long height = 0; - int res = IMAGE_UTIL_ERROR_NONE; - ExifData *exifData = nullptr; - unsigned char *exifBuff = nullptr; - unsigned int exifBuffLen = 0; - unsigned char *jpegBuff = nullptr; - unsigned long long int jpegBuffLen = 0; - std::ofstream outputFile; - - exifData = exif_data_new_from_file(imagePath.c_str()); - if (exifData) - exif_data_save_data(exifData, &exifBuff, &exifBuffLen); - - res = image_util_decode_create(&decode_h); - if (res != IMAGE_UTIL_ERROR_NONE) - return FileUtils::getFileSize(imagePath); - - res = image_util_decode_set_input_path(decode_h, imagePath.c_str()); - if (res != IMAGE_UTIL_ERROR_NONE) { - image_util_decode_destroy(decode_h); - return FileUtils::getFileSize(imagePath); - } - - res = image_util_decode_set_output_buffer(decode_h, &buffer); - if (res != IMAGE_UTIL_ERROR_NONE) { - image_util_decode_destroy(decode_h); - return FileUtils::getFileSize(imagePath); - } - - res = image_util_decode_run(decode_h, &width, &height, nullptr); - image_util_decode_destroy(decode_h); - if (res != IMAGE_UTIL_ERROR_NONE) - return FileUtils::getFileSize(imagePath); - - res = image_util_encode_create(IMAGE_UTIL_JPEG, &encode_h); - if (res != IMAGE_UTIL_ERROR_NONE) - return FileUtils::getFileSize(imagePath); - - res = image_util_encode_set_resolution(encode_h, width, height); - if (res != IMAGE_UTIL_ERROR_NONE){ - image_util_encode_destroy(encode_h); - return FileUtils::getFileSize(imagePath); - } - - res = image_util_encode_set_quality(encode_h, QUALITY); - if (res != IMAGE_UTIL_ERROR_NONE) { - image_util_encode_destroy(encode_h); - return FileUtils::getFileSize(imagePath); - } - - res = image_util_encode_set_input_buffer(encode_h, buffer); - if (res != IMAGE_UTIL_ERROR_NONE) { - image_util_encode_destroy(encode_h); - return FileUtils::getFileSize(imagePath); - } - - res = image_util_encode_set_output_buffer(encode_h, &jpegBuff); - if (res != IMAGE_UTIL_ERROR_NONE) { - image_util_encode_destroy(encode_h); - return FileUtils::getFileSize(imagePath); - } - res = image_util_encode_run(encode_h, &jpegBuffLen); - image_util_encode_destroy(encode_h); - if (res != IMAGE_UTIL_ERROR_NONE) { - free(buffer); - free(jpegBuff); - return FileUtils::getFileSize(imagePath); - } - - outputFile.open(imagePath.c_str()); - if (!outputFile.is_open()) { - MSG_LOG_ERROR("Can't open file for write"); - free(buffer); - free(jpegBuff); - return FileUtils::getFileSize(imagePath); - } - if (exifData) { - // Write EXIF header - outputFile.write((char *)EXIF_HEADER, EXIF_HEADER_LEN); - // Write EXIF block length in big-endian order - outputFile.put((exifBuffLen+2) >> 8); - outputFile.put((exifBuffLen+2) & 0xff); - // Write EXIF data block - outputFile.write((char *)exifBuff, exifBuffLen); - // Write JPEG image data, skipping the non-EXIF header - outputFile.write((char *)jpegBuff + JPEG_HEADER_OFFSET, jpegBuffLen - JPEG_HEADER_OFFSET); - free(exifBuff); - exif_data_unref(exifData); - } else { - // Write JPEG image data - outputFile.write((char *)jpegBuff, jpegBuffLen); - } - outputFile.close(); - free(buffer); - free(jpegBuff); - - return FileUtils::getFileSize(imagePath); + image_util_decode_h decode_h = {}; + image_util_encode_h encode_h = {}; + unsigned char *buffer = nullptr; + unsigned long width = 0; + unsigned long height = 0; + int res = IMAGE_UTIL_ERROR_NONE; + ExifData *exifData = nullptr; + unsigned char *exifBuff = nullptr; + unsigned int exifBuffLen = 0; + unsigned char *jpegBuff = nullptr; + unsigned long long int jpegBuffLen = 0; + std::ofstream outputFile; + + exifData = exif_data_new_from_file(imagePath.c_str()); + if (exifData) + exif_data_save_data(exifData, &exifBuff, &exifBuffLen); + + res = image_util_decode_create(&decode_h); + if (res != IMAGE_UTIL_ERROR_NONE) + return FileUtils::getFileSize(imagePath); + + res = image_util_decode_set_input_path(decode_h, imagePath.c_str()); + if (res != IMAGE_UTIL_ERROR_NONE) { + image_util_decode_destroy(decode_h); + return FileUtils::getFileSize(imagePath); + } + + res = image_util_decode_set_output_buffer(decode_h, &buffer); + if (res != IMAGE_UTIL_ERROR_NONE) { + image_util_decode_destroy(decode_h); + return FileUtils::getFileSize(imagePath); + } + + res = image_util_decode_run(decode_h, &width, &height, nullptr); + image_util_decode_destroy(decode_h); + if (res != IMAGE_UTIL_ERROR_NONE) + return FileUtils::getFileSize(imagePath); + + res = image_util_encode_create(IMAGE_UTIL_JPEG, &encode_h); + if (res != IMAGE_UTIL_ERROR_NONE) + return FileUtils::getFileSize(imagePath); + + res = image_util_encode_set_resolution(encode_h, width, height); + if (res != IMAGE_UTIL_ERROR_NONE){ + image_util_encode_destroy(encode_h); + return FileUtils::getFileSize(imagePath); + } + + res = image_util_encode_set_quality(encode_h, QUALITY); + if (res != IMAGE_UTIL_ERROR_NONE) { + image_util_encode_destroy(encode_h); + return FileUtils::getFileSize(imagePath); + } + + res = image_util_encode_set_input_buffer(encode_h, buffer); + if (res != IMAGE_UTIL_ERROR_NONE) { + image_util_encode_destroy(encode_h); + return FileUtils::getFileSize(imagePath); + } + + res = image_util_encode_set_output_buffer(encode_h, &jpegBuff); + if (res != IMAGE_UTIL_ERROR_NONE) { + image_util_encode_destroy(encode_h); + return FileUtils::getFileSize(imagePath); + } + res = image_util_encode_run(encode_h, &jpegBuffLen); + image_util_encode_destroy(encode_h); + if (res != IMAGE_UTIL_ERROR_NONE) { + free(buffer); + free(jpegBuff); + return FileUtils::getFileSize(imagePath); + } + + outputFile.open(imagePath.c_str()); + if (!outputFile.is_open()) { + MSG_LOG_ERROR("Can't open file for write"); + free(buffer); + free(jpegBuff); + return FileUtils::getFileSize(imagePath); + } + if (exifData) { + // Write EXIF header + outputFile.write((char *)EXIF_HEADER, EXIF_HEADER_LEN); + // Write EXIF block length in big-endian order + outputFile.put((exifBuffLen+2) >> 8); + outputFile.put((exifBuffLen+2) & 0xff); + // Write EXIF data block + outputFile.write((char *)exifBuff, exifBuffLen); + // Write JPEG image data, skipping the non-EXIF header + outputFile.write((char *)jpegBuff + JPEG_HEADER_OFFSET, jpegBuffLen - JPEG_HEADER_OFFSET); + free(exifBuff); + exif_data_unref(exifData); + } else { + // Write JPEG image data + outputFile.write((char *)jpegBuff, jpegBuffLen); + } + outputFile.close(); + free(buffer); + free(jpegBuff); + + return FileUtils::getFileSize(imagePath); } diff --git a/src/Common/Utils/src/PathUtils.cpp b/src/Common/Utils/src/PathUtils.cpp index 024f6f78..f7833432 100644 --- a/src/Common/Utils/src/PathUtils.cpp +++ b/src/Common/Utils/src/PathUtils.cpp @@ -25,89 +25,89 @@ using namespace Msg; std::string PathUtils::getResourcePath(const std::string &filePath) { - std::string res; - static std::string basePath; - if (basePath.empty()) { - char *path = app_get_resource_path(); - if (path) { - basePath = path; - free(path); - } - } - - res += basePath; - res += filePath; - - return res; + std::string res; + static std::string basePath; + if (basePath.empty()) { + char *path = app_get_resource_path(); + if (path) { + basePath = path; + free(path); + } + } + + res += basePath; + res += filePath; + + return res; } std::string PathUtils::getDataPath(const std::string &filePath) { - std::string res; - static std::string basePath; - if (basePath.empty()) { - char *path = app_get_data_path(); - if (path) { - basePath = path; - free(path); - } - } - - res += basePath; - res += filePath; - - return res; + std::string res; + static std::string basePath; + if (basePath.empty()) { + char *path = app_get_data_path(); + if (path) { + basePath = path; + free(path); + } + } + + res += basePath; + res += filePath; + + return res; } std::string PathUtils::getResourcePath() { - std::string res; - char* resPath = app_get_resource_path(); - if (resPath) { - res = resPath; - free(resPath); - } - - return res; + std::string res; + char* resPath = app_get_resource_path(); + if (resPath) { + res = resPath; + free(resPath); + } + + return res; } std::string PathUtils::getLocalePath() { - std::string resPath(getResourcePath()); - if (!resPath.empty()) - resPath.append("locale"); + std::string resPath(getResourcePath()); + if (!resPath.empty()) + resPath.append("locale"); - return resPath; + return resPath; } static bool storageCb(int storageId, storage_type_e type, storage_state_e state, const char *path, void *userData) { - if (type == STORAGE_TYPE_INTERNAL) { - int *internalStorage = (int *)userData; - *internalStorage = storageId; - return false; - } - return true; + if (type == STORAGE_TYPE_INTERNAL) { + int *internalStorage = (int *)userData; + *internalStorage = storageId; + return false; + } + return true; } const std::string &PathUtils::getDownloadPath() { - static std::string downloadPath; + static std::string downloadPath; - if (!downloadPath.empty()) - return downloadPath; + if (!downloadPath.empty()) + return downloadPath; - char *dirPath = nullptr; - int storageId = -1; + char *dirPath = nullptr; + int storageId = -1; - int error = storage_foreach_device_supported(storageCb, &storageId); - if (error == STORAGE_ERROR_NONE) - storage_get_directory(storageId, STORAGE_DIRECTORY_DOWNLOADS, &dirPath); + int error = storage_foreach_device_supported(storageCb, &storageId); + if (error == STORAGE_ERROR_NONE) + storage_get_directory(storageId, STORAGE_DIRECTORY_DOWNLOADS, &dirPath); - if (dirPath) { - downloadPath = dirPath; - free(dirPath); - } + if (dirPath) { + downloadPath = dirPath; + free(dirPath); + } - return downloadPath; + return downloadPath; } diff --git a/src/Common/Utils/src/PhoneNumberUtils.cpp b/src/Common/Utils/src/PhoneNumberUtils.cpp index 5737ce16..15162ea4 100644 --- a/src/Common/Utils/src/PhoneNumberUtils.cpp +++ b/src/Common/Utils/src/PhoneNumberUtils.cpp @@ -24,29 +24,29 @@ using namespace Msg; PhoneNumberUtils &PhoneNumberUtils::getInst() { - static PhoneNumberUtils inst; - return inst; + static PhoneNumberUtils inst; + return inst; } std::string PhoneNumberUtils::getNormalizedNumber(const std::string &number) const { - std::string res; - char *normalizedNum = nullptr; - phone_number_get_normalized_number(number.c_str(), &normalizedNum); - if (normalizedNum) { - res = normalizedNum; - free(normalizedNum); - } - return res; + std::string res; + char *normalizedNum = nullptr; + phone_number_get_normalized_number(number.c_str(), &normalizedNum); + if (normalizedNum) { + res = normalizedNum; + free(normalizedNum); + } + return res; } PhoneNumberUtils::PhoneNumberUtils() { - int res = phone_number_connect(); - MSG_LOG("phone_number_connect = ", res); + int res = phone_number_connect(); + MSG_LOG("phone_number_connect = ", res); } PhoneNumberUtils::~PhoneNumberUtils() { - phone_number_disconnect(); + phone_number_disconnect(); } diff --git a/src/Common/Utils/src/TextDecorator.cpp b/src/Common/Utils/src/TextDecorator.cpp index 579df73e..b7551f5a 100644 --- a/src/Common/Utils/src/TextDecorator.cpp +++ b/src/Common/Utils/src/TextDecorator.cpp @@ -31,36 +31,36 @@ const int TextStyle::defaultFontSize = 28; #define CLOSE_TAG(name) "" namespace { - const char *alignAsString(TextAlign align) - { - switch (align) { - case TextAlign::Center: - return "center"; - case TextAlign::Left: - return "left"; - case TextAlign::Right: - return "right"; - case TextAlign::None: - default: - break; - } - - assert(false); - return ""; - } + const char *alignAsString(TextAlign align) + { + switch (align) { + case TextAlign::Center: + return "center"; + case TextAlign::Left: + return "left"; + case TextAlign::Right: + return "right"; + case TextAlign::None: + default: + break; + } + + assert(false); + return ""; + } } TextStyle::TextStyle() - : m_Color(defaultColor) - , m_Align(TextAlign::None) - , m_Size(defaultFontSize) + : m_Color(defaultColor) + , m_Align(TextAlign::None) + , m_Size(defaultFontSize) { } TextStyle::TextStyle(int size, const std::string &color, TextAlign align) - : m_Color(color) - , m_Align(align) - , m_Size(size) + : m_Color(color) + , m_Align(align) + , m_Size(size) { } @@ -70,99 +70,99 @@ TextStyle::~TextStyle() void TextStyle::setColor(const std::string &color) { - m_Color = color; + m_Color = color; } void TextStyle::setSize(int size) { - m_Size = size; + m_Size = size; } void TextStyle::setAlign(TextAlign align) { - m_Align = align; + m_Align = align; } const std::string &TextStyle::getColor() const { - return m_Color; + return m_Color; } int TextStyle::getSize() const { - return m_Size; + return m_Size; } TextAlign TextStyle::getAlign() const { - return m_Align; + return m_Align; } std::string TextDecorator::make(const std::string &text, const TextStyle &style) { - return make(text, style.getSize(), style.getColor(), style.getAlign()); + return make(text, style.getSize(), style.getColor(), style.getAlign()); } std::string TextDecorator::make(const std::string &text, const std::string &color) { - std::string res = OPEN_TAG_STR("color", color) + text + CLOSE_TAG("color"); - return res; + std::string res = OPEN_TAG_STR("color", color) + text + CLOSE_TAG("color"); + return res; } std::string TextDecorator::make(const std::string &text, - int size, - const std::string &color, - TextAlign align) + int size, + const std::string &color, + TextAlign align) { - std::ostringstream ss; - ss << OPEN_TAG("font_size", size) << OPEN_TAG("color", color); - if (align != TextAlign::None) - ss << OPEN_TAG("align", alignAsString(align)); + std::ostringstream ss; + ss << OPEN_TAG("font_size", size) << OPEN_TAG("color", color); + if (align != TextAlign::None) + ss << OPEN_TAG("align", alignAsString(align)); - ss << text; - if (align != TextAlign::None) - ss << CLOSE_TAG("align"); + ss << text; + if (align != TextAlign::None) + ss << CLOSE_TAG("align"); - ss << CLOSE_TAG("color") << CLOSE_TAG("font_size"); - return ss.str(); + ss << CLOSE_TAG("color") << CLOSE_TAG("font_size"); + return ss.str(); } std::string TextDecorator::makePlainText(const std::string &text) { - std::regex tags("<[^<]*>"); - std::string plainText; - std::regex_replace(std::back_inserter(plainText), text.begin(), text.end(), tags, ""); - return plainText; + std::regex tags("<[^<]*>"); + std::string plainText; + std::regex_replace(std::back_inserter(plainText), text.begin(), text.end(), tags, ""); + return plainText; } std::string TextDecorator::highlightKeyword(std::string str, const std::string &searchWord, bool *foundRes) { - if (foundRes) - *foundRes = false; + if (foundRes) + *foundRes = false; - if (str.empty() || searchWord.empty()) - return str; + if (str.empty() || searchWord.empty()) + return str; - char *found = strcasestr((char*)str.c_str(), (char*)searchWord.c_str()); - if (!found) - return str; + char *found = strcasestr((char*)str.c_str(), (char*)searchWord.c_str()); + if (!found) + return str; - if (foundRes) - *foundRes = true; + if (foundRes) + *foundRes = true; - std::string res; - res.reserve(str.length() + 32); // Reserve string length + highlight tags length + std::string res; + res.reserve(str.length() + 32); // Reserve string length + highlight tags length - int diff = found - str.c_str(); - std::string firstPart = std::string(str.begin(), str.begin() + diff); - std::string lastPart = std::string(str.begin() + diff + searchWord.length(), str.end()); + int diff = found - str.c_str(); + std::string firstPart = std::string(str.begin(), str.begin() + diff); + std::string lastPart = std::string(str.begin() + diff + searchWord.length(), str.end()); - res += firstPart; - res += ""; - res += std::string(found, searchWord.length()); - res += ""; - res += lastPart; + res += firstPart; + res += ""; + res += std::string(found, searchWord.length()); + res += ""; + res += lastPart; - return res; + return res; } diff --git a/src/Common/Utils/src/ThumbnailMaker.cpp b/src/Common/Utils/src/ThumbnailMaker.cpp index 8584f716..aa9109e2 100644 --- a/src/Common/Utils/src/ThumbnailMaker.cpp +++ b/src/Common/Utils/src/ThumbnailMaker.cpp @@ -28,202 +28,202 @@ const int defaultCache = 512; #define COLOR_BLUE 61, 185, 204, 255 #define RAND (rand() % 220) #define COLOR_RAND RAND, RAND, RAND, 255 -#define MSG_THUMB_STYLE_LIST "list_ic_user_thumb_masking" +#define MSG_THUMB_STYLE_LIST "list_ic_user_thumb_masking" ThumbnailMaker::ThumbnailMaker(App &app) - : m_App(app) - , m_ContactsMap() - , m_OriginsMap() - , m_CurrentId(-1) + : m_App(app) + , m_ContactsMap() + , m_OriginsMap() + , m_CurrentId(-1) { - m_App.getContactManager().addListener(*this); - m_ContactsMap.reserve(defaultCache); - m_OriginsMap.reserve(defaultCache); + m_App.getContactManager().addListener(*this); + m_ContactsMap.reserve(defaultCache); + m_OriginsMap.reserve(defaultCache); - for (int i = 0; i <= maxStaticThumbId; i++) - getThumbId((DefaultThumbs)i); + for (int i = 0; i <= maxStaticThumbId; i++) + getThumbId((DefaultThumbs)i); } ThumbnailMaker::~ThumbnailMaker() { - m_App.getContactManager().removeListener(*this); + m_App.getContactManager().removeListener(*this); } ThumbId ThumbnailMaker::getThumbId(const MsgAddress &address) { - return getThumbId(address.getAddress()); + return getThumbId(address.getAddress()); } ThumbId ThumbnailMaker::getThumbId(const std::string &address) { - ContactAddressRef contact = m_App.getContactManager().getContactAddress(address); - return contact ? getThumbIdFromFile(contact->getThumbnailPath()) : getThumbId(SingleThumb); + ContactAddressRef contact = m_App.getContactManager().getContactAddress(address); + return contact ? getThumbIdFromFile(contact->getThumbnailPath()) : getThumbId(SingleThumb); } ThumbId ThumbnailMaker::getThumbIdFromFile(const std::string &path) { - if (path.empty()) { - return getThumbId(SingleThumb); - } else { - auto it = m_ContactsMap.find(path); - if (it != m_ContactsMap.end()) - return it->second; + if (path.empty()) { + return getThumbId(SingleThumb); + } else { + auto it = m_ContactsMap.find(path); + if (it != m_ContactsMap.end()) + return it->second; - Evas_Object *origin = makeOriginThumb(m_App.getWindow(), path); - m_OriginsMap[++m_CurrentId] = origin; - m_ContactsMap[path] = m_CurrentId; - return m_CurrentId; - } + Evas_Object *origin = makeOriginThumb(m_App.getWindow(), path); + m_OriginsMap[++m_CurrentId] = origin; + m_ContactsMap[path] = m_CurrentId; + return m_CurrentId; + } } ThumbId ThumbnailMaker::getThumbId(DefaultThumbs thumb) { - auto it = m_ContactsMap.find(defaultThumbsToStr(thumb)); - if (it != m_ContactsMap.end()) { - return it->second; - } else { - Evas_Object *origin = nullptr; - if (thumb != OwnerThumb) { - origin = makeDefaultOriginThumb(m_App.getWindow(), defaultThumbsToPath(thumb)); - } else { - ContactMyProfileRef ownerProfile = m_App.getContactManager().getOwnerProfile(); - origin = ownerProfile ? makeOriginThumb(m_App.getWindow(), ownerProfile->getThumbnailPath()) : - makeDefaultOriginThumb(m_App.getWindow(), defaultThumbsToPath(SingleThumb)); - } - m_OriginsMap[++m_CurrentId] = origin; - m_ContactsMap[defaultThumbsToStr(thumb)] = m_CurrentId; - return m_CurrentId; - } + auto it = m_ContactsMap.find(defaultThumbsToStr(thumb)); + if (it != m_ContactsMap.end()) { + return it->second; + } else { + Evas_Object *origin = nullptr; + if (thumb != OwnerThumb) { + origin = makeDefaultOriginThumb(m_App.getWindow(), defaultThumbsToPath(thumb)); + } else { + ContactMyProfileRef ownerProfile = m_App.getContactManager().getOwnerProfile(); + origin = ownerProfile ? makeOriginThumb(m_App.getWindow(), ownerProfile->getThumbnailPath()) : + makeDefaultOriginThumb(m_App.getWindow(), defaultThumbsToPath(SingleThumb)); + } + m_OriginsMap[++m_CurrentId] = origin; + m_ContactsMap[defaultThumbsToStr(thumb)] = m_CurrentId; + return m_CurrentId; + } } Evas_Object *ThumbnailMaker::getThumb(Evas_Object *parent, ThumbId id, int thumbSize) { - auto it = m_OriginsMap.find(id); - if (it == m_OriginsMap.end()) { - MSG_LOG_ERROR("Invalid thumbnail id"); - return nullptr; - } + auto it = m_OriginsMap.find(id); + if (it == m_OriginsMap.end()) { + MSG_LOG_ERROR("Invalid thumbnail id"); + return nullptr; + } - Evas_Object *origin = it->second; - Evas_Object *ic = evas_object_image_filled_add(evas_object_evas_get(parent)); - evas_object_image_source_set(ic, origin); - int scaledThumbSize = ELM_SCALE_SIZE(thumbSize); - evas_object_size_hint_min_set(ic, scaledThumbSize, scaledThumbSize); - evas_object_size_hint_max_set(ic, scaledThumbSize, scaledThumbSize); - View::expand(ic); - evas_object_show(ic); - return ic; + Evas_Object *origin = it->second; + Evas_Object *ic = evas_object_image_filled_add(evas_object_evas_get(parent)); + evas_object_image_source_set(ic, origin); + int scaledThumbSize = ELM_SCALE_SIZE(thumbSize); + evas_object_size_hint_min_set(ic, scaledThumbSize, scaledThumbSize); + evas_object_size_hint_max_set(ic, scaledThumbSize, scaledThumbSize); + View::expand(ic); + evas_object_show(ic); + return ic; } Evas_Object *ThumbnailMaker::getThumb(Evas_Object *parent, const std::string &path, int thumbSize) { - int scaledThumbSize = ELM_SCALE_SIZE(thumbSize); + int scaledThumbSize = ELM_SCALE_SIZE(thumbSize); - Evas_Object *ic = makeMask(parent, scaledThumbSize); - Evas_Object *img = makeImage(ic, path, scaledThumbSize); - elm_object_part_content_set(ic, "content", img); - return ic; + Evas_Object *ic = makeMask(parent, scaledThumbSize); + Evas_Object *img = makeImage(ic, path, scaledThumbSize); + elm_object_part_content_set(ic, "content", img); + return ic; } Evas_Object *ThumbnailMaker::makeOriginThumb(Evas_Object *parent, const std::string &path) { - Evas_Object *ic = makeMask(parent, DEFAULT_THUMB_SIZE); - Evas_Object *img = makeImage(ic, path, DEFAULT_THUMB_SIZE); - elm_object_part_content_set(ic, "content", img); - evas_object_move(ic, -DEFAULT_THUMB_SIZE, -DEFAULT_THUMB_SIZE); - return ic; + Evas_Object *ic = makeMask(parent, DEFAULT_THUMB_SIZE); + Evas_Object *img = makeImage(ic, path, DEFAULT_THUMB_SIZE); + elm_object_part_content_set(ic, "content", img); + evas_object_move(ic, -DEFAULT_THUMB_SIZE, -DEFAULT_THUMB_SIZE); + return ic; } Evas_Object *ThumbnailMaker::makeDefaultOriginThumb(Evas_Object *parent, const std::string &path) { - Evas_Object *img = makeImage(parent, path, DEFAULT_THUMB_SIZE); - evas_object_color_set(img, COLOR_BLUE); - evas_object_resize(img, DEFAULT_THUMB_SIZE, DEFAULT_THUMB_SIZE); - evas_object_move(img, -DEFAULT_THUMB_SIZE, -DEFAULT_THUMB_SIZE); - evas_object_show(img); - return img; + Evas_Object *img = makeImage(parent, path, DEFAULT_THUMB_SIZE); + evas_object_color_set(img, COLOR_BLUE); + evas_object_resize(img, DEFAULT_THUMB_SIZE, DEFAULT_THUMB_SIZE); + evas_object_move(img, -DEFAULT_THUMB_SIZE, -DEFAULT_THUMB_SIZE); + evas_object_show(img); + return img; } Evas_Object *ThumbnailMaker::makeImage(Evas_Object *parent, const std::string &path, int size) { - Evas_Object *img = elm_image_add(parent); - elm_image_file_set(img, path.c_str(), nullptr); - evas_object_size_hint_min_set(img, size, size); - evas_object_size_hint_max_set(img, size, size); - elm_image_aspect_fixed_set(img, true); - elm_image_fill_outside_set(img, true); - return img; + Evas_Object *img = elm_image_add(parent); + elm_image_file_set(img, path.c_str(), nullptr); + evas_object_size_hint_min_set(img, size, size); + evas_object_size_hint_max_set(img, size, size); + elm_image_aspect_fixed_set(img, true); + elm_image_fill_outside_set(img, true); + return img; } Evas_Object *ThumbnailMaker::makeMask(Evas_Object *parent, int size) { - Evas_Object *ic = elm_layout_add(parent); - static std::string edjePath = PathUtils::getResourcePath(THUMBNAIL_EDJ_PATH); - elm_layout_file_set(ic, edjePath.c_str(), MSG_THUMB_STYLE_LIST); - evas_object_resize(ic, size, size); - evas_object_show(ic); - return ic; + Evas_Object *ic = elm_layout_add(parent); + static std::string edjePath = PathUtils::getResourcePath(THUMBNAIL_EDJ_PATH); + elm_layout_file_set(ic, edjePath.c_str(), MSG_THUMB_STYLE_LIST); + evas_object_resize(ic, size, size); + evas_object_show(ic); + return ic; } void ThumbnailMaker::invalidate() { - MSG_LOG(""); + MSG_LOG(""); - // m_OriginsMap: - auto originsIt = m_OriginsMap.begin(); + // m_OriginsMap: + auto originsIt = m_OriginsMap.begin(); - for (; originsIt != m_OriginsMap.end();) { - if (originsIt->first > maxStaticThumbId) { - MSG_LOG(originsIt->first); - evas_object_del(originsIt->second); - originsIt = m_OriginsMap.erase(originsIt); - } else { - ++originsIt; - } - } + for (; originsIt != m_OriginsMap.end();) { + if (originsIt->first > maxStaticThumbId) { + MSG_LOG(originsIt->first); + evas_object_del(originsIt->second); + originsIt = m_OriginsMap.erase(originsIt); + } else { + ++originsIt; + } + } - // m_ContactsMap: - auto contactsIt = m_ContactsMap.begin(); - for (; contactsIt != m_ContactsMap.end();) { - if (contactsIt->second > maxStaticThumbId) - contactsIt = m_ContactsMap.erase(contactsIt); - else - ++contactsIt; - } + // m_ContactsMap: + auto contactsIt = m_ContactsMap.begin(); + for (; contactsIt != m_ContactsMap.end();) { + if (contactsIt->second > maxStaticThumbId) + contactsIt = m_ContactsMap.erase(contactsIt); + else + ++contactsIt; + } } const std::string &ThumbnailMaker::defaultThumbsToStr(DefaultThumbs thumb) { - static const std::string sThumb = "SingleThumb"; - static const std::string gThumb = "GroupThumb"; - static const std::string oThumb = "OwnerThumb"; - static const std::string emptyThumb = ""; - switch (thumb) { - case SingleThumb: - return sThumb; - case GroupThumb: - return gThumb; - case OwnerThumb: - return oThumb; - default : - return emptyThumb; - } + static const std::string sThumb = "SingleThumb"; + static const std::string gThumb = "GroupThumb"; + static const std::string oThumb = "OwnerThumb"; + static const std::string emptyThumb = ""; + switch (thumb) { + case SingleThumb: + return sThumb; + case GroupThumb: + return gThumb; + case OwnerThumb: + return oThumb; + default : + return emptyThumb; + } } std::string ThumbnailMaker::defaultThumbsToPath(DefaultThumbs thumb) { - switch (thumb) { - case SingleThumb: - return PathUtils::getResourcePath(THUMB_CONTACT_IMG_PATH); - case GroupThumb: - return PathUtils::getResourcePath(THUMB_GROUP_IMG_PATH); - default : - return ""; - } + switch (thumb) { + case SingleThumb: + return PathUtils::getResourcePath(THUMB_CONTACT_IMG_PATH); + case GroupThumb: + return PathUtils::getResourcePath(THUMB_GROUP_IMG_PATH); + default : + return ""; + } } void ThumbnailMaker::onContactChanged() { - invalidate(); + invalidate(); } diff --git a/src/Common/Utils/src/TimeUtils.cpp b/src/Common/Utils/src/TimeUtils.cpp index 4f3042f0..ab60daf8 100644 --- a/src/Common/Utils/src/TimeUtils.cpp +++ b/src/Common/Utils/src/TimeUtils.cpp @@ -24,242 +24,242 @@ using namespace Msg; namespace { - const int maxUcharLen = 64; - const int maxCharLen = 128; - const int defBufLen = 512; - const std::string time12H = "hma"; - const std::string time24H = "Hm"; - const std::string dateDefault = "EEEMMMdd"; - const std::string dateYear = "EEEMMMddyyyy"; - const std::string dateListDefault = "MMdd"; - const std::string dateListYear = "MMddyyyy"; - const std::string dateTimeSceleton = "MM/dd/yyyy"; //readReport has the same format as Send Received time - const std::string delivReportSms24H = "MMM/dd/yyyy HHmm"; //SMS Delivery report 24H format - const std::string delivReportSms12H = "MMM/dd/yyyy hma"; //SMS Delivery report 12H format - const std::string delivReportMms24H = "HH:mm, d MMM"; //MMS Delivery report 24H format - const std::string delivReportMms12H = "hh:mm a, d MMM"; //MMS Delivery report 12H format + const int maxUcharLen = 64; + const int maxCharLen = 128; + const int defBufLen = 512; + const std::string time12H = "hma"; + const std::string time24H = "Hm"; + const std::string dateDefault = "EEEMMMdd"; + const std::string dateYear = "EEEMMMddyyyy"; + const std::string dateListDefault = "MMdd"; + const std::string dateListYear = "MMddyyyy"; + const std::string dateTimeSceleton = "MM/dd/yyyy"; //readReport has the same format as Send Received time + const std::string delivReportSms24H = "MMM/dd/yyyy HHmm"; //SMS Delivery report 24H format + const std::string delivReportSms12H = "MMM/dd/yyyy hma"; //SMS Delivery report 12H format + const std::string delivReportMms24H = "HH:mm, d MMM"; //MMS Delivery report 24H format + const std::string delivReportMms12H = "hh:mm a, d MMM"; //MMS Delivery report 12H format } std::string TimeUtils::makeThreadTimeString(time_t msgTime) { - tm msgTimeTm = {}; - tm curTimeTm = {}; - const std::string &locale = getDefaultLocale(); + tm msgTimeTm = {}; + tm curTimeTm = {}; + const std::string &locale = getDefaultLocale(); - time_t curTime = time(nullptr); + time_t curTime = time(nullptr); - localtime_r(&msgTime, &msgTimeTm); - localtime_r(&curTime, &curTimeTm); + localtime_r(&msgTime, &msgTimeTm); + localtime_r(&curTime, &curTimeTm); - int msgDay = (msgTimeTm.tm_year - 1900) * 365 + msgTimeTm.tm_yday + (msgTimeTm.tm_year - 1900 - 1) / 4; - int curDay = (curTimeTm.tm_year - 1900) * 365 + curTimeTm.tm_yday + (curTimeTm.tm_year - 1900 - 1) / 4; + int msgDay = (msgTimeTm.tm_year - 1900) * 365 + msgTimeTm.tm_yday + (msgTimeTm.tm_year - 1900 - 1) / 4; + int curDay = (curTimeTm.tm_year - 1900) * 365 + curTimeTm.tm_yday + (curTimeTm.tm_year - 1900 - 1) / 4; - bool isToday = (curDay - msgDay == 0); + bool isToday = (curDay - msgDay == 0); - if (isToday) { - const std::string &timeFormat = getTimeFormat() == TimeFormat24H ? time24H : time12H; - return getFormattedDate(locale, getDateBestPattern(locale, timeFormat), msgTime); - } else { - bool notThisYear = (msgTimeTm.tm_year - curTimeTm.tm_year != 0); - const std::string &date = notThisYear ? dateListYear : dateListDefault; - return getFormattedDate(locale, getDateBestPattern(locale, date), msgTime); - } + if (isToday) { + const std::string &timeFormat = getTimeFormat() == TimeFormat24H ? time24H : time12H; + return getFormattedDate(locale, getDateBestPattern(locale, timeFormat), msgTime); + } else { + bool notThisYear = (msgTimeTm.tm_year - curTimeTm.tm_year != 0); + const std::string &date = notThisYear ? dateListYear : dateListDefault; + return getFormattedDate(locale, getDateBestPattern(locale, date), msgTime); + } } std::string TimeUtils::makeBubbleTimeString(time_t msgTime) { - const std::string &locale = getDefaultLocale(); - const std::string &timeFormat = getTimeFormat() == TimeFormat24H ? time24H : time12H; - return getFormattedDate(locale, getDateBestPattern(locale, timeFormat), msgTime); + const std::string &locale = getDefaultLocale(); + const std::string &timeFormat = getTimeFormat() == TimeFormat24H ? time24H : time12H; + return getFormattedDate(locale, getDateBestPattern(locale, timeFormat), msgTime); } std::string TimeUtils::makeBubbleDateLineString(time_t msgTime) { - const std::string &locale = getDefaultLocale(); - return getFormattedDate(locale, getDateBestPattern(locale, dateYear), msgTime); + const std::string &locale = getDefaultLocale(); + return getFormattedDate(locale, getDateBestPattern(locale, dateYear), msgTime); } std::string TimeUtils::makeDateString(time_t msgTime) { - const std::string &locale = getDefaultLocale(); - return getFormattedDate(locale, getDateBestPattern(locale, dateTimeSceleton), msgTime); + const std::string &locale = getDefaultLocale(); + return getFormattedDate(locale, getDateBestPattern(locale, dateTimeSceleton), msgTime); } std::string TimeUtils::makeDateTimeString(time_t msgTime) //the same for Sim Message List { - const std::string &locale = getDefaultLocale(); - std::string res = getFormattedDate(locale, getDateBestPattern(locale, dateTimeSceleton), msgTime); + const std::string &locale = getDefaultLocale(); + std::string res = getFormattedDate(locale, getDateBestPattern(locale, dateTimeSceleton), msgTime); - res.append(" "); - const std::string &timeFormat = getTimeFormat() == TimeFormat24H ? time24H : time12H; - res += getFormattedDate(locale, getDateBestPattern(locale, timeFormat), msgTime); + res.append(" "); + const std::string &timeFormat = getTimeFormat() == TimeFormat24H ? time24H : time12H; + res += getFormattedDate(locale, getDateBestPattern(locale, timeFormat), msgTime); - return res; + return res; } std::string TimeUtils::makeSmsReportTimeString(time_t msgTime) { - const std::string &locale = getDefaultLocale(); - const std::string &timeFormat = getTimeFormat() == TimeFormat24H ? delivReportSms24H : delivReportSms12H; - return getFormattedDate(locale, getDateBestPattern(locale, timeFormat), msgTime); + const std::string &locale = getDefaultLocale(); + const std::string &timeFormat = getTimeFormat() == TimeFormat24H ? delivReportSms24H : delivReportSms12H; + return getFormattedDate(locale, getDateBestPattern(locale, timeFormat), msgTime); } std::string TimeUtils::makeMmsReportTimeString(time_t msgTime) { - const std::string &locale = getDefaultLocale(); - const std::string &timeFormat = getTimeFormat() == TimeFormat24H ? delivReportMms24H : delivReportMms12H; - return getFormattedDate(locale, getDateBestPattern(locale, timeFormat), msgTime); + const std::string &locale = getDefaultLocale(); + const std::string &timeFormat = getTimeFormat() == TimeFormat24H ? delivReportMms24H : delivReportMms12H; + return getFormattedDate(locale, getDateBestPattern(locale, timeFormat), msgTime); } std::string TimeUtils::makeCalEventString(time_t time) { - const std::string &locale = getDefaultLocale(); - return getFormattedDate(locale, getDateBestPattern(locale, dateYear), time); + const std::string &locale = getDefaultLocale(); + return getFormattedDate(locale, getDateBestPattern(locale, dateYear), time); } std::string TimeUtils::makeCalEventString(int year, int month, int mday, int hour, int min, const char *timezone) { - struct tm time = {}; - time.tm_year = year - 1900; - time.tm_mon = month - 1; - time.tm_mday = mday; - time.tm_hour = hour; - time.tm_min = min; - const std::string &locale = getDefaultLocale(); - return getFormattedDate(locale, getDateBestPattern(locale, dateYear), mktime(&time), timezone); + struct tm time = {}; + time.tm_year = year - 1900; + time.tm_mon = month - 1; + time.tm_mday = mday; + time.tm_hour = hour; + time.tm_min = min; + const std::string &locale = getDefaultLocale(); + return getFormattedDate(locale, getDateBestPattern(locale, dateYear), mktime(&time), timezone); } int TimeUtils::getTimeFormat() { - bool timeFormat = false; - if (system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, &timeFormat) < 0) - return TimeFormatUnknown; - return timeFormat ? TimeFormat24H : TimeFormat12H; + bool timeFormat = false; + if (system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, &timeFormat) < 0) + return TimeFormatUnknown; + return timeFormat ? TimeFormat24H : TimeFormat12H; } const std::string &TimeUtils::getDefaultLocale() { - static std::string res; - - char *str = nullptr; - system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &str); - - if (str) { - i18n_ulocale_set_default(str); - res = str; - size_t i = res.find("."); - if (i != std::string::npos) - res = res.substr(i); - - free(str); - } else { - res.clear(); - } - return res; + static std::string res; + + char *str = nullptr; + system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &str); + + if (str) { + i18n_ulocale_set_default(str); + res = str; + size_t i = res.find("."); + if (i != std::string::npos) + res = res.substr(i); + + free(str); + } else { + res.clear(); + } + return res; } std::string TimeUtils::getTimezone() { - char buf[defBufLen] = {}; - ssize_t len = readlink("/opt/etc/localtime", buf, sizeof(buf) - 1); - int filePathLength = 20; + char buf[defBufLen] = {}; + ssize_t len = readlink("/opt/etc/localtime", buf, sizeof(buf) - 1); + int filePathLength = 20; - if (len != -1) { - buf[len] = '\0'; - } else { - MSG_LOG_ERROR("Getting default timezone failed, use system settings value"); + if (len != -1) { + buf[len] = '\0'; + } else { + MSG_LOG_ERROR("Getting default timezone failed, use system settings value"); - std::string res; - char *time_zone = nullptr; + std::string res; + char *time_zone = nullptr; - system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, &time_zone); - if (time_zone) { - res = time_zone; - free(time_zone); - } + system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, &time_zone); + if (time_zone) { + res = time_zone; + free(time_zone); + } - return res; - } + return res; + } - return buf + filePathLength; + return buf + filePathLength; } std::string TimeUtils::getDateBestPattern(const std::string &locale, const std::string &skeleton) { - i18n_udatepg_h generator = nullptr; - i18n_uchar bestPattern[maxUcharLen] = {}; - char bestPatternString[maxCharLen] = {}; - int32_t bestPatternCapacity = maxUcharLen; - int bestPatternLen = 0; - i18n_uchar customSkeleton[maxUcharLen] = {}; - int skeletonLength = 0; - - skeletonLength = skeleton.length(); - /* convert char to uchar */ - if (skeletonLength <= maxUcharLen) - i18n_ustring_copy_ua_n(customSkeleton, skeleton.c_str(), skeletonLength); - else - i18n_ustring_copy_ua_n(customSkeleton, skeleton.c_str(), maxUcharLen); - - i18n_udatepg_create(locale.c_str(), &generator); - - /* get bestpattern from customskeletom of uchar */ - skeletonLength = i18n_ustring_get_length(customSkeleton); - i18n_udatepg_get_best_pattern(generator, customSkeleton, skeletonLength, bestPattern, bestPatternCapacity, &bestPatternLen); - /* convert uchar to char to know bestPattern */ - i18n_ustring_copy_au(bestPatternString, bestPattern); - - i18n_udatepg_destroy(generator); - - return bestPatternString; + i18n_udatepg_h generator = nullptr; + i18n_uchar bestPattern[maxUcharLen] = {}; + char bestPatternString[maxCharLen] = {}; + int32_t bestPatternCapacity = maxUcharLen; + int bestPatternLen = 0; + i18n_uchar customSkeleton[maxUcharLen] = {}; + int skeletonLength = 0; + + skeletonLength = skeleton.length(); + /* convert char to uchar */ + if (skeletonLength <= maxUcharLen) + i18n_ustring_copy_ua_n(customSkeleton, skeleton.c_str(), skeletonLength); + else + i18n_ustring_copy_ua_n(customSkeleton, skeleton.c_str(), maxUcharLen); + + i18n_udatepg_create(locale.c_str(), &generator); + + /* get bestpattern from customskeletom of uchar */ + skeletonLength = i18n_ustring_get_length(customSkeleton); + i18n_udatepg_get_best_pattern(generator, customSkeleton, skeletonLength, bestPattern, bestPatternCapacity, &bestPatternLen); + /* convert uchar to char to know bestPattern */ + i18n_ustring_copy_au(bestPatternString, bestPattern); + + i18n_udatepg_destroy(generator); + + return bestPatternString; } std::string TimeUtils::getFormattedDate(const std::string &locale, const std::string &bestPattern, time_t time, const char *timezone) { - int status = I18N_ERROR_NONE; - i18n_udate date; - i18n_udate_format_h dateFormat = nullptr; - i18n_uchar utimezoneId[defBufLen] = {}; - i18n_uchar uBestPattern[maxUcharLen] = {}; - i18n_uchar formatted[maxUcharLen] = {}; - char formattedString[maxCharLen] = {}; - int32_t formattedCapacity = maxUcharLen; - int formattedLength = 0; - int patternLength = bestPattern.length(); - - /* convert char to uchar */ - if (patternLength <= maxUcharLen) - i18n_ustring_copy_ua_n(uBestPattern, bestPattern.c_str(), patternLength); - else - i18n_ustring_copy_ua_n(uBestPattern, bestPattern.c_str(), maxUcharLen); - - /* get current timezone and set as default timezone */ - i18n_ustring_copy_ua(utimezoneId, timezone ? timezone : getTimezone().c_str()); - - status = i18n_ucalendar_set_default_timezone(utimezoneId); - if (status != I18N_ERROR_NONE) - MSG_LOG_ERROR("default timezone set error"); - - /* convert time_t to UDate, if it is */ - if (time) - date = (i18n_udate)time * 1000; - else - i18n_ucalendar_get_now(&date); - - dateFormat = getDateFormat(locale, uBestPattern, &status); - if (status == I18N_ERROR_NONE) { - /* get formatted string */ - i18n_udate_format_date(dateFormat, date, formatted, formattedCapacity, nullptr, &formattedLength); - /* convert uchar to char */ - i18n_ustring_copy_au(formattedString, formatted); - } - - return formattedString; + int status = I18N_ERROR_NONE; + i18n_udate date; + i18n_udate_format_h dateFormat = nullptr; + i18n_uchar utimezoneId[defBufLen] = {}; + i18n_uchar uBestPattern[maxUcharLen] = {}; + i18n_uchar formatted[maxUcharLen] = {}; + char formattedString[maxCharLen] = {}; + int32_t formattedCapacity = maxUcharLen; + int formattedLength = 0; + int patternLength = bestPattern.length(); + + /* convert char to uchar */ + if (patternLength <= maxUcharLen) + i18n_ustring_copy_ua_n(uBestPattern, bestPattern.c_str(), patternLength); + else + i18n_ustring_copy_ua_n(uBestPattern, bestPattern.c_str(), maxUcharLen); + + /* get current timezone and set as default timezone */ + i18n_ustring_copy_ua(utimezoneId, timezone ? timezone : getTimezone().c_str()); + + status = i18n_ucalendar_set_default_timezone(utimezoneId); + if (status != I18N_ERROR_NONE) + MSG_LOG_ERROR("default timezone set error"); + + /* convert time_t to UDate, if it is */ + if (time) + date = (i18n_udate)time * 1000; + else + i18n_ucalendar_get_now(&date); + + dateFormat = getDateFormat(locale, uBestPattern, &status); + if (status == I18N_ERROR_NONE) { + /* get formatted string */ + i18n_udate_format_date(dateFormat, date, formatted, formattedCapacity, nullptr, &formattedLength); + /* convert uchar to char */ + i18n_ustring_copy_au(formattedString, formatted); + } + + return formattedString; } i18n_udate_format_h TimeUtils::getDateFormat(const std::string &locale, const i18n_uchar *pattern, int *status) { - i18n_udate_format_h dateFormat = nullptr; - *status = i18n_udate_create(I18N_UDATE_PATTERN, I18N_UDATE_PATTERN, locale.c_str(), nullptr, -1, pattern, -1, &dateFormat); - return dateFormat; + i18n_udate_format_h dateFormat = nullptr; + *status = i18n_udate_create(I18N_UDATE_PATTERN, I18N_UDATE_PATTERN, locale.c_str(), nullptr, -1, pattern, -1, &dateFormat); + return dateFormat; } diff --git a/src/Common/Utils/src/VCalendarParser.cpp b/src/Common/Utils/src/VCalendarParser.cpp index b40cbaf7..f10d8bbb 100644 --- a/src/Common/Utils/src/VCalendarParser.cpp +++ b/src/Common/Utils/src/VCalendarParser.cpp @@ -25,85 +25,85 @@ using namespace Msg; CalendarEvent::CalendarEvent(calendar_record_h record) { - char *summary = nullptr; - calendar_record_get_str_p(record, _calendar_event.summary, &summary); - if (summary) - m_Summary = summary; - - calendar_time_s start = {}; - if (calendar_record_get_caltime(record, _calendar_event.start_time, &start) == 0) { - if (start.type == CALENDAR_TIME_UTIME) { // Unix time - m_StartDate = TimeUtils::makeCalEventString(start.time.utime); - } else { // Local time - m_StartDate = TimeUtils::makeCalEventString - ( - start.time.date.year, - start.time.date.month, - start.time.date.mday, - start.time.date.hour, - start.time.date.minute, - nullptr); - } - } + char *summary = nullptr; + calendar_record_get_str_p(record, _calendar_event.summary, &summary); + if (summary) + m_Summary = summary; + + calendar_time_s start = {}; + if (calendar_record_get_caltime(record, _calendar_event.start_time, &start) == 0) { + if (start.type == CALENDAR_TIME_UTIME) { // Unix time + m_StartDate = TimeUtils::makeCalEventString(start.time.utime); + } else { // Local time + m_StartDate = TimeUtils::makeCalEventString + ( + start.time.date.year, + start.time.date.month, + start.time.date.mday, + start.time.date.hour, + start.time.date.minute, + nullptr); + } + } } const std::string &CalendarEvent::getSummary() const { - return m_Summary; + return m_Summary; } const std::string &CalendarEvent::getStartDate() const { - return m_StartDate; + return m_StartDate; } VCalendarParser::VCalendarParser() { - calendar_connect(); + calendar_connect(); } VCalendarParser::~VCalendarParser() { - calendar_disconnect(); + calendar_disconnect(); } VCalendarParser &VCalendarParser::getInst() { - static VCalendarParser inst; - return inst; + static VCalendarParser inst; + return inst; } std::list VCalendarParser::parse(const std::string &filePath) { - if (filePath.empty()) - return {}; - - std::list list; - std::string text = FileUtils::readTextFile(filePath); - - calendar_list_h records = nullptr; - int parseRes = calendar_vcalendar_parse_to_calendar(text.c_str(), &records); - MSG_LOG("Parse results: ", parseRes); - - int count = 0; - calendar_list_get_count(records, &count); - calendar_list_first(records); - - for (int i = 0; i < count; ++i) { - calendar_record_h record = nullptr; - calendar_list_get_current_record_p(records, &record); - if (record) { - char *viewUri = nullptr; - calendar_record_get_uri_p(record, &viewUri); - if (viewUri && !strcmp(viewUri, _calendar_event._uri)) - list.emplace_back(record); - } - } - - if (records) - calendar_list_destroy(records, true); - - return list; + if (filePath.empty()) + return {}; + + std::list list; + std::string text = FileUtils::readTextFile(filePath); + + calendar_list_h records = nullptr; + int parseRes = calendar_vcalendar_parse_to_calendar(text.c_str(), &records); + MSG_LOG("Parse results: ", parseRes); + + int count = 0; + calendar_list_get_count(records, &count); + calendar_list_first(records); + + for (int i = 0; i < count; ++i) { + calendar_record_h record = nullptr; + calendar_list_get_current_record_p(records, &record); + if (record) { + char *viewUri = nullptr; + calendar_record_get_uri_p(record, &viewUri); + if (viewUri && !strcmp(viewUri, _calendar_event._uri)) + list.emplace_back(record); + } + } + + if (records) + calendar_list_destroy(records, true); + + return list; } diff --git a/src/Common/View/inc/AtspiAccessibleInterface.h b/src/Common/View/inc/AtspiAccessibleInterface.h index 73aecf37..c7d1e760 100644 --- a/src/Common/View/inc/AtspiAccessibleInterface.h +++ b/src/Common/View/inc/AtspiAccessibleInterface.h @@ -22,99 +22,99 @@ #include namespace Msg { - /** - * @brief Wrapper for Elm_Interface_Atspi_Accessible interface (Screen reader) - */ - class AtspiAccessibleInterface { - public: - AtspiAccessibleInterface(Elm_Interface_Atspi_Accessible *obj); - void wrap(Elm_Interface_Atspi_Accessible *obj); - Elm_Interface_Atspi_Accessible *getEo() const; - operator Elm_Interface_Atspi_Accessible *() const; - - void setDescription(const char *text); - void setDescription(const std::string &text); - void setName(const char *text); - void setName(const std::string &text); - void setRole(Elm_Atspi_Role role); - void setReadingInfo(Elm_Accessible_Reading_Info_Type type); - void appendRelationship(Elm_Atspi_Relation_Type type, const Elm_Interface_Atspi_Accessible *obj); - void removeRelationship(Elm_Atspi_Relation_Type type, const Elm_Interface_Atspi_Accessible *obj); - void canHighlight(bool canHighlight); - - // TODO: impl. other methods if needed - - private: - Elm_Interface_Atspi_Accessible *m_pEo; - }; - - typedef AtspiAccessibleInterface Atspi; - - inline AtspiAccessibleInterface::AtspiAccessibleInterface(Elm_Interface_Atspi_Accessible *obj) - : m_pEo(obj) - { - } - - inline void AtspiAccessibleInterface::wrap(Elm_Interface_Atspi_Accessible *obj) - { - m_pEo = obj; - } - - inline Elm_Interface_Atspi_Accessible *AtspiAccessibleInterface::getEo() const - { - return m_pEo; - } - - inline AtspiAccessibleInterface::operator Elm_Interface_Atspi_Accessible *() const - { - return getEo(); - } - - inline void AtspiAccessibleInterface::setDescription(const char *text) - { - elm_atspi_accessible_description_set(m_pEo, text); - elm_atspi_accessible_translation_domain_set(m_pEo, PACKAGE_NAME); - } - - inline void AtspiAccessibleInterface::setDescription(const std::string &text) - { - setDescription(text.c_str()); - } - - inline void AtspiAccessibleInterface::setName(const char *text) - { - elm_atspi_accessible_name_set(m_pEo, (char*)text); - } - - inline void AtspiAccessibleInterface::setName(const std::string &text) - { - setName(text.c_str()); - } - - inline void AtspiAccessibleInterface::setRole(Elm_Atspi_Role role) - { - elm_atspi_accessible_role_set(m_pEo, role); - } - - inline void AtspiAccessibleInterface::setReadingInfo(Elm_Accessible_Reading_Info_Type type) - { - elm_atspi_accessible_reading_info_type_set(m_pEo, type); - } - - inline void AtspiAccessibleInterface::appendRelationship(Elm_Atspi_Relation_Type type, const Elm_Interface_Atspi_Accessible *obj) - { - elm_atspi_accessible_relationship_append(m_pEo, type, obj); - } - - inline void AtspiAccessibleInterface::removeRelationship(Elm_Atspi_Relation_Type type, const Elm_Interface_Atspi_Accessible *obj) - { - elm_atspi_accessible_relationship_remove(m_pEo, type, obj); - } - - inline void AtspiAccessibleInterface::canHighlight(bool canHighlight) - { - elm_atspi_accessible_can_highlight_set(m_pEo, canHighlight); - } + /** + * @brief Wrapper for Elm_Interface_Atspi_Accessible interface (Screen reader) + */ + class AtspiAccessibleInterface { + public: + AtspiAccessibleInterface(Elm_Interface_Atspi_Accessible *obj); + void wrap(Elm_Interface_Atspi_Accessible *obj); + Elm_Interface_Atspi_Accessible *getEo() const; + operator Elm_Interface_Atspi_Accessible *() const; + + void setDescription(const char *text); + void setDescription(const std::string &text); + void setName(const char *text); + void setName(const std::string &text); + void setRole(Elm_Atspi_Role role); + void setReadingInfo(Elm_Accessible_Reading_Info_Type type); + void appendRelationship(Elm_Atspi_Relation_Type type, const Elm_Interface_Atspi_Accessible *obj); + void removeRelationship(Elm_Atspi_Relation_Type type, const Elm_Interface_Atspi_Accessible *obj); + void canHighlight(bool canHighlight); + + // TODO: impl. other methods if needed + + private: + Elm_Interface_Atspi_Accessible *m_pEo; + }; + + typedef AtspiAccessibleInterface Atspi; + + inline AtspiAccessibleInterface::AtspiAccessibleInterface(Elm_Interface_Atspi_Accessible *obj) + : m_pEo(obj) + { + } + + inline void AtspiAccessibleInterface::wrap(Elm_Interface_Atspi_Accessible *obj) + { + m_pEo = obj; + } + + inline Elm_Interface_Atspi_Accessible *AtspiAccessibleInterface::getEo() const + { + return m_pEo; + } + + inline AtspiAccessibleInterface::operator Elm_Interface_Atspi_Accessible *() const + { + return getEo(); + } + + inline void AtspiAccessibleInterface::setDescription(const char *text) + { + elm_atspi_accessible_description_set(m_pEo, text); + elm_atspi_accessible_translation_domain_set(m_pEo, PACKAGE_NAME); + } + + inline void AtspiAccessibleInterface::setDescription(const std::string &text) + { + setDescription(text.c_str()); + } + + inline void AtspiAccessibleInterface::setName(const char *text) + { + elm_atspi_accessible_name_set(m_pEo, (char*)text); + } + + inline void AtspiAccessibleInterface::setName(const std::string &text) + { + setName(text.c_str()); + } + + inline void AtspiAccessibleInterface::setRole(Elm_Atspi_Role role) + { + elm_atspi_accessible_role_set(m_pEo, role); + } + + inline void AtspiAccessibleInterface::setReadingInfo(Elm_Accessible_Reading_Info_Type type) + { + elm_atspi_accessible_reading_info_type_set(m_pEo, type); + } + + inline void AtspiAccessibleInterface::appendRelationship(Elm_Atspi_Relation_Type type, const Elm_Interface_Atspi_Accessible *obj) + { + elm_atspi_accessible_relationship_append(m_pEo, type, obj); + } + + inline void AtspiAccessibleInterface::removeRelationship(Elm_Atspi_Relation_Type type, const Elm_Interface_Atspi_Accessible *obj) + { + elm_atspi_accessible_relationship_remove(m_pEo, type, obj); + } + + inline void AtspiAccessibleInterface::canHighlight(bool canHighlight) + { + elm_atspi_accessible_can_highlight_set(m_pEo, canHighlight); + } } #endif /* AtspiAccessibleInterface_h_ */ diff --git a/src/Common/View/inc/BaseView.h b/src/Common/View/inc/BaseView.h index 6d2ce11d..ce078fbd 100644 --- a/src/Common/View/inc/BaseView.h +++ b/src/Common/View/inc/BaseView.h @@ -21,20 +21,20 @@ #include "PathUtils.h" namespace Msg { - /** - * @brief Basic interface for all visual objects used across the whole application. - */ - class BaseView { - public: - virtual ~BaseView() {}; - virtual void destroy() = 0; + /** + * @brief Basic interface for all visual objects used across the whole application. + */ + class BaseView { + public: + virtual ~BaseView() {}; + virtual void destroy() = 0; - protected: - /** - * @brief Performs self-removing by request from children-classes. - */ - virtual void onViewDestroyed() { delete this; }; - }; + protected: + /** + * @brief Performs self-removing by request from children-classes. + */ + virtual void onViewDestroyed() { delete this; }; + }; } #endif /* BaseView_h_ */ diff --git a/src/Common/View/inc/Box.h b/src/Common/View/inc/Box.h index 33ce3936..ea240ab5 100644 --- a/src/Common/View/inc/Box.h +++ b/src/Common/View/inc/Box.h @@ -21,124 +21,124 @@ #include namespace Msg { - /** - * @brief Wraps all basic Box operations. - */ - class Box - : public View { - public: - Box(Evas_Object *parent); - virtual ~Box(); - - /** - * @brief Set the horizontal orientation of box. - * @param[in] val if true box's orientation becomes horizontal otherwise it becomes vertical. - */ - inline void setHorizontal(bool val); - - /** - * @brief Manages homogeneous mode of box. - * @param[in] val if true homogeneous mode is on, otherwise it's off. - */ - inline void setHomogeneous(bool val); - - /** - * @brief Add an object to the beginning of the pack list. - * @param[in] obj an object to be added. - */ - inline void packStart(Evas_Object *obj); - - /** - * @brief Add an object at the end of the pack list. - * @param[in] obj an object to be added. - */ - inline void packEnd(Evas_Object *obj); - - /** - * @brief Adds an object to the box before the indicated object. - * @param[in] subobj an object to be added. - * @param[in] before the object before which to add it. - */ - inline void packBefore(Evas_Object *subobj, Evas_Object *before); - - /** - * @brief Adds an object to the box after the indicated object. - * @param[in] subobj an object to be added. - * @param[in] after the object after which to add it. - */ - inline void packAfter(Evas_Object *subobj, Evas_Object *after); - - /** - * @brief Remove the object given by @c subobj from the box without deleting it. - * @param[in] subobj an object to be removed. - */ - inline void unpack(Evas_Object *subobj); - - /** - * @brief Remove all items from the box, without deleting them. - */ - inline void unpackAll(); - - /** - * @brief Clear the box of all children, children will be deleted. - */ - inline void clear(); - - /** - * @brief Force the box to recalculate its children packing. - */ - inline void recalculate(); - }; - - inline void Box::setHorizontal(bool val) - { - elm_box_horizontal_set(getEo(), val); - } - - inline void Box::setHomogeneous(bool val) - { - elm_box_homogeneous_set(getEo(), val); - } - - inline void Box::packStart(Evas_Object *obj) - { - elm_box_pack_start(getEo(), obj); - } - - inline void Box::packEnd(Evas_Object *obj) - { - elm_box_pack_end(getEo(), obj); - } - - inline void Box::packBefore(Evas_Object *subobj, Evas_Object *before) - { - elm_box_pack_before(getEo(), subobj, before); - } - - inline void Box::packAfter(Evas_Object *subobj, Evas_Object *after) - { - elm_box_pack_after(getEo(), subobj, after); - } - - inline void Box::unpack(Evas_Object *subobj) - { - elm_box_unpack(getEo(), subobj); - } - - inline void Box::unpackAll() - { - elm_box_unpack_all(getEo()); - } - - inline void Box::clear() - { - elm_box_clear(getEo()); - } - - inline void Box::recalculate() - { - elm_box_recalculate(getEo()); - } + /** + * @brief Wraps all basic Box operations. + */ + class Box + : public View { + public: + Box(Evas_Object *parent); + virtual ~Box(); + + /** + * @brief Set the horizontal orientation of box. + * @param[in] val if true box's orientation becomes horizontal otherwise it becomes vertical. + */ + inline void setHorizontal(bool val); + + /** + * @brief Manages homogeneous mode of box. + * @param[in] val if true homogeneous mode is on, otherwise it's off. + */ + inline void setHomogeneous(bool val); + + /** + * @brief Add an object to the beginning of the pack list. + * @param[in] obj an object to be added. + */ + inline void packStart(Evas_Object *obj); + + /** + * @brief Add an object at the end of the pack list. + * @param[in] obj an object to be added. + */ + inline void packEnd(Evas_Object *obj); + + /** + * @brief Adds an object to the box before the indicated object. + * @param[in] subobj an object to be added. + * @param[in] before the object before which to add it. + */ + inline void packBefore(Evas_Object *subobj, Evas_Object *before); + + /** + * @brief Adds an object to the box after the indicated object. + * @param[in] subobj an object to be added. + * @param[in] after the object after which to add it. + */ + inline void packAfter(Evas_Object *subobj, Evas_Object *after); + + /** + * @brief Remove the object given by @c subobj from the box without deleting it. + * @param[in] subobj an object to be removed. + */ + inline void unpack(Evas_Object *subobj); + + /** + * @brief Remove all items from the box, without deleting them. + */ + inline void unpackAll(); + + /** + * @brief Clear the box of all children, children will be deleted. + */ + inline void clear(); + + /** + * @brief Force the box to recalculate its children packing. + */ + inline void recalculate(); + }; + + inline void Box::setHorizontal(bool val) + { + elm_box_horizontal_set(getEo(), val); + } + + inline void Box::setHomogeneous(bool val) + { + elm_box_homogeneous_set(getEo(), val); + } + + inline void Box::packStart(Evas_Object *obj) + { + elm_box_pack_start(getEo(), obj); + } + + inline void Box::packEnd(Evas_Object *obj) + { + elm_box_pack_end(getEo(), obj); + } + + inline void Box::packBefore(Evas_Object *subobj, Evas_Object *before) + { + elm_box_pack_before(getEo(), subobj, before); + } + + inline void Box::packAfter(Evas_Object *subobj, Evas_Object *after) + { + elm_box_pack_after(getEo(), subobj, after); + } + + inline void Box::unpack(Evas_Object *subobj) + { + elm_box_unpack(getEo(), subobj); + } + + inline void Box::unpackAll() + { + elm_box_unpack_all(getEo()); + } + + inline void Box::clear() + { + elm_box_clear(getEo()); + } + + inline void Box::recalculate() + { + elm_box_recalculate(getEo()); + } } #endif /* Box_h_ */ diff --git a/src/Common/View/inc/ContextPopup.h b/src/Common/View/inc/ContextPopup.h index 010f0cd6..f515dc94 100644 --- a/src/Common/View/inc/ContextPopup.h +++ b/src/Common/View/inc/ContextPopup.h @@ -25,57 +25,57 @@ #include namespace Msg { - class ContextPopup; - class ContextPopupItem; - class Window; - - #define CTXPOPUP_ITEM_PRESSED_CB(ClassName, method) [](ContextPopupItem &item, void *userData) \ - { \ - static_cast(userData)->method(item); \ - } - - typedef void (*ContextPopupItemPressedCb)(ContextPopupItem &item, void *userData); - - class ContextPopupItem - : public ViewItem { - friend class ContextPopup; - - public: - ContextPopup &getParent(); - int getId() const; - - private: - ContextPopupItem(ContextPopup &parent, int id, ContextPopupItemPressedCb userCb, void *userData); - virtual ~ContextPopupItem(); - - private: - ContextPopup &m_ParentContextPopup; - int m_Id; - ContextPopupItemPressedCb m_pUserCb; - void *m_pUserData; - }; - - class ContextPopup - : public View { - public: - ContextPopup(Evas_Object *parent); - virtual ~ContextPopup(); - - ContextPopupItem *appendItem(const std::string &text, Evas_Object *icon = nullptr, - ContextPopupItemPressedCb cb = nullptr, void *userData = nullptr, int id = 0); - void destroy(); - void setDirectionPriority(Elm_Ctxpopup_Direction first, Elm_Ctxpopup_Direction second, - Elm_Ctxpopup_Direction third, Elm_Ctxpopup_Direction fourth); - void align(Window &win); - - Elm_Ctxpopup_Direction getDirection() const; - - private: - void createContextPopup(Evas_Object *parent); - - static void on_dismissed_cb(void *data, Evas_Object *obj, void *event_info); - static void on_item_pressed_cb(void *data, Evas_Object * obj, void *event_info); - }; + class ContextPopup; + class ContextPopupItem; + class Window; + + #define CTXPOPUP_ITEM_PRESSED_CB(ClassName, method) [](ContextPopupItem &item, void *userData) \ + { \ + static_cast(userData)->method(item); \ + } + + typedef void (*ContextPopupItemPressedCb)(ContextPopupItem &item, void *userData); + + class ContextPopupItem + : public ViewItem { + friend class ContextPopup; + + public: + ContextPopup &getParent(); + int getId() const; + + private: + ContextPopupItem(ContextPopup &parent, int id, ContextPopupItemPressedCb userCb, void *userData); + virtual ~ContextPopupItem(); + + private: + ContextPopup &m_ParentContextPopup; + int m_Id; + ContextPopupItemPressedCb m_pUserCb; + void *m_pUserData; + }; + + class ContextPopup + : public View { + public: + ContextPopup(Evas_Object *parent); + virtual ~ContextPopup(); + + ContextPopupItem *appendItem(const std::string &text, Evas_Object *icon = nullptr, + ContextPopupItemPressedCb cb = nullptr, void *userData = nullptr, int id = 0); + void destroy(); + void setDirectionPriority(Elm_Ctxpopup_Direction first, Elm_Ctxpopup_Direction second, + Elm_Ctxpopup_Direction third, Elm_Ctxpopup_Direction fourth); + void align(Window &win); + + Elm_Ctxpopup_Direction getDirection() const; + + private: + void createContextPopup(Evas_Object *parent); + + static void on_dismissed_cb(void *data, Evas_Object *obj, void *event_info); + static void on_item_pressed_cb(void *data, Evas_Object * obj, void *event_info); + }; } #endif // ContextPopup_h_ diff --git a/src/Common/View/inc/DefaultLayout.h b/src/Common/View/inc/DefaultLayout.h index 09bbc7f4..93483f2f 100644 --- a/src/Common/View/inc/DefaultLayout.h +++ b/src/Common/View/inc/DefaultLayout.h @@ -20,19 +20,19 @@ #include "View.h" namespace Msg { - class DefaultLayout - : public View { - public: - DefaultLayout(Evas_Object *parent); - virtual ~DefaultLayout(); + class DefaultLayout + : public View { + public: + DefaultLayout(Evas_Object *parent); + virtual ~DefaultLayout(); - void setContent(Evas_Object *obj); - void setBg(Evas_Object *obj); - void setFloatingButton(Evas_Object *obj); - void showFloatingButton(bool show); - private: - Evas_Object *m_pFloatingBtn; - }; + void setContent(Evas_Object *obj); + void setBg(Evas_Object *obj); + void setFloatingButton(Evas_Object *obj); + void showFloatingButton(bool show); + private: + Evas_Object *m_pFloatingBtn; + }; } diff --git a/src/Common/View/inc/ListItem.h b/src/Common/View/inc/ListItem.h index 20d7529c..8e6b3b48 100644 --- a/src/Common/View/inc/ListItem.h +++ b/src/Common/View/inc/ListItem.h @@ -25,178 +25,178 @@ #include namespace Msg { - class ListView; - class ListItemStyle; - class ListItem; - typedef std::shared_ptr ListItemStyleRef; - typedef std::vector ListItemCollection; - - class ListItemStyle { - public: - ListItemStyle(const char *itemStyle, - const char *decorateItemStyle = nullptr, - const char *decorateAllItemStyle = nullptr); - virtual ~ListItemStyle(); - - static ListItemStyleRef create(const char *itemStyle, - const char *decorateItemStyle = nullptr, - const char *decorateAllItemStyle = nullptr); - private: - friend class ListView; - friend class ListItem; - - void registerCallback(); - void unregisterCallback(); - void setStyle(const char *itemStyle, const char *decorateItemStyle, const char *decorateAllItemStyle); - - private: - Elm_Genlist_Item_Class *m_pGenlistItemClass; - }; - - /** - * @brief Wraps all basic genlist item operations. - */ - class ListItem - : public ViewItem { - friend class ListItemStyle; - friend class ListView; - - public: - /** - * @brief Creates instance of ListItem of specified genlist-item type. - * @param[in] type genlist item-type. - */ - ListItem(Elm_Genlist_Item_Type type = ELM_GENLIST_ITEM_NONE); - - /** - * @brief Creates instance of ListItem of specified genlist-item type with predefined style. - * @param[in] itemStyle predefined item style. - * @param[in] type genlist item-type. - */ - ListItem(const ListItemStyleRef &itemStyle, Elm_Genlist_Item_Type type = ELM_GENLIST_ITEM_NONE); - virtual ~ListItem(); - - // Base elm methods: - /** - * @brief Gets list-item style. - * @return item style. - */ - const ListItemStyleRef &getStyle() const; - - /** - * @brief Sets specified style to list-item. - * @param[in] style a style to be set. - */ - void setStyle(ListItemStyleRef &style); - - /** - * @brief Makes list-item selected(unselected). - * @param[in] selected if true makes list-item selected, if false - unselects it. - */ - void setSelected(bool selected); - - /** - * @brief Checks whether list-item is selected or not. - * @return true if list-item is selected, false otherwise. - */ - bool getSelected() const; - - /** - * @brief Makes list-item able to be selected. - * @param[in] selectable if true makes list-item able to be selected, if false - list-item will ignore selection. - */ - void setSelectable(bool selectable); - - /** - * @brief Checks whether list-item is able to be selected or not. - * @return true if list-item is selectable, false otherwise. - */ - bool getSelectable() const; - - /** - * @brief Sets the expanded state of an list-item. - * @param[in] expand expanded state. - */ - void setExpanded(bool expand); - - /** - * @brief Update all the contents of an item. - */ - void update(); - - /** - * @brief Updates specified parts in list-item. - * @param[in] parts a parts to be updated. Used for globbing to match '*', '?', and '.'. - * @param[in] type The type of item's part type. - */ - void updateFields(const char *parts, Elm_Genlist_Item_Field_Type type); - - /** - * @brief Gets a ListView instance that owns this list-item. - * @return owner ListView. - */ - ListView *getOwner() const; - - /** - * @brief Gets type of nested genlist-item. - * @return genlist item type. - */ - Elm_Genlist_Item_Type getType() const; - - // Check(Select) methods: - /** - * @brief Changes checked state of list-item. Also item optionally can update full it's content. - * @param[in] updateUi if true all list-item's content will be forced to update. - */ - void changeCheckedState(bool updateUi); - - /** - * @brief Updates list-item's checked state with state specified. Also item optionally can update full it's content. - * @param[in] state a new checked-state to be applied. - * @param[in] updateUi if true all list-item's content will be forced to update. - */ - void setCheckedState(bool state, bool updateUi); - - /** - * @brief Checks whether list- item is checked or not. - * @return true if list-item is checked, false otherwise. - */ - bool getCheckedState() const; - - /** - * @brief Checks whether checkbox was created and put into specific list-item's part. - * @return true if checkbox is created and available to manage, false otherwise. - */ - bool isCheckable() const; - - protected: - virtual std::string getText(ListItem &item, const char *part); - virtual Evas_Object *getContent(ListItem &item, const char *part); - virtual bool getState(ListItem &item, const char *part); - virtual void onDelete(ListItem &item); - virtual const char *getCheckPart(ListItem &item); - virtual bool getFilter(ListItem &item, void *key); - - virtual void onRealized(ListItem &item) {}; - virtual void onUnrealized(ListItem &item) {}; - - private: - virtual void onViewDestroyed(); - Evas_Object *addCheck(); - void onCheckChanged(Evas_Object *obj, void *eventInfo); - - static char * elm_gen_item_text_get_cb(void * data, Evas_Object * obj, const char * part); - static Evas_Object * elm_gen_item_content_get_cb(void * data, Evas_Object * obj, const char * part); - static Eina_Bool elm_gen_item_state_get_cb(void * data, Evas_Object * obj, const char * part); - static void elm_gen_item_del_cb(void *data, Evas_Object *obj); - static Eina_Bool elm_gen_item_filter_cb(void *data, Evas_Object *obj, void *key); - - private: - ListView *m_pOwner; - ListItemStyleRef m_ItemStyle; - Elm_Genlist_Item_Type m_Type; - bool m_Checked; - }; + class ListView; + class ListItemStyle; + class ListItem; + typedef std::shared_ptr ListItemStyleRef; + typedef std::vector ListItemCollection; + + class ListItemStyle { + public: + ListItemStyle(const char *itemStyle, + const char *decorateItemStyle = nullptr, + const char *decorateAllItemStyle = nullptr); + virtual ~ListItemStyle(); + + static ListItemStyleRef create(const char *itemStyle, + const char *decorateItemStyle = nullptr, + const char *decorateAllItemStyle = nullptr); + private: + friend class ListView; + friend class ListItem; + + void registerCallback(); + void unregisterCallback(); + void setStyle(const char *itemStyle, const char *decorateItemStyle, const char *decorateAllItemStyle); + + private: + Elm_Genlist_Item_Class *m_pGenlistItemClass; + }; + + /** + * @brief Wraps all basic genlist item operations. + */ + class ListItem + : public ViewItem { + friend class ListItemStyle; + friend class ListView; + + public: + /** + * @brief Creates instance of ListItem of specified genlist-item type. + * @param[in] type genlist item-type. + */ + ListItem(Elm_Genlist_Item_Type type = ELM_GENLIST_ITEM_NONE); + + /** + * @brief Creates instance of ListItem of specified genlist-item type with predefined style. + * @param[in] itemStyle predefined item style. + * @param[in] type genlist item-type. + */ + ListItem(const ListItemStyleRef &itemStyle, Elm_Genlist_Item_Type type = ELM_GENLIST_ITEM_NONE); + virtual ~ListItem(); + + // Base elm methods: + /** + * @brief Gets list-item style. + * @return item style. + */ + const ListItemStyleRef &getStyle() const; + + /** + * @brief Sets specified style to list-item. + * @param[in] style a style to be set. + */ + void setStyle(ListItemStyleRef &style); + + /** + * @brief Makes list-item selected(unselected). + * @param[in] selected if true makes list-item selected, if false - unselects it. + */ + void setSelected(bool selected); + + /** + * @brief Checks whether list-item is selected or not. + * @return true if list-item is selected, false otherwise. + */ + bool getSelected() const; + + /** + * @brief Makes list-item able to be selected. + * @param[in] selectable if true makes list-item able to be selected, if false - list-item will ignore selection. + */ + void setSelectable(bool selectable); + + /** + * @brief Checks whether list-item is able to be selected or not. + * @return true if list-item is selectable, false otherwise. + */ + bool getSelectable() const; + + /** + * @brief Sets the expanded state of an list-item. + * @param[in] expand expanded state. + */ + void setExpanded(bool expand); + + /** + * @brief Update all the contents of an item. + */ + void update(); + + /** + * @brief Updates specified parts in list-item. + * @param[in] parts a parts to be updated. Used for globbing to match '*', '?', and '.'. + * @param[in] type The type of item's part type. + */ + void updateFields(const char *parts, Elm_Genlist_Item_Field_Type type); + + /** + * @brief Gets a ListView instance that owns this list-item. + * @return owner ListView. + */ + ListView *getOwner() const; + + /** + * @brief Gets type of nested genlist-item. + * @return genlist item type. + */ + Elm_Genlist_Item_Type getType() const; + + // Check(Select) methods: + /** + * @brief Changes checked state of list-item. Also item optionally can update full it's content. + * @param[in] updateUi if true all list-item's content will be forced to update. + */ + void changeCheckedState(bool updateUi); + + /** + * @brief Updates list-item's checked state with state specified. Also item optionally can update full it's content. + * @param[in] state a new checked-state to be applied. + * @param[in] updateUi if true all list-item's content will be forced to update. + */ + void setCheckedState(bool state, bool updateUi); + + /** + * @brief Checks whether list- item is checked or not. + * @return true if list-item is checked, false otherwise. + */ + bool getCheckedState() const; + + /** + * @brief Checks whether checkbox was created and put into specific list-item's part. + * @return true if checkbox is created and available to manage, false otherwise. + */ + bool isCheckable() const; + + protected: + virtual std::string getText(ListItem &item, const char *part); + virtual Evas_Object *getContent(ListItem &item, const char *part); + virtual bool getState(ListItem &item, const char *part); + virtual void onDelete(ListItem &item); + virtual const char *getCheckPart(ListItem &item); + virtual bool getFilter(ListItem &item, void *key); + + virtual void onRealized(ListItem &item) {}; + virtual void onUnrealized(ListItem &item) {}; + + private: + virtual void onViewDestroyed(); + Evas_Object *addCheck(); + void onCheckChanged(Evas_Object *obj, void *eventInfo); + + static char * elm_gen_item_text_get_cb(void * data, Evas_Object * obj, const char * part); + static Evas_Object * elm_gen_item_content_get_cb(void * data, Evas_Object * obj, const char * part); + static Eina_Bool elm_gen_item_state_get_cb(void * data, Evas_Object * obj, const char * part); + static void elm_gen_item_del_cb(void *data, Evas_Object *obj); + static Eina_Bool elm_gen_item_filter_cb(void *data, Evas_Object *obj, void *key); + + private: + ListView *m_pOwner; + ListItemStyleRef m_ItemStyle; + Elm_Genlist_Item_Type m_Type; + bool m_Checked; + }; } #endif // ListItem_65152b60_4142_11e3_aa6e_0800200c9a66_h_ diff --git a/src/Common/View/inc/ListView.h b/src/Common/View/inc/ListView.h index 3ec4acdc..a3194c5a 100644 --- a/src/Common/View/inc/ListView.h +++ b/src/Common/View/inc/ListView.h @@ -23,310 +23,310 @@ #include namespace Msg { - class IListViewListener; - - /** - * @brief Wraps all basic genlist operations. - */ - class ListView - : public View { - public: - /**@brief Function of comparing two list-items, used for sorted item insertion.*/ - typedef int (*CmpFunc)(const ListItem &item1, const ListItem &item2); - - public: - /** - * @brief A constructor of ListView object based on outside parent object. - * @param[in] parent an object responsible for automatic removing of ListView instance. - */ - ListView(Evas_Object *parent); - virtual ~ListView(); - - /** - * @brief Sets subscriber that will be notified on list-view events. - * @param[in] listener a listener. - */ - void setListener(IListViewListener *listener); - - /** - * @brief Appends specified list-view item into list-view. - * @param[in] listItem an item to be appended. - * @param[in] parent a parent item. - * @return true in case of success, false otherwise. - */ - bool appendItem(ListItem &listItem, ListItem *parent = nullptr); - - /** - * @brief Inserts an item before another in a genlist widget - * @param[in] listItem an item to be appended. - * @param[in] before the item before which to place this new one - * @param[in] parent a parent item. - * @return true in case of success, false otherwise. - */ - bool insertBeforeItem(ListItem &listItem, ListItem &before, ListItem *parent = nullptr); - - /** - * @brief Prepends specified list-view item into list-view. - * @param[in] listItem an item to be prepended. - * @param[in] parent a parent item. - * @return true in case of success, false otherwise. - */ - bool prependItem(ListItem &listItem, ListItem *parent = nullptr); - - /** - * @brief Performs sorted item insertion. - * @param[in] listItem an item to be inserted. - * @param[in] parent a parent item. - * @return true in case of success, false otherwise. - */ - bool sortedInsertItem(ListItem &listItem, ListItem *parent = nullptr); - - /** - * @brief Sets item compare function to make work of sortedInsertItem() correct. - * @param[in] fn items compare function. - */ - void setCmpFunc(CmpFunc fn); - - /** - * @brief Deletes item from list-view. - * @param[in, out] listItem item to be deleted. - */ - void deleteItem(ListItem &listItem); - - /** - * @brief Gets all list-view items. - * @return list-view items. - */ - ListItemCollection getItems() const; - - /** - * @brief Gets realized list-view items. - * @return list-view items. - */ - ListItemCollection getRealizedItems() const; - - /** - * @brief Gets first list-view item. - * @return first list-view item. - */ - ListItem *getFirstItem() const; - - /** - * @brief Gets last list-view item. - * @return last list-view item. - */ - ListItem *getLastItem() const; - - /** - * @brief Shows list-view item. This causes list-view to jump to the given item @c it and show it (by jumping - * to that position), if it is not fully visible. - * @param[in] listItem an item to be shown. - * @param[in] type The position to bring in, the given item to. - */ - void showItem(ListItem &listItem, Elm_Genlist_Item_Scrollto_Type type); - - /** - * @brief Enables(disables) multiselection. - * @param[in] value if true enables multiselection, otherwise disables it. - */ - void setMultiSelection(bool value); - - /** - * @brief Checks whether multiselection is turned on or not. - * @return true if multiselection is enabled, otherwise false. - */ - bool getMultiSelection() const; - - /** - * @brief Removes all list-items. - */ - void clear(); - - /** - * @brief Checks whether list-view contains at least one item or not. - * @return true if list-view has no items, otherwise false. - */ - bool isEmpty() const; - - /** - * @brief Passes mode to nested genlist. - * @param[in] mode a mode to be applied. - */ - void setMode(Elm_List_Mode mode); - - /** - * @brief Enable(disable) genlist homogeneous mode. - * @param[in] isHomogeneous if true turns on homogeneous mode, otherwise turns it off. - */ - void setHomogeneous(bool isHomogeneous); - - /** - * @brief Gets selected view-item. - * @return selected list-view item or nullptr if no item is selected. - */ - ListItem *getSelectedItem() const; - - /** - * @brief Gets number of items. - * @return number of items. - */ - unsigned getItemsCount() const; - - /** - * @brief Gets list-view item next to specified one. - * @param[in] item an item in genlist. - * @return next item to the specified one. If there's no next item nullptr is returned. - */ - ListItem *getNextItem(ListItem &item) const; - - template - T *getNextItem(ListItem &item) const; - - /** - * @brief Gets list-view item previous to specified one. - * @param[in] item an item in genlist. - * @return next item to the specified one. If there's no previous item nullptr is returned. - */ - ListItem *getPrevItem(ListItem &item) const; - - template - T *getPrevItem(ListItem &item) const; - - /** - * @brief Demotes specified list-view item to the end of the list. - * @param[in] item an item to be demoted. - */ - void demoteItem(ListItem &item); - - /** - * @brief Promotes specified list-view item to the begin of the list. - * @param[in] item an item to be promoted. - */ - void promoteItem(ListItem &item); - - /** - * @brief Set filter for items - * @param[in] key The filter key - */ - void setFilter(void *key); - - /** - * @brief Enables(disables selection mode). Makes all list-view items to show(hide) a check-box. - * @param[in] check if true makes all items to show checkbox, otherwise make them to hide it. - */ - void setCheckMode(bool check); - - /** - * @brief Checks wheather selection mode is enabled or not. - * @return true if selection mode is enabled, false otherwise. - */ - bool getCheckMode() const; - - /** - * @brief Checks(unchecks) all list-view items in selection mode and updates realized items. - * @param[in] check if true all items will be checked, if false - unchecks all items. - * @param[in] updateFullItem if false only check part will be updated, if true whole item will be updated. - */ - void checkAllItems(bool check, bool updateFullItem = false); - - template - std::vector getItems() const; - - /** - * @brief Updates the contents of all realized items. - */ - void updateRealizedItems(); - - private: - typedef void (IListViewListener::*ListenerMethod)(ListItem &item); - - public: - static void notifyListener(void *data, Evas_Object *obj, void *event_info, ListenerMethod method); - - private: - void createListView(Evas_Object *parent); - - static void on_item_selected_cb(void *data, Evas_Object *obj, void *event_info); - static void on_realized_cb(void *data, Evas_Object *obj, void *event_info); - static void on_unrealized_cb(void *data, Evas_Object *obj, void *event_info); - static void on_longpressed_cb(void *data, Evas_Object *obj, void *event_info); - - private: - IListViewListener *m_pListener; - bool m_CheckMode; - CmpFunc m_CmpFunc; - }; - - /** - * @brief A listener-interface aimed to make subscribers to get notified about genlist events. - */ - class IListViewListener { - public: - virtual ~IListViewListener() {}; - - /** - * @brief Notification about insertion of new item into genlist. - * @param[in, out] listItem inserted item - */ - virtual void onListItemSelected(ListItem &listItem) {}; - - /** - * @brief Notification about genlist-item longpress event. - * @param[in, out] listItem lingpressed item - */ - virtual void onListItemLongPressed(ListItem &listItem) {}; - - /** - * @brief Notification occured after changing check-state of check-box placed on genlist-item. - * @param[in, out] listItem checked item - */ - virtual void onListItemChecked(ListItem &listItem) {}; - }; - - template - std::vector ListView::getItems() const - { - std::vector list; - list.reserve(elm_genlist_items_count(getEo())); - Elm_Object_Item *elmItem = elm_genlist_first_item_get(getEo()); - while (elmItem) { - void *data = elm_object_item_data_get(elmItem); - if (data) { - T *listItem = dynamic_cast(static_cast(data)); - if (listItem) - list.push_back(listItem); - } - elmItem = elm_genlist_item_next_get(elmItem); - } - - return list; - } - - template - T *ListView::getNextItem(ListItem &item) const - { - T *res = nullptr; - ListItem *next = &item; - do { - next = getNextItem(*next); - res = dynamic_cast(next); - } while (next && !res); - - return res; - } - - template - T *ListView::getPrevItem(ListItem &item) const - { - T *res = nullptr; - ListItem *prev = &item; - do { - prev = getPrevItem(*prev); - res = dynamic_cast(prev); - } while (prev && !res); - - return res; - } + class IListViewListener; + + /** + * @brief Wraps all basic genlist operations. + */ + class ListView + : public View { + public: + /**@brief Function of comparing two list-items, used for sorted item insertion.*/ + typedef int (*CmpFunc)(const ListItem &item1, const ListItem &item2); + + public: + /** + * @brief A constructor of ListView object based on outside parent object. + * @param[in] parent an object responsible for automatic removing of ListView instance. + */ + ListView(Evas_Object *parent); + virtual ~ListView(); + + /** + * @brief Sets subscriber that will be notified on list-view events. + * @param[in] listener a listener. + */ + void setListener(IListViewListener *listener); + + /** + * @brief Appends specified list-view item into list-view. + * @param[in] listItem an item to be appended. + * @param[in] parent a parent item. + * @return true in case of success, false otherwise. + */ + bool appendItem(ListItem &listItem, ListItem *parent = nullptr); + + /** + * @brief Inserts an item before another in a genlist widget + * @param[in] listItem an item to be appended. + * @param[in] before the item before which to place this new one + * @param[in] parent a parent item. + * @return true in case of success, false otherwise. + */ + bool insertBeforeItem(ListItem &listItem, ListItem &before, ListItem *parent = nullptr); + + /** + * @brief Prepends specified list-view item into list-view. + * @param[in] listItem an item to be prepended. + * @param[in] parent a parent item. + * @return true in case of success, false otherwise. + */ + bool prependItem(ListItem &listItem, ListItem *parent = nullptr); + + /** + * @brief Performs sorted item insertion. + * @param[in] listItem an item to be inserted. + * @param[in] parent a parent item. + * @return true in case of success, false otherwise. + */ + bool sortedInsertItem(ListItem &listItem, ListItem *parent = nullptr); + + /** + * @brief Sets item compare function to make work of sortedInsertItem() correct. + * @param[in] fn items compare function. + */ + void setCmpFunc(CmpFunc fn); + + /** + * @brief Deletes item from list-view. + * @param[in, out] listItem item to be deleted. + */ + void deleteItem(ListItem &listItem); + + /** + * @brief Gets all list-view items. + * @return list-view items. + */ + ListItemCollection getItems() const; + + /** + * @brief Gets realized list-view items. + * @return list-view items. + */ + ListItemCollection getRealizedItems() const; + + /** + * @brief Gets first list-view item. + * @return first list-view item. + */ + ListItem *getFirstItem() const; + + /** + * @brief Gets last list-view item. + * @return last list-view item. + */ + ListItem *getLastItem() const; + + /** + * @brief Shows list-view item. This causes list-view to jump to the given item @c it and show it (by jumping + * to that position), if it is not fully visible. + * @param[in] listItem an item to be shown. + * @param[in] type The position to bring in, the given item to. + */ + void showItem(ListItem &listItem, Elm_Genlist_Item_Scrollto_Type type); + + /** + * @brief Enables(disables) multiselection. + * @param[in] value if true enables multiselection, otherwise disables it. + */ + void setMultiSelection(bool value); + + /** + * @brief Checks whether multiselection is turned on or not. + * @return true if multiselection is enabled, otherwise false. + */ + bool getMultiSelection() const; + + /** + * @brief Removes all list-items. + */ + void clear(); + + /** + * @brief Checks whether list-view contains at least one item or not. + * @return true if list-view has no items, otherwise false. + */ + bool isEmpty() const; + + /** + * @brief Passes mode to nested genlist. + * @param[in] mode a mode to be applied. + */ + void setMode(Elm_List_Mode mode); + + /** + * @brief Enable(disable) genlist homogeneous mode. + * @param[in] isHomogeneous if true turns on homogeneous mode, otherwise turns it off. + */ + void setHomogeneous(bool isHomogeneous); + + /** + * @brief Gets selected view-item. + * @return selected list-view item or nullptr if no item is selected. + */ + ListItem *getSelectedItem() const; + + /** + * @brief Gets number of items. + * @return number of items. + */ + unsigned getItemsCount() const; + + /** + * @brief Gets list-view item next to specified one. + * @param[in] item an item in genlist. + * @return next item to the specified one. If there's no next item nullptr is returned. + */ + ListItem *getNextItem(ListItem &item) const; + + template + T *getNextItem(ListItem &item) const; + + /** + * @brief Gets list-view item previous to specified one. + * @param[in] item an item in genlist. + * @return next item to the specified one. If there's no previous item nullptr is returned. + */ + ListItem *getPrevItem(ListItem &item) const; + + template + T *getPrevItem(ListItem &item) const; + + /** + * @brief Demotes specified list-view item to the end of the list. + * @param[in] item an item to be demoted. + */ + void demoteItem(ListItem &item); + + /** + * @brief Promotes specified list-view item to the begin of the list. + * @param[in] item an item to be promoted. + */ + void promoteItem(ListItem &item); + + /** + * @brief Set filter for items + * @param[in] key The filter key + */ + void setFilter(void *key); + + /** + * @brief Enables(disables selection mode). Makes all list-view items to show(hide) a check-box. + * @param[in] check if true makes all items to show checkbox, otherwise make them to hide it. + */ + void setCheckMode(bool check); + + /** + * @brief Checks wheather selection mode is enabled or not. + * @return true if selection mode is enabled, false otherwise. + */ + bool getCheckMode() const; + + /** + * @brief Checks(unchecks) all list-view items in selection mode and updates realized items. + * @param[in] check if true all items will be checked, if false - unchecks all items. + * @param[in] updateFullItem if false only check part will be updated, if true whole item will be updated. + */ + void checkAllItems(bool check, bool updateFullItem = false); + + template + std::vector getItems() const; + + /** + * @brief Updates the contents of all realized items. + */ + void updateRealizedItems(); + + private: + typedef void (IListViewListener::*ListenerMethod)(ListItem &item); + + public: + static void notifyListener(void *data, Evas_Object *obj, void *event_info, ListenerMethod method); + + private: + void createListView(Evas_Object *parent); + + static void on_item_selected_cb(void *data, Evas_Object *obj, void *event_info); + static void on_realized_cb(void *data, Evas_Object *obj, void *event_info); + static void on_unrealized_cb(void *data, Evas_Object *obj, void *event_info); + static void on_longpressed_cb(void *data, Evas_Object *obj, void *event_info); + + private: + IListViewListener *m_pListener; + bool m_CheckMode; + CmpFunc m_CmpFunc; + }; + + /** + * @brief A listener-interface aimed to make subscribers to get notified about genlist events. + */ + class IListViewListener { + public: + virtual ~IListViewListener() {}; + + /** + * @brief Notification about insertion of new item into genlist. + * @param[in, out] listItem inserted item + */ + virtual void onListItemSelected(ListItem &listItem) {}; + + /** + * @brief Notification about genlist-item longpress event. + * @param[in, out] listItem lingpressed item + */ + virtual void onListItemLongPressed(ListItem &listItem) {}; + + /** + * @brief Notification occured after changing check-state of check-box placed on genlist-item. + * @param[in, out] listItem checked item + */ + virtual void onListItemChecked(ListItem &listItem) {}; + }; + + template + std::vector ListView::getItems() const + { + std::vector list; + list.reserve(elm_genlist_items_count(getEo())); + Elm_Object_Item *elmItem = elm_genlist_first_item_get(getEo()); + while (elmItem) { + void *data = elm_object_item_data_get(elmItem); + if (data) { + T *listItem = dynamic_cast(static_cast(data)); + if (listItem) + list.push_back(listItem); + } + elmItem = elm_genlist_item_next_get(elmItem); + } + + return list; + } + + template + T *ListView::getNextItem(ListItem &item) const + { + T *res = nullptr; + ListItem *next = &item; + do { + next = getNextItem(*next); + res = dynamic_cast(next); + } while (next && !res); + + return res; + } + + template + T *ListView::getPrevItem(ListItem &item) const + { + T *res = nullptr; + ListItem *prev = &item; + do { + prev = getPrevItem(*prev); + res = dynamic_cast(prev); + } while (prev && !res); + + return res; + } } #endif // ListView_15152b60_4142_11b3_aa6e_080a200c9a62_h_ diff --git a/src/Common/View/inc/MbeRecipientViewItem.h b/src/Common/View/inc/MbeRecipientViewItem.h index 7c254246..1d312f5a 100644 --- a/src/Common/View/inc/MbeRecipientViewItem.h +++ b/src/Common/View/inc/MbeRecipientViewItem.h @@ -21,98 +21,98 @@ #include "MsgAddress.h" namespace Msg { - class MbeRecipientsView; - - /** - * @brief Wraps all basic multibutton entry item operations. - */ - class MbeRecipientItem - : public ViewItem { - friend class MbeRecipientsView; - - public: - /** - * @brief Constructs instance of MbeRecipientItem with a specified display-name, address etc. - * @param[in] address recipient-address(phone number or email). - * @param[in] dispName displayable mbe-item text. - * @param[in] addressType type of recipient address. - * @param[in] recipType type of recipient. - */ - MbeRecipientItem(const std::string &address, const std::string &dispName, - MsgAddress::AddressType addressType, MsgAddress::RecipientType recipType = MsgAddress::To); - - /** - * @brief Gets recipient's display-name. - * @return display-name. - */ - const std::string &getDispName() const; - - /** - * @brief Gets recipient address. - * @return recipient address. - */ - const std::string &getAddress() const; - - /** - * @brief Gets address-type. - * @return address-type. - */ - MsgAddress::AddressType getAddressType() const; - - /** - * @brief Gets recipient type. - * @return recipient type. - */ - MsgAddress::RecipientType getRecipType() const; - - /** - * @brief Sets new display name. - * @param[in] dispName new display name. - */ - void setDispName(const std::string &dispName); - - private: - std::string m_Address; - std::string m_DispName; - MsgAddress::AddressType m_AddressType; - MsgAddress::RecipientType m_RecipType; - }; - - inline MbeRecipientItem::MbeRecipientItem(const std::string &address, const std::string &dispName, - MsgAddress::AddressType addressType, MsgAddress::RecipientType recipType) - : m_Address(address) - , m_DispName(dispName) - , m_AddressType(addressType) - , m_RecipType(recipType) - { - } - - inline const std::string &MbeRecipientItem::getDispName() const - { - return m_DispName; - } - - inline const std::string &MbeRecipientItem::getAddress() const - { - return m_Address; - } - - inline MsgAddress::AddressType MbeRecipientItem::getAddressType() const - { - return m_AddressType; - } - - inline MsgAddress::RecipientType MbeRecipientItem::getRecipType() const - { - return m_RecipType; - } - - inline void MbeRecipientItem::setDispName(const std::string &dispName) - { - m_DispName = dispName; - if (getElmObjItem()) - setText(dispName); - } + class MbeRecipientsView; + + /** + * @brief Wraps all basic multibutton entry item operations. + */ + class MbeRecipientItem + : public ViewItem { + friend class MbeRecipientsView; + + public: + /** + * @brief Constructs instance of MbeRecipientItem with a specified display-name, address etc. + * @param[in] address recipient-address(phone number or email). + * @param[in] dispName displayable mbe-item text. + * @param[in] addressType type of recipient address. + * @param[in] recipType type of recipient. + */ + MbeRecipientItem(const std::string &address, const std::string &dispName, + MsgAddress::AddressType addressType, MsgAddress::RecipientType recipType = MsgAddress::To); + + /** + * @brief Gets recipient's display-name. + * @return display-name. + */ + const std::string &getDispName() const; + + /** + * @brief Gets recipient address. + * @return recipient address. + */ + const std::string &getAddress() const; + + /** + * @brief Gets address-type. + * @return address-type. + */ + MsgAddress::AddressType getAddressType() const; + + /** + * @brief Gets recipient type. + * @return recipient type. + */ + MsgAddress::RecipientType getRecipType() const; + + /** + * @brief Sets new display name. + * @param[in] dispName new display name. + */ + void setDispName(const std::string &dispName); + + private: + std::string m_Address; + std::string m_DispName; + MsgAddress::AddressType m_AddressType; + MsgAddress::RecipientType m_RecipType; + }; + + inline MbeRecipientItem::MbeRecipientItem(const std::string &address, const std::string &dispName, + MsgAddress::AddressType addressType, MsgAddress::RecipientType recipType) + : m_Address(address) + , m_DispName(dispName) + , m_AddressType(addressType) + , m_RecipType(recipType) + { + } + + inline const std::string &MbeRecipientItem::getDispName() const + { + return m_DispName; + } + + inline const std::string &MbeRecipientItem::getAddress() const + { + return m_Address; + } + + inline MsgAddress::AddressType MbeRecipientItem::getAddressType() const + { + return m_AddressType; + } + + inline MsgAddress::RecipientType MbeRecipientItem::getRecipType() const + { + return m_RecipType; + } + + inline void MbeRecipientItem::setDispName(const std::string &dispName) + { + m_DispName = dispName; + if (getElmObjItem()) + setText(dispName); + } } #endif /* MbeRecipientItem_h_ */ diff --git a/src/Common/View/inc/MbeRecipientsView.h b/src/Common/View/inc/MbeRecipientsView.h index fe7e0a27..90934eaa 100644 --- a/src/Common/View/inc/MbeRecipientsView.h +++ b/src/Common/View/inc/MbeRecipientsView.h @@ -23,82 +23,82 @@ #include namespace Msg { - class IMbeRecipientsListener; - - /** - * @brief Wraps all basic multibutton entry(mbe) operations. - */ - class MbeRecipientsView - : public View { - public: - MbeRecipientsView(Evas_Object *parent); - virtual ~MbeRecipientsView(); - - /** - * @brief Appends new item into mbe. - * @param[in] item new item to be appended. - */ - void appendItem(MbeRecipientItem &item); - - /** - * @brief Gets number of mbe items. - * @return items count. - */ - int getItemsCount() const; - - /** - * @brief Gets mbe items collection. - * @return mbe items. - */ - std::vector getItems() const; - - /** - * @brief Gets mbe's selected item. - * @return selected item or nullptr if no item is selected. - */ - MbeRecipientItem *getSelectedItem() const; - - /** - * @brief Checks whether mbe is empty or not. - * @return true if mbe is empty false otherwise. - */ - bool isEmpty() const; - - /** - * @brief Removes all mbe items. - */ - void clear(); - - void setListener(IMbeRecipientsListener *pListener); - private: - void onMbeItemClicked(Evas_Object *obj, void *eventInfo); - void onMbeChanged(Evas_Object *obj, void *eventInfo); - - - private: - IMbeRecipientsListener *m_pListener; - MbeRecipientItem *m_pSelectedItem; - Ecore_Job *m_pChangedJob; - }; - - /** - * @brief A listener class that should be implemented by all mbe event subscribers. - */ - class IMbeRecipientsListener { - public: - virtual ~IMbeRecipientsListener() {}; - - /** - * @brief Notification about some mbe item being clicked. - * @param[in] item clicked item. - */ - virtual void onMbeItemClicked(MbeRecipientItem &item) {}; - - /** - * @brief Notification about mbe content being changed(Item was added or deleted). - */ - virtual void onMbeChanged() {}; - }; + class IMbeRecipientsListener; + + /** + * @brief Wraps all basic multibutton entry(mbe) operations. + */ + class MbeRecipientsView + : public View { + public: + MbeRecipientsView(Evas_Object *parent); + virtual ~MbeRecipientsView(); + + /** + * @brief Appends new item into mbe. + * @param[in] item new item to be appended. + */ + void appendItem(MbeRecipientItem &item); + + /** + * @brief Gets number of mbe items. + * @return items count. + */ + int getItemsCount() const; + + /** + * @brief Gets mbe items collection. + * @return mbe items. + */ + std::vector getItems() const; + + /** + * @brief Gets mbe's selected item. + * @return selected item or nullptr if no item is selected. + */ + MbeRecipientItem *getSelectedItem() const; + + /** + * @brief Checks whether mbe is empty or not. + * @return true if mbe is empty false otherwise. + */ + bool isEmpty() const; + + /** + * @brief Removes all mbe items. + */ + void clear(); + + void setListener(IMbeRecipientsListener *pListener); + private: + void onMbeItemClicked(Evas_Object *obj, void *eventInfo); + void onMbeChanged(Evas_Object *obj, void *eventInfo); + + + private: + IMbeRecipientsListener *m_pListener; + MbeRecipientItem *m_pSelectedItem; + Ecore_Job *m_pChangedJob; + }; + + /** + * @brief A listener class that should be implemented by all mbe event subscribers. + */ + class IMbeRecipientsListener { + public: + virtual ~IMbeRecipientsListener() {}; + + /** + * @brief Notification about some mbe item being clicked. + * @param[in] item clicked item. + */ + virtual void onMbeItemClicked(MbeRecipientItem &item) {}; + + /** + * @brief Notification about mbe content being changed(Item was added or deleted). + */ + virtual void onMbeChanged() {}; + }; } #endif /* MbeRecipientsView_h_ */ diff --git a/src/Common/View/inc/NaviFrameItem.h b/src/Common/View/inc/NaviFrameItem.h index 84de4d50..4f00b01d 100644 --- a/src/Common/View/inc/NaviFrameItem.h +++ b/src/Common/View/inc/NaviFrameItem.h @@ -26,232 +26,232 @@ #include namespace Msg { - class NaviFrameView; - class NaviFrameItem; - typedef std::vector NaviFrameItemList; - - /** - * @brief Wraps all basic Naviframe-item operations. - */ - class NaviFrameItem - : public ViewItem { - friend class NaviFrameView; - - public: - /** - * @brief An identifiers of buttons that can be shown on the top naviframe-item. - */ - enum NaviButtonId { - NaviCancelButtonId = 0,/**< Cancel-button */ - NaviOkButtonId, /**< OK-button */ - NaviCenterButtonId, /**< Central-button */ - NaviPrevButtonId, /**< "Previous"-button */ - NaviExpandButtonId, /**< "Expand"-button */ - NaviButtonMax - }; - - public: - class NaviBar; - - /** - * A constructor of NaviFrameItem object based on outside parent object. Creates nested navibar. - * @param[in] owner an object responsible for automatic removing of NaviFrameItem instance. - */ - NaviFrameItem(NaviFrameView &owner); - virtual ~NaviFrameItem(); - - public: - /** - * @brief Gets nested navibar. - * @return nested navibar. - */ - const NaviBar &getNaviBar() const; - NaviBar &getNaviBar(); - - /** - * @brief Gets NaviframeView that owns this item. - * @return owner of this item. - */ - NaviFrameView &getOwner(); - const NaviFrameView &getOwner() const; - - /** - * @brief Gets popping status - * @return true if current frame is popping and will be destroyed, false otherwise. - */ - bool isPopping() const; - - protected: - virtual void onButtonClicked(NaviFrameItem &item, NaviButtonId buttonId) {}; - - //ViewItem - virtual void onAttached(ViewItem &item); - virtual void onTransitionFinished(NaviFrameItem &item) {}; - - private: - void setTitleVisibility(bool visible); - - private: - NaviFrameView &m_Owner; - NaviBar *m_pNaviBar; - bool m_IsPopping; - }; - - /** - * @brief A bar at the top of NaviFrameItem. - */ - class NaviFrameItem::NaviBar - : public View { - friend class NaviFrameItem; - - public: - /** - * @brief An enumeration of colors that could be applied to Navibar's background. - */ - enum NaviColorId { - NaviBlueColorId = 0,/**< Blue */ - NaviWhiteColorId, /**< White */ - NaviColorMax - }; - - public: - /** - * @brief Gets NaviframeItem instance that owns this navibar - * @return owner of this navibar. - */ - NaviFrameItem &getOwner(); - const NaviFrameItem &getOwner() const; - - /** - * @brief Manages navibar's visibility. - * @param[in] visible if true shows navibar, if false - hides it. - */ - void setVisible(bool visible); - - /** - * @brief Sets navibar title with a specified plain text. - * @param[in] title a plain text of new title. - */ - void setTitle(const std::string &title); - - /** - * @brief Sets Title with translatable string-id. - * @param[in] title translatable text. - */ - void setTitle(const TText &title); - - /** - * @brief Gets navibar title text. - * @return title. - */ - std::string getTitle() const; - - /** - * @brief Manages visibility of navibar-button identified with specified id. - * @param[in] id button-id. - * @param[in] value if true the button is visible, if false - hides the button. - */ - void showButton(NaviButtonId id, bool value); - - /** - * @brief Disables(enables) button with specified id. - * @param[in] id id of button to be disabled(enabled). - * @param[in] value if true disables the button otherwise enables it. - */ - void disabledButton(NaviButtonId id, bool value); - - /** - * @brief Sets specified plain text to a button with specified id. - * @param[in] id button-id. - * @param[in] text a plain text to set. - */ - void setButtonText(NaviButtonId id, const std::string &text); - - /** - * @brief Sets specified translatable text to a button with specified id. - * @param[in] id button-id. - * @param[in] text a translatable text to set. - */ - void setButtonText(NaviButtonId id, const TText &text); - - /** - * @brief Hides all buttons on navibar. - */ - void clear(); - - /** - * @brief Sets search-panel layout. - * @param[in] searchPanel a layout with search panel. - */ - void setSearch(Evas_Object *searchPanel); - - /** - * @brief Gets search-panel layout. - * @return layout with search panel. - */ - Evas_Object *getSearch(); - const Evas_Object *getSearch() const; - - /** - * @brief Shows search-panel. - */ - void showSearch(); - - /** - * @brief Hides search-panel. - */ - void hideSearch(); - - /** - * @brief Changes navibar color. - * @param[in] id code of supported color. - */ - void setColor(NaviColorId id); - - /** - * @brief Manages state of down-button. - * @param Changes picture of down-button. If true sets down-arrow to down-button otherwise sets up-arrow there. - */ - void setDownButtonState(bool expand); - - private: - - NaviBar(NaviFrameItem &onwer); - virtual ~NaviBar(); - - void getButton(NaviButtonId id); - void setButtonColor(NaviButtonId id, NaviColorId titleColor); - void showCancelButtonPart(bool value); - void showOkButtonPart(bool value); - void showCenterButtonPart(bool value); - void showPrevButtonPart(bool value); - void showDownButtonPart(bool value); - int getTextSize(NaviFrameItem::NaviButtonId id) const; - - static void on_button_clicked(void *data, Evas_Object *obj, void *event_info); - - private: - struct ButtonStruct { - ButtonStruct(Evas_Object *b = nullptr, const char *p = nullptr, const char *s = nullptr, const char *d = nullptr) - : button(b) - , part(p) - , style(s) - , default_text_id(d) - { - } - Evas_Object *button; - const char *part; - const char *style; - const char *default_text_id; - }; - - private: - NaviFrameItem &m_Owner; - std::string m_Badge; - ButtonStruct m_ButtonList[NaviButtonMax]; - NaviColorId m_CurrentColor; - Evas_Object *m_SearchBar; - }; + class NaviFrameView; + class NaviFrameItem; + typedef std::vector NaviFrameItemList; + + /** + * @brief Wraps all basic Naviframe-item operations. + */ + class NaviFrameItem + : public ViewItem { + friend class NaviFrameView; + + public: + /** + * @brief An identifiers of buttons that can be shown on the top naviframe-item. + */ + enum NaviButtonId { + NaviCancelButtonId = 0,/**< Cancel-button */ + NaviOkButtonId, /**< OK-button */ + NaviCenterButtonId, /**< Central-button */ + NaviPrevButtonId, /**< "Previous"-button */ + NaviExpandButtonId, /**< "Expand"-button */ + NaviButtonMax + }; + + public: + class NaviBar; + + /** + * A constructor of NaviFrameItem object based on outside parent object. Creates nested navibar. + * @param[in] owner an object responsible for automatic removing of NaviFrameItem instance. + */ + NaviFrameItem(NaviFrameView &owner); + virtual ~NaviFrameItem(); + + public: + /** + * @brief Gets nested navibar. + * @return nested navibar. + */ + const NaviBar &getNaviBar() const; + NaviBar &getNaviBar(); + + /** + * @brief Gets NaviframeView that owns this item. + * @return owner of this item. + */ + NaviFrameView &getOwner(); + const NaviFrameView &getOwner() const; + + /** + * @brief Gets popping status + * @return true if current frame is popping and will be destroyed, false otherwise. + */ + bool isPopping() const; + + protected: + virtual void onButtonClicked(NaviFrameItem &item, NaviButtonId buttonId) {}; + + //ViewItem + virtual void onAttached(ViewItem &item); + virtual void onTransitionFinished(NaviFrameItem &item) {}; + + private: + void setTitleVisibility(bool visible); + + private: + NaviFrameView &m_Owner; + NaviBar *m_pNaviBar; + bool m_IsPopping; + }; + + /** + * @brief A bar at the top of NaviFrameItem. + */ + class NaviFrameItem::NaviBar + : public View { + friend class NaviFrameItem; + + public: + /** + * @brief An enumeration of colors that could be applied to Navibar's background. + */ + enum NaviColorId { + NaviBlueColorId = 0,/**< Blue */ + NaviWhiteColorId, /**< White */ + NaviColorMax + }; + + public: + /** + * @brief Gets NaviframeItem instance that owns this navibar + * @return owner of this navibar. + */ + NaviFrameItem &getOwner(); + const NaviFrameItem &getOwner() const; + + /** + * @brief Manages navibar's visibility. + * @param[in] visible if true shows navibar, if false - hides it. + */ + void setVisible(bool visible); + + /** + * @brief Sets navibar title with a specified plain text. + * @param[in] title a plain text of new title. + */ + void setTitle(const std::string &title); + + /** + * @brief Sets Title with translatable string-id. + * @param[in] title translatable text. + */ + void setTitle(const TText &title); + + /** + * @brief Gets navibar title text. + * @return title. + */ + std::string getTitle() const; + + /** + * @brief Manages visibility of navibar-button identified with specified id. + * @param[in] id button-id. + * @param[in] value if true the button is visible, if false - hides the button. + */ + void showButton(NaviButtonId id, bool value); + + /** + * @brief Disables(enables) button with specified id. + * @param[in] id id of button to be disabled(enabled). + * @param[in] value if true disables the button otherwise enables it. + */ + void disabledButton(NaviButtonId id, bool value); + + /** + * @brief Sets specified plain text to a button with specified id. + * @param[in] id button-id. + * @param[in] text a plain text to set. + */ + void setButtonText(NaviButtonId id, const std::string &text); + + /** + * @brief Sets specified translatable text to a button with specified id. + * @param[in] id button-id. + * @param[in] text a translatable text to set. + */ + void setButtonText(NaviButtonId id, const TText &text); + + /** + * @brief Hides all buttons on navibar. + */ + void clear(); + + /** + * @brief Sets search-panel layout. + * @param[in] searchPanel a layout with search panel. + */ + void setSearch(Evas_Object *searchPanel); + + /** + * @brief Gets search-panel layout. + * @return layout with search panel. + */ + Evas_Object *getSearch(); + const Evas_Object *getSearch() const; + + /** + * @brief Shows search-panel. + */ + void showSearch(); + + /** + * @brief Hides search-panel. + */ + void hideSearch(); + + /** + * @brief Changes navibar color. + * @param[in] id code of supported color. + */ + void setColor(NaviColorId id); + + /** + * @brief Manages state of down-button. + * @param Changes picture of down-button. If true sets down-arrow to down-button otherwise sets up-arrow there. + */ + void setDownButtonState(bool expand); + + private: + + NaviBar(NaviFrameItem &onwer); + virtual ~NaviBar(); + + void getButton(NaviButtonId id); + void setButtonColor(NaviButtonId id, NaviColorId titleColor); + void showCancelButtonPart(bool value); + void showOkButtonPart(bool value); + void showCenterButtonPart(bool value); + void showPrevButtonPart(bool value); + void showDownButtonPart(bool value); + int getTextSize(NaviFrameItem::NaviButtonId id) const; + + static void on_button_clicked(void *data, Evas_Object *obj, void *event_info); + + private: + struct ButtonStruct { + ButtonStruct(Evas_Object *b = nullptr, const char *p = nullptr, const char *s = nullptr, const char *d = nullptr) + : button(b) + , part(p) + , style(s) + , default_text_id(d) + { + } + Evas_Object *button; + const char *part; + const char *style; + const char *default_text_id; + }; + + private: + NaviFrameItem &m_Owner; + std::string m_Badge; + ButtonStruct m_ButtonList[NaviButtonMax]; + NaviColorId m_CurrentColor; + Evas_Object *m_SearchBar; + }; } #endif /* NaviFrameItem_h_ */ diff --git a/src/Common/View/inc/NaviFrameView.h b/src/Common/View/inc/NaviFrameView.h index ece8d6ae..6b05b9a0 100644 --- a/src/Common/View/inc/NaviFrameView.h +++ b/src/Common/View/inc/NaviFrameView.h @@ -22,91 +22,91 @@ #include namespace Msg { - /** - * @brief Wraps all basic Naviframe operations. - */ - class NaviFrameView - : public View { - public: - NaviFrameView(Evas_Object *parent); - NaviFrameView(View &parent); - virtual ~NaviFrameView(); - - /** - * @brief Checks is it last frame. - */ - bool isLastFrame() const; - - /** - * @brief Get count of pushed frames. - */ - int getItemsCount() const; - /** - * @brief Get list of pushed frames. - */ - NaviFrameItemList getItems() const; - - /** - * @brief Checks if any frame was pushed. - */ - bool isEmpty() const; - - /** - * @brief Pushes new frame. Attaches @content to frame. Updates @item with created frame. - */ - void push(NaviFrameItem &item, Evas_Object *content = nullptr); - void push(NaviFrameItem &item, View &content); - - /** - * @brief Pops top item from Naviframe. - */ - void pop(); - - /** - * @brief Pops item from Naviframe. - * @param[in] item NaviFrame item for pop. - */ - void pop(NaviFrameItem &item); - - /** - * @brief Inserts specified item to bottom of item's stack. - * @param[in] item an item to be inserted. - */ - void insertToBottom(NaviFrameItem &item); - - /** - * @brief Promote an item already in the naviframe stack to the top of the stack - * @param[in] item an item to be promoted. - */ - void promote(NaviFrameItem &item); - - /** - * @brief Gets top frame from items-stack. - * @return Top naviframe-item or nullptr if item-stack is empty. - */ - NaviFrameItem *getTopFrame() const; - - /** - * Checks if item transition is in progress. - * @return true if transition is in progress, false otherwise. - */ - bool getTransitionStatus() const; - - protected: - virtual void onPause(NaviFrameItem &item) {}; - virtual void onResume(NaviFrameItem &item) {}; - virtual void onBeforeDelete(View &view); - - private: - void create(Evas_Object *parent); - void pause(); - void resume(); - void onTransitionFinished(Evas_Object *obj, void *eventInfo); - - private: - bool m_TransitionStatus; - std::vector m_ItemsToDelete; - }; + /** + * @brief Wraps all basic Naviframe operations. + */ + class NaviFrameView + : public View { + public: + NaviFrameView(Evas_Object *parent); + NaviFrameView(View &parent); + virtual ~NaviFrameView(); + + /** + * @brief Checks is it last frame. + */ + bool isLastFrame() const; + + /** + * @brief Get count of pushed frames. + */ + int getItemsCount() const; + /** + * @brief Get list of pushed frames. + */ + NaviFrameItemList getItems() const; + + /** + * @brief Checks if any frame was pushed. + */ + bool isEmpty() const; + + /** + * @brief Pushes new frame. Attaches @content to frame. Updates @item with created frame. + */ + void push(NaviFrameItem &item, Evas_Object *content = nullptr); + void push(NaviFrameItem &item, View &content); + + /** + * @brief Pops top item from Naviframe. + */ + void pop(); + + /** + * @brief Pops item from Naviframe. + * @param[in] item NaviFrame item for pop. + */ + void pop(NaviFrameItem &item); + + /** + * @brief Inserts specified item to bottom of item's stack. + * @param[in] item an item to be inserted. + */ + void insertToBottom(NaviFrameItem &item); + + /** + * @brief Promote an item already in the naviframe stack to the top of the stack + * @param[in] item an item to be promoted. + */ + void promote(NaviFrameItem &item); + + /** + * @brief Gets top frame from items-stack. + * @return Top naviframe-item or nullptr if item-stack is empty. + */ + NaviFrameItem *getTopFrame() const; + + /** + * Checks if item transition is in progress. + * @return true if transition is in progress, false otherwise. + */ + bool getTransitionStatus() const; + + protected: + virtual void onPause(NaviFrameItem &item) {}; + virtual void onResume(NaviFrameItem &item) {}; + virtual void onBeforeDelete(View &view); + + private: + void create(Evas_Object *parent); + void pause(); + void resume(); + void onTransitionFinished(Evas_Object *obj, void *eventInfo); + + private: + bool m_TransitionStatus; + std::vector m_ItemsToDelete; + }; } #endif /* NaviFrameView_h_ */ diff --git a/src/Common/View/inc/NoContentLayout.h b/src/Common/View/inc/NoContentLayout.h index 5234be9a..49ecb484 100644 --- a/src/Common/View/inc/NoContentLayout.h +++ b/src/Common/View/inc/NoContentLayout.h @@ -22,19 +22,19 @@ #include namespace Msg { - /** - * @brief A Layout that shows a message text when ThreadList is empty - */ - class NoContentLayout - : public View { - public: - NoContentLayout(Evas_Object *parent); - virtual ~NoContentLayout(); + /** + * @brief A Layout that shows a message text when ThreadList is empty + */ + class NoContentLayout + : public View { + public: + NoContentLayout(Evas_Object *parent); + virtual ~NoContentLayout(); - void setText(const TText &text); - void setHelpText(const TText &text); - void setHelpText(const std::string &text = ""); - }; + void setText(const TText &text); + void setHelpText(const TText &text); + void setHelpText(const std::string &text = ""); + }; } #endif /* NoContentLayout_h_ */ diff --git a/src/Common/View/inc/Popup.h b/src/Common/View/inc/Popup.h index ab38e84f..d46f5a3c 100644 --- a/src/Common/View/inc/Popup.h +++ b/src/Common/View/inc/Popup.h @@ -24,65 +24,65 @@ #include namespace Msg { - class IPopupListener; - class Popup; - class PopupManager; + class IPopupListener; + class Popup; + class PopupManager; - typedef void (*PopupButtonCb)(Popup &popup, int buttonId, void *userData); - #define POPUP_BUTTON_CB(ClassName, method) [](Popup &popup, int buttonId, void *userData) \ - { \ - static_cast(userData)->method(popup, buttonId); \ - } + typedef void (*PopupButtonCb)(Popup &popup, int buttonId, void *userData); + #define POPUP_BUTTON_CB(ClassName, method) [](Popup &popup, int buttonId, void *userData) \ + { \ + static_cast(userData)->method(popup, buttonId); \ + } - class Popup - : public View { - public: + class Popup + : public View { + public: - static void defaultButtonCb(Popup &popup, int buttonId, void *userData); - enum ButtonID { - OkButtonId, - CancelButtonId - }; + static void defaultButtonCb(Popup &popup, int buttonId, void *userData); + enum ButtonID { + OkButtonId, + CancelButtonId + }; - public: - Popup(Evas_Object *parent); - Popup(PopupManager &parent); - virtual ~Popup(); + public: + Popup(Evas_Object *parent); + Popup(PopupManager &parent); + virtual ~Popup(); - void show(bool deferred = true); - Evas_Object *getHostEvasObject() const; - Evas_Object *setContent(Evas_Object *content); - void setContent(const std::string &text); - void setContent(const TText &text); - Evas_Object *getContent() const; - void setHeight(int height); - void setDismissByOutsideTapFlag(bool value); - void setDismissByMoreMenuKeyFlag(bool value); - bool getDismissByMoreMenuKeyFlag() const; - void setDismissByPauseAppFlag(bool value); - bool getDismissByPauseAppFlag() const; - Evas_Object *addButton(const TText &text, int buttonId, PopupButtonCb buttonCb = defaultButtonCb, void *userData = nullptr); - void setTitle(const std::string &title); - void setTitle(const TText &title); - void destroy(); - void setTimeOut(double timeout); + void show(bool deferred = true); + Evas_Object *getHostEvasObject() const; + Evas_Object *setContent(Evas_Object *content); + void setContent(const std::string &text); + void setContent(const TText &text); + Evas_Object *getContent() const; + void setHeight(int height); + void setDismissByOutsideTapFlag(bool value); + void setDismissByMoreMenuKeyFlag(bool value); + bool getDismissByMoreMenuKeyFlag() const; + void setDismissByPauseAppFlag(bool value); + bool getDismissByPauseAppFlag() const; + Evas_Object *addButton(const TText &text, int buttonId, PopupButtonCb buttonCb = defaultButtonCb, void *userData = nullptr); + void setTitle(const std::string &title); + void setTitle(const TText &title); + void destroy(); + void setTimeOut(double timeout); - private: + private: - void create(Evas_Object *parent); - static void on_button_clicked(void *data, Evas_Object *obj, void *event_info); - static void on_popup_block_clicked_cb(void *data, Evas_Object *obj, void *event_info); + void create(Evas_Object *parent); + static void on_button_clicked(void *data, Evas_Object *obj, void *event_info); + static void on_popup_block_clicked_cb(void *data, Evas_Object *obj, void *event_info); - private: - Evas_Object *m_pBox; - Evas_Object *m_pContent; - int m_CurrentButtonIndex; - bool m_OutsideTapDismiss; - bool m_MoreKeyDismiss; - bool m_PauseAppDismiss; - PopupManager *m_pManager; - Ecore_Idler *m_pShowIdler; - }; + private: + Evas_Object *m_pBox; + Evas_Object *m_pContent; + int m_CurrentButtonIndex; + bool m_OutsideTapDismiss; + bool m_MoreKeyDismiss; + bool m_PauseAppDismiss; + PopupManager *m_pManager; + Ecore_Idler *m_pShowIdler; + }; } #endif /* Popup_h_ */ diff --git a/src/Common/View/inc/PopupAttachmentListItem.h b/src/Common/View/inc/PopupAttachmentListItem.h index c4405434..767b5d44 100644 --- a/src/Common/View/inc/PopupAttachmentListItem.h +++ b/src/Common/View/inc/PopupAttachmentListItem.h @@ -21,21 +21,21 @@ namespace Msg { - /** - * @brief A class of popup-for attach files - */ - class PopupAttachmentListItem - : public PopupCheckListItem { - public: - PopupAttachmentListItem(PopupList &parent, const std::string &text, const std::string &path, - PopupListItemPressedCb cb, void *userData); - virtual ~PopupAttachmentListItem(); + /** + * @brief A class of popup-for attach files + */ + class PopupAttachmentListItem + : public PopupCheckListItem { + public: + PopupAttachmentListItem(PopupList &parent, const std::string &text, const std::string &path, + PopupListItemPressedCb cb, void *userData); + virtual ~PopupAttachmentListItem(); - public: - const std::string &getFilePath() const; + public: + const std::string &getFilePath() const; - private: - std::string m_FilePath; - }; + private: + std::string m_FilePath; + }; } #endif /* PopupAttachmentListItem_h_ */ diff --git a/src/Common/View/inc/PopupList.h b/src/Common/View/inc/PopupList.h index f2eb8c2b..a21c1025 100644 --- a/src/Common/View/inc/PopupList.h +++ b/src/Common/View/inc/PopupList.h @@ -22,61 +22,61 @@ #include "PopupListItem.h" namespace Msg { - /** - * @brief A popup with list of available popup items. - */ - class PopupList - : public Popup - , private IListViewListener { - public: - enum PopupListType { - ListPopup, /**< Popup with title >*/ - MoreMenuPopup /**< Popup without title, hides by more button and pause events >*/ - }; - public: - PopupList(Evas_Object *parent, PopupListType type = ListPopup); - PopupList(PopupManager &parent, PopupListType type = ListPopup); - virtual ~PopupList(); + /** + * @brief A popup with list of available popup items. + */ + class PopupList + : public Popup + , private IListViewListener { + public: + enum PopupListType { + ListPopup, /**< Popup with title >*/ + MoreMenuPopup /**< Popup without title, hides by more button and pause events >*/ + }; + public: + PopupList(Evas_Object *parent, PopupListType type = ListPopup); + PopupList(PopupManager &parent, PopupListType type = ListPopup); + virtual ~PopupList(); - /** - * @brief Appends specified existing item to popup list. - * @param[in] item an item created outside to be appended. - */ - void appendItem(PopupListItem &item); + /** + * @brief Appends specified existing item to popup list. + * @param[in] item an item created outside to be appended. + */ + void appendItem(PopupListItem &item); - /** - * @brief Creates an item with a single string based on specified parameters and appends it to popup list. - * @param[in] text a text displayed on popup list item. - * @param[in] cb a callback raised by tap on this item. - * @param[in] userData user data passed to item's on-press callback. - */ - void appendItem(const std::string &text, PopupListItemPressedCb cb, void *userData); + /** + * @brief Creates an item with a single string based on specified parameters and appends it to popup list. + * @param[in] text a text displayed on popup list item. + * @param[in] cb a callback raised by tap on this item. + * @param[in] userData user data passed to item's on-press callback. + */ + void appendItem(const std::string &text, PopupListItemPressedCb cb, void *userData); - /** - * Creates an item with a single string and a stored filepath based on specified parameters and appends it to popup list. - * @param[in] text a text displayed on popup list item. - * @param[in] path filepath. - * @param[in] cb a callback raised by tap on this item. - * @param[in] userData user data passed to item's on-press callback. - */ - void appendItem(const std::string &text, const std::string &path, PopupListItemPressedCb cb, void *userData); + /** + * Creates an item with a single string and a stored filepath based on specified parameters and appends it to popup list. + * @param[in] text a text displayed on popup list item. + * @param[in] path filepath. + * @param[in] cb a callback raised by tap on this item. + * @param[in] userData user data passed to item's on-press callback. + */ + void appendItem(const std::string &text, const std::string &path, PopupListItemPressedCb cb, void *userData); - /** - * @brief Gets nested list-view. - * @return list-view. - */ - ListView &getListView(); - const ListView &getListView() const; + /** + * @brief Gets nested list-view. + * @return list-view. + */ + ListView &getListView(); + const ListView &getListView() const; - private: - virtual void onListItemSelected(ListItem &listItem); + private: + virtual void onListItemSelected(ListItem &listItem); - void create(PopupListType type); - Evas_Object *createList(Evas_Object *parent); + void create(PopupListType type); + Evas_Object *createList(Evas_Object *parent); - private: - ListView *m_pList; - }; + private: + ListView *m_pList; + }; } #endif /* PopupList_h_ */ diff --git a/src/Common/View/inc/PopupListItem.h b/src/Common/View/inc/PopupListItem.h index 75bb7c84..20d40783 100644 --- a/src/Common/View/inc/PopupListItem.h +++ b/src/Common/View/inc/PopupListItem.h @@ -20,57 +20,57 @@ #include "ListItem.h" namespace Msg { - class PopupList; - class PopupListItem; + class PopupList; + class PopupListItem; - /** @brief Callback raised when popup-list item was clicked.*/ - typedef void (*PopupListItemPressedCb)(PopupListItem &item, void *userData); - #define POPUPLIST_ITEM_PRESSED_CB(ClassName, method) [](PopupListItem &item, void *userData) \ - { \ - static_cast(userData)->method(item); \ - } + /** @brief Callback raised when popup-list item was clicked.*/ + typedef void (*PopupListItemPressedCb)(PopupListItem &item, void *userData); + #define POPUPLIST_ITEM_PRESSED_CB(ClassName, method) [](PopupListItem &item, void *userData) \ + { \ + static_cast(userData)->method(item); \ + } - /** - * @brief Generic Popup-list item class - */ - class PopupListItem: public ListItem { - public: - PopupListItem(PopupList &parent, PopupListItemPressedCb cb, void *userData); - PopupList &getParent(); - void fireCallback(); - private: - PopupList &m_Parent; - PopupListItemPressedCb m_Cb; - void *m_pUserData; - }; + /** + * @brief Generic Popup-list item class + */ + class PopupListItem: public ListItem { + public: + PopupListItem(PopupList &parent, PopupListItemPressedCb cb, void *userData); + PopupList &getParent(); + void fireCallback(); + private: + PopupList &m_Parent; + PopupListItemPressedCb m_Cb; + void *m_pUserData; + }; - /** - * @brief A class of popup-item with single text displayed. - */ - class PopupTextListItem: public PopupListItem { - public: - PopupTextListItem(PopupList &parent, const std::string &text, PopupListItemPressedCb cb, void *userData); - virtual ~PopupTextListItem(); - private: - virtual std::string getText(ListItem &item, const char *part); - private: - std::string m_Text; - }; + /** + * @brief A class of popup-item with single text displayed. + */ + class PopupTextListItem: public PopupListItem { + public: + PopupTextListItem(PopupList &parent, const std::string &text, PopupListItemPressedCb cb, void *userData); + virtual ~PopupTextListItem(); + private: + virtual std::string getText(ListItem &item, const char *part); + private: + std::string m_Text; + }; - /** - * @brief A class of popup-item with text and check field. - */ - class PopupCheckListItem: public PopupListItem { - public: - PopupCheckListItem(PopupList &parent, const std::string &text, PopupListItemPressedCb cb, void *userData); - virtual ~PopupCheckListItem(); + /** + * @brief A class of popup-item with text and check field. + */ + class PopupCheckListItem: public PopupListItem { + public: + PopupCheckListItem(PopupList &parent, const std::string &text, PopupListItemPressedCb cb, void *userData); + virtual ~PopupCheckListItem(); - private: - virtual const char *getCheckPart(ListItem &item); - virtual std::string getText(ListItem &item, const char *part); - private: - std::string m_Text; - }; + private: + virtual const char *getCheckPart(ListItem &item); + virtual std::string getText(ListItem &item, const char *part); + private: + std::string m_Text; + }; } #endif /* PopupListItem_h_ */ diff --git a/src/Common/View/inc/PopupManager.h b/src/Common/View/inc/PopupManager.h index e803b0e5..82703e4d 100644 --- a/src/Common/View/inc/PopupManager.h +++ b/src/Common/View/inc/PopupManager.h @@ -22,108 +22,108 @@ #include "ContextPopup.h" namespace Msg { - class Window; - - /** - * @brief A global instance that manages context popups and regular popups lifecycle in context of one window. - */ - class PopupManager { - public: - /** - * @brief Creating PopupManager instance in context of specified window. - * @param[in] window a window context. - */ - PopupManager(Window &window); - ~PopupManager(); - - PopupManager(PopupManager&) = delete; - PopupManager &operator=(PopupManager&) = delete; - - /** - * @brief Gets window-context. - * @return window-context. - */ - Window &getWindow() const; - - /** - * @brief Checks whether any context or regular popup is visible. - * @return false if no popup is visible otherwise true. - */ - bool isVisible() const; - - /** - * @brief Destroys all popups (context and regular) created before. - * If no popup was created nothing happens. - * @param[in] popupOwner if popupOwner pointer not nullptr only popup owner can destroy current popup. - */ - void reset(void *popupOwner = nullptr); - - /** - * @brief Destroys previous popup and register new in manager - * @param[in] popup a new popup for register. - * @param[in] new popup owner - */ - void reset(Popup &popup, void *newOwner = nullptr); - - /** - * @brief Creates popup-list. - * @param[in] new popup owner - * @return created popup-list. - */ - PopupList &getPopupList(void *newOwner = nullptr); - - /** - * @brief Creates more-popup. - * @param[in] new popup owner - * @return created more-popup - */ - PopupList &getMorePopup(void *newOwner = nullptr); - - /** - * @brief Creates base-popup. - * @param[in] new popup owner - * @return popup created. - */ - Popup &getPopup(void *newOwner = nullptr); - - /** - * @brief Creates specific popup. - * @param[in] variadic arguments - * @return popup created. - */ - template - ClassName &getPopup(Args&&... args, void *newOwner = nullptr); - - /** - * @brief Checks whether popup exists and it's visible. - * @return true if popup exists and it's visible, false otherwise. - */ - bool isPopupVisible() const; - - /** - * @brief Process pause event - */ - void onPause(); - - private: - void onHwBackButtonPopupClicked(Evas_Object *obj, void *eventInfo); - void onHwMoreButtonPopupListClicked(Evas_Object *obj, void *eventInfo); - - private: - Popup *m_pPopup; - Window &m_Window; - void *m_pPopupOwner; - }; - - template - ClassName &PopupManager::getPopup(Args&&... args, void *newOwner) - { - reset(); - m_pPopup = new ClassName(*this, std::forward(args)...); - m_pPopupOwner = newOwner; - eext_object_event_callback_add(*m_pPopup, EEXT_CALLBACK_BACK, SMART_CALLBACK(PopupManager, onHwBackButtonPopupClicked), this); - return static_cast(*m_pPopup); - } + class Window; + + /** + * @brief A global instance that manages context popups and regular popups lifecycle in context of one window. + */ + class PopupManager { + public: + /** + * @brief Creating PopupManager instance in context of specified window. + * @param[in] window a window context. + */ + PopupManager(Window &window); + ~PopupManager(); + + PopupManager(PopupManager&) = delete; + PopupManager &operator=(PopupManager&) = delete; + + /** + * @brief Gets window-context. + * @return window-context. + */ + Window &getWindow() const; + + /** + * @brief Checks whether any context or regular popup is visible. + * @return false if no popup is visible otherwise true. + */ + bool isVisible() const; + + /** + * @brief Destroys all popups (context and regular) created before. + * If no popup was created nothing happens. + * @param[in] popupOwner if popupOwner pointer not nullptr only popup owner can destroy current popup. + */ + void reset(void *popupOwner = nullptr); + + /** + * @brief Destroys previous popup and register new in manager + * @param[in] popup a new popup for register. + * @param[in] new popup owner + */ + void reset(Popup &popup, void *newOwner = nullptr); + + /** + * @brief Creates popup-list. + * @param[in] new popup owner + * @return created popup-list. + */ + PopupList &getPopupList(void *newOwner = nullptr); + + /** + * @brief Creates more-popup. + * @param[in] new popup owner + * @return created more-popup + */ + PopupList &getMorePopup(void *newOwner = nullptr); + + /** + * @brief Creates base-popup. + * @param[in] new popup owner + * @return popup created. + */ + Popup &getPopup(void *newOwner = nullptr); + + /** + * @brief Creates specific popup. + * @param[in] variadic arguments + * @return popup created. + */ + template + ClassName &getPopup(Args&&... args, void *newOwner = nullptr); + + /** + * @brief Checks whether popup exists and it's visible. + * @return true if popup exists and it's visible, false otherwise. + */ + bool isPopupVisible() const; + + /** + * @brief Process pause event + */ + void onPause(); + + private: + void onHwBackButtonPopupClicked(Evas_Object *obj, void *eventInfo); + void onHwMoreButtonPopupListClicked(Evas_Object *obj, void *eventInfo); + + private: + Popup *m_pPopup; + Window &m_Window; + void *m_pPopupOwner; + }; + + template + ClassName &PopupManager::getPopup(Args&&... args, void *newOwner) + { + reset(); + m_pPopup = new ClassName(*this, std::forward(args)...); + m_pPopupOwner = newOwner; + eext_object_event_callback_add(*m_pPopup, EEXT_CALLBACK_BACK, SMART_CALLBACK(PopupManager, onHwBackButtonPopupClicked), this); + return static_cast(*m_pPopup); + } } #endif /* PopupManager_h_ */ diff --git a/src/Common/View/inc/Scroller.h b/src/Common/View/inc/Scroller.h index f320ebc9..15db1478 100644 --- a/src/Common/View/inc/Scroller.h +++ b/src/Common/View/inc/Scroller.h @@ -21,20 +21,20 @@ #include namespace Msg { - class Scroller - : public View { - public: - Scroller(Evas_Object *parent); - virtual ~Scroller(); + class Scroller + : public View { + public: + Scroller(Evas_Object *parent); + virtual ~Scroller(); - inline void setPpolicy(Elm_Scroller_Policy h, Elm_Scroller_Policy v); - void navigateToBottom(); - }; + inline void setPpolicy(Elm_Scroller_Policy h, Elm_Scroller_Policy v); + void navigateToBottom(); + }; - inline void Scroller::setPpolicy(Elm_Scroller_Policy h, Elm_Scroller_Policy v) - { - elm_scroller_policy_set(getEo(), h, v); - } + inline void Scroller::setPpolicy(Elm_Scroller_Policy h, Elm_Scroller_Policy v) + { + elm_scroller_policy_set(getEo(), h, v); + } } #endif /* Scroller_h_ */ diff --git a/src/Common/View/inc/SelectAllListItem.h b/src/Common/View/inc/SelectAllListItem.h index 736c297a..14a79c5c 100644 --- a/src/Common/View/inc/SelectAllListItem.h +++ b/src/Common/View/inc/SelectAllListItem.h @@ -22,19 +22,19 @@ #include namespace Msg { - class SelectAllListItem - : public ListItem { - public: - SelectAllListItem(); - virtual ~SelectAllListItem(); + class SelectAllListItem + : public ListItem { + public: + SelectAllListItem(); + virtual ~SelectAllListItem(); - private: - virtual const char *getCheckPart(ListItem &item); - virtual std::string getText(ListItem &item, const char *part); + private: + virtual const char *getCheckPart(ListItem &item); + virtual std::string getText(ListItem &item, const char *part); - private: - std::string m_Text; - }; + private: + std::string m_Text; + }; } #endif // SelectAllListItem_h_ diff --git a/src/Common/View/inc/StandardWindow.h b/src/Common/View/inc/StandardWindow.h index 257b3139..5ed75c5e 100644 --- a/src/Common/View/inc/StandardWindow.h +++ b/src/Common/View/inc/StandardWindow.h @@ -20,26 +20,26 @@ #include "Window.h" namespace Msg { - class StandardWindow - : public Window { - public: - StandardWindow(); - virtual ~StandardWindow(); + class StandardWindow + : public Window { + public: + StandardWindow(); + virtual ~StandardWindow(); - virtual Evas_Object *getWinEvasObject() const; - virtual Evas_Object *getConformEvasObject() const; - virtual Evas_Object *getHostEvasObject() const; - virtual void setContent(Evas_Object *content); - virtual void getScreenSize(int *x, int *y, int *w, int *h) const; - virtual int getRotation() const; + virtual Evas_Object *getWinEvasObject() const; + virtual Evas_Object *getConformEvasObject() const; + virtual Evas_Object *getHostEvasObject() const; + virtual void setContent(Evas_Object *content); + virtual void getScreenSize(int *x, int *y, int *w, int *h) const; + virtual int getRotation() const; - void lower(); - void raise(); + void lower(); + void raise(); - private: - Evas_Object *m_pConform; - Evas_Object *m_pBg; - }; + private: + Evas_Object *m_pConform; + Evas_Object *m_pBg; + }; } #endif /* StandardWindow_h_ */ diff --git a/src/Common/View/inc/View.h b/src/Common/View/inc/View.h index 589f09e7..dbca53ce 100644 --- a/src/Common/View/inc/View.h +++ b/src/Common/View/inc/View.h @@ -26,535 +26,535 @@ #include namespace Msg { - /** - * @brief Wraps all basic Evas_Object operations and manages automatic self-removal by EVAS_CALLBACK_FREE and EVAS_CALLBACK_DEL events. - */ - class View - : public BaseView { - public: - View(); - - /** - * @brief Destroys nested Evas_Object. - */ - void destroy(); - operator Evas_Object *() const; - Evas_Object *getEo() const; - - /** - * @brief Checks whether view is visible or not. - * @return true if view is visible, otherwise false. - */ - bool isVisible() const; - - /** - * @brief Shows view. - * @param[in] value - true show, false - otherwise - */ - void show(bool value = true); - - /** - * @brief Moves view to specified Evas-coordinates. - * @param[in] x x-coordinate - * @param[in] y y-coordinate - */ - void move(Evas_Coord x, Evas_Coord y); - - /** - * @brief Sets size-weight hints. - * @param[in] x x-coordinate - * @param[in] y y-coordinate - */ - void setSizeHintWeight(double x = EVAS_HINT_EXPAND, double y = EVAS_HINT_EXPAND); - - /** - * @brief Sets size-align hints. - * @param[in] x x-coordinate - * @param[in] y y-coordinate - */ - void setSizeHintAlign(double x = EVAS_HINT_FILL, double y = EVAS_HINT_FILL); - - /** - * @brief Make the scroller minimum size limited to the minimum size of the view's content - * - * @param[in] w Enable limiting minimum size horizontally - * @param[in] h Enable limiting minimum size vertically - */ - void setScrollerContentMinLimit(Eina_Bool w, Eina_Bool h); - - /** - * @brief Sets size-weight and size-align hints in order to make view expanded. - */ - void expand(); - - /** - * @brief Sets specified Evas_object's size-weight and size-align hints in order to make it expanded. - * @param[in] obj an Evas_Object to be expanded. - */ - static void expand(Evas_Object *obj); - - /** - * @brief Sets min size hints. - * @param[in] w width hint. - * @param[in] h height hint. - */ - void setSizeHintMin(Evas_Coord w, Evas_Coord h); - - /** - * @brief Sets max size hints. - * @param[in] w width hint. - * @param[in] h height hint. - */ - void setSizeHintMax(Evas_Coord w, Evas_Coord h); - - /** - * @brief Gets min size hints. - * @param[out] w width hint. - * @param[out] h height hint. - */ - void getSizeHintMin(Evas_Coord *w, Evas_Coord *h) const; - - /** - * @brief Gets max size hints. - * @param[out] w width hint. - * @param[out] h height hint. - */ - void getSizeHintMax(Evas_Coord *w, Evas_Coord *h) const; - - /** - * @brief Sets specified content into specified part. - * @param[in] content a content to set into view. - * @param[in] part a part content should be placed to. If part is nullptr the default part is used. - * @param[in] saveOldContent a flag that checks whether old view's content should be returned or not. - * @return if saveOldContent is true returns old content set into view before, otherwise returns nullptr. - */ - Evas_Object *setContent(Evas_Object *content, const char *part = nullptr, bool saveOldContent = false); - - /** - * @brief Unsets view's content. - * @param[in] part a part content should be removed from. If part is nullptr the default part is used. - * @return old view's content in case of success, nullptr in case of errors. - */ - Evas_Object *unsetContent(const char *part = nullptr); - - /** - * @brief Gets view's content. - * @param[in] part a content-part. If part is nullptr the default part is used. - * @return view's content in case of success, nullptr in case of errors. - */ - Evas_Object* getContent(const char *part = nullptr) const; - - /** - * @brief Set the ability for an view object to be focused. - * @param[in] enable if true view is enabled to be focused, otherwise it can not be focused. - */ - void setFocusAllow(bool enable); - - /** - * @brief Checks whether view can be focused or not. - * @return true if view is able to be focused, otherwise false. - */ - bool getFocusAllow() const; - - /** - * @brief Sets(unsets) focus to view. - * @param[in] focus if true sets focus to view, otherwise unfocuses it. - */ - void setFocus(bool focus); - - /** - * @brief Checks whether view is focused or not. - * @return true if view is focused, otherwise false. - */ - bool getFocus() const; - - /** - * @brief Mark the part text to be translatable or not. - * @param[in] translatable @c true, the part text will be translated internally. @c false, otherwise. - * @param[in] domain The translation domain to use. - * @param[in] part The part name of the translatable text, if part is nullptr the default part is used. - */ - void setTranslatable(bool translatable, const char *domain, const char *part = nullptr); - - /** - * @brief Sends a signal to edje-object. - * @param[in] emission The signal's name. - * @param[in] source The signal's source. - * @param[in] async true - process an object's message queue in job/timer, false - process immediately. - */ - void emitSignal(const char *emission, const char *source, bool async = false); - - /** - * @brief Sends a signal to edje-object. - * @param[in] obj Target object - * @param[in] emission The signal's name. - * @param[in] source The signal's source. - * @param[in] async true - process the signal postponed, false - process immediately. - */ - static void emitSignal(Evas_Object *obj, const char *emission, const char *source, bool async = false); - - /** - * @brief Process all edje signals for object - * @param[in] obj Target object - */ - static void processSignal(Evas_Object *obj); - - /** - * @brief Process edje signals for object - */ - void processSignal(); - - /** - * @brief Process all edje signals - */ - static void processSignals(); - - /** - * @brief Sets user-data associated with specified key-string. - * @param[in] key a string-key. - * @param[in] data to be stored. - */ - void setData(const char *key, const void *data); - - /** - * @brief Sets the view mirrored mode. - * @param[in] obj evas object - * @param[in] true to set mirrored mode, false othewise - */ - static void setMirrored(Evas_Object *obj, bool mirrored); - void setMirrored(bool mirrored); - - /** - * @brief Gets data associated with specified key-string. - * @param[in] key a string-key. - * @return user-data. - */ - void *getData(const char *key) const; - void addEventCb(Evas_Callback_Type type, Evas_Object_Event_Cb func, const void *data); - void addSmartCb(const char *event, Evas_Smart_Cb func, const void *data); - void addSignalCb(const char *emission, const char *source, Edje_Signal_Cb func, void *data); - - template - static T staticCast(void *evasObj); - template - static T reinterpretCast(void *evasObj); - template - static T dynamicCast(void *evasObj); - - /** - * @brief Gets text placed in specified part. - * @param[in] part a part to get text from. If part is nullptr the default part is used. - * @return a text part contains. If part contains no text returns empty string. - */ - std::string getText(const char *part = nullptr) const; - - /** - * @brief A C-style implementation of getText(). - */ - const char *getTextCStr(const char *part = nullptr) const; - - /** - * @brief Sets text into specified part. - * @param[in] text a text to be set in specified part - * @param[in] part a part to get text from. If part is nullptr the default part is used. - */ - void setText(const char *text, const char *part = nullptr); - - /** - * @brief Sets text into specified part. - * @param[in] text a text to be set in specified part - * @param[in] part a part to get text from. If part is nullptr the default part is used. - */ - void setText(const std::string &text, const char *part = nullptr); - - /** - * @brief Sets IDS of translatable string into specified part. - * @param[in] text a translatable text to be set in specified part. - * @param[in] part a part to get text from. If part is nullptr the default part is used. - */ - void setText(const TText &text, const char *part = nullptr); - - /** - * @brief Set the style to used by a given widget - * @param[in] style The name of the style to use on it - */ - void setStyle(const std::string &style); - - /** - * @brief Gets the edje object - * @return edje object - */ - Evas_Object *getEdje() const; - - /** - * @brief Gets AtspiAccessibleInterface wrapper - * @return wrapper to AtspiAccessibleInterface - */ - AtspiAccessibleInterface getAtspi() const; - - static void setText(Evas_Object *obj, const TText &text, const char *part = nullptr); - - static Evas_Object *addLayout(Evas_Object *parent, const std::string &edjePath, const std::string &group); - - protected: - virtual ~View(); - - /** - * @brief Allows children-classes to perform some cleanup activities before their destroying. - * @param[in] view to be destroyed after exiting onBeforeDelete(). - */ - virtual void onBeforeDelete(View &view) {}; - - void setEventCb(Evas_Callback_Type type); - void unsetEventCb(Evas_Callback_Type type); - void setEo(Evas_Object *eo); - - private: - View(View&) = delete; - View& operator=(View&) = delete; - Evas_Object_Event_Cb getCb(Evas_Callback_Type); - void *getData() const; - static void *getData(Evas_Object *obj); - void setData(const void *data); - static void setData(Evas_Object *obj, const void *data); - - private: - static void on_free_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); - static void on_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); - - private: - Evas_Object *m_pEo; - }; - - std::string markupToUtf8(const char *str); - std::string utf8ToMarkup(const char *str); - std::string markupToUtf8(const std::string &str); - std::string utf8ToMarkup(const std::string &str); - - inline View::operator Evas_Object *() const - { - return m_pEo; - } - - inline Evas_Object *View::getEo() const - { - return m_pEo; - } - - inline void View::destroy() - { - evas_object_del(m_pEo); - } - - inline bool View::isVisible() const - { - return evas_object_visible_get(m_pEo); - } - - inline void View::show(bool value) - { - value ? evas_object_show(m_pEo) : evas_object_hide(m_pEo); - } - - inline void View::setSizeHintWeight(double x, double y) - { - evas_object_size_hint_weight_set(m_pEo, x, y); - } - - inline void View::setSizeHintAlign(double x, double y) - { - evas_object_size_hint_align_set(m_pEo, x, y); - } - - inline void View::setScrollerContentMinLimit(Eina_Bool w, Eina_Bool h) - { - elm_scroller_content_min_limit(m_pEo, w, h); - } - - inline void View::setSizeHintMin(Evas_Coord w, Evas_Coord h) - { - evas_object_size_hint_min_set(m_pEo, w, h); - } - - inline void View::setSizeHintMax(Evas_Coord w, Evas_Coord h) - { - evas_object_size_hint_max_set(m_pEo, w, h); - } - - inline void View::getSizeHintMin(Evas_Coord *w, Evas_Coord *h) const - { - evas_object_size_hint_min_get(m_pEo, w, h); - }; - - inline void View::getSizeHintMax(Evas_Coord *w, Evas_Coord *h) const - { - evas_object_size_hint_max_get(m_pEo, w, h); - } - - inline void View::move(Evas_Coord x, Evas_Coord y) - { - evas_object_move(m_pEo, x, y); - } - - inline Evas_Object* View::getContent(const char *part) const - { - return elm_object_part_content_get(m_pEo, part); - } - - inline void View::setFocusAllow(bool enable) - { - elm_object_focus_allow_set(m_pEo, enable); - } - - inline bool View::getFocusAllow() const - { - return elm_object_focus_allow_get(m_pEo); - } - - inline void View::setFocus(bool focus) - { - return elm_object_focus_set(m_pEo, focus); - } - - inline bool View::getFocus() const - { - return elm_object_focus_get(m_pEo); - } - - inline void View::setTranslatable(bool translatable, const char *domain, const char *part) - { - elm_object_domain_part_text_translatable_set(m_pEo, part, domain, translatable); - } - - inline void View::emitSignal(const char *emission, const char *source, bool async) - { - emitSignal(m_pEo, emission, source, async); - } - - inline void View::processSignal() - { - processSignal(m_pEo); - } - - inline void View::processSignals() - { - edje_message_signal_process(); - } - - inline void View::setText(const char *text, const char *part) - { - elm_object_part_text_set(m_pEo, part, text); - } - - inline void View::setText(const std::string &text, const char *part) - { - setText(text.c_str(), part); - } - - inline void View::setText(const TText &text, const char *part) - { - setText(m_pEo, text, part); - } - - inline void View::setStyle(const std::string &style) - { - elm_object_style_set(getEo(), style.c_str()); - } - - inline void View::setText(Evas_Object *obj, const TText &text, const char *part) - { - elm_object_domain_translatable_part_text_set(obj, part, text.getDomain(), text.getMsg()); - } - - inline std::string View::getText(const char *part) const - { - const char *text = getTextCStr(part); - return text ? text : ""; - } - - inline const char *View::getTextCStr(const char *part) const - { - return elm_object_part_text_get(m_pEo, part); - } - - inline void View::setData(const char *key, const void *data) - { - evas_object_data_set(m_pEo, key, data); - } - - inline void *View::getData(const char *key) const - { - return evas_object_data_get(m_pEo, key); - } - - inline void View::setData(const void *data) - { - setData(m_pEo, data); - } - - inline void *View::getData() const - { - return getData(m_pEo); - } - - template - inline T View::staticCast(void *evasObj) - { - return static_cast(getData((Evas_Object*)evasObj)); - } - - template - inline T View::reinterpretCast(void *evasObj) - { - return reinterpret_cast(getData((Evas_Object*)evasObj)); - } - - template - inline T View::dynamicCast(void *evasObj) - { - return dynamic_cast(staticCast(evasObj)); - } - - inline void View::addEventCb(Evas_Callback_Type type, Evas_Object_Event_Cb func, const void *data) - { - evas_object_event_callback_add(m_pEo, type, func, data); - } - - inline void View::addSmartCb(const char *event, Evas_Smart_Cb func, const void *data) - { - evas_object_smart_callback_add(m_pEo, event, func, data); - } - - inline void View::addSignalCb(const char *emission, const char *source, Edje_Signal_Cb func, void *data) - { - elm_object_signal_callback_add(m_pEo, emission, source, func, data); - } - - inline Evas_Object *View::unsetContent(const char *part) - { - return elm_object_part_content_unset(m_pEo, part); - } - - inline Evas_Object *View::getEdje() const - { - return elm_layout_edje_get(m_pEo); - } - - inline void View::setMirrored(Evas_Object *obj, bool mirrored) - { - elm_object_mirrored_automatic_set(obj, mirrored); - elm_object_mirrored_set(obj, mirrored); - } - - inline void View::setMirrored(bool mirrored) - { - setMirrored(getEo(), mirrored); - } - - inline AtspiAccessibleInterface View::getAtspi() const - { - return AtspiAccessibleInterface(m_pEo); - } + /** + * @brief Wraps all basic Evas_Object operations and manages automatic self-removal by EVAS_CALLBACK_FREE and EVAS_CALLBACK_DEL events. + */ + class View + : public BaseView { + public: + View(); + + /** + * @brief Destroys nested Evas_Object. + */ + void destroy(); + operator Evas_Object *() const; + Evas_Object *getEo() const; + + /** + * @brief Checks whether view is visible or not. + * @return true if view is visible, otherwise false. + */ + bool isVisible() const; + + /** + * @brief Shows view. + * @param[in] value - true show, false - otherwise + */ + void show(bool value = true); + + /** + * @brief Moves view to specified Evas-coordinates. + * @param[in] x x-coordinate + * @param[in] y y-coordinate + */ + void move(Evas_Coord x, Evas_Coord y); + + /** + * @brief Sets size-weight hints. + * @param[in] x x-coordinate + * @param[in] y y-coordinate + */ + void setSizeHintWeight(double x = EVAS_HINT_EXPAND, double y = EVAS_HINT_EXPAND); + + /** + * @brief Sets size-align hints. + * @param[in] x x-coordinate + * @param[in] y y-coordinate + */ + void setSizeHintAlign(double x = EVAS_HINT_FILL, double y = EVAS_HINT_FILL); + + /** + * @brief Make the scroller minimum size limited to the minimum size of the view's content + * + * @param[in] w Enable limiting minimum size horizontally + * @param[in] h Enable limiting minimum size vertically + */ + void setScrollerContentMinLimit(Eina_Bool w, Eina_Bool h); + + /** + * @brief Sets size-weight and size-align hints in order to make view expanded. + */ + void expand(); + + /** + * @brief Sets specified Evas_object's size-weight and size-align hints in order to make it expanded. + * @param[in] obj an Evas_Object to be expanded. + */ + static void expand(Evas_Object *obj); + + /** + * @brief Sets min size hints. + * @param[in] w width hint. + * @param[in] h height hint. + */ + void setSizeHintMin(Evas_Coord w, Evas_Coord h); + + /** + * @brief Sets max size hints. + * @param[in] w width hint. + * @param[in] h height hint. + */ + void setSizeHintMax(Evas_Coord w, Evas_Coord h); + + /** + * @brief Gets min size hints. + * @param[out] w width hint. + * @param[out] h height hint. + */ + void getSizeHintMin(Evas_Coord *w, Evas_Coord *h) const; + + /** + * @brief Gets max size hints. + * @param[out] w width hint. + * @param[out] h height hint. + */ + void getSizeHintMax(Evas_Coord *w, Evas_Coord *h) const; + + /** + * @brief Sets specified content into specified part. + * @param[in] content a content to set into view. + * @param[in] part a part content should be placed to. If part is nullptr the default part is used. + * @param[in] saveOldContent a flag that checks whether old view's content should be returned or not. + * @return if saveOldContent is true returns old content set into view before, otherwise returns nullptr. + */ + Evas_Object *setContent(Evas_Object *content, const char *part = nullptr, bool saveOldContent = false); + + /** + * @brief Unsets view's content. + * @param[in] part a part content should be removed from. If part is nullptr the default part is used. + * @return old view's content in case of success, nullptr in case of errors. + */ + Evas_Object *unsetContent(const char *part = nullptr); + + /** + * @brief Gets view's content. + * @param[in] part a content-part. If part is nullptr the default part is used. + * @return view's content in case of success, nullptr in case of errors. + */ + Evas_Object* getContent(const char *part = nullptr) const; + + /** + * @brief Set the ability for an view object to be focused. + * @param[in] enable if true view is enabled to be focused, otherwise it can not be focused. + */ + void setFocusAllow(bool enable); + + /** + * @brief Checks whether view can be focused or not. + * @return true if view is able to be focused, otherwise false. + */ + bool getFocusAllow() const; + + /** + * @brief Sets(unsets) focus to view. + * @param[in] focus if true sets focus to view, otherwise unfocuses it. + */ + void setFocus(bool focus); + + /** + * @brief Checks whether view is focused or not. + * @return true if view is focused, otherwise false. + */ + bool getFocus() const; + + /** + * @brief Mark the part text to be translatable or not. + * @param[in] translatable @c true, the part text will be translated internally. @c false, otherwise. + * @param[in] domain The translation domain to use. + * @param[in] part The part name of the translatable text, if part is nullptr the default part is used. + */ + void setTranslatable(bool translatable, const char *domain, const char *part = nullptr); + + /** + * @brief Sends a signal to edje-object. + * @param[in] emission The signal's name. + * @param[in] source The signal's source. + * @param[in] async true - process an object's message queue in job/timer, false - process immediately. + */ + void emitSignal(const char *emission, const char *source, bool async = false); + + /** + * @brief Sends a signal to edje-object. + * @param[in] obj Target object + * @param[in] emission The signal's name. + * @param[in] source The signal's source. + * @param[in] async true - process the signal postponed, false - process immediately. + */ + static void emitSignal(Evas_Object *obj, const char *emission, const char *source, bool async = false); + + /** + * @brief Process all edje signals for object + * @param[in] obj Target object + */ + static void processSignal(Evas_Object *obj); + + /** + * @brief Process edje signals for object + */ + void processSignal(); + + /** + * @brief Process all edje signals + */ + static void processSignals(); + + /** + * @brief Sets user-data associated with specified key-string. + * @param[in] key a string-key. + * @param[in] data to be stored. + */ + void setData(const char *key, const void *data); + + /** + * @brief Sets the view mirrored mode. + * @param[in] obj evas object + * @param[in] true to set mirrored mode, false othewise + */ + static void setMirrored(Evas_Object *obj, bool mirrored); + void setMirrored(bool mirrored); + + /** + * @brief Gets data associated with specified key-string. + * @param[in] key a string-key. + * @return user-data. + */ + void *getData(const char *key) const; + void addEventCb(Evas_Callback_Type type, Evas_Object_Event_Cb func, const void *data); + void addSmartCb(const char *event, Evas_Smart_Cb func, const void *data); + void addSignalCb(const char *emission, const char *source, Edje_Signal_Cb func, void *data); + + template + static T staticCast(void *evasObj); + template + static T reinterpretCast(void *evasObj); + template + static T dynamicCast(void *evasObj); + + /** + * @brief Gets text placed in specified part. + * @param[in] part a part to get text from. If part is nullptr the default part is used. + * @return a text part contains. If part contains no text returns empty string. + */ + std::string getText(const char *part = nullptr) const; + + /** + * @brief A C-style implementation of getText(). + */ + const char *getTextCStr(const char *part = nullptr) const; + + /** + * @brief Sets text into specified part. + * @param[in] text a text to be set in specified part + * @param[in] part a part to get text from. If part is nullptr the default part is used. + */ + void setText(const char *text, const char *part = nullptr); + + /** + * @brief Sets text into specified part. + * @param[in] text a text to be set in specified part + * @param[in] part a part to get text from. If part is nullptr the default part is used. + */ + void setText(const std::string &text, const char *part = nullptr); + + /** + * @brief Sets IDS of translatable string into specified part. + * @param[in] text a translatable text to be set in specified part. + * @param[in] part a part to get text from. If part is nullptr the default part is used. + */ + void setText(const TText &text, const char *part = nullptr); + + /** + * @brief Set the style to used by a given widget + * @param[in] style The name of the style to use on it + */ + void setStyle(const std::string &style); + + /** + * @brief Gets the edje object + * @return edje object + */ + Evas_Object *getEdje() const; + + /** + * @brief Gets AtspiAccessibleInterface wrapper + * @return wrapper to AtspiAccessibleInterface + */ + AtspiAccessibleInterface getAtspi() const; + + static void setText(Evas_Object *obj, const TText &text, const char *part = nullptr); + + static Evas_Object *addLayout(Evas_Object *parent, const std::string &edjePath, const std::string &group); + + protected: + virtual ~View(); + + /** + * @brief Allows children-classes to perform some cleanup activities before their destroying. + * @param[in] view to be destroyed after exiting onBeforeDelete(). + */ + virtual void onBeforeDelete(View &view) {}; + + void setEventCb(Evas_Callback_Type type); + void unsetEventCb(Evas_Callback_Type type); + void setEo(Evas_Object *eo); + + private: + View(View&) = delete; + View& operator=(View&) = delete; + Evas_Object_Event_Cb getCb(Evas_Callback_Type); + void *getData() const; + static void *getData(Evas_Object *obj); + void setData(const void *data); + static void setData(Evas_Object *obj, const void *data); + + private: + static void on_free_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); + static void on_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); + + private: + Evas_Object *m_pEo; + }; + + std::string markupToUtf8(const char *str); + std::string utf8ToMarkup(const char *str); + std::string markupToUtf8(const std::string &str); + std::string utf8ToMarkup(const std::string &str); + + inline View::operator Evas_Object *() const + { + return m_pEo; + } + + inline Evas_Object *View::getEo() const + { + return m_pEo; + } + + inline void View::destroy() + { + evas_object_del(m_pEo); + } + + inline bool View::isVisible() const + { + return evas_object_visible_get(m_pEo); + } + + inline void View::show(bool value) + { + value ? evas_object_show(m_pEo) : evas_object_hide(m_pEo); + } + + inline void View::setSizeHintWeight(double x, double y) + { + evas_object_size_hint_weight_set(m_pEo, x, y); + } + + inline void View::setSizeHintAlign(double x, double y) + { + evas_object_size_hint_align_set(m_pEo, x, y); + } + + inline void View::setScrollerContentMinLimit(Eina_Bool w, Eina_Bool h) + { + elm_scroller_content_min_limit(m_pEo, w, h); + } + + inline void View::setSizeHintMin(Evas_Coord w, Evas_Coord h) + { + evas_object_size_hint_min_set(m_pEo, w, h); + } + + inline void View::setSizeHintMax(Evas_Coord w, Evas_Coord h) + { + evas_object_size_hint_max_set(m_pEo, w, h); + } + + inline void View::getSizeHintMin(Evas_Coord *w, Evas_Coord *h) const + { + evas_object_size_hint_min_get(m_pEo, w, h); + }; + + inline void View::getSizeHintMax(Evas_Coord *w, Evas_Coord *h) const + { + evas_object_size_hint_max_get(m_pEo, w, h); + } + + inline void View::move(Evas_Coord x, Evas_Coord y) + { + evas_object_move(m_pEo, x, y); + } + + inline Evas_Object* View::getContent(const char *part) const + { + return elm_object_part_content_get(m_pEo, part); + } + + inline void View::setFocusAllow(bool enable) + { + elm_object_focus_allow_set(m_pEo, enable); + } + + inline bool View::getFocusAllow() const + { + return elm_object_focus_allow_get(m_pEo); + } + + inline void View::setFocus(bool focus) + { + return elm_object_focus_set(m_pEo, focus); + } + + inline bool View::getFocus() const + { + return elm_object_focus_get(m_pEo); + } + + inline void View::setTranslatable(bool translatable, const char *domain, const char *part) + { + elm_object_domain_part_text_translatable_set(m_pEo, part, domain, translatable); + } + + inline void View::emitSignal(const char *emission, const char *source, bool async) + { + emitSignal(m_pEo, emission, source, async); + } + + inline void View::processSignal() + { + processSignal(m_pEo); + } + + inline void View::processSignals() + { + edje_message_signal_process(); + } + + inline void View::setText(const char *text, const char *part) + { + elm_object_part_text_set(m_pEo, part, text); + } + + inline void View::setText(const std::string &text, const char *part) + { + setText(text.c_str(), part); + } + + inline void View::setText(const TText &text, const char *part) + { + setText(m_pEo, text, part); + } + + inline void View::setStyle(const std::string &style) + { + elm_object_style_set(getEo(), style.c_str()); + } + + inline void View::setText(Evas_Object *obj, const TText &text, const char *part) + { + elm_object_domain_translatable_part_text_set(obj, part, text.getDomain(), text.getMsg()); + } + + inline std::string View::getText(const char *part) const + { + const char *text = getTextCStr(part); + return text ? text : ""; + } + + inline const char *View::getTextCStr(const char *part) const + { + return elm_object_part_text_get(m_pEo, part); + } + + inline void View::setData(const char *key, const void *data) + { + evas_object_data_set(m_pEo, key, data); + } + + inline void *View::getData(const char *key) const + { + return evas_object_data_get(m_pEo, key); + } + + inline void View::setData(const void *data) + { + setData(m_pEo, data); + } + + inline void *View::getData() const + { + return getData(m_pEo); + } + + template + inline T View::staticCast(void *evasObj) + { + return static_cast(getData((Evas_Object*)evasObj)); + } + + template + inline T View::reinterpretCast(void *evasObj) + { + return reinterpret_cast(getData((Evas_Object*)evasObj)); + } + + template + inline T View::dynamicCast(void *evasObj) + { + return dynamic_cast(staticCast(evasObj)); + } + + inline void View::addEventCb(Evas_Callback_Type type, Evas_Object_Event_Cb func, const void *data) + { + evas_object_event_callback_add(m_pEo, type, func, data); + } + + inline void View::addSmartCb(const char *event, Evas_Smart_Cb func, const void *data) + { + evas_object_smart_callback_add(m_pEo, event, func, data); + } + + inline void View::addSignalCb(const char *emission, const char *source, Edje_Signal_Cb func, void *data) + { + elm_object_signal_callback_add(m_pEo, emission, source, func, data); + } + + inline Evas_Object *View::unsetContent(const char *part) + { + return elm_object_part_content_unset(m_pEo, part); + } + + inline Evas_Object *View::getEdje() const + { + return elm_layout_edje_get(m_pEo); + } + + inline void View::setMirrored(Evas_Object *obj, bool mirrored) + { + elm_object_mirrored_automatic_set(obj, mirrored); + elm_object_mirrored_set(obj, mirrored); + } + + inline void View::setMirrored(bool mirrored) + { + setMirrored(getEo(), mirrored); + } + + inline AtspiAccessibleInterface View::getAtspi() const + { + return AtspiAccessibleInterface(m_pEo); + } } #endif /* View_h_ */ diff --git a/src/Common/View/inc/ViewItem.h b/src/Common/View/inc/ViewItem.h index 57f7a5e4..994248e5 100644 --- a/src/Common/View/inc/ViewItem.h +++ b/src/Common/View/inc/ViewItem.h @@ -24,230 +24,230 @@ #include namespace Msg { - /** - * @brief Wraps all basic Elm_Object_Item operations and manages automatic self-removal by delete-callback. - */ - class ViewItem - : public BaseView { - public: - ViewItem(); - ViewItem(ViewItem&) = delete; - ViewItem& operator=(const ViewItem&) = delete; - - operator Elm_Object_Item *() const; - - /** - * @brief Destroys view-item. - */ - virtual void destroy(); - - /** - * @brief Sets specified content into specified part. - * @param[in] content a content to set into view-item. - * @param[in] part a part content should be placed to. If part is nullptr the default part is used. - * @param[in] saveOldContent a flag that checks whether old view's content should be returned or not. - * @return if saveOldContent is true returns old content set into view before, otherwise returns nullptr. - */ - Evas_Object *setContent(Evas_Object *content, const char *part = nullptr, bool saveOldContent = false); - - /** - * @brief Gets view-items's content. - * @param[in] part a content-part. If part is nullptr the default part is used. - * @return view's content in case of success, nullptr in case of errors. - */ - Evas_Object *getContent(const char *part = nullptr) const; - - /** - * @brief Sends a signal to edje-object. - * @param[in] emission The signal's name. - * @param[in] source The signal's source. - */ - void emitSignal(const char *signal, const char *source = "elm"); - - /** - * @brief Gets item-data. - * @return item-data. - */ - void *getData() const; - - /** - * @brief Sets item-data. - * @param[in] data item-data. - */ - void setData(void *data); - - /** - * @brief Gets Elm_Object_Item current view-item is wrapping. - * @return wrapped object-item. - */ - Elm_Object_Item *getElmObjItem() const; - - /** - * @brief Get the widget object's handle which contains a given view-item. - */ - Evas_Object *getWidget() const; - - /** - * @brief Disables(enables) view-item. - * @param[in] val if true disables view-item, otherwise enables it. - */ - void disabled(bool val); - - /** - * @brief Checks whether view-item is disabled or not. - * @return true if view-item is disabled, otherwise false. - */ - bool isDisabled() const; - - /** - * @brief Mark the part text to be translatable or not. - * @param[in] translatable @c true, the part text will be translated internally. @c false, otherwise. - * @param[in] domain The translation domain to use. - * @param[in] part The part name of the translatable text, if part is nullptr the default part is used. - */ - void setTranslatable(bool translatable, const char *domain, const char *part = nullptr); - - /** - * @brief Gets text placed in specified part. - * @param[in] part a part to get text from. If part is nullptr the default part is used. - * @return a text part contains. If part contains no text returns empty string. - */ - std::string getText(const char *part = nullptr) const; - - /** - * @brief A C-style implementation of getText(). - */ - const char *getTextCStr(const char *part = nullptr) const; - - /** - * @brief Sets text into specified part. - * @param[in] text a text to be set in specified part - * @param[in] part a part to get text from. If part is nullptr the default part is used. - */ - void setText(const char *text, const char *part = nullptr); - - /** - * @brief Sets text into specified part. - * @param[in] text a text to be set in specified part - * @param[in] part a part to get text from. If part is nullptr the default part is used. - */ - void setText(const std::string &text, const char *part = nullptr); - - /** - * @brief Sets IDS of translatable string into specified part. - * @param[in] text a translatable text to be set in specified part. - * @param[in] part a part to get text from. If part is nullptr the default part is used. - */ - void setText(const TText &text, const char *part = nullptr); - static void setText(Elm_Object_Item *it, const TText &text, const char *part = nullptr); - - template - static T staticCast(void *elmObjectItem); - template - static T reinterpretCast(void *elmObjectItem); - template - static T dynamicCast(void *elmObjectItem); - - protected: - virtual ~ViewItem(); - virtual void onAttached(ViewItem &item) {}; - void setElmObjItem(Elm_Object_Item *item); - - private: - static void on_delete_cb(void *data, Evas_Object *obj, void *event_info); - - private: - Elm_Object_Item *m_pItem; - }; - - inline ViewItem::operator Elm_Object_Item *() const - { - return m_pItem; - } - - inline Elm_Object_Item *ViewItem::getElmObjItem() const - { - return m_pItem; - } - - inline Evas_Object *ViewItem::getWidget() const - { - return elm_object_item_widget_get(m_pItem); - } - - inline void *ViewItem::getData() const - { - return elm_object_item_data_get(m_pItem); - } - - inline void ViewItem::setData(void *data) - { - elm_object_item_data_set(m_pItem, data); - } - - inline void ViewItem::disabled(bool val) - { - elm_object_item_disabled_set(m_pItem, val); - } - - inline bool ViewItem::isDisabled() const - { - return elm_object_item_disabled_get(m_pItem); - } - - inline void ViewItem::setText(const char *text, const char *part) - { - elm_object_item_part_text_set(m_pItem, part, text); - } - - inline void ViewItem::setTranslatable(bool translatable, const char *domain, const char *part) - { - elm_object_item_domain_part_text_translatable_set(m_pItem, part, domain, translatable); - } - - inline void ViewItem::setText(const std::string &text, const char *part) - { - setText(text.c_str(), part); - } - - inline void ViewItem::setText(const TText &text, const char *part) - { - setText(m_pItem, text, part); - } - - inline void ViewItem::setText(Elm_Object_Item *it, const TText &text, const char *part) - { - elm_object_item_domain_translatable_part_text_set(it, part, text.getDomain(), text.getMsg()); - } - - inline std::string ViewItem::getText(const char *part) const - { - const char *text = getTextCStr(part); - return text ? text : ""; - } - - inline const char *ViewItem::getTextCStr(const char *part) const - { - return elm_object_item_part_text_get(m_pItem, part); - } - - template - inline T ViewItem::staticCast(void *elmObjectItem) - { - return static_cast(elm_object_item_data_get((Elm_Object_Item*)elmObjectItem)); - } - - template - inline T ViewItem::reinterpretCast(void *elmObjectItem) - { - return reinterpret_cast(elm_object_item_data_get((Elm_Object_Item*)elmObjectItem)); - } - - template - inline T ViewItem::dynamicCast(void *elmObjectItem) - { - return dynamic_cast(staticCast(elmObjectItem)); - } + /** + * @brief Wraps all basic Elm_Object_Item operations and manages automatic self-removal by delete-callback. + */ + class ViewItem + : public BaseView { + public: + ViewItem(); + ViewItem(ViewItem&) = delete; + ViewItem& operator=(const ViewItem&) = delete; + + operator Elm_Object_Item *() const; + + /** + * @brief Destroys view-item. + */ + virtual void destroy(); + + /** + * @brief Sets specified content into specified part. + * @param[in] content a content to set into view-item. + * @param[in] part a part content should be placed to. If part is nullptr the default part is used. + * @param[in] saveOldContent a flag that checks whether old view's content should be returned or not. + * @return if saveOldContent is true returns old content set into view before, otherwise returns nullptr. + */ + Evas_Object *setContent(Evas_Object *content, const char *part = nullptr, bool saveOldContent = false); + + /** + * @brief Gets view-items's content. + * @param[in] part a content-part. If part is nullptr the default part is used. + * @return view's content in case of success, nullptr in case of errors. + */ + Evas_Object *getContent(const char *part = nullptr) const; + + /** + * @brief Sends a signal to edje-object. + * @param[in] emission The signal's name. + * @param[in] source The signal's source. + */ + void emitSignal(const char *signal, const char *source = "elm"); + + /** + * @brief Gets item-data. + * @return item-data. + */ + void *getData() const; + + /** + * @brief Sets item-data. + * @param[in] data item-data. + */ + void setData(void *data); + + /** + * @brief Gets Elm_Object_Item current view-item is wrapping. + * @return wrapped object-item. + */ + Elm_Object_Item *getElmObjItem() const; + + /** + * @brief Get the widget object's handle which contains a given view-item. + */ + Evas_Object *getWidget() const; + + /** + * @brief Disables(enables) view-item. + * @param[in] val if true disables view-item, otherwise enables it. + */ + void disabled(bool val); + + /** + * @brief Checks whether view-item is disabled or not. + * @return true if view-item is disabled, otherwise false. + */ + bool isDisabled() const; + + /** + * @brief Mark the part text to be translatable or not. + * @param[in] translatable @c true, the part text will be translated internally. @c false, otherwise. + * @param[in] domain The translation domain to use. + * @param[in] part The part name of the translatable text, if part is nullptr the default part is used. + */ + void setTranslatable(bool translatable, const char *domain, const char *part = nullptr); + + /** + * @brief Gets text placed in specified part. + * @param[in] part a part to get text from. If part is nullptr the default part is used. + * @return a text part contains. If part contains no text returns empty string. + */ + std::string getText(const char *part = nullptr) const; + + /** + * @brief A C-style implementation of getText(). + */ + const char *getTextCStr(const char *part = nullptr) const; + + /** + * @brief Sets text into specified part. + * @param[in] text a text to be set in specified part + * @param[in] part a part to get text from. If part is nullptr the default part is used. + */ + void setText(const char *text, const char *part = nullptr); + + /** + * @brief Sets text into specified part. + * @param[in] text a text to be set in specified part + * @param[in] part a part to get text from. If part is nullptr the default part is used. + */ + void setText(const std::string &text, const char *part = nullptr); + + /** + * @brief Sets IDS of translatable string into specified part. + * @param[in] text a translatable text to be set in specified part. + * @param[in] part a part to get text from. If part is nullptr the default part is used. + */ + void setText(const TText &text, const char *part = nullptr); + static void setText(Elm_Object_Item *it, const TText &text, const char *part = nullptr); + + template + static T staticCast(void *elmObjectItem); + template + static T reinterpretCast(void *elmObjectItem); + template + static T dynamicCast(void *elmObjectItem); + + protected: + virtual ~ViewItem(); + virtual void onAttached(ViewItem &item) {}; + void setElmObjItem(Elm_Object_Item *item); + + private: + static void on_delete_cb(void *data, Evas_Object *obj, void *event_info); + + private: + Elm_Object_Item *m_pItem; + }; + + inline ViewItem::operator Elm_Object_Item *() const + { + return m_pItem; + } + + inline Elm_Object_Item *ViewItem::getElmObjItem() const + { + return m_pItem; + } + + inline Evas_Object *ViewItem::getWidget() const + { + return elm_object_item_widget_get(m_pItem); + } + + inline void *ViewItem::getData() const + { + return elm_object_item_data_get(m_pItem); + } + + inline void ViewItem::setData(void *data) + { + elm_object_item_data_set(m_pItem, data); + } + + inline void ViewItem::disabled(bool val) + { + elm_object_item_disabled_set(m_pItem, val); + } + + inline bool ViewItem::isDisabled() const + { + return elm_object_item_disabled_get(m_pItem); + } + + inline void ViewItem::setText(const char *text, const char *part) + { + elm_object_item_part_text_set(m_pItem, part, text); + } + + inline void ViewItem::setTranslatable(bool translatable, const char *domain, const char *part) + { + elm_object_item_domain_part_text_translatable_set(m_pItem, part, domain, translatable); + } + + inline void ViewItem::setText(const std::string &text, const char *part) + { + setText(text.c_str(), part); + } + + inline void ViewItem::setText(const TText &text, const char *part) + { + setText(m_pItem, text, part); + } + + inline void ViewItem::setText(Elm_Object_Item *it, const TText &text, const char *part) + { + elm_object_item_domain_translatable_part_text_set(it, part, text.getDomain(), text.getMsg()); + } + + inline std::string ViewItem::getText(const char *part) const + { + const char *text = getTextCStr(part); + return text ? text : ""; + } + + inline const char *ViewItem::getTextCStr(const char *part) const + { + return elm_object_item_part_text_get(m_pItem, part); + } + + template + inline T ViewItem::staticCast(void *elmObjectItem) + { + return static_cast(elm_object_item_data_get((Elm_Object_Item*)elmObjectItem)); + } + + template + inline T ViewItem::reinterpretCast(void *elmObjectItem) + { + return reinterpret_cast(elm_object_item_data_get((Elm_Object_Item*)elmObjectItem)); + } + + template + inline T ViewItem::dynamicCast(void *elmObjectItem) + { + return dynamic_cast(staticCast(elmObjectItem)); + } } #endif /* ViewItem_h_ */ diff --git a/src/Common/View/inc/Window.h b/src/Common/View/inc/Window.h index 323df62c..6cb3e026 100644 --- a/src/Common/View/inc/Window.h +++ b/src/Common/View/inc/Window.h @@ -21,21 +21,21 @@ #include namespace Msg { - /** - * @brief An interface that should be implemented by all window-classes across whole application. - */ - class Window - : public View { - public: - virtual ~Window() {}; + /** + * @brief An interface that should be implemented by all window-classes across whole application. + */ + class Window + : public View { + public: + virtual ~Window() {}; - virtual Evas_Object *getWinEvasObject() const = 0; - virtual Evas_Object *getConformEvasObject() const = 0; - virtual Evas_Object *getHostEvasObject() const = 0; - virtual void setContent(Evas_Object *content) = 0; - virtual void getScreenSize(int *x, int *y, int *w, int *h) const = 0; - virtual int getRotation() const = 0; - }; + virtual Evas_Object *getWinEvasObject() const = 0; + virtual Evas_Object *getConformEvasObject() const = 0; + virtual Evas_Object *getHostEvasObject() const = 0; + virtual void setContent(Evas_Object *content) = 0; + virtual void getScreenSize(int *x, int *y, int *w, int *h) const = 0; + virtual int getRotation() const = 0; + }; } #endif /* Window_h_ */ diff --git a/src/Common/View/src/Box.cpp b/src/Common/View/src/Box.cpp index d4a429c0..de5d8220 100644 --- a/src/Common/View/src/Box.cpp +++ b/src/Common/View/src/Box.cpp @@ -21,10 +21,10 @@ using namespace Msg; Box::Box(Evas_Object *parent) - : View() + : View() { - setEo(elm_box_add(parent)); - show(); + setEo(elm_box_add(parent)); + show(); } Box::~Box() diff --git a/src/Common/View/src/ContextPopup.cpp b/src/Common/View/src/ContextPopup.cpp index a9d508ae..4c2def3f 100644 --- a/src/Common/View/src/ContextPopup.cpp +++ b/src/Common/View/src/ContextPopup.cpp @@ -21,113 +21,113 @@ using namespace Msg; ContextPopupItem::ContextPopupItem(ContextPopup &parent, int id, ContextPopupItemPressedCb userCb, void *userData) - : ViewItem() - , m_ParentContextPopup(parent) - , m_Id(id) - , m_pUserCb(userCb) - , m_pUserData(userData) + : ViewItem() + , m_ParentContextPopup(parent) + , m_Id(id) + , m_pUserCb(userCb) + , m_pUserData(userData) { } ContextPopupItem::~ContextPopupItem() { - MSG_LOG("Destructor"); + MSG_LOG("Destructor"); } ContextPopup &ContextPopupItem::getParent() { - return m_ParentContextPopup; + return m_ParentContextPopup; } int ContextPopupItem::getId() const { - return m_Id; + return m_Id; } // ContextPopup: ContextPopup::~ContextPopup() { - MSG_LOG("Destructor"); + MSG_LOG("Destructor"); } ContextPopupItem *ContextPopup::appendItem(const std::string &text, Evas_Object *icon, ContextPopupItemPressedCb cb, void *userData, int id) { - ContextPopupItem *newItem = new ContextPopupItem(*this, id, cb, userData); - Elm_Object_Item *elmItem = elm_ctxpopup_item_append(getEo(), text.c_str(), icon, on_item_pressed_cb, newItem); + ContextPopupItem *newItem = new ContextPopupItem(*this, id, cb, userData); + Elm_Object_Item *elmItem = elm_ctxpopup_item_append(getEo(), text.c_str(), icon, on_item_pressed_cb, newItem); - if (elmItem) { - newItem->setElmObjItem(elmItem); - } else { - delete newItem; - newItem = nullptr; - } + if (elmItem) { + newItem->setElmObjItem(elmItem); + } else { + delete newItem; + newItem = nullptr; + } - return newItem; + return newItem; } void ContextPopup::createContextPopup(Evas_Object *parent) { - setEo(elm_ctxpopup_add(parent)); + setEo(elm_ctxpopup_add(parent)); - elm_object_style_set(getEo(), "more/default"); - elm_ctxpopup_horizontal_set(getEo(), EINA_FALSE); - elm_ctxpopup_auto_hide_disabled_set(getEo(), EINA_FALSE); - evas_object_smart_callback_add(getEo(), "dismissed", on_dismissed_cb, this); + elm_object_style_set(getEo(), "more/default"); + elm_ctxpopup_horizontal_set(getEo(), EINA_FALSE); + elm_ctxpopup_auto_hide_disabled_set(getEo(), EINA_FALSE); + evas_object_smart_callback_add(getEo(), "dismissed", on_dismissed_cb, this); - setDirectionPriority(ELM_CTXPOPUP_DIRECTION_UP, - ELM_CTXPOPUP_DIRECTION_UNKNOWN, - ELM_CTXPOPUP_DIRECTION_UNKNOWN, - ELM_CTXPOPUP_DIRECTION_UNKNOWN); + setDirectionPriority(ELM_CTXPOPUP_DIRECTION_UP, + ELM_CTXPOPUP_DIRECTION_UNKNOWN, + ELM_CTXPOPUP_DIRECTION_UNKNOWN, + ELM_CTXPOPUP_DIRECTION_UNKNOWN); } void ContextPopup::destroy() { - View::destroy(); + View::destroy(); } void ContextPopup::setDirectionPriority(Elm_Ctxpopup_Direction first, Elm_Ctxpopup_Direction second, - Elm_Ctxpopup_Direction third, Elm_Ctxpopup_Direction fourth) + Elm_Ctxpopup_Direction third, Elm_Ctxpopup_Direction fourth) { - elm_ctxpopup_direction_priority_set(getEo(), first, second, third, fourth); + elm_ctxpopup_direction_priority_set(getEo(), first, second, third, fourth); } Elm_Ctxpopup_Direction ContextPopup::getDirection() const { - return elm_ctxpopup_direction_get(getEo()); + return elm_ctxpopup_direction_get(getEo()); } void ContextPopup::on_dismissed_cb(void *data, Evas_Object *obj, void *event_info) { - ContextPopup *self = static_cast(data); - self->destroy(); + ContextPopup *self = static_cast(data); + self->destroy(); } void ContextPopup::on_item_pressed_cb(void *data, Evas_Object *obj, void *event_info) { - ContextPopupItem *item = static_cast(data); - if (item && item->m_pUserCb) - item->m_pUserCb(*item, item->m_pUserData); + ContextPopupItem *item = static_cast(data); + if (item && item->m_pUserCb) + item->m_pUserCb(*item, item->m_pUserData); } void ContextPopup::align(Window &win) { - int w; - int h; - - int pos = win.getRotation(); - win.getScreenSize(nullptr, nullptr, &w, &h); - - switch (pos) { - case 0: - case 180: - move(w/2, h); - break; - case 90: - move(h/2, w); - break; - case 270: - move(h/2, w); - break; - } + int w; + int h; + + int pos = win.getRotation(); + win.getScreenSize(nullptr, nullptr, &w, &h); + + switch (pos) { + case 0: + case 180: + move(w/2, h); + break; + case 90: + move(h/2, w); + break; + case 270: + move(h/2, w); + break; + } } diff --git a/src/Common/View/src/DefaultLayout.cpp b/src/Common/View/src/DefaultLayout.cpp index 2c71541c..7a2d489c 100644 --- a/src/Common/View/src/DefaultLayout.cpp +++ b/src/Common/View/src/DefaultLayout.cpp @@ -19,14 +19,14 @@ using namespace Msg; namespace { - const char *floatingPart = "elm.swallow.floatingbutton"; + const char *floatingPart = "elm.swallow.floatingbutton"; } DefaultLayout::DefaultLayout(Evas_Object *parent) - : m_pFloatingBtn(nullptr) + : m_pFloatingBtn(nullptr) { - setEo(elm_layout_add(parent)); - elm_layout_theme_set(getEo(), "layout", "application", "default"); + setEo(elm_layout_add(parent)); + elm_layout_theme_set(getEo(), "layout", "application", "default"); } DefaultLayout::~DefaultLayout() @@ -35,28 +35,28 @@ DefaultLayout::~DefaultLayout() void DefaultLayout::setContent(Evas_Object *obj) { - elm_object_part_content_set(getEo(), "elm.swallow.content", obj); + elm_object_part_content_set(getEo(), "elm.swallow.content", obj); } void DefaultLayout::setBg(Evas_Object *obj) { - elm_object_part_content_set(getEo(), "elm.swallow.bg", obj); + elm_object_part_content_set(getEo(), "elm.swallow.bg", obj); } void DefaultLayout::setFloatingButton(Evas_Object *obj) { - m_pFloatingBtn = obj; - elm_object_part_content_set(getEo(), floatingPart, obj); + m_pFloatingBtn = obj; + elm_object_part_content_set(getEo(), floatingPart, obj); } void DefaultLayout::showFloatingButton(bool show) { - if (show) { - View::setContent(m_pFloatingBtn, floatingPart, true); - evas_object_show(m_pFloatingBtn); - } else { - View::unsetContent(floatingPart); - evas_object_hide(m_pFloatingBtn); - } + if (show) { + View::setContent(m_pFloatingBtn, floatingPart, true); + evas_object_show(m_pFloatingBtn); + } else { + View::unsetContent(floatingPart); + evas_object_hide(m_pFloatingBtn); + } } diff --git a/src/Common/View/src/ListItem.cpp b/src/Common/View/src/ListItem.cpp index c71a5ae5..3fe081fe 100644 --- a/src/Common/View/src/ListItem.cpp +++ b/src/Common/View/src/ListItem.cpp @@ -26,74 +26,74 @@ using namespace Msg; // ListItemClass : ListItemStyle::ListItemStyle(const char *itemStyle, const char *decorateItemStyle, const char *decorateAllItemStyle) - : m_pGenlistItemClass(nullptr) + : m_pGenlistItemClass(nullptr) { - m_pGenlistItemClass = elm_genlist_item_class_new(); + m_pGenlistItemClass = elm_genlist_item_class_new(); - setStyle(itemStyle, decorateItemStyle, decorateAllItemStyle); - registerCallback(); + setStyle(itemStyle, decorateItemStyle, decorateAllItemStyle); + registerCallback(); } ListItemStyle::~ListItemStyle() { - unregisterCallback(); - if (m_pGenlistItemClass) - elm_genlist_item_class_free(m_pGenlistItemClass); + unregisterCallback(); + if (m_pGenlistItemClass) + elm_genlist_item_class_free(m_pGenlistItemClass); } ListItemStyleRef ListItemStyle::create(const char *itemStyle, - const char *decorateItemStyle, - const char *decorateAllItemStyle) + const char *decorateItemStyle, + const char *decorateAllItemStyle) { - return std::shared_ptr(new ListItemStyle(itemStyle, decorateItemStyle, decorateAllItemStyle)); + return std::shared_ptr(new ListItemStyle(itemStyle, decorateItemStyle, decorateAllItemStyle)); } void ListItemStyle::setStyle(const char * itemStyle, const char * decorateItemStyle, const char * decorateAllItemStyle) { - if (!m_pGenlistItemClass) - return; + if (!m_pGenlistItemClass) + return; - m_pGenlistItemClass->decorate_all_item_style = decorateAllItemStyle; - m_pGenlistItemClass->decorate_item_style = decorateItemStyle; - m_pGenlistItemClass->item_style = itemStyle; + m_pGenlistItemClass->decorate_all_item_style = decorateAllItemStyle; + m_pGenlistItemClass->decorate_item_style = decorateItemStyle; + m_pGenlistItemClass->item_style = itemStyle; } void ListItemStyle::registerCallback() { - if (!m_pGenlistItemClass) - return; + if (!m_pGenlistItemClass) + return; - m_pGenlistItemClass->func.text_get = &ListItem::elm_gen_item_text_get_cb; - m_pGenlistItemClass->func.state_get = &ListItem::elm_gen_item_state_get_cb; - m_pGenlistItemClass->func.del = &ListItem::elm_gen_item_del_cb; - m_pGenlistItemClass->func.content_get = &ListItem::elm_gen_item_content_get_cb; - m_pGenlistItemClass->func.filter_get = &ListItem::elm_gen_item_filter_cb; + m_pGenlistItemClass->func.text_get = &ListItem::elm_gen_item_text_get_cb; + m_pGenlistItemClass->func.state_get = &ListItem::elm_gen_item_state_get_cb; + m_pGenlistItemClass->func.del = &ListItem::elm_gen_item_del_cb; + m_pGenlistItemClass->func.content_get = &ListItem::elm_gen_item_content_get_cb; + m_pGenlistItemClass->func.filter_get = &ListItem::elm_gen_item_filter_cb; } void ListItemStyle::unregisterCallback() { - if (!m_pGenlistItemClass) - return; + if (!m_pGenlistItemClass) + return; - m_pGenlistItemClass->func.text_get = nullptr; - m_pGenlistItemClass->func.state_get = nullptr; - m_pGenlistItemClass->func.del = nullptr; - m_pGenlistItemClass->func.content_get = nullptr; - m_pGenlistItemClass->func.filter_get = nullptr; + m_pGenlistItemClass->func.text_get = nullptr; + m_pGenlistItemClass->func.state_get = nullptr; + m_pGenlistItemClass->func.del = nullptr; + m_pGenlistItemClass->func.content_get = nullptr; + m_pGenlistItemClass->func.filter_get = nullptr; } // ListItemClass: ListItem::ListItem(const ListItemStyleRef &itemStyle, Elm_Genlist_Item_Type type) - : ViewItem() - , m_pOwner(nullptr) - , m_ItemStyle(itemStyle) - , m_Type(type) - , m_Checked(false) + : ViewItem() + , m_pOwner(nullptr) + , m_ItemStyle(itemStyle) + , m_Type(type) + , m_Checked(false) { } ListItem::ListItem(Elm_Genlist_Item_Type type) - : ListItem(ListItemStyleRef(), type) + : ListItem(ListItemStyleRef(), type) { } @@ -103,171 +103,171 @@ ListItem::~ListItem() ListView *ListItem::getOwner() const { - return m_pOwner; + return m_pOwner; } Elm_Genlist_Item_Type ListItem::getType() const { - return m_Type; + return m_Type; } void ListItem::setStyle(ListItemStyleRef &style) { - m_ItemStyle = style; + m_ItemStyle = style; } const ListItemStyleRef &ListItem::getStyle() const { - return m_ItemStyle; + return m_ItemStyle; } char *ListItem::elm_gen_item_text_get_cb(void *data, Evas_Object *obj, const char *part) { - ListItem *self = static_cast(data); + ListItem *self = static_cast(data); - if (self) { - std::string text = self->getText(*self, part); - return text.empty() ? nullptr : strdup(text.c_str()); - } + if (self) { + std::string text = self->getText(*self, part); + return text.empty() ? nullptr : strdup(text.c_str()); + } - return nullptr; + return nullptr; } Evas_Object *ListItem::elm_gen_item_content_get_cb(void * data, Evas_Object * obj, const char * part) { - ListItem *self = static_cast(data); + ListItem *self = static_cast(data); - if (!self) - return nullptr; + if (!self) + return nullptr; - if (self->getOwner()->getCheckMode()) { - const char *checkPart = self->getCheckPart(*self); - if (checkPart && strcmp(checkPart, part) == 0) - return self->addCheck(); - } + if (self->getOwner()->getCheckMode()) { + const char *checkPart = self->getCheckPart(*self); + if (checkPart && strcmp(checkPart, part) == 0) + return self->addCheck(); + } - return self->getContent(*self, part); + return self->getContent(*self, part); } Eina_Bool ListItem::elm_gen_item_filter_cb(void *data, Evas_Object *obj, void *key) { - ListItem *self = static_cast(data); - return self ? self->getFilter(*self, key) : false; + ListItem *self = static_cast(data); + return self ? self->getFilter(*self, key) : false; } Evas_Object *ListItem::addCheck() { - Evas_Object *check = elm_check_add(*getOwner()); - elm_check_state_set(check, m_Checked); - evas_object_propagate_events_set(check, EINA_FALSE); - evas_object_smart_callback_add(check, "changed", SMART_CALLBACK(ListItem, onCheckChanged), this); - elm_object_focus_allow_set(check, false); - evas_object_show(check); - return check; + Evas_Object *check = elm_check_add(*getOwner()); + elm_check_state_set(check, m_Checked); + evas_object_propagate_events_set(check, EINA_FALSE); + evas_object_smart_callback_add(check, "changed", SMART_CALLBACK(ListItem, onCheckChanged), this); + elm_object_focus_allow_set(check, false); + evas_object_show(check); + return check; } void ListItem::changeCheckedState(bool updateUi) { - setCheckedState(!getCheckedState(), updateUi); + setCheckedState(!getCheckedState(), updateUi); } void ListItem::setCheckedState(bool state, bool updateUi) { - m_Checked = state; - if (updateUi) - updateFields(getCheckPart(*this), ELM_GENLIST_ITEM_FIELD_ALL); + m_Checked = state; + if (updateUi) + updateFields(getCheckPart(*this), ELM_GENLIST_ITEM_FIELD_ALL); } bool ListItem::getCheckedState() const { - return m_Checked; + return m_Checked; } bool ListItem::isCheckable() const { - ListItem &self = const_cast(*this); - return self.getCheckPart(self) != nullptr; + ListItem &self = const_cast(*this); + return self.getCheckPart(self) != nullptr; } void ListItem::onCheckChanged(Evas_Object *obj, void *eventInfo) { - m_Checked = elm_check_state_get(obj); - getOwner()->notifyListener(nullptr, obj, getElmObjItem(), &IListViewListener::onListItemChecked); + m_Checked = elm_check_state_get(obj); + getOwner()->notifyListener(nullptr, obj, getElmObjItem(), &IListViewListener::onListItemChecked); } Eina_Bool ListItem::elm_gen_item_state_get_cb(void *data, Evas_Object *obj, const char *part) { - ListItem *self = static_cast(data); - return self ? self->getState(*self, part) : false; + ListItem *self = static_cast(data); + return self ? self->getState(*self, part) : false; } void ListItem::setSelected(bool selected) { - elm_genlist_item_selected_set(getElmObjItem(), selected); + elm_genlist_item_selected_set(getElmObjItem(), selected); } bool ListItem::getSelected() const { - return elm_genlist_item_selected_get(getElmObjItem()); + return elm_genlist_item_selected_get(getElmObjItem()); } void ListItem::setSelectable(bool selectable) { - Elm_Object_Select_Mode mode = selectable ? ELM_OBJECT_SELECT_MODE_DEFAULT : ELM_OBJECT_SELECT_MODE_NONE; - elm_genlist_item_select_mode_set(getElmObjItem(), mode); + Elm_Object_Select_Mode mode = selectable ? ELM_OBJECT_SELECT_MODE_DEFAULT : ELM_OBJECT_SELECT_MODE_NONE; + elm_genlist_item_select_mode_set(getElmObjItem(), mode); } bool ListItem::getSelectable() const { - Elm_Object_Select_Mode mode = elm_genlist_item_select_mode_get(getElmObjItem()); - return mode == ELM_OBJECT_SELECT_MODE_DEFAULT || mode == ELM_OBJECT_SELECT_MODE_ALWAYS; + Elm_Object_Select_Mode mode = elm_genlist_item_select_mode_get(getElmObjItem()); + return mode == ELM_OBJECT_SELECT_MODE_DEFAULT || mode == ELM_OBJECT_SELECT_MODE_ALWAYS; } void ListItem::setExpanded(bool expand) { - elm_genlist_item_expanded_set(getElmObjItem(), expand); + elm_genlist_item_expanded_set(getElmObjItem(), expand); } void ListItem::update() { - if (m_ItemStyle->m_pGenlistItemClass != elm_genlist_item_item_class_get(getElmObjItem())) - elm_genlist_item_item_class_update(getElmObjItem(), m_ItemStyle->m_pGenlistItemClass); - elm_genlist_item_update(getElmObjItem()); + if (m_ItemStyle->m_pGenlistItemClass != elm_genlist_item_item_class_get(getElmObjItem())) + elm_genlist_item_item_class_update(getElmObjItem(), m_ItemStyle->m_pGenlistItemClass); + elm_genlist_item_update(getElmObjItem()); } void ListItem::updateFields(const char *parts, Elm_Genlist_Item_Field_Type type) { - elm_genlist_item_fields_update(getElmObjItem(), parts, type); + elm_genlist_item_fields_update(getElmObjItem(), parts, type); } std::string ListItem::getText(ListItem &item, const char* part) { - return std::string(); + return std::string(); } bool ListItem::getFilter(ListItem &item, void *key) { - return true; + return true; } Evas_Object* ListItem::getContent(ListItem &item, const char* part) { - return nullptr; + return nullptr; } bool ListItem::getState(ListItem &item, const char* part) { - return false; + return false; } void ListItem::onDelete(ListItem &item) { - delete this; + delete this; } const char *ListItem::getCheckPart(ListItem &item) { - return nullptr; + return nullptr; } void ListItem::onViewDestroyed() @@ -276,9 +276,9 @@ void ListItem::onViewDestroyed() void ListItem::elm_gen_item_del_cb(void *data, Evas_Object *obj) { - ListItem *self = static_cast(data); + ListItem *self = static_cast(data); - if (self) - self->onDelete(*self); + if (self) + self->onDelete(*self); } diff --git a/src/Common/View/src/ListView.cpp b/src/Common/View/src/ListView.cpp index bae81cca..df75b734 100644 --- a/src/Common/View/src/ListView.cpp +++ b/src/Common/View/src/ListView.cpp @@ -24,20 +24,20 @@ using namespace Msg; namespace { - inline ListItem *getItem(Elm_Object_Item *obj) - { - return obj ? static_cast(elm_object_item_data_get(obj)) : nullptr; - } + inline ListItem *getItem(Elm_Object_Item *obj) + { + return obj ? static_cast(elm_object_item_data_get(obj)) : nullptr; + } } // ListView: ListView::ListView(Evas_Object *parent) - : View() - , m_pListener(nullptr) - , m_CheckMode(false) - , m_CmpFunc() + : View() + , m_pListener(nullptr) + , m_CheckMode(false) + , m_CmpFunc() { - createListView(parent); + createListView(parent); } ListView::~ListView() @@ -46,276 +46,276 @@ ListView::~ListView() void ListView::setListener(IListViewListener *listener) { - m_pListener = listener; + m_pListener = listener; } void ListView::createListView(Evas_Object *parent) { - setEo(elm_genlist_add(parent)); - evas_object_smart_callback_add(getEo(), "realized", ListView::on_realized_cb, this); - evas_object_smart_callback_add(getEo(), "unrealized", ListView::on_unrealized_cb, this); - evas_object_smart_callback_add(getEo(), "longpressed", ListView::on_longpressed_cb, this); + setEo(elm_genlist_add(parent)); + evas_object_smart_callback_add(getEo(), "realized", ListView::on_realized_cb, this); + evas_object_smart_callback_add(getEo(), "unrealized", ListView::on_unrealized_cb, this); + evas_object_smart_callback_add(getEo(), "longpressed", ListView::on_longpressed_cb, this); } bool ListView::appendItem(ListItem &listItem, ListItem *parent) { - Elm_Object_Item *parentItem = parent ? parent->getElmObjItem() : nullptr; + Elm_Object_Item *parentItem = parent ? parent->getElmObjItem() : nullptr; - listItem.m_pOwner = this; - Elm_Object_Item *elmItem = elm_genlist_item_append(getEo(), listItem.m_ItemStyle->m_pGenlistItemClass, - &listItem, parentItem, listItem.getType(), on_item_selected_cb, this); - listItem.setElmObjItem(elmItem); - return elmItem != nullptr; + listItem.m_pOwner = this; + Elm_Object_Item *elmItem = elm_genlist_item_append(getEo(), listItem.m_ItemStyle->m_pGenlistItemClass, + &listItem, parentItem, listItem.getType(), on_item_selected_cb, this); + listItem.setElmObjItem(elmItem); + return elmItem != nullptr; } bool ListView::insertBeforeItem(ListItem &listItem, ListItem &before, ListItem *parent) { - Elm_Object_Item *parentItem = parent ? parent->getElmObjItem() : nullptr; + Elm_Object_Item *parentItem = parent ? parent->getElmObjItem() : nullptr; - listItem.m_pOwner = this; - Elm_Object_Item *elmItem = elm_genlist_item_insert_before(getEo(), listItem.m_ItemStyle->m_pGenlistItemClass, - &listItem, parentItem, before, listItem.getType(), on_item_selected_cb, this); - listItem.setElmObjItem(elmItem); - return elmItem != nullptr; + listItem.m_pOwner = this; + Elm_Object_Item *elmItem = elm_genlist_item_insert_before(getEo(), listItem.m_ItemStyle->m_pGenlistItemClass, + &listItem, parentItem, before, listItem.getType(), on_item_selected_cb, this); + listItem.setElmObjItem(elmItem); + return elmItem != nullptr; } bool ListView::prependItem(ListItem &listItem, ListItem *parent) { - Elm_Object_Item *parentItem = parent ? parent->getElmObjItem() : nullptr; + Elm_Object_Item *parentItem = parent ? parent->getElmObjItem() : nullptr; - listItem.m_pOwner = this; - Elm_Object_Item *elmItem = elm_genlist_item_prepend(getEo(), listItem.m_ItemStyle->m_pGenlistItemClass, - &listItem, parentItem, listItem.getType(), on_item_selected_cb, this); + listItem.m_pOwner = this; + Elm_Object_Item *elmItem = elm_genlist_item_prepend(getEo(), listItem.m_ItemStyle->m_pGenlistItemClass, + &listItem, parentItem, listItem.getType(), on_item_selected_cb, this); - listItem.setElmObjItem(elmItem); - return elmItem != nullptr; + listItem.setElmObjItem(elmItem); + return elmItem != nullptr; } bool ListView::sortedInsertItem(ListItem &listItem, ListItem *parent) { - Elm_Object_Item *parentItem = parent ? parent->getElmObjItem() : nullptr; - - listItem.m_pOwner = this; - Elm_Object_Item *elmItem = elm_genlist_item_sorted_insert - ( - getEo(), - listItem.m_ItemStyle->m_pGenlistItemClass, - &listItem, - parentItem, - listItem.getType(), - [](const void *data1, const void *data2)->int - { - int res = 0; - ListItem *item1 = (ListItem*)elm_object_item_data_get((Elm_Object_Item*)data1); - ListItem *item2 = (ListItem*)elm_object_item_data_get((Elm_Object_Item*)data2); - if (item1->m_pOwner->m_CmpFunc) - res = item1->m_pOwner->m_CmpFunc(*item1, *item2); - - return res; - }, - on_item_selected_cb, - this); - - listItem.setElmObjItem(elmItem); - return elmItem != nullptr; + Elm_Object_Item *parentItem = parent ? parent->getElmObjItem() : nullptr; + + listItem.m_pOwner = this; + Elm_Object_Item *elmItem = elm_genlist_item_sorted_insert + ( + getEo(), + listItem.m_ItemStyle->m_pGenlistItemClass, + &listItem, + parentItem, + listItem.getType(), + [](const void *data1, const void *data2)->int + { + int res = 0; + ListItem *item1 = (ListItem*)elm_object_item_data_get((Elm_Object_Item*)data1); + ListItem *item2 = (ListItem*)elm_object_item_data_get((Elm_Object_Item*)data2); + if (item1->m_pOwner->m_CmpFunc) + res = item1->m_pOwner->m_CmpFunc(*item1, *item2); + + return res; + }, + on_item_selected_cb, + this); + + listItem.setElmObjItem(elmItem); + return elmItem != nullptr; } void ListView::setCmpFunc(CmpFunc fn) { - m_CmpFunc = fn; + m_CmpFunc = fn; } void ListView::deleteItem(ListItem &listItem) { - elm_object_item_del(listItem.getElmObjItem()); + elm_object_item_del(listItem.getElmObjItem()); } ListItemCollection ListView::getItems() const { - ListItemCollection list; - Elm_Object_Item *elmItem = elm_genlist_first_item_get(getEo()); - while (elmItem) { - void *data = elm_object_item_data_get(elmItem); - MSG_ASSERT(data, "Genlist item data is NULL"); - if (data) { - ListItem *listItem = static_cast(data); - list.push_back(listItem); - } - elmItem = elm_genlist_item_next_get(elmItem); - } + ListItemCollection list; + Elm_Object_Item *elmItem = elm_genlist_first_item_get(getEo()); + while (elmItem) { + void *data = elm_object_item_data_get(elmItem); + MSG_ASSERT(data, "Genlist item data is NULL"); + if (data) { + ListItem *listItem = static_cast(data); + list.push_back(listItem); + } + elmItem = elm_genlist_item_next_get(elmItem); + } - return list; + return list; } ListItemCollection ListView::getRealizedItems() const { - ListItemCollection collection; - Eina_List *list = elm_genlist_realized_items_get(getEo()); - if (list) { - void *obj = nullptr; - Eina_List *l = nullptr; + ListItemCollection collection; + Eina_List *list = elm_genlist_realized_items_get(getEo()); + if (list) { + void *obj = nullptr; + Eina_List *l = nullptr; - EINA_LIST_FOREACH(list, l, obj) { - collection.push_back(getItem((Elm_Object_Item *)obj)); - } + EINA_LIST_FOREACH(list, l, obj) { + collection.push_back(getItem((Elm_Object_Item *)obj)); + } - eina_list_free(list); - } + eina_list_free(list); + } - return collection; + return collection; } ListItem *ListView::getFirstItem() const { - return getItem(elm_genlist_first_item_get(getEo())); + return getItem(elm_genlist_first_item_get(getEo())); } ListItem *ListView::getLastItem() const { - return getItem(elm_genlist_last_item_get(getEo())); + return getItem(elm_genlist_last_item_get(getEo())); } void ListView::showItem(ListItem &listItem, Elm_Genlist_Item_Scrollto_Type type) { - elm_genlist_item_show(listItem.getElmObjItem(), type); + elm_genlist_item_show(listItem.getElmObjItem(), type); } void ListView::clear() { - elm_genlist_clear(getEo()); + elm_genlist_clear(getEo()); } bool ListView::isEmpty() const { - return elm_genlist_first_item_get(getEo()) == nullptr; + return elm_genlist_first_item_get(getEo()) == nullptr; } void ListView::setMode(Elm_List_Mode mode) { - elm_genlist_mode_set(getEo(), mode); + elm_genlist_mode_set(getEo(), mode); } void ListView::setHomogeneous(bool isHomogeneous) { - elm_genlist_homogeneous_set(getEo(), isHomogeneous); + elm_genlist_homogeneous_set(getEo(), isHomogeneous); } ListItem *ListView::getSelectedItem() const { - Elm_Object_Item *elmItem = elm_genlist_selected_item_get(getEo()); - return ListItem::staticCast(elmItem); + Elm_Object_Item *elmItem = elm_genlist_selected_item_get(getEo()); + return ListItem::staticCast(elmItem); } unsigned ListView::getItemsCount() const { - return elm_genlist_items_count(getEo()); + return elm_genlist_items_count(getEo()); } ListItem *ListView::getNextItem(ListItem &item) const { - return ListItem::staticCast(elm_genlist_item_next_get(item)); + return ListItem::staticCast(elm_genlist_item_next_get(item)); } ListItem *ListView::getPrevItem(ListItem &item) const { - return ListItem::staticCast(elm_genlist_item_prev_get(item)); + return ListItem::staticCast(elm_genlist_item_prev_get(item)); } void ListView::demoteItem(ListItem &item) { - elm_genlist_item_demote(item); + elm_genlist_item_demote(item); } void ListView::promoteItem(ListItem &item) { - elm_genlist_item_promote(item); + elm_genlist_item_promote(item); } void ListView::setFilter(void *key) { - elm_genlist_filter_set(getEo(), key); + elm_genlist_filter_set(getEo(), key); } void ListView::notifyListener(void *data, Evas_Object *obj, void *event_info, ListenerMethod method) { - ListItem *item = ListItem::staticCast(event_info); - MSG_ASSERT(item, "Item is null"); + ListItem *item = ListItem::staticCast(event_info); + MSG_ASSERT(item, "Item is null"); - if (item) { - ListView *owner = item->getOwner(); - MSG_ASSERT(owner, "ListItem::owner is null"); + if (item) { + ListView *owner = item->getOwner(); + MSG_ASSERT(owner, "ListItem::owner is null"); - if (owner && owner->m_pListener) - (owner->m_pListener->*method)(*item); - } + if (owner && owner->m_pListener) + (owner->m_pListener->*method)(*item); + } } void ListView::setCheckMode(bool check) { - m_CheckMode = check; + m_CheckMode = check; } bool ListView::getCheckMode() const { - return m_CheckMode; + return m_CheckMode; } void ListView::checkAllItems(bool check, bool updateFullItem) { - for (ListItem *item: getItems()) - item->setCheckedState(check, false); + for (ListItem *item: getItems()) + item->setCheckedState(check, false); - if (updateFullItem) - updateRealizedItems(); - else - for (ListItem *item: getRealizedItems()) - item->updateFields(item->getCheckPart(*item), ELM_GENLIST_ITEM_FIELD_ALL); + if (updateFullItem) + updateRealizedItems(); + else + for (ListItem *item: getRealizedItems()) + item->updateFields(item->getCheckPart(*item), ELM_GENLIST_ITEM_FIELD_ALL); } void ListView::updateRealizedItems() { - elm_genlist_realized_items_update(getEo()); + elm_genlist_realized_items_update(getEo()); } void ListView::setMultiSelection(bool value) { - elm_genlist_multi_select_set(getEo(), value); + elm_genlist_multi_select_set(getEo(), value); } bool ListView::getMultiSelection() const { - return elm_genlist_multi_select_get(getEo()); + return elm_genlist_multi_select_get(getEo()); } void ListView::on_item_selected_cb(void *data, Evas_Object *obj, void *event_info) { - ListItem *item = ListItem::staticCast(event_info); + ListItem *item = ListItem::staticCast(event_info); - item->setSelected(false); - if (item->getOwner()->getCheckMode() && item->isCheckable()) { - item->changeCheckedState(true); - notifyListener(data, obj, event_info, &IListViewListener::onListItemChecked); - } else { - notifyListener(data, obj, event_info, &IListViewListener::onListItemSelected); - } + item->setSelected(false); + if (item->getOwner()->getCheckMode() && item->isCheckable()) { + item->changeCheckedState(true); + notifyListener(data, obj, event_info, &IListViewListener::onListItemChecked); + } else { + notifyListener(data, obj, event_info, &IListViewListener::onListItemSelected); + } } void ListView::on_realized_cb(void *data, Evas_Object *obj, void *event_info) { - ListItem *item = ListItem::staticCast(event_info); - item->onRealized(*item); + ListItem *item = ListItem::staticCast(event_info); + item->onRealized(*item); } void ListView::on_unrealized_cb(void *data, Evas_Object *obj, void *event_info) { - ListItem *item = ListItem::staticCast(event_info); - item->onUnrealized(*item); + ListItem *item = ListItem::staticCast(event_info); + item->onUnrealized(*item); } void ListView::on_longpressed_cb(void *data, Evas_Object *obj, void *event_info) { - ListItem *item = ListItem::staticCast(event_info); - item->setSelected(false); - if (!item->getOwner()->getCheckMode()) - notifyListener(data, obj, event_info, &IListViewListener::onListItemLongPressed); + ListItem *item = ListItem::staticCast(event_info); + item->setSelected(false); + if (!item->getOwner()->getCheckMode()) + notifyListener(data, obj, event_info, &IListViewListener::onListItemLongPressed); } diff --git a/src/Common/View/src/MbeRecipientsView.cpp b/src/Common/View/src/MbeRecipientsView.cpp index c6ecbd42..5e9c791e 100644 --- a/src/Common/View/src/MbeRecipientsView.cpp +++ b/src/Common/View/src/MbeRecipientsView.cpp @@ -20,96 +20,96 @@ using namespace Msg; MbeRecipientsView::MbeRecipientsView(Evas_Object *parent) - : m_pListener(nullptr) - , m_pSelectedItem(nullptr) - , m_pChangedJob(nullptr) + : m_pListener(nullptr) + , m_pSelectedItem(nullptr) + , m_pChangedJob(nullptr) { - setEo(elm_multibuttonentry_add(parent)); - elm_multibuttonentry_editable_set(getEo(), false); - elm_multibuttonentry_expanded_set(getEo(), true); - elm_object_tree_focus_allow_set(getEo(), false); - - addSmartCb("item,clicked", SMART_CALLBACK(MbeRecipientsView, onMbeItemClicked), this); - addSmartCb("item,added", SMART_CALLBACK(MbeRecipientsView, onMbeChanged), this); - addSmartCb("item,deleted", SMART_CALLBACK(MbeRecipientsView, onMbeChanged), this); + setEo(elm_multibuttonentry_add(parent)); + elm_multibuttonentry_editable_set(getEo(), false); + elm_multibuttonentry_expanded_set(getEo(), true); + elm_object_tree_focus_allow_set(getEo(), false); + + addSmartCb("item,clicked", SMART_CALLBACK(MbeRecipientsView, onMbeItemClicked), this); + addSmartCb("item,added", SMART_CALLBACK(MbeRecipientsView, onMbeChanged), this); + addSmartCb("item,deleted", SMART_CALLBACK(MbeRecipientsView, onMbeChanged), this); } MbeRecipientsView::~MbeRecipientsView() { - if (m_pChangedJob) { - ecore_job_del(m_pChangedJob); - m_pChangedJob = nullptr; - } + if (m_pChangedJob) { + ecore_job_del(m_pChangedJob); + m_pChangedJob = nullptr; + } } void MbeRecipientsView::appendItem(MbeRecipientItem &item) { - Elm_Object_Item *elmItem = elm_multibuttonentry_item_append(getEo(), item.getDispName().c_str(), nullptr, &item); - item.setElmObjItem(elmItem); + Elm_Object_Item *elmItem = elm_multibuttonentry_item_append(getEo(), item.getDispName().c_str(), nullptr, &item); + item.setElmObjItem(elmItem); } int MbeRecipientsView::getItemsCount() const { - unsigned int res = 0; - const Eina_List* items = elm_multibuttonentry_items_get(getEo()); - if (items) - res = eina_list_count(items); - return res; + unsigned int res = 0; + const Eina_List* items = elm_multibuttonentry_items_get(getEo()); + if (items) + res = eina_list_count(items); + return res; } std::vector MbeRecipientsView::getItems() const { - std::vector res; + std::vector res; - Elm_Object_Item *elmItem = elm_multibuttonentry_first_item_get(getEo()); - while (elmItem) { - MbeRecipientItem *item = static_cast(elm_object_item_data_get(elmItem)); - res.push_back(item); - elmItem = elm_multibuttonentry_item_next_get(elmItem); - } + Elm_Object_Item *elmItem = elm_multibuttonentry_first_item_get(getEo()); + while (elmItem) { + MbeRecipientItem *item = static_cast(elm_object_item_data_get(elmItem)); + res.push_back(item); + elmItem = elm_multibuttonentry_item_next_get(elmItem); + } - return res; + return res; } MbeRecipientItem *MbeRecipientsView::getSelectedItem() const { - MbeRecipientItem *pSelected = ViewItem::staticCast(elm_multibuttonentry_selected_item_get(getEo())); - return pSelected ? pSelected : m_pSelectedItem; + MbeRecipientItem *pSelected = ViewItem::staticCast(elm_multibuttonentry_selected_item_get(getEo())); + return pSelected ? pSelected : m_pSelectedItem; } bool MbeRecipientsView::isEmpty() const { - return elm_multibuttonentry_first_item_get(getEo()) == nullptr; + return elm_multibuttonentry_first_item_get(getEo()) == nullptr; } void MbeRecipientsView::clear() { - elm_multibuttonentry_clear(getEo()); + elm_multibuttonentry_clear(getEo()); } void MbeRecipientsView::setListener(IMbeRecipientsListener *pListener) { - m_pListener = pListener; + m_pListener = pListener; } void MbeRecipientsView::onMbeItemClicked(Evas_Object *obj, void *eventInfo) { - m_pSelectedItem = ViewItem::staticCast(eventInfo); - if (m_pListener) - m_pListener->onMbeItemClicked(*m_pSelectedItem); + m_pSelectedItem = ViewItem::staticCast(eventInfo); + if (m_pListener) + m_pListener->onMbeItemClicked(*m_pSelectedItem); } void MbeRecipientsView::onMbeChanged(Evas_Object *obj, void *eventInfo) { - if (!m_pChangedJob) - m_pChangedJob = ecore_job_add - ( - [](void *data) - { - MbeRecipientsView *self = static_cast(data); - self->m_pChangedJob = nullptr; - if (self->m_pListener) - self->m_pListener->onMbeChanged(); - }, - this); + if (!m_pChangedJob) + m_pChangedJob = ecore_job_add + ( + [](void *data) + { + MbeRecipientsView *self = static_cast(data); + self->m_pChangedJob = nullptr; + if (self->m_pListener) + self->m_pListener->onMbeChanged(); + }, + this); } diff --git a/src/Common/View/src/NaviFrameItem.cpp b/src/Common/View/src/NaviFrameItem.cpp index 76eac2ab..064182fb 100644 --- a/src/Common/View/src/NaviFrameItem.cpp +++ b/src/Common/View/src/NaviFrameItem.cpp @@ -23,35 +23,35 @@ using namespace Msg; namespace { - const char *titleStyleName = "title"; - const char *naviTitlePart = "title"; - const char *titleTextPart = "text.center"; - const char *okButtonPart = "swallow.right"; - const char *cancelButtonPart = "swallow.left"; - const char *prevButtonPart = "swallow.left"; - const char *downButtonPart = "swallow.right"; - const char *centerButtonPart = "swallow.center"; - const char *okButtonStyle = "naviframe/title_right"; - const char *cancelButtonStyle = "naviframe/title_left"; - const char *centerButtonStyle = "naviframe/title_center"; - const char *prevButtonStyle = "naviframe/arrow_back"; - const char *downButtonStyle = "naviframe/arrow_down"; - const char *cancelButtonDefTextId = "IDS_MSG_ACBUTTON_CANCEL_ABB"; - const char *okButtonDefTextId = "IDS_MSG_ACBUTTON_DONE_ABB"; - const char *buttonTypeKey = "BTkey"; - const char *textColorBlueDisableButtons = "#abd1d6"; - const char *textColorBlueTitleButtons = "#2e8b99"; - const char *textColorWhiteTitleButtons = "#fafafa"; - const int textSizeCenterButton = 50; - const int textSizeLateralButton = 35; + const char *titleStyleName = "title"; + const char *naviTitlePart = "title"; + const char *titleTextPart = "text.center"; + const char *okButtonPart = "swallow.right"; + const char *cancelButtonPart = "swallow.left"; + const char *prevButtonPart = "swallow.left"; + const char *downButtonPart = "swallow.right"; + const char *centerButtonPart = "swallow.center"; + const char *okButtonStyle = "naviframe/title_right"; + const char *cancelButtonStyle = "naviframe/title_left"; + const char *centerButtonStyle = "naviframe/title_center"; + const char *prevButtonStyle = "naviframe/arrow_back"; + const char *downButtonStyle = "naviframe/arrow_down"; + const char *cancelButtonDefTextId = "IDS_MSG_ACBUTTON_CANCEL_ABB"; + const char *okButtonDefTextId = "IDS_MSG_ACBUTTON_DONE_ABB"; + const char *buttonTypeKey = "BTkey"; + const char *textColorBlueDisableButtons = "#abd1d6"; + const char *textColorBlueTitleButtons = "#2e8b99"; + const char *textColorWhiteTitleButtons = "#fafafa"; + const int textSizeCenterButton = 50; + const int textSizeLateralButton = 35; } NaviFrameItem::NaviFrameItem(NaviFrameView &owner) - : ViewItem() - , m_Owner(owner) - , m_IsPopping(false) + : ViewItem() + , m_Owner(owner) + , m_IsPopping(false) { - m_pNaviBar = new NaviBar(*this); + m_pNaviBar = new NaviBar(*this); } NaviFrameItem::~NaviFrameItem() @@ -60,51 +60,51 @@ NaviFrameItem::~NaviFrameItem() const NaviFrameItem::NaviBar &NaviFrameItem::getNaviBar() const { - return *m_pNaviBar; + return *m_pNaviBar; } NaviFrameItem::NaviBar &NaviFrameItem::getNaviBar() { - return *m_pNaviBar; + return *m_pNaviBar; } NaviFrameView &NaviFrameItem::getOwner() { - return m_Owner; + return m_Owner; } const NaviFrameView &NaviFrameItem::getOwner() const { - return m_Owner; + return m_Owner; } bool NaviFrameItem::isPopping() const { - return m_IsPopping; + return m_IsPopping; } void NaviFrameItem::setTitleVisibility(bool visible) { - if (visible) { - setContent(*m_pNaviBar, naviTitlePart); - evas_object_show(*m_pNaviBar); - } else { - evas_object_hide(elm_object_item_part_content_unset(getElmObjItem(), naviTitlePart)); - } + if (visible) { + setContent(*m_pNaviBar, naviTitlePart); + evas_object_show(*m_pNaviBar); + } else { + evas_object_hide(elm_object_item_part_content_unset(getElmObjItem(), naviTitlePart)); + } } NaviFrameItem::NaviBar::NaviBar(NaviFrameItem &onwer) - : m_Owner(onwer) - , m_ButtonList() - , m_CurrentColor(NaviBlueColorId) - , m_SearchBar(nullptr) + : m_Owner(onwer) + , m_ButtonList() + , m_CurrentColor(NaviBlueColorId) + , m_SearchBar(nullptr) { - setEo(addLayout(m_Owner.getOwner(), MSG_TITLE_EDJ_PATH, titleStyleName)); - m_ButtonList[NaviCancelButtonId] = ButtonStruct(nullptr, cancelButtonPart, cancelButtonStyle, cancelButtonDefTextId); - m_ButtonList[NaviOkButtonId] = ButtonStruct(nullptr, okButtonPart, okButtonStyle, okButtonDefTextId); - m_ButtonList[NaviCenterButtonId] = ButtonStruct(nullptr, centerButtonPart, centerButtonStyle); - m_ButtonList[NaviPrevButtonId] = ButtonStruct(nullptr, prevButtonPart, prevButtonStyle); - m_ButtonList[NaviExpandButtonId] = ButtonStruct(nullptr, downButtonPart, downButtonStyle); + setEo(addLayout(m_Owner.getOwner(), MSG_TITLE_EDJ_PATH, titleStyleName)); + m_ButtonList[NaviCancelButtonId] = ButtonStruct(nullptr, cancelButtonPart, cancelButtonStyle, cancelButtonDefTextId); + m_ButtonList[NaviOkButtonId] = ButtonStruct(nullptr, okButtonPart, okButtonStyle, okButtonDefTextId); + m_ButtonList[NaviCenterButtonId] = ButtonStruct(nullptr, centerButtonPart, centerButtonStyle); + m_ButtonList[NaviPrevButtonId] = ButtonStruct(nullptr, prevButtonPart, prevButtonStyle); + m_ButtonList[NaviExpandButtonId] = ButtonStruct(nullptr, downButtonPart, downButtonStyle); } NaviFrameItem::NaviBar::~NaviBar() @@ -113,285 +113,285 @@ NaviFrameItem::NaviBar::~NaviBar() NaviFrameItem &NaviFrameItem::NaviBar::getOwner() { - return m_Owner; + return m_Owner; } const NaviFrameItem &NaviFrameItem::NaviBar::getOwner() const { - return m_Owner; + return m_Owner; } void NaviFrameItem::NaviBar::setVisible(bool visible) { - getOwner().setTitleVisibility(visible); + getOwner().setTitleVisibility(visible); } void NaviFrameItem::NaviBar::setTitle(const std::string &title) { - setText(title, titleTextPart); + setText(title, titleTextPart); } void NaviFrameItem::NaviBar::setTitle(const TText &title) { - setText(title, titleTextPart); + setText(title, titleTextPart); } std::string NaviFrameItem::NaviBar::getTitle() const { - return getText(titleTextPart); + return getText(titleTextPart); } void NaviFrameItem::NaviBar::getButton(NaviButtonId id) { - if (!m_ButtonList[id].button) { - Evas_Object *btn = elm_button_add(getEo()); - m_ButtonList[id].button = btn; - elm_object_style_set(btn, m_ButtonList[id].style); - setButtonText(id, msgt(m_ButtonList[id].default_text_id)); - evas_object_data_set(btn, buttonTypeKey, (void*)id); - evas_object_smart_callback_add(btn, "clicked", on_button_clicked, this); - } + if (!m_ButtonList[id].button) { + Evas_Object *btn = elm_button_add(getEo()); + m_ButtonList[id].button = btn; + elm_object_style_set(btn, m_ButtonList[id].style); + setButtonText(id, msgt(m_ButtonList[id].default_text_id)); + evas_object_data_set(btn, buttonTypeKey, (void*)id); + evas_object_smart_callback_add(btn, "clicked", on_button_clicked, this); + } } void NaviFrameItem::NaviBar::showButton(NaviButtonId id, bool value) { - if (value) { - getButton(id); + if (value) { + getButton(id); - if (getContent(m_ButtonList[id].part) != m_ButtonList[id].button) - setContent(m_ButtonList[id].button, m_ButtonList[id].part); - setButtonColor(id, m_CurrentColor); - evas_object_show(m_ButtonList[id].button); - } else { - if (getContent(m_ButtonList[id].part) == m_ButtonList[id].button) { - evas_object_del(m_ButtonList[id].button); - m_ButtonList[id].button = nullptr; - } - } + if (getContent(m_ButtonList[id].part) != m_ButtonList[id].button) + setContent(m_ButtonList[id].button, m_ButtonList[id].part); + setButtonColor(id, m_CurrentColor); + evas_object_show(m_ButtonList[id].button); + } else { + if (getContent(m_ButtonList[id].part) == m_ButtonList[id].button) { + evas_object_del(m_ButtonList[id].button); + m_ButtonList[id].button = nullptr; + } + } - switch (id) { - case NaviCancelButtonId: - showCancelButtonPart(value); - break; + switch (id) { + case NaviCancelButtonId: + showCancelButtonPart(value); + break; - case NaviOkButtonId: - showOkButtonPart(value); - break; + case NaviOkButtonId: + showOkButtonPart(value); + break; - case NaviCenterButtonId: - showCenterButtonPart(value); - break; + case NaviCenterButtonId: + showCenterButtonPart(value); + break; - case NaviPrevButtonId: - showPrevButtonPart(value); - break; + case NaviPrevButtonId: + showPrevButtonPart(value); + break; - case NaviExpandButtonId: - showDownButtonPart(value); - break; + case NaviExpandButtonId: + showDownButtonPart(value); + break; - default: - break; - } + default: + break; + } } void NaviFrameItem::NaviBar::disabledButton(NaviButtonId id, bool value) { - elm_object_disabled_set(m_ButtonList[id].button, value); + elm_object_disabled_set(m_ButtonList[id].button, value); - if (m_CurrentColor == NaviBlueColorId) - return; + if (m_CurrentColor == NaviBlueColorId) + return; - TextStyle style; - value ? style.setColor(textColorBlueDisableButtons) : style.setColor(textColorBlueTitleButtons); - style.setSize(getTextSize(id)); + TextStyle style; + value ? style.setColor(textColorBlueDisableButtons) : style.setColor(textColorBlueTitleButtons); + style.setSize(getTextSize(id)); - const char *buttonText = elm_object_text_get(m_ButtonList[id].button); - if (buttonText != nullptr) - elm_object_text_set(m_ButtonList[id].button, TextDecorator::make(TextDecorator::makePlainText(buttonText), style).c_str()); + const char *buttonText = elm_object_text_get(m_ButtonList[id].button); + if (buttonText != nullptr) + elm_object_text_set(m_ButtonList[id].button, TextDecorator::make(TextDecorator::makePlainText(buttonText), style).c_str()); } void NaviFrameItem::NaviBar::showCancelButtonPart(bool value) { - if (value) { - emitSignal("cancel,show,btn", "*"); - } else if (getContent(cancelButtonPart) == nullptr) { - emitSignal("left,clear", "*"); - } + if (value) { + emitSignal("cancel,show,btn", "*"); + } else if (getContent(cancelButtonPart) == nullptr) { + emitSignal("left,clear", "*"); + } } void NaviFrameItem::NaviBar::showOkButtonPart(bool value) { - if (value) - emitSignal("done,show,btn", "*"); - else if (getContent(okButtonPart) == nullptr) - emitSignal("right,clear", "*"); + if (value) + emitSignal("done,show,btn", "*"); + else if (getContent(okButtonPart) == nullptr) + emitSignal("right,clear", "*"); } void NaviFrameItem::NaviBar::showCenterButtonPart(bool value) { - const char *sig = value ? "center,show,btn" : "center,hide,btn"; - emitSignal(sig, "*"); + const char *sig = value ? "center,show,btn" : "center,hide,btn"; + emitSignal(sig, "*"); } void NaviFrameItem::NaviBar::showPrevButtonPart(bool value) { - if (value) - emitSignal("back,show,btn", "*"); - else if (getContent(prevButtonPart) == nullptr) - emitSignal("left,clear", "*"); + if (value) + emitSignal("back,show,btn", "*"); + else if (getContent(prevButtonPart) == nullptr) + emitSignal("left,clear", "*"); - if (getContent(downButtonPart) == nullptr) - emitSignal("empty,right,show", "*"); + if (getContent(downButtonPart) == nullptr) + emitSignal("empty,right,show", "*"); } void NaviFrameItem::NaviBar::showDownButtonPart(bool value) { - if (value) - emitSignal("down,show,btn", "*"); - else if (getContent(downButtonPart) == nullptr) - emitSignal("right,clear", "*"); + if (value) + emitSignal("down,show,btn", "*"); + else if (getContent(downButtonPart) == nullptr) + emitSignal("right,clear", "*"); } int NaviFrameItem::NaviBar::getTextSize(NaviFrameItem::NaviButtonId id) const { - return id == NaviFrameItem::NaviCenterButtonId ? textSizeCenterButton : textSizeLateralButton; + return id == NaviFrameItem::NaviCenterButtonId ? textSizeCenterButton : textSizeLateralButton; } void NaviFrameItem::NaviBar::on_button_clicked(void *data, Evas_Object *obj, void *event_info) { - NaviFrameItem::NaviBar *naviBar = static_cast(data); - int type = (int)(intptr_t)evas_object_data_get(obj, buttonTypeKey); - naviBar->getOwner().onButtonClicked(naviBar->getOwner(), (NaviButtonId)type); + NaviFrameItem::NaviBar *naviBar = static_cast(data); + int type = (int)(intptr_t)evas_object_data_get(obj, buttonTypeKey); + naviBar->getOwner().onButtonClicked(naviBar->getOwner(), (NaviButtonId)type); } void NaviFrameItem::onAttached(ViewItem &item) { - ViewItem::onAttached(item); - setContent(*m_pNaviBar, naviTitlePart); + ViewItem::onAttached(item); + setContent(*m_pNaviBar, naviTitlePart); } void NaviFrameItem::NaviBar::setColor(NaviColorId id) { - switch (id) { - case NaviBlueColorId: - emitSignal("title,color,blue", "*"); - m_CurrentColor = NaviBlueColorId; - break; + switch (id) { + case NaviBlueColorId: + emitSignal("title,color,blue", "*"); + m_CurrentColor = NaviBlueColorId; + break; - case NaviWhiteColorId: - emitSignal("title,color,white", "*"); - m_CurrentColor = NaviWhiteColorId; - break; + case NaviWhiteColorId: + emitSignal("title,color,white", "*"); + m_CurrentColor = NaviWhiteColorId; + break; - default: - break; - } + default: + break; + } } void NaviFrameItem::NaviBar::setButtonText(NaviButtonId id, const std::string &text) { - // Note that, button's color is opposite to title's color - TextStyle style; + // Note that, button's color is opposite to title's color + TextStyle style; - switch (m_CurrentColor) { - case NaviBlueColorId: - style.setColor(textColorWhiteTitleButtons); - break; + switch (m_CurrentColor) { + case NaviBlueColorId: + style.setColor(textColorWhiteTitleButtons); + break; - case NaviWhiteColorId: - style.setColor(textColorBlueTitleButtons); - break; + case NaviWhiteColorId: + style.setColor(textColorBlueTitleButtons); + break; - default: - break; - } - style.setSize(getTextSize(id)); - elm_object_text_set(m_ButtonList[id].button, TextDecorator::make(text, style).c_str()); + default: + break; + } + style.setSize(getTextSize(id)); + elm_object_text_set(m_ButtonList[id].button, TextDecorator::make(text, style).c_str()); } void NaviFrameItem::NaviBar::setButtonText(NaviButtonId id, const TText &text) { - setText(m_ButtonList[id].button, text); + setText(m_ButtonList[id].button, text); } void NaviFrameItem::NaviBar::setButtonColor(NaviButtonId id, NaviColorId titleColor) { - // Note that, button's color is opposite to title's color - if (id == NaviPrevButtonId || id == NaviExpandButtonId) { - switch (titleColor) - { - case NaviBlueColorId: - emitSignal(m_ButtonList[id].button, "button,color,white", "*"); - break; - - case NaviWhiteColorId: - emitSignal(m_ButtonList[id].button, "button,color,blue", "*"); - break; - - default: - break; - } - } else { - TextStyle style; - - switch (titleColor) { - case NaviBlueColorId: - style.setColor(textColorWhiteTitleButtons); - break; - - case NaviWhiteColorId: - style.setColor(textColorBlueTitleButtons); - break; - - default: - break; - } - style.setSize(getTextSize(id)); - const char *buttonText = elm_object_text_get(m_ButtonList[id].button); - if (buttonText != nullptr) - elm_object_text_set(m_ButtonList[id].button, TextDecorator::make(buttonText, style).c_str()); - } + // Note that, button's color is opposite to title's color + if (id == NaviPrevButtonId || id == NaviExpandButtonId) { + switch (titleColor) + { + case NaviBlueColorId: + emitSignal(m_ButtonList[id].button, "button,color,white", "*"); + break; + + case NaviWhiteColorId: + emitSignal(m_ButtonList[id].button, "button,color,blue", "*"); + break; + + default: + break; + } + } else { + TextStyle style; + + switch (titleColor) { + case NaviBlueColorId: + style.setColor(textColorWhiteTitleButtons); + break; + + case NaviWhiteColorId: + style.setColor(textColorBlueTitleButtons); + break; + + default: + break; + } + style.setSize(getTextSize(id)); + const char *buttonText = elm_object_text_get(m_ButtonList[id].button); + if (buttonText != nullptr) + elm_object_text_set(m_ButtonList[id].button, TextDecorator::make(buttonText, style).c_str()); + } } void NaviFrameItem::NaviBar::clear() { - emitSignal("sides,clear", "*"); - for (int iter = NaviCancelButtonId; iter < NaviButtonMax; iter++) - evas_object_hide(elm_object_part_content_unset(getEo(), m_ButtonList[iter].part)); + emitSignal("sides,clear", "*"); + for (int iter = NaviCancelButtonId; iter < NaviButtonMax; iter++) + evas_object_hide(elm_object_part_content_unset(getEo(), m_ButtonList[iter].part)); - showCenterButtonPart(false); + showCenterButtonPart(false); } void NaviFrameItem::NaviBar::setSearch(Evas_Object *searchPanel) { - m_SearchBar = searchPanel; + m_SearchBar = searchPanel; } Evas_Object *NaviFrameItem::NaviBar::getSearch() { - return m_SearchBar; + return m_SearchBar; } const Evas_Object *NaviFrameItem::NaviBar::getSearch() const { - return m_SearchBar; + return m_SearchBar; } void NaviFrameItem::NaviBar::showSearch() { - emitSignal("search,show", "*"); - setContent(m_SearchBar, m_ButtonList[NaviCenterButtonId].part); + emitSignal("search,show", "*"); + setContent(m_SearchBar, m_ButtonList[NaviCenterButtonId].part); } void NaviFrameItem::NaviBar::hideSearch() { - showButton(NaviCenterButtonId, false); - showDownButtonPart(false); + showButton(NaviCenterButtonId, false); + showDownButtonPart(false); } void NaviFrameItem::NaviBar::setDownButtonState(bool expand) { - const char *sig = expand ? "button,expand" : "button,collapse"; - emitSignal(m_ButtonList[NaviExpandButtonId].button, sig, "*"); + const char *sig = expand ? "button,expand" : "button,collapse"; + emitSignal(m_ButtonList[NaviExpandButtonId].button, sig, "*"); } diff --git a/src/Common/View/src/NaviFrameView.cpp b/src/Common/View/src/NaviFrameView.cpp index e2763f4f..bc5b27d9 100644 --- a/src/Common/View/src/NaviFrameView.cpp +++ b/src/Common/View/src/NaviFrameView.cpp @@ -24,17 +24,17 @@ using namespace Msg; const char *naviTitleStyleEmpty = "empty"; NaviFrameView::NaviFrameView(Evas_Object *parent) - : View() - , m_TransitionStatus(false) + : View() + , m_TransitionStatus(false) { - create(parent); + create(parent); } NaviFrameView::NaviFrameView(View &parent) - : View() - , m_TransitionStatus(false) + : View() + , m_TransitionStatus(false) { - create(parent.getEo()); + create(parent.getEo()); } NaviFrameView::~NaviFrameView() @@ -43,166 +43,166 @@ NaviFrameView::~NaviFrameView() void NaviFrameView::create(Evas_Object *parent) { - setEo(elm_naviframe_add(parent)); - addSmartCb("transition,finished", SMART_CALLBACK(NaviFrameView, onTransitionFinished), this); - show(); + setEo(elm_naviframe_add(parent)); + addSmartCb("transition,finished", SMART_CALLBACK(NaviFrameView, onTransitionFinished), this); + show(); } void NaviFrameView::pause() { - NaviFrameItem *top = getTopFrame(); - if (top) - onPause(*top); + NaviFrameItem *top = getTopFrame(); + if (top) + onPause(*top); } void NaviFrameView::resume() { - NaviFrameItem *top = getTopFrame(); - if (top) - onResume(*top); + NaviFrameItem *top = getTopFrame(); + if (top) + onResume(*top); } bool NaviFrameView::isLastFrame() const { - return elm_naviframe_bottom_item_get(getEo()) == elm_naviframe_top_item_get(getEo()); + return elm_naviframe_bottom_item_get(getEo()) == elm_naviframe_top_item_get(getEo()); } NaviFrameItem *NaviFrameView::getTopFrame() const { - return ViewItem::staticCast(elm_naviframe_top_item_get(getEo())); + return ViewItem::staticCast(elm_naviframe_top_item_get(getEo())); } int NaviFrameView::getItemsCount() const { - int res = 0; - Eina_List *list = elm_naviframe_items_get(getEo()); - if (list) { - res = eina_list_count(list); - eina_list_free(list); - } - return res; + int res = 0; + Eina_List *list = elm_naviframe_items_get(getEo()); + if (list) { + res = eina_list_count(list); + eina_list_free(list); + } + return res; } NaviFrameItemList NaviFrameView::getItems() const { - NaviFrameItemList result; - Eina_List *list = elm_naviframe_items_get(getEo()); + NaviFrameItemList result; + Eina_List *list = elm_naviframe_items_get(getEo()); - if (list) { - Eina_List *l = nullptr; - void *obj = nullptr; + if (list) { + Eina_List *l = nullptr; + void *obj = nullptr; - EINA_LIST_FOREACH(list, l, obj) { - NaviFrameItem *item = static_cast(elm_object_item_data_get((Elm_Object_Item*)obj)); - result.push_back(item); - } + EINA_LIST_FOREACH(list, l, obj) { + NaviFrameItem *item = static_cast(elm_object_item_data_get((Elm_Object_Item*)obj)); + result.push_back(item); + } - eina_list_free(list); - } - return result; + eina_list_free(list); + } + return result; } bool NaviFrameView::isEmpty() const { - return getItemsCount() <= 0; + return getItemsCount() <= 0; } void NaviFrameView::push(NaviFrameItem &item, Evas_Object *content) { - m_TransitionStatus = !isEmpty(); - pause(); - Elm_Object_Item *it = elm_naviframe_item_push(getEo(), nullptr, nullptr, nullptr, content, naviTitleStyleEmpty); - item.setElmObjItem(it); - processSignal(); - resume(); + m_TransitionStatus = !isEmpty(); + pause(); + Elm_Object_Item *it = elm_naviframe_item_push(getEo(), nullptr, nullptr, nullptr, content, naviTitleStyleEmpty); + item.setElmObjItem(it); + processSignal(); + resume(); } void NaviFrameView::push(NaviFrameItem &item, View &content) { - m_TransitionStatus = !isEmpty(); - push(item, content.getEo()); + m_TransitionStatus = !isEmpty(); + push(item, content.getEo()); } void NaviFrameView::pop() { - auto *topFrame = getTopFrame(); - if (topFrame) - pop(*topFrame); + auto *topFrame = getTopFrame(); + if (topFrame) + pop(*topFrame); } void NaviFrameView::pop(NaviFrameItem &item) { - // Workaround solution to avoid rejected JIRA issue: http://suprem.sec.samsung.net/jira/browse/TSAM-6776 - item.m_IsPopping = true; - if (getTransitionStatus()) { - m_ItemsToDelete.push_back(&item); - } else { - if (getTopFrame() == &item) { - m_TransitionStatus = getItemsCount() > 1; - pause(); - elm_naviframe_item_pop(getEo()); - resume(); - } else { - pause(); - item.destroy(); - resume(); - } - } + // Workaround solution to avoid rejected JIRA issue: http://suprem.sec.samsung.net/jira/browse/TSAM-6776 + item.m_IsPopping = true; + if (getTransitionStatus()) { + m_ItemsToDelete.push_back(&item); + } else { + if (getTopFrame() == &item) { + m_TransitionStatus = getItemsCount() > 1; + pause(); + elm_naviframe_item_pop(getEo()); + resume(); + } else { + pause(); + item.destroy(); + resume(); + } + } } void NaviFrameView::insertToBottom(NaviFrameItem &item) { - Elm_Object_Item *before = elm_naviframe_bottom_item_get(getEo()); - Elm_Object_Item *insert = nullptr; + Elm_Object_Item *before = elm_naviframe_bottom_item_get(getEo()); + Elm_Object_Item *insert = nullptr; - if (before) { - insert = elm_naviframe_item_insert_before(getEo(), before, nullptr, nullptr, nullptr, nullptr, naviTitleStyleEmpty); - item.setElmObjItem(insert); - } else { - m_TransitionStatus = !isEmpty(); - pause(); - insert = elm_naviframe_item_push(getEo(), nullptr, nullptr, nullptr, nullptr, naviTitleStyleEmpty); - item.setElmObjItem(insert); - resume(); - } + if (before) { + insert = elm_naviframe_item_insert_before(getEo(), before, nullptr, nullptr, nullptr, nullptr, naviTitleStyleEmpty); + item.setElmObjItem(insert); + } else { + m_TransitionStatus = !isEmpty(); + pause(); + insert = elm_naviframe_item_push(getEo(), nullptr, nullptr, nullptr, nullptr, naviTitleStyleEmpty); + item.setElmObjItem(insert); + resume(); + } } void NaviFrameView::promote(NaviFrameItem &item) { - bool isTop = &item == getTopFrame(); - if (!isTop) { - m_TransitionStatus = true; - pause(); - elm_naviframe_item_promote(item); - resume(); - } + bool isTop = &item == getTopFrame(); + if (!isTop) { + m_TransitionStatus = true; + pause(); + elm_naviframe_item_promote(item); + resume(); + } } void NaviFrameView::onTransitionFinished(Evas_Object *obj, void *eventInfo) { - MSG_LOG(""); - m_TransitionStatus = false; + MSG_LOG(""); + m_TransitionStatus = false; - auto *transFinishedItem = ViewItem::staticCast(eventInfo); + auto *transFinishedItem = ViewItem::staticCast(eventInfo); - for (NaviFrameItem *item: m_ItemsToDelete) { - if (item == transFinishedItem) - transFinishedItem = nullptr; - item->destroy(); - } - m_ItemsToDelete.clear(); + for (NaviFrameItem *item: m_ItemsToDelete) { + if (item == transFinishedItem) + transFinishedItem = nullptr; + item->destroy(); + } + m_ItemsToDelete.clear(); - if (transFinishedItem) - transFinishedItem->onTransitionFinished(*transFinishedItem); + if (transFinishedItem) + transFinishedItem->onTransitionFinished(*transFinishedItem); } void NaviFrameView::onBeforeDelete(View &view) { - pause(); + pause(); } bool NaviFrameView::getTransitionStatus() const { - // TODO: Move functionality for gets TransitionStatus to EFL (elm_naviframe) side. - return m_TransitionStatus; + // TODO: Move functionality for gets TransitionStatus to EFL (elm_naviframe) side. + return m_TransitionStatus; } diff --git a/src/Common/View/src/NoContentLayout.cpp b/src/Common/View/src/NoContentLayout.cpp index e7fa83ef..5b2d569d 100644 --- a/src/Common/View/src/NoContentLayout.cpp +++ b/src/Common/View/src/NoContentLayout.cpp @@ -20,8 +20,8 @@ using namespace Msg; NoContentLayout::NoContentLayout(Evas_Object *parent) { - setEo(elm_layout_add(parent)); - elm_layout_theme_set(getEo(), "layout", "nocontents", "text"); + setEo(elm_layout_add(parent)); + elm_layout_theme_set(getEo(), "layout", "nocontents", "text"); } NoContentLayout::~NoContentLayout() @@ -30,17 +30,17 @@ NoContentLayout::~NoContentLayout() void NoContentLayout::setText(const TText &text) { - View::setText(text, "elm.text"); - elm_layout_signal_emit(getEo(), "text,disabled", ""); - elm_layout_signal_emit(getEo(), "align.center", "elm"); + View::setText(text, "elm.text"); + elm_layout_signal_emit(getEo(), "text,disabled", ""); + elm_layout_signal_emit(getEo(), "align.center", "elm"); } void NoContentLayout::setHelpText(const TText &text) { - View::setText(text, "elm.help.text"); + View::setText(text, "elm.help.text"); } void NoContentLayout::setHelpText(const std::string &text) { - View::setText(text, "elm.help.text"); + View::setText(text, "elm.help.text"); } diff --git a/src/Common/View/src/Popup.cpp b/src/Common/View/src/Popup.cpp index 557bf919..7cd1f7bf 100644 --- a/src/Common/View/src/Popup.cpp +++ b/src/Common/View/src/Popup.cpp @@ -25,206 +25,206 @@ using namespace Msg; namespace { - const char *buttonIdKey = "id"; - const char *buttonCbKey = "cb"; - const char *buttonCbDataKey = "cb-data"; - const char *titlePart = "title,text"; - const char *buttonStyle = "bottom"; + const char *buttonIdKey = "id"; + const char *buttonCbKey = "cb"; + const char *buttonCbDataKey = "cb-data"; + const char *titlePart = "title,text"; + const char *buttonStyle = "bottom"; } Popup::Popup(Evas_Object *parent) - : m_pBox(nullptr) - , m_pContent(nullptr) - , m_CurrentButtonIndex(1) - , m_OutsideTapDismiss(false) - , m_MoreKeyDismiss(false) - , m_PauseAppDismiss(false) - , m_pManager(nullptr) - , m_pShowIdler(nullptr) + : m_pBox(nullptr) + , m_pContent(nullptr) + , m_CurrentButtonIndex(1) + , m_OutsideTapDismiss(false) + , m_MoreKeyDismiss(false) + , m_PauseAppDismiss(false) + , m_pManager(nullptr) + , m_pShowIdler(nullptr) { - create(parent); + create(parent); } Popup::Popup(PopupManager &parent) - : Popup(parent.getWindow()) + : Popup(parent.getWindow()) { - m_pManager = &parent; + m_pManager = &parent; } Popup::~Popup() { - MSG_LOG("Destructor"); - if (m_pShowIdler) { - ecore_idler_del(m_pShowIdler); - m_pShowIdler = nullptr; - } + MSG_LOG("Destructor"); + if (m_pShowIdler) { + ecore_idler_del(m_pShowIdler); + m_pShowIdler = nullptr; + } } void Popup::create(Evas_Object *parent) { - setEo(elm_popup_add(parent)); - evas_object_smart_callback_add(getEo(), "block,clicked", on_popup_block_clicked_cb, this); - elm_popup_orient_set(getEo(), ELM_POPUP_ORIENT_BOTTOM); - elm_popup_align_set(getEo(), ELM_NOTIFY_ALIGN_FILL, 1.0); - expand(); + setEo(elm_popup_add(parent)); + evas_object_smart_callback_add(getEo(), "block,clicked", on_popup_block_clicked_cb, this); + elm_popup_orient_set(getEo(), ELM_POPUP_ORIENT_BOTTOM); + elm_popup_align_set(getEo(), ELM_NOTIFY_ALIGN_FILL, 1.0); + expand(); - m_pBox = elm_box_add(getEo()); - elm_box_homogeneous_set(m_pBox, EINA_FALSE); - expand(m_pBox); - evas_object_show(m_pBox); + m_pBox = elm_box_add(getEo()); + elm_box_homogeneous_set(m_pBox, EINA_FALSE); + expand(m_pBox); + evas_object_show(m_pBox); - elm_object_content_set(getEo(), m_pBox); + elm_object_content_set(getEo(), m_pBox); } void Popup::destroy() { - if (m_pManager) - m_pManager->reset(); - else - View::destroy(); + if (m_pManager) + m_pManager->reset(); + else + View::destroy(); } void Popup::setTimeOut(double timeout) { - elm_popup_timeout_set(getEo(), timeout); + elm_popup_timeout_set(getEo(), timeout); } Evas_Object *Popup::setContent(Evas_Object *content) { - expand(content); - Evas_Object *oldContent = m_pContent; - elm_box_unpack_all(m_pBox); - elm_box_pack_start(m_pBox, content); - m_pContent = content; - evas_object_show(m_pContent); - return oldContent; + expand(content); + Evas_Object *oldContent = m_pContent; + elm_box_unpack_all(m_pBox); + elm_box_pack_start(m_pBox, content); + m_pContent = content; + evas_object_show(m_pContent); + return oldContent; } void Popup::setContent(const std::string &text) { - setText(text); + setText(text); } void Popup::setContent(const TText &text) { - setText(text); + setText(text); } void Popup::setHeight(int height) { - evas_object_size_hint_min_set(m_pBox, 0, height); + evas_object_size_hint_min_set(m_pBox, 0, height); } void Popup::setDismissByOutsideTapFlag(bool value) { - m_OutsideTapDismiss = value; + m_OutsideTapDismiss = value; } void Popup::setDismissByMoreMenuKeyFlag(bool value) { - m_MoreKeyDismiss = value; + m_MoreKeyDismiss = value; } bool Popup::getDismissByMoreMenuKeyFlag() const { - return m_MoreKeyDismiss; + return m_MoreKeyDismiss; } void Popup::setDismissByPauseAppFlag(bool value) { - m_PauseAppDismiss = value; + m_PauseAppDismiss = value; } bool Popup::getDismissByPauseAppFlag() const { - return m_PauseAppDismiss; + return m_PauseAppDismiss; } Evas_Object *Popup::addButton(const TText &text, int buttonId, PopupButtonCb buttonCb, void *userData) { - std::stringstream ss; - ss << "button" << m_CurrentButtonIndex; + std::stringstream ss; + ss << "button" << m_CurrentButtonIndex; - Evas_Object *btn = elm_button_add(getEo()); - elm_object_style_set(btn, buttonStyle); - View::setContent(btn, ss.str().c_str()); + Evas_Object *btn = elm_button_add(getEo()); + elm_object_style_set(btn, buttonStyle); + View::setContent(btn, ss.str().c_str()); - if (elm_object_part_content_get(getEo(), ss.str().c_str())) { - ++m_CurrentButtonIndex; - evas_object_show(btn); - evas_object_data_set(btn, buttonIdKey, (void*)(intptr_t)buttonId); - evas_object_data_set(btn, buttonCbKey, (void*)buttonCb); - evas_object_data_set(btn, buttonCbDataKey, userData); - evas_object_smart_callback_add(btn, "clicked", on_button_clicked, this); - setText(btn, text); - } else { - MSG_LOG_ERROR("Can't set content to part: ", ss.str()); - evas_object_del(btn); - btn = nullptr; - } + if (elm_object_part_content_get(getEo(), ss.str().c_str())) { + ++m_CurrentButtonIndex; + evas_object_show(btn); + evas_object_data_set(btn, buttonIdKey, (void*)(intptr_t)buttonId); + evas_object_data_set(btn, buttonCbKey, (void*)buttonCb); + evas_object_data_set(btn, buttonCbDataKey, userData); + evas_object_smart_callback_add(btn, "clicked", on_button_clicked, this); + setText(btn, text); + } else { + MSG_LOG_ERROR("Can't set content to part: ", ss.str()); + evas_object_del(btn); + btn = nullptr; + } - return btn; + return btn; } Evas_Object *Popup::getHostEvasObject() const { - return m_pBox; + return m_pBox; } Evas_Object *Popup::getContent() const { - return m_pContent; + return m_pContent; } void Popup::setTitle(const std::string &title) { - setText(title, titlePart); + setText(title, titlePart); } void Popup::setTitle(const TText &title) { - setText(title, titlePart); + setText(title, titlePart); } void Popup::show(bool deferred) { - if (!deferred) { - View::show(); - } else { - if (!m_pShowIdler) { - m_pShowIdler = ecore_idler_add - ( - [](void *data)->Eina_Bool - { - auto *self =(Popup*)data; - self->m_pShowIdler = nullptr; - self->View::show(); - return false; // Delete idler - }, - this); - } - } + if (!deferred) { + View::show(); + } else { + if (!m_pShowIdler) { + m_pShowIdler = ecore_idler_add + ( + [](void *data)->Eina_Bool + { + auto *self =(Popup*)data; + self->m_pShowIdler = nullptr; + self->View::show(); + return false; // Delete idler + }, + this); + } + } } void Popup::on_button_clicked(void *data, Evas_Object *obj, void *event_info) { - PopupButtonCb cb = (PopupButtonCb)evas_object_data_get(obj, buttonCbKey); - if (cb) { - void *userData = evas_object_data_get(obj, buttonCbDataKey); - auto *popup = static_cast(data); - int buttonId = (int)(intptr_t)evas_object_data_get(obj, buttonIdKey); - cb(*popup, buttonId, userData); - } + PopupButtonCb cb = (PopupButtonCb)evas_object_data_get(obj, buttonCbKey); + if (cb) { + void *userData = evas_object_data_get(obj, buttonCbDataKey); + auto *popup = static_cast(data); + int buttonId = (int)(intptr_t)evas_object_data_get(obj, buttonIdKey); + cb(*popup, buttonId, userData); + } } void Popup::on_popup_block_clicked_cb(void *data, Evas_Object *obj, void *event_info) { - auto *popup = static_cast(data); - if (popup->m_OutsideTapDismiss) - popup->destroy(); + auto *popup = static_cast(data); + if (popup->m_OutsideTapDismiss) + popup->destroy(); } void Popup::defaultButtonCb(Popup &popup, int buttonId, void *userData) { - popup.destroy(); + popup.destroy(); } diff --git a/src/Common/View/src/PopupAttachmentListItem.cpp b/src/Common/View/src/PopupAttachmentListItem.cpp index ceeffb71..45833c64 100644 --- a/src/Common/View/src/PopupAttachmentListItem.cpp +++ b/src/Common/View/src/PopupAttachmentListItem.cpp @@ -19,9 +19,9 @@ using namespace Msg; PopupAttachmentListItem::PopupAttachmentListItem(PopupList &parent, const std::string &text, const std::string &path, - PopupListItemPressedCb cb, void *userData) - : PopupCheckListItem(parent, text, cb, userData) - , m_FilePath(path) + PopupListItemPressedCb cb, void *userData) + : PopupCheckListItem(parent, text, cb, userData) + , m_FilePath(path) { } @@ -31,5 +31,5 @@ PopupAttachmentListItem::~PopupAttachmentListItem() const std::string &PopupAttachmentListItem::getFilePath() const { - return m_FilePath; + return m_FilePath; } diff --git a/src/Common/View/src/PopupList.cpp b/src/Common/View/src/PopupList.cpp index a6b3fbc5..d66cbe53 100644 --- a/src/Common/View/src/PopupList.cpp +++ b/src/Common/View/src/PopupList.cpp @@ -21,17 +21,17 @@ using namespace Msg; PopupList::PopupList(Evas_Object *parent, PopupListType type) - : Popup(parent) - , m_pList(nullptr) + : Popup(parent) + , m_pList(nullptr) { - create(type); + create(type); } PopupList::PopupList(PopupManager &parent, PopupListType type) - : Popup(parent) - , m_pList(nullptr) + : Popup(parent) + , m_pList(nullptr) { - create(type); + create(type); } PopupList::~PopupList() @@ -40,55 +40,55 @@ PopupList::~PopupList() void PopupList::appendItem(PopupListItem &item) { - m_pList->appendItem(item); + m_pList->appendItem(item); } void PopupList::appendItem(const std::string &text, PopupListItemPressedCb cb, void *userData) { - m_pList->appendItem(*new PopupTextListItem(*this, text, cb, userData)); + m_pList->appendItem(*new PopupTextListItem(*this, text, cb, userData)); } void PopupList::appendItem(const std::string &text, const std::string &path, PopupListItemPressedCb cb, void *userData) { - m_pList->appendItem(*new PopupAttachmentListItem(*this, text, path, cb, userData)); + m_pList->appendItem(*new PopupAttachmentListItem(*this, text, path, cb, userData)); } void PopupList::create(PopupListType type) { - elm_object_style_set(getEo(), "theme_bg"); - Evas_Object *list = createList(getHostEvasObject()); - Popup::setContent(list); + elm_object_style_set(getEo(), "theme_bg"); + Evas_Object *list = createList(getHostEvasObject()); + Popup::setContent(list); - //set popup's behavior - setDismissByOutsideTapFlag(true); - if (type == MoreMenuPopup) { - setDismissByMoreMenuKeyFlag(true); - setDismissByPauseAppFlag(true); - } + //set popup's behavior + setDismissByOutsideTapFlag(true); + if (type == MoreMenuPopup) { + setDismissByMoreMenuKeyFlag(true); + setDismissByPauseAppFlag(true); + } } Evas_Object *PopupList::createList(Evas_Object *parent) { - m_pList = new ListView(parent); - m_pList->setListener(this); - m_pList->show(); - m_pList->setMultiSelection(false); - m_pList->setMode(ELM_LIST_EXPAND); - return *m_pList; + m_pList = new ListView(parent); + m_pList->setListener(this); + m_pList->show(); + m_pList->setMultiSelection(false); + m_pList->setMode(ELM_LIST_EXPAND); + return *m_pList; } ListView &PopupList::getListView() { - return *m_pList; + return *m_pList; } const ListView &PopupList::getListView() const { - return *m_pList; + return *m_pList; } void PopupList::onListItemSelected(ListItem &listItem) { - PopupListItem &it = static_cast(listItem); - it.fireCallback(); + PopupListItem &it = static_cast(listItem); + it.fireCallback(); } diff --git a/src/Common/View/src/PopupListItem.cpp b/src/Common/View/src/PopupListItem.cpp index 9e9d0b5c..b715f908 100644 --- a/src/Common/View/src/PopupListItem.cpp +++ b/src/Common/View/src/PopupListItem.cpp @@ -21,27 +21,27 @@ using namespace Msg; const ListItemStyleRef listItemStyle = ListItemStyle::create("type1"); PopupListItem::PopupListItem(PopupList &parent, PopupListItemPressedCb cb, void *userData) - : ListItem(listItemStyle) - , m_Parent(parent) - , m_Cb(cb) - , m_pUserData(userData) + : ListItem(listItemStyle) + , m_Parent(parent) + , m_Cb(cb) + , m_pUserData(userData) { } void PopupListItem::fireCallback() { - if (m_Cb) - m_Cb(*this, m_pUserData); + if (m_Cb) + m_Cb(*this, m_pUserData); } PopupList &PopupListItem::getParent() { - return m_Parent; + return m_Parent; } PopupTextListItem::PopupTextListItem(PopupList &parent, const std::string &text, PopupListItemPressedCb cb, void *userData) - : PopupListItem(parent, cb, userData) - , m_Text(text) + : PopupListItem(parent, cb, userData) + , m_Text(text) { } @@ -51,14 +51,14 @@ PopupTextListItem::~PopupTextListItem() std::string PopupTextListItem::getText(ListItem &item, const char *part) { - if (strcmp(part, "elm.text") == 0) - return m_Text; - return std::string(); + if (strcmp(part, "elm.text") == 0) + return m_Text; + return std::string(); } PopupCheckListItem::PopupCheckListItem(PopupList &parent, const std::string &text, PopupListItemPressedCb cb, void *userData) - : PopupListItem(parent, cb, userData) - , m_Text(text) + : PopupListItem(parent, cb, userData) + , m_Text(text) { } @@ -68,12 +68,12 @@ PopupCheckListItem::~PopupCheckListItem() const char *PopupCheckListItem::getCheckPart(ListItem &item) { - return "elm.swallow.end"; + return "elm.swallow.end"; } std::string PopupCheckListItem::getText(ListItem &item, const char *part) { - if (strcmp(part, "elm.text") == 0) - return m_Text; - return std::string(); + if (strcmp(part, "elm.text") == 0) + return m_Text; + return std::string(); } diff --git a/src/Common/View/src/PopupManager.cpp b/src/Common/View/src/PopupManager.cpp index ee8bdf5d..df654305 100644 --- a/src/Common/View/src/PopupManager.cpp +++ b/src/Common/View/src/PopupManager.cpp @@ -23,15 +23,15 @@ using namespace Msg; PopupManager::PopupManager(Window &window) - : m_pPopup(nullptr) - , m_Window(window) - , m_pPopupOwner(nullptr) + : m_pPopup(nullptr) + , m_Window(window) + , m_pPopupOwner(nullptr) { } Window &PopupManager::getWindow() const { - return m_Window; + return m_Window; } PopupManager::~PopupManager() @@ -40,64 +40,64 @@ PopupManager::~PopupManager() void PopupManager::reset(void *popupOwner) { - if (!popupOwner || (popupOwner == m_pPopupOwner)) { - if (m_pPopup) { - m_pPopup->View::destroy(); - m_pPopup = nullptr; - } - m_pPopupOwner = nullptr; - } + if (!popupOwner || (popupOwner == m_pPopupOwner)) { + if (m_pPopup) { + m_pPopup->View::destroy(); + m_pPopup = nullptr; + } + m_pPopupOwner = nullptr; + } } void PopupManager::reset(Popup &popup, void *newOwner) { - m_pPopupOwner = newOwner; - if (&popup != m_pPopup) { - reset(); - eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, SMART_CALLBACK(PopupManager, onHwBackButtonPopupClicked), this); - m_pPopup = &popup; - } + m_pPopupOwner = newOwner; + if (&popup != m_pPopup) { + reset(); + eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, SMART_CALLBACK(PopupManager, onHwBackButtonPopupClicked), this); + m_pPopup = &popup; + } } Popup &PopupManager::getPopup(void *newOwner) { - auto &popup = getPopup(newOwner); - return popup; + auto &popup = getPopup(newOwner); + return popup; } PopupList &PopupManager::getPopupList(void *newOwner) { - PopupList &popup = getPopup(PopupList::ListPopup, newOwner); - eext_object_event_callback_add(popup, EEXT_CALLBACK_MORE, SMART_CALLBACK(PopupManager, onHwMoreButtonPopupListClicked), this); - return popup; + PopupList &popup = getPopup(PopupList::ListPopup, newOwner); + eext_object_event_callback_add(popup, EEXT_CALLBACK_MORE, SMART_CALLBACK(PopupManager, onHwMoreButtonPopupListClicked), this); + return popup; } PopupList &PopupManager::getMorePopup(void *newOwner) { - PopupList &popup = getPopup(PopupList::MoreMenuPopup, newOwner); - eext_object_event_callback_add(popup, EEXT_CALLBACK_MORE, SMART_CALLBACK(PopupManager, onHwMoreButtonPopupListClicked), this); - return popup; + PopupList &popup = getPopup(PopupList::MoreMenuPopup, newOwner); + eext_object_event_callback_add(popup, EEXT_CALLBACK_MORE, SMART_CALLBACK(PopupManager, onHwMoreButtonPopupListClicked), this); + return popup; } bool PopupManager::isPopupVisible() const { - return m_pPopup ? m_pPopup->isVisible() : false; + return m_pPopup ? m_pPopup->isVisible() : false; } void PopupManager::onHwBackButtonPopupClicked(Evas_Object *obj, void *eventInfo) { - reset(); + reset(); } void PopupManager::onHwMoreButtonPopupListClicked(Evas_Object *obj, void *eventInfo) { - if (m_pPopup->getDismissByMoreMenuKeyFlag()) - reset(); + if (m_pPopup->getDismissByMoreMenuKeyFlag()) + reset(); } void PopupManager::onPause() { - if (m_pPopup && m_pPopup->getDismissByPauseAppFlag()) - reset(); + if (m_pPopup && m_pPopup->getDismissByPauseAppFlag()) + reset(); } diff --git a/src/Common/View/src/Scroller.cpp b/src/Common/View/src/Scroller.cpp index f210afce..db004e09 100644 --- a/src/Common/View/src/Scroller.cpp +++ b/src/Common/View/src/Scroller.cpp @@ -19,10 +19,10 @@ using namespace Msg; Scroller::Scroller(Evas_Object *parent) - : View() + : View() { - setEo(elm_scroller_add(parent)); - show(); + setEo(elm_scroller_add(parent)); + show(); } Scroller::~Scroller() @@ -31,7 +31,7 @@ Scroller::~Scroller() void Scroller::navigateToBottom() { - int h = 0; - elm_scroller_child_size_get(getEo(), nullptr, &h); - elm_scroller_region_show(getEo(), 0, h, 0, 0); + int h = 0; + elm_scroller_child_size_get(getEo(), nullptr, &h); + elm_scroller_region_show(getEo(), 0, h, 0, 0); } diff --git a/src/Common/View/src/SelectAllListItem.cpp b/src/Common/View/src/SelectAllListItem.cpp index 33f617ed..10479a5c 100644 --- a/src/Common/View/src/SelectAllListItem.cpp +++ b/src/Common/View/src/SelectAllListItem.cpp @@ -22,13 +22,13 @@ using namespace Msg; namespace { - ListItemStyleRef style = ListItemStyle::create("type1"); - const char *textPart = "elm.text"; - const char *checkPart = "elm.swallow.end"; + ListItemStyleRef style = ListItemStyle::create("type1"); + const char *textPart = "elm.text"; + const char *checkPart = "elm.swallow.end"; } SelectAllListItem::SelectAllListItem() - : ListItem(style, ELM_GENLIST_ITEM_NONE) + : ListItem(style, ELM_GENLIST_ITEM_NONE) { } @@ -38,15 +38,15 @@ SelectAllListItem::~SelectAllListItem() const char *SelectAllListItem::getCheckPart(ListItem &item) { - return checkPart; + return checkPart; } std::string SelectAllListItem::getText(ListItem &item, const char *part) { - if (strcmp(part, textPart) == 0) - return msg("IDS_MSG_MBODY_SELECT_ALL"); + if (strcmp(part, textPart) == 0) + return msg("IDS_MSG_MBODY_SELECT_ALL"); - return ""; + return ""; } diff --git a/src/Common/View/src/StandardWindow.cpp b/src/Common/View/src/StandardWindow.cpp index 79497f9d..e0edb9fd 100644 --- a/src/Common/View/src/StandardWindow.cpp +++ b/src/Common/View/src/StandardWindow.cpp @@ -22,73 +22,73 @@ using namespace Msg; StandardWindow::StandardWindow() - : Window() - , m_pConform(nullptr) - , m_pBg(nullptr) + : Window() + , m_pConform(nullptr) + , m_pBg(nullptr) { - // Window: - setEo(elm_win_add(nullptr, PACKAGE_NAME, ELM_WIN_BASIC)); - elm_win_conformant_set(getEo(), EINA_TRUE); - elm_win_autodel_set(getEo(), EINA_TRUE); - - // Conform: - m_pConform = elm_conformant_add(getEo()); - elm_win_indicator_mode_set(getEo(), ELM_WIN_INDICATOR_SHOW); - elm_win_indicator_opacity_set(getEo(), ELM_WIN_INDICATOR_OPAQUE); - evas_object_size_hint_weight_set(m_pConform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_win_resize_object_add(getEo(), m_pConform); - evas_object_show(m_pConform); - - // Bg: - m_pBg = elm_bg_add(m_pConform); - evas_object_size_hint_weight_set(m_pBg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_show(m_pBg); - - elm_object_part_content_set(m_pConform, "elm.swallow.bg", m_pBg); + // Window: + setEo(elm_win_add(nullptr, PACKAGE_NAME, ELM_WIN_BASIC)); + elm_win_conformant_set(getEo(), EINA_TRUE); + elm_win_autodel_set(getEo(), EINA_TRUE); + + // Conform: + m_pConform = elm_conformant_add(getEo()); + elm_win_indicator_mode_set(getEo(), ELM_WIN_INDICATOR_SHOW); + elm_win_indicator_opacity_set(getEo(), ELM_WIN_INDICATOR_OPAQUE); + evas_object_size_hint_weight_set(m_pConform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(getEo(), m_pConform); + evas_object_show(m_pConform); + + // Bg: + m_pBg = elm_bg_add(m_pConform); + evas_object_size_hint_weight_set(m_pBg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_show(m_pBg); + + elm_object_part_content_set(m_pConform, "elm.swallow.bg", m_pBg); } StandardWindow::~StandardWindow() { - evas_object_del(getEo()); + evas_object_del(getEo()); } void StandardWindow::lower() { - elm_win_lower(getEo()); + elm_win_lower(getEo()); } void StandardWindow::raise() { - elm_win_raise(getEo()); + elm_win_raise(getEo()); } Evas_Object *StandardWindow::getWinEvasObject() const { - return getEo(); + return getEo(); } Evas_Object *StandardWindow::getConformEvasObject() const { - return m_pConform; + return m_pConform; } Evas_Object *StandardWindow::getHostEvasObject() const { - return m_pConform; + return m_pConform; } void StandardWindow::setContent(Evas_Object *content) { - elm_object_content_set(m_pConform, content); + elm_object_content_set(m_pConform, content); } void StandardWindow::getScreenSize(int *x, int *y, int *w, int *h) const { - elm_win_screen_size_get(getEo(), x, y, w, h); + elm_win_screen_size_get(getEo(), x, y, w, h); } int StandardWindow::getRotation() const { - return elm_win_rotation_get(getEo()); + return elm_win_rotation_get(getEo()); } diff --git a/src/Common/View/src/View.cpp b/src/Common/View/src/View.cpp index 31852709..c692dd32 100644 --- a/src/Common/View/src/View.cpp +++ b/src/Common/View/src/View.cpp @@ -25,11 +25,11 @@ using namespace Msg; namespace { - const char *thisKey = "this"; + const char *thisKey = "this"; } View::View() - : m_pEo(nullptr) + : m_pEo(nullptr) { } @@ -39,152 +39,152 @@ View::~View() Evas_Object_Event_Cb View::getCb(Evas_Callback_Type type) { - static std::map cbMap = - { - {EVAS_CALLBACK_FREE, on_free_cb}, - {EVAS_CALLBACK_DEL, on_del_cb} - }; + static std::map cbMap = + { + {EVAS_CALLBACK_FREE, on_free_cb}, + {EVAS_CALLBACK_DEL, on_del_cb} + }; - auto it = cbMap.find(type); - return it != cbMap.end() ? it->second : nullptr; + auto it = cbMap.find(type); + return it != cbMap.end() ? it->second : nullptr; } void View::setEventCb(Evas_Callback_Type type) { - Evas_Object_Event_Cb cb = getCb(type); - if (cb) { - evas_object_event_callback_add(m_pEo, type, cb, this); - } else { - MSG_LOG_ERROR("Not implemented"); - assert(false); - } + Evas_Object_Event_Cb cb = getCb(type); + if (cb) { + evas_object_event_callback_add(m_pEo, type, cb, this); + } else { + MSG_LOG_ERROR("Not implemented"); + assert(false); + } } void View::setEo(Evas_Object *eo) { - if (m_pEo) { - MSG_LOG_ERROR("m_pEo not null"); - assert(false); - } + if (m_pEo) { + MSG_LOG_ERROR("m_pEo not null"); + assert(false); + } - m_pEo = eo; - if (eo) { - setData(this); - setEventCb(EVAS_CALLBACK_FREE); - setEventCb(EVAS_CALLBACK_DEL); - } + m_pEo = eo; + if (eo) { + setData(this); + setEventCb(EVAS_CALLBACK_FREE); + setEventCb(EVAS_CALLBACK_DEL); + } } void View::unsetEventCb(Evas_Callback_Type type) { - Evas_Object_Event_Cb cb = getCb(type); - if (cb) { - evas_object_event_callback_del(m_pEo, type, cb); - } else { - MSG_LOG_ERROR("Not implemented"); - assert(false); - } + Evas_Object_Event_Cb cb = getCb(type); + if (cb) { + evas_object_event_callback_del(m_pEo, type, cb); + } else { + MSG_LOG_ERROR("Not implemented"); + assert(false); + } } Evas_Object *View::setContent(Evas_Object *content, const char *part, bool saveOldContent) { - Evas_Object *oldContent = saveOldContent ? elm_object_part_content_unset(m_pEo, part) : nullptr; - elm_object_part_content_set(m_pEo, part, content); - return oldContent; + Evas_Object *oldContent = saveOldContent ? elm_object_part_content_unset(m_pEo, part) : nullptr; + elm_object_part_content_set(m_pEo, part, content); + return oldContent; } void View::on_free_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) { - View *view = static_cast(data); - if (view) - view->onViewDestroyed(); + View *view = static_cast(data); + if (view) + view->onViewDestroyed(); } void View::on_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) { - View *view = static_cast(data); - if (view) - view->onBeforeDelete(*view); + View *view = static_cast(data); + if (view) + view->onBeforeDelete(*view); } void View::expand() { - expand(m_pEo); + expand(m_pEo); } void View::expand(Evas_Object *obj) { - evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(obj, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(obj, EVAS_HINT_FILL, EVAS_HINT_FILL); } void View::processSignal(Evas_Object *obj) { - Evas_Object *edj = elm_layout_edje_get(obj); - edje_object_message_signal_process(edj); + Evas_Object *edj = elm_layout_edje_get(obj); + edje_object_message_signal_process(edj); } void View::emitSignal(Evas_Object *obj, const char *emission, const char *source, bool async) { - elm_object_signal_emit(obj, emission, source); - if (!async) - processSignal(obj); + elm_object_signal_emit(obj, emission, source); + if (!async) + processSignal(obj); } Evas_Object *View::addLayout(Evas_Object *parent, const std::string &edjePath, const std::string &group) { - Evas_Object *layout = elm_layout_add(parent); - std::string edjAbsPath = PathUtils::getResourcePath(edjePath); - elm_layout_file_set(layout, edjAbsPath.c_str(), group.c_str()); - return layout; + Evas_Object *layout = elm_layout_add(parent); + std::string edjAbsPath = PathUtils::getResourcePath(edjePath); + elm_layout_file_set(layout, edjAbsPath.c_str(), group.c_str()); + return layout; } void View::setData(Evas_Object *obj, const void *data) { - evas_object_data_set(obj, thisKey, (void*)data); + evas_object_data_set(obj, thisKey, (void*)data); } void *View::getData(Evas_Object *obj) { - return evas_object_data_get(obj, thisKey); + return evas_object_data_get(obj, thisKey); } std::string Msg::markupToUtf8(const char *str) { - if (!str) - return std::string(); + if (!str) + return std::string(); - std::string res; - char *markup = elm_entry_markup_to_utf8(str); - if (markup) { - res = markup; - free(markup); - } + std::string res; + char *markup = elm_entry_markup_to_utf8(str); + if (markup) { + res = markup; + free(markup); + } - return res; + return res; } std::string Msg::utf8ToMarkup(const char *str) { - if (!str) - return std::string(); + if (!str) + return std::string(); - std::string res; - char *markup = elm_entry_utf8_to_markup(str); - if (markup) { - res = markup; - free(markup); - } + std::string res; + char *markup = elm_entry_utf8_to_markup(str); + if (markup) { + res = markup; + free(markup); + } - return res; + return res; } std::string Msg::markupToUtf8(const std::string &str) { - return markupToUtf8(str.c_str()); + return markupToUtf8(str.c_str()); } std::string Msg::utf8ToMarkup(const std::string &str) { - return utf8ToMarkup(str.c_str()); + return utf8ToMarkup(str.c_str()); } diff --git a/src/Common/View/src/ViewItem.cpp b/src/Common/View/src/ViewItem.cpp index 2d3383a1..22b28de7 100644 --- a/src/Common/View/src/ViewItem.cpp +++ b/src/Common/View/src/ViewItem.cpp @@ -19,49 +19,49 @@ using namespace Msg; ViewItem::ViewItem() - : m_pItem(nullptr) + : m_pItem(nullptr) { } ViewItem::~ViewItem() { - elm_object_item_del_cb_set(m_pItem, nullptr); + elm_object_item_del_cb_set(m_pItem, nullptr); } void ViewItem::setElmObjItem(Elm_Object_Item *item) { - m_pItem = item; - setData(this); - elm_object_item_del_cb_set(m_pItem, on_delete_cb); - onAttached(*this); + m_pItem = item; + setData(this); + elm_object_item_del_cb_set(m_pItem, on_delete_cb); + onAttached(*this); } void ViewItem::destroy() { - elm_object_item_del(m_pItem); + elm_object_item_del(m_pItem); } void ViewItem::on_delete_cb(void *data, Evas_Object *obj, void *event_info) { - Elm_Object_Item *it = static_cast(event_info); - ViewItem *self = static_cast(elm_object_item_data_get(it)); - self->onViewDestroyed(); + Elm_Object_Item *it = static_cast(event_info); + ViewItem *self = static_cast(elm_object_item_data_get(it)); + self->onViewDestroyed(); } Evas_Object *ViewItem::setContent(Evas_Object *content, const char *part, bool saveOldContent) { - Evas_Object *oldContent = saveOldContent ? elm_object_item_part_content_unset(m_pItem, part) : nullptr; - elm_object_item_part_content_set(m_pItem, part, content); - return oldContent; + Evas_Object *oldContent = saveOldContent ? elm_object_item_part_content_unset(m_pItem, part) : nullptr; + elm_object_item_part_content_set(m_pItem, part, content); + return oldContent; } Evas_Object *ViewItem::getContent(const char *part) const { - return m_pItem ? elm_object_item_part_content_get(m_pItem, part) : nullptr; + return m_pItem ? elm_object_item_part_content_get(m_pItem, part) : nullptr; } void ViewItem::emitSignal(const char *signal, const char *source) { - elm_object_item_signal_emit(m_pItem, signal, source); + elm_object_item_signal_emit(m_pItem, signal, source); } diff --git a/src/Conversation/AppControl/inc/AttachPanel.h b/src/Conversation/AppControl/inc/AttachPanel.h index 843a2599..8833096f 100644 --- a/src/Conversation/AppControl/inc/AttachPanel.h +++ b/src/Conversation/AppControl/inc/AttachPanel.h @@ -24,41 +24,41 @@ #include namespace Msg { - class IAttachPanelListener; + class IAttachPanelListener; - class AttachPanel { - public: - typedef std::list FileList; + class AttachPanel { + public: + typedef std::list FileList; - public: - AttachPanel(App &app); - ~AttachPanel(); + public: + AttachPanel(App &app); + ~AttachPanel(); - void setListener(IAttachPanelListener *l); - void show(bool value); - void reset(); - bool isVisible() const; - bool isFullExpanded() const; + void setListener(IAttachPanelListener *l); + void show(bool value); + void reset(); + bool isVisible() const; + bool isFullExpanded() const; - private: - AttachPanel(const AttachPanel&) = delete; - AttachPanel& operator=(AttachPanel&) = delete; + private: + AttachPanel(const AttachPanel&) = delete; + AttachPanel& operator=(AttachPanel&) = delete; - attach_panel_h getAttachPanel(); + attach_panel_h getAttachPanel(); - static void result_cb(attach_panel_h attachPanel, attach_panel_content_category_e contentCategory, - app_control_h result, app_control_result_e resultCode, void *userData); - private: - App &m_App; - attach_panel_h m_Handle; - IAttachPanelListener *m_pListener; - }; + static void result_cb(attach_panel_h attachPanel, attach_panel_content_category_e contentCategory, + app_control_h result, app_control_result_e resultCode, void *userData); + private: + App &m_App; + attach_panel_h m_Handle; + IAttachPanelListener *m_pListener; + }; - class IAttachPanelListener { - public: - virtual ~IAttachPanelListener() {} - virtual void onFileSelected(AttachPanel &panel, const AttachPanel::FileList &files) {}; - }; + class IAttachPanelListener { + public: + virtual ~IAttachPanelListener() {} + virtual void onFileSelected(AttachPanel &panel, const AttachPanel::FileList &files) {}; + }; } #endif /* AttachPanel_h_ */ diff --git a/src/Conversation/AppControl/inc/ContactPicker.h b/src/Conversation/AppControl/inc/ContactPicker.h index 033dd405..1d4f80ad 100644 --- a/src/Conversation/AppControl/inc/ContactPicker.h +++ b/src/Conversation/AppControl/inc/ContactPicker.h @@ -21,50 +21,50 @@ #include "AppControlLauncher.h" namespace Msg { - class IContactPickerListener; + class IContactPickerListener; - /** - * @brief An utility-class aimed to launch contacts-application with pick-operation passed via app-control. - */ - class ContactPicker - : public AppControlHandle { - public: - ContactPicker(); + /** + * @brief An utility-class aimed to launch contacts-application with pick-operation passed via app-control. + */ + class ContactPicker + : public AppControlHandle { + public: + ContactPicker(); - /** - * @brief Sets a listener-object to be notified when pick-operation succeeds. - */ - void setListener(IContactPickerListener *pListener); + /** + * @brief Sets a listener-object to be notified when pick-operation succeeds. + */ + void setListener(IContactPickerListener *pListener); - /** - * @brief Launches pick-operation. - * @param howManyToPick defines a maximum count of contacts allowed to be picked. - * @return true in case of success, otherwise returns false. - */ - bool launch(size_t howManyToPick); + /** + * @brief Launches pick-operation. + * @param howManyToPick defines a maximum count of contacts allowed to be picked. + * @return true in case of success, otherwise returns false. + */ + bool launch(size_t howManyToPick); - private: - virtual void onReply(app_control_h request, app_control_h reply, app_control_result_e result); + private: + virtual void onReply(app_control_h request, app_control_h reply, app_control_result_e result); - private: - IContactPickerListener *m_pListener; - }; + private: + IContactPickerListener *m_pListener; + }; - class IContactPickerListener { - public: - enum AddressType { - PhoneType, - EmailType - }; - struct ResultData { - AddressType type; - int id; - }; + class IContactPickerListener { + public: + enum AddressType { + PhoneType, + EmailType + }; + struct ResultData { + AddressType type; + int id; + }; - public: - virtual ~IContactPickerListener() {} - virtual void onContactsPicked(const std::list &numberIdList) {}; - }; + public: + virtual ~IContactPickerListener() {} + virtual void onContactsPicked(const std::list &numberIdList) {}; + }; } #endif /* ContactPicker_h_ */ diff --git a/src/Conversation/AppControl/inc/SettingsNetwork.h b/src/Conversation/AppControl/inc/SettingsNetwork.h index 800aa0d5..b71f348f 100644 --- a/src/Conversation/AppControl/inc/SettingsNetwork.h +++ b/src/Conversation/AppControl/inc/SettingsNetwork.h @@ -20,12 +20,12 @@ #include "AppControlLauncher.h" namespace Msg { - class SettingsNetwork - : public AppControlHandle { - public: - SettingsNetwork(); - void launch(); - }; + class SettingsNetwork + : public AppControlHandle { + public: + SettingsNetwork(); + void launch(); + }; } #endif /* _LAUNCH_SETTINGS_NETWORK_H_ */ diff --git a/src/Conversation/AppControl/src/AttachPanel.cpp b/src/Conversation/AppControl/src/AttachPanel.cpp index fefd734d..3a85c2b2 100644 --- a/src/Conversation/AppControl/src/AttachPanel.cpp +++ b/src/Conversation/AppControl/src/AttachPanel.cpp @@ -24,108 +24,108 @@ using namespace Msg; namespace { - const char *appControlTotalSize = "http://tizen.org/appcontrol/data/total_size"; - const char *appControlTotalCount = "http://tizen.org/appcontrol/data/total_count"; + const char *appControlTotalSize = "http://tizen.org/appcontrol/data/total_size"; + const char *appControlTotalCount = "http://tizen.org/appcontrol/data/total_count"; } AttachPanel::AttachPanel(App &app) - : m_App(app) - , m_Handle() - , m_pListener(nullptr) + : m_App(app) + , m_Handle() + , m_pListener(nullptr) { } AttachPanel::~AttachPanel() { - reset(); + reset(); } void AttachPanel::setListener(IAttachPanelListener *l) { - m_pListener = l; + m_pListener = l; } void AttachPanel::show(bool value) { - if (!value && !m_Handle) - return; - - getAttachPanel(); - if (value) - attach_panel_show(m_Handle); - else - attach_panel_hide(m_Handle); + if (!value && !m_Handle) + return; + + getAttachPanel(); + if (value) + attach_panel_show(m_Handle); + else + attach_panel_hide(m_Handle); } void AttachPanel::reset() { - if (m_Handle) { - attach_panel_hide(m_Handle); - attach_panel_destroy(m_Handle); - m_Handle = nullptr; - } + if (m_Handle) { + attach_panel_hide(m_Handle); + attach_panel_destroy(m_Handle); + m_Handle = nullptr; + } } bool AttachPanel::isVisible() const { - bool res = false; - if (m_Handle) - attach_panel_get_visibility(m_Handle, &res); - return res; + bool res = false; + if (m_Handle) + attach_panel_get_visibility(m_Handle, &res); + return res; } bool AttachPanel::isFullExpanded() const { - attach_panel_state_e res = ATTACH_PANEL_STATE_HIDDEN; - if (m_Handle) - attach_panel_get_state(m_Handle, &res); - return res == ATTACH_PANEL_STATE_FULL; + attach_panel_state_e res = ATTACH_PANEL_STATE_HIDDEN; + if (m_Handle) + attach_panel_get_state(m_Handle, &res); + return res == ATTACH_PANEL_STATE_FULL; } attach_panel_h AttachPanel::getAttachPanel() { - if (m_Handle) - return m_Handle; + if (m_Handle) + return m_Handle; - attach_panel_create(m_App.getWindow().getConformEvasObject(), &m_Handle); - if (m_Handle) { - bundle *extraData = bundle_create(); + attach_panel_create(m_App.getWindow().getConformEvasObject(), &m_Handle); + if (m_Handle) { + bundle *extraData = bundle_create(); - int maxMmsSize = m_App.getMsgEngine().getSettings().getMaxMmsSize(); - MSG_LOG("Mss mms size = ", maxMmsSize); + int maxMmsSize = m_App.getMsgEngine().getSettings().getMaxMmsSize(); + MSG_LOG("Mss mms size = ", maxMmsSize); - if (maxMmsSize > 0) - bundle_add_str(extraData, appControlTotalSize, std::to_string(maxMmsSize).c_str()); + if (maxMmsSize > 0) + bundle_add_str(extraData, appControlTotalSize, std::to_string(maxMmsSize).c_str()); - std::string maxAttachment = std::to_string(m_App.getMsgEngine().getSettings().getAttachmentsMaxCount()); - bundle_add_str(extraData, appControlTotalCount, maxAttachment.c_str()); + std::string maxAttachment = std::to_string(m_App.getMsgEngine().getSettings().getAttachmentsMaxCount()); + bundle_add_str(extraData, appControlTotalCount, maxAttachment.c_str()); - if (extraData) { - attach_panel_add_content_category(m_Handle, ATTACH_PANEL_CONTENT_CATEGORY_IMAGE, extraData); - attach_panel_add_content_category(m_Handle, ATTACH_PANEL_CONTENT_CATEGORY_CAMERA, extraData); - attach_panel_add_content_category(m_Handle, ATTACH_PANEL_CONTENT_CATEGORY_VOICE, extraData); - attach_panel_add_content_category(m_Handle, ATTACH_PANEL_CONTENT_CATEGORY_VIDEO_RECORDER, extraData); - attach_panel_add_content_category(m_Handle, ATTACH_PANEL_CONTENT_CATEGORY_VIDEO, extraData); - attach_panel_add_content_category(m_Handle, ATTACH_PANEL_CONTENT_CATEGORY_AUDIO, extraData); + if (extraData) { + attach_panel_add_content_category(m_Handle, ATTACH_PANEL_CONTENT_CATEGORY_IMAGE, extraData); + attach_panel_add_content_category(m_Handle, ATTACH_PANEL_CONTENT_CATEGORY_CAMERA, extraData); + attach_panel_add_content_category(m_Handle, ATTACH_PANEL_CONTENT_CATEGORY_VOICE, extraData); + attach_panel_add_content_category(m_Handle, ATTACH_PANEL_CONTENT_CATEGORY_VIDEO_RECORDER, extraData); + attach_panel_add_content_category(m_Handle, ATTACH_PANEL_CONTENT_CATEGORY_VIDEO, extraData); + attach_panel_add_content_category(m_Handle, ATTACH_PANEL_CONTENT_CATEGORY_AUDIO, extraData); - bundle_free(extraData); - attach_panel_set_result_cb(m_Handle, result_cb, this); - } - } + bundle_free(extraData); + attach_panel_set_result_cb(m_Handle, result_cb, this); + } + } - return m_Handle; + return m_Handle; } void AttachPanel::result_cb(attach_panel_h attachPanel, attach_panel_content_category_e contentCategory, - app_control_h result, app_control_result_e resultCode, void *userData) + app_control_h result, app_control_result_e resultCode, void *userData) { - AttachPanel *self = (AttachPanel*)userData; - if (!self->m_pListener || resultCode != APP_CONTROL_RESULT_SUCCEEDED) - return; + AttachPanel *self = (AttachPanel*)userData; + if (!self->m_pListener || resultCode != APP_CONTROL_RESULT_SUCCEEDED) + return; - FileList fileList; - AppControlUtils::getExtraDataArray(result, APP_CONTROL_DATA_SELECTED, fileList); + FileList fileList; + AppControlUtils::getExtraDataArray(result, APP_CONTROL_DATA_SELECTED, fileList); - if (!fileList.empty()) - self->m_pListener->onFileSelected(*self, fileList); + if (!fileList.empty()) + self->m_pListener->onFileSelected(*self, fileList); } diff --git a/src/Conversation/AppControl/src/ContactPicker.cpp b/src/Conversation/AppControl/src/ContactPicker.cpp index 0d9f1af0..0a338679 100644 --- a/src/Conversation/AppControl/src/ContactPicker.cpp +++ b/src/Conversation/AppControl/src/ContactPicker.cpp @@ -20,69 +20,69 @@ using namespace Msg; namespace { - const char* mimeContact = "application/vnd.tizen.contact"; - const char* single = "single"; - const char* multiple = "multiple"; - const std::string typePhone = "phone"; - const std::string typeEmail = "email"; + const char* mimeContact = "application/vnd.tizen.contact"; + const char* single = "single"; + const char* multiple = "multiple"; + const std::string typePhone = "phone"; + const std::string typeEmail = "email"; } ContactPicker::ContactPicker() - : m_pListener(nullptr) + : m_pListener(nullptr) { - app_control_set_operation(m_Handle, APP_CONTROL_OPERATION_PICK); - app_control_set_mime(m_Handle, mimeContact); + app_control_set_operation(m_Handle, APP_CONTROL_OPERATION_PICK); + app_control_set_mime(m_Handle, mimeContact); } void ContactPicker::setListener(IContactPickerListener *pListener) { - m_pListener = pListener; + m_pListener = pListener; } bool ContactPicker::launch(size_t howManyToPick) { - bool res = false; - if (m_Handle) { - if (howManyToPick > 1) { - app_control_add_extra_data(m_Handle, APP_CONTROL_DATA_SELECTION_MODE, multiple); - app_control_add_extra_data(m_Handle, APP_CONTROL_DATA_TOTAL_COUNT, std::to_string(howManyToPick).c_str()); - } else { - app_control_add_extra_data(m_Handle, APP_CONTROL_DATA_SELECTION_MODE, single); - } + bool res = false; + if (m_Handle) { + if (howManyToPick > 1) { + app_control_add_extra_data(m_Handle, APP_CONTROL_DATA_SELECTION_MODE, multiple); + app_control_add_extra_data(m_Handle, APP_CONTROL_DATA_TOTAL_COUNT, std::to_string(howManyToPick).c_str()); + } else { + app_control_add_extra_data(m_Handle, APP_CONTROL_DATA_SELECTION_MODE, single); + } - static const char *addressesTypes[] = {typePhone.c_str(), typeEmail.c_str()}; - size_t len = sizeof(addressesTypes) / sizeof(addressesTypes[0]); - app_control_add_extra_data_array(m_Handle, APP_CONTROL_DATA_TYPE, addressesTypes, len); - res = AppControlLauncher::getInst().launch(*this); - } + static const char *addressesTypes[] = {typePhone.c_str(), typeEmail.c_str()}; + size_t len = sizeof(addressesTypes) / sizeof(addressesTypes[0]); + app_control_add_extra_data_array(m_Handle, APP_CONTROL_DATA_TYPE, addressesTypes, len); + res = AppControlLauncher::getInst().launch(*this); + } - return res; + return res; } void ContactPicker::onReply(app_control_h request, app_control_h reply, app_control_result_e result) { - if (result == APP_CONTROL_RESULT_SUCCEEDED) { - std::list addressIds; - std::list types; - std::list result; + if (result == APP_CONTROL_RESULT_SUCCEEDED) { + std::list addressIds; + std::list types; + std::list result; - AppControlUtils::getExtraDataIntArray(reply, APP_CONTROL_DATA_SELECTED, addressIds); - AppControlUtils::getExtraDataArray(reply, APP_CONTROL_DATA_TYPE, types); + AppControlUtils::getExtraDataIntArray(reply, APP_CONTROL_DATA_SELECTED, addressIds); + AppControlUtils::getExtraDataArray(reply, APP_CONTROL_DATA_TYPE, types); - int minLen = std::min(addressIds.size(), types.size()); - auto itId = addressIds.begin(); - auto itType = types.begin(); - for (int i = 0; i < minLen; ++i, ++itId, ++itType) { - if (*itType == typePhone) { - result.push_back({IContactPickerListener::PhoneType, *itId}); - } else if (*itType == typeEmail) { - result.push_back({IContactPickerListener::EmailType, *itId}); - } else { - MSG_LOG_WARN("Unknown type: ", *itType); - } - } + int minLen = std::min(addressIds.size(), types.size()); + auto itId = addressIds.begin(); + auto itType = types.begin(); + for (int i = 0; i < minLen; ++i, ++itId, ++itType) { + if (*itType == typePhone) { + result.push_back({IContactPickerListener::PhoneType, *itId}); + } else if (*itType == typeEmail) { + result.push_back({IContactPickerListener::EmailType, *itId}); + } else { + MSG_LOG_WARN("Unknown type: ", *itType); + } + } - if (m_pListener) - m_pListener->onContactsPicked(result); - } + if (m_pListener) + m_pListener->onContactsPicked(result); + } } diff --git a/src/Conversation/AppControl/src/SettingsNetwork.cpp b/src/Conversation/AppControl/src/SettingsNetwork.cpp index d111ea04..dd39b7b1 100644 --- a/src/Conversation/AppControl/src/SettingsNetwork.cpp +++ b/src/Conversation/AppControl/src/SettingsNetwork.cpp @@ -21,10 +21,10 @@ using namespace Msg; SettingsNetwork::SettingsNetwork() { - app_control_set_app_id(m_Handle, "org.tizen.setting-network"); + app_control_set_app_id(m_Handle, "org.tizen.setting-network"); } void SettingsNetwork::launch() { - AppControlLauncher::getInst().launch(*this); + AppControlLauncher::getInst().launch(*this); } diff --git a/src/Conversation/Body/Controller/inc/Body.h b/src/Conversation/Body/Controller/inc/Body.h index 7d2218a7..8d354b07 100644 --- a/src/Conversation/Body/Controller/inc/Body.h +++ b/src/Conversation/Body/Controller/inc/Body.h @@ -31,105 +31,105 @@ #include namespace Msg { - class IBodyListener; - class App; - class PopupListItem; - class PopupList; - class ConvList; - - - class Body - : public BodyView - , private IAttachmentHandlerListener - , private IComposeListItemListener { - public: - Body(Evas_Object *parent, App &app, WorkingDirRef workingDir, ConvList &convList); - virtual ~Body(); - - void setListener(IBodyListener *listener); - - void enableAutoFocusForAttachments(bool focus); - void addAttachments(const std::list &fileList); - void addAttachment(const std::string &filePath); - void clear(); - void show(bool value); - bool isEmpty() const; - bool isMms(); - void setMmsRecipFlag(bool value); - const MsgTextMetric &getTextMetric(); - long long getMsgSize(); - void read(Message &msg); - void write(const Message &msg); - void execCmd(const AppControlComposeRef &cmd); - void execCmd(const AppControlDefaultRef &cmd); - - private: - ComposeListItem &getComposeItem(); - const ComposeListItem &getComposeItem() const; - void notifyContentChanged(); - void updateTextMetricIfNeeded(); - void showTooLargePopup(const std::list &tooBigFiles); - void showTooMuchAttachedPopup(); - void showMaxCharactersPopup(); - void showResizingPopup(); - void hideResizingPopup(); - void read(MessageSMS &msg); - void read(MessageMms &msg); - void readAttachments(MessageMms &msg); - void readText(MessageMms &msg); - void write(const MessageSMS &msg); - void write(const MessageMms &msg); - void writeText(const Message &msg); - void writeAttachments(const MessageMms &msg); - void writeTextToFile(); - void runFileProcessing(); - void addFileToPage(MessageMms &msg, const std::string &filePath); - - PopupList &createPopupList(const std::string &title); - - void onTooLargePopupDel(Evas_Object *obj, void *eventInfo); - void onResizingPopupDel(Evas_Object *obj, void *eventInfo); - - std::string createVcfFile(const AppControlComposeRef &cmd); - - // BodyView: - virtual void onContentChanged(); - virtual void onMaxLengthReached(); - virtual void onCheckBoundaryText(char **text); - - // IComposeListItemListener: - virtual void onAttachmentAdded(const std::list &files); - virtual void onAttachmentDeleted(const std::list &files); - - //IAttachmentHandlerListener - virtual long long onFreeSpaceRequest(); - virtual void onFileReady(const std::string &filePath); - virtual void onFileFails(); - - private: - IBodyListener *m_pListener; - App &m_App; - WorkingDirRef m_WorkingDir; - Ecore_Job *m_pOnChangedJob; - bool m_TooLargePopupShow; - bool m_ResizingPopupShow; - bool m_MmsRecipFlag; - AttachmentHandler m_AttachmentHandler; - std::queue m_SelectedFiles; - bool m_AutoFocusForAttachments; - ConvList &m_ConvList; - std::string m_MmsTextFilePath; - MsgTextMetric m_TextMetric; - bool m_TextMetricNeedUpdate; - int m_Utf8TextSize; - }; - - class IBodyListener { - public: - virtual ~IBodyListener() {} - - virtual void onChanged(Body &body) {}; - }; + class IBodyListener; + class App; + class PopupListItem; + class PopupList; + class ConvList; + + + class Body + : public BodyView + , private IAttachmentHandlerListener + , private IComposeListItemListener { + public: + Body(Evas_Object *parent, App &app, WorkingDirRef workingDir, ConvList &convList); + virtual ~Body(); + + void setListener(IBodyListener *listener); + + void enableAutoFocusForAttachments(bool focus); + void addAttachments(const std::list &fileList); + void addAttachment(const std::string &filePath); + void clear(); + void show(bool value); + bool isEmpty() const; + bool isMms(); + void setMmsRecipFlag(bool value); + const MsgTextMetric &getTextMetric(); + long long getMsgSize(); + void read(Message &msg); + void write(const Message &msg); + void execCmd(const AppControlComposeRef &cmd); + void execCmd(const AppControlDefaultRef &cmd); + + private: + ComposeListItem &getComposeItem(); + const ComposeListItem &getComposeItem() const; + void notifyContentChanged(); + void updateTextMetricIfNeeded(); + void showTooLargePopup(const std::list &tooBigFiles); + void showTooMuchAttachedPopup(); + void showMaxCharactersPopup(); + void showResizingPopup(); + void hideResizingPopup(); + void read(MessageSMS &msg); + void read(MessageMms &msg); + void readAttachments(MessageMms &msg); + void readText(MessageMms &msg); + void write(const MessageSMS &msg); + void write(const MessageMms &msg); + void writeText(const Message &msg); + void writeAttachments(const MessageMms &msg); + void writeTextToFile(); + void runFileProcessing(); + void addFileToPage(MessageMms &msg, const std::string &filePath); + + PopupList &createPopupList(const std::string &title); + + void onTooLargePopupDel(Evas_Object *obj, void *eventInfo); + void onResizingPopupDel(Evas_Object *obj, void *eventInfo); + + std::string createVcfFile(const AppControlComposeRef &cmd); + + // BodyView: + virtual void onContentChanged(); + virtual void onMaxLengthReached(); + virtual void onCheckBoundaryText(char **text); + + // IComposeListItemListener: + virtual void onAttachmentAdded(const std::list &files); + virtual void onAttachmentDeleted(const std::list &files); + + //IAttachmentHandlerListener + virtual long long onFreeSpaceRequest(); + virtual void onFileReady(const std::string &filePath); + virtual void onFileFails(); + + private: + IBodyListener *m_pListener; + App &m_App; + WorkingDirRef m_WorkingDir; + Ecore_Job *m_pOnChangedJob; + bool m_TooLargePopupShow; + bool m_ResizingPopupShow; + bool m_MmsRecipFlag; + AttachmentHandler m_AttachmentHandler; + std::queue m_SelectedFiles; + bool m_AutoFocusForAttachments; + ConvList &m_ConvList; + std::string m_MmsTextFilePath; + MsgTextMetric m_TextMetric; + bool m_TextMetricNeedUpdate; + int m_Utf8TextSize; + }; + + class IBodyListener { + public: + virtual ~IBodyListener() {} + + virtual void onChanged(Body &body) {}; + }; } #endif /* Body_h_ */ diff --git a/src/Conversation/Body/Controller/src/Body.cpp b/src/Conversation/Body/Controller/src/Body.cpp index da32c926..1a7744c7 100644 --- a/src/Conversation/Body/Controller/src/Body.cpp +++ b/src/Conversation/Body/Controller/src/Body.cpp @@ -32,493 +32,493 @@ using namespace Msg; namespace { - const std::string contactFileName = "Contact.vcf"; - const std::string contactsFileName = "Contacts.vcf"; + const std::string contactFileName = "Contact.vcf"; + const std::string contactsFileName = "Contacts.vcf"; } Body::Body(Evas_Object *parent, App &app, WorkingDirRef workingDir, ConvList &convList) - : BodyView(parent, app.getMsgEngine().getSettings().getMaxMsgTextLen()) - , m_pListener(nullptr) - , m_App(app) - , m_WorkingDir(workingDir) - , m_pOnChangedJob(nullptr) - , m_TooLargePopupShow(false) - , m_ResizingPopupShow(false) - , m_MmsRecipFlag(false) - , m_AttachmentHandler(workingDir) - , m_AutoFocusForAttachments(true) - , m_ConvList(convList) - , m_TextMetric() - , m_TextMetricNeedUpdate(true) - , m_Utf8TextSize(0) -{ - m_AttachmentHandler.setListener(this); + : BodyView(parent, app.getMsgEngine().getSettings().getMaxMsgTextLen()) + , m_pListener(nullptr) + , m_App(app) + , m_WorkingDir(workingDir) + , m_pOnChangedJob(nullptr) + , m_TooLargePopupShow(false) + , m_ResizingPopupShow(false) + , m_MmsRecipFlag(false) + , m_AttachmentHandler(workingDir) + , m_AutoFocusForAttachments(true) + , m_ConvList(convList) + , m_TextMetric() + , m_TextMetricNeedUpdate(true) + , m_Utf8TextSize(0) +{ + m_AttachmentHandler.setListener(this); } Body::~Body() { - if (m_pOnChangedJob) { - ecore_job_del(m_pOnChangedJob); - m_pOnChangedJob = nullptr; - } + if (m_pOnChangedJob) { + ecore_job_del(m_pOnChangedJob); + m_pOnChangedJob = nullptr; + } } bool Body::isEmpty() const { - return BodyView::isEmpty() && getComposeItem().isEmpty(); + return BodyView::isEmpty() && getComposeItem().isEmpty(); } void Body::clear() { - BodyView::clear(); - getComposeItem().clear(); + BodyView::clear(); + getComposeItem().clear(); } void Body::show(bool value) { - ComposeListItem &item = m_ConvList.getComposeItem(); - item.show(value); - BodyView::show(value); + ComposeListItem &item = m_ConvList.getComposeItem(); + item.show(value); + BodyView::show(value); } void Body::setListener(IBodyListener *listener) { - m_pListener = listener; + m_pListener = listener; } ComposeListItem &Body::getComposeItem() { - ComposeListItem &item = m_ConvList.getComposeItem(); - if (item.getListener() != this) - item.setListener(this); - return item; + ComposeListItem &item = m_ConvList.getComposeItem(); + if (item.getListener() != this) + item.setListener(this); + return item; } const ComposeListItem &Body::getComposeItem() const { - return const_cast(this)->getComposeItem(); + return const_cast(this)->getComposeItem(); } void Body::enableAutoFocusForAttachments(bool focus) { - m_AutoFocusForAttachments = focus; + m_AutoFocusForAttachments = focus; } void Body::addAttachments(const std::list &fileList) { - for (auto& file : fileList) - m_SelectedFiles.push(file); - runFileProcessing(); + for (auto& file : fileList) + m_SelectedFiles.push(file); + runFileProcessing(); } void Body::addAttachment(const std::string &filePath) { - m_SelectedFiles.push(filePath); - runFileProcessing(); + m_SelectedFiles.push(filePath); + runFileProcessing(); } void Body::addFileToPage(MessageMms &msg, const std::string &filePath) { - static const int defaultPageDuration = 5000; // msec - if (!filePath.empty()) { - MsgPage &msgPage = msg.addPage(); - MediaTypeData mediaData = getMsgMediaTypeByFileExt(filePath); - int pageDuration = 0; + static const int defaultPageDuration = 5000; // msec + if (!filePath.empty()) { + MsgPage &msgPage = msg.addPage(); + MediaTypeData mediaData = getMsgMediaTypeByFileExt(filePath); + int pageDuration = 0; - if (mediaData.type == MsgMedia::VideoType || mediaData.type == MsgMedia::AudioType) - pageDuration = MediaUtils::getDuration(filePath); + if (mediaData.type == MsgMedia::VideoType || mediaData.type == MsgMedia::AudioType) + pageDuration = MediaUtils::getDuration(filePath); - if (pageDuration <= 0) - pageDuration = defaultPageDuration; + if (pageDuration <= 0) + pageDuration = defaultPageDuration; - msgPage.setPageDuration(pageDuration); - MsgMedia &media = msgPage.addMedia(); - media.setFilePath(filePath); - } + msgPage.setPageDuration(pageDuration); + MsgMedia &media = msgPage.addMedia(); + media.setFilePath(filePath); + } } void Body::runFileProcessing() { - if (!m_SelectedFiles.empty()) { - long long freeSpace = m_App.getMsgEngine().getSettings().getMaxMmsSize() - getMsgSize(); - if (freeSpace < FileUtils::getFileSize(m_SelectedFiles.front())) - showResizingPopup(); - m_AttachmentHandler.processFile(m_SelectedFiles.front()); - } + if (!m_SelectedFiles.empty()) { + long long freeSpace = m_App.getMsgEngine().getSettings().getMaxMmsSize() - getMsgSize(); + if (freeSpace < FileUtils::getFileSize(m_SelectedFiles.front())) + showResizingPopup(); + m_AttachmentHandler.processFile(m_SelectedFiles.front()); + } } bool Body::isMms() { - if (m_MmsRecipFlag || !getComposeItem().isEmpty()) - return true; + if (m_MmsRecipFlag || !getComposeItem().isEmpty()) + return true; - updateTextMetricIfNeeded(); - return m_TextMetric.isMms; + updateTextMetricIfNeeded(); + return m_TextMetric.isMms; } void Body::setMmsRecipFlag(bool value) { - m_MmsRecipFlag = value; + m_MmsRecipFlag = value; } void Body::updateTextMetricIfNeeded() { - if (m_TextMetricNeedUpdate) { - std::string text = getPlainUtf8Text(); - m_Utf8TextSize = text.length(); - MsgEngine::calculateTextMetric(text, m_TextMetric); - m_TextMetricNeedUpdate = false; - } + if (m_TextMetricNeedUpdate) { + std::string text = getPlainUtf8Text(); + m_Utf8TextSize = text.length(); + MsgEngine::calculateTextMetric(text, m_TextMetric); + m_TextMetricNeedUpdate = false; + } } const MsgTextMetric &Body::getTextMetric() { - updateTextMetricIfNeeded(); - return m_TextMetric; + updateTextMetricIfNeeded(); + return m_TextMetric; } long long Body::getMsgSize() { - long long totalSize = 0; + long long totalSize = 0; - // Attachments: - auto attachments = getComposeItem().getAttachments(); - for (auto *attachment : attachments) - totalSize += attachment->getFileSize(); + // Attachments: + auto attachments = getComposeItem().getAttachments(); + for (auto *attachment : attachments) + totalSize += attachment->getFileSize(); - // Text: - updateTextMetricIfNeeded(); - totalSize += isMms() ? m_Utf8TextSize : m_TextMetric.bytes; + // Text: + updateTextMetricIfNeeded(); + totalSize += isMms() ? m_Utf8TextSize : m_TextMetric.bytes; - return totalSize; + return totalSize; } void Body::read(Message &msg) { - MSG_LOG(""); - if (MessageSMS *sms = dynamic_cast(&msg)) - read(*sms); - else if (MessageMms *mms = dynamic_cast(&msg)) - read(*mms); + MSG_LOG(""); + if (MessageSMS *sms = dynamic_cast(&msg)) + read(*sms); + else if (MessageMms *mms = dynamic_cast(&msg)) + read(*mms); } void Body::write(const Message &msg) { - clear(); - if (const MessageSMS *sms = dynamic_cast(&msg)) - write(*sms); - else if (const MessageMms *mms = dynamic_cast(&msg)) - write(*mms); + clear(); + if (const MessageSMS *sms = dynamic_cast(&msg)) + write(*sms); + else if (const MessageMms *mms = dynamic_cast(&msg)) + write(*mms); } void Body::write(const MessageSMS &msg) { - setText(msg.getText()); + setText(msg.getText()); } void Body::write(const MessageMms &msg) { - writeText(msg); - writeAttachments(msg); + writeText(msg); + writeAttachments(msg); } void Body::writeText(const Message &msg) { - setText(msg.getText()); + setText(msg.getText()); } void Body::writeAttachments(const MessageMms &msg) { - // Pages: - const MsgPageList &pages = msg.getPageList(); - int pageCount = pages.getLength(); - for (int pageIndex = 0; pageIndex < pageCount; ++pageIndex) { - const MsgPage &page = pages[pageIndex]; - - // Media: - const MsgMediaList &mediaList = page.getMediaList(); - int mediaCount = mediaList.getLength(); - for (int mediaIndex = 0; mediaIndex < mediaCount; ++mediaIndex) { - const MsgMedia &media = mediaList[mediaIndex]; - std::string filePath = media.getFilePath(); - if (!filePath.empty()) { - std::string mime = FileUtils::getMimeType(filePath); - if (mime != "text/plain") { // Skip text on page - std::string newFilePath = m_WorkingDir->addFile(filePath); - getComposeItem().addAttachment(newFilePath); - } - } - } - } - - // Attachments: - const MsgAttachmentList &attachments = msg.getAttachmentList(); - int attachmentCount = attachments.getLength(); - for (int i = 0; i < attachmentCount; ++i) { - const MsgAttachment &attachment = attachments[i]; - std::string filePath = attachment.getFilePath(); - if (!filePath.empty()) { - std::string mime = FileUtils::getMimeType(filePath); - if (mime != "application/smil") { // Skip SMIL layout - std::string newFilePath = m_WorkingDir->addFile(filePath); - getComposeItem().addAttachment(newFilePath); - } - } - } + // Pages: + const MsgPageList &pages = msg.getPageList(); + int pageCount = pages.getLength(); + for (int pageIndex = 0; pageIndex < pageCount; ++pageIndex) { + const MsgPage &page = pages[pageIndex]; + + // Media: + const MsgMediaList &mediaList = page.getMediaList(); + int mediaCount = mediaList.getLength(); + for (int mediaIndex = 0; mediaIndex < mediaCount; ++mediaIndex) { + const MsgMedia &media = mediaList[mediaIndex]; + std::string filePath = media.getFilePath(); + if (!filePath.empty()) { + std::string mime = FileUtils::getMimeType(filePath); + if (mime != "text/plain") { // Skip text on page + std::string newFilePath = m_WorkingDir->addFile(filePath); + getComposeItem().addAttachment(newFilePath); + } + } + } + } + + // Attachments: + const MsgAttachmentList &attachments = msg.getAttachmentList(); + int attachmentCount = attachments.getLength(); + for (int i = 0; i < attachmentCount; ++i) { + const MsgAttachment &attachment = attachments[i]; + std::string filePath = attachment.getFilePath(); + if (!filePath.empty()) { + std::string mime = FileUtils::getMimeType(filePath); + if (mime != "application/smil") { // Skip SMIL layout + std::string newFilePath = m_WorkingDir->addFile(filePath); + getComposeItem().addAttachment(newFilePath); + } + } + } } void Body::writeTextToFile() { - if (m_MmsTextFilePath.empty()) - m_MmsTextFilePath = m_WorkingDir->addTextFile(getPlainUtf8Text()); - else - FileUtils::writeTextFile(m_MmsTextFilePath, getPlainUtf8Text()); + if (m_MmsTextFilePath.empty()) + m_MmsTextFilePath = m_WorkingDir->addTextFile(getPlainUtf8Text()); + else + FileUtils::writeTextFile(m_MmsTextFilePath, getPlainUtf8Text()); } void Body::read(MessageSMS &msg) { - msg.setText(getPlainUtf8Text()); + msg.setText(getPlainUtf8Text()); } void Body::read(MessageMms &msg) { - readText(msg); - readAttachments(msg); + readText(msg); + readAttachments(msg); } void Body::readAttachments(MessageMms &msg) { - const auto &attachments = getComposeItem().getAttachments(); - for (auto *attach : attachments) { - const std::string &filePath = attach->getFilePath(); - if (filePath.empty()) - continue; - - switch (getMsgMediaTypeByFileExt(filePath).type) { - case MsgMedia::ImageType: - case MsgMedia::AudioType: - case MsgMedia::VideoType: - addFileToPage(msg, filePath); - break; - default: - MsgAttachment &msgAttach = msg.addAttachment(); - msgAttach.setFilePath(filePath); - break; - } - } + const auto &attachments = getComposeItem().getAttachments(); + for (auto *attach : attachments) { + const std::string &filePath = attach->getFilePath(); + if (filePath.empty()) + continue; + + switch (getMsgMediaTypeByFileExt(filePath).type) { + case MsgMedia::ImageType: + case MsgMedia::AudioType: + case MsgMedia::VideoType: + addFileToPage(msg, filePath); + break; + default: + MsgAttachment &msgAttach = msg.addAttachment(); + msgAttach.setFilePath(filePath); + break; + } + } } void Body::readText(MessageMms &msg) { - if (!BodyView::isEmpty()) { - writeTextToFile(); - addFileToPage(msg, m_MmsTextFilePath); - } + if (!BodyView::isEmpty()) { + writeTextToFile(); + addFileToPage(msg, m_MmsTextFilePath); + } } void Body::execCmd(const AppControlComposeRef &cmd) { - clear(); - setText(cmd->getMessageText()); - std::list path = cmd->getFileList(); - if (!cmd->getVcfInfo().contactsIdList.empty()) - path.push_back(createVcfFile(cmd)); + clear(); + setText(cmd->getMessageText()); + std::list path = cmd->getFileList(); + if (!cmd->getVcfInfo().contactsIdList.empty()) + path.push_back(createVcfFile(cmd)); - addAttachments(path); + addAttachments(path); } void Body::execCmd(const AppControlDefaultRef &cmd) { - if (cmd->getDefaultType() == AppControlDefault::ReplyType) { - clear(); - setText(cmd->getReplyText()); - } + if (cmd->getDefaultType() == AppControlDefault::ReplyType) { + clear(); + setText(cmd->getReplyText()); + } } void Body::onMaxLengthReached() { - MSG_LOG(""); - showMaxCharactersPopup(); + MSG_LOG(""); + showMaxCharactersPopup(); } void Body::onCheckBoundaryText(char **text) { - MSG_LOG(""); - if (isMms()) { - long long maxSize = m_App.getMsgEngine().getSettings().getMaxMmsSize(); - std::string utfText = markupToUtf8(*text); - if (getMsgSize() + static_cast(utfText.size()) > maxSize) { - free(*text); - *text = nullptr; - showMaxCharactersPopup(); - } - } + MSG_LOG(""); + if (isMms()) { + long long maxSize = m_App.getMsgEngine().getSettings().getMaxMmsSize(); + std::string utfText = markupToUtf8(*text); + if (getMsgSize() + static_cast(utfText.size()) > maxSize) { + free(*text); + *text = nullptr; + showMaxCharactersPopup(); + } + } } PopupList &Body::createPopupList(const std::string &title) { - PopupList &popupList = m_App.getPopupManager().getPopupList(); - popupList.setTitle(title); - return popupList; + PopupList &popupList = m_App.getPopupManager().getPopupList(); + popupList.setTitle(title); + return popupList; } void Body::showTooLargePopup(const std::list &tooBigFiles) { - if (!m_TooLargePopupShow) { - Popup &popup = m_App.getPopupManager().getPopup(); - popup.addEventCb(EVAS_CALLBACK_DEL, EVAS_EVENT_CALLBACK(Body, onTooLargePopupDel), this); - popup.addButton(msgt("IDS_MSG_BUTTON_OK_ABB"), Popup::OkButtonId); - popup.setTitle(msgt("IDS_MSG_HEADER_FILE_SIZE_TOO_LARGE_ABB")); - std::string content(msg("IDS_MSG_POP_UNABLE_TO_ATTACH_FILE_FILE_SIZE_TOO_LARGE_TRY_SENDING_VIA_EMAIL_BLUETOOTH_WI_FI_ETC")); - for (auto& file: tooBigFiles) { - content.append("
"); - content.append(FileUtils::getFileName(file)); - } - popup.setContent(content); - popup.show(); - m_TooLargePopupShow = true; - } + if (!m_TooLargePopupShow) { + Popup &popup = m_App.getPopupManager().getPopup(); + popup.addEventCb(EVAS_CALLBACK_DEL, EVAS_EVENT_CALLBACK(Body, onTooLargePopupDel), this); + popup.addButton(msgt("IDS_MSG_BUTTON_OK_ABB"), Popup::OkButtonId); + popup.setTitle(msgt("IDS_MSG_HEADER_FILE_SIZE_TOO_LARGE_ABB")); + std::string content(msg("IDS_MSG_POP_UNABLE_TO_ATTACH_FILE_FILE_SIZE_TOO_LARGE_TRY_SENDING_VIA_EMAIL_BLUETOOTH_WI_FI_ETC")); + for (auto& file: tooBigFiles) { + content.append("
"); + content.append(FileUtils::getFileName(file)); + } + popup.setContent(content); + popup.show(); + m_TooLargePopupShow = true; + } } void Body::showTooMuchAttachedPopup() { - int maxCount = m_App.getMsgEngine().getSettings().getAttachmentsMaxCount(); - std::string content(msgArgs("IDS_MSG_TPOP_CANT_ADD_MORE_THAN_PD_ATTACHMENTS", maxCount)); - notification_status_message_post(content.c_str()); + int maxCount = m_App.getMsgEngine().getSettings().getAttachmentsMaxCount(); + std::string content(msgArgs("IDS_MSG_TPOP_CANT_ADD_MORE_THAN_PD_ATTACHMENTS", maxCount)); + notification_status_message_post(content.c_str()); } void Body::showResizingPopup() { - if (!m_ResizingPopupShow) { - Popup &popup = m_App.getPopupManager().getPopup(); - popup.addEventCb(EVAS_CALLBACK_DEL, EVAS_EVENT_CALLBACK(Body, onResizingPopupDel), this); - int maxSize = m_App.getMsgEngine().getSettings().getMaxMmsSize(); + if (!m_ResizingPopupShow) { + Popup &popup = m_App.getPopupManager().getPopup(); + popup.addEventCb(EVAS_CALLBACK_DEL, EVAS_EVENT_CALLBACK(Body, onResizingPopupDel), this); + int maxSize = m_App.getMsgEngine().getSettings().getMaxMmsSize(); - std::string content(msgArgs("IDS_MSG_TPOP_CANT_ADD_MORE_THAN_P1SS_P2SS_OF_ATTACHMENTS_RESIZING_ATTACHMENTS_ING", - std::to_string(maxSize / 1024).c_str(), msg("IDS_MSGF_BODY_MSGSIZE_KB").get())); - popup.setContent(content); - popup.show(); - m_ResizingPopupShow = true; - } + std::string content(msgArgs("IDS_MSG_TPOP_CANT_ADD_MORE_THAN_P1SS_P2SS_OF_ATTACHMENTS_RESIZING_ATTACHMENTS_ING", + std::to_string(maxSize / 1024).c_str(), msg("IDS_MSGF_BODY_MSGSIZE_KB").get())); + popup.setContent(content); + popup.show(); + m_ResizingPopupShow = true; + } } void Body::hideResizingPopup() { - m_App.getPopupManager().reset(); + m_App.getPopupManager().reset(); } void Body::showMaxCharactersPopup() { - MSG_LOG(""); - std::string notifText = msg("IDS_MSGF_POP_MAXIMUM_CHARACTERS"); - notification_status_message_post(notifText.c_str()); + MSG_LOG(""); + std::string notifText = msg("IDS_MSGF_POP_MAXIMUM_CHARACTERS"); + notification_status_message_post(notifText.c_str()); } void Body::onTooLargePopupDel(Evas_Object *obj, void *eventInfo) { - MSG_LOG(""); - m_TooLargePopupShow = false; + MSG_LOG(""); + m_TooLargePopupShow = false; } void Body::onResizingPopupDel(Evas_Object *obj, void *eventInfo) { - MSG_LOG(""); - m_ResizingPopupShow = false; + MSG_LOG(""); + m_ResizingPopupShow = false; } std::string Body::createVcfFile(const AppControlComposeRef &cmd) { - auto &idList = cmd->getVcfInfo().contactsIdList; - std::string content; - std::string path; + auto &idList = cmd->getVcfInfo().contactsIdList; + std::string content; + std::string path; - if (cmd->getComposeType() == AppControlCompose::OpShare) { - content = m_App.getContactManager().makeVcard(*idList.begin(), cmd->getVcfInfo().isMyProfile); - path = contactFileName; - } else if (cmd->getComposeType() == AppControlCompose::OpMultiShare) { - content = m_App.getContactManager().makeVcard(idList); - path = contactsFileName; - } + if (cmd->getComposeType() == AppControlCompose::OpShare) { + content = m_App.getContactManager().makeVcard(*idList.begin(), cmd->getVcfInfo().isMyProfile); + path = contactFileName; + } else if (cmd->getComposeType() == AppControlCompose::OpMultiShare) { + content = m_App.getContactManager().makeVcard(idList); + path = contactsFileName; + } - path = content.empty() ? std::string() : m_WorkingDir->addTextFile(content, path); + path = content.empty() ? std::string() : m_WorkingDir->addTextFile(content, path); - return path; + return path; } void Body::notifyContentChanged() { - if (!m_pOnChangedJob) { - m_pOnChangedJob = ecore_job_add( - [](void *data) - { - Body *self =(Body*)data; - self->m_pOnChangedJob = nullptr; - if (self->m_pListener) - self->m_pListener->onChanged(*self); - }, - this); - } + if (!m_pOnChangedJob) { + m_pOnChangedJob = ecore_job_add( + [](void *data) + { + Body *self =(Body*)data; + self->m_pOnChangedJob = nullptr; + if (self->m_pListener) + self->m_pListener->onChanged(*self); + }, + this); + } } void Body::onContentChanged() { - m_TextMetricNeedUpdate = true; - notifyContentChanged(); + m_TextMetricNeedUpdate = true; + notifyContentChanged(); } void Body::onAttachmentAdded(const std::list &files) { - notifyContentChanged(); + notifyContentChanged(); } void Body::onAttachmentDeleted(const std::list &files) { - for (const std::string &file : files) - m_WorkingDir->removeFile(file); + for (const std::string &file : files) + m_WorkingDir->removeFile(file); - notifyContentChanged(); + notifyContentChanged(); } void Body::onFileReady(const std::string &filePath) { - int numAttached = getComposeItem().getAttachments().size(); - int numAttachMax = m_App.getMsgEngine().getSettings().getAttachmentsMaxCount(); - if (numAttached == numAttachMax) { - std::queue empty; - std::swap(m_SelectedFiles, empty); - showTooMuchAttachedPopup(); - return; - } - MediaTypeData mediaType = getMsgMediaTypeByFileExt(filePath); - MSG_LOG("Media type: ", mediaType.mime); - - getComposeItem().addAttachment(filePath); - - if (m_AutoFocusForAttachments) - BodyView::setFocus(true); - - m_SelectedFiles.pop(); - if (!m_SelectedFiles.empty()) { - long long freeSpace = m_App.getMsgEngine().getSettings().getMaxMmsSize() - getMsgSize(); - if (freeSpace < FileUtils::getFileSize(m_SelectedFiles.front())) - showResizingPopup(); - m_AttachmentHandler.processFile(m_SelectedFiles.front()); - } else { - hideResizingPopup(); - } + int numAttached = getComposeItem().getAttachments().size(); + int numAttachMax = m_App.getMsgEngine().getSettings().getAttachmentsMaxCount(); + if (numAttached == numAttachMax) { + std::queue empty; + std::swap(m_SelectedFiles, empty); + showTooMuchAttachedPopup(); + return; + } + MediaTypeData mediaType = getMsgMediaTypeByFileExt(filePath); + MSG_LOG("Media type: ", mediaType.mime); + + getComposeItem().addAttachment(filePath); + + if (m_AutoFocusForAttachments) + BodyView::setFocus(true); + + m_SelectedFiles.pop(); + if (!m_SelectedFiles.empty()) { + long long freeSpace = m_App.getMsgEngine().getSettings().getMaxMmsSize() - getMsgSize(); + if (freeSpace < FileUtils::getFileSize(m_SelectedFiles.front())) + showResizingPopup(); + m_AttachmentHandler.processFile(m_SelectedFiles.front()); + } else { + hideResizingPopup(); + } } void Body::onFileFails() { - std::list overflowList; - while (!m_SelectedFiles.empty()) { - overflowList.push_back(m_SelectedFiles.front()); - m_SelectedFiles.pop(); - } - showTooLargePopup(overflowList); + std::list overflowList; + while (!m_SelectedFiles.empty()) { + overflowList.push_back(m_SelectedFiles.front()); + m_SelectedFiles.pop(); + } + showTooLargePopup(overflowList); } long long Body::onFreeSpaceRequest() { - return m_App.getMsgEngine().getSettings().getMaxMmsSize() - getMsgSize(); + return m_App.getMsgEngine().getSettings().getMaxMmsSize() - getMsgSize(); } diff --git a/src/Conversation/Body/View/inc/BodyView.h b/src/Conversation/Body/View/inc/BodyView.h index 0306e3a9..7c4f3c97 100644 --- a/src/Conversation/Body/View/inc/BodyView.h +++ b/src/Conversation/Body/View/inc/BodyView.h @@ -23,32 +23,32 @@ namespace Msg { - class BodyView - : public View { - public: - BodyView(Evas_Object *parent, int maxCharCount); - virtual ~BodyView(); - - bool isEmpty() const; - void clear(); - void setFocus(bool focus); - void setText(const std::string &text); - std::string getText() const; - std::string getPlainUtf8Text() const; - - protected: - virtual void onContentChanged() {}; - virtual void onMaxLengthReached() {}; - virtual void onCheckBoundaryText(char **text) {}; - - private: - Evas_Object *createEntry(Evas_Object *parent, int maxCharCount); - void onContentBoxGeometryChanged(Evas_Object *obj, void *eventInfo); - - private: - Evas_Object *m_pGrid; - Evas_Object *m_pEntry; - }; + class BodyView + : public View { + public: + BodyView(Evas_Object *parent, int maxCharCount); + virtual ~BodyView(); + + bool isEmpty() const; + void clear(); + void setFocus(bool focus); + void setText(const std::string &text); + std::string getText() const; + std::string getPlainUtf8Text() const; + + protected: + virtual void onContentChanged() {}; + virtual void onMaxLengthReached() {}; + virtual void onCheckBoundaryText(char **text) {}; + + private: + Evas_Object *createEntry(Evas_Object *parent, int maxCharCount); + void onContentBoxGeometryChanged(Evas_Object *obj, void *eventInfo); + + private: + Evas_Object *m_pGrid; + Evas_Object *m_pEntry; + }; } #endif /* BodyView_h_ */ diff --git a/src/Conversation/Body/View/src/BodyView.cpp b/src/Conversation/Body/View/src/BodyView.cpp index 26721ab4..5d5bd76c 100644 --- a/src/Conversation/Body/View/src/BodyView.cpp +++ b/src/Conversation/Body/View/src/BodyView.cpp @@ -25,23 +25,23 @@ using namespace Msg; namespace { - #define maxBodyHeight ELM_SCALE_SIZE(360) + #define maxBodyHeight ELM_SCALE_SIZE(360) } BodyView::BodyView(Evas_Object *parent, int maxCharCount) - : m_pGrid(nullptr) - , m_pEntry(nullptr) + : m_pGrid(nullptr) + , m_pEntry(nullptr) { - // Root grid : - m_pGrid = elm_grid_add(parent); - setEo(m_pGrid); + // Root grid : + m_pGrid = elm_grid_add(parent); + setEo(m_pGrid); - // Scroller: - Evas_Object *scroller = elm_scroller_add(getEo()); - evas_object_show(scroller); + // Scroller: + Evas_Object *scroller = elm_scroller_add(getEo()); + evas_object_show(scroller); - elm_grid_pack(m_pGrid, scroller, 0, 0, 100, 100); - elm_object_content_set(scroller, createEntry(scroller, maxCharCount)); + elm_grid_pack(m_pGrid, scroller, 0, 0, 100, 100); + elm_object_content_set(scroller, createEntry(scroller, maxCharCount)); } BodyView::~BodyView() @@ -50,107 +50,107 @@ BodyView::~BodyView() bool BodyView::isEmpty() const { - const char *text = elm_entry_entry_get(m_pEntry); - return text ? text[0] == '\0' : true; + const char *text = elm_entry_entry_get(m_pEntry); + return text ? text[0] == '\0' : true; } void BodyView::clear() { - elm_object_text_set(m_pEntry, ""); + elm_object_text_set(m_pEntry, ""); } void BodyView::setText(const std::string &text) { - if (!text.empty()) { - char *markupText = elm_entry_utf8_to_markup(text.c_str()); - if (markupText) { - elm_object_text_set(m_pEntry, markupText); - free(markupText); - } - } else { - clear(); - } + if (!text.empty()) { + char *markupText = elm_entry_utf8_to_markup(text.c_str()); + if (markupText) { + elm_object_text_set(m_pEntry, markupText); + free(markupText); + } + } else { + clear(); + } } void BodyView::setFocus(bool focus) { - elm_object_focus_set(m_pEntry, focus); - if (focus) - elm_entry_cursor_end_set(m_pEntry); + elm_object_focus_set(m_pEntry, focus); + if (focus) + elm_entry_cursor_end_set(m_pEntry); } std::string BodyView::getText() const { - return m_pEntry ? elm_object_text_get(m_pEntry) : ""; + return m_pEntry ? elm_object_text_get(m_pEntry) : ""; } std::string BodyView::getPlainUtf8Text() const { - std::string res; - const char *plainText = elm_entry_entry_get(m_pEntry); - - if (plainText) { - char *text = elm_entry_markup_to_utf8(plainText); - if (text) { - res.assign(text); - free(text); - } - } - return res; + std::string res; + const char *plainText = elm_entry_entry_get(m_pEntry); + + if (plainText) { + char *text = elm_entry_markup_to_utf8(plainText); + if (text) { + res.assign(text); + free(text); + } + } + return res; } Evas_Object *BodyView::createEntry(Evas_Object *parent, int maxCharCount) { - m_pEntry = elm_entry_add(parent); - elm_entry_prediction_allow_set(m_pEntry, true); - elm_entry_autocapital_type_set(m_pEntry, ELM_AUTOCAPITAL_TYPE_SENTENCE); - elm_entry_input_panel_return_key_type_set(m_pEntry, ELM_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT); - elm_object_focus_allow_set(m_pEntry, true); - eext_entry_selection_back_event_allow_set(m_pEntry, true); - elm_entry_cnp_mode_set(m_pEntry, ELM_CNP_MODE_PLAINTEXT); - evas_object_size_hint_weight_set(m_pEntry, EVAS_HINT_EXPAND, 0); - evas_object_size_hint_align_set(m_pEntry, EVAS_HINT_FILL, 0); - - View::setText(m_pEntry, msgt("IDS_MSG_TMBODY_TEXT_MESSAGES"), "elm.guide"); - - Elm_Entry_Filter_Limit_Size limitFilter = {}; - limitFilter.max_char_count = maxCharCount; - elm_entry_markup_filter_append(m_pEntry, elm_entry_filter_limit_size, &limitFilter); - elm_entry_markup_filter_append( - m_pEntry, - [](void *data, Evas_Object *entry, char **text) - { - ((BodyView*)data)->onCheckBoundaryText(text); - }, - this); - - evas_object_show(m_pEntry); - evas_object_smart_callback_add(m_pEntry, "changed", [](void *data, Evas_Object *obj, void *event_info) - { - ((BodyView*)data)->onContentChanged(); - }, this); - - evas_object_smart_callback_add(m_pEntry, "maxlength,reached", [](void *data, Evas_Object *obj, void *event_info) - { - ((BodyView*)data)->onMaxLengthReached(); - }, this); - - evas_object_event_callback_add(m_pEntry, EVAS_CALLBACK_RESIZE, EVAS_EVENT_CALLBACK(BodyView, onContentBoxGeometryChanged), this); - evas_object_event_callback_add(m_pEntry, EVAS_CALLBACK_CHANGED_SIZE_HINTS, EVAS_EVENT_CALLBACK(BodyView, onContentBoxGeometryChanged), this); - - return m_pEntry; + m_pEntry = elm_entry_add(parent); + elm_entry_prediction_allow_set(m_pEntry, true); + elm_entry_autocapital_type_set(m_pEntry, ELM_AUTOCAPITAL_TYPE_SENTENCE); + elm_entry_input_panel_return_key_type_set(m_pEntry, ELM_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT); + elm_object_focus_allow_set(m_pEntry, true); + eext_entry_selection_back_event_allow_set(m_pEntry, true); + elm_entry_cnp_mode_set(m_pEntry, ELM_CNP_MODE_PLAINTEXT); + evas_object_size_hint_weight_set(m_pEntry, EVAS_HINT_EXPAND, 0); + evas_object_size_hint_align_set(m_pEntry, EVAS_HINT_FILL, 0); + + View::setText(m_pEntry, msgt("IDS_MSG_TMBODY_TEXT_MESSAGES"), "elm.guide"); + + Elm_Entry_Filter_Limit_Size limitFilter = {}; + limitFilter.max_char_count = maxCharCount; + elm_entry_markup_filter_append(m_pEntry, elm_entry_filter_limit_size, &limitFilter); + elm_entry_markup_filter_append( + m_pEntry, + [](void *data, Evas_Object *entry, char **text) + { + ((BodyView*)data)->onCheckBoundaryText(text); + }, + this); + + evas_object_show(m_pEntry); + evas_object_smart_callback_add(m_pEntry, "changed", [](void *data, Evas_Object *obj, void *event_info) + { + ((BodyView*)data)->onContentChanged(); + }, this); + + evas_object_smart_callback_add(m_pEntry, "maxlength,reached", [](void *data, Evas_Object *obj, void *event_info) + { + ((BodyView*)data)->onMaxLengthReached(); + }, this); + + evas_object_event_callback_add(m_pEntry, EVAS_CALLBACK_RESIZE, EVAS_EVENT_CALLBACK(BodyView, onContentBoxGeometryChanged), this); + evas_object_event_callback_add(m_pEntry, EVAS_CALLBACK_CHANGED_SIZE_HINTS, EVAS_EVENT_CALLBACK(BodyView, onContentBoxGeometryChanged), this); + + return m_pEntry; } void BodyView::onContentBoxGeometryChanged(Evas_Object *obj, void *event_info) { - int w = 0; - int h = 0; + int w = 0; + int h = 0; - evas_object_geometry_get(m_pEntry, nullptr, nullptr, &w, &h); + evas_object_geometry_get(m_pEntry, nullptr, nullptr, &w, &h); - if (h > maxBodyHeight) - h = maxBodyHeight; + if (h > maxBodyHeight) + h = maxBodyHeight; - evas_object_size_hint_min_set(m_pGrid, 0, h); - evas_object_size_hint_max_set(m_pGrid, -1, h); + evas_object_size_hint_min_set(m_pGrid, 0, h); + evas_object_size_hint_max_set(m_pGrid, -1, h); } diff --git a/src/Conversation/ContactList/Controller/inc/ContactListItem.h b/src/Conversation/ContactList/Controller/inc/ContactListItem.h index e232572b..45e4261a 100644 --- a/src/Conversation/ContactList/Controller/inc/ContactListItem.h +++ b/src/Conversation/ContactList/Controller/inc/ContactListItem.h @@ -23,28 +23,28 @@ #include "App.h" namespace Msg { - class ContactListItem - : public ContactListViewItem { - public: - ContactListItem(const ContactPersonPhoneLog &rec, App &app, const std::string &searchWord); - ContactListItem(const ContactAddress &rec, App &app, const std::string &searchWord); - virtual ~ContactListItem(); + class ContactListItem + : public ContactListViewItem { + public: + ContactListItem(const ContactPersonPhoneLog &rec, App &app, const std::string &searchWord); + ContactListItem(const ContactAddress &rec, App &app, const std::string &searchWord); + virtual ~ContactListItem(); - const std::string &getRecipient() const; + const std::string &getRecipient() const; - private: - ContactListItem(const std::string &recipient, App &app); - virtual std::string getSubText() const; - virtual std::string getMainText() const; - Evas_Object *getThumbnail() const; + private: + ContactListItem(const std::string &recipient, App &app); + virtual std::string getSubText() const; + virtual std::string getMainText() const; + Evas_Object *getThumbnail() const; - private: - App &m_App; - std::string m_Recipient; - ThumbId m_ThumbId; - std::string m_MainText; - std::string m_SubText; - }; + private: + App &m_App; + std::string m_Recipient; + ThumbId m_ThumbId; + std::string m_MainText; + std::string m_SubText; + }; } #endif // ContactListItem_h_ diff --git a/src/Conversation/ContactList/Controller/inc/ConvContactList.h b/src/Conversation/ContactList/Controller/inc/ConvContactList.h index 59c91dae..2643feba 100644 --- a/src/Conversation/ContactList/Controller/inc/ConvContactList.h +++ b/src/Conversation/ContactList/Controller/inc/ConvContactList.h @@ -24,45 +24,45 @@ #include namespace Msg { - class IConvContactListListener; + class IConvContactListListener; - class ConvContactList - : public ConvContactListView - , private IListViewListener { - public: - ConvContactList(Evas_Object *parent, App &app); - virtual ~ConvContactList(); + class ConvContactList + : public ConvContactListView + , private IListViewListener { + public: + ConvContactList(Evas_Object *parent, App &app); + virtual ~ConvContactList(); - void setListener(IConvContactListListener *l); - void setSearchWorld(const std::string &searchWord); - void requestSearch(); - void clear(); - bool isEmpty() const; + void setListener(IConvContactListListener *l); + void setSearchWorld(const std::string &searchWord); + void requestSearch(); + void clear(); + bool isEmpty() const; - private: - // IListViewListener: - virtual void onListItemSelected(ListItem &listItem); + private: + // IListViewListener: + virtual void onListItemSelected(ListItem &listItem); - template - void search(); - void search(); - bool onPredictSearchUpdateRequest(); - void searchInternal(); + template + void search(); + void search(); + bool onPredictSearchUpdateRequest(); + void searchInternal(); - private: - IConvContactListListener *m_pListener; - Ecore_Idler *m_pPredictSearchIdler; - App &m_App; - std::string m_SearchWord; - }; + private: + IConvContactListListener *m_pListener; + Ecore_Idler *m_pPredictSearchIdler; + App &m_App; + std::string m_SearchWord; + }; - class IConvContactListListener { - public: - virtual ~IConvContactListListener() {} + class IConvContactListListener { + public: + virtual ~IConvContactListListener() {} - virtual void onContactSelected(ContactListItem &item) {}; - virtual void onContactListChanged() {}; - }; + virtual void onContactSelected(ContactListItem &item) {}; + virtual void onContactListChanged() {}; + }; } #endif // ConvContactList_h_ diff --git a/src/Conversation/ContactList/Controller/src/ContactListItem.cpp b/src/Conversation/ContactList/Controller/src/ContactListItem.cpp index 54dfbef6..e543977f 100644 --- a/src/Conversation/ContactList/Controller/src/ContactListItem.cpp +++ b/src/Conversation/ContactList/Controller/src/ContactListItem.cpp @@ -27,26 +27,26 @@ using namespace Msg; ContactListItem::ContactListItem(const ContactPersonPhoneLog &rec, App &app, const std::string &searchWord) - : ContactListItem(rec.getAddress(), app) + : ContactListItem(rec.getAddress(), app) { - setStyle(ContactListViewItem::logStyle); + setStyle(ContactListViewItem::logStyle); - m_MainText = TextDecorator::highlightKeyword(rec.getAddress(), searchWord); + m_MainText = TextDecorator::highlightKeyword(rec.getAddress(), searchWord); } ContactListItem::ContactListItem(const ContactAddress &rec, App &app, const std::string &searchWord) - : ContactListItem(rec.getAddress(), app) + : ContactListItem(rec.getAddress(), app) { - setStyle(ContactListViewItem::nameOrEmailStyle); + setStyle(ContactListViewItem::nameOrEmailStyle); - m_MainText = TextDecorator::highlightKeyword(rec.getDispName(), searchWord); - m_SubText = TextDecorator::highlightKeyword(rec.getAddress(), searchWord); + m_MainText = TextDecorator::highlightKeyword(rec.getDispName(), searchWord); + m_SubText = TextDecorator::highlightKeyword(rec.getAddress(), searchWord); } ContactListItem::ContactListItem(const std::string &recipient, App &app) - : m_App(app) - , m_Recipient(recipient) - , m_ThumbId(m_App.getThumbnailMaker().getThumbId(recipient)) + : m_App(app) + , m_Recipient(recipient) + , m_ThumbId(m_App.getThumbnailMaker().getThumbId(recipient)) { } @@ -56,21 +56,21 @@ ContactListItem::~ContactListItem() const std::string &ContactListItem::getRecipient() const { - return m_Recipient; + return m_Recipient; } std::string ContactListItem::getSubText() const { - return m_SubText; + return m_SubText; } std::string ContactListItem::getMainText() const { - return m_MainText; + return m_MainText; } Evas_Object *ContactListItem::getThumbnail() const { - static const int thumbSize = 80; - return m_App.getThumbnailMaker().getThumb(*getOwner(), m_ThumbId, thumbSize); + static const int thumbSize = 80; + return m_App.getThumbnailMaker().getThumb(*getOwner(), m_ThumbId, thumbSize); } diff --git a/src/Conversation/ContactList/Controller/src/ConvContactList.cpp b/src/Conversation/ContactList/Controller/src/ConvContactList.cpp index c59d5234..ae5704c4 100644 --- a/src/Conversation/ContactList/Controller/src/ConvContactList.cpp +++ b/src/Conversation/ContactList/Controller/src/ConvContactList.cpp @@ -24,91 +24,91 @@ using namespace Msg; ConvContactList::ConvContactList(Evas_Object *parent, App &app) - : ConvContactListView(parent) - , m_pListener(nullptr) - , m_pPredictSearchIdler(nullptr) - , m_App(app) + : ConvContactListView(parent) + , m_pListener(nullptr) + , m_pPredictSearchIdler(nullptr) + , m_App(app) { - getList().setListener(this); + getList().setListener(this); } ConvContactList::~ConvContactList() { - if (m_pPredictSearchIdler) { - ecore_idler_del(m_pPredictSearchIdler); - m_pPredictSearchIdler = nullptr; - } + if (m_pPredictSearchIdler) { + ecore_idler_del(m_pPredictSearchIdler); + m_pPredictSearchIdler = nullptr; + } } void ConvContactList::setListener(IConvContactListListener *l) { - m_pListener = l; + m_pListener = l; } void ConvContactList::clear() { - getList().clear(); + getList().clear(); - if (m_pListener) - m_pListener->onContactListChanged(); + if (m_pListener) + m_pListener->onContactListChanged(); } bool ConvContactList::isEmpty() const { - return getList().isEmpty(); + return getList().isEmpty(); } void ConvContactList::setSearchWorld(const std::string &searchWord) { - m_SearchWord = searchWord; + m_SearchWord = searchWord; } void ConvContactList::requestSearch() { - if (!m_pPredictSearchIdler) - m_pPredictSearchIdler = ecore_idler_add(ECORE_TACK_CALLBACK(ConvContactList, onPredictSearchUpdateRequest), this); + if (!m_pPredictSearchIdler) + m_pPredictSearchIdler = ecore_idler_add(ECORE_TACK_CALLBACK(ConvContactList, onPredictSearchUpdateRequest), this); } void ConvContactList::search() { - getList().clear(); - if (!m_SearchWord.empty()) { - search(); - search(); - search(); - } - if (m_pListener) - m_pListener->onContactListChanged(); + getList().clear(); + if (!m_SearchWord.empty()) { + search(); + search(); + search(); + } + if (m_pListener) + m_pListener->onContactListChanged(); } template void ConvContactList::search() { - auto list = m_App.getContactManager().search(m_SearchWord); - if (list) { - do { - auto &rec = list->get(); - if (MsgUtils::isValidAddress(rec.getAddress())) { - ContactListItem *item = new ContactListItem(rec, m_App, m_SearchWord); - getList().appendItem(*item); - } else { - MSG_LOG("Skip invalid contact: ", rec.getAddress()); - } - } while (list->next()); - } + auto list = m_App.getContactManager().search(m_SearchWord); + if (list) { + do { + auto &rec = list->get(); + if (MsgUtils::isValidAddress(rec.getAddress())) { + ContactListItem *item = new ContactListItem(rec, m_App, m_SearchWord); + getList().appendItem(*item); + } else { + MSG_LOG("Skip invalid contact: ", rec.getAddress()); + } + } while (list->next()); + } } bool ConvContactList::onPredictSearchUpdateRequest() { - m_pPredictSearchIdler = nullptr; - search(); - return false; // Delete idler + m_pPredictSearchIdler = nullptr; + search(); + return false; // Delete idler } void ConvContactList::onListItemSelected(ListItem &listItem) { - ContactListItem &contactItem = static_cast(listItem); - MSG_LOG("Selected recipient: ", contactItem.getRecipient()); - if (m_pListener) - m_pListener->onContactSelected(contactItem); + ContactListItem &contactItem = static_cast(listItem); + MSG_LOG("Selected recipient: ", contactItem.getRecipient()); + if (m_pListener) + m_pListener->onContactSelected(contactItem); } diff --git a/src/Conversation/ContactList/View/inc/ContactListViewItem.h b/src/Conversation/ContactList/View/inc/ContactListViewItem.h index be4235b4..628d8940 100644 --- a/src/Conversation/ContactList/View/inc/ContactListViewItem.h +++ b/src/Conversation/ContactList/View/inc/ContactListViewItem.h @@ -21,24 +21,24 @@ #include namespace Msg { - class ContactListViewItem - : public ListItem { - public: - ContactListViewItem(); - virtual ~ContactListViewItem(); + class ContactListViewItem + : public ListItem { + public: + ContactListViewItem(); + virtual ~ContactListViewItem(); - protected: - static ListItemStyleRef logStyle; - static ListItemStyleRef nameOrEmailStyle; + protected: + static ListItemStyleRef logStyle; + static ListItemStyleRef nameOrEmailStyle; - virtual std::string getSubText() const = 0; - virtual std::string getMainText() const = 0; - virtual Evas_Object *getThumbnail() const = 0; + virtual std::string getSubText() const = 0; + virtual std::string getMainText() const = 0; + virtual Evas_Object *getThumbnail() const = 0; - private: - virtual std::string getText(ListItem &item, const char *part); - virtual Evas_Object *getContent(ListItem &item, const char *part); - }; + private: + virtual std::string getText(ListItem &item, const char *part); + virtual Evas_Object *getContent(ListItem &item, const char *part); + }; } #endif // ContactListItemView_h_ diff --git a/src/Conversation/ContactList/View/inc/ConvContactListView.h b/src/Conversation/ContactList/View/inc/ConvContactListView.h index 502213da..dfa0f5a2 100644 --- a/src/Conversation/ContactList/View/inc/ConvContactListView.h +++ b/src/Conversation/ContactList/View/inc/ConvContactListView.h @@ -20,23 +20,23 @@ #include "ListView.h" namespace Msg { - class ConvContactListView - : public View { - public: - ConvContactListView(Evas_Object *parent); - virtual ~ConvContactListView(); + class ConvContactListView + : public View { + public: + ConvContactListView(Evas_Object *parent); + virtual ~ConvContactListView(); - ListView &getList(); - const ListView &getList() const; + ListView &getList(); + const ListView &getList() const; - private: - void recalcGeometry(); - void onGometryChanged(Evas_Object *obj, void *eventInfo); + private: + void recalcGeometry(); + void onGometryChanged(Evas_Object *obj, void *eventInfo); - private: - ListView *m_pList; - Evas_Object *m_pGrid; - }; + private: + ListView *m_pList; + Evas_Object *m_pGrid; + }; } #endif /* ConvContactListView_h_ */ diff --git a/src/Conversation/ContactList/View/src/ContactListViewItem.cpp b/src/Conversation/ContactList/View/src/ContactListViewItem.cpp index 7c2e57a8..241316a7 100644 --- a/src/Conversation/ContactList/View/src/ContactListViewItem.cpp +++ b/src/Conversation/ContactList/View/src/ContactListViewItem.cpp @@ -23,7 +23,7 @@ ListItemStyleRef ContactListViewItem::logStyle = ListItemStyle::create("type1"); ListItemStyleRef ContactListViewItem::nameOrEmailStyle = ListItemStyle::create("type1"); ContactListViewItem::ContactListViewItem() - : ListItem(ELM_GENLIST_ITEM_NONE) + : ListItem(ELM_GENLIST_ITEM_NONE) { } @@ -33,29 +33,29 @@ ContactListViewItem::~ContactListViewItem() std::string ContactListViewItem::getText(ListItem &item, const char *part) { - if (getStyle() == nameOrEmailStyle) { - const char *mainTextPart = "elm.text"; - const char *subTextPart = "elm.text.sub"; - - if (strcmp(part, mainTextPart) == 0) { - return getMainText(); - } else if (strcmp(part, subTextPart) == 0) { - return getSubText(); - } - } - if (getStyle() == logStyle) { - const char *mainTextPart = "elm.text"; - if (strcmp(part, mainTextPart) == 0) - return getMainText(); - } - - return ""; + if (getStyle() == nameOrEmailStyle) { + const char *mainTextPart = "elm.text"; + const char *subTextPart = "elm.text.sub"; + + if (strcmp(part, mainTextPart) == 0) { + return getMainText(); + } else if (strcmp(part, subTextPart) == 0) { + return getSubText(); + } + } + if (getStyle() == logStyle) { + const char *mainTextPart = "elm.text"; + if (strcmp(part, mainTextPart) == 0) + return getMainText(); + } + + return ""; } Evas_Object *ContactListViewItem::getContent(ListItem &item, const char *part) { - if (strcmp(part, "elm.swallow.icon") == 0) - return getThumbnail(); + if (strcmp(part, "elm.swallow.icon") == 0) + return getThumbnail(); - return nullptr; + return nullptr; } diff --git a/src/Conversation/ContactList/View/src/ConvContactListView.cpp b/src/Conversation/ContactList/View/src/ConvContactListView.cpp index d6097907..82a37511 100644 --- a/src/Conversation/ContactList/View/src/ConvContactListView.cpp +++ b/src/Conversation/ContactList/View/src/ConvContactListView.cpp @@ -21,26 +21,26 @@ using namespace Msg; ConvContactListView::ConvContactListView(Evas_Object *parent) - : m_pList(nullptr) - , m_pGrid(nullptr) + : m_pList(nullptr) + , m_pGrid(nullptr) { - setEo(addLayout(parent, CONV_CONTACT_LIST_LAYOUT, "conv_contact_list_layout")); - setFocusAllow(false); - addEventCb(EVAS_CALLBACK_RESIZE, EVAS_EVENT_CALLBACK(ConvContactListView, onGometryChanged), this); + setEo(addLayout(parent, CONV_CONTACT_LIST_LAYOUT, "conv_contact_list_layout")); + setFocusAllow(false); + addEventCb(EVAS_CALLBACK_RESIZE, EVAS_EVENT_CALLBACK(ConvContactListView, onGometryChanged), this); - m_pGrid = elm_grid_add(*this); + m_pGrid = elm_grid_add(*this); - m_pList = new ListView(m_pGrid); - m_pList->setMultiSelection(true); - m_pList->setMode(ELM_LIST_COMPRESS); - m_pList->setHomogeneous(true); - m_pList->setFocusAllow(false); - m_pList->addEventCb(EVAS_CALLBACK_CHANGED_SIZE_HINTS, EVAS_EVENT_CALLBACK(ConvContactListView, onGometryChanged), this); - m_pList->show(); - elm_scroller_content_min_limit(*m_pList, false, true); + m_pList = new ListView(m_pGrid); + m_pList->setMultiSelection(true); + m_pList->setMode(ELM_LIST_COMPRESS); + m_pList->setHomogeneous(true); + m_pList->setFocusAllow(false); + m_pList->addEventCb(EVAS_CALLBACK_CHANGED_SIZE_HINTS, EVAS_EVENT_CALLBACK(ConvContactListView, onGometryChanged), this); + m_pList->show(); + elm_scroller_content_min_limit(*m_pList, false, true); - elm_grid_pack(m_pGrid, *m_pList, 0, 0, 100, 100); - setContent(m_pGrid, "swl.contact_list"); + elm_grid_pack(m_pGrid, *m_pList, 0, 0, 100, 100); + setContent(m_pGrid, "swl.contact_list"); } ConvContactListView::~ConvContactListView() @@ -49,31 +49,31 @@ ConvContactListView::~ConvContactListView() ListView &ConvContactListView::getList() { - return *m_pList; + return *m_pList; } const ListView &ConvContactListView::getList() const { - return *m_pList; + return *m_pList; } void ConvContactListView::recalcGeometry() { - int maxHeight = 0; - int width = 0; - edje_object_part_geometry_get(getEdje(), "metric", nullptr, nullptr, &width, &maxHeight); + int maxHeight = 0; + int width = 0; + edje_object_part_geometry_get(getEdje(), "metric", nullptr, nullptr, &width, &maxHeight); - int h = 0; - evas_object_size_hint_min_get(*m_pList, nullptr, &h); + int h = 0; + evas_object_size_hint_min_get(*m_pList, nullptr, &h); - if (h > maxHeight) - h = maxHeight; + if (h > maxHeight) + h = maxHeight; - evas_object_size_hint_min_set(m_pGrid, width, h); + evas_object_size_hint_min_set(m_pGrid, width, h); } void ConvContactListView::onGometryChanged(Evas_Object *obj, void *eventInfo) { - recalcGeometry(); + recalcGeometry(); } diff --git a/src/Conversation/ConvList/Controller/inc/BubbleAudioEntity.h b/src/Conversation/ConvList/Controller/inc/BubbleAudioEntity.h index b2a247bf..f47f19b7 100644 --- a/src/Conversation/ConvList/Controller/inc/BubbleAudioEntity.h +++ b/src/Conversation/ConvList/Controller/inc/BubbleAudioEntity.h @@ -21,18 +21,18 @@ #include "BubbleBgEntity.h" namespace Msg { - class BubbleAudioEntity - : public BubbleBgEntity { - public: - BubbleAudioEntity(const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction); - virtual ~BubbleAudioEntity(); + class BubbleAudioEntity + : public BubbleBgEntity { + public: + BubbleAudioEntity(const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction); + virtual ~BubbleAudioEntity(); - virtual BubbleAudioViewItem *createView(Evas_Object *parent); + virtual BubbleAudioViewItem *createView(Evas_Object *parent); - private: - const std::string m_FileName; - const std::string m_Duration; - }; + private: + const std::string m_FileName; + const std::string m_Duration; + }; } #endif /* BubbleAudioEntity_h_ */ diff --git a/src/Conversation/ConvList/Controller/inc/BubbleBgEntity.h b/src/Conversation/ConvList/Controller/inc/BubbleBgEntity.h index 48e9a187..0596a21f 100644 --- a/src/Conversation/ConvList/Controller/inc/BubbleBgEntity.h +++ b/src/Conversation/ConvList/Controller/inc/BubbleBgEntity.h @@ -21,32 +21,32 @@ #include "BubbleBgViewItem.h" namespace Msg { - class BubbleBgEntity - : public BubbleEntity { - public: - BubbleBgEntity(Type type, BubbleBgViewItem::BgType bgType, Message::Direction direction, const std::string &filePath = ""); - virtual ~BubbleBgEntity(); - - void setBgType(BubbleBgViewItem::BgType type); - - protected: - BubbleBgViewItem::BgType m_BgType; - }; - - inline BubbleBgEntity::BubbleBgEntity(Type type, BubbleBgViewItem::BgType bgType, Message::Direction direction, const std::string &filePath) - : BubbleEntity(type, direction, filePath) - , m_BgType(bgType) - { - } - - inline BubbleBgEntity::~BubbleBgEntity() - { - } - - inline void BubbleBgEntity::setBgType(BubbleBgViewItem::BgType type) - { - m_BgType = type; - } + class BubbleBgEntity + : public BubbleEntity { + public: + BubbleBgEntity(Type type, BubbleBgViewItem::BgType bgType, Message::Direction direction, const std::string &filePath = ""); + virtual ~BubbleBgEntity(); + + void setBgType(BubbleBgViewItem::BgType type); + + protected: + BubbleBgViewItem::BgType m_BgType; + }; + + inline BubbleBgEntity::BubbleBgEntity(Type type, BubbleBgViewItem::BgType bgType, Message::Direction direction, const std::string &filePath) + : BubbleEntity(type, direction, filePath) + , m_BgType(bgType) + { + } + + inline BubbleBgEntity::~BubbleBgEntity() + { + } + + inline void BubbleBgEntity::setBgType(BubbleBgViewItem::BgType type) + { + m_BgType = type; + } } #endif /* BubbleBgEntity_h_ */ diff --git a/src/Conversation/ConvList/Controller/inc/BubbleCalEventEntity.h b/src/Conversation/ConvList/Controller/inc/BubbleCalEventEntity.h index 50b5d973..9526656a 100644 --- a/src/Conversation/ConvList/Controller/inc/BubbleCalEventEntity.h +++ b/src/Conversation/ConvList/Controller/inc/BubbleCalEventEntity.h @@ -21,18 +21,18 @@ #include "BubbleBgEntity.h" namespace Msg { - class BubbleCalEventEntity - : public BubbleBgEntity { - public: - BubbleCalEventEntity(const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction); - virtual ~BubbleCalEventEntity(); + class BubbleCalEventEntity + : public BubbleBgEntity { + public: + BubbleCalEventEntity(const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction); + virtual ~BubbleCalEventEntity(); - virtual BubbleCalEventViewItem *createView(Evas_Object *parent); + virtual BubbleCalEventViewItem *createView(Evas_Object *parent); - private: - std::string m_Name; - std::string m_DateTime; - }; + private: + std::string m_Name; + std::string m_DateTime; + }; } #endif /* BubbleCalEventEntity_h_ */ diff --git a/src/Conversation/ConvList/Controller/inc/BubbleContactEntity.h b/src/Conversation/ConvList/Controller/inc/BubbleContactEntity.h index b630225e..1df1f9d7 100644 --- a/src/Conversation/ConvList/Controller/inc/BubbleContactEntity.h +++ b/src/Conversation/ConvList/Controller/inc/BubbleContactEntity.h @@ -23,21 +23,21 @@ #include "Contact.h" namespace Msg { - class BubbleContactEntity - : public BubbleBgEntity { - public: - BubbleContactEntity(App &app, const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction); - virtual ~BubbleContactEntity(); + class BubbleContactEntity + : public BubbleBgEntity { + public: + BubbleContactEntity(App &app, const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction); + virtual ~BubbleContactEntity(); - virtual BubbleContactViewItem *createView(Evas_Object *parent); + virtual BubbleContactViewItem *createView(Evas_Object *parent); - private: - ThumbnailMaker &m_ThumbMaker; - std::string m_Name; - std::string m_Address; - std::string m_ThumbPath; - ContactRef m_Contact; // Thumbnail file holder - }; + private: + ThumbnailMaker &m_ThumbMaker; + std::string m_Name; + std::string m_Address; + std::string m_ThumbPath; + ContactRef m_Contact; // Thumbnail file holder + }; } #endif /* BubbleContactEntity_h_ */ diff --git a/src/Conversation/ConvList/Controller/inc/BubbleDownloadButtonEntity.h b/src/Conversation/ConvList/Controller/inc/BubbleDownloadButtonEntity.h index 22b5d4d5..1cb7d20b 100644 --- a/src/Conversation/ConvList/Controller/inc/BubbleDownloadButtonEntity.h +++ b/src/Conversation/ConvList/Controller/inc/BubbleDownloadButtonEntity.h @@ -21,40 +21,40 @@ #include "BubbleEntity.h" namespace Msg { - class BubbleDownloadButtonEntity - : public BubbleEntity { - public: - BubbleDownloadButtonEntity(); - virtual ~BubbleDownloadButtonEntity(); - - void disabled(bool status); - virtual BubbleDownloadButtonViewItem *createView(Evas_Object *parent); - - private: - bool m_Disabled; - }; - - inline BubbleDownloadButtonEntity::BubbleDownloadButtonEntity() - : BubbleEntity(DownloadButtonItem, Message::MD_Received) - , m_Disabled(false) - { - } - - inline BubbleDownloadButtonEntity::~BubbleDownloadButtonEntity() - { - } - - inline BubbleDownloadButtonViewItem *BubbleDownloadButtonEntity::createView(Evas_Object *parent) - { - auto *item = new BubbleDownloadButtonViewItem(*this, parent); - item->disabled(m_Disabled); - return item; - } - - inline void BubbleDownloadButtonEntity::disabled(bool status) - { - m_Disabled = status; - } + class BubbleDownloadButtonEntity + : public BubbleEntity { + public: + BubbleDownloadButtonEntity(); + virtual ~BubbleDownloadButtonEntity(); + + void disabled(bool status); + virtual BubbleDownloadButtonViewItem *createView(Evas_Object *parent); + + private: + bool m_Disabled; + }; + + inline BubbleDownloadButtonEntity::BubbleDownloadButtonEntity() + : BubbleEntity(DownloadButtonItem, Message::MD_Received) + , m_Disabled(false) + { + } + + inline BubbleDownloadButtonEntity::~BubbleDownloadButtonEntity() + { + } + + inline BubbleDownloadButtonViewItem *BubbleDownloadButtonEntity::createView(Evas_Object *parent) + { + auto *item = new BubbleDownloadButtonViewItem(*this, parent); + item->disabled(m_Disabled); + return item; + } + + inline void BubbleDownloadButtonEntity::disabled(bool status) + { + m_Disabled = status; + } } #endif /* BubbleDownloadButtonEntity_h_ */ diff --git a/src/Conversation/ConvList/Controller/inc/BubbleEntity.h b/src/Conversation/ConvList/Controller/inc/BubbleEntity.h index c96831d5..ab48fc56 100644 --- a/src/Conversation/ConvList/Controller/inc/BubbleEntity.h +++ b/src/Conversation/ConvList/Controller/inc/BubbleEntity.h @@ -26,73 +26,73 @@ #include namespace Msg { - class BubbleEntity { - public: - enum Type { - TextItem, - ImageItem, - AudioItem, - VideoItem, - ContactItem, - CalendarEventItem, - UnknownFileItem, - DownloadButtonItem - }; - - public: - BubbleEntity(Type type, Message::Direction direction, const std::string &filePath = ""); - virtual ~BubbleEntity(); - - Type getType() const; - Message::Direction getDirection() const; - const std::string &getFilePath() const; - void setFilePath(std::string file); - long long getFileSize() const; - virtual BubbleViewItem *createView(Evas_Object *parent) = 0; - - private: - Type m_Type; - Message::Direction m_Direction; - std::string m_FilePath; - long long m_FileSize; - }; - - inline BubbleEntity::BubbleEntity(Type type, Message::Direction direction, const std::string &filePath) - : m_Type(type) - , m_Direction(direction) - , m_FilePath(filePath) - , m_FileSize(!filePath.empty() ? FileUtils::getFileSize(filePath) : 0) - { - } - - inline BubbleEntity::~BubbleEntity() - { - } - - inline BubbleEntity::Type BubbleEntity::getType() const - { - return m_Type; - } - - inline Message::Direction BubbleEntity::getDirection() const - { - return m_Direction; - } - - inline const std::string &BubbleEntity::getFilePath() const - { - return m_FilePath; - } - - inline void BubbleEntity::setFilePath(std::string file) - { - m_FilePath = std::move(file); - } - - inline long long BubbleEntity::getFileSize() const - { - return m_FileSize; - } + class BubbleEntity { + public: + enum Type { + TextItem, + ImageItem, + AudioItem, + VideoItem, + ContactItem, + CalendarEventItem, + UnknownFileItem, + DownloadButtonItem + }; + + public: + BubbleEntity(Type type, Message::Direction direction, const std::string &filePath = ""); + virtual ~BubbleEntity(); + + Type getType() const; + Message::Direction getDirection() const; + const std::string &getFilePath() const; + void setFilePath(std::string file); + long long getFileSize() const; + virtual BubbleViewItem *createView(Evas_Object *parent) = 0; + + private: + Type m_Type; + Message::Direction m_Direction; + std::string m_FilePath; + long long m_FileSize; + }; + + inline BubbleEntity::BubbleEntity(Type type, Message::Direction direction, const std::string &filePath) + : m_Type(type) + , m_Direction(direction) + , m_FilePath(filePath) + , m_FileSize(!filePath.empty() ? FileUtils::getFileSize(filePath) : 0) + { + } + + inline BubbleEntity::~BubbleEntity() + { + } + + inline BubbleEntity::Type BubbleEntity::getType() const + { + return m_Type; + } + + inline Message::Direction BubbleEntity::getDirection() const + { + return m_Direction; + } + + inline const std::string &BubbleEntity::getFilePath() const + { + return m_FilePath; + } + + inline void BubbleEntity::setFilePath(std::string file) + { + m_FilePath = std::move(file); + } + + inline long long BubbleEntity::getFileSize() const + { + return m_FileSize; + } } diff --git a/src/Conversation/ConvList/Controller/inc/BubbleEntityFactory.h b/src/Conversation/ConvList/Controller/inc/BubbleEntityFactory.h index 77f6ab13..775a661b 100644 --- a/src/Conversation/ConvList/Controller/inc/BubbleEntityFactory.h +++ b/src/Conversation/ConvList/Controller/inc/BubbleEntityFactory.h @@ -34,27 +34,27 @@ #include namespace Msg { - class BubbleEntityFactory { - public: - BubbleEntityFactory(App &app, WorkingDirRef workingDir); - ~BubbleEntityFactory(); - - BubbleEntity *createEntity(const std::string &filePath, BubbleBgViewItem::BgType bgType, Message::Direction direction); - BubbleEntity *createEntity(const MsgConvMedia &msgMedia, BubbleBgViewItem::BgType bgType, Message::Direction direction); - BubbleTextEntity *createTextEntity(std::string text, BubbleBgViewItem::BgType bgType, Message::Direction direction); - BubbleDownloadButtonEntity *createDownloadButtonEntity(); - - private: - BubbleEntity *createEntity(const std::string &filePath, const std::string &fileName, std::string mime, BubbleBgViewItem::BgType bgType, Message::Direction direction); - BubbleEntity *createVideoEntity(const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction); - BubbleEntity *createAudioEntity(const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction); - BubbleEntityFactory(BubbleEntityFactory&) = delete; - BubbleEntityFactory& operator=(const BubbleEntityFactory&) = delete; - - private: - App &m_App; - WorkingDirRef m_WorkingDir; - }; + class BubbleEntityFactory { + public: + BubbleEntityFactory(App &app, WorkingDirRef workingDir); + ~BubbleEntityFactory(); + + BubbleEntity *createEntity(const std::string &filePath, BubbleBgViewItem::BgType bgType, Message::Direction direction); + BubbleEntity *createEntity(const MsgConvMedia &msgMedia, BubbleBgViewItem::BgType bgType, Message::Direction direction); + BubbleTextEntity *createTextEntity(std::string text, BubbleBgViewItem::BgType bgType, Message::Direction direction); + BubbleDownloadButtonEntity *createDownloadButtonEntity(); + + private: + BubbleEntity *createEntity(const std::string &filePath, const std::string &fileName, std::string mime, BubbleBgViewItem::BgType bgType, Message::Direction direction); + BubbleEntity *createVideoEntity(const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction); + BubbleEntity *createAudioEntity(const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction); + BubbleEntityFactory(BubbleEntityFactory&) = delete; + BubbleEntityFactory& operator=(const BubbleEntityFactory&) = delete; + + private: + App &m_App; + WorkingDirRef m_WorkingDir; + }; } #endif /* BubbleEntityFactory_h_ */ diff --git a/src/Conversation/ConvList/Controller/inc/BubbleImageEntity.h b/src/Conversation/ConvList/Controller/inc/BubbleImageEntity.h index 2bed0752..10729f32 100644 --- a/src/Conversation/ConvList/Controller/inc/BubbleImageEntity.h +++ b/src/Conversation/ConvList/Controller/inc/BubbleImageEntity.h @@ -21,30 +21,30 @@ #include "BubbleEntity.h" namespace Msg { - class BubbleImageEntity - : public BubbleEntity { - public: - BubbleImageEntity(const std::string &filePath, Message::Direction direction); - virtual ~BubbleImageEntity(); - - virtual BubbleImageViewItem *createView(Evas_Object *parent); - }; - - - inline BubbleImageEntity::BubbleImageEntity(const std::string &filePath, Message::Direction direction) - : BubbleEntity(ImageItem, direction, filePath) - { - } - - inline BubbleImageEntity::~BubbleImageEntity() - { - } - - inline BubbleImageViewItem *BubbleImageEntity::createView(Evas_Object *parent) - { - auto *item = new BubbleImageViewItem(*this, parent, getFilePath()); - return item; - } + class BubbleImageEntity + : public BubbleEntity { + public: + BubbleImageEntity(const std::string &filePath, Message::Direction direction); + virtual ~BubbleImageEntity(); + + virtual BubbleImageViewItem *createView(Evas_Object *parent); + }; + + + inline BubbleImageEntity::BubbleImageEntity(const std::string &filePath, Message::Direction direction) + : BubbleEntity(ImageItem, direction, filePath) + { + } + + inline BubbleImageEntity::~BubbleImageEntity() + { + } + + inline BubbleImageViewItem *BubbleImageEntity::createView(Evas_Object *parent) + { + auto *item = new BubbleImageViewItem(*this, parent, getFilePath()); + return item; + } } #endif /* BubbleImageEntity_h_ */ diff --git a/src/Conversation/ConvList/Controller/inc/BubbleTextEntity.h b/src/Conversation/ConvList/Controller/inc/BubbleTextEntity.h index 9ab9ddd3..76ea18b3 100644 --- a/src/Conversation/ConvList/Controller/inc/BubbleTextEntity.h +++ b/src/Conversation/ConvList/Controller/inc/BubbleTextEntity.h @@ -21,33 +21,33 @@ #include "BubbleBgEntity.h" namespace Msg { - class BubbleTextEntity - : public BubbleBgEntity { - public: - BubbleTextEntity(BubbleBgViewItem::BgType type, Message::Direction direction, std::string text); - virtual ~BubbleTextEntity(); - - virtual BubbleTextViewItem *createView(Evas_Object *parent); - - private: - std::string m_Text; - }; - - inline BubbleTextEntity::BubbleTextEntity(BubbleBgViewItem::BgType type, Message::Direction direction, std::string text) - : BubbleBgEntity(TextItem, type, direction) - , m_Text(std::move(text)) - { - } - - inline BubbleTextEntity::~BubbleTextEntity() - { - } - - inline BubbleTextViewItem *BubbleTextEntity::createView(Evas_Object *parent) - { - auto *item = new BubbleTextViewItem(*this, parent, m_BgType, m_Text); - return item; - } + class BubbleTextEntity + : public BubbleBgEntity { + public: + BubbleTextEntity(BubbleBgViewItem::BgType type, Message::Direction direction, std::string text); + virtual ~BubbleTextEntity(); + + virtual BubbleTextViewItem *createView(Evas_Object *parent); + + private: + std::string m_Text; + }; + + inline BubbleTextEntity::BubbleTextEntity(BubbleBgViewItem::BgType type, Message::Direction direction, std::string text) + : BubbleBgEntity(TextItem, type, direction) + , m_Text(std::move(text)) + { + } + + inline BubbleTextEntity::~BubbleTextEntity() + { + } + + inline BubbleTextViewItem *BubbleTextEntity::createView(Evas_Object *parent) + { + auto *item = new BubbleTextViewItem(*this, parent, m_BgType, m_Text); + return item; + } } #endif /* BubbleTextEntity_h_ */ diff --git a/src/Conversation/ConvList/Controller/inc/BubbleUnknownFileEntity.h b/src/Conversation/ConvList/Controller/inc/BubbleUnknownFileEntity.h index 9d6e928c..803e5de1 100644 --- a/src/Conversation/ConvList/Controller/inc/BubbleUnknownFileEntity.h +++ b/src/Conversation/ConvList/Controller/inc/BubbleUnknownFileEntity.h @@ -21,17 +21,17 @@ #include "BubbleBgEntity.h" namespace Msg { - class BubbleUnknownFileEntity - : public BubbleBgEntity { - public: - BubbleUnknownFileEntity(const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction); - virtual ~BubbleUnknownFileEntity(); + class BubbleUnknownFileEntity + : public BubbleBgEntity { + public: + BubbleUnknownFileEntity(const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction); + virtual ~BubbleUnknownFileEntity(); - virtual BubbleUnknownFileViewItem *createView(Evas_Object *parent); + virtual BubbleUnknownFileViewItem *createView(Evas_Object *parent); - private: - const std::string m_FileName; - }; + private: + const std::string m_FileName; + }; } #endif /* BubbleUnknownFileEntity_h_ */ diff --git a/src/Conversation/ConvList/Controller/inc/BubbleVideoEntity.h b/src/Conversation/ConvList/Controller/inc/BubbleVideoEntity.h index 1f8ca3cf..34f98dfc 100644 --- a/src/Conversation/ConvList/Controller/inc/BubbleVideoEntity.h +++ b/src/Conversation/ConvList/Controller/inc/BubbleVideoEntity.h @@ -22,18 +22,18 @@ #include "WorkingDir.h" namespace Msg { - class BubbleVideoEntity - : public BubbleEntity { - public: - BubbleVideoEntity(WorkingDirRef workingDir, const std::string &filePath, Message::Direction direction); - virtual ~BubbleVideoEntity(); + class BubbleVideoEntity + : public BubbleEntity { + public: + BubbleVideoEntity(WorkingDirRef workingDir, const std::string &filePath, Message::Direction direction); + virtual ~BubbleVideoEntity(); - virtual BubbleVideoViewItem *createView(Evas_Object *parent); + virtual BubbleVideoViewItem *createView(Evas_Object *parent); - private: - std::string m_ImgPath; - WorkingDirRef m_WorkingDir; - }; + private: + std::string m_ImgPath; + WorkingDirRef m_WorkingDir; + }; } #endif /* BubbleVideoEntity_h_ */ diff --git a/src/Conversation/ConvList/Controller/inc/ComposeListItem.h b/src/Conversation/ConvList/Controller/inc/ComposeListItem.h index b86e08f2..5f875206 100644 --- a/src/Conversation/ConvList/Controller/inc/ComposeListItem.h +++ b/src/Conversation/ConvList/Controller/inc/ComposeListItem.h @@ -23,47 +23,47 @@ #include namespace Msg { - class IComposeListItemListener; - class FileViewer; - typedef std::list BubbleEntityList; + class IComposeListItemListener; + class FileViewer; + typedef std::list BubbleEntityList; - class ComposeListItem - : public ComposeListViewItem - , private IBubbleViewItemListener { - public: - ComposeListItem(BubbleEntityFactory &entityFactory, FileViewer &fileViewer); - virtual ~ComposeListItem(); + class ComposeListItem + : public ComposeListViewItem + , private IBubbleViewItemListener { + public: + ComposeListItem(BubbleEntityFactory &entityFactory, FileViewer &fileViewer); + virtual ~ComposeListItem(); - void clear(bool updateUi = true); - void addAttachment(const std::string &filePath); - const BubbleEntityList &getAttachments() const; - bool isEmpty() const; - void setListener(IComposeListItemListener *l); - IComposeListItemListener *getListener() const; + void clear(bool updateUi = true); + void addAttachment(const std::string &filePath); + const BubbleEntityList &getAttachments() const; + bool isEmpty() const; + void setListener(IComposeListItemListener *l); + IComposeListItemListener *getListener() const; - protected: - virtual Evas_Object *getBubbleContent(); + protected: + virtual Evas_Object *getBubbleContent(); - private: - // IBubbleViewItemListener: - virtual void onAction(BubbleViewItem &item); - virtual void onDelClicked(BubbleViewItem &item); + private: + // IBubbleViewItemListener: + virtual void onAction(BubbleViewItem &item); + virtual void onDelClicked(BubbleViewItem &item); - void deleteEntity(BubbleEntity &entity); + void deleteEntity(BubbleEntity &entity); - private: - IComposeListItemListener *m_pListener; - std::list m_BubbleEntityList; - BubbleEntityFactory &m_BubbleEntityFactory; - FileViewer &m_FileViewer; - }; + private: + IComposeListItemListener *m_pListener; + std::list m_BubbleEntityList; + BubbleEntityFactory &m_BubbleEntityFactory; + FileViewer &m_FileViewer; + }; - class IComposeListItemListener { - public: - virtual ~IComposeListItemListener() {} - virtual void onAttachmentAdded(const std::list &files) {}; - virtual void onAttachmentDeleted(const std::list &files) {}; - }; + class IComposeListItemListener { + public: + virtual ~IComposeListItemListener() {} + virtual void onAttachmentAdded(const std::list &files) {}; + virtual void onAttachmentDeleted(const std::list &files) {}; + }; } #endif /* ComposeListItem_H_ */ diff --git a/src/Conversation/ConvList/Controller/inc/ConvList.h b/src/Conversation/ConvList/Controller/inc/ConvList.h index cdc53c13..1fcf1129 100644 --- a/src/Conversation/ConvList/Controller/inc/ConvList.h +++ b/src/Conversation/ConvList/Controller/inc/ConvList.h @@ -34,197 +34,197 @@ #include namespace Msg { - class IConvListListener; - - class ConvList - : public ConvListLayout - , private IMsgStorageListener - , private IListViewListener - , private IConvListItemListener - , private IContactManagerListener - , private ISystemSettingsManager { - public: - enum Mode { - NormalMode, - SelectMode - }; - - public: - /** - * @brief Creates list with messages in thread - * @param[in] parent parent Evas_Object - * @param[in] App ref. to main application - * @param[in] Smart Ref to current working dir. - */ - ConvList(Evas_Object *parent, App &app, WorkingDirRef workingDir); - virtual ~ConvList(); - - /** - * @brief Sets listener - * @param[in] l IConvListListener pointer - */ - void setListener(IConvListListener *l); - - /** - * @brief Sets Conversation list mode - * @details Set SelectMode to show checkboxes. NormalMode to hide them. - * @param[in] mode enum Mode - */ - void setMode(Mode mode); - - /** - * @brief Gets current Conversation list mode - * @return Conversation list mode - */ - Mode getMode() const; - - /** - * @brief Sets thread id - * @param[in] thread id - */ - void setThreadId(ThreadId id, const char *searchWord = nullptr); - - /** - * @brief Gets thread id - * @return thread id - */ - ThreadId getThreadId() const; - - /** - * @brief Navigate to message - * @param[in] msgId message id to navigate - */ - void navigateTo(MsgId msgId); - - /** - * @brief Navigate to bottom - */ - void navigateToBottom(); - - /** - * @brief Deletes selected items in SelectMode - */ - void deleteSelectedItems(); - - /** - * @brief Delete items by MsgId list. - * @param[in] MsgId list. - * @return true if one or more items were removed. - */ - bool deleteItems(const MsgIdList &idList); - - /** - * @brief Get message count - * @return message count - */ - int getMessageCount() const; - - /** - * @brief Get checked message count - * @return message count - */ - int getMessageCheckedCount() const; - - /** - * @brief Get compose item - * @return compose item - */ - ComposeListItem &getComposeItem(); - - /** - * @brief Get conversation(ConvListItem type) items - * @return conversation items. - */ - std::vector getConvItems() const; - - void setBodyFocusCb(std::function bodyFocusFunc); - - private: - typedef std::unordered_map ConvListItemMap; - typedef std::unordered_set DateLineItemSet; - - private: - void create(Evas_Object *parent); - Evas_Object *createSelectAll(Evas_Object *parent); - Evas_Object *createList(Evas_Object *parent); - void fill(); - void selectListItems(bool state); - void updateSelectAllItem(); - ConvListItem *getItem(MsgId msgId) const; - void insertItem(const MsgConversationItem &item); - void insertItem(ConvListItem *item); - void deleteItem(ConvListItem *item); - void demoteItem(ConvListItem *item); //move down existing item - void clear(); - void dateLineDelIfNec(ConvListItem *item); - void dateLineAddIfNec(ConvListItem *item); - - void updateRecipThumbId(); - - // IListViewListener: - virtual void onListItemLongPressed(ListItem &listItem); - virtual void onListItemChecked(ListItem &listItem); - - // List callback - void onListResized(Evas_Object *obj, void *eventInfo); - - // IMsgStorageListener: - virtual void onMsgStorageUpdate(const MsgIdList &msgIdList); - virtual void onMsgStorageInsert(const MsgIdList &msgIdList); - virtual void onMsgStorageDelete(const MsgIdList &msgIdList); - virtual void onMsgStorageContact(const MsgIdList &msgIdList) {}; - - // IConvListItemListener: - virtual void onEditDraftMsg(ConvListItem &item); - virtual void onForwardMsg(ConvListItem &item); - virtual void onResendMsg(ConvListItem &item); - virtual void onSlideShow(ConvListItem &item); - virtual void onSaveAttachments(ConvListItem &item); - - // IContactManagerListener: - virtual void onContactChanged(); - - // SelectAll callback: - void onSelectAllChanged(Evas_Object *obj, void *eventInfo); - - // ISystemSettingsManager: - virtual void onTimeFormatChanged(); - virtual void onLanguageChanged(); - - private: - Mode m_Mode; - MsgEngine &m_MsgEngine; - ThreadId m_ThreadId; - ConvSelectAll *m_pSelectAll; - ListView *m_pList; - ConvListItemMap m_ConvListItemMap; - DateLineItemSet m_DateLineItemSet; - IConvListListener *m_pListener; - App &m_App; - ThumbId m_RecipThumbId; - std::string m_SearchWord; - BubbleEntityFactory m_BubbleEntityFactory; - ComposeListItem *m_pComposeItem; - std::function m_BodyFocusFunc; - FileViewer m_FileViewer; - Share m_Share; - }; - - class IConvListListener { - public: - virtual ~IConvListListener() {}; - - /** - * @brief called when all messages has been deleted from current thread - */ - virtual void onAllConvItemsDeleted(ConvList &list) {}; - virtual void onSlideShow(MsgId id) {}; - virtual void onEditDraftMsg(MsgId id) {}; - virtual void onForwardMsg(MsgId id) {}; - virtual void onSaveAttachments(MsgId id) {}; - virtual void onConvListItemChecked() {}; - virtual void onResendMsg(MsgId id) {}; - }; + class IConvListListener; + + class ConvList + : public ConvListLayout + , private IMsgStorageListener + , private IListViewListener + , private IConvListItemListener + , private IContactManagerListener + , private ISystemSettingsManager { + public: + enum Mode { + NormalMode, + SelectMode + }; + + public: + /** + * @brief Creates list with messages in thread + * @param[in] parent parent Evas_Object + * @param[in] App ref. to main application + * @param[in] Smart Ref to current working dir. + */ + ConvList(Evas_Object *parent, App &app, WorkingDirRef workingDir); + virtual ~ConvList(); + + /** + * @brief Sets listener + * @param[in] l IConvListListener pointer + */ + void setListener(IConvListListener *l); + + /** + * @brief Sets Conversation list mode + * @details Set SelectMode to show checkboxes. NormalMode to hide them. + * @param[in] mode enum Mode + */ + void setMode(Mode mode); + + /** + * @brief Gets current Conversation list mode + * @return Conversation list mode + */ + Mode getMode() const; + + /** + * @brief Sets thread id + * @param[in] thread id + */ + void setThreadId(ThreadId id, const char *searchWord = nullptr); + + /** + * @brief Gets thread id + * @return thread id + */ + ThreadId getThreadId() const; + + /** + * @brief Navigate to message + * @param[in] msgId message id to navigate + */ + void navigateTo(MsgId msgId); + + /** + * @brief Navigate to bottom + */ + void navigateToBottom(); + + /** + * @brief Deletes selected items in SelectMode + */ + void deleteSelectedItems(); + + /** + * @brief Delete items by MsgId list. + * @param[in] MsgId list. + * @return true if one or more items were removed. + */ + bool deleteItems(const MsgIdList &idList); + + /** + * @brief Get message count + * @return message count + */ + int getMessageCount() const; + + /** + * @brief Get checked message count + * @return message count + */ + int getMessageCheckedCount() const; + + /** + * @brief Get compose item + * @return compose item + */ + ComposeListItem &getComposeItem(); + + /** + * @brief Get conversation(ConvListItem type) items + * @return conversation items. + */ + std::vector getConvItems() const; + + void setBodyFocusCb(std::function bodyFocusFunc); + + private: + typedef std::unordered_map ConvListItemMap; + typedef std::unordered_set DateLineItemSet; + + private: + void create(Evas_Object *parent); + Evas_Object *createSelectAll(Evas_Object *parent); + Evas_Object *createList(Evas_Object *parent); + void fill(); + void selectListItems(bool state); + void updateSelectAllItem(); + ConvListItem *getItem(MsgId msgId) const; + void insertItem(const MsgConversationItem &item); + void insertItem(ConvListItem *item); + void deleteItem(ConvListItem *item); + void demoteItem(ConvListItem *item); //move down existing item + void clear(); + void dateLineDelIfNec(ConvListItem *item); + void dateLineAddIfNec(ConvListItem *item); + + void updateRecipThumbId(); + + // IListViewListener: + virtual void onListItemLongPressed(ListItem &listItem); + virtual void onListItemChecked(ListItem &listItem); + + // List callback + void onListResized(Evas_Object *obj, void *eventInfo); + + // IMsgStorageListener: + virtual void onMsgStorageUpdate(const MsgIdList &msgIdList); + virtual void onMsgStorageInsert(const MsgIdList &msgIdList); + virtual void onMsgStorageDelete(const MsgIdList &msgIdList); + virtual void onMsgStorageContact(const MsgIdList &msgIdList) {}; + + // IConvListItemListener: + virtual void onEditDraftMsg(ConvListItem &item); + virtual void onForwardMsg(ConvListItem &item); + virtual void onResendMsg(ConvListItem &item); + virtual void onSlideShow(ConvListItem &item); + virtual void onSaveAttachments(ConvListItem &item); + + // IContactManagerListener: + virtual void onContactChanged(); + + // SelectAll callback: + void onSelectAllChanged(Evas_Object *obj, void *eventInfo); + + // ISystemSettingsManager: + virtual void onTimeFormatChanged(); + virtual void onLanguageChanged(); + + private: + Mode m_Mode; + MsgEngine &m_MsgEngine; + ThreadId m_ThreadId; + ConvSelectAll *m_pSelectAll; + ListView *m_pList; + ConvListItemMap m_ConvListItemMap; + DateLineItemSet m_DateLineItemSet; + IConvListListener *m_pListener; + App &m_App; + ThumbId m_RecipThumbId; + std::string m_SearchWord; + BubbleEntityFactory m_BubbleEntityFactory; + ComposeListItem *m_pComposeItem; + std::function m_BodyFocusFunc; + FileViewer m_FileViewer; + Share m_Share; + }; + + class IConvListListener { + public: + virtual ~IConvListListener() {}; + + /** + * @brief called when all messages has been deleted from current thread + */ + virtual void onAllConvItemsDeleted(ConvList &list) {}; + virtual void onSlideShow(MsgId id) {}; + virtual void onEditDraftMsg(MsgId id) {}; + virtual void onForwardMsg(MsgId id) {}; + virtual void onSaveAttachments(MsgId id) {}; + virtual void onConvListItemChecked() {}; + virtual void onResendMsg(MsgId id) {}; + }; } #endif /* ConvList_h_ */ diff --git a/src/Conversation/ConvList/Controller/inc/ConvListItem.h b/src/Conversation/ConvList/Controller/inc/ConvListItem.h index 31a08404..6a5a270a 100644 --- a/src/Conversation/ConvList/Controller/inc/ConvListItem.h +++ b/src/Conversation/ConvList/Controller/inc/ConvListItem.h @@ -32,133 +32,133 @@ #include "BubbleEntityFactory.h" namespace Msg { - class MsgConversationItem; - class IConvListItemListener; - class FileViewer; - class Share; - - class ConvListItem - : public ConvListViewItem - , public IBubbleViewItemListener { - public: - /** - * @brief Creates item for Conversation list - * @param[in] item MsgConversationItem model - * @param[in] app Main application - * @param[in] file viewer. - * @param[in] data share. - * @param[in] bubbleEntityFactory Bubble entity factory. - * @param[in] searchWord string for search in bubble - * @param[in] thumbId Reference to id of user thumbnail - */ - ConvListItem(const MsgConversationItem &item, - App &app, - FileViewer &fileViewer, - Share &share, - BubbleEntityFactory &bubbleEntityFactory, - const std::string &searchWord, - const ThumbId &thumbId = invalidThumbId); - - virtual ~ConvListItem(); - - /** - * @brief Returns MsgId related to this ConvListItem - */ - MsgId getMsgId() const; - - /** - * @brief Returns message's time - */ - time_t getRawTime() const; - void showPopup(); - void setListener(IConvListItemListener *l); - - void update(); - void updateTime(); - bool isNeededReadReport() const; - - protected: - // ConvListViewItem: - virtual Evas_Object *getBubbleContent(); - virtual Evas_Object *getThumbnail(); - virtual Evas_Object *getProgress(); - virtual std::string getTime(); - virtual std::string getMsgType(); - - virtual void onEditButtonClicked(Evas_Object *obj, void *event_info); - virtual void onFailedButtonClicked(Evas_Object *obj, void *event_info); - - private: - ConvListViewItem::ConvItemType getConvItemType(const MsgConversationItem &item); - void update(const MsgConversationItem &item); - BubbleTextEntity *createTextEntity(BubbleBgViewItem::BgType bgType, const MsgConvMedia &media, std::string searchWord); - BubbleTextEntity *createTextEntity(BubbleBgViewItem::BgType bgType, std::string text, bool markup, std::string searchWord); - void addEntity(BubbleEntity *entity); - void updateEntityBgType(BubbleBgViewItem::BgType bgType); - BubbleBgViewItem::BgType getBubbleBgType(const MsgConversationItem &item); - void tryToDownloadMms(bool showToast = true); - void updateDownloadButton(); - void convertNotiToMms(); - BubbleDownloadButtonEntity *findDownloadButton() const; - void shareContent(); - void copyMsgToSimCard(); - void clearEntityList(); - - // Create Popup when message is clicked - void showMainListPopup(); - void showDraftListPopup(); - void onDownloadItemPressed(PopupListItem &item); - void onDeleteItemPressed(PopupListItem &item); - void onCopyTextItemPressed(PopupListItem &item); - void onForwardItemPressed(PopupListItem &item); - void onShareItemPressed(PopupListItem &item); - void onResendItemPressed(PopupListItem &item); - void onSlideShowItemPressed(PopupListItem &item); - void onEditItemPressed(PopupListItem &item); - void onSaveAttachmentsItemPressed(PopupListItem &item); - void onCopyToSimCardItemPressed(PopupListItem &item); - void onViewDetailsItemPressed(PopupListItem &item); - std::string getAllMsgText() const; - - // Create popup when failed button is clicked - void showFailedToSendPopup(); - void onCancelButtonClicked(Popup &popup, int buttonId); - void onFailedResendButtonClicked(Popup &popup, int buttonId); - void onDeleteButtonClicked(Popup &popup, int buttonId); - - // IBubbleViewItemListener - virtual void onAction(BubbleViewItem &item); - - private: - IConvListItemListener *m_pListener; - App &m_App; - FileViewer &m_FileViewer; - Share &m_Share; - WorkingDirRef m_WorkingDir; - MsgId m_MsgId; - bool m_IsDraft; - Message::Direction m_Direction; - Message::NetworkStatus m_NetworkStatus; - Message::Type m_Type; - time_t m_Time; - std::string m_TimeStr; - std::list m_BubbleEntityList; - const ThumbId &m_ThumbId; - BubbleEntityFactory &m_BubbleEntityFactory; - bool m_IsRestrictedByDpm; - bool m_IsNeededReadReport; - const std::string m_SearchWord; - }; - - class IConvListItemListener { - public: - virtual ~IConvListItemListener() {} - virtual void onEditDraftMsg(ConvListItem &item) {}; - virtual void onForwardMsg(ConvListItem &item) {}; - virtual void onResendMsg(ConvListItem &item) {}; - virtual void onSlideShow(ConvListItem &item) {}; - virtual void onSaveAttachments(ConvListItem &item) {}; - }; + class MsgConversationItem; + class IConvListItemListener; + class FileViewer; + class Share; + + class ConvListItem + : public ConvListViewItem + , public IBubbleViewItemListener { + public: + /** + * @brief Creates item for Conversation list + * @param[in] item MsgConversationItem model + * @param[in] app Main application + * @param[in] file viewer. + * @param[in] data share. + * @param[in] bubbleEntityFactory Bubble entity factory. + * @param[in] searchWord string for search in bubble + * @param[in] thumbId Reference to id of user thumbnail + */ + ConvListItem(const MsgConversationItem &item, + App &app, + FileViewer &fileViewer, + Share &share, + BubbleEntityFactory &bubbleEntityFactory, + const std::string &searchWord, + const ThumbId &thumbId = invalidThumbId); + + virtual ~ConvListItem(); + + /** + * @brief Returns MsgId related to this ConvListItem + */ + MsgId getMsgId() const; + + /** + * @brief Returns message's time + */ + time_t getRawTime() const; + void showPopup(); + void setListener(IConvListItemListener *l); + + void update(); + void updateTime(); + bool isNeededReadReport() const; + + protected: + // ConvListViewItem: + virtual Evas_Object *getBubbleContent(); + virtual Evas_Object *getThumbnail(); + virtual Evas_Object *getProgress(); + virtual std::string getTime(); + virtual std::string getMsgType(); + + virtual void onEditButtonClicked(Evas_Object *obj, void *event_info); + virtual void onFailedButtonClicked(Evas_Object *obj, void *event_info); + + private: + ConvListViewItem::ConvItemType getConvItemType(const MsgConversationItem &item); + void update(const MsgConversationItem &item); + BubbleTextEntity *createTextEntity(BubbleBgViewItem::BgType bgType, const MsgConvMedia &media, std::string searchWord); + BubbleTextEntity *createTextEntity(BubbleBgViewItem::BgType bgType, std::string text, bool markup, std::string searchWord); + void addEntity(BubbleEntity *entity); + void updateEntityBgType(BubbleBgViewItem::BgType bgType); + BubbleBgViewItem::BgType getBubbleBgType(const MsgConversationItem &item); + void tryToDownloadMms(bool showToast = true); + void updateDownloadButton(); + void convertNotiToMms(); + BubbleDownloadButtonEntity *findDownloadButton() const; + void shareContent(); + void copyMsgToSimCard(); + void clearEntityList(); + + // Create Popup when message is clicked + void showMainListPopup(); + void showDraftListPopup(); + void onDownloadItemPressed(PopupListItem &item); + void onDeleteItemPressed(PopupListItem &item); + void onCopyTextItemPressed(PopupListItem &item); + void onForwardItemPressed(PopupListItem &item); + void onShareItemPressed(PopupListItem &item); + void onResendItemPressed(PopupListItem &item); + void onSlideShowItemPressed(PopupListItem &item); + void onEditItemPressed(PopupListItem &item); + void onSaveAttachmentsItemPressed(PopupListItem &item); + void onCopyToSimCardItemPressed(PopupListItem &item); + void onViewDetailsItemPressed(PopupListItem &item); + std::string getAllMsgText() const; + + // Create popup when failed button is clicked + void showFailedToSendPopup(); + void onCancelButtonClicked(Popup &popup, int buttonId); + void onFailedResendButtonClicked(Popup &popup, int buttonId); + void onDeleteButtonClicked(Popup &popup, int buttonId); + + // IBubbleViewItemListener + virtual void onAction(BubbleViewItem &item); + + private: + IConvListItemListener *m_pListener; + App &m_App; + FileViewer &m_FileViewer; + Share &m_Share; + WorkingDirRef m_WorkingDir; + MsgId m_MsgId; + bool m_IsDraft; + Message::Direction m_Direction; + Message::NetworkStatus m_NetworkStatus; + Message::Type m_Type; + time_t m_Time; + std::string m_TimeStr; + std::list m_BubbleEntityList; + const ThumbId &m_ThumbId; + BubbleEntityFactory &m_BubbleEntityFactory; + bool m_IsRestrictedByDpm; + bool m_IsNeededReadReport; + const std::string m_SearchWord; + }; + + class IConvListItemListener { + public: + virtual ~IConvListItemListener() {} + virtual void onEditDraftMsg(ConvListItem &item) {}; + virtual void onForwardMsg(ConvListItem &item) {}; + virtual void onResendMsg(ConvListItem &item) {}; + virtual void onSlideShow(ConvListItem &item) {}; + virtual void onSaveAttachments(ConvListItem &item) {}; + }; } diff --git a/src/Conversation/ConvList/Controller/inc/DateLineItem.h b/src/Conversation/ConvList/Controller/inc/DateLineItem.h index 34af0109..beb75bd6 100644 --- a/src/Conversation/ConvList/Controller/inc/DateLineItem.h +++ b/src/Conversation/ConvList/Controller/inc/DateLineItem.h @@ -21,18 +21,18 @@ #include namespace Msg { - class DateLineItem - : public DateLineViewItem { - public: - DateLineItem(time_t dateTime); - DateLineItem(time_t dateTime, const std::string &dateTimeStr); - virtual ~DateLineItem(); + class DateLineItem + : public DateLineViewItem { + public: + DateLineItem(time_t dateTime); + DateLineItem(time_t dateTime, const std::string &dateTimeStr); + virtual ~DateLineItem(); - void update(); + void update(); - private: - time_t m_Time; - }; + private: + time_t m_Time; + }; } #endif /* DateLineItem_H_ */ diff --git a/src/Conversation/ConvList/Controller/inc/MsgDetailsPopup.h b/src/Conversation/ConvList/Controller/inc/MsgDetailsPopup.h index 5d18a886..8cdd1bed 100644 --- a/src/Conversation/ConvList/Controller/inc/MsgDetailsPopup.h +++ b/src/Conversation/ConvList/Controller/inc/MsgDetailsPopup.h @@ -24,28 +24,28 @@ #include "SystemSettingsManager.h" namespace Msg { - class MsgDetailsPopup - : public Popup - , private IContactManagerListener - , private ISystemSettingsManager { - public: - MsgDetailsPopup(PopupManager &mngr, App &app, MsgId msgId); - virtual ~MsgDetailsPopup(); - - private: - void updateContent(); - - // IContactManagerListener: - virtual void onContactChanged(); - - // ISystemSettingsManager: - virtual void onLanguageChanged(); - virtual void onTimeFormatChanged(); - - private: - App &m_App; - MsgId m_MsgId; - }; + class MsgDetailsPopup + : public Popup + , private IContactManagerListener + , private ISystemSettingsManager { + public: + MsgDetailsPopup(PopupManager &mngr, App &app, MsgId msgId); + virtual ~MsgDetailsPopup(); + + private: + void updateContent(); + + // IContactManagerListener: + virtual void onContactChanged(); + + // ISystemSettingsManager: + virtual void onLanguageChanged(); + virtual void onTimeFormatChanged(); + + private: + App &m_App; + MsgId m_MsgId; + }; } #endif /* MsgDetailsPopup_h_ */ diff --git a/src/Conversation/ConvList/Controller/src/BubbleAudioEntity.cpp b/src/Conversation/ConvList/Controller/src/BubbleAudioEntity.cpp index 72da641d..9e4a4757 100644 --- a/src/Conversation/ConvList/Controller/src/BubbleAudioEntity.cpp +++ b/src/Conversation/ConvList/Controller/src/BubbleAudioEntity.cpp @@ -26,19 +26,19 @@ using namespace Msg; std::string makeDurationStr(const std::string &filePath) { - int duration = MediaUtils::getDurationSec(filePath); - std::stringstream ss; - int h = duration / 60; - int m = duration % 60; - ss << std::setfill('0') << std::setw(2) << h << ':' - << std::setfill('0') << std::setw(2) << m; - return ss.str(); + int duration = MediaUtils::getDurationSec(filePath); + std::stringstream ss; + int h = duration / 60; + int m = duration % 60; + ss << std::setfill('0') << std::setw(2) << h << ':' + << std::setfill('0') << std::setw(2) << m; + return ss.str(); } BubbleAudioEntity::BubbleAudioEntity(const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction) - : BubbleBgEntity(AudioItem, bgType, direction, filePath) - , m_FileName(fileName) - , m_Duration(makeDurationStr(filePath)) + : BubbleBgEntity(AudioItem, bgType, direction, filePath) + , m_FileName(fileName) + , m_Duration(makeDurationStr(filePath)) { } @@ -48,10 +48,10 @@ BubbleAudioEntity::~BubbleAudioEntity() BubbleAudioViewItem *BubbleAudioEntity::createView(Evas_Object *parent) { - auto *item = new BubbleAudioViewItem(*this, parent, m_BgType); - item->setMainText(m_FileName); - item->setSubText(m_Duration); - return item; + auto *item = new BubbleAudioViewItem(*this, parent, m_BgType); + item->setMainText(m_FileName); + item->setSubText(m_Duration); + return item; } diff --git a/src/Conversation/ConvList/Controller/src/BubbleCalEventEntity.cpp b/src/Conversation/ConvList/Controller/src/BubbleCalEventEntity.cpp index 29b3bf52..247b4915 100644 --- a/src/Conversation/ConvList/Controller/src/BubbleCalEventEntity.cpp +++ b/src/Conversation/ConvList/Controller/src/BubbleCalEventEntity.cpp @@ -21,16 +21,16 @@ using namespace Msg; BubbleCalEventEntity::BubbleCalEventEntity(const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction) - : BubbleBgEntity(CalendarEventItem, bgType, direction, filePath) + : BubbleBgEntity(CalendarEventItem, bgType, direction, filePath) { - auto list = VCalendarParser::getInst().parse(filePath); - if (list.size() == 1) { - const CalendarEvent &event = list.front(); - m_Name = event.getSummary(); - m_DateTime = event.getStartDate(); - } else { - m_Name = fileName; - } + auto list = VCalendarParser::getInst().parse(filePath); + if (list.size() == 1) { + const CalendarEvent &event = list.front(); + m_Name = event.getSummary(); + m_DateTime = event.getStartDate(); + } else { + m_Name = fileName; + } } BubbleCalEventEntity::~BubbleCalEventEntity() @@ -39,11 +39,11 @@ BubbleCalEventEntity::~BubbleCalEventEntity() BubbleCalEventViewItem *BubbleCalEventEntity::createView(Evas_Object *parent) { - BubbleCalEventViewItem::LayoutType type = m_DateTime.empty() ? BubbleCalEventViewItem::Layout1Icon1Text : - BubbleCalEventViewItem::Layout1Icon2Text; - auto *item = new BubbleCalEventViewItem(*this, parent, m_BgType, type); - item->setMainText(m_Name); - if (!m_DateTime.empty()) - item->setSubText(m_DateTime); - return item; + BubbleCalEventViewItem::LayoutType type = m_DateTime.empty() ? BubbleCalEventViewItem::Layout1Icon1Text : + BubbleCalEventViewItem::Layout1Icon2Text; + auto *item = new BubbleCalEventViewItem(*this, parent, m_BgType, type); + item->setMainText(m_Name); + if (!m_DateTime.empty()) + item->setSubText(m_DateTime); + return item; } diff --git a/src/Conversation/ConvList/Controller/src/BubbleContactEntity.cpp b/src/Conversation/ConvList/Controller/src/BubbleContactEntity.cpp index 7fdcad8e..e7e5a49a 100644 --- a/src/Conversation/ConvList/Controller/src/BubbleContactEntity.cpp +++ b/src/Conversation/ConvList/Controller/src/BubbleContactEntity.cpp @@ -23,22 +23,22 @@ using namespace Msg; BubbleContactEntity::BubbleContactEntity(App &app, const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction) - : BubbleBgEntity(ContactItem, bgType, direction, filePath) - , m_ThumbMaker(app.getThumbnailMaker()) + : BubbleBgEntity(ContactItem, bgType, direction, filePath) + , m_ThumbMaker(app.getThumbnailMaker()) { - auto list = app.getContactManager().parseVcard(getFilePath()); - if (!list.empty()) { - if (list.size() == 1) { - m_Contact = list.front(); - if (m_Contact) { - m_Name = m_Contact->getDispName(); - m_Address = m_Contact->getAddress(); - m_ThumbPath = m_Contact->getThumb(); - } - } - } - if (!m_Contact) - m_Name = fileName; + auto list = app.getContactManager().parseVcard(getFilePath()); + if (!list.empty()) { + if (list.size() == 1) { + m_Contact = list.front(); + if (m_Contact) { + m_Name = m_Contact->getDispName(); + m_Address = m_Contact->getAddress(); + m_ThumbPath = m_Contact->getThumb(); + } + } + } + if (!m_Contact) + m_Name = fileName; } BubbleContactEntity::~BubbleContactEntity() @@ -47,16 +47,16 @@ BubbleContactEntity::~BubbleContactEntity() BubbleContactViewItem *BubbleContactEntity::createView(Evas_Object *parent) { - BubbleContactViewItem::LayoutType type = m_Address.empty() ? BubbleContactViewItem::Layout1Icon1Text : - BubbleContactViewItem::Layout1Icon2Text; - auto *item = new BubbleContactViewItem(*this, parent, m_BgType, type); - item->setMainText(m_Name); + BubbleContactViewItem::LayoutType type = m_Address.empty() ? BubbleContactViewItem::Layout1Icon1Text : + BubbleContactViewItem::Layout1Icon2Text; + auto *item = new BubbleContactViewItem(*this, parent, m_BgType, type); + item->setMainText(m_Name); - Evas_Object *thumb = m_ThumbPath.empty() ? item->createIcon(ATTACH_CONTACT_ICON) - : m_ThumbMaker.getThumb(*item, m_ThumbPath, BubbleContactViewItem::iconSize); - if (thumb) - item->setIcon(thumb); - if (!m_Address.empty()) - item->setSubText(m_Address); - return item; + Evas_Object *thumb = m_ThumbPath.empty() ? item->createIcon(ATTACH_CONTACT_ICON) + : m_ThumbMaker.getThumb(*item, m_ThumbPath, BubbleContactViewItem::iconSize); + if (thumb) + item->setIcon(thumb); + if (!m_Address.empty()) + item->setSubText(m_Address); + return item; } diff --git a/src/Conversation/ConvList/Controller/src/BubbleEntityFactory.cpp b/src/Conversation/ConvList/Controller/src/BubbleEntityFactory.cpp index 6b37e8ea..4882a5a9 100644 --- a/src/Conversation/ConvList/Controller/src/BubbleEntityFactory.cpp +++ b/src/Conversation/ConvList/Controller/src/BubbleEntityFactory.cpp @@ -34,8 +34,8 @@ using namespace Msg; BubbleEntityFactory::BubbleEntityFactory(App &app, WorkingDirRef workingDir) - : m_App(app) - , m_WorkingDir(workingDir) + : m_App(app) + , m_WorkingDir(workingDir) { } @@ -45,76 +45,76 @@ BubbleEntityFactory::~BubbleEntityFactory() BubbleEntity *BubbleEntityFactory::createEntity(const MsgConvMedia &msgMedia, BubbleBgViewItem::BgType bgType, Message::Direction direction) { - std::string mime = msgMedia.getMime(); - std::string fileName = msgMedia.getName(); - std::string filePath = msgMedia.getPath(); + std::string mime = msgMedia.getMime(); + std::string fileName = msgMedia.getName(); + std::string filePath = msgMedia.getPath(); - if (mime.empty()) - mime = FileUtils::getMimeType(filePath); + if (mime.empty()) + mime = FileUtils::getMimeType(filePath); - if (fileName.empty()) - fileName = FileUtils::getFileName(filePath); + if (fileName.empty()) + fileName = FileUtils::getFileName(filePath); - return createEntity(filePath, fileName, mime, bgType, direction); + return createEntity(filePath, fileName, mime, bgType, direction); } BubbleEntity *BubbleEntityFactory::createEntity(const std::string &filePath, BubbleBgViewItem::BgType bgType, Message::Direction direction) { - return createEntity(filePath, FileUtils::getFileName(filePath), FileUtils::getMimeType(filePath), bgType, direction); + return createEntity(filePath, FileUtils::getFileName(filePath), FileUtils::getMimeType(filePath), bgType, direction); } BubbleTextEntity *BubbleEntityFactory::createTextEntity(std::string text, BubbleBgViewItem::BgType bgType, Message::Direction direction) { - return text.empty() ? nullptr : new BubbleTextEntity(bgType, direction, std::move(text)); + return text.empty() ? nullptr : new BubbleTextEntity(bgType, direction, std::move(text)); } BubbleDownloadButtonEntity *BubbleEntityFactory::createDownloadButtonEntity() { - return new BubbleDownloadButtonEntity; + return new BubbleDownloadButtonEntity; } BubbleEntity *BubbleEntityFactory::createAudioEntity(const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction) { - if (MediaUtils::hasAudio(filePath)) - return new BubbleAudioEntity(filePath, fileName, bgType, direction); + if (MediaUtils::hasAudio(filePath)) + return new BubbleAudioEntity(filePath, fileName, bgType, direction); - // File does not contain audio or broken: - return new BubbleUnknownFileEntity(filePath, fileName, bgType, direction); + // File does not contain audio or broken: + return new BubbleUnknownFileEntity(filePath, fileName, bgType, direction); } BubbleEntity *BubbleEntityFactory::createVideoEntity(const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction) { - if (MediaUtils::hasVideo(filePath)) - return new BubbleVideoEntity(m_WorkingDir, filePath, direction); + if (MediaUtils::hasVideo(filePath)) + return new BubbleVideoEntity(m_WorkingDir, filePath, direction); - // Try to create Audio entity. - return createAudioEntity(filePath, fileName, bgType, direction); + // Try to create Audio entity. + return createAudioEntity(filePath, fileName, bgType, direction); } BubbleEntity *BubbleEntityFactory::createEntity(const std::string &filePath, const std::string &fileName, std::string mime, BubbleBgViewItem::BgType bgType, Message::Direction direction) { - if (FileUtils::isExists(filePath)) { - std::transform(mime.begin(), mime.end(), mime.begin(), ::tolower); - MsgMedia::Type msgMediaType = getMsgMediaTypeByMime(mime); - switch (msgMediaType) { - case MsgMedia::ImageType: - return new BubbleImageEntity(filePath, direction); - case MsgMedia::AudioType: - return createAudioEntity(filePath, fileName, bgType, direction); - case MsgMedia::VideoType: - return createVideoEntity(filePath, fileName, bgType, direction); - default: - if (mime == "text/x-vcalendar" || mime == "text/calendar") - return new BubbleCalEventEntity(filePath, fileName, bgType, direction); - else if (mime == "text/x-vcard" || - mime == "text/vcard" || - mime == "text/x-vcalendar") - return new BubbleContactEntity(m_App, filePath, fileName , bgType, direction); - else if (mime != "application/smil") - return new BubbleUnknownFileEntity(filePath, fileName, bgType, direction); - } - } - - return nullptr; + if (FileUtils::isExists(filePath)) { + std::transform(mime.begin(), mime.end(), mime.begin(), ::tolower); + MsgMedia::Type msgMediaType = getMsgMediaTypeByMime(mime); + switch (msgMediaType) { + case MsgMedia::ImageType: + return new BubbleImageEntity(filePath, direction); + case MsgMedia::AudioType: + return createAudioEntity(filePath, fileName, bgType, direction); + case MsgMedia::VideoType: + return createVideoEntity(filePath, fileName, bgType, direction); + default: + if (mime == "text/x-vcalendar" || mime == "text/calendar") + return new BubbleCalEventEntity(filePath, fileName, bgType, direction); + else if (mime == "text/x-vcard" || + mime == "text/vcard" || + mime == "text/x-vcalendar") + return new BubbleContactEntity(m_App, filePath, fileName , bgType, direction); + else if (mime != "application/smil") + return new BubbleUnknownFileEntity(filePath, fileName, bgType, direction); + } + } + + return nullptr; } diff --git a/src/Conversation/ConvList/Controller/src/BubbleUnknownFileEntity.cpp b/src/Conversation/ConvList/Controller/src/BubbleUnknownFileEntity.cpp index 6fb7eff6..ae83b88d 100644 --- a/src/Conversation/ConvList/Controller/src/BubbleUnknownFileEntity.cpp +++ b/src/Conversation/ConvList/Controller/src/BubbleUnknownFileEntity.cpp @@ -22,8 +22,8 @@ using namespace Msg; BubbleUnknownFileEntity::BubbleUnknownFileEntity(const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction) - : BubbleBgEntity(UnknownFileItem, bgType, direction, filePath) - , m_FileName(fileName) + : BubbleBgEntity(UnknownFileItem, bgType, direction, filePath) + , m_FileName(fileName) { } @@ -33,7 +33,7 @@ BubbleUnknownFileEntity::~BubbleUnknownFileEntity() BubbleUnknownFileViewItem *BubbleUnknownFileEntity::createView(Evas_Object *parent) { - auto *item = new BubbleUnknownFileViewItem(*this, parent, m_BgType); - item->setMainText(m_FileName); - return item; + auto *item = new BubbleUnknownFileViewItem(*this, parent, m_BgType); + item->setMainText(m_FileName); + return item; } diff --git a/src/Conversation/ConvList/Controller/src/BubbleVideoEntity.cpp b/src/Conversation/ConvList/Controller/src/BubbleVideoEntity.cpp index c939975c..f0cedac6 100644 --- a/src/Conversation/ConvList/Controller/src/BubbleVideoEntity.cpp +++ b/src/Conversation/ConvList/Controller/src/BubbleVideoEntity.cpp @@ -22,23 +22,23 @@ using namespace Msg; BubbleVideoEntity::BubbleVideoEntity(WorkingDirRef workingDir, const std::string &filePath, Message::Direction direction) - : BubbleEntity(VideoItem, direction, filePath) - , m_WorkingDir(workingDir) + : BubbleEntity(VideoItem, direction, filePath) + , m_WorkingDir(workingDir) { - static const std::string thumbFileName = "thumbnail.jpeg"; - m_ImgPath = m_WorkingDir->genUniqueFilePath(thumbFileName); - if (!m_ImgPath.empty()) - MediaUtils::getVideoFrame(getFilePath(), m_ImgPath); + static const std::string thumbFileName = "thumbnail.jpeg"; + m_ImgPath = m_WorkingDir->genUniqueFilePath(thumbFileName); + if (!m_ImgPath.empty()) + MediaUtils::getVideoFrame(getFilePath(), m_ImgPath); } BubbleVideoEntity::~BubbleVideoEntity() { - m_WorkingDir->removeFile(m_ImgPath); + m_WorkingDir->removeFile(m_ImgPath); } BubbleVideoViewItem *BubbleVideoEntity::createView(Evas_Object *parent) { - auto *item = new BubbleVideoViewItem(*this, parent, m_ImgPath); - return item; + auto *item = new BubbleVideoViewItem(*this, parent, m_ImgPath); + return item; } diff --git a/src/Conversation/ConvList/Controller/src/ComposeListItem.cpp b/src/Conversation/ConvList/Controller/src/ComposeListItem.cpp index db58a605..96e4ffc9 100644 --- a/src/Conversation/ConvList/Controller/src/ComposeListItem.cpp +++ b/src/Conversation/ConvList/Controller/src/ComposeListItem.cpp @@ -35,107 +35,107 @@ using namespace Msg; ComposeListItem::ComposeListItem(BubbleEntityFactory &entityFactory, FileViewer &fileViewer) - : m_pListener(nullptr) - , m_BubbleEntityFactory(entityFactory) - , m_FileViewer(fileViewer) + : m_pListener(nullptr) + , m_BubbleEntityFactory(entityFactory) + , m_FileViewer(fileViewer) { } ComposeListItem::~ComposeListItem() { - m_pListener = nullptr; - clear(false); + m_pListener = nullptr; + clear(false); } void ComposeListItem::addAttachment(const std::string &filePath) { - auto *entity = m_BubbleEntityFactory.createEntity(filePath, BubbleBgViewItem::DraftStyle, Message::MD_Sent); - if (entity) { - m_BubbleEntityList.push_back(entity); - updateBubblePart(); - show(true); - navigate(); - if (m_pListener) - m_pListener->onAttachmentAdded({filePath}); - } + auto *entity = m_BubbleEntityFactory.createEntity(filePath, BubbleBgViewItem::DraftStyle, Message::MD_Sent); + if (entity) { + m_BubbleEntityList.push_back(entity); + updateBubblePart(); + show(true); + navigate(); + if (m_pListener) + m_pListener->onAttachmentAdded({filePath}); + } } void ComposeListItem::setListener(IComposeListItemListener *l) { - m_pListener = l; + m_pListener = l; } IComposeListItemListener *ComposeListItem::getListener() const { - return m_pListener; + return m_pListener; } const BubbleEntityList &ComposeListItem::getAttachments() const { - return m_BubbleEntityList; + return m_BubbleEntityList; } bool ComposeListItem::isEmpty() const { - return m_BubbleEntityList.empty(); + return m_BubbleEntityList.empty(); } void ComposeListItem::clear(bool updateUi) { - std::list fileList; - for (BubbleEntity *entity : m_BubbleEntityList) { - fileList.push_back(entity->getFilePath()); - delete entity; - } - m_BubbleEntityList.clear(); - if (updateUi) { - show(false); - ComposeListItem::updateBubblePart(); - } - if (m_pListener) - m_pListener->onAttachmentDeleted(fileList); + std::list fileList; + for (BubbleEntity *entity : m_BubbleEntityList) { + fileList.push_back(entity->getFilePath()); + delete entity; + } + m_BubbleEntityList.clear(); + if (updateUi) { + show(false); + ComposeListItem::updateBubblePart(); + } + if (m_pListener) + m_pListener->onAttachmentDeleted(fileList); } Evas_Object *ComposeListItem::getBubbleContent() { - if (m_BubbleEntityList.empty()) - return nullptr; - - auto *bubble = new BubbleItemContainer(*getOwner()); - for (BubbleEntity *entity : m_BubbleEntityList) { - BubbleViewItem *item = entity->createView(*bubble); - if (item) { - item->showDelButton(true); - item->setListener(this); - bubble->append(*item, entity->getDirection()); - } - } - bubble->go(); - bubble->show(); - return *bubble; + if (m_BubbleEntityList.empty()) + return nullptr; + + auto *bubble = new BubbleItemContainer(*getOwner()); + for (BubbleEntity *entity : m_BubbleEntityList) { + BubbleViewItem *item = entity->createView(*bubble); + if (item) { + item->showDelButton(true); + item->setListener(this); + bubble->append(*item, entity->getDirection()); + } + } + bubble->go(); + bubble->show(); + return *bubble; } void ComposeListItem::deleteEntity(BubbleEntity &entity) { - auto it = std::find(m_BubbleEntityList.begin(), m_BubbleEntityList.end(), &entity); - if (it != m_BubbleEntityList.end()) { - std::string filePath = entity.getFilePath(); - delete *it; - m_BubbleEntityList.erase(it); - if (isEmpty()) - show(false); - updateBubblePart(); - if (m_pListener) - m_pListener->onAttachmentDeleted({filePath}); - } + auto it = std::find(m_BubbleEntityList.begin(), m_BubbleEntityList.end(), &entity); + if (it != m_BubbleEntityList.end()) { + std::string filePath = entity.getFilePath(); + delete *it; + m_BubbleEntityList.erase(it); + if (isEmpty()) + show(false); + updateBubblePart(); + if (m_pListener) + m_pListener->onAttachmentDeleted({filePath}); + } } void ComposeListItem::onAction(BubbleViewItem &item) { - m_FileViewer.launch(item.getEntity().getFilePath()); + m_FileViewer.launch(item.getEntity().getFilePath()); } void ComposeListItem::onDelClicked(BubbleViewItem &item) { - deleteEntity(item.getEntity()); + deleteEntity(item.getEntity()); } diff --git a/src/Conversation/ConvList/Controller/src/ConvList.cpp b/src/Conversation/ConvList/Controller/src/ConvList.cpp index c39c44a6..2bb38e12 100644 --- a/src/Conversation/ConvList/Controller/src/ConvList.cpp +++ b/src/Conversation/ConvList/Controller/src/ConvList.cpp @@ -23,480 +23,480 @@ using namespace Msg; namespace { - const int minMessagesBulk = 100; - const int additionalMessagesBulk = 50; - const std::string solidStyle = "solid/default"; + const int minMessagesBulk = 100; + const int additionalMessagesBulk = 50; + const std::string solidStyle = "solid/default"; } ConvList::ConvList(Evas_Object *parent, App &app, WorkingDirRef workingDir) - : ConvListLayout(parent) - , m_Mode(NormalMode) - , m_MsgEngine(app.getMsgEngine()) - , m_pSelectAll(nullptr) - , m_pList(nullptr) - , m_ConvListItemMap() - , m_DateLineItemSet() - , m_pListener(nullptr) - , m_App(app) - , m_RecipThumbId(m_App.getThumbnailMaker().getThumbId(ThumbnailMaker::SingleThumb)) - , m_SearchWord() - , m_BubbleEntityFactory(app, workingDir) - , m_pComposeItem(nullptr) - , m_BodyFocusFunc() -{ - create(parent); + : ConvListLayout(parent) + , m_Mode(NormalMode) + , m_MsgEngine(app.getMsgEngine()) + , m_pSelectAll(nullptr) + , m_pList(nullptr) + , m_ConvListItemMap() + , m_DateLineItemSet() + , m_pListener(nullptr) + , m_App(app) + , m_RecipThumbId(m_App.getThumbnailMaker().getThumbId(ThumbnailMaker::SingleThumb)) + , m_SearchWord() + , m_BubbleEntityFactory(app, workingDir) + , m_pComposeItem(nullptr) + , m_BodyFocusFunc() +{ + create(parent); } ConvList::~ConvList() { - m_MsgEngine.getStorage().removeListener(*this); - m_App.getContactManager().removeListener(*this); - m_App.getSysSettingsManager().removeListener(*this); + m_MsgEngine.getStorage().removeListener(*this); + m_App.getContactManager().removeListener(*this); + m_App.getSysSettingsManager().removeListener(*this); } void ConvList::setListener(IConvListListener *l) { - m_pListener = l; + m_pListener = l; } void ConvList::setMode(ConvList::Mode mode) { - m_Mode = mode; - bool isCheckMode = (m_Mode == ConvList::SelectMode); + m_Mode = mode; + bool isCheckMode = (m_Mode == ConvList::SelectMode); - showSelectAllMode(isCheckMode); - m_pList->setCheckMode(isCheckMode); - if (isCheckMode) { - selectListItems(false); - m_pSelectAll->setCheckState(false); - } else { - ConvListViewItem::resetCheckMode(*m_pList); - } - m_pList->updateRealizedItems(); + showSelectAllMode(isCheckMode); + m_pList->setCheckMode(isCheckMode); + if (isCheckMode) { + selectListItems(false); + m_pSelectAll->setCheckState(false); + } else { + ConvListViewItem::resetCheckMode(*m_pList); + } + m_pList->updateRealizedItems(); } ConvList::Mode ConvList::getMode() const { - return m_Mode; + return m_Mode; } void ConvList::create(Evas_Object *parent) { - m_MsgEngine.getStorage().addListener(*this); - Evas_Object *list = createList(parent); - Evas_Object *selectAll = createSelectAll(parent); + m_MsgEngine.getStorage().addListener(*this); + Evas_Object *list = createList(parent); + Evas_Object *selectAll = createSelectAll(parent); - setSelectAll(selectAll); - setBubbleList(list); - showSelectAllMode(m_Mode == SelectMode); + setSelectAll(selectAll); + setBubbleList(list); + showSelectAllMode(m_Mode == SelectMode); - m_App.getContactManager().addListener(*this); - m_App.getSysSettingsManager().addListener(*this); + m_App.getContactManager().addListener(*this); + m_App.getSysSettingsManager().addListener(*this); } Evas_Object *ConvList::createSelectAll(Evas_Object *parent) { - m_pSelectAll = new ConvSelectAll(parent); - m_pSelectAll->addCheckCallback(SMART_CALLBACK(ConvList, onSelectAllChanged), this); - m_pSelectAll->show(); - return *m_pSelectAll; + m_pSelectAll = new ConvSelectAll(parent); + m_pSelectAll->addCheckCallback(SMART_CALLBACK(ConvList, onSelectAllChanged), this); + m_pSelectAll->show(); + return *m_pSelectAll; } Evas_Object *ConvList::createList(Evas_Object *parent) { - m_pList = new ListView(parent); - m_pList->setListener(this); - m_pList->setMode(ELM_LIST_COMPRESS); - m_pList->setHomogeneous(false); - m_pList->setStyle(solidStyle); - m_pList->show(); - m_pList->addEventCb(EVAS_CALLBACK_RESIZE, EVAS_EVENT_CALLBACK(ConvList, onListResized), this); + m_pList = new ListView(parent); + m_pList->setListener(this); + m_pList->setMode(ELM_LIST_COMPRESS); + m_pList->setHomogeneous(false); + m_pList->setStyle(solidStyle); + m_pList->show(); + m_pList->addEventCb(EVAS_CALLBACK_RESIZE, EVAS_EVENT_CALLBACK(ConvList, onListResized), this); - return *m_pList; + return *m_pList; } void ConvList::fill() { - clear(); - if (!m_ThreadId.isValid()) - return; + clear(); + if (!m_ThreadId.isValid()) + return; - MsgConversationListRef convList = m_MsgEngine.getStorage().getConversationList(m_ThreadId); - int convListLen = convList->getLength(); - int reserveSize = convListLen <= minMessagesBulk/2 ? minMessagesBulk : convListLen + additionalMessagesBulk; - m_ConvListItemMap.reserve(reserveSize); - m_DateLineItemSet.reserve(reserveSize); + MsgConversationListRef convList = m_MsgEngine.getStorage().getConversationList(m_ThreadId); + int convListLen = convList->getLength(); + int reserveSize = convListLen <= minMessagesBulk/2 ? minMessagesBulk : convListLen + additionalMessagesBulk; + m_ConvListItemMap.reserve(reserveSize); + m_DateLineItemSet.reserve(reserveSize); - for (int i = 0; i < convListLen; ++i) { - MsgConversationItem &item = convList->at(i); - insertItem(item); - } + for (int i = 0; i < convListLen; ++i) { + MsgConversationItem &item = convList->at(i); + insertItem(item); + } } void ConvList::setThreadId(ThreadId id, const char *searchWord) { - bool fillList = false; + bool fillList = false; - if (m_ThreadId != id) { - fillList = true; - m_ThreadId = id; - updateRecipThumbId(); - } + if (m_ThreadId != id) { + fillList = true; + m_ThreadId = id; + updateRecipThumbId(); + } - if (searchWord && strcmp(searchWord, m_SearchWord.c_str())) { - fillList = true; - m_SearchWord = searchWord; - } + if (searchWord && strcmp(searchWord, m_SearchWord.c_str())) { + fillList = true; + m_SearchWord = searchWord; + } - if (fillList) - fill(); + if (fillList) + fill(); } ThreadId ConvList::getThreadId() const { - return m_ThreadId; + return m_ThreadId; } void ConvList::updateRecipThumbId() { - const MsgAddressListRef addressList = m_App.getMsgEngine().getStorage().getAddressList(m_ThreadId); - if (addressList) { - int countContact = addressList->getLength(); - if (countContact > 1) { - m_RecipThumbId = m_App.getThumbnailMaker().getThumbId(ThumbnailMaker::GroupThumb); - } else if (countContact == 1) { - m_RecipThumbId = m_App.getThumbnailMaker().getThumbId(addressList->at(0)); - } else { - m_RecipThumbId = m_App.getThumbnailMaker().getThumbId(ThumbnailMaker::SingleThumb); - MSG_LOG_WARN("Msg address list is empty"); - } - } else { - m_RecipThumbId = invalidThumbId; - } + const MsgAddressListRef addressList = m_App.getMsgEngine().getStorage().getAddressList(m_ThreadId); + if (addressList) { + int countContact = addressList->getLength(); + if (countContact > 1) { + m_RecipThumbId = m_App.getThumbnailMaker().getThumbId(ThumbnailMaker::GroupThumb); + } else if (countContact == 1) { + m_RecipThumbId = m_App.getThumbnailMaker().getThumbId(addressList->at(0)); + } else { + m_RecipThumbId = m_App.getThumbnailMaker().getThumbId(ThumbnailMaker::SingleThumb); + MSG_LOG_WARN("Msg address list is empty"); + } + } else { + m_RecipThumbId = invalidThumbId; + } } void ConvList::navigateTo(MsgId msgId) { - ConvListItem *item = getItem(msgId); - if (item) - m_pList->showItem(*item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE); + ConvListItem *item = getItem(msgId); + if (item) + m_pList->showItem(*item, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE); } void ConvList::navigateToBottom() { - ListItem *item = m_pList->getLastItem(); - if (item) { - ComposeListViewItem *composeItem = dynamic_cast(item); - if (!(composeItem && composeItem->isVisible())) - item = m_pList->getPrevItem(*item); - if (item) - m_pList->showItem(*item, ELM_GENLIST_ITEM_SCROLLTO_BOTTOM); - } + ListItem *item = m_pList->getLastItem(); + if (item) { + ComposeListViewItem *composeItem = dynamic_cast(item); + if (!(composeItem && composeItem->isVisible())) + item = m_pList->getPrevItem(*item); + if (item) + m_pList->showItem(*item, ELM_GENLIST_ITEM_SCROLLTO_BOTTOM); + } } ConvListItem *ConvList::getItem(MsgId msgId) const { - auto it = m_ConvListItemMap.find(msgId); - return it != m_ConvListItemMap.end() ? it->second : nullptr; + auto it = m_ConvListItemMap.find(msgId); + return it != m_ConvListItemMap.end() ? it->second : nullptr; } void ConvList::insertItem(const MsgConversationItem &item) { - if (item.getDirection() == Message::MD_Received) - insertItem(new ConvListItem(item, m_App, m_FileViewer, m_Share, m_BubbleEntityFactory, m_SearchWord, m_RecipThumbId)); - else - insertItem(new ConvListItem(item, m_App, m_FileViewer, m_Share, m_BubbleEntityFactory, m_SearchWord)); + if (item.getDirection() == Message::MD_Received) + insertItem(new ConvListItem(item, m_App, m_FileViewer, m_Share, m_BubbleEntityFactory, m_SearchWord, m_RecipThumbId)); + else + insertItem(new ConvListItem(item, m_App, m_FileViewer, m_Share, m_BubbleEntityFactory, m_SearchWord)); } void ConvList::insertItem(ConvListItem *item) { - dateLineAddIfNec(item); - m_ConvListItemMap[item->getMsgId()] = item; - item->setListener(this); - if (m_pComposeItem) - m_pList->insertBeforeItem(*item, *m_pComposeItem); - else - m_pList->appendItem(*item); - updateSelectAllItem(); + dateLineAddIfNec(item); + m_ConvListItemMap[item->getMsgId()] = item; + item->setListener(this); + if (m_pComposeItem) + m_pList->insertBeforeItem(*item, *m_pComposeItem); + else + m_pList->appendItem(*item); + updateSelectAllItem(); } void ConvList::deleteItem(ConvListItem *item) { - dateLineDelIfNec(item); - m_ConvListItemMap.erase(item->getMsgId()); - m_pList->deleteItem(*item); - updateSelectAllItem(); + dateLineDelIfNec(item); + m_ConvListItemMap.erase(item->getMsgId()); + m_pList->deleteItem(*item); + updateSelectAllItem(); } bool ConvList::deleteItems(const MsgIdList &idList) { - bool res = false; - for (const MsgId &id: idList) { - ConvListItem *deleted = getItem(id); - if (deleted) - { - res = true; - deleteItem(deleted); - } - } + bool res = false; + for (const MsgId &id: idList) { + ConvListItem *deleted = getItem(id); + if (deleted) + { + res = true; + deleteItem(deleted); + } + } - if (m_pListener && m_ConvListItemMap.empty()) - m_pListener->onAllConvItemsDeleted(*this); + if (m_pListener && m_ConvListItemMap.empty()) + m_pListener->onAllConvItemsDeleted(*this); - return res; + return res; } void ConvList::demoteItem(ConvListItem *item) { - dateLineDelIfNec(item); - dateLineAddIfNec(item); - m_pList->demoteItem(*item); - if (m_pComposeItem) - m_pList->demoteItem(*m_pComposeItem); + dateLineDelIfNec(item); + dateLineAddIfNec(item); + m_pList->demoteItem(*item); + if (m_pComposeItem) + m_pList->demoteItem(*m_pComposeItem); } void ConvList::dateLineDelIfNec(ConvListItem *item) { - bool needDelDateLine = false; - DateLineItem *prev = dynamic_cast(m_pList->getPrevItem(*item)); - if (prev) { - ListItem *nextItem = m_pList->getNextItem(*item); - needDelDateLine = nextItem ? dynamic_cast(nextItem) == nullptr : true; - if (needDelDateLine) { - m_DateLineItemSet.erase(prev->getDateLine()); - m_pList->deleteItem(*prev); - } - } + bool needDelDateLine = false; + DateLineItem *prev = dynamic_cast(m_pList->getPrevItem(*item)); + if (prev) { + ListItem *nextItem = m_pList->getNextItem(*item); + needDelDateLine = nextItem ? dynamic_cast(nextItem) == nullptr : true; + if (needDelDateLine) { + m_DateLineItemSet.erase(prev->getDateLine()); + m_pList->deleteItem(*prev); + } + } } void ConvList::dateLineAddIfNec(ConvListItem *item) { - std::string dateStr = TimeUtils::makeBubbleDateLineString(item->getRawTime()); - auto it = m_DateLineItemSet.find(dateStr); - if (it == m_DateLineItemSet.end()) { - DateLineItem *dateLine = new DateLineItem(item->getRawTime(), dateStr); - m_DateLineItemSet.insert(dateStr); - if (m_pComposeItem) - m_pList->insertBeforeItem(*dateLine, *m_pComposeItem); - else - m_pList->appendItem(*dateLine); - } + std::string dateStr = TimeUtils::makeBubbleDateLineString(item->getRawTime()); + auto it = m_DateLineItemSet.find(dateStr); + if (it == m_DateLineItemSet.end()) { + DateLineItem *dateLine = new DateLineItem(item->getRawTime(), dateStr); + m_DateLineItemSet.insert(dateStr); + if (m_pComposeItem) + m_pList->insertBeforeItem(*dateLine, *m_pComposeItem); + else + m_pList->appendItem(*dateLine); + } } void ConvList::clear() { - auto items = m_pList->getItems(); - for (ListItem *item : items) { - if (item != m_pComposeItem) - item->destroy(); - } - m_ConvListItemMap.clear(); - m_DateLineItemSet.clear(); + auto items = m_pList->getItems(); + for (ListItem *item : items) { + if (item != m_pComposeItem) + item->destroy(); + } + m_ConvListItemMap.clear(); + m_DateLineItemSet.clear(); } void ConvList::deleteSelectedItems() { - auto items = getConvItems(); - MsgIdList messages; - for (ConvListItem *item : items) { - if (item->getCheckedState()) - messages.push_back(item->getMsgId()); - } - m_MsgEngine.getStorage().deleteMessages(messages); + auto items = getConvItems(); + MsgIdList messages; + for (ConvListItem *item : items) { + if (item->getCheckedState()) + messages.push_back(item->getMsgId()); + } + m_MsgEngine.getStorage().deleteMessages(messages); } int ConvList::getMessageCount() const { - auto items = getConvItems(); - return (int)items.size(); + auto items = getConvItems(); + return (int)items.size(); } int ConvList::getMessageCheckedCount() const { - auto items = getConvItems(); - int count = 0; - for (ConvListItem *item : items) { - if (item->getCheckedState()) - count++; - } - return count; + auto items = getConvItems(); + int count = 0; + for (ConvListItem *item : items) { + if (item->getCheckedState()) + count++; + } + return count; } void ConvList::selectListItems(bool state) { - m_pList->checkAllItems(state); - if (m_pListener) - m_pListener->onConvListItemChecked(); + m_pList->checkAllItems(state); + if (m_pListener) + m_pListener->onConvListItemChecked(); } void ConvList::updateSelectAllItem() { - if (m_Mode == SelectMode && m_pSelectAll) { - bool check = true; - auto items = getConvItems(); - for (ConvListItem *item : items) { - if (!item->getCheckedState()) { - check = false; - break; - } - } - m_pSelectAll->setCheckState(check); - } + if (m_Mode == SelectMode && m_pSelectAll) { + bool check = true; + auto items = getConvItems(); + for (ConvListItem *item : items) { + if (!item->getCheckedState()) { + check = false; + break; + } + } + m_pSelectAll->setCheckState(check); + } } ComposeListItem &ConvList::getComposeItem() { - if (!m_pComposeItem) { - m_pComposeItem = new ComposeListItem(m_BubbleEntityFactory, m_FileViewer); - m_pList->appendItem(*m_pComposeItem); - m_pComposeItem->show(false); - } - return *m_pComposeItem; + if (!m_pComposeItem) { + m_pComposeItem = new ComposeListItem(m_BubbleEntityFactory, m_FileViewer); + m_pList->appendItem(*m_pComposeItem); + m_pComposeItem->show(false); + } + return *m_pComposeItem; } std::vector ConvList::getConvItems() const { - return m_pList->getItems(); + return m_pList->getItems(); } void ConvList::setBodyFocusCb(std::function bodyFocusFunc) { - m_BodyFocusFunc = std::move(bodyFocusFunc); + m_BodyFocusFunc = std::move(bodyFocusFunc); } void ConvList::onListItemLongPressed(ListItem &listItem) { - ConvListItem *item = dynamic_cast(&listItem); - if (item) - item->showPopup(); + ConvListItem *item = dynamic_cast(&listItem); + if (item) + item->showPopup(); } void ConvList::onSelectAllChanged(Evas_Object *obj, void *eventInfo) { - selectListItems(m_pSelectAll->getCheckState()); + selectListItems(m_pSelectAll->getCheckState()); } void ConvList::onListItemChecked(ListItem &listItem) { - updateSelectAllItem(); - if (m_pListener) - m_pListener->onConvListItemChecked(); + updateSelectAllItem(); + if (m_pListener) + m_pListener->onConvListItemChecked(); } void ConvList::onMsgStorageUpdate(const MsgIdList &msgIdList) { - MSG_LOG(""); - for (auto &itemId: msgIdList) { - ConvListItem *updated = getItem(itemId); - if (updated) { - time_t beforeTime = updated->getRawTime(); - updated->update(); - if (beforeTime != updated->getRawTime()) - demoteItem(updated); - } - } + MSG_LOG(""); + for (auto &itemId: msgIdList) { + ConvListItem *updated = getItem(itemId); + if (updated) { + time_t beforeTime = updated->getRawTime(); + updated->update(); + if (beforeTime != updated->getRawTime()) + demoteItem(updated); + } + } } void ConvList::onMsgStorageInsert(const MsgIdList &msgIdList) { - MSG_LOG(""); - bool inserted = false; - for (MsgId msgId: msgIdList) { - if (getItem(msgId)) - continue; - - MessageRef msg = m_MsgEngine.getStorage().getMessage(msgId); - if (msg && msg->getThreadId() == m_ThreadId && msg->getMessageStorageType() != Message::MS_Sim) { - MsgConversationItemRef item = m_MsgEngine.getStorage().getConversationItem(msgId); - if (item) { - insertItem(*item); - inserted = true; - } - } - } - if (inserted) - navigateToBottom(); + MSG_LOG(""); + bool inserted = false; + for (MsgId msgId: msgIdList) { + if (getItem(msgId)) + continue; + + MessageRef msg = m_MsgEngine.getStorage().getMessage(msgId); + if (msg && msg->getThreadId() == m_ThreadId && msg->getMessageStorageType() != Message::MS_Sim) { + MsgConversationItemRef item = m_MsgEngine.getStorage().getConversationItem(msgId); + if (item) { + insertItem(*item); + inserted = true; + } + } + } + if (inserted) + navigateToBottom(); } void ConvList::onMsgStorageDelete(const MsgIdList &msgIdList) { - MSG_LOG(""); - deleteItems(msgIdList); + MSG_LOG(""); + deleteItems(msgIdList); } void ConvList::onForwardMsg(ConvListItem &item) { - if (m_pListener) - m_pListener->onForwardMsg(item.getMsgId()); + if (m_pListener) + m_pListener->onForwardMsg(item.getMsgId()); } void ConvList::onSlideShow(ConvListItem &item) { - if (m_pListener) - m_pListener->onSlideShow(item.getMsgId()); + if (m_pListener) + m_pListener->onSlideShow(item.getMsgId()); } void ConvList::onResendMsg(ConvListItem &item) { - if (m_pListener) - m_pListener->onResendMsg(item.getMsgId()); + if (m_pListener) + m_pListener->onResendMsg(item.getMsgId()); } void ConvList::onSaveAttachments(ConvListItem &item) { - if (m_pListener) - m_pListener->onSaveAttachments(item.getMsgId()); + if (m_pListener) + m_pListener->onSaveAttachments(item.getMsgId()); } void ConvList::onEditDraftMsg(ConvListItem &item) { - if (m_pListener) { - item.disabled(true); - m_pListener->onEditDraftMsg(item.getMsgId()); - } + if (m_pListener) { + item.disabled(true); + m_pListener->onEditDraftMsg(item.getMsgId()); + } } void ConvList::onContactChanged() { - MSG_LOG(""); - updateRecipThumbId(); - m_pList->updateRealizedItems(); + MSG_LOG(""); + updateRecipThumbId(); + m_pList->updateRealizedItems(); } void ConvList::onTimeFormatChanged() { - MSG_LOG(""); - auto items = getConvItems(); - for (ConvListItem *item : items) { - item->updateTime(); - } - m_pList->updateRealizedItems(); + MSG_LOG(""); + auto items = getConvItems(); + for (ConvListItem *item : items) { + item->updateTime(); + } + m_pList->updateRealizedItems(); } void ConvList::onLanguageChanged() { - MSG_LOG(""); + MSG_LOG(""); - // Update ConvListItem: - auto convListItems = getConvItems(); - for (ConvListItem *item : convListItems) - item->updateTime(); + // Update ConvListItem: + auto convListItems = getConvItems(); + for (ConvListItem *item : convListItems) + item->updateTime(); - // Update DateLineItem: - m_DateLineItemSet.clear(); - auto DateLineItems = m_pList->getItems(); - for (DateLineItem *item : DateLineItems) { - item->update(); - m_DateLineItemSet.insert(item->getDateLine()); - } + // Update DateLineItem: + m_DateLineItemSet.clear(); + auto DateLineItems = m_pList->getItems(); + for (DateLineItem *item : DateLineItems) { + item->update(); + m_DateLineItemSet.insert(item->getDateLine()); + } - m_pList->updateRealizedItems(); + m_pList->updateRealizedItems(); } void ConvList::onListResized(Evas_Object *obj, void *eventInfo) { - MSG_LOG(""); - if (m_BodyFocusFunc && m_BodyFocusFunc()) - navigateToBottom(); + MSG_LOG(""); + if (m_BodyFocusFunc && m_BodyFocusFunc()) + navigateToBottom(); } diff --git a/src/Conversation/ConvList/Controller/src/ConvListItem.cpp b/src/Conversation/ConvList/Controller/src/ConvListItem.cpp index 41918be2..aefd9200 100644 --- a/src/Conversation/ConvList/Controller/src/ConvListItem.cpp +++ b/src/Conversation/ConvList/Controller/src/ConvListItem.cpp @@ -44,525 +44,525 @@ using namespace Msg; ConvListItem::ConvListItem(const MsgConversationItem &item, - App &app, - FileViewer &fileViewer, - Share &share, - BubbleEntityFactory &bubbleEntityFactory, - const std::string &searchWord, - const ThumbId &thumbId) - : ConvListViewItem(getConvItemType(item)) - , m_pListener(nullptr) - , m_App(app) - , m_FileViewer(fileViewer) - , m_Share(share) - , m_MsgId(item.getMsgId()) - , m_IsDraft(item.isDraft()) - , m_Direction() - , m_NetworkStatus(Message::NS_Unknown) - , m_Type(Message::MT_SMS) - , m_Time() - , m_ThumbId(thumbId) - , m_BubbleEntityFactory(bubbleEntityFactory) - , m_IsRestrictedByDpm(false) - , m_IsNeededReadReport(false) - , m_SearchWord(searchWord) -{ - update(item); + App &app, + FileViewer &fileViewer, + Share &share, + BubbleEntityFactory &bubbleEntityFactory, + const std::string &searchWord, + const ThumbId &thumbId) + : ConvListViewItem(getConvItemType(item)) + , m_pListener(nullptr) + , m_App(app) + , m_FileViewer(fileViewer) + , m_Share(share) + , m_MsgId(item.getMsgId()) + , m_IsDraft(item.isDraft()) + , m_Direction() + , m_NetworkStatus(Message::NS_Unknown) + , m_Type(Message::MT_SMS) + , m_Time() + , m_ThumbId(thumbId) + , m_BubbleEntityFactory(bubbleEntityFactory) + , m_IsRestrictedByDpm(false) + , m_IsNeededReadReport(false) + , m_SearchWord(searchWord) +{ + update(item); } ConvListItem::~ConvListItem() { - m_App.getPopupManager().reset(this); - clearEntityList(); + m_App.getPopupManager().reset(this); + clearEntityList(); } void ConvListItem::clearEntityList() { - for (auto *entity : m_BubbleEntityList) - delete entity; - m_BubbleEntityList.clear(); + for (auto *entity : m_BubbleEntityList) + delete entity; + m_BubbleEntityList.clear(); } void ConvListItem::updateTime() { - m_TimeStr.clear(); + m_TimeStr.clear(); } bool ConvListItem::isNeededReadReport() const { - return m_IsNeededReadReport && !m_IsRestrictedByDpm; + return m_IsNeededReadReport && !m_IsRestrictedByDpm; } ConvListViewItem::ConvItemType ConvListItem::getConvItemType(const MsgConversationItem &item) { - ConvItemType type = ConvItemType::Sent; - if (item.getDirection() == Message::Direction::MD_Sent) { - if (item.isDraft()) - type = ConvItemType::Draft; - else if (item.getNetworkStatus() == Message::NS_Send_Fail) - type = ConvItemType::Failed; - } else { - type = ConvItemType::Received; - } - return type; + ConvItemType type = ConvItemType::Sent; + if (item.getDirection() == Message::Direction::MD_Sent) { + if (item.isDraft()) + type = ConvItemType::Draft; + else if (item.getNetworkStatus() == Message::NS_Send_Fail) + type = ConvItemType::Failed; + } else { + type = ConvItemType::Received; + } + return type; } BubbleBgViewItem::BgType ConvListItem::getBubbleBgType(const MsgConversationItem &item) { - BubbleBgViewItem::BgType type = BubbleBgViewItem::SentStyle; - if (item.getDirection() == Message::Direction::MD_Sent) { - if (item.isDraft()) - type = BubbleBgViewItem::DraftStyle; - else if (item.getNetworkStatus() == Message::NS_Send_Fail) - type = BubbleBgViewItem::FailedStyle; - } else { - type = BubbleBgViewItem::ReceivedStyle; - } - return type; + BubbleBgViewItem::BgType type = BubbleBgViewItem::SentStyle; + if (item.getDirection() == Message::Direction::MD_Sent) { + if (item.isDraft()) + type = BubbleBgViewItem::DraftStyle; + else if (item.getNetworkStatus() == Message::NS_Send_Fail) + type = BubbleBgViewItem::FailedStyle; + } else { + type = BubbleBgViewItem::ReceivedStyle; + } + return type; } BubbleTextEntity *ConvListItem::createTextEntity(BubbleBgViewItem::BgType bgType, const MsgConvMedia &media, std::string searchWord) { - std::string filePath = media.getPath(); - std::string text = FileUtils::readTextFile(filePath); - BubbleTextEntity *entity = createTextEntity(bgType, std::move(text), true, std::move(searchWord)); - if (entity) - entity->setFilePath(std::move(filePath)); - return entity; + std::string filePath = media.getPath(); + std::string text = FileUtils::readTextFile(filePath); + BubbleTextEntity *entity = createTextEntity(bgType, std::move(text), true, std::move(searchWord)); + if (entity) + entity->setFilePath(std::move(filePath)); + return entity; } BubbleTextEntity *ConvListItem::createTextEntity(BubbleBgViewItem::BgType bgType, std::string text, bool markup, std::string searchWord) { - bool found = false; - std::string markupText = markup ? utf8ToMarkup(text) : std::move(text); - std::string markupSearchWord = markup ? utf8ToMarkup(searchWord) : std::move(searchWord); - std::string resText = TextDecorator::highlightKeyword(std::move(markupText), markupSearchWord, &found); + bool found = false; + std::string markupText = markup ? utf8ToMarkup(text) : std::move(text); + std::string markupSearchWord = markup ? utf8ToMarkup(searchWord) : std::move(searchWord); + std::string resText = TextDecorator::highlightKeyword(std::move(markupText), markupSearchWord, &found); - if (found) - showSearch(); + if (found) + showSearch(); - return m_BubbleEntityFactory.createTextEntity(std::move(resText), bgType, m_Direction); + return m_BubbleEntityFactory.createTextEntity(std::move(resText), bgType, m_Direction); } BubbleDownloadButtonEntity *ConvListItem::findDownloadButton() const { - for (BubbleEntity *entity : m_BubbleEntityList) { - if (entity->getType() == BubbleEntity::DownloadButtonItem) - return static_cast(entity); - } - return nullptr; + for (BubbleEntity *entity : m_BubbleEntityList) { + if (entity->getType() == BubbleEntity::DownloadButtonItem) + return static_cast(entity); + } + return nullptr; } void ConvListItem::updateDownloadButton() { - auto *downloadButton = findDownloadButton(); - if (downloadButton) - downloadButton->disabled(m_NetworkStatus == Message::NS_Retrieving); + auto *downloadButton = findDownloadButton(); + if (downloadButton) + downloadButton->disabled(m_NetworkStatus == Message::NS_Retrieving); } void ConvListItem::convertNotiToMms() { - if (m_Type == Message::MT_MMS_Noti) { - MsgConversationItemRef item = m_App.getMsgEngine().getStorage().getConversationItem(m_MsgId); - if (item) - update(*item); - } + if (m_Type == Message::MT_MMS_Noti) { + MsgConversationItemRef item = m_App.getMsgEngine().getStorage().getConversationItem(m_MsgId); + if (item) + update(*item); + } } void ConvListItem::addEntity(BubbleEntity *entity) { - if (entity) - m_BubbleEntityList.push_back(entity); + if (entity) + m_BubbleEntityList.push_back(entity); } void ConvListItem::updateEntityBgType(BubbleBgViewItem::BgType bgType) { - for (BubbleEntity *entity : m_BubbleEntityList) { - auto *bgEntity = dynamic_cast(entity); - if (bgEntity) - bgEntity->setBgType(bgType); - } + for (BubbleEntity *entity : m_BubbleEntityList) { + auto *bgEntity = dynamic_cast(entity); + if (bgEntity) + bgEntity->setBgType(bgType); + } } void ConvListItem::update() { - MessageRef msg = m_App.getMsgEngine().getStorage().getMessage(m_MsgId); - if (!msg) - return; - - updateTime(); - m_Time = msg->getTime(); - m_NetworkStatus = msg->getNetworkStatus(); - m_IsRestrictedByDpm = msg->isRestrictedByDpm(); - - if (m_NetworkStatus == Message::NS_Send_Fail) { - updateItemType(ConvItemType::Failed); - updateEntityBgType(BubbleBgViewItem::FailedStyle); - } else if (m_NetworkStatus == Message::NS_Send_Success || m_NetworkStatus == Message::NS_Sending) { - updateItemType(ConvItemType::Sent); - updateEntityBgType(BubbleBgViewItem::SentStyle); - } else if (m_NetworkStatus == Message::NS_Not_Send) { - updateItemType(ConvItemType::Draft); - updateEntityBgType(BubbleBgViewItem::DraftStyle); - } else if (m_NetworkStatus == Message::NS_Received) { - updateItemType(ConvItemType::Received); - BubbleBgViewItem::BgType bgType = m_IsRestrictedByDpm ? BubbleBgViewItem::RestrictedStyle : BubbleBgViewItem::ReceivedStyle; - updateEntityBgType(bgType); - } else if (m_NetworkStatus == Message::NS_Retrieving) { - updateDownloadButton(); - } else if (m_NetworkStatus == Message::NS_Retrieve_Success) { - convertNotiToMms(); - } - - ConvListViewItem::update(); + MessageRef msg = m_App.getMsgEngine().getStorage().getMessage(m_MsgId); + if (!msg) + return; + + updateTime(); + m_Time = msg->getTime(); + m_NetworkStatus = msg->getNetworkStatus(); + m_IsRestrictedByDpm = msg->isRestrictedByDpm(); + + if (m_NetworkStatus == Message::NS_Send_Fail) { + updateItemType(ConvItemType::Failed); + updateEntityBgType(BubbleBgViewItem::FailedStyle); + } else if (m_NetworkStatus == Message::NS_Send_Success || m_NetworkStatus == Message::NS_Sending) { + updateItemType(ConvItemType::Sent); + updateEntityBgType(BubbleBgViewItem::SentStyle); + } else if (m_NetworkStatus == Message::NS_Not_Send) { + updateItemType(ConvItemType::Draft); + updateEntityBgType(BubbleBgViewItem::DraftStyle); + } else if (m_NetworkStatus == Message::NS_Received) { + updateItemType(ConvItemType::Received); + BubbleBgViewItem::BgType bgType = m_IsRestrictedByDpm ? BubbleBgViewItem::RestrictedStyle : BubbleBgViewItem::ReceivedStyle; + updateEntityBgType(bgType); + } else if (m_NetworkStatus == Message::NS_Retrieving) { + updateDownloadButton(); + } else if (m_NetworkStatus == Message::NS_Retrieve_Success) { + convertNotiToMms(); + } + + ConvListViewItem::update(); } void ConvListItem::update(const MsgConversationItem &item) { - updateTime(); - clearEntityList(); - - BubbleBgViewItem::BgType bgType = getBubbleBgType(item); - m_MsgId = item.getMsgId(); - m_IsDraft = item.isDraft(); - m_Direction = item.getDirection(); - m_NetworkStatus = item.getNetworkStatus(); - m_Type = item.getType(); - m_Time = item.getTime(); - m_IsRestrictedByDpm = item.isRestrictedByDpm(); - m_IsNeededReadReport = m_Direction == Message::MD_Received && - m_Type == Message::MT_MMS && - !item.isRead(); - - if (m_IsRestrictedByDpm) { - addEntity(createTextEntity(BubbleBgViewItem::RestrictedStyle, msg("IDS_MSG_BODY_COULDNT_RECEIVE_THIS_MESSAGE_THE_SECURITY_POLICY_PREVENTS_RECEIVING_MESSAGES"), false, "")); - } else if (!MsgUtils::isMms(m_Type)) { - addEntity(createTextEntity(bgType, item.getText(), true, m_SearchWord)); - } else if (m_Type == Message::MT_MMS_Noti) { - std::string text = MessageDetailContent::getMmsNotiConvListItemContent(m_App, m_MsgId); - addEntity(createTextEntity(bgType, std::move(text), false, m_SearchWord)); - addEntity(m_BubbleEntityFactory.createDownloadButtonEntity()); - updateDownloadButton(); - } else { - const MsgConvMediaList &list = item.getMediaList(); - for (int i = 0; i < list.getLength(); ++i) { - const MsgConvMedia &media = list.at(i); - std::string mime = media.getMime(); - std::transform(mime.begin(), mime.end(), mime.begin(), ::tolower); - if (mime == "text/plain") - addEntity(createTextEntity(bgType, media, m_SearchWord)); - else if (mime != "application/smil") - addEntity(m_BubbleEntityFactory.createEntity(media, bgType, m_Direction)); - } - } + updateTime(); + clearEntityList(); + + BubbleBgViewItem::BgType bgType = getBubbleBgType(item); + m_MsgId = item.getMsgId(); + m_IsDraft = item.isDraft(); + m_Direction = item.getDirection(); + m_NetworkStatus = item.getNetworkStatus(); + m_Type = item.getType(); + m_Time = item.getTime(); + m_IsRestrictedByDpm = item.isRestrictedByDpm(); + m_IsNeededReadReport = m_Direction == Message::MD_Received && + m_Type == Message::MT_MMS && + !item.isRead(); + + if (m_IsRestrictedByDpm) { + addEntity(createTextEntity(BubbleBgViewItem::RestrictedStyle, msg("IDS_MSG_BODY_COULDNT_RECEIVE_THIS_MESSAGE_THE_SECURITY_POLICY_PREVENTS_RECEIVING_MESSAGES"), false, "")); + } else if (!MsgUtils::isMms(m_Type)) { + addEntity(createTextEntity(bgType, item.getText(), true, m_SearchWord)); + } else if (m_Type == Message::MT_MMS_Noti) { + std::string text = MessageDetailContent::getMmsNotiConvListItemContent(m_App, m_MsgId); + addEntity(createTextEntity(bgType, std::move(text), false, m_SearchWord)); + addEntity(m_BubbleEntityFactory.createDownloadButtonEntity()); + updateDownloadButton(); + } else { + const MsgConvMediaList &list = item.getMediaList(); + for (int i = 0; i < list.getLength(); ++i) { + const MsgConvMedia &media = list.at(i); + std::string mime = media.getMime(); + std::transform(mime.begin(), mime.end(), mime.begin(), ::tolower); + if (mime == "text/plain") + addEntity(createTextEntity(bgType, media, m_SearchWord)); + else if (mime != "application/smil") + addEntity(m_BubbleEntityFactory.createEntity(media, bgType, m_Direction)); + } + } } void ConvListItem::shareContent() { - if (MsgUtils::isSms(m_Type)) { - m_Share.launch(getAllMsgText()); - } else { - std::list fileList; - for (BubbleEntity *entity : m_BubbleEntityList) { - const std::string &filePath = entity->getFilePath(); - if (!filePath.empty()) - fileList.push_back(filePath); - } - m_Share.launch(fileList); - } + if (MsgUtils::isSms(m_Type)) { + m_Share.launch(getAllMsgText()); + } else { + std::list fileList; + for (BubbleEntity *entity : m_BubbleEntityList) { + const std::string &filePath = entity->getFilePath(); + if (!filePath.empty()) + fileList.push_back(filePath); + } + m_Share.launch(fileList); + } } void ConvListItem::copyMsgToSimCard() { - MsgStorage::StorageResult result = MsgStorage::StorageFail; - MessageRef msg = m_App.getMsgEngine().getStorage().getMessage(m_MsgId); - if (msg) { - msg->setMessageStorageType(Message::MS_Sim); - m_App.getMsgEngine().getStorage().saveMessage(*msg, false, &result); + MsgStorage::StorageResult result = MsgStorage::StorageFail; + MessageRef msg = m_App.getMsgEngine().getStorage().getMessage(m_MsgId); + if (msg) { + msg->setMessageStorageType(Message::MS_Sim); + m_App.getMsgEngine().getStorage().saveMessage(*msg, false, &result); - if (result == MsgStorage::StorageSimFull) - notification_status_message_post(msg("IDS_MSGF_BODY_SIM_MEMORY_FULL_DELETE_SOME_ITEMS").cStr()); - } - if (result == MsgStorage::StorageSuccess) - notification_status_message_post(msg("IDS_MSGC_POP_COPIED_TO_SIM_CARD").cStr()); + if (result == MsgStorage::StorageSimFull) + notification_status_message_post(msg("IDS_MSGF_BODY_SIM_MEMORY_FULL_DELETE_SOME_ITEMS").cStr()); + } + if (result == MsgStorage::StorageSuccess) + notification_status_message_post(msg("IDS_MSGC_POP_COPIED_TO_SIM_CARD").cStr()); } Evas_Object *ConvListItem::getBubbleContent() { - auto *bubble = new BubbleItemContainer(*getOwner()); - for (BubbleEntity *entity : m_BubbleEntityList) { - BubbleViewItem *item = entity->createView(*bubble); - if (item) { - bubble->append(*item, entity->getDirection()); - item->setListener(this); - } - } - bubble->go(); - bubble->show(); - return *bubble; + auto *bubble = new BubbleItemContainer(*getOwner()); + for (BubbleEntity *entity : m_BubbleEntityList) { + BubbleViewItem *item = entity->createView(*bubble); + if (item) { + bubble->append(*item, entity->getDirection()); + item->setListener(this); + } + } + bubble->go(); + bubble->show(); + return *bubble; } Evas_Object *ConvListItem::getThumbnail() { - static const int thumbSize = 80; - return m_App.getThumbnailMaker().getThumb(*getOwner(), m_ThumbId, thumbSize); + static const int thumbSize = 80; + return m_App.getThumbnailMaker().getThumb(*getOwner(), m_ThumbId, thumbSize); } Evas_Object *ConvListItem::getProgress() { - return m_NetworkStatus == Message::NS_Send_Pending || - m_NetworkStatus == Message::NS_Sending || - m_NetworkStatus == Message::NS_Retrieving ? createProgress() : nullptr; + return m_NetworkStatus == Message::NS_Send_Pending || + m_NetworkStatus == Message::NS_Sending || + m_NetworkStatus == Message::NS_Retrieving ? createProgress() : nullptr; } std::string ConvListItem::getTime() { - if (m_TimeStr.empty()) - m_TimeStr = TimeUtils::makeBubbleTimeString(m_Time); - return m_TimeStr; + if (m_TimeStr.empty()) + m_TimeStr = TimeUtils::makeBubbleTimeString(m_Time); + return m_TimeStr; } std::string ConvListItem::getMsgType() { - return MsgUtils::isMms(m_Type) ? (std::string)msg("IDS_MSGF_BODY_MMS") : (std::string)msg("WDS_MSG_SBODY_SMS_ABB"); + return MsgUtils::isMms(m_Type) ? (std::string)msg("IDS_MSGF_BODY_MMS") : (std::string)msg("WDS_MSG_SBODY_SMS_ABB"); } MsgId ConvListItem::getMsgId() const { - return m_MsgId; + return m_MsgId; } time_t ConvListItem::getRawTime() const { - return m_Time; + return m_Time; } void ConvListItem::setListener(IConvListItemListener *l) { - m_pListener = l; + m_pListener = l; } void ConvListItem::showPopup() { - m_IsDraft ? showDraftListPopup() : showMainListPopup(); + m_IsDraft ? showDraftListPopup() : showMainListPopup(); } void ConvListItem::showMainListPopup() { - auto &listPopup = m_App.getPopupManager().getPopupList(this); - listPopup.setTitle(msg("IDS_MSGF_BODY_MESSAGE_OPTIONS")); + auto &listPopup = m_App.getPopupManager().getPopupList(this); + listPopup.setTitle(msg("IDS_MSGF_BODY_MESSAGE_OPTIONS")); - std::string msgText = getAllMsgText(); + std::string msgText = getAllMsgText(); - if (m_NetworkStatus == Message::NS_Send_Fail) - listPopup.appendItem(msg("IDS_MSG_OPT_RESEND"), POPUPLIST_ITEM_PRESSED_CB(ConvListItem, onResendItemPressed), this); + if (m_NetworkStatus == Message::NS_Send_Fail) + listPopup.appendItem(msg("IDS_MSG_OPT_RESEND"), POPUPLIST_ITEM_PRESSED_CB(ConvListItem, onResendItemPressed), this); - listPopup.appendItem(msg("IDS_MSG_OPT_DELETE"), POPUPLIST_ITEM_PRESSED_CB(ConvListItem, onDeleteItemPressed), this); + listPopup.appendItem(msg("IDS_MSG_OPT_DELETE"), POPUPLIST_ITEM_PRESSED_CB(ConvListItem, onDeleteItemPressed), this); - if (m_Type == Message::MT_MMS) - listPopup.appendItem(msg("IDS_MSG_OPT_VIEW_AS_SLIDESHOW_ABB"), POPUPLIST_ITEM_PRESSED_CB(ConvListItem, onSlideShowItemPressed), this); - if (m_Type == Message::MT_MMS_Noti && m_NetworkStatus != Message::NS_Retrieving) - listPopup.appendItem(msg("IDS_MSG_BUTTON_DOWNLOAD_ABB3"), POPUPLIST_ITEM_PRESSED_CB(ConvListItem, onDownloadItemPressed), this); + if (m_Type == Message::MT_MMS) + listPopup.appendItem(msg("IDS_MSG_OPT_VIEW_AS_SLIDESHOW_ABB"), POPUPLIST_ITEM_PRESSED_CB(ConvListItem, onSlideShowItemPressed), this); + if (m_Type == Message::MT_MMS_Noti && m_NetworkStatus != Message::NS_Retrieving) + listPopup.appendItem(msg("IDS_MSG_BUTTON_DOWNLOAD_ABB3"), POPUPLIST_ITEM_PRESSED_CB(ConvListItem, onDownloadItemPressed), this); - if (!msgText.empty()) - listPopup.appendItem(msg("IDS_MSG_OPT_COPY_TEXT"), POPUPLIST_ITEM_PRESSED_CB(ConvListItem, onCopyTextItemPressed), this); + if (!msgText.empty()) + listPopup.appendItem(msg("IDS_MSG_OPT_COPY_TEXT"), POPUPLIST_ITEM_PRESSED_CB(ConvListItem, onCopyTextItemPressed), this); - if (!m_IsRestrictedByDpm) { - listPopup.appendItem(msg("IDS_MSGF_OPT_FORWARD"), POPUPLIST_ITEM_PRESSED_CB(ConvListItem, onForwardItemPressed), this); - listPopup.appendItem(msg("IDS_COM_BUTTON_SHARE"), POPUPLIST_ITEM_PRESSED_CB(ConvListItem, onShareItemPressed), this); - } + if (!m_IsRestrictedByDpm) { + listPopup.appendItem(msg("IDS_MSGF_OPT_FORWARD"), POPUPLIST_ITEM_PRESSED_CB(ConvListItem, onForwardItemPressed), this); + listPopup.appendItem(msg("IDS_COM_BUTTON_SHARE"), POPUPLIST_ITEM_PRESSED_CB(ConvListItem, onShareItemPressed), this); + } - if (m_NetworkStatus == Message::NS_Send_Fail) - listPopup.appendItem(msg("IDS_MSG_OPT_EDIT"), POPUPLIST_ITEM_PRESSED_CB(ConvListItem, onEditItemPressed), this); + if (m_NetworkStatus == Message::NS_Send_Fail) + listPopup.appendItem(msg("IDS_MSG_OPT_EDIT"), POPUPLIST_ITEM_PRESSED_CB(ConvListItem, onEditItemPressed), this); - if (m_Type == Message::MT_MMS) { - MessageMmsRef mms = std::dynamic_pointer_cast(m_App.getMsgEngine().getStorage().getMessage(m_MsgId)); - if (mms && (!mms->getAttachmentList().isEmpty() || mms->getMediaCount() > 0)) - listPopup.appendItem(msg("IDS_MSG_OPT_SAVE_ATTACHMENTS_ABB"), POPUPLIST_ITEM_PRESSED_CB(ConvListItem, onSaveAttachmentsItemPressed), this); - } + if (m_Type == Message::MT_MMS) { + MessageMmsRef mms = std::dynamic_pointer_cast(m_App.getMsgEngine().getStorage().getMessage(m_MsgId)); + if (mms && (!mms->getAttachmentList().isEmpty() || mms->getMediaCount() > 0)) + listPopup.appendItem(msg("IDS_MSG_OPT_SAVE_ATTACHMENTS_ABB"), POPUPLIST_ITEM_PRESSED_CB(ConvListItem, onSaveAttachmentsItemPressed), this); + } - if (!msgText.empty() && - m_Type == Message::MT_SMS && - (m_NetworkStatus == Message::NS_Send_Success || m_NetworkStatus == Message::NS_Received)) - listPopup.appendItem(msg("IDS_MSG_OPT_COPY_TO_SIM_CARD_ABB"), POPUPLIST_ITEM_PRESSED_CB(ConvListItem, onCopyToSimCardItemPressed), this); + if (!msgText.empty() && + m_Type == Message::MT_SMS && + (m_NetworkStatus == Message::NS_Send_Success || m_NetworkStatus == Message::NS_Received)) + listPopup.appendItem(msg("IDS_MSG_OPT_COPY_TO_SIM_CARD_ABB"), POPUPLIST_ITEM_PRESSED_CB(ConvListItem, onCopyToSimCardItemPressed), this); - listPopup.appendItem(msg("IDS_MSG_OPT_VIEW_DETAILS_ABB"), POPUPLIST_ITEM_PRESSED_CB(ConvListItem, onViewDetailsItemPressed), this); - listPopup.show(); + listPopup.appendItem(msg("IDS_MSG_OPT_VIEW_DETAILS_ABB"), POPUPLIST_ITEM_PRESSED_CB(ConvListItem, onViewDetailsItemPressed), this); + listPopup.show(); } void ConvListItem::tryToDownloadMms(bool showToast) { - if (!m_App.getSysSettingsManager().isMessagingRestrictedByDpm()) { - MsgTransport::SendResult res = m_App.getMsgEngine().getTransport().retrieveMessage(m_MsgId); - if (res == MsgTransport::SendSuccess) { - auto *button = findDownloadButton(); - if (button) { - button->disabled(true); - updateContent(); - } - } - } else if (showToast) { - notification_status_message_post(msg("IDS_MSG_TPOP_SECURITY_POLICY_RESTRICTS_DOWNLOADING_MULTIMEDIA_MESSAGES").cStr()); - } + if (!m_App.getSysSettingsManager().isMessagingRestrictedByDpm()) { + MsgTransport::SendResult res = m_App.getMsgEngine().getTransport().retrieveMessage(m_MsgId); + if (res == MsgTransport::SendSuccess) { + auto *button = findDownloadButton(); + if (button) { + button->disabled(true); + updateContent(); + } + } + } else if (showToast) { + notification_status_message_post(msg("IDS_MSG_TPOP_SECURITY_POLICY_RESTRICTS_DOWNLOADING_MULTIMEDIA_MESSAGES").cStr()); + } } void ConvListItem::showDraftListPopup() { - auto &listPopup = m_App.getPopupManager().getPopupList(this); - listPopup.setTitle(msg("IDS_MSGF_BODY_MESSAGE_OPTIONS")); - listPopup.appendItem(msg("IDS_MSGF_OPT_EDIT_MESSAGE"), POPUPLIST_ITEM_PRESSED_CB(ConvListItem, onEditItemPressed), this); - listPopup.appendItem(msg("IDS_MSG_OPT_DELETE"), POPUPLIST_ITEM_PRESSED_CB(ConvListItem, onDeleteItemPressed), this); - listPopup.show(); + auto &listPopup = m_App.getPopupManager().getPopupList(this); + listPopup.setTitle(msg("IDS_MSGF_BODY_MESSAGE_OPTIONS")); + listPopup.appendItem(msg("IDS_MSGF_OPT_EDIT_MESSAGE"), POPUPLIST_ITEM_PRESSED_CB(ConvListItem, onEditItemPressed), this); + listPopup.appendItem(msg("IDS_MSG_OPT_DELETE"), POPUPLIST_ITEM_PRESSED_CB(ConvListItem, onDeleteItemPressed), this); + listPopup.show(); } void ConvListItem::showFailedToSendPopup() { - Popup &popup = m_App.getPopupManager().getPopup(this); - popup.addButton(msgt("IDS_MSG_BUTTON_CANCEL_ABB"), Popup::CancelButtonId, POPUP_BUTTON_CB(ConvListItem, onCancelButtonClicked), this); - popup.addButton(msgt("IDS_MSG_BUTTON_RESEND_ABB"), Popup::OkButtonId, POPUP_BUTTON_CB(ConvListItem, onFailedResendButtonClicked), this); - popup.setTitle(msgt("IDS_MSG_HEADER_COULDNT_SEND_MESSAGE_ABB")); - popup.setContent(msgt("IDS_MSG_POP_THIS_MESSAGE_WILL_BE_RESENT")); - popup.show(); + Popup &popup = m_App.getPopupManager().getPopup(this); + popup.addButton(msgt("IDS_MSG_BUTTON_CANCEL_ABB"), Popup::CancelButtonId, POPUP_BUTTON_CB(ConvListItem, onCancelButtonClicked), this); + popup.addButton(msgt("IDS_MSG_BUTTON_RESEND_ABB"), Popup::OkButtonId, POPUP_BUTTON_CB(ConvListItem, onFailedResendButtonClicked), this); + popup.setTitle(msgt("IDS_MSG_HEADER_COULDNT_SEND_MESSAGE_ABB")); + popup.setContent(msgt("IDS_MSG_POP_THIS_MESSAGE_WILL_BE_RESENT")); + popup.show(); } void ConvListItem::onDeleteItemPressed(PopupListItem &item) { - item.getParent().destroy(); - Popup &popup = m_App.getPopupManager().getPopup(this); - popup.addButton(msgt("IDS_MSG_BUTTON_CANCEL_ABB"), Popup::CancelButtonId, POPUP_BUTTON_CB(ConvListItem, onCancelButtonClicked), this); - popup.addButton(msgt("IDS_MSG_BUTTON_DELETE_ABB4"), Popup::OkButtonId, POPUP_BUTTON_CB(ConvListItem, onDeleteButtonClicked), this); - popup.setTitle(msgt("IDS_MSG_HEADER_DELETE")); - popup.setContent(msgt("IDS_MSG_POP_1_MESSAGE_WILL_BE_DELETED")); - popup.show(); + item.getParent().destroy(); + Popup &popup = m_App.getPopupManager().getPopup(this); + popup.addButton(msgt("IDS_MSG_BUTTON_CANCEL_ABB"), Popup::CancelButtonId, POPUP_BUTTON_CB(ConvListItem, onCancelButtonClicked), this); + popup.addButton(msgt("IDS_MSG_BUTTON_DELETE_ABB4"), Popup::OkButtonId, POPUP_BUTTON_CB(ConvListItem, onDeleteButtonClicked), this); + popup.setTitle(msgt("IDS_MSG_HEADER_DELETE")); + popup.setContent(msgt("IDS_MSG_POP_1_MESSAGE_WILL_BE_DELETED")); + popup.show(); } void ConvListItem::onDownloadItemPressed(PopupListItem &item) { - MSG_LOG(""); - item.getParent().destroy(); - tryToDownloadMms(); + MSG_LOG(""); + item.getParent().destroy(); + tryToDownloadMms(); } void ConvListItem::onAction(BubbleViewItem &item) { - MSG_LOG(""); + MSG_LOG(""); - switch (item.getEntity().getType()) { - case BubbleEntity::DownloadButtonItem: - tryToDownloadMms(); - break; - case BubbleEntity::TextItem: - break; - default: - const std::string &filePath = item.getEntity().getFilePath(); - if (!filePath.empty()) - m_FileViewer.launchWithCopy(filePath); - break; - } + switch (item.getEntity().getType()) { + case BubbleEntity::DownloadButtonItem: + tryToDownloadMms(); + break; + case BubbleEntity::TextItem: + break; + default: + const std::string &filePath = item.getEntity().getFilePath(); + if (!filePath.empty()) + m_FileViewer.launchWithCopy(filePath); + break; + } } void ConvListItem::onCopyTextItemPressed(PopupListItem &item) { - item.getParent().destroy(); - std::string text = getAllMsgText(); - if (!text.empty()) - elm_cnp_selection_set(*getOwner(), ELM_SEL_TYPE_CLIPBOARD, ELM_SEL_FORMAT_TEXT, text.c_str(), text.length()); + item.getParent().destroy(); + std::string text = getAllMsgText(); + if (!text.empty()) + elm_cnp_selection_set(*getOwner(), ELM_SEL_TYPE_CLIPBOARD, ELM_SEL_FORMAT_TEXT, text.c_str(), text.length()); } std::string ConvListItem::getAllMsgText() const { - // Warning: slow function - MessageRef msg = m_App.getMsgEngine().getStorage().getMessage(m_MsgId); - return msg ? msg->getText() : ""; + // Warning: slow function + MessageRef msg = m_App.getMsgEngine().getStorage().getMessage(m_MsgId); + return msg ? msg->getText() : ""; } void ConvListItem::onForwardItemPressed(PopupListItem &item) { - MSG_LOG(""); - item.getParent().destroy(); - if (m_pListener) - m_pListener->onForwardMsg(*this); + MSG_LOG(""); + item.getParent().destroy(); + if (m_pListener) + m_pListener->onForwardMsg(*this); } void ConvListItem::onShareItemPressed(PopupListItem &item) { - MSG_LOG(""); - item.getParent().destroy(); - shareContent(); + MSG_LOG(""); + item.getParent().destroy(); + shareContent(); } void ConvListItem::onResendItemPressed(PopupListItem &item) { - MSG_LOG(""); - showFailedToSendPopup(); + MSG_LOG(""); + showFailedToSendPopup(); } void ConvListItem::onSlideShowItemPressed(PopupListItem &item) { - MSG_LOG(""); - item.getParent().destroy(); - if (m_pListener) - m_pListener->onSlideShow(*this); + MSG_LOG(""); + item.getParent().destroy(); + if (m_pListener) + m_pListener->onSlideShow(*this); } void ConvListItem::onEditItemPressed(PopupListItem &item) { - MSG_LOG(""); - item.getParent().destroy(); - if (m_pListener) - m_pListener->onEditDraftMsg(*this); + MSG_LOG(""); + item.getParent().destroy(); + if (m_pListener) + m_pListener->onEditDraftMsg(*this); } void ConvListItem::onSaveAttachmentsItemPressed(PopupListItem &item) { - MSG_LOG(""); - item.getParent().destroy(); - if (m_pListener) - m_pListener->onSaveAttachments(*this); + MSG_LOG(""); + item.getParent().destroy(); + if (m_pListener) + m_pListener->onSaveAttachments(*this); } void ConvListItem::onCopyToSimCardItemPressed(PopupListItem &item) { - MSG_LOG(""); - item.getParent().destroy(); - copyMsgToSimCard(); + MSG_LOG(""); + item.getParent().destroy(); + copyMsgToSimCard(); } void ConvListItem::onViewDetailsItemPressed(PopupListItem &item) { - MSG_LOG(""); - m_App.getPopupManager().getPopup(m_App, m_MsgId, this).show(); + MSG_LOG(""); + m_App.getPopupManager().getPopup(m_App, m_MsgId, this).show(); } void ConvListItem::onEditButtonClicked(Evas_Object *obj, void *event_info) { - MSG_LOG(""); - if (m_pListener) - m_pListener->onEditDraftMsg(*this); + MSG_LOG(""); + if (m_pListener) + m_pListener->onEditDraftMsg(*this); } void ConvListItem::onFailedButtonClicked(Evas_Object *obj, void *event_info) { - MSG_LOG(""); - showFailedToSendPopup(); + MSG_LOG(""); + showFailedToSendPopup(); } void ConvListItem::onCancelButtonClicked(Popup &popup, int buttonId) { - MSG_LOG(""); - popup.destroy(); + MSG_LOG(""); + popup.destroy(); } void ConvListItem::onFailedResendButtonClicked(Popup &popup, int buttonId) { - MSG_LOG(""); - popup.destroy(); - if (m_pListener) - m_pListener->onResendMsg(*this); + MSG_LOG(""); + popup.destroy(); + if (m_pListener) + m_pListener->onResendMsg(*this); } void ConvListItem::onDeleteButtonClicked(Popup &popup, int buttonId) { - m_App.getMsgEngine().getStorage().deleteMessage(getMsgId()); - popup.destroy(); + m_App.getMsgEngine().getStorage().deleteMessage(getMsgId()); + popup.destroy(); } diff --git a/src/Conversation/ConvList/Controller/src/DateLineItem.cpp b/src/Conversation/ConvList/Controller/src/DateLineItem.cpp index 7e5192a1..32b17592 100644 --- a/src/Conversation/ConvList/Controller/src/DateLineItem.cpp +++ b/src/Conversation/ConvList/Controller/src/DateLineItem.cpp @@ -20,14 +20,14 @@ using namespace Msg; DateLineItem::DateLineItem(time_t dateTime) - : DateLineViewItem(TimeUtils::makeBubbleDateLineString(dateTime)) - , m_Time(dateTime) + : DateLineViewItem(TimeUtils::makeBubbleDateLineString(dateTime)) + , m_Time(dateTime) { } DateLineItem::DateLineItem(time_t dateTime, const std::string &dateTimeStr) - : DateLineViewItem(dateTimeStr) - , m_Time(dateTime) + : DateLineViewItem(dateTimeStr) + , m_Time(dateTime) { } @@ -37,5 +37,5 @@ DateLineItem::~DateLineItem() void DateLineItem::update() { - setDateLine(TimeUtils::makeBubbleDateLineString(m_Time)); + setDateLine(TimeUtils::makeBubbleDateLineString(m_Time)); } diff --git a/src/Conversation/ConvList/Controller/src/MsgDetailsPopup.cpp b/src/Conversation/ConvList/Controller/src/MsgDetailsPopup.cpp index 43656840..3af41220 100644 --- a/src/Conversation/ConvList/Controller/src/MsgDetailsPopup.cpp +++ b/src/Conversation/ConvList/Controller/src/MsgDetailsPopup.cpp @@ -23,78 +23,78 @@ using namespace Msg; using namespace MessageDetailContent; MsgDetailsPopup::MsgDetailsPopup(PopupManager &mngr, App &app, MsgId msgId) - : Popup(mngr) - , m_App(app) - , m_MsgId(msgId) + : Popup(mngr) + , m_App(app) + , m_MsgId(msgId) { - m_App.getSysSettingsManager().addListener(*this); - m_App.getContactManager().addListener(*this); - addButton(msgt("IDS_MSG_BUTTON_OK_ABB"), Popup::OkButtonId); - setTitle(msgt("IDS_MSGF_HEADER_MESSAGE_DETAILS")); - updateContent(); + m_App.getSysSettingsManager().addListener(*this); + m_App.getContactManager().addListener(*this); + addButton(msgt("IDS_MSG_BUTTON_OK_ABB"), Popup::OkButtonId); + setTitle(msgt("IDS_MSGF_HEADER_MESSAGE_DETAILS")); + updateContent(); } MsgDetailsPopup::~MsgDetailsPopup() { - m_App.getSysSettingsManager().removeListener(*this); - m_App.getContactManager().removeListener(*this); + m_App.getSysSettingsManager().removeListener(*this); + m_App.getContactManager().removeListener(*this); } void MsgDetailsPopup::updateContent() { - static const std::string brTag = "

"; + static const std::string brTag = "

"; - std::string content; - MsgStorage &msgStorage = m_App.getMsgEngine().getStorage(); - MessageRef message = msgStorage.getMessage(m_MsgId); - Message::Direction msgDirection = message->getDirection(); - Message::Type msgType = message->getType(); - Message::NetworkStatus msgStatus = message->getNetworkStatus(); - ThreadId msgThreadId = message->getThreadId(); + std::string content; + MsgStorage &msgStorage = m_App.getMsgEngine().getStorage(); + MessageRef message = msgStorage.getMessage(m_MsgId); + Message::Direction msgDirection = message->getDirection(); + Message::Type msgType = message->getType(); + Message::NetworkStatus msgStatus = message->getNetworkStatus(); + ThreadId msgThreadId = message->getThreadId(); - content += getMessageType(msgType); - content += getContactsInfo(m_App, msgDirection, msgThreadId); - content += getSentReceivedTime(*message, msgDirection); + content += getMessageType(msgType); + content += getContactsInfo(m_App, msgDirection, msgThreadId); + content += getSentReceivedTime(*message, msgDirection); - if (msgDirection == Message::MD_Sent && msgType == Message::MT_SMS) { - content += brTag; - content += makeDeliveryReportResult(m_App, msgStatus, msgType, msgThreadId, m_MsgId); - content += getSmsStatus(msgStatus); - } else if (msgType == Message::MT_MMS_Noti) { - content += brTag; - content += getMmsSubject(*message, ViewDetailsTextStyle); - content += getMmsMessageSize(*message, ViewDetailsTextStyle); - content += getMmsMessageExpired(*message, ViewDetailsTextStyle); - } else if (msgType == Message::MT_MMS) { - content += brTag; - content += getMmsSubject(*message, ViewDetailsTextStyle); - content += getMmsMessageSize(*message, ViewDetailsTextStyle); + if (msgDirection == Message::MD_Sent && msgType == Message::MT_SMS) { + content += brTag; + content += makeDeliveryReportResult(m_App, msgStatus, msgType, msgThreadId, m_MsgId); + content += getSmsStatus(msgStatus); + } else if (msgType == Message::MT_MMS_Noti) { + content += brTag; + content += getMmsSubject(*message, ViewDetailsTextStyle); + content += getMmsMessageSize(*message, ViewDetailsTextStyle); + content += getMmsMessageExpired(*message, ViewDetailsTextStyle); + } else if (msgType == Message::MT_MMS) { + content += brTag; + content += getMmsSubject(*message, ViewDetailsTextStyle); + content += getMmsMessageSize(*message, ViewDetailsTextStyle); - if (msgDirection == Message::MD_Sent) { - content += brTag; - content += makeDeliveryReportResult(m_App, msgStatus, msgType, msgThreadId, m_MsgId); - content += makeReadReportResult(m_App, m_MsgId, msgThreadId, msgStatus); - } - } + if (msgDirection == Message::MD_Sent) { + content += brTag; + content += makeDeliveryReportResult(m_App, msgStatus, msgType, msgThreadId, m_MsgId); + content += makeReadReportResult(m_App, m_MsgId, msgThreadId, msgStatus); + } + } - setContent(content); + setContent(content); } void MsgDetailsPopup::onContactChanged() { - MSG_LOG(""); - updateContent(); + MSG_LOG(""); + updateContent(); } void MsgDetailsPopup::onLanguageChanged() { - MSG_LOG(""); - updateContent(); + MSG_LOG(""); + updateContent(); } void MsgDetailsPopup::onTimeFormatChanged() { - MSG_LOG(""); - updateContent(); + MSG_LOG(""); + updateContent(); } diff --git a/src/Conversation/ConvList/View/inc/BubbleAudioViewItem.h b/src/Conversation/ConvList/View/inc/BubbleAudioViewItem.h index bee59ce0..f0397417 100644 --- a/src/Conversation/ConvList/View/inc/BubbleAudioViewItem.h +++ b/src/Conversation/ConvList/View/inc/BubbleAudioViewItem.h @@ -21,22 +21,22 @@ #include "Resource.h" namespace Msg { - class BubbleAudioViewItem - : public BubbleIconTextLayoutItem { - public: - BubbleAudioViewItem(BubbleEntity &entity, Evas_Object *parent, BgType bgType); - virtual ~BubbleAudioViewItem(); - }; + class BubbleAudioViewItem + : public BubbleIconTextLayoutItem { + public: + BubbleAudioViewItem(BubbleEntity &entity, Evas_Object *parent, BgType bgType); + virtual ~BubbleAudioViewItem(); + }; - inline BubbleAudioViewItem::BubbleAudioViewItem(BubbleEntity &entity, Evas_Object *parent, BgType bgType) - : BubbleIconTextLayoutItem(entity, parent, bgType, Layout1Icon2Text) - { - setIcon(createIcon(ATTACH_MUSIC_ICON)); - } + inline BubbleAudioViewItem::BubbleAudioViewItem(BubbleEntity &entity, Evas_Object *parent, BgType bgType) + : BubbleIconTextLayoutItem(entity, parent, bgType, Layout1Icon2Text) + { + setIcon(createIcon(ATTACH_MUSIC_ICON)); + } - inline BubbleAudioViewItem::~BubbleAudioViewItem() - { - } + inline BubbleAudioViewItem::~BubbleAudioViewItem() + { + } } #endif /* BubbleAudioViewItem_h_ */ diff --git a/src/Conversation/ConvList/View/inc/BubbleBgViewItem.h b/src/Conversation/ConvList/View/inc/BubbleBgViewItem.h index 1cc14f13..92578188 100644 --- a/src/Conversation/ConvList/View/inc/BubbleBgViewItem.h +++ b/src/Conversation/ConvList/View/inc/BubbleBgViewItem.h @@ -20,39 +20,39 @@ #include "BubbleViewItem.h" namespace Msg { - class BubbleBgViewItem - : public BubbleViewItem { - public: - enum BgType { - SentStyle, - ReceivedStyle, - DraftStyle, - FailedStyle, - RestrictedStyle - }; - static const int bgPadLeft = 34; - static const int bgPadRight = 34; - - public: - BubbleBgViewItem(BubbleEntity &entity, Evas_Object *parent, BgType bgType); - virtual ~BubbleBgViewItem(); - - BgType getBgType() const; - void showSearch(bool search); - void setContent(Evas_Object *obj); - Evas_Object *getContent() const; - - static std::string applyColor(const std::string &text, BgType bgType); - static void applyColor(Evas_Object *obj, BgType bgType); - std::string applyColor(const std::string &text) const; - void applyColor(Evas_Object *obj) const; - - private: - Evas_Object *createGestureRect(Evas_Object *parent); - - private: - BgType m_BgType; - }; + class BubbleBgViewItem + : public BubbleViewItem { + public: + enum BgType { + SentStyle, + ReceivedStyle, + DraftStyle, + FailedStyle, + RestrictedStyle + }; + static const int bgPadLeft = 34; + static const int bgPadRight = 34; + + public: + BubbleBgViewItem(BubbleEntity &entity, Evas_Object *parent, BgType bgType); + virtual ~BubbleBgViewItem(); + + BgType getBgType() const; + void showSearch(bool search); + void setContent(Evas_Object *obj); + Evas_Object *getContent() const; + + static std::string applyColor(const std::string &text, BgType bgType); + static void applyColor(Evas_Object *obj, BgType bgType); + std::string applyColor(const std::string &text) const; + void applyColor(Evas_Object *obj) const; + + private: + Evas_Object *createGestureRect(Evas_Object *parent); + + private: + BgType m_BgType; + }; } #endif /* BubbleBgViewItem_h_ */ diff --git a/src/Conversation/ConvList/View/inc/BubbleCalEventViewItem.h b/src/Conversation/ConvList/View/inc/BubbleCalEventViewItem.h index 6d0281f4..66a1fc1d 100644 --- a/src/Conversation/ConvList/View/inc/BubbleCalEventViewItem.h +++ b/src/Conversation/ConvList/View/inc/BubbleCalEventViewItem.h @@ -21,22 +21,22 @@ #include "Resource.h" namespace Msg { - class BubbleCalEventViewItem - : public BubbleIconTextLayoutItem { - public: - BubbleCalEventViewItem(BubbleEntity &entity, Evas_Object *parent, BgType bgType, LayoutType layoutType); - virtual ~BubbleCalEventViewItem(); - }; + class BubbleCalEventViewItem + : public BubbleIconTextLayoutItem { + public: + BubbleCalEventViewItem(BubbleEntity &entity, Evas_Object *parent, BgType bgType, LayoutType layoutType); + virtual ~BubbleCalEventViewItem(); + }; - inline BubbleCalEventViewItem::BubbleCalEventViewItem(BubbleEntity &entity, Evas_Object *parent, BgType bgType, LayoutType layoutType) - : BubbleIconTextLayoutItem(entity, parent, bgType, layoutType) - { - setIcon(createIcon(ATTACH_CAL_ICON)); - } + inline BubbleCalEventViewItem::BubbleCalEventViewItem(BubbleEntity &entity, Evas_Object *parent, BgType bgType, LayoutType layoutType) + : BubbleIconTextLayoutItem(entity, parent, bgType, layoutType) + { + setIcon(createIcon(ATTACH_CAL_ICON)); + } - inline BubbleCalEventViewItem::~BubbleCalEventViewItem() - { - } + inline BubbleCalEventViewItem::~BubbleCalEventViewItem() + { + } } #endif /* BubbleCalEventViewItem_h_ */ diff --git a/src/Conversation/ConvList/View/inc/BubbleContactViewItem.h b/src/Conversation/ConvList/View/inc/BubbleContactViewItem.h index 76d7a8d5..c46b28f7 100644 --- a/src/Conversation/ConvList/View/inc/BubbleContactViewItem.h +++ b/src/Conversation/ConvList/View/inc/BubbleContactViewItem.h @@ -21,21 +21,21 @@ #include "Resource.h" namespace Msg { - class BubbleContactViewItem - : public BubbleIconTextLayoutItem { - public: - BubbleContactViewItem(BubbleEntity &entity, Evas_Object *parent, BgType bgType, LayoutType type); - virtual ~BubbleContactViewItem(); - }; + class BubbleContactViewItem + : public BubbleIconTextLayoutItem { + public: + BubbleContactViewItem(BubbleEntity &entity, Evas_Object *parent, BgType bgType, LayoutType type); + virtual ~BubbleContactViewItem(); + }; - inline BubbleContactViewItem::BubbleContactViewItem(BubbleEntity &entity, Evas_Object *parent, BgType bgType, LayoutType type) - : BubbleIconTextLayoutItem(entity, parent, bgType, type) - { - } + inline BubbleContactViewItem::BubbleContactViewItem(BubbleEntity &entity, Evas_Object *parent, BgType bgType, LayoutType type) + : BubbleIconTextLayoutItem(entity, parent, bgType, type) + { + } - inline BubbleContactViewItem::~BubbleContactViewItem() - { - } + inline BubbleContactViewItem::~BubbleContactViewItem() + { + } } #endif /* BubbleContactViewItem_h_ */ diff --git a/src/Conversation/ConvList/View/inc/BubbleDownloadButtonViewItem.h b/src/Conversation/ConvList/View/inc/BubbleDownloadButtonViewItem.h index d3e9096d..44cb3f70 100644 --- a/src/Conversation/ConvList/View/inc/BubbleDownloadButtonViewItem.h +++ b/src/Conversation/ConvList/View/inc/BubbleDownloadButtonViewItem.h @@ -20,17 +20,17 @@ #include "BubbleViewItem.h" namespace Msg { - class BubbleDownloadButtonViewItem - : public BubbleViewItem { - public: - BubbleDownloadButtonViewItem(BubbleEntity &entity, Evas_Object *parent); - virtual ~BubbleDownloadButtonViewItem(); + class BubbleDownloadButtonViewItem + : public BubbleViewItem { + public: + BubbleDownloadButtonViewItem(BubbleEntity &entity, Evas_Object *parent); + virtual ~BubbleDownloadButtonViewItem(); - void disabled(bool status); + void disabled(bool status); - private: - void onPressed(Evas_Object *obj, void *eventInfo); - }; + private: + void onPressed(Evas_Object *obj, void *eventInfo); + }; } #endif /* BubbleDownloadButtonViewItem_h_ */ diff --git a/src/Conversation/ConvList/View/inc/BubbleIconTextLayoutItem.h b/src/Conversation/ConvList/View/inc/BubbleIconTextLayoutItem.h index 13a66832..97d24974 100644 --- a/src/Conversation/ConvList/View/inc/BubbleIconTextLayoutItem.h +++ b/src/Conversation/ConvList/View/inc/BubbleIconTextLayoutItem.h @@ -20,32 +20,32 @@ #include "BubbleBgViewItem.h" namespace Msg { - class BubbleIconTextLayoutItem - : public BubbleBgViewItem { - public: - enum LayoutType { - Layout1Icon1Text, - Layout1Icon2Text - }; - static const int iconSize = 50; - - public: - BubbleIconTextLayoutItem(BubbleEntity &entity, Evas_Object *parent, BgType bgType, LayoutType layoutType); - virtual ~BubbleIconTextLayoutItem(); - - LayoutType getLayoutType() const; - void setIcon(Evas_Object *icon); - void setMainText(const std::string &text); - void setSubText(const std::string &text); - virtual void calculate(); - - static Evas_Object *createIcon(Evas_Object *parent, const std::string &edjFileName, BgType bgType); - Evas_Object *createIcon(const std::string &edjFileName) const; - - private: - LayoutType m_LayoutType; - Evas_Object *m_pIconTextLayout; - }; + class BubbleIconTextLayoutItem + : public BubbleBgViewItem { + public: + enum LayoutType { + Layout1Icon1Text, + Layout1Icon2Text + }; + static const int iconSize = 50; + + public: + BubbleIconTextLayoutItem(BubbleEntity &entity, Evas_Object *parent, BgType bgType, LayoutType layoutType); + virtual ~BubbleIconTextLayoutItem(); + + LayoutType getLayoutType() const; + void setIcon(Evas_Object *icon); + void setMainText(const std::string &text); + void setSubText(const std::string &text); + virtual void calculate(); + + static Evas_Object *createIcon(Evas_Object *parent, const std::string &edjFileName, BgType bgType); + Evas_Object *createIcon(const std::string &edjFileName) const; + + private: + LayoutType m_LayoutType; + Evas_Object *m_pIconTextLayout; + }; } #endif /* BubbleIconTextLayoutItem_h_ */ diff --git a/src/Conversation/ConvList/View/inc/BubbleImageViewItem.h b/src/Conversation/ConvList/View/inc/BubbleImageViewItem.h index 73ea4f9e..c72765fe 100644 --- a/src/Conversation/ConvList/View/inc/BubbleImageViewItem.h +++ b/src/Conversation/ConvList/View/inc/BubbleImageViewItem.h @@ -20,15 +20,15 @@ #include "BubbleViewItem.h" namespace Msg { - class BubbleImageViewItem - : public BubbleViewItem { - public: - BubbleImageViewItem(BubbleEntity &entity, Evas_Object *parent, const std::string &imagePath); - virtual ~BubbleImageViewItem(); + class BubbleImageViewItem + : public BubbleViewItem { + public: + BubbleImageViewItem(BubbleEntity &entity, Evas_Object *parent, const std::string &imagePath); + virtual ~BubbleImageViewItem(); - private: - Evas_Object *createImage(Evas_Object *parent, const std::string &path); - }; + private: + Evas_Object *createImage(Evas_Object *parent, const std::string &path); + }; } #endif /* BubbleImageViewItem_h_ */ diff --git a/src/Conversation/ConvList/View/inc/BubbleItemContainer.h b/src/Conversation/ConvList/View/inc/BubbleItemContainer.h index 825cda57..f2237fae 100644 --- a/src/Conversation/ConvList/View/inc/BubbleItemContainer.h +++ b/src/Conversation/ConvList/View/inc/BubbleItemContainer.h @@ -21,15 +21,15 @@ #include "Message.h" namespace Msg { - class BubbleItemContainer - : public View { - public: - BubbleItemContainer(Evas_Object *parent); - virtual ~BubbleItemContainer(); + class BubbleItemContainer + : public View { + public: + BubbleItemContainer(Evas_Object *parent); + virtual ~BubbleItemContainer(); - void append(BubbleViewItem &item, Message::Direction direction); - void go(); - }; + void append(BubbleViewItem &item, Message::Direction direction); + void go(); + }; } #endif /* BubbleItemContainer_h_ */ diff --git a/src/Conversation/ConvList/View/inc/BubbleTextViewItem.h b/src/Conversation/ConvList/View/inc/BubbleTextViewItem.h index f556b01a..58877133 100644 --- a/src/Conversation/ConvList/View/inc/BubbleTextViewItem.h +++ b/src/Conversation/ConvList/View/inc/BubbleTextViewItem.h @@ -20,15 +20,15 @@ #include "BubbleBgViewItem.h" namespace Msg { - class BubbleTextViewItem - : public BubbleBgViewItem { - public: - BubbleTextViewItem(BubbleEntity &entity, Evas_Object *parent, BgType bgType, const std::string &text); - virtual ~BubbleTextViewItem(); + class BubbleTextViewItem + : public BubbleBgViewItem { + public: + BubbleTextViewItem(BubbleEntity &entity, Evas_Object *parent, BgType bgType, const std::string &text); + virtual ~BubbleTextViewItem(); - private: - Evas_Object *createText(Evas_Object *parent, const std::string &text); - }; + private: + Evas_Object *createText(Evas_Object *parent, const std::string &text); + }; } #endif /* BubbleTextViewItem_h_ */ diff --git a/src/Conversation/ConvList/View/inc/BubbleUnknownFileViewItem.h b/src/Conversation/ConvList/View/inc/BubbleUnknownFileViewItem.h index 77761c97..c539dd68 100644 --- a/src/Conversation/ConvList/View/inc/BubbleUnknownFileViewItem.h +++ b/src/Conversation/ConvList/View/inc/BubbleUnknownFileViewItem.h @@ -21,22 +21,22 @@ #include "Resource.h" namespace Msg { - class BubbleUnknownFileViewItem - : public BubbleIconTextLayoutItem { - public: - BubbleUnknownFileViewItem(BubbleEntity &entity, Evas_Object *parent, BgType bgType); - virtual ~BubbleUnknownFileViewItem(); - }; + class BubbleUnknownFileViewItem + : public BubbleIconTextLayoutItem { + public: + BubbleUnknownFileViewItem(BubbleEntity &entity, Evas_Object *parent, BgType bgType); + virtual ~BubbleUnknownFileViewItem(); + }; - inline BubbleUnknownFileViewItem::BubbleUnknownFileViewItem(BubbleEntity &entity, Evas_Object *parent, BgType bgType) - : BubbleIconTextLayoutItem(entity, parent, bgType, Layout1Icon1Text) - { - setIcon(createIcon(ATTACH_UNKNOWN_ICON)); - } + inline BubbleUnknownFileViewItem::BubbleUnknownFileViewItem(BubbleEntity &entity, Evas_Object *parent, BgType bgType) + : BubbleIconTextLayoutItem(entity, parent, bgType, Layout1Icon1Text) + { + setIcon(createIcon(ATTACH_UNKNOWN_ICON)); + } - inline BubbleUnknownFileViewItem::~BubbleUnknownFileViewItem() - { - } + inline BubbleUnknownFileViewItem::~BubbleUnknownFileViewItem() + { + } } #endif /* BubbleUnknownFileViewItem_h_ */ diff --git a/src/Conversation/ConvList/View/inc/BubbleVideoViewItem.h b/src/Conversation/ConvList/View/inc/BubbleVideoViewItem.h index 012245fb..85340c48 100644 --- a/src/Conversation/ConvList/View/inc/BubbleVideoViewItem.h +++ b/src/Conversation/ConvList/View/inc/BubbleVideoViewItem.h @@ -20,15 +20,15 @@ #include "BubbleViewItem.h" namespace Msg { - class BubbleVideoViewItem - : public BubbleViewItem { - public: - BubbleVideoViewItem(BubbleEntity &entity, Evas_Object *parent, const std::string &imagePath); - virtual ~BubbleVideoViewItem(); + class BubbleVideoViewItem + : public BubbleViewItem { + public: + BubbleVideoViewItem(BubbleEntity &entity, Evas_Object *parent, const std::string &imagePath); + virtual ~BubbleVideoViewItem(); - private: - Evas_Object *createIamge(Evas_Object *parent, const std::string &path); - }; + private: + Evas_Object *createIamge(Evas_Object *parent, const std::string &path); + }; } #endif /* BubbleVideoViewItem_h_ */ diff --git a/src/Conversation/ConvList/View/inc/BubbleViewItem.h b/src/Conversation/ConvList/View/inc/BubbleViewItem.h index 54923b6b..c28c6893 100644 --- a/src/Conversation/ConvList/View/inc/BubbleViewItem.h +++ b/src/Conversation/ConvList/View/inc/BubbleViewItem.h @@ -21,41 +21,41 @@ #include namespace Msg { - class IBubbleViewItemListener; - class BubbleEntity; - - class BubbleViewItem - : public View { - public: - static const int maxWidth = 408; - - BubbleViewItem(BubbleEntity &entity); - virtual ~BubbleViewItem(); - - virtual void calculate(); - void setListener(IBubbleViewItemListener *l); - BubbleEntity &getEntity(); - void showDelButton(bool show); - - protected: - void emitActionEvent(); - void attachGestureTapLayer(Evas_Object *parent, Evas_Object *obj); - - private: - void onDelButtonClicked(Evas_Object *obj, void *eventInfo); - - private: - BubbleEntity &m_Entity; - IBubbleViewItemListener *m_pListener; - Evas_Object *m_pDelButton; - }; - - class IBubbleViewItemListener { - public: - virtual ~IBubbleViewItemListener() {}; - virtual void onAction(BubbleViewItem &item) {}; // Tap or Click - virtual void onDelClicked(BubbleViewItem &item) {}; // Delete button clicked - }; + class IBubbleViewItemListener; + class BubbleEntity; + + class BubbleViewItem + : public View { + public: + static const int maxWidth = 408; + + BubbleViewItem(BubbleEntity &entity); + virtual ~BubbleViewItem(); + + virtual void calculate(); + void setListener(IBubbleViewItemListener *l); + BubbleEntity &getEntity(); + void showDelButton(bool show); + + protected: + void emitActionEvent(); + void attachGestureTapLayer(Evas_Object *parent, Evas_Object *obj); + + private: + void onDelButtonClicked(Evas_Object *obj, void *eventInfo); + + private: + BubbleEntity &m_Entity; + IBubbleViewItemListener *m_pListener; + Evas_Object *m_pDelButton; + }; + + class IBubbleViewItemListener { + public: + virtual ~IBubbleViewItemListener() {}; + virtual void onAction(BubbleViewItem &item) {}; // Tap or Click + virtual void onDelClicked(BubbleViewItem &item) {}; // Delete button clicked + }; } #endif /* BubbleViewItem_h_ */ diff --git a/src/Conversation/ConvList/View/inc/ComposeListViewItem.h b/src/Conversation/ConvList/View/inc/ComposeListViewItem.h index 7ccad59c..f7c3014e 100644 --- a/src/Conversation/ConvList/View/inc/ComposeListViewItem.h +++ b/src/Conversation/ConvList/View/inc/ComposeListViewItem.h @@ -20,28 +20,28 @@ #include "ListItem.h" namespace Msg { - class ComposeListViewItem - : public ListItem { - public: - ComposeListViewItem(); - virtual ~ComposeListViewItem(); + class ComposeListViewItem + : public ListItem { + public: + ComposeListViewItem(); + virtual ~ComposeListViewItem(); - void show(bool show); - void navigate(); - bool isVisible() const; + void show(bool show); + void navigate(); + bool isVisible() const; - protected: - virtual Evas_Object *getBubbleContent() = 0; + protected: + virtual Evas_Object *getBubbleContent() = 0; - void updateBubblePart(); + void updateBubblePart(); - private: - virtual Evas_Object *getContent(ListItem &item, const char *part); - virtual bool getFilter(ListItem &item, void *key); + private: + virtual Evas_Object *getContent(ListItem &item, const char *part); + virtual bool getFilter(ListItem &item, void *key); - private: - bool m_Visibility; - }; + private: + bool m_Visibility; + }; } #endif /* ComposeListViewItem_H_ */ diff --git a/src/Conversation/ConvList/View/inc/ConvListLayout.h b/src/Conversation/ConvList/View/inc/ConvListLayout.h index 5b6047e4..cc8d5e21 100644 --- a/src/Conversation/ConvList/View/inc/ConvListLayout.h +++ b/src/Conversation/ConvList/View/inc/ConvListLayout.h @@ -20,20 +20,20 @@ #include "View.h" namespace Msg { - class ConvListLayout - : public View { - public: - ConvListLayout(Evas_Object *parent); - virtual ~ConvListLayout(); + class ConvListLayout + : public View { + public: + ConvListLayout(Evas_Object *parent); + virtual ~ConvListLayout(); - protected: - void showSelectAllMode(bool value); - void setBubbleList(Evas_Object *layout); - void setSelectAll(Evas_Object *layout); + protected: + void showSelectAllMode(bool value); + void setBubbleList(Evas_Object *layout); + void setSelectAll(Evas_Object *layout); - private: - void create(Evas_Object *parent); - }; + private: + void create(Evas_Object *parent); + }; } #endif /* ConvListLayout_h_ */ diff --git a/src/Conversation/ConvList/View/inc/ConvListViewItem.h b/src/Conversation/ConvList/View/inc/ConvListViewItem.h index aee2ea3a..0aaa7f4b 100644 --- a/src/Conversation/ConvList/View/inc/ConvListViewItem.h +++ b/src/Conversation/ConvList/View/inc/ConvListViewItem.h @@ -20,51 +20,51 @@ #include "ListItem.h" namespace Msg { - class ConvListViewItem - : public ListItem { - public: - enum ConvItemType { - InitType, - Sent, - Received, - Draft, - Failed - }; + class ConvListViewItem + : public ListItem { + public: + enum ConvItemType { + InitType, + Sent, + Received, + Draft, + Failed + }; - ConvListViewItem(ConvItemType type); - virtual ~ConvListViewItem(); - static void resetCheckMode(ListView &listView); + ConvListViewItem(ConvItemType type); + virtual ~ConvListViewItem(); + static void resetCheckMode(ListView &listView); - protected: - virtual Evas_Object *getBubbleContent() = 0; - virtual Evas_Object *getThumbnail() = 0; - virtual Evas_Object *getProgress() = 0; - virtual std::string getTime() = 0; - virtual std::string getMsgType() = 0; + protected: + virtual Evas_Object *getBubbleContent() = 0; + virtual Evas_Object *getThumbnail() = 0; + virtual Evas_Object *getProgress() = 0; + virtual std::string getTime() = 0; + virtual std::string getMsgType() = 0; - virtual void onEditButtonClicked(Evas_Object *obj, void *event_info) = 0; - virtual void onFailedButtonClicked(Evas_Object *obj, void *event_info) = 0; + virtual void onEditButtonClicked(Evas_Object *obj, void *event_info) = 0; + virtual void onFailedButtonClicked(Evas_Object *obj, void *event_info) = 0; - void showSearch(); + void showSearch(); - protected: - Evas_Object *createProgress(); - void updateProgress(); - void updateContent(); - void updateItemType(ConvItemType type); - virtual void onRealized(ListItem &item); - virtual void onUnrealized(ListItem &item); + protected: + Evas_Object *createProgress(); + void updateProgress(); + void updateContent(); + void updateItemType(ConvItemType type); + virtual void onRealized(ListItem &item); + virtual void onUnrealized(ListItem &item); - private: - Evas_Object *createButton(bool isEnabled, ConvItemType type); - virtual std::string getText(ListItem &item, const char *part); - virtual Evas_Object *getContent(ListItem &item, const char *part); - virtual const char *getCheckPart(ListItem &item); + private: + Evas_Object *createButton(bool isEnabled, ConvItemType type); + virtual std::string getText(ListItem &item, const char *part); + virtual Evas_Object *getContent(ListItem &item, const char *part); + virtual const char *getCheckPart(ListItem &item); - private: - bool m_SearchMode; - ConvItemType m_Type; - }; + private: + bool m_SearchMode; + ConvItemType m_Type; + }; } #endif /* ConvListViewItem_H_ */ diff --git a/src/Conversation/ConvList/View/inc/ConvSelectAll.h b/src/Conversation/ConvList/View/inc/ConvSelectAll.h index 2cf2fac0..f4208316 100644 --- a/src/Conversation/ConvList/View/inc/ConvSelectAll.h +++ b/src/Conversation/ConvList/View/inc/ConvSelectAll.h @@ -21,25 +21,25 @@ #include "LangUtils.h" namespace Msg { - class ConvSelectAll - : public View { - public: - ConvSelectAll(Evas_Object *parent); - virtual ~ConvSelectAll(); + class ConvSelectAll + : public View { + public: + ConvSelectAll(Evas_Object *parent); + virtual ~ConvSelectAll(); - void setText(const std::string &text); - void setText(const TText &text); - void addCheckCallback(Evas_Smart_Cb cb, void *userData); - bool getCheckState() const; - void setCheckState(bool check); + void setText(const std::string &text); + void setText(const TText &text); + void addCheckCallback(Evas_Smart_Cb cb, void *userData); + bool getCheckState() const; + void setCheckState(bool check); - private: - Evas_Object *createCheck(Evas_Object *parent); - static void onLayoutClicked(void *data, Evas_Object *obj, const char *emission, const char *source); + private: + Evas_Object *createCheck(Evas_Object *parent); + static void onLayoutClicked(void *data, Evas_Object *obj, const char *emission, const char *source); - private: - Evas_Object *m_pCheck; - }; + private: + Evas_Object *m_pCheck; + }; } #endif // ConvSelectAll_h_ diff --git a/src/Conversation/ConvList/View/inc/DateLineViewItem.h b/src/Conversation/ConvList/View/inc/DateLineViewItem.h index e68d27c4..135d2069 100644 --- a/src/Conversation/ConvList/View/inc/DateLineViewItem.h +++ b/src/Conversation/ConvList/View/inc/DateLineViewItem.h @@ -20,23 +20,23 @@ #include "ListItem.h" namespace Msg { - class DateLineViewItem - : public ListItem { - public: - DateLineViewItem(const std::string &dateLine); - virtual ~DateLineViewItem(); + class DateLineViewItem + : public ListItem { + public: + DateLineViewItem(const std::string &dateLine); + virtual ~DateLineViewItem(); - std::string getDateLine() const; + std::string getDateLine() const; - protected: - void setDateLine(const std::string &dateLine); + protected: + void setDateLine(const std::string &dateLine); - private: - virtual std::string getText(ListItem &item, const char *part); + private: + virtual std::string getText(ListItem &item, const char *part); - private: - std::string m_DateLine; - }; + private: + std::string m_DateLine; + }; } #endif /* DateLineViewItem_H_ */ diff --git a/src/Conversation/ConvList/View/src/BubbleBgViewItem.cpp b/src/Conversation/ConvList/View/src/BubbleBgViewItem.cpp index c35ac170..1cd3d4f1 100644 --- a/src/Conversation/ConvList/View/src/BubbleBgViewItem.cpp +++ b/src/Conversation/ConvList/View/src/BubbleBgViewItem.cpp @@ -26,31 +26,31 @@ const std::string redTextColor = "#b8293e"; #define DARK_OBJ_COLOR 128, 128, 128, 255 BubbleBgViewItem::BubbleBgViewItem(BubbleEntity &entity, Evas_Object *parent, BgType bgType) - : BubbleViewItem(entity) - , m_BgType(bgType) + : BubbleViewItem(entity) + , m_BgType(bgType) { - const char *group = nullptr; - switch (bgType) { - case SentStyle: - group = "conv/list/bubble_sent_bg"; - break; - case ReceivedStyle: - group = "conv/list/bubble_received_bg"; - break; - case DraftStyle: - group = "conv/list/bubble_draft_bg"; - break; - case FailedStyle: - group = "conv/list/bubble_failed_bg"; - break; - case RestrictedStyle: - group = "conv/list/bubble_restricted_bg"; - break; - } + const char *group = nullptr; + switch (bgType) { + case SentStyle: + group = "conv/list/bubble_sent_bg"; + break; + case ReceivedStyle: + group = "conv/list/bubble_received_bg"; + break; + case DraftStyle: + group = "conv/list/bubble_draft_bg"; + break; + case FailedStyle: + group = "conv/list/bubble_failed_bg"; + break; + case RestrictedStyle: + group = "conv/list/bubble_restricted_bg"; + break; + } - setEo(addLayout(parent, CONV_LIST_BUBBLE_EDJ_PATH, group)); - View::setContent(createGestureRect(getEo()), "swl.gesture"); - evas_object_size_hint_align_set(getEo(), 1.0, EVAS_HINT_FILL); + setEo(addLayout(parent, CONV_LIST_BUBBLE_EDJ_PATH, group)); + View::setContent(createGestureRect(getEo()), "swl.gesture"); + evas_object_size_hint_align_set(getEo(), 1.0, EVAS_HINT_FILL); } BubbleBgViewItem::~BubbleBgViewItem() @@ -59,53 +59,53 @@ BubbleBgViewItem::~BubbleBgViewItem() BubbleBgViewItem::BgType BubbleBgViewItem::getBgType() const { - return m_BgType; + return m_BgType; } void BubbleBgViewItem::setContent(Evas_Object *obj) { - View::setContent(obj, "content"); + View::setContent(obj, "content"); } Evas_Object *BubbleBgViewItem::getContent() const { - return View::getContent("content"); + return View::getContent("content"); } void BubbleBgViewItem::showSearch(bool search) { - // TODO: impl + // TODO: impl } std::string BubbleBgViewItem::applyColor(const std::string &text, BgType bgType) { - const std::string &color = (bgType == RestrictedStyle) ? redTextColor : (bgType == SentStyle || bgType == ReceivedStyle) ? whiteTextColor : darkTextColor; - return TextDecorator::make(text, color); + const std::string &color = (bgType == RestrictedStyle) ? redTextColor : (bgType == SentStyle || bgType == ReceivedStyle) ? whiteTextColor : darkTextColor; + return TextDecorator::make(text, color); } void BubbleBgViewItem::applyColor(Evas_Object *obj, BgType bgType) { - if (bgType == SentStyle || bgType == ReceivedStyle) - evas_object_color_set(obj, WHITE_OBJ_COLOR); - else - evas_object_color_set(obj, DARK_OBJ_COLOR); + if (bgType == SentStyle || bgType == ReceivedStyle) + evas_object_color_set(obj, WHITE_OBJ_COLOR); + else + evas_object_color_set(obj, DARK_OBJ_COLOR); } std::string BubbleBgViewItem::applyColor(const std::string &text) const { - return applyColor(text, m_BgType); + return applyColor(text, m_BgType); } void BubbleBgViewItem::applyColor(Evas_Object *obj) const { - applyColor(obj, m_BgType); + applyColor(obj, m_BgType); } Evas_Object *BubbleBgViewItem::createGestureRect(Evas_Object *parent) { - Evas *e = evas_object_rectangle_add(evas_object_evas_get(parent)); - Evas_Object *rect = evas_object_rectangle_add(e); - evas_object_color_set(rect, 0, 0, 0, 0); - attachGestureTapLayer(parent, rect); - return rect; + Evas *e = evas_object_rectangle_add(evas_object_evas_get(parent)); + Evas_Object *rect = evas_object_rectangle_add(e); + evas_object_color_set(rect, 0, 0, 0, 0); + attachGestureTapLayer(parent, rect); + return rect; } diff --git a/src/Conversation/ConvList/View/src/BubbleDownloadButtonViewItem.cpp b/src/Conversation/ConvList/View/src/BubbleDownloadButtonViewItem.cpp index e5106db2..1dd42c2d 100644 --- a/src/Conversation/ConvList/View/src/BubbleDownloadButtonViewItem.cpp +++ b/src/Conversation/ConvList/View/src/BubbleDownloadButtonViewItem.cpp @@ -20,15 +20,15 @@ using namespace Msg; BubbleDownloadButtonViewItem::BubbleDownloadButtonViewItem(BubbleEntity &entity, Evas_Object *parent) - : BubbleViewItem(entity) + : BubbleViewItem(entity) { - Evas_Object *button = elm_button_add(parent); - evas_object_propagate_events_set(button, false); - setEo(button); - expand(); - setText(msgt("IDS_MSG_BUTTON_DOWNLOAD_ABB3")); - evas_object_smart_callback_add(button, "clicked", SMART_CALLBACK(BubbleDownloadButtonViewItem, onPressed), this); - evas_object_show(button); + Evas_Object *button = elm_button_add(parent); + evas_object_propagate_events_set(button, false); + setEo(button); + expand(); + setText(msgt("IDS_MSG_BUTTON_DOWNLOAD_ABB3")); + evas_object_smart_callback_add(button, "clicked", SMART_CALLBACK(BubbleDownloadButtonViewItem, onPressed), this); + evas_object_show(button); } BubbleDownloadButtonViewItem::~BubbleDownloadButtonViewItem() @@ -37,11 +37,11 @@ BubbleDownloadButtonViewItem::~BubbleDownloadButtonViewItem() void BubbleDownloadButtonViewItem::disabled(bool status) { - elm_object_disabled_set(getEo(), status); - processSignal(); + elm_object_disabled_set(getEo(), status); + processSignal(); } void BubbleDownloadButtonViewItem::onPressed(Evas_Object *obj, void *eventInfo) { - emitActionEvent(); + emitActionEvent(); } diff --git a/src/Conversation/ConvList/View/src/BubbleIconTextLayoutItem.cpp b/src/Conversation/ConvList/View/src/BubbleIconTextLayoutItem.cpp index ca163107..4326cda1 100644 --- a/src/Conversation/ConvList/View/src/BubbleIconTextLayoutItem.cpp +++ b/src/Conversation/ConvList/View/src/BubbleIconTextLayoutItem.cpp @@ -24,23 +24,23 @@ using namespace Msg; BubbleIconTextLayoutItem::BubbleIconTextLayoutItem(BubbleEntity &entity, Evas_Object *parent, BgType bgType, LayoutType layoutType) - : BubbleBgViewItem(entity, parent, bgType) - , m_LayoutType(layoutType) - , m_pIconTextLayout(nullptr) + : BubbleBgViewItem(entity, parent, bgType) + , m_LayoutType(layoutType) + , m_pIconTextLayout(nullptr) { - const char *group = nullptr; - switch (layoutType) { - case Layout1Icon1Text: - group = "conv/list/1icon_1text"; - break; + const char *group = nullptr; + switch (layoutType) { + case Layout1Icon1Text: + group = "conv/list/1icon_1text"; + break; - case Layout1Icon2Text: - group = "conv/list/1icon_2text"; - break; - } + case Layout1Icon2Text: + group = "conv/list/1icon_2text"; + break; + } - m_pIconTextLayout = addLayout(getEo(), CONV_LIST_BUBBLE_EDJ_PATH, group); - setContent(m_pIconTextLayout); + m_pIconTextLayout = addLayout(getEo(), CONV_LIST_BUBBLE_EDJ_PATH, group); + setContent(m_pIconTextLayout); } BubbleIconTextLayoutItem::~BubbleIconTextLayoutItem() @@ -49,41 +49,41 @@ BubbleIconTextLayoutItem::~BubbleIconTextLayoutItem() void BubbleIconTextLayoutItem::setIcon(Evas_Object *icon) { - elm_object_part_content_set(m_pIconTextLayout, "icon", icon); + elm_object_part_content_set(m_pIconTextLayout, "icon", icon); } void BubbleIconTextLayoutItem::setMainText(const std::string &text) { - elm_object_part_text_set(m_pIconTextLayout, "main.text", applyColor(text).c_str()); + elm_object_part_text_set(m_pIconTextLayout, "main.text", applyColor(text).c_str()); } void BubbleIconTextLayoutItem::setSubText(const std::string &text) { - elm_object_part_text_set(m_pIconTextLayout, "sub.text", applyColor(text).c_str()); + elm_object_part_text_set(m_pIconTextLayout, "sub.text", applyColor(text).c_str()); } Evas_Object *BubbleIconTextLayoutItem::createIcon(Evas_Object *parent, const std::string &edjFileName, BgType bgType) { - Evas_Object *icon = elm_icon_add(parent); - std::string resPath = PathUtils::getResourcePath(IMAGES_EDJ_PATH); - elm_image_file_set(icon, resPath.c_str(), edjFileName.c_str()); - applyColor(icon, bgType); - evas_object_show(icon); - return icon; + Evas_Object *icon = elm_icon_add(parent); + std::string resPath = PathUtils::getResourcePath(IMAGES_EDJ_PATH); + elm_image_file_set(icon, resPath.c_str(), edjFileName.c_str()); + applyColor(icon, bgType); + evas_object_show(icon); + return icon; } Evas_Object *BubbleIconTextLayoutItem::createIcon(const std::string &edjFileName) const { - return createIcon(*this, edjFileName, getBgType()); + return createIcon(*this, edjFileName, getBgType()); } BubbleIconTextLayoutItem::LayoutType BubbleIconTextLayoutItem::getLayoutType() const { - return m_LayoutType; + return m_LayoutType; } void BubbleIconTextLayoutItem::calculate() { - evas_object_smart_calculate(m_pIconTextLayout); - BubbleBgViewItem::calculate(); + evas_object_smart_calculate(m_pIconTextLayout); + BubbleBgViewItem::calculate(); } diff --git a/src/Conversation/ConvList/View/src/BubbleImageViewItem.cpp b/src/Conversation/ConvList/View/src/BubbleImageViewItem.cpp index 78f6c38a..6269ad1c 100644 --- a/src/Conversation/ConvList/View/src/BubbleImageViewItem.cpp +++ b/src/Conversation/ConvList/View/src/BubbleImageViewItem.cpp @@ -20,12 +20,12 @@ using namespace Msg; BubbleImageViewItem::BubbleImageViewItem(BubbleEntity &entity, Evas_Object *parent, const std::string &imagePath) - : BubbleViewItem(entity) + : BubbleViewItem(entity) { - setEo(addLayout(parent, CONV_LIST_BUBBLE_EDJ_PATH, "conv/list/image_item")); - Evas_Object *img = createImage(parent, imagePath); - setContent(img, "content"); - attachGestureTapLayer(getEo(), img); + setEo(addLayout(parent, CONV_LIST_BUBBLE_EDJ_PATH, "conv/list/image_item")); + Evas_Object *img = createImage(parent, imagePath); + setContent(img, "content"); + attachGestureTapLayer(getEo(), img); } BubbleImageViewItem::~BubbleImageViewItem() @@ -34,22 +34,22 @@ BubbleImageViewItem::~BubbleImageViewItem() Evas_Object *BubbleImageViewItem::createImage(Evas_Object *parent, const std::string &path) { - int imageWidth = 0; - int imageHeight = 0; + int imageWidth = 0; + int imageHeight = 0; - Evas_Object *image = elm_image_add(parent); - elm_image_preload_disabled_set(image, true); - elm_image_prescale_set(image, maxWidth); - elm_image_aspect_fixed_set(image, true); - elm_image_file_set(image, path.c_str(), nullptr); - elm_image_object_size_get(image, &imageWidth, &imageHeight); - if (imageWidth > maxWidth) { - double scale = maxWidth/(double)imageWidth; - imageWidth *= scale; - imageHeight *= scale; - } - evas_object_size_hint_min_set(image, imageWidth, imageHeight); - evas_object_size_hint_align_set(image, 1.0, EVAS_HINT_FILL); - evas_object_show(image); - return image; + Evas_Object *image = elm_image_add(parent); + elm_image_preload_disabled_set(image, true); + elm_image_prescale_set(image, maxWidth); + elm_image_aspect_fixed_set(image, true); + elm_image_file_set(image, path.c_str(), nullptr); + elm_image_object_size_get(image, &imageWidth, &imageHeight); + if (imageWidth > maxWidth) { + double scale = maxWidth/(double)imageWidth; + imageWidth *= scale; + imageHeight *= scale; + } + evas_object_size_hint_min_set(image, imageWidth, imageHeight); + evas_object_size_hint_align_set(image, 1.0, EVAS_HINT_FILL); + evas_object_show(image); + return image; } diff --git a/src/Conversation/ConvList/View/src/BubbleItemContainer.cpp b/src/Conversation/ConvList/View/src/BubbleItemContainer.cpp index 0de4c011..12b9a2ca 100644 --- a/src/Conversation/ConvList/View/src/BubbleItemContainer.cpp +++ b/src/Conversation/ConvList/View/src/BubbleItemContainer.cpp @@ -22,18 +22,18 @@ using namespace Msg; namespace { - const int verticalBoxPads = 10; - const int horizontalBoxPads = 0; + const int verticalBoxPads = 10; + const int horizontalBoxPads = 0; } BubbleItemContainer::BubbleItemContainer(Evas_Object *parent) { - Evas_Object *box = elm_box_add(parent); - elm_box_homogeneous_set(box, false); - elm_box_padding_set(box, ELM_SCALE_SIZE(horizontalBoxPads), ELM_SCALE_SIZE(verticalBoxPads)); - setEo(box); - expand(); - show(); + Evas_Object *box = elm_box_add(parent); + elm_box_homogeneous_set(box, false); + elm_box_padding_set(box, ELM_SCALE_SIZE(horizontalBoxPads), ELM_SCALE_SIZE(verticalBoxPads)); + setEo(box); + expand(); + show(); } BubbleItemContainer::~BubbleItemContainer() @@ -42,22 +42,22 @@ BubbleItemContainer::~BubbleItemContainer() void BubbleItemContainer::append(BubbleViewItem &item, Message::Direction direction) { - const char *itemType = evas_object_type_get(item); - if (strcmp(itemType, "elm_button") == 0) - expand(item); - else if (direction == Message::MD_Sent) - evas_object_size_hint_align_set(item, 1.0, EVAS_HINT_FILL); - else - evas_object_size_hint_align_set(item, 0.0, EVAS_HINT_FILL); - - item.calculate(); - item.show(); - elm_box_pack_end(getEo(), item); + const char *itemType = evas_object_type_get(item); + if (strcmp(itemType, "elm_button") == 0) + expand(item); + else if (direction == Message::MD_Sent) + evas_object_size_hint_align_set(item, 1.0, EVAS_HINT_FILL); + else + evas_object_size_hint_align_set(item, 0.0, EVAS_HINT_FILL); + + item.calculate(); + item.show(); + elm_box_pack_end(getEo(), item); } void BubbleItemContainer::go() { - elm_box_recalculate(getEo()); + elm_box_recalculate(getEo()); } diff --git a/src/Conversation/ConvList/View/src/BubbleTextViewItem.cpp b/src/Conversation/ConvList/View/src/BubbleTextViewItem.cpp index 2c3f7d20..e09964c5 100644 --- a/src/Conversation/ConvList/View/src/BubbleTextViewItem.cpp +++ b/src/Conversation/ConvList/View/src/BubbleTextViewItem.cpp @@ -21,9 +21,9 @@ using namespace Msg; BubbleTextViewItem::BubbleTextViewItem(BubbleEntity &entity, Evas_Object *parent, BgType bgType, const std::string &text) - : BubbleBgViewItem(entity, parent, bgType) + : BubbleBgViewItem(entity, parent, bgType) { - setContent(createText(*this, applyColor(text))); + setContent(createText(*this, applyColor(text))); } BubbleTextViewItem::~BubbleTextViewItem() @@ -32,27 +32,27 @@ BubbleTextViewItem::~BubbleTextViewItem() Evas_Object *BubbleTextViewItem::createText(Evas_Object *parent, const std::string &text) { - if (text.empty()) - return nullptr; + if (text.empty()) + return nullptr; - static const int maxTextWidth = maxWidth - (bgPadLeft + bgPadRight); + static const int maxTextWidth = maxWidth - (bgPadLeft + bgPadRight); - Evas_Object *label = elm_label_add(parent); - elm_object_style_set(label, "conv_bubble"); + Evas_Object *label = elm_label_add(parent); + elm_object_style_set(label, "conv_bubble"); - elm_label_line_wrap_set(label, ELM_WRAP_MIXED); - elm_object_part_text_set(label, nullptr, text.c_str()); - evas_object_show(label); + elm_label_line_wrap_set(label, ELM_WRAP_MIXED); + elm_object_part_text_set(label, nullptr, text.c_str()); + evas_object_show(label); - Evas_Object *edjeLabel = elm_layout_edje_get(label); - const Evas_Object *textBlock = edje_object_part_object_get(edjeLabel, "elm.text"); + Evas_Object *edjeLabel = elm_layout_edje_get(label); + const Evas_Object *textBlock = edje_object_part_object_get(edjeLabel, "elm.text"); - Evas_Coord ww = 0; - Evas_Coord hh = 0; + Evas_Coord ww = 0; + Evas_Coord hh = 0; - evas_object_textblock_size_native_get(textBlock, &ww, &hh); - int wrapWidth = ww > maxTextWidth ? maxTextWidth : ww; - elm_label_wrap_width_set(label, wrapWidth); + evas_object_textblock_size_native_get(textBlock, &ww, &hh); + int wrapWidth = ww > maxTextWidth ? maxTextWidth : ww; + elm_label_wrap_width_set(label, wrapWidth); - return label; + return label; } diff --git a/src/Conversation/ConvList/View/src/BubbleVideoViewItem.cpp b/src/Conversation/ConvList/View/src/BubbleVideoViewItem.cpp index fd3faefb..853c3543 100644 --- a/src/Conversation/ConvList/View/src/BubbleVideoViewItem.cpp +++ b/src/Conversation/ConvList/View/src/BubbleVideoViewItem.cpp @@ -20,14 +20,14 @@ using namespace Msg; BubbleVideoViewItem::BubbleVideoViewItem(BubbleEntity &entity, Evas_Object *parent, const std::string &imagePath) - : BubbleViewItem(entity) + : BubbleViewItem(entity) { - Evas_Object *layout = addLayout(parent, CONV_LIST_BUBBLE_EDJ_PATH, "conv/list/video_item"); - setEo(layout); - Evas_Object *image = createIamge(layout, imagePath); - attachGestureTapLayer(layout, image); - setContent(image, "content"); - show(); + Evas_Object *layout = addLayout(parent, CONV_LIST_BUBBLE_EDJ_PATH, "conv/list/video_item"); + setEo(layout); + Evas_Object *image = createIamge(layout, imagePath); + attachGestureTapLayer(layout, image); + setContent(image, "content"); + show(); } BubbleVideoViewItem::~BubbleVideoViewItem() @@ -36,18 +36,18 @@ BubbleVideoViewItem::~BubbleVideoViewItem() Evas_Object *BubbleVideoViewItem::createIamge(Evas_Object *parent, const std::string &path) { - Evas_Object *image = elm_image_add(parent); - elm_image_prescale_set(image, maxWidth); - elm_image_file_set(image, path.c_str(), nullptr); - int imageWidth = 0; - int imageHeight = 0; - elm_image_object_size_get(image, &imageWidth, &imageHeight); - if (imageWidth > maxWidth) { - double scale = maxWidth/(double)imageWidth; - imageWidth *= scale; - imageHeight *= scale; - } - evas_object_size_hint_min_set(image, imageWidth, imageHeight); - evas_object_show(image); - return image; + Evas_Object *image = elm_image_add(parent); + elm_image_prescale_set(image, maxWidth); + elm_image_file_set(image, path.c_str(), nullptr); + int imageWidth = 0; + int imageHeight = 0; + elm_image_object_size_get(image, &imageWidth, &imageHeight); + if (imageWidth > maxWidth) { + double scale = maxWidth/(double)imageWidth; + imageWidth *= scale; + imageHeight *= scale; + } + evas_object_size_hint_min_set(image, imageWidth, imageHeight); + evas_object_show(image); + return image; } diff --git a/src/Conversation/ConvList/View/src/BubbleViewItem.cpp b/src/Conversation/ConvList/View/src/BubbleViewItem.cpp index c68bb479..427693bd 100644 --- a/src/Conversation/ConvList/View/src/BubbleViewItem.cpp +++ b/src/Conversation/ConvList/View/src/BubbleViewItem.cpp @@ -21,9 +21,9 @@ using namespace Msg; BubbleViewItem::BubbleViewItem(BubbleEntity &entity) - : m_Entity(entity) - , m_pListener(nullptr) - , m_pDelButton(nullptr) + : m_Entity(entity) + , m_pListener(nullptr) + , m_pDelButton(nullptr) { } @@ -33,93 +33,93 @@ BubbleViewItem::~BubbleViewItem() void BubbleViewItem::setListener(IBubbleViewItemListener *l) { - m_pListener = l; + m_pListener = l; } BubbleEntity &BubbleViewItem::getEntity() { - return m_Entity; + return m_Entity; } void BubbleViewItem::attachGestureTapLayer(Evas_Object *parent, Evas_Object *obj) { - const int tapFingerSize = 12; - - Evas_Object *layer = elm_gesture_layer_add(parent); - evas_object_show(layer); - elm_gesture_layer_attach(layer, obj); - elm_gesture_layer_tap_finger_size_set(layer, ELM_SCALE_SIZE(tapFingerSize)); - - elm_gesture_layer_cb_add( - layer, - ELM_GESTURE_N_TAPS, - ELM_GESTURE_STATE_END, - [](void *data, void *event_info)->Evas_Event_Flags - { - auto *self = static_cast(data); - if (self) - self->emitActionEvent(); - return EVAS_EVENT_FLAG_NONE; - }, - this); + const int tapFingerSize = 12; + + Evas_Object *layer = elm_gesture_layer_add(parent); + evas_object_show(layer); + elm_gesture_layer_attach(layer, obj); + elm_gesture_layer_tap_finger_size_set(layer, ELM_SCALE_SIZE(tapFingerSize)); + + elm_gesture_layer_cb_add( + layer, + ELM_GESTURE_N_TAPS, + ELM_GESTURE_STATE_END, + [](void *data, void *event_info)->Evas_Event_Flags + { + auto *self = static_cast(data); + if (self) + self->emitActionEvent(); + return EVAS_EVENT_FLAG_NONE; + }, + this); } void BubbleViewItem::showDelButton(bool show) { - if (show && !m_pDelButton) { - m_pDelButton = elm_button_add(getEo()); - elm_object_style_set(m_pDelButton, "transparent"); - evas_object_smart_callback_add(m_pDelButton, "clicked", SMART_CALLBACK(BubbleViewItem, onDelButtonClicked), this); - elm_object_focus_allow_set(m_pDelButton, false); - evas_object_event_callback_add( - m_pDelButton, - EVAS_CALLBACK_MOUSE_DOWN, - [](void *data, Evas *e, Evas_Object *obj, void *event_info) - { - if (!elm_object_disabled_get(obj)) - emitSignal(elm_object_content_get(obj), "pressed", "*"); - }, - this); - evas_object_event_callback_add( - m_pDelButton, - EVAS_CALLBACK_MOUSE_UP, - [](void *data, Evas *e, Evas_Object *obj, void *event_info) - { - if (!elm_object_disabled_get(obj)) - emitSignal(elm_object_content_get(obj), "unpressed", "*"); - }, - this); - - const char *delButtonPart = "del_button"; - - Evas_Object *icon = View::addLayout(m_pDelButton, ICONS_EDJ_PATH, "attach_del_icon"); - elm_object_content_set(m_pDelButton, icon); - - setContent(m_pDelButton, delButtonPart); - if (!getContent(delButtonPart)) { - MSG_LOG_ERROR("Layout has not 'del_button' part"); - evas_object_del(m_pDelButton); - m_pDelButton = nullptr; - return; - } - } - const char *sig = show ? "show_del_button" : "hide_del_button"; - emitSignal(sig, "*"); + if (show && !m_pDelButton) { + m_pDelButton = elm_button_add(getEo()); + elm_object_style_set(m_pDelButton, "transparent"); + evas_object_smart_callback_add(m_pDelButton, "clicked", SMART_CALLBACK(BubbleViewItem, onDelButtonClicked), this); + elm_object_focus_allow_set(m_pDelButton, false); + evas_object_event_callback_add( + m_pDelButton, + EVAS_CALLBACK_MOUSE_DOWN, + [](void *data, Evas *e, Evas_Object *obj, void *event_info) + { + if (!elm_object_disabled_get(obj)) + emitSignal(elm_object_content_get(obj), "pressed", "*"); + }, + this); + evas_object_event_callback_add( + m_pDelButton, + EVAS_CALLBACK_MOUSE_UP, + [](void *data, Evas *e, Evas_Object *obj, void *event_info) + { + if (!elm_object_disabled_get(obj)) + emitSignal(elm_object_content_get(obj), "unpressed", "*"); + }, + this); + + const char *delButtonPart = "del_button"; + + Evas_Object *icon = View::addLayout(m_pDelButton, ICONS_EDJ_PATH, "attach_del_icon"); + elm_object_content_set(m_pDelButton, icon); + + setContent(m_pDelButton, delButtonPart); + if (!getContent(delButtonPart)) { + MSG_LOG_ERROR("Layout has not 'del_button' part"); + evas_object_del(m_pDelButton); + m_pDelButton = nullptr; + return; + } + } + const char *sig = show ? "show_del_button" : "hide_del_button"; + emitSignal(sig, "*"); } void BubbleViewItem::calculate() { - evas_object_smart_calculate(getEo()); + evas_object_smart_calculate(getEo()); } void BubbleViewItem::emitActionEvent() { - if (m_pListener) - m_pListener->onAction(*this); + if (m_pListener) + m_pListener->onAction(*this); } void BubbleViewItem::onDelButtonClicked(Evas_Object *obj, void *eventInfo) { - if (m_pListener) - m_pListener->onDelClicked(*this); + if (m_pListener) + m_pListener->onDelClicked(*this); } diff --git a/src/Conversation/ConvList/View/src/ComposeListViewItem.cpp b/src/Conversation/ConvList/View/src/ComposeListViewItem.cpp index bc383741..a4612f0c 100644 --- a/src/Conversation/ConvList/View/src/ComposeListViewItem.cpp +++ b/src/Conversation/ConvList/View/src/ComposeListViewItem.cpp @@ -22,13 +22,13 @@ using namespace Msg; namespace { - ListItemStyleRef sentStyle = ListItemStyle::create("sentbubble"); - const char *bubbleContentPart = "bubble.content"; + ListItemStyleRef sentStyle = ListItemStyle::create("sentbubble"); + const char *bubbleContentPart = "bubble.content"; } ComposeListViewItem::ComposeListViewItem() - : ListItem(sentStyle) - , m_Visibility(false) + : ListItem(sentStyle) + , m_Visibility(false) { } @@ -38,34 +38,34 @@ ComposeListViewItem::~ComposeListViewItem() Evas_Object *ComposeListViewItem::getContent(ListItem &item, const char *part) { - if (!strcmp(part, bubbleContentPart)) - return getBubbleContent(); + if (!strcmp(part, bubbleContentPart)) + return getBubbleContent(); - return nullptr; + return nullptr; } void ComposeListViewItem::updateBubblePart() { - updateFields(bubbleContentPart, ELM_GENLIST_ITEM_FIELD_CONTENT); + updateFields(bubbleContentPart, ELM_GENLIST_ITEM_FIELD_CONTENT); } bool ComposeListViewItem::getFilter(ListItem &item, void *key) { - return m_Visibility; + return m_Visibility; } void ComposeListViewItem::navigate() { - getOwner()->showItem(*this, ELM_GENLIST_ITEM_SCROLLTO_BOTTOM); + getOwner()->showItem(*this, ELM_GENLIST_ITEM_SCROLLTO_BOTTOM); } bool ComposeListViewItem::isVisible() const { - return m_Visibility; + return m_Visibility; } void ComposeListViewItem::show(bool show) { - m_Visibility = show; - getOwner()->setFilter(&m_Visibility); + m_Visibility = show; + getOwner()->setFilter(&m_Visibility); } diff --git a/src/Conversation/ConvList/View/src/ConvListLayout.cpp b/src/Conversation/ConvList/View/src/ConvListLayout.cpp index 3709b966..db6c6f97 100644 --- a/src/Conversation/ConvList/View/src/ConvListLayout.cpp +++ b/src/Conversation/ConvList/View/src/ConvListLayout.cpp @@ -19,12 +19,12 @@ using namespace Msg; namespace { - const char *layoutStyle = "conv_list_base"; + const char *layoutStyle = "conv_list_base"; } ConvListLayout::ConvListLayout(Evas_Object *parent) { - create(parent); + create(parent); } ConvListLayout::~ConvListLayout() @@ -33,24 +33,24 @@ ConvListLayout::~ConvListLayout() void ConvListLayout::showSelectAllMode(bool value) { - const char *signal = value ? "show.select":"hide.select"; - emitSignal(signal, "*"); + const char *signal = value ? "show.select":"hide.select"; + emitSignal(signal, "*"); } void ConvListLayout::setBubbleList(Evas_Object *layout) { - elm_object_part_content_set(getEo(), "swl.list", layout); + elm_object_part_content_set(getEo(), "swl.list", layout); } void ConvListLayout::setSelectAll(Evas_Object *layout) { - elm_object_part_content_set(getEo(), "swl.select", layout); + elm_object_part_content_set(getEo(), "swl.select", layout); } void ConvListLayout::create(Evas_Object *parent) { - setEo(elm_layout_add(parent)); - elm_layout_file_set(getEo(), PathUtils::getResourcePath(CONV_LIST_EDJ_PATH).c_str(), layoutStyle); - expand(); - show(); + setEo(elm_layout_add(parent)); + elm_layout_file_set(getEo(), PathUtils::getResourcePath(CONV_LIST_EDJ_PATH).c_str(), layoutStyle); + expand(); + show(); } diff --git a/src/Conversation/ConvList/View/src/ConvListViewItem.cpp b/src/Conversation/ConvList/View/src/ConvListViewItem.cpp index b94a19cd..98cfc8d6 100644 --- a/src/Conversation/ConvList/View/src/ConvListViewItem.cpp +++ b/src/Conversation/ConvList/View/src/ConvListViewItem.cpp @@ -22,27 +22,27 @@ using namespace Msg; namespace { - ListItemStyleRef sentStyle = ListItemStyle::create("sentbubble"); - ListItemStyleRef receivedStyle = ListItemStyle::create("receivebubble"); - ListItemStyleRef draftStyle = ListItemStyle::create("draft"); - ListItemStyleRef failedStyle = ListItemStyle::create("failed"); - - const char *checkBoxPart = "bubble.check"; - const char *bubbleContentPart = "bubble.content"; - const char *thumbContentPart = "info.thumbnail"; - const char *timeTextPart = "info.time"; - const char *draftButtonPart = "draft.button"; - const char *failedButtonPart = "failed.button"; - const char *infoStatus = "info.status"; - const char *msgType = "msg.type"; + ListItemStyleRef sentStyle = ListItemStyle::create("sentbubble"); + ListItemStyleRef receivedStyle = ListItemStyle::create("receivebubble"); + ListItemStyleRef draftStyle = ListItemStyle::create("draft"); + ListItemStyleRef failedStyle = ListItemStyle::create("failed"); + + const char *checkBoxPart = "bubble.check"; + const char *bubbleContentPart = "bubble.content"; + const char *thumbContentPart = "info.thumbnail"; + const char *timeTextPart = "info.time"; + const char *draftButtonPart = "draft.button"; + const char *failedButtonPart = "failed.button"; + const char *infoStatus = "info.status"; + const char *msgType = "msg.type"; } ConvListViewItem::ConvListViewItem(ConvItemType type) - : ListItem() - , m_SearchMode(false) - , m_Type(InitType) + : ListItem() + , m_SearchMode(false) + , m_Type(InitType) { - updateItemType(type); + updateItemType(type); } ConvListViewItem::~ConvListViewItem() @@ -51,141 +51,141 @@ ConvListViewItem::~ConvListViewItem() std::string ConvListViewItem::getText(ListItem &item, const char *part) { - if (!strcmp(part, timeTextPart)) - return getTime(); - else if (!strcmp(part, msgType)) - return getMsgType(); - else - return ""; + if (!strcmp(part, timeTextPart)) + return getTime(); + else if (!strcmp(part, msgType)) + return getMsgType(); + else + return ""; } Evas_Object *ConvListViewItem::getContent(ListItem &item, const char *part) { - if (!strcmp(part, bubbleContentPart)) - return getBubbleContent(); - else if (!strcmp(part, thumbContentPart)) - return getThumbnail(); - else if (!strcmp(part, draftButtonPart)) - return createButton(!getOwner()->getCheckMode(), Draft); - else if (!strcmp(part, failedButtonPart)) - return createButton(!getOwner()->getCheckMode(), Failed); - else if (!strcmp(part, infoStatus)) - return getProgress(); - - return nullptr; + if (!strcmp(part, bubbleContentPart)) + return getBubbleContent(); + else if (!strcmp(part, thumbContentPart)) + return getThumbnail(); + else if (!strcmp(part, draftButtonPart)) + return createButton(!getOwner()->getCheckMode(), Draft); + else if (!strcmp(part, failedButtonPart)) + return createButton(!getOwner()->getCheckMode(), Failed); + else if (!strcmp(part, infoStatus)) + return getProgress(); + + return nullptr; } const char *ConvListViewItem::getCheckPart(ListItem &item) { - return checkBoxPart; + return checkBoxPart; } Evas_Object *ConvListViewItem::createButton(bool isEnabled, ConvItemType type) { - Evas_Object *button = elm_button_add(*getOwner()); - evas_object_event_callback_add( - button, - EVAS_CALLBACK_MOUSE_DOWN, - [](void *data, Evas *e, Evas_Object *obj, void *event_info) - { - if (!elm_object_disabled_get(obj)) - View::emitSignal(elm_object_content_get(obj), "pressed", "*"); - }, - this); - - evas_object_event_callback_add( - button, - EVAS_CALLBACK_MOUSE_UP, - [](void *data, Evas *e, Evas_Object *obj, void *event_info) - { - if (!elm_object_disabled_get(obj)) - View::emitSignal(elm_object_content_get(obj), "unpressed", "*"); - }, - this); - - elm_object_style_set(button, "transparent"); - Evas_Object *icon = nullptr; - - if (type == Draft) { - icon = View::addLayout(button, ICONS_EDJ_PATH, "draft_icon"); - evas_object_smart_callback_add(button, "clicked", SMART_CALLBACK(ConvListViewItem, onEditButtonClicked), this); - } else if (type == Failed) { - icon = View::addLayout(button, ICONS_EDJ_PATH, "failed_icon"); - evas_object_smart_callback_add(button, "clicked", SMART_CALLBACK(ConvListViewItem, onFailedButtonClicked), this); - } - - elm_object_content_set(button, icon); - evas_object_propagate_events_set(button, !isEnabled); - elm_object_disabled_set(button, !isEnabled); - - return button; + Evas_Object *button = elm_button_add(*getOwner()); + evas_object_event_callback_add( + button, + EVAS_CALLBACK_MOUSE_DOWN, + [](void *data, Evas *e, Evas_Object *obj, void *event_info) + { + if (!elm_object_disabled_get(obj)) + View::emitSignal(elm_object_content_get(obj), "pressed", "*"); + }, + this); + + evas_object_event_callback_add( + button, + EVAS_CALLBACK_MOUSE_UP, + [](void *data, Evas *e, Evas_Object *obj, void *event_info) + { + if (!elm_object_disabled_get(obj)) + View::emitSignal(elm_object_content_get(obj), "unpressed", "*"); + }, + this); + + elm_object_style_set(button, "transparent"); + Evas_Object *icon = nullptr; + + if (type == Draft) { + icon = View::addLayout(button, ICONS_EDJ_PATH, "draft_icon"); + evas_object_smart_callback_add(button, "clicked", SMART_CALLBACK(ConvListViewItem, onEditButtonClicked), this); + } else if (type == Failed) { + icon = View::addLayout(button, ICONS_EDJ_PATH, "failed_icon"); + evas_object_smart_callback_add(button, "clicked", SMART_CALLBACK(ConvListViewItem, onFailedButtonClicked), this); + } + + elm_object_content_set(button, icon); + evas_object_propagate_events_set(button, !isEnabled); + elm_object_disabled_set(button, !isEnabled); + + return button; } Evas_Object *ConvListViewItem::createProgress() { - Evas_Object *progressbar = elm_progressbar_add(*getOwner()); - elm_object_style_set(progressbar, "process_small"); - evas_object_show(progressbar); - elm_progressbar_pulse(progressbar, EINA_TRUE); - return progressbar; + Evas_Object *progressbar = elm_progressbar_add(*getOwner()); + elm_object_style_set(progressbar, "process_small"); + evas_object_show(progressbar); + elm_progressbar_pulse(progressbar, EINA_TRUE); + return progressbar; } void ConvListViewItem::showSearch() { - m_SearchMode = true; - if (getElmObjItem()) - emitSignal("show_search", "*"); + m_SearchMode = true; + if (getElmObjItem()) + emitSignal("show_search", "*"); } void ConvListViewItem::onRealized(ListItem &item) { - if (m_SearchMode) - emitSignal("show_search", "*"); + if (m_SearchMode) + emitSignal("show_search", "*"); } void ConvListViewItem::onUnrealized(ListItem &item) { - // Use because genlist does not save state for other items - if (m_SearchMode) - emitSignal("hide_search", "*"); + // Use because genlist does not save state for other items + if (m_SearchMode) + emitSignal("hide_search", "*"); } void ConvListViewItem::updateContent() { - updateFields(bubbleContentPart, ELM_GENLIST_ITEM_FIELD_CONTENT); + updateFields(bubbleContentPart, ELM_GENLIST_ITEM_FIELD_CONTENT); } void ConvListViewItem::updateProgress() { - updateFields(infoStatus, ELM_GENLIST_ITEM_FIELD_CONTENT); + updateFields(infoStatus, ELM_GENLIST_ITEM_FIELD_CONTENT); } void ConvListViewItem::updateItemType(ConvItemType type) { - if (type == m_Type || type == InitType) - return; - - m_Type = type; - switch (type) { - case Sent: - setStyle(sentStyle); - break; - case Received: - setStyle(receivedStyle); - break; - case Draft: - setStyle(draftStyle); - break; - case Failed: - setStyle(failedStyle); - break; - default: - break; - } + if (type == m_Type || type == InitType) + return; + + m_Type = type; + switch (type) { + case Sent: + setStyle(sentStyle); + break; + case Received: + setStyle(receivedStyle); + break; + case Draft: + setStyle(draftStyle); + break; + case Failed: + setStyle(failedStyle); + break; + default: + break; + } } void ConvListViewItem::resetCheckMode(ListView &listView) { - for (ListItem *item: listView.getRealizedItems()) - item->emitSignal("elm,state,default", "elm"); + for (ListItem *item: listView.getRealizedItems()) + item->emitSignal("elm,state,default", "elm"); } diff --git a/src/Conversation/ConvList/View/src/ConvSelectAll.cpp b/src/Conversation/ConvList/View/src/ConvSelectAll.cpp index 4f4afbee..91ff8cf8 100644 --- a/src/Conversation/ConvList/View/src/ConvSelectAll.cpp +++ b/src/Conversation/ConvList/View/src/ConvSelectAll.cpp @@ -21,20 +21,20 @@ using namespace Msg; namespace { - const char *groupName = "elm/layout/select_all_layout"; - const char *textPart = "elm.select_all_text"; - const char *iconPart = "elm.swallow.select_icon"; - const char *clickedSig = "sel_all_layout,clicked"; + const char *groupName = "elm/layout/select_all_layout"; + const char *textPart = "elm.select_all_text"; + const char *iconPart = "elm.swallow.select_icon"; + const char *clickedSig = "sel_all_layout,clicked"; } ConvSelectAll::ConvSelectAll(Evas_Object *parent) - : m_pCheck(nullptr) + : m_pCheck(nullptr) { - setEo(addLayout(parent, SELECT_ALL_EDJ_PATH, groupName)); - Evas_Object *check = createCheck(getEo()); - setContent(check, iconPart); - setText(msgt("IDS_MSG_MBODY_SELECT_ALL")); - elm_object_signal_callback_add(getEo(), clickedSig, "", onLayoutClicked, this); + setEo(addLayout(parent, SELECT_ALL_EDJ_PATH, groupName)); + Evas_Object *check = createCheck(getEo()); + setContent(check, iconPart); + setText(msgt("IDS_MSG_MBODY_SELECT_ALL")); + elm_object_signal_callback_add(getEo(), clickedSig, "", onLayoutClicked, this); } ConvSelectAll::~ConvSelectAll() @@ -43,40 +43,40 @@ ConvSelectAll::~ConvSelectAll() void ConvSelectAll::setText(const std::string &text) { - View::setText(text, textPart); + View::setText(text, textPart); } void ConvSelectAll::setText(const TText &text) { - View::setText(text, textPart); + View::setText(text, textPart); } void ConvSelectAll::addCheckCallback(Evas_Smart_Cb cb, void *userData) { - evas_object_smart_callback_add(m_pCheck, "changed", cb, userData); + evas_object_smart_callback_add(m_pCheck, "changed", cb, userData); } Evas_Object *ConvSelectAll::createCheck(Evas_Object *parent) { - m_pCheck = elm_check_add(parent); - evas_object_propagate_events_set(m_pCheck, EINA_FALSE); - evas_object_show(m_pCheck); - return m_pCheck; + m_pCheck = elm_check_add(parent); + evas_object_propagate_events_set(m_pCheck, EINA_FALSE); + evas_object_show(m_pCheck); + return m_pCheck; } bool ConvSelectAll::getCheckState() const { - return elm_check_state_get(m_pCheck); + return elm_check_state_get(m_pCheck); } void ConvSelectAll::setCheckState(bool check) { - elm_check_state_set(m_pCheck, check); + elm_check_state_set(m_pCheck, check); } void ConvSelectAll::onLayoutClicked(void *data, Evas_Object *obj, const char *emission, const char *source) { - Evas_Object *check = static_cast(data)->m_pCheck; - elm_check_state_set(check, !elm_check_state_get(check)); - evas_object_smart_callback_call(check, "changed", nullptr); + Evas_Object *check = static_cast(data)->m_pCheck; + elm_check_state_set(check, !elm_check_state_get(check)); + evas_object_smart_callback_call(check, "changed", nullptr); } diff --git a/src/Conversation/ConvList/View/src/DateLineViewItem.cpp b/src/Conversation/ConvList/View/src/DateLineViewItem.cpp index a4058c33..eafb10d9 100644 --- a/src/Conversation/ConvList/View/src/DateLineViewItem.cpp +++ b/src/Conversation/ConvList/View/src/DateLineViewItem.cpp @@ -20,15 +20,15 @@ using namespace Msg; namespace { - ListItemStyleRef dateLineStyle = ListItemStyle::create("dateline"); - const char *datePart = "text.date"; + ListItemStyleRef dateLineStyle = ListItemStyle::create("dateline"); + const char *datePart = "text.date"; } DateLineViewItem::DateLineViewItem(const std::string &dateLine) - : ListItem() - , m_DateLine(dateLine) + : ListItem() + , m_DateLine(dateLine) { - setStyle(dateLineStyle); + setStyle(dateLineStyle); } DateLineViewItem::~DateLineViewItem() @@ -37,18 +37,18 @@ DateLineViewItem::~DateLineViewItem() std::string DateLineViewItem::getDateLine() const { - return m_DateLine; + return m_DateLine; } void DateLineViewItem::setDateLine(const std::string &dateLine) { - m_DateLine = dateLine; + m_DateLine = dateLine; } std::string DateLineViewItem::getText(ListItem &item, const char *part) { - if (!strcmp(part, datePart)) - return m_DateLine; - else - return ""; + if (!strcmp(part, datePart)) + return m_DateLine; + else + return ""; } diff --git a/src/Conversation/Main/Controller/inc/Conversation.h b/src/Conversation/Main/Controller/inc/Conversation.h index b0db7695..8fb96be1 100644 --- a/src/Conversation/Main/Controller/inc/Conversation.h +++ b/src/Conversation/Main/Controller/inc/Conversation.h @@ -42,202 +42,202 @@ #include namespace Msg { - class NaviFrameController; - class Scroller; - class ConversationInputPanel; - class IConversationListener; - - class Conversation - : public FrameController - , private IHwButtonListener - , private IMessageInputPanelListener - , private IBodyListener - , private IConvRecipientsPanelListener - , private IConvContactListListener - , private IConvListListener - , private IAttachPanelListener - , private IContactManagerListener - , private ISystemSettingsManager { - public: - Conversation(NaviFrameController &parent); - virtual ~Conversation(); - - void navigateTo(MsgId msgId); - void navigateToBottom(); - void execCmd(const AppControlComposeRef &cmd); - void execCmd(const AppControlDefaultRef &cmd); - void setThreadId(ThreadId id, const char *searchWord = nullptr, bool updateConvList = true, bool updateRecipPanel = true); - void setListener(IConversationListener *listener); - void forwardMsg(MsgId id); - - private: - enum Mode { - InitMode, - NewMessageMode, - ConversationMode - }; - - struct DefferedCmd { - AppControlComposeRef composeCmd; - AppControlDefaultRef defaultCmd; - }; - - private: - // NaviFrameItem: - virtual void onAttached(ViewItem &item); - virtual void onTransitionFinished(NaviFrameItem &item); - virtual void onButtonClicked(NaviFrameItem &item, NaviButtonId buttonId); - virtual void onPause(); - virtual void onResume(); - - // IHwButtonListener: - virtual void onHwBackButtonClicked(); - virtual void onHwMoreButtonClicked(); - - // IMessageInputPanelListener: - virtual void onButtonClicked(MessageInputPanel &obj, MessageInputPanel::ButtonId id); - - // IConvRecipientsPanelListener: - virtual void onMbeChanged(ConvRecipientsPanel &panel); - virtual void onKeyDown(ConvRecipientsPanel &panel, Evas_Event_Key_Down &ev); - virtual void onEntryFocusChanged(ConvRecipientsPanel &panel); - virtual void onEntryChanged(ConvRecipientsPanel &panel); - virtual void onItemClicked(ConvRecipientsPanel &panel, MbeRecipientItem &item); - virtual void onEntrySizeChanged(ConvRecipientsPanel &panel); - - // IBodyListener: - virtual void onChanged(Body &body); - - // IConvContactListListener: - virtual void onContactSelected(ContactListItem &item); - virtual void onContactListChanged(); - - // Popup callbacks: - void onSendReadReportPopupDel(Evas_Object *popup, void *eventInfo); - void onSendReadReportPopupButtonClicked(Popup &popup, int buttonId); - void onNoRecipPopupDel(Evas_Object *popup, void *eventInfo); - void onRecipPopupDel(Evas_Object *popup, void *eventInfo); - void onMsgSendErrorButtonClicked(Popup &popup, int buttonId); - void onMsgSettingsButtonClicked(Popup &popup, int buttonId); - void onNoRecipDiscardButtonClicked(Popup &popup, int buttonId); - void onDeleteItemPressed(PopupListItem &item); - void onAddRecipientsItemPressed(PopupListItem &item); - void onMakeVoiceItemPressed(PopupListItem &item); - void onCreateContactItemPressed(PopupListItem &item); - void onUpdateContactItemPressed(PopupListItem &item); - void onRecipRemoveItemPressed(PopupListItem &item); - void onEditItemPressed(PopupListItem &item); - void onViewContactDetailsItemPressed(PopupListItem &item); - - // IConvListListener: - virtual void onAllConvItemsDeleted(ConvList &list); - virtual void onEditDraftMsg(MsgId id); - virtual void onForwardMsg(MsgId id); - virtual void onResendMsg(MsgId id); - virtual void onSlideShow(MsgId id); - virtual void onSaveAttachments(MsgId id); - virtual void onConvListItemChecked(); - - // IAttachPanelListener: - virtual void onFileSelected(AttachPanel &panel, const AttachPanel::FileList &files); - - // IContactManagerListener: - virtual void onContactChanged(); - - // ISystemSettingsManager: - virtual void onLanguageChanged(); - - private: - void create(); - void setMode(Mode mode); - void setNewMessageMode(); - void setConversationMode(); - void setDeleteMode(bool value); - void showConvList(bool show); - void showRecipPanel(bool show); - void showContactList(bool show); - void createMsgInputPanel(); - void destroyMsgInputPanel(); - void showMsgInputPanelIfNeeded(bool show); - void updateMsgInputPanel(); - void updateNavibar(); - void updateSelectMsgTitle(); - void updateRecipientArea(); - void createMainLayout(); - void markAsRead(); - void recipientClickHandler(const std::string &address); - void contactChangedHandler(); - MsgAddressListRef getAddressList(); - void resetDefferedCmd(); - bool isDefferedCmd() const; - bool isRecipExists() const; - bool isBodyEmpty() const; - void notifyConvertMsgType(); - void convertMsgTypeHandler(); - void checkAndSetMsgType(bool force = false); - void navigateToSlideShow(MsgId id); - void setBodyFocus(); - bool getSipVisibility() const; // SIP = Software input panel - void setRecipEntryFocus(); - void resetMsgThread(bool updateConvList = true, bool updateRecipPanel = true); - void updateActiveNotifPolicy(); - std::vector getMsgIdListForReadReport() const; - bool isHiddenAddress() const; - - void showSendReadReportPopup(); - void showMainPopup(); - void showNoRecipPopup(); - PopupList &createPopupList(const std::string &title); - void showMobileDataPopup(); - void showSendDpmNotif(const MsgAddressList &addressList); - void showUnsavedRecipientPopup(const std::string &address); - void showSavedRecipientPopup(const std::string &title, int contactId, ContactAddress::OwnerType ownerType); - void sendReadReport(MsgReport::ReadStatus status); - bool sendReadReportIfNeeded(); - void sendMessage(MsgId msgId); - void sendMessage(); - bool checkBeforeSend(const Message &msg); - void handleSendResult(const Message &msg, MsgTransport::SendResult result); - bool read(Message &msg); - bool readMsgAddress(Message &msg); - void write(const Message &msg); - MsgId saveDraftMsg(); - void editDraftMsg(MsgId id); - void createNewMsgThread(); - - void onNaviOkButtonClicked(); - void onNaviCenterButtonClicked(); - void onNaviExpandButtonClicked(); - - private: - Mode m_Mode; - bool m_DeleteMode; - WorkingDirRef m_WorkingDir; - ConversationLayout *m_pLayout; - MessageInputPanel *m_pMsgInputPanel; - Body *m_pBody; - ConvRecipientsPanel *m_pRecipPanel; - ConvContactList *m_pContactsList; - ThreadId m_ThreadId; - MsgAddressListRef m_AddressList; - bool m_IsMms; // Compose message type - bool m_DispIsMms; // Last displayed message type for user. - Ecore_Idler *m_NnotifyConvertMsgTypeIdler; - ConvList *m_pConvList; - AttachPanel m_AttachPanel; - DefferedCmd m_DefferedCmd; - ContactEditor m_ContactEditor; - ContactViewer m_ContactViewer; - SettingsNetwork m_SettingsNetwork; - IConversationListener *m_pListener; - std::function m_TransFinishedFunc; - }; - - class IConversationListener { - public: - virtual ~IConversationListener() {}; - virtual void onConversationSentMessage() {}; - }; + class NaviFrameController; + class Scroller; + class ConversationInputPanel; + class IConversationListener; + + class Conversation + : public FrameController + , private IHwButtonListener + , private IMessageInputPanelListener + , private IBodyListener + , private IConvRecipientsPanelListener + , private IConvContactListListener + , private IConvListListener + , private IAttachPanelListener + , private IContactManagerListener + , private ISystemSettingsManager { + public: + Conversation(NaviFrameController &parent); + virtual ~Conversation(); + + void navigateTo(MsgId msgId); + void navigateToBottom(); + void execCmd(const AppControlComposeRef &cmd); + void execCmd(const AppControlDefaultRef &cmd); + void setThreadId(ThreadId id, const char *searchWord = nullptr, bool updateConvList = true, bool updateRecipPanel = true); + void setListener(IConversationListener *listener); + void forwardMsg(MsgId id); + + private: + enum Mode { + InitMode, + NewMessageMode, + ConversationMode + }; + + struct DefferedCmd { + AppControlComposeRef composeCmd; + AppControlDefaultRef defaultCmd; + }; + + private: + // NaviFrameItem: + virtual void onAttached(ViewItem &item); + virtual void onTransitionFinished(NaviFrameItem &item); + virtual void onButtonClicked(NaviFrameItem &item, NaviButtonId buttonId); + virtual void onPause(); + virtual void onResume(); + + // IHwButtonListener: + virtual void onHwBackButtonClicked(); + virtual void onHwMoreButtonClicked(); + + // IMessageInputPanelListener: + virtual void onButtonClicked(MessageInputPanel &obj, MessageInputPanel::ButtonId id); + + // IConvRecipientsPanelListener: + virtual void onMbeChanged(ConvRecipientsPanel &panel); + virtual void onKeyDown(ConvRecipientsPanel &panel, Evas_Event_Key_Down &ev); + virtual void onEntryFocusChanged(ConvRecipientsPanel &panel); + virtual void onEntryChanged(ConvRecipientsPanel &panel); + virtual void onItemClicked(ConvRecipientsPanel &panel, MbeRecipientItem &item); + virtual void onEntrySizeChanged(ConvRecipientsPanel &panel); + + // IBodyListener: + virtual void onChanged(Body &body); + + // IConvContactListListener: + virtual void onContactSelected(ContactListItem &item); + virtual void onContactListChanged(); + + // Popup callbacks: + void onSendReadReportPopupDel(Evas_Object *popup, void *eventInfo); + void onSendReadReportPopupButtonClicked(Popup &popup, int buttonId); + void onNoRecipPopupDel(Evas_Object *popup, void *eventInfo); + void onRecipPopupDel(Evas_Object *popup, void *eventInfo); + void onMsgSendErrorButtonClicked(Popup &popup, int buttonId); + void onMsgSettingsButtonClicked(Popup &popup, int buttonId); + void onNoRecipDiscardButtonClicked(Popup &popup, int buttonId); + void onDeleteItemPressed(PopupListItem &item); + void onAddRecipientsItemPressed(PopupListItem &item); + void onMakeVoiceItemPressed(PopupListItem &item); + void onCreateContactItemPressed(PopupListItem &item); + void onUpdateContactItemPressed(PopupListItem &item); + void onRecipRemoveItemPressed(PopupListItem &item); + void onEditItemPressed(PopupListItem &item); + void onViewContactDetailsItemPressed(PopupListItem &item); + + // IConvListListener: + virtual void onAllConvItemsDeleted(ConvList &list); + virtual void onEditDraftMsg(MsgId id); + virtual void onForwardMsg(MsgId id); + virtual void onResendMsg(MsgId id); + virtual void onSlideShow(MsgId id); + virtual void onSaveAttachments(MsgId id); + virtual void onConvListItemChecked(); + + // IAttachPanelListener: + virtual void onFileSelected(AttachPanel &panel, const AttachPanel::FileList &files); + + // IContactManagerListener: + virtual void onContactChanged(); + + // ISystemSettingsManager: + virtual void onLanguageChanged(); + + private: + void create(); + void setMode(Mode mode); + void setNewMessageMode(); + void setConversationMode(); + void setDeleteMode(bool value); + void showConvList(bool show); + void showRecipPanel(bool show); + void showContactList(bool show); + void createMsgInputPanel(); + void destroyMsgInputPanel(); + void showMsgInputPanelIfNeeded(bool show); + void updateMsgInputPanel(); + void updateNavibar(); + void updateSelectMsgTitle(); + void updateRecipientArea(); + void createMainLayout(); + void markAsRead(); + void recipientClickHandler(const std::string &address); + void contactChangedHandler(); + MsgAddressListRef getAddressList(); + void resetDefferedCmd(); + bool isDefferedCmd() const; + bool isRecipExists() const; + bool isBodyEmpty() const; + void notifyConvertMsgType(); + void convertMsgTypeHandler(); + void checkAndSetMsgType(bool force = false); + void navigateToSlideShow(MsgId id); + void setBodyFocus(); + bool getSipVisibility() const; // SIP = Software input panel + void setRecipEntryFocus(); + void resetMsgThread(bool updateConvList = true, bool updateRecipPanel = true); + void updateActiveNotifPolicy(); + std::vector getMsgIdListForReadReport() const; + bool isHiddenAddress() const; + + void showSendReadReportPopup(); + void showMainPopup(); + void showNoRecipPopup(); + PopupList &createPopupList(const std::string &title); + void showMobileDataPopup(); + void showSendDpmNotif(const MsgAddressList &addressList); + void showUnsavedRecipientPopup(const std::string &address); + void showSavedRecipientPopup(const std::string &title, int contactId, ContactAddress::OwnerType ownerType); + void sendReadReport(MsgReport::ReadStatus status); + bool sendReadReportIfNeeded(); + void sendMessage(MsgId msgId); + void sendMessage(); + bool checkBeforeSend(const Message &msg); + void handleSendResult(const Message &msg, MsgTransport::SendResult result); + bool read(Message &msg); + bool readMsgAddress(Message &msg); + void write(const Message &msg); + MsgId saveDraftMsg(); + void editDraftMsg(MsgId id); + void createNewMsgThread(); + + void onNaviOkButtonClicked(); + void onNaviCenterButtonClicked(); + void onNaviExpandButtonClicked(); + + private: + Mode m_Mode; + bool m_DeleteMode; + WorkingDirRef m_WorkingDir; + ConversationLayout *m_pLayout; + MessageInputPanel *m_pMsgInputPanel; + Body *m_pBody; + ConvRecipientsPanel *m_pRecipPanel; + ConvContactList *m_pContactsList; + ThreadId m_ThreadId; + MsgAddressListRef m_AddressList; + bool m_IsMms; // Compose message type + bool m_DispIsMms; // Last displayed message type for user. + Ecore_Idler *m_NnotifyConvertMsgTypeIdler; + ConvList *m_pConvList; + AttachPanel m_AttachPanel; + DefferedCmd m_DefferedCmd; + ContactEditor m_ContactEditor; + ContactViewer m_ContactViewer; + SettingsNetwork m_SettingsNetwork; + IConversationListener *m_pListener; + std::function m_TransFinishedFunc; + }; + + class IConversationListener { + public: + virtual ~IConversationListener() {}; + virtual void onConversationSentMessage() {}; + }; } #endif /* ConversationFrame_h_ */ diff --git a/src/Conversation/Main/Controller/inc/PopupRecipientListItem.h b/src/Conversation/Main/Controller/inc/PopupRecipientListItem.h index edc93bf8..bb7a7e05 100644 --- a/src/Conversation/Main/Controller/inc/PopupRecipientListItem.h +++ b/src/Conversation/Main/Controller/inc/PopupRecipientListItem.h @@ -21,41 +21,41 @@ #include "ContactAddress.h" namespace Msg { - class PopupAddressListItem - : public PopupTextListItem { - public: - PopupAddressListItem(PopupList &parent, - const std::string &text, - const std::string &address, - PopupListItemPressedCb cb, - void *userData); - - virtual ~PopupAddressListItem(); - std::string getAddress() const; - - private: - std::string m_Address; - }; - - class PopupPersonIdListItem - : public PopupTextListItem { - public: - PopupPersonIdListItem(PopupList &parent, - const std::string &text, - int contactId, - ContactAddress::OwnerType ownerType, - PopupListItemPressedCb cb, - void *userData); - - virtual ~PopupPersonIdListItem(); - - int getContactId() const; - ContactAddress::OwnerType getContactOwnerType() const; - - private: - int m_ContactId; - ContactAddress::OwnerType m_OwnerType; - }; + class PopupAddressListItem + : public PopupTextListItem { + public: + PopupAddressListItem(PopupList &parent, + const std::string &text, + const std::string &address, + PopupListItemPressedCb cb, + void *userData); + + virtual ~PopupAddressListItem(); + std::string getAddress() const; + + private: + std::string m_Address; + }; + + class PopupPersonIdListItem + : public PopupTextListItem { + public: + PopupPersonIdListItem(PopupList &parent, + const std::string &text, + int contactId, + ContactAddress::OwnerType ownerType, + PopupListItemPressedCb cb, + void *userData); + + virtual ~PopupPersonIdListItem(); + + int getContactId() const; + ContactAddress::OwnerType getContactOwnerType() const; + + private: + int m_ContactId; + ContactAddress::OwnerType m_OwnerType; + }; } #endif /* PopupRecipientListItem_h_ */ diff --git a/src/Conversation/Main/Controller/src/Conversation.cpp b/src/Conversation/Main/Controller/src/Conversation.cpp index 4418d429..b629b58e 100644 --- a/src/Conversation/Main/Controller/src/Conversation.cpp +++ b/src/Conversation/Main/Controller/src/Conversation.cpp @@ -35,1372 +35,1372 @@ using namespace Msg; namespace { - std::string makeDispAddress(std::string address, std::string dispName) - { - if (dispName.empty()) - return address; - std::string res = std::move(dispName); - res += " ("; - res += std::move(address) + ')'; - return res; - } + std::string makeDispAddress(std::string address, std::string dispName) + { + if (dispName.empty()) + return address; + std::string res = std::move(dispName); + res += " ("; + res += std::move(address) + ')'; + return res; + } } Conversation::Conversation(NaviFrameController &parent) - : FrameController(parent) - , m_Mode(InitMode) - , m_DeleteMode(false) - , m_pLayout(nullptr) - , m_pMsgInputPanel(nullptr) - , m_pBody(nullptr) - , m_pRecipPanel(nullptr) - , m_pContactsList(nullptr) - , m_ThreadId() - , m_IsMms(false) - , m_DispIsMms(false) - , m_NnotifyConvertMsgTypeIdler(nullptr) - , m_pConvList(nullptr) - , m_AttachPanel(getApp()) - , m_pListener(nullptr) -{ - create(); + : FrameController(parent) + , m_Mode(InitMode) + , m_DeleteMode(false) + , m_pLayout(nullptr) + , m_pMsgInputPanel(nullptr) + , m_pBody(nullptr) + , m_pRecipPanel(nullptr) + , m_pContactsList(nullptr) + , m_ThreadId() + , m_IsMms(false) + , m_DispIsMms(false) + , m_NnotifyConvertMsgTypeIdler(nullptr) + , m_pConvList(nullptr) + , m_AttachPanel(getApp()) + , m_pListener(nullptr) +{ + create(); } Conversation::~Conversation() { - // Call before delete all children: - MSG_LOG(""); - getApp().getContactManager().removeListener(*this); - getApp().getSysSettingsManager().removeListener(*this); - if (m_pBody) - m_pBody->setListener(nullptr); - if (m_pRecipPanel) - m_pRecipPanel->setListener(nullptr); - if (m_pContactsList) - m_pContactsList->setListener(nullptr); - if (m_pConvList) { - m_pConvList->setListener(nullptr); - m_pConvList->setBodyFocusCb(nullptr); - } - m_AttachPanel.setListener(nullptr); - if (m_NnotifyConvertMsgTypeIdler) { - ecore_idler_del(m_NnotifyConvertMsgTypeIdler); - m_NnotifyConvertMsgTypeIdler = nullptr; - } - markAsRead(); + // Call before delete all children: + MSG_LOG(""); + getApp().getContactManager().removeListener(*this); + getApp().getSysSettingsManager().removeListener(*this); + if (m_pBody) + m_pBody->setListener(nullptr); + if (m_pRecipPanel) + m_pRecipPanel->setListener(nullptr); + if (m_pContactsList) + m_pContactsList->setListener(nullptr); + if (m_pConvList) { + m_pConvList->setListener(nullptr); + m_pConvList->setBodyFocusCb(nullptr); + } + m_AttachPanel.setListener(nullptr); + if (m_NnotifyConvertMsgTypeIdler) { + ecore_idler_del(m_NnotifyConvertMsgTypeIdler); + m_NnotifyConvertMsgTypeIdler = nullptr; + } + markAsRead(); } void Conversation::execCmd(const AppControlComposeRef &cmd) { - getApp().getPopupManager().reset(); - setDeleteMode(false); - if (!isRecipExists() && !isBodyEmpty() && m_Mode == NewMessageMode) { // Check if we can save draft to avoid losing data - m_DefferedCmd.composeCmd = cmd; - showNoRecipPopup(); - return; - } else { - saveDraftMsg(); - } + getApp().getPopupManager().reset(); + setDeleteMode(false); + if (!isRecipExists() && !isBodyEmpty() && m_Mode == NewMessageMode) { // Check if we can save draft to avoid losing data + m_DefferedCmd.composeCmd = cmd; + showNoRecipPopup(); + return; + } else { + saveDraftMsg(); + } - setThreadId(ThreadId()); + setThreadId(ThreadId()); - if (m_pRecipPanel) - m_pRecipPanel->execCmd(cmd); + if (m_pRecipPanel) + m_pRecipPanel->execCmd(cmd); - if (m_pBody) { - m_pBody->enableAutoFocusForAttachments(isRecipExists()); - m_pBody->execCmd(cmd); - } + if (m_pBody) { + m_pBody->enableAutoFocusForAttachments(isRecipExists()); + m_pBody->execCmd(cmd); + } - if (isRecipExists() && m_pBody) - m_pBody->setFocus(true); - else if (m_pRecipPanel) - m_pRecipPanel->setEntryFocus(true); + if (isRecipExists() && m_pBody) + m_pBody->setFocus(true); + else if (m_pRecipPanel) + m_pRecipPanel->setEntryFocus(true); } void Conversation::execCmd(const AppControlDefaultRef &cmd) { - getApp().getPopupManager().reset(); - setDeleteMode(false); - if (!isRecipExists() && !isBodyEmpty() && m_Mode == NewMessageMode) { // Check if we can save draft to avoid losing data - m_DefferedCmd.defaultCmd = cmd; - showNoRecipPopup(); - return; - } else { - saveDraftMsg(); - if (m_pBody) - m_pBody->clear(); - } - - if (cmd->getDefaultType() == AppControlDefault::SendFailedType) { - pop(); - return; - } - - if (cmd->getDefaultType() == AppControlDefault::NotificationType && getMsgEngine().getStorage().getUnreadThreadCount() > 1) { - pop(); - return; - } - - MsgId msgId = cmd->getMessageId(); - setThreadId(getMsgEngine().getStorage().getMessage(msgId)->getThreadId()); - if (msgId.isValid()) - navigateTo(msgId); - else - navigateToBottom(); - if (cmd->getDefaultType() == AppControlDefault::ReplyType) { - m_pBody->execCmd(cmd); - m_pBody->setFocus(true); - } + getApp().getPopupManager().reset(); + setDeleteMode(false); + if (!isRecipExists() && !isBodyEmpty() && m_Mode == NewMessageMode) { // Check if we can save draft to avoid losing data + m_DefferedCmd.defaultCmd = cmd; + showNoRecipPopup(); + return; + } else { + saveDraftMsg(); + if (m_pBody) + m_pBody->clear(); + } + + if (cmd->getDefaultType() == AppControlDefault::SendFailedType) { + pop(); + return; + } + + if (cmd->getDefaultType() == AppControlDefault::NotificationType && getMsgEngine().getStorage().getUnreadThreadCount() > 1) { + pop(); + return; + } + + MsgId msgId = cmd->getMessageId(); + setThreadId(getMsgEngine().getStorage().getMessage(msgId)->getThreadId()); + if (msgId.isValid()) + navigateTo(msgId); + else + navigateToBottom(); + if (cmd->getDefaultType() == AppControlDefault::ReplyType) { + m_pBody->execCmd(cmd); + m_pBody->setFocus(true); + } } void Conversation::create() { - m_WorkingDir = std::make_shared(); - createMainLayout(); - showConvList(true); - getApp().getContactManager().addListener(*this); - getApp().getSysSettingsManager().addListener(*this); - m_AttachPanel.setListener(this); + m_WorkingDir = std::make_shared(); + createMainLayout(); + showConvList(true); + getApp().getContactManager().addListener(*this); + getApp().getSysSettingsManager().addListener(*this); + m_AttachPanel.setListener(this); } void Conversation::markAsRead() { - // Warning thread and messages marks as read only for ConversationMode. - if (m_ThreadId.isValid() && m_Mode == ConversationMode) - getMsgEngine().getStorage().setReadStatus(m_ThreadId); + // Warning thread and messages marks as read only for ConversationMode. + if (m_ThreadId.isValid() && m_Mode == ConversationMode) + getMsgEngine().getStorage().setReadStatus(m_ThreadId); } void Conversation::recipientClickHandler(const std::string &address) { - MSG_LOG(""); - MSG_ASSERT(m_Mode != InitMode, "m_Mode is in initial state"); - - ContactAddressRef contactAddress = getApp().getContactManager().getContactAddress(address); - if (contactAddress) { - if (m_Mode == NewMessageMode) { - MbeRecipientItem *pItem = m_pRecipPanel->getSelectedItem(); - if (pItem) - showSavedRecipientPopup(pItem->getDispName(), contactAddress->getOwnerId(), contactAddress->getOwnerType()); - } else if (m_Mode == ConversationMode) { - if (m_pRecipPanel) - m_pRecipPanel->unselectMbeItem(); - m_ContactViewer.launch(*contactAddress); - } - } else { - showUnsavedRecipientPopup(address); - } + MSG_LOG(""); + MSG_ASSERT(m_Mode != InitMode, "m_Mode is in initial state"); + + ContactAddressRef contactAddress = getApp().getContactManager().getContactAddress(address); + if (contactAddress) { + if (m_Mode == NewMessageMode) { + MbeRecipientItem *pItem = m_pRecipPanel->getSelectedItem(); + if (pItem) + showSavedRecipientPopup(pItem->getDispName(), contactAddress->getOwnerId(), contactAddress->getOwnerType()); + } else if (m_Mode == ConversationMode) { + if (m_pRecipPanel) + m_pRecipPanel->unselectMbeItem(); + m_ContactViewer.launch(*contactAddress); + } + } else { + showUnsavedRecipientPopup(address); + } } void Conversation::showSavedRecipientPopup(const std::string &title, int contactId, ContactAddress::OwnerType ownerType) { - PopupList &popup = createPopupList(title); - popup.addEventCb(EVAS_CALLBACK_DEL, EVAS_EVENT_CALLBACK(Conversation, onRecipPopupDel), this); - popup.appendItem(msg("IDS_MSGF_OPT_REMOVE"), POPUPLIST_ITEM_PRESSED_CB(Conversation, onRecipRemoveItemPressed), this); - popup.appendItem(msg("IDS_MSG_OPT_EDIT"), POPUPLIST_ITEM_PRESSED_CB(Conversation, onEditItemPressed), this); - popup.appendItem(*new PopupPersonIdListItem(popup, msg("IDS_MSG_OPT_VIEW_CONTACT_DETAILS_ABB"), contactId, ownerType, - POPUPLIST_ITEM_PRESSED_CB(Conversation, onViewContactDetailsItemPressed), this)); - popup.show(); + PopupList &popup = createPopupList(title); + popup.addEventCb(EVAS_CALLBACK_DEL, EVAS_EVENT_CALLBACK(Conversation, onRecipPopupDel), this); + popup.appendItem(msg("IDS_MSGF_OPT_REMOVE"), POPUPLIST_ITEM_PRESSED_CB(Conversation, onRecipRemoveItemPressed), this); + popup.appendItem(msg("IDS_MSG_OPT_EDIT"), POPUPLIST_ITEM_PRESSED_CB(Conversation, onEditItemPressed), this); + popup.appendItem(*new PopupPersonIdListItem(popup, msg("IDS_MSG_OPT_VIEW_CONTACT_DETAILS_ABB"), contactId, ownerType, + POPUPLIST_ITEM_PRESSED_CB(Conversation, onViewContactDetailsItemPressed), this)); + popup.show(); } void Conversation::showUnsavedRecipientPopup(const std::string &address) { - PopupList &popup = createPopupList(address); - popup.addEventCb(EVAS_CALLBACK_DEL, EVAS_EVENT_CALLBACK(Conversation, onRecipPopupDel), this); - if (m_Mode == NewMessageMode) { - popup.appendItem(*new PopupAddressListItem(popup, msg("IDS_MSGF_OPT_REMOVE"), address, - POPUPLIST_ITEM_PRESSED_CB(Conversation, onRecipRemoveItemPressed), this)); + PopupList &popup = createPopupList(address); + popup.addEventCb(EVAS_CALLBACK_DEL, EVAS_EVENT_CALLBACK(Conversation, onRecipPopupDel), this); + if (m_Mode == NewMessageMode) { + popup.appendItem(*new PopupAddressListItem(popup, msg("IDS_MSGF_OPT_REMOVE"), address, + POPUPLIST_ITEM_PRESSED_CB(Conversation, onRecipRemoveItemPressed), this)); - popup.appendItem(*new PopupAddressListItem(popup, msg("IDS_MSG_OPT_EDIT"), address, - POPUPLIST_ITEM_PRESSED_CB(Conversation, onEditItemPressed), this)); - } else if (m_Mode == ConversationMode) { - if (MsgUtils::isValidNumber(address)) { - popup.appendItem(*new PopupAddressListItem(popup, msg("IDS_MSG_OPT_MAKE_VOICE_CALL"), address, - POPUPLIST_ITEM_PRESSED_CB(Conversation, onMakeVoiceItemPressed), this)); - } - } + popup.appendItem(*new PopupAddressListItem(popup, msg("IDS_MSG_OPT_EDIT"), address, + POPUPLIST_ITEM_PRESSED_CB(Conversation, onEditItemPressed), this)); + } else if (m_Mode == ConversationMode) { + if (MsgUtils::isValidNumber(address)) { + popup.appendItem(*new PopupAddressListItem(popup, msg("IDS_MSG_OPT_MAKE_VOICE_CALL"), address, + POPUPLIST_ITEM_PRESSED_CB(Conversation, onMakeVoiceItemPressed), this)); + } + } - popup.appendItem(*new PopupAddressListItem(popup, msg("IDS_MSG_OPT_CREATE_CONTACT_ABB"), address, - POPUPLIST_ITEM_PRESSED_CB(Conversation, onCreateContactItemPressed), this)); + popup.appendItem(*new PopupAddressListItem(popup, msg("IDS_MSG_OPT_CREATE_CONTACT_ABB"), address, + POPUPLIST_ITEM_PRESSED_CB(Conversation, onCreateContactItemPressed), this)); - popup.appendItem(*new PopupAddressListItem(popup, msg("IDS_MSG_OPT_UPDATE_CONTACT"), address, - POPUPLIST_ITEM_PRESSED_CB(Conversation, onUpdateContactItemPressed), this)); - popup.show(); + popup.appendItem(*new PopupAddressListItem(popup, msg("IDS_MSG_OPT_UPDATE_CONTACT"), address, + POPUPLIST_ITEM_PRESSED_CB(Conversation, onUpdateContactItemPressed), this)); + popup.show(); } void Conversation::contactChangedHandler() { - updateNavibar(); + updateNavibar(); } void Conversation::navigateTo(MsgId msgId) { - m_pConvList->navigateTo(msgId); + m_pConvList->navigateTo(msgId); } void Conversation::navigateToBottom() { - m_pConvList->navigateToBottom(); + m_pConvList->navigateToBottom(); } void Conversation::updateActiveNotifPolicy() { - ThreadId threadId = m_pConvList ? m_pConvList->getThreadId() : ThreadId(); - if (isPause() || !threadId.isValid()) - getApp().updateActiveNotifPolicy(); - else - getMsgEngine().getSettings().setActiveNotifPolicy(threadId); + ThreadId threadId = m_pConvList ? m_pConvList->getThreadId() : ThreadId(); + if (isPause() || !threadId.isValid()) + getApp().updateActiveNotifPolicy(); + else + getMsgEngine().getSettings().setActiveNotifPolicy(threadId); } void Conversation::setThreadId(ThreadId id, const char *searchWord, bool updateConvList, bool updateRecipPanel) { - MSG_LOG("Thread id = ", id); - m_ThreadId = id; - if (id.isValid()) - m_AddressList = getMsgEngine().getStorage().getAddressList(id); - else - m_AddressList.reset(); + MSG_LOG("Thread id = ", id); + m_ThreadId = id; + if (id.isValid()) + m_AddressList = getMsgEngine().getStorage().getAddressList(id); + else + m_AddressList.reset(); - setMode(m_ThreadId.isValid() ? ConversationMode : NewMessageMode); - isHiddenAddress() ? destroyMsgInputPanel() : showMsgInputPanelIfNeeded(true); + setMode(m_ThreadId.isValid() ? ConversationMode : NewMessageMode); + isHiddenAddress() ? destroyMsgInputPanel() : showMsgInputPanelIfNeeded(true); - if (m_pBody) - m_pBody->setMmsRecipFlag(getMsgEngine().getStorage().hasEmail(m_ThreadId)); + if (m_pBody) + m_pBody->setMmsRecipFlag(getMsgEngine().getStorage().hasEmail(m_ThreadId)); - if (m_pRecipPanel && updateRecipPanel) - m_pRecipPanel->update(m_ThreadId); + if (m_pRecipPanel && updateRecipPanel) + m_pRecipPanel->update(m_ThreadId); - if (m_pConvList && updateConvList) - m_pConvList->setThreadId(m_ThreadId, searchWord); + if (m_pConvList && updateConvList) + m_pConvList->setThreadId(m_ThreadId, searchWord); - markAsRead(); - updateNavibar(); - updateActiveNotifPolicy(); - checkAndSetMsgType(true); + markAsRead(); + updateNavibar(); + updateActiveNotifPolicy(); + checkAndSetMsgType(true); } void Conversation::resetMsgThread(bool updateConvList, bool updateRecipPanel) { - m_IsMms = false; - m_DispIsMms = false; - if (m_NnotifyConvertMsgTypeIdler) { - ecore_idler_del(m_NnotifyConvertMsgTypeIdler); - m_NnotifyConvertMsgTypeIdler = nullptr; - } - setThreadId(ThreadId(), "", updateConvList, updateRecipPanel); + m_IsMms = false; + m_DispIsMms = false; + if (m_NnotifyConvertMsgTypeIdler) { + ecore_idler_del(m_NnotifyConvertMsgTypeIdler); + m_NnotifyConvertMsgTypeIdler = nullptr; + } + setThreadId(ThreadId(), "", updateConvList, updateRecipPanel); } bool Conversation::isHiddenAddress() const { - if (m_AddressList && !m_AddressList->isEmpty()) { - std::string addr = m_AddressList->at(0).getAddress(); - return !MsgUtils::isValidAddress(addr); - } - return false; + if (m_AddressList && !m_AddressList->isEmpty()) { + std::string addr = m_AddressList->at(0).getAddress(); + return !MsgUtils::isValidAddress(addr); + } + return false; } void Conversation::setListener(IConversationListener *listener) { - m_pListener = listener; + m_pListener = listener; } void Conversation::forwardMsg(MsgId id) { - MessageRef msg = getMsgEngine().getStorage().getMessage(id); - if (msg) { - resetMsgThread(); - if (m_pBody) - m_pBody->write(*msg); - m_pRecipPanel->setEntryFocus(true); - } + MessageRef msg = getMsgEngine().getStorage().getMessage(id); + if (msg) { + resetMsgThread(); + if (m_pBody) + m_pBody->write(*msg); + m_pRecipPanel->setEntryFocus(true); + } } MsgAddressListRef Conversation::getAddressList() { - return m_AddressList ? m_AddressList : getMsgEngine().getStorage().getAddressList(m_ThreadId); + return m_AddressList ? m_AddressList : getMsgEngine().getStorage().getAddressList(m_ThreadId); } void Conversation::setMode(Mode mode) { - if (m_Mode == mode) - return; + if (m_Mode == mode) + return; - switch (mode) { - case NewMessageMode: - setNewMessageMode(); - break; + switch (mode) { + case NewMessageMode: + setNewMessageMode(); + break; - case ConversationMode: - setConversationMode(); - break; + case ConversationMode: + setConversationMode(); + break; - case InitMode: - break; + case InitMode: + break; - default: - MSG_LOG_ERROR("Wrong mode"); - break; - } + default: + MSG_LOG_ERROR("Wrong mode"); + break; + } } void Conversation::setNewMessageMode() { - MSG_LOG(""); + MSG_LOG(""); - m_Mode = NewMessageMode; - m_pLayout->showRecipEditMode(true); - showMsgInputPanelIfNeeded(true); - showRecipPanel(true); - showContactList(true); - m_pRecipPanel->update(m_ThreadId); - m_pRecipPanel->showMbe(!m_pRecipPanel->isMbeEmpty()); - m_pRecipPanel->showEntry(true); - m_pRecipPanel->setEntryFocus(true); // TODO: Not bad to remove from here - updateRecipientArea(); + m_Mode = NewMessageMode; + m_pLayout->showRecipEditMode(true); + showMsgInputPanelIfNeeded(true); + showRecipPanel(true); + showContactList(true); + m_pRecipPanel->update(m_ThreadId); + m_pRecipPanel->showMbe(!m_pRecipPanel->isMbeEmpty()); + m_pRecipPanel->showEntry(true); + m_pRecipPanel->setEntryFocus(true); // TODO: Not bad to remove from here + updateRecipientArea(); } void Conversation::setConversationMode() { - MSG_LOG(""); + MSG_LOG(""); - m_Mode = ConversationMode; - m_pLayout->showRecipEditMode(false); - MsgAddressListRef addressList = getAddressList(); - if (addressList && addressList->getLength() > 1) { - showRecipPanel(true); - m_pRecipPanel->showEntry(false); - m_pRecipPanel->update(addressList); - } else { - showRecipPanel(false); - } - showContactList(false); + m_Mode = ConversationMode; + m_pLayout->showRecipEditMode(false); + MsgAddressListRef addressList = getAddressList(); + if (addressList && addressList->getLength() > 1) { + showRecipPanel(true); + m_pRecipPanel->showEntry(false); + m_pRecipPanel->update(addressList); + } else { + showRecipPanel(false); + } + showContactList(false); } void Conversation::setDeleteMode(bool value) { - if (m_DeleteMode == value) - return; + if (m_DeleteMode == value) + return; - m_DeleteMode = value; - updateNavibar(); - showMsgInputPanelIfNeeded(!value); + m_DeleteMode = value; + updateNavibar(); + showMsgInputPanelIfNeeded(!value); - if (value) { - if (m_AttachPanel.isFullExpanded()) - m_AttachPanel.show(false); - m_pConvList->setMode(ConvList::SelectMode); - } else { - m_pConvList->setMode(ConvList::NormalMode); - } + if (value) { + if (m_AttachPanel.isFullExpanded()) + m_AttachPanel.show(false); + m_pConvList->setMode(ConvList::SelectMode); + } else { + m_pConvList->setMode(ConvList::NormalMode); + } } void Conversation::createMainLayout() { - m_pLayout = new ConversationLayout(getParent()); - m_pLayout->show(); - m_pLayout->expand(); - setHwButtonListener(*m_pLayout, this); + m_pLayout = new ConversationLayout(getParent()); + m_pLayout->show(); + m_pLayout->expand(); + setHwButtonListener(*m_pLayout, this); } void Conversation::showConvList(bool show) { - if (show) { - if (!m_pConvList) { - m_pConvList = new ConvList(*m_pLayout, getApp(), m_WorkingDir); - m_pConvList->setBodyFocusCb(std::bind(&Conversation::getSipVisibility, this)); - m_pConvList->setListener(this); - m_pConvList->show(); - m_pLayout->setConvList(*m_pConvList); - } - } else { - if (m_pConvList) - { - m_pConvList->setListener(nullptr); - m_pConvList->destroy(); - m_pConvList = nullptr; - } - } + if (show) { + if (!m_pConvList) { + m_pConvList = new ConvList(*m_pLayout, getApp(), m_WorkingDir); + m_pConvList->setBodyFocusCb(std::bind(&Conversation::getSipVisibility, this)); + m_pConvList->setListener(this); + m_pConvList->show(); + m_pLayout->setConvList(*m_pConvList); + } + } else { + if (m_pConvList) + { + m_pConvList->setListener(nullptr); + m_pConvList->destroy(); + m_pConvList = nullptr; + } + } } void Conversation::showRecipPanel(bool show) { - if (show) { - if (!m_pRecipPanel) { - m_pRecipPanel = new ConvRecipientsPanel(*m_pLayout, getApp()); - m_pRecipPanel->setListener(this); - m_pRecipPanel->show(); - m_pLayout->setRecipientPanel(*m_pRecipPanel); - m_pLayout->setRecipientRect(m_pRecipPanel->getAreaRect()); - } - } else { - if (m_pRecipPanel) - { - m_pRecipPanel->destroy(); - m_pRecipPanel = nullptr; - } - } + if (show) { + if (!m_pRecipPanel) { + m_pRecipPanel = new ConvRecipientsPanel(*m_pLayout, getApp()); + m_pRecipPanel->setListener(this); + m_pRecipPanel->show(); + m_pLayout->setRecipientPanel(*m_pRecipPanel); + m_pLayout->setRecipientRect(m_pRecipPanel->getAreaRect()); + } + } else { + if (m_pRecipPanel) + { + m_pRecipPanel->destroy(); + m_pRecipPanel = nullptr; + } + } } void Conversation::showContactList(bool show) { - if (show) { - if (!m_pContactsList) { - m_pContactsList = new ConvContactList(*m_pLayout, getApp()); - m_pContactsList->setListener(this); - m_pLayout->setContactList(*m_pContactsList); - } - } else { - if (m_pContactsList) { - m_pContactsList->destroy(); - m_pContactsList = nullptr; - m_pLayout->showContactList(false); - } - } + if (show) { + if (!m_pContactsList) { + m_pContactsList = new ConvContactList(*m_pLayout, getApp()); + m_pContactsList->setListener(this); + m_pLayout->setContactList(*m_pContactsList); + } + } else { + if (m_pContactsList) { + m_pContactsList->destroy(); + m_pContactsList = nullptr; + m_pLayout->showContactList(false); + } + } } void Conversation::createMsgInputPanel() { - if (!m_pMsgInputPanel) { - m_pMsgInputPanel = new MessageInputPanel(*m_pConvList); - m_pMsgInputPanel->setListener(this); - m_pLayout->setMsgInputPanel(*m_pMsgInputPanel); - } - if (!m_pBody && m_pConvList) { - m_pBody = new Body(*m_pMsgInputPanel, getApp(), m_WorkingDir, *m_pConvList); - m_pBody->setListener(this); - m_pMsgInputPanel->setEntry(*m_pBody); - updateMsgInputPanel(); - } + if (!m_pMsgInputPanel) { + m_pMsgInputPanel = new MessageInputPanel(*m_pConvList); + m_pMsgInputPanel->setListener(this); + m_pLayout->setMsgInputPanel(*m_pMsgInputPanel); + } + if (!m_pBody && m_pConvList) { + m_pBody = new Body(*m_pMsgInputPanel, getApp(), m_WorkingDir, *m_pConvList); + m_pBody->setListener(this); + m_pMsgInputPanel->setEntry(*m_pBody); + updateMsgInputPanel(); + } } void Conversation::destroyMsgInputPanel() { - if (m_pBody) { - m_pBody->setListener(this); - m_pBody->destroy(); - m_pBody = nullptr; - } - if (m_pMsgInputPanel) { - m_pMsgInputPanel->setListener(this); - m_pMsgInputPanel->destroy(); - m_pMsgInputPanel = nullptr; - } - m_pLayout->showMsgInputPanel(false); + if (m_pBody) { + m_pBody->setListener(this); + m_pBody->destroy(); + m_pBody = nullptr; + } + if (m_pMsgInputPanel) { + m_pMsgInputPanel->setListener(this); + m_pMsgInputPanel->destroy(); + m_pMsgInputPanel = nullptr; + } + m_pLayout->showMsgInputPanel(false); } void Conversation::showMsgInputPanelIfNeeded(bool show) { - if (show && !isHiddenAddress()) - createMsgInputPanel(); - if (m_pBody) - m_pBody->show(show); - if (m_pMsgInputPanel) - m_pMsgInputPanel->show(show); - m_pLayout->showMsgInputPanel(show); + if (show && !isHiddenAddress()) + createMsgInputPanel(); + if (m_pBody) + m_pBody->show(show); + if (m_pMsgInputPanel) + m_pMsgInputPanel->show(show); + m_pLayout->showMsgInputPanel(show); } void Conversation::write(const Message &msg) { - if (m_pBody) - m_pBody->write(msg); - if (m_pRecipPanel) - m_pRecipPanel->write(msg); + if (m_pBody) + m_pBody->write(msg); + if (m_pRecipPanel) + m_pRecipPanel->write(msg); } bool Conversation::read(Message &msg) { - if (readMsgAddress(msg)) { - if (m_pBody) - m_pBody->read(msg); - return true; - } - return false; + if (readMsgAddress(msg)) { + if (m_pBody) + m_pBody->read(msg); + return true; + } + return false; } bool Conversation::readMsgAddress(Message &msg) { - bool res = false; - if (m_ThreadId.isValid()) { - MsgAddressListRef addressList = getAddressList(); - if (addressList) { - res = !addressList->isEmpty(); - msg.addAddresses(*addressList); - } - } else { - if (m_pRecipPanel) { - m_pRecipPanel->read(msg); - res = !m_pRecipPanel->isMbeEmpty(); - } - } - return res; + bool res = false; + if (m_ThreadId.isValid()) { + MsgAddressListRef addressList = getAddressList(); + if (addressList) { + res = !addressList->isEmpty(); + msg.addAddresses(*addressList); + } + } else { + if (m_pRecipPanel) { + m_pRecipPanel->read(msg); + res = !m_pRecipPanel->isMbeEmpty(); + } + } + return res; } void Conversation::handleSendResult(const Message &msg, MsgTransport::SendResult result) { - if (result == MsgTransport::SendSuccess) - return; + if (result == MsgTransport::SendSuccess) + return; - const char *strId = nullptr; - switch (result) { - case MsgTransport::SendNoSIM: - strId = "IDS_MSG_BODY_UNABLE_TO_SEND_THIS_MESSAGE_INSERT_YOUR_SIM_CARD_AND_TRY_AGAIN"; - break; - case MsgTransport::SendDPMRestricted: - // Checked in checkBeforeSend() method. - return; - default: - strId = "IDS_MSGC_BODY_UNABLE_TO_SEND_MESSAGE"; - }; + const char *strId = nullptr; + switch (result) { + case MsgTransport::SendNoSIM: + strId = "IDS_MSG_BODY_UNABLE_TO_SEND_THIS_MESSAGE_INSERT_YOUR_SIM_CARD_AND_TRY_AGAIN"; + break; + case MsgTransport::SendDPMRestricted: + // Checked in checkBeforeSend() method. + return; + default: + strId = "IDS_MSGC_BODY_UNABLE_TO_SEND_MESSAGE"; + }; - auto &popupMngr = getApp().getPopupManager(); - Popup &popup = popupMngr.getPopup(); - popup.addButton(msgt("IDS_MSG_BUTTON_OK_ABB"), Popup::OkButtonId, POPUP_BUTTON_CB(Conversation, onMsgSendErrorButtonClicked), this); - popup.setContent(msgt(strId)); - popup.show(); + auto &popupMngr = getApp().getPopupManager(); + Popup &popup = popupMngr.getPopup(); + popup.addButton(msgt("IDS_MSG_BUTTON_OK_ABB"), Popup::OkButtonId, POPUP_BUTTON_CB(Conversation, onMsgSendErrorButtonClicked), this); + popup.setContent(msgt(strId)); + popup.show(); } bool Conversation::checkBeforeSend(const Message &msg) { - if (!getApp().getSysSettingsManager().isSimInserted()) { - handleSendResult(msg, MsgTransport::SendNoSIM); // Show no SIM card - return false; - } + if (!getApp().getSysSettingsManager().isSimInserted()) { + handleSendResult(msg, MsgTransport::SendNoSIM); // Show no SIM card + return false; + } - if (getApp().getSysSettingsManager().isMessagingRestrictedByDpm()) { - showSendDpmNotif(msg.getAddressList()); - return false; - } + if (getApp().getSysSettingsManager().isMessagingRestrictedByDpm()) { + showSendDpmNotif(msg.getAddressList()); + return false; + } - if (msg.isMms() && !getApp().getSysSettingsManager().isMobileDataEnabled()) { - showMobileDataPopup(); - return false; - } + if (msg.isMms() && !getApp().getSysSettingsManager().isMobileDataEnabled()) { + showMobileDataPopup(); + return false; + } - return true; + return true; } std::vector Conversation::getMsgIdListForReadReport() const { - std::vector msgIds; - if (m_pConvList) { - auto items = m_pConvList->getConvItems(); - for (ConvListItem *item : items) { - if (item->isNeededReadReport()) - msgIds.push_back(item->getMsgId()); - } - } + std::vector msgIds; + if (m_pConvList) { + auto items = m_pConvList->getConvItems(); + for (ConvListItem *item : items) { + if (item->isNeededReadReport()) + msgIds.push_back(item->getMsgId()); + } + } - return msgIds; + return msgIds; } bool Conversation::sendReadReportIfNeeded() { - if (getMsgEngine().getSettings().getMmsReadReport() && - !getApp().getSysSettingsManager().isMessagingRestrictedByDpm()) { - auto msgIds = getMsgIdListForReadReport(); - if (!msgIds.empty()) { - showSendReadReportPopup(); - return true; - } - } + if (getMsgEngine().getSettings().getMmsReadReport() && + !getApp().getSysSettingsManager().isMessagingRestrictedByDpm()) { + auto msgIds = getMsgIdListForReadReport(); + if (!msgIds.empty()) { + showSendReadReportPopup(); + return true; + } + } - return false; + return false; } void Conversation::sendReadReport(MsgReport::ReadStatus status) { - auto ids = getMsgIdListForReadReport(); - for (MsgId id : ids) - getMsgEngine().getTransport().sendReadReport(id, status); + auto ids = getMsgIdListForReadReport(); + for (MsgId id : ids) + getMsgEngine().getTransport().sendReadReport(id, status); } void Conversation::sendMessage(MsgId msgId) { - MessageRef msg = getMsgEngine().getStorage().getMessage(msgId); - if (msg && checkBeforeSend(*msg)) { - auto sentRes = getMsgEngine().getTransport().sendMessage(msg); - handleSendResult(*msg, sentRes); - } + MessageRef msg = getMsgEngine().getStorage().getMessage(msgId); + if (msg && checkBeforeSend(*msg)) { + auto sentRes = getMsgEngine().getTransport().sendMessage(msg); + handleSendResult(*msg, sentRes); + } } void Conversation::sendMessage() { - if (!m_pMsgInputPanel || !m_pBody) - return; + if (!m_pMsgInputPanel || !m_pBody) + return; - if (m_pRecipPanel && - m_pRecipPanel->getEntryFocus() && - !m_pRecipPanel->getEntryText().empty() && - !m_pRecipPanel->addRecipientsFromEntry()) - return; + if (m_pRecipPanel && + m_pRecipPanel->getEntryFocus() && + !m_pRecipPanel->getEntryText().empty() && + !m_pRecipPanel->addRecipientsFromEntry()) + return; - auto msg = getMsgEngine().getComposer().createMessage(m_IsMms ? Message::MT_MMS : Message::MT_SMS); - if (!msg || !read(*msg) || !checkBeforeSend(*msg)) - return; + auto msg = getMsgEngine().getComposer().createMessage(m_IsMms ? Message::MT_MMS : Message::MT_SMS); + if (!msg || !read(*msg) || !checkBeforeSend(*msg)) + return; - MSG_LOG("Old threadId = ", m_ThreadId); - MsgTransport::SendResult sendRes = getMsgEngine().getTransport().sendMessage(*msg, &m_ThreadId); + MSG_LOG("Old threadId = ", m_ThreadId); + MsgTransport::SendResult sendRes = getMsgEngine().getTransport().sendMessage(*msg, &m_ThreadId); - MSG_LOG("Send result = ", sendRes); - MSG_LOG("New threadId = ", m_ThreadId); + MSG_LOG("Send result = ", sendRes); + MSG_LOG("New threadId = ", m_ThreadId); - if (sendRes == MsgTransport::SendSuccess && m_ThreadId.isValid()) { - m_DispIsMms = false; // Skip "Convert to SMS" after sent message with MMS body. - setThreadId(m_ThreadId); - m_pMsgInputPanel->disabledButton(MessageInputPanel::SendButtonId, true); - m_pBody->clear(); - } else { - handleSendResult(*msg, sendRes); - } + if (sendRes == MsgTransport::SendSuccess && m_ThreadId.isValid()) { + m_DispIsMms = false; // Skip "Convert to SMS" after sent message with MMS body. + setThreadId(m_ThreadId); + m_pMsgInputPanel->disabledButton(MessageInputPanel::SendButtonId, true); + m_pBody->clear(); + } else { + handleSendResult(*msg, sendRes); + } - if (m_pListener) - m_pListener->onConversationSentMessage(); + if (m_pListener) + m_pListener->onConversationSentMessage(); } MsgId Conversation::saveDraftMsg() { - MsgId msgId; - if (!isBodyEmpty()) { - MessageRef msg = getMsgEngine().getComposer().createMessage(m_IsMms ? Message::MT_MMS : Message::MT_SMS); - if (msg) { - read(*msg); - msg->setMessageStorageType(Message::MS_Phone); - msgId = getMsgEngine().getStorage().saveMessage(*msg, false); - MSG_LOG("Draft message id = ", msgId); - } - } - return msgId; + MsgId msgId; + if (!isBodyEmpty()) { + MessageRef msg = getMsgEngine().getComposer().createMessage(m_IsMms ? Message::MT_MMS : Message::MT_SMS); + if (msg) { + read(*msg); + msg->setMessageStorageType(Message::MS_Phone); + msgId = getMsgEngine().getStorage().saveMessage(*msg, false); + MSG_LOG("Draft message id = ", msgId); + } + } + return msgId; } void Conversation::editDraftMsg(MsgId id) { - if (!m_pBody) - return; + if (!m_pBody) + return; - MessageRef msg = getMsgEngine().getStorage().getMessage(id); - if (msg) { - MsgId draftMsgId = saveDraftMsg(); - m_pBody->clear(); - if (m_pConvList->getMessageCount() <= 1 && !draftMsgId.isValid()) - setThreadId(ThreadId()); + MessageRef msg = getMsgEngine().getStorage().getMessage(id); + if (msg) { + MsgId draftMsgId = saveDraftMsg(); + m_pBody->clear(); + if (m_pConvList->getMessageCount() <= 1 && !draftMsgId.isValid()) + setThreadId(ThreadId()); - write(*msg); - if (getMsgEngine().getStorage().deleteMessage(id)) { - // Fast remove item in order to avoid blink: - m_pConvList->deleteItems({id}); - } - m_pBody->setFocus(true); - } + write(*msg); + if (getMsgEngine().getStorage().deleteMessage(id)) { + // Fast remove item in order to avoid blink: + m_pConvList->deleteItems({id}); + } + m_pBody->setFocus(true); + } } void Conversation::createNewMsgThread() { - MsgAddressListRef addressList = getAddressList(); - resetMsgThread(false, true); - if (m_pRecipPanel) - m_pRecipPanel->update(addressList); + MsgAddressListRef addressList = getAddressList(); + resetMsgThread(false, true); + if (m_pRecipPanel) + m_pRecipPanel->update(addressList); } void Conversation::notifyConvertMsgType() { - if (!m_NnotifyConvertMsgTypeIdler) { - m_NnotifyConvertMsgTypeIdler = ecore_idler_add( - [](void *data)->Eina_Bool - { - auto *self =(Conversation*)data; - self->m_NnotifyConvertMsgTypeIdler = nullptr; - if (self->m_DispIsMms != self->m_IsMms) { - self->m_DispIsMms = self->m_IsMms; - std::string notifText = self->m_IsMms ? - msg("IDS_MSGF_POP_CONVERTING_TO_MULTIMEDIA_MESSAGE_ING") : - (std::string)msg("IDS_MSGF_POP_CONVERTING_TO_TEXT_MESSAGE_ING"); - notification_status_message_post(notifText.c_str()); - } - return false; // Delete idler - }, - this); - } + if (!m_NnotifyConvertMsgTypeIdler) { + m_NnotifyConvertMsgTypeIdler = ecore_idler_add( + [](void *data)->Eina_Bool + { + auto *self =(Conversation*)data; + self->m_NnotifyConvertMsgTypeIdler = nullptr; + if (self->m_DispIsMms != self->m_IsMms) { + self->m_DispIsMms = self->m_IsMms; + std::string notifText = self->m_IsMms ? + msg("IDS_MSGF_POP_CONVERTING_TO_MULTIMEDIA_MESSAGE_ING") : + (std::string)msg("IDS_MSGF_POP_CONVERTING_TO_TEXT_MESSAGE_ING"); + notification_status_message_post(notifText.c_str()); + } + return false; // Delete idler + }, + this); + } } void Conversation::convertMsgTypeHandler() { - MSG_LOG("Is MMS: ", m_IsMms); - updateMsgInputPanel(); - notifyConvertMsgType(); + MSG_LOG("Is MMS: ", m_IsMms); + updateMsgInputPanel(); + notifyConvertMsgType(); } void Conversation::checkAndSetMsgType(bool force) { - // Body: - bool isMms = m_pBody ? m_pBody->isMms() : false; + // Body: + bool isMms = m_pBody ? m_pBody->isMms() : false; - // Recipients: - if (!isMms && m_pRecipPanel && !m_pRecipPanel->isMbeEmpty()) - isMms = m_pRecipPanel->isMms(); + // Recipients: + if (!isMms && m_pRecipPanel && !m_pRecipPanel->isMbeEmpty()) + isMms = m_pRecipPanel->isMms(); - if (force || isMms != m_IsMms) { - m_IsMms = isMms; - convertMsgTypeHandler(); - } + if (force || isMms != m_IsMms) { + m_IsMms = isMms; + convertMsgTypeHandler(); + } } void Conversation::resetDefferedCmd() { - m_DefferedCmd.composeCmd.reset(); - m_DefferedCmd.defaultCmd.reset(); + m_DefferedCmd.composeCmd.reset(); + m_DefferedCmd.defaultCmd.reset(); } bool Conversation::isDefferedCmd() const { - return m_DefferedCmd.composeCmd || m_DefferedCmd.defaultCmd; + return m_DefferedCmd.composeCmd || m_DefferedCmd.defaultCmd; } bool Conversation::isRecipExists() const { - return m_pRecipPanel && !m_pRecipPanel->isMbeEmpty(); + return m_pRecipPanel && !m_pRecipPanel->isMbeEmpty(); } bool Conversation::isBodyEmpty() const { - return !m_pBody || m_pBody->isEmpty(); + return !m_pBody || m_pBody->isEmpty(); } void Conversation::navigateToSlideShow(MsgId id) { - m_AttachPanel.show(false); - Viewer *viewer = new Viewer(getParent(), id); - getParent().push(*viewer); + m_AttachPanel.show(false); + Viewer *viewer = new Viewer(getParent(), id); + getParent().push(*viewer); } void Conversation::setBodyFocus() { - if (getOwner().getTransitionStatus()) { - m_TransFinishedFunc = [this]() - { - if (m_pBody) - m_pBody->setFocus(true); - }; - } else { - if (m_pBody) - m_pBody->setFocus(true); - } + if (getOwner().getTransitionStatus()) { + m_TransFinishedFunc = [this]() + { + if (m_pBody) + m_pBody->setFocus(true); + }; + } else { + if (m_pBody) + m_pBody->setFocus(true); + } } bool Conversation::getSipVisibility() const { - bool res = m_pBody ? m_pBody->getFocus() : false; - if (!res) - res = m_AttachPanel.isVisible(); - return res; + bool res = m_pBody ? m_pBody->getFocus() : false; + if (!res) + res = m_AttachPanel.isVisible(); + return res; } void Conversation::setRecipEntryFocus() { - if (getOwner().getTransitionStatus()) { - m_TransFinishedFunc = [this]() - { - if (m_pRecipPanel) - m_pRecipPanel->setEntryFocus(true); - }; - } else { - if (m_pRecipPanel) - m_pRecipPanel->setEntryFocus(true); - } + if (getOwner().getTransitionStatus()) { + m_TransFinishedFunc = [this]() + { + if (m_pRecipPanel) + m_pRecipPanel->setEntryFocus(true); + }; + } else { + if (m_pRecipPanel) + m_pRecipPanel->setEntryFocus(true); + } } PopupList &Conversation::createPopupList(const std::string &title) { - PopupList &popup = getApp().getPopupManager().getPopupList(); - popup.setTitle(title); - return popup; + PopupList &popup = getApp().getPopupManager().getPopupList(); + popup.setTitle(title); + return popup; } void Conversation::showSendDpmNotif(const MsgAddressList &addressList) { - int len = addressList.getLength(); - std::string addresses; - - for (int i = 0; i < len; ++i) { - std::string address = addressList[i].getAddress(); - std::string dispName; - if (!address.empty()) { - ContactAddressRef rec = getApp().getContactManager().getContactAddress(address); - if (rec) - dispName = rec->getDispName(); - addresses += makeDispAddress(address, dispName); - if (i < len - 1) - addresses += "
"; - } - } - - if (len <= 1) { - std::string text = msgArgs("IDS_MSG_POP_THE_SECURITY_POLICY_PREVENTS_SENDING_MESSAGES_TO_PS", addresses.c_str()); - notification_status_message_post(text.c_str()); - } else { - std::string text = msgArgs("IDS_MSG_POP_THE_SECURITY_POLICY_PREVENTS_SENDING_MESSAGES_TO_THE_FOLLOWING_RECIPIENTS_C_NPS", addresses.c_str()); - auto &popupMngr = getApp().getPopupManager(); - Popup &popup = popupMngr.getPopup(); - popup.addButton(msgt("IDS_MSG_BUTTON_OK_ABB"), Popup::OkButtonId); - popup.setContent(text); - popup.show(); - } + int len = addressList.getLength(); + std::string addresses; + + for (int i = 0; i < len; ++i) { + std::string address = addressList[i].getAddress(); + std::string dispName; + if (!address.empty()) { + ContactAddressRef rec = getApp().getContactManager().getContactAddress(address); + if (rec) + dispName = rec->getDispName(); + addresses += makeDispAddress(address, dispName); + if (i < len - 1) + addresses += "
"; + } + } + + if (len <= 1) { + std::string text = msgArgs("IDS_MSG_POP_THE_SECURITY_POLICY_PREVENTS_SENDING_MESSAGES_TO_PS", addresses.c_str()); + notification_status_message_post(text.c_str()); + } else { + std::string text = msgArgs("IDS_MSG_POP_THE_SECURITY_POLICY_PREVENTS_SENDING_MESSAGES_TO_THE_FOLLOWING_RECIPIENTS_C_NPS", addresses.c_str()); + auto &popupMngr = getApp().getPopupManager(); + Popup &popup = popupMngr.getPopup(); + popup.addButton(msgt("IDS_MSG_BUTTON_OK_ABB"), Popup::OkButtonId); + popup.setContent(text); + popup.show(); + } } void Conversation::showNoRecipPopup() { - Popup &popup = getApp().getPopupManager().getPopup(); - popup.addEventCb(EVAS_CALLBACK_DEL, EVAS_EVENT_CALLBACK(Conversation, onNoRecipPopupDel), this); - popup.addButton(msgt("IDS_MSG_BUTTON_CANCEL_ABB"), Popup::CancelButtonId); - popup.addButton(msgt("IDS_MSG_BUTTON_DISCARD_ABB"), Popup::OkButtonId, POPUP_BUTTON_CB(Conversation, onNoRecipDiscardButtonClicked), this); - popup.setTitle(msgt("IDS_MSG_HEADER_DISCARD_MESSAGE_M_CLOSE_ABB")); - popup.setContent(msgt("IDS_MSG_POP_NO_VALID_RECIPIENTS_HAVE_BEEN_ADDED_THIS_MESSAGE_WILL_BE_DISCARDED")); - popup.show(); + Popup &popup = getApp().getPopupManager().getPopup(); + popup.addEventCb(EVAS_CALLBACK_DEL, EVAS_EVENT_CALLBACK(Conversation, onNoRecipPopupDel), this); + popup.addButton(msgt("IDS_MSG_BUTTON_CANCEL_ABB"), Popup::CancelButtonId); + popup.addButton(msgt("IDS_MSG_BUTTON_DISCARD_ABB"), Popup::OkButtonId, POPUP_BUTTON_CB(Conversation, onNoRecipDiscardButtonClicked), this); + popup.setTitle(msgt("IDS_MSG_HEADER_DISCARD_MESSAGE_M_CLOSE_ABB")); + popup.setContent(msgt("IDS_MSG_POP_NO_VALID_RECIPIENTS_HAVE_BEEN_ADDED_THIS_MESSAGE_WILL_BE_DISCARDED")); + popup.show(); } void Conversation::showMobileDataPopup() { - auto &popupMngr = getApp().getPopupManager(); - Popup &popup = popupMngr.getPopup(); - popup.setTitle(msgt("IDS_MSG_HEADER_COULDNT_SEND_MESSAGE_ABB")); - popup.addButton(msgt("IDS_MSG_BUTTON_CANCEL_ABB2"), Popup::CancelButtonId, POPUP_BUTTON_CB(Conversation, onMsgSendErrorButtonClicked), this); - popup.addButton(msgt("IDS_MSGF_BODY_SETTINGS"), Popup::OkButtonId, POPUP_BUTTON_CB(Conversation, onMsgSettingsButtonClicked), this); - popup.setContent(msgt("IDS_MSGC_POP_MOBILE_DATA_IS_DISABLED_ENABLE_MOBILE_DATA_AND_TRY_AGAIN")); - popup.show(); + auto &popupMngr = getApp().getPopupManager(); + Popup &popup = popupMngr.getPopup(); + popup.setTitle(msgt("IDS_MSG_HEADER_COULDNT_SEND_MESSAGE_ABB")); + popup.addButton(msgt("IDS_MSG_BUTTON_CANCEL_ABB2"), Popup::CancelButtonId, POPUP_BUTTON_CB(Conversation, onMsgSendErrorButtonClicked), this); + popup.addButton(msgt("IDS_MSGF_BODY_SETTINGS"), Popup::OkButtonId, POPUP_BUTTON_CB(Conversation, onMsgSettingsButtonClicked), this); + popup.setContent(msgt("IDS_MSGC_POP_MOBILE_DATA_IS_DISABLED_ENABLE_MOBILE_DATA_AND_TRY_AGAIN")); + popup.show(); } void Conversation::showSendReadReportPopup() { - auto &popupMngr = getApp().getPopupManager(); - Popup &popup = popupMngr.getPopup(); - popup.setTitle(msgt("IDS_MSGF_OPT_SEND_READ_REPORT")); - popup.addEventCb(EVAS_CALLBACK_DEL, EVAS_EVENT_CALLBACK(Conversation, onSendReadReportPopupDel), this); - popup.addButton(msgt("IDS_MSG_BUTTON_SEND_ABB3"), Popup::OkButtonId, POPUP_BUTTON_CB(Conversation, onSendReadReportPopupButtonClicked), this); - popup.addButton(msgt("IDS_MSG_BUTTON_CANCEL_ABB2"), Popup::CancelButtonId, POPUP_BUTTON_CB(Conversation, onSendReadReportPopupButtonClicked), this); - popup.setContent(msgt("IDS_MSG_POP_THE_SENDER_HAS_REQUESTED_A_READ_REPORT_TAP_SEND_TO_SEND_ONE")); - popup.show(); + auto &popupMngr = getApp().getPopupManager(); + Popup &popup = popupMngr.getPopup(); + popup.setTitle(msgt("IDS_MSGF_OPT_SEND_READ_REPORT")); + popup.addEventCb(EVAS_CALLBACK_DEL, EVAS_EVENT_CALLBACK(Conversation, onSendReadReportPopupDel), this); + popup.addButton(msgt("IDS_MSG_BUTTON_SEND_ABB3"), Popup::OkButtonId, POPUP_BUTTON_CB(Conversation, onSendReadReportPopupButtonClicked), this); + popup.addButton(msgt("IDS_MSG_BUTTON_CANCEL_ABB2"), Popup::CancelButtonId, POPUP_BUTTON_CB(Conversation, onSendReadReportPopupButtonClicked), this); + popup.setContent(msgt("IDS_MSG_POP_THE_SENDER_HAS_REQUESTED_A_READ_REPORT_TAP_SEND_TO_SEND_ONE")); + popup.show(); } void Conversation::showMainPopup() { - PopupList &popup = getApp().getPopupManager().getMorePopup(); - popup.appendItem(msg("IDS_MSG_OPT_DELETE"), POPUPLIST_ITEM_PRESSED_CB(Conversation, onDeleteItemPressed), this); - if (m_AddressList && m_AddressList->getLength() == 1) { - const std::string adress = m_AddressList->at(0).getAddress(); - ContactAddressRef contactAddress = getApp().getContactManager().getContactAddress(adress); - - if (contactAddress) { - popup.appendItem(*new PopupPersonIdListItem(popup, msg("IDS_MSG_OPT_VIEW_CONTACT_DETAILS_ABB"), contactAddress->getOwnerId(), - contactAddress->getOwnerType(), POPUPLIST_ITEM_PRESSED_CB(Conversation, onViewContactDetailsItemPressed), this)); - } else if (!isHiddenAddress()) { - popup.appendItem(*new PopupAddressListItem(popup, msg("IDS_MSG_OPT_MAKE_VOICE_CALL"), adress, - POPUPLIST_ITEM_PRESSED_CB(Conversation, onMakeVoiceItemPressed), this)); - popup.appendItem(*new PopupAddressListItem(popup, msg("IDS_MSG_OPT_CREATE_CONTACT_ABB"), adress, - POPUPLIST_ITEM_PRESSED_CB(Conversation, onCreateContactItemPressed), this)); - popup.appendItem(*new PopupAddressListItem(popup, msg("IDS_MSG_OPT_UPDATE_CONTACT"), adress, - POPUPLIST_ITEM_PRESSED_CB(Conversation, onUpdateContactItemPressed), this)); - } - } - if (!isHiddenAddress()) - popup.appendItem(msg("IDS_MSG_TMBODY_ADD_OR_REMOVE_RECIPIENTS"), POPUPLIST_ITEM_PRESSED_CB(Conversation, onAddRecipientsItemPressed), this); - popup.show(); + PopupList &popup = getApp().getPopupManager().getMorePopup(); + popup.appendItem(msg("IDS_MSG_OPT_DELETE"), POPUPLIST_ITEM_PRESSED_CB(Conversation, onDeleteItemPressed), this); + if (m_AddressList && m_AddressList->getLength() == 1) { + const std::string adress = m_AddressList->at(0).getAddress(); + ContactAddressRef contactAddress = getApp().getContactManager().getContactAddress(adress); + + if (contactAddress) { + popup.appendItem(*new PopupPersonIdListItem(popup, msg("IDS_MSG_OPT_VIEW_CONTACT_DETAILS_ABB"), contactAddress->getOwnerId(), + contactAddress->getOwnerType(), POPUPLIST_ITEM_PRESSED_CB(Conversation, onViewContactDetailsItemPressed), this)); + } else if (!isHiddenAddress()) { + popup.appendItem(*new PopupAddressListItem(popup, msg("IDS_MSG_OPT_MAKE_VOICE_CALL"), adress, + POPUPLIST_ITEM_PRESSED_CB(Conversation, onMakeVoiceItemPressed), this)); + popup.appendItem(*new PopupAddressListItem(popup, msg("IDS_MSG_OPT_CREATE_CONTACT_ABB"), adress, + POPUPLIST_ITEM_PRESSED_CB(Conversation, onCreateContactItemPressed), this)); + popup.appendItem(*new PopupAddressListItem(popup, msg("IDS_MSG_OPT_UPDATE_CONTACT"), adress, + POPUPLIST_ITEM_PRESSED_CB(Conversation, onUpdateContactItemPressed), this)); + } + } + if (!isHiddenAddress()) + popup.appendItem(msg("IDS_MSG_TMBODY_ADD_OR_REMOVE_RECIPIENTS"), POPUPLIST_ITEM_PRESSED_CB(Conversation, onAddRecipientsItemPressed), this); + popup.show(); } void Conversation::onKeyDown(ConvRecipientsPanel &panel, Evas_Event_Key_Down &ev) { - if (ev.keyname) { - if ((strcmp(ev.keyname, "Return") == 0)) { - m_pBody->setFocus(true); - } else { - if (m_pContactsList) { - m_pContactsList->setSearchWorld(m_pRecipPanel->getEntryText()); - m_pContactsList->requestSearch(); - } - } - } + if (ev.keyname) { + if ((strcmp(ev.keyname, "Return") == 0)) { + m_pBody->setFocus(true); + } else { + if (m_pContactsList) { + m_pContactsList->setSearchWorld(m_pRecipPanel->getEntryText()); + m_pContactsList->requestSearch(); + } + } + } } void Conversation::onEntryFocusChanged(ConvRecipientsPanel &panel) { - MSG_LOG(""); - if (!m_pRecipPanel->getEntryFocus() && m_pContactsList) - m_pContactsList->clear(); + MSG_LOG(""); + if (!m_pRecipPanel->getEntryFocus() && m_pContactsList) + m_pContactsList->clear(); } void Conversation::onEntryChanged(ConvRecipientsPanel &panel) { - MSG_LOG(""); - if (m_pRecipPanel->isEntryEmpty() && m_pContactsList) - m_pContactsList->clear(); + MSG_LOG(""); + if (m_pRecipPanel->isEntryEmpty() && m_pContactsList) + m_pContactsList->clear(); } void Conversation::onMbeChanged(ConvRecipientsPanel &panel) { - MSG_LOG(""); - if (m_pBody) - m_pBody->setMmsRecipFlag(m_pRecipPanel->isMms()); - checkAndSetMsgType(); - if (m_pConvList) { - std::list recips; - auto items = panel.getMbeRecipients().getItems(); - for (MbeRecipientItem *item : items) { - recips.push_back(item->getAddress()); - } - ThreadId id; - if (!recips.empty()) - id = getMsgEngine().getStorage().getThreadId(recips); - - m_pConvList->setThreadId(id); - updateActiveNotifPolicy(); - m_pConvList->navigateToBottom(); - } + MSG_LOG(""); + if (m_pBody) + m_pBody->setMmsRecipFlag(m_pRecipPanel->isMms()); + checkAndSetMsgType(); + if (m_pConvList) { + std::list recips; + auto items = panel.getMbeRecipients().getItems(); + for (MbeRecipientItem *item : items) { + recips.push_back(item->getAddress()); + } + ThreadId id; + if (!recips.empty()) + id = getMsgEngine().getStorage().getThreadId(recips); + + m_pConvList->setThreadId(id); + updateActiveNotifPolicy(); + m_pConvList->navigateToBottom(); + } } void Conversation::onItemClicked(ConvRecipientsPanel &panel, MbeRecipientItem &item) { - MSG_LOG(""); - recipientClickHandler(item.getAddress()); + MSG_LOG(""); + recipientClickHandler(item.getAddress()); } void Conversation::onEntrySizeChanged(ConvRecipientsPanel &panel) { - updateRecipientArea(); + updateRecipientArea(); } void Conversation::onChanged(Body &body) { - updateMsgInputPanel(); - checkAndSetMsgType(); + updateMsgInputPanel(); + checkAndSetMsgType(); } void Conversation::updateMsgInputPanel() { - if (!m_pBody || !m_pMsgInputPanel) - return; + if (!m_pBody || !m_pMsgInputPanel) + return; - if (m_pBody->isMms()) { - // Mms: - m_pMsgInputPanel->setCounter(MsgUtils::makeKbStr(m_pBody->getMsgSize())); - } else { - // Sms: - std::ostringstream ss; - const MsgTextMetric &size = m_pBody->getTextMetric(); - ss << size.charsLeft << "/" << size.segmentsCount; - m_pMsgInputPanel->setCounter(ss.str()); - } + if (m_pBody->isMms()) { + // Mms: + m_pMsgInputPanel->setCounter(MsgUtils::makeKbStr(m_pBody->getMsgSize())); + } else { + // Sms: + std::ostringstream ss; + const MsgTextMetric &size = m_pBody->getTextMetric(); + ss << size.charsLeft << "/" << size.segmentsCount; + m_pMsgInputPanel->setCounter(ss.str()); + } - bool disabledButton = m_pBody->isEmpty(); - m_pMsgInputPanel->disabledButton(MessageInputPanel::SendButtonId, disabledButton); + bool disabledButton = m_pBody->isEmpty(); + m_pMsgInputPanel->disabledButton(MessageInputPanel::SendButtonId, disabledButton); } void Conversation::updateNavibar() { - NaviBar &naviBar = getNaviBar(); - naviBar.clear(); - naviBar.setColor(NaviBar::NaviWhiteColorId); - - if (m_Mode == NewMessageMode) { - naviBar.setTitle(msgt("IDS_MSG_HEADER_COMPOSE_MESSAGE_ABB")); - naviBar.showButton(NaviPrevButtonId, true); - } else if (m_Mode == ConversationMode) { - if (m_DeleteMode) { - updateSelectMsgTitle(); - naviBar.showButton(NaviCancelButtonId, true); - naviBar.showButton(NaviOkButtonId, true); - naviBar.setButtonText(NaviOkButtonId, msgt("IDS_MSG_ACBUTTON_DELETE_ABB")); - naviBar.disabledButton(NaviOkButtonId, true); - naviBar.setDownButtonState(false); - if (m_pRecipPanel) - m_pRecipPanel->showMbe(false, false); - } else { - naviBar.showButton(NaviPrevButtonId, true); - MsgAddressListRef addressList = getAddressList(); - if (addressList) { - naviBar.showButton(NaviCenterButtonId, true); - FrameController::setNaviBarTitle(*addressList); - } - } - } + NaviBar &naviBar = getNaviBar(); + naviBar.clear(); + naviBar.setColor(NaviBar::NaviWhiteColorId); + + if (m_Mode == NewMessageMode) { + naviBar.setTitle(msgt("IDS_MSG_HEADER_COMPOSE_MESSAGE_ABB")); + naviBar.showButton(NaviPrevButtonId, true); + } else if (m_Mode == ConversationMode) { + if (m_DeleteMode) { + updateSelectMsgTitle(); + naviBar.showButton(NaviCancelButtonId, true); + naviBar.showButton(NaviOkButtonId, true); + naviBar.setButtonText(NaviOkButtonId, msgt("IDS_MSG_ACBUTTON_DELETE_ABB")); + naviBar.disabledButton(NaviOkButtonId, true); + naviBar.setDownButtonState(false); + if (m_pRecipPanel) + m_pRecipPanel->showMbe(false, false); + } else { + naviBar.showButton(NaviPrevButtonId, true); + MsgAddressListRef addressList = getAddressList(); + if (addressList) { + naviBar.showButton(NaviCenterButtonId, true); + FrameController::setNaviBarTitle(*addressList); + } + } + } } void Conversation::updateSelectMsgTitle() { - if (m_pConvList && m_DeleteMode) { - int checked = m_pConvList->getMessageCheckedCount(); - if (checked > 0) - getNaviBar().setTitle(msgArgs("IDS_MSG_HEADER_PD_SELECTED_ABB3", checked)); - else - getNaviBar().setTitle(msgt("IDS_MSGF_HEADER_SELECT_MESSAGES")); - } + if (m_pConvList && m_DeleteMode) { + int checked = m_pConvList->getMessageCheckedCount(); + if (checked > 0) + getNaviBar().setTitle(msgArgs("IDS_MSG_HEADER_PD_SELECTED_ABB3", checked)); + else + getNaviBar().setTitle(msgt("IDS_MSGF_HEADER_SELECT_MESSAGES")); + } } void Conversation::updateRecipientArea() { - MSG_LOG(""); - int height = m_pRecipPanel->getEntryHeight(); - m_pLayout->setRecipEntryHeight(height); + MSG_LOG(""); + int height = m_pRecipPanel->getEntryHeight(); + m_pLayout->setRecipEntryHeight(height); } void Conversation::onButtonClicked(MessageInputPanel &obj, MessageInputPanel::ButtonId id) { - MSG_LOG("MessageInputPanel: button clicked: id = ", id); + MSG_LOG("MessageInputPanel: button clicked: id = ", id); - switch (id) { - case MessageInputPanel::AddButtonId: - m_AttachPanel.show(true); - break; - case MessageInputPanel::SendButtonId: - sendMessage(); - m_AttachPanel.show(false); - break; - default: - break; - } + switch (id) { + case MessageInputPanel::AddButtonId: + m_AttachPanel.show(true); + break; + case MessageInputPanel::SendButtonId: + sendMessage(); + m_AttachPanel.show(false); + break; + default: + break; + } } void Conversation::onContactSelected(ContactListItem &item) { - m_pRecipPanel->appendItem(item.getRecipient()); - m_pRecipPanel->clearEntry(); - m_pContactsList->clear(); + m_pRecipPanel->appendItem(item.getRecipient()); + m_pRecipPanel->clearEntry(); + m_pContactsList->clear(); } void Conversation::onContactListChanged() { - if (m_pContactsList) - m_pLayout->showContactList(!m_pContactsList->isEmpty()); + if (m_pContactsList) + m_pLayout->showContactList(!m_pContactsList->isEmpty()); } void Conversation::onAttached(ViewItem &item) { - MSG_LOG(""); - FrameController::onAttached(item); - updateNavibar(); - setContent(*m_pLayout); + MSG_LOG(""); + FrameController::onAttached(item); + updateNavibar(); + setContent(*m_pLayout); } void Conversation::onTransitionFinished(NaviFrameItem &item) { - MSG_LOG(""); - if (m_TransFinishedFunc) { - m_TransFinishedFunc(); - m_TransFinishedFunc = nullptr; - } + MSG_LOG(""); + if (m_TransFinishedFunc) { + m_TransFinishedFunc(); + m_TransFinishedFunc = nullptr; + } } void Conversation::onPause() { - MSG_LOG(""); - updateActiveNotifPolicy(); + MSG_LOG(""); + updateActiveNotifPolicy(); } void Conversation::onResume() { - MSG_LOG(""); - updateActiveNotifPolicy(); + MSG_LOG(""); + updateActiveNotifPolicy(); } void Conversation::onHwBackButtonClicked() { - MSG_LOG(""); - if (m_DeleteMode) { - setDeleteMode(false); - return; - } + MSG_LOG(""); + if (m_DeleteMode) { + setDeleteMode(false); + return; + } - if (m_pRecipPanel) { - if (m_pRecipPanel->isMbeVisible() || m_pRecipPanel->getItemsCount() == 0) - m_pRecipPanel->addRecipientsFromEntry(false); - m_pRecipPanel->clearEntry(); - } + if (m_pRecipPanel) { + if (m_pRecipPanel->isMbeVisible() || m_pRecipPanel->getItemsCount() == 0) + m_pRecipPanel->addRecipientsFromEntry(false); + m_pRecipPanel->clearEntry(); + } - if (!isRecipExists() && !isBodyEmpty() && m_Mode == NewMessageMode) { - showNoRecipPopup(); - return; - } + if (!isRecipExists() && !isBodyEmpty() && m_Mode == NewMessageMode) { + showNoRecipPopup(); + return; + } - if (sendReadReportIfNeeded()) - return; + if (sendReadReportIfNeeded()) + return; - m_AttachPanel.reset(); - saveDraftMsg(); - pop(); + m_AttachPanel.reset(); + saveDraftMsg(); + pop(); } void Conversation::onHwMoreButtonClicked() { - MSG_LOG(""); - if (m_Mode == ConversationMode && !m_DeleteMode) - showMainPopup(); + MSG_LOG(""); + if (m_Mode == ConversationMode && !m_DeleteMode) + showMainPopup(); } void Conversation::onNaviOkButtonClicked() { - MSG_LOG(""); - if (m_Mode == ConversationMode && m_DeleteMode) { - m_pConvList->deleteSelectedItems(); - setDeleteMode(false); - } + MSG_LOG(""); + if (m_Mode == ConversationMode && m_DeleteMode) { + m_pConvList->deleteSelectedItems(); + setDeleteMode(false); + } } void Conversation::onNaviCenterButtonClicked() { - MSG_LOG(""); - if (m_pRecipPanel) { - onNaviExpandButtonClicked(); - } else { - MsgAddressListRef addressList = getAddressList(); - if (addressList && !addressList->isEmpty() && !isHiddenAddress()) - recipientClickHandler(addressList->at(0).getAddress()); - } + MSG_LOG(""); + if (m_pRecipPanel) { + onNaviExpandButtonClicked(); + } else { + MsgAddressListRef addressList = getAddressList(); + if (addressList && !addressList->isEmpty() && !isHiddenAddress()) + recipientClickHandler(addressList->at(0).getAddress()); + } } void Conversation::onNaviExpandButtonClicked() { - MSG_LOG(""); - if (m_pRecipPanel) { - bool isMbeInvisible = !m_pRecipPanel->isMbeVisible(); - m_pRecipPanel->showMbe(isMbeInvisible); - getNaviBar().setDownButtonState(isMbeInvisible); - } + MSG_LOG(""); + if (m_pRecipPanel) { + bool isMbeInvisible = !m_pRecipPanel->isMbeVisible(); + m_pRecipPanel->showMbe(isMbeInvisible); + getNaviBar().setDownButtonState(isMbeInvisible); + } } void Conversation::onButtonClicked(NaviFrameItem &item, NaviButtonId buttonId) { - switch (buttonId) { - case NaviPrevButtonId: - onHwBackButtonClicked(); - break; - case NaviExpandButtonId: - onNaviExpandButtonClicked(); - break; - case NaviCenterButtonId: - onNaviCenterButtonClicked(); - break; - case NaviCancelButtonId: - onHwBackButtonClicked(); - break; - case NaviOkButtonId: - onNaviOkButtonClicked(); - break; - default: - MSG_LOG_ERROR("Invalid buttonId: ", buttonId); - break; - } + switch (buttonId) { + case NaviPrevButtonId: + onHwBackButtonClicked(); + break; + case NaviExpandButtonId: + onNaviExpandButtonClicked(); + break; + case NaviCenterButtonId: + onNaviCenterButtonClicked(); + break; + case NaviCancelButtonId: + onHwBackButtonClicked(); + break; + case NaviOkButtonId: + onNaviOkButtonClicked(); + break; + default: + MSG_LOG_ERROR("Invalid buttonId: ", buttonId); + break; + } } void Conversation::onNoRecipPopupDel(Evas_Object *popup, void *eventInfo) { - MSG_LOG(""); - resetDefferedCmd(); + MSG_LOG(""); + resetDefferedCmd(); } void Conversation::onSendReadReportPopupDel(Evas_Object *popup, void *eventInfo) { - MSG_LOG(""); - pop(); + MSG_LOG(""); + pop(); } void Conversation::onSendReadReportPopupButtonClicked(Popup &popup, int buttonId) { - MSG_LOG(""); - if (buttonId == Popup::OkButtonId) - sendReadReport(MsgReport::ReadStatusIsRead); - popup.destroy(); + MSG_LOG(""); + if (buttonId == Popup::OkButtonId) + sendReadReport(MsgReport::ReadStatusIsRead); + popup.destroy(); } void Conversation::onRecipPopupDel(Evas_Object *popup, void *eventInfo) { - MSG_LOG(""); - if (m_pRecipPanel) - m_pRecipPanel->unselectMbeItem(); + MSG_LOG(""); + if (m_pRecipPanel) + m_pRecipPanel->unselectMbeItem(); } void Conversation::onMsgSendErrorButtonClicked(Popup &popup, int buttonId) { - MSG_LOG(""); - popup.destroy(); + MSG_LOG(""); + popup.destroy(); } void Conversation::onMsgSettingsButtonClicked(Popup &popup, int buttonId) { - MSG_LOG(""); - m_SettingsNetwork.launch(); - popup.destroy(); + MSG_LOG(""); + m_SettingsNetwork.launch(); + popup.destroy(); } void Conversation::onNoRecipDiscardButtonClicked(Popup &popup, int buttonId) { - if (isDefferedCmd()) { - if (m_pBody) - m_pBody->clear(); - if (m_DefferedCmd.defaultCmd) { // If we came from notification menu and unread threads will be more than one, we should to go back on thread list view - if (m_DefferedCmd.defaultCmd->getDefaultType() == AppControlDefault::NotificationType && getMsgEngine().getStorage().getUnreadThreadCount() > 1) { - pop(); - } else { - // Go to needed conversation - MessageRef msg = getMsgEngine().getStorage().getMessage(m_DefferedCmd.defaultCmd->getMessageId()); - if (msg) - setThreadId(msg->getThreadId()); - if (m_DefferedCmd.defaultCmd->getDefaultType() == AppControlDefault::ReplyType && m_pBody) - { - m_pBody->execCmd(m_DefferedCmd.defaultCmd); - m_pBody->setFocus(true); - } - } - } else if (m_DefferedCmd.composeCmd) { - // Go to needed conversation - setThreadId(ThreadId()); - if (m_pRecipPanel) - m_pRecipPanel->execCmd(m_DefferedCmd.composeCmd); - if (m_pBody) - m_pBody->execCmd(m_DefferedCmd.composeCmd); - } - resetDefferedCmd(); - } else { - pop(); - } - - if (!isPopping()) - popup.destroy(); + if (isDefferedCmd()) { + if (m_pBody) + m_pBody->clear(); + if (m_DefferedCmd.defaultCmd) { // If we came from notification menu and unread threads will be more than one, we should to go back on thread list view + if (m_DefferedCmd.defaultCmd->getDefaultType() == AppControlDefault::NotificationType && getMsgEngine().getStorage().getUnreadThreadCount() > 1) { + pop(); + } else { + // Go to needed conversation + MessageRef msg = getMsgEngine().getStorage().getMessage(m_DefferedCmd.defaultCmd->getMessageId()); + if (msg) + setThreadId(msg->getThreadId()); + if (m_DefferedCmd.defaultCmd->getDefaultType() == AppControlDefault::ReplyType && m_pBody) + { + m_pBody->execCmd(m_DefferedCmd.defaultCmd); + m_pBody->setFocus(true); + } + } + } else if (m_DefferedCmd.composeCmd) { + // Go to needed conversation + setThreadId(ThreadId()); + if (m_pRecipPanel) + m_pRecipPanel->execCmd(m_DefferedCmd.composeCmd); + if (m_pBody) + m_pBody->execCmd(m_DefferedCmd.composeCmd); + } + resetDefferedCmd(); + } else { + pop(); + } + + if (!isPopping()) + popup.destroy(); } void Conversation::onDeleteItemPressed(PopupListItem &item) { - MSG_LOG(""); - item.getParent().destroy(); - setDeleteMode(true); + MSG_LOG(""); + item.getParent().destroy(); + setDeleteMode(true); } void Conversation::onAddRecipientsItemPressed(PopupListItem &item) { - MSG_LOG(""); - item.getParent().destroy(); - if (m_AttachPanel.isFullExpanded()) - m_AttachPanel.show(false); - createNewMsgThread(); - if (m_pRecipPanel) - m_pRecipPanel->setEntryFocus(true); + MSG_LOG(""); + item.getParent().destroy(); + if (m_AttachPanel.isFullExpanded()) + m_AttachPanel.show(false); + createNewMsgThread(); + if (m_pRecipPanel) + m_pRecipPanel->setEntryFocus(true); } void Conversation::onMakeVoiceItemPressed(PopupListItem &item) { - MSG_LOG(""); - std::string address = static_cast(item).getAddress(); - item.getParent().destroy(); - VoiceCall::launch(address); + MSG_LOG(""); + std::string address = static_cast(item).getAddress(); + item.getParent().destroy(); + VoiceCall::launch(address); } void Conversation::onCreateContactItemPressed(PopupListItem &item) { - MSG_LOG(""); - std::string address = static_cast(item).getAddress(); - item.getParent().destroy(); - m_ContactEditor.launch(address, ContactEditor::CreateOp); + MSG_LOG(""); + std::string address = static_cast(item).getAddress(); + item.getParent().destroy(); + m_ContactEditor.launch(address, ContactEditor::CreateOp); } void Conversation::onUpdateContactItemPressed(PopupListItem &item) { - MSG_LOG(""); - std::string address = static_cast(item).getAddress(); - item.getParent().destroy(); - m_ContactEditor.launch(address, ContactEditor::EditOp); + MSG_LOG(""); + std::string address = static_cast(item).getAddress(); + item.getParent().destroy(); + m_ContactEditor.launch(address, ContactEditor::EditOp); } void Conversation::onRecipRemoveItemPressed(PopupListItem &item) { - MSG_LOG(""); - item.getParent().destroy(); - m_pRecipPanel->removeSelectedItem(); - m_pRecipPanel->setEntryFocus(true); + MSG_LOG(""); + item.getParent().destroy(); + m_pRecipPanel->removeSelectedItem(); + m_pRecipPanel->setEntryFocus(true); } void Conversation::onEditItemPressed(PopupListItem &item) { - MSG_LOG(""); - item.getParent().destroy(); - m_pRecipPanel->editSelectedItem(); + MSG_LOG(""); + item.getParent().destroy(); + m_pRecipPanel->editSelectedItem(); } void Conversation::onViewContactDetailsItemPressed(PopupListItem &item) { - MSG_LOG(""); - int id = static_cast(item).getContactId(); - auto ownerType = static_cast(item).getContactOwnerType(); - item.getParent().destroy(); - m_ContactViewer.launch(id, ownerType); + MSG_LOG(""); + int id = static_cast(item).getContactId(); + auto ownerType = static_cast(item).getContactOwnerType(); + item.getParent().destroy(); + m_ContactViewer.launch(id, ownerType); } void Conversation::onAllConvItemsDeleted(ConvList &list) { - MSG_LOG(""); - if (m_Mode != NewMessageMode) { - auto convList = getMsgEngine().getStorage().getConversationList(m_ThreadId); - if ((convList && convList->getLength() == 0) || !convList) { - if (isBodyEmpty()) { - onHwBackButtonClicked(); - } else { - // Current MsgThread is dead, so create new MsgThread from existing recipients. - createNewMsgThread(); - if (m_pBody) - m_pBody->setFocus(true); - } - } - } + MSG_LOG(""); + if (m_Mode != NewMessageMode) { + auto convList = getMsgEngine().getStorage().getConversationList(m_ThreadId); + if ((convList && convList->getLength() == 0) || !convList) { + if (isBodyEmpty()) { + onHwBackButtonClicked(); + } else { + // Current MsgThread is dead, so create new MsgThread from existing recipients. + createNewMsgThread(); + if (m_pBody) + m_pBody->setFocus(true); + } + } + } } void Conversation::onEditDraftMsg(MsgId id) { - MSG_LOG(""); - editDraftMsg(id); + MSG_LOG(""); + editDraftMsg(id); } void Conversation::onForwardMsg(MsgId id) { - MSG_LOG(""); - forwardMsg(id); + MSG_LOG(""); + forwardMsg(id); } void Conversation::onResendMsg(MsgId id) { - MSG_LOG(""); - sendMessage(id); + MSG_LOG(""); + sendMessage(id); } void Conversation::onSlideShow(MsgId id) { - MSG_LOG(""); - navigateToSlideShow(id); + MSG_LOG(""); + navigateToSlideShow(id); } void Conversation::onSaveAttachments(MsgId id) { - MSG_LOG(""); - m_AttachPanel.show(false); - SaveAttachments *controller = new SaveAttachments(getParent(), id); - getParent().push(*controller); + MSG_LOG(""); + m_AttachPanel.show(false); + SaveAttachments *controller = new SaveAttachments(getParent(), id); + getParent().push(*controller); } void Conversation::onConvListItemChecked() { - getNaviBar().disabledButton(NaviOkButtonId, m_pConvList->getMessageCheckedCount() == 0); - updateSelectMsgTitle(); + getNaviBar().disabledButton(NaviOkButtonId, m_pConvList->getMessageCheckedCount() == 0); + updateSelectMsgTitle(); } void Conversation::onFileSelected(AttachPanel &panel, const AttachPanel::FileList &files) { - MSG_LOG(""); - m_pBody->addAttachments(files); + MSG_LOG(""); + m_pBody->addAttachments(files); } void Conversation::onContactChanged() { - MSG_LOG(""); - contactChangedHandler(); + MSG_LOG(""); + contactChangedHandler(); } void Conversation::onLanguageChanged() { - MSG_LOG(""); - updateMsgInputPanel(); - updateSelectMsgTitle(); + MSG_LOG(""); + updateMsgInputPanel(); + updateSelectMsgTitle(); } diff --git a/src/Conversation/Main/Controller/src/PopupRecipientListItem.cpp b/src/Conversation/Main/Controller/src/PopupRecipientListItem.cpp index 68a9ca09..e2df56b0 100644 --- a/src/Conversation/Main/Controller/src/PopupRecipientListItem.cpp +++ b/src/Conversation/Main/Controller/src/PopupRecipientListItem.cpp @@ -19,12 +19,12 @@ using namespace Msg; PopupAddressListItem::PopupAddressListItem(PopupList &parent, - const std::string &text, - const std::string &address, - PopupListItemPressedCb cb, - void *userData) - : PopupTextListItem(parent, text, cb, userData) - , m_Address(address) + const std::string &text, + const std::string &address, + PopupListItemPressedCb cb, + void *userData) + : PopupTextListItem(parent, text, cb, userData) + , m_Address(address) { } @@ -34,19 +34,19 @@ PopupAddressListItem::~PopupAddressListItem() std::string PopupAddressListItem::getAddress() const { - return m_Address; + return m_Address; } PopupPersonIdListItem::PopupPersonIdListItem(PopupList &parent, - const std::string &text, - int contactId, - ContactAddress::OwnerType ownerType, - PopupListItemPressedCb cb, - void *userData) - : PopupTextListItem(parent, text, cb, userData) - , m_ContactId(contactId) - , m_OwnerType(ownerType) + const std::string &text, + int contactId, + ContactAddress::OwnerType ownerType, + PopupListItemPressedCb cb, + void *userData) + : PopupTextListItem(parent, text, cb, userData) + , m_ContactId(contactId) + , m_OwnerType(ownerType) { } @@ -56,10 +56,10 @@ PopupPersonIdListItem::~PopupPersonIdListItem() int PopupPersonIdListItem::getContactId() const { - return m_ContactId; + return m_ContactId; } ContactAddress::OwnerType PopupPersonIdListItem::getContactOwnerType() const { - return m_OwnerType; + return m_OwnerType; } diff --git a/src/Conversation/Main/View/inc/ConversationLayout.h b/src/Conversation/Main/View/inc/ConversationLayout.h index 63322116..6126c4ff 100644 --- a/src/Conversation/Main/View/inc/ConversationLayout.h +++ b/src/Conversation/Main/View/inc/ConversationLayout.h @@ -22,30 +22,30 @@ #include namespace Msg { - class ConversationLayout - : public View { - public: - ConversationLayout(Evas_Object *parent); - virtual ~ConversationLayout(); - - void showContactList(bool value); - void setConvList(Evas_Object *layout); - void setContactList(Evas_Object *layout); - void setMsgInputPanel(Evas_Object *layout); - void setRecipientPanel(Evas_Object *layout); - void setRecipientRect(Evas_Object *layout); - void showRecipEditMode(bool show); - void showMsgInputPanel(bool show); - void setRecipEntryHeight(int height); - - private: - void create(Evas_Object *parent); - Evas_Object *createMainLayout(Evas_Object *parent); - - private: - Evas_Object *m_pLayout; - Evas_Object *m_pRect; - }; + class ConversationLayout + : public View { + public: + ConversationLayout(Evas_Object *parent); + virtual ~ConversationLayout(); + + void showContactList(bool value); + void setConvList(Evas_Object *layout); + void setContactList(Evas_Object *layout); + void setMsgInputPanel(Evas_Object *layout); + void setRecipientPanel(Evas_Object *layout); + void setRecipientRect(Evas_Object *layout); + void showRecipEditMode(bool show); + void showMsgInputPanel(bool show); + void setRecipEntryHeight(int height); + + private: + void create(Evas_Object *parent); + Evas_Object *createMainLayout(Evas_Object *parent); + + private: + Evas_Object *m_pLayout; + Evas_Object *m_pRect; + }; } #endif /* ConversationLayout_h_ */ diff --git a/src/Conversation/Main/View/inc/MessageInputPanel.h b/src/Conversation/Main/View/inc/MessageInputPanel.h index 603207f6..6a87e50c 100644 --- a/src/Conversation/Main/View/inc/MessageInputPanel.h +++ b/src/Conversation/Main/View/inc/MessageInputPanel.h @@ -22,51 +22,51 @@ #include namespace Msg { - class IMessageInputPanelListener; + class IMessageInputPanelListener; - class MessageInputPanel - : public View { - public: - enum ButtonId { - AddButtonId, - SendButtonId - }; + class MessageInputPanel + : public View { + public: + enum ButtonId { + AddButtonId, + SendButtonId + }; - public: - MessageInputPanel(Evas_Object *parent); - virtual ~MessageInputPanel(); + public: + MessageInputPanel(Evas_Object *parent); + virtual ~MessageInputPanel(); - void setEntry(Evas_Object *obj); - void disabledButton(ButtonId id, bool val); - void setCounter(const std::string &text); - void setListener(IMessageInputPanelListener *l); + void setEntry(Evas_Object *obj); + void disabledButton(ButtonId id, bool val); + void setCounter(const std::string &text); + void setListener(IMessageInputPanelListener *l); - private: - void create(Evas_Object *parent); - Evas_Object *createButton(Evas_Object *parent, ButtonId buttonId, const char *res); - Evas_Object *getIcon(Evas_Object *button); - Evas_Object *getButton(ButtonId id); + private: + void create(Evas_Object *parent); + Evas_Object *createButton(Evas_Object *parent, ButtonId buttonId, const char *res); + Evas_Object *getIcon(Evas_Object *button); + Evas_Object *getButton(ButtonId id); - void setNormalColor(Evas_Object *button); - void setPressedColor(Evas_Object *button); - void setDisabledColor(Evas_Object *button); + void setNormalColor(Evas_Object *button); + void setPressedColor(Evas_Object *button); + void setDisabledColor(Evas_Object *button); - void onButtonClicked(Evas_Object *obj, void *event_info); - void onButtonPressed(Evas_Object *obj, void *event_info); - void onButtonUnpressed(Evas_Object *obj, void *event_info); + void onButtonClicked(Evas_Object *obj, void *event_info); + void onButtonPressed(Evas_Object *obj, void *event_info); + void onButtonUnpressed(Evas_Object *obj, void *event_info); - private: - IMessageInputPanelListener * m_pListener; - Evas_Object *m_pLayout; - Evas_Object *m_pSendButton; - Evas_Object *m_pAddButton; - }; + private: + IMessageInputPanelListener * m_pListener; + Evas_Object *m_pLayout; + Evas_Object *m_pSendButton; + Evas_Object *m_pAddButton; + }; - class IMessageInputPanelListener { - public: - virtual ~IMessageInputPanelListener() {} - virtual void onButtonClicked(MessageInputPanel &obj, MessageInputPanel::ButtonId id) {}; - }; + class IMessageInputPanelListener { + public: + virtual ~IMessageInputPanelListener() {} + virtual void onButtonClicked(MessageInputPanel &obj, MessageInputPanel::ButtonId id) {}; + }; } #endif /* MessageInputPanel_h_ */ diff --git a/src/Conversation/Main/View/src/ConversationLayout.cpp b/src/Conversation/Main/View/src/ConversationLayout.cpp index b8bb125d..88419db1 100644 --- a/src/Conversation/Main/View/src/ConversationLayout.cpp +++ b/src/Conversation/Main/View/src/ConversationLayout.cpp @@ -20,11 +20,11 @@ using namespace Msg; ConversationLayout::ConversationLayout(Evas_Object *parent) - : View() - , m_pLayout(nullptr) - , m_pRect(nullptr) + : View() + , m_pLayout(nullptr) + , m_pRect(nullptr) { - create(parent); + create(parent); } ConversationLayout::~ConversationLayout() @@ -33,68 +33,68 @@ ConversationLayout::~ConversationLayout() void ConversationLayout::showContactList(bool value) { - const char *sig = value ? "show.predictsearch" : "hide.predictsearch"; - emitSignal(m_pLayout, sig, "*"); + const char *sig = value ? "show.predictsearch" : "hide.predictsearch"; + emitSignal(m_pLayout, sig, "*"); } void ConversationLayout::setRecipientRect(Evas_Object *layout) { - elm_object_part_content_set(m_pLayout, "swl.recipient.rect", layout); + elm_object_part_content_set(m_pLayout, "swl.recipient.rect", layout); } void ConversationLayout::setConvList(Evas_Object *layout) { - elm_object_part_content_set(m_pLayout, "swl.bubble", layout); + elm_object_part_content_set(m_pLayout, "swl.bubble", layout); } void ConversationLayout::setContactList(Evas_Object *layout) { - elm_object_part_content_set(m_pLayout, "swl.predictsearch", layout); + elm_object_part_content_set(m_pLayout, "swl.predictsearch", layout); } void ConversationLayout::setMsgInputPanel(Evas_Object *layout) { - elm_object_part_content_set(m_pLayout, "swl.msg_input_panel", layout); + elm_object_part_content_set(m_pLayout, "swl.msg_input_panel", layout); } void ConversationLayout::setRecipientPanel(Evas_Object *layout) { - elm_object_part_content_set(m_pLayout, "swl.recipient", layout); + elm_object_part_content_set(m_pLayout, "swl.recipient", layout); } void ConversationLayout::create(Evas_Object *parent) { - m_pLayout = createMainLayout(parent); - setEo(m_pLayout); + m_pLayout = createMainLayout(parent); + setEo(m_pLayout); } void ConversationLayout::showRecipEditMode(bool show) { - const char *sig = show ? "show.recip.edit_mode" : "hide.recip.edit_mode"; - emitSignal(sig, "*"); + const char *sig = show ? "show.recip.edit_mode" : "hide.recip.edit_mode"; + emitSignal(sig, "*"); } void ConversationLayout::showMsgInputPanel(bool show) { - const char *sig = show ? "show.msg_input_panel" : "hide.msg_input_panel"; - emitSignal(sig, "*"); + const char *sig = show ? "show.msg_input_panel" : "hide.msg_input_panel"; + emitSignal(sig, "*"); } Evas_Object *ConversationLayout::createMainLayout(Evas_Object *parent) { - Evas_Object *layout = elm_layout_add(parent); - std::string edjePath = PathUtils::getResourcePath(CONV_LAYOUT_EDJ_PATH); - elm_layout_file_set(layout, edjePath.c_str(), "conv_layout"); - evas_object_show(layout); - return layout; + Evas_Object *layout = elm_layout_add(parent); + std::string edjePath = PathUtils::getResourcePath(CONV_LAYOUT_EDJ_PATH); + elm_layout_file_set(layout, edjePath.c_str(), "conv_layout"); + evas_object_show(layout); + return layout; } void ConversationLayout::setRecipEntryHeight(int height) { - if (!m_pRect) { - m_pRect = evas_object_rectangle_add(evas_object_evas_get(m_pLayout)); - setContent(m_pRect, "entry.pad.top"); - } + if (!m_pRect) { + m_pRect = evas_object_rectangle_add(evas_object_evas_get(m_pLayout)); + setContent(m_pRect, "entry.pad.top"); + } - evas_object_size_hint_min_set(m_pRect, 0, height); + evas_object_size_hint_min_set(m_pRect, 0, height); } diff --git a/src/Conversation/Main/View/src/MessageInputPanel.cpp b/src/Conversation/Main/View/src/MessageInputPanel.cpp index d0fe6e3c..e44859c8 100644 --- a/src/Conversation/Main/View/src/MessageInputPanel.cpp +++ b/src/Conversation/Main/View/src/MessageInputPanel.cpp @@ -26,21 +26,21 @@ using namespace Msg; -#define BUTTON_COLOR 78, 97, 173, 255 -#define BUTTON_PRESSED_COLOR 60, 75, 140, 255 -#define BUTTON_DISABLED_COLOR 179, 197, 218, 255 +#define BUTTON_COLOR 78, 97, 173, 255 +#define BUTTON_PRESSED_COLOR 60, 75, 140, 255 +#define BUTTON_DISABLED_COLOR 179, 197, 218, 255 namespace { - const char *buttonIdKey = "id"; + const char *buttonIdKey = "id"; } MessageInputPanel::MessageInputPanel(Evas_Object *parent) - : m_pListener(nullptr) - , m_pLayout(nullptr) - , m_pSendButton(nullptr) - , m_pAddButton(nullptr) + : m_pListener(nullptr) + , m_pLayout(nullptr) + , m_pSendButton(nullptr) + , m_pAddButton(nullptr) { - create(parent); + create(parent); } MessageInputPanel::~MessageInputPanel() @@ -49,123 +49,123 @@ MessageInputPanel::~MessageInputPanel() void MessageInputPanel::create(Evas_Object *parent) { - m_pLayout = elm_layout_add(parent); - setEo(m_pLayout); - show(); + m_pLayout = elm_layout_add(parent); + setEo(m_pLayout); + show(); - std::string edjPath = PathUtils::getResourcePath(MSG_INPUT_PANEL_EDJ_PATH); - elm_layout_file_set(m_pLayout, edjPath.c_str(), "conversation/msg_input_panel"); + std::string edjPath = PathUtils::getResourcePath(MSG_INPUT_PANEL_EDJ_PATH); + elm_layout_file_set(m_pLayout, edjPath.c_str(), "conversation/msg_input_panel"); - m_pSendButton = createButton(m_pLayout, SendButtonId, CONV_SEND_IMG); - m_pAddButton = createButton(m_pLayout, AddButtonId, CONV_ADD_IMG); + m_pSendButton = createButton(m_pLayout, SendButtonId, CONV_SEND_IMG); + m_pAddButton = createButton(m_pLayout, AddButtonId, CONV_ADD_IMG); - elm_object_part_content_set(m_pLayout, "swl.send_button", m_pSendButton); - elm_object_part_content_set(m_pLayout, "swl.add_button", m_pAddButton); + elm_object_part_content_set(m_pLayout, "swl.send_button", m_pSendButton); + elm_object_part_content_set(m_pLayout, "swl.add_button", m_pAddButton); } void MessageInputPanel::setEntry(Evas_Object *obj) { - elm_object_part_content_set(m_pLayout, "swl.main", obj); + elm_object_part_content_set(m_pLayout, "swl.main", obj); } Evas_Object *MessageInputPanel::getIcon(Evas_Object *button) { - return elm_object_content_get(button); + return elm_object_content_get(button); } void MessageInputPanel::setNormalColor(Evas_Object *button) { - evas_object_color_set(getIcon(button), BUTTON_COLOR); + evas_object_color_set(getIcon(button), BUTTON_COLOR); } void MessageInputPanel::setPressedColor(Evas_Object *button) { - evas_object_color_set(getIcon(button), BUTTON_PRESSED_COLOR); + evas_object_color_set(getIcon(button), BUTTON_PRESSED_COLOR); } void MessageInputPanel::setDisabledColor(Evas_Object *button) { - evas_object_color_set(getIcon(button), BUTTON_DISABLED_COLOR); + evas_object_color_set(getIcon(button), BUTTON_DISABLED_COLOR); } Evas_Object *MessageInputPanel::getButton(ButtonId id) { - switch (id) { - case AddButtonId: - return m_pAddButton; - break; - case SendButtonId: - return m_pSendButton; - break; - default: - MSG_ASSERT(false, "Unknown button id"); - break; - } + switch (id) { + case AddButtonId: + return m_pAddButton; + break; + case SendButtonId: + return m_pSendButton; + break; + default: + MSG_ASSERT(false, "Unknown button id"); + break; + } - return nullptr; + return nullptr; } Evas_Object *MessageInputPanel::createButton(Evas_Object *parent, ButtonId buttonId, const char *res) { - Evas_Object *button = elm_button_add(parent); - if (buttonId == SendButtonId) - elm_object_focus_allow_set(button, false); - elm_object_style_set(button, "transparent"); - evas_object_data_set(button, buttonIdKey, (void*)buttonId); - evas_object_size_hint_weight_set(button, 0.0, 0.0); - evas_object_smart_callback_add(button, "clicked", SMART_CALLBACK(MessageInputPanel, onButtonClicked), this); - evas_object_smart_callback_add(button, "pressed", SMART_CALLBACK(MessageInputPanel, onButtonPressed), this); - evas_object_smart_callback_add(button, "unpressed", SMART_CALLBACK(MessageInputPanel, onButtonUnpressed), this); - evas_object_show(button); - - Evas_Object *icon = elm_icon_add(button); - if (buttonId == SendButtonId) - elm_object_focus_allow_set(icon, false); - std::string resPath = PathUtils::getResourcePath(IMAGES_EDJ_PATH); - elm_image_file_set(icon, resPath.c_str(), res); - evas_object_color_set(icon, BUTTON_COLOR); - evas_object_show(icon); - elm_object_content_set(button, icon); - - return button; + Evas_Object *button = elm_button_add(parent); + if (buttonId == SendButtonId) + elm_object_focus_allow_set(button, false); + elm_object_style_set(button, "transparent"); + evas_object_data_set(button, buttonIdKey, (void*)buttonId); + evas_object_size_hint_weight_set(button, 0.0, 0.0); + evas_object_smart_callback_add(button, "clicked", SMART_CALLBACK(MessageInputPanel, onButtonClicked), this); + evas_object_smart_callback_add(button, "pressed", SMART_CALLBACK(MessageInputPanel, onButtonPressed), this); + evas_object_smart_callback_add(button, "unpressed", SMART_CALLBACK(MessageInputPanel, onButtonUnpressed), this); + evas_object_show(button); + + Evas_Object *icon = elm_icon_add(button); + if (buttonId == SendButtonId) + elm_object_focus_allow_set(icon, false); + std::string resPath = PathUtils::getResourcePath(IMAGES_EDJ_PATH); + elm_image_file_set(icon, resPath.c_str(), res); + evas_object_color_set(icon, BUTTON_COLOR); + evas_object_show(icon); + elm_object_content_set(button, icon); + + return button; } void MessageInputPanel::disabledButton(ButtonId id, bool val) { - Evas_Object *btn = getButton(id); - elm_object_disabled_set(btn, val); + Evas_Object *btn = getButton(id); + elm_object_disabled_set(btn, val); - if (val) - setDisabledColor(btn); - else - setNormalColor(btn); + if (val) + setDisabledColor(btn); + else + setNormalColor(btn); } void MessageInputPanel::setCounter(const std::string &text) { - elm_object_part_text_set(m_pLayout, "text.char_count", text.c_str()); + elm_object_part_text_set(m_pLayout, "text.char_count", text.c_str()); } void MessageInputPanel::setListener(IMessageInputPanelListener *l) { - m_pListener = l; + m_pListener = l; } void MessageInputPanel::onButtonClicked(Evas_Object *obj, void *event_info) { - feedback_play(FEEDBACK_PATTERN_TAP); - if (m_pListener) { - int id = (int)(intptr_t)evas_object_data_get(obj, buttonIdKey); - m_pListener->onButtonClicked(*this, (ButtonId)id); - } + feedback_play(FEEDBACK_PATTERN_TAP); + if (m_pListener) { + int id = (int)(intptr_t)evas_object_data_get(obj, buttonIdKey); + m_pListener->onButtonClicked(*this, (ButtonId)id); + } } void MessageInputPanel::onButtonPressed(Evas_Object *obj, void *event_info) { - setPressedColor(obj); + setPressedColor(obj); } void MessageInputPanel::onButtonUnpressed(Evas_Object *obj, void *event_info) { - setNormalColor(obj); + setNormalColor(obj); } diff --git a/src/Conversation/Recipients/Controller/inc/ConvRecipientsPanel.h b/src/Conversation/Recipients/Controller/inc/ConvRecipientsPanel.h index 08533d81..126a6f93 100644 --- a/src/Conversation/Recipients/Controller/inc/ConvRecipientsPanel.h +++ b/src/Conversation/Recipients/Controller/inc/ConvRecipientsPanel.h @@ -26,81 +26,81 @@ #include "ContactManager.h" namespace Msg { - class IConvRecipientsPanelListener; + class IConvRecipientsPanelListener; - class ConvRecipientsPanel - : public ConvRecipientsPanelView - , private IContactPickerListener - , private IMbeRecipientsListener - , private IContactManagerListener { - public: - ConvRecipientsPanel(Evas_Object *parent, App &app); - virtual ~ConvRecipientsPanel(); + class ConvRecipientsPanel + : public ConvRecipientsPanelView + , private IContactPickerListener + , private IMbeRecipientsListener + , private IContactManagerListener { + public: + ConvRecipientsPanel(Evas_Object *parent, App &app); + virtual ~ConvRecipientsPanel(); - void read(Message &msg); - void write(const Message &msg); - bool isMms() const; - void setListener(IConvRecipientsPanelListener *l); - void update(const ThreadId &threadId); - void update(const MsgAddressListRef &addressList); - void update(const MsgAddressList &addressList); - void execCmd(const AppControlComposeRef &cmd); - MbeRecipients::AppendItemStatus appendItem(const std::string &address, MsgAddress::AddressType addressType = MsgAddress::UnknownAddressType); - bool addRecipientsFromEntry(bool showPopup = true); - MbeRecipients &getMbeRecipients(); + void read(Message &msg); + void write(const Message &msg); + bool isMms() const; + void setListener(IConvRecipientsPanelListener *l); + void update(const ThreadId &threadId); + void update(const MsgAddressListRef &addressList); + void update(const MsgAddressList &addressList); + void execCmd(const AppControlComposeRef &cmd); + MbeRecipients::AppendItemStatus appendItem(const std::string &address, MsgAddress::AddressType addressType = MsgAddress::UnknownAddressType); + bool addRecipientsFromEntry(bool showPopup = true); + MbeRecipients &getMbeRecipients(); - private: - // RecipientsPanelView: - virtual void onKeyDown(Evas_Event_Key_Down *ev); - virtual void onEntryFocusChanged(); - virtual void onContactButtonClicked(); - virtual void onPlusButtonClicked(); - virtual void onEntryChanged(); - virtual void onEntrySizeChanged(); + private: + // RecipientsPanelView: + virtual void onKeyDown(Evas_Event_Key_Down *ev); + virtual void onEntryFocusChanged(); + virtual void onContactButtonClicked(); + virtual void onPlusButtonClicked(); + virtual void onEntryChanged(); + virtual void onEntrySizeChanged(); - // IMbeRecipientsListener - virtual void onMbeItemClicked(MbeRecipientItem &item); - virtual void onMbeChanged(); + // IMbeRecipientsListener + virtual void onMbeItemClicked(MbeRecipientItem &item); + virtual void onMbeChanged(); - void onAppControlRes(app_control_h request, app_control_h reply, app_control_result_e result); - void onPopupBtnClicked(Popup &popup, int buttonId); - void onPopupDel(Evas_Object *popup, void *eventInfo); + void onAppControlRes(app_control_h request, app_control_h reply, app_control_result_e result); + void onPopupBtnClicked(Popup &popup, int buttonId); + void onPopupDel(Evas_Object *popup, void *eventInfo); - void appendStatusHandler(MbeRecipients::AppendItemStatus status); - int getMaxRecipientCount() const; - void showInvalidRecipientPopup(); - void showInvalidSomeRecipientsPopup(); - void showInvalidAllRecipientsPopup(); - void showTooManyRecipientsNotif(); - void showAddRecipNotif(); - void showDuplicatedRecipientNotif(); - MbeRecipients::AppendItemStatus appendItem(const std::string &address, const std::string &dispName, - MsgAddress::AddressType addressType = MsgAddress::UnknownAddressType); + void appendStatusHandler(MbeRecipients::AppendItemStatus status); + int getMaxRecipientCount() const; + void showInvalidRecipientPopup(); + void showInvalidSomeRecipientsPopup(); + void showInvalidAllRecipientsPopup(); + void showTooManyRecipientsNotif(); + void showAddRecipNotif(); + void showDuplicatedRecipientNotif(); + MbeRecipients::AppendItemStatus appendItem(const std::string &address, const std::string &dispName, + MsgAddress::AddressType addressType = MsgAddress::UnknownAddressType); - // IContactPickerListener - virtual void onContactsPicked(const std::list &addressIdList); + // IContactPickerListener + virtual void onContactsPicked(const std::list &addressIdList); - // IContactManagerListener: - virtual void onContactChanged(); + // IContactManagerListener: + virtual void onContactChanged(); - private: - App &m_App; - IConvRecipientsPanelListener *m_pListener; - ContactPicker m_Picker; - MbeRecipients *m_pMbe; - }; + private: + App &m_App; + IConvRecipientsPanelListener *m_pListener; + ContactPicker m_Picker; + MbeRecipients *m_pMbe; + }; - class IConvRecipientsPanelListener { - public: - virtual ~IConvRecipientsPanelListener() {} + class IConvRecipientsPanelListener { + public: + virtual ~IConvRecipientsPanelListener() {} - virtual void onKeyDown(ConvRecipientsPanel &panel, Evas_Event_Key_Down &ev) {}; - virtual void onEntryFocusChanged(ConvRecipientsPanel &panel) {}; - virtual void onMbeChanged(ConvRecipientsPanel &panel) {}; - virtual void onItemClicked(ConvRecipientsPanel &panel, MbeRecipientItem &item) {}; - virtual void onEntryChanged(ConvRecipientsPanel &panel) {}; - virtual void onEntrySizeChanged(ConvRecipientsPanel &panel) {}; - }; + virtual void onKeyDown(ConvRecipientsPanel &panel, Evas_Event_Key_Down &ev) {}; + virtual void onEntryFocusChanged(ConvRecipientsPanel &panel) {}; + virtual void onMbeChanged(ConvRecipientsPanel &panel) {}; + virtual void onItemClicked(ConvRecipientsPanel &panel, MbeRecipientItem &item) {}; + virtual void onEntryChanged(ConvRecipientsPanel &panel) {}; + virtual void onEntrySizeChanged(ConvRecipientsPanel &panel) {}; + }; } #endif /* RecipientsPanel_h_ */ diff --git a/src/Conversation/Recipients/Controller/src/ConvRecipientsPanel.cpp b/src/Conversation/Recipients/Controller/src/ConvRecipientsPanel.cpp index ab2a59af..20c383c5 100644 --- a/src/Conversation/Recipients/Controller/src/ConvRecipientsPanel.cpp +++ b/src/Conversation/Recipients/Controller/src/ConvRecipientsPanel.cpp @@ -25,327 +25,327 @@ using namespace Msg; ConvRecipientsPanel::ConvRecipientsPanel(Evas_Object *parent, App &app) - : ConvRecipientsPanelView(parent, app.getMsgEngine().getSettings().getAddressMaxLen()) - , m_App(app) - , m_pListener(nullptr) + : ConvRecipientsPanelView(parent, app.getMsgEngine().getSettings().getAddressMaxLen()) + , m_App(app) + , m_pListener(nullptr) { - m_Picker.setListener(this); - m_pMbe = new MbeRecipients(*this, m_App); - m_pMbe->setListener(this); - m_pMbe->show(); - setMbe(m_pMbe); - showButton(ContactButton); - m_App.getContactManager().addListener(*this); + m_Picker.setListener(this); + m_pMbe = new MbeRecipients(*this, m_App); + m_pMbe->setListener(this); + m_pMbe->show(); + setMbe(m_pMbe); + showButton(ContactButton); + m_App.getContactManager().addListener(*this); } ConvRecipientsPanel::~ConvRecipientsPanel() { - m_Picker.setListener(nullptr); - m_App.getContactManager().removeListener(*this); + m_Picker.setListener(nullptr); + m_App.getContactManager().removeListener(*this); } void ConvRecipientsPanel::read(Message &msg) { - auto list = m_pMbe->getItems(); - for (auto it : list) { - MbeRecipientItem *recipItem = static_cast(it); - MsgAddress &msgAddr = msg.addAddress(); - msgAddr.setAddress(recipItem->getAddress()); - msgAddr.setRecipientType(recipItem->getRecipType()); - msgAddr.setAddressType(recipItem->getAddressType()); - } + auto list = m_pMbe->getItems(); + for (auto it : list) { + MbeRecipientItem *recipItem = static_cast(it); + MsgAddress &msgAddr = msg.addAddress(); + msgAddr.setAddress(recipItem->getAddress()); + msgAddr.setRecipientType(recipItem->getRecipType()); + msgAddr.setAddressType(recipItem->getAddressType()); + } - if (list.empty()) { - showInvalidIcon(true); - showAddRecipNotif(); - setEntryFocus(true); - } + if (list.empty()) { + showInvalidIcon(true); + showAddRecipNotif(); + setEntryFocus(true); + } } void ConvRecipientsPanel::write(const Message &msg) { - update(msg.getAddressList()); + update(msg.getAddressList()); } bool ConvRecipientsPanel::isMms() const { - auto items = m_pMbe->getItems(); - for (MbeRecipientItem *it : items) { - MbeRecipientItem *item = static_cast(it); - if (item->getAddressType() == MsgAddress::Email) - return true; - } - return false; + auto items = m_pMbe->getItems(); + for (MbeRecipientItem *it : items) { + MbeRecipientItem *item = static_cast(it); + if (item->getAddressType() == MsgAddress::Email) + return true; + } + return false; } void ConvRecipientsPanel::setListener(IConvRecipientsPanelListener *l) { - m_pListener = l; + m_pListener = l; } bool ConvRecipientsPanel::addRecipientsFromEntry(bool showPopup) { - MSG_LOG(""); - std::string text = getEntryText(); - TokenizedRecipients result = MsgUtils::tokenizeRecipients(text); - bool duplicateFound = false; + MSG_LOG(""); + std::string text = getEntryText(); + TokenizedRecipients result = MsgUtils::tokenizeRecipients(text); + bool duplicateFound = false; - for (auto &it : result.validResults) { - if (it.second == MsgAddress::Phone) - it.first = MsgUtils::makeNormalizedNumber(it.first); + for (auto &it : result.validResults) { + if (it.second == MsgAddress::Phone) + it.first = MsgUtils::makeNormalizedNumber(it.first); - duplicateFound |= appendItem(it.first, it.second) == MbeRecipients::DuplicatedStatus; - } + duplicateFound |= appendItem(it.first, it.second) == MbeRecipients::DuplicatedStatus; + } - if (duplicateFound) { - showDuplicatedRecipientNotif(); - return false; - } + if (duplicateFound) { + showDuplicatedRecipientNotif(); + return false; + } - setEntryText(result.invalidResult); - if (!result.invalidResult.empty() && showPopup) { - showInvalidRecipientPopup(); - return false; - } - return true; + setEntryText(result.invalidResult); + if (!result.invalidResult.empty() && showPopup) { + showInvalidRecipientPopup(); + return false; + } + return true; } MbeRecipients &ConvRecipientsPanel::getMbeRecipients() { - return *m_pMbe; + return *m_pMbe; } void ConvRecipientsPanel::update(const MsgAddressListRef &addressList) { - addressList ? update(*addressList) : clearMbe(); + addressList ? update(*addressList) : clearMbe(); } void ConvRecipientsPanel::update(const MsgAddressList &addressList) { - clearMbe(); - int addrListLen = addressList.getLength(); - for (int i = 0; i < addrListLen; ++i) { - auto &addr = addressList.at(i); - appendItem(addr.getAddress(), addr.getAddressType()); - } + clearMbe(); + int addrListLen = addressList.getLength(); + for (int i = 0; i < addrListLen; ++i) { + auto &addr = addressList.at(i); + appendItem(addr.getAddress(), addr.getAddressType()); + } } void ConvRecipientsPanel::update(const ThreadId &threadId) { - clear(); - m_pMbe->update(threadId); + clear(); + m_pMbe->update(threadId); } MbeRecipients::AppendItemStatus ConvRecipientsPanel::appendItem(const std::string &address, - const std::string &dispName, MsgAddress::AddressType addressType) + const std::string &dispName, MsgAddress::AddressType addressType) { - return m_pMbe->appendItem(address, dispName, addressType); + return m_pMbe->appendItem(address, dispName, addressType); } MbeRecipients::AppendItemStatus ConvRecipientsPanel::appendItem(const std::string &address, MsgAddress::AddressType addressType) { - auto appendStatus = m_pMbe->appendItem(address, addressType); - appendStatusHandler(appendStatus); - return appendStatus; + auto appendStatus = m_pMbe->appendItem(address, addressType); + appendStatusHandler(appendStatus); + return appendStatus; } void ConvRecipientsPanel::execCmd(const AppControlComposeRef &cmd) { - m_pMbe->clear(); - for (auto recipStr: cmd->getRecipientList()) { - appendStatusHandler(appendItem(recipStr)); - } + m_pMbe->clear(); + for (auto recipStr: cmd->getRecipientList()) { + appendStatusHandler(appendItem(recipStr)); + } } int ConvRecipientsPanel::getMaxRecipientCount() const { - return m_App.getMsgEngine().getSettings().getMaxRecipientCount(); + return m_App.getMsgEngine().getSettings().getMaxRecipientCount(); } void ConvRecipientsPanel::appendStatusHandler(MbeRecipients::AppendItemStatus status) { - switch (status) { - case MbeRecipients::SuccessStatus: - showInvalidIcon(false); - if (getEntryFocus()) - showMbe(true); - break; - case MbeRecipients::DuplicatedStatus: - showDuplicatedRecipientNotif(); - break; - case MbeRecipients::TooManyRecipStatus: - showTooManyRecipientsNotif(); - break; - case MbeRecipients::InvalidAllRecipStatus: - showInvalidAllRecipientsPopup(); - break; - case MbeRecipients::InvalidRecipStatus: - showInvalidRecipientPopup(); - break; - case MbeRecipients::InvalidSomeRecipStatus: - default: - showInvalidSomeRecipientsPopup(); - break; - } + switch (status) { + case MbeRecipients::SuccessStatus: + showInvalidIcon(false); + if (getEntryFocus()) + showMbe(true); + break; + case MbeRecipients::DuplicatedStatus: + showDuplicatedRecipientNotif(); + break; + case MbeRecipients::TooManyRecipStatus: + showTooManyRecipientsNotif(); + break; + case MbeRecipients::InvalidAllRecipStatus: + showInvalidAllRecipientsPopup(); + break; + case MbeRecipients::InvalidRecipStatus: + showInvalidRecipientPopup(); + break; + case MbeRecipients::InvalidSomeRecipStatus: + default: + showInvalidSomeRecipientsPopup(); + break; + } } void ConvRecipientsPanel::onKeyDown(Evas_Event_Key_Down *ev) { - if (ev && ev->keyname) { - MSG_LOG("Key: ", ev->keyname); + if (ev && ev->keyname) { + MSG_LOG("Key: ", ev->keyname); - if ((strcmp(ev->keyname, "semicolon") == 0) || (strcmp(ev->keyname, "comma") == 0)) { - addRecipientsFromEntry(); - } else { - if (m_pListener) - m_pListener->onKeyDown(*this, *ev); - } - } + if ((strcmp(ev->keyname, "semicolon") == 0) || (strcmp(ev->keyname, "comma") == 0)) { + addRecipientsFromEntry(); + } else { + if (m_pListener) + m_pListener->onKeyDown(*this, *ev); + } + } } void ConvRecipientsPanel::onEntryFocusChanged() { - MSG_LOG(""); + MSG_LOG(""); - unselectMbeItem(); - if (!getEntryFocus()) - showButton(ContactButton); + unselectMbeItem(); + if (!getEntryFocus()) + showButton(ContactButton); - if (getEntryFocus()) { - expandRecipients(); - } else { - addRecipientsFromEntry(); - collapseRecipients(); - } + if (getEntryFocus()) { + expandRecipients(); + } else { + addRecipientsFromEntry(); + collapseRecipients(); + } - if (!isMbeEmpty()) - showInvalidIcon(false); + if (!isMbeEmpty()) + showInvalidIcon(false); - if (m_pListener) - m_pListener->onEntryFocusChanged(*this); + if (m_pListener) + m_pListener->onEntryFocusChanged(*this); } void ConvRecipientsPanel::onEntryChanged() { - unselectMbeItem(); - if (!isEntryEmpty() && getEntryFocus()) { - showButton(PlusButton); - showInvalidIcon(false); - } else { - showButton(ContactButton); - } + unselectMbeItem(); + if (!isEntryEmpty() && getEntryFocus()) { + showButton(PlusButton); + showInvalidIcon(false); + } else { + showButton(ContactButton); + } - if (m_pListener) - m_pListener->onEntryChanged(*this); + if (m_pListener) + m_pListener->onEntryChanged(*this); } void ConvRecipientsPanel::onEntrySizeChanged() { - if (m_pListener) - m_pListener->onEntrySizeChanged(*this); + if (m_pListener) + m_pListener->onEntrySizeChanged(*this); } void ConvRecipientsPanel::onContactButtonClicked() { - MSG_LOG(""); - int currentRecipientsCount = getItemsCount(); - if (currentRecipientsCount < getMaxRecipientCount()) - m_Picker.launch(getMaxRecipientCount() - currentRecipientsCount); - else - showTooManyRecipientsNotif(); + MSG_LOG(""); + int currentRecipientsCount = getItemsCount(); + if (currentRecipientsCount < getMaxRecipientCount()) + m_Picker.launch(getMaxRecipientCount() - currentRecipientsCount); + else + showTooManyRecipientsNotif(); } void ConvRecipientsPanel::onPlusButtonClicked() { - MSG_LOG(""); - addRecipientsFromEntry(true); + MSG_LOG(""); + addRecipientsFromEntry(true); } void ConvRecipientsPanel::onContactsPicked(const std::list &addressIdList) { - int addressOfInvalids = 0; - int duplicateRecip = 0; - int sizeOfList = addressIdList.size(); - for (auto &addressData : addressIdList) { - ContactAddressRef address; - if (addressData.type == IContactPickerListener::PhoneType) - address = m_App.getContactManager().getContactPersonNumber(addressData.id); - else if (addressData.type == IContactPickerListener::EmailType) - address = m_App.getContactManager().getContactPersonEmail(addressData.id); - - if (address) { - auto apendStatus = appendItem(address->getAddress(), address->getDispName(), MsgAddress::UnknownAddressType); - if (apendStatus == MbeRecipients::InvalidRecipStatus) - ++addressOfInvalids; - if (apendStatus == MbeRecipients::DuplicatedStatus) - ++duplicateRecip; - } - } - if (addressOfInvalids != 0) - appendStatusHandler((addressOfInvalids == sizeOfList) ? MbeRecipients::InvalidAllRecipStatus : MbeRecipients::InvalidSomeRecipStatus); - else if (duplicateRecip != 0) - appendStatusHandler(MbeRecipients::DuplicatedStatus); - - setEntryFocus(true); + int addressOfInvalids = 0; + int duplicateRecip = 0; + int sizeOfList = addressIdList.size(); + for (auto &addressData : addressIdList) { + ContactAddressRef address; + if (addressData.type == IContactPickerListener::PhoneType) + address = m_App.getContactManager().getContactPersonNumber(addressData.id); + else if (addressData.type == IContactPickerListener::EmailType) + address = m_App.getContactManager().getContactPersonEmail(addressData.id); + + if (address) { + auto apendStatus = appendItem(address->getAddress(), address->getDispName(), MsgAddress::UnknownAddressType); + if (apendStatus == MbeRecipients::InvalidRecipStatus) + ++addressOfInvalids; + if (apendStatus == MbeRecipients::DuplicatedStatus) + ++duplicateRecip; + } + } + if (addressOfInvalids != 0) + appendStatusHandler((addressOfInvalids == sizeOfList) ? MbeRecipients::InvalidAllRecipStatus : MbeRecipients::InvalidSomeRecipStatus); + else if (duplicateRecip != 0) + appendStatusHandler(MbeRecipients::DuplicatedStatus); + + setEntryFocus(true); } void ConvRecipientsPanel::onPopupBtnClicked(Popup &popup, int buttonId) { - popup.destroy(); + popup.destroy(); } void ConvRecipientsPanel::onPopupDel(Evas_Object *popup, void *eventInfo) { - setEntryFocus(true); + setEntryFocus(true); } void ConvRecipientsPanel::showInvalidRecipientPopup() { - notification_status_message_post(msg("IDS_MSG_TPOP_CANT_ADD_RECIPIENT_NUMBER_NOT_VALID").cStr()); + notification_status_message_post(msg("IDS_MSG_TPOP_CANT_ADD_RECIPIENT_NUMBER_NOT_VALID").cStr()); } void ConvRecipientsPanel::showInvalidSomeRecipientsPopup() { - notification_status_message_post(msg("IDS_MSG_TPOP_CANT_ADD_SOME_RECIPIENTS_NUMBERS_NOT_VALID").cStr()); + notification_status_message_post(msg("IDS_MSG_TPOP_CANT_ADD_SOME_RECIPIENTS_NUMBERS_NOT_VALID").cStr()); } void ConvRecipientsPanel::showInvalidAllRecipientsPopup() { - notification_status_message_post(msg("IDS_MSG_TPOP_CANT_ADD_RECIPIENTS_NUMBERS_NOT_VALID").cStr()); + notification_status_message_post(msg("IDS_MSG_TPOP_CANT_ADD_RECIPIENTS_NUMBERS_NOT_VALID").cStr()); } void ConvRecipientsPanel::showDuplicatedRecipientNotif() { - notification_status_message_post(msg("IDS_MSG_TPOP_SOME_RECIPIENTS_ALREADY_ADDED").cStr()); + notification_status_message_post(msg("IDS_MSG_TPOP_SOME_RECIPIENTS_ALREADY_ADDED").cStr()); } void ConvRecipientsPanel::showTooManyRecipientsNotif() { - notification_status_message_post(msgArgs("IDS_MSG_TPOP_CANT_ADD_MORE_THAN_PD_RECIPIENTS", getMaxRecipientCount()).cStr()); + notification_status_message_post(msgArgs("IDS_MSG_TPOP_CANT_ADD_MORE_THAN_PD_RECIPIENTS", getMaxRecipientCount()).cStr()); } void ConvRecipientsPanel::showAddRecipNotif() { - notification_status_message_post(msg("IDS_MSG_TPOP_ADD_RECIPIENTS").cStr()); + notification_status_message_post(msg("IDS_MSG_TPOP_ADD_RECIPIENTS").cStr()); } void ConvRecipientsPanel::onMbeChanged() { - if (!isMbeVisible()) - updateShortenedRecipients(); - if (m_pListener) - m_pListener->onMbeChanged(*this); + if (!isMbeVisible()) + updateShortenedRecipients(); + if (m_pListener) + m_pListener->onMbeChanged(*this); } void ConvRecipientsPanel::onMbeItemClicked(MbeRecipientItem &item) { - if (m_pListener) - m_pListener->onItemClicked(*this, item); + if (m_pListener) + m_pListener->onItemClicked(*this, item); } void ConvRecipientsPanel::onContactChanged() { - MSG_LOG(""); - if (!getEntryFocus()) - updateShortenedRecipients(); + MSG_LOG(""); + if (!getEntryFocus()) + updateShortenedRecipients(); } diff --git a/src/Conversation/Recipients/View/inc/ConvRecipientsPanelView.h b/src/Conversation/Recipients/View/inc/ConvRecipientsPanelView.h index d53ef85f..4a4cefe5 100644 --- a/src/Conversation/Recipients/View/inc/ConvRecipientsPanelView.h +++ b/src/Conversation/Recipients/View/inc/ConvRecipientsPanelView.h @@ -24,111 +24,111 @@ #include namespace Msg { - class ConvRecipientsPanelView - : public View { - public: - ConvRecipientsPanelView(Evas_Object *parent, int entryMaxCharCount); - virtual ~ConvRecipientsPanelView(); - - void editSelectedItem(); - void removeSelectedItem(); - void unselectMbeItem(); - Evas_Object *getAreaRect() const; - int getEntryHeight() const; - void showMbe(bool show, bool animation = true); - void showEntry(bool show); - std::string getEntryText() const; - void setEntryText(const std::string &utf8); - bool isMbeEmpty() const; - bool isEntryEmpty() const; - bool isMbeVisible() const; - bool getEntryFocus() const; - void setEntryFocus(bool val); - void clearEntry(); - void clearMbe(); - void clear(); - - /** - * @brief Gets a count of mbe items - */ - unsigned int getItemsCount() const; - MbeRecipientItem *getSelectedItem() const; - void collapseRecipients(); - void expandRecipients(); - void updateShortenedRecipients(); - - protected: - enum ButtonType { - NoneButton, - ContactButton, - PlusButton - }; - - void setMbe(MbeRecipientsView *pMbe); - void showButton(ButtonType buttonType); - void setEditMode(bool isEdit); - void showInvalidIcon(bool show); - void showClearButton(bool show); - void setButtonEnabled(ButtonType buttonType, bool enabled); - - - private: - // Out signals: - virtual void onKeyDown(Evas_Event_Key_Down *ev) {}; - virtual void onEntryFocusChanged() {}; - virtual void onContactButtonClicked() {} - virtual void onPlusButtonClicked() {} - virtual void onEntryChanged() {} - virtual void onEntrySizeChanged() {} - - private: - void onMbeFocused(Evas_Object *obj, void *event_info); - void onMbeUnfocused(Evas_Object *obj, void *event_info); - void onMbeClicked(Evas_Object *obj, void *event_info); - - void onEntryChanged(Evas_Object *obj, void *event_info); - void onEntryPreeditChanged(Evas_Object *obj, void *event_info); - void onEntryActivated(Evas_Object *obj, void *event_info); - void onEntryFocusChanged(Evas_Object *obj, void *event_info); - void onEntryClicked(Evas_Object *obj, void *event_info); - void onEntryMaxlengthReached(Evas_Object *obj, void *event_info); - void onKeyDown(Evas_Object *obj, void *event_info); - - void onBtnPressed(Evas_Object *obj, void *event_info); - void onBtnUnpressed(Evas_Object *obj, void *event_info); - void onContactBtnClicked(Evas_Object *obj, void *event_info); - void onPlusBtnClicked(Evas_Object *obj, void *event_info); - void onClearButtonClicked(Evas_Object *obj, void *event_info); - - void onGeometryChanged(Evas_Object *obj, void *event_info); - void onEntrySizeChanged(Evas_Object *obj, void *event_info); - - private: - void create(Evas_Object *parent); - Evas_Object *getEntry(); - Evas_Object *getPlusBtn(); - Evas_Object *getContactBtn(); - Evas_Object *createAreaRect(Evas_Object *parent); - Evas_Object *createClearButton(Evas_Object *parent); - void setContactBtnColor(Evas_Object *btn, int r, int g, int b, int a); - void deleteNextRecipient(); - void selectLastItem(); - - void addGeometryChangedCb(Evas_Object *obj); - - private: - Evas_Object *m_pLayout; - Evas_Object *m_pEntry; - Evas_Object *m_pEntryLayout; - Evas_Object *m_pContactBtn; - Evas_Object *m_pPlusBtn; - Evas_Object *m_pRect; - int m_EntryMaxCharCount; - bool m_IsMbeVisible; - MbeRecipientsView *m_pMbe; - std::string m_SavedRecipText; - bool m_IsEditItemClicked; - }; + class ConvRecipientsPanelView + : public View { + public: + ConvRecipientsPanelView(Evas_Object *parent, int entryMaxCharCount); + virtual ~ConvRecipientsPanelView(); + + void editSelectedItem(); + void removeSelectedItem(); + void unselectMbeItem(); + Evas_Object *getAreaRect() const; + int getEntryHeight() const; + void showMbe(bool show, bool animation = true); + void showEntry(bool show); + std::string getEntryText() const; + void setEntryText(const std::string &utf8); + bool isMbeEmpty() const; + bool isEntryEmpty() const; + bool isMbeVisible() const; + bool getEntryFocus() const; + void setEntryFocus(bool val); + void clearEntry(); + void clearMbe(); + void clear(); + + /** + * @brief Gets a count of mbe items + */ + unsigned int getItemsCount() const; + MbeRecipientItem *getSelectedItem() const; + void collapseRecipients(); + void expandRecipients(); + void updateShortenedRecipients(); + + protected: + enum ButtonType { + NoneButton, + ContactButton, + PlusButton + }; + + void setMbe(MbeRecipientsView *pMbe); + void showButton(ButtonType buttonType); + void setEditMode(bool isEdit); + void showInvalidIcon(bool show); + void showClearButton(bool show); + void setButtonEnabled(ButtonType buttonType, bool enabled); + + + private: + // Out signals: + virtual void onKeyDown(Evas_Event_Key_Down *ev) {}; + virtual void onEntryFocusChanged() {}; + virtual void onContactButtonClicked() {} + virtual void onPlusButtonClicked() {} + virtual void onEntryChanged() {} + virtual void onEntrySizeChanged() {} + + private: + void onMbeFocused(Evas_Object *obj, void *event_info); + void onMbeUnfocused(Evas_Object *obj, void *event_info); + void onMbeClicked(Evas_Object *obj, void *event_info); + + void onEntryChanged(Evas_Object *obj, void *event_info); + void onEntryPreeditChanged(Evas_Object *obj, void *event_info); + void onEntryActivated(Evas_Object *obj, void *event_info); + void onEntryFocusChanged(Evas_Object *obj, void *event_info); + void onEntryClicked(Evas_Object *obj, void *event_info); + void onEntryMaxlengthReached(Evas_Object *obj, void *event_info); + void onKeyDown(Evas_Object *obj, void *event_info); + + void onBtnPressed(Evas_Object *obj, void *event_info); + void onBtnUnpressed(Evas_Object *obj, void *event_info); + void onContactBtnClicked(Evas_Object *obj, void *event_info); + void onPlusBtnClicked(Evas_Object *obj, void *event_info); + void onClearButtonClicked(Evas_Object *obj, void *event_info); + + void onGeometryChanged(Evas_Object *obj, void *event_info); + void onEntrySizeChanged(Evas_Object *obj, void *event_info); + + private: + void create(Evas_Object *parent); + Evas_Object *getEntry(); + Evas_Object *getPlusBtn(); + Evas_Object *getContactBtn(); + Evas_Object *createAreaRect(Evas_Object *parent); + Evas_Object *createClearButton(Evas_Object *parent); + void setContactBtnColor(Evas_Object *btn, int r, int g, int b, int a); + void deleteNextRecipient(); + void selectLastItem(); + + void addGeometryChangedCb(Evas_Object *obj); + + private: + Evas_Object *m_pLayout; + Evas_Object *m_pEntry; + Evas_Object *m_pEntryLayout; + Evas_Object *m_pContactBtn; + Evas_Object *m_pPlusBtn; + Evas_Object *m_pRect; + int m_EntryMaxCharCount; + bool m_IsMbeVisible; + MbeRecipientsView *m_pMbe; + std::string m_SavedRecipText; + bool m_IsEditItemClicked; + }; } #endif /* ConvRecipientsPanelView_h_ */ diff --git a/src/Conversation/Recipients/View/src/ConvRecipientsPanelView.cpp b/src/Conversation/Recipients/View/src/ConvRecipientsPanelView.cpp index 4f2819d8..542ce92a 100644 --- a/src/Conversation/Recipients/View/src/ConvRecipientsPanelView.cpp +++ b/src/Conversation/Recipients/View/src/ConvRecipientsPanelView.cpp @@ -24,27 +24,27 @@ using namespace Msg; -#define BUTTON_COLOR 61, 185, 204, 255 -#define BUTTON_PRESSED_COLOR 50, 160, 170, 255 +#define BUTTON_COLOR 61, 185, 204, 255 +#define BUTTON_PRESSED_COLOR 50, 160, 170, 255 namespace { - const char *buttonPart = "swl.contact_btn"; + const char *buttonPart = "swl.contact_btn"; } ConvRecipientsPanelView::ConvRecipientsPanelView(Evas_Object *parent, int entryMaxCharCount) - : View() - , m_pLayout(nullptr) - , m_pEntry(nullptr) - , m_pEntryLayout(nullptr) - , m_pContactBtn(nullptr) - , m_pPlusBtn(nullptr) - , m_pRect(nullptr) - , m_EntryMaxCharCount(entryMaxCharCount) - , m_IsMbeVisible(false) - , m_pMbe(nullptr) - , m_IsEditItemClicked(false) + : View() + , m_pLayout(nullptr) + , m_pEntry(nullptr) + , m_pEntryLayout(nullptr) + , m_pContactBtn(nullptr) + , m_pPlusBtn(nullptr) + , m_pRect(nullptr) + , m_EntryMaxCharCount(entryMaxCharCount) + , m_IsMbeVisible(false) + , m_pMbe(nullptr) + , m_IsEditItemClicked(false) { - create(parent); + create(parent); } ConvRecipientsPanelView::~ConvRecipientsPanelView() @@ -53,448 +53,448 @@ ConvRecipientsPanelView::~ConvRecipientsPanelView() void ConvRecipientsPanelView::setMbe(MbeRecipientsView *pMbe) { - m_pMbe = pMbe; - addGeometryChangedCb(*m_pMbe); - elm_object_part_content_set(m_pLayout, "swl.mbe", *m_pMbe); + m_pMbe = pMbe; + addGeometryChangedCb(*m_pMbe); + elm_object_part_content_set(m_pLayout, "swl.mbe", *m_pMbe); } void ConvRecipientsPanelView::showButton(ButtonType buttonType) { - Evas_Object *button = elm_object_part_content_unset(m_pLayout, buttonPart); - if (button) - evas_object_hide(button); - - switch (buttonType) { - case NoneButton: - break; - case ContactButton: - elm_object_part_content_set(m_pLayout, buttonPart, getContactBtn()); - break; - case PlusButton: - elm_object_part_content_set(m_pLayout, buttonPart, getPlusBtn()); - break; - default: - assert(false); - break; - } + Evas_Object *button = elm_object_part_content_unset(m_pLayout, buttonPart); + if (button) + evas_object_hide(button); + + switch (buttonType) { + case NoneButton: + break; + case ContactButton: + elm_object_part_content_set(m_pLayout, buttonPart, getContactBtn()); + break; + case PlusButton: + elm_object_part_content_set(m_pLayout, buttonPart, getPlusBtn()); + break; + default: + assert(false); + break; + } } void ConvRecipientsPanelView::setButtonEnabled(ButtonType buttonType, bool enabled) { - Evas_Object *pBtn = nullptr; - switch (buttonType) { - case NoneButton: - break; - case ContactButton: - pBtn = getContactBtn(); - break; - case PlusButton: - pBtn = getPlusBtn(); - break; - default: - assert(false); - break; - } - - if (pBtn) - elm_object_disabled_set(pBtn, !enabled); + Evas_Object *pBtn = nullptr; + switch (buttonType) { + case NoneButton: + break; + case ContactButton: + pBtn = getContactBtn(); + break; + case PlusButton: + pBtn = getPlusBtn(); + break; + default: + assert(false); + break; + } + + if (pBtn) + elm_object_disabled_set(pBtn, !enabled); } void ConvRecipientsPanelView::addGeometryChangedCb(Evas_Object *obj) { - evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, EVAS_EVENT_CALLBACK(ConvRecipientsPanelView, onGeometryChanged), this); - evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, EVAS_EVENT_CALLBACK(ConvRecipientsPanelView, onGeometryChanged), this); - evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, EVAS_EVENT_CALLBACK(ConvRecipientsPanelView, onGeometryChanged), this); - evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, EVAS_EVENT_CALLBACK(ConvRecipientsPanelView, onGeometryChanged), this); - evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, EVAS_EVENT_CALLBACK(ConvRecipientsPanelView, onGeometryChanged), this); + evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, EVAS_EVENT_CALLBACK(ConvRecipientsPanelView, onGeometryChanged), this); + evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, EVAS_EVENT_CALLBACK(ConvRecipientsPanelView, onGeometryChanged), this); + evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, EVAS_EVENT_CALLBACK(ConvRecipientsPanelView, onGeometryChanged), this); + evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, EVAS_EVENT_CALLBACK(ConvRecipientsPanelView, onGeometryChanged), this); + evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, EVAS_EVENT_CALLBACK(ConvRecipientsPanelView, onGeometryChanged), this); } bool ConvRecipientsPanelView::getEntryFocus() const { - return elm_object_focus_get(m_pEntry); + return elm_object_focus_get(m_pEntry); } void ConvRecipientsPanelView::setEntryFocus(bool val) { - elm_object_focus_set(m_pEntry, val); + elm_object_focus_set(m_pEntry, val); } void ConvRecipientsPanelView::clearEntry() { - elm_object_text_set(m_pEntry, ""); + elm_object_text_set(m_pEntry, ""); } void ConvRecipientsPanelView::clearMbe() { - elm_multibuttonentry_clear(*m_pMbe); + elm_multibuttonentry_clear(*m_pMbe); } void ConvRecipientsPanelView::clear() { - clearEntry(); - clearMbe(); + clearEntry(); + clearMbe(); } void ConvRecipientsPanelView::showMbe(bool show, bool animation) { - m_IsMbeVisible = show; - const char *sig = nullptr; - if (animation) - sig = show ? "show_to_mbe_anim" : "hide_to_mbe_anim"; - else - sig = show ? "show_to_mbe" : "hide_to_mbe"; + m_IsMbeVisible = show; + const char *sig = nullptr; + if (animation) + sig = show ? "show_to_mbe_anim" : "hide_to_mbe_anim"; + else + sig = show ? "show_to_mbe" : "hide_to_mbe"; - emitSignal(m_pLayout, sig, "*"); + emitSignal(m_pLayout, sig, "*"); } void ConvRecipientsPanelView::showEntry(bool show) { - if (show) - getEntry(); - const char *sig = show ? "show_entry" : "hide_entry"; - emitSignal(m_pLayout, sig, "*"); - show ? evas_object_show(m_pEntry) : evas_object_hide(m_pEntry); + if (show) + getEntry(); + const char *sig = show ? "show_entry" : "hide_entry"; + emitSignal(m_pLayout, sig, "*"); + show ? evas_object_show(m_pEntry) : evas_object_hide(m_pEntry); } bool ConvRecipientsPanelView::isMbeEmpty() const { - return elm_multibuttonentry_first_item_get(*m_pMbe) == nullptr; + return elm_multibuttonentry_first_item_get(*m_pMbe) == nullptr; } bool ConvRecipientsPanelView::isMbeVisible() const { - return m_IsMbeVisible; + return m_IsMbeVisible; } std::string ConvRecipientsPanelView::getEntryText() const { - return markupToUtf8(elm_entry_entry_get(m_pEntry)); + return markupToUtf8(elm_entry_entry_get(m_pEntry)); } void ConvRecipientsPanelView::setEntryText(const std::string &utf8) { - char *text = elm_entry_utf8_to_markup(utf8.c_str()); - if (text) { - elm_entry_entry_set(m_pEntry, text); - elm_entry_cursor_end_set(m_pEntry); - free(text); - } + char *text = elm_entry_utf8_to_markup(utf8.c_str()); + if (text) { + elm_entry_entry_set(m_pEntry, text); + elm_entry_cursor_end_set(m_pEntry); + free(text); + } } void ConvRecipientsPanelView::create(Evas_Object *parent) { - Evas_Object *box = elm_box_add(parent); - evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL); - setEo(box); - show(); + Evas_Object *box = elm_box_add(parent); + evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL); + setEo(box); + show(); - m_pLayout = elm_layout_add(box); - std::string path = PathUtils::getResourcePath(RECIPIENT_PANEL_EDJ_PATH); - elm_layout_file_set(m_pLayout, path.c_str(), "recipient_panel"); - expand(m_pLayout); - evas_object_show(m_pLayout); + m_pLayout = elm_layout_add(box); + std::string path = PathUtils::getResourcePath(RECIPIENT_PANEL_EDJ_PATH); + elm_layout_file_set(m_pLayout, path.c_str(), "recipient_panel"); + expand(m_pLayout); + evas_object_show(m_pLayout); - elm_box_pack_end(box, m_pLayout); + elm_box_pack_end(box, m_pLayout); - createAreaRect(m_pLayout); + createAreaRect(m_pLayout); } Evas_Object *ConvRecipientsPanelView::getEntry() { - if (m_pEntryLayout) - return m_pEntryLayout; - - m_pEntryLayout = elm_layout_add(m_pLayout); - elm_layout_theme_set(m_pEntryLayout, "layout", "editfield", "singleline"); - evas_object_show(m_pEntryLayout); - elm_object_part_content_set(m_pEntryLayout, "elm.swallow.button", createClearButton(m_pEntryLayout)); - elm_object_part_content_set(m_pLayout, "swl.entry", m_pEntryLayout); - - m_pEntry = elm_entry_add(m_pEntryLayout); - elm_entry_cnp_mode_set(m_pEntry, ELM_CNP_MODE_PLAINTEXT); - evas_object_show(m_pEntry); - evas_object_size_hint_weight_set(m_pEntry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_pEntry, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_entry_editable_set(m_pEntry, true); - elm_entry_single_line_set(m_pEntry, true); - elm_entry_scrollable_set(m_pEntry, true); - eext_entry_selection_back_event_allow_set(m_pEntry, true); - elm_scroller_policy_set(m_pEntry, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); - elm_entry_autocapital_type_set(m_pEntry, ELM_AUTOCAPITAL_TYPE_NONE); - elm_entry_input_panel_return_key_type_set(m_pEntry, ELM_INPUT_PANEL_RETURN_KEY_TYPE_NEXT); - setText(m_pEntry, msgt("IDS_MSGF_BODY_RECIPIENTS"), "elm.guide"); - processSignal(m_pEntry); - - Elm_Entry_Filter_Limit_Size limitFilter = {}; - limitFilter.max_char_count = m_EntryMaxCharCount; - elm_entry_markup_filter_append(m_pEntry, elm_entry_filter_limit_size, &limitFilter); - - evas_object_smart_callback_add(m_pEntry, "changed", SMART_CALLBACK(ConvRecipientsPanelView, onEntryChanged), this); - evas_object_smart_callback_add(m_pEntry, "focused", SMART_CALLBACK(ConvRecipientsPanelView, onEntryFocusChanged), this); - evas_object_smart_callback_add(m_pEntry, "unfocused", SMART_CALLBACK(ConvRecipientsPanelView, onEntryFocusChanged), this); - evas_object_smart_callback_add(m_pEntry, "clicked", SMART_CALLBACK(ConvRecipientsPanelView, onEntryClicked), this); - evas_object_smart_callback_add(m_pEntry, "maxlength,reached", SMART_CALLBACK(ConvRecipientsPanelView, onEntryMaxlengthReached), this); - evas_object_event_callback_add(m_pEntry, EVAS_CALLBACK_KEY_DOWN, EVAS_EVENT_CALLBACK(ConvRecipientsPanelView, onKeyDown), this); - evas_object_event_callback_add(m_pEntryLayout, EVAS_CALLBACK_RESIZE, EVAS_EVENT_CALLBACK(ConvRecipientsPanelView, onEntrySizeChanged), this); - addGeometryChangedCb(m_pEntry); - elm_object_content_set(m_pEntryLayout, m_pEntry); - processSignal(m_pEntryLayout); - - return m_pEntryLayout; + if (m_pEntryLayout) + return m_pEntryLayout; + + m_pEntryLayout = elm_layout_add(m_pLayout); + elm_layout_theme_set(m_pEntryLayout, "layout", "editfield", "singleline"); + evas_object_show(m_pEntryLayout); + elm_object_part_content_set(m_pEntryLayout, "elm.swallow.button", createClearButton(m_pEntryLayout)); + elm_object_part_content_set(m_pLayout, "swl.entry", m_pEntryLayout); + + m_pEntry = elm_entry_add(m_pEntryLayout); + elm_entry_cnp_mode_set(m_pEntry, ELM_CNP_MODE_PLAINTEXT); + evas_object_show(m_pEntry); + evas_object_size_hint_weight_set(m_pEntry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_pEntry, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_entry_editable_set(m_pEntry, true); + elm_entry_single_line_set(m_pEntry, true); + elm_entry_scrollable_set(m_pEntry, true); + eext_entry_selection_back_event_allow_set(m_pEntry, true); + elm_scroller_policy_set(m_pEntry, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); + elm_entry_autocapital_type_set(m_pEntry, ELM_AUTOCAPITAL_TYPE_NONE); + elm_entry_input_panel_return_key_type_set(m_pEntry, ELM_INPUT_PANEL_RETURN_KEY_TYPE_NEXT); + setText(m_pEntry, msgt("IDS_MSGF_BODY_RECIPIENTS"), "elm.guide"); + processSignal(m_pEntry); + + Elm_Entry_Filter_Limit_Size limitFilter = {}; + limitFilter.max_char_count = m_EntryMaxCharCount; + elm_entry_markup_filter_append(m_pEntry, elm_entry_filter_limit_size, &limitFilter); + + evas_object_smart_callback_add(m_pEntry, "changed", SMART_CALLBACK(ConvRecipientsPanelView, onEntryChanged), this); + evas_object_smart_callback_add(m_pEntry, "focused", SMART_CALLBACK(ConvRecipientsPanelView, onEntryFocusChanged), this); + evas_object_smart_callback_add(m_pEntry, "unfocused", SMART_CALLBACK(ConvRecipientsPanelView, onEntryFocusChanged), this); + evas_object_smart_callback_add(m_pEntry, "clicked", SMART_CALLBACK(ConvRecipientsPanelView, onEntryClicked), this); + evas_object_smart_callback_add(m_pEntry, "maxlength,reached", SMART_CALLBACK(ConvRecipientsPanelView, onEntryMaxlengthReached), this); + evas_object_event_callback_add(m_pEntry, EVAS_CALLBACK_KEY_DOWN, EVAS_EVENT_CALLBACK(ConvRecipientsPanelView, onKeyDown), this); + evas_object_event_callback_add(m_pEntryLayout, EVAS_CALLBACK_RESIZE, EVAS_EVENT_CALLBACK(ConvRecipientsPanelView, onEntrySizeChanged), this); + addGeometryChangedCb(m_pEntry); + elm_object_content_set(m_pEntryLayout, m_pEntry); + processSignal(m_pEntryLayout); + + return m_pEntryLayout; } Evas_Object *ConvRecipientsPanelView::createAreaRect(Evas_Object *parent) { - m_pRect = evas_object_rectangle_add(evas_object_evas_get(parent)); - evas_object_show(m_pRect); - evas_object_color_set(m_pRect, 0, 0, 0, 0); - return m_pRect; + m_pRect = evas_object_rectangle_add(evas_object_evas_get(parent)); + evas_object_show(m_pRect); + evas_object_color_set(m_pRect, 0, 0, 0, 0); + return m_pRect; } Evas_Object *ConvRecipientsPanelView::createClearButton(Evas_Object *parent) { - Evas_Object *button = elm_button_add(parent); - evas_object_smart_callback_add(button, "clicked", SMART_CALLBACK(ConvRecipientsPanelView, onClearButtonClicked), this); - elm_object_focus_allow_set(button, false); - evas_object_smart_callback_add(button, "clicked", SMART_CALLBACK(ConvRecipientsPanelView, onClearButtonClicked), this);; - elm_object_style_set(button, "editfield_clear"); - evas_object_show(button); - return button; + Evas_Object *button = elm_button_add(parent); + evas_object_smart_callback_add(button, "clicked", SMART_CALLBACK(ConvRecipientsPanelView, onClearButtonClicked), this); + elm_object_focus_allow_set(button, false); + evas_object_smart_callback_add(button, "clicked", SMART_CALLBACK(ConvRecipientsPanelView, onClearButtonClicked), this);; + elm_object_style_set(button, "editfield_clear"); + evas_object_show(button); + return button; } Evas_Object *ConvRecipientsPanelView::getContactBtn() { - if (m_pContactBtn) { - evas_object_show(m_pContactBtn); - return m_pContactBtn; - } + if (m_pContactBtn) { + evas_object_show(m_pContactBtn); + return m_pContactBtn; + } - m_pContactBtn = elm_button_add(m_pLayout); - elm_object_focus_allow_set(m_pContactBtn, false); - evas_object_hide(m_pContactBtn); - elm_object_style_set(m_pContactBtn, "contact_button"); + m_pContactBtn = elm_button_add(m_pLayout); + elm_object_focus_allow_set(m_pContactBtn, false); + evas_object_hide(m_pContactBtn); + elm_object_style_set(m_pContactBtn, "contact_button"); - Evas_Object *icon = elm_image_add(m_pLayout); - evas_object_show(icon); - std::string imgPath = PathUtils::getResourcePath(IMAGES_EDJ_PATH); - elm_image_file_set(icon, imgPath.c_str(), CONTACT_IMG); + Evas_Object *icon = elm_image_add(m_pLayout); + evas_object_show(icon); + std::string imgPath = PathUtils::getResourcePath(IMAGES_EDJ_PATH); + elm_image_file_set(icon, imgPath.c_str(), CONTACT_IMG); - elm_object_part_content_set(m_pContactBtn, "button_center_part", icon); - elm_image_resizable_set(icon, EINA_TRUE, EINA_TRUE); - evas_object_color_set(icon, BUTTON_COLOR); + elm_object_part_content_set(m_pContactBtn, "button_center_part", icon); + elm_image_resizable_set(icon, EINA_TRUE, EINA_TRUE); + evas_object_color_set(icon, BUTTON_COLOR); - evas_object_smart_callback_add(m_pContactBtn, "pressed", SMART_CALLBACK(ConvRecipientsPanelView, onBtnPressed), this); - evas_object_smart_callback_add(m_pContactBtn, "unpressed", SMART_CALLBACK(ConvRecipientsPanelView, onBtnUnpressed), this); - evas_object_smart_callback_add(m_pContactBtn, "clicked", SMART_CALLBACK(ConvRecipientsPanelView, onContactBtnClicked), this); + evas_object_smart_callback_add(m_pContactBtn, "pressed", SMART_CALLBACK(ConvRecipientsPanelView, onBtnPressed), this); + evas_object_smart_callback_add(m_pContactBtn, "unpressed", SMART_CALLBACK(ConvRecipientsPanelView, onBtnUnpressed), this); + evas_object_smart_callback_add(m_pContactBtn, "clicked", SMART_CALLBACK(ConvRecipientsPanelView, onContactBtnClicked), this); - setContactBtnColor(m_pContactBtn, BUTTON_COLOR); + setContactBtnColor(m_pContactBtn, BUTTON_COLOR); - return m_pContactBtn; + return m_pContactBtn; } Evas_Object *ConvRecipientsPanelView::getPlusBtn() { - if (m_pPlusBtn) { - evas_object_show(m_pPlusBtn); - return m_pPlusBtn; - } + if (m_pPlusBtn) { + evas_object_show(m_pPlusBtn); + return m_pPlusBtn; + } - m_pPlusBtn = elm_button_add(m_pLayout); - elm_object_focus_allow_set(m_pPlusBtn, false); - evas_object_hide(m_pPlusBtn); - elm_object_style_set(m_pPlusBtn, "plus_button"); + m_pPlusBtn = elm_button_add(m_pLayout); + elm_object_focus_allow_set(m_pPlusBtn, false); + evas_object_hide(m_pPlusBtn); + elm_object_style_set(m_pPlusBtn, "plus_button"); - Evas_Object *icon = elm_image_add(m_pLayout); - evas_object_show(icon); - std::string imgPath = PathUtils::getResourcePath(IMAGES_EDJ_PATH); - elm_image_file_set(icon, imgPath.c_str(), ADD_PLUS_ICON); - elm_image_resizable_set(icon, EINA_TRUE, EINA_TRUE); - evas_object_color_set(icon, BUTTON_COLOR); + Evas_Object *icon = elm_image_add(m_pLayout); + evas_object_show(icon); + std::string imgPath = PathUtils::getResourcePath(IMAGES_EDJ_PATH); + elm_image_file_set(icon, imgPath.c_str(), ADD_PLUS_ICON); + elm_image_resizable_set(icon, EINA_TRUE, EINA_TRUE); + evas_object_color_set(icon, BUTTON_COLOR); - elm_object_part_content_set(m_pPlusBtn, "button_center_part", icon); + elm_object_part_content_set(m_pPlusBtn, "button_center_part", icon); - evas_object_smart_callback_add(m_pPlusBtn, "pressed", SMART_CALLBACK(ConvRecipientsPanelView, onBtnPressed), this); - evas_object_smart_callback_add(m_pPlusBtn, "unpressed", SMART_CALLBACK(ConvRecipientsPanelView, onBtnUnpressed), this); - evas_object_smart_callback_add(m_pPlusBtn, "clicked", SMART_CALLBACK(ConvRecipientsPanelView, onPlusBtnClicked), this); + evas_object_smart_callback_add(m_pPlusBtn, "pressed", SMART_CALLBACK(ConvRecipientsPanelView, onBtnPressed), this); + evas_object_smart_callback_add(m_pPlusBtn, "unpressed", SMART_CALLBACK(ConvRecipientsPanelView, onBtnUnpressed), this); + evas_object_smart_callback_add(m_pPlusBtn, "clicked", SMART_CALLBACK(ConvRecipientsPanelView, onPlusBtnClicked), this); - return m_pPlusBtn; + return m_pPlusBtn; } Evas_Object *ConvRecipientsPanelView::getAreaRect() const { - return m_pRect; + return m_pRect; } int ConvRecipientsPanelView::getEntryHeight() const { - int h = 0; - evas_object_geometry_get(m_pEntryLayout, nullptr, nullptr, nullptr, &h); - return h; + int h = 0; + evas_object_geometry_get(m_pEntryLayout, nullptr, nullptr, nullptr, &h); + return h; } void ConvRecipientsPanelView::onEntrySizeChanged(Evas_Object *obj, void *event_info) { - onEntrySizeChanged(); + onEntrySizeChanged(); } void ConvRecipientsPanelView::onGeometryChanged(Evas_Object *obj, void *event_info) { - int y = 0; - int w = 0; - int h = 0; - int lyayoutTop = 0; - Evas_Object * targetObj = evas_object_visible_get(m_pEntry) ? m_pEntry : m_pMbe->getEo(); + int y = 0; + int w = 0; + int h = 0; + int lyayoutTop = 0; + Evas_Object * targetObj = evas_object_visible_get(m_pEntry) ? m_pEntry : m_pMbe->getEo(); - evas_object_geometry_get(targetObj, nullptr, &y, nullptr, &h); - int bottom = y + h; + evas_object_geometry_get(targetObj, nullptr, &y, nullptr, &h); + int bottom = y + h; - evas_object_geometry_get(m_pLayout, nullptr, &y, nullptr, nullptr); - lyayoutTop = y; + evas_object_geometry_get(m_pLayout, nullptr, &y, nullptr, nullptr); + lyayoutTop = y; - evas_object_size_hint_min_get(m_pRect, &w, nullptr); - evas_object_size_hint_min_set(m_pRect, w, bottom - lyayoutTop); + evas_object_size_hint_min_get(m_pRect, &w, nullptr); + evas_object_size_hint_min_set(m_pRect, w, bottom - lyayoutTop); } void ConvRecipientsPanelView::setContactBtnColor(Evas_Object *btn, int r, int g, int b, int a) { - Evas_Object *icon = elm_object_part_content_get(btn, "button_center_part"); - evas_object_color_set(icon, r, g, b, a); + Evas_Object *icon = elm_object_part_content_get(btn, "button_center_part"); + evas_object_color_set(icon, r, g, b, a); } void ConvRecipientsPanelView::deleteNextRecipient() { - if (!isMbeEmpty()) { - Elm_Object_Item *selectedItem = elm_multibuttonentry_selected_item_get(*m_pMbe); - if (selectedItem) - elm_object_item_del(selectedItem); + if (!isMbeEmpty()) { + Elm_Object_Item *selectedItem = elm_multibuttonentry_selected_item_get(*m_pMbe); + if (selectedItem) + elm_object_item_del(selectedItem); - selectLastItem(); - } + selectLastItem(); + } } void ConvRecipientsPanelView::selectLastItem() { - Elm_Object_Item *lastItem = elm_multibuttonentry_last_item_get(*m_pMbe); + Elm_Object_Item *lastItem = elm_multibuttonentry_last_item_get(*m_pMbe); - if (lastItem) { - elm_object_focus_allow_set(*m_pMbe, true); - elm_multibuttonentry_item_selected_set(lastItem, true); - } else { - showMbe(false); - } + if (lastItem) { + elm_object_focus_allow_set(*m_pMbe, true); + elm_multibuttonentry_item_selected_set(lastItem, true); + } else { + showMbe(false); + } } bool ConvRecipientsPanelView::isEntryEmpty() const { - return elm_entry_is_empty(m_pEntry); + return elm_entry_is_empty(m_pEntry); } void ConvRecipientsPanelView::unselectMbeItem() { - Elm_Object_Item *selectedItem = elm_multibuttonentry_selected_item_get(*m_pMbe); - if (selectedItem) - elm_multibuttonentry_item_selected_set(selectedItem, EINA_FALSE); + Elm_Object_Item *selectedItem = elm_multibuttonentry_selected_item_get(*m_pMbe); + if (selectedItem) + elm_multibuttonentry_item_selected_set(selectedItem, EINA_FALSE); } unsigned int ConvRecipientsPanelView::getItemsCount() const { - unsigned int res = 0; - const Eina_List* items = elm_multibuttonentry_items_get(*m_pMbe); - if (items) - res = eina_list_count(items); - return res; + unsigned int res = 0; + const Eina_List* items = elm_multibuttonentry_items_get(*m_pMbe); + if (items) + res = eina_list_count(items); + return res; } void ConvRecipientsPanelView::collapseRecipients() { - showMbe(false); - m_SavedRecipText = getEntryText(); - clearEntry(); - updateShortenedRecipients(); + showMbe(false); + m_SavedRecipText = getEntryText(); + clearEntry(); + updateShortenedRecipients(); } void ConvRecipientsPanelView::expandRecipients() { - showMbe(!isMbeEmpty()); - if (!m_IsEditItemClicked) { - setEntryText(m_SavedRecipText); - } else { - setEditMode(false); - setEntryText(""); - } + showMbe(!isMbeEmpty()); + if (!m_IsEditItemClicked) { + setEntryText(m_SavedRecipText); + } else { + setEditMode(false); + setEntryText(""); + } } void ConvRecipientsPanelView::updateShortenedRecipients() { - const auto &items = m_pMbe->getItems(); - std::string shortenedRecipients; - if (!items.empty()) { - shortenedRecipients = items[0]->getDispName(); - if (items.size() > 1) - shortenedRecipients += " + " + std::to_string(items.size() - 1); - setEntryText(shortenedRecipients); - } + const auto &items = m_pMbe->getItems(); + std::string shortenedRecipients; + if (!items.empty()) { + shortenedRecipients = items[0]->getDispName(); + if (items.size() > 1) + shortenedRecipients += " + " + std::to_string(items.size() - 1); + setEntryText(shortenedRecipients); + } } void ConvRecipientsPanelView::editSelectedItem() { - MbeRecipientItem* pItem = getSelectedItem(); - if (pItem) { - setEditMode(true); - setEntryText(pItem->getAddress()); - showEntry(true); - pItem->destroy(); - if (isMbeEmpty()) - showMbe(false, false); - setEntryFocus(true); - } + MbeRecipientItem* pItem = getSelectedItem(); + if (pItem) { + setEditMode(true); + setEntryText(pItem->getAddress()); + showEntry(true); + pItem->destroy(); + if (isMbeEmpty()) + showMbe(false, false); + setEntryFocus(true); + } } void ConvRecipientsPanelView::removeSelectedItem() { - MbeRecipientItem* pItem = getSelectedItem(); - if (pItem) { - pItem->destroy(); - if (isMbeEmpty()) - showMbe(false, false); - } + MbeRecipientItem* pItem = getSelectedItem(); + if (pItem) { + pItem->destroy(); + if (isMbeEmpty()) + showMbe(false, false); + } } void ConvRecipientsPanelView::setEditMode(bool isEdit) { - m_IsEditItemClicked = isEdit; + m_IsEditItemClicked = isEdit; } void ConvRecipientsPanelView::showInvalidIcon(bool show) { - const char *sig = show ? "show_invalid_icon" : "hide_invalid_icon"; - emitSignal(m_pLayout, sig, "*"); + const char *sig = show ? "show_invalid_icon" : "hide_invalid_icon"; + emitSignal(m_pLayout, sig, "*"); } void ConvRecipientsPanelView::showClearButton(bool show) { - const char *sig = show ? "elm,action,show,button" : "elm,action,hide,button"; - emitSignal(m_pEntryLayout, sig, ""); + const char *sig = show ? "elm,action,show,button" : "elm,action,hide,button"; + emitSignal(m_pEntryLayout, sig, ""); } void ConvRecipientsPanelView::onEntryChanged(Evas_Object *obj, void *event_info) { - MSG_LOG(""); - showClearButton(getEntryFocus() && !isEntryEmpty()); - onEntryChanged(); + MSG_LOG(""); + showClearButton(getEntryFocus() && !isEntryEmpty()); + onEntryChanged(); } void ConvRecipientsPanelView::onEntryFocusChanged(Evas_Object *obj, void *event_info) { - MSG_LOG(""); - showClearButton(getEntryFocus() && !isEntryEmpty()); - onEntryFocusChanged(); + MSG_LOG(""); + showClearButton(getEntryFocus() && !isEntryEmpty()); + onEntryFocusChanged(); } void ConvRecipientsPanelView::onEntryClicked(Evas_Object *obj, void *event_info) { - unselectMbeItem(); + unselectMbeItem(); } void ConvRecipientsPanelView::onEntryMaxlengthReached(Evas_Object *obj, void *event_info) @@ -503,39 +503,39 @@ void ConvRecipientsPanelView::onEntryMaxlengthReached(Evas_Object *obj, void *ev void ConvRecipientsPanelView::onKeyDown(Evas_Object *obj, void *event_info) { - Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info; - if ((strcmp(ev->keyname, "BackSpace") == 0) && isEntryEmpty()) - deleteNextRecipient(); - onKeyDown(ev); + Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info; + if ((strcmp(ev->keyname, "BackSpace") == 0) && isEntryEmpty()) + deleteNextRecipient(); + onKeyDown(ev); } void ConvRecipientsPanelView::onBtnPressed(Evas_Object *obj, void *event_info) { - setContactBtnColor(obj, BUTTON_PRESSED_COLOR); + setContactBtnColor(obj, BUTTON_PRESSED_COLOR); } void ConvRecipientsPanelView::onBtnUnpressed(Evas_Object *obj, void *event_info) { - setContactBtnColor(obj, BUTTON_COLOR); + setContactBtnColor(obj, BUTTON_COLOR); } void ConvRecipientsPanelView::onContactBtnClicked(Evas_Object *obj, void *event_info) { - onContactButtonClicked(); + onContactButtonClicked(); } void ConvRecipientsPanelView::onPlusBtnClicked(Evas_Object *obj, void *event_info) { - onPlusButtonClicked(); + onPlusButtonClicked(); } void ConvRecipientsPanelView::ConvRecipientsPanelView::onClearButtonClicked(Evas_Object *obj, void *event_info) { - MSG_LOG(""); - clearEntry(); + MSG_LOG(""); + clearEntry(); } MbeRecipientItem *ConvRecipientsPanelView::getSelectedItem() const { - return m_pMbe ? m_pMbe->getSelectedItem() : nullptr; + return m_pMbe ? m_pMbe->getSelectedItem() : nullptr; } diff --git a/src/Conversation/Utils/inc/AttachmentHandler.h b/src/Conversation/Utils/inc/AttachmentHandler.h index 66040111..0db60cee 100644 --- a/src/Conversation/Utils/inc/AttachmentHandler.h +++ b/src/Conversation/Utils/inc/AttachmentHandler.h @@ -27,49 +27,49 @@ #include "WorkingDir.h" namespace Msg { - class IAttachmentHandlerListener; + class IAttachmentHandlerListener; - class AttachmentHandler { - public: - AttachmentHandler(WorkingDirRef workingDir); - ~AttachmentHandler(); + class AttachmentHandler { + public: + AttachmentHandler(WorkingDirRef workingDir); + ~AttachmentHandler(); - AttachmentHandler(AttachmentHandler&) = delete; - void operator=(AttachmentHandler&) = delete; - /** - * @brief Run checking and resizing of files asynchronously. - * Invokes functions of IAttachmentHandlerListener. - */ - void processFile(const std::string &file); - void setListener(IAttachmentHandlerListener *listener); - private: - static void *safeCallOnFreeSpaceRequest(void *data); - static void *safeCallOnFileReady(void *data); - static void *safeCallOnFileFails(void *data); + AttachmentHandler(AttachmentHandler&) = delete; + void operator=(AttachmentHandler&) = delete; + /** + * @brief Run checking and resizing of files asynchronously. + * Invokes functions of IAttachmentHandlerListener. + */ + void processFile(const std::string &file); + void setListener(IAttachmentHandlerListener *listener); + private: + static void *safeCallOnFreeSpaceRequest(void *data); + static void *safeCallOnFileReady(void *data); + static void *safeCallOnFileFails(void *data); - static void *on_routine_cb(void *data, Eina_Thread t); - void onRoutine(); + static void *on_routine_cb(void *data, Eina_Thread t); + void onRoutine(); - private: - IAttachmentHandlerListener *m_pListener; - WorkingDirRef m_WorkingDir; - std::string m_CurrentFile; - Eina_Thread m_Thread; - bool m_ThreadCreated; - long long m_CurrentFreeSpace; - mutable std::mutex m_Mutex; - std::condition_variable m_Condition; - std::atomic m_NeedTerminate; - std::queue m_Task; - }; + private: + IAttachmentHandlerListener *m_pListener; + WorkingDirRef m_WorkingDir; + std::string m_CurrentFile; + Eina_Thread m_Thread; + bool m_ThreadCreated; + long long m_CurrentFreeSpace; + mutable std::mutex m_Mutex; + std::condition_variable m_Condition; + std::atomic m_NeedTerminate; + std::queue m_Task; + }; - class IAttachmentHandlerListener { - public: - virtual ~IAttachmentHandlerListener() {}; - virtual long long onFreeSpaceRequest() = 0; - virtual void onFileReady(const std::string &filePath) = 0; - virtual void onFileFails() = 0; - }; + class IAttachmentHandlerListener { + public: + virtual ~IAttachmentHandlerListener() {}; + virtual long long onFreeSpaceRequest() = 0; + virtual void onFileReady(const std::string &filePath) = 0; + virtual void onFileFails() = 0; + }; } #endif /* AttachmentHandler_h_ */ diff --git a/src/Conversation/Utils/inc/MessageDetailContent.h b/src/Conversation/Utils/inc/MessageDetailContent.h index aec910eb..3ac73483 100644 --- a/src/Conversation/Utils/inc/MessageDetailContent.h +++ b/src/Conversation/Utils/inc/MessageDetailContent.h @@ -23,26 +23,26 @@ #include namespace Msg { - namespace MessageDetailContent { - enum TextStyle { - ViewDetailsTextStyle, - DownloadTextStyle - }; + namespace MessageDetailContent { + enum TextStyle { + ViewDetailsTextStyle, + DownloadTextStyle + }; - std::string getMmsNotiConvListItemContent(App &app, MsgId msgId); - std::string getMessageType(Message::Type msgType); - std::string getContactsInfo(App &app, Message::Direction m_Direction, ThreadId msgThreadId); - std::string getSentReceivedTime(const Message &message, Message::Direction msgDirection); - std::string makeDeliveryReportResult(App &app, Message::NetworkStatus msgStatus, Message::Type msgType, ThreadId msgThreadId, MsgId msgId); - std::string getSmsStatus(Message::NetworkStatus msgStatus); - std::string getMmsSubject(const Message &msg, int style); - std::string getMmsMessageSize(const Message &message, int style); - std::string getMmsMessageExpired(const Message &message, int style); - std::string makeReadReportResult(App &app, MsgId msgId, ThreadId msgThreadId, Message::NetworkStatus msgStatus); - std::string makeDispAddress(App &app, const std::string &address); - std::string makeMainText(const std::string &text); - std::string makeSecondText(const std::string &text); - }; + std::string getMmsNotiConvListItemContent(App &app, MsgId msgId); + std::string getMessageType(Message::Type msgType); + std::string getContactsInfo(App &app, Message::Direction m_Direction, ThreadId msgThreadId); + std::string getSentReceivedTime(const Message &message, Message::Direction msgDirection); + std::string makeDeliveryReportResult(App &app, Message::NetworkStatus msgStatus, Message::Type msgType, ThreadId msgThreadId, MsgId msgId); + std::string getSmsStatus(Message::NetworkStatus msgStatus); + std::string getMmsSubject(const Message &msg, int style); + std::string getMmsMessageSize(const Message &message, int style); + std::string getMmsMessageExpired(const Message &message, int style); + std::string makeReadReportResult(App &app, MsgId msgId, ThreadId msgThreadId, Message::NetworkStatus msgStatus); + std::string makeDispAddress(App &app, const std::string &address); + std::string makeMainText(const std::string &text); + std::string makeSecondText(const std::string &text); + }; } #endif /* MessageDetailContent_H_ */ diff --git a/src/Conversation/Utils/inc/WorkingDir.h b/src/Conversation/Utils/inc/WorkingDir.h index e44fb6b7..495a0f31 100644 --- a/src/Conversation/Utils/inc/WorkingDir.h +++ b/src/Conversation/Utils/inc/WorkingDir.h @@ -22,34 +22,34 @@ #include namespace Msg { - class WorkingDir { - public: - WorkingDir(); - ~WorkingDir(); - - WorkingDir(WorkingDir&) = delete; - void operator=(WorkingDir&) = delete; - - bool isValid() const; - const std::string &getPath() const; - - std::string genUniqueFilePath(const std::string &fileName) const; - std::string addFile(const std::string &path); - std::string addTextFile(const std::string &text, const std::string &fileName = ""); - void removeFile(const std::string &path); - void clear(); - - private: - void createWorkingDir(); - void removeWorkingDir(); - std::string getUniqueDirName(const std::string &path); - - private: - std::string m_Path; - mutable std::recursive_mutex m_Mutex; - }; - - typedef std::shared_ptr WorkingDirRef; + class WorkingDir { + public: + WorkingDir(); + ~WorkingDir(); + + WorkingDir(WorkingDir&) = delete; + void operator=(WorkingDir&) = delete; + + bool isValid() const; + const std::string &getPath() const; + + std::string genUniqueFilePath(const std::string &fileName) const; + std::string addFile(const std::string &path); + std::string addTextFile(const std::string &text, const std::string &fileName = ""); + void removeFile(const std::string &path); + void clear(); + + private: + void createWorkingDir(); + void removeWorkingDir(); + std::string getUniqueDirName(const std::string &path); + + private: + std::string m_Path; + mutable std::recursive_mutex m_Mutex; + }; + + typedef std::shared_ptr WorkingDirRef; } #endif /* WorkingDir_h_ */ diff --git a/src/Conversation/Utils/src/AttachmentHandler.cpp b/src/Conversation/Utils/src/AttachmentHandler.cpp index 132c3cb9..9ae2d05c 100644 --- a/src/Conversation/Utils/src/AttachmentHandler.cpp +++ b/src/Conversation/Utils/src/AttachmentHandler.cpp @@ -25,116 +25,116 @@ using namespace Msg; AttachmentHandler::AttachmentHandler(WorkingDirRef workingDir) - : m_pListener(nullptr) - , m_WorkingDir(workingDir) - , m_Thread() - , m_ThreadCreated(false) - , m_NeedTerminate(false) + : m_pListener(nullptr) + , m_WorkingDir(workingDir) + , m_Thread() + , m_ThreadCreated(false) + , m_NeedTerminate(false) { } AttachmentHandler::~AttachmentHandler() { - m_NeedTerminate = true; - m_Condition.notify_one(); + m_NeedTerminate = true; + m_Condition.notify_one(); - if (m_ThreadCreated) - eina_thread_join(m_Thread); - m_ThreadCreated = false; + if (m_ThreadCreated) + eina_thread_join(m_Thread); + m_ThreadCreated = false; } void AttachmentHandler::processFile(const std::string &file) { - if (!m_ThreadCreated) { - if (eina_thread_create(&m_Thread, EINA_THREAD_NORMAL, 0, on_routine_cb, this)) { - m_ThreadCreated = true; - } else { - if (m_pListener) - m_pListener->onFileFails(); - } - } - - // TODO: revert this code (eina_thread), when C++11 will work on Emulator, JIRA: SDKRM-1187 - /*if (!m_Thread.joinable()) - m_Thread = std::thread(&AttachmentHandler::onRoutine, this);*/ - - std::unique_lock _lock(m_Mutex); - m_Task.push(file); - _lock.unlock(); - m_Condition.notify_one(); + if (!m_ThreadCreated) { + if (eina_thread_create(&m_Thread, EINA_THREAD_NORMAL, 0, on_routine_cb, this)) { + m_ThreadCreated = true; + } else { + if (m_pListener) + m_pListener->onFileFails(); + } + } + + // TODO: revert this code (eina_thread), when C++11 will work on Emulator, JIRA: SDKRM-1187 + /*if (!m_Thread.joinable()) + m_Thread = std::thread(&AttachmentHandler::onRoutine, this);*/ + + std::unique_lock _lock(m_Mutex); + m_Task.push(file); + _lock.unlock(); + m_Condition.notify_one(); } void AttachmentHandler::setListener(IAttachmentHandlerListener *listener) { - m_pListener = listener; + m_pListener = listener; } void *AttachmentHandler::safeCallOnFreeSpaceRequest(void *data) { - auto *self = static_cast(data); - if (self->m_pListener) - self->m_CurrentFreeSpace = self->m_pListener->onFreeSpaceRequest(); - return nullptr; + auto *self = static_cast(data); + if (self->m_pListener) + self->m_CurrentFreeSpace = self->m_pListener->onFreeSpaceRequest(); + return nullptr; } void *AttachmentHandler::safeCallOnFileReady(void *data) { - auto *self = static_cast(data); - if (self->m_pListener) - self->m_pListener->onFileReady(self->m_CurrentFile); - return nullptr; + auto *self = static_cast(data); + if (self->m_pListener) + self->m_pListener->onFileReady(self->m_CurrentFile); + return nullptr; } void *AttachmentHandler::safeCallOnFileFails(void *data) { - auto *self = static_cast(data); - if (self->m_pListener) - self->m_pListener->onFileFails(); - return nullptr; + auto *self = static_cast(data); + if (self->m_pListener) + self->m_pListener->onFileFails(); + return nullptr; } void *AttachmentHandler::on_routine_cb(void *data, Eina_Thread t) { - ((AttachmentHandler*)data)->onRoutine(); - return nullptr; + ((AttachmentHandler*)data)->onRoutine(); + return nullptr; } void AttachmentHandler::onRoutine() { - while (!m_NeedTerminate) { - std::unique_lock _lock(m_Mutex); - if (m_Task.empty() && !m_NeedTerminate) - m_Condition.wait(_lock); - if (m_Task.empty() || m_NeedTerminate) - continue; - - m_CurrentFile = m_Task.front(); - m_Task.pop(); - _lock.unlock(); - - if (!FileUtils::isExists(m_CurrentFile) || FileUtils::isDir(m_CurrentFile)) { - MSG_LOG_ERROR("File not exists: ", m_CurrentFile); - ecore_main_loop_thread_safe_call_sync(safeCallOnFileFails, this); - continue; - } - - m_CurrentFile = m_WorkingDir->addFile(m_CurrentFile); - if (m_CurrentFile.empty()) { - MSG_LOG_ERROR("Error while copy file"); - ecore_main_loop_thread_safe_call_sync(safeCallOnFileFails, this); - continue; - } - - ecore_main_loop_thread_safe_call_sync(safeCallOnFreeSpaceRequest, this); - if (FileUtils::getFileSize(m_CurrentFile) > m_CurrentFreeSpace) { - bool isImage = getMsgMediaTypeByFileExt(m_CurrentFile).type == MsgMedia::ImageType; - if ((isImage && MediaUtils::downgradeImageQuality(m_CurrentFile) > m_CurrentFreeSpace) || !isImage) { - m_WorkingDir->removeFile(m_CurrentFile); - ecore_main_loop_thread_safe_call_sync(safeCallOnFileFails, this); - continue; - } - } - - ecore_main_loop_thread_safe_call_sync(safeCallOnFileReady, this); - } + while (!m_NeedTerminate) { + std::unique_lock _lock(m_Mutex); + if (m_Task.empty() && !m_NeedTerminate) + m_Condition.wait(_lock); + if (m_Task.empty() || m_NeedTerminate) + continue; + + m_CurrentFile = m_Task.front(); + m_Task.pop(); + _lock.unlock(); + + if (!FileUtils::isExists(m_CurrentFile) || FileUtils::isDir(m_CurrentFile)) { + MSG_LOG_ERROR("File not exists: ", m_CurrentFile); + ecore_main_loop_thread_safe_call_sync(safeCallOnFileFails, this); + continue; + } + + m_CurrentFile = m_WorkingDir->addFile(m_CurrentFile); + if (m_CurrentFile.empty()) { + MSG_LOG_ERROR("Error while copy file"); + ecore_main_loop_thread_safe_call_sync(safeCallOnFileFails, this); + continue; + } + + ecore_main_loop_thread_safe_call_sync(safeCallOnFreeSpaceRequest, this); + if (FileUtils::getFileSize(m_CurrentFile) > m_CurrentFreeSpace) { + bool isImage = getMsgMediaTypeByFileExt(m_CurrentFile).type == MsgMedia::ImageType; + if ((isImage && MediaUtils::downgradeImageQuality(m_CurrentFile) > m_CurrentFreeSpace) || !isImage) { + m_WorkingDir->removeFile(m_CurrentFile); + ecore_main_loop_thread_safe_call_sync(safeCallOnFileFails, this); + continue; + } + } + + ecore_main_loop_thread_safe_call_sync(safeCallOnFileReady, this); + } } diff --git a/src/Conversation/Utils/src/MessageDetailContent.cpp b/src/Conversation/Utils/src/MessageDetailContent.cpp index 7836e9ad..1bb4f5d1 100644 --- a/src/Conversation/Utils/src/MessageDetailContent.cpp +++ b/src/Conversation/Utils/src/MessageDetailContent.cpp @@ -29,325 +29,325 @@ namespace Msg { namespace MessageDetailContent { namespace { - const std::string secondTextColor = "#737373"; - const unsigned int mainTextSize = 40; - const unsigned int secondTextSize = 32; + const std::string secondTextColor = "#737373"; + const unsigned int mainTextSize = 40; + const unsigned int secondTextSize = 32; } std::string getMmsNotiConvListItemContent(App &app, MsgId msgId) { - MessageRef msg = app.getMsgEngine().getStorage().getMessage(msgId); - std::string msgDetails; - msgDetails += getMmsSubject(*msg, DownloadTextStyle); - msgDetails += getMmsMessageSize(*msg, DownloadTextStyle); - msgDetails += getMmsMessageExpired(*msg, DownloadTextStyle); - return msgDetails; + MessageRef msg = app.getMsgEngine().getStorage().getMessage(msgId); + std::string msgDetails; + msgDetails += getMmsSubject(*msg, DownloadTextStyle); + msgDetails += getMmsMessageSize(*msg, DownloadTextStyle); + msgDetails += getMmsMessageExpired(*msg, DownloadTextStyle); + return msgDetails; } std::string getMessageType(Message::Type msgType) { - std::string msgDetails = makeMainText(msg("IDS_MSG_POP_TYPE")); - msgDetails.append("
"); - - switch (msgType) { - case Message::MT_SMS: - msgDetails.append(makeSecondText(msg("IDS_MSGF_OPT_TEXT_MESSAGE"))); - break; - case Message::MT_MMS: - msgDetails.append(makeSecondText(msg("IDS_MSGF_BODY_MULTIMEDIA_MESSAGE"))); - break; - case Message::MT_MMS_Noti: - msgDetails.append(makeSecondText(msg("IDS_MSGF_BODY_MULTIMEDIA_MESSAGE_NOTIFICATION"))); - break; - default: - MSG_LOG_WARN("Unknown message type"); - } - msgDetails.append("

"); - return msgDetails; + std::string msgDetails = makeMainText(msg("IDS_MSG_POP_TYPE")); + msgDetails.append("
"); + + switch (msgType) { + case Message::MT_SMS: + msgDetails.append(makeSecondText(msg("IDS_MSGF_OPT_TEXT_MESSAGE"))); + break; + case Message::MT_MMS: + msgDetails.append(makeSecondText(msg("IDS_MSGF_BODY_MULTIMEDIA_MESSAGE"))); + break; + case Message::MT_MMS_Noti: + msgDetails.append(makeSecondText(msg("IDS_MSGF_BODY_MULTIMEDIA_MESSAGE_NOTIFICATION"))); + break; + default: + MSG_LOG_WARN("Unknown message type"); + } + msgDetails.append("

"); + return msgDetails; } std::string getContactsInfo(App &app, Message::Direction msgDirection, ThreadId msgThreadId) { - MsgAddressListRef addrList = app.getMsgEngine().getStorage().getAddressList(msgThreadId); - - std::string contactsInfo; - if (msgDirection == Message::MD_Sent) { - contactsInfo.append(msg("IDS_MSG_HEADER_TO_M_RECIPIENT")); - contactsInfo.append("
"); - } - - if (msgDirection == Message::MD_Received) { - contactsInfo.append(makeMainText(msg("IDS_MSG_BODY_FROM_ABB_M_PERIOD"))); - contactsInfo.append("
"); - } - - int addressListLength = addrList->getLength(); - for (int i = 0; i < addressListLength; ++i) { - std::string address = addrList->at(i).getAddress(); - contactsInfo.append(makeSecondText(makeDispAddress(app, address))); - if (i != addressListLength - 1) - contactsInfo.append(makeSecondText(", ")); - } - contactsInfo.append("

"); - - return contactsInfo; + MsgAddressListRef addrList = app.getMsgEngine().getStorage().getAddressList(msgThreadId); + + std::string contactsInfo; + if (msgDirection == Message::MD_Sent) { + contactsInfo.append(msg("IDS_MSG_HEADER_TO_M_RECIPIENT")); + contactsInfo.append("
"); + } + + if (msgDirection == Message::MD_Received) { + contactsInfo.append(makeMainText(msg("IDS_MSG_BODY_FROM_ABB_M_PERIOD"))); + contactsInfo.append("
"); + } + + int addressListLength = addrList->getLength(); + for (int i = 0; i < addressListLength; ++i) { + std::string address = addrList->at(i).getAddress(); + contactsInfo.append(makeSecondText(makeDispAddress(app, address))); + if (i != addressListLength - 1) + contactsInfo.append(makeSecondText(", ")); + } + contactsInfo.append("

"); + + return contactsInfo; } std::string getSentReceivedTime(const Message &message, Message::Direction msgDirection) { - std::string msgDetails; - if (msgDirection == Message::MD_Sent) - msgDetails.append(makeMainText(msg("IDS_MSG_HEADER_TIME_SENT"))); - else if (msgDirection == Message::MD_Received) - msgDetails.append(makeMainText(msg("IDS_MSG_HEADER_TIME_RECEIVED"))); - - msgDetails.append("
"); - time_t time = message.getTime(); - msgDetails.append(makeSecondText(TimeUtils::makeDateTimeString(time))); - return msgDetails; + std::string msgDetails; + if (msgDirection == Message::MD_Sent) + msgDetails.append(makeMainText(msg("IDS_MSG_HEADER_TIME_SENT"))); + else if (msgDirection == Message::MD_Received) + msgDetails.append(makeMainText(msg("IDS_MSG_HEADER_TIME_RECEIVED"))); + + msgDetails.append("
"); + time_t time = message.getTime(); + msgDetails.append(makeSecondText(TimeUtils::makeDateTimeString(time))); + return msgDetails; } std::string makeDeliveryReportResult(App &app, Message::NetworkStatus msgStatus, Message::Type msgType, ThreadId msgThreadId, MsgId msgId) { - std::string deliverText = makeMainText(msg("IDS_MSGF_BODY_DELIVERY_REPORT")); - - bool deliverFlag = app.getMsgEngine().getStorage().isDeliverReportChecked(msgId); - if (deliverFlag) { - MsgReportListRef reportList = app.getMsgEngine().getStorage().getMsgReportList(msgId); - int size = reportList->getLength(); - bool isDelivReportExists = false; - - for (int i = 0; i < size; i++) { - const MsgReport &report = reportList->at(i); - if (report.getType() == MsgReport::TypeDelivery) { - isDelivReportExists = true; - deliverText.append("
"); - deliverText.append(makeSecondText(makeDispAddress(app, report.getAddress()))); - deliverText.append(makeSecondText(": ")); - MsgReport::DeliveryStatus deliveryStatus = report.getDeliveryStatus(); - - switch (deliveryStatus) { - case MsgReport::StatusSuccess: - deliverText.append(makeSecondText(msg("IDS_MSG_BODY_DELIVERED_M_STATUS"))); - break; - case MsgReport::StatusExpired: - deliverText.append(makeSecondText(msg("IDS_MSGF_BODY_EXPIRED"))); - break; - case MsgReport::StatusRejected: - deliverText.append(makeSecondText(msg("IDS_MSGF_POP_REJECTED"))); - break; - case MsgReport::StatusNone: - deliverText.append(makeSecondText(msg("IDS_MSG_BODY_REQUESTED_M_MESSAGE_STATUS"))); - break; - } - } - } - if (!isDelivReportExists) { - deliverText.append("
"); - deliverText.append(makeSecondText(msg("IDS_MSGF_BODY_UNKNOWN"))); - } - } else { - deliverText.append("
"); - deliverText.append(makeSecondText(msg("IDS_MSGC_BODY_NOT_REQUESTED"))); - } - - deliverText.append("

"); - return deliverText; + std::string deliverText = makeMainText(msg("IDS_MSGF_BODY_DELIVERY_REPORT")); + + bool deliverFlag = app.getMsgEngine().getStorage().isDeliverReportChecked(msgId); + if (deliverFlag) { + MsgReportListRef reportList = app.getMsgEngine().getStorage().getMsgReportList(msgId); + int size = reportList->getLength(); + bool isDelivReportExists = false; + + for (int i = 0; i < size; i++) { + const MsgReport &report = reportList->at(i); + if (report.getType() == MsgReport::TypeDelivery) { + isDelivReportExists = true; + deliverText.append("
"); + deliverText.append(makeSecondText(makeDispAddress(app, report.getAddress()))); + deliverText.append(makeSecondText(": ")); + MsgReport::DeliveryStatus deliveryStatus = report.getDeliveryStatus(); + + switch (deliveryStatus) { + case MsgReport::StatusSuccess: + deliverText.append(makeSecondText(msg("IDS_MSG_BODY_DELIVERED_M_STATUS"))); + break; + case MsgReport::StatusExpired: + deliverText.append(makeSecondText(msg("IDS_MSGF_BODY_EXPIRED"))); + break; + case MsgReport::StatusRejected: + deliverText.append(makeSecondText(msg("IDS_MSGF_POP_REJECTED"))); + break; + case MsgReport::StatusNone: + deliverText.append(makeSecondText(msg("IDS_MSG_BODY_REQUESTED_M_MESSAGE_STATUS"))); + break; + } + } + } + if (!isDelivReportExists) { + deliverText.append("
"); + deliverText.append(makeSecondText(msg("IDS_MSGF_BODY_UNKNOWN"))); + } + } else { + deliverText.append("
"); + deliverText.append(makeSecondText(msg("IDS_MSGC_BODY_NOT_REQUESTED"))); + } + + deliverText.append("

"); + return deliverText; } std::string getSmsStatus(Message::NetworkStatus msgStatus) { - std::string status = makeMainText(msg("IDS_MSG_BODY_STATUS_C")); - status.append("
"); - - switch (msgStatus) { - case Message::NS_Sending: - status.append(makeSecondText(msg("IDS_MSG_BODY_SENDING_ING_M_STATUS_ABB"))); - break; - case Message::NS_Send_Success: - case Message::NS_Deliver_Success: - status.append(makeSecondText(msg("IDS_MSG_BODY_SENT_M_STATUS"))); - break; - case Message::NS_Send_Pending: - status.append(makeSecondText(msg("IDS_MSG_BODY_WAITING_TO_SEND_ING_M_STATUS"))); - break; - case Message::NS_Send_Fail: - case Message::NS_Deliver_Fail: - status.append(makeSecondText(msg("IDS_MSG_BODY_SENDING_FAILED_M_STATUS"))); - break; - default: - MSG_LOG("Indifference type of network status ", msgStatus); - break; - } - - return status; + std::string status = makeMainText(msg("IDS_MSG_BODY_STATUS_C")); + status.append("
"); + + switch (msgStatus) { + case Message::NS_Sending: + status.append(makeSecondText(msg("IDS_MSG_BODY_SENDING_ING_M_STATUS_ABB"))); + break; + case Message::NS_Send_Success: + case Message::NS_Deliver_Success: + status.append(makeSecondText(msg("IDS_MSG_BODY_SENT_M_STATUS"))); + break; + case Message::NS_Send_Pending: + status.append(makeSecondText(msg("IDS_MSG_BODY_WAITING_TO_SEND_ING_M_STATUS"))); + break; + case Message::NS_Send_Fail: + case Message::NS_Deliver_Fail: + status.append(makeSecondText(msg("IDS_MSG_BODY_SENDING_FAILED_M_STATUS"))); + break; + default: + MSG_LOG("Indifference type of network status ", msgStatus); + break; + } + + return status; } std::string getMmsSubject(const Message &message, int style) { - std::string msgDetails; - std::string subject = message.getSubject(); - switch (style) { - case ViewDetailsTextStyle: - msgDetails.append(makeMainText(msg("IDS_MSG_HEADER_SUBJECT"))).append("
"); - if (subject.empty()) - msgDetails.append(makeSecondText(msg("IDS_MSGF_BODY_NO_SUBJECT"))); - else - msgDetails.append(makeSecondText(subject)); - - msgDetails.append("

"); - break; - case DownloadTextStyle: - msgDetails.append(msg("IDS_MSGF_OPT_SUBJECT_COLON")); - msgDetails.append(" "); - if (subject.empty()) - msgDetails.append(msg("IDS_MSGF_BODY_NO_SUBJECT")); - else - msgDetails.append(subject); - - msgDetails.append("
"); - break; - default: - MSG_LOG("Unknown text style!"); - break; - } - - return msgDetails; + std::string msgDetails; + std::string subject = message.getSubject(); + switch (style) { + case ViewDetailsTextStyle: + msgDetails.append(makeMainText(msg("IDS_MSG_HEADER_SUBJECT"))).append("
"); + if (subject.empty()) + msgDetails.append(makeSecondText(msg("IDS_MSGF_BODY_NO_SUBJECT"))); + else + msgDetails.append(makeSecondText(subject)); + + msgDetails.append("

"); + break; + case DownloadTextStyle: + msgDetails.append(msg("IDS_MSGF_OPT_SUBJECT_COLON")); + msgDetails.append(" "); + if (subject.empty()) + msgDetails.append(msg("IDS_MSGF_BODY_NO_SUBJECT")); + else + msgDetails.append(subject); + + msgDetails.append("
"); + break; + default: + MSG_LOG("Unknown text style!"); + break; + } + + return msgDetails; } std::string getMmsMessageSize(const Message &message, int style) { - int msgSize = message.getSize(); - std::string msgDetails; - switch (style) { - case ViewDetailsTextStyle: - msgDetails.append(makeMainText(msg("IDS_MSGF_BODY_MESSAGE_SIZE"))); - msgDetails.append("
"); - msgDetails.append(makeSecondText(MsgUtils::makeKbStr(msgSize))); - break; - case DownloadTextStyle: - msgDetails.append(msg("IDS_MSGF_BODY_MESSAGE_SIZE")); - msgDetails.append(": "); - msgDetails.append(MsgUtils::makeKbStr(msgSize)); - msgDetails.append("
"); - break; - default: - MSG_LOG("Unknown text style!"); - break; - } - - return msgDetails; + int msgSize = message.getSize(); + std::string msgDetails; + switch (style) { + case ViewDetailsTextStyle: + msgDetails.append(makeMainText(msg("IDS_MSGF_BODY_MESSAGE_SIZE"))); + msgDetails.append("
"); + msgDetails.append(makeSecondText(MsgUtils::makeKbStr(msgSize))); + break; + case DownloadTextStyle: + msgDetails.append(msg("IDS_MSGF_BODY_MESSAGE_SIZE")); + msgDetails.append(": "); + msgDetails.append(MsgUtils::makeKbStr(msgSize)); + msgDetails.append("
"); + break; + default: + MSG_LOG("Unknown text style!"); + break; + } + + return msgDetails; } std::string getMmsMessageExpired(const Message &message, int style) { - const MessageMms *mms = dynamic_cast(&message); - std::string msgDetails; - switch (style) { - case ViewDetailsTextStyle: - msgDetails.append("

"); - msgDetails.append(makeMainText(msg("IDS_MSG_BODY_EXPIRES_ON_C"))); - msgDetails.append("
"); - if (mms) { - time_t msgExpired = mms->getExpired(); - msgDetails.append(makeSecondText(TimeUtils::makeDateString(msgExpired))); - } - break; - case DownloadTextStyle: - msgDetails.append(msg("IDS_MSG_BODY_EXPIRES_ON_C")); - msgDetails.append(" "); - if (mms) { - time_t msgExpired = mms->getExpired(); - msgDetails.append(TimeUtils::makeDateString(msgExpired)); - } - break; - default: - MSG_LOG("Unknown text style!"); - break; - } - - return msgDetails; + const MessageMms *mms = dynamic_cast(&message); + std::string msgDetails; + switch (style) { + case ViewDetailsTextStyle: + msgDetails.append("

"); + msgDetails.append(makeMainText(msg("IDS_MSG_BODY_EXPIRES_ON_C"))); + msgDetails.append("
"); + if (mms) { + time_t msgExpired = mms->getExpired(); + msgDetails.append(makeSecondText(TimeUtils::makeDateString(msgExpired))); + } + break; + case DownloadTextStyle: + msgDetails.append(msg("IDS_MSG_BODY_EXPIRES_ON_C")); + msgDetails.append(" "); + if (mms) { + time_t msgExpired = mms->getExpired(); + msgDetails.append(TimeUtils::makeDateString(msgExpired)); + } + break; + default: + MSG_LOG("Unknown text style!"); + break; + } + + return msgDetails; } std::string makeReadReportResult(App &app, MsgId msgId, ThreadId msgThreadId, Message::NetworkStatus msgStatus) { - std::string readReport = makeMainText(msg("IDS_MSGF_POP_READ_REPORT")); - bool readFlag = app.getMsgEngine().getStorage().isReadReportChecked(msgId); - if (readFlag) { - MsgReportListRef reportList = app.getMsgEngine().getStorage().getMsgReportList(msgId); - - int size = reportList->getLength(); - bool isReadReportExists = false; - - for (int i = 0; i < size; i++) { - const MsgReport &report = reportList->at(i); - if (report.getType() == MsgReport::TypeRead) { - isReadReportExists = true; - readReport.append("
"); - readReport.append(makeSecondText(makeDispAddress(app, report.getAddress()))); - readReport.append(makeSecondText(": ")); - MsgReport::ReadStatus readStatus = report.getReadStatus(); - - switch (readStatus) { - case MsgReport::ReadStatusIsRead: - readReport.append(makeSecondText(msg("IDS_MSGF_BODY_MMSREADREPLYMSGREAD"))); - break; - case MsgReport::ReadStatusIsDeleted: - readReport.append(makeSecondText(msg("IDS_MSG_POP_DELETED"))); - break; - case MsgReport::ReadStatusNone: - readReport.append(makeSecondText(msg("IDS_MSG_BODY_REQUESTED_M_MESSAGE_STATUS"))); - break; - default: - readReport.append(makeSecondText(msg("IDS_MSGF_BODY_UNKNOWN"))); - } - } - } - - if (!isReadReportExists) { - readReport.append("
"); - readReport.append(makeSecondText(msg("IDS_MSGF_BODY_UNKNOWN"))); - } - } else { - readReport.append("
"); - readReport.append(makeSecondText(msg("IDS_MSGC_BODY_NOT_REQUESTED"))); - } - - return readReport; + std::string readReport = makeMainText(msg("IDS_MSGF_POP_READ_REPORT")); + bool readFlag = app.getMsgEngine().getStorage().isReadReportChecked(msgId); + if (readFlag) { + MsgReportListRef reportList = app.getMsgEngine().getStorage().getMsgReportList(msgId); + + int size = reportList->getLength(); + bool isReadReportExists = false; + + for (int i = 0; i < size; i++) { + const MsgReport &report = reportList->at(i); + if (report.getType() == MsgReport::TypeRead) { + isReadReportExists = true; + readReport.append("
"); + readReport.append(makeSecondText(makeDispAddress(app, report.getAddress()))); + readReport.append(makeSecondText(": ")); + MsgReport::ReadStatus readStatus = report.getReadStatus(); + + switch (readStatus) { + case MsgReport::ReadStatusIsRead: + readReport.append(makeSecondText(msg("IDS_MSGF_BODY_MMSREADREPLYMSGREAD"))); + break; + case MsgReport::ReadStatusIsDeleted: + readReport.append(makeSecondText(msg("IDS_MSG_POP_DELETED"))); + break; + case MsgReport::ReadStatusNone: + readReport.append(makeSecondText(msg("IDS_MSG_BODY_REQUESTED_M_MESSAGE_STATUS"))); + break; + default: + readReport.append(makeSecondText(msg("IDS_MSGF_BODY_UNKNOWN"))); + } + } + } + + if (!isReadReportExists) { + readReport.append("
"); + readReport.append(makeSecondText(msg("IDS_MSGF_BODY_UNKNOWN"))); + } + } else { + readReport.append("
"); + readReport.append(makeSecondText(msg("IDS_MSGC_BODY_NOT_REQUESTED"))); + } + + return readReport; } std::string makeDispAddress(App &app, const std::string &address) { - std::string res; - ContactAddressRef rec = app.getContactManager().getContactAddress(address); + std::string res; + ContactAddressRef rec = app.getContactManager().getContactAddress(address); - std::string dispName; - if (rec) - dispName = rec->getDispName(); + std::string dispName; + if (rec) + dispName = rec->getDispName(); - res = dispName; + res = dispName; - if (!res.empty()) - res += "("; + if (!res.empty()) + res += "("; - res += address; - if (!dispName.empty()) - res += ')'; + res += address; + if (!dispName.empty()) + res += ')'; - if (res.empty()) - res += msg("IDS_MSGF_BODY_UNKNOWN"); + if (res.empty()) + res += msg("IDS_MSGF_BODY_UNKNOWN"); - return res; + return res; } std::string makeMainText(const std::string &text) { - return TextDecorator::make(text, mainTextSize); + return TextDecorator::make(text, mainTextSize); } std::string makeSecondText(const std::string &text) { - return TextDecorator::make(text, secondTextSize, secondTextColor); + return TextDecorator::make(text, secondTextSize, secondTextColor); } } // namespace MessageDetailContent diff --git a/src/Conversation/Utils/src/WorkingDir.cpp b/src/Conversation/Utils/src/WorkingDir.cpp index e0c07562..7e6dddf2 100644 --- a/src/Conversation/Utils/src/WorkingDir.cpp +++ b/src/Conversation/Utils/src/WorkingDir.cpp @@ -31,122 +31,122 @@ const std::string textFileName = "mms.txt"; WorkingDir::WorkingDir() { - MSG_LOG(""); - createWorkingDir(); + MSG_LOG(""); + createWorkingDir(); } WorkingDir::~WorkingDir() { - MSG_LOG(""); - removeWorkingDir(); + MSG_LOG(""); + removeWorkingDir(); } void WorkingDir::createWorkingDir() { - // Create common dir. if not exists: - std::string commonDir = PathUtils::getDataPath(commonWorkingDirName); - bool isCommonExists = FileUtils::isExists(commonDir); - if (!isCommonExists) { - isCommonExists = FileUtils::makeDir(commonDir); - MSG_ASSERT(isCommonExists, "Can't create common working dir: ", commonDir); - } - - // Create current dir: - if (isCommonExists) { - std::string uniqueDir = getUniqueDirName(commonDir + "/" + currentWorkingDirPrefix); - FileUtils::makeDir(uniqueDir); - bool isExists = FileUtils::isExists(uniqueDir); - MSG_ASSERT(isExists, "Can't create current working dir: ", uniqueDir); - if (isExists) - m_Path = uniqueDir; - } + // Create common dir. if not exists: + std::string commonDir = PathUtils::getDataPath(commonWorkingDirName); + bool isCommonExists = FileUtils::isExists(commonDir); + if (!isCommonExists) { + isCommonExists = FileUtils::makeDir(commonDir); + MSG_ASSERT(isCommonExists, "Can't create common working dir: ", commonDir); + } + + // Create current dir: + if (isCommonExists) { + std::string uniqueDir = getUniqueDirName(commonDir + "/" + currentWorkingDirPrefix); + FileUtils::makeDir(uniqueDir); + bool isExists = FileUtils::isExists(uniqueDir); + MSG_ASSERT(isExists, "Can't create current working dir: ", uniqueDir); + if (isExists) + m_Path = uniqueDir; + } } void WorkingDir::removeWorkingDir() { - if (!m_Path.empty()) { - bool res = FileUtils::remove(m_Path, true); - MSG_LOG("Working dir remove with result = ", res); - } + if (!m_Path.empty()) { + bool res = FileUtils::remove(m_Path, true); + MSG_LOG("Working dir remove with result = ", res); + } } bool WorkingDir::isValid() const { - return !m_Path.empty() && FileUtils::isExists(m_Path); + return !m_Path.empty() && FileUtils::isExists(m_Path); } const std::string &WorkingDir::getPath() const { - return m_Path; + return m_Path; } std::string WorkingDir::genUniqueFilePath(const std::string &path) const { - std::lock_guard _lock(m_Mutex); - return FileUtils::genUniqueFilePath(m_Path, path); + std::lock_guard _lock(m_Mutex); + return FileUtils::genUniqueFilePath(m_Path, path); } std::string WorkingDir::addFile(const std::string &path) { - std::lock_guard _lock(m_Mutex); - std::string newPath; - - if (FileUtils::isExists(path)) { - if (path.find(m_Path) != std::string::npos) { - newPath = path; - MSG_LOG("File is already exists: ", newPath); - } else { - newPath = genUniqueFilePath(path); - if (FileUtils::copy(path, newPath)) { - MSG_LOG("File added: ", newPath); - } else { - MSG_LOG_ERROR("Can't copy to working dir: ", path); - newPath.clear(); - } - } - } - - return newPath; + std::lock_guard _lock(m_Mutex); + std::string newPath; + + if (FileUtils::isExists(path)) { + if (path.find(m_Path) != std::string::npos) { + newPath = path; + MSG_LOG("File is already exists: ", newPath); + } else { + newPath = genUniqueFilePath(path); + if (FileUtils::copy(path, newPath)) { + MSG_LOG("File added: ", newPath); + } else { + MSG_LOG_ERROR("Can't copy to working dir: ", path); + newPath.clear(); + } + } + } + + return newPath; } std::string WorkingDir::addTextFile(const std::string &text, const std::string &fileName) { - std::lock_guard _lock(m_Mutex); - std::string result; - result = fileName.empty() ? textFileName : fileName; - - std::string path = genUniqueFilePath(result); - std::ofstream file(path, std::ofstream::trunc | std::ofstream::binary | std::ofstream::out); - if (file.is_open()) { - file << text; - MSG_LOG("Text file added: ", path); - } else { - path.clear(); - } - - return path; + std::lock_guard _lock(m_Mutex); + std::string result; + result = fileName.empty() ? textFileName : fileName; + + std::string path = genUniqueFilePath(result); + std::ofstream file(path, std::ofstream::trunc | std::ofstream::binary | std::ofstream::out); + if (file.is_open()) { + file << text; + MSG_LOG("Text file added: ", path); + } else { + path.clear(); + } + + return path; } void WorkingDir::removeFile(const std::string &path) { - std::lock_guard _lock(m_Mutex); - if (!path.empty()) - FileUtils::remove(path); + std::lock_guard _lock(m_Mutex); + if (!path.empty()) + FileUtils::remove(path); } void WorkingDir::clear() { - std::lock_guard _lock(m_Mutex); - FileUtils::remove(m_Path, false); + std::lock_guard _lock(m_Mutex); + FileUtils::remove(m_Path, false); } std::string WorkingDir::getUniqueDirName(const std::string &path) { - std::string res; - unsigned i = 0; - do { - res = path + "-" + std::to_string(i); - ++i; - } while (FileUtils::isExists(res)); - return res; + std::string res; + unsigned i = 0; + do { + res = path + "-" + std::to_string(i); + ++i; + } while (FileUtils::isExists(res)); + return res; } diff --git a/src/MainApp/MainApp.cpp b/src/MainApp/MainApp.cpp index ee81b9b9..15c531b1 100644 --- a/src/MainApp/MainApp.cpp +++ b/src/MainApp/MainApp.cpp @@ -34,9 +34,9 @@ using namespace Msg; MainApp::MainApp() - : m_pWindow(nullptr) - , m_pRootController(nullptr) - , m_NeedToCloseApp(false) + : m_pWindow(nullptr) + , m_pRootController(nullptr) + , m_NeedToCloseApp(false) { } @@ -46,169 +46,169 @@ MainApp::~MainApp() int MainApp::start(int argc, char *argv[]) { - ui_app_lifecycle_callback_s cbs = {}; - - cbs.app_control = [](app_control_h app_control, void *user_data) - { - static_cast(user_data)->onAppControl(app_control); - }; - - cbs.create = [](void *user_data)->bool - { - return static_cast(user_data)->onAppCreate(); - }; - - cbs.pause = [](void *user_data) - { - static_cast(user_data)->onAppPause(); - }; - - cbs.resume = [](void *user_data) - { - static_cast(user_data)->onAppResume(); - }; - - cbs.terminate = [](void *user_data) - { - static_cast(user_data)->onAppTerminate(); - }; - - app_event_handler_h handlers[3] = {}; - ui_app_add_event_handler(&handlers[0], APP_EVENT_LOW_BATTERY, APP_EVENT_CALLBACK(MainApp, onLowBattery), this); - ui_app_add_event_handler(&handlers[1], APP_EVENT_LANGUAGE_CHANGED, APP_EVENT_CALLBACK(MainApp, onLanguageChanged), this); - ui_app_add_event_handler(&handlers[2], APP_EVENT_REGION_FORMAT_CHANGED, APP_EVENT_CALLBACK(MainApp, onRegionChanged), this); - - return ui_app_main(argc, argv, &cbs, this); + ui_app_lifecycle_callback_s cbs = {}; + + cbs.app_control = [](app_control_h app_control, void *user_data) + { + static_cast(user_data)->onAppControl(app_control); + }; + + cbs.create = [](void *user_data)->bool + { + return static_cast(user_data)->onAppCreate(); + }; + + cbs.pause = [](void *user_data) + { + static_cast(user_data)->onAppPause(); + }; + + cbs.resume = [](void *user_data) + { + static_cast(user_data)->onAppResume(); + }; + + cbs.terminate = [](void *user_data) + { + static_cast(user_data)->onAppTerminate(); + }; + + app_event_handler_h handlers[3] = {}; + ui_app_add_event_handler(&handlers[0], APP_EVENT_LOW_BATTERY, APP_EVENT_CALLBACK(MainApp, onLowBattery), this); + ui_app_add_event_handler(&handlers[1], APP_EVENT_LANGUAGE_CHANGED, APP_EVENT_CALLBACK(MainApp, onLanguageChanged), this); + ui_app_add_event_handler(&handlers[2], APP_EVENT_REGION_FORMAT_CHANGED, APP_EVENT_CALLBACK(MainApp, onRegionChanged), this); + + return ui_app_main(argc, argv, &cbs, this); } Window &MainApp::getWindow() { - MSG_ASSERT(m_pWindow, "Window is null"); - return *m_pWindow; + MSG_ASSERT(m_pWindow, "Window is null"); + return *m_pWindow; } const Window &MainApp::getWindow() const { - MSG_ASSERT(m_pWindow, "Window is null"); - return *m_pWindow; + MSG_ASSERT(m_pWindow, "Window is null"); + return *m_pWindow; } void MainApp::terminate() { - if (m_NeedToCloseApp) { - // Close app completely - ui_app_exit(); - } else if (m_pWindow) { - // Minimize window: - m_pWindow->lower(); - } + if (m_NeedToCloseApp) { + // Close app completely + ui_app_exit(); + } else if (m_pWindow) { + // Minimize window: + m_pWindow->lower(); + } } bool MainApp::onAppCreate() { - TRACE; - bool res = false; + TRACE; + bool res = false; - std::string localePath(PathUtils::getLocalePath()); - if (!localePath.empty()) - bindtextdomain(PROJECT_NAME, localePath.c_str()); + std::string localePath(PathUtils::getLocalePath()); + if (!localePath.empty()) + bindtextdomain(PROJECT_NAME, localePath.c_str()); - elm_app_base_scale_set(2.6); - elm_config_accel_preference_set("3d"); - feedback_initialize(); - updateCharacterOrientation(); + elm_app_base_scale_set(2.6); + elm_config_accel_preference_set("3d"); + feedback_initialize(); + updateCharacterOrientation(); - m_pWindow = new StandardWindow; - m_pWindow->show(); + m_pWindow = new StandardWindow; + m_pWindow->show(); - res = App::init(); + res = App::init(); - m_pRootController = new NaviFrameController(*this); - m_pWindow->setContent(*m_pRootController); + m_pRootController = new NaviFrameController(*this); + m_pWindow->setContent(*m_pRootController); - return res; + return res; } void MainApp::onAppTerminate() { - TRACE; - m_pRootController->destroy(); - m_pWindow->destroy(); - feedback_deinitialize(); + TRACE; + m_pRootController->destroy(); + m_pWindow->destroy(); + feedback_deinitialize(); } void MainApp::onAppPause() { - TRACE; - App::pause(); + TRACE; + App::pause(); } void MainApp::onAppResume() { - TRACE; - App::resume(); + TRACE; + App::resume(); } void MainApp::onAppControl(app_control_h app_control) { - TRACE; - AppControlCommandRef cmd = AppControlParser::parse(app_control); - if (!cmd) - return; - - app_control_launch_mode_e mode = APP_CONTROL_LAUNCH_MODE_SINGLE; - app_control_get_launch_mode(app_control, &mode); - m_NeedToCloseApp = (mode == APP_CONTROL_LAUNCH_MODE_GROUP); - - switch (cmd->getOperationType()) { - case AppControlCommand::OpDefault: - if (m_pRootController) - m_pRootController->execCmd(std::static_pointer_cast(cmd)); - break; - case AppControlCommand::OpComposeFamily: - if (m_pRootController) - m_pRootController->execCmd(std::static_pointer_cast(cmd)); - break; - case AppControlCommand::OpUnknown: - default: - MSG_LOG_WARN("Not supported command"); - break; - } + TRACE; + AppControlCommandRef cmd = AppControlParser::parse(app_control); + if (!cmd) + return; + + app_control_launch_mode_e mode = APP_CONTROL_LAUNCH_MODE_SINGLE; + app_control_get_launch_mode(app_control, &mode); + m_NeedToCloseApp = (mode == APP_CONTROL_LAUNCH_MODE_GROUP); + + switch (cmd->getOperationType()) { + case AppControlCommand::OpDefault: + if (m_pRootController) + m_pRootController->execCmd(std::static_pointer_cast(cmd)); + break; + case AppControlCommand::OpComposeFamily: + if (m_pRootController) + m_pRootController->execCmd(std::static_pointer_cast(cmd)); + break; + case AppControlCommand::OpUnknown: + default: + MSG_LOG_WARN("Not supported command"); + break; + } } void MainApp::onLanguageChanged(app_event_info_h appEvent) { - TRACE; - updateCharacterOrientation(); + TRACE; + updateCharacterOrientation(); } void MainApp::updateCharacterOrientation() { - char *lang = nullptr; - system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &lang); - if (lang) { - MSG_LOG("Language: ", lang); - elm_language_set(lang); - i18n_ulocale_layout_type_e layout = I18N_ULOCALE_LAYOUT_UNKNOWN; - if (i18n_ulocale_get_character_orientation(lang, &layout) == I18N_ERROR_NONE) { - if (layout == I18N_ULOCALE_LAYOUT_LTR) - elm_config_mirrored_set(false); - else if (layout == I18N_ULOCALE_LAYOUT_RTL) - elm_config_mirrored_set(true); - else - MSG_LOG_ERROR("Unsupported character orientation type: ", layout); - } - free(lang); - } + char *lang = nullptr; + system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &lang); + if (lang) { + MSG_LOG("Language: ", lang); + elm_language_set(lang); + i18n_ulocale_layout_type_e layout = I18N_ULOCALE_LAYOUT_UNKNOWN; + if (i18n_ulocale_get_character_orientation(lang, &layout) == I18N_ERROR_NONE) { + if (layout == I18N_ULOCALE_LAYOUT_LTR) + elm_config_mirrored_set(false); + else if (layout == I18N_ULOCALE_LAYOUT_RTL) + elm_config_mirrored_set(true); + else + MSG_LOG_ERROR("Unsupported character orientation type: ", layout); + } + free(lang); + } } void MainApp::onLowBattery(app_event_info_h appEvent) { - TRACE; + TRACE; } void MainApp::onRegionChanged(app_event_info_h appEvent) { - TRACE; + TRACE; } diff --git a/src/MainApp/MainApp.h b/src/MainApp/MainApp.h index c5c24ebf..25b9685f 100644 --- a/src/MainApp/MainApp.h +++ b/src/MainApp/MainApp.h @@ -24,39 +24,39 @@ #include namespace Msg { - class StandardWindow; - class NaviFrameController; - - class MainApp: - public App { - public: - MainApp(); - virtual ~MainApp(); - - int start(int argc, char *argv[]); - - virtual Window &getWindow(); - virtual const Window &getWindow() const; - - private: - virtual void terminate(); - void updateCharacterOrientation(); - - // App cbs: - bool onAppCreate(); - void onAppTerminate(); - void onAppPause(); - void onAppResume(); - void onAppControl(app_control_h app_control); - void onLanguageChanged(app_event_info_h appEvent); - void onLowBattery(app_event_info_h appEvent); - void onRegionChanged(app_event_info_h appEvent); - - private: - StandardWindow *m_pWindow; - NaviFrameController *m_pRootController; - bool m_NeedToCloseApp; - }; + class StandardWindow; + class NaviFrameController; + + class MainApp: + public App { + public: + MainApp(); + virtual ~MainApp(); + + int start(int argc, char *argv[]); + + virtual Window &getWindow(); + virtual const Window &getWindow() const; + + private: + virtual void terminate(); + void updateCharacterOrientation(); + + // App cbs: + bool onAppCreate(); + void onAppTerminate(); + void onAppPause(); + void onAppResume(); + void onAppControl(app_control_h app_control); + void onLanguageChanged(app_event_info_h appEvent); + void onLowBattery(app_event_info_h appEvent); + void onRegionChanged(app_event_info_h appEvent); + + private: + StandardWindow *m_pWindow; + NaviFrameController *m_pRootController; + bool m_NeedToCloseApp; + }; } #endif /* MainApp_h_ */ diff --git a/src/MainApp/main.cpp b/src/MainApp/main.cpp index bbc237b2..fd69850a 100644 --- a/src/MainApp/main.cpp +++ b/src/MainApp/main.cpp @@ -24,9 +24,9 @@ using namespace Msg; EXPORT_API int main(int argc, char *argv[]) { - std::cout << "Message start" << std::endl; // Test for entrance to the main function (use stdout) - TRACE; - MainApp app; - int ret = app.start(argc, argv); - return ret; + std::cout << "Message start" << std::endl; // Test for entrance to the main function (use stdout) + TRACE; + MainApp app; + int ret = app.start(argc, argv); + return ret; } diff --git a/src/MsgThread/Controller/inc/BaseThreadListItem.h b/src/MsgThread/Controller/inc/BaseThreadListItem.h index 464bae0b..4c61dd76 100644 --- a/src/MsgThread/Controller/inc/BaseThreadListItem.h +++ b/src/MsgThread/Controller/inc/BaseThreadListItem.h @@ -27,37 +27,37 @@ #include namespace Msg { - class BaseThreadListItem - : public ThreadListViewItem { - public: - BaseThreadListItem(App &app); - virtual ~BaseThreadListItem(); - - void updateThumbnailAndName(const MsgAddressList &addressList, bool decorateName); - void updateThumbnailAndName(const MsgThreadItem &threadItem, bool decorateName); - void updateName(const MsgAddress &address, int addressesCount, bool decorateName); - void updateName(const ContactAddress &address, int addressesCount, bool decorateName); - void updateName(const std::string &address, int addressesCount, bool decorateName); - void updateTime(time_t time); - void updateTime(); - void updateMessage(const MsgThreadItem &threadItem); - void updateMessage(const std::string &msg); - time_t getRawTime() const; - - protected: - // ThreadListViewItem: - virtual std::string getName(); - virtual std::string getMessage(); - virtual std::string getTime(); - virtual Evas_Object *getThumbnail(); - - App &m_App; - ThumbId m_ThumbId; - std::string m_Name; - std::string m_Message; - std::string m_Time; - time_t m_RawTime; - }; + class BaseThreadListItem + : public ThreadListViewItem { + public: + BaseThreadListItem(App &app); + virtual ~BaseThreadListItem(); + + void updateThumbnailAndName(const MsgAddressList &addressList, bool decorateName); + void updateThumbnailAndName(const MsgThreadItem &threadItem, bool decorateName); + void updateName(const MsgAddress &address, int addressesCount, bool decorateName); + void updateName(const ContactAddress &address, int addressesCount, bool decorateName); + void updateName(const std::string &address, int addressesCount, bool decorateName); + void updateTime(time_t time); + void updateTime(); + void updateMessage(const MsgThreadItem &threadItem); + void updateMessage(const std::string &msg); + time_t getRawTime() const; + + protected: + // ThreadListViewItem: + virtual std::string getName(); + virtual std::string getMessage(); + virtual std::string getTime(); + virtual Evas_Object *getThumbnail(); + + App &m_App; + ThumbId m_ThumbId; + std::string m_Name; + std::string m_Message; + std::string m_Time; + time_t m_RawTime; + }; } #endif // BaseThreadListItem_h_ diff --git a/src/MsgThread/Controller/inc/MsgSearchListItem.h b/src/MsgThread/Controller/inc/MsgSearchListItem.h index 0efe05dd..ec0a9edf 100644 --- a/src/MsgThread/Controller/inc/MsgSearchListItem.h +++ b/src/MsgThread/Controller/inc/MsgSearchListItem.h @@ -21,20 +21,20 @@ #include "Message.h" namespace Msg { - class MsgSearchListItem - : public BaseThreadListItem { - public: - MsgSearchListItem(App &app, const Message &msg, const std::string &searchWord); - virtual ~MsgSearchListItem(); + class MsgSearchListItem + : public BaseThreadListItem { + public: + MsgSearchListItem(App &app, const Message &msg, const std::string &searchWord); + virtual ~MsgSearchListItem(); - MsgId getMsgId() const; + MsgId getMsgId() const; - private: - void update(const Message &msg, const std::string &searchWord); + private: + void update(const Message &msg, const std::string &searchWord); - private: - MsgId m_MsgId; - }; + private: + MsgId m_MsgId; + }; } #endif // MsgSearchListItem_h_ diff --git a/src/MsgThread/Controller/inc/MsgThread.h b/src/MsgThread/Controller/inc/MsgThread.h index eff7be55..34dc9772 100644 --- a/src/MsgThread/Controller/inc/MsgThread.h +++ b/src/MsgThread/Controller/inc/MsgThread.h @@ -34,94 +34,94 @@ #include namespace Msg { - class SelectAllListItem; - class NaviFrameController; - class ThreadListItem; - class App; - - class MsgThread - : public FrameController - , private IHwButtonListener - , private IMsgThreadSearchPanelListener - , private IFloatingButtonListener - , private IThreadListListener - , private IThreadSearchListListener - , private ISystemSettingsManager { - public: - MsgThread(NaviFrameController &parent); - virtual ~MsgThread(); - - private: - // NaviFrameItem: - virtual void onAttached(ViewItem &item); - virtual void onButtonClicked(NaviFrameItem &item, NaviButtonId buttonId); - - // IHwButtonListener: - virtual void onHwBackButtonClicked(); - virtual void onHwMoreButtonClicked(); - - // Popup callbacks: - void onSettingsItemPressed(PopupListItem &item); - void onDeleteItemPressed(PopupListItem &item); - void onSearchItemPressed(PopupListItem &item); - - // IMsgThreadSearchPanelListener: - virtual void onSearchButtonClicked(MsgThreadSearchPanel &obj); - virtual void onEntryChanged(MsgThreadSearchPanel &obj); - - // IFloatingButtonListener - virtual void onFloatingButtonPressed(); - - // IThreadListListener: - virtual void onListItemSelected(ThreadId id); - virtual void onThreadListChanged(); - virtual void onThreadListItemChecked(); - - // ThreadSearchList: - virtual void onSearchListChanged(); - virtual void onSearchListItemSelected(ThreadId id); - virtual void onSearchListItemSelected(MsgId id, const std::string &searchWord); - - // ISystemSettingsManager: - virtual void onLanguageChanged(); - - private: - enum Mode { - InitMode, - DeleteMode, - NormalMode, - SearchMode - }; - - private: - // MsgThread: - void composeNewMessage(); - void navigateToSettings(); - void navigateToConversation(ThreadId threadId, MsgId msgId = MsgId(), const std::string &searchWord = std::string()); - void showMainPopup(); - void setMode(Mode mode); - void setDeleteMode(bool value); - void setNormalMode(); - void update(); - void updateSelectItemsTitle(); - void search(const std::string &searchWord); - - // Search: - void prepareSearchPanel(); - void prepareSearchList(); - void prepareNoContentLayout(); - void prepareThreadList(); - void setSearchMode(bool value); - - private: - MsgThreadLayout *m_pLayout; - NoContentLayout *m_pNoContent; - ThreadList *m_pThreadList; - ThreadSearchList *m_pSearchList; - MsgThreadSearchPanel *m_pSearchPanel; - Mode m_Mode; - FloatingButton *m_pFloatingBtn; - }; + class SelectAllListItem; + class NaviFrameController; + class ThreadListItem; + class App; + + class MsgThread + : public FrameController + , private IHwButtonListener + , private IMsgThreadSearchPanelListener + , private IFloatingButtonListener + , private IThreadListListener + , private IThreadSearchListListener + , private ISystemSettingsManager { + public: + MsgThread(NaviFrameController &parent); + virtual ~MsgThread(); + + private: + // NaviFrameItem: + virtual void onAttached(ViewItem &item); + virtual void onButtonClicked(NaviFrameItem &item, NaviButtonId buttonId); + + // IHwButtonListener: + virtual void onHwBackButtonClicked(); + virtual void onHwMoreButtonClicked(); + + // Popup callbacks: + void onSettingsItemPressed(PopupListItem &item); + void onDeleteItemPressed(PopupListItem &item); + void onSearchItemPressed(PopupListItem &item); + + // IMsgThreadSearchPanelListener: + virtual void onSearchButtonClicked(MsgThreadSearchPanel &obj); + virtual void onEntryChanged(MsgThreadSearchPanel &obj); + + // IFloatingButtonListener + virtual void onFloatingButtonPressed(); + + // IThreadListListener: + virtual void onListItemSelected(ThreadId id); + virtual void onThreadListChanged(); + virtual void onThreadListItemChecked(); + + // ThreadSearchList: + virtual void onSearchListChanged(); + virtual void onSearchListItemSelected(ThreadId id); + virtual void onSearchListItemSelected(MsgId id, const std::string &searchWord); + + // ISystemSettingsManager: + virtual void onLanguageChanged(); + + private: + enum Mode { + InitMode, + DeleteMode, + NormalMode, + SearchMode + }; + + private: + // MsgThread: + void composeNewMessage(); + void navigateToSettings(); + void navigateToConversation(ThreadId threadId, MsgId msgId = MsgId(), const std::string &searchWord = std::string()); + void showMainPopup(); + void setMode(Mode mode); + void setDeleteMode(bool value); + void setNormalMode(); + void update(); + void updateSelectItemsTitle(); + void search(const std::string &searchWord); + + // Search: + void prepareSearchPanel(); + void prepareSearchList(); + void prepareNoContentLayout(); + void prepareThreadList(); + void setSearchMode(bool value); + + private: + MsgThreadLayout *m_pLayout; + NoContentLayout *m_pNoContent; + ThreadList *m_pThreadList; + ThreadSearchList *m_pSearchList; + MsgThreadSearchPanel *m_pSearchPanel; + Mode m_Mode; + FloatingButton *m_pFloatingBtn; + }; } #endif /* ThreadFrame_h_ */ diff --git a/src/MsgThread/Controller/inc/ThreadList.h b/src/MsgThread/Controller/inc/ThreadList.h index f07eec73..f405216a 100644 --- a/src/MsgThread/Controller/inc/ThreadList.h +++ b/src/MsgThread/Controller/inc/ThreadList.h @@ -25,74 +25,74 @@ #include namespace Msg { - class IThreadListListener; - class SelectAllListItem; - class ThreadListItem; - class App; + class IThreadListListener; + class SelectAllListItem; + class ThreadListItem; + class App; - class ThreadList - : public ListView - , private IMsgStorageListener - , private IListViewListener - , private IContactManagerListener - , private ISystemSettingsManager { - public: - ThreadList(Evas_Object *parent, App &app); - virtual ~ThreadList(); + class ThreadList + : public ListView + , private IMsgStorageListener + , private IListViewListener + , private IContactManagerListener + , private ISystemSettingsManager { + public: + ThreadList(Evas_Object *parent, App &app); + virtual ~ThreadList(); - void setListener(IThreadListListener *l); - void setDeleteMode(bool value); - bool isDeleteModeEnabled() const; - void deleteSelectedItems(); - int getThreadsCheckedCount() const; + void setListener(IThreadListListener *l); + void setDeleteMode(bool value); + bool isDeleteModeEnabled() const; + void deleteSelectedItems(); + int getThreadsCheckedCount() const; - private: - // IMsgStorageListener: - virtual void onMsgStorageThreadUpdate(const ThreadId &threadId); - virtual void onMsgStorageThreadInsert(const ThreadId &threadId); - virtual void onMsgStorageThreadDelete(const ThreadId &threadId); + private: + // IMsgStorageListener: + virtual void onMsgStorageThreadUpdate(const ThreadId &threadId); + virtual void onMsgStorageThreadInsert(const ThreadId &threadId); + virtual void onMsgStorageThreadDelete(const ThreadId &threadId); - // IContactManagerListener: - virtual void onContactChanged(); + // IContactManagerListener: + virtual void onContactChanged(); - // IListViewListener: - virtual void onListItemSelected(ListItem &listItem); - virtual void onListItemChecked(ListItem &listItem); + // IListViewListener: + virtual void onListItemSelected(ListItem &listItem); + virtual void onListItemChecked(ListItem &listItem); - // ISystemSettingsManager: - virtual void onTimeFormatChanged(); - virtual void onLanguageChanged(); + // ISystemSettingsManager: + virtual void onTimeFormatChanged(); + virtual void onLanguageChanged(); - private: - void showSelectAllItem(bool show, bool resetCheck = true); - void checkHandler(SelectAllListItem &item); - void checkHandler(ThreadListItem &item); - void fillList(); - void deleteItems(); - void updateItems(const MsgIdList &idList); - void updateItems(); - void updateItem(ThreadListItem &item); - void insertItem(ThreadId id); - void navigateTo(ThreadListItem &item); - ThreadListItem *getItem(ThreadId id) const; - bool isAllThreadListItemChecked() const; - void updateSelectAllItem(); - std::set getThreadIdSet(const MsgIdList &idList); - static int cmpFunc(const ListItem &item1, const ListItem &item2); + private: + void showSelectAllItem(bool show, bool resetCheck = true); + void checkHandler(SelectAllListItem &item); + void checkHandler(ThreadListItem &item); + void fillList(); + void deleteItems(); + void updateItems(const MsgIdList &idList); + void updateItems(); + void updateItem(ThreadListItem &item); + void insertItem(ThreadId id); + void navigateTo(ThreadListItem &item); + ThreadListItem *getItem(ThreadId id) const; + bool isAllThreadListItemChecked() const; + void updateSelectAllItem(); + std::set getThreadIdSet(const MsgIdList &idList); + static int cmpFunc(const ListItem &item1, const ListItem &item2); - private: - IThreadListListener *m_pListener; - App &m_App; - bool m_DeleteMode; - }; + private: + IThreadListListener *m_pListener; + App &m_App; + bool m_DeleteMode; + }; - class IThreadListListener { - public: - virtual ~IThreadListListener() {} - virtual void onListItemSelected(ThreadId id) {}; - virtual void onThreadListChanged() {} - virtual void onThreadListItemChecked() {} - }; + class IThreadListListener { + public: + virtual ~IThreadListListener() {} + virtual void onListItemSelected(ThreadId id) {}; + virtual void onThreadListChanged() {} + virtual void onThreadListItemChecked() {} + }; } #endif // ThreadList_h_ diff --git a/src/MsgThread/Controller/inc/ThreadListItem.h b/src/MsgThread/Controller/inc/ThreadListItem.h index cebbceb5..0de1cfc4 100644 --- a/src/MsgThread/Controller/inc/ThreadListItem.h +++ b/src/MsgThread/Controller/inc/ThreadListItem.h @@ -25,25 +25,25 @@ #include "App.h" namespace Msg { - class ThreadListItem - : public BaseThreadListItem { - public: - ThreadListItem(const MsgThreadItem &threadItem, App &app); - virtual ~ThreadListItem(); + class ThreadListItem + : public BaseThreadListItem { + public: + ThreadListItem(const MsgThreadItem &threadItem, App &app); + virtual ~ThreadListItem(); - ThreadId getThreadId() const; - void update(const MsgThreadItem &threadItem, bool updateUi); + ThreadId getThreadId() const; + void update(const MsgThreadItem &threadItem, bool updateUi); - private: - // ThreadListViewItem: - virtual std::string getStatus(); - virtual Evas_Object *getIcon(); + private: + // ThreadListViewItem: + virtual std::string getStatus(); + virtual Evas_Object *getIcon(); - private: - ThreadId m_ThreadId; - std::string m_Status; - std::string m_UnreadCount; - }; + private: + ThreadId m_ThreadId; + std::string m_Status; + std::string m_UnreadCount; + }; } #endif // ThreadListItem_h_ diff --git a/src/MsgThread/Controller/inc/ThreadSearchList.h b/src/MsgThread/Controller/inc/ThreadSearchList.h index 546ecba4..d549acdc 100644 --- a/src/MsgThread/Controller/inc/ThreadSearchList.h +++ b/src/MsgThread/Controller/inc/ThreadSearchList.h @@ -25,56 +25,56 @@ #include namespace Msg { - class IThreadSearchListListener; + class IThreadSearchListListener; - class ThreadSearchList - : public ListView - , private IListViewListener - , private IContactManagerListener - , private ISystemSettingsManager - , private IMsgStorageListener { - public: - ThreadSearchList(Evas_Object *parent, App &app); - virtual ~ThreadSearchList(); + class ThreadSearchList + : public ListView + , private IListViewListener + , private IContactManagerListener + , private ISystemSettingsManager + , private IMsgStorageListener { + public: + ThreadSearchList(Evas_Object *parent, App &app); + virtual ~ThreadSearchList(); - void setListener(IThreadSearchListListener *l); - void requestSearch(const std::string &searchWord); - void cancelSearch(); - const std::string &getSearchWord() const; + void setListener(IThreadSearchListListener *l); + void requestSearch(const std::string &searchWord); + void cancelSearch(); + const std::string &getSearchWord() const; - private: - // IListViewListener: - virtual void onListItemSelected(ListItem &listItem); + private: + // IListViewListener: + virtual void onListItemSelected(ListItem &listItem); - // IContactManagerListener: - virtual void onContactChanged(); + // IContactManagerListener: + virtual void onContactChanged(); - // ISystemSettingsManager: - virtual void onTimeFormatChanged(); - virtual void onLanguageChanged(); + // ISystemSettingsManager: + virtual void onTimeFormatChanged(); + virtual void onLanguageChanged(); - // IMsgStorageListener: - virtual void onMsgStorageUpdate(const MsgIdList &msgIdList); - virtual void onMsgStorageInsert(const MsgIdList &msgIdList); - virtual void onMsgStorageDelete(const MsgIdList &msgIdList); + // IMsgStorageListener: + virtual void onMsgStorageUpdate(const MsgIdList &msgIdList); + virtual void onMsgStorageInsert(const MsgIdList &msgIdList); + virtual void onMsgStorageDelete(const MsgIdList &msgIdList); - void search(); - void updateTime(); + void search(); + void updateTime(); - private: - App &m_App; - Ecore_Idler *m_pIdler; - std::string m_SearchWord; - IThreadSearchListListener *m_pListener; - }; + private: + App &m_App; + Ecore_Idler *m_pIdler; + std::string m_SearchWord; + IThreadSearchListListener *m_pListener; + }; - class IThreadSearchListListener { - public: - virtual ~IThreadSearchListListener() {} - virtual void onSearchListChanged() {}; - virtual void onSearchListItemSelected(ThreadId id) {}; - virtual void onSearchListItemSelected(MsgId id, const std::string &searchWord) {}; - }; + class IThreadSearchListListener { + public: + virtual ~IThreadSearchListListener() {} + virtual void onSearchListChanged() {}; + virtual void onSearchListItemSelected(ThreadId id) {}; + virtual void onSearchListItemSelected(MsgId id, const std::string &searchWord) {}; + }; } #endif // ThreadSearchList_h_ diff --git a/src/MsgThread/Controller/inc/ThreadSearchListItem.h b/src/MsgThread/Controller/inc/ThreadSearchListItem.h index 6822a555..1d24b664 100644 --- a/src/MsgThread/Controller/inc/ThreadSearchListItem.h +++ b/src/MsgThread/Controller/inc/ThreadSearchListItem.h @@ -22,20 +22,20 @@ #include "MsgTypes.h" namespace Msg { - class ThreadSearchListItem - : public BaseThreadListItem { - public: - ThreadSearchListItem(App &app, const MsgThreadItem &item, const std::string &searchWord); - virtual ~ThreadSearchListItem(); + class ThreadSearchListItem + : public BaseThreadListItem { + public: + ThreadSearchListItem(App &app, const MsgThreadItem &item, const std::string &searchWord); + virtual ~ThreadSearchListItem(); - ThreadId getThreadId() const; + ThreadId getThreadId() const; - private: - void update(const MsgThreadItem &item, const std::string &searchWord); + private: + void update(const MsgThreadItem &item, const std::string &searchWord); - private: - ThreadId m_ThreadId; - }; + private: + ThreadId m_ThreadId; + }; } #endif // ThreadSearchListItem_h_ diff --git a/src/MsgThread/Controller/src/BaseThreadListItem.cpp b/src/MsgThread/Controller/src/BaseThreadListItem.cpp index c8a9caf2..db804247 100644 --- a/src/MsgThread/Controller/src/BaseThreadListItem.cpp +++ b/src/MsgThread/Controller/src/BaseThreadListItem.cpp @@ -24,9 +24,9 @@ using namespace Msg; BaseThreadListItem::BaseThreadListItem(App &app) - : m_App(app) - , m_ThumbId(m_App.getThumbnailMaker().getThumbId(ThumbnailMaker::SingleThumb)) - , m_RawTime() + : m_App(app) + , m_ThumbId(m_App.getThumbnailMaker().getThumbId(ThumbnailMaker::SingleThumb)) + , m_RawTime() { } @@ -36,100 +36,100 @@ BaseThreadListItem::~BaseThreadListItem() void BaseThreadListItem::updateMessage(const MsgThreadItem &threadItem) { - updateMessage(threadItem.getLastMessage()); + updateMessage(threadItem.getLastMessage()); } void BaseThreadListItem::updateMessage(const std::string &msg) { - m_Message = decorateMessageText(msg); + m_Message = decorateMessageText(msg); } void BaseThreadListItem::updateThumbnailAndName(const MsgThreadItem &threadItem, bool decorateName) { - const MsgAddressListRef addressList = m_App.getMsgEngine().getStorage().getAddressList(threadItem.getId()); - if (addressList) - updateThumbnailAndName(*addressList, decorateName); + const MsgAddressListRef addressList = m_App.getMsgEngine().getStorage().getAddressList(threadItem.getId()); + if (addressList) + updateThumbnailAndName(*addressList, decorateName); } void BaseThreadListItem::updateThumbnailAndName(const MsgAddressList &addressList, bool decorateName) { - int countContact = addressList.getLength(); - if (countContact <= 0) { - MSG_LOG_WARN("Msg address list is empty"); - return; - } + int countContact = addressList.getLength(); + if (countContact <= 0) { + MSG_LOG_WARN("Msg address list is empty"); + return; + } - const MsgAddress &addr = addressList[0]; + const MsgAddress &addr = addressList[0]; - if (countContact > 1) { - m_ThumbId = m_App.getThumbnailMaker().getThumbId(ThumbnailMaker::GroupThumb); - updateName(addr, countContact, decorateName); - } else if (countContact == 1) { - m_ThumbId = m_App.getThumbnailMaker().getThumbId(addr); - updateName(addr, countContact, decorateName); - } + if (countContact > 1) { + m_ThumbId = m_App.getThumbnailMaker().getThumbId(ThumbnailMaker::GroupThumb); + updateName(addr, countContact, decorateName); + } else if (countContact == 1) { + m_ThumbId = m_App.getThumbnailMaker().getThumbId(addr); + updateName(addr, countContact, decorateName); + } } void BaseThreadListItem::updateName(const MsgAddress &address, int addressesCount, bool decorateName) { - ContactAddressRef contactAddress = m_App.getContactManager().getContactAddress(address.getAddress()); - if (contactAddress) - updateName(*contactAddress, addressesCount, decorateName); - else - updateName(address.getAddress(), addressesCount, decorateName); + ContactAddressRef contactAddress = m_App.getContactManager().getContactAddress(address.getAddress()); + if (contactAddress) + updateName(*contactAddress, addressesCount, decorateName); + else + updateName(address.getAddress(), addressesCount, decorateName); } void BaseThreadListItem::updateName(const ContactAddress &address, int addressesCount, bool decorateName) { - std::string dispName = address.getDispName(); - if (dispName.empty()) - dispName = address.getAddress(); - updateName(dispName, addressesCount, decorateName); + std::string dispName = address.getDispName(); + if (dispName.empty()) + dispName = address.getAddress(); + updateName(dispName, addressesCount, decorateName); } void BaseThreadListItem::updateName(const std::string &address, int addressesCount, bool decorateName) { - m_Name = address; - --addressesCount; - if (addressesCount > 0) - m_Name += " +" + std::to_string(addressesCount); - if (decorateName) - m_Name = decorateNameText(m_Name); + m_Name = address; + --addressesCount; + if (addressesCount > 0) + m_Name += " +" + std::to_string(addressesCount); + if (decorateName) + m_Name = decorateNameText(m_Name); } void BaseThreadListItem::updateTime(time_t time) { - m_RawTime = time; - m_Time = TimeUtils::makeThreadTimeString(time); + m_RawTime = time; + m_Time = TimeUtils::makeThreadTimeString(time); } void BaseThreadListItem::updateTime() { - m_Time = TimeUtils::makeThreadTimeString(m_RawTime); + m_Time = TimeUtils::makeThreadTimeString(m_RawTime); } std::string BaseThreadListItem::getName() { - return m_Name; + return m_Name; } std::string BaseThreadListItem::getMessage() { - return m_Message; + return m_Message; } std::string BaseThreadListItem::getTime() { - return m_Time; + return m_Time; } Evas_Object *BaseThreadListItem::getThumbnail() { - static const int thumbSize = 98; - return m_App.getThumbnailMaker().getThumb(*getOwner(), m_ThumbId, thumbSize); + static const int thumbSize = 98; + return m_App.getThumbnailMaker().getThumb(*getOwner(), m_ThumbId, thumbSize); } time_t BaseThreadListItem::getRawTime() const { - return m_RawTime; + return m_RawTime; } diff --git a/src/MsgThread/Controller/src/MsgSearchListItem.cpp b/src/MsgThread/Controller/src/MsgSearchListItem.cpp index 0e714216..8b53b72a 100644 --- a/src/MsgThread/Controller/src/MsgSearchListItem.cpp +++ b/src/MsgThread/Controller/src/MsgSearchListItem.cpp @@ -21,11 +21,11 @@ using namespace Msg; MsgSearchListItem::MsgSearchListItem(App &app, const Message &msg, const std::string &searchWord) - : BaseThreadListItem(app) - , m_MsgId(msg.getId()) + : BaseThreadListItem(app) + , m_MsgId(msg.getId()) { - setState(NormalState, false); - update(msg, searchWord); + setState(NormalState, false); + update(msg, searchWord); } MsgSearchListItem::~MsgSearchListItem() @@ -34,13 +34,13 @@ MsgSearchListItem::~MsgSearchListItem() MsgId MsgSearchListItem::getMsgId() const { - return m_MsgId; + return m_MsgId; } void MsgSearchListItem::update(const Message &msg, const std::string &searchWord) { - m_MsgId = msg.getId(); - updateMessage(TextDecorator::highlightKeyword(msg.getText(), searchWord)); - updateThumbnailAndName(msg.getAddressList(), true); - updateTime(msg.getTime()); + m_MsgId = msg.getId(); + updateMessage(TextDecorator::highlightKeyword(msg.getText(), searchWord)); + updateThumbnailAndName(msg.getAddressList(), true); + updateTime(msg.getTime()); } diff --git a/src/MsgThread/Controller/src/MsgThread.cpp b/src/MsgThread/Controller/src/MsgThread.cpp index 45578b79..56d67674 100644 --- a/src/MsgThread/Controller/src/MsgThread.cpp +++ b/src/MsgThread/Controller/src/MsgThread.cpp @@ -24,351 +24,351 @@ using namespace Msg; MsgThread::MsgThread(NaviFrameController &parent) - : FrameController(parent) - , m_pLayout(nullptr) - , m_pNoContent(nullptr) - , m_pThreadList(nullptr) - , m_pSearchList(nullptr) - , m_pSearchPanel(nullptr) - , m_Mode(InitMode) - , m_pFloatingBtn(nullptr) + : FrameController(parent) + , m_pLayout(nullptr) + , m_pNoContent(nullptr) + , m_pThreadList(nullptr) + , m_pSearchList(nullptr) + , m_pSearchPanel(nullptr) + , m_Mode(InitMode) + , m_pFloatingBtn(nullptr) { - m_pLayout = new MsgThreadLayout(getParent()); - m_pLayout->show(); + m_pLayout = new MsgThreadLayout(getParent()); + m_pLayout->show(); - m_pFloatingBtn = new FloatingButton(*m_pLayout); - m_pFloatingBtn->show(); - m_pFloatingBtn->setListener(this); - m_pLayout->setFloatingButton(*m_pFloatingBtn); + m_pFloatingBtn = new FloatingButton(*m_pLayout); + m_pFloatingBtn->show(); + m_pFloatingBtn->setListener(this); + m_pLayout->setFloatingButton(*m_pFloatingBtn); - prepareThreadList(); - prepareNoContentLayout(); + prepareThreadList(); + prepareNoContentLayout(); - getApp().getSysSettingsManager().addListener(*this); - setMode(NormalMode); + getApp().getSysSettingsManager().addListener(*this); + setMode(NormalMode); } MsgThread::~MsgThread() { - getApp().getSysSettingsManager().removeListener(*this); + getApp().getSysSettingsManager().removeListener(*this); } void MsgThread::prepareSearchPanel() { - if (!m_pSearchPanel) { - m_pSearchPanel = new MsgThreadSearchPanel(*m_pLayout); - m_pSearchPanel->setListener(this); - getNaviBar().setSearch(*m_pSearchPanel); - } + if (!m_pSearchPanel) { + m_pSearchPanel = new MsgThreadSearchPanel(*m_pLayout); + m_pSearchPanel->setListener(this); + getNaviBar().setSearch(*m_pSearchPanel); + } } void MsgThread::prepareSearchList() { - if (!m_pSearchList) { - m_pSearchList = new ThreadSearchList(*m_pLayout, getApp()); - m_pSearchList->setListener(this); - m_pSearchList->show(); - m_pLayout->setSearchList(*m_pSearchList); - } + if (!m_pSearchList) { + m_pSearchList = new ThreadSearchList(*m_pLayout, getApp()); + m_pSearchList->setListener(this); + m_pSearchList->show(); + m_pLayout->setSearchList(*m_pSearchList); + } } void MsgThread::prepareNoContentLayout() { - if (!m_pNoContent) { - m_pNoContent = new NoContentLayout(*m_pLayout); - m_pNoContent->show(); - m_pLayout->setNoContent(*m_pNoContent); - } + if (!m_pNoContent) { + m_pNoContent = new NoContentLayout(*m_pLayout); + m_pNoContent->show(); + m_pLayout->setNoContent(*m_pNoContent); + } } void MsgThread::prepareThreadList() { - if (!m_pThreadList) { - m_pThreadList = new ThreadList(*m_pLayout, getApp()); - m_pThreadList->setListener(this); - m_pThreadList->show(); - m_pLayout->setList(*m_pThreadList); - } + if (!m_pThreadList) { + m_pThreadList = new ThreadList(*m_pLayout, getApp()); + m_pThreadList->setListener(this); + m_pThreadList->show(); + m_pLayout->setList(*m_pThreadList); + } } void MsgThread::onAttached(ViewItem &item) { - FrameController::onAttached(item); - getNaviBar().setColor(NaviBar::NaviBlueColorId); - setHwButtonListener(*m_pLayout, this); - setContent(*m_pLayout); + FrameController::onAttached(item); + getNaviBar().setColor(NaviBar::NaviBlueColorId); + setHwButtonListener(*m_pLayout, this); + setContent(*m_pLayout); } void MsgThread::showMainPopup() { - PopupList &popup = getApp().getPopupManager().getMorePopup(); - if (!m_pThreadList->isEmpty()) { - popup.appendItem(msg("IDS_MSG_OPT_DELETE"), POPUPLIST_ITEM_PRESSED_CB(MsgThread, onDeleteItemPressed), this); - popup.appendItem(msg("IDS_MSG_OPT_SEARCH"), POPUPLIST_ITEM_PRESSED_CB(MsgThread, onSearchItemPressed), this); - } - popup.appendItem(msg("IDS_MSG_OPT_SETTINGS"), POPUPLIST_ITEM_PRESSED_CB(MsgThread, onSettingsItemPressed), this); - popup.show(); + PopupList &popup = getApp().getPopupManager().getMorePopup(); + if (!m_pThreadList->isEmpty()) { + popup.appendItem(msg("IDS_MSG_OPT_DELETE"), POPUPLIST_ITEM_PRESSED_CB(MsgThread, onDeleteItemPressed), this); + popup.appendItem(msg("IDS_MSG_OPT_SEARCH"), POPUPLIST_ITEM_PRESSED_CB(MsgThread, onSearchItemPressed), this); + } + popup.appendItem(msg("IDS_MSG_OPT_SETTINGS"), POPUPLIST_ITEM_PRESSED_CB(MsgThread, onSettingsItemPressed), this); + popup.show(); } void MsgThread::composeNewMessage() { - Conversation *frame = new Conversation(getParent()); - getParent().push(*frame); - frame->setThreadId(ThreadId()); + Conversation *frame = new Conversation(getParent()); + getParent().push(*frame); + frame->setThreadId(ThreadId()); } void MsgThread::navigateToSettings() { - Settings *frame = new Settings(getParent()); - getParent().push(*frame); + Settings *frame = new Settings(getParent()); + getParent().push(*frame); } void MsgThread::navigateToConversation(ThreadId threadId, MsgId msgId, const std::string &searchWord) { - Conversation *frame = new Conversation(getParent()); - frame->setThreadId(threadId, searchWord.c_str()); - if (msgId.isValid()) - frame->navigateTo(msgId); - else - frame->navigateToBottom(); - getParent().push(*frame); + Conversation *frame = new Conversation(getParent()); + frame->setThreadId(threadId, searchWord.c_str()); + if (msgId.isValid()) + frame->navigateTo(msgId); + else + frame->navigateToBottom(); + getParent().push(*frame); } void MsgThread::setMode(Mode mode) { - if (m_Mode == mode) - return; - - NaviBar::NaviColorId colorId = mode == SearchMode ? NaviBar::NaviWhiteColorId : NaviBar::NaviBlueColorId; - getNaviBar().setColor(colorId); - setNormalMode(); - - switch (mode) { - case NormalMode: - break; - case SearchMode: - setSearchMode(true); - break; - case DeleteMode: - setDeleteMode(true); - break; - case InitMode: - default: - MSG_ASSERT(false, "Not supported mode"); - break; - } + if (m_Mode == mode) + return; + + NaviBar::NaviColorId colorId = mode == SearchMode ? NaviBar::NaviWhiteColorId : NaviBar::NaviBlueColorId; + getNaviBar().setColor(colorId); + setNormalMode(); + + switch (mode) { + case NormalMode: + break; + case SearchMode: + setSearchMode(true); + break; + case DeleteMode: + setDeleteMode(true); + break; + case InitMode: + default: + MSG_ASSERT(false, "Not supported mode"); + break; + } } void MsgThread::setNormalMode() { - MSG_LOG(""); - getNaviBar().clear(); - // Reset previus mode: - switch (m_Mode) { - case DeleteMode: - setDeleteMode(false); - break; - case SearchMode: - setSearchMode(false); - break; - default: - break; - } - - m_pLayout->showFloatingButton(true); - getNaviBar().setTitle(msgt("IDS_MSG_HEADER_MESSAGES")); - m_pNoContent->setText(msgt("IDS_MSG_NPBODY_NO_MESSAGES")); - m_pNoContent->setHelpText(msgt("IDS_MSG_BODY_AFTER_YOU_SEND_OR_RECEIVE_MESSAGES_THEY_WILL_BE_SHOWN_HERE")); - m_Mode = NormalMode; - update(); + MSG_LOG(""); + getNaviBar().clear(); + // Reset previus mode: + switch (m_Mode) { + case DeleteMode: + setDeleteMode(false); + break; + case SearchMode: + setSearchMode(false); + break; + default: + break; + } + + m_pLayout->showFloatingButton(true); + getNaviBar().setTitle(msgt("IDS_MSG_HEADER_MESSAGES")); + m_pNoContent->setText(msgt("IDS_MSG_NPBODY_NO_MESSAGES")); + m_pNoContent->setHelpText(msgt("IDS_MSG_BODY_AFTER_YOU_SEND_OR_RECEIVE_MESSAGES_THEY_WILL_BE_SHOWN_HERE")); + m_Mode = NormalMode; + update(); } void MsgThread::setDeleteMode(bool value) { - MSG_LOG(""); + MSG_LOG(""); - if (value) - m_Mode = DeleteMode; + if (value) + m_Mode = DeleteMode; - NaviBar &naviBar = getNaviBar(); + NaviBar &naviBar = getNaviBar(); - naviBar.showButton(NaviOkButtonId, value); - if (value) { - m_pLayout->showFloatingButton(false); - updateSelectItemsTitle(); - naviBar.setButtonText(NaviOkButtonId, msgt("IDS_MSG_ACBUTTON_DELETE_ABB")); - naviBar.disabledButton(NaviOkButtonId, value); - } - naviBar.showButton(NaviCancelButtonId, value); - m_pThreadList->setDeleteMode(value); + naviBar.showButton(NaviOkButtonId, value); + if (value) { + m_pLayout->showFloatingButton(false); + updateSelectItemsTitle(); + naviBar.setButtonText(NaviOkButtonId, msgt("IDS_MSG_ACBUTTON_DELETE_ABB")); + naviBar.disabledButton(NaviOkButtonId, value); + } + naviBar.showButton(NaviCancelButtonId, value); + m_pThreadList->setDeleteMode(value); } void MsgThread::setSearchMode(bool value) { - MSG_LOG(""); - - getNaviBar().showButton(NaviPrevButtonId, value); - if (value) { - m_pLayout->showFloatingButton(false); - prepareSearchList(); - prepareSearchPanel(); - m_Mode = SearchMode; - m_pSearchPanel->clearEntry(); - m_pSearchList->clear(); - getNaviBar().showSearch(); - m_pNoContent->setText(msgt("IDS_MSG_NPBODY_NO_RESULTS_FOUND_ABB")); - m_pNoContent->setHelpText(); - } else { - if (m_pSearchList) - m_pSearchList->cancelSearch(); - getNaviBar().hideSearch(); - } - - update(); - if (m_pSearchPanel) - m_pSearchPanel->setEntryFocus(value); + MSG_LOG(""); + + getNaviBar().showButton(NaviPrevButtonId, value); + if (value) { + m_pLayout->showFloatingButton(false); + prepareSearchList(); + prepareSearchPanel(); + m_Mode = SearchMode; + m_pSearchPanel->clearEntry(); + m_pSearchList->clear(); + getNaviBar().showSearch(); + m_pNoContent->setText(msgt("IDS_MSG_NPBODY_NO_RESULTS_FOUND_ABB")); + m_pNoContent->setHelpText(); + } else { + if (m_pSearchList) + m_pSearchList->cancelSearch(); + getNaviBar().hideSearch(); + } + + update(); + if (m_pSearchPanel) + m_pSearchPanel->setEntryFocus(value); } void MsgThread::update() { - bool searchEnabled = m_Mode == SearchMode; - if (searchEnabled) { - bool showSearch = !m_pSearchList->isEmpty(); - bool showThread = !showSearch && !m_pThreadList->isEmpty() && m_pSearchList->getSearchWord().empty(); - bool showNoContent = !showThread && !showSearch; + bool searchEnabled = m_Mode == SearchMode; + if (searchEnabled) { + bool showSearch = !m_pSearchList->isEmpty(); + bool showThread = !showSearch && !m_pThreadList->isEmpty() && m_pSearchList->getSearchWord().empty(); + bool showNoContent = !showThread && !showSearch; - m_pLayout->showSearchList(showSearch); - m_pLayout->showThreadList(showThread); - m_pLayout->showNoContent(showNoContent); + m_pLayout->showSearchList(showSearch); + m_pLayout->showThreadList(showThread); + m_pLayout->showNoContent(showNoContent); - } else { - bool showThread = !m_pThreadList->isEmpty(); - m_pLayout->showThreadList(showThread); - m_pLayout->showNoContent(!showThread); - m_pLayout->showSearchList(false); - } - updateSelectItemsTitle(); + } else { + bool showThread = !m_pThreadList->isEmpty(); + m_pLayout->showThreadList(showThread); + m_pLayout->showNoContent(!showThread); + m_pLayout->showSearchList(false); + } + updateSelectItemsTitle(); } void MsgThread::updateSelectItemsTitle() { - if (m_Mode == DeleteMode) { - int checked = m_pThreadList->getThreadsCheckedCount(); - if (checked > 0) - getNaviBar().setTitle(msgArgs("IDS_MSG_HEADER_PD_SELECTED_ABB3", checked)); - else - getNaviBar().setTitle(msgt("IDS_MSG_HEADER_SELECT_ITEMS_ABB3")); - } + if (m_Mode == DeleteMode) { + int checked = m_pThreadList->getThreadsCheckedCount(); + if (checked > 0) + getNaviBar().setTitle(msgArgs("IDS_MSG_HEADER_PD_SELECTED_ABB3", checked)); + else + getNaviBar().setTitle(msgt("IDS_MSG_HEADER_SELECT_ITEMS_ABB3")); + } } void MsgThread::search(const std::string &searchWord) { - if (m_Mode == SearchMode && m_pSearchList) - m_pSearchList->requestSearch(searchWord); + if (m_Mode == SearchMode && m_pSearchList) + m_pSearchList->requestSearch(searchWord); } void MsgThread::onHwBackButtonClicked() { - MSG_LOG(""); - if (m_Mode == SearchMode || m_Mode == DeleteMode) - setMode(NormalMode); - else - pop(); + MSG_LOG(""); + if (m_Mode == SearchMode || m_Mode == DeleteMode) + setMode(NormalMode); + else + pop(); } void MsgThread::onHwMoreButtonClicked() { - MSG_LOG(""); - if (m_Mode == NormalMode) - showMainPopup(); + MSG_LOG(""); + if (m_Mode == NormalMode) + showMainPopup(); } void MsgThread::onSettingsItemPressed(PopupListItem &item) { - MSG_LOG(""); - item.getParent().destroy(); - navigateToSettings(); + MSG_LOG(""); + item.getParent().destroy(); + navigateToSettings(); } void MsgThread::onDeleteItemPressed(PopupListItem &item) { - MSG_LOG(""); - item.getParent().destroy(); - setMode(DeleteMode); + MSG_LOG(""); + item.getParent().destroy(); + setMode(DeleteMode); } void MsgThread::onSearchItemPressed(PopupListItem &item) { - MSG_LOG(""); - item.getParent().destroy(); - setMode(SearchMode); + MSG_LOG(""); + item.getParent().destroy(); + setMode(SearchMode); } void MsgThread::onButtonClicked(NaviFrameItem &item, NaviButtonId buttonId) { - MSG_LOG("NaviButton id:", buttonId); - if (buttonId == NaviOkButtonId) - m_pThreadList->deleteSelectedItems(); - setMode(NormalMode); + MSG_LOG("NaviButton id:", buttonId); + if (buttonId == NaviOkButtonId) + m_pThreadList->deleteSelectedItems(); + setMode(NormalMode); } void MsgThread::onListItemSelected(ThreadId id) { - navigateToConversation(id); + navigateToConversation(id); } void MsgThread::onThreadListChanged() { - MSG_LOG(""); - update(); + MSG_LOG(""); + update(); } void MsgThread::onThreadListItemChecked() { - int checked = m_pThreadList->getThreadsCheckedCount(); - getNaviBar().disabledButton(NaviOkButtonId, checked == 0); - updateSelectItemsTitle(); + int checked = m_pThreadList->getThreadsCheckedCount(); + getNaviBar().disabledButton(NaviOkButtonId, checked == 0); + updateSelectItemsTitle(); } void MsgThread::onSearchListChanged() { - MSG_LOG(""); - update(); + MSG_LOG(""); + update(); } void MsgThread::onSearchListItemSelected(ThreadId id) { - MSG_LOG(""); - navigateToConversation(id); + MSG_LOG(""); + navigateToConversation(id); } void MsgThread::onSearchListItemSelected(MsgId id, const std::string &searchWord) { - MSG_LOG(""); - MessageRef msg = getMsgEngine().getStorage().getMessage(id); - if (msg) - navigateToConversation(msg->getThreadId(), id, searchWord); + MSG_LOG(""); + MessageRef msg = getMsgEngine().getStorage().getMessage(id); + if (msg) + navigateToConversation(msg->getThreadId(), id, searchWord); } void MsgThread::onFloatingButtonPressed() { - MSG_LOG(""); - composeNewMessage(); + MSG_LOG(""); + composeNewMessage(); } void MsgThread::onSearchButtonClicked(MsgThreadSearchPanel &obj) { - MSG_LOG(""); + MSG_LOG(""); } void MsgThread::onEntryChanged(MsgThreadSearchPanel &obj) { - MSG_LOG(""); - search(obj.getEntryText()); + MSG_LOG(""); + search(obj.getEntryText()); } void MsgThread::onLanguageChanged() { - MSG_LOG(""); - updateSelectItemsTitle(); + MSG_LOG(""); + updateSelectItemsTitle(); } diff --git a/src/MsgThread/Controller/src/ThreadList.cpp b/src/MsgThread/Controller/src/ThreadList.cpp index 239792e7..f42aac22 100644 --- a/src/MsgThread/Controller/src/ThreadList.cpp +++ b/src/MsgThread/Controller/src/ThreadList.cpp @@ -25,334 +25,334 @@ using namespace Msg; namespace { - inline SelectAllListItem *isSelectAll(ListItem *it) - { - return dynamic_cast(it); - } - - inline const SelectAllListItem *isSelectAll(const ListItem *it) - { - return dynamic_cast(it); - } + inline SelectAllListItem *isSelectAll(ListItem *it) + { + return dynamic_cast(it); + } + + inline const SelectAllListItem *isSelectAll(const ListItem *it) + { + return dynamic_cast(it); + } } ThreadList::ThreadList(Evas_Object *parent, App &app) - : ListView(parent) - , m_pListener(nullptr) - , m_App(app) - , m_DeleteMode(false) + : ListView(parent) + , m_pListener(nullptr) + , m_App(app) + , m_DeleteMode(false) { - ListView::setListener(this); - ListView::setHomogeneous(true); - ListView::setMultiSelection(false); - ListView::setMode(ELM_LIST_COMPRESS); - ListView::setCmpFunc(cmpFunc); - - m_App.getMsgEngine().getStorage().addListener(*this); - m_App.getContactManager().addListener(*this); - m_App.getSysSettingsManager().addListener(*this); - fillList(); + ListView::setListener(this); + ListView::setHomogeneous(true); + ListView::setMultiSelection(false); + ListView::setMode(ELM_LIST_COMPRESS); + ListView::setCmpFunc(cmpFunc); + + m_App.getMsgEngine().getStorage().addListener(*this); + m_App.getContactManager().addListener(*this); + m_App.getSysSettingsManager().addListener(*this); + fillList(); } ThreadList::~ThreadList() { - m_App.getMsgEngine().getStorage().removeListener(*this); - m_App.getContactManager().removeListener(*this); - m_App.getSysSettingsManager().removeListener(*this); + m_App.getMsgEngine().getStorage().removeListener(*this); + m_App.getContactManager().removeListener(*this); + m_App.getSysSettingsManager().removeListener(*this); } void ThreadList::setListener(IThreadListListener *l) { - m_pListener = l; + m_pListener = l; } void ThreadList::setDeleteMode(bool value) { - m_DeleteMode = value; - setCheckMode(value); - ThreadListViewItem::resetCheckMode(*this); - checkAllItems(false, true); - showSelectAllItem(value); + m_DeleteMode = value; + setCheckMode(value); + ThreadListViewItem::resetCheckMode(*this); + checkAllItems(false, true); + showSelectAllItem(value); } bool ThreadList::isDeleteModeEnabled() const { - return m_DeleteMode; + return m_DeleteMode; } void ThreadList::deleteSelectedItems() { - auto items = getItems(); - for (ThreadListItem *it : items) { - if (it->getCheckedState()) - m_App.getMsgEngine().getStorage().deleteThread(it->getThreadId()); - } + auto items = getItems(); + for (ThreadListItem *it : items) { + if (it->getCheckedState()) + m_App.getMsgEngine().getStorage().deleteThread(it->getThreadId()); + } } int ThreadList::getThreadsCheckedCount() const { - auto items = getItems(); - int count = 0; - for (ThreadListItem *item : items) { - if (item->isCheckable() && item->getCheckedState()) - ++count; - } - return count; + auto items = getItems(); + int count = 0; + for (ThreadListItem *item : items) { + if (item->isCheckable() && item->getCheckedState()) + ++count; + } + return count; } void ThreadList::showSelectAllItem(bool show, bool resetCheck) { - SelectAllListItem *item = dynamic_cast(getFirstItem()); - - if (show) { - if (!item) { - item = new SelectAllListItem; - prependItem(*item); - } - - if (item && resetCheck) - item->setCheckedState(false, true); - } else { - if (item) - item->destroy(); - } + SelectAllListItem *item = dynamic_cast(getFirstItem()); + + if (show) { + if (!item) { + item = new SelectAllListItem; + prependItem(*item); + } + + if (item && resetCheck) + item->setCheckedState(false, true); + } else { + if (item) + item->destroy(); + } } bool ThreadList::isAllThreadListItemChecked() const { - // Simple impl. but not fast: - auto items = getItems(); - for (ThreadListItem *item : items) { - if (item->isCheckable() && !item->getCheckedState()) - return false; - } - return true; + // Simple impl. but not fast: + auto items = getItems(); + for (ThreadListItem *item : items) { + if (item->isCheckable() && !item->getCheckedState()) + return false; + } + return true; } void ThreadList::updateSelectAllItem() { - if (!m_DeleteMode) - return; + if (!m_DeleteMode) + return; - bool allChecked = isAllThreadListItemChecked(); - SelectAllListItem *selectAllItem = dynamic_cast(getFirstItem()); - if (selectAllItem) - selectAllItem->setCheckedState(allChecked, true); + bool allChecked = isAllThreadListItemChecked(); + SelectAllListItem *selectAllItem = dynamic_cast(getFirstItem()); + if (selectAllItem) + selectAllItem->setCheckedState(allChecked, true); } void ThreadList::checkHandler(SelectAllListItem &item) { - bool checked = item.getCheckedState(); - checkAllItems(checked); - if (m_pListener) - m_pListener->onThreadListItemChecked(); + bool checked = item.getCheckedState(); + checkAllItems(checked); + if (m_pListener) + m_pListener->onThreadListItemChecked(); } void ThreadList::checkHandler(ThreadListItem &item) { - ThreadId threadId = item.getThreadId(); - MSG_LOG("Checked (id : state) = ", threadId, ":", item.getCheckedState()); - updateSelectAllItem(); - if (m_pListener) - m_pListener->onThreadListItemChecked(); + ThreadId threadId = item.getThreadId(); + MSG_LOG("Checked (id : state) = ", threadId, ":", item.getCheckedState()); + updateSelectAllItem(); + if (m_pListener) + m_pListener->onThreadListItemChecked(); } int ThreadList::cmpFunc(const ListItem &item1, const ListItem &item2) { - if (isSelectAll(&item1)) - return 0; + if (isSelectAll(&item1)) + return 0; - if (isSelectAll(&item2)) - return 1; + if (isSelectAll(&item2)) + return 1; - auto &threadItem1 = static_cast(item1); - auto &threadItem2 = static_cast(item2); - return threadItem2.getRawTime() - threadItem1.getRawTime(); + auto &threadItem1 = static_cast(item1); + auto &threadItem2 = static_cast(item2); + return threadItem2.getRawTime() - threadItem1.getRawTime(); } void ThreadList::insertItem(ThreadId id) { - MsgThreadItemRef threadItem = m_App.getMsgEngine().getStorage().getThread(id); - if (threadItem) { - auto newItem = new ThreadListItem(*threadItem, m_App); - ListView::sortedInsertItem(*newItem); - navigateTo(*newItem); - } + MsgThreadItemRef threadItem = m_App.getMsgEngine().getStorage().getThread(id); + if (threadItem) { + auto newItem = new ThreadListItem(*threadItem, m_App); + ListView::sortedInsertItem(*newItem); + navigateTo(*newItem); + } } ThreadListItem *ThreadList::getItem(ThreadId id) const { - auto items = ListView::getItems(); - for (ThreadListItem *item : items) { - if (item->getThreadId() == id) - return item; - } - return nullptr; + auto items = ListView::getItems(); + for (ThreadListItem *item : items) { + if (item->getThreadId() == id) + return item; + } + return nullptr; } void ThreadList::fillList() { - MsgThreadListRef msgThreadList = m_App.getMsgEngine().getStorage().getThreadList(); - if (!msgThreadList) - return; + MsgThreadListRef msgThreadList = m_App.getMsgEngine().getStorage().getThreadList(); + if (!msgThreadList) + return; - int length = msgThreadList->getLength(); + int length = msgThreadList->getLength(); - for (int i = 0; i < length; ++i) { - const MsgThreadItem &msgThreadItem = msgThreadList->at(i); - ListView::appendItem(*new ThreadListItem(msgThreadItem, m_App)); - } + for (int i = 0; i < length; ++i) { + const MsgThreadItem &msgThreadItem = msgThreadList->at(i); + ListView::appendItem(*new ThreadListItem(msgThreadItem, m_App)); + } } void ThreadList::deleteItems() { - MsgThreadListRef msgThreadList = m_App.getMsgEngine().getStorage().getThreadList(); - if (!msgThreadList) - return; + MsgThreadListRef msgThreadList = m_App.getMsgEngine().getStorage().getThreadList(); + if (!msgThreadList) + return; - std::set threadIdSet; - int length = msgThreadList->getLength(); - for (int i = 0; i < length; ++i) { - const MsgThreadItem &msgThreadItem = msgThreadList->at(i); - threadIdSet.insert(msgThreadItem.getId()); - } + std::set threadIdSet; + int length = msgThreadList->getLength(); + for (int i = 0; i < length; ++i) { + const MsgThreadItem &msgThreadItem = msgThreadList->at(i); + threadIdSet.insert(msgThreadItem.getId()); + } - auto items = ListView::getItems(); + auto items = ListView::getItems(); - for (ThreadListItem *item : items) { - if (threadIdSet.count(item->getThreadId()) == 0) - ListView::deleteItem(*item); - } + for (ThreadListItem *item : items) { + if (threadIdSet.count(item->getThreadId()) == 0) + ListView::deleteItem(*item); + } - updateSelectAllItem(); + updateSelectAllItem(); } void ThreadList::navigateTo(ThreadListItem &item) { - ListView::showItem(item, ELM_GENLIST_ITEM_SCROLLTO_TOP); + ListView::showItem(item, ELM_GENLIST_ITEM_SCROLLTO_TOP); } void ThreadList::updateItems(const MsgIdList &idList) { - auto threadIdSet = getThreadIdSet(idList); - auto threadItems = getItems(); + auto threadIdSet = getThreadIdSet(idList); + auto threadItems = getItems(); - for (ThreadListItem *item: threadItems) { - if (threadIdSet.count(item->getThreadId())) - updateItem(*item); - } + for (ThreadListItem *item: threadItems) { + if (threadIdSet.count(item->getThreadId())) + updateItem(*item); + } } void ThreadList::updateItems() { - auto items = getItems(); - for (ThreadListItem *item: items) { - updateItem(*item); - } + auto items = getItems(); + for (ThreadListItem *item: items) { + updateItem(*item); + } } void ThreadList::updateItem(ThreadListItem &item) { - MsgThreadItemRef msgThread = m_App.getMsgEngine().getStorage().getThread(item.getThreadId()); - if (!msgThread) { - MSG_LOG_ERROR("msgThread is null"); - return; - } - - ThreadListItem *next = getNextItem(item); - ThreadListItem *prev = getPrevItem(item); - time_t threadTime = msgThread->getTime(); - - if ((next && threadTime < next->getRawTime()) || - (prev && threadTime > prev->getRawTime())) { - auto newItem = new ThreadListItem(*msgThread, m_App); - newItem->setCheckedState(item.getCheckedState(), false); - item.destroy(); - ListView::sortedInsertItem(*newItem); - navigateTo(*newItem); - } else { - item.update(*msgThread, true); - navigateTo(item); - } + MsgThreadItemRef msgThread = m_App.getMsgEngine().getStorage().getThread(item.getThreadId()); + if (!msgThread) { + MSG_LOG_ERROR("msgThread is null"); + return; + } + + ThreadListItem *next = getNextItem(item); + ThreadListItem *prev = getPrevItem(item); + time_t threadTime = msgThread->getTime(); + + if ((next && threadTime < next->getRawTime()) || + (prev && threadTime > prev->getRawTime())) { + auto newItem = new ThreadListItem(*msgThread, m_App); + newItem->setCheckedState(item.getCheckedState(), false); + item.destroy(); + ListView::sortedInsertItem(*newItem); + navigateTo(*newItem); + } else { + item.update(*msgThread, true); + navigateTo(item); + } } std::set ThreadList::getThreadIdSet(const MsgIdList &idList) { - std::set res; - for (MsgId msgId : idList) { - ThreadId threadId = m_App.getMsgEngine().getStorage().getThreadId(msgId); - if (threadId.isValid()) - res.insert(threadId); - } - return res; + std::set res; + for (MsgId msgId : idList) { + ThreadId threadId = m_App.getMsgEngine().getStorage().getThreadId(msgId); + if (threadId.isValid()) + res.insert(threadId); + } + return res; } void ThreadList::onListItemSelected(ListItem &listItem) { - MSG_LOG(""); - ThreadListItem *it = dynamic_cast(&listItem); - if (it && m_pListener) - m_pListener->onListItemSelected(it->getThreadId()); + MSG_LOG(""); + ThreadListItem *it = dynamic_cast(&listItem); + if (it && m_pListener) + m_pListener->onListItemSelected(it->getThreadId()); } void ThreadList::onListItemChecked(ListItem &listItem) { - MSG_LOG(""); - if (ThreadListItem *it = dynamic_cast(&listItem)) - checkHandler(*it); - else if (SelectAllListItem *it = isSelectAll(&listItem)) - checkHandler(*it); + MSG_LOG(""); + if (ThreadListItem *it = dynamic_cast(&listItem)) + checkHandler(*it); + else if (SelectAllListItem *it = isSelectAll(&listItem)) + checkHandler(*it); } void ThreadList::onMsgStorageThreadUpdate(const ThreadId &threadId) { - MSG_LOG(""); - auto* item = getItem(threadId); - if (item) - updateItem(*item); + MSG_LOG(""); + auto* item = getItem(threadId); + if (item) + updateItem(*item); } void ThreadList::onMsgStorageThreadInsert(const ThreadId &threadId) { - MSG_LOG(""); - insertItem(threadId); - updateSelectAllItem(); - if (m_pListener) - m_pListener->onThreadListChanged(); + MSG_LOG(""); + insertItem(threadId); + updateSelectAllItem(); + if (m_pListener) + m_pListener->onThreadListChanged(); } void ThreadList::onMsgStorageThreadDelete(const ThreadId &threadId) { - MSG_LOG(""); - auto* thread = getItem(threadId); - if (thread) { - ListView::deleteItem(*thread); - updateSelectAllItem(); - } - - if (m_pListener) - m_pListener->onThreadListChanged(); + MSG_LOG(""); + auto* thread = getItem(threadId); + if (thread) { + ListView::deleteItem(*thread); + updateSelectAllItem(); + } + + if (m_pListener) + m_pListener->onThreadListChanged(); } void ThreadList::onContactChanged() { - MSG_LOG(""); - updateItems(); + MSG_LOG(""); + updateItems(); } void ThreadList::onTimeFormatChanged() { - MSG_LOG(""); - auto items = ListView::getItems(); - for (ThreadListItem *item : items) { - item->updateTime(); - } + MSG_LOG(""); + auto items = ListView::getItems(); + for (ThreadListItem *item : items) { + item->updateTime(); + } - ListView::updateRealizedItems(); + ListView::updateRealizedItems(); } void ThreadList::onLanguageChanged() { - MSG_LOG(""); - updateItems(); + MSG_LOG(""); + updateItems(); } diff --git a/src/MsgThread/Controller/src/ThreadListItem.cpp b/src/MsgThread/Controller/src/ThreadListItem.cpp index 4998a2ef..a3b1f6d5 100644 --- a/src/MsgThread/Controller/src/ThreadListItem.cpp +++ b/src/MsgThread/Controller/src/ThreadListItem.cpp @@ -29,10 +29,10 @@ using namespace Msg; ThreadListItem::ThreadListItem(const MsgThreadItem &threadItem, App &app) - : BaseThreadListItem(app) - , m_ThreadId() + : BaseThreadListItem(app) + , m_ThreadId() { - update(threadItem, false); + update(threadItem, false); } ThreadListItem::~ThreadListItem() @@ -41,54 +41,54 @@ ThreadListItem::~ThreadListItem() ThreadId ThreadListItem::getThreadId() const { - return m_ThreadId; + return m_ThreadId; } std::string ThreadListItem::getStatus() { - return m_Status; + return m_Status; } Evas_Object *ThreadListItem::getIcon() { - return makeUnreadIcon(m_UnreadCount); + return makeUnreadIcon(m_UnreadCount); } void ThreadListItem::update(const MsgThreadItem &threadItem, bool updateUi) { - m_ThreadId = threadItem.getId(); - State state = NormalState; + m_ThreadId = threadItem.getId(); + State state = NormalState; - MsgConversationListRef convList = m_App.getMsgEngine().getStorage().getConversationList(m_ThreadId); - if (convList && convList->getLength() > 0) { - MsgConversationItem &item = convList->at(convList->getLength() - 1); + MsgConversationListRef convList = m_App.getMsgEngine().getStorage().getConversationList(m_ThreadId); + if (convList && convList->getLength() > 0) { + MsgConversationItem &item = convList->at(convList->getLength() - 1); - Message::NetworkStatus status = item.getNetworkStatus(); - if (status == Message::NS_Sending) { - state = StatusState; - m_Status = decorateSendingText(msg("IDS_MSG_BODY_SENDING_ING_M_STATUS_ABB")); - } else if (status == Message::NS_Send_Fail) { - state = StatusState; - m_Status = decorateFailedText(msg("IDS_MSG_BODY_FAILED_M_STATUS_ABB2")); - } else if (item.isDraft()) { - state = StatusState; - m_Status = decorateDraftText(msg("IDS_MSG_BODY_DRAFT_M_STATUS_ABB")); - } else if (!item.isRead()) { - int count = threadItem.getUnreadCount(); - if (count > 0) - { - state = IconState; - m_UnreadCount = std::to_string(count); - } - } - } + Message::NetworkStatus status = item.getNetworkStatus(); + if (status == Message::NS_Sending) { + state = StatusState; + m_Status = decorateSendingText(msg("IDS_MSG_BODY_SENDING_ING_M_STATUS_ABB")); + } else if (status == Message::NS_Send_Fail) { + state = StatusState; + m_Status = decorateFailedText(msg("IDS_MSG_BODY_FAILED_M_STATUS_ABB2")); + } else if (item.isDraft()) { + state = StatusState; + m_Status = decorateDraftText(msg("IDS_MSG_BODY_DRAFT_M_STATUS_ABB")); + } else if (!item.isRead()) { + int count = threadItem.getUnreadCount(); + if (count > 0) + { + state = IconState; + m_UnreadCount = std::to_string(count); + } + } + } - setState(state, false); - updateMessage(threadItem); - updateThumbnailAndName(threadItem, true); - updateTime(threadItem.getTime()); + setState(state, false); + updateMessage(threadItem); + updateThumbnailAndName(threadItem, true); + updateTime(threadItem.getTime()); - if (updateUi) - ListItem::update(); + if (updateUi) + ListItem::update(); } diff --git a/src/MsgThread/Controller/src/ThreadSearchList.cpp b/src/MsgThread/Controller/src/ThreadSearchList.cpp index 4536f007..e78e1daa 100644 --- a/src/MsgThread/Controller/src/ThreadSearchList.cpp +++ b/src/MsgThread/Controller/src/ThreadSearchList.cpp @@ -24,148 +24,148 @@ using namespace Msg; ThreadSearchList::ThreadSearchList(Evas_Object *parent, App &app) - : ListView(parent) - , m_App(app) - , m_pIdler(nullptr) - , m_pListener(nullptr) + : ListView(parent) + , m_App(app) + , m_pIdler(nullptr) + , m_pListener(nullptr) { - ListView::setHomogeneous(true); - ListView::setMultiSelection(false); - ListView::setMode(ELM_LIST_COMPRESS); - ListView::setListener(this); - m_App.getContactManager().addListener(*this); - m_App.getSysSettingsManager().addListener(*this); - m_App.getMsgEngine().getStorage().addListener(*this); + ListView::setHomogeneous(true); + ListView::setMultiSelection(false); + ListView::setMode(ELM_LIST_COMPRESS); + ListView::setListener(this); + m_App.getContactManager().addListener(*this); + m_App.getSysSettingsManager().addListener(*this); + m_App.getMsgEngine().getStorage().addListener(*this); } ThreadSearchList::~ThreadSearchList() { - cancelSearch(); - m_App.getContactManager().removeListener(*this); - m_App.getSysSettingsManager().removeListener(*this); - m_App.getMsgEngine().getStorage().removeListener(*this); + cancelSearch(); + m_App.getContactManager().removeListener(*this); + m_App.getSysSettingsManager().removeListener(*this); + m_App.getMsgEngine().getStorage().removeListener(*this); } void ThreadSearchList::setListener(IThreadSearchListListener *l) { - m_pListener = l; + m_pListener = l; } void ThreadSearchList::requestSearch(const std::string &searchWord) { - m_SearchWord = searchWord; - if (!m_pIdler) { - m_pIdler = ecore_idler_add - ( - [](void *data)->Eina_Bool - { - ThreadSearchList *self =(ThreadSearchList*)data; - self->m_pIdler = nullptr; - self->search(); - return false; // Delete idler - }, - this); - } + m_SearchWord = searchWord; + if (!m_pIdler) { + m_pIdler = ecore_idler_add + ( + [](void *data)->Eina_Bool + { + ThreadSearchList *self =(ThreadSearchList*)data; + self->m_pIdler = nullptr; + self->search(); + return false; // Delete idler + }, + this); + } } void ThreadSearchList::cancelSearch() { - if (m_pIdler) { - ecore_idler_del(m_pIdler); - m_pIdler = nullptr; - } + if (m_pIdler) { + ecore_idler_del(m_pIdler); + m_pIdler = nullptr; + } } const std::string &ThreadSearchList::getSearchWord() const { - return m_SearchWord; + return m_SearchWord; } void ThreadSearchList::search() { - MSG_LOG("Search word: ", m_SearchWord); - ListView::clear(); - - if (!m_SearchWord.empty()) { - MsgStorage &msgSotrage = m_App.getMsgEngine().getStorage(); - - // Thread: - MsgThreadListRef threadList = msgSotrage.searchThread(m_SearchWord); - if (threadList) { - int length = threadList->getLength(); - for (int i = 0; i < length; ++i) { - const MsgThreadItem &threadItem = threadList->at(i); - ListView::appendItem(*new ThreadSearchListItem(m_App, threadItem, m_SearchWord)); - } - } - - // Message: - MessageListRef msgList = msgSotrage.searchMessage(m_SearchWord); - if (msgList) { - int length = msgList->getLength(); - for (int i = 0; i < length; ++i) { - const Message &msg = msgList->at(i); - ListView::appendItem(*new MsgSearchListItem(m_App, msg, m_SearchWord)); - } - } - } - - if (m_pListener) - m_pListener->onSearchListChanged(); + MSG_LOG("Search word: ", m_SearchWord); + ListView::clear(); + + if (!m_SearchWord.empty()) { + MsgStorage &msgSotrage = m_App.getMsgEngine().getStorage(); + + // Thread: + MsgThreadListRef threadList = msgSotrage.searchThread(m_SearchWord); + if (threadList) { + int length = threadList->getLength(); + for (int i = 0; i < length; ++i) { + const MsgThreadItem &threadItem = threadList->at(i); + ListView::appendItem(*new ThreadSearchListItem(m_App, threadItem, m_SearchWord)); + } + } + + // Message: + MessageListRef msgList = msgSotrage.searchMessage(m_SearchWord); + if (msgList) { + int length = msgList->getLength(); + for (int i = 0; i < length; ++i) { + const Message &msg = msgList->at(i); + ListView::appendItem(*new MsgSearchListItem(m_App, msg, m_SearchWord)); + } + } + } + + if (m_pListener) + m_pListener->onSearchListChanged(); } void ThreadSearchList::updateTime() { - auto items = ListView::getItems(); - for (BaseThreadListItem *item : items) { - item->updateTime(); - } + auto items = ListView::getItems(); + for (BaseThreadListItem *item : items) { + item->updateTime(); + } - ListView::updateRealizedItems(); + ListView::updateRealizedItems(); } void ThreadSearchList::onListItemSelected(ListItem &listItem) { - if (m_pListener) { - if (auto it = dynamic_cast(&listItem)) - m_pListener->onSearchListItemSelected(it->getMsgId(), m_SearchWord); - else if (auto it = dynamic_cast(&listItem)) - m_pListener->onSearchListItemSelected(it->getThreadId()); - } + if (m_pListener) { + if (auto it = dynamic_cast(&listItem)) + m_pListener->onSearchListItemSelected(it->getMsgId(), m_SearchWord); + else if (auto it = dynamic_cast(&listItem)) + m_pListener->onSearchListItemSelected(it->getThreadId()); + } } void ThreadSearchList::onContactChanged() { - MSG_LOG(""); - search(); + MSG_LOG(""); + search(); } void ThreadSearchList::onMsgStorageUpdate(const MsgIdList &msgIdList) { - MSG_LOG(""); - search(); + MSG_LOG(""); + search(); } void ThreadSearchList::onMsgStorageInsert(const MsgIdList &msgIdList) { - MSG_LOG(""); - search(); + MSG_LOG(""); + search(); } void ThreadSearchList::onMsgStorageDelete(const MsgIdList &msgIdList) { - MSG_LOG(""); - search(); + MSG_LOG(""); + search(); } void ThreadSearchList::onTimeFormatChanged() { - MSG_LOG(""); - updateTime(); + MSG_LOG(""); + updateTime(); } void ThreadSearchList::onLanguageChanged() { - MSG_LOG(""); - updateTime(); + MSG_LOG(""); + updateTime(); } diff --git a/src/MsgThread/Controller/src/ThreadSearchListItem.cpp b/src/MsgThread/Controller/src/ThreadSearchListItem.cpp index 2533ed5f..2f8b2ff9 100644 --- a/src/MsgThread/Controller/src/ThreadSearchListItem.cpp +++ b/src/MsgThread/Controller/src/ThreadSearchListItem.cpp @@ -20,9 +20,9 @@ using namespace Msg; ThreadSearchListItem::ThreadSearchListItem(App &app, const MsgThreadItem &item, const std::string &searchWord) - : BaseThreadListItem(app) + : BaseThreadListItem(app) { - update(item, searchWord); + update(item, searchWord); } ThreadSearchListItem::~ThreadSearchListItem() @@ -31,14 +31,14 @@ ThreadSearchListItem::~ThreadSearchListItem() ThreadId ThreadSearchListItem::getThreadId() const { - return m_ThreadId; + return m_ThreadId; } void ThreadSearchListItem::update(const MsgThreadItem &item, const std::string &searchWord) { - m_ThreadId = item.getId(); - m_Message = decorateMessageText(item.getLastMessage()); - updateThumbnailAndName(item, false); - m_Name = decorateNameText(TextDecorator::highlightKeyword(std::move(m_Name), searchWord)); - updateTime(item.getTime()); + m_ThreadId = item.getId(); + m_Message = decorateMessageText(item.getLastMessage()); + updateThumbnailAndName(item, false); + m_Name = decorateNameText(TextDecorator::highlightKeyword(std::move(m_Name), searchWord)); + updateTime(item.getTime()); } diff --git a/src/MsgThread/View/inc/FloatingButton.h b/src/MsgThread/View/inc/FloatingButton.h index 8d25f64a..3c46ab19 100644 --- a/src/MsgThread/View/inc/FloatingButton.h +++ b/src/MsgThread/View/inc/FloatingButton.h @@ -20,31 +20,31 @@ #include "View.h" namespace Msg { - class IFloatingButtonListener; - - class FloatingButton - : public View { - public: - FloatingButton(Evas_Object *parent); - - /** - * @brief Allows to subscribe on floating button's events. - * @param pListener handler of floating-button events - */ - void setListener(IFloatingButtonListener* pListener); - - private: - void pressed(Evas_Object *obj, void *event_info); - - private: - IFloatingButtonListener* m_pListener; - }; - - class IFloatingButtonListener { - public: - virtual ~IFloatingButtonListener() {}; - virtual void onFloatingButtonPressed() = 0; - }; + class IFloatingButtonListener; + + class FloatingButton + : public View { + public: + FloatingButton(Evas_Object *parent); + + /** + * @brief Allows to subscribe on floating button's events. + * @param pListener handler of floating-button events + */ + void setListener(IFloatingButtonListener* pListener); + + private: + void pressed(Evas_Object *obj, void *event_info); + + private: + IFloatingButtonListener* m_pListener; + }; + + class IFloatingButtonListener { + public: + virtual ~IFloatingButtonListener() {}; + virtual void onFloatingButtonPressed() = 0; + }; } #endif /* FloatingButton_h_ */ diff --git a/src/MsgThread/View/inc/MsgThreadLayout.h b/src/MsgThread/View/inc/MsgThreadLayout.h index f22cefcb..85a62093 100644 --- a/src/MsgThread/View/inc/MsgThreadLayout.h +++ b/src/MsgThread/View/inc/MsgThreadLayout.h @@ -21,25 +21,25 @@ #include "DefaultLayout.h" namespace Msg { - class MsgThreadLayout - : public DefaultLayout { - public: - MsgThreadLayout(Evas_Object *parent); - virtual ~MsgThreadLayout(); + class MsgThreadLayout + : public DefaultLayout { + public: + MsgThreadLayout(Evas_Object *parent); + virtual ~MsgThreadLayout(); - void setList(Evas_Object *list); - void setSearchList(Evas_Object *searchList); - void setNoContent(Evas_Object *bg); - void showNoContent(bool show); - void showSearchList(bool show); - void showThreadList(bool show); - private: - void create(Evas_Object *parent); - void setContent(Evas_Object *obj); + void setList(Evas_Object *list); + void setSearchList(Evas_Object *searchList); + void setNoContent(Evas_Object *bg); + void showNoContent(bool show); + void showSearchList(bool show); + void showThreadList(bool show); + private: + void create(Evas_Object *parent); + void setContent(Evas_Object *obj); - private: - Evas_Object *m_pLayout; - }; + private: + Evas_Object *m_pLayout; + }; } #endif // MsgThreadLayout_h_ diff --git a/src/MsgThread/View/inc/MsgThreadSearchPanel.h b/src/MsgThread/View/inc/MsgThreadSearchPanel.h index 978e78db..034c52ea 100644 --- a/src/MsgThread/View/inc/MsgThreadSearchPanel.h +++ b/src/MsgThread/View/inc/MsgThreadSearchPanel.h @@ -21,49 +21,49 @@ #include namespace Msg { - class IMsgThreadSearchPanelListener; + class IMsgThreadSearchPanelListener; - class MsgThreadSearchPanel - : public View { - public: - MsgThreadSearchPanel(Evas_Object *parent); - virtual ~MsgThreadSearchPanel(); + class MsgThreadSearchPanel + : public View { + public: + MsgThreadSearchPanel(Evas_Object *parent); + virtual ~MsgThreadSearchPanel(); - void setListener(IMsgThreadSearchPanelListener *listener); - std::string getEntryText() const; - void clearEntry(); - void showClearButton(bool visible); - void setEntryFocus(bool focus); - bool isEmpty() const; + void setListener(IMsgThreadSearchPanelListener *listener); + std::string getEntryText() const; + void clearEntry(); + void showClearButton(bool visible); + void setEntryFocus(bool focus); + bool isEmpty() const; - private: - void create(Evas_Object *parent); - Evas_Object *createClearButton(Evas_Object *parent); - Evas_Object *createEntry(Evas_Object *parent); - Evas_Object *createButton(Evas_Object *parent, const char *style); + private: + void create(Evas_Object *parent); + Evas_Object *createClearButton(Evas_Object *parent); + Evas_Object *createEntry(Evas_Object *parent); + Evas_Object *createButton(Evas_Object *parent, const char *style); - private: - void onEntryChanged(Evas_Object *obj, void *eventInfo); - void onKeyDown(Evas_Object *obj, void *eventInfo); - void onClearButtonClicked(Evas_Object *obj, void *eventInfo); - static void onPostponedEntryFocus(void *data); + private: + void onEntryChanged(Evas_Object *obj, void *eventInfo); + void onKeyDown(Evas_Object *obj, void *eventInfo); + void onClearButtonClicked(Evas_Object *obj, void *eventInfo); + static void onPostponedEntryFocus(void *data); - private: - Evas_Object *m_pEntry; - Evas_Object *m_pClearButton; - IMsgThreadSearchPanelListener *m_pListener; - bool m_EntryFocus; - Ecore_Job *m_pEntryJob; - }; + private: + Evas_Object *m_pEntry; + Evas_Object *m_pClearButton; + IMsgThreadSearchPanelListener *m_pListener; + bool m_EntryFocus; + Ecore_Job *m_pEntryJob; + }; - class IMsgThreadSearchPanelListener { - public: - virtual ~IMsgThreadSearchPanelListener() {}; + class IMsgThreadSearchPanelListener { + public: + virtual ~IMsgThreadSearchPanelListener() {}; - virtual void onBackButtonClicked(MsgThreadSearchPanel &obj) {}; - virtual void onSearchButtonClicked(MsgThreadSearchPanel &obj) {}; - virtual void onEntryChanged(MsgThreadSearchPanel &obj) {}; - }; + virtual void onBackButtonClicked(MsgThreadSearchPanel &obj) {}; + virtual void onSearchButtonClicked(MsgThreadSearchPanel &obj) {}; + virtual void onEntryChanged(MsgThreadSearchPanel &obj) {}; + }; } #endif // MsgThreadSearchPanel_h_ diff --git a/src/MsgThread/View/inc/ThreadListViewItem.h b/src/MsgThread/View/inc/ThreadListViewItem.h index c36b01dd..2f5fb697 100644 --- a/src/MsgThread/View/inc/ThreadListViewItem.h +++ b/src/MsgThread/View/inc/ThreadListViewItem.h @@ -21,48 +21,48 @@ #include namespace Msg { - class ThreadListViewItem - : public ListItem { - public: - enum State { - NormalState, - StatusState, - IconState - }; + class ThreadListViewItem + : public ListItem { + public: + enum State { + NormalState, + StatusState, + IconState + }; - public: - ThreadListViewItem(Elm_Genlist_Item_Type type = ELM_GENLIST_ITEM_NONE); - virtual ~ThreadListViewItem(); + public: + ThreadListViewItem(Elm_Genlist_Item_Type type = ELM_GENLIST_ITEM_NONE); + virtual ~ThreadListViewItem(); - void setState(State state, bool updateUi); - State getState() const; - static void resetCheckMode(ListView &listView); + void setState(State state, bool updateUi); + State getState() const; + static void resetCheckMode(ListView &listView); - protected: - virtual std::string getName() = 0; - virtual std::string getMessage() = 0; - virtual std::string getTime() = 0; - virtual Evas_Object *getThumbnail() = 0; - virtual std::string getStatus(); - virtual Evas_Object *getIcon(); + protected: + virtual std::string getName() = 0; + virtual std::string getMessage() = 0; + virtual std::string getTime() = 0; + virtual Evas_Object *getThumbnail() = 0; + virtual std::string getStatus(); + virtual Evas_Object *getIcon(); - using ListItem::getState; - Evas_Object *makeUnreadIcon(const std::string &text) const; - std::string decorateNameText(const std::string &text) const; - std::string decorateMessageText(const std::string &text) const; - std::string decorateTimeText(const std::string &text) const; - std::string decorateFailedText(const std::string &text) const; - std::string decorateSendingText(const std::string &text) const; - std::string decorateDraftText(const std::string &text) const; + using ListItem::getState; + Evas_Object *makeUnreadIcon(const std::string &text) const; + std::string decorateNameText(const std::string &text) const; + std::string decorateMessageText(const std::string &text) const; + std::string decorateTimeText(const std::string &text) const; + std::string decorateFailedText(const std::string &text) const; + std::string decorateSendingText(const std::string &text) const; + std::string decorateDraftText(const std::string &text) const; - private: - virtual std::string getText(ListItem &item, const char *part); - virtual Evas_Object *getContent(ListItem &item, const char *part); - virtual const char *getCheckPart(ListItem &item); + private: + virtual std::string getText(ListItem &item, const char *part); + virtual Evas_Object *getContent(ListItem &item, const char *part); + virtual const char *getCheckPart(ListItem &item); - private: - State m_State; - }; + private: + State m_State; + }; } #endif // ThreadListViewItem_h_ diff --git a/src/MsgThread/View/src/FloatingButton.cpp b/src/MsgThread/View/src/FloatingButton.cpp index 2988ace6..eb66ead2 100644 --- a/src/MsgThread/View/src/FloatingButton.cpp +++ b/src/MsgThread/View/src/FloatingButton.cpp @@ -23,30 +23,30 @@ using namespace Msg; #define COMPOSE_BUTTON_ICON_SIZE ELM_SCALE_SIZE(80) FloatingButton::FloatingButton(Evas_Object *parent) - : m_pListener(nullptr) + : m_pListener(nullptr) { - setEo(eext_floatingbutton_add(parent)); - Evas_Object *composeBtn = elm_button_add(getEo()); + setEo(eext_floatingbutton_add(parent)); + Evas_Object *composeBtn = elm_button_add(getEo()); - Evas_Object *icon = elm_image_add(composeBtn); - std::string resPath = PathUtils::getResourcePath(MSG_THREAD_FLOATING_BTN_ICON); - elm_image_file_set(icon, resPath.c_str(), NULL); - evas_object_size_hint_min_set(icon, COMPOSE_BUTTON_ICON_SIZE, COMPOSE_BUTTON_ICON_SIZE); - elm_object_part_content_set(composeBtn, "icon", icon); + Evas_Object *icon = elm_image_add(composeBtn); + std::string resPath = PathUtils::getResourcePath(MSG_THREAD_FLOATING_BTN_ICON); + elm_image_file_set(icon, resPath.c_str(), NULL); + evas_object_size_hint_min_set(icon, COMPOSE_BUTTON_ICON_SIZE, COMPOSE_BUTTON_ICON_SIZE); + elm_object_part_content_set(composeBtn, "icon", icon); - setContent(composeBtn, "button1"); - evas_object_smart_callback_add(composeBtn, "clicked", SMART_CALLBACK(FloatingButton, pressed), this); + setContent(composeBtn, "button1"); + evas_object_smart_callback_add(composeBtn, "clicked", SMART_CALLBACK(FloatingButton, pressed), this); - show(); + show(); } void FloatingButton::setListener(IFloatingButtonListener* pListener) { - m_pListener = pListener; + m_pListener = pListener; } void FloatingButton::pressed(Evas_Object *obj, void *event_info) { - if (m_pListener) - m_pListener->onFloatingButtonPressed(); + if (m_pListener) + m_pListener->onFloatingButtonPressed(); } diff --git a/src/MsgThread/View/src/MsgThreadLayout.cpp b/src/MsgThread/View/src/MsgThreadLayout.cpp index 04181b4d..2fae63ad 100644 --- a/src/MsgThread/View/src/MsgThreadLayout.cpp +++ b/src/MsgThread/View/src/MsgThreadLayout.cpp @@ -21,9 +21,9 @@ using namespace Msg; MsgThreadLayout::MsgThreadLayout(Evas_Object *parent) - : DefaultLayout(parent) + : DefaultLayout(parent) { - create(parent); + create(parent); } MsgThreadLayout::~MsgThreadLayout() @@ -32,42 +32,42 @@ MsgThreadLayout::~MsgThreadLayout() void MsgThreadLayout::create(Evas_Object *parent) { - m_pLayout = elm_layout_add(parent); - evas_object_show(m_pLayout); - std::string path = PathUtils::getResourcePath(MSG_THREAD_EDJ_PATH); - elm_layout_file_set(m_pLayout, path.c_str(), "msg_thread_layout"); - DefaultLayout::setContent(m_pLayout); + m_pLayout = elm_layout_add(parent); + evas_object_show(m_pLayout); + std::string path = PathUtils::getResourcePath(MSG_THREAD_EDJ_PATH); + elm_layout_file_set(m_pLayout, path.c_str(), "msg_thread_layout"); + DefaultLayout::setContent(m_pLayout); } void MsgThreadLayout::setList(Evas_Object *list) { - elm_object_part_content_set(m_pLayout, "swl.list", list); + elm_object_part_content_set(m_pLayout, "swl.list", list); } void MsgThreadLayout::setSearchList(Evas_Object *searchList) { - elm_object_part_content_set(m_pLayout, "swl.search_list", searchList); + elm_object_part_content_set(m_pLayout, "swl.search_list", searchList); } void MsgThreadLayout::setNoContent(Evas_Object *bg) { - elm_object_part_content_set(m_pLayout, "swl.bg", bg); + elm_object_part_content_set(m_pLayout, "swl.bg", bg); } void MsgThreadLayout::showNoContent(bool show) { - const char *sig = show ? "show_bg" : "hide_bg"; - elm_layout_signal_emit(m_pLayout, sig, ""); + const char *sig = show ? "show_bg" : "hide_bg"; + elm_layout_signal_emit(m_pLayout, sig, ""); } void MsgThreadLayout::showSearchList(bool show) { - const char *sig = show ? "show_search_list" : "hide_search_list"; - elm_layout_signal_emit(m_pLayout, sig, ""); + const char *sig = show ? "show_search_list" : "hide_search_list"; + elm_layout_signal_emit(m_pLayout, sig, ""); } void MsgThreadLayout::showThreadList(bool show) { - const char *sig = show ? "show_list" : "hide_list"; - elm_layout_signal_emit(m_pLayout, sig, ""); + const char *sig = show ? "show_list" : "hide_list"; + elm_layout_signal_emit(m_pLayout, sig, ""); } diff --git a/src/MsgThread/View/src/MsgThreadSearchPanel.cpp b/src/MsgThread/View/src/MsgThreadSearchPanel.cpp index aef85226..86802423 100644 --- a/src/MsgThread/View/src/MsgThreadSearchPanel.cpp +++ b/src/MsgThread/View/src/MsgThreadSearchPanel.cpp @@ -24,137 +24,137 @@ using namespace Msg; MsgThreadSearchPanel::MsgThreadSearchPanel(Evas_Object *parent) - : m_pEntry(nullptr) - , m_pClearButton(nullptr) - , m_pListener(nullptr) - , m_EntryFocus(false) - , m_pEntryJob(nullptr) + : m_pEntry(nullptr) + , m_pClearButton(nullptr) + , m_pListener(nullptr) + , m_EntryFocus(false) + , m_pEntryJob(nullptr) { - create(parent); + create(parent); } MsgThreadSearchPanel::~MsgThreadSearchPanel() { - if (m_pEntryJob) { - ecore_job_del(m_pEntryJob); - m_pEntryJob = nullptr; - } + if (m_pEntryJob) { + ecore_job_del(m_pEntryJob); + m_pEntryJob = nullptr; + } } void MsgThreadSearchPanel::create(Evas_Object *parent) { - setEo(elm_layout_add(parent)); - elm_layout_theme_set(getEo(), "layout", "searchfield", "singleline"); - expand(); + setEo(elm_layout_add(parent)); + elm_layout_theme_set(getEo(), "layout", "searchfield", "singleline"); + expand(); - Evas_Object *entry = createEntry(getEo()); - setContent(entry, "elm.swallow.content"); + Evas_Object *entry = createEntry(getEo()); + setContent(entry, "elm.swallow.content"); } bool MsgThreadSearchPanel::isEmpty() const { - const char *text = elm_entry_entry_get(m_pEntry); - return text ? *text == 0 : true; + const char *text = elm_entry_entry_get(m_pEntry); + return text ? *text == 0 : true; } void MsgThreadSearchPanel::setListener(IMsgThreadSearchPanelListener *listener) { - m_pListener = listener; + m_pListener = listener; } Evas_Object *MsgThreadSearchPanel::createClearButton(Evas_Object *parent) { - m_pClearButton = createButton(parent, "editfield_clear"); - return m_pClearButton; + m_pClearButton = createButton(parent, "editfield_clear"); + return m_pClearButton; } Evas_Object *MsgThreadSearchPanel::createEntry(Evas_Object *parent) { - m_pEntry = elm_entry_add(parent); - elm_entry_cnp_mode_set(m_pEntry, ELM_CNP_MODE_PLAINTEXT); - evas_object_size_hint_weight_set(m_pEntry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_pEntry, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_entry_editable_set(m_pEntry, EINA_TRUE); - elm_entry_single_line_set(m_pEntry, EINA_TRUE); - elm_entry_scrollable_set(m_pEntry, EINA_TRUE); - eext_entry_selection_back_event_allow_set(m_pEntry, EINA_TRUE); - elm_scroller_policy_set(m_pEntry, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); - elm_entry_autocapital_type_set(m_pEntry, ELM_AUTOCAPITAL_TYPE_NONE); - elm_entry_input_panel_return_key_type_set(m_pEntry, ELM_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH); - elm_object_focus_allow_set(m_pEntry, EINA_TRUE); - setText(m_pEntry, msgt("IDS_MSG_NPBODY_SEARCH"), "elm.guide"); - evas_object_show(m_pEntry); - - evas_object_smart_callback_add(m_pEntry, "changed", SMART_CALLBACK(MsgThreadSearchPanel, onEntryChanged), this);; - evas_object_event_callback_add(m_pEntry, EVAS_CALLBACK_KEY_DOWN, EVAS_EVENT_CALLBACK(MsgThreadSearchPanel, onKeyDown), this); - - Evas_Object *btn = createClearButton(m_pEntry); - evas_object_show(btn); - elm_object_focus_allow_set(btn, false); - evas_object_smart_callback_add(btn, "clicked", SMART_CALLBACK(MsgThreadSearchPanel, onClearButtonClicked), this); - elm_object_part_content_set(getEo(), "elm.swallow.button", btn); - - return m_pEntry; + m_pEntry = elm_entry_add(parent); + elm_entry_cnp_mode_set(m_pEntry, ELM_CNP_MODE_PLAINTEXT); + evas_object_size_hint_weight_set(m_pEntry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_pEntry, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_entry_editable_set(m_pEntry, EINA_TRUE); + elm_entry_single_line_set(m_pEntry, EINA_TRUE); + elm_entry_scrollable_set(m_pEntry, EINA_TRUE); + eext_entry_selection_back_event_allow_set(m_pEntry, EINA_TRUE); + elm_scroller_policy_set(m_pEntry, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); + elm_entry_autocapital_type_set(m_pEntry, ELM_AUTOCAPITAL_TYPE_NONE); + elm_entry_input_panel_return_key_type_set(m_pEntry, ELM_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH); + elm_object_focus_allow_set(m_pEntry, EINA_TRUE); + setText(m_pEntry, msgt("IDS_MSG_NPBODY_SEARCH"), "elm.guide"); + evas_object_show(m_pEntry); + + evas_object_smart_callback_add(m_pEntry, "changed", SMART_CALLBACK(MsgThreadSearchPanel, onEntryChanged), this);; + evas_object_event_callback_add(m_pEntry, EVAS_CALLBACK_KEY_DOWN, EVAS_EVENT_CALLBACK(MsgThreadSearchPanel, onKeyDown), this); + + Evas_Object *btn = createClearButton(m_pEntry); + evas_object_show(btn); + elm_object_focus_allow_set(btn, false); + evas_object_smart_callback_add(btn, "clicked", SMART_CALLBACK(MsgThreadSearchPanel, onClearButtonClicked), this); + elm_object_part_content_set(getEo(), "elm.swallow.button", btn); + + return m_pEntry; } Evas_Object *MsgThreadSearchPanel::createButton(Evas_Object *parent, const char *style) { - Evas_Object *button = elm_button_add(parent); - elm_object_style_set(button, style); - evas_object_show(button); - return button; + Evas_Object *button = elm_button_add(parent); + elm_object_style_set(button, style); + evas_object_show(button); + return button; } std::string MsgThreadSearchPanel::getEntryText() const { - std::string res; - const char *plainText = elm_entry_entry_get(m_pEntry); + std::string res; + const char *plainText = elm_entry_entry_get(m_pEntry); - if (plainText) { - char *text = elm_entry_markup_to_utf8(elm_entry_entry_get(m_pEntry)); - if (text) { - res.assign(text); - free(text); - } - } - return res; + if (plainText) { + char *text = elm_entry_markup_to_utf8(elm_entry_entry_get(m_pEntry)); + if (text) { + res.assign(text); + free(text); + } + } + return res; } void MsgThreadSearchPanel::onPostponedEntryFocus(void *data) { - MsgThreadSearchPanel *self = static_cast(data); - self->m_pEntryJob = nullptr; - elm_object_focus_set(self->m_pEntry, self->m_EntryFocus); + MsgThreadSearchPanel *self = static_cast(data); + self->m_pEntryJob = nullptr; + elm_object_focus_set(self->m_pEntry, self->m_EntryFocus); } void MsgThreadSearchPanel::setEntryFocus(bool focus) { - m_EntryFocus = focus; - if (!m_pEntryJob) - m_pEntryJob = ecore_job_add(onPostponedEntryFocus, this); + m_EntryFocus = focus; + if (!m_pEntryJob) + m_pEntryJob = ecore_job_add(onPostponedEntryFocus, this); } void MsgThreadSearchPanel::clearEntry() { - elm_entry_entry_set(m_pEntry, ""); + elm_entry_entry_set(m_pEntry, ""); } void MsgThreadSearchPanel::showClearButton(bool visible) { - const char *sig = visible ? "elm,action,show,button" : "elm,action,hide,button"; - emitSignal(sig, ""); + const char *sig = visible ? "elm,action,show,button" : "elm,action,hide,button"; + emitSignal(sig, ""); } void MsgThreadSearchPanel::onEntryChanged(Evas_Object *obj, void *eventInfo) { - showClearButton(!isEmpty()); - if (m_pListener) - m_pListener->onEntryChanged(*this); + showClearButton(!isEmpty()); + if (m_pListener) + m_pListener->onEntryChanged(*this); } void MsgThreadSearchPanel::onClearButtonClicked(Evas_Object *obj, void *eventInfo) { - clearEntry(); + clearEntry(); } void MsgThreadSearchPanel::onKeyDown(Evas_Object *obj, void *eventInfo) diff --git a/src/MsgThread/View/src/ThreadListViewItem.cpp b/src/MsgThread/View/src/ThreadListViewItem.cpp index 4de810e4..78f5da79 100644 --- a/src/MsgThread/View/src/ThreadListViewItem.cpp +++ b/src/MsgThread/View/src/ThreadListViewItem.cpp @@ -28,25 +28,25 @@ using namespace Msg; namespace { - ListItemStyleRef threadItemStyle = ListItemStyle::create("msg_thread"); + ListItemStyleRef threadItemStyle = ListItemStyle::create("msg_thread"); - const char *messagePart = "elm.text"; - const char *namePart = "elm.text.sub"; - const char *timePart = "elm.text.sub.end"; - const char *thumbnailPart = "elm.swallow.icon"; - const char *checkBoxPart = "elm.swallow.end"; - const char *statusPart = "elm.text.end"; - const char *iconPart = "elm.swallow.icon.1"; + const char *messagePart = "elm.text"; + const char *namePart = "elm.text.sub"; + const char *timePart = "elm.text.sub.end"; + const char *thumbnailPart = "elm.swallow.icon"; + const char *checkBoxPart = "elm.swallow.end"; + const char *statusPart = "elm.text.end"; + const char *iconPart = "elm.swallow.icon.1"; - const TextStyle unreadTextStyle(34, "#e43d3dFF"); - const TextStyle failedTextStyle(32, "#e43d3dFF"); - const TextStyle draftTextStyle(32, "#e43d3dFF"); - const TextStyle sendingTextStyle(32, "#969696FF"); + const TextStyle unreadTextStyle(34, "#e43d3dFF"); + const TextStyle failedTextStyle(32, "#e43d3dFF"); + const TextStyle draftTextStyle(32, "#e43d3dFF"); + const TextStyle sendingTextStyle(32, "#969696FF"); } ThreadListViewItem::ThreadListViewItem(Elm_Genlist_Item_Type type) - : ListItem(threadItemStyle, type) - , m_State(NormalState) + : ListItem(threadItemStyle, type) + , m_State(NormalState) { } @@ -56,109 +56,109 @@ ThreadListViewItem::~ThreadListViewItem() std::string ThreadListViewItem::getText(ListItem &item, const char *part) { - if (!strcmp(part, messagePart)) { - return getMessage(); - } else if (!strcmp(part, namePart)) { - return getName(); - } else if (!strcmp(part, timePart)) { - return getTime(); - } else if (!strcmp(part, statusPart)) { - if (m_State == StatusState) - return getStatus(); - } + if (!strcmp(part, messagePart)) { + return getMessage(); + } else if (!strcmp(part, namePart)) { + return getName(); + } else if (!strcmp(part, timePart)) { + return getTime(); + } else if (!strcmp(part, statusPart)) { + if (m_State == StatusState) + return getStatus(); + } - return ""; + return ""; } Evas_Object *ThreadListViewItem::getContent(ListItem &item, const char *part) { - Evas_Object *content = nullptr; + Evas_Object *content = nullptr; - if (!strcmp(part, thumbnailPart)) { - content = getThumbnail(); - } else if (!strcmp(part, iconPart)) { - if (m_State == IconState) { - content = getIcon(); - } - } + if (!strcmp(part, thumbnailPart)) { + content = getThumbnail(); + } else if (!strcmp(part, iconPart)) { + if (m_State == IconState) { + content = getIcon(); + } + } - return content; + return content; } const char *ThreadListViewItem::getCheckPart(ListItem &item) { - return checkBoxPart; + return checkBoxPart; } void ThreadListViewItem::setState(State state, bool updateUi) { - m_State = state; - if (updateUi) { - updateFields(iconPart, ELM_GENLIST_ITEM_FIELD_CONTENT); - updateFields(statusPart, ELM_GENLIST_ITEM_FIELD_TEXT); - } + m_State = state; + if (updateUi) { + updateFields(iconPart, ELM_GENLIST_ITEM_FIELD_CONTENT); + updateFields(statusPart, ELM_GENLIST_ITEM_FIELD_TEXT); + } } ThreadListViewItem::State ThreadListViewItem::getState() const { - return m_State; + return m_State; } Evas_Object *ThreadListViewItem::makeUnreadIcon(const std::string &text) const { - if (text.empty()) - return nullptr; - Evas_Object *icon = View::addLayout(*getOwner(), ICONS_EDJ_PATH, "badge"); - elm_object_part_text_set(icon, "elm.text.count", text.c_str()); - evas_object_show(icon); - return icon; + if (text.empty()) + return nullptr; + Evas_Object *icon = View::addLayout(*getOwner(), ICONS_EDJ_PATH, "badge"); + elm_object_part_text_set(icon, "elm.text.count", text.c_str()); + evas_object_show(icon); + return icon; } std::string ThreadListViewItem::getStatus() { - return std::string(); + return std::string(); } Evas_Object *ThreadListViewItem::getIcon() { - return nullptr; + return nullptr; } std::string ThreadListViewItem::decorateNameText(const std::string &text) const { - // Style set in edc - return text; + // Style set in edc + return text; } std::string ThreadListViewItem::decorateMessageText(const std::string &text) const { - // Style set in edc - return text; + // Style set in edc + return text; } std::string ThreadListViewItem::decorateTimeText(const std::string &text) const { - // Style set in edc - return text; + // Style set in edc + return text; } std::string ThreadListViewItem::decorateFailedText(const std::string &text) const { - return TextDecorator::make(text, failedTextStyle); + return TextDecorator::make(text, failedTextStyle); } std::string ThreadListViewItem::decorateSendingText(const std::string &text) const { - return TextDecorator::make(text, sendingTextStyle); + return TextDecorator::make(text, sendingTextStyle); } std::string ThreadListViewItem::decorateDraftText(const std::string &text) const { - return TextDecorator::make(text, draftTextStyle); + return TextDecorator::make(text, draftTextStyle); } void ThreadListViewItem::resetCheckMode(ListView &listView) { - for (ListItem *item: listView.getRealizedItems()) - item->emitSignal("elm,state,reset_check", "elm"); + for (ListItem *item: listView.getRealizedItems()) + item->emitSignal("elm,state,reset_check", "elm"); } diff --git a/src/Settings/Controller/inc/MsgOnSimCard.h b/src/Settings/Controller/inc/MsgOnSimCard.h index 75aee789..850369c8 100644 --- a/src/Settings/Controller/inc/MsgOnSimCard.h +++ b/src/Settings/Controller/inc/MsgOnSimCard.h @@ -31,83 +31,83 @@ #include "PopupList.h" namespace Msg { - class NaviFrameController; - class MsgSettings; - - /** - * @brief Visual representation of "Messages on SIM" list. - */ - class MsgOnSimCard - : public FrameController - , private IHwButtonListener - , private IListViewListener - , private IMsgStorageListener - , private ISystemSettingsManager { - public: - MsgOnSimCard(NaviFrameController &parent); - virtual ~MsgOnSimCard(); - - public: - /** - * @brief Switches to(from) selection mode. - * @param[in] show if true switches to selection mode, otherwise switches to normal mode. - * @param[in] resetCheck if true forces "Select all" checkbox to be unchecked by default. - */ - void showSelectAllItem(bool show, bool resetCheck = true); - - private: - void fillList(); - void showNoContent(); - - // NaviFrameItem: - virtual void onAttached(ViewItem &item); - virtual void onButtonClicked(NaviFrameItem &item, NaviButtonId buttonId); - void calcChecked(int &check, int &total) const; - int getItemsCount() const; - - // IListViewListener: - virtual void onListItemChecked(ListItem &listItem); - - // IHwButtonListener: - virtual void onHwMoreButtonClicked(); - virtual void onHwBackButtonClicked(); - - // ContextPopup callbacks: - void onCopyToDeviceItemPressed(PopupListItem &item); - void onDeleteItemPressed(PopupListItem &item); - - // IMsgStorageListener - virtual void onMsgStorageDelete(const MsgIdList &msgIdList); - - // ISystemSettingsManager: - virtual void onLanguageChanged(); - - private: - enum SimMode { - NormalMode, - CopyToDeviceMode, - DeleteMode - }; - - private: - void create(); - void showCopyDeletePopup(); - void setMode(SimMode mode); - void setNormalMode(); - void setDeleteMode(bool value); - void setCopyToDeviceMode(bool value); - void setTitleTranslatable(); - void setTitleWithButtons(bool value); - void deleteSelectedItems(); - void copySelectedItems(); - - private: - SimMsgLayout *m_pLayout; - NoContentLayout *m_pNoContent; - ListView *m_pList; - SimMode m_SimMode; - int m_CheckCount; - }; + class NaviFrameController; + class MsgSettings; + + /** + * @brief Visual representation of "Messages on SIM" list. + */ + class MsgOnSimCard + : public FrameController + , private IHwButtonListener + , private IListViewListener + , private IMsgStorageListener + , private ISystemSettingsManager { + public: + MsgOnSimCard(NaviFrameController &parent); + virtual ~MsgOnSimCard(); + + public: + /** + * @brief Switches to(from) selection mode. + * @param[in] show if true switches to selection mode, otherwise switches to normal mode. + * @param[in] resetCheck if true forces "Select all" checkbox to be unchecked by default. + */ + void showSelectAllItem(bool show, bool resetCheck = true); + + private: + void fillList(); + void showNoContent(); + + // NaviFrameItem: + virtual void onAttached(ViewItem &item); + virtual void onButtonClicked(NaviFrameItem &item, NaviButtonId buttonId); + void calcChecked(int &check, int &total) const; + int getItemsCount() const; + + // IListViewListener: + virtual void onListItemChecked(ListItem &listItem); + + // IHwButtonListener: + virtual void onHwMoreButtonClicked(); + virtual void onHwBackButtonClicked(); + + // ContextPopup callbacks: + void onCopyToDeviceItemPressed(PopupListItem &item); + void onDeleteItemPressed(PopupListItem &item); + + // IMsgStorageListener + virtual void onMsgStorageDelete(const MsgIdList &msgIdList); + + // ISystemSettingsManager: + virtual void onLanguageChanged(); + + private: + enum SimMode { + NormalMode, + CopyToDeviceMode, + DeleteMode + }; + + private: + void create(); + void showCopyDeletePopup(); + void setMode(SimMode mode); + void setNormalMode(); + void setDeleteMode(bool value); + void setCopyToDeviceMode(bool value); + void setTitleTranslatable(); + void setTitleWithButtons(bool value); + void deleteSelectedItems(); + void copySelectedItems(); + + private: + SimMsgLayout *m_pLayout; + NoContentLayout *m_pNoContent; + ListView *m_pList; + SimMode m_SimMode; + int m_CheckCount; + }; } #endif /* MsgOnSimCard_h_h */ diff --git a/src/Settings/Controller/inc/Settings.h b/src/Settings/Controller/inc/Settings.h index 5e901ef0..0338f094 100644 --- a/src/Settings/Controller/inc/Settings.h +++ b/src/Settings/Controller/inc/Settings.h @@ -26,108 +26,108 @@ #include "SettingsSound.h" namespace Msg { - class NaviFrameController; - class MsgSettings; - class IMsgSettingsListener; - - /** - * @brief A core-class responsible for a whole lifecycle of settings-module and for managing - * sub-components of message settings. - */ - class Settings - : public FrameController - , private IListViewListener - , private ISettingsListViewItemListener - , private IMsgSettingsListener - , private ISystemSettingsManager { - public: - /** - * @brief A constructor of Settings object based on outside parent object. - * @param[in] parent an object responsible for automatic removing of Settings instance. - */ - Settings(NaviFrameController &parent); - virtual ~Settings(); - - private: - // NaviFrameItem: - virtual void onAttached(ViewItem &item); - virtual void onButtonClicked(NaviFrameItem &item, NaviButtonId buttonId); - - // IListViewListener: - virtual void onListItemSelected(ListItem &listItem); - - // ISettingsListViewItemListener - virtual void onCheckButtonChanged(SettingsListViewItem &item); - - // IMsgSettingsListener - virtual void onRingtoneChanged(MsgSettings &msgSetting); - - // ISystemSettingsManager: - virtual void onLanguageChanged(); - - private: - MsgSettings &getMsgSettings(); - const MsgSettings &getMsgSettings() const; - - void setMmsAutoRetrRoamingBackup(bool value); - bool getMmsAutoRetrRoamingBackup() const; - bool isExistingMmsAutoRetrRoamingBackup() const; - - void create(); - void fillList(); - void updateItems(); - void appendGroupItem(const std::string &title); - void callItemHandler(SettingsListItem &item); - SettingsListItem *appendItem(ListItemStyleRef style, - SettingsListItem::MethodHandler handler, - const std::string &mainText, - const std::string &subText = std::string()); - - void appendAlertsItem(); - void appendSoundItem(); - void appendVibrationItem(); - void appendDelivReportSmsItem(); - void appendMsgOnSimItem(); - void appendDelivReportMmsItem(); - void appendReadReportItem(); - void appendAutoRetItem(); - void appendAutoRetRoamingItem(); - - void updateAlertsItem(); - void updateSoundItem(); - void updateVibrationItem(); - void updateDelivReportSmsItem(); - void updateDelivReportMmsItem(); - void updateReadReportItem(); - void updateAutoRetItem(); - void updateAutoRetRoamingItem(); - - void alertsItemHandler(SettingsListItem &item); - void soundItemHandler(SettingsListItem &item); - void vibrationItemHandler(SettingsListItem &item); - void delivReportSmsItemHandler(SettingsListItem &item); - void msgOnSimItemHandler(SettingsListItem &item); - void delivReportMmsItemHandler(SettingsListItem &item); - void readReportItemHandler(SettingsListItem &item); - void autoRetItemHandler(SettingsListItem &item); - void autoRetRoamingItemHandler(SettingsListItem &item); - - bool isAutoRetRoamngDisabled() const; - bool getAutoRetRoamng(); - - private: - ListView *m_pList; - SettingsListItem *m_pAlertsItem; - SettingsListItem *m_pSoundItem; - SettingsListItem *m_pVibrationItem; - SettingsListItem *m_pDelivReportSmsItem; - SettingsListItem *m_pMsgOnSimItem; - SettingsListItem *m_pDelivReportMmsItem; - SettingsListItem *m_pReadReportItem; - SettingsListItem *m_pAutoRetItem; - SettingsListItem *m_pAutoRetRoamingItem; - SettingsSound m_SoundPicker; - }; + class NaviFrameController; + class MsgSettings; + class IMsgSettingsListener; + + /** + * @brief A core-class responsible for a whole lifecycle of settings-module and for managing + * sub-components of message settings. + */ + class Settings + : public FrameController + , private IListViewListener + , private ISettingsListViewItemListener + , private IMsgSettingsListener + , private ISystemSettingsManager { + public: + /** + * @brief A constructor of Settings object based on outside parent object. + * @param[in] parent an object responsible for automatic removing of Settings instance. + */ + Settings(NaviFrameController &parent); + virtual ~Settings(); + + private: + // NaviFrameItem: + virtual void onAttached(ViewItem &item); + virtual void onButtonClicked(NaviFrameItem &item, NaviButtonId buttonId); + + // IListViewListener: + virtual void onListItemSelected(ListItem &listItem); + + // ISettingsListViewItemListener + virtual void onCheckButtonChanged(SettingsListViewItem &item); + + // IMsgSettingsListener + virtual void onRingtoneChanged(MsgSettings &msgSetting); + + // ISystemSettingsManager: + virtual void onLanguageChanged(); + + private: + MsgSettings &getMsgSettings(); + const MsgSettings &getMsgSettings() const; + + void setMmsAutoRetrRoamingBackup(bool value); + bool getMmsAutoRetrRoamingBackup() const; + bool isExistingMmsAutoRetrRoamingBackup() const; + + void create(); + void fillList(); + void updateItems(); + void appendGroupItem(const std::string &title); + void callItemHandler(SettingsListItem &item); + SettingsListItem *appendItem(ListItemStyleRef style, + SettingsListItem::MethodHandler handler, + const std::string &mainText, + const std::string &subText = std::string()); + + void appendAlertsItem(); + void appendSoundItem(); + void appendVibrationItem(); + void appendDelivReportSmsItem(); + void appendMsgOnSimItem(); + void appendDelivReportMmsItem(); + void appendReadReportItem(); + void appendAutoRetItem(); + void appendAutoRetRoamingItem(); + + void updateAlertsItem(); + void updateSoundItem(); + void updateVibrationItem(); + void updateDelivReportSmsItem(); + void updateDelivReportMmsItem(); + void updateReadReportItem(); + void updateAutoRetItem(); + void updateAutoRetRoamingItem(); + + void alertsItemHandler(SettingsListItem &item); + void soundItemHandler(SettingsListItem &item); + void vibrationItemHandler(SettingsListItem &item); + void delivReportSmsItemHandler(SettingsListItem &item); + void msgOnSimItemHandler(SettingsListItem &item); + void delivReportMmsItemHandler(SettingsListItem &item); + void readReportItemHandler(SettingsListItem &item); + void autoRetItemHandler(SettingsListItem &item); + void autoRetRoamingItemHandler(SettingsListItem &item); + + bool isAutoRetRoamngDisabled() const; + bool getAutoRetRoamng(); + + private: + ListView *m_pList; + SettingsListItem *m_pAlertsItem; + SettingsListItem *m_pSoundItem; + SettingsListItem *m_pVibrationItem; + SettingsListItem *m_pDelivReportSmsItem; + SettingsListItem *m_pMsgOnSimItem; + SettingsListItem *m_pDelivReportMmsItem; + SettingsListItem *m_pReadReportItem; + SettingsListItem *m_pAutoRetItem; + SettingsListItem *m_pAutoRetRoamingItem; + SettingsSound m_SoundPicker; + }; } #endif /* SettingFrame_h_ */ diff --git a/src/Settings/Controller/inc/SettingsListItem.h b/src/Settings/Controller/inc/SettingsListItem.h index a4741482..a8ab77a6 100644 --- a/src/Settings/Controller/inc/SettingsListItem.h +++ b/src/Settings/Controller/inc/SettingsListItem.h @@ -20,45 +20,45 @@ #include "SettingsListViewItem.h" namespace Msg { - class Settings; + class Settings; - /** - * @brief Visual representation of particular element of message-settings list. - */ - class SettingsListItem - : public SettingsListViewItem { - public: - typedef void (Settings::*MethodHandler)(SettingsListItem &item); /**< A delegate fired when user taps on particular settings list element. */ + /** + * @brief Visual representation of particular element of message-settings list. + */ + class SettingsListItem + : public SettingsListViewItem { + public: + typedef void (Settings::*MethodHandler)(SettingsListItem &item); /**< A delegate fired when user taps on particular settings list element. */ - public: - /** - * @brief Constructs settings list item based on style and "on-tap" handler passed from outside. - * @param[in] style a style to be applied to settings list item - * @param[in] method to handle tap on this settings list element. - */ - inline SettingsListItem(const ListItemStyleRef &style, MethodHandler method); - virtual ~SettingsListItem() {}; + public: + /** + * @brief Constructs settings list item based on style and "on-tap" handler passed from outside. + * @param[in] style a style to be applied to settings list item + * @param[in] method to handle tap on this settings list element. + */ + inline SettingsListItem(const ListItemStyleRef &style, MethodHandler method); + virtual ~SettingsListItem() {}; - /** - * @brief gets "on-tap" handler. - * @return a handler to be returned. - */ - inline MethodHandler getHandler() const; + /** + * @brief gets "on-tap" handler. + * @return a handler to be returned. + */ + inline MethodHandler getHandler() const; - private: - MethodHandler m_Handler; - }; + private: + MethodHandler m_Handler; + }; - inline SettingsListItem::SettingsListItem(const ListItemStyleRef &style, MethodHandler method) - : SettingsListViewItem(style) - , m_Handler(method) - { - } + inline SettingsListItem::SettingsListItem(const ListItemStyleRef &style, MethodHandler method) + : SettingsListViewItem(style) + , m_Handler(method) + { + } - inline SettingsListItem::MethodHandler SettingsListItem::getHandler() const - { - return m_Handler; - } + inline SettingsListItem::MethodHandler SettingsListItem::getHandler() const + { + return m_Handler; + } } #endif // SettingsListItem_h_ diff --git a/src/Settings/Controller/inc/SettingsSound.h b/src/Settings/Controller/inc/SettingsSound.h index 719e1dd4..c4afa23c 100644 --- a/src/Settings/Controller/inc/SettingsSound.h +++ b/src/Settings/Controller/inc/SettingsSound.h @@ -20,32 +20,32 @@ #include "AppControlLauncher.h" namespace Msg { - class MsgSettings; - - /** - * @brief This class is aimed to launch preinstalled utility from settings-app that allows to chose message-alert sound. - */ - class SettingsSound - : public AppControlHandle { - public: - /** - * @brief Constructs an instance of SettingsSound based on message-service settings wrapper passed from outside. - * @param[in] settingsHandle an instance of message-settings api wrapper. - */ - SettingsSound(MsgSettings &settingsHandle); - virtual ~SettingsSound(); - - /** - * @brief launches preinstalled sound-picker utility via app-control. - */ - bool launch(); - - private: - virtual void onReply(app_control_h request, app_control_h reply, app_control_result_e result); - - private: - MsgSettings &m_SettingsHandle; - }; + class MsgSettings; + + /** + * @brief This class is aimed to launch preinstalled utility from settings-app that allows to chose message-alert sound. + */ + class SettingsSound + : public AppControlHandle { + public: + /** + * @brief Constructs an instance of SettingsSound based on message-service settings wrapper passed from outside. + * @param[in] settingsHandle an instance of message-settings api wrapper. + */ + SettingsSound(MsgSettings &settingsHandle); + virtual ~SettingsSound(); + + /** + * @brief launches preinstalled sound-picker utility via app-control. + */ + bool launch(); + + private: + virtual void onReply(app_control_h request, app_control_h reply, app_control_result_e result); + + private: + MsgSettings &m_SettingsHandle; + }; } diff --git a/src/Settings/Controller/inc/SimListViewItem.h b/src/Settings/Controller/inc/SimListViewItem.h index 96dedf5e..33e5b9e2 100644 --- a/src/Settings/Controller/inc/SimListViewItem.h +++ b/src/Settings/Controller/inc/SimListViewItem.h @@ -22,42 +22,42 @@ #include "MessageSMS.h" namespace Msg { - /** - * @brief Visual representation of an element in "Messages on SIM" list. - */ - class SimListViewItem - : public ListItem { - public: - /** - * @brief Creates element of "Messages on SIM" list based on message-service structure and genlist item type passed from outside. - * @param[in] msg a reference to message-service structure wrapped into class from Common module. - * @param[in] type type of genlist-item. - */ - SimListViewItem(const MessageSMS &msg, Elm_Genlist_Item_Type type = ELM_GENLIST_ITEM_NONE); - virtual ~SimListViewItem(); - - /** - * @brief gets message-id - * @return id of message associated with current list-element. - */ - MsgId getMsgId() const; - - protected: - virtual std::string getName() const; - virtual std::string getMessage() const; - - private: - void updateModel(const MessageSMS &msg); - virtual const char *getCheckPart(ListItem &item); - // ListItem: - virtual std::string getText(ListItem &item, const char *part); - - private: - std::string m_Name; - std::string m_MessageText; - std::string m_Time; - MsgId m_MsgId; - }; + /** + * @brief Visual representation of an element in "Messages on SIM" list. + */ + class SimListViewItem + : public ListItem { + public: + /** + * @brief Creates element of "Messages on SIM" list based on message-service structure and genlist item type passed from outside. + * @param[in] msg a reference to message-service structure wrapped into class from Common module. + * @param[in] type type of genlist-item. + */ + SimListViewItem(const MessageSMS &msg, Elm_Genlist_Item_Type type = ELM_GENLIST_ITEM_NONE); + virtual ~SimListViewItem(); + + /** + * @brief gets message-id + * @return id of message associated with current list-element. + */ + MsgId getMsgId() const; + + protected: + virtual std::string getName() const; + virtual std::string getMessage() const; + + private: + void updateModel(const MessageSMS &msg); + virtual const char *getCheckPart(ListItem &item); + // ListItem: + virtual std::string getText(ListItem &item, const char *part); + + private: + std::string m_Name; + std::string m_MessageText; + std::string m_Time; + MsgId m_MsgId; + }; } #endif // SimListViewItem_h_ diff --git a/src/Settings/Controller/src/MsgOnSimCard.cpp b/src/Settings/Controller/src/MsgOnSimCard.cpp index cc751720..ba670055 100644 --- a/src/Settings/Controller/src/MsgOnSimCard.cpp +++ b/src/Settings/Controller/src/MsgOnSimCard.cpp @@ -31,297 +31,297 @@ using namespace Msg; MsgOnSimCard::MsgOnSimCard(NaviFrameController &parent) - : FrameController(parent) - , m_pLayout(nullptr) - , m_pNoContent(nullptr) - , m_pList(nullptr) - , m_SimMode(NormalMode) - , m_CheckCount(0) + : FrameController(parent) + , m_pLayout(nullptr) + , m_pNoContent(nullptr) + , m_pList(nullptr) + , m_SimMode(NormalMode) + , m_CheckCount(0) { - create(); + create(); } MsgOnSimCard::~MsgOnSimCard() { - getApp().getMsgEngine().getStorage().removeListener(*this); - getApp().getSysSettingsManager().removeListener(*this); + getApp().getMsgEngine().getStorage().removeListener(*this); + getApp().getSysSettingsManager().removeListener(*this); } void MsgOnSimCard::create() { - m_pLayout = new SimMsgLayout(getParent()); - m_pLayout->show(); - - m_pNoContent = new NoContentLayout(*m_pLayout); - m_pNoContent->setText(msgt("IDS_MSG_NPBODY_NO_MESSAGES_ON_SIM_CARD")); - m_pNoContent->setHelpText(msgt("IDS_MSG_BODY_AFTER_YOU_COPY_MESSAGES_TO_THE_SIM_CARD_THEY_WILL_BE_SHOWN_HERE")); - - m_pList = new ListView(*m_pLayout); - m_pList->setListener(this); - m_pList->expand(); - m_pList->setMultiSelection(false); - m_pList->setMode(ELM_LIST_COMPRESS); - fillList(); - - m_pLayout->setNoContent(*m_pNoContent); - m_pLayout->setSimMsgList(*m_pList); - showNoContent(); - - getApp().getMsgEngine().getStorage().addListener(*this); - getApp().getSysSettingsManager().addListener(*this); + m_pLayout = new SimMsgLayout(getParent()); + m_pLayout->show(); + + m_pNoContent = new NoContentLayout(*m_pLayout); + m_pNoContent->setText(msgt("IDS_MSG_NPBODY_NO_MESSAGES_ON_SIM_CARD")); + m_pNoContent->setHelpText(msgt("IDS_MSG_BODY_AFTER_YOU_COPY_MESSAGES_TO_THE_SIM_CARD_THEY_WILL_BE_SHOWN_HERE")); + + m_pList = new ListView(*m_pLayout); + m_pList->setListener(this); + m_pList->expand(); + m_pList->setMultiSelection(false); + m_pList->setMode(ELM_LIST_COMPRESS); + fillList(); + + m_pLayout->setNoContent(*m_pNoContent); + m_pLayout->setSimMsgList(*m_pList); + showNoContent(); + + getApp().getMsgEngine().getStorage().addListener(*this); + getApp().getSysSettingsManager().addListener(*this); } void MsgOnSimCard::fillList() { - MessageSMSListRef list = getMsgEngine().getStorage().getSimMsgList(); - int length = list->getLength(); - for (int i = 0; i < length; ++i) { - SimListViewItem *item = new SimListViewItem(list->at(i)); - m_pList->appendItem(*item); - } + MessageSMSListRef list = getMsgEngine().getStorage().getSimMsgList(); + int length = list->getLength(); + for (int i = 0; i < length; ++i) { + SimListViewItem *item = new SimListViewItem(list->at(i)); + m_pList->appendItem(*item); + } } void MsgOnSimCard::showNoContent() { - m_pLayout->setNoContentLayoutVisible(m_pList->isEmpty()); - m_pLayout->setSimMsgListVisible(!m_pList->isEmpty()); + m_pLayout->setNoContentLayoutVisible(m_pList->isEmpty()); + m_pLayout->setSimMsgListVisible(!m_pList->isEmpty()); } void MsgOnSimCard::onAttached(ViewItem &item) { - FrameController::onAttached(item); - getNaviBar().setColor(NaviBar::NaviWhiteColorId); - setTitleWithButtons(false); - setHwButtonListener(*m_pList, this); - setContent(*m_pLayout); + FrameController::onAttached(item); + getNaviBar().setColor(NaviBar::NaviWhiteColorId); + setTitleWithButtons(false); + setHwButtonListener(*m_pList, this); + setContent(*m_pLayout); } void MsgOnSimCard::onButtonClicked(NaviFrameItem &item, NaviButtonId buttonId) { - if (buttonId == NaviOkButtonId) { - if (m_SimMode == DeleteMode) { - deleteSelectedItems(); - } else if (m_SimMode == CopyToDeviceMode) { - copySelectedItems(); - } - } else if (buttonId == NaviPrevButtonId) { - pop(); - } - setMode(NormalMode); + if (buttonId == NaviOkButtonId) { + if (m_SimMode == DeleteMode) { + deleteSelectedItems(); + } else if (m_SimMode == CopyToDeviceMode) { + copySelectedItems(); + } + } else if (buttonId == NaviPrevButtonId) { + pop(); + } + setMode(NormalMode); } void MsgOnSimCard::onListItemChecked(ListItem &listItem) { - if (dynamic_cast(&listItem)) { - bool checked = listItem.getCheckedState(); - m_pList->checkAllItems(checked); - } - - int check = 0; - int total = 0; - calcChecked(check, total); - m_CheckCount = check; - getNaviBar().disabledButton(NaviOkButtonId, m_CheckCount == 0); - bool all = (check == total) ? true : false; - m_pList->getFirstItem()->setCheckedState(all, true); - - setTitleTranslatable(); + if (dynamic_cast(&listItem)) { + bool checked = listItem.getCheckedState(); + m_pList->checkAllItems(checked); + } + + int check = 0; + int total = 0; + calcChecked(check, total); + m_CheckCount = check; + getNaviBar().disabledButton(NaviOkButtonId, m_CheckCount == 0); + bool all = (check == total) ? true : false; + m_pList->getFirstItem()->setCheckedState(all, true); + + setTitleTranslatable(); } void MsgOnSimCard::onHwMoreButtonClicked() { - showCopyDeletePopup(); + showCopyDeletePopup(); } void MsgOnSimCard::onHwBackButtonClicked() { - if (m_SimMode == CopyToDeviceMode || m_SimMode == DeleteMode) - setNormalMode(); - else - pop(); + if (m_SimMode == CopyToDeviceMode || m_SimMode == DeleteMode) + setNormalMode(); + else + pop(); } void MsgOnSimCard::showCopyDeletePopup() { - if (!m_pList->isEmpty()) { - PopupList &listPopup = getApp().getPopupManager().getMorePopup(); - listPopup.appendItem(msg("IDS_MSG_OPT_COPY_TO_DEVICE_ABB"), POPUPLIST_ITEM_PRESSED_CB(MsgOnSimCard, onCopyToDeviceItemPressed), this); - listPopup.appendItem(msg("IDS_MSG_OPT_DELETE"), POPUPLIST_ITEM_PRESSED_CB(MsgOnSimCard, onDeleteItemPressed), this); - listPopup.show(); - } + if (!m_pList->isEmpty()) { + PopupList &listPopup = getApp().getPopupManager().getMorePopup(); + listPopup.appendItem(msg("IDS_MSG_OPT_COPY_TO_DEVICE_ABB"), POPUPLIST_ITEM_PRESSED_CB(MsgOnSimCard, onCopyToDeviceItemPressed), this); + listPopup.appendItem(msg("IDS_MSG_OPT_DELETE"), POPUPLIST_ITEM_PRESSED_CB(MsgOnSimCard, onDeleteItemPressed), this); + listPopup.show(); + } } void MsgOnSimCard::onCopyToDeviceItemPressed(PopupListItem &item) { - item.getParent().destroy(); - setMode(CopyToDeviceMode); + item.getParent().destroy(); + setMode(CopyToDeviceMode); } void MsgOnSimCard::onDeleteItemPressed(PopupListItem &item) { - item.getParent().destroy(); - setMode(DeleteMode); + item.getParent().destroy(); + setMode(DeleteMode); } void MsgOnSimCard::onMsgStorageDelete(const MsgIdList &msgIdList) { - auto simListItems = m_pList->getItems(); - for (auto &itemId: msgIdList) { - for (auto *simItem : simListItems) { - if (simItem->getMsgId() == itemId) { - simItem->destroy(); - break; - } - } - } - showNoContent(); + auto simListItems = m_pList->getItems(); + for (auto &itemId: msgIdList) { + for (auto *simItem : simListItems) { + if (simItem->getMsgId() == itemId) { + simItem->destroy(); + break; + } + } + } + showNoContent(); } void MsgOnSimCard::setMode(SimMode mode) { - if (m_SimMode == mode) - return; - - switch (mode) { - case CopyToDeviceMode: - setCopyToDeviceMode(true); - break; - case DeleteMode: - setDeleteMode(true); - break; - case NormalMode: - setNormalMode(); - break; - default: - MSG_ASSERT(false, "Not supported mode"); - break; - } + if (m_SimMode == mode) + return; + + switch (mode) { + case CopyToDeviceMode: + setCopyToDeviceMode(true); + break; + case DeleteMode: + setDeleteMode(true); + break; + case NormalMode: + setNormalMode(); + break; + default: + MSG_ASSERT(false, "Not supported mode"); + break; + } } void MsgOnSimCard::setNormalMode() { - // Reset previus mode: - switch (m_SimMode) { - case CopyToDeviceMode: - setCopyToDeviceMode(false); - break; - case DeleteMode: - setDeleteMode(false); - break; - default: - break; - } - - m_SimMode = NormalMode; - m_CheckCount = 0; - setTitleTranslatable(); + // Reset previus mode: + switch (m_SimMode) { + case CopyToDeviceMode: + setCopyToDeviceMode(false); + break; + case DeleteMode: + setDeleteMode(false); + break; + default: + break; + } + + m_SimMode = NormalMode; + m_CheckCount = 0; + setTitleTranslatable(); } void MsgOnSimCard::setCopyToDeviceMode(bool value) { - if (value) - m_SimMode = CopyToDeviceMode; + if (value) + m_SimMode = CopyToDeviceMode; - setTitleWithButtons(value); + setTitleWithButtons(value); } void MsgOnSimCard::setDeleteMode(bool value) { - if (value) - m_SimMode = DeleteMode; + if (value) + m_SimMode = DeleteMode; - setTitleWithButtons(value); + setTitleWithButtons(value); } void MsgOnSimCard::setTitleTranslatable() { - if (m_SimMode == NormalMode) - getNaviBar().setTitle(msg("IDS_MSG_HEADER_MESSAGES_ON_SIM_CARD_ABB")); - else if (m_SimMode == DeleteMode || m_SimMode == CopyToDeviceMode) - getNaviBar().setTitle(msgArgs("IDS_MSG_HEADER_PD_SELECTED_ABB3", m_CheckCount)); + if (m_SimMode == NormalMode) + getNaviBar().setTitle(msg("IDS_MSG_HEADER_MESSAGES_ON_SIM_CARD_ABB")); + else if (m_SimMode == DeleteMode || m_SimMode == CopyToDeviceMode) + getNaviBar().setTitle(msgArgs("IDS_MSG_HEADER_PD_SELECTED_ABB3", m_CheckCount)); } void MsgOnSimCard::setTitleWithButtons(bool value) { - setTitleTranslatable(); - - getNaviBar().clear(); - getNaviBar().showButton(NaviOkButtonId, value); - if (value) { - if (m_SimMode == DeleteMode) - getNaviBar().setButtonText(NaviOkButtonId, msgt("IDS_MSG_ACBUTTON_DELETE_ABB")); - else - getNaviBar().setButtonText(NaviOkButtonId, msgt("IDS_MSG_ACBUTTON_DONE_ABB")); - } - getNaviBar().disabledButton(NaviOkButtonId, true); - getNaviBar().showButton(NaviCancelButtonId, value); - getNaviBar().showButton(NaviPrevButtonId, !value); - - m_pList->setCheckMode(value); - m_pList->checkAllItems(false, true); - showSelectAllItem(value); + setTitleTranslatable(); + + getNaviBar().clear(); + getNaviBar().showButton(NaviOkButtonId, value); + if (value) { + if (m_SimMode == DeleteMode) + getNaviBar().setButtonText(NaviOkButtonId, msgt("IDS_MSG_ACBUTTON_DELETE_ABB")); + else + getNaviBar().setButtonText(NaviOkButtonId, msgt("IDS_MSG_ACBUTTON_DONE_ABB")); + } + getNaviBar().disabledButton(NaviOkButtonId, true); + getNaviBar().showButton(NaviCancelButtonId, value); + getNaviBar().showButton(NaviPrevButtonId, !value); + + m_pList->setCheckMode(value); + m_pList->checkAllItems(false, true); + showSelectAllItem(value); } void MsgOnSimCard::deleteSelectedItems() { - auto items = m_pList->getItems(); + auto items = m_pList->getItems(); - MsgIdList messages; - for (auto *item : items) { - if (item->getCheckedState()) - messages.push_back(item->getMsgId()); - } + MsgIdList messages; + for (auto *item : items) { + if (item->getCheckedState()) + messages.push_back(item->getMsgId()); + } - getApp().getMsgEngine().getStorage().deleteMessages(messages); + getApp().getMsgEngine().getStorage().deleteMessages(messages); } void MsgOnSimCard::copySelectedItems() { - auto items = m_pList->getItems(); - for (auto *item : items) { - if (item->getCheckedState()) { - MessageRef msg = getApp().getMsgEngine().getStorage().getMessage(item->getMsgId()); - if (msg) { - msg->setMessageStorageType(Message::MS_Phone); - getApp().getMsgEngine().getStorage().saveMessage(*msg, false); - } - } - } - notification_status_message_post(msg("IDS_MSG_TPOP_SELECTED_MESSAGES_COPIED_TO_MOBILE_DEVICE").cStr()); + auto items = m_pList->getItems(); + for (auto *item : items) { + if (item->getCheckedState()) { + MessageRef msg = getApp().getMsgEngine().getStorage().getMessage(item->getMsgId()); + if (msg) { + msg->setMessageStorageType(Message::MS_Phone); + getApp().getMsgEngine().getStorage().saveMessage(*msg, false); + } + } + } + notification_status_message_post(msg("IDS_MSG_TPOP_SELECTED_MESSAGES_COPIED_TO_MOBILE_DEVICE").cStr()); } void MsgOnSimCard::showSelectAllItem(bool show, bool resetCheck) { - SelectAllListItem *item = dynamic_cast(m_pList->getFirstItem()); - - if (show) { - if (!item) { - item = new SelectAllListItem; - m_pList->prependItem(*item); - } - - if (item && resetCheck) - item->setCheckedState(false, true); - } else { - if (item) - item->destroy(); - } + SelectAllListItem *item = dynamic_cast(m_pList->getFirstItem()); + + if (show) { + if (!item) { + item = new SelectAllListItem; + m_pList->prependItem(*item); + } + + if (item && resetCheck) + item->setCheckedState(false, true); + } else { + if (item) + item->destroy(); + } } void MsgOnSimCard::calcChecked(int &check, int &total) const { - check = 0; - total = 0; - auto items = m_pList->getItems(); - for (ListItem *item: items) { - if (item->getCheckedState()) - ++check; - ++total; - } + check = 0; + total = 0; + auto items = m_pList->getItems(); + for (ListItem *item: items) { + if (item->getCheckedState()) + ++check; + ++total; + } } void MsgOnSimCard::onLanguageChanged() { - MSG_LOG(""); - setTitleTranslatable(); + MSG_LOG(""); + setTitleTranslatable(); } diff --git a/src/Settings/Controller/src/Settings.cpp b/src/Settings/Controller/src/Settings.cpp index b79f4aeb..1ad6abcf 100644 --- a/src/Settings/Controller/src/Settings.cpp +++ b/src/Settings/Controller/src/Settings.cpp @@ -35,373 +35,373 @@ using namespace Msg; #define KEY_AUTO_RETRIEVE_WHILE_ROAMING_BACKUP_KEY PREF_PREFX"/auto_retrieve_while_roaming_backup" Settings::Settings(NaviFrameController &parent) - : FrameController(parent) - , m_pList(nullptr) - , m_pAlertsItem(nullptr) - , m_pSoundItem(nullptr) - , m_pVibrationItem(nullptr) - , m_pDelivReportSmsItem(nullptr) - , m_pMsgOnSimItem(nullptr) - , m_pDelivReportMmsItem(nullptr) - , m_pReadReportItem(nullptr) - , m_pAutoRetItem(nullptr) - , m_pAutoRetRoamingItem(nullptr) - , m_SoundPicker(getMsgEngine().getSettings()) -{ - create(); + : FrameController(parent) + , m_pList(nullptr) + , m_pAlertsItem(nullptr) + , m_pSoundItem(nullptr) + , m_pVibrationItem(nullptr) + , m_pDelivReportSmsItem(nullptr) + , m_pMsgOnSimItem(nullptr) + , m_pDelivReportMmsItem(nullptr) + , m_pReadReportItem(nullptr) + , m_pAutoRetItem(nullptr) + , m_pAutoRetRoamingItem(nullptr) + , m_SoundPicker(getMsgEngine().getSettings()) +{ + create(); } Settings::~Settings() { - getMsgSettings().removeListener(*this); - getApp().getSysSettingsManager().removeListener(*this); + getMsgSettings().removeListener(*this); + getApp().getSysSettingsManager().removeListener(*this); } void Settings::create() { - if (!isExistingMmsAutoRetrRoamingBackup()) - setMmsAutoRetrRoamingBackup(getMsgSettings().getMmsAutoRetrRoaming()); + if (!isExistingMmsAutoRetrRoamingBackup()) + setMmsAutoRetrRoamingBackup(getMsgSettings().getMmsAutoRetrRoaming()); - m_pList = new ListView(getParent()); - m_pList->setListener(this); - m_pList->expand(); - m_pList->setMultiSelection(false); - m_pList->show(); - m_pList->setMode(ELM_LIST_COMPRESS); - fillList(); - updateItems(); - getMsgSettings().addListener(*this); - getApp().getSysSettingsManager().addListener(*this); + m_pList = new ListView(getParent()); + m_pList->setListener(this); + m_pList->expand(); + m_pList->setMultiSelection(false); + m_pList->show(); + m_pList->setMode(ELM_LIST_COMPRESS); + fillList(); + updateItems(); + getMsgSettings().addListener(*this); + getApp().getSysSettingsManager().addListener(*this); } MsgSettings &Settings::getMsgSettings() { - return getMsgEngine().getSettings(); + return getMsgEngine().getSettings(); } const MsgSettings &Settings::getMsgSettings() const { - return getMsgEngine().getSettings(); + return getMsgEngine().getSettings(); } void Settings::setMmsAutoRetrRoamingBackup(bool value) { - preference_set_boolean(KEY_AUTO_RETRIEVE_WHILE_ROAMING_BACKUP_KEY, value); + preference_set_boolean(KEY_AUTO_RETRIEVE_WHILE_ROAMING_BACKUP_KEY, value); } bool Settings::getMmsAutoRetrRoamingBackup() const { - bool value = false; - preference_get_boolean(KEY_AUTO_RETRIEVE_WHILE_ROAMING_BACKUP_KEY, &value); - return value; + bool value = false; + preference_get_boolean(KEY_AUTO_RETRIEVE_WHILE_ROAMING_BACKUP_KEY, &value); + return value; } bool Settings::isExistingMmsAutoRetrRoamingBackup() const { - bool value = false; - preference_is_existing(KEY_AUTO_RETRIEVE_WHILE_ROAMING_BACKUP_KEY, &value); - return value; + bool value = false; + preference_is_existing(KEY_AUTO_RETRIEVE_WHILE_ROAMING_BACKUP_KEY, &value); + return value; } void Settings::fillList() { - appendGroupItem("IDS_MSGS_BODY_NOTIFICATIONS"); - appendAlertsItem(); - appendSoundItem(); - appendVibrationItem(); + appendGroupItem("IDS_MSGS_BODY_NOTIFICATIONS"); + appendAlertsItem(); + appendSoundItem(); + appendVibrationItem(); - appendGroupItem("IDS_MSGF_BODY_TEXT_MESSAGES"); - appendDelivReportSmsItem(); - appendMsgOnSimItem(); + appendGroupItem("IDS_MSGF_BODY_TEXT_MESSAGES"); + appendDelivReportSmsItem(); + appendMsgOnSimItem(); - appendGroupItem("IDS_MSGF_BODY_MULTIMEDIA_MESSAGE"); - appendDelivReportMmsItem(); - appendReadReportItem(); - appendAutoRetItem(); - appendAutoRetRoamingItem(); + appendGroupItem("IDS_MSGF_BODY_MULTIMEDIA_MESSAGE"); + appendDelivReportMmsItem(); + appendReadReportItem(); + appendAutoRetItem(); + appendAutoRetRoamingItem(); } void Settings::updateItems() { - updateAlertsItem(); - updateSoundItem(); - updateVibrationItem(); - updateDelivReportSmsItem(); - updateDelivReportMmsItem(); - updateReadReportItem(); - updateAutoRetItem(); - updateAutoRetRoamingItem(); + updateAlertsItem(); + updateSoundItem(); + updateVibrationItem(); + updateDelivReportSmsItem(); + updateDelivReportMmsItem(); + updateReadReportItem(); + updateAutoRetItem(); + updateAutoRetRoamingItem(); } void Settings::appendGroupItem(const std::string &title) { - SettingsGroupListViewItem *item = new SettingsGroupListViewItem(title); - m_pList->appendItem(*item); - item->setSelectable(false); + SettingsGroupListViewItem *item = new SettingsGroupListViewItem(title); + m_pList->appendItem(*item); + item->setSelectable(false); } SettingsListItem *Settings::appendItem(ListItemStyleRef style, SettingsListItem::MethodHandler handler, - const std::string &mainText, const std::string &subText) + const std::string &mainText, const std::string &subText) { - SettingsListItem *item = new SettingsListItem(style, handler); - item->setListener(this); - item->setMainText(mainText); - item->setSubText(subText); - m_pList->appendItem(*item); - return item; + SettingsListItem *item = new SettingsListItem(style, handler); + item->setListener(this); + item->setMainText(mainText); + item->setSubText(subText); + m_pList->appendItem(*item); + return item; } void Settings::appendAlertsItem() { - m_pAlertsItem = appendItem(SettingsListViewItem::oneLineIconStyle, &Settings::alertsItemHandler, "IDS_MSG_MBODY_ALERTS"); + m_pAlertsItem = appendItem(SettingsListViewItem::oneLineIconStyle, &Settings::alertsItemHandler, "IDS_MSG_MBODY_ALERTS"); } void Settings::appendSoundItem() { - m_pSoundItem = appendItem(SettingsListViewItem::multiLineStyle, &Settings::soundItemHandler, "IDS_MSG_TMBODY_SOUND", "Default"); + m_pSoundItem = appendItem(SettingsListViewItem::multiLineStyle, &Settings::soundItemHandler, "IDS_MSG_TMBODY_SOUND", "Default"); } void Settings::appendVibrationItem() { - m_pVibrationItem = appendItem(SettingsListViewItem::oneLineIconStyle, &Settings::vibrationItemHandler, "IDS_MSG_MBODY_VIBRATION"); + m_pVibrationItem = appendItem(SettingsListViewItem::oneLineIconStyle, &Settings::vibrationItemHandler, "IDS_MSG_MBODY_VIBRATION"); } void Settings::appendDelivReportSmsItem() { - m_pDelivReportSmsItem = appendItem( - SettingsListViewItem::multiLineIconStyle, - &Settings::delivReportSmsItemHandler, - "IDS_MSGF_BODY_DELIVERY_REPORT", - "IDS_MSGS_BODY_REQUEST_A_DELIVERY_REPORT_FOR_EACH_MESSAGE_YOU_SEND"); + m_pDelivReportSmsItem = appendItem( + SettingsListViewItem::multiLineIconStyle, + &Settings::delivReportSmsItemHandler, + "IDS_MSGF_BODY_DELIVERY_REPORT", + "IDS_MSGS_BODY_REQUEST_A_DELIVERY_REPORT_FOR_EACH_MESSAGE_YOU_SEND"); } void Settings::appendMsgOnSimItem() { - m_pMsgOnSimItem = appendItem( - SettingsListViewItem::multiLineStyle, - &Settings::msgOnSimItemHandler, - "IDS_MSG_TMBODY_MESSAGES_ON_SIM_CARD", - "IDS_MSG_SBODY_MANAGE_THE_MESSAGES_STORED_ON_YOUR_SIM_CARD"); + m_pMsgOnSimItem = appendItem( + SettingsListViewItem::multiLineStyle, + &Settings::msgOnSimItemHandler, + "IDS_MSG_TMBODY_MESSAGES_ON_SIM_CARD", + "IDS_MSG_SBODY_MANAGE_THE_MESSAGES_STORED_ON_YOUR_SIM_CARD"); } void Settings::appendDelivReportMmsItem() { - m_pDelivReportMmsItem = appendItem( - SettingsListViewItem::multiLineIconStyle, - &Settings::delivReportMmsItemHandler, - "IDS_MSGF_BODY_DELIVERY_REPORT", - "IDS_MSGS_BODY_REQUEST_A_DELIVERY_REPORT_FOR_EACH_MESSAGE_YOU_SEND"); + m_pDelivReportMmsItem = appendItem( + SettingsListViewItem::multiLineIconStyle, + &Settings::delivReportMmsItemHandler, + "IDS_MSGF_BODY_DELIVERY_REPORT", + "IDS_MSGS_BODY_REQUEST_A_DELIVERY_REPORT_FOR_EACH_MESSAGE_YOU_SEND"); } void Settings::appendReadReportItem() { - m_pReadReportItem = appendItem( - SettingsListViewItem::multiLineIconStyle, - &Settings::readReportItemHandler, - "IDS_MSGF_BODY_READ_REPORT", - "IDS_MSGS_BODY_REQUEST_A_READ_REPORT_FOR_EACH_MESSAGE_YOU_SEND"); + m_pReadReportItem = appendItem( + SettingsListViewItem::multiLineIconStyle, + &Settings::readReportItemHandler, + "IDS_MSGF_BODY_READ_REPORT", + "IDS_MSGS_BODY_REQUEST_A_READ_REPORT_FOR_EACH_MESSAGE_YOU_SEND"); } void Settings::appendAutoRetItem() { - m_pAutoRetItem = appendItem( - SettingsListViewItem::multiLineIconStyle, - &Settings::autoRetItemHandler, - "IDS_MSG_TMBODY_AUTO_RETRIEVE", - "IDS_MSG_BODY_RETRIEVE_MESSAGES_AUTOMATICALLY"); + m_pAutoRetItem = appendItem( + SettingsListViewItem::multiLineIconStyle, + &Settings::autoRetItemHandler, + "IDS_MSG_TMBODY_AUTO_RETRIEVE", + "IDS_MSG_BODY_RETRIEVE_MESSAGES_AUTOMATICALLY"); } void Settings::appendAutoRetRoamingItem() { - m_pAutoRetRoamingItem = appendItem( - SettingsListViewItem::multiLineIconStyle, - &Settings::autoRetRoamingItemHandler, - "IDS_MSG_TMBODY_AUTO_RETRIEVE_WHILE_ROAMING", - "IDS_MSG_BODY_RETRIEVE_MESSAGES_AUTOMATICALLY_WHILE_ROAMING"); + m_pAutoRetRoamingItem = appendItem( + SettingsListViewItem::multiLineIconStyle, + &Settings::autoRetRoamingItemHandler, + "IDS_MSG_TMBODY_AUTO_RETRIEVE_WHILE_ROAMING", + "IDS_MSG_BODY_RETRIEVE_MESSAGES_AUTOMATICALLY_WHILE_ROAMING"); } void Settings::updateAlertsItem() { - m_pAlertsItem->setCheckButtonState(getMsgSettings().getAlerts()); + m_pAlertsItem->setCheckButtonState(getMsgSettings().getAlerts()); } void Settings::updateSoundItem() { - MSG_LOG("updateSoundItem activated!"); - m_pSoundItem->disabled(!getMsgSettings().getAlerts()); + MSG_LOG("updateSoundItem activated!"); + m_pSoundItem->disabled(!getMsgSettings().getAlerts()); - std::string ringtoneName; - if (getMsgSettings().getRingtoneType() == MsgSettings::SilentRingtone) - ringtoneName = "Silent"; - else if (getMsgSettings().getRingtoneType() == MsgSettings::DefaultRingtone) - ringtoneName = "Default"; - else if (getMsgSettings().getRingtoneType() == MsgSettings::UserRingtone) - ringtoneName = MediaUtils::getTitle(getMsgSettings().getRingtone()); + std::string ringtoneName; + if (getMsgSettings().getRingtoneType() == MsgSettings::SilentRingtone) + ringtoneName = "Silent"; + else if (getMsgSettings().getRingtoneType() == MsgSettings::DefaultRingtone) + ringtoneName = "Default"; + else if (getMsgSettings().getRingtoneType() == MsgSettings::UserRingtone) + ringtoneName = MediaUtils::getTitle(getMsgSettings().getRingtone()); - m_pSoundItem->setSubText(ringtoneName); + m_pSoundItem->setSubText(ringtoneName); } void Settings::updateVibrationItem() { - m_pVibrationItem->disabled(!getMsgSettings().getAlerts()); - m_pVibrationItem->setCheckButtonState(getMsgSettings().getVibration()); + m_pVibrationItem->disabled(!getMsgSettings().getAlerts()); + m_pVibrationItem->setCheckButtonState(getMsgSettings().getVibration()); } void Settings::updateDelivReportSmsItem() { - m_pDelivReportSmsItem->setCheckButtonState(getMsgSettings().getSmsDelivReport()); + m_pDelivReportSmsItem->setCheckButtonState(getMsgSettings().getSmsDelivReport()); } void Settings::updateDelivReportMmsItem() { - m_pDelivReportMmsItem->setCheckButtonState(getMsgSettings().getMmsDelivReport()); + m_pDelivReportMmsItem->setCheckButtonState(getMsgSettings().getMmsDelivReport()); } void Settings::updateReadReportItem() { - m_pReadReportItem->setCheckButtonState(getMsgSettings().getMmsReadReport()); + m_pReadReportItem->setCheckButtonState(getMsgSettings().getMmsReadReport()); } void Settings::updateAutoRetItem() { - m_pAutoRetItem->setCheckButtonState(getMsgSettings().getMmsAutoRetr()); + m_pAutoRetItem->setCheckButtonState(getMsgSettings().getMmsAutoRetr()); } void Settings::updateAutoRetRoamingItem() { - bool mmsAutoRetr = getMsgSettings().getMmsAutoRetr(); - m_pAutoRetRoamingItem->disabled(!mmsAutoRetr); + bool mmsAutoRetr = getMsgSettings().getMmsAutoRetr(); + m_pAutoRetRoamingItem->disabled(!mmsAutoRetr); - bool check = mmsAutoRetr ? getMsgSettings().getMmsAutoRetrRoaming() : getMmsAutoRetrRoamingBackup(); - m_pAutoRetRoamingItem->setCheckButtonState(check); + bool check = mmsAutoRetr ? getMsgSettings().getMmsAutoRetrRoaming() : getMmsAutoRetrRoamingBackup(); + m_pAutoRetRoamingItem->setCheckButtonState(check); } void Settings::alertsItemHandler(SettingsListItem &item) { - MSG_LOG(""); - getMsgSettings().setAlerts(item.getCheckButtonState()); - updateAlertsItem(); - updateSoundItem(); - updateVibrationItem(); + MSG_LOG(""); + getMsgSettings().setAlerts(item.getCheckButtonState()); + updateAlertsItem(); + updateSoundItem(); + updateVibrationItem(); } void Settings::soundItemHandler(SettingsListItem &item) { - MSG_LOG("soundItemHandler activated!"); - m_SoundPicker.launch(); + MSG_LOG("soundItemHandler activated!"); + m_SoundPicker.launch(); } void Settings::vibrationItemHandler(SettingsListItem &item) { - MSG_LOG(""); - getMsgSettings().setVibration(item.getCheckButtonState()); - updateVibrationItem(); + MSG_LOG(""); + getMsgSettings().setVibration(item.getCheckButtonState()); + updateVibrationItem(); } void Settings::delivReportSmsItemHandler(SettingsListItem &item) { - MSG_LOG(""); - getMsgSettings().setSmsDelivReport(item.getCheckButtonState()); - updateDelivReportSmsItem(); + MSG_LOG(""); + getMsgSettings().setSmsDelivReport(item.getCheckButtonState()); + updateDelivReportSmsItem(); } void Settings::msgOnSimItemHandler(SettingsListItem &item) { - MSG_LOG(""); + MSG_LOG(""); - MsgOnSimCard *frame = new MsgOnSimCard(getParent()); - getParent().push(*frame); + MsgOnSimCard *frame = new MsgOnSimCard(getParent()); + getParent().push(*frame); } void Settings::delivReportMmsItemHandler(SettingsListItem &item) { - MSG_LOG(""); - getMsgSettings().setMmsDelivReport(item.getCheckButtonState()); - updateDelivReportMmsItem(); + MSG_LOG(""); + getMsgSettings().setMmsDelivReport(item.getCheckButtonState()); + updateDelivReportMmsItem(); } void Settings::readReportItemHandler(SettingsListItem &item) { - MSG_LOG(""); - getMsgSettings().setMmsReadReport(item.getCheckButtonState()); - updateDelivReportMmsItem(); + MSG_LOG(""); + getMsgSettings().setMmsReadReport(item.getCheckButtonState()); + updateDelivReportMmsItem(); } void Settings::autoRetItemHandler(SettingsListItem &item) { - MSG_LOG(""); - getMsgSettings().setMmsAutoRetr(item.getCheckButtonState()); - bool mmsAutoRetr = getMsgSettings().getMmsAutoRetr(); - if (mmsAutoRetr) { - // Restore: - if (isExistingMmsAutoRetrRoamingBackup()) - getMsgSettings().setMmsAutoRetrRoaming(getMmsAutoRetrRoamingBackup()); - } else { - // Save: - setMmsAutoRetrRoamingBackup(getMsgSettings().getMmsAutoRetrRoaming()); - getMsgSettings().setMmsAutoRetrRoaming(false); - } + MSG_LOG(""); + getMsgSettings().setMmsAutoRetr(item.getCheckButtonState()); + bool mmsAutoRetr = getMsgSettings().getMmsAutoRetr(); + if (mmsAutoRetr) { + // Restore: + if (isExistingMmsAutoRetrRoamingBackup()) + getMsgSettings().setMmsAutoRetrRoaming(getMmsAutoRetrRoamingBackup()); + } else { + // Save: + setMmsAutoRetrRoamingBackup(getMsgSettings().getMmsAutoRetrRoaming()); + getMsgSettings().setMmsAutoRetrRoaming(false); + } - updateAutoRetItem(); - updateAutoRetRoamingItem(); + updateAutoRetItem(); + updateAutoRetRoamingItem(); } void Settings::autoRetRoamingItemHandler(SettingsListItem &item) { - MSG_LOG(""); - getMsgSettings().setMmsAutoRetrRoaming(item.getCheckButtonState()); - updateAutoRetRoamingItem(); + MSG_LOG(""); + getMsgSettings().setMmsAutoRetrRoaming(item.getCheckButtonState()); + updateAutoRetRoamingItem(); } void Settings::onAttached(ViewItem &item) { - FrameController::onAttached(item); - getNaviBar().setColor(NaviBar::NaviWhiteColorId); - getNaviBar().setTitle(msgt("IDS_MSG_HEADER_SETTINGS")); - getNaviBar().showButton(NaviPrevButtonId, true); - setContent(*m_pList); + FrameController::onAttached(item); + getNaviBar().setColor(NaviBar::NaviWhiteColorId); + getNaviBar().setTitle(msgt("IDS_MSG_HEADER_SETTINGS")); + getNaviBar().showButton(NaviPrevButtonId, true); + setContent(*m_pList); } void Settings::callItemHandler(SettingsListItem &item) { - SettingsListItem::MethodHandler m = item.getHandler(); - if (m) - (this->*m)(item); + SettingsListItem::MethodHandler m = item.getHandler(); + if (m) + (this->*m)(item); } void Settings::onListItemSelected(ListItem &listItem) { - MSG_LOG("Item: ", &listItem); - listItem.setSelected(false); - SettingsListItem *settingItem = dynamic_cast(&listItem); - if (settingItem) { - settingItem->changeCheckButtonState(); - callItemHandler(*settingItem); - } + MSG_LOG("Item: ", &listItem); + listItem.setSelected(false); + SettingsListItem *settingItem = dynamic_cast(&listItem); + if (settingItem) { + settingItem->changeCheckButtonState(); + callItemHandler(*settingItem); + } } void Settings::onCheckButtonChanged(SettingsListViewItem &item) { - MSG_LOG("Item: ", &item); - SettingsListItem *settingItem = dynamic_cast(&item); - if (settingItem) - callItemHandler(*settingItem); + MSG_LOG("Item: ", &item); + SettingsListItem *settingItem = dynamic_cast(&item); + if (settingItem) + callItemHandler(*settingItem); } void Settings::onRingtoneChanged(MsgSettings &msgSetting) { - updateSoundItem(); - m_pSoundItem->update(); + updateSoundItem(); + m_pSoundItem->update(); } void Settings::onLanguageChanged() { - MSG_LOG(""); - m_pList->updateRealizedItems(); + MSG_LOG(""); + m_pList->updateRealizedItems(); } void Settings::onButtonClicked(NaviFrameItem &item, NaviButtonId buttonId) { - if (buttonId == NaviPrevButtonId) - pop(); + if (buttonId == NaviPrevButtonId) + pop(); } diff --git a/src/Settings/Controller/src/SettingsSound.cpp b/src/Settings/Controller/src/SettingsSound.cpp index 20005326..ac0b3486 100644 --- a/src/Settings/Controller/src/SettingsSound.cpp +++ b/src/Settings/Controller/src/SettingsSound.cpp @@ -23,25 +23,25 @@ using namespace Msg; namespace { - const char *sRingtoneValuePath = "/opt/share/settings/Alerts"; - const char *sRingtoneKeySilent = "silent"; - const char *sRingtoneKeyDefault = "default"; - const char *sRingtoneIsDefaultFlag = "is_default"; - const char *sRingtoneAppId = "org.tizen.setting-ringtone"; - const char *sRingtoneValueTrue = "true"; - const char *sRingtoneKeyDefaultSubstitution = "default_substitution"; - const char *sDefaultAlert = "General notification_sdk.wav"; + const char *sRingtoneValuePath = "/opt/share/settings/Alerts"; + const char *sRingtoneKeySilent = "silent"; + const char *sRingtoneKeyDefault = "default"; + const char *sRingtoneIsDefaultFlag = "is_default"; + const char *sRingtoneAppId = "org.tizen.setting-ringtone"; + const char *sRingtoneValueTrue = "true"; + const char *sRingtoneKeyDefaultSubstitution = "default_substitution"; + const char *sDefaultAlert = "General notification_sdk.wav"; } SettingsSound::SettingsSound(MsgSettings &settingsHandle) - : m_SettingsHandle(settingsHandle) + : m_SettingsHandle(settingsHandle) { - app_control_set_app_id(m_Handle, sRingtoneAppId); - app_control_add_extra_data_array(m_Handle, APP_CONTROL_DATA_PATH, &sRingtoneValuePath, 1); - app_control_add_extra_data_array(m_Handle, APP_CONTROL_DATA_SELECTED, &sRingtoneValuePath, 1); + app_control_set_app_id(m_Handle, sRingtoneAppId); + app_control_add_extra_data_array(m_Handle, APP_CONTROL_DATA_PATH, &sRingtoneValuePath, 1); + app_control_add_extra_data_array(m_Handle, APP_CONTROL_DATA_SELECTED, &sRingtoneValuePath, 1); - std::string defaultRingtonePath = sRingtoneValuePath + std::string("/") + sDefaultAlert; - app_control_add_extra_data(m_Handle, sRingtoneKeyDefaultSubstitution, defaultRingtonePath.c_str()); + std::string defaultRingtonePath = sRingtoneValuePath + std::string("/") + sDefaultAlert; + app_control_add_extra_data(m_Handle, sRingtoneKeyDefaultSubstitution, defaultRingtonePath.c_str()); } SettingsSound::~SettingsSound() @@ -50,48 +50,48 @@ SettingsSound::~SettingsSound() void SettingsSound::onReply(app_control_h request, app_control_h reply, app_control_result_e result) { - char **ringtones = nullptr; - int count = 0; - app_control_get_extra_data_array(reply, APP_CONTROL_DATA_SELECTED, &ringtones, &count); - - char *isDefault = nullptr; - app_control_get_extra_data(reply, sRingtoneIsDefaultFlag, &isDefault); - - if (!ringtones || !ringtones[0] || !isDefault) - return; - - char *ringtone = ringtones[0]; - if (strcmp(ringtone, sRingtoneKeySilent) == 0) - m_SettingsHandle.setRingtoneType(MsgSettings::SilentRingtone); - else if (strcmp(isDefault, sRingtoneValueTrue) == 0) - m_SettingsHandle.setRingtoneType(MsgSettings::DefaultRingtone); - else - { - m_SettingsHandle.setRingtoneType(MsgSettings::UserRingtone); - m_SettingsHandle.setRingtone(ringtone); - } - - for (int i = 0; i < count; ++i) { - free(ringtones[i]); - } - free(ringtones); - free(isDefault); + char **ringtones = nullptr; + int count = 0; + app_control_get_extra_data_array(reply, APP_CONTROL_DATA_SELECTED, &ringtones, &count); + + char *isDefault = nullptr; + app_control_get_extra_data(reply, sRingtoneIsDefaultFlag, &isDefault); + + if (!ringtones || !ringtones[0] || !isDefault) + return; + + char *ringtone = ringtones[0]; + if (strcmp(ringtone, sRingtoneKeySilent) == 0) + m_SettingsHandle.setRingtoneType(MsgSettings::SilentRingtone); + else if (strcmp(isDefault, sRingtoneValueTrue) == 0) + m_SettingsHandle.setRingtoneType(MsgSettings::DefaultRingtone); + else + { + m_SettingsHandle.setRingtoneType(MsgSettings::UserRingtone); + m_SettingsHandle.setRingtone(ringtone); + } + + for (int i = 0; i < count; ++i) { + free(ringtones[i]); + } + free(ringtones); + free(isDefault); } bool SettingsSound::launch() { - std::string selectedData; + std::string selectedData; - if (m_SettingsHandle.getRingtoneType() == MsgSettings::SilentRingtone) - selectedData = sRingtoneKeySilent; - else if (m_SettingsHandle.getRingtoneType() == MsgSettings::DefaultRingtone) - selectedData = sRingtoneKeyDefault; - else if (m_SettingsHandle.getRingtoneType() == MsgSettings::UserRingtone) - selectedData = m_SettingsHandle.getRingtone(); + if (m_SettingsHandle.getRingtoneType() == MsgSettings::SilentRingtone) + selectedData = sRingtoneKeySilent; + else if (m_SettingsHandle.getRingtoneType() == MsgSettings::DefaultRingtone) + selectedData = sRingtoneKeyDefault; + else if (m_SettingsHandle.getRingtoneType() == MsgSettings::UserRingtone) + selectedData = m_SettingsHandle.getRingtone(); - const char *selectedDataArray[] = {selectedData.c_str()}; - app_control_add_extra_data_array(m_Handle, APP_CONTROL_DATA_SELECTED, selectedDataArray, 1); + const char *selectedDataArray[] = {selectedData.c_str()}; + app_control_add_extra_data_array(m_Handle, APP_CONTROL_DATA_SELECTED, selectedDataArray, 1); - return AppControlLauncher::getInst().launch(*this); + return AppControlLauncher::getInst().launch(*this); } diff --git a/src/Settings/Controller/src/SimListViewItem.cpp b/src/Settings/Controller/src/SimListViewItem.cpp index 4f1cd478..9d736890 100644 --- a/src/Settings/Controller/src/SimListViewItem.cpp +++ b/src/Settings/Controller/src/SimListViewItem.cpp @@ -26,20 +26,20 @@ using namespace Msg; namespace { - ListItemStyleRef SimItemStyle = ListItemStyle::create("multiline"); + ListItemStyleRef SimItemStyle = ListItemStyle::create("multiline"); - const char *messagePart = "elm.text.multiline"; - const char *namePart = "elm.text"; - const char *checkBoxPart = "elm.swallow.end"; + const char *messagePart = "elm.text.multiline"; + const char *namePart = "elm.text"; + const char *checkBoxPart = "elm.swallow.end"; - const TextStyle nameTextStyle(40, "#131313FF"); - const TextStyle msgTextStyle(32, "#969696FF"); + const TextStyle nameTextStyle(40, "#131313FF"); + const TextStyle msgTextStyle(32, "#969696FF"); } SimListViewItem::SimListViewItem(const MessageSMS &msg, Elm_Genlist_Item_Type type) - : ListItem(SimItemStyle, type) + : ListItem(SimItemStyle, type) { - updateModel(msg); + updateModel(msg); } SimListViewItem::~SimListViewItem() @@ -48,44 +48,44 @@ SimListViewItem::~SimListViewItem() void SimListViewItem::updateModel(const MessageSMS &msg) { - const MsgAddressList &addressList = msg.getAddressList(); - int length = addressList.getLength(); - for (int i = 0; i < length; ++i) - m_Name += addressList.at(i).getAddress(); - - m_MessageText = msg.getText(); - m_Time = TimeUtils::makeDateTimeString(msg.getTime()); - m_MsgId = msg.getId(); + const MsgAddressList &addressList = msg.getAddressList(); + int length = addressList.getLength(); + for (int i = 0; i < length; ++i) + m_Name += addressList.at(i).getAddress(); + + m_MessageText = msg.getText(); + m_Time = TimeUtils::makeDateTimeString(msg.getTime()); + m_MsgId = msg.getId(); } std::string SimListViewItem::getText(ListItem &item, const char *part) { - if (!strcmp(part, messagePart)) - { - return TextDecorator::make(getMessage(), msgTextStyle); - } else if (!strcmp(part, namePart)) { - return TextDecorator::make(getName(), nameTextStyle); - } - - return ""; + if (!strcmp(part, messagePart)) + { + return TextDecorator::make(getMessage(), msgTextStyle); + } else if (!strcmp(part, namePart)) { + return TextDecorator::make(getName(), nameTextStyle); + } + + return ""; } const char *SimListViewItem::getCheckPart(ListItem &item) { - return checkBoxPart; + return checkBoxPart; } std::string SimListViewItem::getName() const { - return m_Name; + return m_Name; } std::string SimListViewItem::getMessage() const { - return m_MessageText + "

" + m_Time; + return m_MessageText + "

" + m_Time; } MsgId SimListViewItem::getMsgId() const { - return m_MsgId; + return m_MsgId; } diff --git a/src/Settings/View/inc/SettingsGroupListViewItem.h b/src/Settings/View/inc/SettingsGroupListViewItem.h index 4c548b9e..cff9da45 100644 --- a/src/Settings/View/inc/SettingsGroupListViewItem.h +++ b/src/Settings/View/inc/SettingsGroupListViewItem.h @@ -21,26 +21,26 @@ #include namespace Msg { - /** - * @brief Visual representation of grouping settings list items(a genlist item with "group_index" style). - */ - class SettingsGroupListViewItem - : public ListItem { - public: - /** - * @brief Constructs genlist-item with "group_index style" and title based on text passed from outside. - * @param title a text to be displayed. - */ - SettingsGroupListViewItem(const std::string &title); - virtual ~SettingsGroupListViewItem(); + /** + * @brief Visual representation of grouping settings list items(a genlist item with "group_index" style). + */ + class SettingsGroupListViewItem + : public ListItem { + public: + /** + * @brief Constructs genlist-item with "group_index style" and title based on text passed from outside. + * @param title a text to be displayed. + */ + SettingsGroupListViewItem(const std::string &title); + virtual ~SettingsGroupListViewItem(); - private: - // ListItem: - virtual std::string getText(ListItem &item, const char *part); + private: + // ListItem: + virtual std::string getText(ListItem &item, const char *part); - private: - const std::string m_Title; - }; + private: + const std::string m_Title; + }; } #endif // SettingsGroupListViewItem_h diff --git a/src/Settings/View/inc/SettingsListViewItem.h b/src/Settings/View/inc/SettingsListViewItem.h index f689ed7a..68072da5 100644 --- a/src/Settings/View/inc/SettingsListViewItem.h +++ b/src/Settings/View/inc/SettingsListViewItem.h @@ -20,104 +20,104 @@ #include "ListItem.h" namespace Msg { - class ISettingsListViewItemListener; - - /** - * @brief Generic visual representation of messages-settings list element. - */ - class SettingsListViewItem - : public ListItem { - public: - static ListItemStyleRef multiLineStyle; /**< style for "multiline" genlist-item. */ - static ListItemStyleRef multiLineIconStyle; /**< style for "multiline + icon" genlist-item. */ - static ListItemStyleRef oneLineIconStyle; /**< style for "single-line + icon" genlist-item. */ - - public: - /** - * @brief Constructs list-item style based on a genlist-item style passed from outside. - * @param[in] style to be applied. - */ - SettingsListViewItem(const ListItemStyleRef &style); - virtual ~SettingsListViewItem(); - - /** - * @brief Manages visibility of check-button at the moment when user creates it. - * @param[in] show if true shows check-button, otherwise hides it. - */ - void showCheckButton(bool show); - - /** - * @brief Enables\disables check-button at moment of it's creation. Nothing happens if showCheckButton(false) was called before. - * @param[in] disabled if true, check-button is created disabled, if false - check-button is enabled. - */ - void disabledCheckButton(bool disabled); - - /** - * @brief checks\unchecks check-button at moment of it's creation. Nothing happens if showCheckButton(false) was called before. - * @param[in] state if true, check-button is created checked, if false - check-button is unchecked. - */ - void setCheckButtonState(bool state); - - /** - * @brief Gets state of check-button. - * @return true if check-button is checked, otherwise false. Also returns false if no check-button was created. - */ - bool getCheckButtonState() const; - - /** - * @brief Switches state of check-button to opposite(checked/unchecked). - */ - void changeCheckButtonState(); - - /** - * @brief Sets text to "elm.text" part. - * @param[in] text a text to be set. - */ - void setMainText(const std::string &text); - - /** - * @brief Sets text to "elm.text.multiline" part. If instance of SettingsListViewItem have single-line style nothing happens. - * @param[in] text a text to be set. - */ - void setSubText(const std::string &text); - - /** - * @brief Sets a listener to notify subscriber about list-item events. - * @param[in] listener a listener to be notified. - */ - void setListener(ISettingsListViewItemListener *listener); - - private: - // ListItem: - virtual std::string getText(ListItem &item, const char *part); - virtual Evas_Object *getContent(ListItem &item, const char *part); - - void onCheckButtonChanged(Evas_Object *obj, void *eventInfo); - - Evas_Object *createCheckButton(Evas_Object *parent); - - private: - std::string m_MainText; - std::string m_SubText; - bool m_ShowCheckButton; - Eina_Bool m_CheckButtonState; - bool m_DisabledCheckButton; - ISettingsListViewItemListener *m_pListener; - }; - - /** - * @brief Listener to send list-item events to subscribers. - */ - class ISettingsListViewItemListener { - public: - virtual ~ISettingsListViewItemListener(){} - - /** - * @brief raised when state of check-button has been changed. - * @param[in] item an item that owns a check-button with state modified. - */ - virtual void onCheckButtonChanged(SettingsListViewItem &item) {}; - }; + class ISettingsListViewItemListener; + + /** + * @brief Generic visual representation of messages-settings list element. + */ + class SettingsListViewItem + : public ListItem { + public: + static ListItemStyleRef multiLineStyle; /**< style for "multiline" genlist-item. */ + static ListItemStyleRef multiLineIconStyle; /**< style for "multiline + icon" genlist-item. */ + static ListItemStyleRef oneLineIconStyle; /**< style for "single-line + icon" genlist-item. */ + + public: + /** + * @brief Constructs list-item style based on a genlist-item style passed from outside. + * @param[in] style to be applied. + */ + SettingsListViewItem(const ListItemStyleRef &style); + virtual ~SettingsListViewItem(); + + /** + * @brief Manages visibility of check-button at the moment when user creates it. + * @param[in] show if true shows check-button, otherwise hides it. + */ + void showCheckButton(bool show); + + /** + * @brief Enables\disables check-button at moment of it's creation. Nothing happens if showCheckButton(false) was called before. + * @param[in] disabled if true, check-button is created disabled, if false - check-button is enabled. + */ + void disabledCheckButton(bool disabled); + + /** + * @brief checks\unchecks check-button at moment of it's creation. Nothing happens if showCheckButton(false) was called before. + * @param[in] state if true, check-button is created checked, if false - check-button is unchecked. + */ + void setCheckButtonState(bool state); + + /** + * @brief Gets state of check-button. + * @return true if check-button is checked, otherwise false. Also returns false if no check-button was created. + */ + bool getCheckButtonState() const; + + /** + * @brief Switches state of check-button to opposite(checked/unchecked). + */ + void changeCheckButtonState(); + + /** + * @brief Sets text to "elm.text" part. + * @param[in] text a text to be set. + */ + void setMainText(const std::string &text); + + /** + * @brief Sets text to "elm.text.multiline" part. If instance of SettingsListViewItem have single-line style nothing happens. + * @param[in] text a text to be set. + */ + void setSubText(const std::string &text); + + /** + * @brief Sets a listener to notify subscriber about list-item events. + * @param[in] listener a listener to be notified. + */ + void setListener(ISettingsListViewItemListener *listener); + + private: + // ListItem: + virtual std::string getText(ListItem &item, const char *part); + virtual Evas_Object *getContent(ListItem &item, const char *part); + + void onCheckButtonChanged(Evas_Object *obj, void *eventInfo); + + Evas_Object *createCheckButton(Evas_Object *parent); + + private: + std::string m_MainText; + std::string m_SubText; + bool m_ShowCheckButton; + Eina_Bool m_CheckButtonState; + bool m_DisabledCheckButton; + ISettingsListViewItemListener *m_pListener; + }; + + /** + * @brief Listener to send list-item events to subscribers. + */ + class ISettingsListViewItemListener { + public: + virtual ~ISettingsListViewItemListener(){} + + /** + * @brief raised when state of check-button has been changed. + * @param[in] item an item that owns a check-button with state modified. + */ + virtual void onCheckButtonChanged(SettingsListViewItem &item) {}; + }; } #endif // SettingsOnOffListViewItem_h_ diff --git a/src/Settings/View/inc/SimMsgLayout.h b/src/Settings/View/inc/SimMsgLayout.h index f78598f2..dca95210 100644 --- a/src/Settings/View/inc/SimMsgLayout.h +++ b/src/Settings/View/inc/SimMsgLayout.h @@ -21,49 +21,49 @@ #include "DefaultLayout.h" namespace Msg { - /** - * @brief Represents a layout of "Messages on SIM" view. - */ - class SimMsgLayout - : public DefaultLayout { - public: - /** - * @brief Constructs an instance of SimMsgLayout based on parent passed from outside. - * @param[in] an object responsible for automatic destroying of SimMsgLayout instance. - */ - SimMsgLayout(Evas_Object *parent); - virtual ~SimMsgLayout(); + /** + * @brief Represents a layout of "Messages on SIM" view. + */ + class SimMsgLayout + : public DefaultLayout { + public: + /** + * @brief Constructs an instance of SimMsgLayout based on parent passed from outside. + * @param[in] an object responsible for automatic destroying of SimMsgLayout instance. + */ + SimMsgLayout(Evas_Object *parent); + virtual ~SimMsgLayout(); - /** - * @brief populates itself according to list passed from outside. - * @param[in] list to be placed on layout. - */ - void setSimMsgList(Evas_Object *list); + /** + * @brief populates itself according to list passed from outside. + * @param[in] list to be placed on layout. + */ + void setSimMsgList(Evas_Object *list); - /** - * @brief acquires a layout for "No content" mode. - * @param[in] bg a background layout that will be shown if list of messages on SIM is empty. - */ - void setNoContent(Evas_Object *bg); + /** + * @brief acquires a layout for "No content" mode. + * @param[in] bg a background layout that will be shown if list of messages on SIM is empty. + */ + void setNoContent(Evas_Object *bg); - /** - * @brief Shows/hides "No content" layout. - * @param[in] show if true no list is shown, but "No messages on SIM card" text, if false hides "No content" layout. - */ - void setNoContentLayoutVisible(bool show); + /** + * @brief Shows/hides "No content" layout. + * @param[in] show if true no list is shown, but "No messages on SIM card" text, if false hides "No content" layout. + */ + void setNoContentLayoutVisible(bool show); - /** - * @brief Shows/hides list of messages on SIM. - * @param[in] show if true the list is shown, otherwise list is hidden. - */ - void setSimMsgListVisible(bool show); - private: - void create(Evas_Object *parent); - void setContent(Evas_Object *obj); + /** + * @brief Shows/hides list of messages on SIM. + * @param[in] show if true the list is shown, otherwise list is hidden. + */ + void setSimMsgListVisible(bool show); + private: + void create(Evas_Object *parent); + void setContent(Evas_Object *obj); - private: - Evas_Object *m_pLayout; - }; + private: + Evas_Object *m_pLayout; + }; } #endif // SimMsgLayout_h_ diff --git a/src/Settings/View/src/SettingsGroupListViewItem.cpp b/src/Settings/View/src/SettingsGroupListViewItem.cpp index b9e704af..bb6098d9 100644 --- a/src/Settings/View/src/SettingsGroupListViewItem.cpp +++ b/src/Settings/View/src/SettingsGroupListViewItem.cpp @@ -20,12 +20,12 @@ using namespace Msg; namespace { - ListItemStyleRef itemStyle = ListItemStyle::create("group_index"); + ListItemStyleRef itemStyle = ListItemStyle::create("group_index"); } SettingsGroupListViewItem::SettingsGroupListViewItem(const std::string &title) - : ListItem(itemStyle, ELM_GENLIST_ITEM_NONE) - , m_Title(title) + : ListItem(itemStyle, ELM_GENLIST_ITEM_NONE) + , m_Title(title) { } @@ -35,9 +35,9 @@ SettingsGroupListViewItem::~SettingsGroupListViewItem() std::string SettingsGroupListViewItem::getText(ListItem &item, const char *part) { - if (!strcmp(part, "elm.text")) - return msg(m_Title); - else - return ""; + if (!strcmp(part, "elm.text")) + return msg(m_Title); + else + return ""; } diff --git a/src/Settings/View/src/SettingsListViewItem.cpp b/src/Settings/View/src/SettingsListViewItem.cpp index 3ab97feb..e8bdcf15 100644 --- a/src/Settings/View/src/SettingsListViewItem.cpp +++ b/src/Settings/View/src/SettingsListViewItem.cpp @@ -29,13 +29,13 @@ ListItemStyleRef SettingsListViewItem::oneLineIconStyle = ListItemStyle::create( ListItemStyleRef SettingsListViewItem::multiLineStyle = ListItemStyle::create("multiline"); SettingsListViewItem::SettingsListViewItem(const ListItemStyleRef &style) - : ListItem(style, ELM_GENLIST_ITEM_NONE) - , m_ShowCheckButton(false) - , m_CheckButtonState(false) - , m_DisabledCheckButton(false) - , m_pListener(nullptr) + : ListItem(style, ELM_GENLIST_ITEM_NONE) + , m_ShowCheckButton(false) + , m_CheckButtonState(false) + , m_DisabledCheckButton(false) + , m_pListener(nullptr) { - m_ShowCheckButton = style == multiLineIconStyle || style == oneLineIconStyle; + m_ShowCheckButton = style == multiLineIconStyle || style == oneLineIconStyle; } SettingsListViewItem::~SettingsListViewItem() @@ -44,96 +44,96 @@ SettingsListViewItem::~SettingsListViewItem() void SettingsListViewItem::showCheckButton(bool show) { - m_ShowCheckButton = show; + m_ShowCheckButton = show; } void SettingsListViewItem::disabledCheckButton(bool disabled) { - m_DisabledCheckButton = disabled; + m_DisabledCheckButton = disabled; } void SettingsListViewItem::setCheckButtonState(bool state) { - if (m_CheckButtonState != state) { - m_CheckButtonState = state; - update(); - } + if (m_CheckButtonState != state) { + m_CheckButtonState = state; + update(); + } } void SettingsListViewItem::changeCheckButtonState() { - setCheckButtonState(!m_CheckButtonState); + setCheckButtonState(!m_CheckButtonState); } bool SettingsListViewItem::getCheckButtonState() const { - return m_CheckButtonState; + return m_CheckButtonState; } void SettingsListViewItem::setMainText(const std::string &text) { - m_MainText = text; + m_MainText = text; } void SettingsListViewItem::setSubText(const std::string &text) { - m_SubText = text; + m_SubText = text; } std::string SettingsListViewItem::getText(ListItem &item, const char *part) { - if (getStyle().get() == oneLineIconStyle.get()) { - if (strcmp(part, "elm.text") == 0) - return msg(m_MainText); - } else if (getStyle().get() == multiLineStyle.get() || getStyle().get() == multiLineIconStyle.get()) { - if (strcmp(part, "elm.text") == 0) - return msg(m_MainText); - else if (strcmp(part, "elm.text.multiline") == 0) - return msg(m_SubText); - } else { - MSG_LOG_ERROR("Unknown style"); - } - - return ""; + if (getStyle().get() == oneLineIconStyle.get()) { + if (strcmp(part, "elm.text") == 0) + return msg(m_MainText); + } else if (getStyle().get() == multiLineStyle.get() || getStyle().get() == multiLineIconStyle.get()) { + if (strcmp(part, "elm.text") == 0) + return msg(m_MainText); + else if (strcmp(part, "elm.text.multiline") == 0) + return msg(m_SubText); + } else { + MSG_LOG_ERROR("Unknown style"); + } + + return ""; } Evas_Object *SettingsListViewItem::getContent(ListItem &item, const char *part) { - if (getStyle().get() == oneLineIconStyle.get() || getStyle().get() == multiLineIconStyle.get()) { - if (strcmp(part, "elm.swallow.end") == 0) - return createCheckButton(*getOwner()); - } else if (getStyle().get() == multiLineStyle.get()) { - } else { - MSG_LOG_ERROR("Unknown style"); - } - - return nullptr; + if (getStyle().get() == oneLineIconStyle.get() || getStyle().get() == multiLineIconStyle.get()) { + if (strcmp(part, "elm.swallow.end") == 0) + return createCheckButton(*getOwner()); + } else if (getStyle().get() == multiLineStyle.get()) { + } else { + MSG_LOG_ERROR("Unknown style"); + } + + return nullptr; } Evas_Object *SettingsListViewItem::createCheckButton(Evas_Object *parent) { - Evas_Object *check = nullptr; - if (m_ShowCheckButton) { - check = elm_check_add(parent); - elm_object_focus_allow_set(check, false); - elm_object_style_set(check, "on&off"); - elm_object_disabled_set(check, m_DisabledCheckButton); - elm_check_state_set(check, m_CheckButtonState); - elm_check_state_pointer_set(check, &m_CheckButtonState); - evas_object_propagate_events_set(check, EINA_FALSE); - evas_object_smart_callback_add(check, "changed", SMART_CALLBACK(SettingsListViewItem, onCheckButtonChanged), this); - View::processSignal(check); - } - return check; + Evas_Object *check = nullptr; + if (m_ShowCheckButton) { + check = elm_check_add(parent); + elm_object_focus_allow_set(check, false); + elm_object_style_set(check, "on&off"); + elm_object_disabled_set(check, m_DisabledCheckButton); + elm_check_state_set(check, m_CheckButtonState); + elm_check_state_pointer_set(check, &m_CheckButtonState); + evas_object_propagate_events_set(check, EINA_FALSE); + evas_object_smart_callback_add(check, "changed", SMART_CALLBACK(SettingsListViewItem, onCheckButtonChanged), this); + View::processSignal(check); + } + return check; } void SettingsListViewItem::setListener(ISettingsListViewItemListener *listener) { - m_pListener = listener; + m_pListener = listener; } void SettingsListViewItem::onCheckButtonChanged(Evas_Object *obj, void *eventInfo) { - if (m_pListener) - m_pListener->onCheckButtonChanged(*this); + if (m_pListener) + m_pListener->onCheckButtonChanged(*this); } diff --git a/src/Settings/View/src/SimMsgLayout.cpp b/src/Settings/View/src/SimMsgLayout.cpp index 2c1132d3..e02a1e2a 100644 --- a/src/Settings/View/src/SimMsgLayout.cpp +++ b/src/Settings/View/src/SimMsgLayout.cpp @@ -21,9 +21,9 @@ using namespace Msg; SimMsgLayout::SimMsgLayout(Evas_Object *parent) - : DefaultLayout(parent) + : DefaultLayout(parent) { - create(parent); + create(parent); } SimMsgLayout::~SimMsgLayout() @@ -32,31 +32,31 @@ SimMsgLayout::~SimMsgLayout() void SimMsgLayout::create(Evas_Object *parent) { - m_pLayout = elm_layout_add(parent); - evas_object_show(m_pLayout); - std::string path = PathUtils::getResourcePath(MSG_THREAD_EDJ_PATH); - elm_layout_file_set(m_pLayout, path.c_str(), "msg_thread_layout"); - DefaultLayout::setContent(m_pLayout); + m_pLayout = elm_layout_add(parent); + evas_object_show(m_pLayout); + std::string path = PathUtils::getResourcePath(MSG_THREAD_EDJ_PATH); + elm_layout_file_set(m_pLayout, path.c_str(), "msg_thread_layout"); + DefaultLayout::setContent(m_pLayout); } void SimMsgLayout::setSimMsgList(Evas_Object *list) { - elm_object_part_content_set(m_pLayout, "swl.list", list); + elm_object_part_content_set(m_pLayout, "swl.list", list); } void SimMsgLayout::setNoContent(Evas_Object *bg) { - elm_object_part_content_set(m_pLayout, "swl.bg", bg); + elm_object_part_content_set(m_pLayout, "swl.bg", bg); } void SimMsgLayout::setNoContentLayoutVisible(bool show) { - const char *sig = show ? "show_bg" : "hide_bg"; - elm_layout_signal_emit(m_pLayout, sig, ""); + const char *sig = show ? "show_bg" : "hide_bg"; + elm_layout_signal_emit(m_pLayout, sig, ""); } void SimMsgLayout::setSimMsgListVisible(bool show) { - const char *sig = show ? "show_list" : "hide_list"; - elm_layout_signal_emit(m_pLayout, sig, ""); + const char *sig = show ? "show_list" : "hide_list"; + elm_layout_signal_emit(m_pLayout, sig, ""); } diff --git a/src/Viewer/Controller/inc/SmilPage.h b/src/Viewer/Controller/inc/SmilPage.h index 940b52f0..5cf1794a 100644 --- a/src/Viewer/Controller/inc/SmilPage.h +++ b/src/Viewer/Controller/inc/SmilPage.h @@ -26,59 +26,59 @@ #include namespace Msg { - class SmilImageItemView; - class FileViewer; + class SmilImageItemView; + class FileViewer; - class SmilPage - : public SmilPageLayout - , private ISmilSaveAllItemViewListener - , private ISmilAttachmentItemViewListener { - public: - SmilPage(Evas_Object *parent, FileViewer &fileViewer, const MsgPage &page); - SmilPage(Evas_Object *parent, FileViewer &fileViewer, const MsgAttachmentList &list); - virtual ~SmilPage(); + class SmilPage + : public SmilPageLayout + , private ISmilSaveAllItemViewListener + , private ISmilAttachmentItemViewListener { + public: + SmilPage(Evas_Object *parent, FileViewer &fileViewer, const MsgPage &page); + SmilPage(Evas_Object *parent, FileViewer &fileViewer, const MsgAttachmentList &list); + virtual ~SmilPage(); - int getDuration() const; - bool hasMedia() const; - bool hasInvalidFiles() const; - bool hasVideo() const; - bool hasAudio() const; - bool hasAnimation() const; - void playAnimation(bool play); - Evas_Object *getVideoSink() const; - std::string getMediaPath() const; - const std::list &getAttachments() const; - static bool isEmpty(const MsgPage &page); + int getDuration() const; + bool hasMedia() const; + bool hasInvalidFiles() const; + bool hasVideo() const; + bool hasAudio() const; + bool hasAnimation() const; + void playAnimation(bool play); + Evas_Object *getVideoSink() const; + std::string getMediaPath() const; + const std::list &getAttachments() const; + static bool isEmpty(const MsgPage &page); - private: - const MsgMedia *getMedia(const MsgPage &page, MsgMedia::Type type) const; - void build(const MsgPage &page); - void build(const MsgAttachmentList &list); - void buildImage(const MsgMedia& media); - void buildText(const MsgMedia& media); - void buildAudio(const MsgMedia& media); - void buildVideo(const MsgMedia& media); - void buildSaveAllItem(int attachmentCount); - void buildAttachmentInfo(int attachmentCount); - void buildAttachment(const MsgAttachment& attachment); + private: + const MsgMedia *getMedia(const MsgPage &page, MsgMedia::Type type) const; + void build(const MsgPage &page); + void build(const MsgAttachmentList &list); + void buildImage(const MsgMedia& media); + void buildText(const MsgMedia& media); + void buildAudio(const MsgMedia& media); + void buildVideo(const MsgMedia& media); + void buildSaveAllItem(int attachmentCount); + void buildAttachmentInfo(int attachmentCount); + void buildAttachment(const MsgAttachment& attachment); - // ISmilAttachmentItemViewListener: - virtual void onItemClicked(SmilAttachmentItemView &item); - virtual void onSaveButtonClicked(SmilAttachmentItemView &item); + // ISmilAttachmentItemViewListener: + virtual void onItemClicked(SmilAttachmentItemView &item); + virtual void onSaveButtonClicked(SmilAttachmentItemView &item); - // ISmilSaveAllItemViewListener: - virtual void onItemClicked(SmilSaveAllItemView &item); + // ISmilSaveAllItemViewListener: + virtual void onItemClicked(SmilSaveAllItemView &item); - private: - int m_Duration; // seconds - std::string m_MediaPath; - Evas_Object *m_pVideoSink; - bool m_HasAudio; - SmilImageItemView *m_pImageItem; - std::list m_Attachments; - bool m_HasInvalidFiles; - FileViewer &m_FileViewer; - }; + private: + int m_Duration; // seconds + std::string m_MediaPath; + Evas_Object *m_pVideoSink; + bool m_HasAudio; + SmilImageItemView *m_pImageItem; + std::list m_Attachments; + bool m_HasInvalidFiles; + FileViewer &m_FileViewer; + }; } #endif /* SmilPage_h_ */ diff --git a/src/Viewer/Controller/inc/SmilPlayer.h b/src/Viewer/Controller/inc/SmilPlayer.h index c964ae82..61d14128 100644 --- a/src/Viewer/Controller/inc/SmilPlayer.h +++ b/src/Viewer/Controller/inc/SmilPlayer.h @@ -28,81 +28,81 @@ #include namespace Msg { - class ISmilPlayerListener; + class ISmilPlayerListener; - class SmilPlayer - : public SmilPlayerView - , private IMediaPlayerListener { - public: - typedef std::vector PageList; - enum State { - StopState, // Stop = Pause - PlayState, - }; + class SmilPlayer + : public SmilPlayerView + , private IMediaPlayerListener { + public: + typedef std::vector PageList; + enum State { + StopState, // Stop = Pause + PlayState, + }; - public: - SmilPlayer(Evas_Object *parent, const MessageMms &mms); - virtual ~SmilPlayer(); + public: + SmilPlayer(Evas_Object *parent, const MessageMms &mms); + virtual ~SmilPlayer(); - void setListener(ISmilPlayerListener *l); - State getState() const; - void start(); - void stop(); - void reset(); - double getPosition() const; - const PageList &getPages() const; - SmilPage *getCurrentPage() const; - int getDuration() const; - bool nextPage(); - bool prevPage(); - bool probeNextPage() const; - bool probePrevPage() const; - unsigned getCurrentPageIndex() const; + void setListener(ISmilPlayerListener *l); + State getState() const; + void start(); + void stop(); + void reset(); + double getPosition() const; + const PageList &getPages() const; + SmilPage *getCurrentPage() const; + int getDuration() const; + bool nextPage(); + bool prevPage(); + bool probeNextPage() const; + bool probePrevPage() const; + unsigned getCurrentPageIndex() const; - private: - // IMediaPlayerListener: - virtual void onMediaPlayerSoundFocusChanged(); + private: + // IMediaPlayerListener: + virtual void onMediaPlayerSoundFocusChanged(); - // View: - virtual void onBeforeDelete(View &view); + // View: + virtual void onBeforeDelete(View &view); - private: - bool playPage(); - bool canPlay(SmilPage *page); - void startMedia(); - void playAnimation(bool start); - void stopMedia(); - void prepareMedia(); - void create(const MessageMms &mms); - void startTimer(int sec); - void pauseTimer(); - void continueTimer(); - Eina_Bool onTick(); - void setState(State state); - void showUnableToPlayVideoNotif(); - void showUnableToPlayAudioNotif(); - void showNotSupportedFileNotif(); - void showUnableToPlayNotif(SmilPage &page); + private: + bool playPage(); + bool canPlay(SmilPage *page); + void startMedia(); + void playAnimation(bool start); + void stopMedia(); + void prepareMedia(); + void create(const MessageMms &mms); + void startTimer(int sec); + void pauseTimer(); + void continueTimer(); + Eina_Bool onTick(); + void setState(State state); + void showUnableToPlayVideoNotif(); + void showUnableToPlayAudioNotif(); + void showNotSupportedFileNotif(); + void showUnableToPlayNotif(SmilPage &page); - private: - ISmilPlayerListener *m_pListener; - Ecore_Timer *m_pTimer; - std::unique_ptr m_MediaPlayer; - PageList m_PageList; - unsigned m_CurrentPageIndex; - int m_Duration; - State m_State; - int m_PageTickCounter; - FileViewer m_FileViewer; - }; + private: + ISmilPlayerListener *m_pListener; + Ecore_Timer *m_pTimer; + std::unique_ptr m_MediaPlayer; + PageList m_PageList; + unsigned m_CurrentPageIndex; + int m_Duration; + State m_State; + int m_PageTickCounter; + FileViewer m_FileViewer; + }; - class ISmilPlayerListener { - public: - virtual ~ISmilPlayerListener() {} - virtual void onSmilPlayerPageChanged() {}; - virtual void onSmilPlayerStateChanged() {}; - virtual void onSmilPlayerTick() {}; - }; + class ISmilPlayerListener { + public: + virtual ~ISmilPlayerListener() {} + virtual void onSmilPlayerPageChanged() {}; + virtual void onSmilPlayerStateChanged() {}; + virtual void onSmilPlayerTick() {}; + }; } #endif /* SmilPlayer_h_ */ diff --git a/src/Viewer/Controller/inc/Viewer.h b/src/Viewer/Controller/inc/Viewer.h index 5cac09ac..331d6c48 100644 --- a/src/Viewer/Controller/inc/Viewer.h +++ b/src/Viewer/Controller/inc/Viewer.h @@ -34,104 +34,104 @@ #include "ContactViewer.h" namespace Msg { - class NaviFrameController; - - class Viewer - : public FrameController - , private IHwButtonListener - , private IPlayerControlListener - , private IContactManagerListener - , private IViewerLayoutListener - , private IConversationListener - , private ISmilPlayerListener - , private ISystemSettingsManager - , private IMsgStorageListener { - public: - Viewer(NaviFrameController &parent, MsgId id); - virtual ~Viewer(); - - private: - // NaviFrameItem: - virtual void onAttached(ViewItem &item); - virtual void onButtonClicked(NaviFrameItem &item, NaviButtonId buttonId); - virtual void onPause(); - - // IHwButtonListener: - virtual void onHwBackButtonClicked(); - virtual void onHwMoreButtonClicked(); - - // IPlayerControlListener: - virtual void onPlayClicked(); - virtual void onPauseClicked(); - virtual void onNextClicked(); - virtual void onPrevClicked(); - - // IContactManagerListener: - virtual void onContactChanged(); - - // IViewerLayoutListener: - virtual void onLayoutTap(); - - // ISmilPlayerListener: - virtual void onSmilPlayerStateChanged(); - virtual void onSmilPlayerPageChanged(); - virtual void onSmilPlayerTick(); - - // Popup: - void onMakeVoiceItemPressed(PopupListItem &item); - void onCreateContactItemPressed(PopupListItem &item); - void onUpdateContactItemPressed(PopupListItem &item); - - // More Button popup - void onDeleteItemPressed(PopupListItem &item); - void onCancelButtonClicked(Popup &popup, int buttonId); - void onDeleteButtonClicked(Popup &popup, int buttonId); - void onCopyTextItemPressed(PopupListItem &item); - void onForwardItemPressed(PopupListItem &item); - void onSaveAttachmentsItemPressed(PopupListItem &item); - - // MbeRecipients: - void onRecipItemClicked(Evas_Object *obj, void *eventInfo); - - // Conversation listener - virtual void onConversationSentMessage(); - - // SystemSettingsManager: - virtual void onLanguageChanged(); - - // IMsgStorageListener: - virtual void onMsgStorageDelete(const MsgIdList &msgIdList); - - private: - void naviExpandButtonHandler(); - void naviCenterButtonHandler(); - void naviPrevButtonHandler(); - void updateNavibar(); - void updateRecipPanel(); - void create(MsgId id); - void createLayout(); - void createSubjectLayout(); - void createPlayerControl(); - void createRecipPanel(); - std::string createMessageText() const; - void createSmilPlayer(); - void recipientClickHandler(const std::string &address); - void showRecipPopup(const std::string &address); - void updatePlayPos(); - void updateSubject(); - void updateButtonState(); - - private: - MessageMmsRef m_Msg; - ViewerLayout *m_pLayout; - PlayerControl *m_pPlayerControl; - MbeRecipients *m_pRecipPanel; - std::string m_SelectedAddress; - ContactEditor m_ContactEditor; - SmilPlayer *m_pSmilPlayer; - SubjectLayout *m_pSubjectLayout; - ContactViewer m_ContactViewer; - }; + class NaviFrameController; + + class Viewer + : public FrameController + , private IHwButtonListener + , private IPlayerControlListener + , private IContactManagerListener + , private IViewerLayoutListener + , private IConversationListener + , private ISmilPlayerListener + , private ISystemSettingsManager + , private IMsgStorageListener { + public: + Viewer(NaviFrameController &parent, MsgId id); + virtual ~Viewer(); + + private: + // NaviFrameItem: + virtual void onAttached(ViewItem &item); + virtual void onButtonClicked(NaviFrameItem &item, NaviButtonId buttonId); + virtual void onPause(); + + // IHwButtonListener: + virtual void onHwBackButtonClicked(); + virtual void onHwMoreButtonClicked(); + + // IPlayerControlListener: + virtual void onPlayClicked(); + virtual void onPauseClicked(); + virtual void onNextClicked(); + virtual void onPrevClicked(); + + // IContactManagerListener: + virtual void onContactChanged(); + + // IViewerLayoutListener: + virtual void onLayoutTap(); + + // ISmilPlayerListener: + virtual void onSmilPlayerStateChanged(); + virtual void onSmilPlayerPageChanged(); + virtual void onSmilPlayerTick(); + + // Popup: + void onMakeVoiceItemPressed(PopupListItem &item); + void onCreateContactItemPressed(PopupListItem &item); + void onUpdateContactItemPressed(PopupListItem &item); + + // More Button popup + void onDeleteItemPressed(PopupListItem &item); + void onCancelButtonClicked(Popup &popup, int buttonId); + void onDeleteButtonClicked(Popup &popup, int buttonId); + void onCopyTextItemPressed(PopupListItem &item); + void onForwardItemPressed(PopupListItem &item); + void onSaveAttachmentsItemPressed(PopupListItem &item); + + // MbeRecipients: + void onRecipItemClicked(Evas_Object *obj, void *eventInfo); + + // Conversation listener + virtual void onConversationSentMessage(); + + // SystemSettingsManager: + virtual void onLanguageChanged(); + + // IMsgStorageListener: + virtual void onMsgStorageDelete(const MsgIdList &msgIdList); + + private: + void naviExpandButtonHandler(); + void naviCenterButtonHandler(); + void naviPrevButtonHandler(); + void updateNavibar(); + void updateRecipPanel(); + void create(MsgId id); + void createLayout(); + void createSubjectLayout(); + void createPlayerControl(); + void createRecipPanel(); + std::string createMessageText() const; + void createSmilPlayer(); + void recipientClickHandler(const std::string &address); + void showRecipPopup(const std::string &address); + void updatePlayPos(); + void updateSubject(); + void updateButtonState(); + + private: + MessageMmsRef m_Msg; + ViewerLayout *m_pLayout; + PlayerControl *m_pPlayerControl; + MbeRecipients *m_pRecipPanel; + std::string m_SelectedAddress; + ContactEditor m_ContactEditor; + SmilPlayer *m_pSmilPlayer; + SubjectLayout *m_pSubjectLayout; + ContactViewer m_ContactViewer; + }; } #endif /* ViewerFrame_h_ */ diff --git a/src/Viewer/Controller/src/SmilPage.cpp b/src/Viewer/Controller/src/SmilPage.cpp index f8d40d9e..358e2a5f 100644 --- a/src/Viewer/Controller/src/SmilPage.cpp +++ b/src/Viewer/Controller/src/SmilPage.cpp @@ -34,270 +34,270 @@ using namespace Msg; const int defaultPageDuration = 5; // sec; SmilPage::SmilPage(Evas_Object *parent, FileViewer &fileViewer, const MsgPage &page) - : SmilPageLayout(parent) - , m_Duration(0) - , m_pVideoSink(nullptr) - , m_HasAudio(false) - , m_pImageItem(nullptr) - , m_HasInvalidFiles(false) - , m_FileViewer(fileViewer) + : SmilPageLayout(parent) + , m_Duration(0) + , m_pVideoSink(nullptr) + , m_HasAudio(false) + , m_pImageItem(nullptr) + , m_HasInvalidFiles(false) + , m_FileViewer(fileViewer) { - build(page); + build(page); } SmilPage::SmilPage(Evas_Object *parent, FileViewer &fileViewer, const MsgAttachmentList &list) - : SmilPageLayout(parent) - , m_Duration(0) - , m_pVideoSink(nullptr) - , m_HasAudio(false) - , m_pImageItem(nullptr) - , m_HasInvalidFiles(false) - , m_FileViewer(fileViewer) + : SmilPageLayout(parent) + , m_Duration(0) + , m_pVideoSink(nullptr) + , m_HasAudio(false) + , m_pImageItem(nullptr) + , m_HasInvalidFiles(false) + , m_FileViewer(fileViewer) { - build(list); + build(list); } SmilPage::~SmilPage() { - MSG_LOG(""); + MSG_LOG(""); } int SmilPage::getDuration() const { - return m_Duration; + return m_Duration; } bool SmilPage::hasMedia() const { - return !m_MediaPath.empty(); + return !m_MediaPath.empty(); } bool SmilPage::hasInvalidFiles() const { - return m_HasInvalidFiles; + return m_HasInvalidFiles; } bool SmilPage::hasVideo() const { - return m_pVideoSink != nullptr; + return m_pVideoSink != nullptr; } bool SmilPage::hasAudio() const { - return m_HasAudio; + return m_HasAudio; } Evas_Object *SmilPage::getVideoSink() const { - return m_pVideoSink; + return m_pVideoSink; } std::string SmilPage::getMediaPath() const { - return m_MediaPath; + return m_MediaPath; } const std::list &SmilPage::getAttachments() const { - return m_Attachments; + return m_Attachments; } bool SmilPage::hasAnimation() const { - return m_pImageItem && m_pImageItem->hasAnimation(); + return m_pImageItem && m_pImageItem->hasAnimation(); } void SmilPage::playAnimation(bool play) { - if (m_pImageItem && m_pImageItem->hasAnimation()) - m_pImageItem->playAnimation(play); + if (m_pImageItem && m_pImageItem->hasAnimation()) + m_pImageItem->playAnimation(play); } const MsgMedia *SmilPage::getMedia(const MsgPage &page, MsgMedia::Type type) const { - const MsgMediaList &list = page.getMediaList(); - for (int i = 0; i < list.getLength(); ++i) { - if (list[i].getType() == type) - return &list[i]; - } - return nullptr; + const MsgMediaList &list = page.getMediaList(); + for (int i = 0; i < list.getLength(); ++i) { + if (list[i].getType() == type) + return &list[i]; + } + return nullptr; } bool SmilPage::isEmpty(const MsgPage &page) { - const MsgMediaList &list = page.getMediaList(); - for (int i = 0; i < list.getLength(); ++i) { - const MsgMedia &media = list[i]; - std::string filePath = media.getFilePath(); - if (media.getType() != MsgMedia::UnknownType && FileUtils::getFileSize(filePath) > 0) - return false; - } - return true; + const MsgMediaList &list = page.getMediaList(); + for (int i = 0; i < list.getLength(); ++i) { + const MsgMedia &media = list[i]; + std::string filePath = media.getFilePath(); + if (media.getType() != MsgMedia::UnknownType && FileUtils::getFileSize(filePath) > 0) + return false; + } + return true; } void SmilPage::build(const MsgPage &page) { - m_Duration = page.getPageDuration() / 1000.0 + 0.5; - - const MsgMediaList &list = page.getMediaList(); - for (int i = 0; i < list.getLength(); ++i) { - m_Attachments.push_back(list[i].getFilePath()); - } - - const MsgMedia *video = getMedia(page, MsgMedia::VideoType); - if (video) { - buildVideo(*video); - } else { - const MsgMedia *image = getMedia(page, MsgMedia::ImageType); - if (image) - buildImage(*image); - } - - const MsgMedia *text = getMedia(page, MsgMedia::TextType); - if (text) - buildText(*text); - - if (!video) { - const MsgMedia *audio = getMedia(page, MsgMedia::AudioType); - if (audio) - buildAudio(*audio); - } - - if (m_Duration <= 0) - m_Duration = defaultPageDuration; - - MSG_LOG("Page duration: ", m_Duration); + m_Duration = page.getPageDuration() / 1000.0 + 0.5; + + const MsgMediaList &list = page.getMediaList(); + for (int i = 0; i < list.getLength(); ++i) { + m_Attachments.push_back(list[i].getFilePath()); + } + + const MsgMedia *video = getMedia(page, MsgMedia::VideoType); + if (video) { + buildVideo(*video); + } else { + const MsgMedia *image = getMedia(page, MsgMedia::ImageType); + if (image) + buildImage(*image); + } + + const MsgMedia *text = getMedia(page, MsgMedia::TextType); + if (text) + buildText(*text); + + if (!video) { + const MsgMedia *audio = getMedia(page, MsgMedia::AudioType); + if (audio) + buildAudio(*audio); + } + + if (m_Duration <= 0) + m_Duration = defaultPageDuration; + + MSG_LOG("Page duration: ", m_Duration); } void SmilPage::build(const MsgAttachmentList &list) { - m_Duration = defaultPageDuration; + m_Duration = defaultPageDuration; - for (int i = 0; i < list.getLength(); ++i) { - m_Attachments.push_back(list[i].getFilePath()); - } + for (int i = 0; i < list.getLength(); ++i) { + m_Attachments.push_back(list[i].getFilePath()); + } - if (list.isEmpty()) - return; + if (list.isEmpty()) + return; - buildAttachmentInfo(list.getLength()); - buildSaveAllItem(list.getLength()); - for (int i = 0; i < list.getLength(); ++i) { - buildAttachment(list[i]); - } + buildAttachmentInfo(list.getLength()); + buildSaveAllItem(list.getLength()); + for (int i = 0; i < list.getLength(); ++i) { + buildAttachment(list[i]); + } } void SmilPage::buildImage(const MsgMedia &media) { - m_pImageItem = new SmilImageItemView(getBox(), media.getFilePath()); - m_HasInvalidFiles = m_pImageItem->getImage() == nullptr; - m_pImageItem->show(); - appendItem(*m_pImageItem); + m_pImageItem = new SmilImageItemView(getBox(), media.getFilePath()); + m_HasInvalidFiles = m_pImageItem->getImage() == nullptr; + m_pImageItem->show(); + appendItem(*m_pImageItem); } void SmilPage::buildText(const MsgMedia& media) { - std::string text = FileUtils::readTextFile(media.getFilePath()); - if (!text.empty()) { - SmilTextItemView *item = new SmilTextItemView(getBox(), text); - item->show(); - appendItem(*item); - } + std::string text = FileUtils::readTextFile(media.getFilePath()); + if (!text.empty()) { + SmilTextItemView *item = new SmilTextItemView(getBox(), text); + item->show(); + appendItem(*item); + } } void SmilPage::buildAudio(const MsgMedia& media) { - m_MediaPath = media.getFilePath(); - m_HasAudio = true; - - int duration = MediaUtils::getDurationSec(m_MediaPath); - if (duration == 0) { - m_HasInvalidFiles = true; - return; - } - - if (m_Duration == 0) - m_Duration = duration; - - SmilAudioItemView *item = new SmilAudioItemView(getBox(), media.getFileName()); - item->show(); - item->showIcon(true); - appendItem(*item); + m_MediaPath = media.getFilePath(); + m_HasAudio = true; + + int duration = MediaUtils::getDurationSec(m_MediaPath); + if (duration == 0) { + m_HasInvalidFiles = true; + return; + } + + if (m_Duration == 0) + m_Duration = duration; + + SmilAudioItemView *item = new SmilAudioItemView(getBox(), media.getFileName()); + item->show(); + item->showIcon(true); + appendItem(*item); } void SmilPage::buildVideo(const MsgMedia& media) { - m_MediaPath = media.getFilePath(); - - int duration = MediaUtils::getDurationSec(m_MediaPath); - if (duration == 0) { - m_HasInvalidFiles = true; - return; - } - if (m_Duration == 0) - m_Duration = duration; - - int width = 0; - int height = 0; - MediaUtils::getFrameSize(m_MediaPath, width, height); - - if (width * height == 0) { - MSG_LOG_ERROR("Wrong video dimension"); - m_HasInvalidFiles = true; - return; - } - - std::string thumbPath = FileUtils::genUniqueFilePath(PathUtils::getDataPath(""), "thumbnail.jpg"); - if (!thumbPath.empty()) - MediaUtils::getVideoFrame(m_MediaPath, thumbPath); - - SmilVideoItemView *item = new SmilVideoItemView(getBox(), width, height, thumbPath); - remove(thumbPath.c_str()); - m_pVideoSink = item->getVideoSink(); - item->show(); - appendItem(*item); + m_MediaPath = media.getFilePath(); + + int duration = MediaUtils::getDurationSec(m_MediaPath); + if (duration == 0) { + m_HasInvalidFiles = true; + return; + } + if (m_Duration == 0) + m_Duration = duration; + + int width = 0; + int height = 0; + MediaUtils::getFrameSize(m_MediaPath, width, height); + + if (width * height == 0) { + MSG_LOG_ERROR("Wrong video dimension"); + m_HasInvalidFiles = true; + return; + } + + std::string thumbPath = FileUtils::genUniqueFilePath(PathUtils::getDataPath(""), "thumbnail.jpg"); + if (!thumbPath.empty()) + MediaUtils::getVideoFrame(m_MediaPath, thumbPath); + + SmilVideoItemView *item = new SmilVideoItemView(getBox(), width, height, thumbPath); + remove(thumbPath.c_str()); + m_pVideoSink = item->getVideoSink(); + item->show(); + appendItem(*item); } void SmilPage::buildSaveAllItem(int attachmentCount) { - SmilSaveAllItemView *item = new SmilSaveAllItemView(getBox(), attachmentCount); - item->setListener(this); - appendItem(*item); + SmilSaveAllItemView *item = new SmilSaveAllItemView(getBox(), attachmentCount); + item->setListener(this); + appendItem(*item); } void SmilPage::buildAttachmentInfo(int attachmentCount) { - SmilAttachmentInfoItemView *item = new SmilAttachmentInfoItemView(getBox(), attachmentCount > 1); - item->show(); - appendItem(*item); + SmilAttachmentInfoItemView *item = new SmilAttachmentInfoItemView(getBox(), attachmentCount > 1); + item->show(); + appendItem(*item); } void SmilPage::buildAttachment(const MsgAttachment& attachment) { - SmilAttachmentItemView *item = new SmilAttachmentItemView(getBox()); - item->setListener(this); - item->setFilePath(attachment.getFilePath()); - item->setFileName(attachment.getFileName()); - item->show(); - appendItem(*item); + SmilAttachmentItemView *item = new SmilAttachmentItemView(getBox()); + item->setListener(this); + item->setFilePath(attachment.getFilePath()); + item->setFileName(attachment.getFileName()); + item->show(); + appendItem(*item); } void SmilPage::onItemClicked(SmilAttachmentItemView &item) { - MSG_LOG(""); - m_FileViewer.launchWithCopy(item.getFilePath()); + MSG_LOG(""); + m_FileViewer.launchWithCopy(item.getFilePath()); } void SmilPage::onSaveButtonClicked(SmilAttachmentItemView &item) { - MSG_LOG(""); - if (FileUtils::saveFileToStorage(item.getFilePath())) - notification_status_message_post(msg("IDS_MSGF_POP_SAVED_IN_MY_FILES").cStr()); + MSG_LOG(""); + if (FileUtils::saveFileToStorage(item.getFilePath())) + notification_status_message_post(msg("IDS_MSGF_POP_SAVED_IN_MY_FILES").cStr()); } void SmilPage::onItemClicked(SmilSaveAllItemView &item) { - MSG_LOG(""); - if (!m_Attachments.empty() && FileUtils::saveFilesToStorage(m_Attachments)) - notification_status_message_post(msg("IDS_MSGF_POP_SAVED_IN_MY_FILES").cStr()); + MSG_LOG(""); + if (!m_Attachments.empty() && FileUtils::saveFilesToStorage(m_Attachments)) + notification_status_message_post(msg("IDS_MSGF_POP_SAVED_IN_MY_FILES").cStr()); } diff --git a/src/Viewer/Controller/src/SmilPlayer.cpp b/src/Viewer/Controller/src/SmilPlayer.cpp index 01cbafc3..49062ef4 100644 --- a/src/Viewer/Controller/src/SmilPlayer.cpp +++ b/src/Viewer/Controller/src/SmilPlayer.cpp @@ -24,15 +24,15 @@ using namespace Msg; SmilPlayer::SmilPlayer(Evas_Object *parent, const MessageMms &mms) - : SmilPlayerView(parent) - , m_pListener(nullptr) - , m_pTimer(nullptr) - , m_CurrentPageIndex(0) - , m_Duration(0) - , m_State(StopState) - , m_PageTickCounter(0) + : SmilPlayerView(parent) + , m_pListener(nullptr) + , m_pTimer(nullptr) + , m_CurrentPageIndex(0) + , m_Duration(0) + , m_State(StopState) + , m_PageTickCounter(0) { - create(mms); + create(mms); } SmilPlayer::~SmilPlayer() @@ -41,320 +41,320 @@ SmilPlayer::~SmilPlayer() void SmilPlayer::create(const MessageMms &mms) { - // Pages: - const MsgPageList &pages = mms.getPageList(); - for (int i = 0; i < pages.getLength(); ++i) { - const MsgPage &page = pages[i]; - if (!SmilPage::isEmpty(page)) { - SmilPage *smilPage = new SmilPage(getEo(), m_FileViewer, page); - m_Duration += smilPage->getDuration(); - m_PageList.push_back(smilPage); - } - } + // Pages: + const MsgPageList &pages = mms.getPageList(); + for (int i = 0; i < pages.getLength(); ++i) { + const MsgPage &page = pages[i]; + if (!SmilPage::isEmpty(page)) { + SmilPage *smilPage = new SmilPage(getEo(), m_FileViewer, page); + m_Duration += smilPage->getDuration(); + m_PageList.push_back(smilPage); + } + } - // Attachment: - if (!mms.getAttachmentList().isEmpty()) { - SmilPage *smilPage = new SmilPage(getEo(), m_FileViewer, mms.getAttachmentList()); - m_Duration += smilPage->getDuration(); - m_PageList.push_back(smilPage); - } + // Attachment: + if (!mms.getAttachmentList().isEmpty()) { + SmilPage *smilPage = new SmilPage(getEo(), m_FileViewer, mms.getAttachmentList()); + m_Duration += smilPage->getDuration(); + m_PageList.push_back(smilPage); + } - if (!m_PageList.empty()) - displayPage(**m_PageList.begin()); + if (!m_PageList.empty()) + displayPage(**m_PageList.begin()); } void SmilPlayer::setListener(ISmilPlayerListener *l) { - m_pListener = l; + m_pListener = l; } void SmilPlayer::startTimer(int sec) { - if (m_pTimer) { - ecore_timer_del(m_pTimer); - m_pTimer = nullptr; - } - m_PageTickCounter = 0; - m_pTimer = ecore_timer_add(1.0, ECORE_TACK_CALLBACK(SmilPlayer, onTick), this); + if (m_pTimer) { + ecore_timer_del(m_pTimer); + m_pTimer = nullptr; + } + m_PageTickCounter = 0; + m_pTimer = ecore_timer_add(1.0, ECORE_TACK_CALLBACK(SmilPlayer, onTick), this); } void SmilPlayer::pauseTimer() { - if (m_pTimer) - ecore_timer_freeze(m_pTimer); + if (m_pTimer) + ecore_timer_freeze(m_pTimer); } void SmilPlayer::continueTimer() { - if (m_pTimer) - ecore_timer_thaw(m_pTimer); + if (m_pTimer) + ecore_timer_thaw(m_pTimer); } Eina_Bool SmilPlayer::onTick() { - MSG_LOG(""); + MSG_LOG(""); - ++m_PageTickCounter; - if (m_pListener) - m_pListener->onSmilPlayerTick(); + ++m_PageTickCounter; + if (m_pListener) + m_pListener->onSmilPlayerTick(); - if (m_PageTickCounter >= getCurrentPage()->getDuration()) - { - m_pTimer = nullptr; + if (m_PageTickCounter >= getCurrentPage()->getDuration()) + { + m_pTimer = nullptr; - if (!nextPage()) - stop(); - return false; - } - return true; + if (!nextPage()) + stop(); + return false; + } + return true; } void SmilPlayer::setState(State state) { - if (m_State != state) { - m_State = state; - if (m_pListener) - m_pListener->onSmilPlayerStateChanged(); - } + if (m_State != state) { + m_State = state; + if (m_pListener) + m_pListener->onSmilPlayerStateChanged(); + } } SmilPlayer::State SmilPlayer::getState() const { - return m_State; + return m_State; } void SmilPlayer::start() { - if (m_pTimer) { - if (canPlay(getCurrentPage())) { - MSG_LOG("Continue"); - setState(PlayState); - continueTimer(); - startMedia(); - playAnimation(true); - } - } else { - MSG_LOG("Restart"); - reset(); - if (canPlay(getCurrentPage())) - { - setState(PlayState); - playPage(); - } - } + if (m_pTimer) { + if (canPlay(getCurrentPage())) { + MSG_LOG("Continue"); + setState(PlayState); + continueTimer(); + startMedia(); + playAnimation(true); + } + } else { + MSG_LOG("Restart"); + reset(); + if (canPlay(getCurrentPage())) + { + setState(PlayState); + playPage(); + } + } } void SmilPlayer::stop() { - pauseTimer(); - stopMedia(); - playAnimation(false); - setState(StopState); + pauseTimer(); + stopMedia(); + playAnimation(false); + setState(StopState); } void SmilPlayer::reset() { - stop(); - m_CurrentPageIndex = 0; - m_PageTickCounter = 0; + stop(); + m_CurrentPageIndex = 0; + m_PageTickCounter = 0; } bool SmilPlayer::playPage() { - SmilPage *page = getCurrentPage(); - if (!page) - return false; + SmilPage *page = getCurrentPage(); + if (!page) + return false; - SmilPlayerView::displayPage(*page); - startTimer(page->getDuration()); - playAnimation(true); + SmilPlayerView::displayPage(*page); + startTimer(page->getDuration()); + playAnimation(true); - if (page->hasMedia()) { - prepareMedia(); - if (!canPlay(page)) { - stop(); - showUnableToPlayNotif(*page); - return false; - } - startMedia(); - } + if (page->hasMedia()) { + prepareMedia(); + if (!canPlay(page)) { + stop(); + showUnableToPlayNotif(*page); + return false; + } + startMedia(); + } - if (page->hasInvalidFiles()) - showNotSupportedFileNotif(); + if (page->hasInvalidFiles()) + showNotSupportedFileNotif(); - if (m_pListener) - m_pListener->onSmilPlayerPageChanged(); + if (m_pListener) + m_pListener->onSmilPlayerPageChanged(); - return true; + return true; } void SmilPlayer::prepareMedia() { - if (m_MediaPlayer) { - m_MediaPlayer->stop(); - m_MediaPlayer->setPosition(0); - } + if (m_MediaPlayer) { + m_MediaPlayer->stop(); + m_MediaPlayer->setPosition(0); + } - SmilPage *page = getCurrentPage(); - if (page->hasMedia()) { - if (!m_MediaPlayer) { - m_MediaPlayer.reset(new MediaPlayer); - m_MediaPlayer->setListener(this); - } + SmilPage *page = getCurrentPage(); + if (page->hasMedia()) { + if (!m_MediaPlayer) { + m_MediaPlayer.reset(new MediaPlayer); + m_MediaPlayer->setListener(this); + } - m_MediaPlayer->setUri(page->getMediaPath()); - Evas_Object *videoSink = page->getVideoSink(); - m_MediaPlayer->setDisplay(videoSink); - } + m_MediaPlayer->setUri(page->getMediaPath()); + Evas_Object *videoSink = page->getVideoSink(); + m_MediaPlayer->setDisplay(videoSink); + } } void SmilPlayer::stopMedia() { - if (m_MediaPlayer) - m_MediaPlayer->pause(); + if (m_MediaPlayer) + m_MediaPlayer->pause(); } bool SmilPlayer::canPlay(SmilPage *page) { - if (!page) - return false; + if (!page) + return false; - if (page->hasMedia() && m_MediaPlayer && !m_MediaPlayer->getFocus()) { - showUnableToPlayNotif(*page); - return false; - } - return true; + if (page->hasMedia() && m_MediaPlayer && !m_MediaPlayer->getFocus()) { + showUnableToPlayNotif(*page); + return false; + } + return true; } void SmilPlayer::startMedia() { - SmilPage *page = getCurrentPage(); - if (!page) - return; + SmilPage *page = getCurrentPage(); + if (!page) + return; - if (page->hasMedia() && m_MediaPlayer) - m_MediaPlayer->start(); + if (page->hasMedia() && m_MediaPlayer) + m_MediaPlayer->start(); } void SmilPlayer::playAnimation(bool start) { - SmilPage *page = getCurrentPage(); - if (!page || !page->hasAnimation()) - return; - page->playAnimation(start); + SmilPage *page = getCurrentPage(); + if (!page || !page->hasAnimation()) + return; + page->playAnimation(start); } double SmilPlayer::getPosition() const { - unsigned pos = 0; - for (unsigned i = 0; i < m_CurrentPageIndex; ++i) - pos += m_PageList[i]->getDuration(); + unsigned pos = 0; + for (unsigned i = 0; i < m_CurrentPageIndex; ++i) + pos += m_PageList[i]->getDuration(); - pos += m_PageTickCounter; + pos += m_PageTickCounter; - return pos / (double)m_Duration; + return pos / (double)m_Duration; } const SmilPlayer::PageList &SmilPlayer::getPages() const { - return m_PageList; + return m_PageList; } SmilPage *SmilPlayer::getCurrentPage() const { - return m_PageList[m_CurrentPageIndex]; + return m_PageList[m_CurrentPageIndex]; } int SmilPlayer::getDuration() const { - return m_Duration; + return m_Duration; } bool SmilPlayer::nextPage() { - if (probeNextPage()) { - stopMedia(); - ++m_CurrentPageIndex; - playPage(); - return true; - } - return false; + if (probeNextPage()) { + stopMedia(); + ++m_CurrentPageIndex; + playPage(); + return true; + } + return false; } bool SmilPlayer::prevPage() { - if (probePrevPage()) { - stopMedia(); - --m_CurrentPageIndex; - playPage(); - return true; - } - return false; + if (probePrevPage()) { + stopMedia(); + --m_CurrentPageIndex; + playPage(); + return true; + } + return false; } bool SmilPlayer::probeNextPage() const { - return m_CurrentPageIndex < m_PageList.size() - 1; + return m_CurrentPageIndex < m_PageList.size() - 1; } bool SmilPlayer::probePrevPage() const { - return m_CurrentPageIndex > 0; + return m_CurrentPageIndex > 0; } unsigned SmilPlayer::getCurrentPageIndex() const { - return m_CurrentPageIndex; + return m_CurrentPageIndex; } void SmilPlayer::showUnableToPlayVideoNotif() { - notification_status_message_post(msg("IDS_MSG_TPOP_CANT_PLAY_VIDEOS_DURING_CALLS").cStr()); + notification_status_message_post(msg("IDS_MSG_TPOP_CANT_PLAY_VIDEOS_DURING_CALLS").cStr()); } void SmilPlayer::showUnableToPlayAudioNotif() { - notification_status_message_post(msg("IDS_MSG_TPOP_CANT_PLAY_AUDIO_FILES_DURING_CALLS").cStr()); + notification_status_message_post(msg("IDS_MSG_TPOP_CANT_PLAY_AUDIO_FILES_DURING_CALLS").cStr()); } void SmilPlayer::showNotSupportedFileNotif() { - notification_status_message_post(msg("IDS_MSG_TPOP_CANT_PREVIEW_FILE_FILE_FORMAT_NOT_SUPPORTED").cStr()); + notification_status_message_post(msg("IDS_MSG_TPOP_CANT_PREVIEW_FILE_FILE_FORMAT_NOT_SUPPORTED").cStr()); } void SmilPlayer::showUnableToPlayNotif(SmilPage &page) { - if (page.hasVideo()) - showUnableToPlayVideoNotif(); - else if (page.hasAudio()) - showUnableToPlayAudioNotif(); + if (page.hasVideo()) + showUnableToPlayVideoNotif(); + else if (page.hasAudio()) + showUnableToPlayAudioNotif(); } void SmilPlayer::onBeforeDelete(View &view) { - MSG_LOG(""); + MSG_LOG(""); - m_pListener = nullptr; - stop(); + m_pListener = nullptr; + stop(); - for (SmilPage *page : m_PageList) - page->destroy(); + for (SmilPage *page : m_PageList) + page->destroy(); - if (m_pTimer) { - ecore_timer_del(m_pTimer); - m_pTimer = nullptr; - } + if (m_pTimer) { + ecore_timer_del(m_pTimer); + m_pTimer = nullptr; + } } void SmilPlayer::onMediaPlayerSoundFocusChanged() { - if (m_MediaPlayer->isPlaying() && !m_MediaPlayer->getFocus()) { - SmilPage *page = getCurrentPage(); - if (page) { - if (page->hasMedia()) { - showUnableToPlayNotif(*page); - stop(); - } - } - } + if (m_MediaPlayer->isPlaying() && !m_MediaPlayer->getFocus()) { + SmilPage *page = getCurrentPage(); + if (page) { + if (page->hasMedia()) { + showUnableToPlayNotif(*page); + stop(); + } + } + } } diff --git a/src/Viewer/Controller/src/Viewer.cpp b/src/Viewer/Controller/src/Viewer.cpp index bcfe8e95..a545163a 100644 --- a/src/Viewer/Controller/src/Viewer.cpp +++ b/src/Viewer/Controller/src/Viewer.cpp @@ -33,422 +33,422 @@ using namespace Msg; namespace { - std::string makeTimeStr(int timeSec) - { - const int digitCount = 2; - int min = timeSec / 60; - int sec = timeSec % 60; + std::string makeTimeStr(int timeSec) + { + const int digitCount = 2; + int min = timeSec / 60; + int sec = timeSec % 60; - std::ostringstream ss; - ss.width(); - ss << std::setw(digitCount) << std::setfill('0') << min << ":" << std::setw(digitCount) << std::setfill('0') << sec; - return ss.str(); - } + std::ostringstream ss; + ss.width(); + ss << std::setw(digitCount) << std::setfill('0') << min << ":" << std::setw(digitCount) << std::setfill('0') << sec; + return ss.str(); + } } Viewer::Viewer(NaviFrameController &parent, MsgId id) - : FrameController(parent) - , m_pLayout(nullptr) - , m_pPlayerControl(nullptr) - , m_pRecipPanel(nullptr) - , m_pSmilPlayer(nullptr) - , m_pSubjectLayout(nullptr) + : FrameController(parent) + , m_pLayout(nullptr) + , m_pPlayerControl(nullptr) + , m_pRecipPanel(nullptr) + , m_pSmilPlayer(nullptr) + , m_pSubjectLayout(nullptr) { - create(id); + create(id); } Viewer::~Viewer() { - MSG_LOG(""); - getApp().getMsgEngine().getStorage().removeListener(*this); - getApp().getContactManager().removeListener(*this); - getApp().getSysSettingsManager().removeListener(*this); + MSG_LOG(""); + getApp().getMsgEngine().getStorage().removeListener(*this); + getApp().getContactManager().removeListener(*this); + getApp().getSysSettingsManager().removeListener(*this); } void Viewer::onAttached(ViewItem &item) { - FrameController::onAttached(item); - updateNavibar(); - setContent(*m_pLayout); + FrameController::onAttached(item); + updateNavibar(); + setContent(*m_pLayout); } void Viewer::updateNavibar() { - getNaviBar().clear(); - getNaviBar().setColor(NaviBar::NaviBlueColorId); - getNaviBar().showButton(NaviPrevButtonId, true); - if (m_Msg->getAddressList().getLength() > 1) - getNaviBar().showButton(NaviExpandButtonId, true); - FrameController::setNaviBarTitle(m_Msg->getAddressList()); + getNaviBar().clear(); + getNaviBar().setColor(NaviBar::NaviBlueColorId); + getNaviBar().showButton(NaviPrevButtonId, true); + if (m_Msg->getAddressList().getLength() > 1) + getNaviBar().showButton(NaviExpandButtonId, true); + FrameController::setNaviBarTitle(m_Msg->getAddressList()); } void Viewer::updateRecipPanel() { - if (m_pRecipPanel) - m_pRecipPanel->update(m_Msg->getAddressList()); + if (m_pRecipPanel) + m_pRecipPanel->update(m_Msg->getAddressList()); } void Viewer::create(MsgId id) { - m_Msg = std::dynamic_pointer_cast(getMsgEngine().getStorage().getMessage(id)); - if (!m_Msg) { - MSG_LOG_ERROR("Can't get message by id"); - // Create empty message: - m_Msg = getMsgEngine().getComposer().createMms(); - } + m_Msg = std::dynamic_pointer_cast(getMsgEngine().getStorage().getMessage(id)); + if (!m_Msg) { + MSG_LOG_ERROR("Can't get message by id"); + // Create empty message: + m_Msg = getMsgEngine().getComposer().createMms(); + } - createLayout(); - createSmilPlayer(); - createSubjectLayout(); - createPlayerControl(); - createRecipPanel(); + createLayout(); + createSmilPlayer(); + createSubjectLayout(); + createPlayerControl(); + createRecipPanel(); - updateButtonState(); - updatePlayPos(); + updateButtonState(); + updatePlayPos(); - getApp().getSysSettingsManager().addListener(*this); - getApp().getContactManager().addListener(*this); - getApp().getMsgEngine().getStorage().addListener(*this); - setHwButtonListener(*m_pLayout, this); + getApp().getSysSettingsManager().addListener(*this); + getApp().getContactManager().addListener(*this); + getApp().getMsgEngine().getStorage().addListener(*this); + setHwButtonListener(*m_pLayout, this); - m_pSmilPlayer->start(); + m_pSmilPlayer->start(); } void Viewer::createLayout() { - if (!m_pLayout) { - m_pLayout = new ViewerLayout(getParent()); - m_pLayout->setListener(this); - m_pLayout->show(); - } + if (!m_pLayout) { + m_pLayout = new ViewerLayout(getParent()); + m_pLayout->setListener(this); + m_pLayout->show(); + } } void Viewer::createSubjectLayout() { - if (!m_pSubjectLayout) { - int numberOfPages = m_pSmilPlayer ? m_pSmilPlayer->getPages().size() : 0; - m_pSubjectLayout = new SubjectLayout(*m_pLayout); - m_pSubjectLayout->setNumberOfPages(numberOfPages); - m_pSubjectLayout->show(); - m_pLayout->setSubject(*m_pSubjectLayout); - updateSubject(); - } + if (!m_pSubjectLayout) { + int numberOfPages = m_pSmilPlayer ? m_pSmilPlayer->getPages().size() : 0; + m_pSubjectLayout = new SubjectLayout(*m_pLayout); + m_pSubjectLayout->setNumberOfPages(numberOfPages); + m_pSubjectLayout->show(); + m_pLayout->setSubject(*m_pSubjectLayout); + updateSubject(); + } } void Viewer::createPlayerControl() { - if (!m_pPlayerControl) { - m_pPlayerControl = new PlayerControl(*m_pLayout); + if (!m_pPlayerControl) { + m_pPlayerControl = new PlayerControl(*m_pLayout); - m_pPlayerControl->setListener(this); - m_pPlayerControl->show(); - m_pPlayerControl->setProgress(0.0); - m_pLayout->setPlayerControl(*m_pPlayerControl); + m_pPlayerControl->setListener(this); + m_pPlayerControl->show(); + m_pPlayerControl->setProgress(0.0); + m_pLayout->setPlayerControl(*m_pPlayerControl); - createSmilPlayer(); - m_pPlayerControl->setStartTime(makeTimeStr(0)); - m_pPlayerControl->setEndTime(makeTimeStr(m_pSmilPlayer->getDuration())); - } + createSmilPlayer(); + m_pPlayerControl->setStartTime(makeTimeStr(0)); + m_pPlayerControl->setEndTime(makeTimeStr(m_pSmilPlayer->getDuration())); + } } void Viewer::createRecipPanel() { - if (!m_pRecipPanel && m_Msg->getAddressList().getLength() > 1) { - m_pRecipPanel = new MbeRecipients(*m_pLayout, getApp()); - m_pRecipPanel->addSmartCb("item,clicked", SMART_CALLBACK(Viewer, onRecipItemClicked), this); - m_pRecipPanel->show(); - m_pLayout->setRecipients(*m_pRecipPanel); - updateRecipPanel(); - } + if (!m_pRecipPanel && m_Msg->getAddressList().getLength() > 1) { + m_pRecipPanel = new MbeRecipients(*m_pLayout, getApp()); + m_pRecipPanel->addSmartCb("item,clicked", SMART_CALLBACK(Viewer, onRecipItemClicked), this); + m_pRecipPanel->show(); + m_pLayout->setRecipients(*m_pRecipPanel); + updateRecipPanel(); + } } void Viewer::createSmilPlayer() { - if (!m_pSmilPlayer) { - m_pSmilPlayer = new SmilPlayer(*m_pLayout, *m_Msg); - m_pSmilPlayer->setListener(this); - m_pSmilPlayer->show(); - m_pLayout->setBody(*m_pSmilPlayer); - } + if (!m_pSmilPlayer) { + m_pSmilPlayer = new SmilPlayer(*m_pLayout, *m_Msg); + m_pSmilPlayer->setListener(this); + m_pSmilPlayer->show(); + m_pLayout->setBody(*m_pSmilPlayer); + } } void Viewer::naviExpandButtonHandler() { - MSG_LOG(""); - if (m_pRecipPanel) { - bool isRecipInvisible = !m_pLayout->isRecipientsVisible(); - m_pLayout->showRecipients(isRecipInvisible); - getNaviBar().setDownButtonState(isRecipInvisible); - } + MSG_LOG(""); + if (m_pRecipPanel) { + bool isRecipInvisible = !m_pLayout->isRecipientsVisible(); + m_pLayout->showRecipients(isRecipInvisible); + getNaviBar().setDownButtonState(isRecipInvisible); + } } void Viewer::naviCenterButtonHandler() { - MSG_LOG(""); - if (m_pRecipPanel) { - naviExpandButtonHandler(); - } else { - const MsgAddressList &addressList = m_Msg->getAddressList(); - if (!addressList.isEmpty()) - recipientClickHandler(addressList[0].getAddress()); - } + MSG_LOG(""); + if (m_pRecipPanel) { + naviExpandButtonHandler(); + } else { + const MsgAddressList &addressList = m_Msg->getAddressList(); + if (!addressList.isEmpty()) + recipientClickHandler(addressList[0].getAddress()); + } } void Viewer::naviPrevButtonHandler() { - pop(); + pop(); } void Viewer::showRecipPopup(const std::string &address) { - PopupList &popup = getApp().getPopupManager().getPopupList(); - popup.setTitle(address); - if (MsgUtils::isValidNumber(address)) - popup.appendItem(msg("IDS_MSG_OPT_MAKE_VOICE_CALL"), POPUPLIST_ITEM_PRESSED_CB(Viewer, onMakeVoiceItemPressed), this); - popup.appendItem(msg("IDS_MSG_OPT_CREATE_CONTACT_ABB"), POPUPLIST_ITEM_PRESSED_CB(Viewer, onCreateContactItemPressed), this); - popup.appendItem(msg("IDS_MSG_OPT_UPDATE_CONTACT"), POPUPLIST_ITEM_PRESSED_CB(Viewer, onUpdateContactItemPressed), this); - popup.show(); + PopupList &popup = getApp().getPopupManager().getPopupList(); + popup.setTitle(address); + if (MsgUtils::isValidNumber(address)) + popup.appendItem(msg("IDS_MSG_OPT_MAKE_VOICE_CALL"), POPUPLIST_ITEM_PRESSED_CB(Viewer, onMakeVoiceItemPressed), this); + popup.appendItem(msg("IDS_MSG_OPT_CREATE_CONTACT_ABB"), POPUPLIST_ITEM_PRESSED_CB(Viewer, onCreateContactItemPressed), this); + popup.appendItem(msg("IDS_MSG_OPT_UPDATE_CONTACT"), POPUPLIST_ITEM_PRESSED_CB(Viewer, onUpdateContactItemPressed), this); + popup.show(); } void Viewer::recipientClickHandler(const std::string &address) { - MSG_LOG(""); - m_SelectedAddress = address; - ContactAddressRef contactAddress = getApp().getContactManager().getContactAddress(address); - if (contactAddress) - m_ContactViewer.launch(*contactAddress); - else - showRecipPopup(address); + MSG_LOG(""); + m_SelectedAddress = address; + ContactAddressRef contactAddress = getApp().getContactManager().getContactAddress(address); + if (contactAddress) + m_ContactViewer.launch(*contactAddress); + else + showRecipPopup(address); } void Viewer::updatePlayPos() { - double pos = m_pSmilPlayer->getPosition(); - int sec = m_pSmilPlayer->getDuration() * pos + 0.5; - m_pPlayerControl->setProgress(pos); - m_pPlayerControl->setStartTime(makeTimeStr(sec)); + double pos = m_pSmilPlayer->getPosition(); + int sec = m_pSmilPlayer->getDuration() * pos + 0.5; + m_pPlayerControl->setProgress(pos); + m_pPlayerControl->setStartTime(makeTimeStr(sec)); } void Viewer::updateSubject() { - if (m_pSubjectLayout) { - std::string subject = m_Msg->getSubject(); - if (subject.empty()) - subject = msg("IDS_MSGF_BODY_NO_SUBJECT"); - m_pSubjectLayout->setSubjectText(subject); - } + if (m_pSubjectLayout) { + std::string subject = m_Msg->getSubject(); + if (subject.empty()) + subject = msg("IDS_MSGF_BODY_NO_SUBJECT"); + m_pSubjectLayout->setSubjectText(subject); + } } void Viewer::updateButtonState() { - auto playPauseState = PlayerControl::PauseState; - bool isPlaying = m_pSmilPlayer->getState() == SmilPlayer::PlayState; + auto playPauseState = PlayerControl::PauseState; + bool isPlaying = m_pSmilPlayer->getState() == SmilPlayer::PlayState; - if (m_pSmilPlayer->getState() == SmilPlayer::StopState) - playPauseState = PlayerControl::PlayState; + if (m_pSmilPlayer->getState() == SmilPlayer::StopState) + playPauseState = PlayerControl::PlayState; - m_pPlayerControl->setPlayState(playPauseState); - m_pPlayerControl->enableNextButton(m_pSmilPlayer->probeNextPage() && isPlaying); - m_pPlayerControl->enablePrevButton(m_pSmilPlayer->probePrevPage() && isPlaying); + m_pPlayerControl->setPlayState(playPauseState); + m_pPlayerControl->enableNextButton(m_pSmilPlayer->probeNextPage() && isPlaying); + m_pPlayerControl->enablePrevButton(m_pSmilPlayer->probePrevPage() && isPlaying); } void Viewer::onHwBackButtonClicked() { - pop(); + pop(); } void Viewer::onHwMoreButtonClicked() { - m_pSmilPlayer->stop(); + m_pSmilPlayer->stop(); - PopupList &popup = getApp().getPopupManager().getMorePopup(); - popup.appendItem(msg("IDS_MSG_OPT_DELETE"), POPUPLIST_ITEM_PRESSED_CB(Viewer, onDeleteItemPressed), this); + PopupList &popup = getApp().getPopupManager().getMorePopup(); + popup.appendItem(msg("IDS_MSG_OPT_DELETE"), POPUPLIST_ITEM_PRESSED_CB(Viewer, onDeleteItemPressed), this); - if (!m_Msg->getText().empty()) - popup.appendItem(msg("IDS_MSG_OPT_COPY_TEXT"), POPUPLIST_ITEM_PRESSED_CB(Viewer, onCopyTextItemPressed), this); + if (!m_Msg->getText().empty()) + popup.appendItem(msg("IDS_MSG_OPT_COPY_TEXT"), POPUPLIST_ITEM_PRESSED_CB(Viewer, onCopyTextItemPressed), this); - popup.appendItem(msg("IDS_MSGF_OPT_FORWARD"), POPUPLIST_ITEM_PRESSED_CB(Viewer, onForwardItemPressed), this); + popup.appendItem(msg("IDS_MSGF_OPT_FORWARD"), POPUPLIST_ITEM_PRESSED_CB(Viewer, onForwardItemPressed), this); - bool hasAttachment = !m_Msg->getAttachmentList().isEmpty() || m_Msg->getMediaCount() > 0; - if (hasAttachment) - popup.appendItem(msg("IDS_MSG_OPT_SAVE_ATTACHMENTS_ABB"), POPUPLIST_ITEM_PRESSED_CB(Viewer, onSaveAttachmentsItemPressed), this); + bool hasAttachment = !m_Msg->getAttachmentList().isEmpty() || m_Msg->getMediaCount() > 0; + if (hasAttachment) + popup.appendItem(msg("IDS_MSG_OPT_SAVE_ATTACHMENTS_ABB"), POPUPLIST_ITEM_PRESSED_CB(Viewer, onSaveAttachmentsItemPressed), this); - popup.show(); + popup.show(); } void Viewer::onButtonClicked(NaviFrameItem &item, NaviButtonId buttonId) { - MSG_LOG(""); - switch (buttonId) { - case NaviCenterButtonId: - naviCenterButtonHandler(); - break; - case NaviPrevButtonId: - naviPrevButtonHandler(); - break; - case NaviExpandButtonId: - naviExpandButtonHandler(); - break; - default: - break; - }; + MSG_LOG(""); + switch (buttonId) { + case NaviCenterButtonId: + naviCenterButtonHandler(); + break; + case NaviPrevButtonId: + naviPrevButtonHandler(); + break; + case NaviExpandButtonId: + naviExpandButtonHandler(); + break; + default: + break; + }; } void Viewer::onPlayClicked() { - MSG_LOG(""); - m_pSmilPlayer->start(); + MSG_LOG(""); + m_pSmilPlayer->start(); } void Viewer::onPauseClicked() { - MSG_LOG(""); - m_pSmilPlayer->stop(); + MSG_LOG(""); + m_pSmilPlayer->stop(); } void Viewer::onNextClicked() { - MSG_LOG(""); - m_pSmilPlayer->nextPage(); + MSG_LOG(""); + m_pSmilPlayer->nextPage(); } void Viewer::onPrevClicked() { - MSG_LOG(""); - m_pSmilPlayer->prevPage(); + MSG_LOG(""); + m_pSmilPlayer->prevPage(); } void Viewer::onContactChanged() { - MSG_LOG(""); - updateNavibar(); + MSG_LOG(""); + updateNavibar(); } void Viewer::onLayoutTap() { - MSG_LOG(""); - m_pLayout->showPlayerControl(!m_pLayout->isPlayerControlVisible()); + MSG_LOG(""); + m_pLayout->showPlayerControl(!m_pLayout->isPlayerControlVisible()); } void Viewer::onMakeVoiceItemPressed(PopupListItem &item) { - MSG_LOG(""); - item.getParent().destroy(); - VoiceCall::launch(m_SelectedAddress); + MSG_LOG(""); + item.getParent().destroy(); + VoiceCall::launch(m_SelectedAddress); } void Viewer::onCreateContactItemPressed(PopupListItem &item) { - MSG_LOG(""); - item.getParent().destroy(); - m_ContactEditor.launch(m_SelectedAddress, ContactEditor::CreateOp); + MSG_LOG(""); + item.getParent().destroy(); + m_ContactEditor.launch(m_SelectedAddress, ContactEditor::CreateOp); } void Viewer::onUpdateContactItemPressed(PopupListItem &item) { - MSG_LOG(""); - item.getParent().destroy(); - m_ContactEditor.launch(m_SelectedAddress, ContactEditor::EditOp); + MSG_LOG(""); + item.getParent().destroy(); + m_ContactEditor.launch(m_SelectedAddress, ContactEditor::EditOp); } void Viewer::onDeleteItemPressed(PopupListItem &item) { - item.getParent().destroy(); - Popup &popup = getApp().getPopupManager().getPopup(); - popup.addButton(msgt("IDS_MSG_BUTTON_CANCEL_ABB"), Popup::CancelButtonId, POPUP_BUTTON_CB(Viewer, onCancelButtonClicked), this); - popup.addButton(msgt("IDS_MSG_BUTTON_DELETE_ABB4"), Popup::OkButtonId, POPUP_BUTTON_CB(Viewer, onDeleteButtonClicked), this); - popup.setTitle(msgt("IDS_MSG_HEADER_DELETE")); - popup.setContent(msgt("IDS_MSG_POP_1_MESSAGE_WILL_BE_DELETED")); - popup.show(); + item.getParent().destroy(); + Popup &popup = getApp().getPopupManager().getPopup(); + popup.addButton(msgt("IDS_MSG_BUTTON_CANCEL_ABB"), Popup::CancelButtonId, POPUP_BUTTON_CB(Viewer, onCancelButtonClicked), this); + popup.addButton(msgt("IDS_MSG_BUTTON_DELETE_ABB4"), Popup::OkButtonId, POPUP_BUTTON_CB(Viewer, onDeleteButtonClicked), this); + popup.setTitle(msgt("IDS_MSG_HEADER_DELETE")); + popup.setContent(msgt("IDS_MSG_POP_1_MESSAGE_WILL_BE_DELETED")); + popup.show(); } void Viewer::onCancelButtonClicked(Popup &popup, int buttonId) { - popup.destroy(); + popup.destroy(); } void Viewer::onDeleteButtonClicked(Popup &popup, int buttonId) { - popup.destroy(); - getApp().getMsgEngine().getStorage().deleteMessage(m_Msg->getId()); + popup.destroy(); + getApp().getMsgEngine().getStorage().deleteMessage(m_Msg->getId()); } void Viewer::onCopyTextItemPressed(PopupListItem &item) { - item.getParent().destroy(); - std::string msgText = m_Msg->getText(); - elm_cnp_selection_set(this->getContent(), ELM_SEL_TYPE_CLIPBOARD, ELM_SEL_FORMAT_TEXT, msgText.c_str(), msgText.length()); + item.getParent().destroy(); + std::string msgText = m_Msg->getText(); + elm_cnp_selection_set(this->getContent(), ELM_SEL_TYPE_CLIPBOARD, ELM_SEL_FORMAT_TEXT, msgText.c_str(), msgText.length()); } void Viewer::onForwardItemPressed(PopupListItem &item) { - item.getParent().destroy(); + item.getParent().destroy(); - Conversation *conv = new Conversation(getParent()); - conv->setListener(this); - conv->forwardMsg(m_Msg->getId()); - getParent().push(*conv); + Conversation *conv = new Conversation(getParent()); + conv->setListener(this); + conv->forwardMsg(m_Msg->getId()); + getParent().push(*conv); } void Viewer::onSaveAttachmentsItemPressed(PopupListItem &item) { - MSG_LOG(""); - item.getParent().destroy(); - SaveAttachments *controller = new SaveAttachments(getParent(), m_Msg->getId()); - getParent().push(*controller); + MSG_LOG(""); + item.getParent().destroy(); + SaveAttachments *controller = new SaveAttachments(getParent(), m_Msg->getId()); + getParent().push(*controller); } void Viewer::onRecipItemClicked(Evas_Object *obj, void *eventInfo) { - MSG_LOG(""); - MbeRecipientItem *item = ViewItem::staticCast(eventInfo); - recipientClickHandler(item->getAddress()); + MSG_LOG(""); + MbeRecipientItem *item = ViewItem::staticCast(eventInfo); + recipientClickHandler(item->getAddress()); } void Viewer::onConversationSentMessage() { - pop(); + pop(); } void Viewer::onSmilPlayerStateChanged() { - MSG_LOG("Smil player state: ", m_pSmilPlayer->getState()); - updateButtonState(); + MSG_LOG("Smil player state: ", m_pSmilPlayer->getState()); + updateButtonState(); } void Viewer::onSmilPlayerPageChanged() { - MSG_LOG(""); - updateButtonState(); - updatePlayPos(); - m_pSubjectLayout->setPageIndex(m_pSmilPlayer->getCurrentPageIndex() + 1); + MSG_LOG(""); + updateButtonState(); + updatePlayPos(); + m_pSubjectLayout->setPageIndex(m_pSmilPlayer->getCurrentPageIndex() + 1); } void Viewer::onSmilPlayerTick() { - MSG_LOG(""); - updatePlayPos(); + MSG_LOG(""); + updatePlayPos(); } void Viewer::onLanguageChanged() { - MSG_LOG(""); - updateSubject(); + MSG_LOG(""); + updateSubject(); } void Viewer::onMsgStorageDelete(const MsgIdList &msgIdList) { - MSG_LOG(""); - if (m_Msg) { - MsgId id = m_Msg->getId(); - if (std::find(msgIdList.begin(), msgIdList.end(), id) != msgIdList.end()) - pop(); - } + MSG_LOG(""); + if (m_Msg) { + MsgId id = m_Msg->getId(); + if (std::find(msgIdList.begin(), msgIdList.end(), id) != msgIdList.end()) + pop(); + } } void Viewer::onPause() { - MSG_LOG(""); - if (m_pSmilPlayer) - m_pSmilPlayer->stop(); + MSG_LOG(""); + if (m_pSmilPlayer) + m_pSmilPlayer->stop(); } diff --git a/src/Viewer/Utils/inc/MediaPlayer.h b/src/Viewer/Utils/inc/MediaPlayer.h index 50d3cfe5..8a8af1e0 100644 --- a/src/Viewer/Utils/inc/MediaPlayer.h +++ b/src/Viewer/Utils/inc/MediaPlayer.h @@ -23,54 +23,54 @@ #include namespace Msg { - class IMediaPlayerListener; + class IMediaPlayerListener; - class MediaPlayer { - public: - MediaPlayer(); - ~MediaPlayer(); - MediaPlayer(const MediaPlayer&) = delete; - MediaPlayer& operator=(const MediaPlayer&) = delete; + class MediaPlayer { + public: + MediaPlayer(); + ~MediaPlayer(); + MediaPlayer(const MediaPlayer&) = delete; + MediaPlayer& operator=(const MediaPlayer&) = delete; - void setDisplay(Evas_Object *obj); - void start(); - void stop(); - void pause(); - bool isPlaying() const; - void setUri(const std::string &uri); - void setListener(IMediaPlayerListener *l); - int getDuration() const; // msec - void setPosition(int msec); - static int getDuration(const std::string &uri); - bool getFocus() const; + void setDisplay(Evas_Object *obj); + void start(); + void stop(); + void pause(); + bool isPlaying() const; + void setUri(const std::string &uri); + void setListener(IMediaPlayerListener *l); + int getDuration() const; // msec + void setPosition(int msec); + static int getDuration(const std::string &uri); + bool getFocus() const; - private: - static void on_completed_cb(void *user_data); - static void on_seek_cb(void *user_data); + private: + static void on_completed_cb(void *user_data); + static void on_seek_cb(void *user_data); - // Call from media internal thread: - static void on_sound_stream_focus_state_changed_cb(sound_stream_info_h stream_info, - sound_stream_focus_mask_e focus_mask, - sound_stream_focus_state_e focus_state, - sound_stream_focus_change_reason_e reason, - int sound_behavior, - const char *extra_info, - void *user_data); - player_state_e getState() const; - static bool isCallReason(sound_stream_focus_change_reason_e reason); + // Call from media internal thread: + static void on_sound_stream_focus_state_changed_cb(sound_stream_info_h stream_info, + sound_stream_focus_mask_e focus_mask, + sound_stream_focus_state_e focus_state, + sound_stream_focus_change_reason_e reason, + int sound_behavior, + const char *extra_info, + void *user_data); + player_state_e getState() const; + static bool isCallReason(sound_stream_focus_change_reason_e reason); - private: - player_h m_Player; - IMediaPlayerListener *m_pListener; - sound_stream_info_h m_StreamInfo; - }; + private: + player_h m_Player; + IMediaPlayerListener *m_pListener; + sound_stream_info_h m_StreamInfo; + }; - class IMediaPlayerListener { - public: - virtual ~IMediaPlayerListener() {} - virtual void onMediaPlayerCompleted() {}; - virtual void onMediaPlayerSoundFocusChanged() {}; - }; + class IMediaPlayerListener { + public: + virtual ~IMediaPlayerListener() {} + virtual void onMediaPlayerCompleted() {}; + virtual void onMediaPlayerSoundFocusChanged() {}; + }; } #endif // MediaPlayer_h_ diff --git a/src/Viewer/Utils/src/MediaPlayer.cpp b/src/Viewer/Utils/src/MediaPlayer.cpp index c8c7229a..daea6737 100644 --- a/src/Viewer/Utils/src/MediaPlayer.cpp +++ b/src/Viewer/Utils/src/MediaPlayer.cpp @@ -23,173 +23,173 @@ using namespace Msg; MediaPlayer::MediaPlayer() - : m_Player() - , m_pListener(nullptr) - , m_StreamInfo() -{ - sound_manager_create_stream_information(SOUND_STREAM_TYPE_MEDIA, on_sound_stream_focus_state_changed_cb, this, &m_StreamInfo); - if (m_StreamInfo) { - player_create(&m_Player); - if (m_Player) { - player_set_sound_type(m_Player, SOUND_TYPE_MEDIA); - player_set_volume(m_Player, 1.0, 1.0); - player_set_looping(m_Player, false); - player_set_sound_stream_info(m_Player, m_StreamInfo); - player_set_completed_cb(m_Player, on_completed_cb, this); - } - } + : m_Player() + , m_pListener(nullptr) + , m_StreamInfo() +{ + sound_manager_create_stream_information(SOUND_STREAM_TYPE_MEDIA, on_sound_stream_focus_state_changed_cb, this, &m_StreamInfo); + if (m_StreamInfo) { + player_create(&m_Player); + if (m_Player) { + player_set_sound_type(m_Player, SOUND_TYPE_MEDIA); + player_set_volume(m_Player, 1.0, 1.0); + player_set_looping(m_Player, false); + player_set_sound_stream_info(m_Player, m_StreamInfo); + player_set_completed_cb(m_Player, on_completed_cb, this); + } + } } MediaPlayer::~MediaPlayer() { - m_pListener = nullptr; - stop(); + m_pListener = nullptr; + stop(); - if (m_StreamInfo) - sound_manager_destroy_stream_information(m_StreamInfo); + if (m_StreamInfo) + sound_manager_destroy_stream_information(m_StreamInfo); - if (m_Player) { - player_unprepare(m_Player); - player_destroy(m_Player); - } + if (m_Player) { + player_unprepare(m_Player); + player_destroy(m_Player); + } } void MediaPlayer::setDisplay(Evas_Object *obj) { - player_set_display_mode(m_Player, PLAYER_DISPLAY_MODE_LETTER_BOX); - player_set_display(m_Player, PLAYER_DISPLAY_TYPE_EVAS, GET_DISPLAY(obj)); - player_set_display_visible(m_Player, obj != nullptr); + player_set_display_mode(m_Player, PLAYER_DISPLAY_MODE_LETTER_BOX); + player_set_display(m_Player, PLAYER_DISPLAY_TYPE_EVAS, GET_DISPLAY(obj)); + player_set_display_visible(m_Player, obj != nullptr); } player_state_e MediaPlayer::getState() const { - player_state_e state = PLAYER_STATE_NONE; - player_get_state(m_Player, &state); - return state; + player_state_e state = PLAYER_STATE_NONE; + player_get_state(m_Player, &state); + return state; } bool MediaPlayer::isCallReason(sound_stream_focus_change_reason_e reason) { - return reason == SOUND_STREAM_FOCUS_CHANGED_BY_RINGTONE || - reason == SOUND_STREAM_FOCUS_CHANGED_BY_VOIP || - reason == SOUND_STREAM_FOCUS_CHANGED_BY_CALL; + return reason == SOUND_STREAM_FOCUS_CHANGED_BY_RINGTONE || + reason == SOUND_STREAM_FOCUS_CHANGED_BY_VOIP || + reason == SOUND_STREAM_FOCUS_CHANGED_BY_CALL; } bool MediaPlayer::getFocus() const { - sound_stream_focus_change_reason_e acquiredBy = SOUND_STREAM_FOCUS_CHANGED_BY_MEDIA; - int flags = 0; - char *extraInfo = nullptr; + sound_stream_focus_change_reason_e acquiredBy = SOUND_STREAM_FOCUS_CHANGED_BY_MEDIA; + int flags = 0; + char *extraInfo = nullptr; - if (sound_manager_get_current_playback_focus(&acquiredBy, &flags, &extraInfo) == SOUND_MANAGER_ERROR_NONE) { - free(extraInfo); - return !isCallReason(acquiredBy); - } + if (sound_manager_get_current_playback_focus(&acquiredBy, &flags, &extraInfo) == SOUND_MANAGER_ERROR_NONE) { + free(extraInfo); + return !isCallReason(acquiredBy); + } - return true; + return true; } void MediaPlayer::start() { - sound_manager_acquire_focus(m_StreamInfo, SOUND_STREAM_FOCUS_FOR_PLAYBACK, SOUND_BEHAVIOR_NONE, nullptr); - if (getState() == PLAYER_STATE_IDLE) - player_prepare(m_Player); + sound_manager_acquire_focus(m_StreamInfo, SOUND_STREAM_FOCUS_FOR_PLAYBACK, SOUND_BEHAVIOR_NONE, nullptr); + if (getState() == PLAYER_STATE_IDLE) + player_prepare(m_Player); - if (getState() != PLAYER_STATE_PLAYING) - player_start(m_Player); + if (getState() != PLAYER_STATE_PLAYING) + player_start(m_Player); } void MediaPlayer::stop() { - sound_manager_release_focus(m_StreamInfo, SOUND_STREAM_FOCUS_FOR_PLAYBACK, SOUND_BEHAVIOR_NONE, nullptr); - player_state_e state = getState(); - if (state == PLAYER_STATE_PLAYING || state == PLAYER_STATE_PAUSED) - player_stop(m_Player); + sound_manager_release_focus(m_StreamInfo, SOUND_STREAM_FOCUS_FOR_PLAYBACK, SOUND_BEHAVIOR_NONE, nullptr); + player_state_e state = getState(); + if (state == PLAYER_STATE_PLAYING || state == PLAYER_STATE_PAUSED) + player_stop(m_Player); } void MediaPlayer::pause() { - if (getState() == PLAYER_STATE_PLAYING) - player_pause(m_Player); + if (getState() == PLAYER_STATE_PLAYING) + player_pause(m_Player); } bool MediaPlayer::isPlaying() const { - return getState() == PLAYER_STATE_PLAYING; + return getState() == PLAYER_STATE_PLAYING; } void MediaPlayer::setUri(const std::string &uri) { - stop(); - player_unprepare(m_Player); - player_set_uri(m_Player, uri.c_str()); + stop(); + player_unprepare(m_Player); + player_set_uri(m_Player, uri.c_str()); } void MediaPlayer::setListener(IMediaPlayerListener *l) { - m_pListener = l; + m_pListener = l; } int MediaPlayer::getDuration() const { - int msec = 0; - player_get_duration(m_Player, &msec); - return msec; + int msec = 0; + player_get_duration(m_Player, &msec); + return msec; } void MediaPlayer::setPosition(int msec) { - player_state_e state = getState(); - if (state == PLAYER_STATE_PLAYING || state == PLAYER_STATE_PAUSED || state == PLAYER_STATE_READY) - player_set_play_position(m_Player, msec, true, on_seek_cb, this); + player_state_e state = getState(); + if (state == PLAYER_STATE_PLAYING || state == PLAYER_STATE_PAUSED || state == PLAYER_STATE_READY) + player_set_play_position(m_Player, msec, true, on_seek_cb, this); } int MediaPlayer::getDuration(const std::string &uri) { - int msec = 0; - if (!uri.empty()) { - player_h player = {}; - player_create(&player); - if (player_set_uri(player, uri.c_str()) == PLAYER_ERROR_NONE) { - player_prepare(player); - player_get_duration(player, &msec); - player_unprepare(player); - } - player_destroy(player); - } - return msec; + int msec = 0; + if (!uri.empty()) { + player_h player = {}; + player_create(&player); + if (player_set_uri(player, uri.c_str()) == PLAYER_ERROR_NONE) { + player_prepare(player); + player_get_duration(player, &msec); + player_unprepare(player); + } + player_destroy(player); + } + return msec; } void MediaPlayer::on_completed_cb(void *user_data) { - IMediaPlayerListener *l = static_cast(user_data)->m_pListener; - if (l) - l->onMediaPlayerCompleted(); + IMediaPlayerListener *l = static_cast(user_data)->m_pListener; + if (l) + l->onMediaPlayerCompleted(); } void MediaPlayer::on_seek_cb(void *user_data) { - MSG_LOG(""); + MSG_LOG(""); } void MediaPlayer::on_sound_stream_focus_state_changed_cb(sound_stream_info_h stream_info, - sound_stream_focus_mask_e focus_mask, - sound_stream_focus_state_e focus_state, - sound_stream_focus_change_reason_e reason, - int sound_behavior, - const char *extra_info, - void *user_data) -{ - MSG_LOG("Interrupted focus change reason = ", reason); - auto *self = static_cast(user_data); - if (isCallReason(reason)) { - ecore_main_loop_thread_safe_call_async( - [](void *data) - { - auto *self = (MediaPlayer*)data; - if (self->m_pListener) - self->m_pListener->onMediaPlayerSoundFocusChanged(); - }, - self); - } + sound_stream_focus_mask_e focus_mask, + sound_stream_focus_state_e focus_state, + sound_stream_focus_change_reason_e reason, + int sound_behavior, + const char *extra_info, + void *user_data) +{ + MSG_LOG("Interrupted focus change reason = ", reason); + auto *self = static_cast(user_data); + if (isCallReason(reason)) { + ecore_main_loop_thread_safe_call_async( + [](void *data) + { + auto *self = (MediaPlayer*)data; + if (self->m_pListener) + self->m_pListener->onMediaPlayerSoundFocusChanged(); + }, + self); + } } diff --git a/src/Viewer/View/inc/PlayerControl.h b/src/Viewer/View/inc/PlayerControl.h index fce232b3..1edeb9e6 100644 --- a/src/Viewer/View/inc/PlayerControl.h +++ b/src/Viewer/View/inc/PlayerControl.h @@ -20,51 +20,51 @@ #include "View.h" namespace Msg { - class IPlayerControlListener; + class IPlayerControlListener; - class PlayerControl - : public View { - public: - enum PlayPauseState { - PlayState, - PauseState - }; + class PlayerControl + : public View { + public: + enum PlayPauseState { + PlayState, + PauseState + }; - public: - PlayerControl(Evas_Object *parent); - virtual ~PlayerControl(); + public: + PlayerControl(Evas_Object *parent); + virtual ~PlayerControl(); - void setListener(IPlayerControlListener *l); - void setProgress(double value); // 0.0..1.0 - void enablePrevButton(bool enable); - void enableNextButton(bool enable); - void setPlayState(PlayPauseState state); - void setStartTime(const std::string &time); - void setEndTime(const std::string &time); + void setListener(IPlayerControlListener *l); + void setProgress(double value); // 0.0..1.0 + void enablePrevButton(bool enable); + void enableNextButton(bool enable); + void setPlayState(PlayPauseState state); + void setStartTime(const std::string &time); + void setEndTime(const std::string &time); - private: - void onPlay(Evas_Object *obj, const char *emission, const char *source); - void onPause(Evas_Object *obj, const char *emission, const char *source); - void onNext(Evas_Object *obj, const char *emission, const char *source); - void onPrev(Evas_Object *obj, const char *emission, const char *source); + private: + void onPlay(Evas_Object *obj, const char *emission, const char *source); + void onPause(Evas_Object *obj, const char *emission, const char *source); + void onNext(Evas_Object *obj, const char *emission, const char *source); + void onPrev(Evas_Object *obj, const char *emission, const char *source); - Evas_Object *createPlayer(Evas_Object *parent); - Evas_Object *createProgress(Evas_Object *parent); + Evas_Object *createPlayer(Evas_Object *parent); + Evas_Object *createProgress(Evas_Object *parent); - private: - IPlayerControlListener *m_pListener; - Evas_Object *m_pProgress; - }; + private: + IPlayerControlListener *m_pListener; + Evas_Object *m_pProgress; + }; - class IPlayerControlListener { - public: - virtual ~IPlayerControlListener() {} + class IPlayerControlListener { + public: + virtual ~IPlayerControlListener() {} - virtual void onPlayClicked() {}; - virtual void onPauseClicked() {}; - virtual void onNextClicked() {}; - virtual void onPrevClicked() {}; - }; + virtual void onPlayClicked() {}; + virtual void onPauseClicked() {}; + virtual void onNextClicked() {}; + virtual void onPrevClicked() {}; + }; } #endif // PlayerControl_h_ diff --git a/src/Viewer/View/inc/SmilAttachmentItemView.h b/src/Viewer/View/inc/SmilAttachmentItemView.h index 560d6bfd..b7025f56 100644 --- a/src/Viewer/View/inc/SmilAttachmentItemView.h +++ b/src/Viewer/View/inc/SmilAttachmentItemView.h @@ -20,67 +20,67 @@ #include "View.h" namespace Msg { - class ISmilAttachmentItemViewListener; - class ISmilSaveAllItemViewListener; + class ISmilAttachmentItemViewListener; + class ISmilSaveAllItemViewListener; - // SmilAttachmentItemView: - class SmilAttachmentItemView - : public View { - public: - SmilAttachmentItemView(Evas_Object *parent); - virtual ~SmilAttachmentItemView(); + // SmilAttachmentItemView: + class SmilAttachmentItemView + : public View { + public: + SmilAttachmentItemView(Evas_Object *parent); + virtual ~SmilAttachmentItemView(); - void setListener(ISmilAttachmentItemViewListener *l); - void setFileName(const std::string &name); - void setFilePath(const std::string &filePath); - const std::string &getFilePath() const; // Return reference to file path + void setListener(ISmilAttachmentItemViewListener *l); + void setFileName(const std::string &name); + void setFilePath(const std::string &filePath); + const std::string &getFilePath() const; // Return reference to file path - private: - ISmilAttachmentItemViewListener *m_pListener; - std::string m_FilePath; - Evas_Object *m_pFileButton; - Evas_Object *m_pSaveButton; - }; + private: + ISmilAttachmentItemViewListener *m_pListener; + std::string m_FilePath; + Evas_Object *m_pFileButton; + Evas_Object *m_pSaveButton; + }; - // SmilAttachmentInfoItemView : - class SmilAttachmentInfoItemView - : public View { - public: - SmilAttachmentInfoItemView(Evas_Object *parent, bool manyAttachments); - virtual ~SmilAttachmentInfoItemView(); - }; + // SmilAttachmentInfoItemView : + class SmilAttachmentInfoItemView + : public View { + public: + SmilAttachmentInfoItemView(Evas_Object *parent, bool manyAttachments); + virtual ~SmilAttachmentInfoItemView(); + }; - // SmilSaveAllItemView : - class SmilSaveAllItemView - : public View { - public: - SmilSaveAllItemView(Evas_Object *parent, int count); - virtual ~SmilSaveAllItemView(); + // SmilSaveAllItemView : + class SmilSaveAllItemView + : public View { + public: + SmilSaveAllItemView(Evas_Object *parent, int count); + virtual ~SmilSaveAllItemView(); - void setListener(ISmilSaveAllItemViewListener *l); + void setListener(ISmilSaveAllItemViewListener *l); - private: - void onLanguageChanged(Evas_Object *obj, void *eventInfo); - void updateTitle(); + private: + void onLanguageChanged(Evas_Object *obj, void *eventInfo); + void updateTitle(); - private: - Evas_Object *m_pButton; - ISmilSaveAllItemViewListener *m_pListener; - const int m_Count; - }; + private: + Evas_Object *m_pButton; + ISmilSaveAllItemViewListener *m_pListener; + const int m_Count; + }; - class ISmilAttachmentItemViewListener { - public: - virtual ~ISmilAttachmentItemViewListener() {} - virtual void onItemClicked(SmilAttachmentItemView &item) {}; - virtual void onSaveButtonClicked(SmilAttachmentItemView &item) {}; - }; + class ISmilAttachmentItemViewListener { + public: + virtual ~ISmilAttachmentItemViewListener() {} + virtual void onItemClicked(SmilAttachmentItemView &item) {}; + virtual void onSaveButtonClicked(SmilAttachmentItemView &item) {}; + }; - class ISmilSaveAllItemViewListener { - public: - virtual ~ISmilSaveAllItemViewListener() {} - virtual void onItemClicked(SmilSaveAllItemView &item) {}; - }; + class ISmilSaveAllItemViewListener { + public: + virtual ~ISmilSaveAllItemViewListener() {} + virtual void onItemClicked(SmilSaveAllItemView &item) {}; + }; } #endif // SmilAttachmentItemView_h_ diff --git a/src/Viewer/View/inc/SmilAudioItemView.h b/src/Viewer/View/inc/SmilAudioItemView.h index 0faad1e4..9ffafa56 100644 --- a/src/Viewer/View/inc/SmilAudioItemView.h +++ b/src/Viewer/View/inc/SmilAudioItemView.h @@ -20,14 +20,14 @@ #include "View.h" namespace Msg { - class SmilAudioItemView - : public View { - public: - SmilAudioItemView(Evas_Object *parent, const std::string &label); - virtual ~SmilAudioItemView(); + class SmilAudioItemView + : public View { + public: + SmilAudioItemView(Evas_Object *parent, const std::string &label); + virtual ~SmilAudioItemView(); - void showIcon(bool show); - }; + void showIcon(bool show); + }; } #endif // SmilAudioItemView_h_ diff --git a/src/Viewer/View/inc/SmilImageItemView.h b/src/Viewer/View/inc/SmilImageItemView.h index c29d526a..38430d8a 100644 --- a/src/Viewer/View/inc/SmilImageItemView.h +++ b/src/Viewer/View/inc/SmilImageItemView.h @@ -20,22 +20,22 @@ #include "View.h" namespace Msg { - class SmilImageItemView - : public View { - public: - SmilImageItemView(Evas_Object *parent, const std::string &imagePath); - virtual ~SmilImageItemView(); + class SmilImageItemView + : public View { + public: + SmilImageItemView(Evas_Object *parent, const std::string &imagePath); + virtual ~SmilImageItemView(); - Evas_Object *getImage() const; - void playAnimation(bool play); - bool hasAnimation() const; + Evas_Object *getImage() const; + void playAnimation(bool play); + bool hasAnimation() const; - private: - Evas_Object *createImage(Evas_Object *parent, const std::string &imagePath); + private: + Evas_Object *createImage(Evas_Object *parent, const std::string &imagePath); - private: - Evas_Object *m_pImage; - }; + private: + Evas_Object *m_pImage; + }; } #endif // SmilImageItemView_h_ diff --git a/src/Viewer/View/inc/SmilPageLayout.h b/src/Viewer/View/inc/SmilPageLayout.h index d2c4c3e2..e4afb7a3 100644 --- a/src/Viewer/View/inc/SmilPageLayout.h +++ b/src/Viewer/View/inc/SmilPageLayout.h @@ -20,22 +20,22 @@ #include "View.h" namespace Msg { - class SmilPageLayout - : public View { - public: - SmilPageLayout(Evas_Object *parent); - virtual ~SmilPageLayout(); + class SmilPageLayout + : public View { + public: + SmilPageLayout(Evas_Object *parent); + virtual ~SmilPageLayout(); - void appendItem(Evas_Object *item); - Evas_Object *getBox() const; + void appendItem(Evas_Object *item); + Evas_Object *getBox() const; - private: - Evas_Object *createScroller(Evas_Object *parent); - Evas_Object *createBox(Evas_Object *parent); + private: + Evas_Object *createScroller(Evas_Object *parent); + Evas_Object *createBox(Evas_Object *parent); - private: - Evas_Object *m_pBox; - }; + private: + Evas_Object *m_pBox; + }; } #endif // SmilPageLayout_h_ diff --git a/src/Viewer/View/inc/SmilPlayerView.h b/src/Viewer/View/inc/SmilPlayerView.h index da17bd65..12352afe 100644 --- a/src/Viewer/View/inc/SmilPlayerView.h +++ b/src/Viewer/View/inc/SmilPlayerView.h @@ -20,17 +20,17 @@ #include "View.h" namespace Msg { - class SmilPlayerView - : public View { - public: - SmilPlayerView(Evas_Object *parent); - virtual ~SmilPlayerView(); + class SmilPlayerView + : public View { + public: + SmilPlayerView(Evas_Object *parent); + virtual ~SmilPlayerView(); - void displayPage(Evas_Object *page); + void displayPage(Evas_Object *page); - private: - Evas_Object *createBox(Evas_Object *parent); - }; + private: + Evas_Object *createBox(Evas_Object *parent); + }; } #endif /* SmilPlayerView_h_ */ diff --git a/src/Viewer/View/inc/SmilTextItemView.h b/src/Viewer/View/inc/SmilTextItemView.h index a145ec70..5ba85649 100644 --- a/src/Viewer/View/inc/SmilTextItemView.h +++ b/src/Viewer/View/inc/SmilTextItemView.h @@ -20,15 +20,15 @@ #include "View.h" namespace Msg { - class SmilTextItemView - : public View { - public: - SmilTextItemView(Evas_Object *parent, const std::string &text); - virtual ~SmilTextItemView(); + class SmilTextItemView + : public View { + public: + SmilTextItemView(Evas_Object *parent, const std::string &text); + virtual ~SmilTextItemView(); - private: - Evas_Object *createEntry(Evas_Object *parent, const std::string &text); - }; + private: + Evas_Object *createEntry(Evas_Object *parent, const std::string &text); + }; } #endif // SmilTextItemView_h_ diff --git a/src/Viewer/View/inc/SmilVideoItemView.h b/src/Viewer/View/inc/SmilVideoItemView.h index a252ff96..f11ad75d 100644 --- a/src/Viewer/View/inc/SmilVideoItemView.h +++ b/src/Viewer/View/inc/SmilVideoItemView.h @@ -20,20 +20,20 @@ #include "View.h" namespace Msg { - class SmilVideoItemView - : public View { - public: - SmilVideoItemView(Evas_Object *parent, int videoWidth, int videoHeight, const std::string &thumbPath); - virtual ~SmilVideoItemView(); + class SmilVideoItemView + : public View { + public: + SmilVideoItemView(Evas_Object *parent, int videoWidth, int videoHeight, const std::string &thumbPath); + virtual ~SmilVideoItemView(); - Evas_Object *getVideoSink() const; + Evas_Object *getVideoSink() const; - private: - Evas_Object *createImage(Evas_Object *parent, int width, int height, const std::string &thumbPath); + private: + Evas_Object *createImage(Evas_Object *parent, int width, int height, const std::string &thumbPath); - private: - Evas_Object *m_pVideoSink; - }; + private: + Evas_Object *m_pVideoSink; + }; } #endif // SmilVideoItemView_h_ diff --git a/src/Viewer/View/inc/SubjectLayout.h b/src/Viewer/View/inc/SubjectLayout.h index bc9a781e..5c28c3c7 100644 --- a/src/Viewer/View/inc/SubjectLayout.h +++ b/src/Viewer/View/inc/SubjectLayout.h @@ -22,22 +22,22 @@ #include "MessageMms.h" namespace Msg { - class SubjectLayout - : public View { - public: - SubjectLayout(Evas_Object *parent); - ~SubjectLayout(); + class SubjectLayout + : public View { + public: + SubjectLayout(Evas_Object *parent); + ~SubjectLayout(); - void setSubjectText(const std::string &subject); - void setNumberOfPages(int numberOfPages); - void setPageIndex(int pageIndex); + void setSubjectText(const std::string &subject); + void setNumberOfPages(int numberOfPages); + void setPageIndex(int pageIndex); - private: - Evas_Object *createLayout(Evas_Object *parent); + private: + Evas_Object *createLayout(Evas_Object *parent); - private: - int m_NumberOfPages; - }; + private: + int m_NumberOfPages; + }; } #endif // _SUBJECT_LAYOUT_H_ diff --git a/src/Viewer/View/inc/ViewerLayout.h b/src/Viewer/View/inc/ViewerLayout.h index 719a9d9d..f0b07304 100644 --- a/src/Viewer/View/inc/ViewerLayout.h +++ b/src/Viewer/View/inc/ViewerLayout.h @@ -20,36 +20,36 @@ #include "View.h" namespace Msg { - class IViewerLayoutListener; - - class ViewerLayout - : public View { - public: - ViewerLayout(Evas_Object *parent); - virtual ~ViewerLayout(); - - void setListener(IViewerLayoutListener *l); - - void setPlayerControl(Evas_Object *obj); - void setSubject(Evas_Object *obj); - void setBody(Evas_Object *obj); - void setBg(Evas_Object *obj); - void setRecipients(Evas_Object *obj); - - void showRecipients(bool show); - bool isRecipientsVisible() const; - void showPlayerControl(bool show); - bool isPlayerControlVisible() const; - - private: - IViewerLayoutListener *m_pListener; - }; - - class IViewerLayoutListener { - public: - virtual ~IViewerLayoutListener() {} - virtual void onLayoutTap() {}; - }; + class IViewerLayoutListener; + + class ViewerLayout + : public View { + public: + ViewerLayout(Evas_Object *parent); + virtual ~ViewerLayout(); + + void setListener(IViewerLayoutListener *l); + + void setPlayerControl(Evas_Object *obj); + void setSubject(Evas_Object *obj); + void setBody(Evas_Object *obj); + void setBg(Evas_Object *obj); + void setRecipients(Evas_Object *obj); + + void showRecipients(bool show); + bool isRecipientsVisible() const; + void showPlayerControl(bool show); + bool isPlayerControlVisible() const; + + private: + IViewerLayoutListener *m_pListener; + }; + + class IViewerLayoutListener { + public: + virtual ~IViewerLayoutListener() {} + virtual void onLayoutTap() {}; + }; } #endif // ViewerLayout_h_ diff --git a/src/Viewer/View/src/PlayerControl.cpp b/src/Viewer/View/src/PlayerControl.cpp index bfab6578..53ec3202 100644 --- a/src/Viewer/View/src/PlayerControl.cpp +++ b/src/Viewer/View/src/PlayerControl.cpp @@ -21,29 +21,29 @@ using namespace Msg; namespace { - const char *groupName = "player"; - const char *prevCb = "prev_clicked"; - const char *playCb = "play_clicked"; - const char *pauseCb = "pause_clicked"; - const char *nextCb = "next_clicked"; - const char *progressSwl = "progress_area"; - const char *playSig = "play"; - const char *pauseSig = "pause"; - const char *prevEnableSig = "prev_enable"; - const char *prevDisableSig = "prev_disable"; - const char *nextEnableSig = "next_enable"; - const char *nextDisableSig = "next_disable"; - const char *startTime = "progress/start/time"; - const char *endTime = "progress/end/time"; + const char *groupName = "player"; + const char *prevCb = "prev_clicked"; + const char *playCb = "play_clicked"; + const char *pauseCb = "pause_clicked"; + const char *nextCb = "next_clicked"; + const char *progressSwl = "progress_area"; + const char *playSig = "play"; + const char *pauseSig = "pause"; + const char *prevEnableSig = "prev_enable"; + const char *prevDisableSig = "prev_disable"; + const char *nextEnableSig = "next_enable"; + const char *nextDisableSig = "next_disable"; + const char *startTime = "progress/start/time"; + const char *endTime = "progress/end/time"; } PlayerControl::PlayerControl(Evas_Object *parent) - : m_pListener(nullptr) - , m_pProgress(nullptr) + : m_pListener(nullptr) + , m_pProgress(nullptr) { - setEo(createPlayer(parent)); - Evas_Object *progress = createProgress(getEo()); - setContent(progress, progressSwl); + setEo(createPlayer(parent)); + Evas_Object *progress = createProgress(getEo()); + setContent(progress, progressSwl); } PlayerControl::~PlayerControl() @@ -52,86 +52,86 @@ PlayerControl::~PlayerControl() void PlayerControl::setListener(IPlayerControlListener *l) { - m_pListener = l; + m_pListener = l; } void PlayerControl::setProgress(double percentage) { - elm_progressbar_value_set(m_pProgress, percentage); + elm_progressbar_value_set(m_pProgress, percentage); } Evas_Object *PlayerControl::createPlayer(Evas_Object *parent) { - Evas_Object *layout = addLayout(parent, VIEWER_PALYER_EDJ_PATH, groupName); - setMirrored(layout, false); - elm_object_signal_callback_add(layout, playCb, "", EDJE_SIGNAL_CALLBACK(PlayerControl, onPlay), this); - elm_object_signal_callback_add(layout, pauseCb, "", EDJE_SIGNAL_CALLBACK(PlayerControl, onPause), this); - elm_object_signal_callback_add(layout, nextCb, "", EDJE_SIGNAL_CALLBACK(PlayerControl, onNext), this); - elm_object_signal_callback_add(layout, prevCb, "", EDJE_SIGNAL_CALLBACK(PlayerControl, onPrev), this); - return layout; + Evas_Object *layout = addLayout(parent, VIEWER_PALYER_EDJ_PATH, groupName); + setMirrored(layout, false); + elm_object_signal_callback_add(layout, playCb, "", EDJE_SIGNAL_CALLBACK(PlayerControl, onPlay), this); + elm_object_signal_callback_add(layout, pauseCb, "", EDJE_SIGNAL_CALLBACK(PlayerControl, onPause), this); + elm_object_signal_callback_add(layout, nextCb, "", EDJE_SIGNAL_CALLBACK(PlayerControl, onNext), this); + elm_object_signal_callback_add(layout, prevCb, "", EDJE_SIGNAL_CALLBACK(PlayerControl, onPrev), this); + return layout; } Evas_Object *PlayerControl::createProgress(Evas_Object *parent) { - m_pProgress = elm_progressbar_add(parent); - setMirrored(m_pProgress, false); - elm_progressbar_horizontal_set(m_pProgress, true); - elm_progressbar_unit_format_set(m_pProgress, nullptr); - elm_progressbar_pulse_set(m_pProgress, true); - elm_progressbar_pulse(m_pProgress, true); - evas_object_show(m_pProgress); - return m_pProgress; + m_pProgress = elm_progressbar_add(parent); + setMirrored(m_pProgress, false); + elm_progressbar_horizontal_set(m_pProgress, true); + elm_progressbar_unit_format_set(m_pProgress, nullptr); + elm_progressbar_pulse_set(m_pProgress, true); + elm_progressbar_pulse(m_pProgress, true); + evas_object_show(m_pProgress); + return m_pProgress; } void PlayerControl::enablePrevButton(bool enable) { - const char *sig = enable ? prevEnableSig : prevDisableSig; - emitSignal(sig, "*"); + const char *sig = enable ? prevEnableSig : prevDisableSig; + emitSignal(sig, "*"); } void PlayerControl::enableNextButton(bool enable) { - const char *sig = enable ? nextEnableSig : nextDisableSig; - emitSignal(sig, "*"); + const char *sig = enable ? nextEnableSig : nextDisableSig; + emitSignal(sig, "*"); } void PlayerControl::setPlayState(PlayPauseState state) { - const char *sig = state == PlayState ? playSig : pauseSig; - emitSignal(sig, "*"); + const char *sig = state == PlayState ? playSig : pauseSig; + emitSignal(sig, "*"); } void PlayerControl::setStartTime(const std::string &time) { - setText(time, startTime); + setText(time, startTime); } void PlayerControl::setEndTime(const std::string &time) { - setText(time, endTime); + setText(time, endTime); } void PlayerControl::onPlay(Evas_Object *obj, const char *emission, const char *source) { - if (m_pListener) - m_pListener->onPlayClicked(); + if (m_pListener) + m_pListener->onPlayClicked(); } void PlayerControl::onPause(Evas_Object *obj, const char *emission, const char *source) { - if (m_pListener) - m_pListener->onPauseClicked(); + if (m_pListener) + m_pListener->onPauseClicked(); } void PlayerControl::onNext(Evas_Object *obj, const char *emission, const char *source) { - if (m_pListener) - m_pListener->onNextClicked(); + if (m_pListener) + m_pListener->onNextClicked(); } void PlayerControl::onPrev(Evas_Object *obj, const char *emission, const char *source) { - if (m_pListener) - m_pListener->onPrevClicked(); + if (m_pListener) + m_pListener->onPrevClicked(); } diff --git a/src/Viewer/View/src/SmilAttachmentItemView.cpp b/src/Viewer/View/src/SmilAttachmentItemView.cpp index 0620d143..789ac5f8 100644 --- a/src/Viewer/View/src/SmilAttachmentItemView.cpp +++ b/src/Viewer/View/src/SmilAttachmentItemView.cpp @@ -23,66 +23,66 @@ using namespace Msg; namespace { - const float fileButtonWeight = 2.0 / 3.0; - const float saveButtonWeight = 1.0 / 3.0; - const char *layoutGroupName = "smil_attachment_item_layout"; - const char *layoutSwallowContent = "swallow.content"; - #define paddingBetweenButton ELM_SCALE_SIZE(16) + const float fileButtonWeight = 2.0 / 3.0; + const float saveButtonWeight = 1.0 / 3.0; + const char *layoutGroupName = "smil_attachment_item_layout"; + const char *layoutSwallowContent = "swallow.content"; + #define paddingBetweenButton ELM_SCALE_SIZE(16) } SmilAttachmentItemView::SmilAttachmentItemView(Evas_Object *parent) - : m_pListener(nullptr) - , m_pFileButton(nullptr) - , m_pSaveButton(nullptr) + : m_pListener(nullptr) + , m_pFileButton(nullptr) + , m_pSaveButton(nullptr) { - setEo(addLayout(parent, SMIL_ITEM_EDJ_PATH, layoutGroupName)); - - // Box: - Evas_Object *box = elm_box_add(getEo()); - elm_box_horizontal_set(box, true); - elm_box_homogeneous_set(box, false); - elm_box_padding_set(box, paddingBetweenButton, 0); - evas_object_show(box); - - setContent(box, layoutSwallowContent); - - // File button: - m_pFileButton = elm_button_add(box); - evas_object_size_hint_weight_set(m_pFileButton, fileButtonWeight, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_pFileButton, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_smart_callback_add - ( - m_pFileButton, - "clicked", - [] (void *data, Evas_Object *obj, void *event_info) - { - auto *self = (SmilAttachmentItemView*)data; - if (self->m_pListener) - self->m_pListener->onItemClicked(*self); - }, - this); - evas_object_show(m_pFileButton); - - // Save button: - m_pSaveButton = elm_button_add(box); - evas_object_size_hint_weight_set(m_pSaveButton, saveButtonWeight, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_pSaveButton, EVAS_HINT_FILL, EVAS_HINT_FILL); - setText(m_pSaveButton, msgt("IDS_MSG_BUTTON_SAVE_ABB2")); - evas_object_smart_callback_add - ( - m_pSaveButton, - "clicked", - [] (void *data, Evas_Object *obj, void *event_info) - { - auto *self = (SmilAttachmentItemView*)data; - if (self->m_pListener) - self->m_pListener->onSaveButtonClicked(*self); - }, - this); - evas_object_show(m_pSaveButton); - - elm_box_pack_end(box, m_pFileButton); - elm_box_pack_end(box, m_pSaveButton); + setEo(addLayout(parent, SMIL_ITEM_EDJ_PATH, layoutGroupName)); + + // Box: + Evas_Object *box = elm_box_add(getEo()); + elm_box_horizontal_set(box, true); + elm_box_homogeneous_set(box, false); + elm_box_padding_set(box, paddingBetweenButton, 0); + evas_object_show(box); + + setContent(box, layoutSwallowContent); + + // File button: + m_pFileButton = elm_button_add(box); + evas_object_size_hint_weight_set(m_pFileButton, fileButtonWeight, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_pFileButton, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_smart_callback_add + ( + m_pFileButton, + "clicked", + [] (void *data, Evas_Object *obj, void *event_info) + { + auto *self = (SmilAttachmentItemView*)data; + if (self->m_pListener) + self->m_pListener->onItemClicked(*self); + }, + this); + evas_object_show(m_pFileButton); + + // Save button: + m_pSaveButton = elm_button_add(box); + evas_object_size_hint_weight_set(m_pSaveButton, saveButtonWeight, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_pSaveButton, EVAS_HINT_FILL, EVAS_HINT_FILL); + setText(m_pSaveButton, msgt("IDS_MSG_BUTTON_SAVE_ABB2")); + evas_object_smart_callback_add + ( + m_pSaveButton, + "clicked", + [] (void *data, Evas_Object *obj, void *event_info) + { + auto *self = (SmilAttachmentItemView*)data; + if (self->m_pListener) + self->m_pListener->onSaveButtonClicked(*self); + }, + this); + evas_object_show(m_pSaveButton); + + elm_box_pack_end(box, m_pFileButton); + elm_box_pack_end(box, m_pSaveButton); } SmilAttachmentItemView::~SmilAttachmentItemView() @@ -91,39 +91,39 @@ SmilAttachmentItemView::~SmilAttachmentItemView() void SmilAttachmentItemView::setListener(ISmilAttachmentItemViewListener *l) { - m_pListener = l; + m_pListener = l; } const std::string &SmilAttachmentItemView::getFilePath() const { - return m_FilePath; + return m_FilePath; } void SmilAttachmentItemView::setFileName(const std::string &name) { - elm_object_text_set(m_pFileButton, name.c_str()); + elm_object_text_set(m_pFileButton, name.c_str()); } void SmilAttachmentItemView::setFilePath(const std::string &filePath) { - m_FilePath = filePath; + m_FilePath = filePath; } // SmilAttachmentInfoItemView: SmilAttachmentInfoItemView::SmilAttachmentInfoItemView(Evas_Object *parent, bool manyAttachments) { - setEo(addLayout(parent, SMIL_ITEM_EDJ_PATH, layoutGroupName)); + setEo(addLayout(parent, SMIL_ITEM_EDJ_PATH, layoutGroupName)); - Evas_Object *entry = elm_entry_add(getEo()); - elm_entry_editable_set(entry, false); - evas_object_show(entry); + Evas_Object *entry = elm_entry_add(getEo()); + elm_entry_editable_set(entry, false); + evas_object_show(entry); - setContent(entry, layoutSwallowContent); + setContent(entry, layoutSwallowContent); - if (manyAttachments) - setText(entry, msgt("IDS_MSGF_POP_HELP_PAGE_MESSAGE")); - else - setText(entry, msgt("IDS_MSGF_POP_HELP_PAGE_MESSAGE_FOR_ONE_FILE")); + if (manyAttachments) + setText(entry, msgt("IDS_MSGF_POP_HELP_PAGE_MESSAGE")); + else + setText(entry, msgt("IDS_MSGF_POP_HELP_PAGE_MESSAGE_FOR_ONE_FILE")); } SmilAttachmentInfoItemView::~SmilAttachmentInfoItemView() @@ -132,27 +132,27 @@ SmilAttachmentInfoItemView::~SmilAttachmentInfoItemView() // SmilSaveAllItemView: SmilSaveAllItemView::SmilSaveAllItemView(Evas_Object *parent, int count) - : m_pButton(nullptr) - , m_pListener(nullptr) - , m_Count(count) + : m_pButton(nullptr) + , m_pListener(nullptr) + , m_Count(count) { - setEo(addLayout(parent, SMIL_ITEM_EDJ_PATH, layoutGroupName)); - m_pButton = elm_button_add(getEo()); - updateTitle(); - evas_object_smart_callback_add(m_pButton, "language,changed", SMART_CALLBACK(SmilSaveAllItemView, onLanguageChanged), this); - evas_object_smart_callback_add - ( - m_pButton, - "clicked", - [] (void *data, Evas_Object *obj, void *event_info) - { - auto *self = (SmilSaveAllItemView*)data; - if (self->m_pListener) - self->m_pListener->onItemClicked(*self); - }, - this); - evas_object_show(m_pButton); - setContent(m_pButton, layoutSwallowContent); + setEo(addLayout(parent, SMIL_ITEM_EDJ_PATH, layoutGroupName)); + m_pButton = elm_button_add(getEo()); + updateTitle(); + evas_object_smart_callback_add(m_pButton, "language,changed", SMART_CALLBACK(SmilSaveAllItemView, onLanguageChanged), this); + evas_object_smart_callback_add + ( + m_pButton, + "clicked", + [] (void *data, Evas_Object *obj, void *event_info) + { + auto *self = (SmilSaveAllItemView*)data; + if (self->m_pListener) + self->m_pListener->onItemClicked(*self); + }, + this); + evas_object_show(m_pButton); + setContent(m_pButton, layoutSwallowContent); } SmilSaveAllItemView::~SmilSaveAllItemView() @@ -161,18 +161,18 @@ SmilSaveAllItemView::~SmilSaveAllItemView() void SmilSaveAllItemView::setListener(ISmilSaveAllItemViewListener *l) { - m_pListener = l; + m_pListener = l; } void SmilSaveAllItemView::updateTitle() { - std::string title = msg("IDS_MSGF_BUTTON_SAVE_ALL_ATTACHMENTS_ABB"); - title += " (" + std::to_string(m_Count) + ")"; - elm_object_text_set(m_pButton, title.c_str()); + std::string title = msg("IDS_MSGF_BUTTON_SAVE_ALL_ATTACHMENTS_ABB"); + title += " (" + std::to_string(m_Count) + ")"; + elm_object_text_set(m_pButton, title.c_str()); } void SmilSaveAllItemView::onLanguageChanged(Evas_Object *obj, void *eventInfo) { - MSG_LOG(""); - updateTitle(); + MSG_LOG(""); + updateTitle(); } diff --git a/src/Viewer/View/src/SmilAudioItemView.cpp b/src/Viewer/View/src/SmilAudioItemView.cpp index 563d0471..d80a766c 100644 --- a/src/Viewer/View/src/SmilAudioItemView.cpp +++ b/src/Viewer/View/src/SmilAudioItemView.cpp @@ -21,8 +21,8 @@ using namespace Msg; SmilAudioItemView::SmilAudioItemView(Evas_Object *parent, const std::string &label) { - setEo(addLayout(parent, SMIL_ITEM_EDJ_PATH, "smil_audio_item")); - setText(label, "elm.text"); + setEo(addLayout(parent, SMIL_ITEM_EDJ_PATH, "smil_audio_item")); + setText(label, "elm.text"); } SmilAudioItemView::~SmilAudioItemView() @@ -31,6 +31,6 @@ SmilAudioItemView::~SmilAudioItemView() void SmilAudioItemView::showIcon(bool show) { - const char *sig = show ? "audio,icon,show" : "audio,icon,hide"; - emitSignal(sig, "*"); + const char *sig = show ? "audio,icon,show" : "audio,icon,hide"; + emitSignal(sig, "*"); } diff --git a/src/Viewer/View/src/SmilImageItemView.cpp b/src/Viewer/View/src/SmilImageItemView.cpp index 3ffab37e..5a304db7 100644 --- a/src/Viewer/View/src/SmilImageItemView.cpp +++ b/src/Viewer/View/src/SmilImageItemView.cpp @@ -21,11 +21,11 @@ using namespace Msg; SmilImageItemView::SmilImageItemView(Evas_Object *parent, const std::string &imagePath) - : m_pImage(nullptr) + : m_pImage(nullptr) { - setEo(addLayout(parent, SMIL_ITEM_EDJ_PATH, "smil_image_item")); - Evas_Object *image = createImage(getEo(), imagePath); - setContent(image, "image.swallow.content"); + setEo(addLayout(parent, SMIL_ITEM_EDJ_PATH, "smil_image_item")); + Evas_Object *image = createImage(getEo(), imagePath); + setContent(image, "image.swallow.content"); } SmilImageItemView::~SmilImageItemView() @@ -34,41 +34,41 @@ SmilImageItemView::~SmilImageItemView() Evas_Object *SmilImageItemView::getImage() const { - return m_pImage; + return m_pImage; } void SmilImageItemView::playAnimation(bool play) { - if (hasAnimation()) - elm_image_animated_play_set(m_pImage, play); + if (hasAnimation()) + elm_image_animated_play_set(m_pImage, play); } bool SmilImageItemView::hasAnimation() const { - return elm_image_animated_get(m_pImage); + return elm_image_animated_get(m_pImage); } Evas_Object *SmilImageItemView::createImage(Evas_Object *parent, const std::string &imagePath) { - m_pImage = elm_image_add(parent); - if (!elm_image_file_set(m_pImage, imagePath.c_str(), nullptr)) { - evas_object_del(m_pImage); - m_pImage = nullptr; - return m_pImage; - } + m_pImage = elm_image_add(parent); + if (!elm_image_file_set(m_pImage, imagePath.c_str(), nullptr)) { + evas_object_del(m_pImage); + m_pImage = nullptr; + return m_pImage; + } - evas_object_show(m_pImage); + evas_object_show(m_pImage); - int w = 0; - int h = 0; + int w = 0; + int h = 0; - elm_image_object_size_get(m_pImage, &w, &h); + elm_image_object_size_get(m_pImage, &w, &h); - evas_object_size_hint_min_set(m_pImage, ELM_SCALE_SIZE(w), ELM_SCALE_SIZE(h)); - evas_object_size_hint_max_set(m_pImage, ELM_SCALE_SIZE(w), ELM_SCALE_SIZE(h)); + evas_object_size_hint_min_set(m_pImage, ELM_SCALE_SIZE(w), ELM_SCALE_SIZE(h)); + evas_object_size_hint_max_set(m_pImage, ELM_SCALE_SIZE(w), ELM_SCALE_SIZE(h)); - if (elm_image_animated_available_get(m_pImage)) - elm_image_animated_set(m_pImage, true); + if (elm_image_animated_available_get(m_pImage)) + elm_image_animated_set(m_pImage, true); - return m_pImage; + return m_pImage; } diff --git a/src/Viewer/View/src/SmilPageLayout.cpp b/src/Viewer/View/src/SmilPageLayout.cpp index 8e91eb4f..801abb3d 100644 --- a/src/Viewer/View/src/SmilPageLayout.cpp +++ b/src/Viewer/View/src/SmilPageLayout.cpp @@ -19,11 +19,11 @@ using namespace Msg; SmilPageLayout::SmilPageLayout(Evas_Object *parent) - : m_pBox(nullptr) + : m_pBox(nullptr) { - setEo(createScroller(parent)); - Evas_Object *box = createBox(getEo()); - setContent(box); + setEo(createScroller(parent)); + Evas_Object *box = createBox(getEo()); + setContent(box); } SmilPageLayout::~SmilPageLayout() @@ -32,32 +32,32 @@ SmilPageLayout::~SmilPageLayout() Evas_Object *SmilPageLayout::getBox() const { - return m_pBox; + return m_pBox; } void SmilPageLayout::appendItem(Evas_Object *item) { - expand(item); - evas_object_show(item); - elm_box_pack_end(m_pBox, item); + expand(item); + evas_object_show(item); + elm_box_pack_end(m_pBox, item); } Evas_Object *SmilPageLayout::createScroller(Evas_Object *parent) { - Evas_Object *scroller = elm_scroller_add(parent); - elm_object_style_set(scroller, "effect"); - elm_scroller_bounce_set(scroller, false, true); - elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO); - return scroller; + Evas_Object *scroller = elm_scroller_add(parent); + elm_object_style_set(scroller, "effect"); + elm_scroller_bounce_set(scroller, false, true); + elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO); + return scroller; } Evas_Object *SmilPageLayout::createBox(Evas_Object *parent) { - m_pBox = elm_box_add(parent); - evas_object_size_hint_weight_set(m_pBox, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(m_pBox, EVAS_HINT_FILL, 0.0); - elm_box_horizontal_set(m_pBox, false); - elm_box_homogeneous_set(m_pBox, EINA_FALSE); - evas_object_show(m_pBox); - return m_pBox; + m_pBox = elm_box_add(parent); + evas_object_size_hint_weight_set(m_pBox, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(m_pBox, EVAS_HINT_FILL, 0.0); + elm_box_horizontal_set(m_pBox, false); + elm_box_homogeneous_set(m_pBox, EINA_FALSE); + evas_object_show(m_pBox); + return m_pBox; } diff --git a/src/Viewer/View/src/SmilPlayerView.cpp b/src/Viewer/View/src/SmilPlayerView.cpp index 3a383ce1..178cdcff 100644 --- a/src/Viewer/View/src/SmilPlayerView.cpp +++ b/src/Viewer/View/src/SmilPlayerView.cpp @@ -20,7 +20,7 @@ using namespace Msg; SmilPlayerView::SmilPlayerView(Evas_Object *parent) { - setEo(createBox(parent)); + setEo(createBox(parent)); } SmilPlayerView::~SmilPlayerView() @@ -29,28 +29,28 @@ SmilPlayerView::~SmilPlayerView() void SmilPlayerView::displayPage(Evas_Object *page) { - Eina_List *list = elm_box_children_get(getEo()); - if (list) { - Eina_List *l = nullptr; - void *obj = nullptr; - - EINA_LIST_FOREACH(list, l, obj) { - evas_object_hide((Evas_Object*)obj); - } - eina_list_free(list); - } - - elm_box_unpack_all(getEo()); - View::expand(page); - evas_object_show(page); - elm_box_pack_start(getEo(), page); + Eina_List *list = elm_box_children_get(getEo()); + if (list) { + Eina_List *l = nullptr; + void *obj = nullptr; + + EINA_LIST_FOREACH(list, l, obj) { + evas_object_hide((Evas_Object*)obj); + } + eina_list_free(list); + } + + elm_box_unpack_all(getEo()); + View::expand(page); + evas_object_show(page); + elm_box_pack_start(getEo(), page); } Evas_Object *SmilPlayerView::createBox(Evas_Object *parent) { - Evas_Object *box = elm_box_add(parent); - elm_box_align_set(box, 0.5, 0.5); - elm_box_homogeneous_set(box, false); - return box; + Evas_Object *box = elm_box_add(parent); + elm_box_align_set(box, 0.5, 0.5); + elm_box_homogeneous_set(box, false); + return box; } diff --git a/src/Viewer/View/src/SmilTextItemView.cpp b/src/Viewer/View/src/SmilTextItemView.cpp index ca20bd1d..897e38a8 100644 --- a/src/Viewer/View/src/SmilTextItemView.cpp +++ b/src/Viewer/View/src/SmilTextItemView.cpp @@ -23,9 +23,9 @@ using namespace Msg; SmilTextItemView::SmilTextItemView(Evas_Object *parent, const std::string &text) { - setEo(addLayout(parent, SMIL_ITEM_EDJ_PATH, "smil_text_item")); - Evas_Object *entry = createEntry(getEo(), text); - setContent(entry, "swallow.content"); + setEo(addLayout(parent, SMIL_ITEM_EDJ_PATH, "smil_text_item")); + Evas_Object *entry = createEntry(getEo(), text); + setContent(entry, "swallow.content"); } SmilTextItemView::~SmilTextItemView() @@ -34,17 +34,17 @@ SmilTextItemView::~SmilTextItemView() Evas_Object *SmilTextItemView::createEntry(Evas_Object *parent, const std::string &text) { - Evas_Object *entry = elm_entry_add(parent); - evas_object_show(entry); - - char *markupText = elm_entry_utf8_to_markup(text.c_str()); - if (markupText) { - elm_entry_entry_set(entry, markupText); - free(markupText); - } - - elm_entry_line_wrap_set(entry, ELM_WRAP_MIXED); - elm_entry_editable_set(entry, false); - eext_entry_selection_back_event_allow_set(entry, true); - return entry; + Evas_Object *entry = elm_entry_add(parent); + evas_object_show(entry); + + char *markupText = elm_entry_utf8_to_markup(text.c_str()); + if (markupText) { + elm_entry_entry_set(entry, markupText); + free(markupText); + } + + elm_entry_line_wrap_set(entry, ELM_WRAP_MIXED); + elm_entry_editable_set(entry, false); + eext_entry_selection_back_event_allow_set(entry, true); + return entry; } diff --git a/src/Viewer/View/src/SmilVideoItemView.cpp b/src/Viewer/View/src/SmilVideoItemView.cpp index 8f42d202..9ac3e1f6 100644 --- a/src/Viewer/View/src/SmilVideoItemView.cpp +++ b/src/Viewer/View/src/SmilVideoItemView.cpp @@ -20,43 +20,43 @@ using namespace Msg; namespace { - const int viewerMaxWidth = 656; // Max width size according to UI - const int viewerMaxHeight = 369; // Max height size according to UI + const int viewerMaxWidth = 656; // Max width size according to UI + const int viewerMaxHeight = 369; // Max height size according to UI - void getResizedSize(int contentW, int contentH, int &w, int &h) - { - bool isLandscape = contentW > contentH; + void getResizedSize(int contentW, int contentH, int &w, int &h) + { + bool isLandscape = contentW > contentH; - if (isLandscape) { - w = viewerMaxWidth; - h = viewerMaxWidth * contentH / contentW; - if (h > viewerMaxHeight) { - w = viewerMaxHeight * contentW / contentH; - h = viewerMaxHeight; - } - } else { - w = viewerMaxHeight * contentH / contentW; - h = viewerMaxHeight; - if (w > viewerMaxWidth) { - w = viewerMaxWidth; - h = viewerMaxWidth * contentW / contentH; - } - } - } + if (isLandscape) { + w = viewerMaxWidth; + h = viewerMaxWidth * contentH / contentW; + if (h > viewerMaxHeight) { + w = viewerMaxHeight * contentW / contentH; + h = viewerMaxHeight; + } + } else { + w = viewerMaxHeight * contentH / contentW; + h = viewerMaxHeight; + if (w > viewerMaxWidth) { + w = viewerMaxWidth; + h = viewerMaxWidth * contentW / contentH; + } + } + } } SmilVideoItemView::SmilVideoItemView(Evas_Object *parent, int videoWidth, int videoHeight, const std::string &thumbPath) - : m_pVideoSink(nullptr) + : m_pVideoSink(nullptr) { - int w = 0; - int h = 0; + int w = 0; + int h = 0; - if (videoWidth > 0 && videoHeight > 0) - getResizedSize(videoWidth, videoHeight, w, h); + if (videoWidth > 0 && videoHeight > 0) + getResizedSize(videoWidth, videoHeight, w, h); - setEo(addLayout(parent, SMIL_ITEM_EDJ_PATH, "smil_video_item")); - Evas_Object *image = createImage(getEo(), w, h, thumbPath); - setContent(image, "swallow.thumbnail"); + setEo(addLayout(parent, SMIL_ITEM_EDJ_PATH, "smil_video_item")); + Evas_Object *image = createImage(getEo(), w, h, thumbPath); + setContent(image, "swallow.thumbnail"); } SmilVideoItemView::~SmilVideoItemView() @@ -65,18 +65,18 @@ SmilVideoItemView::~SmilVideoItemView() Evas_Object *SmilVideoItemView::getVideoSink() const { - return m_pVideoSink; + return m_pVideoSink; } Evas_Object *SmilVideoItemView::createImage(Evas_Object *parent, int width, int height, const std::string &thumbPath) { - Evas *evas = evas_object_evas_get(parent); - m_pVideoSink = evas_object_image_filled_add(evas); - evas_object_image_file_set(m_pVideoSink, thumbPath.c_str(), nullptr); - evas_object_image_fill_set(m_pVideoSink, 0, 0, width, height); - evas_object_size_hint_min_set(m_pVideoSink, width, height); - evas_object_size_hint_max_set(m_pVideoSink, width, height); - evas_object_show(m_pVideoSink); - return m_pVideoSink; + Evas *evas = evas_object_evas_get(parent); + m_pVideoSink = evas_object_image_filled_add(evas); + evas_object_image_file_set(m_pVideoSink, thumbPath.c_str(), nullptr); + evas_object_image_fill_set(m_pVideoSink, 0, 0, width, height); + evas_object_size_hint_min_set(m_pVideoSink, width, height); + evas_object_size_hint_max_set(m_pVideoSink, width, height); + evas_object_show(m_pVideoSink); + return m_pVideoSink; } diff --git a/src/Viewer/View/src/SubjectLayout.cpp b/src/Viewer/View/src/SubjectLayout.cpp index 16ed0bf7..e58c383f 100644 --- a/src/Viewer/View/src/SubjectLayout.cpp +++ b/src/Viewer/View/src/SubjectLayout.cpp @@ -21,15 +21,15 @@ using namespace Msg; namespace { - const char *groupName = "subject/pageindex"; - const char *partSubject = "subject/text"; - const char *partPageText = "page/text"; + const char *groupName = "subject/pageindex"; + const char *partSubject = "subject/text"; + const char *partPageText = "page/text"; } SubjectLayout::SubjectLayout(Evas_Object *parent) - : m_NumberOfPages(0) + : m_NumberOfPages(0) { - setEo(createLayout(parent)); + setEo(createLayout(parent)); } SubjectLayout::~SubjectLayout() @@ -38,24 +38,24 @@ SubjectLayout::~SubjectLayout() Evas_Object *SubjectLayout::createLayout(Evas_Object *parent) { - Evas_Object *layout = addLayout(parent, VIEWER_SUBJECT_LAYOUT_EDJ_PATH, groupName); - return layout; + Evas_Object *layout = addLayout(parent, VIEWER_SUBJECT_LAYOUT_EDJ_PATH, groupName); + return layout; } void SubjectLayout::setSubjectText(const std::string &subject) { - std::string subjectText = '(' + subject + ')'; - setText(subjectText, partSubject); + std::string subjectText = '(' + subject + ')'; + setText(subjectText, partSubject); } void SubjectLayout::setNumberOfPages(int numberOfPages) { - m_NumberOfPages = numberOfPages; + m_NumberOfPages = numberOfPages; } void SubjectLayout::setPageIndex(int pageIndex) { - std::ostringstream pageText; - pageText << "(" << pageIndex << "/" << m_NumberOfPages << ")"; - setText(pageText.str(), partPageText); + std::ostringstream pageText; + pageText << "(" << pageIndex << "/" << m_NumberOfPages << ")"; + setText(pageText.str(), partPageText); } diff --git a/src/Viewer/View/src/ViewerLayout.cpp b/src/Viewer/View/src/ViewerLayout.cpp index f2a97649..74e5834a 100644 --- a/src/Viewer/View/src/ViewerLayout.cpp +++ b/src/Viewer/View/src/ViewerLayout.cpp @@ -19,49 +19,49 @@ using namespace Msg; namespace { - const char *layoutGroup = "viewer_layout"; - const char *bodyPart = "body"; - const char *playerPart = "swallow.playctrl"; - const char *subjectPart = "swallow.subject"; - const char *bgPart = "body.bg"; - const char *recipientsPart = "swallow.recipients"; - const char *touchAreaPart = "swallow.touch_area"; - const char *showRecipSig = "show_recipients"; - const char *hideRecipSig = "hide_recipients"; - const char *showPlayerSig = "show_player"; - const char *hidePlayerSig = "hide_player"; - const int tapFingerSize = 15; + const char *layoutGroup = "viewer_layout"; + const char *bodyPart = "body"; + const char *playerPart = "swallow.playctrl"; + const char *subjectPart = "swallow.subject"; + const char *bgPart = "body.bg"; + const char *recipientsPart = "swallow.recipients"; + const char *touchAreaPart = "swallow.touch_area"; + const char *showRecipSig = "show_recipients"; + const char *hideRecipSig = "hide_recipients"; + const char *showPlayerSig = "show_player"; + const char *hidePlayerSig = "hide_player"; + const int tapFingerSize = 15; } ViewerLayout::ViewerLayout(Evas_Object *parent) - : m_pListener(nullptr) + : m_pListener(nullptr) { - setEo(addLayout(parent, VIEWER_LAYOUT_EDJ_PATH, layoutGroup)); - - Evas_Object *button = elm_button_add(getEo()); - elm_object_style_set(button, "transparent"); - evas_object_show(button); - - Evas_Object *layer = elm_gesture_layer_add(getEo()); - evas_object_show(layer); - elm_gesture_layer_tap_finger_size_set(layer, ELM_SCALE_SIZE(tapFingerSize)); - elm_gesture_layer_attach(layer, button); - - elm_gesture_layer_cb_add - ( - layer, - ELM_GESTURE_N_TAPS, - ELM_GESTURE_STATE_END, - [](void *data, void *event_info)->Evas_Event_Flags - { - ViewerLayout *self = static_cast(data); - if (self->m_pListener) - self->m_pListener->onLayoutTap(); - return EVAS_EVENT_FLAG_NONE; - }, - this); - - setContent(button, touchAreaPart); + setEo(addLayout(parent, VIEWER_LAYOUT_EDJ_PATH, layoutGroup)); + + Evas_Object *button = elm_button_add(getEo()); + elm_object_style_set(button, "transparent"); + evas_object_show(button); + + Evas_Object *layer = elm_gesture_layer_add(getEo()); + evas_object_show(layer); + elm_gesture_layer_tap_finger_size_set(layer, ELM_SCALE_SIZE(tapFingerSize)); + elm_gesture_layer_attach(layer, button); + + elm_gesture_layer_cb_add + ( + layer, + ELM_GESTURE_N_TAPS, + ELM_GESTURE_STATE_END, + [](void *data, void *event_info)->Evas_Event_Flags + { + ViewerLayout *self = static_cast(data); + if (self->m_pListener) + self->m_pListener->onLayoutTap(); + return EVAS_EVENT_FLAG_NONE; + }, + this); + + setContent(button, touchAreaPart); } ViewerLayout::~ViewerLayout() @@ -70,54 +70,54 @@ ViewerLayout::~ViewerLayout() void ViewerLayout::setListener(IViewerLayoutListener *l) { - m_pListener = l; + m_pListener = l; } void ViewerLayout::setPlayerControl(Evas_Object *obj) { - setContent(obj, playerPart); + setContent(obj, playerPart); } void ViewerLayout::setSubject(Evas_Object *obj) { - setContent(obj, subjectPart); + setContent(obj, subjectPart); } void ViewerLayout::setBody(Evas_Object *obj) { - setContent(obj, bodyPart); + setContent(obj, bodyPart); } void ViewerLayout::setBg(Evas_Object *obj) { - setContent(obj, bgPart); + setContent(obj, bgPart); } void ViewerLayout::setRecipients(Evas_Object *obj) { - setContent(obj, recipientsPart); + setContent(obj, recipientsPart); } void ViewerLayout::showRecipients(bool show) { - const char *sig = show ? showRecipSig : hideRecipSig; - emitSignal(sig, ""); + const char *sig = show ? showRecipSig : hideRecipSig; + emitSignal(sig, ""); } void ViewerLayout::showPlayerControl(bool show) { - const char *sig = show ? showPlayerSig : hidePlayerSig; - emitSignal(sig, ""); + const char *sig = show ? showPlayerSig : hidePlayerSig; + emitSignal(sig, ""); } bool ViewerLayout::isPlayerControlVisible() const { - Evas_Object *obj = getContent(playerPart); - return evas_object_visible_get(obj); + Evas_Object *obj = getContent(playerPart); + return evas_object_visible_get(obj); } bool ViewerLayout::isRecipientsVisible() const { - Evas_Object *obj = getContent(recipientsPart); - return evas_object_visible_get(obj); + Evas_Object *obj = getContent(recipientsPart); + return evas_object_visible_get(obj); } diff --git a/test/TC/ContactUtils.cpp b/test/TC/ContactUtils.cpp index 9f5d6881..e0289427 100644 --- a/test/TC/ContactUtils.cpp +++ b/test/TC/ContactUtils.cpp @@ -2,110 +2,110 @@ namespace Msg { - namespace Test - { - ContactUtils::ContactUtils() - { - contacts_connect(); - } - - ContactUtils::~ContactUtils() - { - contacts_disconnect(); - } - - ContactUtils &ContactUtils::getInst() - { - static ContactUtils inst; - return inst; - } - - int ContactUtils::createContact(const std::string &strName, const std::string &strNumber) - { - contacts_record_h contact = NULL; - contacts_record_create(_contacts_contact._uri, &contact); - - contacts_record_h name = NULL; - contacts_record_create(_contacts_name._uri, &name); - contacts_record_set_str(name, _contacts_name.first, strName.c_str()); - contacts_record_add_child_record(contact, _contacts_contact.name, name); - - contacts_record_h number = NULL; - contacts_record_create(_contacts_number._uri, &number); - contacts_record_set_str(number, _contacts_number.number, strNumber.c_str()); - contacts_record_add_child_record(contact, _contacts_contact.number, number); - - int contact_id = 0; - contacts_db_insert_record(contact, &contact_id); - contacts_record_destroy(contact, true); - - return contact_id; - } - - bool ContactUtils::getContactName(int contactId, contacts_record_h &contact, contacts_record_h &name) - { - int error = CONTACTS_ERROR_NONE; - - error = contacts_db_get_record(_contacts_contact._uri, contactId, &contact); - if (error != CONTACTS_ERROR_NONE) { - MSG_LOG_ERROR("contacts_db_get_record failed"); - return false; - } - - error = contacts_record_get_child_record_at_p(contact, _contacts_contact.name, 0, &name); - if (error != CONTACTS_ERROR_NONE) { - MSG_LOG_ERROR("contacts_record_get_child_record_at_p failed"); - contacts_record_destroy(contact, true); - return false; - } - - return true; - } - - void ContactUtils::renameContact(int contactId, const std::string &newName) - { - contacts_record_h contact = NULL; - contacts_record_h name = NULL; - int error = CONTACTS_ERROR_NONE; - - if (getContactName(contactId, contact, name)) { - contacts_record_set_str(name, _contacts_name.first, newName.c_str()); - - error = contacts_db_update_record(contact); - if (error != CONTACTS_ERROR_NONE) { - MSG_LOG_ERROR("contacts_db_update_record failed"); - contacts_record_destroy(contact, true); - return; - } - - contacts_record_destroy(contact, true); - } - } - - std::string ContactUtils::getNameById(int contactId) const - { - contacts_record_h contact = NULL; - contacts_record_h name = NULL; - char *str = nullptr; - int error = CONTACTS_ERROR_NONE; - std::string result; - - if (getContactName(contactId, contact, name)) { - contacts_record_get_str(name, _contacts_name.first, &str); - if (str) { - result = str; - free(str); - } - - contacts_record_destroy(contact, true); - } - - return result; - } - - void ContactUtils::removeContact(int contactId) - { - contacts_db_delete_record(_contacts_contact._uri, contactId); - } - } + namespace Test + { + ContactUtils::ContactUtils() + { + contacts_connect(); + } + + ContactUtils::~ContactUtils() + { + contacts_disconnect(); + } + + ContactUtils &ContactUtils::getInst() + { + static ContactUtils inst; + return inst; + } + + int ContactUtils::createContact(const std::string &strName, const std::string &strNumber) + { + contacts_record_h contact = NULL; + contacts_record_create(_contacts_contact._uri, &contact); + + contacts_record_h name = NULL; + contacts_record_create(_contacts_name._uri, &name); + contacts_record_set_str(name, _contacts_name.first, strName.c_str()); + contacts_record_add_child_record(contact, _contacts_contact.name, name); + + contacts_record_h number = NULL; + contacts_record_create(_contacts_number._uri, &number); + contacts_record_set_str(number, _contacts_number.number, strNumber.c_str()); + contacts_record_add_child_record(contact, _contacts_contact.number, number); + + int contact_id = 0; + contacts_db_insert_record(contact, &contact_id); + contacts_record_destroy(contact, true); + + return contact_id; + } + + bool ContactUtils::getContactName(int contactId, contacts_record_h &contact, contacts_record_h &name) + { + int error = CONTACTS_ERROR_NONE; + + error = contacts_db_get_record(_contacts_contact._uri, contactId, &contact); + if (error != CONTACTS_ERROR_NONE) { + MSG_LOG_ERROR("contacts_db_get_record failed"); + return false; + } + + error = contacts_record_get_child_record_at_p(contact, _contacts_contact.name, 0, &name); + if (error != CONTACTS_ERROR_NONE) { + MSG_LOG_ERROR("contacts_record_get_child_record_at_p failed"); + contacts_record_destroy(contact, true); + return false; + } + + return true; + } + + void ContactUtils::renameContact(int contactId, const std::string &newName) + { + contacts_record_h contact = NULL; + contacts_record_h name = NULL; + int error = CONTACTS_ERROR_NONE; + + if (getContactName(contactId, contact, name)) { + contacts_record_set_str(name, _contacts_name.first, newName.c_str()); + + error = contacts_db_update_record(contact); + if (error != CONTACTS_ERROR_NONE) { + MSG_LOG_ERROR("contacts_db_update_record failed"); + contacts_record_destroy(contact, true); + return; + } + + contacts_record_destroy(contact, true); + } + } + + std::string ContactUtils::getNameById(int contactId) const + { + contacts_record_h contact = NULL; + contacts_record_h name = NULL; + char *str = nullptr; + int error = CONTACTS_ERROR_NONE; + std::string result; + + if (getContactName(contactId, contact, name)) { + contacts_record_get_str(name, _contacts_name.first, &str); + if (str) { + result = str; + free(str); + } + + contacts_record_destroy(contact, true); + } + + return result; + } + + void ContactUtils::removeContact(int contactId) + { + contacts_db_delete_record(_contacts_contact._uri, contactId); + } + } } diff --git a/test/TC/ContactUtils.h b/test/TC/ContactUtils.h index a54564e9..34a98302 100644 --- a/test/TC/ContactUtils.h +++ b/test/TC/ContactUtils.h @@ -10,25 +10,25 @@ namespace Msg { - namespace Test - { - class ContactUtils { - public: - static ContactUtils &getInst(); + namespace Test + { + class ContactUtils { + public: + static ContactUtils &getInst(); - int createContact(const std::string &strName, const std::string &strNumber); - bool getContactName(int contactId, contacts_record_h &contact, contacts_record_h &name); - void renameContact(int contactId, const std::string &newName); - std::string getNameById(int contactId) const; - void removeContact(int contactId); + int createContact(const std::string &strName, const std::string &strNumber); + bool getContactName(int contactId, contacts_record_h &contact, contacts_record_h &name); + void renameContact(int contactId, const std::string &newName); + std::string getNameById(int contactId) const; + void removeContact(int contactId); - private: - ContactUtils(); - ~ContactUtils(); - ContactUtils(ContactUtils&) = delete; - ContactUtils &operator=(ContactUtils&) = delete; - }; - } + private: + ContactUtils(); + ~ContactUtils(); + ContactUtils(ContactUtils&) = delete; + ContactUtils &operator=(ContactUtils&) = delete; + }; + } } #endif /* __ContactUtils_h__ */ diff --git a/test/TC/TestAppControlUtils.cpp b/test/TC/TestAppControlUtils.cpp index f464ca8d..32cf3052 100644 --- a/test/TC/TestAppControlUtils.cpp +++ b/test/TC/TestAppControlUtils.cpp @@ -21,69 +21,69 @@ using namespace Msg; class TestAppControlUtils: public testing::Test { - protected: - virtual void SetUp() - { - app_control_create(&m_handle); - } + protected: + virtual void SetUp() + { + app_control_create(&m_handle); + } - virtual void TearDown() - { - app_control_destroy(m_handle); - } - app_control_h m_handle; + virtual void TearDown() + { + app_control_destroy(m_handle); + } + app_control_h m_handle; }; TEST_F(TestAppControlUtils, GetExtraData) { - const std::string stringToBeFound("test-string"); - app_control_add_extra_data(m_handle, APP_CONTROL_DATA_PATH, stringToBeFound.c_str()); - ASSERT_EQ(stringToBeFound, AppControlUtils::getExtraData(m_handle, APP_CONTROL_DATA_PATH)); + const std::string stringToBeFound("test-string"); + app_control_add_extra_data(m_handle, APP_CONTROL_DATA_PATH, stringToBeFound.c_str()); + ASSERT_EQ(stringToBeFound, AppControlUtils::getExtraData(m_handle, APP_CONTROL_DATA_PATH)); - const std::string stringToBeNotFound("not-written-string"); - ASSERT_NE(stringToBeNotFound, AppControlUtils::getExtraData(m_handle, APP_CONTROL_DATA_PATH)); + const std::string stringToBeNotFound("not-written-string"); + ASSERT_NE(stringToBeNotFound, AppControlUtils::getExtraData(m_handle, APP_CONTROL_DATA_PATH)); } TEST_F(TestAppControlUtils, GetExtraDataArray) { - const size_t arrSize = 4; - char* arr[] = {"hello", "world", "asdf", "qwerty"}; - app_control_add_extra_data_array(m_handle, APP_CONTROL_DATA_PATH, arr, arrSize); + const size_t arrSize = 4; + char* arr[] = {"hello", "world", "asdf", "qwerty"}; + app_control_add_extra_data_array(m_handle, APP_CONTROL_DATA_PATH, arr, arrSize); - std::list gotList; - AppControlUtils::getExtraDataArray(m_handle, APP_CONTROL_DATA_PATH, gotList); + std::list gotList; + AppControlUtils::getExtraDataArray(m_handle, APP_CONTROL_DATA_PATH, gotList); - int i = 0; - for (auto num: gotList) { - std::string s(arr[i]); - ASSERT_EQ(s, num); - ++i; - } + int i = 0; + for (auto num: gotList) { + std::string s(arr[i]); + ASSERT_EQ(s, num); + ++i; + } } TEST_F(TestAppControlUtils, getExtraDataInt) { - const char* numsStr = "100"; - app_control_add_extra_data(m_handle, APP_CONTROL_DATA_SELECTED, numsStr); + const char* numsStr = "100"; + app_control_add_extra_data(m_handle, APP_CONTROL_DATA_SELECTED, numsStr); - int number = AppControlUtils::getExtraDataInt(m_handle, APP_CONTROL_DATA_SELECTED); + int number = AppControlUtils::getExtraDataInt(m_handle, APP_CONTROL_DATA_SELECTED); - std::string s(numsStr); - ASSERT_EQ(s, std::to_string(number)); + std::string s(numsStr); + ASSERT_EQ(s, std::to_string(number)); } TEST_F(TestAppControlUtils, GetExtraDataIntArray) { - const std::size_t arrSize = 4; - const char* numsStrList[] = {"1", "2", "3", "4"}; - app_control_add_extra_data_array(m_handle, APP_CONTROL_DATA_SELECTED, numsStrList, arrSize); + const std::size_t arrSize = 4; + const char* numsStrList[] = {"1", "2", "3", "4"}; + app_control_add_extra_data_array(m_handle, APP_CONTROL_DATA_SELECTED, numsStrList, arrSize); - std::list gotNums; - AppControlUtils::getExtraDataIntArray(m_handle, APP_CONTROL_DATA_SELECTED, gotNums); - int i = 0; - for (auto num: gotNums) { - std::string s(numsStrList[i]); - ASSERT_EQ(s, std::to_string(num)); - ++i; - } + std::list gotNums; + AppControlUtils::getExtraDataIntArray(m_handle, APP_CONTROL_DATA_SELECTED, gotNums); + int i = 0; + for (auto num: gotNums) { + std::string s(numsStrList[i]); + ASSERT_EQ(s, std::to_string(num)); + ++i; + } } diff --git a/test/TC/TestContactManager.cpp b/test/TC/TestContactManager.cpp index 64449782..132b24db 100644 --- a/test/TC/TestContactManager.cpp +++ b/test/TC/TestContactManager.cpp @@ -24,89 +24,89 @@ using namespace Msg; class TestContactManager: public testing::Test { - protected: - virtual void SetUp() - { - m_ContactId = -100; //dummy id - } - - virtual void TearDown() - { - if (m_ContactId != -100) - { - Msg::Test::ContactUtils::getInst().removeContact(m_ContactId); - } - } - int m_ContactId; - ContactManager m_ContactManager; + protected: + virtual void SetUp() + { + m_ContactId = -100; //dummy id + } + + virtual void TearDown() + { + if (m_ContactId != -100) + { + Msg::Test::ContactUtils::getInst().removeContact(m_ContactId); + } + } + int m_ContactId; + ContactManager m_ContactManager; }; //____________________________________________________________________________// TEST_F(TestContactManager, FindNameSasha) { - const std::string strNumber = "0936403503"; - const std::string strName = "Sasha"; + const std::string strNumber = "0936403503"; + const std::string strName = "Sasha"; - m_ContactId = Msg::Test::ContactUtils::getInst().createContact(strName, strNumber); - auto item = m_ContactManager.getContactAddress(strNumber); - std::string result = item->getDispName(); + m_ContactId = Msg::Test::ContactUtils::getInst().createContact(strName, strNumber); + auto item = m_ContactManager.getContactAddress(strNumber); + std::string result = item->getDispName(); - testing::Test::RecordProperty("Number", strNumber.c_str()); - testing::Test::RecordProperty("Name", strName.c_str()); + testing::Test::RecordProperty("Number", strNumber.c_str()); + testing::Test::RecordProperty("Name", strName.c_str()); - ASSERT_EQ(result, strName); + ASSERT_EQ(result, strName); } //____________________________________________________________________________// TEST_F(TestContactManager, FindNameVova) { - const std::string strNumber = "0501234567"; - const std::string strName = "Vova"; + const std::string strNumber = "0501234567"; + const std::string strName = "Vova"; - m_ContactId = Msg::Test::ContactUtils::getInst().createContact(strName, strNumber); + m_ContactId = Msg::Test::ContactUtils::getInst().createContact(strName, strNumber); - auto item = m_ContactManager.getContactAddress(strNumber); - std::string result = item->getDispName(); + auto item = m_ContactManager.getContactAddress(strNumber); + std::string result = item->getDispName(); - testing::Test::RecordProperty("Number", strNumber.c_str()); - testing::Test::RecordProperty("Name", strName.c_str()); + testing::Test::RecordProperty("Number", strNumber.c_str()); + testing::Test::RecordProperty("Name", strName.c_str()); - ASSERT_EQ(result, strName); + ASSERT_EQ(result, strName); } //____________________________________________________________________________// TEST_F(TestContactManager, TestGetNameById) { - const std::string strNumber = "0971234567"; - const std::string strName = "Test1"; + const std::string strNumber = "0971234567"; + const std::string strName = "Test1"; - m_ContactId = Msg::Test::ContactUtils::getInst().createContact(strName, strNumber); + m_ContactId = Msg::Test::ContactUtils::getInst().createContact(strName, strNumber); - auto item = m_ContactManager.getContactAddress(strNumber); - std::string result1 = item->getDispName(); + auto item = m_ContactManager.getContactAddress(strNumber); + std::string result1 = item->getDispName(); - std::string result2 = Msg::Test::ContactUtils::getInst().getNameById(m_ContactId); + std::string result2 = Msg::Test::ContactUtils::getInst().getNameById(m_ContactId); - ASSERT_EQ(result1, result2); + ASSERT_EQ(result1, result2); } //____________________________________________________________________________// TEST_F(TestContactManager, TestRenameContact) { - const std::string strNumber = "0971234567"; - const std::string strName = "Test1"; - const std::string newName = "Test2"; + const std::string strNumber = "0971234567"; + const std::string strName = "Test1"; + const std::string newName = "Test2"; - m_ContactId = Msg::Test::ContactUtils::getInst().createContact(strName, strNumber); - Msg::Test::ContactUtils::getInst().renameContact(m_ContactId, newName); + m_ContactId = Msg::Test::ContactUtils::getInst().createContact(strName, strNumber); + Msg::Test::ContactUtils::getInst().renameContact(m_ContactId, newName); - std::string result = Msg::Test::ContactUtils::getInst().getNameById(m_ContactId); + std::string result = Msg::Test::ContactUtils::getInst().getNameById(m_ContactId); - ASSERT_EQ(newName, result); + ASSERT_EQ(newName, result); } //____________________________________________________________________________// diff --git a/test/TC/TestMessageSender.cpp b/test/TC/TestMessageSender.cpp index b1754da3..11bd6b53 100644 --- a/test/TC/TestMessageSender.cpp +++ b/test/TC/TestMessageSender.cpp @@ -27,53 +27,53 @@ using namespace Msg; class TestMessageSender: public testing::Test { - protected: - virtual void SetUp() - { - m_Engine.openService(); - } - - virtual void TearDown() - { - m_Engine.closeService(); - } - MsgEngine m_Engine; + protected: + virtual void SetUp() + { + m_Engine.openService(); + } + + virtual void TearDown() + { + m_Engine.closeService(); + } + MsgEngine m_Engine; }; //____________________________________________________________________________// TEST_F(TestMessageSender, SendSms) { - std::string number = "0941234567"; + std::string number = "0941234567"; - MessageSMSRef sms = m_Engine.getComposer().createSms(); + MessageSMSRef sms = m_Engine.getComposer().createSms(); - ASSERT_NE(sms.get(), nullptr); + ASSERT_NE(sms.get(), nullptr); - sms->setText("Test"); + sms->setText("Test"); - MsgAddress &msgAddr = sms->addAddress(); - msgAddr.setAddress(number); - msgAddr.setRecipientType(MsgAddress::To); - msgAddr.setAddressType(MsgAddress::Phone); + MsgAddress &msgAddr = sms->addAddress(); + msgAddr.setAddress(number); + msgAddr.setRecipientType(MsgAddress::To); + msgAddr.setAddressType(MsgAddress::Phone); - ThreadId id = 0; + ThreadId id = 0; - MsgTransport::SendResult result = m_Engine.getTransport().sendMessage(sms, &id); + MsgTransport::SendResult result = m_Engine.getTransport().sendMessage(sms, &id); - testing::Test::RecordProperty("result", result); - ASSERT_EQ(result, MsgTransport::SendSuccess); + testing::Test::RecordProperty("result", result); + ASSERT_EQ(result, MsgTransport::SendSuccess); } //____________________________________________________________________________// TEST_F(TestMessageSender, TestInvalidSmsHandle) { - MessageSMSRef sms; - MsgTransport::SendResult result = m_Engine.getTransport().sendMessage(sms); + MessageSMSRef sms; + MsgTransport::SendResult result = m_Engine.getTransport().sendMessage(sms); - testing::Test::RecordProperty("result", result); - ASSERT_EQ(result, MsgTransport::SendNullPointer); + testing::Test::RecordProperty("result", result); + ASSERT_EQ(result, MsgTransport::SendNullPointer); } //____________________________________________________________________________// diff --git a/test/TC/TestMsgUtils.cpp b/test/TC/TestMsgUtils.cpp index 0e7d2ee7..3292a9ee 100644 --- a/test/TC/TestMsgUtils.cpp +++ b/test/TC/TestMsgUtils.cpp @@ -74,43 +74,43 @@ TEST(TestMsgUtils, isValidEmailTest) TEST(TestMsgUtils, makeNormalizedNumberTest) { - ASSERT_EQ(Msg::MsgUtils::makeNormalizedNumber("+38(045)34332"), "+3804534332"); - ASSERT_EQ(Msg::MsgUtils::makeNormalizedNumber("+380453-43-32"), "+3804534332"); - ASSERT_EQ(Msg::MsgUtils::makeNormalizedNumber("+380453 43 32"), "+3804534332"); - ASSERT_EQ(Msg::MsgUtils::makeNormalizedNumber("+380453*43*32"), "+380453*43*32"); - ASSERT_EQ(Msg::MsgUtils::makeNormalizedNumber("+380453- *43-32"), "+380453*4332"); - ASSERT_EQ(Msg::MsgUtils::makeNormalizedNumber("+38(045)343-32-12-115"), "+380453433212115"); + ASSERT_EQ(Msg::MsgUtils::makeNormalizedNumber("+38(045)34332"), "+3804534332"); + ASSERT_EQ(Msg::MsgUtils::makeNormalizedNumber("+380453-43-32"), "+3804534332"); + ASSERT_EQ(Msg::MsgUtils::makeNormalizedNumber("+380453 43 32"), "+3804534332"); + ASSERT_EQ(Msg::MsgUtils::makeNormalizedNumber("+380453*43*32"), "+380453*43*32"); + ASSERT_EQ(Msg::MsgUtils::makeNormalizedNumber("+380453- *43-32"), "+380453*4332"); + ASSERT_EQ(Msg::MsgUtils::makeNormalizedNumber("+38(045)343-32-12-115"), "+380453433212115"); } TEST(TestMsgUtils, tokenizeRecipients) { - Msg::TokenizedRecipients expectedResult = {{{"123", Msg::MsgAddress::Phone}, {"345", Msg::MsgAddress::Phone}}, ""}; - Msg::TokenizedRecipients actualResult = Msg::MsgUtils::tokenizeRecipients("123,345"); - ASSERT_EQ(expectedResult.validResults, actualResult.validResults); - ASSERT_EQ(expectedResult.invalidResult, actualResult.invalidResult); + Msg::TokenizedRecipients expectedResult = {{{"123", Msg::MsgAddress::Phone}, {"345", Msg::MsgAddress::Phone}}, ""}; + Msg::TokenizedRecipients actualResult = Msg::MsgUtils::tokenizeRecipients("123,345"); + ASSERT_EQ(expectedResult.validResults, actualResult.validResults); + ASSERT_EQ(expectedResult.invalidResult, actualResult.invalidResult); - expectedResult = {{{"1233", Msg::MsgAddress::Phone}}, "45,"}; - actualResult = Msg::MsgUtils::tokenizeRecipients("1233,45,"); - ASSERT_EQ(expectedResult.validResults, actualResult.validResults); - ASSERT_EQ(expectedResult.invalidResult, actualResult.invalidResult); + expectedResult = {{{"1233", Msg::MsgAddress::Phone}}, "45,"}; + actualResult = Msg::MsgUtils::tokenizeRecipients("1233,45,"); + ASSERT_EQ(expectedResult.validResults, actualResult.validResults); + ASSERT_EQ(expectedResult.invalidResult, actualResult.invalidResult); - expectedResult = {{}, "asad,1234,"}; - actualResult = Msg::MsgUtils::tokenizeRecipients("asad,1234,"); - ASSERT_EQ(expectedResult.validResults, actualResult.validResults); - ASSERT_EQ(expectedResult.invalidResult, actualResult.invalidResult); + expectedResult = {{}, "asad,1234,"}; + actualResult = Msg::MsgUtils::tokenizeRecipients("asad,1234,"); + ASSERT_EQ(expectedResult.validResults, actualResult.validResults); + ASSERT_EQ(expectedResult.invalidResult, actualResult.invalidResult); - expectedResult = {{{"abc.\"dc,d;\"@mail.com", Msg::MsgAddress::Email}, {"+380777777", Msg::MsgAddress::Phone}}, ""}; - actualResult = Msg::MsgUtils::tokenizeRecipients("abc.\"dc,d;\"@mail.com,+380777777"); - ASSERT_EQ(expectedResult.validResults, actualResult.validResults); - ASSERT_EQ(expectedResult.invalidResult, actualResult.invalidResult); + expectedResult = {{{"abc.\"dc,d;\"@mail.com", Msg::MsgAddress::Email}, {"+380777777", Msg::MsgAddress::Phone}}, ""}; + actualResult = Msg::MsgUtils::tokenizeRecipients("abc.\"dc,d;\"@mail.com,+380777777"); + ASSERT_EQ(expectedResult.validResults, actualResult.validResults); + ASSERT_EQ(expectedResult.invalidResult, actualResult.invalidResult); - expectedResult = {{{"6238", Msg::MsgAddress::Phone}, {"abc.\"dc,d;\"@mail.com", Msg::MsgAddress::Email}, {"+380777777", Msg::MsgAddress::Phone}}, ""}; - actualResult = Msg::MsgUtils::tokenizeRecipients(",,,6238;abc.\"dc,d;\"@mail.com,+380777777"); - ASSERT_EQ(expectedResult.validResults, actualResult.validResults); - ASSERT_EQ(expectedResult.invalidResult, actualResult.invalidResult); + expectedResult = {{{"6238", Msg::MsgAddress::Phone}, {"abc.\"dc,d;\"@mail.com", Msg::MsgAddress::Email}, {"+380777777", Msg::MsgAddress::Phone}}, ""}; + actualResult = Msg::MsgUtils::tokenizeRecipients(",,,6238;abc.\"dc,d;\"@mail.com,+380777777"); + ASSERT_EQ(expectedResult.validResults, actualResult.validResults); + ASSERT_EQ(expectedResult.invalidResult, actualResult.invalidResult); - expectedResult = {{}, ""}; - actualResult = Msg::MsgUtils::tokenizeRecipients(""); - ASSERT_EQ(expectedResult.validResults, actualResult.validResults); - ASSERT_EQ(expectedResult.invalidResult, actualResult.invalidResult); + expectedResult = {{}, ""}; + actualResult = Msg::MsgUtils::tokenizeRecipients(""); + ASSERT_EQ(expectedResult.validResults, actualResult.validResults); + ASSERT_EQ(expectedResult.invalidResult, actualResult.invalidResult); } diff --git a/test/TC/TestTextDecorator.cpp b/test/TC/TestTextDecorator.cpp index 94c4712b..e7076f98 100644 --- a/test/TC/TestTextDecorator.cpp +++ b/test/TC/TestTextDecorator.cpp @@ -21,38 +21,38 @@ TEST(TestTextDecorator, customStyleTest) { - std::string text("a text to format"); - Msg::TextStyle styleToApply(50, "#00ff00ff", Msg::TextAlign::Center); - std::string result = Msg::TextDecorator::make(text, styleToApply); - std::transform(result.begin(), result.end(), result.begin(), ::tolower); + std::string text("a text to format"); + Msg::TextStyle styleToApply(50, "#00ff00ff", Msg::TextAlign::Center); + std::string result = Msg::TextDecorator::make(text, styleToApply); + std::transform(result.begin(), result.end(), result.begin(), ::tolower); - testing::Test::RecordProperty("result", result.c_str()); + testing::Test::RecordProperty("result", result.c_str()); - std::size_t foundPos = result.find(" class TimeUtilsTest - : public Msg::TimeUtils { - public: - using TimeUtils::getDefaultLocale; - using TimeUtils::getDateBestPattern; - using TimeUtils::getFormattedDate; + : public Msg::TimeUtils { + public: + using TimeUtils::getDefaultLocale; + using TimeUtils::getDateBestPattern; + using TimeUtils::getFormattedDate; }; using namespace Msg; TEST(TimeUtilsTest, ValidTime) { - std::string systemLocale = TimeUtilsTest::getDefaultLocale(); // Save system locale before test start - std::string localeTest = "en_"; - i18n_ulocale_set_default(localeTest.c_str()); + std::string systemLocale = TimeUtilsTest::getDefaultLocale(); // Save system locale before test start + std::string localeTest = "en_"; + i18n_ulocale_set_default(localeTest.c_str()); - struct tm generateTime; - time_t time; - generateTime.tm_sec = 0; /* Seconds. [0-60] (1 leap second) */ - generateTime.tm_min = 0; /* Minutes. [0-59] */ - generateTime.tm_hour = 10; /* Hours. [0-23] */ - generateTime.tm_mday = 1; /* Day. [1-31] */ - generateTime.tm_mon = 0; /* Month. [0-11] */ - generateTime.tm_year = 1970 - 1900; /* Year - 1900. */ - generateTime.tm_wday = 3; /* Day of week. [0-6] */ - time = mktime(&generateTime); + struct tm generateTime; + time_t time; + generateTime.tm_sec = 0; /* Seconds. [0-60] (1 leap second) */ + generateTime.tm_min = 0; /* Minutes. [0-59] */ + generateTime.tm_hour = 10; /* Hours. [0-23] */ + generateTime.tm_mday = 1; /* Day. [1-31] */ + generateTime.tm_mon = 0; /* Month. [0-11] */ + generateTime.tm_year = 1970 - 1900; /* Year - 1900. */ + generateTime.tm_wday = 3; /* Day of week. [0-6] */ + time = mktime(&generateTime); - ASSERT_EQ("10:00", TimeUtilsTest::getFormattedDate(localeTest, TimeUtilsTest::getDateBestPattern(localeTest, "Hm"), time)); - ASSERT_EQ("10:00 AM", TimeUtilsTest::getFormattedDate(localeTest, TimeUtilsTest::getDateBestPattern(localeTest, "hma"), time)); + ASSERT_EQ("10:00", TimeUtilsTest::getFormattedDate(localeTest, TimeUtilsTest::getDateBestPattern(localeTest, "Hm"), time)); + ASSERT_EQ("10:00 AM", TimeUtilsTest::getFormattedDate(localeTest, TimeUtilsTest::getDateBestPattern(localeTest, "hma"), time)); - ASSERT_EQ("01/01/1970", TimeUtilsTest::getFormattedDate(localeTest, TimeUtilsTest::getDateBestPattern(localeTest, "MM/dd/yyyy"), time)); - ASSERT_NE("15/06/2016", TimeUtilsTest::getFormattedDate(localeTest, TimeUtilsTest::getDateBestPattern(localeTest, "MM/dd/yyyy"), time)); + ASSERT_EQ("01/01/1970", TimeUtilsTest::getFormattedDate(localeTest, TimeUtilsTest::getDateBestPattern(localeTest, "MM/dd/yyyy"), time)); + ASSERT_NE("15/06/2016", TimeUtilsTest::getFormattedDate(localeTest, TimeUtilsTest::getDateBestPattern(localeTest, "MM/dd/yyyy"), time)); - ASSERT_EQ("Jan 01, 1970, 10:00", TimeUtilsTest::getFormattedDate(localeTest, TimeUtilsTest::getDateBestPattern(localeTest, "MMM/dd/yyyy HHmm"), time)); - ASSERT_NE("Dec 20, 2015, 15:49", TimeUtilsTest::getFormattedDate(localeTest, TimeUtilsTest::getDateBestPattern(localeTest, "MMM/dd/yyyy HHmm"), time)); + ASSERT_EQ("Jan 01, 1970, 10:00", TimeUtilsTest::getFormattedDate(localeTest, TimeUtilsTest::getDateBestPattern(localeTest, "MMM/dd/yyyy HHmm"), time)); + ASSERT_NE("Dec 20, 2015, 15:49", TimeUtilsTest::getFormattedDate(localeTest, TimeUtilsTest::getDateBestPattern(localeTest, "MMM/dd/yyyy HHmm"), time)); - ASSERT_EQ("Jan 01, 1970, 10:00 AM", TimeUtilsTest::getFormattedDate(localeTest, TimeUtilsTest::getDateBestPattern(localeTest, "MMM/dd/yyyy hma"), time)); - ASSERT_NE("Feb 12, 1992, 05:45 PM", TimeUtilsTest::getFormattedDate(localeTest, TimeUtilsTest::getDateBestPattern(localeTest, "MMM/dd/yyyy hma"), time)); + ASSERT_EQ("Jan 01, 1970, 10:00 AM", TimeUtilsTest::getFormattedDate(localeTest, TimeUtilsTest::getDateBestPattern(localeTest, "MMM/dd/yyyy hma"), time)); + ASSERT_NE("Feb 12, 1992, 05:45 PM", TimeUtilsTest::getFormattedDate(localeTest, TimeUtilsTest::getDateBestPattern(localeTest, "MMM/dd/yyyy hma"), time)); - ASSERT_EQ("Jan 1, 10:00", TimeUtilsTest::getFormattedDate(localeTest, TimeUtilsTest::getDateBestPattern(localeTest, "HH:mm, d MMM"), time)); - ASSERT_NE("Feb 5, 23:15", TimeUtilsTest::getFormattedDate(localeTest, TimeUtilsTest::getDateBestPattern(localeTest, "HH:mm, d MMM"), time)); + ASSERT_EQ("Jan 1, 10:00", TimeUtilsTest::getFormattedDate(localeTest, TimeUtilsTest::getDateBestPattern(localeTest, "HH:mm, d MMM"), time)); + ASSERT_NE("Feb 5, 23:15", TimeUtilsTest::getFormattedDate(localeTest, TimeUtilsTest::getDateBestPattern(localeTest, "HH:mm, d MMM"), time)); - ASSERT_EQ("Jan 1, 10:00 AM", TimeUtilsTest::getFormattedDate(localeTest, TimeUtilsTest::getDateBestPattern(localeTest, "hh:mm a, d MMM"), time)); - ASSERT_NE("Dec 31, 08:42 PM", TimeUtilsTest::getFormattedDate(localeTest, TimeUtilsTest::getDateBestPattern(localeTest, "hh:mm a, d MMM"), time)); + ASSERT_EQ("Jan 1, 10:00 AM", TimeUtilsTest::getFormattedDate(localeTest, TimeUtilsTest::getDateBestPattern(localeTest, "hh:mm a, d MMM"), time)); + ASSERT_NE("Dec 31, 08:42 PM", TimeUtilsTest::getFormattedDate(localeTest, TimeUtilsTest::getDateBestPattern(localeTest, "hh:mm a, d MMM"), time)); - i18n_ulocale_set_default(systemLocale.c_str()); + i18n_ulocale_set_default(systemLocale.c_str()); } -- 2.34.1