using namespace Msg;
-// TODO: move to common part
-std::string makeKbStr(long long bytes)
-{
- const long long kb = 1000; // Bytes in kb
- long long sizeKb = 0;
- if(bytes <= kb)
- {
- sizeKb = 1;
- }
- else
- {
- sizeKb = bytes / kb;
- long long sizeB = bytes % kb;
- if(sizeB >= (kb / 2))
- ++sizeKb;
- }
- return std::to_string(sizeKb) + " " + (std::string)msg("IDS_MSGF_BODY_MSGSIZE_KB");
-}
-
namespace
{
std::string makeDispAddress(std::string address, std::string dispName)
void Conversation::create()
{
m_WorkingDir = std::make_shared<WorkingDir>();
- createMainLayout(getParent());
- createConvList(*m_pLayout);
- createMsgInputPanel(*m_pLayout, *m_pConvList);
-
+ createMainLayout();
+ showConvList(true);
getApp().getContactManager().addListener(*this);
getApp().getSysSettingsManager().addListener(*this);
- setHwButtonListener(*m_pLayout, this);
m_AttachPanel.setListener(this);
}
{
MSG_LOG("");
MSG_ASSERT(m_Mode != InitMode, "m_Mode is in initial state");
+
ContactAddressRef contactAddress = getApp().getContactManager().getContactAddress(address);
if(contactAddress)
{
m_AddressList.reset();
setMode(m_ThreadId.isValid() ? ConversationMode : NewMessageMode);
+ showMsgInputPanel(!isHiddenAddress());
if(m_pBody)
m_pBody->setMmsRecipFlag(getMsgEngine().getStorage().hasEmail(m_ThreadId));
setThreadId(ThreadId(), "", updateConvList, updateRecipPanel);
}
+bool Conversation::isHiddenAddress() const
+{
+ if(m_AddressList && !m_AddressList->isEmpty())
+ {
+ std::string addr = m_AddressList->at(0).getAddress();
+ return !MsgUtils::isValidAddress(addr);
+ }
+ return false;
+}
+
void Conversation::setListener(IConversationListener *listener)
{
m_pListener = listener;
m_Mode = NewMessageMode;
m_pLayout->showRecipEditMode(true);
- createRecipPanel(*m_pLayout);
- createContactList(*m_pLayout);
+ showMsgInputPanel(true);
+ showRecipPanel(true);
+ showContactList(true);
m_pRecipPanel->update(m_ThreadId);
m_pRecipPanel->showMbe(!m_pRecipPanel->isMbeEmpty());
m_pRecipPanel->showEntry(true);
MsgAddressListRef addressList = getAddressList();
if(addressList && addressList->getLength() > 1)
{
- createRecipPanel(*m_pLayout);
+ showRecipPanel(true);
m_pRecipPanel->showEntry(false);
m_pRecipPanel->update(addressList);
}
else
{
- destroyRecipPanel();
+ showRecipPanel(false);
}
- destroyContactList();
+ showContactList(false);
}
-void Conversation::createMainLayout(Evas_Object *parent)
+void Conversation::createMainLayout()
{
- m_pLayout = new ConversationLayout(parent);
+ m_pLayout = new ConversationLayout(getParent());
m_pLayout->show();
m_pLayout->expand();
+ setHwButtonListener(*m_pLayout, this);
}
-void Conversation::createConvList(Evas_Object *parent)
+void Conversation::showConvList(bool show)
{
- if(!m_pConvList)
+ if(show)
{
- m_pConvList = new ConvList(*m_pLayout, getApp(), m_WorkingDir);
- m_pConvList->setListener(this);
- m_pConvList->show();
- m_pLayout->setConvList(*m_pConvList);
+ if(!m_pConvList)
+ {
+ m_pConvList = new ConvList(*m_pLayout, getApp(), m_WorkingDir);
+ m_pConvList->setListener(this);
+ m_pConvList->show();
+ m_pLayout->setConvList(*m_pConvList);
+ }
}
-}
-
-void Conversation::destroyConvList()
-{
- if(m_pConvList)
+ else
{
- m_pConvList->destroy();
- m_pConvList = nullptr;
+ if(m_pConvList)
+ {
+ m_pConvList->setListener(nullptr);
+ m_pConvList->destroy();
+ m_pConvList = nullptr;
+ }
}
}
-void Conversation::createRecipPanel(Evas_Object *parent)
+void Conversation::showRecipPanel(bool show)
{
- if(!m_pRecipPanel)
+ if(show)
{
- m_pRecipPanel = new ConvRecipientsPanel(parent, getApp());
- m_pRecipPanel->setListener(this);
- m_pRecipPanel->show();
- m_pLayout->setRecipientPanel(*m_pRecipPanel);
- m_pLayout->setRecipientRect(m_pRecipPanel->getAreaRect());
+ if(!m_pRecipPanel)
+ {
+ m_pRecipPanel = new ConvRecipientsPanel(*m_pLayout, getApp());
+ m_pRecipPanel->setListener(this);
+ m_pRecipPanel->show();
+ m_pLayout->setRecipientPanel(*m_pRecipPanel);
+ m_pLayout->setRecipientRect(m_pRecipPanel->getAreaRect());
+ }
}
-}
-
-void Conversation::destroyRecipPanel()
-{
- if(m_pRecipPanel)
+ else
{
- m_pRecipPanel->destroy();
- m_pRecipPanel = nullptr;
+ if(m_pRecipPanel)
+ {
+ m_pRecipPanel->destroy();
+ m_pRecipPanel = nullptr;
+ }
}
}
-void Conversation::createContactList(Evas_Object *parent)
+void Conversation::showContactList(bool show)
{
- if(!m_pContactsList)
+ if(show)
{
- m_pContactsList = new ConvContactList(parent, getApp());
- m_pContactsList->setListener(this);
- m_pContactsList->show();
- m_pLayout->setContactList(*m_pContactsList);
+ if(!m_pContactsList)
+ {
+ m_pContactsList = new ConvContactList(*m_pLayout, getApp());
+ m_pContactsList->setListener(this);
+ m_pLayout->setContactList(*m_pContactsList);
+ }
}
-}
-
-void Conversation::destroyContactList()
-{
- m_pLayout->showContactList(false);
- if(m_pContactsList)
+ else
{
- m_pContactsList->destroy();
- m_pContactsList = nullptr;
+ if(m_pContactsList)
+ {
+ m_pContactsList->destroy();
+ m_pContactsList = nullptr;
+ m_pLayout->showContactList(false);
+ }
}
}
-void Conversation::createMsgInputPanel(Evas_Object *parent, ConvList &convList)
+void Conversation::showMsgInputPanel(bool show)
{
- if(!m_pMsgInputPanel)
+ if(show)
{
- m_pMsgInputPanel = new MessageInputPanel(parent);
- m_pMsgInputPanel->setListener(this);
- m_pLayout->setMsgInputPanel(*m_pMsgInputPanel);
- m_pLayout->showMsgInputPanel(true);
+ if(!m_pMsgInputPanel)
+ {
+ m_pMsgInputPanel = new MessageInputPanel(*m_pConvList);
+ m_pMsgInputPanel->setListener(this);
+ m_pLayout->setMsgInputPanel(*m_pMsgInputPanel);
+ }
+ if(!m_pBody && m_pConvList)
+ {
+ m_pBody = new Body(*m_pMsgInputPanel, getApp(), m_WorkingDir, *m_pConvList);
+ m_pBody->setListener(this);
+ m_pBody->show();
+ m_pMsgInputPanel->setEntry(*m_pBody);
+ updateMsgInputPanel();
+ }
}
- if(!m_pBody)
+ else
{
- m_pBody = new Body(*m_pMsgInputPanel, getApp(), m_WorkingDir, convList);
- m_pBody->setListener(this);
- m_pBody->show();
- m_pMsgInputPanel->setEntry(*m_pBody);
- updateMsgInputPanel();
+ if(m_pBody)
+ {
+ m_pBody->setListener(this);
+ m_pBody->destroy();
+ m_pBody = nullptr;
+ }
+ if(m_pMsgInputPanel)
+ {
+ m_pMsgInputPanel->setListener(this);
+ m_pMsgInputPanel->destroy();
+ m_pMsgInputPanel = nullptr;
+ }
}
+ m_pLayout->showMsgInputPanel(show);
}
void Conversation::write(const Message &msg)
{
- m_pBody->write(msg);
+ if(m_pBody)
+ m_pBody->write(msg);
if(m_pRecipPanel)
m_pRecipPanel->write(msg);
}
{
if(readMsgAddress(msg))
{
- m_pBody->read(msg);
+ if(m_pBody)
+ m_pBody->read(msg);
return true;
}
return false;
void Conversation::sendMessage()
{
+ if(!m_pMsgInputPanel || !m_pBody)
+ return;
+
if(m_pRecipPanel &&
m_pRecipPanel->getEntryFocus() &&
!m_pRecipPanel->getEntryText().empty() &&
void Conversation::editDraftMsg(MsgId id)
{
+ if(!m_pBody)
+ return;
+
MessageRef msg = getMsgEngine().getStorage().getMessage(id);
if(msg)
{
bool Conversation::isBodyEmpty() const
{
- return m_pBody && m_pBody->isEmpty();
+ return !m_pBody || m_pBody->isEmpty();
}
void Conversation::navigateToSlideShow(MsgId id)
{
PopupList &popup = getApp().getPopupManager().getPopupList(PopupList::MoreMenuPopup);
popup.appendItem(msg("IDS_MSG_OPT_DELETE"), POPUPLIST_ITEM_PRESSED_CB(Conversation, onDeleteItemPressed), this);
- popup.appendItem(msg("IDS_MSG_TMBODY_ADD_OR_REMOVE_RECIPIENTS"), POPUPLIST_ITEM_PRESSED_CB(Conversation, onAddRecipientsItemPressed), this);
+ if(!isHiddenAddress())
+ popup.appendItem(msg("IDS_MSG_TMBODY_ADD_OR_REMOVE_RECIPIENTS"), POPUPLIST_ITEM_PRESSED_CB(Conversation, onAddRecipientsItemPressed), this);
popup.show();
}
void Conversation::onMbeChanged(ConvRecipientsPanel &panel)
{
MSG_LOG("");
- m_pBody->setMmsRecipFlag(m_pRecipPanel->isMms());
+ if(m_pBody)
+ m_pBody->setMmsRecipFlag(m_pRecipPanel->isMms());
checkAndSetMsgType();
if(m_pConvList)
{
void Conversation::updateMsgInputPanel()
{
- if(!m_pBody)
+ if(!m_pBody || !m_pMsgInputPanel)
return;
if(m_pBody->isMms())
{
// Mms:
- m_pMsgInputPanel->setCounter(makeKbStr(m_pBody->getMsgSize()));
+ m_pMsgInputPanel->setCounter(MsgUtils::makeKbStr(m_pBody->getMsgSize()));
}
else
{
else
{
MsgAddressListRef addressList = getAddressList();
- if(addressList && !addressList->isEmpty())
+ if(addressList && !addressList->isEmpty() && !isHiddenAddress())
recipientClickHandler(addressList->at(0).getAddress());
}
}
void Conversation::onPopupDel(Evas_Object *popup, void *eventInfo)
{
MSG_LOG("");
- m_pBody->setFocus(true);
+ if(m_pBody)
+ m_pBody->setFocus(true);
}
void Conversation::onSendReadReportPopupDel(Evas_Object *popup, void *eventInfo)
void Conversation::onMsgSendErrorButtonClicked(Popup &popup, int buttonId)
{
MSG_LOG("");
- m_pBody->setFocus(true);
popup.destroy();
+ if(m_pBody)
+ m_pBody->setFocus(true);
}
void Conversation::onMsgSettingsButtonClicked(Popup &popup, int buttonId)
void Conversation::onNoRecipCancelButtonClicked(Popup &popup, int buttonId)
{
- m_pBody->setFocus(true);
popup.destroy();
+ if(m_pBody)
+ m_pBody->setFocus(true);
}
void Conversation::onNoRecipDiscardButtonClicked(Popup &popup, int buttonId)
{
+ popup.destroy();
if(isDefferedCmd())
{
- m_pBody->clear();
+ if(m_pBody)
+ m_pBody->clear();
if(m_DefferedCmd.defaultCmd)
{ // If we came from notification menu and unread threads will be more than one, we should to go back on thread list view
if(m_DefferedCmd.defaultCmd->getDefaultType() == AppControlDefault::NotificationType && getMsgEngine().getStorage().getUnreadThreadCount() > 1)
resetDefferedCmd();
}
else
- { // We will get here from conversation after tap on Back Button
+ {
pop();
}
-
- popup.destroy();
}
void Conversation::onDeleteItemPressed(PopupListItem &item)
auto convList = getMsgEngine().getStorage().getConversationList(m_ThreadId);
if((convList && convList->getLength() == 0) || !convList)
{
- if(m_pBody->isEmpty())
+ if(isBodyEmpty())
{
onHwBackButtonClicked();
}
{
// Current MsgThread is dead, so create new MsgThread from existing recipients.
createNewMsgThread();
- m_pBody->setFocus(true);
+ if(m_pBody)
+ m_pBody->setFocus(true);
}
}
}