TizenRefApp-6398 Share attachment from slideshow 49/72349/5
authorDenis Dolzhenko <d.dolzhenko@samsung.com>
Tue, 31 May 2016 13:23:49 +0000 (16:23 +0300)
committerDenis Dolzhenko <d.dolzhenko@samsung.com>
Wed, 1 Jun 2016 08:32:59 +0000 (11:32 +0300)
Change-Id: Id8b51c1de2e81b2db5e6371302792b54da700b92
Signed-off-by: Denis Dolzhenko <d.dolzhenko@samsung.com>
src/Common/AppControl/inc/FileShare.h [new file with mode: 0644]
src/Common/AppControl/src/FileShare.cpp [new file with mode: 0644]
src/Viewer/Controller/inc/SmilPage.h
src/Viewer/Controller/inc/Viewer.h
src/Viewer/Controller/src/SmilPage.cpp
src/Viewer/Controller/src/Viewer.cpp

diff --git a/src/Common/AppControl/inc/FileShare.h b/src/Common/AppControl/inc/FileShare.h
new file mode 100644 (file)
index 0000000..9b29511
--- /dev/null
@@ -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 <list>
+#include <string>
+
+
+namespace Msg
+{
+    class FileShare
+    {
+        public:
+            static bool launch(const std::list<std::string> &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 (file)
index 0000000..fa99427
--- /dev/null
@@ -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 <app_control.h>
+#include <vector>
+
+using namespace Msg;
+
+
+bool FileShare::launch(const std::list<std::string> &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<const char*> 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;
+}
+
index 6488ce2..7f547c3 100644 (file)
@@ -22,6 +22,8 @@
 #include "MsgPage.h"
 #include "MsgAttachment.h"
 
+#include <list>
+
 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<std::string> &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<std::string> m_Attachments;
     };
 }
 
index 475c097..16f35dd 100644 (file)
@@ -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:
index 425e5ab..ce6377d 100644 (file)
@@ -87,6 +87,11 @@ std::string SmilPage::getMediaPath() const
     return m_MediaPath;
 }
 
+const std::list<std::string> &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;
 
index 6439c31..fb0f874 100644 (file)
@@ -27,6 +27,7 @@
 #include "ContactViewer.h"
 #include "FileUtils.h"
 #include "SaveAttachmentsPopup.h"
+#include "FileShare.h"
 
 #include <sstream>
 #include <iomanip>
@@ -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("");