diff --git a/ChangeLog b/ChangeLog index 7b8e390df..22529ecf1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2010-10-26 Wolfgang Sourdeau + * SoObjects/Contacts/SOGoContactSourceFolder.m + (-lookupContactsWithFilter:onCriteria:sortBy:ordering:): added the + handling of the new "criteria" parameter, returning an empty set + if no known one has been passed. + + * SoObjects/Contacts/SOGoContactGCSFolder.m + (-lookupContactsWithFilter:onCriteria:sortBy:ordering:): added the + handling of the new "criteria" parameter, returning an empty set + if no known one has been passed. + * OGoContentStore/OCSContactFieldExtractor.m (-extractQuickFieldsFromVCard:): we now extract the list of categories from the vcard. diff --git a/SoObjects/Contacts/SOGoContactFolder.h b/SoObjects/Contacts/SOGoContactFolder.h index 00a52456f..01b6e85f1 100644 --- a/SoObjects/Contacts/SOGoContactFolder.h +++ b/SoObjects/Contacts/SOGoContactFolder.h @@ -43,6 +43,7 @@ @protocol SOGoContactFolder - (NSArray *) lookupContactsWithFilter: (NSString *) filter + onCriteria: (NSString *) criteria sortBy: (NSString *) sortKey ordering: (NSComparisonResult) sortOrdering; - (NSDictionary *) lookupContactWithName: (NSString *) aName; diff --git a/SoObjects/Contacts/SOGoContactGCSFolder.m b/SoObjects/Contacts/SOGoContactGCSFolder.m index 30a5401b7..b176e4da6 100644 --- a/SoObjects/Contacts/SOGoContactGCSFolder.m +++ b/SoObjects/Contacts/SOGoContactGCSFolder.m @@ -169,21 +169,33 @@ static NSArray *folderListingFields = nil; } - (EOQualifier *) _qualifierForFilter: (NSString *) filter + onCriteria: (NSString *) criteria { NSString *qs; EOQualifier *qualifier; - if (filter && [filter length] > 0) + if ([filter length] > 0) { filter = [[filter stringByReplacingString: @"\\" withString: @"\\\\"] - stringByReplacingString: @"'" withString: @"\\'\\'"]; - qs = [NSString stringWithFormat: - @"(c_sn isCaseInsensitiveLike: '%%%@%%') OR " - @"(c_givenname isCaseInsensitiveLike: '%%%@%%') OR " - @"(c_cn isCaseInsensitiveLike: '%%%@%%') OR " - @"(c_mail isCaseInsensitiveLike: '%%%@%%')", - filter, filter, filter, filter]; - qualifier = [EOQualifier qualifierWithQualifierFormat: qs]; + stringByReplacingString: @"'" withString: @"\\'\\'"]; + if ([criteria isEqualToString: @"name_or_address"]) + qs = [NSString stringWithFormat: + @"(c_sn isCaseInsensitiveLike: '%%%@%%') OR " + @"(c_givenname isCaseInsensitiveLike: '%%%@%%') OR " + @"(c_cn isCaseInsensitiveLike: '%%%@%%') OR " + @"(c_mail isCaseInsensitiveLike: '%%%@%%')", + filter, filter, filter, filter]; + else if ([criteria isEqualToString: @"category"]) + qs = [NSString stringWithFormat: + @"(c_categories isCaseInsensitiveLike: '%%%@%%')", + filter]; + else + qs = @"(1 == 0)"; + + if (qs) + qualifier = [EOQualifier qualifierWithQualifierFormat: qs]; + else + qualifier = nil; } else qualifier = nil; @@ -264,6 +276,7 @@ static NSArray *folderListingFields = nil; } - (NSArray *) lookupContactsWithFilter: (NSString *) filter + onCriteria: (NSString *) criteria sortBy: (NSString *) sortKey ordering: (NSComparisonResult) sortOrdering { @@ -271,7 +284,7 @@ static NSArray *folderListingFields = nil; EOQualifier *qualifier; EOSortOrdering *ordering; - qualifier = [self _qualifierForFilter: filter]; + qualifier = [self _qualifierForFilter: filter onCriteria: criteria]; dbRecords = [[self ocsFolder] fetchFields: folderListingFields matchingQualifier: qualifier]; diff --git a/SoObjects/Contacts/SOGoContactSourceFolder.m b/SoObjects/Contacts/SOGoContactSourceFolder.m index 214bafe06..81edfc550 100644 --- a/SoObjects/Contacts/SOGoContactSourceFolder.m +++ b/SoObjects/Contacts/SOGoContactSourceFolder.m @@ -243,6 +243,7 @@ } - (NSArray *) lookupContactsWithFilter: (NSString *) filter + onCriteria: (NSString *) criteria sortBy: (NSString *) sortKey ordering: (NSComparisonResult) sortOrdering { @@ -251,7 +252,7 @@ result = nil; - if (filter && [filter length] > 0) + if ([filter length] > 0 && [criteria isEqualToString: @"name_or_address"]) { records = [source fetchContactsMatching: filter]; [childRecords setObjects: records diff --git a/SoObjects/Contacts/SOGoFolder+CardDAV.m b/SoObjects/Contacts/SOGoFolder+CardDAV.m index 26494ba8e..db9da4aef 100644 --- a/SoObjects/Contacts/SOGoFolder+CardDAV.m +++ b/SoObjects/Contacts/SOGoFolder+CardDAV.m @@ -100,8 +100,9 @@ { currentFilter = [filters objectAtIndex: count]; contacts = [[(id)self lookupContactsWithFilter: [[currentFilter allValues] lastObject] - sortBy: @"c_givenname" - ordering: NSOrderedDescending] + onCriteria: @"name_or_address" + sortBy: @"c_givenname" + ordering: NSOrderedDescending] objectEnumerator]; while ((contact = [contacts nextObject])) diff --git a/Tools/SOGoSockDOperation.m b/Tools/SOGoSockDOperation.m index e52b33651..82159751a 100644 --- a/Tools/SOGoSockDOperation.m +++ b/Tools/SOGoSockDOperation.m @@ -270,6 +270,7 @@ Class SOGoContactSourceFolderKlass = Nil; filter = @"."; resultEntries = [folder lookupContactsWithFilter: filter + onCriteria: @"name_or_address" sortBy: @"c_cn" ordering: NSOrderedAscending]; } diff --git a/UI/Contacts/BrazilianPortuguese.lproj/Localizable.strings b/UI/Contacts/BrazilianPortuguese.lproj/Localizable.strings index 14281f41f..bde0a9c38 100644 --- a/UI/Contacts/BrazilianPortuguese.lproj/Localizable.strings +++ b/UI/Contacts/BrazilianPortuguese.lproj/Localizable.strings @@ -58,6 +58,7 @@ "htmlMailFormat_TRUE" = "HTML"; "Name or Email" = "Nome ou Email"; +"Category" = "Category"; "Personal Addressbook" = "Catálogo Pessoal"; "Search in Addressbook" = "Localizar no Catálogo"; diff --git a/UI/Contacts/Catalan.lproj/Localizable.strings b/UI/Contacts/Catalan.lproj/Localizable.strings index 71703358a..297362875 100644 --- a/UI/Contacts/Catalan.lproj/Localizable.strings +++ b/UI/Contacts/Catalan.lproj/Localizable.strings @@ -58,6 +58,7 @@ "htmlMailFormat_TRUE" = "HTML"; "Name or Email" = "Nom o correu"; +"Category" = "Category"; "Personal Addressbook" = "Llibre personal d'adreces"; "Search in Addressbook" = "Buscar en la llibreta"; diff --git a/UI/Contacts/Czech.lproj/Localizable.strings b/UI/Contacts/Czech.lproj/Localizable.strings index a0e1ea34d..1e203c3b3 100644 --- a/UI/Contacts/Czech.lproj/Localizable.strings +++ b/UI/Contacts/Czech.lproj/Localizable.strings @@ -58,6 +58,7 @@ "htmlMailFormat_TRUE" = "HTML"; "Name or Email" = "Jméno nebo e-mail"; +"Category" = "Category"; "Personal Addressbook" = "Osobní kontakty"; "Search in Addressbook" = "Vyhledávat v kontaktech"; diff --git a/UI/Contacts/Dutch.lproj/Localizable.strings b/UI/Contacts/Dutch.lproj/Localizable.strings index a9a0e52de..210d36f62 100644 --- a/UI/Contacts/Dutch.lproj/Localizable.strings +++ b/UI/Contacts/Dutch.lproj/Localizable.strings @@ -58,6 +58,7 @@ "htmlMailFormat_TRUE" = "HTML"; "Name or Email" = "Naam of E-mail"; +"Category" = "Category"; "Personal Addressbook" = "Persoonlijk adresboek"; "Search in Addressbook" = "Adresboek doorzoeken..."; diff --git a/UI/Contacts/English.lproj/Localizable.strings b/UI/Contacts/English.lproj/Localizable.strings index e947ad714..c74e4a76d 100644 --- a/UI/Contacts/English.lproj/Localizable.strings +++ b/UI/Contacts/English.lproj/Localizable.strings @@ -58,6 +58,7 @@ "htmlMailFormat_TRUE" = "HTML"; "Name or Email" = "Name or Email"; +"Category" = "Category"; "Personal Addressbook" = "Personal Addressbook"; "Search in Addressbook" = "Search in Addressbook"; diff --git a/UI/Contacts/French.lproj/Localizable.strings b/UI/Contacts/French.lproj/Localizable.strings index 72cfca2f3..a4fe53415 100644 --- a/UI/Contacts/French.lproj/Localizable.strings +++ b/UI/Contacts/French.lproj/Localizable.strings @@ -58,6 +58,7 @@ "htmlMailFormat_TRUE" = "HTML"; "Name or Email" = "Le nom ou l'adresse"; +"Category" = "La catégorie"; "Personal Addressbook" = "Adresses personnelles"; "Search in Addressbook" = "Carnet d'adresses..."; diff --git a/UI/Contacts/German.lproj/Localizable.strings b/UI/Contacts/German.lproj/Localizable.strings index b8f16d505..6ec8fe7ff 100644 --- a/UI/Contacts/German.lproj/Localizable.strings +++ b/UI/Contacts/German.lproj/Localizable.strings @@ -57,6 +57,7 @@ "htmlMailFormat_TRUE" = "HTML"; "Name or Email" = "Name oder E-Mail"; +"Category" = "Category"; "Personal Addressbook" = "Persönliches Adressbuch"; "Search in Addressbook" = "Im Adressbuch suchen ..."; diff --git a/UI/Contacts/Hungarian.lproj/Localizable.strings b/UI/Contacts/Hungarian.lproj/Localizable.strings index 5b5c3bf2a..dd85e3890 100644 --- a/UI/Contacts/Hungarian.lproj/Localizable.strings +++ b/UI/Contacts/Hungarian.lproj/Localizable.strings @@ -58,6 +58,7 @@ "htmlMailFormat_TRUE" = "HTML"; "Name or Email" = "Név vagy email"; +"Category" = "Category"; "Personal Addressbook" = "Személyes címjegyzék"; "Search in Addressbook" = "Keresés a címjegyzékben"; diff --git a/UI/Contacts/Italian.lproj/Localizable.strings b/UI/Contacts/Italian.lproj/Localizable.strings index 7e0b310f4..00e052a6c 100644 --- a/UI/Contacts/Italian.lproj/Localizable.strings +++ b/UI/Contacts/Italian.lproj/Localizable.strings @@ -58,6 +58,7 @@ "htmlMailFormat_TRUE" = "HTML"; "Name or Email" = "Nome o indirizzo Email"; +"Category" = "Category"; "Personal Addressbook" = "Rubrica personale"; "Search in Addressbook" = "Cerca nella rubrica"; diff --git a/UI/Contacts/Polish.lproj/Localizable.strings b/UI/Contacts/Polish.lproj/Localizable.strings index 88195ea2b..88cb8ef79 100644 --- a/UI/Contacts/Polish.lproj/Localizable.strings +++ b/UI/Contacts/Polish.lproj/Localizable.strings @@ -58,6 +58,7 @@ "htmlMailFormat_TRUE" = "HTML"; "Name or Email" = "Nazwa lub e-mail"; +"Category" = "Category"; "Personal Addressbook" = "Osobista książka adresowa"; "Search in Addressbook" = "Szukaj w książce adresowej"; diff --git a/UI/Contacts/Russian.lproj/Localizable.strings b/UI/Contacts/Russian.lproj/Localizable.strings index ae5aa0e4d..4bb0cb4f6 100644 --- a/UI/Contacts/Russian.lproj/Localizable.strings +++ b/UI/Contacts/Russian.lproj/Localizable.strings @@ -52,6 +52,7 @@ "htmlMailFormat_TRUE" = "HTML"; "Name or Email" = "Name or Email"; +"Category" = "Category"; "Personal Addressbook" = "Personal Addressbook"; "Search in Addressbook" = "Search in Addressbook"; diff --git a/UI/Contacts/Spanish.lproj/Localizable.strings b/UI/Contacts/Spanish.lproj/Localizable.strings index cfebd2823..cce44ead7 100644 --- a/UI/Contacts/Spanish.lproj/Localizable.strings +++ b/UI/Contacts/Spanish.lproj/Localizable.strings @@ -58,6 +58,7 @@ "htmlMailFormat_TRUE" = "HTML"; "Name or Email" = "Nombre o correo"; +"Category" = "Category"; "Personal Addressbook" = "Libre personal de direcciones"; "Search in Addressbook" = "Buscar en libreta"; diff --git a/UI/Contacts/Swedish.lproj/Localizable.strings b/UI/Contacts/Swedish.lproj/Localizable.strings index 82b1ef16f..2dfc2bfdc 100644 --- a/UI/Contacts/Swedish.lproj/Localizable.strings +++ b/UI/Contacts/Swedish.lproj/Localizable.strings @@ -58,6 +58,7 @@ "htmlMailFormat_TRUE" = "HTML"; "Name or Email" = "Namn eller e-post"; +"Category" = "Category"; "Personal Addressbook" = "Personlig adressbok"; "Search in Addressbook" = "Sök i adressbok"; diff --git a/UI/Contacts/UIxContactFoldersView.m b/UI/Contacts/UIxContactFoldersView.m index ff207f1b8..765032af3 100644 --- a/UI/Contacts/UIxContactFoldersView.m +++ b/UI/Contacts/UIxContactFoldersView.m @@ -113,45 +113,6 @@ return (selectorComponentClass != nil); } -- (void) _fillResults: (NSMutableDictionary *) results - inFolder: (id ) folder - withSearchOn: (NSString *) contact -{ - NSEnumerator *folderResults; - NSDictionary *currentContact; - NSString *uid; - - folderResults = [[folder lookupContactsWithFilter: contact - sortBy: @"cn" - ordering: NSOrderedAscending] objectEnumerator]; - currentContact = [folderResults nextObject]; - while (currentContact) - { - uid = [currentContact objectForKey: @"c_uid"]; - if (uid && ![results objectForKey: uid]) - [results setObject: currentContact forKey: uid]; - currentContact = [folderResults nextObject]; - } -} - -- (NSString *) _emailForResult: (NSDictionary *) result -{ - NSMutableString *email; - NSString *name, *mail; - - email = [NSMutableString string]; - name = [result objectForKey: @"displayName"]; - if (![name length]) - name = [result objectForKey: @"cn"]; - mail = [result objectForKey: @"mail"]; - if ([name length]) - [email appendFormat: @"%@ <%@>", name, mail]; - else - [email appendString: mail]; - - return email; -} - - (id ) allContactSearchAction { id result; @@ -199,6 +160,7 @@ folder = [sortedFolders objectAtIndex: i]; //NSLog(@" Address book: %@ (%@)", [folder displayName], [folder class]); contacts = [folder lookupContactsWithFilter: searchText + onCriteria: @"name_or_address" sortBy: @"c_cn" ordering: NSOrderedAscending]; for (j = 0; j < [contacts count]; j++) diff --git a/UI/Contacts/UIxContactsListView.m b/UI/Contacts/UIxContactsListView.m index dd521162b..34c3dfd75 100644 --- a/UI/Contacts/UIxContactsListView.m +++ b/UI/Contacts/UIxContactsListView.m @@ -112,8 +112,9 @@ [contactInfos release]; contactInfos = [folder lookupContactsWithFilter: valueText - sortBy: [self sortKey] - ordering: ordering]; + onCriteria: searchText + sortBy: [self sortKey] + ordering: ordering]; [contactInfos retain]; } @@ -145,6 +146,7 @@ uniqueContacts = [NSMutableDictionary dictionary]; contacts = [folder lookupContactsWithFilter: searchText + onCriteria: @"name_or_address" sortBy: @"c_cn" ordering: NSOrderedAscending]; for (i = 0; i < [contacts count]; i++) diff --git a/UI/Contacts/Ukrainian.lproj/Localizable.strings b/UI/Contacts/Ukrainian.lproj/Localizable.strings index d5d2d2ade..499852e78 100644 --- a/UI/Contacts/Ukrainian.lproj/Localizable.strings +++ b/UI/Contacts/Ukrainian.lproj/Localizable.strings @@ -55,6 +55,7 @@ "htmlMailFormat_TRUE" = "HTML"; "Name or Email" = "Ім’я або адреса електронної пошти"; +"Category" = "Category"; "Personal Addressbook" = "Особиста адресна книга"; "Search in Addressbook" = "Шукати в адресній книзі"; diff --git a/UI/Contacts/Welsh.lproj/Localizable.strings b/UI/Contacts/Welsh.lproj/Localizable.strings index 17a95ad98..97103f9b8 100644 --- a/UI/Contacts/Welsh.lproj/Localizable.strings +++ b/UI/Contacts/Welsh.lproj/Localizable.strings @@ -52,6 +52,7 @@ "htmlMailFormat_TRUE" = "HTML"; "Name or Email" = "Enw neu Ebost"; +"Category" = "Category"; "Personal Addressbook" = "Llyfr Cyfeiriadau Personol"; "Search in Addressbook" = "Chwilio yn Llyfr Cyfeiriadau"; diff --git a/UI/Templates/ContactsUI/UIxContactsFilterPanel.wox b/UI/Templates/ContactsUI/UIxContactsFilterPanel.wox index 4c8b24427..c7e87d2d3 100644 --- a/UI/Templates/ContactsUI/UIxContactsFilterPanel.wox +++ b/UI/Templates/ContactsUI/UIxContactsFilterPanel.wox @@ -9,6 +9,7 @@
  • +
diff --git a/UI/WebServerResources/ContactsUI.js b/UI/WebServerResources/ContactsUI.js index 7a9f15395..1951994cb 100644 --- a/UI/WebServerResources/ContactsUI.js +++ b/UI/WebServerResources/ContactsUI.js @@ -1125,7 +1125,7 @@ function getMenus() { "-", onMenuDeleteContact, "-", "moveContactMenu", "copyContactMenu", onMenuExportContact); - menus["searchMenu"] = new Array(setSearchCriteria); + menus["searchMenu"] = new Array(setSearchCriteria, setSearchCriteria); var contactFoldersMenu = $("contactFoldersMenu"); if (contactFoldersMenu)