class ContactViewer
{
public:
+ static ContactViewer &getInst();
+
/**
* @brief Launches view-operation.
* @param[in] id Contact person id or MyProfile id
* @param[in] ownerType PersonType or MyProfileType
* @return true in case of success, otherwise returns false.
*/
- static bool launch(int id, ContactAddress::OwnerType ownerType);
+ bool launch(int id, ContactAddress::OwnerType ownerType);
/**
* @brief Launches view-operation.
* @param[in] address reference to ContactAddress object.
* @return true in case of success, otherwise returns false.
*/
- static bool launch(const ContactAddress &address);
+ bool launch(const ContactAddress &address);
private:
+ ContactViewer();
+ ~ContactViewer();
ContactViewer(const ContactViewer&) = delete;
ContactViewer& operator=(const ContactViewer&) = delete;
- static const char *toStr(ContactAddress::OwnerType type);
+ const char *toStr(ContactAddress::OwnerType type);
+ void reset();
+
+ private:
+ app_control_h m_Handle;
};
}
const char *myProfileTypeStr = "my_profile";
}
+ContactViewer::ContactViewer()
+ : m_Handle()
+{
+
+}
+
+ContactViewer::~ContactViewer()
+{
+ reset();
+}
+
+ContactViewer &ContactViewer::getInst()
+{
+ static ContactViewer inst;
+ return inst;
+}
+
+void ContactViewer::reset()
+{
+ if(m_Handle)
+ {
+ app_control_send_terminate_request(m_Handle);
+ app_control_destroy(m_Handle);
+ m_Handle = nullptr;
+ }
+}
+
bool ContactViewer::launch(int id, ContactAddress::OwnerType ownerType)
{
bool res = false;
- app_control_h svc_handle = nullptr;
- if(APP_CONTROL_ERROR_NONE == app_control_create(&svc_handle))
+ reset();
+ if(APP_CONTROL_ERROR_NONE == app_control_create(&m_Handle))
{
- app_control_set_operation(svc_handle, APP_CONTROL_OPERATION_VIEW);
- app_control_set_mime(svc_handle, mimeContact);
- app_control_add_extra_data(svc_handle, APP_CONTROL_DATA_TYPE, toStr(ownerType));
- app_control_add_extra_data(svc_handle, APP_CONTROL_DATA_ID, std::to_string(id).c_str());
- app_control_set_launch_mode(svc_handle, APP_CONTROL_LAUNCH_MODE_GROUP);
- int ret = app_control_send_launch_request(svc_handle, nullptr, nullptr);
+ app_control_set_operation(m_Handle, APP_CONTROL_OPERATION_VIEW);
+ app_control_set_mime(m_Handle, mimeContact);
+ app_control_add_extra_data(m_Handle, APP_CONTROL_DATA_TYPE, toStr(ownerType));
+ app_control_add_extra_data(m_Handle, APP_CONTROL_DATA_ID, std::to_string(id).c_str());
+ app_control_set_launch_mode(m_Handle, APP_CONTROL_LAUNCH_MODE_GROUP);
+ int ret = app_control_send_launch_request(m_Handle, nullptr, nullptr);
MSG_LOG("Result code: ", ret);
res = ret == APP_CONTROL_ERROR_NONE;
- app_control_destroy(svc_handle);
}
return res;
{
if(m_pRecipPanel)
m_pRecipPanel->unselectMbeItem();
- ContactViewer::launch(*contactAddress);
+ ContactViewer::getInst().launch(*contactAddress);
}
}
else
int id = static_cast<PopupPersonIdListItem&>(item).getContactId();
auto ownerType = static_cast<PopupPersonIdListItem&>(item).getContactOwnerType();
item.getParent().destroy();
- ContactViewer::launch(id, ownerType);
+ ContactViewer::getInst().launch(id, ownerType);
}
void Conversation::onAllConvItemsDeleted(ConvList &list)