summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvivek <vivek.ellur@samsung.com>2013-07-18 14:30:19 +0530
committervivek <vivek.ellur@samsung.com>2013-08-21 17:11:48 +0530
commit7428459afc4860f7ca3287682763fea07f12b1b3 (patch)
tree83e02d75d5a8eeec6aa950c0beb4bc53323ff161
parent6b76cc373c9d889503902c1f00bf4afa6345f34a (diff)
downloadsocial-7428459afc4860f7ca3287682763fea07f12b1b3.tar.gz
social-7428459afc4860f7ca3287682763fea07f12b1b3.tar.bz2
social-7428459afc4860f7ca3287682763fea07f12b1b3.zip
Replaced all the references for contacts_db_update_record with AddressbookUtil::UpdateContactRecord method
Change-Id: Ie5f369c3302ca13ecaf8d4806988dadac51054c4
-rw-r--r--src/FScl_AddressbookImpl.cpp35
-rw-r--r--src/FScl_AddressbookManagerImpl.cpp43
-rw-r--r--src/FScl_AddressbookUtil.h22
-rw-r--r--src/FScl_PersonImpl.cpp5
4 files changed, 60 insertions, 45 deletions
diff --git a/src/FScl_AddressbookImpl.cpp b/src/FScl_AddressbookImpl.cpp
index ac2d0c4..b482df9 100644
--- a/src/FScl_AddressbookImpl.cpp
+++ b/src/FScl_AddressbookImpl.cpp
@@ -464,8 +464,8 @@ _AddressbookImpl::UpdateContact(const Contact& contact)
recordHandle = _ContactImpl::GetInstance(contact)->GetContactRecordHandle();
SysTryReturn(NID_SCL, recordHandle != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- ret = contacts_db_update_record(recordHandle);
- if (ret == CONTACTS_ERROR_NO_DATA)
+ result r = _AddressbookUtil::UpdateContactRecord(recordHandle);
+ if (r == E_OBJ_NOT_FOUND)
{
unsigned int count = 0;
unsigned int count2 = 0;
@@ -557,12 +557,14 @@ _AddressbookImpl::UpdateContact(const Contact& contact)
tempPath.Clear();
}
+ SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_FILE_NO_SPACE, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is insufficient.", GetErrorMessage(E_STORAGE_FULL));
+ SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+ }
+ else
+ {
+ SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
}
-
- SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_FILE_NO_SPACE, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is insufficient.", GetErrorMessage(E_STORAGE_FULL));
- SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
-
ret = contacts_db_get_record(_contacts_contact._uri, contactId, &recordHandle);
SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_NO_DATA, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] The contact is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
@@ -630,11 +632,8 @@ _AddressbookImpl::UpdateCategory(const Category& category)
SysTryReturn(NID_SCL, count == 0, E_OBJ_ALREADY_EXIST, E_OBJ_ALREADY_EXIST, "[%s] The category name is alread being used by other category.", GetErrorMessage(E_OBJ_ALREADY_EXIST));
}
- ret = contacts_db_update_record(recordHandle);
- SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_NO_DATA, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] The contact is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
- SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_FILE_NO_SPACE, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is insufficient.", GetErrorMessage(E_STORAGE_FULL));
- SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+ result r = _AddressbookUtil::UpdateContactRecord(recordHandle);
+ SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
ret = contacts_db_get_record(_contacts_group._uri, category.GetRecordId(), &recordHandle);
SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_NO_DATA, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] The category is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
@@ -1338,12 +1337,9 @@ _AddressbookImpl::UpdateContacts(const Tizen::Base::Collection::IList& contactLi
contacts_list_add(listHandle, recordHandle);
}
- ret = contacts_db_update_records(listHandle);
+ result r = _AddressbookUtil::UpdateContactRecords(listHandle);
+ SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
contacts_list_destroy(listHandle, false);
- SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_NO_DATA, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] The contact is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
- SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_INVALID_PARAMETER, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
- SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
return E_SUCCESS;
}
@@ -1439,10 +1435,9 @@ _AddressbookImpl::SetUserProfile(const UserProfile* pUserProfile)
ret = contacts_record_clone(recordHandle, &newRecordHandle);
SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- ret = contacts_db_update_record(newRecordHandle);
+ result r = _AddressbookUtil::UpdateContactRecord(newRecordHandle);
+ SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
contacts_record_destroy(newRecordHandle, true);
- SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
}
else
{
diff --git a/src/FScl_AddressbookManagerImpl.cpp b/src/FScl_AddressbookManagerImpl.cpp
index 8acd001..a0a88c4 100644
--- a/src/FScl_AddressbookManagerImpl.cpp
+++ b/src/FScl_AddressbookManagerImpl.cpp
@@ -456,7 +456,7 @@ _AddressbookManagerImpl::RemoveCategory(RecordId categoryId)
{
SysTryReturn(NID_SCL, categoryId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified categoryId is invalid", GetErrorMessage(E_INVALID_ARG));
SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
-
+
unique_ptr<ContactRecord, ContactRecordDeleter> pCategoryRecord(_AddressbookUtil::GetContactRecordN(_contacts_group._uri, categoryId));
SysTryReturn(NID_SCL, pCategoryRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
@@ -488,14 +488,14 @@ _AddressbookManagerImpl::UpdateContact(const Contact& contact)
contacts_record_h recordHandle = _ContactImpl::GetInstance(contact)->GetContactRecordHandle();
SysTryReturn(NID_SCL, recordHandle != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- int ret = contacts_db_update_record(recordHandle);
- if (ret == CONTACTS_ERROR_NO_DATA)
+ result r = _AddressbookUtil::UpdateContactRecord(recordHandle);
+ if (r == E_OBJ_NOT_FOUND)
{
unsigned int count = 0;
unsigned int count2 = 0;
contacts_record_h newRecordHandle = null;
- ret = contacts_db_get_record(_contacts_contact._uri, contactId, &newRecordHandle);
+ int ret = contacts_db_get_record(_contacts_contact._uri, contactId, &newRecordHandle);
SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
@@ -581,12 +581,14 @@ _AddressbookManagerImpl::UpdateContact(const Contact& contact)
tempPath.Clear();
}
+ SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_FILE_NO_SPACE, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is insufficient.", GetErrorMessage(E_STORAGE_FULL));
+ SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred. Failed to update a contact.", GetErrorMessage(E_SYSTEM));
+ }
+ else
+ {
+ SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
}
-
- SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_FILE_NO_SPACE, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is insufficient.", GetErrorMessage(E_STORAGE_FULL));
- SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred. Failed to update a contact.", GetErrorMessage(E_SYSTEM));
-
pContactRecord.reset(_AddressbookUtil::GetContactRecordN(_contacts_contact._uri, contact.GetRecordId()));
SysTryReturn(NID_SCL, pContactRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
@@ -612,10 +614,8 @@ _AddressbookManagerImpl::UpdateCategory(const Category& category)
contacts_record_h recordHandle = _CategoryImpl::GetInstance(category)->GetRecordHandle();
- int ret = contacts_db_update_record(recordHandle);
- SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_FILE_NO_SPACE, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is insufficient.", GetErrorMessage(E_STORAGE_FULL));
- SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+ result r = _AddressbookUtil::UpdateContactRecord(recordHandle);
+ SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
pCategoryRecord.reset(_AddressbookUtil::GetContactRecordN(_contacts_group._uri, category.GetRecordId()));
SysTryReturn(NID_SCL, pCategoryRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
@@ -717,7 +717,7 @@ _AddressbookManagerImpl::GetCategoriesByContactN(RecordId contactId) const
ClearLastResult();
IList* pCategories = null;
-
+
unique_ptr< __Filter<__ContactsContactGroupRel> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsContactGroupRel>());
__Filter<__ContactsContactGroupRel> relFilter;
@@ -849,7 +849,7 @@ _AddressbookManagerImpl::GetContactsByCategoryN(RecordId categoryId) const
__Filter<__ContactsContactGroupRel> relFilter;
relFilter.Construct();
-
+
if (categoryId != INVALID_RECORD_ID)
{
relFilter.AddInt(_contacts_contact_grouprel.group_id, CONTACTS_MATCH_EQUAL, categoryId);
@@ -894,7 +894,7 @@ _AddressbookManagerImpl::GetContactsByPersonN(PersonId personId) const
SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
ClearLastResult();
-
+
IList* pContacts = null;
unique_ptr< __Filter<__ContactsContact> > pRwAbFilter(_AddressbookUtil::GetRwAbFilterN<__ContactsContact>());
@@ -1087,7 +1087,7 @@ _AddressbookManagerImpl::SearchContactsByPhoneNumberN(const String& phoneNumber)
pContacts = _AddressbookUtil::SearchWithQueryN<__ContactsContactNumber, Contact>(query);
SysTryReturn(NID_SCL, pContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
}
-
+
return pContacts;
}
@@ -1282,7 +1282,7 @@ _AddressbookManagerImpl::GetChangedCategoriesAfterN(int version, int& latestVers
pChangedRelations->RemoveAll(false);
latestVersion = latestVersion2 > latestVersion1 ? latestVersion2 : latestVersion1;
-
+
return pChangeList.release();
}
@@ -1592,9 +1592,8 @@ _AddressbookManagerImpl::SetPersonAsFavorite(PersonId personId, bool isFavorite)
{
contacts_record_set_bool(pPersonRecord.get(), _contacts_person.is_favorite, isFavorite);
- int ret = contacts_db_update_record(pPersonRecord.get());
- SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+ result r = _AddressbookUtil::UpdateContactRecord(pPersonRecord.get());
+ SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
}
return E_SUCCESS;
@@ -2158,7 +2157,7 @@ _AddressbookManagerImpl::OnEachContact(contacts_record_h recordHandle, void* pUs
pContact.release();
- return true;
+ return true;
}
IList*
diff --git a/src/FScl_AddressbookUtil.h b/src/FScl_AddressbookUtil.h
index 4a3d259..0403f1f 100644
--- a/src/FScl_AddressbookUtil.h
+++ b/src/FScl_AddressbookUtil.h
@@ -835,6 +835,28 @@ public:
return E_SUCCESS;
}
+ static result UpdateContactRecord(contacts_record_h recordHandle)
+ {
+ int ret = contacts_db_update_record(recordHandle);
+ SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed. (%d)", GetErrorMessage(E_OUT_OF_MEMORY), ret);
+ SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_NO_DATA, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] The Record is not found. (%d)", GetErrorMessage(E_OBJ_NOT_FOUND), ret);
+ SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_FILE_NO_SPACE, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is insufficient. (%d)", GetErrorMessage(E_STORAGE_FULL), ret);
+ SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred. Failed to update a contact", GetErrorMessage(E_SYSTEM));
+
+ return E_SUCCESS;
+ }
+
+ static result UpdateContactRecords(contacts_list_h listHandle)
+ {
+ int ret = contacts_db_update_records(listHandle);
+ SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_NO_DATA, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] The contact is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
+ SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_INVALID_PARAMETER, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
+ SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+
+ return E_SUCCESS;
+ }
+
static ContactRecord* GetContactRecordN(const char* pUri, RecordId recordId)
{
ClearLastResult();
diff --git a/src/FScl_PersonImpl.cpp b/src/FScl_PersonImpl.cpp
index 77a1552..f8df1f8 100644
--- a/src/FScl_PersonImpl.cpp
+++ b/src/FScl_PersonImpl.cpp
@@ -253,9 +253,8 @@ _PersonImpl::SetAsFavorite(bool isFavorite)
{
contacts_record_set_bool(personHandle, _contacts_person.is_favorite, isFavorite);
- ret = contacts_db_update_record(personHandle);
- SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
+ result r = _AddressbookUtil::UpdateContactRecord(personHandle);
+ SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
__isFavorite = isFavorite;
}