void ConvListItem::showFailedToSendPopup()
{
Popup &popup = m_App.getPopupManager().getPopup();
- popup.addEventCb(EVAS_CALLBACK_DEL, EVAS_EVENT_CALLBACK(ConvListItem, onPopupDel), this);
popup.addButton(msgt("IDS_MSG_BUTTON_CANCEL_ABB"), Popup::CancelButtonId, POPUP_BUTTON_CB(ConvListItem, onCancelButtonClicked), this);
popup.addButton(msgt("IDS_MSG_BUTTON_RESEND_ABB"), Popup::OkButtonId, POPUP_BUTTON_CB(ConvListItem, onFailedResendButtonClicked), this);
popup.setTitle(msgt("IDS_MSG_HEADER_COULDNT_SEND_MESSAGE_ABB"));
{
item.getParent().destroy();
Popup &popup = m_App.getPopupManager().getPopup();
- popup.addEventCb(EVAS_CALLBACK_DEL, EVAS_EVENT_CALLBACK(ConvListItem, onPopupDel), this);
popup.addButton(msgt("IDS_MSG_BUTTON_CANCEL_ABB"), Popup::CancelButtonId, POPUP_BUTTON_CB(ConvListItem, onCancelButtonClicked), this);
popup.addButton(msgt("IDS_MSG_BUTTON_DELETE_ABB4"), Popup::OkButtonId, POPUP_BUTTON_CB(ConvListItem, onDeleteButtonClicked), this);
popup.setTitle(msgt("IDS_MSG_HEADER_DELETE"));
void ConvListItem::onFailedResendButtonClicked(Popup &popup, int buttonId)
{
MSG_LOG("");
- MessageRef msg = m_App.getMsgEngine().getStorage().getMessage(m_MsgId);
- if(msg)
- m_App.getMsgEngine().getTransport().sendMessage(msg);
-
popup.destroy();
+ if(m_pListener)
+ m_pListener->onResendMsg(*this);
}
void ConvListItem::onDeleteButtonClicked(Popup &popup, int buttonId)
m_App.getMsgEngine().getStorage().deleteMessage(getMsgId());
popup.destroy();
}
-
-void ConvListItem::onPopupDel(Evas_Object *popup, void *eventInfo)
-{
- MSG_LOG("");
-}
virtual void onAllConvItemsDeleted(ConvList &list);
virtual void onEditDraftMsg(MsgId id);
virtual void onForwardMsg(MsgId id);
+ virtual void onResendMsg(MsgId id);
virtual void onSlideShow(MsgId id);
virtual void onConvListItemChecked();
void showMainPopup();
void showNoRecipPopup();
PopupList &createPopupList(const std::string &title);
- void showSendResultPopup(MsgTransport::SendResult result);
void showMobileDataPopup();
+ void showSendDpmNotif(const MsgAddressList &addressList);
void showUnsavedRecipientPopup(const std::string &address);
void showSavedRecipientPopup(const std::string &title, int contactId, ContactAddress::OwnerType ownerType);
+ void sendMessage(MsgId msgId);
void sendMessage();
+ bool checkBeforeSend(const Message &msg);
+ void handleSendResult(const Message &msg, MsgTransport::SendResult result);
bool read(Message &msg);
bool readMsgAddress(Message &msg);
void write(const Message &msg);
return std::to_string(sizeKb) + " " + (std::string)msg("IDS_MSGF_BODY_MSGSIZE_KB");
}
+namespace
+{
+ std::string makeDispAddress(std::string address, std::string dispName)
+ {
+ if(dispName.empty())
+ return std::move(address);
+ std::string res = std::move(dispName);
+ res += " (";
+ res += std::move(address) + ')';
+ return res;
+ }
+}
+
Conversation::Conversation(NaviFrameController &parent)
: FrameController(parent)
, m_Mode(InitMode)
return res;
}
-void Conversation::sendMessage()
+void Conversation::handleSendResult(const Message &msg, MsgTransport::SendResult result)
{
- if(m_pRecipPanel &&
- m_pRecipPanel->getEntryFocus() &&
- !m_pRecipPanel->getEntryText().empty() &&
- !m_pRecipPanel->addRecipientsFromEntry())
+ if(result == MsgTransport::SendSuccess)
+ return;
+
+ const char *strId = nullptr;
+ switch(result)
+ {
+ case MsgTransport::SendNoSIM:
+ strId = "IDS_MSG_BODY_UNABLE_TO_SEND_THIS_MESSAGE_INSERT_YOUR_SIM_CARD_AND_TRY_AGAIN";
+ break;
+ case MsgTransport::SendDPMRestricted:
+ showSendDpmNotif(msg.getAddressList());
return;
+ default:
+ strId = "IDS_MSGC_BODY_UNABLE_TO_SEND_MESSAGE";
+ };
+ auto &popupMngr = getApp().getPopupManager();
+ Popup &popup = popupMngr.getPopup();
+ popup.addButton(msgt("IDS_MSG_BUTTON_OK_ABB"), Popup::OkButtonId, POPUP_BUTTON_CB(Conversation, onMsgSendErrorButtonClicked), this);
+ popup.setContent(msgt(strId));
+ popup.show();
+}
+bool Conversation::checkBeforeSend(const Message &msg)
+{
if(!getApp().getSysSettingsManager().isSimInserted())
{
- showSendResultPopup(MsgTransport::SendNoSIM);
- return;
+ handleSendResult(msg, MsgTransport::SendNoSIM); // Show no SIM card
+ return false;
}
- if(m_IsMms && !getApp().getSysSettingsManager().isMobileDataEnabled())
+ if(msg.isMms() && !getApp().getSysSettingsManager().isMobileDataEnabled())
{
showMobileDataPopup();
- return;
+ return false;
}
- auto msg = getMsgEngine().getComposer().createMessage(m_IsMms ? Message::MT_MMS : Message::MT_SMS);
+ return true;
+}
+
+void Conversation::sendMessage(MsgId msgId)
+{
+ MessageRef msg = getMsgEngine().getStorage().getMessage(msgId);
+ if(msg && checkBeforeSend(*msg))
+ {
+ auto sentRes = getMsgEngine().getTransport().sendMessage(msg);
+ handleSendResult(*msg, sentRes);
+ }
+}
+
+void Conversation::sendMessage()
+{
+ if(m_pRecipPanel &&
+ m_pRecipPanel->getEntryFocus() &&
+ !m_pRecipPanel->getEntryText().empty() &&
+ !m_pRecipPanel->addRecipientsFromEntry())
+ return;
- if(!read(*msg))
+ auto msg = getMsgEngine().getComposer().createMessage(m_IsMms ? Message::MT_MMS : Message::MT_SMS);
+ if(!msg || !read(*msg) || !checkBeforeSend(*msg))
return;
MSG_LOG("Old threadId = ", m_ThreadId);
}
else
{
- showSendResultPopup(sendRes);
+ handleSendResult(*msg, sendRes);
}
if(m_pListener)
return popup;
}
+void Conversation::showSendDpmNotif(const MsgAddressList &addressList)
+{
+ int len = addressList.getLength();
+ std::string addresses;
+
+ for(int i = 0; i < len; ++i)
+ {
+ std::string address = addressList[i].getAddress();
+ std::string dispName;
+ if(!address.empty())
+ {
+ ContactAddressRef rec = getApp().getContactManager().getContactAddress(address);
+ if(rec)
+ dispName = rec->getDispName();
+ addresses += makeDispAddress(address, dispName);
+ if(i < len - 1)
+ addresses += "<br/>";
+ }
+ }
+
+ if(len <= 1)
+ {
+ std::string text = msgArgs("IDS_MSG_POP_THE_SECURITY_POLICY_PREVENTS_SENDING_MESSAGES_TO_PS", addresses.c_str());
+ notification_status_message_post(text.c_str());
+ }
+ else
+ {
+ std::string text = msgArgs("IDS_MSG_POP_THE_SECURITY_POLICY_PREVENTS_SENDING_MESSAGES_TO_THE_FOLLOWING_RECIPIENTS_C_NPS", addresses.c_str());
+ auto &popupMngr = getApp().getPopupManager();
+ Popup &popup = popupMngr.getPopup();
+ popup.addButton(msgt("IDS_MSG_BUTTON_OK_ABB"), Popup::OkButtonId);
+ popup.setContent(text);
+ popup.show();
+ }
+}
+
void Conversation::showNoRecipPopup()
{
Popup &popup = getApp().getPopupManager().getPopup();
popup.show();
}
-void Conversation::showSendResultPopup(MsgTransport::SendResult result)
-{
- if(result == MsgTransport::SendSuccess)
- return;
-
- const char *strId = nullptr;
- switch(result)
- {
- case MsgTransport::SendNoSIM:
- strId = "IDS_MSG_BODY_UNABLE_TO_SEND_THIS_MESSAGE_INSERT_YOUR_SIM_CARD_AND_TRY_AGAIN";
- break;
- case MsgTransport::SendDPMRestricted:
- strId = "IDS_MSG_POP_THE_SECURITY_POLICY_PREVENTS_THE_USE_OF_SMS_MMS";
- break;
- default:
- strId = "IDS_MSGC_BODY_UNABLE_TO_SEND_MESSAGE";
- };
-
- auto &popupMngr = getApp().getPopupManager();
- Popup &popup = popupMngr.getPopup();
- popup.addEventCb(EVAS_CALLBACK_DEL, EVAS_EVENT_CALLBACK(Conversation, onPopupDel), this);
- popup.addButton(msgt("IDS_MSG_BUTTON_OK_ABB"), Popup::OkButtonId, POPUP_BUTTON_CB(Conversation, onMsgSendErrorButtonClicked), this);
- popup.setContent(msgt(strId));
- popup.show();
-}
-
void Conversation::showMobileDataPopup()
{
auto &popupMngr = getApp().getPopupManager();
forwardMsg(id);
}
+void Conversation::onResendMsg(MsgId id)
+{
+ MSG_LOG("");
+ sendMessage(id);
+}
+
void Conversation::onSlideShow(MsgId id)
{
MSG_LOG("");