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
maint-2.0.2
C Robert 2009-09-09 15:30:22 +00:00
parent c543b9e9a7
commit f4fabba6b9
12 changed files with 290 additions and 153 deletions

View File

@ -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 <crobert@inverse.ca>

View File

@ -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 <crobert@inverse.ca>

View File

@ -157,7 +157,6 @@ typedef enum
- (NSString *) preferredEMail;
- (NSString *) preferredTel;
- (CardElement *) preferredAdr;
- (NSString *) ldifString;
@end

View File

@ -24,8 +24,6 @@
#import <Foundation/NSEnumerator.h>
#import <Foundation/NSString.h>
#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 */

View File

@ -64,8 +64,6 @@
- (void) deleteCardReference: (NGVCardReference *) cardRef;
- (NSArray *) cardReferences;
- (NSString *) ldifString;
@end
#endif /* NGVLIST_H */

View File

@ -25,8 +25,6 @@
#import <Foundation/NSString.h>
#import <Foundation/NSDictionary.h>
#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

View File

@ -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 \

View File

@ -0,0 +1,34 @@
/* NGVCard+SOGo.h - this file is part of SOGo
*
* Copyright (C) 2009 Inverse inc.
*
* Author: Cyril Robert <crobert@inverse.ca>
*
* 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 <NGCards/NGVCard.h>
@interface NGVCard (SOGoExtensions)
- (NSString *) ldifString;
@end
#endif /* NGVCARD_SOGO_H */

View File

@ -0,0 +1,137 @@
/* NGVCard+SOGo.m - this file is part of SOGo
*
* Copyright (C) 2009 Inverse inc.
*
* Author: Cyril Robert <crobert@inverse.ca>
*
* 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 <Foundation/NSArray.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSEnumerator.h>
#import <Foundation/NSString.h>
#import <SOGo/NSDictionary+Utilities.h>
#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 */

View File

@ -0,0 +1,34 @@
/* NGVCard+SOGo.h - this file is part of SOGo
*
* Copyright (C) 2009 Inverse inc.
*
* Author: Cyril Robert <crobert@inverse.ca>
*
* 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 <NGCards/NGVList.h>
@interface NGVList (SOGoExtensions)
- (NSString *) ldifString;
@end
#endif /* NGVLIST_SOGO_H */

View File

@ -0,0 +1,73 @@
/* NGVCard+SOGo.m - this file is part of SOGo
*
* Copyright (C) 2009 Inverse inc.
*
* Author: Cyril Robert <crobert@inverse.ca>
*
* 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 <Foundation/NSArray.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSEnumerator.h>
#import <Foundation/NSString.h>
#import <SOGo/NSDictionary+Utilities.h>
#import "NGVList+SOGo.h"
#import <NGCards/NGVCardReference.h>
@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 */

View File

@ -35,8 +35,8 @@
#import <Contacts/SOGoContactFolder.h>
#import <Contacts/SOGoContactFolders.h>
#import <NGCards/NGVCard.h>
#import <NGCards/NGVList.h>
#import <SoObjects/Contacts/NGVCard+SOGo.h>
#import <SoObjects/Contacts/NGVList+SOGo.h>
#import <SoObjects/Contacts/SOGoContactGCSEntry.h>
#import <SoObjects/Contacts/SOGoContactLDIFEntry.h>
#import <SoObjects/Contacts/SOGoContactGCSList.h>