ContactViewer();
virtual ~ContactViewer();
- /**
- * @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.
- */
- bool launch(int id, ContactAddress::OwnerType ownerType);
-
/**
* @brief Launches view-operation.
* @param[in] address reference to ContactAddress object.
bool launch();
private:
+ void clear();
const char *toStr(ContactAddress::OwnerType type);
};
}
#include "ContactViewer.h"
#include "Logger.h"
+#include "ContactManager.h"
+#include "App.h"
+#include "ContactPersonPhoneLog.h"
#include <app_control.h>
#include <string>
namespace {
const char *mimeContact = "application/vnd.tizen.contact";
+ const char *mimeLog = "application/vnd.tizen.log";
const char *personContactTypeStr = "person";
const char *myProfileTypeStr = "my_profile";
+ const char *contactsAppId = "org.tizen.w-contacts";
}
ContactViewer::ContactViewer()
{
app_control_set_operation(m_Handle, APP_CONTROL_OPERATION_VIEW);
- app_control_set_mime(m_Handle, mimeContact);
}
ContactViewer::~ContactViewer()
{
}
-bool ContactViewer::launch(int id, ContactAddress::OwnerType ownerType)
-{
- 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());
- return launch();
-}
-
bool ContactViewer::launch(const ContactAddress &address)
{
- return launch(address.getOwnerId(), address.getOwnerType());
+ clear();
+ 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());
+ return AppControlLauncher::getInst().launch(*this);
}
bool ContactViewer::launch()
{
+ clear();
+ app_control_set_app_id(m_Handle, contactsAppId);
return AppControlLauncher::getInst().launch(*this);
}
bool ContactViewer::launch(const std::string &address)
{
- app_control_add_extra_data(m_Handle, APP_CONTROL_DATA_PHONE, address.c_str());
+ clear();
+
+ auto rec = App::getInst().getContactManager().getContactAddress(address);
+ if (rec)
+ return launch(*rec);
+
+ app_control_set_mime(m_Handle, mimeLog);
+ if (MsgUtils::isValidNumber(address))
+ app_control_add_extra_data(m_Handle, 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());
+ else
+ return false;
+
return 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);
+}
+
const char *ContactViewer::toStr(ContactAddress::OwnerType type)
{
switch (type)
: public ContactRecord {
public:
- enum AddressType {
- EmailType,
- NumberType
- };
-
enum OwnerType {
PersonType,
- MyProfileType
+ MyProfileType,
};
public:
ContactAddress();
ContactAddress(bool release, contacts_record_h record = nullptr);
virtual ~ContactAddress() {};
- virtual AddressType getAddressType() const = 0;
virtual OwnerType getOwnerType() const = 0;
virtual int getOwnerId() const = 0;
+ virtual int getId() const = 0;
virtual std::string getDispName() const = 0;
virtual std::string getAddress() const = 0; // Email or Number
virtual std::string getThumbnailPath() const = 0;
*/
ContactPersonEmailRef getContactPersonEmail(const std::string &email);
+ /**
+ *@brief Search by number or email ContactPersonPhoneLog record
+ *@param[in] address - number or email address
+ *@return Reference to ContactPersonPhoneLog
+ */
+ ContactPersonPhoneLogRef getContactPersonPhoneLog(const std::string &address);
+
/**
*@brief Search by number address ContactMyProfileNumber record
*@param[in] number - phone number
*/
ContactPersonNumberRef getContactPersonNumber(contacts_filter_h filter);
ContactPersonEmailRef getContactPersonEmail(contacts_filter_h filter);
+ ContactPersonPhoneLogRef getContactPersonPhoneLog(contacts_filter_h filter);
/**
*@brief Search by phone number ContactPersonNumber record
public:
ContactMyProfileEmail(bool release, const ContactMyProfile &myProfile, contacts_record_h record = nullptr);
static const char *getUri();
- int getId() const;
// ContactAddress:
- AddressType getAddressType() const override;
OwnerType getOwnerType() const override;
int getOwnerId() const override;
+ int getId() const override;
std::string getDispName() const override;
std::string getAddress() const override;
std::string getThumbnailPath() const override;
return MyProfileType;
}
- inline ContactMyProfileNumber::AddressType ContactMyProfileEmail::getAddressType() const
- {
- return EmailType;
- }
-
inline ContactRecordRef ContactMyProfileEmail::clone() const
{
return cloneInternal<ContactMyProfileEmail>();
public:
ContactMyProfileNumber(bool release, const ContactMyProfile &myProfile, contacts_record_h record = nullptr);
static const char *getUri();
- int getId() const;
// ContactAddress:
- AddressType getAddressType() const override;
OwnerType getOwnerType() const override;
int getOwnerId() const override;
+ int getId() const override;
std::string getDispName() const override;
std::string getAddress() const override;
std::string getThumbnailPath() const override;
return MyProfileType;
}
- inline ContactMyProfileNumber::AddressType ContactMyProfileNumber::getAddressType() const
- {
- return NumberType;
- }
-
inline ContactRecordRef ContactMyProfileNumber::clone() const
{
return cloneInternal<ContactMyProfileNumber>();
public:
ContactPersonEmail(bool release, contacts_record_h record = nullptr);
static const char *getUri();
- int getEmailId() const;
// ContactAddress:
OwnerType getOwnerType() const override;
- AddressType getAddressType() const override;
int getOwnerId() const override;
+ int getId() const override;
std::string getDispName() const override;
std::string getAddress() const override;
std::string getThumbnailPath() const override;
{
}
- inline int ContactPersonEmail::getEmailId() const
+ inline int ContactPersonEmail::getId() const
{
return getInt(_contacts_person_email.email_id);
}
return PersonType;
}
- inline ContactPersonEmail::AddressType ContactPersonEmail::getAddressType() const
- {
- return EmailType;
- }
-
inline ContactRecordRef ContactPersonEmail::clone() const
{
return cloneInternal<ContactPersonEmail>();
public:
ContactPersonNumber(bool release, contacts_record_h record = nullptr);
static const char *getUri();
- int getNumberId() const;
// ContactAddress:
OwnerType getOwnerType() const override;
- AddressType getAddressType() const override;
int getOwnerId() const override;
+ int getId() const override;
std::string getDispName() const override;
std::string getAddress() const override;
std::string getThumbnailPath() const override;
{
}
- inline int ContactPersonNumber::getNumberId() const
+ inline int ContactPersonNumber::getId() const
{
return getInt(_contacts_person_number.number_id);
}
return PersonType;
}
- inline ContactPersonNumber::AddressType ContactPersonNumber::getAddressType() const
- {
- return NumberType;
- }
-
inline ContactRecordRef ContactPersonNumber::clone() const
{
return cloneInternal<ContactPersonNumber>();
#define __ContactPersonPhoneLog_h__
#include "ContactRecord.h"
+#include "ContactAddress.h"
namespace Msg {
class ContactPersonPhoneLog;
typedef std::shared_ptr<ContactPersonPhoneLog> ContactPersonPhoneLogRef;
class ContactPersonPhoneLog
- : public ContactRecord {
+ : public ContactAddress {
+
public:
ContactPersonPhoneLog(bool release, contacts_record_h record = nullptr);
static const char *getUri();
- int getId() const;
- int getPersonId() const;
- std::string getAddress() const;
- std::string getDispName() const;
+
+ // ContactAddress:
+ OwnerType getOwnerType() const override;
+ int getOwnerId() const override;
+ int getId() const override;
+ std::string getDispName() const override;
+ std::string getAddress() const override;
ContactRecordRef clone() const override;
+ std::string getThumbnailPath() const override;
};
inline ContactPersonPhoneLog::ContactPersonPhoneLog(bool release, contacts_record_h record)
- : ContactRecord(release, record)
+ : ContactAddress(release, record)
{
}
return getInt(_contacts_person_phone_log.log_id);
}
- inline int ContactPersonPhoneLog::getPersonId() const
+ inline int ContactPersonPhoneLog::getOwnerId() const
{
return getInt(_contacts_person_phone_log.person_id);
}
return getStr(_contacts_person_phone_log.address);
}
+ inline std::string ContactPersonPhoneLog::getThumbnailPath() const
+ {
+ return getStr(_contacts_person_phone_log.image_thumbnail_path);
+ }
+
inline const char *ContactPersonPhoneLog::getUri()
{
return _contacts_person_phone_log._uri;
{
return cloneInternal<ContactPersonPhoneLog>();
}
+
+ inline ContactPersonPhoneLog::OwnerType ContactPersonPhoneLog::getOwnerType() const
+ {
+ return PersonType;
+ }
}
ContactPersonEmailRef ContactManager::getContactPersonEmail(const std::string &email)
{
contacts_filter_h filter = nullptr;
- contacts_filter_create(_contacts_person_email._uri, &filter);
- contacts_filter_add_str(filter, _contacts_person_email.email, CONTACTS_MATCH_EXACTLY, email.c_str());
+ contacts_filter_create(_contacts_contact_email._uri, &filter);
+ contacts_filter_add_str(filter, _contacts_person_email.email, CONTACTS_MATCH_FULLSTRING, email.c_str());
return filter ? getContactPersonEmail(filter) : nullptr;
}
+ ContactPersonPhoneLogRef ContactManager::getContactPersonPhoneLog(const std::string &address)
+ {
+ contacts_filter_h filter = nullptr;
+ contacts_filter_create(_contacts_person_phone_log._uri, &filter);
+ contacts_filter_add_str(filter, _contacts_person_email.email, CONTACTS_MATCH_FULLSTRING, address.c_str());
+ return filter ? getContactPersonPhoneLog(filter) : nullptr;
+ }
+
ContactMyProfileNumberRef ContactManager::getContactMyProfileNumber(const std::string &number)
{
auto myProfile = getOwnerProfile();
return cResValue ? std::make_shared<ContactPersonEmail>(true, cResValue) : nullptr;
}
+ ContactPersonPhoneLogRef ContactManager::getContactPersonPhoneLog(contacts_filter_h filter)
+ {
+ contacts_query_h query = nullptr;
+ contacts_list_h list = nullptr;
+ contacts_record_h crValue = nullptr;
+ contacts_record_h cResValue = nullptr;
+
+ contacts_query_create(_contacts_person_phone_log._uri, &query);
+ contacts_query_set_filter(query, filter);
+
+ unsigned int projection[] = {
+ _contacts_person_phone_log.person_id,
+ _contacts_person_phone_log.address,
+ _contacts_person_phone_log.display_name,
+ _contacts_person_phone_log.image_thumbnail_path
+ };
+
+ int ctRrr = contacts_query_set_projection(query, projection, sizeof(projection) / sizeof(unsigned int));
+ if (ctRrr == CONTACTS_ERROR_NONE)
+ ctRrr = contacts_db_get_records_with_query(query, 0, 0, &list);
+
+ contacts_filter_destroy(filter);
+ contacts_query_destroy(query);
+
+ while (ctRrr == CONTACTS_ERROR_NONE) {
+ int logId = 0;
+
+ contacts_list_get_current_record_p(list, &crValue);
+ if (crValue) {
+ contacts_record_get_int(crValue, _contacts_person_phone_log.log_id, &logId);
+ if (logId > 0)
+ cResValue = crValue;
+ else
+ contacts_record_destroy(crValue, true);
+ }
+ ctRrr = contacts_list_next(list);
+ }
+
+ contacts_list_destroy(list, false);
+ return cResValue ? std::make_shared<ContactPersonPhoneLog>(true, cResValue) : nullptr;
+ }
+
ContactAddressRef ContactManager::getAddress(const std::string &address)
{
auto it = m_AddressMap.find(address);
else
contactAddress = getContactPersonEmail(address);
+
// MyProfile:
#if (0)
if (!contactAddress)
}
#endif
+ if (!contactAddress)
+ contactAddress = getContactPersonPhoneLog(address);
+
m_AddressMap[address] = contactAddress;
return contactAddress;
}
void NaviFrameController::execCmd(const AppControlDefaultRef &cmd)
{
if (prepare(*cmd)) {
- AppControlLauncher::getInst().terminate();
AppControlDefault::DefaultType type = cmd->getDefaultType();
auto *thread = findTopFrame<MsgThreadFrame>(); // Check if thread is open
if (!thread)
if (msg) {
auto *conv = findTopFrame<ConvFrame>(); // Check if conversation is open
if (conv) {
+ AppControlLauncher::getInst().terminate();
promote(*conv);
conv->execCmd(cmd);
} else if (type == AppControlDefault::ViewType || type == AppControlDefault::ReplyType || isUnreadNotificationSingle(type)) {
+ AppControlLauncher::getInst().terminate();
conv = new ConvFrame(*this);
push(*conv);
conv->execCmd(cmd);