From 9584c54db8b03db2bdd9e3eb66265b0b5f8ef1fd Mon Sep 17 00:00:00 2001 From: Gwangbok Kim Date: Mon, 29 Apr 2013 18:54:40 +0900 Subject: [PATCH] fix codes for abnormal result of GetLastResult() Change-Id: I757e2c5ec7f4b049c21d845fec65136e58598a5d Signed-off-by: Gwangbok Kim --- src/FScl_AddressbookImpl.cpp | 9 +++++++- src/FScl_AddressbookManagerImpl.cpp | 44 ++++++++++++++++++++++++++++++------- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/FScl_AddressbookImpl.cpp b/src/FScl_AddressbookImpl.cpp index 4909b9e..0af9b5c 100644 --- a/src/FScl_AddressbookImpl.cpp +++ b/src/FScl_AddressbookImpl.cpp @@ -872,7 +872,6 @@ _AddressbookImpl::SearchContactsByNameN(const String& name) const SysTryReturn(NID_SCL, name.GetLength() <= MAX_CONTACT_NAME_LENGTH, null, E_INVALID_ARG, "[%s] Invalid argument is used. The length of name is greater than MAX_CONTACT_NAME_LENGTH.", GetErrorMessage(E_INVALID_ARG)); } - ClearLastResult(); std::unique_ptr pCharArray(_StringConverter::CopyToCharArrayN(name)); @@ -1074,6 +1073,8 @@ _AddressbookImpl::GetChangedContactsAfterN(int version, int& latestVersion) cons SysTryReturn(NID_SCL, version >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. version %d must be greater that or equal 0.", GetErrorMessage(E_INVALID_ARG), version); SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + ClearLastResult(); + IList* pChangedContacts = _AddressbookUtil::SearchWithVersionN<__ContactsContactUpdatedInfo, ContactChangeInfo>(__addressbookId, version, latestVersion); SysTryReturn(NID_SCL, pChangedContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); @@ -1086,6 +1087,8 @@ _AddressbookImpl::GetChangedCategoriesAfterN(int version, int& latestVersion) co SysTryReturn(NID_SCL, version >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. version %d must be greater that or equal 0.", GetErrorMessage(E_INVALID_ARG), version); SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + ClearLastResult(); + int latestVersion1 = 0; int latestVersion2 = 0; @@ -1118,6 +1121,8 @@ _AddressbookImpl::GetChangedContactInfoListN(int version, int& latestVersion) co SysTryReturn(NID_SCL, version >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. version %d must be greater that or equal 0.", GetErrorMessage(E_INVALID_ARG), version); SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + ClearLastResult(); + IList* pChangedContacts = _AddressbookUtil::SearchWithVersionN<__ContactsContactUpdatedInfo, ContactChangeInfo>(__addressbookId, version, latestVersion); SysTryReturn(NID_SCL, pChangedContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); @@ -1136,6 +1141,8 @@ _AddressbookImpl::GetChangedGroupsAfterN(int version, int& latestVersion) const SysTryReturn(NID_SCL, version >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. version %d must be greater that or equal 0.", GetErrorMessage(E_INVALID_ARG), version); SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + ClearLastResult(); + IList* pChangedGroups = _AddressbookUtil::SearchWithVersionN<__ContactsGroupUpdatedInfo, CategoryChangeInfo>(__addressbookId, version, latestVersion); SysTryReturn(NID_SCL, pChangedGroups != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); diff --git a/src/FScl_AddressbookManagerImpl.cpp b/src/FScl_AddressbookManagerImpl.cpp index c7b63c1..44e63c6 100644 --- a/src/FScl_AddressbookManagerImpl.cpp +++ b/src/FScl_AddressbookManagerImpl.cpp @@ -200,6 +200,8 @@ _AddressbookManagerImpl::CreateAddressbookN(AccountId accountId, const String& n SysTryReturn(NID_SCL, accountId >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. account id is invalid.", GetErrorMessage(E_INVALID_ARG)); SysTryReturn(NID_SCL, !name.IsEmpty(), null, E_INVALID_ARG, "[%s] Invalid argument is used. The name is empty.", GetErrorMessage(E_INVALID_ARG)); + ClearLastResult(); + result r = E_SUCCESS; int ret = CONTACTS_ERROR_NONE; int recordId = 0; @@ -271,6 +273,8 @@ _AddressbookManagerImpl::GetAddressbooksByAccountN(AccountId accountId) const SysTryReturn(NID_SCL, accountId >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. accountId = %d.", GetErrorMessage(E_INVALID_ARG), accountId); SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + ClearLastResult(); + __Filter<__ContactsAddressbook> filter; filter.Construct(); filter.AddInt(_contacts_address_book.account_id, CONTACTS_MATCH_EQUAL, accountId); @@ -290,6 +294,8 @@ _AddressbookManagerImpl::GetAllAddressbooksN(void) const { SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + ClearLastResult(); + __Query<__ContactsAddressbook> query; query.Construct(); query.SetSort(_contacts_address_book.name, true); @@ -306,6 +312,8 @@ _AddressbookManagerImpl::GetAddressbookN(AddressbookId addressbookId) const SysTryReturn(NID_SCL, addressbookId >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. addressbookId.", GetErrorMessage(E_INVALID_ARG), addressbookId); SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + ClearLastResult(); + result r = E_SUCCESS; int ret = CONTACTS_ERROR_NONE; contacts_record_h addressbookHandle = null; @@ -318,7 +326,6 @@ _AddressbookManagerImpl::GetAddressbookN(AddressbookId addressbookId) const r = pAddressbook->Construct(); SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - ret = contacts_db_get_record(_contacts_address_book._uri, addressbookId, &addressbookHandle); SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_NO_DATA, null, E_OBJ_NOT_FOUND, "[%s] The addressbook %d is not found.", GetErrorMessage(E_OBJ_NOT_FOUND), addressbookId); @@ -350,7 +357,6 @@ _AddressbookManagerImpl::AddContact(Contact& contact, AddressbookId addressbookI SysTryReturn(NID_SCL, !_ContactImpl::GetInstance(contact)->IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified contact does not have any property.", GetErrorMessage(E_INVALID_ARG)); SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - int recordId = 0; contacts_record_h recordHandle = null; @@ -882,9 +888,10 @@ Contact* _AddressbookManagerImpl::GetContactN(RecordId contactId) const { SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - SysTryReturn(NID_SCL, contactId != INVALID_RECORD_ID, null, E_INVALID_ARG, "[%s] Invalid argument is used. contactId = %d.", GetErrorMessage(E_INVALID_ARG), contactId); + ClearLastResult(); + int intValue = 0; contacts_record_h contactHandle = null; @@ -910,11 +917,12 @@ Person* _AddressbookManagerImpl::GetPersonN(PersonId personId) const { SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - SysTryReturn(NID_SCL, personId >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. personId = %d.", GetErrorMessage(E_INVALID_ARG), personId); contacts_record_h recordHandle = null; + ClearLastResult(); + int intValue = 0; int ret = contacts_db_get_record(_contacts_person._uri, personId, &recordHandle); SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); @@ -938,7 +946,6 @@ _AddressbookManagerImpl::GetCategoryN(RecordId categoryId) const SysTryReturn(NID_SCL, categoryId != INVALID_RECORD_ID, null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. categoryId = %d.", categoryId); SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - contacts_record_h recordHandle = null; ClearLastResult(); @@ -995,6 +1002,7 @@ _AddressbookManagerImpl::GetChangedContactsAfterN(int version, int& latestVersio SysTryReturn(NID_SCL, version >= 0, null, E_INVALID_ARG, "[%s] Invalid arguent is used. version %d must be greater that or equal 0.", GetErrorMessage(E_INVALID_ARG), version); SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + ClearLastResult(); IList* pChangedContacts = _AddressbookUtil::SearchWithVersionN<__ContactsContactUpdatedInfo, ContactChangeInfo>(-1, version, latestVersion); SysTryReturn(NID_SCL, pChangedContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); @@ -1254,6 +1262,8 @@ _AddressbookManagerImpl::SearchPersonsN(const Tizen::Base::String& keyword) cons SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); SysTryReturn(NID_SCL, !keyword.IsEmpty(), null, E_INVALID_ARG, "Invalid argument is used. keyword is empty string.", GetErrorMessage(E_INVALID_ARG)); + ClearLastResult(); + contacts_record_h currentRecord = null; std::unique_ptr pPerson(null); @@ -1343,6 +1353,8 @@ _AddressbookManagerImpl::SearchN(const AddressbookFilter& filter, unsigned long { SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + ClearLastResult(); + IList* pList = null; bool ascending = false; unsigned int viewSortPropertyId = 0; @@ -1488,6 +1500,8 @@ _AddressbookManagerImpl::GetMatchedItemCount(const AddressbookFilter& filter) { SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + ClearLastResult(); + int count = 0; AddressbookFilterType type = _AddressbookFilterImpl::GetInstance(filter)->GetType(); contacts_filter_h filterHandle = _AddressbookFilterImpl::GetInstance(filter)->GetFilterHandle(); @@ -1745,6 +1759,8 @@ _AddressbookManagerImpl::ExportContactToVcardStreamN(const Contact& contact) { SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + ClearLastResult(); + contacts_record_h recordHandle = _ContactImpl::GetInstance(contact)->GetContactRecordHandle(); char* pVcardStream = null; @@ -1786,6 +1802,8 @@ _AddressbookManagerImpl::ExportContactsToVcardStreamN(const Tizen::Base::Collect { SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + ClearLastResult(); + char* pVcardStream = null; int ret = CONTACTS_ERROR_NONE; Contact* pContact = null; @@ -1843,6 +1861,8 @@ _AddressbookManagerImpl::ExportPersonToVcardStreamN(const Person& person) { SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + ClearLastResult(); + int ret = CONTACTS_ERROR_NONE; contacts_record_h personRecordHandle = null; @@ -1891,6 +1911,8 @@ _AddressbookManagerImpl::ExportPersonsToVcardStreamN(const Tizen::Base::Collecti { SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + ClearLastResult(); + int ret = CONTACTS_ERROR_NONE; Person* pPerson = null; char* pVcardStream = null; @@ -1954,6 +1976,8 @@ _AddressbookManagerImpl::ParseVcardStreamN(const Tizen::Base::ByteBuffer& vcardS { SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + ClearLastResult(); + contacts_list_h listHandle = null; result r = E_SUCCESS; @@ -2023,11 +2047,13 @@ _AddressbookManagerImpl::ParseVcardStreamN(const Tizen::Base::ByteBuffer& vcardS return pList.release(); } -Tizen::Base::ByteBuffer* +ByteBuffer* _AddressbookManagerImpl::ExportUserProfileToVcardStreamN(const UserProfile& userProfile) { SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + ClearLastResult(); + char* pVcardStream = null; int ret = CONTACTS_ERROR_NONE; contacts_record_h recordHandle = null; @@ -2066,11 +2092,13 @@ _AddressbookManagerImpl::ExportUserProfileToVcardStreamN(const UserProfile& user return pByteBuffer.release(); } -Tizen::Base::ByteBuffer* +ByteBuffer* _AddressbookManagerImpl::ExportUserProfilesToVcardStreamN(const Tizen::Base::Collection::IList& userProfileList) { SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + ClearLastResult(); + char* pVcardStream = null; int ret = CONTACTS_ERROR_NONE; UserProfile* pProfile = null; @@ -2195,7 +2223,7 @@ _AddressbookManagerImpl::ExportUserProfilesToVcard(const Tizen::Base::Collection return E_SUCCESS; } -Tizen::Base::Collection::IList* +IList* _AddressbookManagerImpl::GetAllUserProfilesN(void) const { SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); -- 2.7.4