void ContactSearchEngine::visitAttribute(string& attrName, MatchFlag& matchFlag, AnyPtr& matchValue, int depth)
{
+ if(matchValue == NULL || matchValue->isNullOrUndefined())
+ matchFlag = MATCH_EXISTS;
+
ContactIdSetPtr idSet = ContactIdSetPtr(new ContactIdSet());
if(attrName == "id")
{
- string value = matchValue->getString();
- idSet->insert(ContactUtility::strToInt(value));
+ if(matchFlag != MATCH_EXISTS){
+ string value = matchValue->getString();
+ idSet->insert(ContactUtility::strToInt(value));
- if(depth == 0)
- m_filteredContactIds = idSet;
- else
- {
- ContactIdSetArrayPtr parentIdSets = m_contactIdSetArrayStack.top();
- parentIdSets->push_back(idSet);
+ if(depth == 0)
+ m_filteredContactIds = idSet;
+ else
+ {
+ ContactIdSetArrayPtr parentIdSets = m_contactIdSetArrayStack.top();
+ parentIdSets->push_back(idSet);
+ }
}
return;
if(properties.type == ContactSvcPrimitiveType_Boolean)
{
- bool value = matchValue->getBool();
+ bool value = true;
+ if(matchFlag != MATCH_EXISTS)
+ value = matchValue->getBool();
+
queryAttributeBool(properties, idSet, value);
}
else if(properties.type == ContactSvcPrimitiveType_String)
{
string value;
- if(attrName == "photoURI" || attrName == "ringtoneURI" || attrName == "organizations.logoURI")
- value = ContactUtility::convertUriToPath(matchValue->getString());
- else
- value = matchValue->getString();
+
+ if(matchFlag != MATCH_EXISTS)
+ {
+ if(attrName == "photoURI" || attrName == "ringtoneURI" || attrName == "organizations.logoURI")
+ value = ContactUtility::convertUriToPath(matchValue->getString());
+ else
+ value = matchValue->getString();
+ }else
+ value = "";
contacts_match_str_flag_e flag = CONTACTS_MATCH_EXISTS;
{
int value;
- if(attrName == "id" || attrName == "personId"){
- value = ContactUtility::strToInt(matchValue->getString());
- }else if(attrName == "lastUpdated"){
- time_t tmpTime = mktime(matchValue->getDateTm());
- value = (int)tmpTime;
- }else if(attrName == "birthday" || attrName == "anniversaries.date"){
- value = ContactUtility::toDateDbInt(*matchValue->getDateTm());
- }else{
- value = matchValue->getLong();
+ if(matchFlag != MATCH_EXISTS)
+ {
+ if(attrName == "id" || attrName == "personId"){
+ value = ContactUtility::strToInt(matchValue->getString());
+ }else if(attrName == "lastUpdated"){
+ time_t tmpTime = mktime(matchValue->getDateTm());
+ value = (int)tmpTime;
+ }else if(attrName == "birthday" || attrName == "anniversaries.date"){
+ value = ContactUtility::toDateDbInt(*matchValue->getDateTm());
+ }else{
+ value = matchValue->getLong();
+ }
}
contacts_match_int_flag_e flag;
flag = CONTACTS_MATCH_EQUAL;
}
- queryAttributeInt(properties, idSet, flag, value);
+ if(attrName == "birthday" || attrName == "anniversaries.date"){
+ queryAttributeDate(attrName, properties, idSet, flag, value);
+ }else{
+ queryAttributeInt(properties, idSet, flag, value);
+ }
+
}
if(depth == 0)
_CONTACTS_SVC_QUERY_FUNC_SUFFIX(query, filter, list, property_contact_id, result);
}
+void ContactSearchEngine::queryAttributeDate(string& attrName, AttributeProperties& attributeProperties, ContactIdSetPtr& result,
+ contacts_match_int_flag_e match, int match_value)
+{
+ const char* view_uri = attributeProperties.viewUri;
+ unsigned int property_contact_id = attributeProperties.propertyContactId;
+ unsigned int property_id = attributeProperties.propertyId;
+
+ int errorCode = 0;
+ contacts_query_h query = NULL;
+ contacts_filter_h filter = NULL;
+ contacts_list_h list = NULL;
+
+ _CONTACTS_SVC_QUERY_FUNC_PREFIX(view_uri, query, filter);
+
+ errorCode = contacts_filter_add_int(filter, property_id, match, match_value);
+ if(errorCode != CONTACTS_ERROR_NONE)
+ ThrowMsg(PlatformException, "contacts_filter_add_int error : " << errorCode << " (" << __FUNCTION__ << ")");
+
+ LoggerD("attrName" << attrName);
+
+ if(attrName == "birthday"){
+ errorCode = contacts_filter_add_operator( filter, CONTACTS_FILTER_OPERATOR_AND);
+ if(errorCode != CONTACTS_ERROR_NONE)
+ ThrowMsg(PlatformException, "contacts_filter_add_int error : " << errorCode << " (" << __FUNCTION__ << ")");
+
+ errorCode = contacts_filter_add_int(filter, _contacts_event.type, CONTACTS_MATCH_EQUAL, CONTACTS_EVENT_TYPE_BIRTH);
+ if(errorCode != CONTACTS_ERROR_NONE)
+ ThrowMsg(PlatformException, "contacts_filter_add_int error : " << errorCode << " (" << __FUNCTION__ << ")");
+
+ }else if(attrName == "anniversaries.date"){
+ errorCode = contacts_filter_add_operator( filter, CONTACTS_FILTER_OPERATOR_AND);
+ if(errorCode != CONTACTS_ERROR_NONE)
+ ThrowMsg(PlatformException, "contacts_filter_add_int error : " << errorCode << " (" << __FUNCTION__ << ")");
+
+ errorCode = contacts_filter_add_int(filter, _contacts_event.type, CONTACTS_MATCH_EQUAL, CONTACTS_EVENT_TYPE_ANNIVERSARY);
+ if(errorCode != CONTACTS_ERROR_NONE)
+ ThrowMsg(PlatformException, "contacts_filter_add_int error : " << errorCode << " (" << __FUNCTION__ << ")");
+ }
+
+ _CONTACTS_SVC_QUERY_FUNC_SUFFIX(query, filter, list, property_contact_id, result);
+}
+
void ContactSearchEngine::queryAttributeString(AttributeProperties& attributeProperties, ContactIdSetPtr& result,
contacts_match_str_flag_e match, const char* match_value)
{