From f5b0bdf3dfd038074170cfe41c56967e73be50e7 Mon Sep 17 00:00:00 2001 From: Oleksander Kostenko Date: Wed, 6 Jan 2016 15:53:12 +0200 Subject: [PATCH] TizenRefApp-5263 Implement support of SHARE operation TizenRefApp-5266 Implement support of SHARE_TEXT operation TizenRefApp-5264 Implement support of MULTI_SHARE operation Change-Id: I1923e7d711baa4a72b019369b11368269023c49a Signed-off-by: Oleksander Kostenko --- src/Common/AppControl/inc/AppControlCompose.h | 8 +- src/Common/AppControl/src/AppControlCompose.cpp | 127 +++++++++++++++++++----- 2 files changed, 110 insertions(+), 25 deletions(-) diff --git a/src/Common/AppControl/inc/AppControlCompose.h b/src/Common/AppControl/inc/AppControlCompose.h index d9a1ee3..63d0f82 100644 --- a/src/Common/AppControl/inc/AppControlCompose.h +++ b/src/Common/AppControl/inc/AppControlCompose.h @@ -79,7 +79,13 @@ namespace Msg const FileList &getFileList() const; private: - bool parseUri(const char *uri); + bool parseUriCompose(app_control_h handle); + bool parseUriShare(app_control_h handle); + + void createComposeOp(app_control_h handle); + void createShareOp(app_control_h handle); + void createMultiShareOp(app_control_h handle); + void createShareTextOp(app_control_h handle); private: OpComposeType m_ComposeType; diff --git a/src/Common/AppControl/src/AppControlCompose.cpp b/src/Common/AppControl/src/AppControlCompose.cpp index f354575..be99eba 100644 --- a/src/Common/AppControl/src/AppControlCompose.cpp +++ b/src/Common/AppControl/src/AppControlCompose.cpp @@ -49,17 +49,24 @@ AppControlCompose::AppControlCompose(const std::string &opMsg, app_control_h han { if(handle) { - char *uri = NULL; - if(APP_CONTROL_ERROR_NONE == app_control_get_uri(handle, &uri)) + switch(m_ComposeType) { - parseUri(uri); - free(uri); + case OpCompose: + createComposeOp(handle); + break; + case OpShare: + createShareOp(handle); + break; + case OpMultiShare: + createMultiShareOp(handle); + break; + case OpShareText: + createShareTextOp(handle); + break; + case OpUnknown: + MSG_LOG_ERROR("Invalid op-type") + break; } - - AppControlUtils::getExtraDataArray(handle, APP_CONTROL_DATA_TO, m_RecipientList); - m_MessageText = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_TEXT); - m_Subject = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_SUBJECT); - AppControlUtils::getExtraDataArray(handle, APP_CONTROL_DATA_PATH, m_FileList); } } @@ -67,6 +74,38 @@ AppControlCompose::~AppControlCompose() { } +void AppControlCompose::createComposeOp(app_control_h handle) +{ + parseUriCompose(handle); + if (m_RecipientList.empty()) + { + AppControlUtils::getExtraDataArray(handle, APP_CONTROL_DATA_TO, m_RecipientList); + } + m_MessageText = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_TEXT); + m_Subject = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_SUBJECT); + AppControlUtils::getExtraDataArray(handle, APP_CONTROL_DATA_PATH, m_FileList); +} +void AppControlCompose::createShareOp(app_control_h handle) +{ + parseUriShare(handle); + if (m_FileList.empty()) + { + m_FileList.push_back(AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_PATH)); + } +} +void AppControlCompose::createMultiShareOp(app_control_h handle) +{ + AppControlUtils::getExtraDataArray(handle, APP_CONTROL_DATA_PATH, m_FileList); + parseUriShare(handle); +} +void AppControlCompose::createShareTextOp(app_control_h handle) +{ + parseUriShare(handle); + m_MessageText = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_TEXT); + m_Subject = AppControlUtils::getExtraData(handle, APP_CONTROL_DATA_SUBJECT); + AppControlUtils::getExtraDataArray(handle, APP_CONTROL_DATA_PATH, m_FileList); +} + AppControlCompose::OpComposeType AppControlCompose::getComposeType() const { return m_ComposeType; @@ -94,32 +133,72 @@ const AppControlCompose::FileList &AppControlCompose::getFileList() const return m_FileList; } - -bool AppControlCompose::parseUri(const char *uri) +bool AppControlCompose::parseUriCompose(app_control_h handle) { TRACE; bool res = false; - if(uri) + char *uri = nullptr; + + if (APP_CONTROL_ERROR_NONE == app_control_get_uri(handle, &uri)) { - MSG_LOG("uri = ", uri); - std::string uriToParse(uri); - std::istringstream is(uriToParse); + if (uri) + { + MSG_LOG("uri = ", uri); + std::string uriToParse(uri); + std::istringstream is(uriToParse); - std::string cur; - std::getline(is, cur, ':'); - MSG_LOG("cur = ", cur.c_str()); + std::string cur; + std::getline(is, cur, ':'); + MSG_LOG("cur = ", cur.c_str()); - if(cur == "sms" || cur == "mmsto") - { - m_isMms = (cur == "mmsto"); - for( ;std::getline(is, cur, ','); ) + if (cur == "sms" || cur == "mmsto") { - m_RecipientList.push_back(cur); + m_isMms = (cur == "mmsto"); + for (; std::getline(is, cur, ',');) + { + m_RecipientList.push_back(cur); + } + res = true; } - res = true; } + free(uri); + } + + return res; +} + +bool AppControlCompose::parseUriShare(app_control_h handle) +{ + TRACE; + bool res = false; + char *uri = nullptr; + + if (APP_CONTROL_ERROR_NONE == app_control_get_uri(handle, &uri)) + { + if (uri) + { + MSG_LOG("uri = ", uri); + std::string uriToParse(uri); + std::istringstream is(uriToParse); + + std::string cur; + std::getline(is, cur, ':'); + MSG_LOG("cur = ", cur.c_str()); + if (cur == "sms" || cur == "mmsto" || cur == "file") + { + m_isMms = (cur == "mmsto" || cur == "file"); + if (cur == "file" && m_FileList.empty()) + { + std::string prefix("file://"); + m_FileList.push_back(uriToParse.erase(0, prefix.length())); + } + res = true; + } + } + free(uri); } + return res; } -- 2.7.4