diff options
author | Denis Dolzhenko <d.dolzhenko@samsung.com> | 2017-07-24 16:46:36 +0300 |
---|---|---|
committer | Denis Dolzhenko <d.dolzhenko@samsung.com> | 2017-07-24 16:49:00 +0300 |
commit | c07e7fe33c6ec2369f061cd7148aa856cf556250 (patch) | |
tree | e75ea734478d3a54f2d11a48be9280967c3be805 | |
parent | 606eade99b2ca90705fa1dc4d939ad8eeb12a417 (diff) | |
download | message-c07e7fe33c6ec2369f061cd7148aa856cf556250.tar.gz message-c07e7fe33c6ec2369f061cd7148aa856cf556250.tar.bz2 message-c07e7fe33c6ec2369f061cd7148aa856cf556250.zip |
TizenRefApp-8919 Fix ContactViewer class
Change-Id: I3d67729d800bd218b53abad5529b499f1035caa6
Signed-off-by: Denis Dolzhenko <d.dolzhenko@samsung.com>
-rw-r--r-- | src/Common/AppControl/inc/AppControlHandle.h | 1 | ||||
-rw-r--r-- | src/Common/AppControl/inc/ContactViewer.h | 1 | ||||
-rw-r--r-- | src/Common/AppControl/src/AppControlHandle.cpp | 5 | ||||
-rw-r--r-- | src/Common/AppControl/src/ContactViewer.cpp | 65 |
4 files changed, 47 insertions, 25 deletions
diff --git a/src/Common/AppControl/inc/AppControlHandle.h b/src/Common/AppControl/inc/AppControlHandle.h index 99a671d..22ead32 100644 --- a/src/Common/AppControl/inc/AppControlHandle.h +++ b/src/Common/AppControl/inc/AppControlHandle.h @@ -49,6 +49,7 @@ namespace Msg { bool isGroupMode() const; void setOperation(const char *operation); + void setAppId(const char *id); void setUri(const char *uri); void setMime(const char *mime); void setLaunchMode(app_control_launch_mode_e mode); diff --git a/src/Common/AppControl/inc/ContactViewer.h b/src/Common/AppControl/inc/ContactViewer.h index b79626b..d5f8023 100644 --- a/src/Common/AppControl/inc/ContactViewer.h +++ b/src/Common/AppControl/inc/ContactViewer.h @@ -51,6 +51,7 @@ namespace Msg { bool launch(); private: + bool launchPrivate(const ContactAddress &address); void clear(); const char *toStr(ContactAddress::OwnerType type); }; diff --git a/src/Common/AppControl/src/AppControlHandle.cpp b/src/Common/AppControl/src/AppControlHandle.cpp index 27feb84..f6a65ff 100644 --- a/src/Common/AppControl/src/AppControlHandle.cpp +++ b/src/Common/AppControl/src/AppControlHandle.cpp @@ -65,6 +65,11 @@ void AppControlHandle::setOperation(const char *operation) app_control_set_operation(m_Handle, operation); } +void AppControlHandle::setAppId(const char *id) +{ + app_control_set_app_id(m_Handle, id); +} + void AppControlHandle::setUri(const char *uri) { app_control_set_uri(m_Handle, uri); diff --git a/src/Common/AppControl/src/ContactViewer.cpp b/src/Common/AppControl/src/ContactViewer.cpp index 8bed60b..e8014fc 100644 --- a/src/Common/AppControl/src/ContactViewer.cpp +++ b/src/Common/AppControl/src/ContactViewer.cpp @@ -35,71 +35,86 @@ namespace { ContactViewer::ContactViewer() { - app_control_set_operation(m_Handle, APP_CONTROL_OPERATION_VIEW); } ContactViewer::~ContactViewer() { } -bool ContactViewer::launch(const ContactAddress &address) +bool ContactViewer::launchPrivate(const ContactAddress &address) { - clear(); + setOperation(APP_CONTROL_OPERATION_VIEW); bool isLog = dynamic_cast<const ContactPersonPhoneLog*>(&address); std::string mime = isLog ? mimeLog : mimeContact; int id = isLog ? address.getId() : address.getOwnerId(); - app_control_set_mime(m_Handle, mime.c_str()); - app_control_add_extra_data(m_Handle, APP_CONTROL_DATA_TYPE, toStr(address.getOwnerType())); - app_control_add_extra_data(m_Handle, APP_CONTROL_DATA_ID, std::to_string(id).c_str()); + setMime(mime.c_str()); + addExtraData(APP_CONTROL_DATA_TYPE, toStr(address.getOwnerType())); + addExtraData(APP_CONTROL_DATA_ID, std::to_string(id).c_str()); return AppControlHandle::launch(); } +bool ContactViewer::launch(const ContactAddress &address) +{ + if (getLauncher().isLaunchInProgress()) + return false; + + clear(); + launchPrivate(address); +} + bool ContactViewer::launch() { + if (getLauncher().isLaunchInProgress()) + return false; + clear(); - app_control_set_app_id(m_Handle, contactsAppId); + setAppId(contactsAppId); return AppControlHandle::launch(); } bool ContactViewer::launch(const std::string &address) { - clear(); + if (getLauncher().isLaunchInProgress()) + return false; + clear(); + setOperation(APP_CONTROL_OPERATION_VIEW); auto rec = App::getInst().getContactManager().getContactAddress(address); if (rec) - return launch(*rec); + return launchPrivate(*rec); - app_control_set_mime(m_Handle, mimeLog); + setMime(mimeLog); if (MsgUtils::isValidNumber(address)) - app_control_add_extra_data(m_Handle, APP_CONTROL_DATA_PHONE, address.c_str()); + addExtraData(APP_CONTROL_DATA_PHONE, address.c_str()); else if (MsgUtils::isValidEmail(address)) - app_control_add_extra_data(m_Handle, APP_CONTROL_DATA_EMAIL, address.c_str()); + addExtraData(APP_CONTROL_DATA_EMAIL, address.c_str()); else return false; - return launch(); + return AppControlHandle::launch(); } void ContactViewer::clear() { - app_control_set_app_id(m_Handle, nullptr); - app_control_set_mime(m_Handle, nullptr); - app_control_remove_extra_data(m_Handle, APP_CONTROL_DATA_PHONE); - app_control_remove_extra_data(m_Handle, APP_CONTROL_DATA_EMAIL); - app_control_remove_extra_data(m_Handle, APP_CONTROL_DATA_TYPE); - app_control_remove_extra_data(m_Handle, APP_CONTROL_DATA_ID); + setOperation(nullptr); + setAppId(nullptr); + setMime(nullptr); + removeExtraData(APP_CONTROL_DATA_PHONE); + removeExtraData(APP_CONTROL_DATA_EMAIL); + removeExtraData(APP_CONTROL_DATA_TYPE); + removeExtraData(APP_CONTROL_DATA_ID); } const char *ContactViewer::toStr(ContactAddress::OwnerType type) { switch (type) { - case ContactAddress::PersonType: - return personContactTypeStr; - case ContactAddress::MyProfileType: - return myProfileTypeStr; - default: - MSG_LOG_ERROR("Unknown ContactType"); + case ContactAddress::PersonType: + return personContactTypeStr; + case ContactAddress::MyProfileType: + return myProfileTypeStr; + default: + MSG_LOG_ERROR("Unknown ContactType"); }; return ""; } |