add filter for searching by phone number
authorGwangbok Kim <gwangbok.kim@samsung.com>
Thu, 1 Aug 2013 04:14:22 +0000 (13:14 +0900)
committerGwangbok Kim <gwangbok.kim@samsung.com>
Thu, 1 Aug 2013 11:27:55 +0000 (20:27 +0900)
Change-Id: Iff95a6c016768f2b0b07fa05d0bd29c8e2dfbd0c
Signed-off-by: Gwangbok Kim <gwangbok.kim@samsung.com>
src/FScl_AddressbookFilterImpl.cpp
src/FScl_AddressbookImpl.cpp
src/FScl_AddressbookManagerImpl.cpp

index d202442..88ae63f 100644 (file)
@@ -227,6 +227,7 @@ _AddressbookFilterImpl::GetMatchIntFlag(FilterComparisonOperator comparisonOpera
                break;
        default:
                match = CONTACTS_MATCH_NONE;
+               break;
        };
 
        return match;
@@ -258,6 +259,7 @@ _AddressbookFilterImpl::GetMatchStrFlag(FilterStringOperator stringOperstor)
                break;
        default:
                match = CONTACTS_MATCH_EXISTS;
+               break;
        };
 
        return match;
@@ -351,9 +353,27 @@ _AddressbookFilterImpl::AppendString(FilterConjunctiveOperator conjunctiveOperat
                contacts_filter_add_operator(__filterHandle, filterOperator);
        }
 
-       int ret = contacts_filter_add_str(__filterHandle, viewPropertyId, match, pCharArray.get());
-       SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       int ret = CONTACTS_ERROR_NONE;
+
+       if (filterProperty == PHONE_CONTACT_FI_PR_PHONE)
+       {
+               contacts_filter_h numberHandle = null;
+               ret = contacts_filter_create(_contacts_contact_number._uri, &numberHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s ] Memory allocation failed.", GetErrorMessage(GetLastResult()));
 
+               contacts_filter_add_str(numberHandle, viewPropertyId, match, pCharArray.get());
+               contacts_filter_add_operator(numberHandle, CONTACTS_FILTER_OPERATOR_OR);
+               contacts_filter_add_str(numberHandle, _contacts_contact_number.number, match, pCharArray.get());
+
+               ret = contacts_filter_add_filter(__filterHandle, numberHandle);
+               contacts_filter_destroy(numberHandle);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
+       else
+       {
+               ret = contacts_filter_add_str(__filterHandle, viewPropertyId, match, pCharArray.get());
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+       }
 
        __isEmpty = false;
 
index df37681..b13e613 100644 (file)
@@ -944,6 +944,8 @@ _AddressbookImpl::SearchContactsByPhoneNumberN(const String& phoneNumber) const
        filter.AddInt(_contacts_contact_number.address_book_id, CONTACTS_MATCH_EQUAL, __addressbookId);
        filter.AddOperator(CONTACTS_FILTER_OPERATOR_AND);
        filter.AddString(_contacts_contact_number.normalized_number, CONTACTS_MATCH_CONTAINS, pCharArray.get());
+       filter.AddOperator(CONTACTS_FILTER_OPERATOR_OR);
+       filter.AddString(_contacts_contact_number.number, CONTACTS_MATCH_CONTAINS, pCharArray.get());
 
        unsigned int projectionIds[1];
        projectionIds[0] = _contacts_contact_number.contact_id;
index bacc1e3..cd96957 100644 (file)
@@ -1016,6 +1016,8 @@ _AddressbookManagerImpl::SearchContactsByPhoneNumberN(const String& phoneNumber)
        __Filter<__ContactsContactNumber> numberFilter;
        numberFilter.Construct();
        numberFilter.AddString(_contacts_contact_number.normalized_number, CONTACTS_MATCH_CONTAINS, pCharArray.get());
+       numberFilter.AddOperator(CONTACTS_FILTER_OPERATOR_OR);
+       numberFilter.AddString(_contacts_contact_number.number, CONTACTS_MATCH_CONTAINS, pCharArray.get());
 
        if (pRwAbFilter->Get() != null)
        {
@@ -1893,6 +1895,7 @@ _AddressbookManagerImpl::SearchN(const AddressbookFilter& filter, unsigned long
        default:
                SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. The filter type is invalid", GetErrorMessage(E_INVALID_ARG));
                pList = null;
+               break;
        };
 
        return pList;
@@ -2088,6 +2091,7 @@ _AddressbookManagerImpl::GetMatchedItemCount(const AddressbookFilter& filter)
        default:
                SysLogException(NID_SCL, E_INVALID_ARG, "[%s] Invalid argument is used. The type of the filter is invalid", GetErrorMessage(GetLastResult()));
                count = 0;
+               break;
        };
 
        return count;