Fixed DCM-2074: Enhanced query performance
[platform/framework/native/social.git] / src / FScl_AddressbookUtil.cpp
index 195c59d..aba153d 100644 (file)
@@ -915,4 +915,40 @@ _AddressbookUtil::GetRwAbIdListN(void)
        return pAbIdList.release();
 }
 
+result
+_AddressbookUtil::GetAbListN(IListT<AddressbookId>& rwAbIdList, IListT<AddressbookId>& roAbIdList)
+{
+       ClearLastResult();
+
+       __Query<__ContactsAddressbook> query;
+       query.Construct();
+
+       std::unique_ptr<__SearchResult<__ContactsAddressbook> > pSearchResult(_AddressbookUtil::ExecuteQuery(query, 0, 0));
+       if (pSearchResult == null)
+       {
+               return E_SUCCESS;
+       }
+
+       while (pSearchResult->MoveNext() == E_SUCCESS)
+       {
+               int intValue = 0;
+               contacts_record_h currentRecord = pSearchResult->GetCurrentRecord();
+
+               contacts_record_get_int(currentRecord, _contacts_address_book.mode, &intValue);
+               if (intValue == CONTACTS_ADDRESS_BOOK_MODE_NONE)
+               {
+                       contacts_record_get_int(currentRecord, _contacts_address_book.id, &intValue);
+
+                       rwAbIdList.Add(intValue);
+               }
+               else
+               {
+                       contacts_record_get_int(currentRecord, _contacts_address_book.id, &intValue);
+                       roAbIdList.Add(intValue);
+               }
+       }
+
+       return E_SUCCESS;
+}
+
 }}  // Tizen::Social