From 08271a40be8baaed05d60f7e569c9b809e9e4065 Mon Sep 17 00:00:00 2001 From: Denis Dolzhenko Date: Tue, 31 May 2016 16:23:49 +0300 Subject: [PATCH] TizenRefApp-6398 Share attachment from slideshow Change-Id: Id8b51c1de2e81b2db5e6371302792b54da700b92 Signed-off-by: Denis Dolzhenko --- src/Common/AppControl/inc/FileShare.h | 37 ++++++++++++++++++++ src/Common/AppControl/src/FileShare.cpp | 60 +++++++++++++++++++++++++++++++++ src/Viewer/Controller/inc/SmilPage.h | 4 +++ src/Viewer/Controller/inc/Viewer.h | 1 + src/Viewer/Controller/src/SmilPage.cpp | 16 +++++++++ src/Viewer/Controller/src/Viewer.cpp | 20 ++++++++++- 6 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 src/Common/AppControl/inc/FileShare.h create mode 100644 src/Common/AppControl/src/FileShare.cpp diff --git a/src/Common/AppControl/inc/FileShare.h b/src/Common/AppControl/inc/FileShare.h new file mode 100644 index 0000000..9b29511 --- /dev/null +++ b/src/Common/AppControl/inc/FileShare.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2009-2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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 FileShare_h_ +#define FileShare_h_ + +#include +#include + + +namespace Msg +{ + class FileShare + { + public: + static bool launch(const std::list &files); + + FileShare(const FileShare&) = delete; + FileShare& operator=(const FileShare&) = delete; + }; +} + +#endif /* FileShare_h_ */ diff --git a/src/Common/AppControl/src/FileShare.cpp b/src/Common/AppControl/src/FileShare.cpp new file mode 100644 index 0000000..fa99427 --- /dev/null +++ b/src/Common/AppControl/src/FileShare.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2009-2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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 "FileShare.h" +#include "AppControlUtils.h" +#include "Logger.h" + +#include +#include + +using namespace Msg; + + +bool FileShare::launch(const std::list &files) +{ + if(files.empty()) + 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_MULTI_SHARE); + app_control_set_mime(svc_handle, "*/*"); + + app_control_set_launch_mode(svc_handle, APP_CONTROL_LAUNCH_MODE_GROUP); + + std::vector paths; + for(const std::string &file : files) + { + if(!file.empty()) + paths.push_back(file.c_str()); + } + + app_control_add_extra_data_array(svc_handle, APP_CONTROL_DATA_PATH, paths.data(), paths.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); + } + + return res; +} + diff --git a/src/Viewer/Controller/inc/SmilPage.h b/src/Viewer/Controller/inc/SmilPage.h index 6488ce2..7f547c3 100644 --- a/src/Viewer/Controller/inc/SmilPage.h +++ b/src/Viewer/Controller/inc/SmilPage.h @@ -22,6 +22,8 @@ #include "MsgPage.h" #include "MsgAttachment.h" +#include + namespace Msg { class SmilImageItemView; @@ -42,6 +44,7 @@ namespace Msg void playAnimation(bool play); Evas_Object *getVideoSink() const; std::string getMediaPath() const; + const std::list &getAttachments() const; private: const MsgMedia *getMedia(const MsgPage &page, MsgMedia::Type type) const; @@ -60,6 +63,7 @@ namespace Msg Evas_Object *m_pVideoSink; bool m_HasAudio; SmilImageItemView *m_pImageItem; + std::list m_Attachments; }; } diff --git a/src/Viewer/Controller/inc/Viewer.h b/src/Viewer/Controller/inc/Viewer.h index 475c097..16f35dd 100644 --- a/src/Viewer/Controller/inc/Viewer.h +++ b/src/Viewer/Controller/inc/Viewer.h @@ -87,6 +87,7 @@ namespace Msg void onDeleteButtonClicked(Popup &popup, int buttonId); void onCopyTextItemPressed(PopupListItem &item); void onForwardItemPressed(PopupListItem &item); + void onShareItemPressed(PopupListItem &item); void onSaveAttachmentsItemPressed(PopupListItem &item); // MbeRecipients: diff --git a/src/Viewer/Controller/src/SmilPage.cpp b/src/Viewer/Controller/src/SmilPage.cpp index 425e5ab..ce6377d 100644 --- a/src/Viewer/Controller/src/SmilPage.cpp +++ b/src/Viewer/Controller/src/SmilPage.cpp @@ -87,6 +87,11 @@ std::string SmilPage::getMediaPath() const return m_MediaPath; } +const std::list &SmilPage::getAttachments() const +{ + return m_Attachments; +} + bool SmilPage::hasAnimation() const { return m_pImageItem && m_pImageItem->hasAnimation(); @@ -113,6 +118,12 @@ void SmilPage::build(const MsgPage &page) { m_Duration = page.getPageDuration(); + const MsgMediaList &list = page.getMediaList(); + for(int i = 0; i < list.getLength(); ++i) + { + m_Attachments.push_back(list[i].getFilePath()); + } + // TODO: image/video, text order bool hasVideo = getMedia(page, MsgMedia::VideoType) != nullptr; @@ -145,6 +156,11 @@ void SmilPage::build(const MsgAttachmentList &list) { m_Duration = defaultPageDuration; + for(int i = 0; i < list.getLength(); ++i) + { + m_Attachments.push_back(list[i].getFilePath()); + } + if(list.isEmpty()) return; diff --git a/src/Viewer/Controller/src/Viewer.cpp b/src/Viewer/Controller/src/Viewer.cpp index 6439c31..fb0f874 100644 --- a/src/Viewer/Controller/src/Viewer.cpp +++ b/src/Viewer/Controller/src/Viewer.cpp @@ -27,6 +27,7 @@ #include "ContactViewer.h" #include "FileUtils.h" #include "SaveAttachmentsPopup.h" +#include "FileShare.h" #include #include @@ -269,6 +270,8 @@ void Viewer::onHwBackButtonClicked() void Viewer::onHwMoreButtonClicked() { + m_pSmilPlayer->stop(); + PopupList &popup = getApp().getPopupManager().getPopupList(); popup.setAutoDismissBlockClickedFlag(true); popup.appendItem(msg("IDS_MSG_OPT_DELETE"), POPUPLIST_ITEM_PRESSED_CB(Viewer, onDeleteItemPressed), this); @@ -278,8 +281,13 @@ void Viewer::onHwMoreButtonClicked() popup.appendItem(msg("IDS_MSGF_OPT_FORWARD"), POPUPLIST_ITEM_PRESSED_CB(Viewer, onForwardItemPressed), this); - if(!m_Msg->getAttachmentList().isEmpty() || m_Msg->getMediaCount() > 0) + 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.appendItem(msg("IDS_COM_BUTTON_SHARE"), POPUPLIST_ITEM_PRESSED_CB(Viewer, onShareItemPressed), this); + } + popup.show(); } @@ -412,6 +420,16 @@ void Viewer::onSaveAttachmentsItemPressed(PopupListItem &item) popup->show(); } +void Viewer::onShareItemPressed(PopupListItem &item) +{ + MSG_LOG(""); + item.getParent().destroy(); + + SmilPage *page = m_pSmilPlayer->getCurrentPage(); + if(page) + FileShare::launch(page->getAttachments()); +} + void Viewer::onRecipItemClicked(Evas_Object *obj, void *eventInfo) { MSG_LOG(""); -- 2.7.4