From: Denis Dolzhenko Date: Tue, 6 Dec 2016 15:06:06 +0000 (+0200) Subject: TizenRefApp-7785 Implement general mechanism of app-control events handling X-Git-Tag: submit/tizen_3.0/20161208.125554~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e959d5d9843133473e388ce276dc6164b2b5d922;p=profile%2Fmobile%2Fapps%2Fnative%2Fmessage.git TizenRefApp-7785 Implement general mechanism of app-control events handling Change-Id: I58bdcae50f14ca6b9dae40294bed32aa90b2ba07 Signed-off-by: Denis Dolzhenko --- diff --git a/Build/build_c.mk b/Build/build_c.mk index 81940cdc..d818ab60 100644 --- a/Build/build_c.mk +++ b/Build/build_c.mk @@ -31,7 +31,7 @@ $(call CONVERT_ESC_EXT_TO_O,$(1),$(2),$(4)) : $(call DECODE_4MAKE,$(1)) $(7) @echo ' Building file: $$<' @echo ' Invoking: $(3) Compiler' $$(call MAKEDIRS,$$(@D)) - $(5) -c "$$<" -o "$$@" $(6) @$(7) + $(5) -c "$$<" -o "$$@" $(6) -Wp,@$(7) @echo ' Finished building: $$<' $(8) += $(call CONVERT_ESC_EXT_TO_O,$(1),$(2),$(4)) endef diff --git a/project_def.prop b/project_def.prop index 8cc37d0c..6e64a2d3 100644 --- a/project_def.prop +++ b/project_def.prop @@ -9,7 +9,7 @@ type = app profile = mobile-3.0 # C/CPP Sources -USER_SRCS = src/Common/MsgEngine/src/MsgThreadItem.cpp src/Common/Utils/src/VCalendarParser.cpp src/Conversation/Body/View/src/BodyView.cpp src/Conversation/ConvList/Controller/src/ConvList.cpp src/MsgThread/Controller/src/MsgThread.cpp src/Common/Controller/src/SaveAttachmentsListItem.cpp src/Conversation/ConvList/Controller/src/BubbleCalEventEntity.cpp src/Conversation/Utils/src/MessageDetailContent.cpp src/Common/MsgEngine/src/private/MsgAddressPrivate.cpp src/MainApp/MainApp.cpp src/Common/MsgEngine/src/private/MsgReportPrivate.cpp src/Conversation/Utils/src/WorkingDir.cpp src/Common/View/src/ListItem.cpp src/MsgThread/Controller/src/BaseThreadListItem.cpp src/Viewer/Controller/src/SmilPlayer.cpp src/Common/MsgEngine/src/private/MsgTransportPrivate.cpp src/MsgThread/View/src/MsgThreadLayout.cpp src/Common/Controller/src/SaveAttachments.cpp src/Conversation/ContactList/Controller/src/ConvContactList.cpp src/Common/MsgEngine/src/Message.cpp src/Viewer/Utils/src/MediaPlayer.cpp src/Common/AppControl/src/AppControlDefault.cpp src/Common/View/src/ListView.cpp src/Settings/Controller/src/MsgOnSimCard.cpp src/Common/MsgEngine/src/MessageMms.cpp src/Conversation/Main/Controller/src/Conversation.cpp src/Common/MsgEngine/src/private/MsgConvMediaPrivate.cpp src/Common/MsgEngine/src/MsgTransport.cpp src/Viewer/View/src/SmilImageItemView.cpp src/Common/ContactManager/src/ContactRecord.cpp src/Conversation/ContactList/View/src/ConvContactListView.cpp src/MsgThread/Controller/src/ThreadSearchList.cpp src/MsgThread/View/src/MsgThreadSearchPanel.cpp src/Common/Utils/src/FileUtils.cpp src/Common/View/src/ContextPopup.cpp src/Common/MsgEngine/src/MessageSMS.cpp src/Conversation/ConvList/Controller/src/BubbleContactEntity.cpp src/Conversation/ContactList/View/src/ContactListViewItem.cpp src/Common/MsgEngine/src/private/MessagePrivate.cpp src/Conversation/ConvList/Controller/src/BubbleAudioEntity.cpp src/Common/View/src/MbeRecipientsView.cpp src/MsgThread/Controller/src/ThreadListItem.cpp src/Settings/View/src/SettingsGroupListViewItem.cpp src/Common/View/src/Popup.cpp src/Common/Controller/src/ViewItemController.cpp src/Settings/Controller/src/Settings.cpp src/Common/ContactManager/src/ContactVCardParser.cpp src/Viewer/Controller/src/Viewer.cpp src/Viewer/Controller/src/SmilPage.cpp src/Conversation/ConvList/Controller/src/BubbleUnknownFileEntity.cpp src/Common/Utils/src/HwButtonListener.cpp src/Common/AppControl/src/AppControlCompose.cpp src/Common/MsgEngine/src/MsgUtils.cpp src/Conversation/ConvList/View/src/BubbleTextViewItem.cpp src/Common/Utils/src/PhoneNumberUtils.cpp src/Common/MsgEngine/src/private/MessageSMSPrivate.cpp src/Conversation/ConvList/Controller/src/BubbleEntityFactory.cpp src/Viewer/View/src/SmilPageLayout.cpp src/Common/View/src/View.cpp src/Conversation/Main/Controller/src/PopupRecipientListItem.cpp src/Common/MsgEngine/src/private/MsgConversationItemPrivate.cpp src/Conversation/ConvList/Controller/src/MsgDetailsPopup.cpp src/Common/Controller/src/FrameController.cpp src/Conversation/ConvList/View/src/DateLineViewItem.cpp src/Common/AppControl/src/AppControlCommand.cpp src/Viewer/View/src/SmilTextItemView.cpp src/Settings/View/src/SimMsgLayout.cpp src/Common/MsgEngine/src/private/MsgThreadItemPrivate.cpp src/Common/MsgEngine/src/MsgEngine.cpp src/Viewer/View/src/PlayerControl.cpp src/Common/AppControl/src/AppControlParser.cpp src/Common/Controller/src/ViewController.cpp src/Conversation/ConvList/View/src/BubbleIconTextLayoutItem.cpp src/Common/View/src/NaviFrameView.cpp src/Common/AppControl/src/FileViewer.cpp src/Common/Utils/src/PathUtils.cpp src/Conversation/ConvList/Controller/src/ComposeListItem.cpp src/Conversation/ConvList/Controller/src/DateLineItem.cpp src/Conversation/ConvList/View/src/BubbleItemContainer.cpp src/Common/AppControl/src/VoiceCall.cpp src/Common/View/src/Scroller.cpp src/Conversation/ConvList/Controller/src/BubbleVideoEntity.cpp src/Common/MsgEngine/src/MsgSettings.cpp src/Conversation/ContactList/Controller/src/ContactListItem.cpp src/Common/ContactManager/src/ContactVCardGenerator.cpp src/Viewer/View/src/SmilAudioItemView.cpp src/Common/Utils/src/LoggerImpl.cpp src/Conversation/ConvList/View/src/ConvSelectAll.cpp src/Common/ContactManager/src/ContactManager.cpp src/Conversation/Utils/src/AttachmentHandler.cpp src/Conversation/ConvList/View/src/ComposeListViewItem.cpp src/Common/MsgEngine/src/private/MsgAttachmentPrivate.cpp src/Common/View/src/ViewItem.cpp src/Conversation/AppControl/src/ContactPicker.cpp src/Common/MsgEngine/src/private/MsgMediaPrivate.cpp src/Viewer/View/src/SubjectLayout.cpp src/Conversation/Main/View/src/MessageInputPanel.cpp src/Conversation/Recipients/View/src/ConvRecipientsPanelView.cpp src/Common/Controller/src/BaseController.cpp src/Conversation/AppControl/src/AttachPanel.cpp src/Settings/Controller/src/SettingsSound.cpp src/Conversation/ConvList/View/src/ConvListViewItem.cpp src/Common/AppControl/src/Share.cpp src/Conversation/Body/Controller/src/Body.cpp src/Common/View/src/StandardWindow.cpp src/Common/MsgEngine/src/MsgConversationItem.cpp src/Common/MsgEngine/src/private/MessageMmsPrivate.cpp src/Viewer/View/src/SmilAttachmentItemView.cpp src/MsgThread/Controller/src/ThreadSearchListItem.cpp src/Common/View/src/DefaultLayout.cpp src/Conversation/Recipients/Controller/src/ConvRecipientsPanel.cpp src/Conversation/ConvList/View/src/BubbleVideoViewItem.cpp src/Common/View/src/PopupListItem.cpp src/Conversation/ConvList/View/src/BubbleViewItem.cpp src/Viewer/View/src/SmilVideoItemView.cpp src/Common/Controller/src/NaviFrameController.cpp src/MsgThread/Controller/src/ThreadList.cpp src/Common/Utils/src/TextDecorator.cpp src/Common/MsgEngine/src/MsgStorage.cpp src/Common/View/src/SelectAllListItem.cpp src/Conversation/ConvList/View/src/BubbleDownloadButtonViewItem.cpp src/Common/AppControl/src/ContactViewer.cpp src/Common/View/src/Box.cpp src/Common/Utils/src/ThumbnailMaker.cpp src/Common/View/src/NaviFrameItem.cpp src/Common/View/src/PopupList.cpp src/MsgThread/View/src/FloatingButton.cpp src/MsgThread/Controller/src/MsgSearchListItem.cpp src/Common/Controller/src/App.cpp src/Conversation/ConvList/View/src/ConvListLayout.cpp src/Common/View/src/PopupAttachmentListItem.cpp src/Common/MsgEngine/src/private/MsgComposerPrivate.cpp src/Viewer/View/src/ViewerLayout.cpp src/Common/Utils/src/MediaUtils.cpp src/Common/Controller/src/MbeRecipients.cpp src/Settings/Controller/src/SimListViewItem.cpp src/Common/Utils/src/TimeUtils.cpp src/Common/MsgEngine/src/private/MsgSettingsPrivate.cpp src/Viewer/View/src/SmilPlayerView.cpp src/MainApp/main.cpp src/Conversation/ConvList/View/src/BubbleImageViewItem.cpp src/Common/View/src/NoContentLayout.cpp src/Common/SystemSettingsManager/src/SystemSettingsManager.cpp src/Common/MsgEngine/src/MsgPage.cpp src/Common/AppControl/src/ContactEditor.cpp src/Conversation/Main/View/src/ConversationLayout.cpp src/Common/MsgEngine/src/private/MsgUtilsPrivate.cpp src/Common/View/src/PopupManager.cpp src/Settings/View/src/SettingsListViewItem.cpp src/Common/MsgEngine/src/private/MsgStoragePrivate.cpp src/Conversation/ConvList/Controller/src/ConvListItem.cpp src/Conversation/ConvList/View/src/BubbleBgViewItem.cpp src/MsgThread/View/src/ThreadListViewItem.cpp src/Common/MsgEngine/src/private/MsgPagePrivate.cpp src/Common/AppControl/src/AppControlUtils.cpp src/Conversation/AppControl/src/LaunchSettings.cpp +USER_SRCS = src/Common/MsgEngine/src/MsgThreadItem.cpp src/Common/Utils/src/VCalendarParser.cpp src/Conversation/Body/View/src/BodyView.cpp src/Conversation/ConvList/Controller/src/ConvList.cpp src/MsgThread/Controller/src/MsgThread.cpp src/Common/Controller/src/SaveAttachmentsListItem.cpp src/Conversation/ConvList/Controller/src/BubbleCalEventEntity.cpp src/Conversation/Utils/src/MessageDetailContent.cpp src/Common/MsgEngine/src/private/MsgAddressPrivate.cpp src/MainApp/MainApp.cpp src/Common/MsgEngine/src/private/MsgReportPrivate.cpp src/Conversation/Utils/src/WorkingDir.cpp src/Common/View/src/ListItem.cpp src/MsgThread/Controller/src/BaseThreadListItem.cpp src/Viewer/Controller/src/SmilPlayer.cpp src/Common/MsgEngine/src/private/MsgTransportPrivate.cpp src/MsgThread/View/src/MsgThreadLayout.cpp src/Common/Controller/src/SaveAttachments.cpp src/Conversation/ContactList/Controller/src/ConvContactList.cpp src/Common/MsgEngine/src/Message.cpp src/Viewer/Utils/src/MediaPlayer.cpp src/Common/AppControl/src/AppControlDefault.cpp src/Common/View/src/ListView.cpp src/Settings/Controller/src/MsgOnSimCard.cpp src/Common/MsgEngine/src/MessageMms.cpp src/Conversation/Main/Controller/src/Conversation.cpp src/Common/MsgEngine/src/private/MsgConvMediaPrivate.cpp src/Common/MsgEngine/src/MsgTransport.cpp src/Viewer/View/src/SmilImageItemView.cpp src/Common/ContactManager/src/ContactRecord.cpp src/Conversation/ContactList/View/src/ConvContactListView.cpp src/MsgThread/Controller/src/ThreadSearchList.cpp src/MsgThread/View/src/MsgThreadSearchPanel.cpp src/Common/Utils/src/FileUtils.cpp src/Common/View/src/ContextPopup.cpp src/Common/MsgEngine/src/MessageSMS.cpp src/Conversation/ConvList/Controller/src/BubbleContactEntity.cpp src/Conversation/ContactList/View/src/ContactListViewItem.cpp src/Common/MsgEngine/src/private/MessagePrivate.cpp src/Conversation/ConvList/Controller/src/BubbleAudioEntity.cpp src/Common/View/src/MbeRecipientsView.cpp src/MsgThread/Controller/src/ThreadListItem.cpp src/Settings/View/src/SettingsGroupListViewItem.cpp src/Common/View/src/Popup.cpp src/Common/Controller/src/ViewItemController.cpp src/Settings/Controller/src/Settings.cpp src/Common/ContactManager/src/ContactVCardParser.cpp src/Viewer/Controller/src/Viewer.cpp src/Viewer/Controller/src/SmilPage.cpp src/Conversation/ConvList/Controller/src/BubbleUnknownFileEntity.cpp src/Common/Utils/src/HwButtonListener.cpp src/Common/AppControl/src/AppControlCompose.cpp src/Common/MsgEngine/src/MsgUtils.cpp src/Conversation/ConvList/View/src/BubbleTextViewItem.cpp src/Common/Utils/src/PhoneNumberUtils.cpp src/Common/MsgEngine/src/private/MessageSMSPrivate.cpp src/Conversation/ConvList/Controller/src/BubbleEntityFactory.cpp src/Viewer/View/src/SmilPageLayout.cpp src/Common/View/src/View.cpp src/Conversation/Main/Controller/src/PopupRecipientListItem.cpp src/Common/MsgEngine/src/private/MsgConversationItemPrivate.cpp src/Conversation/ConvList/Controller/src/MsgDetailsPopup.cpp src/Common/Controller/src/FrameController.cpp src/Conversation/ConvList/View/src/DateLineViewItem.cpp src/Common/AppControl/src/AppControlCommand.cpp src/Viewer/View/src/SmilTextItemView.cpp src/Settings/View/src/SimMsgLayout.cpp src/Common/MsgEngine/src/private/MsgThreadItemPrivate.cpp src/Common/MsgEngine/src/MsgEngine.cpp src/Viewer/View/src/PlayerControl.cpp src/Common/AppControl/src/AppControlParser.cpp src/Common/Controller/src/ViewController.cpp src/Conversation/ConvList/View/src/BubbleIconTextLayoutItem.cpp src/Common/View/src/NaviFrameView.cpp src/Common/AppControl/src/FileViewer.cpp src/Common/Utils/src/PathUtils.cpp src/Conversation/ConvList/Controller/src/ComposeListItem.cpp src/Conversation/ConvList/Controller/src/DateLineItem.cpp src/Conversation/ConvList/View/src/BubbleItemContainer.cpp src/Common/AppControl/src/VoiceCall.cpp src/Common/View/src/Scroller.cpp src/Conversation/ConvList/Controller/src/BubbleVideoEntity.cpp src/Common/MsgEngine/src/MsgSettings.cpp src/Conversation/ContactList/Controller/src/ContactListItem.cpp src/Common/ContactManager/src/ContactVCardGenerator.cpp src/Common/AppControl/src/AppControlLauncher.cpp src/Viewer/View/src/SmilAudioItemView.cpp src/Common/Utils/src/LoggerImpl.cpp src/Conversation/ConvList/View/src/ConvSelectAll.cpp src/Common/ContactManager/src/ContactManager.cpp src/Conversation/Utils/src/AttachmentHandler.cpp src/Conversation/ConvList/View/src/ComposeListViewItem.cpp src/Common/MsgEngine/src/private/MsgAttachmentPrivate.cpp src/Common/View/src/ViewItem.cpp src/Conversation/AppControl/src/ContactPicker.cpp src/Common/MsgEngine/src/private/MsgMediaPrivate.cpp src/Viewer/View/src/SubjectLayout.cpp src/Conversation/Main/View/src/MessageInputPanel.cpp src/Conversation/Recipients/View/src/ConvRecipientsPanelView.cpp src/Common/Controller/src/BaseController.cpp src/Conversation/AppControl/src/AttachPanel.cpp src/Settings/Controller/src/SettingsSound.cpp src/Conversation/ConvList/View/src/ConvListViewItem.cpp src/Conversation/AppControl/src/SettingsNetwork.cpp src/Common/AppControl/src/Share.cpp src/Conversation/Body/Controller/src/Body.cpp src/Common/View/src/StandardWindow.cpp src/Common/MsgEngine/src/MsgConversationItem.cpp src/Common/MsgEngine/src/private/MessageMmsPrivate.cpp src/Viewer/View/src/SmilAttachmentItemView.cpp src/MsgThread/Controller/src/ThreadSearchListItem.cpp src/Common/View/src/DefaultLayout.cpp src/Conversation/Recipients/Controller/src/ConvRecipientsPanel.cpp src/Conversation/ConvList/View/src/BubbleVideoViewItem.cpp src/Common/View/src/PopupListItem.cpp src/Conversation/ConvList/View/src/BubbleViewItem.cpp src/Viewer/View/src/SmilVideoItemView.cpp src/Common/Controller/src/NaviFrameController.cpp src/MsgThread/Controller/src/ThreadList.cpp src/Common/Utils/src/TextDecorator.cpp src/Common/MsgEngine/src/MsgStorage.cpp src/Common/View/src/SelectAllListItem.cpp src/Conversation/ConvList/View/src/BubbleDownloadButtonViewItem.cpp src/Common/AppControl/src/ContactViewer.cpp src/Common/View/src/Box.cpp src/Common/Utils/src/ThumbnailMaker.cpp src/Common/View/src/NaviFrameItem.cpp src/Common/View/src/PopupList.cpp src/MsgThread/View/src/FloatingButton.cpp src/MsgThread/Controller/src/MsgSearchListItem.cpp src/Common/Controller/src/App.cpp src/Conversation/ConvList/View/src/ConvListLayout.cpp src/Common/View/src/PopupAttachmentListItem.cpp src/Common/MsgEngine/src/private/MsgComposerPrivate.cpp src/Viewer/View/src/ViewerLayout.cpp src/Common/Utils/src/MediaUtils.cpp src/Common/Controller/src/MbeRecipients.cpp src/Settings/Controller/src/SimListViewItem.cpp src/Common/Utils/src/TimeUtils.cpp src/Common/MsgEngine/src/private/MsgSettingsPrivate.cpp src/Viewer/View/src/SmilPlayerView.cpp src/MainApp/main.cpp src/Conversation/ConvList/View/src/BubbleImageViewItem.cpp src/Common/View/src/NoContentLayout.cpp src/Common/SystemSettingsManager/src/SystemSettingsManager.cpp src/Common/MsgEngine/src/MsgPage.cpp src/Common/AppControl/src/ContactEditor.cpp src/Conversation/Main/View/src/ConversationLayout.cpp src/Common/MsgEngine/src/private/MsgUtilsPrivate.cpp src/Common/View/src/PopupManager.cpp src/Settings/View/src/SettingsListViewItem.cpp src/Common/MsgEngine/src/private/MsgStoragePrivate.cpp src/Conversation/ConvList/Controller/src/ConvListItem.cpp src/Conversation/ConvList/View/src/BubbleBgViewItem.cpp src/MsgThread/View/src/ThreadListViewItem.cpp src/Common/MsgEngine/src/private/MsgPagePrivate.cpp src/Common/AppControl/src/AppControlUtils.cpp # EDC Sources USER_EDCS = diff --git a/src/Common/AppControl/inc/AppControlLauncher.h b/src/Common/AppControl/inc/AppControlLauncher.h new file mode 100644 index 00000000..a87f5a7d --- /dev/null +++ b/src/Common/AppControl/inc/AppControlLauncher.h @@ -0,0 +1,95 @@ +/* + * Copyright 2016 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AppControlLauncher_h_ +#define AppControlLauncher_h_ + +#include "AppControlUtils.h" + +#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; + }; +} + +#endif /* AppControlLauncher_h_ */ diff --git a/src/Common/AppControl/inc/ContactEditor.h b/src/Common/AppControl/inc/ContactEditor.h index a5c0dc98..51e7612f 100644 --- a/src/Common/AppControl/inc/ContactEditor.h +++ b/src/Common/AppControl/inc/ContactEditor.h @@ -17,8 +17,9 @@ #ifndef ContactEditor_h_ #define ContactEditor_h_ +#include "AppControlLauncher.h" + #include -#include namespace Msg { @@ -28,6 +29,7 @@ namespace Msg *@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 @@ -38,7 +40,7 @@ namespace Msg public: ContactEditor(); - ~ContactEditor(); + virtual ~ContactEditor(); /** * @brief Launches add-operation. @@ -46,31 +48,8 @@ namespace Msg * @return true in case of success, otherwise returns false. */ bool launch(const std::string &address, Operation operation); - - /** - * @brief Set listener - * @param[in] l listener - */ - void setListener(IContactEditorListener *l); - private: - ContactEditor(const ContactEditor&) = delete; - ContactEditor& operator=(const ContactEditor&) = delete; bool launch(const std::string &address, const char *operation, const char *addressType); - void onResultCb(app_control_h request, app_control_h reply, app_control_result_e result); - void terminate(); - - private: - IContactEditorListener *m_pListener; - app_control_h m_Handle; - }; - - class IContactEditorListener - { - public: - virtual ~IContactEditorListener() {} - virtual void onContactCreated(ContactEditor &obj) {}; - virtual void onContactChanged(ContactEditor &obj) {}; }; } diff --git a/src/Common/AppControl/inc/ContactViewer.h b/src/Common/AppControl/inc/ContactViewer.h index 9dcbf63a..08947ba9 100644 --- a/src/Common/AppControl/inc/ContactViewer.h +++ b/src/Common/AppControl/inc/ContactViewer.h @@ -17,7 +17,7 @@ #ifndef ContactViewer_h_ #define ContactViewer_h_ -#include "AppControlUtils.h" +#include "AppControlLauncher.h" #include "ContactAddress.h" namespace Msg @@ -26,9 +26,11 @@ namespace Msg *@brief An utility-class aimed to launch contacts-application with view-operation passed via app-control. */ class ContactViewer + : public AppControlHandle { public: - static ContactViewer &getInst(); + ContactViewer(); + virtual ~ContactViewer(); /** * @brief Launches view-operation. @@ -46,15 +48,7 @@ namespace Msg bool launch(const ContactAddress &address); private: - ContactViewer(); - ~ContactViewer(); - ContactViewer(const ContactViewer&) = delete; - ContactViewer& operator=(const ContactViewer&) = delete; const char *toStr(ContactAddress::OwnerType type); - void reset(); - - private: - app_control_h m_Handle; }; } diff --git a/src/Common/AppControl/inc/FileViewer.h b/src/Common/AppControl/inc/FileViewer.h index a501779f..868502fc 100644 --- a/src/Common/AppControl/inc/FileViewer.h +++ b/src/Common/AppControl/inc/FileViewer.h @@ -17,24 +17,20 @@ #ifndef FileViewer_h_ #define FileViewer_h_ -#include "AppControlUtils.h" +#include "AppControlLauncher.h" namespace Msg { class FileViewer + : public AppControlHandle { public: - static FileViewer &getInst(); + FileViewer(); + virtual ~FileViewer(); - static bool launch(const std::string &file); + bool launch(const std::string &file); bool launchWithCopy(const std::string &file); - private: - FileViewer(); - ~FileViewer(); - FileViewer(const FileViewer&) = delete; - FileViewer& operator=(const FileViewer&) = delete; - private: std::string m_FilePath; }; diff --git a/src/Common/AppControl/inc/Share.h b/src/Common/AppControl/inc/Share.h index ca33525a..2f086125 100644 --- a/src/Common/AppControl/inc/Share.h +++ b/src/Common/AppControl/inc/Share.h @@ -17,25 +17,24 @@ #ifndef Share_h_ #define Share_h_ +#include "AppControlLauncher.h" + #include #include namespace Msg { class Share + : public AppControlHandle { public: - static Share &getInst(); + Share(); + virtual ~Share(); bool launch(const std::list &files); bool launch(const std::string &text); private: - Share(); - ~Share(); - Share(const Share&) = delete; - Share& operator=(const Share&) = delete; - void removeFiles(); void addFiles(const std::list &files); diff --git a/src/Common/AppControl/src/AppControlLauncher.cpp b/src/Common/AppControl/src/AppControlLauncher.cpp new file mode 100644 index 00000000..26313d62 --- /dev/null +++ b/src/Common/AppControl/src/AppControlLauncher.cpp @@ -0,0 +1,120 @@ +/* + * Copyright 2016 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "AppControlLauncher.h" +#include "Logger.h" + +using namespace Msg; + +AppControlHandle::AppControlHandle(app_control_launch_mode_e launchMode) + : m_Handle() +{ + 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); + } +} + +AppControlHandle::operator app_control_h() +{ + return m_Handle; +} + +void AppControlHandle::terminate() +{ + if (m_Handle && AppControlLauncher::getInst().m_pHandle == this) + AppControlLauncher::getInst().terminate(); +} + +AppControlLauncher::AppControlLauncher() + : m_LaunchInProgress(false) + , m_pTimer(nullptr) + , m_pHandle(nullptr) +{ +} + +AppControlLauncher::~AppControlLauncher() +{ + if (m_pTimer) + ecore_timer_del(m_pTimer); +} + +AppControlLauncher &AppControlLauncher::getInst() +{ + 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; +} + +bool AppControlLauncher::isLaunchInProgress() const +{ + 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; +} + +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); + } +} + + diff --git a/src/Common/AppControl/src/ContactEditor.cpp b/src/Common/AppControl/src/ContactEditor.cpp index 9317832b..374bb022 100644 --- a/src/Common/AppControl/src/ContactEditor.cpp +++ b/src/Common/AppControl/src/ContactEditor.cpp @@ -27,9 +27,8 @@ namespace } ContactEditor::ContactEditor() - : m_pListener(nullptr) - , m_Handle() { + app_control_set_mime(m_Handle, mimeContact); } ContactEditor::~ContactEditor() @@ -37,11 +36,6 @@ ContactEditor::~ContactEditor() terminate(); } -void ContactEditor::setListener(IContactEditorListener *l) -{ - m_pListener = l; -} - bool ContactEditor::launch(const std::string &address, Operation operation) { bool res = false; @@ -66,53 +60,7 @@ bool ContactEditor::launch(const std::string &address, Operation operation) bool ContactEditor::launch(const std::string &address, const char *operation, const char *addressType) { - bool res = false; - terminate(); - if (APP_CONTROL_ERROR_NONE == app_control_create(&m_Handle)) - { - app_control_set_operation(m_Handle, operation); - app_control_set_mime(m_Handle, mimeContact); - app_control_add_extra_data(m_Handle, addressType, address.c_str()); - app_control_set_launch_mode(m_Handle, APP_CONTROL_LAUNCH_MODE_GROUP); - int ret = app_control_send_launch_request(m_Handle, APP_CONTROL_RES_CALLBACK(ContactEditor, onResultCb), this); - MSG_LOG("Result code: ", ret); - res = ret == APP_CONTROL_ERROR_NONE; - if (!res) - terminate(); - } - - return res; -} - -void ContactEditor::terminate() -{ - if (m_Handle) - { - app_control_send_terminate_request(m_Handle); - app_control_destroy(m_Handle); - m_Handle = nullptr; - } -} - -void ContactEditor::onResultCb(app_control_h request, app_control_h reply, app_control_result_e result) -{ - if (m_Handle) - { - if (result == APP_CONTROL_RESULT_SUCCEEDED && m_pListener) - { - char *op = nullptr; - app_control_get_operation(m_Handle, &op); - - if (op) - { - terminate(); - if (strcmp(op, APP_CONTROL_OPERATION_EDIT) == 0) - m_pListener->onContactChanged(*this); - else if (strcmp(op, APP_CONTROL_OPERATION_ADD) == 0) - m_pListener->onContactCreated(*this); - free(op); - } - } - terminate(); - } + 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 9be1f167..40d41f29 100644 --- a/src/Common/AppControl/src/ContactViewer.cpp +++ b/src/Common/AppControl/src/ContactViewer.cpp @@ -30,49 +30,20 @@ namespace } ContactViewer::ContactViewer() - : m_Handle() { + app_control_set_operation(m_Handle, APP_CONTROL_OPERATION_VIEW); + app_control_set_mime(m_Handle, mimeContact); } ContactViewer::~ContactViewer() { - reset(); -} - -ContactViewer &ContactViewer::getInst() -{ - static ContactViewer inst; - return inst; -} - -void ContactViewer::reset() -{ - if (m_Handle) - { - app_control_send_terminate_request(m_Handle); - app_control_destroy(m_Handle); - m_Handle = nullptr; - } } bool ContactViewer::launch(int id, ContactAddress::OwnerType ownerType) { - bool res = false; - - reset(); - if (APP_CONTROL_ERROR_NONE == app_control_create(&m_Handle)) - { - app_control_set_operation(m_Handle, APP_CONTROL_OPERATION_VIEW); - app_control_set_mime(m_Handle, mimeContact); - 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()); - app_control_set_launch_mode(m_Handle, APP_CONTROL_LAUNCH_MODE_GROUP); - int ret = app_control_send_launch_request(m_Handle, nullptr, nullptr); - MSG_LOG("Result code: ", ret); - res = ret == APP_CONTROL_ERROR_NONE; - } - - return res; + 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) diff --git a/src/Common/AppControl/src/FileViewer.cpp b/src/Common/AppControl/src/FileViewer.cpp index 0309fac9..a24f2a26 100644 --- a/src/Common/AppControl/src/FileViewer.cpp +++ b/src/Common/AppControl/src/FileViewer.cpp @@ -19,12 +19,11 @@ #include "FileUtils.h" #include "PathUtils.h" -#include - using namespace Msg; FileViewer::FileViewer() { + app_control_set_operation(m_Handle, APP_CONTROL_OPERATION_VIEW); } FileViewer::~FileViewer() @@ -33,16 +32,12 @@ FileViewer::~FileViewer() FileUtils::remove(m_FilePath); } -FileViewer &FileViewer::getInst() -{ - static FileViewer inst; - return inst; -} - bool FileViewer::launch(const std::string &file) { + if (AppControlLauncher::getInst().isLaunchInProgress()) + return false; + bool res = false; - app_control_h svc_handle = nullptr; std::string mime = FileUtils::getMimeType(file); MSG_LOG("File path: ", file); @@ -51,17 +46,12 @@ bool FileViewer::launch(const std::string &file) if (mime.empty() || file.empty()) return false; - if (APP_CONTROL_ERROR_NONE == app_control_create(&svc_handle)) + if (m_Handle) { - app_control_set_operation(svc_handle, APP_CONTROL_OPERATION_VIEW); - app_control_set_mime(svc_handle, mime.c_str()); + app_control_set_mime(m_Handle, mime.c_str()); std::string uri = "file://" + file; - app_control_set_uri(svc_handle, uri.c_str()); - app_control_set_launch_mode(svc_handle, APP_CONTROL_LAUNCH_MODE_GROUP); - int ret = app_control_send_launch_request(svc_handle, nullptr, nullptr); - MSG_LOG("Result code: ", ret); - res = ret == APP_CONTROL_ERROR_NONE; - app_control_destroy(svc_handle); + app_control_set_uri(m_Handle, uri.c_str()); + res = AppControlLauncher::getInst().launch(*this); } return res; @@ -70,14 +60,20 @@ bool FileViewer::launch(const std::string &file) bool FileViewer::launchWithCopy(const std::string &file) { bool res = false; - // 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); + 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()) + { + FileUtils::saveFileToStorage(m_FilePath); + res = launch(m_FilePath); + } + } return res; } diff --git a/src/Common/AppControl/src/Share.cpp b/src/Common/AppControl/src/Share.cpp index fda98aa1..4385add9 100644 --- a/src/Common/AppControl/src/Share.cpp +++ b/src/Common/AppControl/src/Share.cpp @@ -33,12 +33,6 @@ Share::~Share() removeFiles(); } -Share &Share::getInst() -{ - static Share inst; - return inst; -} - void Share::removeFiles() { for (auto &&file : m_FileList) @@ -59,54 +53,29 @@ void Share::addFiles(const std::list &files) bool Share::launch(const std::list &files) { - if (files.empty()) + if (files.empty() || AppControlLauncher::getInst().isLaunchInProgress()) return false; - bool res = false; - app_control_h svc_handle = nullptr; - - if (APP_CONTROL_ERROR_NONE == app_control_create(&svc_handle)) + addFiles(files); + std::vector nativePaths; + for (const std::string &file : m_FileList) { - addFiles(files); - app_control_set_operation(svc_handle, APP_CONTROL_OPERATION_MULTI_SHARE); - app_control_set_launch_mode(svc_handle, APP_CONTROL_LAUNCH_MODE_GROUP); - - std::vector nativePaths; - for (const std::string &file : m_FileList) - { - if (!file.empty()) - nativePaths.push_back(file.c_str()); - } - - app_control_add_extra_data_array(svc_handle, APP_CONTROL_DATA_PATH, nativePaths.data(), nativePaths.size()); - int ret = app_control_send_launch_request(svc_handle, nullptr, nullptr); - MSG_LOG("Result code: ", ret); - res = ret == APP_CONTROL_ERROR_NONE; - app_control_destroy(svc_handle); + if (!file.empty()) + nativePaths.push_back(file.c_str()); } - return res; + 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()) + if (text.empty() || AppControlLauncher::getInst().isLaunchInProgress()) return false; - bool res = false; - app_control_h svc_handle = nullptr; - - if (APP_CONTROL_ERROR_NONE == app_control_create(&svc_handle)) - { - app_control_set_operation(svc_handle, APP_CONTROL_OPERATION_SHARE_TEXT); - app_control_add_extra_data(svc_handle, APP_CONTROL_DATA_TEXT, text.c_str()); - app_control_set_launch_mode(svc_handle, APP_CONTROL_LAUNCH_MODE_GROUP); - int ret = app_control_send_launch_request(svc_handle, nullptr, nullptr); - MSG_LOG("Result code: ", ret); - res = ret == APP_CONTROL_ERROR_NONE; - app_control_destroy(svc_handle); - } - - return res; + 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/Controller/src/NaviFrameController.cpp b/src/Common/Controller/src/NaviFrameController.cpp index 565ca2bb..37be247a 100644 --- a/src/Common/Controller/src/NaviFrameController.cpp +++ b/src/Common/Controller/src/NaviFrameController.cpp @@ -21,6 +21,7 @@ #include "Conversation.h" #include "Logger.h" #include "PopupManager.h" +#include "AppControlLauncher.h" #include #include @@ -72,13 +73,13 @@ void NaviFrameController::execCmd(const AppControlDefaultRef &cmd) { if (prepare(*cmd)) { + AppControlLauncher::getInst().terminate(); 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 - Conversation *conv = getTopFrame(); // Check if conversation is open + 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) { @@ -89,7 +90,7 @@ void NaviFrameController::execCmd(const AppControlDefaultRef &cmd) } else if (!conv) { if (type == AppControlDefault::ViewType || type == AppControlDefault::ReplyType || isUnreadNotificationSingle(type)) { - Conversation *conversation = new Conversation(*this); + auto *conversation = new Conversation(*this); push(*conversation); conversation->execCmd(cmd); } @@ -102,7 +103,8 @@ void NaviFrameController::execCmd(const AppControlComposeRef &cmd) { if (prepare(*cmd)) { - Conversation *conv = getTopFrame(); + AppControlLauncher::getInst().terminate(); + auto *conv = getTopFrame(); if (conv) { promote(*conv); diff --git a/src/Conversation/AppControl/inc/ContactPicker.h b/src/Conversation/AppControl/inc/ContactPicker.h index 0ea346d4..643db174 100644 --- a/src/Conversation/AppControl/inc/ContactPicker.h +++ b/src/Conversation/AppControl/inc/ContactPicker.h @@ -18,6 +18,7 @@ #define ContactPicker_h_ #include "AppControlUtils.h" +#include "AppControlLauncher.h" namespace Msg { @@ -27,6 +28,7 @@ namespace Msg * @brief An utility-class aimed to launch contacts-application with pick-operation passed via app-control. */ class ContactPicker + : public AppControlHandle { public: ContactPicker(); @@ -44,9 +46,7 @@ namespace Msg bool launch(size_t howManyToPick); private: - ContactPicker(const ContactPicker&) = delete; - ContactPicker& operator=(const ContactPicker&) = delete; - void onAppControlRes(app_control_h request, app_control_h reply, app_control_result_e result); + virtual void onReply(app_control_h request, app_control_h reply, app_control_result_e result); private: IContactPickerListener *m_pListener; @@ -69,7 +69,6 @@ namespace Msg public: virtual ~IContactPickerListener() {} virtual void onContactsPicked(const std::list &numberIdList) {}; - virtual void onFinish() {}; }; } diff --git a/src/Conversation/AppControl/inc/LaunchSettings.h b/src/Conversation/AppControl/inc/LaunchSettings.h deleted file mode 100644 index ae27d512..00000000 --- a/src/Conversation/AppControl/inc/LaunchSettings.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2016 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _LAUNCH_SETTINGS_H_ -#define _LAUNCH_SETTINGS_H_ - -namespace Msg -{ - class LaunchSettings - { - public: - static void launch(); - }; -} - -#endif /* _LAUNCH_SETTINGS_H_ */ diff --git a/src/Conversation/AppControl/inc/SettingsNetwork.h b/src/Conversation/AppControl/inc/SettingsNetwork.h new file mode 100644 index 00000000..9ba3f3be --- /dev/null +++ b/src/Conversation/AppControl/inc/SettingsNetwork.h @@ -0,0 +1,33 @@ +/* + * Copyright 2016 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _LAUNCH_SETTINGS_NETWORK_H_ +#define _LAUNCH_SETTINGS_NETWORK_H_ + +#include "AppControlLauncher.h" + +namespace Msg +{ + class SettingsNetwork + : public AppControlHandle + { + public: + SettingsNetwork(); + void launch(); + }; +} + +#endif /* _LAUNCH_SETTINGS_NETWORK_H_ */ diff --git a/src/Conversation/AppControl/src/ContactPicker.cpp b/src/Conversation/AppControl/src/ContactPicker.cpp index f5cf201d..aee6357f 100644 --- a/src/Conversation/AppControl/src/ContactPicker.cpp +++ b/src/Conversation/AppControl/src/ContactPicker.cpp @@ -31,6 +31,8 @@ namespace ContactPicker::ContactPicker() : m_pListener(nullptr) { + app_control_set_operation(m_Handle, APP_CONTROL_OPERATION_PICK); + app_control_set_mime(m_Handle, mimeContact); } void ContactPicker::setListener(IContactPickerListener *pListener) @@ -41,39 +43,27 @@ void ContactPicker::setListener(IContactPickerListener *pListener) bool ContactPicker::launch(size_t howManyToPick) { bool res = false; - app_control_h svc_handle = NULL; - - if (APP_CONTROL_ERROR_NONE == app_control_create(&svc_handle)) + if (m_Handle) { - app_control_set_operation(svc_handle, APP_CONTROL_OPERATION_PICK); - app_control_set_mime(svc_handle, mimeContact); if (howManyToPick > 1) { - app_control_add_extra_data(svc_handle, APP_CONTROL_DATA_SELECTION_MODE, multiple); - app_control_add_extra_data(svc_handle, APP_CONTROL_DATA_TOTAL_COUNT, std::to_string(howManyToPick).c_str()); + 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(svc_handle, APP_CONTROL_DATA_SELECTION_MODE, single); + 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(svc_handle, APP_CONTROL_DATA_TYPE, addressesTypes, len); - app_control_set_launch_mode(svc_handle, APP_CONTROL_LAUNCH_MODE_GROUP); - app_control_enable_app_started_result_event(svc_handle); - int ret = app_control_send_launch_request(svc_handle, APP_CONTROL_RES_CALLBACK(ContactPicker, onAppControlRes), this); - MSG_LOG("launching contacts, result-code: ", ret); - res = (ret == APP_CONTROL_ERROR_NONE); - app_control_destroy(svc_handle); + app_control_add_extra_data_array(m_Handle, APP_CONTROL_DATA_TYPE, addressesTypes, len); + res = AppControlLauncher::getInst().launch(*this); } return res; } -void ContactPicker::onAppControlRes(app_control_h request, app_control_h reply, app_control_result_e result) +void ContactPicker::onReply(app_control_h request, app_control_h reply, app_control_result_e result) { - if (m_pListener) - m_pListener->onFinish(); - if (result == APP_CONTROL_RESULT_SUCCEEDED) { std::list addressIds; diff --git a/src/Conversation/AppControl/src/LaunchSettings.cpp b/src/Conversation/AppControl/src/LaunchSettings.cpp deleted file mode 100644 index 3f98b423..00000000 --- a/src/Conversation/AppControl/src/LaunchSettings.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2016 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "LaunchSettings.h" -#include - -using namespace Msg; - -void LaunchSettings::launch() -{ - app_control_h h; - app_control_create(&h); - app_control_set_app_id(h, "org.tizen.setting-network"); - app_control_send_launch_request(h, NULL, NULL); - app_control_destroy(h); -} diff --git a/src/Conversation/AppControl/src/SettingsNetwork.cpp b/src/Conversation/AppControl/src/SettingsNetwork.cpp new file mode 100644 index 00000000..d111ea04 --- /dev/null +++ b/src/Conversation/AppControl/src/SettingsNetwork.cpp @@ -0,0 +1,30 @@ +/* + * Copyright 2016 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include "SettingsNetwork.h" + +using namespace Msg; + +SettingsNetwork::SettingsNetwork() +{ + app_control_set_app_id(m_Handle, "org.tizen.setting-network"); +} + +void SettingsNetwork::launch() +{ + AppControlLauncher::getInst().launch(*this); +} diff --git a/src/Conversation/ConvList/Controller/inc/ComposeListItem.h b/src/Conversation/ConvList/Controller/inc/ComposeListItem.h index 4ec7634c..ba1e942e 100644 --- a/src/Conversation/ConvList/Controller/inc/ComposeListItem.h +++ b/src/Conversation/ConvList/Controller/inc/ComposeListItem.h @@ -25,6 +25,7 @@ namespace Msg { class IComposeListItemListener; + class FileViewer; typedef std::list BubbleEntityList; class ComposeListItem @@ -32,7 +33,7 @@ namespace Msg , private IBubbleViewItemListener { public: - ComposeListItem(BubbleEntityFactory &entityFactory); + ComposeListItem(BubbleEntityFactory &entityFactory, FileViewer &fileViewer); virtual ~ComposeListItem(); void clear(bool updateUi = true); @@ -56,6 +57,7 @@ namespace Msg IComposeListItemListener *m_pListener; std::list m_BubbleEntityList; BubbleEntityFactory &m_BubbleEntityFactory; + FileViewer &m_FileViewer; }; class IComposeListItemListener diff --git a/src/Conversation/ConvList/Controller/inc/ConvList.h b/src/Conversation/ConvList/Controller/inc/ConvList.h index 964bcb88..cbcbce81 100644 --- a/src/Conversation/ConvList/Controller/inc/ConvList.h +++ b/src/Conversation/ConvList/Controller/inc/ConvList.h @@ -26,6 +26,8 @@ #include "ContactManager.h" #include "FileViewer.h" #include "ComposeListItem.h" +#include "FileViewer.h" +#include "Share.h" #include #include @@ -207,6 +209,8 @@ namespace Msg BubbleEntityFactory m_BubbleEntityFactory; ComposeListItem *m_pComposeItem; std::function m_BodyFocusFunc; + FileViewer m_FileViewer; + Share m_Share; }; class IConvListListener diff --git a/src/Conversation/ConvList/Controller/inc/ConvListItem.h b/src/Conversation/ConvList/Controller/inc/ConvListItem.h index 13b40868..3b6ae519 100644 --- a/src/Conversation/ConvList/Controller/inc/ConvListItem.h +++ b/src/Conversation/ConvList/Controller/inc/ConvListItem.h @@ -24,7 +24,6 @@ #include "ContextPopup.h" #include "App.h" #include "MessageDetailContent.h" -#include "FileViewer.h" #include "MsgUtils.h" #include "WorkingDir.h" #include "BubbleViewItem.h" @@ -36,6 +35,8 @@ namespace Msg { class MsgConversationItem; class IConvListItemListener; + class FileViewer; + class Share; class ConvListItem : public ConvListViewItem @@ -46,12 +47,16 @@ namespace Msg * @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); @@ -127,6 +132,8 @@ namespace Msg private: IConvListItemListener *m_pListener; App &m_App; + FileViewer &m_FileViewer; + Share &m_Share; WorkingDirRef m_WorkingDir; MsgId m_MsgId; bool m_IsDraft; diff --git a/src/Conversation/ConvList/Controller/src/ComposeListItem.cpp b/src/Conversation/ConvList/Controller/src/ComposeListItem.cpp index 3f67643f..2875b621 100644 --- a/src/Conversation/ConvList/Controller/src/ComposeListItem.cpp +++ b/src/Conversation/ConvList/Controller/src/ComposeListItem.cpp @@ -28,14 +28,16 @@ #include "BubbleUnknownFileEntity.h" #include "BubbleCalEventEntity.h" #include "BubbleContactEntity.h" +#include "FileViewer.h" #include using namespace Msg; -ComposeListItem::ComposeListItem(BubbleEntityFactory &entityFactory) +ComposeListItem::ComposeListItem(BubbleEntityFactory &entityFactory, FileViewer &fileViewer) : m_pListener(nullptr) , m_BubbleEntityFactory(entityFactory) + , m_FileViewer(fileViewer) { } @@ -136,7 +138,7 @@ void ComposeListItem::deleteEntity(BubbleEntity &entity) void ComposeListItem::onAction(BubbleViewItem &item) { - FileViewer::launch(item.getEntity().getFilePath()); + m_FileViewer.launch(item.getEntity().getFilePath()); } void ComposeListItem::onDelClicked(BubbleViewItem &item) diff --git a/src/Conversation/ConvList/Controller/src/ConvList.cpp b/src/Conversation/ConvList/Controller/src/ConvList.cpp index a6a88bbc..7b713cd7 100644 --- a/src/Conversation/ConvList/Controller/src/ConvList.cpp +++ b/src/Conversation/ConvList/Controller/src/ConvList.cpp @@ -211,9 +211,9 @@ ConvListItem *ConvList::getItem(MsgId msgId) const void ConvList::insertItem(const MsgConversationItem &item) { if (item.getDirection() == Message::MD_Received) - insertItem(new ConvListItem(item, m_App, m_BubbleEntityFactory, m_SearchWord, m_RecipThumbId)); + insertItem(new ConvListItem(item, m_App, m_FileViewer, m_Share, m_BubbleEntityFactory, m_SearchWord, m_RecipThumbId)); else - insertItem(new ConvListItem(item, m_App, m_BubbleEntityFactory, m_SearchWord)); + insertItem(new ConvListItem(item, m_App, m_FileViewer, m_Share, m_BubbleEntityFactory, m_SearchWord)); } void ConvList::insertItem(ConvListItem *item) @@ -363,7 +363,7 @@ ComposeListItem &ConvList::getComposeItem() { if (!m_pComposeItem) { - m_pComposeItem = new ComposeListItem(m_BubbleEntityFactory); + m_pComposeItem = new ComposeListItem(m_BubbleEntityFactory, m_FileViewer); m_pList->appendItem(*m_pComposeItem); m_pComposeItem->show(false); } diff --git a/src/Conversation/ConvList/Controller/src/ConvListItem.cpp b/src/Conversation/ConvList/Controller/src/ConvListItem.cpp index d5f9a18e..1cc36105 100644 --- a/src/Conversation/ConvList/Controller/src/ConvListItem.cpp +++ b/src/Conversation/ConvList/Controller/src/ConvListItem.cpp @@ -45,12 +45,16 @@ 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(item.getDirection()) @@ -239,7 +243,7 @@ void ConvListItem::shareContent() { if (MsgUtils::isSms(m_Type)) { - Share::getInst().launch(getAllMsgText()); + m_Share.launch(getAllMsgText()); } else { std::list fileList; for (BubbleEntity *entity : m_BubbleEntityList) @@ -248,7 +252,7 @@ void ConvListItem::shareContent() if (!filePath.empty()) fileList.push_back(filePath); } - Share::getInst().launch(fileList); + m_Share.launch(fileList); } } @@ -447,7 +451,7 @@ void ConvListItem::onAction(BubbleViewItem &item) { const std::string &filePath = item.getEntity().getFilePath(); if (!filePath.empty()) - FileViewer::getInst().launchWithCopy(filePath); + m_FileViewer.launchWithCopy(filePath); break; } } diff --git a/src/Conversation/Main/Controller/inc/Conversation.h b/src/Conversation/Main/Controller/inc/Conversation.h index 6a2a3448..a911c658 100644 --- a/src/Conversation/Main/Controller/inc/Conversation.h +++ b/src/Conversation/Main/Controller/inc/Conversation.h @@ -36,6 +36,8 @@ #include "SystemSettingsManager.h" #include "WorkingDir.h" #include "MsgReport.h" +#include "ContactViewer.h" +#include "SettingsNetwork.h" #include @@ -227,6 +229,8 @@ namespace Msg AttachPanel m_AttachPanel; DefferedCmd m_DefferedCmd; ContactEditor m_ContactEditor; + ContactViewer m_ContactViewer; + SettingsNetwork m_SettingsNetwork; IConversationListener *m_pListener; std::function m_TransFinishedFunc; }; diff --git a/src/Conversation/Main/Controller/src/Conversation.cpp b/src/Conversation/Main/Controller/src/Conversation.cpp index b0918507..e9570315 100644 --- a/src/Conversation/Main/Controller/src/Conversation.cpp +++ b/src/Conversation/Main/Controller/src/Conversation.cpp @@ -27,11 +27,10 @@ #include "VoiceCall.h" #include "Viewer.h" #include "PopupRecipientListItem.h" -#include "LaunchSettings.h" -#include +#include "SaveAttachments.h" + #include #include -#include using namespace Msg; @@ -197,7 +196,7 @@ void Conversation::recipientClickHandler(const std::string &address) } else if (m_Mode == ConversationMode) { if (m_pRecipPanel) m_pRecipPanel->unselectMbeItem(); - ContactViewer::getInst().launch(*contactAddress); + m_ContactViewer.launch(*contactAddress); } } else { showUnsavedRecipientPopup(address); @@ -1290,7 +1289,7 @@ void Conversation::onMsgSendErrorButtonClicked(Popup &popup, int buttonId) void Conversation::onMsgSettingsButtonClicked(Popup &popup, int buttonId) { MSG_LOG(""); - LaunchSettings::launch(); + m_SettingsNetwork.launch(); popup.destroy(); } @@ -1396,7 +1395,7 @@ void Conversation::onViewContactDetailsItemPressed(PopupListItem &item) int id = static_cast(item).getContactId(); auto ownerType = static_cast(item).getContactOwnerType(); item.getParent().destroy(); - ContactViewer::getInst().launch(id, ownerType); + m_ContactViewer.launch(id, ownerType); } void Conversation::onAllConvItemsDeleted(ConvList &list) diff --git a/src/Conversation/Recipients/Controller/inc/ConvRecipientsPanel.h b/src/Conversation/Recipients/Controller/inc/ConvRecipientsPanel.h index e5140aee..24b33ed4 100644 --- a/src/Conversation/Recipients/Controller/inc/ConvRecipientsPanel.h +++ b/src/Conversation/Recipients/Controller/inc/ConvRecipientsPanel.h @@ -80,7 +80,6 @@ namespace Msg // IContactPickerListener virtual void onContactsPicked(const std::list &addressIdList); - virtual void onFinish(); // IContactManagerListener: virtual void onContactChanged(); diff --git a/src/Conversation/Recipients/Controller/src/ConvRecipientsPanel.cpp b/src/Conversation/Recipients/Controller/src/ConvRecipientsPanel.cpp index 346a2879..ac62108e 100644 --- a/src/Conversation/Recipients/Controller/src/ConvRecipientsPanel.cpp +++ b/src/Conversation/Recipients/Controller/src/ConvRecipientsPanel.cpp @@ -257,10 +257,7 @@ void ConvRecipientsPanel::onContactButtonClicked() MSG_LOG(""); int currentRecipientsCount = getItemsCount(); if (currentRecipientsCount < getMaxRecipientCount()) - { - setButtonEnabled(ContactButton, false); m_Picker.launch(getMaxRecipientCount() - currentRecipientsCount); - } else showTooManyRecipientsNotif(); } @@ -301,12 +298,6 @@ void ConvRecipientsPanel::onContactsPicked(const std::list &addressI setEntryFocus(true); } -void ConvRecipientsPanel::onFinish() -{ - MSG_LOG(""); - setButtonEnabled(ContactButton, true); -} - void ConvRecipientsPanel::onPopupBtnClicked(Popup &popup, int buttonId) { popup.destroy(); diff --git a/src/Settings/Controller/inc/Settings.h b/src/Settings/Controller/inc/Settings.h index 4cf7b491..ec2efaf0 100644 --- a/src/Settings/Controller/inc/Settings.h +++ b/src/Settings/Controller/inc/Settings.h @@ -23,6 +23,7 @@ #include "SettingsListItem.h" #include "MsgSettings.h" #include "SystemSettingsManager.h" +#include "SettingsSound.h" namespace Msg { @@ -127,6 +128,7 @@ namespace Msg SettingsListItem *m_pReadReportItem; SettingsListItem *m_pAutoRetItem; SettingsListItem *m_pAutoRetRoamingItem; + SettingsSound m_SoundPicker; }; } diff --git a/src/Settings/Controller/inc/SettingsSound.h b/src/Settings/Controller/inc/SettingsSound.h index ecc04b75..972625b4 100644 --- a/src/Settings/Controller/inc/SettingsSound.h +++ b/src/Settings/Controller/inc/SettingsSound.h @@ -17,6 +17,8 @@ #ifndef SETTINGSSOUND_H_ #define SETTINGSSOUND_H_ +#include "AppControlLauncher.h" + namespace Msg { class MsgSettings; @@ -25,6 +27,7 @@ namespace Msg * @brief This class is aimed to launch preinstalled utility from settings-app that allows to chose message-alert sound. */ class SettingsSound + : public AppControlHandle { public: /** @@ -32,16 +35,15 @@ namespace Msg * @param[in] settingsHandle an instance of message-settings api wrapper. */ SettingsSound(MsgSettings &settingsHandle); - ~SettingsSound(); + virtual ~SettingsSound(); /** * @brief launches preinstalled sound-picker utility via app-control. */ - void launchSoundPicker(); + bool launch(); private: - SettingsSound(SettingsSound&) = delete; - SettingsSound& operator=(SettingsSound&) = delete; + 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/src/Settings.cpp b/src/Settings/Controller/src/Settings.cpp index 29eb5ce6..ac014ffe 100644 --- a/src/Settings/Controller/src/Settings.cpp +++ b/src/Settings/Controller/src/Settings.cpp @@ -15,7 +15,6 @@ */ #include "Settings.h" -#include "SettingsSound.h" #include "Config.h" #include "MsgEngine.h" #include "Logger.h" @@ -47,6 +46,7 @@ Settings::Settings(NaviFrameController &parent) , m_pReadReportItem(nullptr) , m_pAutoRetItem(nullptr) , m_pAutoRetRoamingItem(nullptr) + , m_SoundPicker(getMsgEngine().getSettings()) { create(); } @@ -288,8 +288,7 @@ void Settings::alertsItemHandler(SettingsListItem &item) void Settings::soundItemHandler(SettingsListItem &item) { MSG_LOG("soundItemHandler activated!"); - SettingsSound picker(getMsgSettings()); - picker.launchSoundPicker(); + m_SoundPicker.launch(); } void Settings::vibrationItemHandler(SettingsListItem &item) diff --git a/src/Settings/Controller/src/SettingsSound.cpp b/src/Settings/Controller/src/SettingsSound.cpp index ec40ed88..b5d7e8a6 100644 --- a/src/Settings/Controller/src/SettingsSound.cpp +++ b/src/Settings/Controller/src/SettingsSound.cpp @@ -25,7 +25,6 @@ using namespace Msg; namespace { const char *sRingtoneValuePath = "/opt/share/settings/Alerts"; - const char *sRingtoneKeySelectType = "select_type"; const char *sRingtoneKeyFileType = "file_type"; const char *sRingtoneValueSound = "SOUND"; const char *sRingtoneKeySilent = "silent"; @@ -42,13 +41,21 @@ namespace SettingsSound::SettingsSound(MsgSettings &settingsHandle) : m_SettingsHandle(settingsHandle) { + app_control_set_app_id(m_Handle, sRingtoneAppId); + app_control_add_extra_data(m_Handle, APP_CONTROL_DATA_PATH, sRingtoneValuePath); + app_control_add_extra_data(m_Handle, sRingtoneKeyDomain, PACKAGE_NAME); + app_control_add_extra_data(m_Handle, sRingtoneKeyFileType, sRingtoneValueSound); + app_control_add_extra_data(m_Handle, sRingtoneKeySilent, sRingtoneValueSilentShow); + app_control_add_extra_data(m_Handle, sRingtoneKeyDefault, sRingtoneValueDefaultShow); + app_control_add_extra_data(m_Handle, sRingtoneKeyDrmType, sRingtoneValueDrmAll); + app_control_add_extra_data(m_Handle, sRingtoneKeyTitle, msg("IDS_MSG_HEADER_MESSAGE_TONE_ABB").get()); } SettingsSound::~SettingsSound() { } -static void soundPickerCb(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data) +void SettingsSound::onReply(app_control_h request, app_control_h reply, app_control_result_e result) { char **ringtones = nullptr; int count = 0; @@ -58,16 +65,15 @@ static void soundPickerCb(app_control_h request, app_control_h reply, app_contro return; char *ringtone = ringtones[0]; - auto *settings = static_cast(user_data); if (strcmp(ringtone, sRingtoneKeySilent) == 0) - settings->setRingtoneType(MsgSettings::SilentRingtone); + m_SettingsHandle.setRingtoneType(MsgSettings::SilentRingtone); else if (strcmp(ringtone, sRingtoneKeyDefault) == 0) - settings->setRingtoneType(MsgSettings::DefaultRingtone); + m_SettingsHandle.setRingtoneType(MsgSettings::DefaultRingtone); else { - settings->setRingtoneType(MsgSettings::UserRingtone); - settings->setRingtone(ringtone); + m_SettingsHandle.setRingtoneType(MsgSettings::UserRingtone); + m_SettingsHandle.setRingtone(ringtone); } for (int i = 0; i < count; ++i) { @@ -76,34 +82,19 @@ static void soundPickerCb(app_control_h request, app_control_h reply, app_contro free(ringtones); } -void SettingsSound::launchSoundPicker() +bool SettingsSound::launch() { - app_control_h h; - app_control_create(&h); - app_control_set_launch_mode(h, APP_CONTROL_LAUNCH_MODE_GROUP); - - app_control_add_extra_data(h, APP_CONTROL_DATA_PATH, sRingtoneValuePath); - app_control_add_extra_data(h, sRingtoneKeyDomain, PACKAGE_NAME); - app_control_add_extra_data(h, sRingtoneKeyFileType, sRingtoneValueSound); - app_control_add_extra_data(h, sRingtoneKeySilent, sRingtoneValueSilentShow); - app_control_add_extra_data(h, sRingtoneKeyDefault, sRingtoneValueDefaultShow); - app_control_add_extra_data(h, sRingtoneKeyDrmType, sRingtoneValueDrmAll); - app_control_add_extra_data(h, sRingtoneKeyTitle, msg("IDS_MSG_HEADER_MESSAGE_TONE_ABB").get()); - std::string selectedData; if (m_SettingsHandle.getRingtoneType() == MsgSettings::SilentRingtone) - selectedData = sRingtoneKeySilent; + selectedData = sRingtoneKeySilent; else if (m_SettingsHandle.getRingtoneType() == MsgSettings::DefaultRingtone) - selectedData = sRingtoneKeyDefault; + selectedData = sRingtoneKeyDefault; else if (m_SettingsHandle.getRingtoneType() == MsgSettings::UserRingtone) - selectedData = m_SettingsHandle.getRingtone(); + selectedData = m_SettingsHandle.getRingtone(); const char *selectedDataArray[] = {selectedData.c_str()}; - app_control_add_extra_data_array(h, APP_CONTROL_DATA_SELECTED, selectedDataArray, 1); - - app_control_set_app_id(h, sRingtoneAppId); - app_control_send_launch_request(h, soundPickerCb, &m_SettingsHandle); + app_control_add_extra_data_array(m_Handle, APP_CONTROL_DATA_SELECTED, selectedDataArray, 1); - app_control_destroy(h); + return AppControlLauncher::getInst().launch(*this); } diff --git a/src/Viewer/Controller/inc/SmilPage.h b/src/Viewer/Controller/inc/SmilPage.h index 12b9e4d6..e040e288 100644 --- a/src/Viewer/Controller/inc/SmilPage.h +++ b/src/Viewer/Controller/inc/SmilPage.h @@ -28,6 +28,7 @@ namespace Msg { class SmilImageItemView; + class FileViewer; class SmilPage : public SmilPageLayout @@ -35,8 +36,8 @@ namespace Msg , private ISmilAttachmentItemViewListener { public: - SmilPage(Evas_Object *parent, const MsgPage &page); - SmilPage(Evas_Object *parent, const MsgAttachmentList &list); + SmilPage(Evas_Object *parent, FileViewer &fileViewer, const MsgPage &page); + SmilPage(Evas_Object *parent, FileViewer &fileViewer, const MsgAttachmentList &list); virtual ~SmilPage(); int getDuration() const; @@ -78,6 +79,7 @@ namespace Msg SmilImageItemView *m_pImageItem; std::list m_Attachments; bool m_HasInvalidFiles; + FileViewer &m_FileViewer; }; } diff --git a/src/Viewer/Controller/inc/SmilPlayer.h b/src/Viewer/Controller/inc/SmilPlayer.h index a02ee2ff..bc5a1c6f 100644 --- a/src/Viewer/Controller/inc/SmilPlayer.h +++ b/src/Viewer/Controller/inc/SmilPlayer.h @@ -21,6 +21,7 @@ #include "MessageMms.h" #include "SmilPage.h" #include "MediaPlayer.h" +#include "FileViewer.h" #include #include @@ -94,6 +95,7 @@ namespace Msg int m_Duration; State m_State; int m_PageTickCounter; + FileViewer m_FileViewer; }; class ISmilPlayerListener diff --git a/src/Viewer/Controller/inc/Viewer.h b/src/Viewer/Controller/inc/Viewer.h index 7154663e..d348f14a 100644 --- a/src/Viewer/Controller/inc/Viewer.h +++ b/src/Viewer/Controller/inc/Viewer.h @@ -31,6 +31,7 @@ #include "SubjectLayout.h" #include "SystemSettingsManager.h" #include "MsgStorage.h" +#include "ContactViewer.h" namespace Msg { @@ -131,6 +132,7 @@ namespace Msg ContactEditor m_ContactEditor; SmilPlayer *m_pSmilPlayer; SubjectLayout *m_pSubjectLayout; + ContactViewer m_ContactViewer; }; } diff --git a/src/Viewer/Controller/src/SmilPage.cpp b/src/Viewer/Controller/src/SmilPage.cpp index 771cc69d..1d94c9ce 100644 --- a/src/Viewer/Controller/src/SmilPage.cpp +++ b/src/Viewer/Controller/src/SmilPage.cpp @@ -25,30 +25,34 @@ #include "PathUtils.h" #include "MediaPlayer.h" #include "MediaUtils.h" +#include "FileViewer.h" + #include using namespace Msg; const int defaultPageDuration = 5; // sec; -SmilPage::SmilPage(Evas_Object *parent, const MsgPage &page) +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) { build(page); } -SmilPage::SmilPage(Evas_Object *parent, const MsgAttachmentList &list) +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) { build(list); } @@ -292,7 +296,7 @@ void SmilPage::buildAttachment(const MsgAttachment& attachment) void SmilPage::onItemClicked(SmilAttachmentItemView &item) { MSG_LOG(""); - FileViewer::getInst().launchWithCopy(item.getFilePath()); + m_FileViewer.launchWithCopy(item.getFilePath()); } void SmilPage::onSaveButtonClicked(SmilAttachmentItemView &item) diff --git a/src/Viewer/Controller/src/SmilPlayer.cpp b/src/Viewer/Controller/src/SmilPlayer.cpp index a001b5f4..b87728ed 100644 --- a/src/Viewer/Controller/src/SmilPlayer.cpp +++ b/src/Viewer/Controller/src/SmilPlayer.cpp @@ -48,7 +48,7 @@ void SmilPlayer::create(const MessageMms &mms) const MsgPage &page = pages[i]; if (!SmilPage::isEmpty(page)) { - SmilPage *smilPage = new SmilPage(getEo(), page); + SmilPage *smilPage = new SmilPage(getEo(), m_FileViewer, page); m_Duration += smilPage->getDuration(); m_PageList.push_back(smilPage); } @@ -57,7 +57,7 @@ void SmilPlayer::create(const MessageMms &mms) // Attachment: if (!mms.getAttachmentList().isEmpty()) { - SmilPage *smilPage = new SmilPage(getEo(), mms.getAttachmentList()); + SmilPage *smilPage = new SmilPage(getEo(), m_FileViewer, mms.getAttachmentList()); m_Duration += smilPage->getDuration(); m_PageList.push_back(smilPage); } diff --git a/src/Viewer/Controller/src/Viewer.cpp b/src/Viewer/Controller/src/Viewer.cpp index 265b40d5..d2a3d5dd 100644 --- a/src/Viewer/Controller/src/Viewer.cpp +++ b/src/Viewer/Controller/src/Viewer.cpp @@ -225,7 +225,7 @@ void Viewer::recipientClickHandler(const std::string &address) m_SelectedAddress = address; ContactAddressRef contactAddress = getApp().getContactManager().getContactAddress(address); if (contactAddress) - ContactViewer::getInst().launch(*contactAddress); + m_ContactViewer.launch(*contactAddress); else showRecipPopup(address); } @@ -348,7 +348,7 @@ void Viewer::onMakeVoiceItemPressed(PopupListItem &item) { MSG_LOG(""); item.getParent().destroy(); - VoiceCall::launch(m_SelectedAddress); + VoiceCall::launch(m_SelectedAddress); } void Viewer::onCreateContactItemPressed(PopupListItem &item)