From f4fabba6b900b14d53672e4d728b14a584daa88a Mon Sep 17 00:00:00 2001 From: C Robert Date: Wed, 9 Sep 2009 15:30:22 +0000 Subject: [PATCH] New category for ldifString (NGVCard, NGVList) Monotone-Parent: d124c012f70febcfcbb9a2b5d4f3a20a7a001d7a Monotone-Revision: 2ca761e2d40488480678e105a10bfe240b9c689c Monotone-Author: crobert@inverse.ca Monotone-Date: 2009-09-09T15:30:22 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 6 ++ SOPE/NGCards/ChangeLog | 2 + SOPE/NGCards/NGVCard.h | 1 - SOPE/NGCards/NGVCard.m | 107 -------------------- SOPE/NGCards/NGVList.h | 2 - SOPE/NGCards/NGVList.m | 41 -------- SoObjects/Contacts/GNUmakefile | 2 + SoObjects/Contacts/NGVCard+SOGo.h | 34 +++++++ SoObjects/Contacts/NGVCard+SOGo.m | 137 ++++++++++++++++++++++++++ SoObjects/Contacts/NGVList+SOGo.h | 34 +++++++ SoObjects/Contacts/NGVList+SOGo.m | 73 ++++++++++++++ UI/Contacts/UIxContactFolderActions.m | 4 +- 12 files changed, 290 insertions(+), 153 deletions(-) create mode 100644 SoObjects/Contacts/NGVCard+SOGo.h create mode 100644 SoObjects/Contacts/NGVCard+SOGo.m create mode 100644 SoObjects/Contacts/NGVList+SOGo.h create mode 100644 SoObjects/Contacts/NGVList+SOGo.m diff --git a/ChangeLog b/ChangeLog index d2cd6c3ea..9e2fb3139 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,12 @@ userRecordAsLDIFEntry. * UI/Contacts/UIxContactsListView.m: Removed import/export actions * UI/Scheduler/UIxCalView.m: Removed import/export actions + * SoObjects/Contacts/NGVCard+SOGo.m: Added a new category to remove a + circular dependency issue. + * SoObjects/Contacts/NGVList+SOGo.m: Added a new category to remove a + circular dependency issue. + * UI/Contacts/UIxContactFolderActions.m: Changed import instructions to use + the new category. 2009-09-03 Cyril Robert diff --git a/SOPE/NGCards/ChangeLog b/SOPE/NGCards/ChangeLog index c4f6b93b0..d1163690b 100644 --- a/SOPE/NGCards/ChangeLog +++ b/SOPE/NGCards/ChangeLog @@ -2,6 +2,8 @@ * NGVCard.m: Made use of NSDictionary+Utilities' userRecordAsLDIFEntry. * NGVList.m: Made use of NSDictionary+Utilities' userRecordAsLDIFEntry. + * NGVCard.m (ldifString): Moved to a category in SOGo + * NGVList.m (ldifString): Moved to a category in SOGo 2009-09-02 Cyril Robert diff --git a/SOPE/NGCards/NGVCard.h b/SOPE/NGCards/NGVCard.h index 9ede021b0..a687e2a01 100644 --- a/SOPE/NGCards/NGVCard.h +++ b/SOPE/NGCards/NGVCard.h @@ -157,7 +157,6 @@ typedef enum - (NSString *) preferredEMail; - (NSString *) preferredTel; - (CardElement *) preferredAdr; -- (NSString *) ldifString; @end diff --git a/SOPE/NGCards/NGVCard.m b/SOPE/NGCards/NGVCard.m index 5579c7b3f..41cb7c2b9 100644 --- a/SOPE/NGCards/NGVCard.m +++ b/SOPE/NGCards/NGVCard.m @@ -24,8 +24,6 @@ #import #import -#import "../../SoObjects/SOGo/NSDictionary+Utilities.h" - #import "NSArray+NGCards.h" #import "NGVCard.h" @@ -511,109 +509,4 @@ return str; } - -- (NSString *) ldifString -{ - NSMutableString *rc; - NSString *buffer; - NSArray *array; - NSMutableArray *marray; - NSMutableDictionary *entry; - id tmp; - - entry = [NSMutableDictionary dictionary]; - - [entry setObject: [NSString stringWithFormat: @"cn=%@,mail=%@", - [self fn], [self preferredEMail]] - forKey: @"dn"]; - [entry setObject: [NSArray arrayWithObjects: @"top", @"person", - @"organizationalPerson", @"inetOrgPerson", - @"mozillaAbPersonObsolete", nil] - forKey: @"objectclass"]; - [entry setObject: [[self n] objectAtIndex: 1] forKey: @"givenName"]; - [entry setObject: [[self n] objectAtIndex: 0] forKey: @"sn"]; - [entry setObject: [self fn] forKey: @"cn"]; - [entry setObject: [self preferredEMail] forKey: @"mail"]; - [entry setObject: @"0Z" forKey: @"modifytimestamp"]; - - buffer = [self nickname]; - if (buffer && [buffer length] > 0) - [entry setObject: buffer forKey: @"mozillaNickname"]; - - marray = [NSMutableArray arrayWithArray: [self childrenWithTag: @"email"]]; - [marray removeObjectsInArray: [self childrenWithTag: @"email" - andAttribute: @"type" - havingValue: @"pref"]]; - if ([marray count]) - { - buffer = [[marray objectAtIndex: [marray count]-1] value: 0]; - - if ([buffer caseInsensitiveCompare: [self preferredEMail]] != NSOrderedSame) - [entry setObject: buffer forKey: @"mozillaSecondEmail"]; - } - - array = [self childrenWithTag: @"tel" andAttribute: @"type" havingValue: @"home"]; - if ([array count]) - [entry setObject: [[array objectAtIndex: 0] value: 0] forKey: @"homePhone"]; - array = [self childrenWithTag: @"tel" andAttribute: @"type" havingValue: @"fax"]; - if ([array count]) - [entry setObject: [[array objectAtIndex: 0] value: 0] forKey: @"fax"]; - array = [self childrenWithTag: @"tel" andAttribute: @"type" havingValue: @"cell"]; - if ([array count]) - [entry setObject: [[array objectAtIndex: 0] value: 0] forKey: @"mobile"]; - array = [self childrenWithTag: @"tel" andAttribute: @"type" havingValue: @"pager"]; - if ([array count]) - [entry setObject: [[array objectAtIndex: 0] value: 0] forKey: @"pager"]; - - array = [self childrenWithTag: @"adr" andAttribute: @"type" havingValue: @"home"]; - if ([array count]) - { - tmp = [array objectAtIndex: 0]; - [entry setObject: [tmp value: 0] forKey: @"homeStreet"]; - [entry setObject: [tmp value: 1] forKey: @"mozillaHomeLocalityName"]; - [entry setObject: [tmp value: 2] forKey: @"mozillaHomeState"]; - [entry setObject: [tmp value: 3] forKey: @"mozillaHomePostalCode"]; - [entry setObject: [tmp value: 4] forKey: @"mozillaHomeCountryName"]; - } - - array = [self org]; - if (array && [array count]) - [entry setObject: [array objectAtIndex: 0] forKey: @"o"]; - - array = [self childrenWithTag: @"adr" andAttribute: @"type" havingValue: @"work"]; - if ([array count]) - { - tmp = [array objectAtIndex: 0]; - [entry setObject: [tmp value: 0] forKey: @"street"]; - [entry setObject: [tmp value: 1] forKey: @"l"]; - [entry setObject: [tmp value: 2] forKey: @"st"]; - [entry setObject: [tmp value: 3] forKey: @"postalCode"]; - [entry setObject: [tmp value: 4] forKey: @"c"]; - } - - array = [self childrenWithTag: @"tel" andAttribute: @"type" havingValue: @"work"]; - if ([array count]) - [entry setObject: [[array objectAtIndex: 0] value: 0] - forKey: @"telephoneNumber"]; - - array = [self childrenWithTag: @"url" andAttribute: @"type" havingValue: @"work"]; - if ([array count]) - [entry setObject: [[array objectAtIndex: 0] value: 0] - forKey: @"workurl"]; - - array = [self childrenWithTag: @"url" andAttribute: @"type" havingValue: @"home"]; - if ([array count]) - [entry setObject: [[array objectAtIndex: 0] value: 0] - forKey: @"homeurl"]; - - tmp = [self note]; - if (tmp && [tmp length]) - [entry setObject: tmp forKey: @"description"]; - - rc = [NSMutableString stringWithString: [entry userRecordAsLDIFEntry]]; - [rc appendFormat: @"\n"]; - - return rc; -} - @end /* NGVCard */ diff --git a/SOPE/NGCards/NGVList.h b/SOPE/NGCards/NGVList.h index 3d05aa36b..9c11b7d57 100644 --- a/SOPE/NGCards/NGVList.h +++ b/SOPE/NGCards/NGVList.h @@ -64,8 +64,6 @@ - (void) deleteCardReference: (NGVCardReference *) cardRef; - (NSArray *) cardReferences; -- (NSString *) ldifString; - @end #endif /* NGVLIST_H */ diff --git a/SOPE/NGCards/NGVList.m b/SOPE/NGCards/NGVList.m index 926347ca3..3e85fa6ea 100644 --- a/SOPE/NGCards/NGVList.m +++ b/SOPE/NGCards/NGVList.m @@ -25,8 +25,6 @@ #import #import -#import "../../SoObjects/SOGo/NSDictionary+Utilities.h" - #import "NGVCardReference.h" #import "NGVList.h" @@ -200,43 +198,4 @@ return [self childrenWithTag: @"card"]; } -- (NSString *) ldifString -{ - NSMutableString *rc; - NSArray *array; - NSMutableArray *members; - NGVCardReference *tmp; - NSMutableDictionary *entry; - int i, count; - - entry = [NSMutableDictionary dictionary]; - - [entry setObject: [NSString stringWithFormat: @"cn=%@", [self fn]] - forKey: @"dn"]; - [entry setObject: [NSArray arrayWithObjects: @"top", @"groupOfNames", nil] - forKey: @"objectclass"]; - [entry setObject: [self fn] forKey: @"cn"]; - if ([self nickname]) - [entry setObject: [self nickname] forKey: @"mozillaNickname"]; - if ([self description]) - [entry setObject: [self description] forKey: @"description"]; - - array = [self cardReferences]; - count = [array count]; - members = [NSMutableArray array]; - for (i = 0; i < count; i++) - { - tmp = [array objectAtIndex: i]; - [members addObject: [NSString stringWithFormat: - @"cn=%@,mail=%@", [tmp fn], [tmp email]]]; - } - [entry setObject: members forKey: @"member"]; - - rc = [NSMutableString stringWithString: [entry userRecordAsLDIFEntry]]; - [rc appendFormat: @"\n"]; - - return rc; -} - - @end diff --git a/SoObjects/Contacts/GNUmakefile b/SoObjects/Contacts/GNUmakefile index 1a9872fe3..4d48263be 100644 --- a/SoObjects/Contacts/GNUmakefile +++ b/SoObjects/Contacts/GNUmakefile @@ -9,6 +9,8 @@ Contacts_PRINCIPAL_CLASS = SOGoContactsProduct Contacts_OBJC_FILES = \ Product.m \ + NGVCard+SOGo.m \ + NGVList+SOGo.m \ SOGoFolder+CardDAV.m \ SOGoContactFolders.m \ SOGoContactGCSEntry.m \ diff --git a/SoObjects/Contacts/NGVCard+SOGo.h b/SoObjects/Contacts/NGVCard+SOGo.h new file mode 100644 index 000000000..a758d86c8 --- /dev/null +++ b/SoObjects/Contacts/NGVCard+SOGo.h @@ -0,0 +1,34 @@ +/* NGVCard+SOGo.h - this file is part of SOGo + * + * Copyright (C) 2009 Inverse inc. + * + * Author: Cyril Robert + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef NGVCARD_SOGO_H +#define NGVCARD_SOGO_H + +#import + +@interface NGVCard (SOGoExtensions) + +- (NSString *) ldifString; + +@end + +#endif /* NGVCARD_SOGO_H */ diff --git a/SoObjects/Contacts/NGVCard+SOGo.m b/SoObjects/Contacts/NGVCard+SOGo.m new file mode 100644 index 000000000..750e63518 --- /dev/null +++ b/SoObjects/Contacts/NGVCard+SOGo.m @@ -0,0 +1,137 @@ +/* NGVCard+SOGo.m - this file is part of SOGo + * + * Copyright (C) 2009 Inverse inc. + * + * Author: Cyril Robert + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#import +#import +#import +#import + +#import +#import "NGVCard+SOGo.h" + +@implementation NGVCard (SOGoExtensions) + +- (NSString *) ldifString +{ + NSMutableString *rc; + NSString *buffer; + NSArray *array; + NSMutableArray *marray; + NSMutableDictionary *entry; + id tmp; + + entry = [NSMutableDictionary dictionary]; + + [entry setObject: [NSString stringWithFormat: @"cn=%@,mail=%@", + [self fn], [self preferredEMail]] + forKey: @"dn"]; + [entry setObject: [NSArray arrayWithObjects: @"top", @"person", + @"organizationalPerson", @"inetOrgPerson", + @"mozillaAbPersonObsolete", nil] + forKey: @"objectclass"]; + [entry setObject: [[self n] objectAtIndex: 1] forKey: @"givenName"]; + [entry setObject: [[self n] objectAtIndex: 0] forKey: @"sn"]; + [entry setObject: [self fn] forKey: @"cn"]; + [entry setObject: [self preferredEMail] forKey: @"mail"]; + [entry setObject: @"0Z" forKey: @"modifytimestamp"]; + + buffer = [self nickname]; + if (buffer && [buffer length] > 0) + [entry setObject: buffer forKey: @"mozillaNickname"]; + + marray = [NSMutableArray arrayWithArray: [self childrenWithTag: @"email"]]; + [marray removeObjectsInArray: [self childrenWithTag: @"email" + andAttribute: @"type" + havingValue: @"pref"]]; + if ([marray count]) + { + buffer = [[marray objectAtIndex: [marray count]-1] value: 0]; + + if ([buffer caseInsensitiveCompare: [self preferredEMail]] != NSOrderedSame) + [entry setObject: buffer forKey: @"mozillaSecondEmail"]; + } + + array = [self childrenWithTag: @"tel" andAttribute: @"type" havingValue: @"home"]; + if ([array count]) + [entry setObject: [[array objectAtIndex: 0] value: 0] forKey: @"homePhone"]; + array = [self childrenWithTag: @"tel" andAttribute: @"type" havingValue: @"fax"]; + if ([array count]) + [entry setObject: [[array objectAtIndex: 0] value: 0] forKey: @"fax"]; + array = [self childrenWithTag: @"tel" andAttribute: @"type" havingValue: @"cell"]; + if ([array count]) + [entry setObject: [[array objectAtIndex: 0] value: 0] forKey: @"mobile"]; + array = [self childrenWithTag: @"tel" andAttribute: @"type" havingValue: @"pager"]; + if ([array count]) + [entry setObject: [[array objectAtIndex: 0] value: 0] forKey: @"pager"]; + + array = [self childrenWithTag: @"adr" andAttribute: @"type" havingValue: @"home"]; + if ([array count]) + { + tmp = [array objectAtIndex: 0]; + [entry setObject: [tmp value: 0] forKey: @"homeStreet"]; + [entry setObject: [tmp value: 1] forKey: @"mozillaHomeLocalityName"]; + [entry setObject: [tmp value: 2] forKey: @"mozillaHomeState"]; + [entry setObject: [tmp value: 3] forKey: @"mozillaHomePostalCode"]; + [entry setObject: [tmp value: 4] forKey: @"mozillaHomeCountryName"]; + } + + array = [self org]; + if (array && [array count]) + [entry setObject: [array objectAtIndex: 0] forKey: @"o"]; + + array = [self childrenWithTag: @"adr" andAttribute: @"type" havingValue: @"work"]; + if ([array count]) + { + tmp = [array objectAtIndex: 0]; + [entry setObject: [tmp value: 0] forKey: @"street"]; + [entry setObject: [tmp value: 1] forKey: @"l"]; + [entry setObject: [tmp value: 2] forKey: @"st"]; + [entry setObject: [tmp value: 3] forKey: @"postalCode"]; + [entry setObject: [tmp value: 4] forKey: @"c"]; + } + + array = [self childrenWithTag: @"tel" andAttribute: @"type" havingValue: @"work"]; + if ([array count]) + [entry setObject: [[array objectAtIndex: 0] value: 0] + forKey: @"telephoneNumber"]; + + array = [self childrenWithTag: @"url" andAttribute: @"type" havingValue: @"work"]; + if ([array count]) + [entry setObject: [[array objectAtIndex: 0] value: 0] + forKey: @"workurl"]; + + array = [self childrenWithTag: @"url" andAttribute: @"type" havingValue: @"home"]; + if ([array count]) + [entry setObject: [[array objectAtIndex: 0] value: 0] + forKey: @"homeurl"]; + + tmp = [self note]; + if (tmp && [tmp length]) + [entry setObject: tmp forKey: @"description"]; + + rc = [NSMutableString stringWithString: [entry userRecordAsLDIFEntry]]; + [rc appendFormat: @"\n"]; + + return rc; +} + +@end /* NGVCard */ diff --git a/SoObjects/Contacts/NGVList+SOGo.h b/SoObjects/Contacts/NGVList+SOGo.h new file mode 100644 index 000000000..04601ae1c --- /dev/null +++ b/SoObjects/Contacts/NGVList+SOGo.h @@ -0,0 +1,34 @@ +/* NGVCard+SOGo.h - this file is part of SOGo + * + * Copyright (C) 2009 Inverse inc. + * + * Author: Cyril Robert + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef NGVLIST_SOGO_H +#define NGVLIST_SOGO_H + +#import + +@interface NGVList (SOGoExtensions) + +- (NSString *) ldifString; + +@end + +#endif /* NGVLIST_SOGO_H */ diff --git a/SoObjects/Contacts/NGVList+SOGo.m b/SoObjects/Contacts/NGVList+SOGo.m new file mode 100644 index 000000000..bce521a31 --- /dev/null +++ b/SoObjects/Contacts/NGVList+SOGo.m @@ -0,0 +1,73 @@ +/* NGVCard+SOGo.m - this file is part of SOGo + * + * Copyright (C) 2009 Inverse inc. + * + * Author: Cyril Robert + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#import +#import +#import +#import + +#import +#import "NGVList+SOGo.h" + +#import + +@implementation NGVList (SOGoExtensions) + +- (NSString *) ldifString +{ + NSMutableString *rc; + NSArray *array; + NSMutableArray *members; + NGVCardReference *tmp; + NSMutableDictionary *entry; + int i, count; + + entry = [NSMutableDictionary dictionary]; + + [entry setObject: [NSString stringWithFormat: @"cn=%@", [self fn]] + forKey: @"dn"]; + [entry setObject: [NSArray arrayWithObjects: @"top", @"groupOfNames", nil] + forKey: @"objectclass"]; + [entry setObject: [self fn] forKey: @"cn"]; + if ([self nickname]) + [entry setObject: [self nickname] forKey: @"mozillaNickname"]; + if ([self description]) + [entry setObject: [self description] forKey: @"description"]; + + array = [self cardReferences]; + count = [array count]; + members = [NSMutableArray array]; + for (i = 0; i < count; i++) + { + tmp = [array objectAtIndex: i]; + [members addObject: [NSString stringWithFormat: + @"cn=%@,mail=%@", [tmp fn], [tmp email]]]; + } + [entry setObject: members forKey: @"member"]; + + rc = [NSMutableString stringWithString: [entry userRecordAsLDIFEntry]]; + [rc appendFormat: @"\n"]; + + return rc; +} + +@end /* NGVList */ diff --git a/UI/Contacts/UIxContactFolderActions.m b/UI/Contacts/UIxContactFolderActions.m index b55c1f5f0..4dfc2a99d 100644 --- a/UI/Contacts/UIxContactFolderActions.m +++ b/UI/Contacts/UIxContactFolderActions.m @@ -35,8 +35,8 @@ #import #import -#import -#import +#import +#import #import #import #import