From 3d93f4f8608cbb3b3992232697a062d4e59d3979 Mon Sep 17 00:00:00 2001 From: Denis Dolzhenko Date: Mon, 23 Oct 2017 14:49:20 +0300 Subject: TizenRefApp-9668 Implement image sending Change-Id: Ia8f288456a3c1430e53378b02d5896c7f2371fbb Signed-off-by: Denis Dolzhenko --- src/Common/AppControl/inc/InputSelector.h | 1 + src/Common/AppControl/src/InputSelector.cpp | 5 ++++- src/Composer/Controller/inc/MsgInputController.h | 1 + src/Composer/Controller/src/MsgInputController.cpp | 22 +++++++++++++--------- .../Controller/src/MsgSenderController.cpp | 16 +++++++++------- 5 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/Common/AppControl/inc/InputSelector.h b/src/Common/AppControl/inc/InputSelector.h index 103f44b..2b9063a 100644 --- a/src/Common/AppControl/inc/InputSelector.h +++ b/src/Common/AppControl/inc/InputSelector.h @@ -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 &filePath) {}; + virtual void onImageReply(const std::list &filePath) {}; virtual void onEmoticonReply(const std::string &emoticon) {}; }; } diff --git a/src/Common/AppControl/src/InputSelector.cpp b/src/Common/AppControl/src/InputSelector.cpp index a62a65a..c8991fe 100644 --- a/src/Common/AppControl/src/InputSelector.cpp +++ b/src/Common/AppControl/src/InputSelector.cpp @@ -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); } } } diff --git a/src/Composer/Controller/inc/MsgInputController.h b/src/Composer/Controller/inc/MsgInputController.h index 87f832e..26e4853 100644 --- a/src/Composer/Controller/inc/MsgInputController.h +++ b/src/Composer/Controller/inc/MsgInputController.h @@ -68,6 +68,7 @@ namespace Msg { void onKeyboardReply(const std::string &text, int cursorPos) override; void onVoiceReply(const std::string &text, const std::list &fileList) override; void onEmoticonReply(const std::string &emoticon) override; + void onImageReply(const std::list &fileList) override; void onTerminate(InputSelector &) override; private: diff --git a/src/Composer/Controller/src/MsgInputController.cpp b/src/Composer/Controller/src/MsgInputController.cpp index ac8722d..1717404 100644 --- a/src/Composer/Controller/src/MsgInputController.cpp +++ b/src/Composer/Controller/src/MsgInputController.cpp @@ -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 &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 &fileList) +{ + MSG_LOG(""); + m_InputData.files = fileList; notifyOnSendRequest(); } diff --git a/src/Composer/Controller/src/MsgSenderController.cpp b/src/Composer/Controller/src/MsgSenderController.cpp index 592950b..b870377 100644 --- a/src/Composer/Controller/src/MsgSenderController.cpp +++ b/src/Composer/Controller/src/MsgSenderController.cpp @@ -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 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 MsgSenderController::createMessage() } } } else { - MSG_LOG(""); // Create MMS: auto mms = msgEngine.getComposer().createMms(); if (mms) { -- cgit v1.2.3