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
static Tizen::Base::Collection::IListT<AddressbookId>* GetRwAbIdListN(void);
static Tizen::Base::Collection::IListT<AddressbookId>* GetRoAbIdListN(void);
+ static result GetAbListN(Tizen::Base::Collection::IListT<AddressbookId>& rwAbIdList, Tizen::Base::Collection::IListT<AddressbookId>& roAbIdList);
+
template<typename __View>
static __Filter<__View>* GetRwAbFilterN(void)
{
- std::unique_ptr< Tizen::Base::Collection::IListT<AddressbookId> > pAbIdList(GetRwAbIdListN());
- SysTryReturn(NID_SCL, pAbIdList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
-
std::unique_ptr< __Filter<__View> > pFilter(new (std::nothrow) __Filter<__View>);
SysTryReturn(NID_SCL, pFilter != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ Tizen::Base::Collection::ArrayListT<AddressbookId> rwAbIdList;
+ rwAbIdList.Construct();
+
+ Tizen::Base::Collection::ArrayListT<AddressbookId> roAbIdList;
+ roAbIdList.Construct();
+
+ GetAbListN(rwAbIdList, roAbIdList);
+
+ if (roAbIdList.GetCount() == 0)
+ {
+ // return null filter
+ return pFilter.release();
+ }
+
pFilter->Construct();
bool isFirst = true;
AddressbookId addressbookId = -1;
- std::unique_ptr< Tizen::Base::Collection::IEnumeratorT<AddressbookId> > pEnum(pAbIdList->GetEnumeratorN());
-
- if (pAbIdList->GetCount() > 0)
+ if (rwAbIdList.GetCount() < 5)
{
+ std::unique_ptr< Tizen::Base::Collection::IEnumeratorT<AddressbookId> > pEnum(rwAbIdList.GetEnumeratorN());
while (pEnum->MoveNext() == E_SUCCESS)
{
pEnum->GetCurrent(addressbookId);
if (!isFirst)
{
- pFilter->AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+ pFilter->AddOperator(CONTACTS_FILTER_OPERATOR_OR);
}
else
{
isFirst = false;
}
- pFilter->AddInt(__View::GetAbPropertyId(), CONTACTS_MATCH_NOT_EQUAL, addressbookId);
+ pFilter->AddInt(__View::GetAbPropertyId(), CONTACTS_MATCH_EQUAL, addressbookId);
}
}
else
{
- pFilter->AddInt(__View::GetAbPropertyId(), CONTACTS_MATCH_NOT_EQUAL, 2);
- pFilter->AddOperator(CONTACTS_FILTER_OPERATOR_AND);
- pFilter->AddInt(__View::GetAbPropertyId(), CONTACTS_MATCH_NOT_EQUAL, 3);
+ std::unique_ptr< Tizen::Base::Collection::IEnumeratorT<AddressbookId> > pEnum(roAbIdList.GetEnumeratorN());
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ pEnum->GetCurrent(addressbookId);
+ if (!isFirst)
+ {
+ pFilter->AddOperator(CONTACTS_FILTER_OPERATOR_AND);
+ }
+ else
+ {
+ isFirst = false;
+ }
+
+ pFilter->AddInt(__View::GetAbPropertyId(), CONTACTS_MATCH_NOT_EQUAL, addressbookId);
+ }
}
return pFilter.release();