# $Id: lbdb-mac_address_book_aliases.diff,v 1.1 2011/02/14 23:20:53 jcs Exp $ # # make ABQuery of lbdb also search the nickname/alias field of the address book # to find matches # # because the resulting entries will probably not have the original search text # in them, remove the duplicate grep that filters the ABQuery output # # by jcs@jcs.org # --- ABQuery/ABQuery.m.orig 2011-02-14 17:18:52.000000000 -0600 +++ ABQuery/ABQuery.m 2011-02-14 17:19:14.000000000 -0600 @@ -26,7 +26,7 @@ int main (int argc, const char *argv[]) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; ABAddressBook *book = [ABAddressBook sharedAddressBook]; - ABSearchElement *firstNameSearch, *lastNameSearch, *emailSearch, *search; + ABSearchElement *firstNameSearch, *lastNameSearch, *emailSearch, *nicknameSearch, *search; NSArray *searchTerms; NSArray *results; NSEnumerator *addressEnum; @@ -48,7 +48,12 @@ key:nil value:key comparison:kABContainsSubStringCaseInsensitive]; - searchTerms = [NSArray arrayWithObjects:firstNameSearch, lastNameSearch, emailSearch, nil]; + nicknameSearch = [ABPerson searchElementForProperty:kABNicknameProperty + label:nil + key:nil + value:key + comparison:kABContainsSubStringCaseInsensitive]; + searchTerms = [NSArray arrayWithObjects:firstNameSearch, lastNameSearch, emailSearch, nicknameSearch, nil]; search = [ABSearchElement searchElementForConjunction:kABSearchOr children:searchTerms]; results = [book recordsMatchingSearchElement:search]; Exit 1 --- m_osx_addressbook.sh.in.orig 2011-02-14 17:19:09.000000000 -0600 +++ m_osx_addressbook.sh.in 2011-02-14 17:19:14.000000000 -0600 @@ -24,5 +24,5 @@ m_osx_addressbook_query() { - $libdir/ABQuery "$@" | grep -ia "$@" || : + $libdir/ABQuery "$@" || : }