result _OSP_EXPORT_ TerminateAppControl(int req);
void OnAppControlResult(void*, int, service_result_e, void*);
void OnAppControlResultTizen(void*, int, service_result_e, void*);
+void OnAppControlResultLegacy(void*, int, service_result_e, void*);
static int __req = -1;
static int __processId = -1;
-static const char __allowedAppControlPickTable[][2][96] =
+static const char __allowedAppControlLegacyPickTable[][2][96] =
{
{"osp.appcontrol.CONTACT", "osp.appcontrol.operation.PICK"},
{"osp.appcontrol.provider.contact", "osp.appcontrol.operation.pick"},
{"tizen.contacts", "http://tizen.org/appcontrol/operation/pick"},
+};
+
+
+static const char __allowedAppControlPickTable[][2][96] =
+{
{"tizen.contacts", "http://tizen.org/appcontrol/operation/social/pick"},
};
-static const char __allowedAppControlAddTable[][2][96] =
+static const char __allowedAppControlLegacyAddTable[][2][96] =
{
{"osp.appcontrol.CONTACT", "osp.appcontrol.operation.ADD"},
{"osp.appcontrol.provider.contact", "osp.appcontrol.operation.add"},
{"tizen.contacts", "http://tizen.org/appcontrol/operation/add"},
+};
+
+
+static const char __allowedAppControlAddTable[][2][96] =
+{
{"tizen.contacts", "http://tizen.org/appcontrol/operation/social/add"},
};
-static const char __allowedAppControlEditTable[][2][96] =
+static const char __allowedAppControlLegacyEditTable[][2][96] =
{
{"osp.appcontrol.CONTACT", "osp.appcontrol.operation.EDIT"},
{"osp.appcontrol.provider.contact", "osp.appcontrol.operation.edit"},
{"tizen.contacts", "http://tizen.org/appcontrol/operation/edit"},
+};
+
+
+static const char __allowedAppControlEditTable[][2][96] =
+{
{"tizen.contacts", "http://tizen.org/appcontrol/operation/social/edit"},
};
-static const char __allowedAppControlViewTable[][2][96] =
+static const char __allowedAppControlLegacyViewTable[][2][96] =
{
{"osp.appcontrol.CONTACT", "osp.appcontrol.operation.VIEW"},
{"osp.appcontrol.provider.contact", "osp.appcontrol.operation.view"},
{"tizen.contacts", "http://tizen.org/appcontrol/operation/view"},
+};
+
+
+static const char __allowedAppControlViewTable[][2][96] =
+{
{"tizen.contacts", "http://tizen.org/appcontrol/operation/social/view"},
};
private:
contacts_query_h __query;
};
+
result
-StartAppControlForPick(const String* pUri, const String* pMime, const IMap* pMap)
+StartAppControl(int req, const String& aId, const String& oId, const String* pUri, const String* pMime, const IMap* pMap)
{
- _AppMessageImpl msg;
- msg.AddData(pMap);
-
- const char* pBuf = appsvc_get_data(msg.GetBundle(), PICK_OP_SEL_MODE_KEY);
- if (pBuf == null)
- {
- SysLog(NID_APP, "selectionMode has not been set");
- return E_INVALID_ARG;
- }
-
- if (strncmp(pBuf, PICK_OP_SEL_MODE_VALUE_SINGLE, PICK_OP_SEL_MODE_VALUE_LENGTH_MAX) == 0)
- {
- pBuf = appsvc_get_data(msg.GetBundle(), PICK_OP_RET_KEY_RET_TYPE);
- if (pBuf == null)
- {
- SysLog(NID_APP, "returnType has not been set");
- return E_INVALID_ARG;
- }
-
- if (strncmp(pBuf, PICK_OP_RET_VALUE_PHONE, PICK_OP_RET_VALUE_LENGTH_MAX) == 0)
- {
- msg.AddData(CORE_OP_KEY_TYPE, CORE_OP_VALUE_PICK_NUMBER);
- }
- else if (strncmp(pBuf, PICK_OP_RET_VALUE_EMAIL, PICK_OP_RET_VALUE_LENGTH_MAX) == 0)
- {
- msg.AddData(CORE_OP_KEY_TYPE, CORE_OP_VALUE_PICK_EMAIL);
- }
- else if (strncmp(pBuf, PICK_OP_RET_VALUE_VCARD, PICK_OP_RET_VALUE_LENGTH_MAX) == 0)
- {
- msg.AddData(CORE_OP_KEY_TYPE, CORE_OP_VALUE_PICK_VCARD);
- }
- else if (strncmp(pBuf, PICK_OP_RET_VALUE_CONTACT_ID, PICK_OP_RET_VALUE_LENGTH_MAX) == 0)
- {
- msg.AddData(CORE_OP_KEY_TYPE, CORE_OP_VALUE_PICK_PERSON_ID);
- }
- else
- {
- SysLog(NID_APP, "returnType must be phone, email, contactId, or vcard.");
- return E_INVALID_ARG;
- }
- }
- else if (strncmp(pBuf, PICK_OP_SEL_MODE_VALUE_MULTIPLE, PICK_OP_SEL_MODE_VALUE_LENGTH_MAX) == 0)
- {
- pBuf = appsvc_get_data(msg.GetBundle(), PICK_OP_RET_KEY_RET_TYPE);
- if (pBuf == null)
- {
- SysLog(NID_APP, "returnType has not been set");
- return E_INVALID_ARG;
- }
+ SysLog(NID_APP, "StartAppControl: Entry to Contact AppControl");
- if (strncmp(pBuf, PICK_OP_RET_VALUE_PHONE, PICK_OP_RET_VALUE_LENGTH_MAX) == 0)
- {
- msg.AddData(CORE_OP_KEY_TYPE, CORE_OP_VALUE_PICK_NUMBER_LIST);
- }
- else if (strncmp(pBuf, PICK_OP_RET_VALUE_EMAIL, PICK_OP_RET_VALUE_LENGTH_MAX) == 0)
- {
- msg.AddData(CORE_OP_KEY_TYPE, CORE_OP_VALUE_PICK_EMAIL_LIST);
- }
- else if (strncmp(pBuf, PICK_OP_RET_VALUE_CONTACT_ID, PICK_OP_RET_VALUE_LENGTH_MAX) == 0)
- {
- msg.AddData(CORE_OP_KEY_TYPE, CORE_OP_VALUE_PICK_PERSON_ID_LIST);
- }
- else
- {
- SysLog(NID_APP, "returnType must be phone, email, or contactId.");
- return E_INVALID_ARG;
- }
- }
- else
- {
- SysLog(NID_APP, "selectionMode must be either single or multiple.");
- return E_INVALID_ARG;
- }
+ result r = E_SUCCESS;
- __processId = _AppControlManager::GetInstance()->Launch(msg, "contacts-list-efl", NULL, NULL, NULL, OnAppControlResult, 0);
-
- SysTryReturnResult(NID_APP, __processId >= 0, E_SYSTEM, "StartAppControl: Launching Contacts List AppControl is failed.");
+ const bool isLegacyContactPick = _AppControlManager::IsAllowedAppControl(__allowedAppControlLegacyPickTable, 3, aId, oId);
+ const bool isContactPick = _AppControlManager::IsAllowedAppControl(__allowedAppControlPickTable, 1, aId, oId);
+ const bool isLegacyContactAdd = _AppControlManager::IsAllowedAppControl(__allowedAppControlLegacyAddTable, 3, aId, oId);
+ const bool isContactAdd = _AppControlManager::IsAllowedAppControl(__allowedAppControlAddTable, 1, aId, oId);
+ const bool isLegacyContactEdit = _AppControlManager::IsAllowedAppControl(__allowedAppControlLegacyEditTable, 3, aId, oId);
+ const bool isContactEdit = _AppControlManager::IsAllowedAppControl(__allowedAppControlEditTable, 1, aId, oId);
+ const bool isLegacyContactView = _AppControlManager::IsAllowedAppControl(__allowedAppControlLegacyViewTable, 3, aId, oId);
+ const bool isContactView = _AppControlManager::IsAllowedAppControl(__allowedAppControlViewTable, 1, aId, oId);
+ const bool isContactChoose = _AppControlManager::IsAllowedAppControl(__allowedAppControlChooseTable, 1, aId, oId);
- return E_SUCCESS;
-}
+ SysTryReturnResult(NID_APP, isLegacyContactPick || isContactPick || isLegacyContactAdd || isContactAdd || isLegacyContactEdit || isContactEdit || isLegacyContactView || isContactView || isContactChoose, E_SYSTEM, "Invalid AppControl entry for (%ls, %ls).", aId.GetPointer(), oId.GetPointer());
-result
-StartAppControlForAdd(const String* pUri, const String* pMime, const IMap* pMap)
-{
_AppMessageImpl msg;
msg.AddData(pMap);
- msg.AddData(CORE_OP_KEY_TYPE, CORE_OP_VALUE_ADD_CONTACT);
-
- const char* pBuf = appsvc_get_data(msg.GetBundle(), ADD_OP_KEY_NUMBER);
- if (pBuf != null)
- {
- msg.AddData(CORE_OP_KEY_NUMBER, String(pBuf));
- }
-
- pBuf = appsvc_get_data(msg.GetBundle(), ADD_OP_KEY_EMAIL);
- if (pBuf != null)
- {
- msg.AddData(CORE_OP_KEY_EMAIL, String(pBuf));
- }
-
- pBuf = appsvc_get_data(msg.GetBundle(), ADD_OP_KEY_URL);
- if (pBuf != null)
- {
- msg.AddData(CORE_OP_KEY_URL, String(pBuf));
- }
-
- __processId = _AppControlManager::GetInstance()->Launch(msg, "contacts-details-efl", NULL, NULL, NULL, NULL, 0);
-
- SysTryReturnResult(NID_APP, __processId >= 0, E_SYSTEM, "StartAppControl: Launching Contacts Details AppControl is failed.");
-
- return E_SUCCESS;
-}
+ AppSvcResFn pCb = NULL;
-result
-StartAppControlForEdit(const String* pUri, const String* pMime, const IMap* pMap)
-{
- _AppMessageImpl msg;
- msg.AddData(pMap);
+ String providerAppId;
+ String operation;
+ String uri;
+ const String* pActualUri = pUri;
+ const char* pBuf = null;
- const char* pBuf = appsvc_get_data(msg.GetBundle(), EDIT_OP_KEY_CONTACT_ID);
- if (pBuf != null)
+ if (isContactAdd || isLegacyContactAdd)
{
- int contactId = atoi(pBuf);
- int personId = -1;
+ providerAppId = L"tizen.contact_detail";
+ operation = L"http://tizen.org/appcontrol/operation/social/add";
- ScopedConnection conn;
- if (conn.IsConnected())
+ if (isLegacyContactAdd)
{
- contacts_record_h contactHandle = null;
- int ret = contacts_db_get_record(_contacts_simple_contact._uri, contactId, &contactHandle);
- if (ret == CONTACTS_ERROR_NONE)
+ msg.AddData(CONTACT_ITEM_TYPE, L"contact");
+
+ pBuf = appsvc_get_data(msg.GetBundle(), "phone");
+ if (pBuf != null)
{
- contacts_record_get_int(contactHandle, _contacts_simple_contact.person_id, &personId);
- contacts_record_destroy(contactHandle, true);
+ msg.AddData(L"http://tizen.org/appcontrol/data/social/phone", String(pBuf));
}
- SysLog(NID_APP, "contact ID(%s) -> person ID(%d).", pBuf, personId);
- }
-
- msg.AddData(CORE_OP_KEY_TYPE, CORE_OP_VALUE_EDIT_PERSON);
- msg.AddData(CORE_OP_KEY_PERSON_ID, Integer::ToString(personId));
-
- pBuf = appsvc_get_data(msg.GetBundle(), EDIT_OP_KEY_PHONE);
- if (pBuf != null)
- {
- msg.AddData(CORE_OP_KEY_NUMBER, String(pBuf));
- }
+ pBuf = appsvc_get_data(msg.GetBundle(), "email");
+ if (pBuf != null)
+ {
+ msg.AddData(L"http://tizen.org/appcontrol/data/social/email", String(pBuf));
+ }
- pBuf = appsvc_get_data(msg.GetBundle(), EDIT_OP_KEY_EMAIL);
- if (pBuf != null)
- {
- msg.AddData(CORE_OP_KEY_EMAIL, String(pBuf));
+ pBuf = appsvc_get_data(msg.GetBundle(), "url");
+ if (pBuf != null)
+ {
+ msg.AddData(L"http://tizen.org/appcontrol/data/social/url", String(pBuf));
+ }
}
-
- pBuf = appsvc_get_data(msg.GetBundle(), EDIT_OP_KEY_URL);
- if (pBuf != null)
+ else
{
- msg.AddData(CORE_OP_KEY_URL, String(pBuf));
+ pCb = OnAppControlResultTizen;
}
-
- __processId = _AppControlManager::GetInstance()->Launch(msg, "contacts-details-efl", NULL, NULL, NULL, NULL, 0);
-
- SysTryReturnResult(NID_APP, __processId >= 0, E_SYSTEM, "StartAppControl: Launching Contacts Details AppControl is failed.");
}
- else
+ else if (isContactEdit || isLegacyContactEdit)
{
- msg.AddData(CORE_OP_KEY_TYPE, CORE_OP_VALUE_EDIT_PERSON_BY_SEL);
-
- pBuf = appsvc_get_data(msg.GetBundle(), EDIT_OP_KEY_PHONE);
- if (pBuf != null)
- {
- msg.AddData(CORE_OP_KEY_NUMBER, String(pBuf));
- }
-
- pBuf = appsvc_get_data(msg.GetBundle(), EDIT_OP_KEY_EMAIL);
- if (pBuf != null)
- {
- msg.AddData(CORE_OP_KEY_EMAIL, String(pBuf));
- }
+ providerAppId = L"tizen.contact_detail";
- pBuf = appsvc_get_data(msg.GetBundle(), EDIT_OP_KEY_URL);
- if (pBuf != null)
+ if (isLegacyContactEdit)
{
- msg.AddData(CORE_OP_KEY_URL, String(pBuf));
- }
-
- __processId = _AppControlManager::GetInstance()->Launch(msg, "contacts-list-efl", NULL, NULL, NULL, NULL, 0);
-
- SysTryReturnResult(NID_APP, __processId >= 0, E_SYSTEM, "StartAppControl: Launching Contacts List AppControl is failed.");
- }
-
- return E_SUCCESS;
-}
-
-result
-StartAppControlForView( const String* pUri, const String* pMime, const IMap* pMap)
-{
-
- _AppMessageImpl msg;
- msg.AddData(pMap);
+ msg.AddData(CONTACT_ITEM_TYPE, L"person");
- msg.AddData(CORE_OP_KEY_TYPE, CORE_OP_VALUE_VIEW_PERSON);
+ pBuf = appsvc_get_data(msg.GetBundle(), EDIT_OP_KEY_CONTACT_ID);
+ if (pBuf != null)
+ {
+ operation = L"http://tizen.org/appcontrol/operation/social/edit";
- const char* pBuf = appsvc_get_data(msg.GetBundle(), VIEW_OP_KEY_VIEW_TYPE);
- if (pBuf == null)
- {
- SysLog(NID_APP, "viewType has not been set");
- return E_SUCCESS;
- }
+ int contactId = atoi(pBuf);
+ int personId = -1;
- if (strncmp(pBuf, VIEW_OP_VALUE_CONTACT, VIEW_OP_VALUE_LENGTH_MAX) == 0)
- {
- int contactId = -1;
- int personId = -1;
+ ScopedConnection conn;
+ if (conn.IsConnected())
+ {
+ contacts_record_h contactHandle = null;
+ int ret = contacts_db_get_record(_contacts_simple_contact._uri, contactId, &contactHandle);
+ if (ret == CONTACTS_ERROR_NONE)
+ {
+ contacts_record_get_int(contactHandle, _contacts_simple_contact.person_id, &personId);
+ contacts_record_destroy(contactHandle, true);
+ }
+ }
- ScopedConnection conn;
-
- pBuf = appsvc_get_data(msg.GetBundle(), VIEW_OP_KEY_CONTACT_ID);
- if (pBuf != null)
- {
- contactId = atoi(pBuf);
+ msg.AddData(L"http://tizen.org/appcontrol/data/social/item_id", Integer::ToString(personId));
+ }
+ else
+ {
+ operation = L"http://tizen.org/appcontrol/operation/social/choose";
+ }
- if (conn.IsConnected())
+ pBuf = appsvc_get_data(msg.GetBundle(), "phone");
+ if (pBuf != null)
{
- contacts_record_h contactHandle = null;
- int ret = contacts_db_get_record(_contacts_simple_contact._uri, contactId, &contactHandle);
- if (ret == CONTACTS_ERROR_NONE)
- {
- contacts_record_get_int(contactHandle, _contacts_simple_contact.person_id, &personId);
- contacts_record_destroy(contactHandle, true);
+ msg.AddData(L"http://tizen.org/appcontrol/data/social/phone", String(pBuf));
+ }
- }
+ pBuf = appsvc_get_data(msg.GetBundle(), "email");
+ if (pBuf != null)
+ {
+ msg.AddData(L"http://tizen.org/appcontrol/data/social/email", String(pBuf));
}
- }
- else
- {
- SysLog(NID_APP, "The value for contactId is not set.");
- return E_SUCCESS;
- }
- msg.AddData(CORE_OP_KEY_PERSON_ID, Integer::ToString(personId));
- }
- else if (strncmp(pBuf, VIEW_OP_VALUE_VCARD, VIEW_OP_VALUE_LENGTH_MAX) == 0)
- {
- pBuf = appsvc_get_data(msg.GetBundle(), VIEW_OP_KEY_VCARD_PATH);
- if (pBuf != null)
- {
- msg.AddData(CORE_OP_KEY_VCARD, pBuf);
+ pBuf = appsvc_get_data(msg.GetBundle(), "url");
+ if (pBuf != null)
+ {
+ msg.AddData(L"http://tizen.org/appcontrol/data/social/url", String(pBuf));
+ }
}
else
{
- SysLog(NID_APP, "The value for path is not set.");
- return E_SUCCESS;
+ operation = L"http://tizen.org/appcontrol/operation/social/edit";
}
-
}
- else
- {
- SysLog(NID_APP, "viewType must be either vcf or contact.");
- return E_SUCCESS;
- }
-
- __processId = _AppControlManager::GetInstance()->Launch(msg, "contacts-details-efl", NULL, NULL, NULL, NULL, 0);
-
- SysTryReturnResult(NID_APP, __processId >= 0, E_SYSTEM, "StartAppControl: Launching Contacts Details AppControl is failed.");
-
- return E_SUCCESS;
-}
-
-result
-StartAppControl(int req, const String& aId, const String& oId, const String* pUri, const String* pMime, const IMap* pMap)
-{
- SysLog(NID_APP, "StartAppControl: Entry to Contact AppControl");
-
- result r = E_SUCCESS;
-
- const bool isContactPick = _AppControlManager::IsAllowedAppControl(__allowedAppControlPickTable, 4, aId, oId);
- const bool isContactAdd = _AppControlManager::IsAllowedAppControl(__allowedAppControlAddTable, 4, aId, oId);
- const bool isContactEdit = _AppControlManager::IsAllowedAppControl(__allowedAppControlEditTable, 4, aId, oId);
- const bool isContactView = _AppControlManager::IsAllowedAppControl(__allowedAppControlViewTable, 4, aId, oId);
- const bool isContactChoose = _AppControlManager::IsAllowedAppControl(__allowedAppControlChooseTable, 1, aId, oId);
-
- SysTryReturnResult(NID_APP, isContactPick || isContactAdd || isContactEdit || isContactView || isContactChoose, E_SYSTEM, "Invalid AppControl entry for (%ls, %ls).", aId.GetPointer(), oId.GetPointer());
-
- SysLog(NID_APP, "Contact AppControl : %ls operation.", oId.GetPointer());
-
-#ifdef __i386__
- _AppMessageImpl msg;
- msg.AddData(pMap);
-
- AppSvcResFn pCb = NULL;
-
- String providerAppId;
- String operation;
- String uri;
- const String* pActualUri = pUri;
-
- if (isContactAdd)
- {
- providerAppId = L"tizen.contact_detail";
- operation = L"http://tizen.org/appcontrol/operation/social/add";
- pCb = OnAppControlResultTizen;
-
- msg.AddData(CONTACT_ITEM_TYPE, L"contact");
- }
- else if (isContactEdit)
- {
- providerAppId = L"tizen.contact_detail";
- operation = L"http://tizen.org/appcontrol/operation/social/edit";
- pCb = OnAppControlResultTizen;
-
- msg.AddData(CONTACT_ITEM_TYPE, L"person");
- }
- else if (isContactView)
+ else if (isContactView || isLegacyContactView)
{
providerAppId = L"tizen.contact_detail";
else
{
operation = L"http://tizen.org/appcontrol/operation/social/view";
-
msg.AddData(CONTACT_ITEM_TYPE, L"person");
- const String& contactId = msg.GetValue(L"contactId");
- if (!contactId.IsEmpty())
+ pBuf = appsvc_get_data(msg.GetBundle(), "contactId");
+ if (pBuf != null)
{
- msg.AddData(CONTACT_ITEM_ID, contactId);
- msg.RemoveData(L"contactId");
+ int contactId = atoi(pBuf);
+ int personId = -1;
+
+ ScopedConnection conn;
+ if (conn.IsConnected())
+ {
+ contacts_record_h contactHandle = null;
+ int ret = contacts_db_get_record(_contacts_simple_contact._uri, contactId, &contactHandle);
+ if (ret == CONTACTS_ERROR_NONE)
+ {
+ contacts_record_get_int(contactHandle, _contacts_simple_contact.person_id, &personId);
+ contacts_record_destroy(contactHandle, true);
+ }
+ }
+
+ msg.AddData(L"http://tizen.org/appcontrol/data/social/item_id", Integer::ToString(personId));
}
}
-
- pCb = NULL;
}
- else if (isContactPick)
+ else if (isContactPick || isLegacyContactPick)
{
providerAppId = L"tizen.contact_list";
operation = L"http://tizen.org/appcontrol/operation/social/pick";
- pCb = OnAppControlResultTizen;
-
- msg.AddData(CONTACT_ITEM_TYPE, L"person");
- const String& mode = msg.GetValue(L"selectionMode");
- if (!mode.IsEmpty())
+ if (isLegacyContactPick)
{
- msg.AddData(SELECTION_MODE, mode);
- msg.RemoveData(L"selectionMode");
- }
+ msg.AddData(CONTACT_ITEM_TYPE, L"person");
+
+ const String& mode = msg.GetValue(L"selectionMode");
+ if (!mode.IsEmpty())
+ {
+ msg.AddData(SELECTION_MODE, mode);
+ msg.RemoveData(L"selectionMode");
+ }
+
+ const String& retType = msg.GetValue(L"returnType");
+ if (!retType.IsEmpty())
+ {
+ if (retType == L"contactId")
+ {
+ msg.AddData(CONTACT_RESULT_TYPE, L"item_id");
+ }
+ else
+ {
+ msg.AddData(CONTACT_RESULT_TYPE, retType);
+ }
- const String& retType = msg.GetValue(L"returnType");
- if (!retType.IsEmpty())
+ msg.RemoveData(L"returnType");
+ }
+
+ pCb = OnAppControlResultLegacy;
+ }
+ else
{
- msg.AddData(CONTACT_RESULT_TYPE, retType);
- msg.RemoveData(L"returnType");
+ pCb = OnAppControlResultTizen;
}
}
else if (isContactChoose)
providerAppId = L"tizen.contact_list";
operation = L"http://tizen.org/appcontrol/operation/social/choose";
pCb = OnAppControlResultTizen;
-
- msg.AddData(CONTACT_ITEM_TYPE, L"person");
}
else
{
}
const String& package = _AppControlManager::GetAliasAppId(aId);
- SysLog(NID_APP, "Actual packageId is %ls.", package.GetPointer());
__req = req;
__processId = _AppControlManager::GetInstance()->Launch(msg, package, operation, pActualUri, pMime, pCb, 0);
r = E_SUCCESS;
SysLog(NID_APP, "StartAppControl: Launching Contact AppControl succeeded");
-#else
- if (isContactPick)
- {
- SysLog(NID_APP, "Contact AppControl : PICK operation.");
-
- __req = req;
-
- r = StartAppControlForPick(pUri, pMime, pMap);
- if (r == E_INVALID_ARG)
- {
- SysLog(NID_APP, "Finish pick operation.");
- _AppControlManager::GetInstance()->FinishAppControl(__req, APP_CTRL_RESULT_FAILED, null);
-
- __req = -1;
-
- return E_SUCCESS;
- }
- SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] System error.", GetErrorMessage(r));
-
- SysLog(NID_APP, "StartAppControl: Launching Contact AppControl succeeded");
- }
- else if (isContactAdd)
- {
- SysLog(NID_APP, "Contact AppControl : ADD operation.");
-
- r = StartAppControlForAdd(pUri, pMime, pMap);
- SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] System error.", GetErrorMessage(r));
-
- SysLog(NID_APP, "StartAppControl: Launching Contact AppControl succeeded");
- }
- else if (isContactEdit)
- {
- SysLog(NID_APP, "Contact AppControl : EDIT operation.");
-
- r = StartAppControlForEdit(pUri, pMime, pMap);
- SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] System error.", GetErrorMessage(r));
-
- SysLog(NID_APP, "StartAppControl: Launching Contact AppControl succeeded");
- }
- else if (isContactView)
- {
- SysLog(NID_APP, "Contact AppControl : VIEW operation.");
-
- r = StartAppControlForView(pUri, pMime, pMap);
- SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] System error.", GetErrorMessage(r));
-
- SysLog(NID_APP, "StartAppControl: Launching Contact AppControl succeeded");
- }
-#endif
return r;
}
void
-OnAppControlResultForPickNumber(const char* pRawData, HashMap* pResult)
+OnAppControlResultTizen(void* b, int requestCode, service_result_e res, void* userData)
{
- ScopedConnection conn;
- if (!conn.IsConnected())
- {
- return;
- }
-
- int numberId = atoi(pRawData);
- char* pPhoneNumber = null;
-
- contacts_record_h recordHandle = null;
-
- int ret = contacts_db_get_record(_contacts_number._uri, numberId, &recordHandle);
- if (ret == CONTACTS_ERROR_NONE)
- {
- ScopedHandle numberHandle(recordHandle);
- contacts_record_get_str_p(numberHandle.Get(), _contacts_number.number, &pPhoneNumber);
-
- pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_RET_TYPE), new (std::nothrow) String(PICK_OP_RET_VALUE_PHONE));
- pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_VALUE), new (std::nothrow) String(pPhoneNumber));
- }
-}
+ result r = E_SYSTEM;
+ bundle* pBundle = static_cast<bundle*>(b);
-void
-OnAppControlResultForPickNumberList(const char* pRawData, HashMap* pResult)
-{
- ScopedConnection conn;
- if (!conn.IsConnected())
- {
- return;
- }
+ HashMap* pResult = new (std::nothrow) HashMap();
+ SysTryCatch(NID_APP, pResult != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Allocation failure.");
- int id = 0;
- bool isFirst = true;
- String numbers;
- String encodedString(pRawData);
- std::unique_ptr<ByteBuffer> pDecodeByteBuffer(StringUtil::DecodeBase64StringN(encodedString));
-
- while (pDecodeByteBuffer->GetInt(id) == E_SUCCESS)
- {
- char* pNumber = null;
- contacts_record_h recordHandle = null;
- int ret = contacts_db_get_record(_contacts_number._uri, id, &recordHandle);
- if (ret != CONTACTS_ERROR_NONE)
- {
- continue;
- }
-
- ScopedHandle numberHandle(recordHandle);
-
- contacts_record_get_str_p(numberHandle.Get(), _contacts_number.number, &pNumber);
+ r = pResult->Construct();
- if(!isFirst)
- {
- numbers.Append(L";");
- }
- else
- {
- isFirst = false;
- }
+ _AppArg::SetArgMap(pBundle, pResult);
- numbers.Append(pNumber);
- }
+ _AppControlManager::GetInstance()->FinishAppControl(__req, res, pResult);
- pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_RET_TYPE), new (std::nothrow) String(L"phone"));
- pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_VALUE), new (std::nothrow) String(numbers));
+CATCH:
+ __req = -1;
}
-
void
-OnAppControlResultForPickEmail(const char* pRawData, HashMap* pResult)
+OnAppControlResultLegacy(void* b, int requestCode, service_result_e res, void* userData)
{
- ScopedConnection conn;
- if (!conn.IsConnected())
- {
- return;
- }
-
- char* pEmail = null;
- int emailId = atoi(pRawData);
- contacts_record_h recordHandle = null;
-
- int ret = contacts_db_get_record(_contacts_email._uri, emailId, &recordHandle);
- if (ret != CONTACTS_ERROR_NONE)
- {
- return;
- }
-
- ScopedHandle emailHandle(recordHandle);
-
- contacts_record_get_str_p(emailHandle.Get(), _contacts_email.email, &pEmail);
-
- pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_RET_TYPE), new (std::nothrow) String(PICK_OP_RET_VALUE_EMAIL));
- pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_VALUE), new (std::nothrow) String(pEmail));
-}
+ result r = E_SYSTEM;
+ bundle* pBundle = static_cast<bundle*>(b);
-void
-OnAppControlResultForPickEmailList(const char* pRawData, HashMap* pResult)
-{
- ScopedConnection conn;
- if (!conn.IsConnected())
- {
- return;
- }
+ HashMap* pResult = new (std::nothrow) HashMap();
+ SysTryCatch(NID_APP, pResult != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Allocation failure.");
- int id = 0;
- bool isFirst = true;
- String emailIds;
- String encodedString(pRawData);
- std::unique_ptr<ByteBuffer> pDecodeByteBuffer(StringUtil::DecodeBase64StringN(encodedString));
+ r = pResult->Construct();
- while (pDecodeByteBuffer->GetInt(id) == E_SUCCESS)
+ switch (res)
{
- char* pEmail = null;
- contacts_record_h recordHandle = null;
- int ret = contacts_db_get_record(_contacts_email._uri, id, &recordHandle);
- if (ret != CONTACTS_ERROR_NONE)
+ case SERVICE_RESULT_SUCCEEDED:
{
- continue;
- }
-
- ScopedHandle emailHandle(recordHandle);
- contacts_record_get_str_p(emailHandle.Get(), _contacts_email.email, &pEmail);
+ _AppArg::SetArgMap(pBundle, pResult);
- if(!isFirst)
+ ArrayList* pList = static_cast<ArrayList*>(pResult->GetValue(String(L"http://tizen.org/appcontrol/data/social/phone")));
+ if (pList != null)
{
- emailIds.Append(L";");
- }
- else
- {
- isFirst = false;
- }
-
- emailIds.Append(pEmail);
- }
-
- pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_RET_TYPE), new (std::nothrow) String(L"email"));
- pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_VALUE), new (std::nothrow) String(emailIds));
-}
-
-void
-OnAppControlResultForPickContact(const char* pRawData, HashMap* pResult)
-{
- ScopedConnection conn;
- if (!conn.IsConnected())
- {
- return;
- }
-
- int personId = atoi(pRawData);
- int contactId = 0;
-
- unsigned int simple_contact_projection[] = {
- _contacts_simple_contact.id,
- _contacts_simple_contact.address_book_id,
- };
-
- contacts_filter_h filterHandle = null;
- int ret = contacts_filter_create(_contacts_simple_contact._uri, &filterHandle);
- if (ret != CONTACTS_ERROR_NONE)
- {
- return;
- }
-
- ScopedFilter filter(filterHandle);
- contacts_filter_add_int(filter.Get(), _contacts_simple_contact.person_id, CONTACTS_MATCH_EQUAL, personId);
-
- contacts_query_h queryHandle = null;
- ret = contacts_query_create(_contacts_simple_contact._uri, &queryHandle);
- if (ret != CONTACTS_ERROR_NONE)
- {
- return;
- }
-
- ScopedQuery query(queryHandle);
- ret = contacts_query_set_filter(query.Get(), filter.Get());
- if (ret != CONTACTS_ERROR_NONE)
- {
- return;
- }
-
- ret = contacts_query_set_projection(query.Get(), simple_contact_projection, sizeof(simple_contact_projection)/sizeof(unsigned int));
- if (ret != CONTACTS_ERROR_NONE)
- {
- return;
- }
+ bool isFirst = true;
+ String retValue;
- ret = contacts_query_set_sort(query.Get(), _contacts_simple_contact.address_book_id, true);
- if (ret != CONTACTS_ERROR_NONE)
- {
- return;
- }
-
-
- contacts_list_h listHandle = null;
- ret = contacts_db_get_records_with_query(query.Get(), 0, 0, &listHandle);
- if (ret != CONTACTS_ERROR_NONE)
- {
- return;
- }
-
- ScopedList contactList(listHandle);
-
- unsigned int count = 0;
- contacts_list_get_count(contactList.Get(), &count);
- if (count <= 0)
- {
- return;
- }
-
- contacts_record_h contactHandle = null;
- contacts_list_get_current_record_p(contactList.Get(), &contactHandle);
- contacts_record_get_int(contactHandle, _contacts_simple_contact.id, &contactId);
-
- pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_RET_TYPE), new (std::nothrow) String(PICK_OP_RET_VALUE_CONTACT_ID));
- pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_VALUE), new (std::nothrow) String(Integer::ToString(contactId)));
-}
-
-void
-OnAppControlResultForPickContactList(const char* pRawData, HashMap* pResult)
-{
- ScopedConnection conn;
- if (!conn.IsConnected())
- {
- return;
- }
+ std::unique_ptr<IEnumerator> pEnum(pList->GetEnumeratorN());
+ SysTryCatch(NID_APP, pEnum != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Allocation failure.");
- String personIds;
- int id = 0;
- int contactId;
- bool isFirst = true;
- String encodedString(pRawData);
- std::unique_ptr<ByteBuffer> pDecodeByteBuffer(StringUtil::DecodeBase64StringN(encodedString));
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ String* pPhoneNumber = static_cast<String*>(pEnum->GetCurrent());
- while (pDecodeByteBuffer->GetInt(id) == E_SUCCESS)
- {
- unsigned int simple_contact_projection[] = {
- _contacts_simple_contact.id,
- _contacts_simple_contact.address_book_id,
- };
+ if (!isFirst)
+ {
+ retValue.Append(L";");
+ }
+ else
+ {
+ isFirst = false;
+ }
- contacts_record_h contactHandle = null;
+ retValue.Append(*pPhoneNumber);
+ }
- contacts_filter_h filterHandle = null;
- int ret = contacts_filter_create(_contacts_simple_contact._uri, &filterHandle);
- if (ret != CONTACTS_ERROR_NONE)
- {
- break;
+ pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_RET_TYPE), new (std::nothrow) String(PICK_OP_RET_VALUE_PHONE));
+ pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_VALUE), new (std::nothrow) String(retValue));
}
- ScopedFilter filter(filterHandle);
-
-
- contacts_filter_add_int(filter.Get(), _contacts_simple_contact.person_id, CONTACTS_MATCH_EQUAL, id);
-
- contacts_query_h queryHandle = null;
- ret = contacts_query_create(_contacts_simple_contact._uri, &queryHandle);
- if (ret != CONTACTS_ERROR_NONE)
+ pList = static_cast<ArrayList*>(pResult->GetValue(String(L"http://tizen.org/appcontrol/data/social/email")));
+ if (pList != null)
{
- break;
- }
+ bool isFirst = true;
+ String retValue;
- ScopedQuery query(queryHandle);
+ std::unique_ptr<IEnumerator> pEnum(pList->GetEnumeratorN());
+ SysTryCatch(NID_APP, pEnum != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Allocation failure.");
- ret = contacts_query_set_filter(query.Get(), filter.Get());
- if (ret != CONTACTS_ERROR_NONE)
- {
- break;
- }
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ String* pEmail = static_cast<String*>(pEnum->GetCurrent());
- ret = contacts_query_set_projection(query.Get(), simple_contact_projection, sizeof(simple_contact_projection)/sizeof(unsigned int));
- if (ret != CONTACTS_ERROR_NONE)
- {
- break;
- }
+ if (!isFirst)
+ {
+ retValue.Append(L";");
+ }
+ else
+ {
+ isFirst = false;
+ }
- ret = contacts_query_set_sort(query.Get(), _contacts_simple_contact.address_book_id, true);
- if (ret != CONTACTS_ERROR_NONE)
- {
- break;
- }
+ retValue.Append(*pEmail);
+ }
+ pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_RET_TYPE), new (std::nothrow) String(PICK_OP_RET_VALUE_EMAIL));
+ pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_VALUE), new (std::nothrow) String(retValue));
+ }
- contacts_list_h listHandle = null;
- ret = contacts_db_get_records_with_query(query.Get(), 0, 0, &listHandle);
- if (ret != CONTACTS_ERROR_NONE)
+ String* pString = dynamic_cast<String*>(pResult->GetValue(String(L"http://tizen.org/appcontrol/data/path")));
+ if (pString != null)
{
- break;
+ pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_RET_TYPE), new (std::nothrow) String(PICK_OP_RET_VALUE_VCARD));
+ pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_VALUE), new (std::nothrow) String(*pString));
}
-
- ScopedList contactList(listHandle);
- unsigned int count = 0;
- contacts_list_get_count(contactList.Get(), &count);
- if (count > 0)
+ else
{
- contacts_list_get_current_record_p(contactList.Get(), &contactHandle);
- contacts_record_get_int(contactHandle, _contacts_simple_contact.id, &contactId);
- if (!isFirst)
+ String* pString = static_cast<String*>(pResult->GetValue(String(L"http://tizen.org/appcontrol/data/path")));
+ if (pString != null)
{
- personIds.Append(L";");
+ pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_RET_TYPE), new (std::nothrow) String(PICK_OP_RET_VALUE_VCARD));
+ pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_VALUE), new (std::nothrow) String(*pString));
}
- else
- {
- isFirst = false;
- }
-
- personIds.Append(id);
-
}
- }
-
- pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_RET_TYPE), new (std::nothrow) String(PICK_OP_RET_VALUE_CONTACT_ID));
- pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_VALUE), new (std::nothrow) String(personIds));
- contacts_disconnect2();
-
-}
-
-void
-OnAppControlResultForPickVcard(const char* pRawData, HashMap* pResult)
-{
- pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_RET_TYPE), new (std::nothrow) String(PICK_OP_RET_VALUE_VCARD));
- pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_VALUE), new (std::nothrow) String(pRawData));
-}
-
-void
-OnAppControlResult(void* b, int requestCode, service_result_e res, void* userData)
-{
- result r = E_SYSTEM;
- bundle* pBundle = static_cast<bundle*>(b);
- AppCtrlResult appControlResult = APP_CTRL_RESULT_SUCCEEDED;
- std::unique_ptr<HashMap, AllElementsDeleter> pResult(null);
-
- switch (res)
- {
- case SERVICE_RESULT_SUCCEEDED:
- {
- pResult.reset(new (std::nothrow) HashMap());
- SysTryCatch(NID_APP, pResult != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
-
- r = pResult->Construct();
- SysTryCatch(NID_APP, !IsFailed(r), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
-
- const char* pBuf = appsvc_get_data(pBundle, CORE_RESULT_TYPE_KEY_NUMBER);
- if (pBuf != null)
- {
- OnAppControlResultForPickNumber(pBuf, pResult.get());
- break;
- }
+ pList = static_cast<ArrayList*>(pResult->GetValue(String(L"http://tizen.org/appcontrol/data/social/item_id")));
+ if (pList != null)
+ {
+ bool isFirst = true;
+ int contactId = 0;
+ int id = 0;
+ String retValue;
- pBuf = appsvc_get_data(pBundle, CORE_RESULT_TYPE_KEY_EMAIL);
- if (pBuf != null)
- {
- OnAppControlResultForPickEmail(pBuf, pResult.get());
- break;
- }
+ std::unique_ptr<IEnumerator> pEnum(pList->GetEnumeratorN());
+ SysTryCatch(NID_APP, pEnum != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Allocation failure.");
- pBuf = appsvc_get_data(pBundle, CORE_RESULT_TYPE_KEY_PERSON);
- if (pBuf != null)
- {
- OnAppControlResultForPickContact(pBuf, pResult.get());
- break;
- }
-
- pBuf = appsvc_get_data(pBundle, CORE_RESULT_TYPE_KEY_VCARD);
- if (pBuf != null)
+ ScopedConnection conn;
+ if (conn.IsConnected())
{
- OnAppControlResultForPickVcard(pBuf, pResult.get());
- break;
- }
+ unsigned int simple_contact_projection[] = {
+ _contacts_simple_contact.id,
+ _contacts_simple_contact.address_book_id,
+ };
- pBuf = appsvc_get_data(pBundle, CORE_RESULT_TYPE_KEY_NUMBER_LIST);
- if (pBuf != null)
- {
- OnAppControlResultForPickNumberList(pBuf, pResult.get());
- break;
- }
- pBuf = appsvc_get_data(pBundle, CORE_RESULT_TYPE_KEY_EMAIL_LIST);
- if (pBuf != null)
- {
- OnAppControlResultForPickEmailList(pBuf, pResult.get());
- break;
- }
-
- pBuf = appsvc_get_data(pBundle, CORE_RESULT_TYPE_KEY_PERSON_LIST);
- if (pBuf != null)
- {
- OnAppControlResultForPickContactList(pBuf, pResult.get());
- break;
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ String* pPersonId = static_cast<String*>(pEnum->GetCurrent());
+ Integer::Decode(*pPersonId, id);
+
+ contacts_filter_h filterHandle = null;
+ int ret = contacts_filter_create(_contacts_simple_contact._uri, &filterHandle);
+ if (ret != CONTACTS_ERROR_NONE)
+ {
+ break;
+ }
+
+ ScopedFilter filter(filterHandle);
+
+ contacts_filter_add_int(filter.Get(), _contacts_simple_contact.person_id, CONTACTS_MATCH_EQUAL, id);
+
+ contacts_query_h queryHandle = null;
+ ret = contacts_query_create(_contacts_simple_contact._uri, &queryHandle);
+ if (ret != CONTACTS_ERROR_NONE)
+ {
+ break;
+ }
+
+ ScopedQuery query(queryHandle);
+
+ ret = contacts_query_set_filter(query.Get(), filter.Get());
+ if (ret != CONTACTS_ERROR_NONE)
+ {
+ break;
+ }
+
+ ret = contacts_query_set_projection(query.Get(), simple_contact_projection, sizeof(simple_contact_projection)/sizeof(unsigned int));
+ if (ret != CONTACTS_ERROR_NONE)
+ {
+ break;
+ }
+
+ ret = contacts_query_set_sort(query.Get(), _contacts_simple_contact.address_book_id, true);
+ if (ret != CONTACTS_ERROR_NONE)
+ {
+ break;
+ }
+
+
+ contacts_list_h listHandle = null;
+ ret = contacts_db_get_records_with_query(query.Get(), 0, 0, &listHandle);
+ if (ret != CONTACTS_ERROR_NONE)
+ {
+ break;
+ }
+
+ ScopedList contactList(listHandle);
+ unsigned int count = 0;
+ contacts_list_get_count(contactList.Get(), &count);
+ if (count > 0)
+ {
+ contacts_record_h contactHandle = null;
+ contacts_list_get_current_record_p(contactList.Get(), &contactHandle);
+ contacts_record_get_int(contactHandle, _contacts_simple_contact.id, &contactId);
+ }
+
+ if (!isFirst)
+ {
+ retValue.Append(L";");
+ }
+ else
+ {
+ isFirst = false;
+ }
+
+ retValue.Append(contactId);
+ }
}
+ pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_RET_TYPE), new (std::nothrow) String(PICK_OP_RET_VALUE_CONTACT_ID));
+ pResult->Add(new (std::nothrow) String(PICK_OP_RET_KEY_VALUE), new (std::nothrow) String(retValue));
+ }
}
break;
- case SERVICE_RESULT_FAILED:
- case SERVICE_RESULT_CANCELED:
+
default:
- appControlResult = APP_CTRL_RESULT_FAILED;
break;
}
- _AppControlManager::GetInstance()->FinishAppControl(__req, appControlResult, pResult.release());
-
-CATCH:
- __req = -1;
-}
-
-void
-OnAppControlResultTizen(void* b, int requestCode, service_result_e res, void* userData)
-{
- result r = E_SYSTEM;
- bundle* pBundle = static_cast<bundle*>(b);
-
- HashMap* pResult = new (std::nothrow) HashMap();
- SysTryCatch(NID_APP, pResult != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Allocation failure.");
-
- r = pResult->Construct();
-
- _AppArg::SetArgMap(pBundle, pResult);
-
_AppControlManager::GetInstance()->FinishAppControl(__req, res, pResult);
CATCH: