diff options
author | Denis Dolzhenko <d.dolzhenko@samsung.com> | 2017-04-24 18:27:28 +0300 |
---|---|---|
committer | Denis Dolzhenko <d.dolzhenko@samsung.com> | 2017-04-25 11:09:03 +0300 |
commit | 97dc9026ef2bccb6f175c063441f967e448a1961 (patch) | |
tree | 972ae02dd22aabc262a8a1c3caaf4f710923a091 | |
parent | ecc8aae5e8d2a748f48611690e863fe64f3eeb4f (diff) | |
download | message-97dc9026ef2bccb6f175c063441f967e448a1961.tar.gz message-97dc9026ef2bccb6f175c063441f967e448a1961.tar.bz2 message-97dc9026ef2bccb6f175c063441f967e448a1961.zip |
TizenRefApp-8426 Implement text limit exceeded case
Change-Id: I72c933d5cc07a3cd9f51a831e3debc37f3e5c140
Signed-off-by: Denis Dolzhenko <d.dolzhenko@samsung.com>
-rw-r--r-- | .cproject | 6 | ||||
-rw-r--r-- | src/Common/MsgEngine/inc/MsgComposer.h | 11 | ||||
-rw-r--r-- | src/Common/MsgEngine/inc/MsgEngine.h | 7 | ||||
-rw-r--r-- | src/Common/MsgEngine/src/MsgEngine.cpp | 55 | ||||
-rw-r--r-- | src/Common/MsgEngine/src/MsgUtils.cpp | 5 | ||||
-rw-r--r-- | src/Common/MsgEngine/src/dummy/MsgComposerDummy.cpp | 5 | ||||
-rw-r--r-- | src/Common/MsgEngine/src/dummy/MsgComposerDummy.h | 1 | ||||
-rw-r--r-- | src/Common/MsgEngine/src/private/MsgComposerPrivate.cpp | 81 | ||||
-rw-r--r-- | src/Common/MsgEngine/src/private/MsgComposerPrivate.h | 12 | ||||
-rw-r--r-- | src/Common/MsgEngine/src/private/MsgTransportPrivate.cpp | 1 | ||||
-rw-r--r-- | src/Common/View/inc/BasePopup.h | 5 | ||||
-rw-r--r-- | src/Common/View/src/BasePopup.cpp | 11 | ||||
-rw-r--r-- | src/Common/View/src/PopupManager.cpp | 3 | ||||
-rw-r--r-- | src/Composer/Controller/inc/MsgBodyFrame.h | 25 | ||||
-rw-r--r-- | src/Composer/Controller/src/MsgBodyFrame.cpp | 151 | ||||
-rw-r--r-- | src/MsgThread/Controller/inc/ThreadList.h | 3 | ||||
-rw-r--r-- | src/MsgThread/Controller/src/MsgThreadFrame.cpp | 2 | ||||
-rw-r--r-- | src/MsgThread/Controller/src/ThreadList.cpp | 5 |
18 files changed, 282 insertions, 107 deletions
@@ -155,7 +155,9 @@ <listOptionValue builtIn="false" value="Native_API"/> </option> <option id="gnu.cpp.compiler.option.dialect.std.1756711526" name="Language standard" superClass="gnu.cpp.compiler.option.dialect.std" useByScannerDiscovery="true" value="gnu.cpp.compiler.dialect.c++11" valueType="enumerated"/> - <option id="gnu.cpp.compiler.option.preprocessor.def.1776859471" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" useByScannerDiscovery="false" valueType="definedSymbols"/> + <option id="gnu.cpp.compiler.option.preprocessor.def.1776859471" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" useByScannerDiscovery="false" valueType="definedSymbols"> + <listOptionValue builtIn="false" value="MSG_PRIVATE_API"/> + </option> <option id="gnu.cpp.compiler.option.other.other.1256197611" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -Wno-extern-c-compat" valueType="string"/> <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1529131313" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> </tool> @@ -469,7 +471,7 @@ <listOptionValue builtIn="false" value="Native_API"/> </option> <option id="gnu.cpp.compiler.option.dialect.std.177145679" name="Language standard" superClass="gnu.cpp.compiler.option.dialect.std" value="gnu.cpp.compiler.dialect.c++11" valueType="enumerated"/> - <option id="gnu.cpp.compiler.option.preprocessor.def.889877088" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols"/> + <option id="gnu.cpp.compiler.option.preprocessor.def.889877088" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def"/> <option id="gnu.cpp.compiler.option.other.other.645149247" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -Wno-extern-c-compat" valueType="string"/> <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1209285457" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/> </tool> diff --git a/src/Common/MsgEngine/inc/MsgComposer.h b/src/Common/MsgEngine/inc/MsgComposer.h index 9f9a3aa..8d08ac2 100644 --- a/src/Common/MsgEngine/inc/MsgComposer.h +++ b/src/Common/MsgEngine/inc/MsgComposer.h @@ -21,6 +21,9 @@ #include "MessageMms.h" #include "MsgUtils.h" #include "Logger.h" +#include "MsgTypes.h" + +#include <vector> namespace Msg { class MsgComposer { @@ -29,6 +32,14 @@ namespace Msg { virtual MessageSMSRef createSms() = 0; virtual MessageMmsRef createMms() = 0; + virtual std::vector<MessageRef> createMultiMessage(const std::string &text) = 0; + + /** + * @brief Calculates input text length by encode type. + * @param[in] text input text. + * @param[out] text metric. + **/ + virtual void calculateTextMetric(const std::string &text, MsgTextMetric &textMetric) = 0; MessageRef createMessage(Message::Type type); }; diff --git a/src/Common/MsgEngine/inc/MsgEngine.h b/src/Common/MsgEngine/inc/MsgEngine.h index 4072033..00fb908 100644 --- a/src/Common/MsgEngine/inc/MsgEngine.h +++ b/src/Common/MsgEngine/inc/MsgEngine.h @@ -80,13 +80,6 @@ namespace Msg { */ static std::string whatError(int error); - /** - * @brief Calculates input text length by encode type. - * @param[in] text input text. - * @param[out] text metric. - **/ - static void calculateTextMetric(const std::string &text, MsgTextMetric &textMetric); - private: std::unique_ptr<MsgStorage> m_Storage; std::unique_ptr<MsgTransport> m_Transport; diff --git a/src/Common/MsgEngine/src/MsgEngine.cpp b/src/Common/MsgEngine/src/MsgEngine.cpp index c123f0b..0e45d49 100644 --- a/src/Common/MsgEngine/src/MsgEngine.cpp +++ b/src/Common/MsgEngine/src/MsgEngine.cpp @@ -68,7 +68,7 @@ int MsgEngine::openService() m_Storage.reset(new MsgStoragePrivate(m_MsgHandle)); m_Transport.reset(new MsgTransportPrivate(m_MsgHandle)); - m_Composer.reset(new MsgComposerPrivate()); + m_Composer.reset(new MsgComposerPrivate(*this)); #elif MSG_PUBLIC_API // TODO: impl for public API @@ -431,56 +431,3 @@ std::string MsgEngine::whatError(int error) #endif return "SOME ANOTHER ERROR"; } - -void MsgEngine::calculateTextMetric(const std::string &text, MsgTextMetric &textMetric) -{ - textMetric.reset(); - -#ifdef MSG_PRIVATE_API - static const int maxGsm7Len = 160; - static const int maxUnicodeLen = 70; - static const int maxMmsLen = 180; // In bytes - int maxSmsLen = maxGsm7Len; // In chars - - msg_encode_type_t encode = MSG_ENCODE_GSM7BIT; - unsigned textLen = 0; - unsigned segmentLen = 0; - int bytesInChar = 1; - - if (!text.empty()) { - if (msg_util_calculate_text_length(text.c_str(), MSG_ENCODE_AUTO, &textLen, &segmentLen, &encode) != 0) { - MSG_LOG_ERROR("msg_util_calculate_text_length returns error"); - } - - switch (encode) - { - case MSG_ENCODE_UCS2: - bytesInChar = 2; - maxSmsLen = maxUnicodeLen; - break; - - case MSG_ENCODE_GSM7BIT: - case MSG_ENCODE_AUTO: - bytesInChar = 1; - maxSmsLen = maxGsm7Len; - break; - - default: - MSG_LOG_ERROR("Unknown encode type: ", encode); - break; - } - - textLen /= bytesInChar; - } - - if (textLen == 0) - textLen = text.length() / bytesInChar; - - textMetric.isMms = textLen > maxSmsLen; - textMetric.bytes = textLen * bytesInChar; - textMetric.textLen = textLen; - textMetric.maxLen = textMetric.isMms ? maxMmsLen : maxSmsLen; - - -#endif -} diff --git a/src/Common/MsgEngine/src/MsgUtils.cpp b/src/Common/MsgEngine/src/MsgUtils.cpp index da53637..dd86771 100644 --- a/src/Common/MsgEngine/src/MsgUtils.cpp +++ b/src/Common/MsgEngine/src/MsgUtils.cpp @@ -16,6 +16,7 @@ #include "MsgUtils.h" #include "LangUtils.h" +#include "Logger.h" #include <string.h> #include <ctype.h> @@ -173,13 +174,14 @@ std::list<std::string> splitUtf8String(const std::string &str, const int maxSize do { prevIndex = index; eina_unicode_utf8_next_get(str.c_str(), &index); + // FIXME: recognize graphemes bytes += index - prevIndex; if (bytes >= maxSize || index == size) { int from = startIndex; int to = 0; - if (bytes == maxSize || index == size) { + if (bytes <= maxSize) { to = index; } else { to = prevIndex; @@ -187,6 +189,7 @@ std::list<std::string> splitUtf8String(const std::string &str, const int maxSize } startIndex = index; std::string s(&str[from], &str[to]); + if (!s.empty() && s.size() <= maxSize) list.push_back(std::move(s)); bytes = 0; diff --git a/src/Common/MsgEngine/src/dummy/MsgComposerDummy.cpp b/src/Common/MsgEngine/src/dummy/MsgComposerDummy.cpp index b855537..aa3cd9b 100644 --- a/src/Common/MsgEngine/src/dummy/MsgComposerDummy.cpp +++ b/src/Common/MsgEngine/src/dummy/MsgComposerDummy.cpp @@ -47,6 +47,11 @@ MessageMmsRef MsgComposerDummy::createMms() return mmsRef; } +std::vector<MessageRef> MsgComposerDummy::createMultiMessage(const std::string &text) +{ + return {}; +} + void MsgComposerDummy::setSmilHeader(bool isTextTop) { } diff --git a/src/Common/MsgEngine/src/dummy/MsgComposerDummy.h b/src/Common/MsgEngine/src/dummy/MsgComposerDummy.h index 6997cc1..44b00ed 100644 --- a/src/Common/MsgEngine/src/dummy/MsgComposerDummy.h +++ b/src/Common/MsgEngine/src/dummy/MsgComposerDummy.h @@ -32,6 +32,7 @@ namespace Msg virtual MessageSMSRef createSms(); virtual MessageMmsRef createMms(); + virtual std::vector<MessageRef> createMultiMessage(const std::string &text); private: void setSmilHeader(bool isTextTop); diff --git a/src/Common/MsgEngine/src/private/MsgComposerPrivate.cpp b/src/Common/MsgEngine/src/private/MsgComposerPrivate.cpp index 82dc2a4..00d4d87 100644 --- a/src/Common/MsgEngine/src/private/MsgComposerPrivate.cpp +++ b/src/Common/MsgEngine/src/private/MsgComposerPrivate.cpp @@ -14,18 +14,23 @@ * limitations under the License. */ +#include "MsgEngine.h" #include "MsgComposerPrivate.h" #include "MessageSMSPrivate.h" #include "MessageMmsPrivate.h" #include "MsgUtilsPrivate.h" #include "MsgDefPrivate.h" +#include "MsgUtils.h" +#include "MsgEngine.h" +#include "Logger.h" #include <msg.h> using namespace Msg; -MsgComposerPrivate::MsgComposerPrivate() +MsgComposerPrivate::MsgComposerPrivate(MsgEngine &msgEngine) + : m_Engine(msgEngine) { } @@ -106,3 +111,77 @@ void MsgComposerPrivate::setSmilHeader(msg_struct_t mms, bool isTextTop) msg_set_int_value(imageRegion, MSG_MMS_REGION_LENGTH_HEIGHT_INT, smilRegionHeight); msg_set_bool_value(imageRegion, MSG_MMS_REGION_LENGTH_HEIGHT_PERCENT_BOOL, true); } + +std::vector<MessageRef> MsgComposerPrivate::createMultiMessage(const std::string &text) +{ + std::vector<MessageRef> msgList; + int maxMsgSize = m_Engine.getSettings().getMaxMmsSize(); + if (maxMsgSize <= 0) { + MSG_LOG_ERROR("getMaxMmsSize() returns 0"); + return {}; + } + + auto textList = MsgUtils::splitUtf8String(text, maxMsgSize); + + for (auto &&text : textList) { + MsgTextMetric metric; + calculateTextMetric(text, metric); + Message::Type type = metric.isMms ? Message::MT_MMS : Message::MT_SMS; + auto msg = createMessage(type); + if (msg) { + msg->setText(std::move(text)); + msgList.push_back(msg); + } + } + + return msgList; +} + +void MsgComposerPrivate::calculateTextMetric(const std::string &text, MsgTextMetric &textMetric) +{ + textMetric.reset(); + + static const int maxGsm7Len = 160; + static const int maxUnicodeLen = 70; + const int maxMmsLen = m_Engine.getSettings().getMaxMmsSize();; // In bytes + int maxSmsLen = maxGsm7Len; // In chars + + msg_encode_type_t encode = MSG_ENCODE_GSM7BIT; + unsigned textLen = 0; + unsigned segmentLen = 0; + int bytesInChar = 1; + + if (!text.empty()) { + if (msg_util_calculate_text_length(text.c_str(), MSG_ENCODE_AUTO, &textLen, &segmentLen, &encode) != 0) { + MSG_LOG_ERROR("msg_util_calculate_text_length returns error"); + } + + switch (encode) + { + case MSG_ENCODE_UCS2: + bytesInChar = 2; + maxSmsLen = maxUnicodeLen; + break; + + case MSG_ENCODE_GSM7BIT: + case MSG_ENCODE_AUTO: + bytesInChar = 1; + maxSmsLen = maxGsm7Len; + break; + + default: + MSG_LOG_ERROR("Unknown encode type: ", encode); + break; + } + + textLen /= bytesInChar; + } + + if (textLen == 0) + textLen = text.length() / bytesInChar; + + textMetric.isMms = textLen > maxSmsLen; + textMetric.bytes = textLen * bytesInChar; + textMetric.textLen = textLen; + textMetric.maxLen = textMetric.isMms ? maxMmsLen : maxSmsLen; +} diff --git a/src/Common/MsgEngine/src/private/MsgComposerPrivate.h b/src/Common/MsgEngine/src/private/MsgComposerPrivate.h index 8f6cda4..e6416f3 100644 --- a/src/Common/MsgEngine/src/private/MsgComposerPrivate.h +++ b/src/Common/MsgEngine/src/private/MsgComposerPrivate.h @@ -21,19 +21,25 @@ #include <msg_types.h> namespace Msg { + class MsgEngine; class MsgComposerPrivate : public MsgComposer { public: - MsgComposerPrivate(); + MsgComposerPrivate(MsgEngine &msgEngine); MsgComposerPrivate(MsgComposerPrivate&) = delete; MsgComposerPrivate &operator=(MsgComposerPrivate&) = delete; virtual ~MsgComposerPrivate(); - virtual MessageSMSRef createSms(); - virtual MessageMmsRef createMms(); + MessageSMSRef createSms() override; + MessageMmsRef createMms() override; + std::vector<MessageRef> createMultiMessage(const std::string &text) override; + void calculateTextMetric(const std::string &text, MsgTextMetric &textMetric) override; private: void setSmilHeader(msg_struct_t mms, bool isTextTop); + + private: + MsgEngine &m_Engine; }; } diff --git a/src/Common/MsgEngine/src/private/MsgTransportPrivate.cpp b/src/Common/MsgEngine/src/private/MsgTransportPrivate.cpp index f535f84..ce06f78 100644 --- a/src/Common/MsgEngine/src/private/MsgTransportPrivate.cpp +++ b/src/Common/MsgEngine/src/private/MsgTransportPrivate.cpp @@ -60,7 +60,6 @@ MsgTransport::SendResult MsgTransportPrivate::sendMessage(Message &msg, ThreadId msg_set_struct_handle(req, MSG_REQUEST_MESSAGE_HND, privMsg); - if (privMsg.isMms()) { MSG_LOG("Sending MMS"); err = msg_mms_send_message(m_ServiceHandle, req); diff --git a/src/Common/View/inc/BasePopup.h b/src/Common/View/inc/BasePopup.h index 4cdb496..08c6ff3 100644 --- a/src/Common/View/inc/BasePopup.h +++ b/src/Common/View/inc/BasePopup.h @@ -34,15 +34,20 @@ namespace Msg { void setDismissByOutsideTapFlag(bool value); bool getDismissByOutsideTapFlag() const; + void setDismissByPauseAppFlag(bool value); bool getDismissByPauseAppFlag() const; + void setDismissByBackButtonFlag(bool value); + bool getDismissByBackButtonFlag() const; + protected: static Evas_Object *getWindow(); private: bool m_OutsideTapDismiss; bool m_PauseAppDismiss; + bool m_BackButtonDismiss; }; } diff --git a/src/Common/View/src/BasePopup.cpp b/src/Common/View/src/BasePopup.cpp index ae31156..a326f65 100644 --- a/src/Common/View/src/BasePopup.cpp +++ b/src/Common/View/src/BasePopup.cpp @@ -24,6 +24,7 @@ using namespace Msg; BasePopup::BasePopup(Evas_Object *popup) : m_OutsideTapDismiss(false) , m_PauseAppDismiss(false) + , m_BackButtonDismiss(true) { setEo(popup); App::getInst().getPopupManager().push(*this); @@ -62,3 +63,13 @@ bool BasePopup::getDismissByPauseAppFlag() const { return m_PauseAppDismiss; } + +void BasePopup::setDismissByBackButtonFlag(bool value) +{ + m_BackButtonDismiss = value; +} + +bool BasePopup::getDismissByBackButtonFlag() const +{ + return m_BackButtonDismiss; +} diff --git a/src/Common/View/src/PopupManager.cpp b/src/Common/View/src/PopupManager.cpp index 0d69e3f..39a972c 100644 --- a/src/Common/View/src/PopupManager.cpp +++ b/src/Common/View/src/PopupManager.cpp @@ -76,7 +76,8 @@ BasePopup *PopupManager::getTop() const void PopupManager::onHwBackButtonClicked(Evas_Object *obj, void *eventInfo) { - pop(); + if (m_pPopup && m_pPopup->getDismissByBackButtonFlag()) + pop(); } void PopupManager::onPause() diff --git a/src/Composer/Controller/inc/MsgBodyFrame.h b/src/Composer/Controller/inc/MsgBodyFrame.h index 6cdc37d..73a5ab4 100644 --- a/src/Composer/Controller/inc/MsgBodyFrame.h +++ b/src/Composer/Controller/inc/MsgBodyFrame.h @@ -23,8 +23,11 @@ #include "Recipient.h" #include "MsgStorage.h" +#include <set> + namespace Msg { + class MsgEngine; class DefaultLayout; class IconTextPopup; class Popup; @@ -45,11 +48,25 @@ namespace Msg { void onHwBackButtonPreessed(Evas_Object *obj, void *event); private: + struct SendInfo { + SendInfo (); + void reset(); + std::vector<MessageRef> msgs; + std::set<RequestId> reqtIdSet; + Message::NetworkStatus status; + ThreadId threadId; + bool inProgress; + }; + void prepareLayout(); void prepareBody(); void updateTextCounter(); - void sendMsg(); - bool checkBeforeSend(const Message &msg); + std::vector<MessageRef> createMessage(); + void sendMessage(); + void requestSendMessage(); + void resetSendInfo(); + MsgEngine &getMsgEngine(); + bool checkBeforeSend(Message::Type type); void handleSendResult(const Message &msg, MsgTransport::SendResult result); bool read(Message &msg); bool readBody(Message &msg); @@ -68,6 +85,7 @@ namespace Msg { // Popup callback: void onSendingPopupDestroy(Evas *e, Evas_Object *obj, void *event_info); + void onSendingPopupBackButtonPressed(Evas_Object *obj, void *event_info); void onTurnOffFlightModeClicked(Popup &popup); void onAllowTransmissionTextLClicked(Popup &popup); void onEnableDataRoamingClicked(Popup &popup); @@ -91,8 +109,7 @@ namespace Msg { IconTextPopup *m_pSendingPopup; MsgTextMetric m_TextMetric; Recipient m_Recip; - ThreadId m_ThreadId; - RequestId m_ReqtId; + SendInfo m_SendInfo; }; } diff --git a/src/Composer/Controller/src/MsgBodyFrame.cpp b/src/Composer/Controller/src/MsgBodyFrame.cpp index 012e9c1..122bae9 100644 --- a/src/Composer/Controller/src/MsgBodyFrame.cpp +++ b/src/Composer/Controller/src/MsgBodyFrame.cpp @@ -25,9 +25,27 @@ #include "SystemSettingsManager.h" #include "PopupManager.h" #include "ConvFrame.h" +#include "MsgUtils.h" using namespace Msg; +MsgBodyFrame::SendInfo::SendInfo() + : reqtIdSet() + , status(Message::NS_Unknown) + , threadId() + , inProgress(false) +{ +} + +void MsgBodyFrame::SendInfo::reset() +{ + msgs.clear(); + inProgress = false; + reqtIdSet.clear(); + status = Message::NS_Unknown; + threadId.reset(); +} + MsgBodyFrame::MsgBodyFrame(NaviFrameController &parent, Recipient recip) : FrameController(parent) , m_pLayout(nullptr) @@ -39,13 +57,15 @@ MsgBodyFrame::MsgBodyFrame(NaviFrameController &parent, Recipient recip) MSG_LOG(""); prepareLayout(); prepareBody(); - App::getInst().getMsgEngine().getTransport().addListener(*this); + getMsgEngine().getTransport().addListener(*this); } MsgBodyFrame::~MsgBodyFrame() { MSG_LOG(""); - App::getInst().getMsgEngine().getTransport().removeListener(*this); + if (m_pSendingPopup) + m_pSendingPopup->destroy(); + getMsgEngine().getTransport().removeListener(*this); } void MsgBodyFrame::prepareLayout() @@ -72,7 +92,7 @@ void MsgBodyFrame::prepareBody() void MsgBodyFrame::updateTextCounter() { const std::string &text = m_pBody->getEntry().getText(); - App::getInst().getMsgEngine().calculateTextMetric(text, m_TextMetric); + getMsgEngine().getComposer().calculateTextMetric(text, m_TextMetric); m_TextMetric.isMms ? m_pBody->setCounter(msgt("WDS_MSG_SBODY_MMS_ABB")) : @@ -87,7 +107,7 @@ void MsgBodyFrame::handleSendResult(const Message &msg, MsgTransport::SendResult // TODO: impl. } -bool MsgBodyFrame::checkBeforeSend(const Message &msg) +bool MsgBodyFrame::checkBeforeSend(Message::Type type) { if (!App::getInst().getSysSettingsManager().isSimInserted()) { // TODO: popup for No SIM card @@ -99,7 +119,7 @@ bool MsgBodyFrame::checkBeforeSend(const Message &msg) return false; } - if (msg.isMms() && !App::getInst().getSysSettingsManager().isMobileDataEnabled()) { + if (MsgUtils::isMms(type) && !App::getInst().getSysSettingsManager().isMobileDataEnabled()) { showMobileNetworkSettingsPopup(); return false; } @@ -138,26 +158,63 @@ bool MsgBodyFrame::readAddress(Message &msg) return false; } -void MsgBodyFrame::sendMsg() +MsgEngine &MsgBodyFrame::getMsgEngine() { - auto msgRef = App::getInst().getMsgEngine().getComposer().createMessage(m_TextMetric.isMms ? Message::MT_MMS : Message::MT_SMS); - if (!msgRef) - return; + return App::getInst().getMsgEngine(); +} - Message &msg = *msgRef; +std::vector<MessageRef> MsgBodyFrame::createMessage() +{ + const std::string &text = m_pBody->getEntry().getText(); + std::vector<MessageRef> msgList = getMsgEngine().getComposer().createMultiMessage(text); - if (!read(msg) || !checkBeforeSend(msg)) + for (MessageRef &msg : msgList) { + readAddress(*msg); + } + + return msgList; +} + +void MsgBodyFrame::requestSendMessage() +{ + m_SendInfo.reset(); + + m_SendInfo.msgs = createMessage(); + if (m_SendInfo.msgs .empty()) return; - MsgTransport::SendResult sendRes = App::getInst().getMsgEngine().getTransport().sendMessage(msg, &m_ThreadId, &m_ReqtId); - MSG_LOG("Send result = ", sendRes); - MSG_LOG("Request id = ", m_ReqtId); + if (!checkBeforeSend(m_SendInfo.msgs [0]->getType())) + return; + + sendMessage(); +} + +void MsgBodyFrame::sendMessage() +{ + MsgTransport::SendResult sendRes = MsgTransport::SendFail; + MessageRef lastSentMsg; + + for (MessageRef msg : m_SendInfo.msgs) { + lastSentMsg = msg; + RequestId reqId; + sendRes = getMsgEngine().getTransport().sendMessage(msg, &m_SendInfo.threadId, &reqId); + + MSG_LOG("Send result = ", sendRes); + MSG_LOG("Request id = ", reqId); + + if (sendRes != MsgTransport::SendSuccess) + break; - if (sendRes == MsgTransport::SendSuccess && m_ThreadId.isValid()) { + m_SendInfo.inProgress = true; + m_SendInfo.reqtIdSet.insert(reqId); + } + + if (sendRes == MsgTransport::SendSuccess && m_SendInfo.threadId.isValid()) { m_pBody->getEntry().clear(); showSendingProgressPopup(); } else { - handleSendResult(msg, sendRes); + if (lastSentMsg) + handleSendResult(*lastSentMsg, sendRes); } } @@ -168,14 +225,14 @@ void MsgBodyFrame::navigateAfterSent() if (!App::getInst().isTerminating()) { // Navigate to ConvFrame - if (m_ThreadId.isValid()) { - ConvFrame *conv = getParent().getTopFrame<ConvFrame>(); + if (m_SendInfo.threadId.isValid()) { + auto *conv = getParent().getTopFrame<ConvFrame>(); if (!conv) { conv = new ConvFrame(getParent()); - conv->setThreadId(m_ThreadId); + conv->setThreadId(m_SendInfo.threadId); getParent().push(*conv); } else { - conv->setThreadId(m_ThreadId); + conv->setThreadId(m_SendInfo.threadId); getParent().promote(*conv); } } @@ -209,7 +266,9 @@ void MsgBodyFrame::showSendingProgressPopup() { if (!m_pSendingPopup) { m_pSendingPopup = new IconTextPopup; + m_pSendingPopup->setDismissByBackButtonFlag(false); m_pSendingPopup->addEventCb(EVAS_CALLBACK_DEL, makeCbFirst(&MsgBodyFrame::onSendingPopupDestroy), this); + m_pSendingPopup->addHwButtonEvent(EEXT_CALLBACK_BACK, makeCbFirst(&MsgBodyFrame::onSendingPopupBackButtonPressed), this); m_pSendingPopup->setIcon(IconTextPopup::ProgressIcon); m_pSendingPopup->setText(msgt("IDS_MSG_BODY_SENDING_ING_M_STATUS_ABB")); m_pSendingPopup->show(); @@ -228,7 +287,7 @@ void MsgBodyFrame::showMmsTextLimitExceededPopup() { auto *popup = new StandardPopup(StandardPopup::buttons2Style); // TODO: remove later - int numberOfCharacters = 2048; + int numberOfCharacters = getMsgEngine().getSettings().getMaxMmsSize(); int numberOfMmsMsg = 2; std::string popupMessage = msgArgs("WDS_MSG_BODY_MAXIMUM_NUMBER_OF_CHARACTERS_HPD_EXCEEDED", numberOfCharacters); @@ -266,6 +325,18 @@ void MsgBodyFrame::onSendingPopupDestroy(Evas *e, Evas_Object *obj, void *event_ m_pSendingPopup = nullptr; } +void MsgBodyFrame::onSendingPopupBackButtonPressed(Evas_Object *obj, void *event_info) +{ + MSG_LOG(""); + if (m_pSendingPopup) + m_pSendingPopup->destroy(); + + if (m_SendInfo.inProgress) { + m_SendInfo.reset(); + getParent().popGroup(*this); + } +} + void MsgBodyFrame::onTurnOffFlightModeClicked(Popup &popup) { MSG_LOG(""); @@ -322,13 +393,13 @@ void MsgBodyFrame::onEntryChanged(Evas_Object *obj, void *event) void MsgBodyFrame::onEntryActivated(Evas_Object *obj, void *event) { MSG_LOG(""); - sendMsg(); + requestSendMessage(); } void MsgBodyFrame::onSendButtonClicked() { MSG_LOG(""); - sendMsg(); + requestSendMessage(); } void MsgBodyFrame::onEntryFilter(Evas_Object *obj, char **text) @@ -350,19 +421,45 @@ void MsgBodyFrame::onMsgTransportSentStatus(const MsgSentStatus &status) MSG_LOG("Id = ", id); MSG_LOG("Network status = ", networkStatus); - if (m_pSendingPopup && m_ReqtId == id && networkStatus != Message::NS_Sending) { - if (networkStatus == Message::NS_Send_Success) { + auto reqIdIt = m_SendInfo.reqtIdSet.find(id); + bool reqFound = reqIdIt != m_SendInfo.reqtIdSet.end(); + + // Skip unknown request + if (!reqFound) + return; + + if (networkStatus == Message::NS_Sending) + return; + + m_SendInfo.reqtIdSet.erase(reqIdIt); + bool isLast = m_SendInfo.reqtIdSet.empty(); + + if (networkStatus == Message::NS_Send_Fail) + m_SendInfo.status = Message::NS_Send_Fail; + else if (networkStatus == Message::NS_Send_Pending && m_SendInfo.status != Message::NS_Send_Fail) + m_SendInfo.status = Message::NS_Send_Pending; + else if (m_SendInfo.status == Message::NS_Unknown) + m_SendInfo.status = networkStatus; + + if (isLast || m_SendInfo.status == Message::NS_Send_Fail) { + + m_SendInfo.inProgress = false; + m_SendInfo.reqtIdSet.clear(); + + if (m_SendInfo.status == Message::NS_Send_Success) { m_pSendingPopup->setIcon(IconTextPopup::CheckIcon); m_pSendingPopup->setText(msgt("WDS_WNOTI_TPOP_SENT_ABB")); m_pSendingPopup->setTimeOut(); - } else if (networkStatus == Message::NS_Send_Fail) { + } else if (m_SendInfo.status == Message::NS_Send_Fail) { m_pSendingPopup->setIcon(IconTextPopup::FailedIcon); m_pSendingPopup->setText(msgt("WDS_MSG_TPOP_SENDING_FAILED_ABB")); m_pSendingPopup->setTimeOut(); - } else if (networkStatus != Message::NS_Send_Pending) { + } else if (m_SendInfo.status != Message::NS_Send_Pending) { m_pSendingPopup->destroy(); showSentWhenServiceBecomesAvailablePopup(); } + navigateAfterSent(); + m_SendInfo.reset(); } } diff --git a/src/MsgThread/Controller/inc/ThreadList.h b/src/MsgThread/Controller/inc/ThreadList.h index db9d57f..81363b5 100644 --- a/src/MsgThread/Controller/inc/ThreadList.h +++ b/src/MsgThread/Controller/inc/ThreadList.h @@ -43,7 +43,7 @@ namespace Msg { , private IThreadComposeListViewItemListener { public: - ThreadList(DefaultLayout *parent); + ThreadList(DefaultLayout &parent); virtual ~ThreadList(); void setListener(IThreadListListener *l); @@ -97,7 +97,6 @@ namespace Msg { PaddingListViewItem *m_pTopPadItem; PaddingListViewItem *m_pBottomPadItem; NoContentListViewItem *m_pNoContentItem; - DefaultLayout *m_pParentLayout; }; class IThreadListListener { diff --git a/src/MsgThread/Controller/src/MsgThreadFrame.cpp b/src/MsgThread/Controller/src/MsgThreadFrame.cpp index 1c1988d..c87132a 100644 --- a/src/MsgThread/Controller/src/MsgThreadFrame.cpp +++ b/src/MsgThread/Controller/src/MsgThreadFrame.cpp @@ -101,7 +101,7 @@ void MsgThreadFrame::setDeleteMode(bool value) void MsgThreadFrame::prepareThreadList() { if (!m_pThreadList) { - m_pThreadList = new ThreadList(m_pLayout); + m_pThreadList = new ThreadList(*m_pLayout); m_pThreadList->setListener(this); m_pLayout->setContent(*m_pThreadList); m_pLayout->showContent(true); diff --git a/src/MsgThread/Controller/src/ThreadList.cpp b/src/MsgThread/Controller/src/ThreadList.cpp index 9579f01..f1c47a5 100644 --- a/src/MsgThread/Controller/src/ThreadList.cpp +++ b/src/MsgThread/Controller/src/ThreadList.cpp @@ -34,8 +34,8 @@ namespace { } } -ThreadList::ThreadList(DefaultLayout *parent) - : ListView(*parent, App::getInst().getWindow().getCircleSurface()) +ThreadList::ThreadList(DefaultLayout &parent) + : ListView(parent, App::getInst().getWindow().getCircleSurface()) , m_pListener(nullptr) , m_App(App::getInst()) , m_DeleteMode(false) @@ -43,7 +43,6 @@ ThreadList::ThreadList(DefaultLayout *parent) , m_pTopPadItem(nullptr) , m_pBottomPadItem(nullptr) , m_pNoContentItem(nullptr) - , m_pParentLayout(parent) { ListView::setListener(this); ListView::setHomogeneous(false); |