TizenRefApp-9668 Implement image sending 45/157145/2 submit/tizen_4.0/20171024.072906 tizen_4.0.IoT.p2_release
authorDenis Dolzhenko <d.dolzhenko@samsung.com>
Mon, 23 Oct 2017 11:49:20 +0000 (14:49 +0300)
committerDenis Dolzhenko <d.dolzhenko@samsung.com>
Mon, 23 Oct 2017 12:21:01 +0000 (15:21 +0300)
Change-Id: Ia8f288456a3c1430e53378b02d5896c7f2371fbb
Signed-off-by: Denis Dolzhenko <d.dolzhenko@samsung.com>
src/Common/AppControl/inc/InputSelector.h
src/Common/AppControl/src/InputSelector.cpp
src/Composer/Controller/inc/MsgInputController.h
src/Composer/Controller/src/MsgInputController.cpp
src/Composer/Controller/src/MsgSenderController.cpp

index 103f44b8d0b3b75555b979553540a3d1d9b51986..2b9063a7419a634b2336dccfb82e0dc50229804a 100644 (file)
@@ -76,6 +76,7 @@ namespace Msg {
                        virtual void onKeyboardReply(const std::string &text, int cursorPos) {};
                        virtual void onTemplateReply(const std::string &text) {};
                        virtual void onVoiceReply(const std::string &text, const std::list<std::string> &filePath) {};
+                       virtual void onImageReply(const std::list<std::string> &filePath) {};
                        virtual void onEmoticonReply(const std::string &emoticon) {};
        };
 }
index a62a65a938dce4129126e4b6607b0eaeaf6ae116..c8991fe1c4e4ea0d17fd8c9d36b1d3ef2cd58487 100644 (file)
@@ -24,7 +24,7 @@ InputSelector::InputSelector()
 {
        setOperation(APP_CONTROL_OPERATION_GET_INPUT);
        addExtraData("return_key_type", "DONE");
-       setMime("text/plain");
+       setMime("*/*");
 }
 
 InputSelector::~InputSelector()
@@ -103,6 +103,9 @@ void InputSelector::onReply(app_control_h request, app_control_h reply, app_cont
                                m_pListener->onVoiceReply(text, fileList);
                        } else if (replyType == "template") {
                                m_pListener->onTemplateReply(text);
+                       } else if (replyType == "image") {
+                               auto fileList = AppControlUtils::getExtraDataArray(reply, APP_CONTROL_DATA_PATH);
+                               m_pListener->onImageReply(fileList);
                        }
                }
        }
index 87f832e13d37995b20ba98524e7f221e7a087525..26e4853b16f1117e30f60a5fcb184d3f11bb983a 100644 (file)
@@ -68,6 +68,7 @@ namespace Msg {
                        void onKeyboardReply(const std::string &text, int cursorPos) override;
                        void onVoiceReply(const std::string &text, const std::list<std::string> &fileList) override;
                        void onEmoticonReply(const std::string &emoticon) override;
+                       void onImageReply(const std::list<std::string> &fileList) override;
                        void onTerminate(InputSelector &) override;
 
                private:
index ac8722dee6f7cedafa497fc73380a6eb0f648a52..1717404a7b6a5ee3a2bde3d42cb1f359f1d771ea 100644 (file)
@@ -104,8 +104,11 @@ bool MsgInputController::launchTextInputView(const std::string &text)
 
 void MsgInputController::notifyOnSendRequest()
 {
-       if (m_pListener)
-               m_pListener->onSendRequest(*this);
+       if (m_pListener) {
+               bool isEmpty = m_InputData.files.empty() && m_InputData.text.empty();
+               if (!isEmpty)
+                       m_pListener->onSendRequest(*this);
+       }
 }
 
 void MsgInputController::onDestroy(MsgBodyFrame &frame)
@@ -151,14 +154,15 @@ void MsgInputController::onEmoticonReply(const std::string &emoticon)
 void MsgInputController::onVoiceReply(const std::string &text, const std::list<std::string> &fileList)
 {
        MSG_LOG("");
+       m_InputData.files = fileList;
+       m_InputData.text = text;
+       notifyOnSendRequest();
+}
 
-       // TODO: Dummy file for test
-       #if (0)
-               std::string file = PathUtils::getResourcePath("dummy_res/1.mp3");
-               m_InputData.files.push_back(file);
-               m_InputData.files = fileList;
-       #endif
-
+void MsgInputController::onImageReply(const std::list<std::string> &fileList)
+{
+       MSG_LOG("");
+       m_InputData.files = fileList;
        notifyOnSendRequest();
 }
 
index 592950bd6fd353eb0abc2797feadf7d634264c23..b870377bde8a652c43e8973ebea7f98e0f4cceb4 100644 (file)
@@ -108,10 +108,15 @@ void MsgSenderController::setText(std::string text)
 
 bool MsgSenderController::addFile(const std::string &file)
 {
-       std::string newFilePath = m_WorkingDir->addFile(file);
-       bool isValid = !newFilePath.empty();
-       if (isValid)
-               m_Files.push_back(std::move(newFilePath));
+       bool isValid = FileUtils::isExists(file);
+       if (isValid) {
+               std::string newFilePath = m_WorkingDir->addFile(file);
+               isValid = !newFilePath.empty();
+               if (isValid)
+                       m_Files.push_back(std::move(newFilePath));
+       } else {
+               MSG_LOG_ERROR("File path is not valid: ", file);
+       }
        return isValid;
 }
 
@@ -389,9 +394,7 @@ std::vector<MessageRef> MsgSenderController::createMessage()
                return {};
        }
 
-       MSG_LOG("");
        if (m_Files.empty()) {
-               MSG_LOG("");
                // Text messages:
                auto textList = MsgUtils::splitUtf8String(m_Text, maxMsgSize);
                for (auto &&text : textList) {
@@ -405,7 +408,6 @@ std::vector<MessageRef> MsgSenderController::createMessage()
                        }
                }
        } else {
-               MSG_LOG("");
                // Create MMS:
                auto mms = msgEngine.getComposer().createMms();
                if (mms) {