#include "Popup.h"
#include "ListView.h"
+#include "PopupListItem.h"
namespace Msg
{
- class PopupList;
- class PopupListItem;
- typedef void (*PopupListItemPressedCb)(PopupListItem &item, void *userData);
-
- #define POPUPLIST_ITEM_PRESSED_CB(ClassName, method) [](PopupListItem &item, void *userData) \
- { \
- static_cast<ClassName*>(userData)->method(item); \
- }
-
- class PopupListItem
- : public ListItem
- {
- friend class PopupList;
- public:
- PopupListItem(PopupList &parent, const std::string &text, PopupListItemPressedCb cb, void *userData);
- PopupList &getParent();
-
- private:
- virtual std::string getText(ListItem &item, const char *part);
-
- private:
- PopupList &m_Parent;
- std::string m_Text;
- PopupListItemPressedCb m_Cb;
- void *m_pUserData;
- };
-
class PopupList
: public Popup
, private IListViewListener
PopupList(PopupManager &parent);
virtual ~PopupList();
+ void appendItem(PopupListItem &item);
void appendItem(const std::string &text, PopupListItemPressedCb cb, void *userData);
ListView &getListView();
--- /dev/null
+/*
+ * Copyright (c) 2009-2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef PopupListItem_h_
+#define PopupListItem_h_
+
+#include "ListItem.h"
+
+namespace Msg
+{
+ class PopupList;
+ class PopupListItem;
+ typedef void (*PopupListItemPressedCb)(PopupListItem &item, void *userData);
+ #define POPUPLIST_ITEM_PRESSED_CB(ClassName, method) [](PopupListItem &item, void *userData) \
+ { \
+ static_cast<ClassName*>(userData)->method(item); \
+ }
+
+ /**
+ * Generic Popup-list item class
+ */
+ class PopupListItem: public ListItem
+ {
+ public:
+ PopupListItem(PopupList &parent, PopupListItemPressedCb cb, void *userData);
+ PopupList &getParent();
+ void fireCallback();
+ private:
+ PopupList &m_Parent;
+ PopupListItemPressedCb m_Cb;
+ void *m_pUserData;
+ };
+
+ /**
+ * A class of popup-item with single text displayed
+ */
+ class PopupTextListItem: public PopupListItem
+ {
+ public:
+ PopupTextListItem(PopupList &parent, const std::string &text, PopupListItemPressedCb cb, void *userData);
+ virtual ~PopupTextListItem();
+ private:
+ virtual std::string getText(ListItem &item, const char *part);
+ private:
+ std::string m_Text;
+ };
+}
+
+#endif /* PopupListItem_h_ */
using namespace Msg;
-const ListItemStyleRef listItemStyle = ListItemStyle::create("type1");
-
-PopupListItem::PopupListItem(PopupList &parent, const std::string &text, PopupListItemPressedCb cb, void *userData)
- : ListItem(listItemStyle)
- , m_Parent(parent)
- , m_Text(text)
- , m_Cb(cb)
- , m_pUserData(userData)
-{
-}
-
-PopupList &PopupListItem::getParent()
-{
- return m_Parent;
-}
-
-std::string PopupListItem::getText(ListItem &item, const char *part)
-{
- if(strcmp(part, "elm.text") == 0)
- return m_Text;
- return std::string();
-}
-
PopupList::PopupList(Evas_Object *parent)
: Popup(parent)
, m_pList(nullptr)
{
}
+void PopupList::appendItem(PopupListItem &item)
+{
+ m_pList->appendItem(item);
+}
+
void PopupList::appendItem(const std::string &text, PopupListItemPressedCb cb, void *userData)
{
- m_pList->appendItem(*new PopupListItem(*this, text, cb, userData));
+ m_pList->appendItem(*new PopupTextListItem(*this, text, cb, userData));
}
void PopupList::create()
void PopupList::onListItemSelected(ListItem &listItem)
{
PopupListItem &it = static_cast<PopupListItem&>(listItem);
- if(it.m_Cb)
- it.m_Cb(it, it.m_pUserData);;
+ it.fireCallback();
}
--- /dev/null
+/*
+ * Copyright (c) 2009-2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "PopupListItem.h"
+
+using namespace Msg;
+
+const ListItemStyleRef listItemStyle = ListItemStyle::create("type1");
+
+PopupListItem::PopupListItem(PopupList &parent, PopupListItemPressedCb cb, void *userData)
+ : ListItem(listItemStyle)
+ , m_Parent(parent)
+ , m_Cb(cb)
+ , m_pUserData(userData)
+{
+}
+
+void PopupListItem::fireCallback()
+{
+ if (m_Cb)
+ m_Cb(*this, m_pUserData);
+}
+
+PopupList &PopupListItem::getParent()
+{
+ return m_Parent;
+}
+
+PopupTextListItem::PopupTextListItem(PopupList &parent, const std::string &text, PopupListItemPressedCb cb, void *userData)
+ : PopupListItem(parent, cb, userData)
+ , m_Text(text)
+{
+}
+
+PopupTextListItem::~PopupTextListItem()
+{
+}
+
+std::string PopupTextListItem::getText(ListItem &item, const char *part)
+{
+ if(strcmp(part, "elm.text") == 0)
+ return m_Text;
+ return std::string();
+}
void showNoRecipPopup();
PopupList &createPopupList(const std::string &title);
void showSendResultPopup(MsgTransport::SendResult result);
-
+ void showUnsavedRecipientPopup(const std::string &address);
+ void showSavedRecipientPopup(const std::string &title, int personId);
void sendMessage();
void read(Message &msg);
void readMsgAddress(Message &msg);
ConvList *m_pConvList;
AttachPanel m_AttachPanel;
DefferedCmd m_DefferedCmd;
-
- // TODO: remove usage of pre-saved person-id of contact-recipient after implementation of modal popup routine
- int m_SelectedPersonId;
ContactEditor m_ContactEditor;
IConversationListener *m_pListener;
};
--- /dev/null
+/*
+ * Copyright (c) 2009-2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef PopupRecipientListItem_h_
+#define PopupRecipientListItem_h_
+
+#include "PopupListItem.h"
+
+namespace Msg
+{
+ class PopupAddressListItem
+ : public PopupTextListItem
+ {
+ public:
+ PopupAddressListItem(PopupList &parent, const std::string &text, const std::string &address,
+ PopupListItemPressedCb cb, void *userData);
+ virtual ~PopupAddressListItem();
+ std::string getAddress() const;
+ private:
+ std::string m_Address;
+ };
+
+
+ class PopupPersonIdListItem
+ : public PopupTextListItem
+ {
+ public:
+ PopupPersonIdListItem(PopupList &parent, const std::string &text, int personId,
+ PopupListItemPressedCb cb, void *userData);
+ virtual ~PopupPersonIdListItem();
+ int getPersonId() const;
+ private:
+ int m_PersonId;
+ };
+}
+
+#endif /* PopupRecipientListItem_h_ */
#include "ContactViewer.h"
#include "VoiceCall.h"
#include "Viewer.h"
+#include "PopupRecipientListItem.h"
#include <Elementary.h>
#include <sstream>
, m_IsMms(false)
, m_pConvList(nullptr)
, m_AttachPanel(getApp())
- , m_SelectedPersonId(-1)
, m_pListener(nullptr)
{
create();
ContactPersonAddressRef contactPersonAddress = getApp().getContactManager().getContactPersonAddress(address);
if(contactPersonAddress)
{
- m_SelectedPersonId = contactPersonAddress->getPersonId();
+ int selectedPersonId = contactPersonAddress->getPersonId();
if(m_Mode == NewMessageMode)
{
MbeRecipientItem *pItem = m_pRecipPanel->getSelectedItem();
if(pItem)
{
- PopupList &popup = createPopupList(pItem->getDispName());
- popup.appendItem(msg("IDS_MSGF_OPT_REMOVE"), POPUPLIST_ITEM_PRESSED_CB(Conversation, onRemoveItemPressed), this);
- popup.appendItem(msg("IDS_MSG_OPT_EDIT"), POPUPLIST_ITEM_PRESSED_CB(Conversation, onEditItemPressed), this);
- popup.appendItem(msg("IDS_MSG_OPT_VIEW_CONTACT_DETAILS_ABB"), POPUPLIST_ITEM_PRESSED_CB(Conversation, onViewContactDetailsItemPressed), this);
- popup.show();
+ showSavedRecipientPopup(pItem->getDispName(), selectedPersonId);
}
}
else if(m_Mode == ConversationMode)
{
- ContactViewer::launch(m_SelectedPersonId);
- m_SelectedPersonId = -1;
+ ContactViewer::launch(selectedPersonId);
}
}
else
{
- PopupList &popup = createPopupList(address);
- if(m_Mode == NewMessageMode)
- {
- popup.appendItem(msg("IDS_MSGF_OPT_REMOVE"), POPUPLIST_ITEM_PRESSED_CB(Conversation, onRemoveItemPressed), this);
- popup.appendItem(msg("IDS_MSG_OPT_EDIT"), POPUPLIST_ITEM_PRESSED_CB(Conversation, onEditItemPressed), this);
- }
- else if(m_Mode == ConversationMode)
- {
- popup.appendItem(msg("IDS_MSG_OPT_MAKE_VOICE_CALL"), POPUPLIST_ITEM_PRESSED_CB(Conversation, onMakeVoiceItemPressed), this);
- }
+ showUnsavedRecipientPopup(address);
+ }
+}
+
+void Conversation::showSavedRecipientPopup(const std::string &title, int personId)
+{
+ PopupList &popup = createPopupList(title);
+ popup.appendItem(msg("IDS_MSGF_OPT_REMOVE"), POPUPLIST_ITEM_PRESSED_CB(Conversation, onRemoveItemPressed), this);
+ popup.appendItem(msg("IDS_MSG_OPT_EDIT"), POPUPLIST_ITEM_PRESSED_CB(Conversation, onEditItemPressed), this);
+ popup.appendItem(*new PopupPersonIdListItem(popup, msg("IDS_MSG_OPT_VIEW_CONTACT_DETAILS_ABB"), personId,
+ POPUPLIST_ITEM_PRESSED_CB(Conversation, onViewContactDetailsItemPressed), this));
+ popup.show();
+}
- popup.appendItem(msg("IDS_MSG_OPT_CREATE_CONTACT_ABB"), POPUPLIST_ITEM_PRESSED_CB(Conversation, onCreateContactItemPressed), this);
- popup.appendItem(msg("IDS_MSG_OPT_UPDATE_CONTACT"), POPUPLIST_ITEM_PRESSED_CB(Conversation, onUpdateContactItemPressed), this);
- popup.show();
+void Conversation::showUnsavedRecipientPopup(const std::string &address)
+{
+ PopupList &popup = createPopupList(address);
+ if(m_Mode == NewMessageMode)
+ {
+ popup.appendItem(*new PopupAddressListItem(popup, msg("IDS_MSGF_OPT_REMOVE"), address,
+ POPUPLIST_ITEM_PRESSED_CB(Conversation, onRemoveItemPressed), this));
+
+ popup.appendItem(*new PopupAddressListItem(popup, msg("IDS_MSG_OPT_EDIT"), address,
+ POPUPLIST_ITEM_PRESSED_CB(Conversation, onEditItemPressed), this));
+ }
+ else if(m_Mode == ConversationMode)
+ {
+ popup.appendItem(*new PopupAddressListItem(popup, msg("IDS_MSG_OPT_MAKE_VOICE_CALL"), address,
+ POPUPLIST_ITEM_PRESSED_CB(Conversation, onMakeVoiceItemPressed), this));
}
+
+ popup.appendItem(*new PopupAddressListItem(popup, msg("IDS_MSG_OPT_CREATE_CONTACT_ABB"), address,
+ POPUPLIST_ITEM_PRESSED_CB(Conversation, onCreateContactItemPressed), this));
+
+ popup.appendItem(*new PopupAddressListItem(popup, msg("IDS_MSG_OPT_UPDATE_CONTACT"), address,
+ POPUPLIST_ITEM_PRESSED_CB(Conversation, onUpdateContactItemPressed), this));
+ popup.show();
}
void Conversation::contactChangedHandler()
void Conversation::onMakeVoiceItemPressed(PopupListItem &item)
{
MSG_LOG("");
+ std::string address = static_cast<PopupAddressListItem&>(item).getAddress();
item.getParent().destroy();
- MbeRecipientItem *pItem = m_pRecipPanel->getSelectedItem();
- if(pItem)
- VoiceCall::launch(pItem->getAddress());
-
- m_SelectedPersonId = -1;
+ VoiceCall::launch(address);
}
void Conversation::onCreateContactItemPressed(PopupListItem &item)
{
MSG_LOG("");
+ std::string address = static_cast<PopupAddressListItem&>(item).getAddress();
item.getParent().destroy();
- MbeRecipientItem *pItem = m_pRecipPanel->getSelectedItem();
- if(pItem)
- m_ContactEditor.launch(pItem->getAddress(), ContactEditor::CreateOp);
-
- m_SelectedPersonId = -1;
+ m_ContactEditor.launch(address, ContactEditor::CreateOp);
}
void Conversation::onUpdateContactItemPressed(PopupListItem &item)
{
MSG_LOG("");
+ std::string address = static_cast<PopupAddressListItem&>(item).getAddress();
item.getParent().destroy();
- MbeRecipientItem *pItem = m_pRecipPanel->getSelectedItem();
- if(pItem)
- m_ContactEditor.launch(pItem->getAddress(), ContactEditor::EditOp);
-
- m_SelectedPersonId = -1;
+ m_ContactEditor.launch(address, ContactEditor::EditOp);
}
void Conversation::onRemoveItemPressed(PopupListItem &item)
MSG_LOG("");
item.getParent().destroy();
m_pRecipPanel->removeSelectedItem();
- m_SelectedPersonId = -1;
}
void Conversation::onEditItemPressed(PopupListItem &item)
MSG_LOG("");
item.getParent().destroy();
m_pRecipPanel->editSelectedItem();
- m_SelectedPersonId = -1;
}
void Conversation::onViewContactDetailsItemPressed(PopupListItem &item)
{
MSG_LOG("");
+ int personId = static_cast<PopupPersonIdListItem&>(item).getPersonId();
item.getParent().destroy();
- ContactViewer::launch(m_SelectedPersonId);
- m_SelectedPersonId = -1;
+ ContactViewer::launch(personId);
}
void Conversation::onAllItemsDeleted(ConvList &list)
--- /dev/null
+/*
+ * Copyright (c) 2009-2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "PopupRecipientListItem.h"
+
+using namespace Msg;
+
+PopupAddressListItem::PopupAddressListItem(PopupList &parent, const std::string &text, const std::string &address,
+ PopupListItemPressedCb cb, void *userData)
+ : PopupTextListItem(parent, text, cb, userData)
+ , m_Address(address)
+{
+}
+
+PopupAddressListItem::~PopupAddressListItem()
+{
+}
+
+std::string PopupAddressListItem::getAddress() const
+{
+ return m_Address;
+}
+
+
+PopupPersonIdListItem::PopupPersonIdListItem(PopupList &parent, const std::string &text, int personId,
+ PopupListItemPressedCb cb, void *userData)
+ : PopupTextListItem(parent, text, cb, userData)
+ , m_PersonId(personId)
+{
+}
+
+PopupPersonIdListItem::~PopupPersonIdListItem()
+{
+}
+
+int PopupPersonIdListItem::getPersonId() const
+{
+ return m_PersonId;
+}