propagate from branch 'ca.inverse.sogo.1_3_12' (head b8548824eb65ecdb685bcfce0f1f1a07d6e8f2c0)
to branch 'ca.inverse.sogo' (head f2f2f66b3df579ca384e578aded6976b6634ffcb) Monotone-Parent: b8548824eb65ecdb685bcfce0f1f1a07d6e8f2c0 Monotone-Parent: f2f2f66b3df579ca384e578aded6976b6634ffcb Monotone-Revision: 71d893c6f56295ecb4a106a46e10ccc403627cc4 Monotone-Author: jraby@inverse.ca Monotone-Date: 2012-01-03T21:08:29 Monotone-Branch: ca.inverse.sogomaint-2.0.2
commit
444a208f86
103
ChangeLog
103
ChangeLog
|
@ -1,3 +1,106 @@
|
||||||
|
2011-12-30 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||||
|
|
||||||
|
* SoObjects/SOGo/LDAPSourceSchema.[hm]: new class module enabling
|
||||||
|
schema auto-discovery.
|
||||||
|
|
||||||
|
* UI/WebServerResources/UIxContactEditor.js
|
||||||
|
(validateContactEditor): the birth date is validated slightly
|
||||||
|
differently, by enabling empty and 2-digit years as well as single
|
||||||
|
digits months and days.
|
||||||
|
|
||||||
|
* UI/Contacts/UIxContactView.m (-defaultAction, -dealloc): retain
|
||||||
|
and release the "card" ivar.
|
||||||
|
(_formattedURL:): the url should be displayed only if it is
|
||||||
|
non-nil AND non-empty.
|
||||||
|
(-vcardAction): removed useless method.
|
||||||
|
|
||||||
|
* UI/Contacts/UIxContactEditor.m (init): removed the "snapshot",
|
||||||
|
"preferredEmail", "card", "photosURL" and "contactCategories" ivars.
|
||||||
|
(-ldifRecord): new getter that proxy the invocation to the client
|
||||||
|
object, but by taking the contactEmail and contactFN url
|
||||||
|
parameters. Replaces the "-snapshot" getter, since the LDIF record
|
||||||
|
is now directly edited.
|
||||||
|
(-addressBooksList): the client object container class is no
|
||||||
|
longer taken into account when fetching the current user's permissions.
|
||||||
|
(-supportCategories, -supportPhotos): new getters that enables the
|
||||||
|
categories and photo tabs.
|
||||||
|
(-setJsonContactCategories:, -jsonContactCategories): now make
|
||||||
|
use of the special "vcardcategories" parameter found in the
|
||||||
|
contact LDIF record.
|
||||||
|
|
||||||
|
* SoObjects/SOGo/SQLSource.m (_lookupContactEntry:considerEmail:):
|
||||||
|
enhanced to copy the "c_XX" fields to unprefixed equivalents.
|
||||||
|
|
||||||
|
* SoObjects/Contacts/NSString+LDIF.m (mustEncodeLDIFValue): new
|
||||||
|
method, replacing "_isLDIFSafe" in a clearly public manner.
|
||||||
|
|
||||||
|
* SoObjects/SOGo/LDAPSource.m (-[NGLdapEntry _asDictionary]): new
|
||||||
|
utility method to convert an entry into a "SOGo LDIF record".
|
||||||
|
(-[NGLdapAttribute _asArrayOrString]): new utility method to
|
||||||
|
convert an LDAP attribute into a string or an array of strings
|
||||||
|
when the attribute has one or more values.
|
||||||
|
(-initFromUDSource:inDomain:): handle the new "modifiers",
|
||||||
|
"mapping" and "objectClasses" configuration keys, used when the
|
||||||
|
source instance is used as an addressbook. All LDAP fields are now
|
||||||
|
converted to lowercase.
|
||||||
|
(_searchAttributes): removed method as the special "*" attribute
|
||||||
|
is not costly enough to justify its existence, thereby reducing
|
||||||
|
code complexity.
|
||||||
|
(-lookupContactEntry:, -lookupContactEntryWithUIDorEmail:)
|
||||||
|
(-lookupLoginByDN:): merged common code in the new
|
||||||
|
-_lookupLDAPEntry: method, that accepts an EOQualifier as argument.
|
||||||
|
(--addContactEntry:withID:, -updateContactEntry: and
|
||||||
|
removeContactEntryWithID:): new methods for editing addressbook
|
||||||
|
sources.
|
||||||
|
|
||||||
|
* SoObjects/Contacts/SOGoContactSourceFolder.m (-source): new
|
||||||
|
getter for the "source" ivar.
|
||||||
|
(-lookupName:inContext:acquire:): accept the creation of new LDIF
|
||||||
|
entries via web methods ending with "AsContact".
|
||||||
|
(-saveLDIFEntry:, -deleteLDIFEntry:): new proxy methods for the
|
||||||
|
new SOGoSource -addContactEntry:withID:, -updateContactEntry: and
|
||||||
|
removeContactEntryWithID: methods, enabling the creation,
|
||||||
|
modification and deletion of LDAP contacts.
|
||||||
|
(-aclsForUser:): implemented method based on the array returned by
|
||||||
|
-[<SOGoSource> modifiers].
|
||||||
|
|
||||||
|
* SoObjects/Contacts/SOGoContactLDIFEntry.m (-vCard): the vcard is
|
||||||
|
now generated automatically from the LDIF record of the entry,
|
||||||
|
using the new method provided by NGVCard+SOGo.
|
||||||
|
(-aclsForUser:): new overriden method similar to the
|
||||||
|
implementation from SOGoContentObject.
|
||||||
|
|
||||||
|
* SoObjects/Contacts/SOGoContactGCSEntry.m (-setLDIFRecord)
|
||||||
|
(-ldifRecord, -hasPhoto): new accessors required by the
|
||||||
|
SOGoContactObject protocol.
|
||||||
|
(-lookupName:inContext:acquire:): return the only photo element
|
||||||
|
when the "photo" key is requested, if present in the card.
|
||||||
|
(-save): now returns an NSException, instead of void.
|
||||||
|
|
||||||
|
* SoObjects/Contacts/SOGoContactEntryPhoto.m
|
||||||
|
(+entryPhotoWithID:inContainer:, -setPhotoID:): removed methods,
|
||||||
|
since there can only be one PHOTO element per contact.
|
||||||
|
(-photo): simplified thanks to the constraint mentionned above.
|
||||||
|
|
||||||
|
* SoObjects/Contacts/NSDictionary+LDIF.m (-ldifRecordAsString):
|
||||||
|
new method implementing the code previously found in
|
||||||
|
SOGo/NSDictionary+Utilities.m, in order to produce a textual
|
||||||
|
representation of an LDIF record.
|
||||||
|
|
||||||
|
* SoObjects/Contacts/NSDictionary+LDIF.[hm]: new category module.
|
||||||
|
|
||||||
|
* SoObjects/Contacts/NGVCard+SOGo.m (-asLDIFRecord): new method
|
||||||
|
implementing the conversion code previously found in
|
||||||
|
UIxContactEditor, in order to produce an "LDIF record" in the form
|
||||||
|
of an NSDictionary matching the inetOrgPerson and
|
||||||
|
mozillaAbPersonAlpha object classes.
|
||||||
|
(-updateFromLDIFRecord:) reciprocal method to "-asLDIFRecord",
|
||||||
|
with conversion code moved from UIxContactEditor.
|
||||||
|
|
||||||
|
* SoObjects/Contacts/SOGoFolder+CardDAV.m (_isValidFilter:): make
|
||||||
|
use of the lowercase instance of the string, which was erroneously
|
||||||
|
ignored previously.
|
||||||
|
|
||||||
2012-01-02 Francis Lachapelle <flachapelle@inverse.ca>
|
2012-01-02 Francis Lachapelle <flachapelle@inverse.ca>
|
||||||
|
|
||||||
* UI/WebServerResources/UIxPreferences.js (getFilterFromEditor):
|
* UI/WebServerResources/UIxPreferences.js (getFilterFromEditor):
|
||||||
|
|
|
@ -172,12 +172,12 @@ LIBMAPISTORE_CFLAGS = $(shell pkg-config libmapistore --cflags) -DSAMBA_PREFIX="
|
||||||
LIBMAPISTORE_LIBS = $(shell pkg-config libmapistore --libs) -lmapiproxy
|
LIBMAPISTORE_LIBS = $(shell pkg-config libmapistore --libs) -lmapiproxy
|
||||||
|
|
||||||
$(MAPISTORESOGO)_INSTALL_DIR = $(DESTDIR)/$(SAMBA_LIB_DIR)/mapistore_backends
|
$(MAPISTORESOGO)_INSTALL_DIR = $(DESTDIR)/$(SAMBA_LIB_DIR)/mapistore_backends
|
||||||
$(MAPISTORESOGO)_LDFLAGS += \
|
$(MAPISTORESOGO)_LIB_DIRS += \
|
||||||
-L../SoObjects/SOGo/SOGo.framework/ -lSOGo \
|
-L../SoObjects/SOGo/SOGo.framework/ -lSOGo \
|
||||||
$(LIBMAPI_LIBS) \
|
$(LIBMAPI_LIBS) \
|
||||||
$(LIBMAPISTORE_LIBS)
|
$(LIBMAPISTORE_LIBS)
|
||||||
|
|
||||||
$(SOGOBACKEND)_LDFLAGS += \
|
$(SOGOBACKEND)_LIB_DIRS += \
|
||||||
-L../OGoContentStore/$(GNUSTEP_OBJ_DIR)/ -lOGoContentStore \
|
-L../OGoContentStore/$(GNUSTEP_OBJ_DIR)/ -lOGoContentStore \
|
||||||
-L../SoObjects/SOGo/SOGo.framework/ -lSOGo \
|
-L../SoObjects/SOGo/SOGo.framework/ -lSOGo \
|
||||||
$(LIBMAPI_LIBS) \
|
$(LIBMAPI_LIBS) \
|
||||||
|
|
|
@ -460,8 +460,6 @@ _orderedValuesAreVoid (NSArray *orderedValues)
|
||||||
NSMutableArray *orderedValues;
|
NSMutableArray *orderedValues;
|
||||||
NSUInteger count, max;
|
NSUInteger count, max;
|
||||||
|
|
||||||
result = YES;
|
|
||||||
|
|
||||||
keys = [values allKeys];
|
keys = [values allKeys];
|
||||||
max = [keys count];
|
max = [keys count];
|
||||||
for (count = 0; result && count < max; count++)
|
for (count = 0; result && count < max; count++)
|
||||||
|
|
|
@ -46,12 +46,15 @@
|
||||||
- (CardElement *) uniqueChildWithTag: (NSString *) aTag;
|
- (CardElement *) uniqueChildWithTag: (NSString *) aTag;
|
||||||
- (void) setUniqueChild: (CardElement *) aChild;
|
- (void) setUniqueChild: (CardElement *) aChild;
|
||||||
|
|
||||||
|
- (NSMutableArray *) children;
|
||||||
|
|
||||||
- (void) addChild: (CardElement *) aChild;
|
- (void) addChild: (CardElement *) aChild;
|
||||||
- (void) addChildren: (NSArray *) someChildren;
|
- (void) addChildren: (NSArray *) someChildren;
|
||||||
- (void) removeChild: (CardElement *) aChild;
|
- (void) removeChild: (CardElement *) aChild;
|
||||||
- (void) removeChildren: (NSArray *) someChildren;
|
- (void) removeChildren: (NSArray *) someChildren;
|
||||||
|
|
||||||
- (NSMutableArray *) children;
|
- (void) cleanupEmptyChildren;
|
||||||
|
|
||||||
- (CardElement *) firstChildWithTag: (NSString *) aTag;
|
- (CardElement *) firstChildWithTag: (NSString *) aTag;
|
||||||
- (NSArray *) childrenWithTag: (NSString *) aTag;
|
- (NSArray *) childrenWithTag: (NSString *) aTag;
|
||||||
- (NSArray *) childrenWithAttribute: (NSString *) anAttribute
|
- (NSArray *) childrenWithAttribute: (NSString *) anAttribute
|
||||||
|
|
|
@ -142,6 +142,19 @@ static NGCardsSaxHandler *sax = nil;
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL) isVoid
|
||||||
|
{
|
||||||
|
BOOL isVoid = YES;
|
||||||
|
NSUInteger count, max;
|
||||||
|
|
||||||
|
max = [children count];
|
||||||
|
for (count = 0; isVoid && count < max; count++)
|
||||||
|
if (![[children objectAtIndex: count] isVoid])
|
||||||
|
isVoid = NO;
|
||||||
|
|
||||||
|
return isVoid;
|
||||||
|
}
|
||||||
|
|
||||||
- (void) addChild: (CardElement *) aChild
|
- (void) addChild: (CardElement *) aChild
|
||||||
{
|
{
|
||||||
Class mappedClass;
|
Class mappedClass;
|
||||||
|
@ -366,6 +379,23 @@ static NGCardsSaxHandler *sax = nil;
|
||||||
[self addChild: newChild];
|
[self addChild: newChild];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) cleanupEmptyChildren
|
||||||
|
{
|
||||||
|
NSUInteger max;
|
||||||
|
NSInteger count;
|
||||||
|
CardElement *child;
|
||||||
|
|
||||||
|
max = [children count];
|
||||||
|
for (count = max - 1; count > -1; count--)
|
||||||
|
{
|
||||||
|
child = [children objectAtIndex: count];
|
||||||
|
if ([child isKindOfClass: [CardGroup class]])
|
||||||
|
[(CardGroup *) child cleanupEmptyChildren];
|
||||||
|
if ([child isVoid])
|
||||||
|
[children removeObjectAtIndex: count];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (NSString *) description
|
- (NSString *) description
|
||||||
{
|
{
|
||||||
NSMutableString *str;
|
NSMutableString *str;
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
2011-12-30 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||||
|
|
||||||
|
* NGVCard.m (-initWithUid:): initialize "CLASS" and "PROFILE".
|
||||||
|
|
||||||
|
* CardGroup.m (-isVoid): overriden method.
|
||||||
|
(-cleanupEmptyChildren): make use of "isVoid" to detect and remove
|
||||||
|
empty children.
|
||||||
|
|
||||||
2011-11-21 Francis Lachapelle <flachapelle@inverse.ca>
|
2011-11-21 Francis Lachapelle <flachapelle@inverse.ca>
|
||||||
|
|
||||||
* iCalTimeZone.m (+knownTimeZoneNames): ignore files that don't
|
* iCalTimeZone.m (+knownTimeZoneNames): ignore files that don't
|
||||||
|
|
|
@ -50,6 +50,8 @@
|
||||||
[self setTag: @"vcard"];
|
[self setTag: @"vcard"];
|
||||||
[self setUid: _uid];
|
[self setUid: _uid];
|
||||||
[self setVersion: @"3.0"];
|
[self setVersion: @"3.0"];
|
||||||
|
[self setVClass: @"PUBLIC"];
|
||||||
|
[self setProfile: @"VCARD"];
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
|
|
@ -20,6 +20,9 @@ Contacts_OBJC_FILES = \
|
||||||
SOGoContactSourceFolder.m \
|
SOGoContactSourceFolder.m \
|
||||||
SOGoUserFolder+Contacts.m \
|
SOGoUserFolder+Contacts.m \
|
||||||
SOGoContactEntryPhoto.m \
|
SOGoContactEntryPhoto.m \
|
||||||
|
\
|
||||||
|
NSDictionary+LDIF.m \
|
||||||
|
NSString+LDIF.m
|
||||||
|
|
||||||
Contacts_RESOURCE_FILES += \
|
Contacts_RESOURCE_FILES += \
|
||||||
product.plist \
|
product.plist \
|
||||||
|
|
|
@ -25,9 +25,13 @@
|
||||||
|
|
||||||
#import <NGCards/NGVCard.h>
|
#import <NGCards/NGVCard.h>
|
||||||
|
|
||||||
|
@class NSDictionary;
|
||||||
|
@class NSMutableDictionary;
|
||||||
|
|
||||||
@interface NGVCard (SOGoExtensions)
|
@interface NGVCard (SOGoExtensions)
|
||||||
|
|
||||||
- (NSString *) ldifString;
|
- (void) updateFromLDIFRecord: (NSDictionary *) ldifRecord;
|
||||||
|
- (NSMutableDictionary *) asLDIFRecord;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -21,153 +21,610 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import <Foundation/NSArray.h>
|
#import <Foundation/NSArray.h>
|
||||||
|
#import <Foundation/NSCalendarDate.h>
|
||||||
#import <Foundation/NSDictionary.h>
|
#import <Foundation/NSDictionary.h>
|
||||||
#import <Foundation/NSEnumerator.h>
|
#import <Foundation/NSEnumerator.h>
|
||||||
#import <Foundation/NSString.h>
|
#import <Foundation/NSString.h>
|
||||||
|
|
||||||
#import <SOGo/NSDictionary+Utilities.h>
|
#import <NGCards/NSArray+NGCards.h>
|
||||||
|
#import <NGCards/NSString+NGCards.h>
|
||||||
|
|
||||||
|
#import "NSDictionary+LDIF.h"
|
||||||
|
|
||||||
#import "NGVCard+SOGo.h"
|
#import "NGVCard+SOGo.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
objectclass ( 2.5.6.6 NAME 'person'
|
||||||
|
DESC 'RFC2256: a person'
|
||||||
|
SUP top STRUCTURAL
|
||||||
|
MUST ( sn $ cn )
|
||||||
|
MAY ( userPassword $ telephoneNumber $ seeAlso $ description ) )
|
||||||
|
|
||||||
|
objectclass ( 2.5.6.7 NAME 'organizationalPerson'
|
||||||
|
DESC 'RFC2256: an organizational person'
|
||||||
|
SUP person STRUCTURAL
|
||||||
|
MAY ( title $ x121Address $ registeredAddress $ destinationIndicator $
|
||||||
|
preferredDeliveryMethod $ telexNumber $ teletexTerminalIdentifier $
|
||||||
|
telephoneNumber $ internationaliSDNNumber $
|
||||||
|
facsimileTelephoneNumber $ street $ postOfficeBox $ postalCode $
|
||||||
|
postalAddress $ physicalDeliveryOfficeName $ ou $ st $ l ) )
|
||||||
|
|
||||||
|
objectclass ( 2.16.840.1.113730.3.2.2
|
||||||
|
NAME 'inetOrgPerson'
|
||||||
|
DESC 'RFC2798: Internet Organizational Person'
|
||||||
|
SUP organizationalPerson
|
||||||
|
STRUCTURAL
|
||||||
|
MAY (
|
||||||
|
audio $ businessCategory $ carLicense $ departmentNumber $
|
||||||
|
displayName $ employeeNumber $ employeeType $ givenName $
|
||||||
|
homePhone $ homePostalAddress $ initials $ jpegPhoto $
|
||||||
|
labeledURI $ mail $ manager $ mobile $ o $ pager $
|
||||||
|
photo $ roomNumber $ secretary $ uid $ userCertificate $
|
||||||
|
x500uniqueIdentifier $ preferredLanguage $
|
||||||
|
userSMIMECertificate $ userPKCS12 )
|
||||||
|
)
|
||||||
|
|
||||||
|
objectclass ( 1.3.6.1.4.1.13769.9.1 NAME 'mozillaAbPersonAlpha'
|
||||||
|
SUP top AUXILIARY
|
||||||
|
MUST ( cn )
|
||||||
|
MAY( c $
|
||||||
|
description $
|
||||||
|
displayName $
|
||||||
|
facsimileTelephoneNumber $
|
||||||
|
givenName $
|
||||||
|
homePhone $
|
||||||
|
l $
|
||||||
|
mail $
|
||||||
|
mobile $
|
||||||
|
mozillaCustom1 $
|
||||||
|
mozillaCustom2 $
|
||||||
|
mozillaCustom3 $
|
||||||
|
mozillaCustom4 $
|
||||||
|
mozillaHomeCountryName $
|
||||||
|
mozillaHomeLocalityName $
|
||||||
|
mozillaHomePostalCode $
|
||||||
|
mozillaHomeState $
|
||||||
|
mozillaHomeStreet $
|
||||||
|
mozillaHomeStreet2 $
|
||||||
|
mozillaHomeUrl $
|
||||||
|
mozillaNickname $
|
||||||
|
mozillaSecondEmail $
|
||||||
|
mozillaUseHtmlMail $
|
||||||
|
mozillaWorkStreet2 $
|
||||||
|
mozillaWorkUrl $
|
||||||
|
nsAIMid $
|
||||||
|
o $
|
||||||
|
ou $
|
||||||
|
pager $
|
||||||
|
postalCode $
|
||||||
|
postOfficeBox $
|
||||||
|
sn $
|
||||||
|
st $
|
||||||
|
street $
|
||||||
|
telephoneNumber $
|
||||||
|
title ) )
|
||||||
|
|
||||||
|
additional vcard fields:
|
||||||
|
"vcardCategories"
|
||||||
|
|
||||||
|
test contact (export from tb):
|
||||||
|
|
||||||
|
dn:: Y249UHLDqW5vbSBOb20sbWFpbD1hZHIxQGVsZS5jb20=
|
||||||
|
objectclass: top
|
||||||
|
objectclass: person
|
||||||
|
objectclass: organizationalPerson
|
||||||
|
objectclass: inetOrgPerson
|
||||||
|
objectclass: mozillaAbPersonAlpha
|
||||||
|
givenName:: UHLDqW5vbQ==
|
||||||
|
sn: Nom
|
||||||
|
cn:: UHLDqW5vbSBOb20=
|
||||||
|
mozillaNickname: Surnom
|
||||||
|
mail: adr1@ele.com
|
||||||
|
mozillaSecondEmail: adralt@ele.com
|
||||||
|
nsAIMid: pseudo aim
|
||||||
|
modifytimestamp: 1324509379
|
||||||
|
telephoneNumber: travail
|
||||||
|
homePhone: dom
|
||||||
|
facsimiletelephonenumber: fax
|
||||||
|
pager: pager
|
||||||
|
mobile: port
|
||||||
|
mozillaHomeStreet:: YWRyMSBwcml2w6ll
|
||||||
|
mozillaHomeStreet2:: YWRyMiBwcml2w6ll
|
||||||
|
mozillaHomeLocalityName: ville/locallite
|
||||||
|
mozillaHomeState:: w6l0YXQvcHJvdg==
|
||||||
|
mozillaHomePostalCode: codepos
|
||||||
|
mozillaHomeCountryName: pays
|
||||||
|
street: adr1 pro
|
||||||
|
mozillaWorkStreet2: adr2 pro
|
||||||
|
l: ville pro
|
||||||
|
st: etat pro
|
||||||
|
postalCode: codepro
|
||||||
|
c: payspro
|
||||||
|
title: fonction pro
|
||||||
|
ou: service pro
|
||||||
|
o: soc pro
|
||||||
|
mozillaWorkUrl: webpro
|
||||||
|
mozillaHomeUrl: web
|
||||||
|
birthyear: 1946
|
||||||
|
birthmonth: 12
|
||||||
|
birthday: 04
|
||||||
|
mozillaCustom1: d1
|
||||||
|
mozillaCustom2: d2
|
||||||
|
mozillaCustom3: d3
|
||||||
|
mozillaCustom4: d4
|
||||||
|
description: notes
|
||||||
|
|
||||||
|
convention:
|
||||||
|
- our "LDIF records" are inetOrgPerson + mozillaAbPersonAlpha + a few custom
|
||||||
|
fields (categories)
|
||||||
|
- all keys are lowercase
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
@implementation NGVCard (SOGoExtensions)
|
@implementation NGVCard (SOGoExtensions)
|
||||||
|
|
||||||
- (NSString *) ldifString
|
/* LDIF -> VCARD */
|
||||||
|
- (CardElement *) _elementWithTag: (NSString *) elementTag
|
||||||
|
ofType: (NSString *) type
|
||||||
{
|
{
|
||||||
NSMutableString *rc;
|
NSArray *elements;
|
||||||
NSString *buffer;
|
|
||||||
NSArray *array;
|
|
||||||
NSMutableArray *marray;
|
|
||||||
NSMutableDictionary *entry;
|
|
||||||
CardElement *element;
|
CardElement *element;
|
||||||
id tmp;
|
|
||||||
|
|
||||||
entry = [NSMutableDictionary dictionary];
|
elements = [self childrenWithTag: elementTag
|
||||||
|
andAttribute: @"type" havingValue: type];
|
||||||
|
if ([elements count] > 0)
|
||||||
|
element = [elements objectAtIndex: 0];
|
||||||
|
else
|
||||||
|
{
|
||||||
|
element = [CardElement elementWithTag: elementTag];
|
||||||
|
[element addType: type];
|
||||||
|
[self addChild: element];
|
||||||
|
}
|
||||||
|
|
||||||
[entry setObject: [NSString stringWithFormat: @"cn=%@,mail=%@",
|
return element;
|
||||||
[self fn], [self preferredEMail]]
|
}
|
||||||
forKey: @"dn"];
|
|
||||||
[entry setObject: [NSArray arrayWithObjects: @"top", @"person",
|
- (void) _setPhoneValues: (NSDictionary *) ldifRecord
|
||||||
@"organizationalPerson", @"inetOrgPerson",
|
{
|
||||||
@"mozillaAbPersonObsolete", nil]
|
CardElement *phone;
|
||||||
forKey: @"objectclass"];
|
|
||||||
|
phone = [self _elementWithTag: @"tel" ofType: @"work"];
|
||||||
|
[phone setSingleValue: [ldifRecord objectForKey: @"telephonenumber"] forKey: @""];
|
||||||
|
phone = [self _elementWithTag: @"tel" ofType: @"home"];
|
||||||
|
[phone setSingleValue: [ldifRecord objectForKey: @"homephone"] forKey: @""];
|
||||||
|
phone = [self _elementWithTag: @"tel" ofType: @"cell"];
|
||||||
|
[phone setSingleValue: [ldifRecord objectForKey: @"mobile"] forKey: @""];
|
||||||
|
phone = [self _elementWithTag: @"tel" ofType: @"fax"];
|
||||||
|
[phone setSingleValue: [ldifRecord objectForKey: @"facsimiletelephonenumber"]
|
||||||
|
forKey: @""];
|
||||||
|
phone = [self _elementWithTag: @"tel" ofType: @"pager"];
|
||||||
|
[phone setSingleValue: [ldifRecord objectForKey: @"pager"] forKey: @""];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) _setEmails: (NSDictionary *) ldifRecord
|
||||||
|
{
|
||||||
|
CardElement *mail, *homeMail;
|
||||||
|
|
||||||
|
mail = [self _elementWithTag: @"email" ofType: @"work"];
|
||||||
|
[mail setSingleValue: [ldifRecord objectForKey: @"mail"] forKey: @""];
|
||||||
|
homeMail = [self _elementWithTag: @"email" ofType: @"home"];
|
||||||
|
[homeMail setSingleValue: [ldifRecord objectForKey: @"mozillasecondemail"] forKey: @""];
|
||||||
|
[[self uniqueChildWithTag: @"x-mozilla-html"]
|
||||||
|
setSingleValue: [ldifRecord objectForKey: @"mozillausehtmlmail"]
|
||||||
|
forKey: @""];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) updateFromLDIFRecord: (NSDictionary *) ldifRecord
|
||||||
|
{
|
||||||
|
CardElement *element;
|
||||||
|
NSArray *units;
|
||||||
|
NSInteger year, yearOfToday, month, day;
|
||||||
|
NSCalendarDate *now;
|
||||||
|
NSString *ou;
|
||||||
|
|
||||||
|
[self setNWithFamily: [ldifRecord objectForKey: @"sn"]
|
||||||
|
given: [ldifRecord objectForKey: @"givenname"]
|
||||||
|
additional: nil prefixes: nil suffixes: nil];
|
||||||
|
[self setNickname: [ldifRecord objectForKey: @"mozillanickname"]];
|
||||||
|
[self setFn: [ldifRecord objectForKey: @"displayname"]];
|
||||||
|
[self setTitle: [ldifRecord objectForKey: @"title"]];
|
||||||
|
|
||||||
|
element = [self _elementWithTag: @"adr" ofType: @"home"];
|
||||||
|
[element setSingleValue: [ldifRecord objectForKey: @"mozillahomestreet2"]
|
||||||
|
atIndex: 1 forKey: @""];
|
||||||
|
[element setSingleValue: [ldifRecord objectForKey: @"mozillahomestreet"]
|
||||||
|
atIndex: 2 forKey: @""];
|
||||||
|
[element setSingleValue: [ldifRecord objectForKey: @"mozillahomelocalityname"]
|
||||||
|
atIndex: 3 forKey: @""];
|
||||||
|
[element setSingleValue: [ldifRecord objectForKey: @"mozillahomestate"]
|
||||||
|
atIndex: 4 forKey: @""];
|
||||||
|
[element setSingleValue: [ldifRecord objectForKey: @"mozillahomepostalcode"]
|
||||||
|
atIndex: 5 forKey: @""];
|
||||||
|
[element setSingleValue: [ldifRecord objectForKey: @"mozillahomecountryname"]
|
||||||
|
atIndex: 6 forKey: @""];
|
||||||
|
|
||||||
|
element = [self _elementWithTag: @"adr" ofType: @"work"];
|
||||||
|
[element setSingleValue: [ldifRecord objectForKey: @"mozillaworkstreet2"]
|
||||||
|
atIndex: 1 forKey: @""];
|
||||||
|
[element setSingleValue: [ldifRecord objectForKey: @"street"]
|
||||||
|
atIndex: 2 forKey: @""];
|
||||||
|
[element setSingleValue: [ldifRecord objectForKey: @"l"]
|
||||||
|
atIndex: 3 forKey: @""];
|
||||||
|
[element setSingleValue: [ldifRecord objectForKey: @"st"]
|
||||||
|
atIndex: 4 forKey: @""];
|
||||||
|
[element setSingleValue: [ldifRecord objectForKey: @"postalcode"]
|
||||||
|
atIndex: 5 forKey: @""];
|
||||||
|
[element setSingleValue: [ldifRecord objectForKey: @"c"]
|
||||||
|
atIndex: 6 forKey: @""];
|
||||||
|
|
||||||
|
ou = [ldifRecord objectForKey: @"ou"];
|
||||||
|
if (ou)
|
||||||
|
units = [NSArray arrayWithObject: ou];
|
||||||
|
else
|
||||||
|
units = nil;
|
||||||
|
[self setOrg: [ldifRecord objectForKey: @"o"]
|
||||||
|
units: units];
|
||||||
|
|
||||||
|
[self _setPhoneValues: ldifRecord];
|
||||||
|
[self _setEmails: ldifRecord];
|
||||||
|
[[self _elementWithTag: @"url" ofType: @"home"]
|
||||||
|
setSingleValue: [ldifRecord objectForKey: @"mozillahomeurl"] forKey: @""];
|
||||||
|
[[self _elementWithTag: @"url" ofType: @"work"]
|
||||||
|
setSingleValue: [ldifRecord objectForKey: @"mozillaworkurl"] forKey: @""];
|
||||||
|
|
||||||
|
[[self uniqueChildWithTag: @"x-aim"]
|
||||||
|
setSingleValue: [ldifRecord objectForKey: @"nsaimid"]
|
||||||
|
forKey: @""];
|
||||||
|
|
||||||
|
now = [NSCalendarDate date];
|
||||||
|
year = [[ldifRecord objectForKey: @"birthyear"] intValue];
|
||||||
|
if (year < 100)
|
||||||
|
{
|
||||||
|
yearOfToday = [now yearOfCommonEra];
|
||||||
|
if (year == 0)
|
||||||
|
year = yearOfToday;
|
||||||
|
else if (yearOfToday < (year + 2000))
|
||||||
|
year += 1900;
|
||||||
|
else
|
||||||
|
year += 2000;
|
||||||
|
}
|
||||||
|
month = [[ldifRecord objectForKey: @"birthmonth"] intValue];
|
||||||
|
day = [[ldifRecord objectForKey: @"birthday"] intValue];
|
||||||
|
|
||||||
|
if (year && month && day)
|
||||||
|
[self setBday: [NSString stringWithFormat: @"%.4d-%.2d-%.2d",
|
||||||
|
year, month, day]];
|
||||||
|
else
|
||||||
|
[self setBday: @""];
|
||||||
|
|
||||||
|
[self setNote: [ldifRecord objectForKey: @"description"]];
|
||||||
|
[self setCategories: [ldifRecord objectForKey: @"vcardcategories"]];
|
||||||
|
|
||||||
|
[self cleanupEmptyChildren];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* VCARD -> LDIF */
|
||||||
|
- (NSString *) _simpleValueForType: (NSString *) aType
|
||||||
|
inArray: (NSArray *) anArray
|
||||||
|
excluding: (NSString *) aTypeToExclude
|
||||||
|
{
|
||||||
|
NSArray *elements;
|
||||||
|
NSString *value;
|
||||||
|
|
||||||
|
elements = [anArray cardElementsWithAttribute: @"type"
|
||||||
|
havingValue: aType];
|
||||||
|
value = nil;
|
||||||
|
|
||||||
|
if ([elements count] > 0)
|
||||||
|
{
|
||||||
|
CardElement *ce;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < [elements count]; i++)
|
||||||
|
{
|
||||||
|
ce = [elements objectAtIndex: i];
|
||||||
|
value = [ce flattenedValuesForKey: @""];
|
||||||
|
|
||||||
|
if (!aTypeToExclude)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (![ce hasAttribute: @"type" havingValue: aTypeToExclude])
|
||||||
|
break;
|
||||||
|
|
||||||
|
value = nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) _setValue: (NSString *) key
|
||||||
|
to: (NSString *) aValue
|
||||||
|
inLDIFRecord: (NSMutableDictionary *) ldifRecord
|
||||||
|
{
|
||||||
|
if (!aValue)
|
||||||
|
aValue = @"";
|
||||||
|
|
||||||
|
[ldifRecord setObject: aValue forKey: key];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) _setupEmailFieldsInLDIFRecord: (NSMutableDictionary *) ldifRecord
|
||||||
|
{
|
||||||
|
NSArray *elements;
|
||||||
|
NSString *workMail, *homeMail, *potential;
|
||||||
|
unsigned int max;
|
||||||
|
|
||||||
|
elements = [self childrenWithTag: @"email"];
|
||||||
|
max = [elements count];
|
||||||
|
workMail = [self _simpleValueForType: @"work"
|
||||||
|
inArray: elements excluding: nil];
|
||||||
|
homeMail = [self _simpleValueForType: @"home"
|
||||||
|
inArray: elements excluding: nil];
|
||||||
|
|
||||||
|
if (max > 0)
|
||||||
|
{
|
||||||
|
potential = [[elements objectAtIndex: 0] flattenedValuesForKey: @""];
|
||||||
|
if (!workMail)
|
||||||
|
{
|
||||||
|
if (homeMail && homeMail == potential)
|
||||||
|
{
|
||||||
|
if (max > 1)
|
||||||
|
workMail = [[elements objectAtIndex: 1] flattenedValuesForKey: @""];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
workMail = potential;
|
||||||
|
}
|
||||||
|
if (!homeMail && max > 1)
|
||||||
|
{
|
||||||
|
if (workMail && workMail == potential)
|
||||||
|
homeMail = [[elements objectAtIndex: 1] flattenedValuesForKey: @""];
|
||||||
|
else
|
||||||
|
homeMail = potential;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[self _setValue: @"mail" to: workMail inLDIFRecord: ldifRecord];
|
||||||
|
[self _setValue: @"mozillasecondemail" to: homeMail inLDIFRecord: ldifRecord];
|
||||||
|
|
||||||
|
[self _setValue: @"mozillausehtmlmail"
|
||||||
|
to: [[self uniqueChildWithTag: @"x-mozilla-html"]
|
||||||
|
flattenedValuesForKey: @""]
|
||||||
|
inLDIFRecord: ldifRecord];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) _setupOrgFieldsInLDIFRecord: (NSMutableDictionary *) ldifRecord
|
||||||
|
{
|
||||||
|
NSMutableArray *orgServices;
|
||||||
|
CardElement *org;
|
||||||
|
NSString *service;
|
||||||
|
NSUInteger count, max;
|
||||||
|
|
||||||
|
org = [self org];
|
||||||
|
[self _setValue: @"o"
|
||||||
|
to: [org flattenedValueAtIndex: 0 forKey: @""]
|
||||||
|
inLDIFRecord: ldifRecord];
|
||||||
|
max = [[org valuesForKey: @""] count];
|
||||||
|
if (max > 1)
|
||||||
|
{
|
||||||
|
orgServices = [NSMutableArray arrayWithCapacity: max];
|
||||||
|
for (count = 1; count < max; count++)
|
||||||
|
{
|
||||||
|
service = [org flattenedValueAtIndex: count forKey: @""];
|
||||||
|
if ([service length] > 0)
|
||||||
|
[orgServices addObject: service];
|
||||||
|
}
|
||||||
|
|
||||||
|
[self _setValue: @"ou"
|
||||||
|
to: [orgServices componentsJoinedByString: @", "]
|
||||||
|
inLDIFRecord: ldifRecord];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSMutableDictionary *) asLDIFRecord
|
||||||
|
{
|
||||||
|
NSArray *elements, *categories;
|
||||||
|
CardElement *element;
|
||||||
|
NSMutableDictionary *ldifRecord;
|
||||||
|
NSCalendarDate *birthDay;
|
||||||
|
NSString *dn, *stringValue, *stringValue2;
|
||||||
|
|
||||||
|
ldifRecord = [NSMutableDictionary dictionaryWithCapacity: 32];
|
||||||
|
[ldifRecord setObject: [NSArray arrayWithObjects: @"top", @"inetOrgPerson",
|
||||||
|
@"mozillaAbPersonAlpha", nil]
|
||||||
|
forKey: @"objectClass"];
|
||||||
|
|
||||||
element = [self n];
|
element = [self n];
|
||||||
tmp = [element flattenedValueAtIndex: 1 forKey: @""];
|
[self _setValue: @"sn"
|
||||||
if ([tmp length] > 0)
|
to: [element flattenedValueAtIndex: 0 forKey: @""]
|
||||||
[entry setObject: tmp forKey: @"givenName"];
|
inLDIFRecord: ldifRecord];
|
||||||
|
[self _setValue: @"givenname"
|
||||||
|
to: [element flattenedValueAtIndex: 1 forKey: @""]
|
||||||
|
inLDIFRecord: ldifRecord];
|
||||||
|
[self _setValue: @"displayname" to: [self fn]
|
||||||
|
inLDIFRecord: ldifRecord];
|
||||||
|
[self _setValue: @"mozillanickname" to: [self nickname]
|
||||||
|
inLDIFRecord: ldifRecord];
|
||||||
|
|
||||||
tmp = [element flattenedValueAtIndex: 0 forKey: @""];
|
elements = [self childrenWithTag: @"tel"];
|
||||||
if ([tmp length] > 0)
|
// We do this (exclude FAX) in order to avoid setting the WORK number as the FAX
|
||||||
[entry setObject: tmp forKey: @"sn"];
|
// one if we do see the FAX field BEFORE the WORK number.
|
||||||
|
[self _setValue: @"telephonenumber"
|
||||||
|
to: [self _simpleValueForType: @"work" inArray: elements
|
||||||
|
excluding: @"fax"]
|
||||||
|
inLDIFRecord: ldifRecord];
|
||||||
|
[self _setValue: @"homephone"
|
||||||
|
to: [self _simpleValueForType: @"home" inArray: elements
|
||||||
|
excluding: @"fax"]
|
||||||
|
inLDIFRecord: ldifRecord];
|
||||||
|
[self _setValue: @"mobile"
|
||||||
|
to: [self _simpleValueForType: @"cell" inArray: elements
|
||||||
|
excluding: nil]
|
||||||
|
inLDIFRecord: ldifRecord];
|
||||||
|
[self _setValue: @"facsimiletelephonenumber"
|
||||||
|
to: [self _simpleValueForType: @"fax" inArray: elements
|
||||||
|
excluding: nil]
|
||||||
|
inLDIFRecord: ldifRecord];
|
||||||
|
[self _setValue: @"pager"
|
||||||
|
to: [self _simpleValueForType: @"pager" inArray: elements
|
||||||
|
excluding: nil]
|
||||||
|
inLDIFRecord: ldifRecord];
|
||||||
|
|
||||||
tmp = [self fn];
|
// If we don't have a "home" and "work" phone number but
|
||||||
if (tmp)
|
// we have a "voice" one defined, we set it to the "work" value
|
||||||
[entry setObject: tmp forKey: @"cn"];
|
// This can happen when we have :
|
||||||
|
// VERSION:2.1
|
||||||
|
// N:name;surname;;;;
|
||||||
|
// TEL;VOICE;HOME:
|
||||||
|
// TEL;VOICE;WORK:
|
||||||
|
// TEL;PAGER:
|
||||||
|
// TEL;FAX;WORK:
|
||||||
|
// TEL;CELL:514 123 1234
|
||||||
|
// TEL;VOICE:450 456 6789
|
||||||
|
// ADR;HOME:;;;;;;
|
||||||
|
// ADR;WORK:;;;;;;
|
||||||
|
// ADR:;;;;;;
|
||||||
|
if ([[ldifRecord objectForKey: @"telephonenumber"] length] == 0 &&
|
||||||
|
[[ldifRecord objectForKey: @"homephone"] length] == 0 &&
|
||||||
|
[elements count] > 0)
|
||||||
|
[self _setValue: @"telephonenumber"
|
||||||
|
to: [self _simpleValueForType: @"voice" inArray: elements
|
||||||
|
excluding: nil]
|
||||||
|
inLDIFRecord: ldifRecord];
|
||||||
|
|
||||||
tmp = [self preferredEMail];
|
[self _setupEmailFieldsInLDIFRecord: ldifRecord];
|
||||||
if (tmp)
|
|
||||||
[entry setObject: tmp forKey: @"mail"];
|
|
||||||
|
|
||||||
[entry setObject: @"0Z" forKey: @"modifytimestamp"];
|
[self _setValue: @"nsaimid"
|
||||||
|
to: [[self uniqueChildWithTag: @"x-aim"]
|
||||||
|
flattenedValuesForKey: @""]
|
||||||
|
inLDIFRecord: ldifRecord];
|
||||||
|
|
||||||
buffer = [self nickname];
|
elements = [self childrenWithTag: @"adr"
|
||||||
if (buffer && [buffer length] > 0)
|
andAttribute: @"type" havingValue: @"work"];
|
||||||
[entry setObject: buffer forKey: @"mozillaNickname"];
|
if (elements && [elements count] > 0)
|
||||||
|
|
||||||
marray = [NSMutableArray arrayWithArray: [self childrenWithTag: @"email"]];
|
|
||||||
[marray removeObjectsInArray: [self childrenWithTag: @"email"
|
|
||||||
andAttribute: @"type"
|
|
||||||
havingValue: @"pref"]];
|
|
||||||
if ([marray count])
|
|
||||||
{
|
{
|
||||||
buffer = [[marray objectAtIndex: [marray count]-1]
|
element = [elements objectAtIndex: 0];
|
||||||
flattenedValuesForKey: @""];
|
[self _setValue: @"mozillaworkstreet2"
|
||||||
|
to: [element flattenedValueAtIndex: 1 forKey: @""]
|
||||||
if ([buffer caseInsensitiveCompare: [self preferredEMail]] != NSOrderedSame)
|
inLDIFRecord: ldifRecord];
|
||||||
[entry setObject: buffer forKey: @"mozillaSecondEmail"];
|
[self _setValue: @"street"
|
||||||
|
to: [element flattenedValueAtIndex: 2 forKey: @""]
|
||||||
|
inLDIFRecord: ldifRecord];
|
||||||
|
[self _setValue: @"l"
|
||||||
|
to: [element flattenedValueAtIndex: 3 forKey: @""]
|
||||||
|
inLDIFRecord: ldifRecord];
|
||||||
|
[self _setValue: @"st"
|
||||||
|
to: [element flattenedValueAtIndex: 4 forKey: @""]
|
||||||
|
inLDIFRecord: ldifRecord];
|
||||||
|
[self _setValue: @"postalcode"
|
||||||
|
to: [element flattenedValueAtIndex: 5 forKey: @""]
|
||||||
|
inLDIFRecord: ldifRecord];
|
||||||
|
[self _setValue: @"c"
|
||||||
|
to: [element flattenedValueAtIndex: 6 forKey: @""]
|
||||||
|
inLDIFRecord: ldifRecord];
|
||||||
}
|
}
|
||||||
|
|
||||||
array = [self childrenWithTag: @"tel" andAttribute: @"type" havingValue: @"home"];
|
elements = [self childrenWithTag: @"adr"
|
||||||
if ([array count])
|
andAttribute: @"type" havingValue: @"home"];
|
||||||
[entry setObject: [[array objectAtIndex: 0] flattenedValuesForKey: @""]
|
if (elements && [elements count] > 0)
|
||||||
forKey: @"homePhone"];
|
|
||||||
array = [self childrenWithTag: @"tel" andAttribute: @"type" havingValue: @"fax"];
|
|
||||||
if ([array count])
|
|
||||||
[entry setObject: [[array objectAtIndex: 0] flattenedValuesForKey: @""]
|
|
||||||
forKey: @"fax"];
|
|
||||||
array = [self childrenWithTag: @"tel" andAttribute: @"type" havingValue: @"cell"];
|
|
||||||
if ([array count])
|
|
||||||
[entry setObject: [[array objectAtIndex: 0] flattenedValuesForKey: @""]
|
|
||||||
forKey: @"mobile"];
|
|
||||||
array = [self childrenWithTag: @"tel" andAttribute: @"type" havingValue: @"pager"];
|
|
||||||
if ([array count])
|
|
||||||
[entry setObject: [[array objectAtIndex: 0] flattenedValuesForKey: @""]
|
|
||||||
forKey: @"pager"];
|
|
||||||
|
|
||||||
array = [self childrenWithTag: @"adr" andAttribute: @"type" havingValue: @"home"];
|
|
||||||
if ([array count])
|
|
||||||
{
|
{
|
||||||
tmp = [array objectAtIndex: 0];
|
element = [elements objectAtIndex: 0];
|
||||||
[entry setObject: [tmp flattenedValueAtIndex: 1 forKey: @""]
|
[self _setValue: @"mozillahomestreet2"
|
||||||
forKey: @"mozillaHomeStreet2"];
|
to: [element flattenedValueAtIndex: 1 forKey: @""]
|
||||||
[entry setObject: [tmp flattenedValueAtIndex: 2 forKey: @""]
|
inLDIFRecord: ldifRecord];
|
||||||
forKey: @"homeStreet"];
|
[self _setValue: @"mozillahomestreet"
|
||||||
[entry setObject: [tmp flattenedValueAtIndex: 3 forKey: @""]
|
to: [element flattenedValueAtIndex: 2 forKey: @""]
|
||||||
forKey: @"mozillaHomeLocalityName"];
|
inLDIFRecord: ldifRecord];
|
||||||
[entry setObject: [tmp flattenedValueAtIndex: 4 forKey: @""]
|
[self _setValue: @"mozillahomelocalityname"
|
||||||
forKey: @"mozillaHomeState"];
|
to: [element flattenedValueAtIndex: 3 forKey: @""]
|
||||||
[entry setObject: [tmp flattenedValueAtIndex: 5 forKey: @""]
|
inLDIFRecord: ldifRecord];
|
||||||
forKey: @"mozillaHomePostalCode"];
|
[self _setValue: @"mozillahomestate"
|
||||||
[entry setObject: [tmp flattenedValueAtIndex: 6 forKey: @""]
|
to: [element flattenedValueAtIndex: 4 forKey: @""]
|
||||||
forKey: @"mozillaHomeCountryName"];
|
inLDIFRecord: ldifRecord];
|
||||||
|
[self _setValue: @"mozillahomepostalcode"
|
||||||
|
to: [element flattenedValueAtIndex: 5 forKey: @""]
|
||||||
|
inLDIFRecord: ldifRecord];
|
||||||
|
[self _setValue: @"mozillahomecountryname"
|
||||||
|
to: [element flattenedValueAtIndex: 6 forKey: @""]
|
||||||
|
inLDIFRecord: ldifRecord];
|
||||||
}
|
}
|
||||||
|
|
||||||
element = [self org];
|
elements = [self childrenWithTag: @"url"];
|
||||||
tmp = [element flattenedValueAtIndex: 0 forKey: @""];
|
[self _setValue: @"mozillaworkurl"
|
||||||
if ([tmp length] > 0)
|
to: [self _simpleValueForType: @"work" inArray: elements
|
||||||
[entry setObject: tmp forKey: @"o"];
|
excluding: nil]
|
||||||
|
inLDIFRecord: ldifRecord];
|
||||||
|
[self _setValue: @"mozillahomeurl"
|
||||||
|
to: [self _simpleValueForType: @"home" inArray: elements
|
||||||
|
excluding: nil]
|
||||||
|
inLDIFRecord: ldifRecord];
|
||||||
|
|
||||||
array = [self childrenWithTag: @"adr" andAttribute: @"type" havingValue: @"work"];
|
// If we don't have a "work" or "home" URL but we still have
|
||||||
if ([array count])
|
// an URL field present, let's add it to the "home" value
|
||||||
|
if ([[ldifRecord objectForKey: @"mozillaworkurl"] length] == 0 &&
|
||||||
|
[[ldifRecord objectForKey: @"mozillahomeurl"] length] == 0 &&
|
||||||
|
[elements count] > 0)
|
||||||
|
[self _setValue: @"mozillahomeurl"
|
||||||
|
to: [[elements objectAtIndex: 0]
|
||||||
|
flattenedValuesForKey: @""]
|
||||||
|
inLDIFRecord: ldifRecord];
|
||||||
|
// If we do have a "work" URL but no "home" URL but two
|
||||||
|
// values URLs present, let's add the second one as the home URL
|
||||||
|
else if ([[ldifRecord objectForKey: @"mozillaworkurl"] length] > 0 &&
|
||||||
|
[[ldifRecord objectForKey: @"mozillahomeurl"] length] == 0 &&
|
||||||
|
[elements count] > 1)
|
||||||
{
|
{
|
||||||
tmp = [array objectAtIndex: 0];
|
int i;
|
||||||
[entry setObject: [tmp flattenedValueAtIndex: 1 forKey: @""]
|
|
||||||
forKey: @"mozillaWorkStreet2"];
|
for (i = 0; i < [elements count]; i++)
|
||||||
[entry setObject: [tmp flattenedValueAtIndex: 2 forKey: @""]
|
{
|
||||||
forKey: @"street"];
|
if ([[[elements objectAtIndex: i] flattenedValuesForKey: @""]
|
||||||
[entry setObject: [tmp flattenedValueAtIndex: 3 forKey: @""]
|
caseInsensitiveCompare: [ldifRecord objectForKey: @"mozillaworkurl"]] != NSOrderedSame)
|
||||||
forKey: @"l"];
|
{
|
||||||
[entry setObject: [tmp flattenedValueAtIndex: 4 forKey: @""]
|
[self _setValue: @"mozillahomeurl"
|
||||||
forKey: @"st"];
|
to: [[elements objectAtIndex: i]
|
||||||
[entry setObject: [tmp flattenedValueAtIndex: 5 forKey: @""]
|
flattenedValuesForKey: @""]
|
||||||
forKey: @"postalCode"];
|
inLDIFRecord: ldifRecord];
|
||||||
[entry setObject: [tmp flattenedValueAtIndex: 6 forKey: @""]
|
break;
|
||||||
forKey: @"c"];
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
array = [self childrenWithTag: @"tel" andAttribute: @"type" havingValue: @"work"];
|
[self _setValue: @"title" to: [self title] inLDIFRecord: ldifRecord];
|
||||||
if ([array count])
|
[self _setupOrgFieldsInLDIFRecord: ldifRecord];
|
||||||
[entry setObject: [[array objectAtIndex: 0] flattenedValuesForKey: @""]
|
|
||||||
forKey: @"telephoneNumber"];
|
|
||||||
|
|
||||||
array = [self childrenWithTag: @"url" andAttribute: @"type" havingValue: @"work"];
|
categories = [self categories];
|
||||||
if ([array count])
|
if ([categories count] > 0)
|
||||||
[entry setObject: [[array objectAtIndex: 0] flattenedValuesForKey: @""]
|
[ldifRecord setValue: categories forKey: @"vcardcategories"];
|
||||||
forKey: @"workurl"];
|
|
||||||
|
|
||||||
array = [self childrenWithTag: @"url" andAttribute: @"type" havingValue: @"home"];
|
birthDay = [[self bday] asCalendarDate];
|
||||||
if ([array count])
|
if (birthDay)
|
||||||
[entry setObject: [[array objectAtIndex: 0] flattenedValuesForKey: @""]
|
{
|
||||||
forKey: @"homeurl"];
|
stringValue = [NSString stringWithFormat: @"%.4d", [birthDay yearOfCommonEra]];
|
||||||
|
[self _setValue: @"birthyear" to: stringValue inLDIFRecord: ldifRecord];
|
||||||
|
stringValue = [NSString stringWithFormat: @"%.2d", [birthDay monthOfYear]];
|
||||||
|
[self _setValue: @"birthmonth" to: stringValue inLDIFRecord: ldifRecord];
|
||||||
|
stringValue = [NSString stringWithFormat: @"%.2d", [birthDay dayOfMonth]];
|
||||||
|
[self _setValue: @"birthday" to: stringValue inLDIFRecord: ldifRecord];
|
||||||
|
}
|
||||||
|
[self _setValue: @"description" to: [self note] inLDIFRecord: ldifRecord];
|
||||||
|
|
||||||
tmp = [self note];
|
stringValue = [ldifRecord objectForKey: @"displayname"];
|
||||||
if (tmp && [tmp length])
|
stringValue2 = [ldifRecord objectForKey: @"mail"];
|
||||||
[entry setObject: tmp forKey: @"description"];
|
if ([stringValue length] > 0)
|
||||||
|
{
|
||||||
|
if ([stringValue2 length] > 0)
|
||||||
|
dn = [NSString stringWithFormat: @"cn=%@,mail=%@",
|
||||||
|
stringValue, stringValue2];
|
||||||
|
else
|
||||||
|
dn = [NSString stringWithFormat: @"cn=%@", stringValue];
|
||||||
|
}
|
||||||
|
else if ([stringValue2 length] > 0)
|
||||||
|
dn = [NSString stringWithFormat: @"mail=%@", stringValue2];
|
||||||
|
else
|
||||||
|
dn = @"";
|
||||||
|
[ldifRecord setObject: dn forKey: @"dn"];
|
||||||
|
|
||||||
rc = [NSMutableString stringWithString: [entry userRecordAsLDIFEntry]];
|
return ldifRecord;
|
||||||
[rc appendFormat: @"\n"];
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end /* NGVCard */
|
@end /* NGVCard */
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
#import <NGCards/NGVCardReference.h>
|
#import <NGCards/NGVCardReference.h>
|
||||||
|
|
||||||
#import <SOGo/NSDictionary+Utilities.h>
|
#import "NSDictionary+LDIF.h"
|
||||||
|
|
||||||
#import "NGVList+SOGo.h"
|
#import "NGVList+SOGo.h"
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@
|
||||||
}
|
}
|
||||||
[entry setObject: members forKey: @"member"];
|
[entry setObject: members forKey: @"member"];
|
||||||
|
|
||||||
rc = [NSMutableString stringWithString: [entry userRecordAsLDIFEntry]];
|
rc = [NSMutableString stringWithString: [entry ldifRecordAsString]];
|
||||||
[rc appendFormat: @"\n"];
|
[rc appendFormat: @"\n"];
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
/* NSDictionary+LDIF.h - this file is part of SOGo
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011 Inverse inc
|
||||||
|
*
|
||||||
|
* Author: Wolfgang Sourdeau <wsourdeau@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 NSDICTIONARY_LDIF_H
|
||||||
|
#define NSDICTIONARY_LDIF_H
|
||||||
|
|
||||||
|
#import <Foundation/NSDictionary.h>
|
||||||
|
|
||||||
|
@interface NSDictionary (SOGoLDIF)
|
||||||
|
|
||||||
|
- (NSString *) ldifRecordAsString;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif /* NSDICTIONARY_LDIF_H */
|
|
@ -0,0 +1,111 @@
|
||||||
|
/* NSDictionary+LDIF.m - this file is part of SOGo
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011 Inverse inc
|
||||||
|
*
|
||||||
|
* Author: Wolfgang Sourdeau <wsourdeau@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/NSString.h>
|
||||||
|
#import <NGExtensions/NGBase64Coding.h>
|
||||||
|
|
||||||
|
#import "NSString+LDIF.h"
|
||||||
|
|
||||||
|
#import "NSDictionary+LDIF.h"
|
||||||
|
|
||||||
|
@implementation NSDictionary (SOGoLDIF)
|
||||||
|
|
||||||
|
- (void) _appendLDIFKey: (NSString *) key
|
||||||
|
value: (NSString *) value
|
||||||
|
toString: (NSMutableString *) ldifString
|
||||||
|
{
|
||||||
|
if ([value isKindOfClass: [NSString class]] && [value length] > 0)
|
||||||
|
{
|
||||||
|
if ([value mustEncodeLDIFValue])
|
||||||
|
[ldifString appendFormat: @"%@:: %@\n",
|
||||||
|
key, [value stringByEncodingBase64]];
|
||||||
|
else
|
||||||
|
[ldifString appendFormat: @"%@: %@\n", key, value];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) _appendLDIFKey: (NSString *) key
|
||||||
|
toString: (NSMutableString *) ldifString
|
||||||
|
{
|
||||||
|
id value;
|
||||||
|
int count, max;
|
||||||
|
|
||||||
|
value = [self objectForKey: key];
|
||||||
|
if ([value isKindOfClass: [NSArray class]])
|
||||||
|
{
|
||||||
|
max = [value count];
|
||||||
|
for (count = 0; count < max; count++)
|
||||||
|
[self _appendLDIFKey: key value: [value objectAtIndex: count]
|
||||||
|
toString: ldifString];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
[self _appendLDIFKey: key value: [self objectForKey: key]
|
||||||
|
toString: ldifString];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) _appendObjectClassesToString: (NSMutableString *) ldifString
|
||||||
|
{
|
||||||
|
NSEnumerator *classes;
|
||||||
|
NSString *currentClass;
|
||||||
|
NSArray *objectClass;
|
||||||
|
|
||||||
|
objectClass = [self objectForKey: @"objectClass"];
|
||||||
|
if ([objectClass isKindOfClass: [NSString class]])
|
||||||
|
[self _appendLDIFKey: @"objectClass" value: (NSString *) objectClass
|
||||||
|
toString: ldifString];
|
||||||
|
else
|
||||||
|
{
|
||||||
|
classes = [objectClass objectEnumerator];
|
||||||
|
while ((currentClass = [classes nextObject]))
|
||||||
|
[self _appendLDIFKey: @"objectClass" value: currentClass
|
||||||
|
toString: ldifString];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *) ldifRecordAsString
|
||||||
|
{
|
||||||
|
NSArray *keys;
|
||||||
|
NSMutableString *ldifString;
|
||||||
|
NSUInteger count, max;
|
||||||
|
NSString *currentKey;
|
||||||
|
|
||||||
|
// {CalendarAccess = YES; MailAccess = YES; c_cn = "Wolfgang Sourdeau"; c_emails = ("wolfgang@test.com"); c_name = "wolfgang@test.com"; c_uid = "wolfgang@test.com"; cn = "wolfgang@test.com"; displayName = "Wolfgang Sourdeau"; dn = "cn=wolfgang@test.com,ou=evariste,o=inverse.ca"; givenName = Wolfgang; mail = "wolfgang@test.com"; objectClass = organizationalPerson; sn = Sourdeau; }
|
||||||
|
|
||||||
|
ldifString = [NSMutableString string];
|
||||||
|
[self _appendLDIFKey: @"dn" toString: ldifString];
|
||||||
|
[self _appendObjectClassesToString: ldifString];
|
||||||
|
|
||||||
|
keys = [self allKeys];
|
||||||
|
max = [keys count];
|
||||||
|
for (count = 0; count < max; count++)
|
||||||
|
{
|
||||||
|
currentKey = [keys objectAtIndex: count];
|
||||||
|
if (!([currentKey hasPrefix: @"objectClass"]
|
||||||
|
|| [currentKey isEqualToString: @"dn"]))
|
||||||
|
[self _appendLDIFKey: currentKey toString: ldifString];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ldifString;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
|
@ -0,0 +1,34 @@
|
||||||
|
/* NSString+LDIF.h - this file is part of SOGo
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011 Inverse inc
|
||||||
|
*
|
||||||
|
* Author: Wolfgang Sourdeau <wsourdeau@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 NSSTRING_LDIF_H
|
||||||
|
#define NSSTRING_LDIF_H
|
||||||
|
|
||||||
|
#import <Foundation/NSString.h>
|
||||||
|
|
||||||
|
@interface NSString (SOGoLDIF)
|
||||||
|
|
||||||
|
- (BOOL) mustEncodeLDIFValue;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif /* NSSTRING_LDIF_H */
|
|
@ -0,0 +1,67 @@
|
||||||
|
/* NSString+LDIF.m - this file is part of SOGo
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011 Inverse inc
|
||||||
|
*
|
||||||
|
* Author: Wolfgang Sourdeau <wsourdeau@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/NSCharacterSet.h>
|
||||||
|
|
||||||
|
#import "NSString+LDIF.h"
|
||||||
|
|
||||||
|
@implementation NSString (SOGoLDIF)
|
||||||
|
|
||||||
|
static NSMutableCharacterSet *safeLDIFChars = nil;
|
||||||
|
static NSMutableCharacterSet *safeLDIFStartChars = nil;
|
||||||
|
|
||||||
|
- (void) _initSafeLDIFChars
|
||||||
|
{
|
||||||
|
safeLDIFChars = [NSMutableCharacterSet new];
|
||||||
|
[safeLDIFChars addCharactersInRange: NSMakeRange (0x01, 9)];
|
||||||
|
[safeLDIFChars addCharactersInRange: NSMakeRange (0x0b, 2)];
|
||||||
|
[safeLDIFChars addCharactersInRange: NSMakeRange (0x0e, 114)];
|
||||||
|
|
||||||
|
safeLDIFStartChars = [safeLDIFChars mutableCopy];
|
||||||
|
[safeLDIFStartChars removeCharactersInString: @" :<"];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) mustEncodeLDIFValue
|
||||||
|
{
|
||||||
|
int count, max;
|
||||||
|
BOOL rc;
|
||||||
|
|
||||||
|
if (!safeLDIFChars)
|
||||||
|
[self _initSafeLDIFChars];
|
||||||
|
|
||||||
|
rc = NO;
|
||||||
|
|
||||||
|
max = [self length];
|
||||||
|
if (max > 0)
|
||||||
|
{
|
||||||
|
if ([safeLDIFStartChars characterIsMember: [self characterAtIndex: 0]])
|
||||||
|
for (count = 1; !rc && count < max; count++)
|
||||||
|
rc = ![safeLDIFChars
|
||||||
|
characterIsMember: [self characterAtIndex: count]];
|
||||||
|
else
|
||||||
|
rc = YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
|
@ -30,11 +30,6 @@
|
||||||
int photoID;
|
int photoID;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (id) entryPhotoWithID: (int) photoId
|
|
||||||
inContainer: (id) container;
|
|
||||||
|
|
||||||
- (void) setPhotoID: (int) newPhotoID;
|
|
||||||
|
|
||||||
- (NSString *) davContentType;
|
- (NSString *) davContentType;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -35,36 +35,9 @@
|
||||||
|
|
||||||
@implementation SOGoContactEntryPhoto
|
@implementation SOGoContactEntryPhoto
|
||||||
|
|
||||||
+ (id) entryPhotoWithID: (int) photoID
|
|
||||||
inContainer: (id) container
|
|
||||||
{
|
|
||||||
id photo;
|
|
||||||
|
|
||||||
photo
|
|
||||||
= [super objectWithName: [NSString stringWithFormat: @"photo%d", photoID]
|
|
||||||
inContainer: container];
|
|
||||||
[photo setPhotoID: photoID];
|
|
||||||
|
|
||||||
return photo;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) setPhotoID: (int) newPhotoID
|
|
||||||
{
|
|
||||||
photoID = newPhotoID;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NGVCardPhoto *) photo
|
- (NGVCardPhoto *) photo
|
||||||
{
|
{
|
||||||
NGVCardPhoto *photo;
|
return (NGVCardPhoto *) [[container vCard] firstChildWithTag: @"photo"];
|
||||||
NSArray *photoElements;
|
|
||||||
|
|
||||||
photoElements = [[container vCard] childrenWithTag: @"photo"];
|
|
||||||
if ([photoElements count] > photoID)
|
|
||||||
photo = [photoElements objectAtIndex: photoID];
|
|
||||||
else
|
|
||||||
photo = nil;
|
|
||||||
|
|
||||||
return photo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) GETAction: (WOContext *) localContext
|
- (id) GETAction: (WOContext *) localContext
|
||||||
|
|
|
@ -19,11 +19,15 @@
|
||||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import <Foundation/NSArray.h>
|
#import <Foundation/NSArray.h>
|
||||||
|
#import <Foundation/NSDictionary.h>
|
||||||
#import <Foundation/NSString.h>
|
#import <Foundation/NSString.h>
|
||||||
|
|
||||||
#import <NGCards/NGVCard.h>
|
#import <NGCards/NGVCard.h>
|
||||||
|
#import <NGCards/NGVCardPhoto.h>
|
||||||
|
|
||||||
|
#import "NGVCard+SOGo.h"
|
||||||
#import "SOGoContactEntryPhoto.h"
|
#import "SOGoContactEntryPhoto.h"
|
||||||
|
|
||||||
#import "SOGoContactGCSEntry.h"
|
#import "SOGoContactGCSEntry.h"
|
||||||
|
@ -62,6 +66,21 @@
|
||||||
return card;
|
return card;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) setLDIFRecord: (NSDictionary *) newLDIFRecord
|
||||||
|
{
|
||||||
|
[[self vCard] updateFromLDIFRecord: newLDIFRecord];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSDictionary *) ldifRecord
|
||||||
|
{
|
||||||
|
return [[self vCard] asLDIFRecord];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) hasPhoto
|
||||||
|
{
|
||||||
|
return ([[self vCard] firstChildWithTag: @"photo"] != nil);
|
||||||
|
}
|
||||||
|
|
||||||
/* actions */
|
/* actions */
|
||||||
|
|
||||||
- (id) lookupName: (NSString *) lookupName
|
- (id) lookupName: (NSString *) lookupName
|
||||||
|
@ -69,15 +88,11 @@
|
||||||
acquire: (BOOL) acquire
|
acquire: (BOOL) acquire
|
||||||
{
|
{
|
||||||
id obj;
|
id obj;
|
||||||
int photoIndex;
|
|
||||||
NSArray *photoElements;
|
|
||||||
|
|
||||||
if ([lookupName hasPrefix: @"photo"])
|
if ([lookupName isEqualToString: @"photo"])
|
||||||
{
|
{
|
||||||
photoElements = [[self vCard] childrenWithTag: @"photo"];
|
if ([self hasPhoto])
|
||||||
photoIndex = [[lookupName substringFromIndex: 5] intValue];
|
obj = [SOGoContactEntryPhoto objectWithName: lookupName
|
||||||
if (photoIndex > -1 && photoIndex < [photoElements count])
|
|
||||||
obj = [SOGoContactEntryPhoto entryPhotoWithID: photoIndex
|
|
||||||
inContainer: self];
|
inContainer: self];
|
||||||
else
|
else
|
||||||
obj = nil;
|
obj = nil;
|
||||||
|
@ -127,13 +142,16 @@
|
||||||
|
|
||||||
/* specialized actions */
|
/* specialized actions */
|
||||||
|
|
||||||
- (void) save
|
- (NSException *) save
|
||||||
{
|
{
|
||||||
NGVCard *vcard;
|
NSException *result;
|
||||||
|
|
||||||
vcard = [self vCard];
|
if (card)
|
||||||
|
result = [self saveContentString: [card versitString]];
|
||||||
|
else
|
||||||
|
result = nil; /* TODO: we should probably return an exception instead */
|
||||||
|
|
||||||
[self saveContentString: [vcard versitString]];
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSException *) saveContentString: (NSString *) newContent
|
- (NSException *) saveContentString: (NSString *) newContent
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
#import <SOGo/NSDictionary+Utilities.h>
|
#import <SOGo/NSDictionary+Utilities.h>
|
||||||
#import <SOGo/NSString+Utilities.h>
|
#import <SOGo/NSString+Utilities.h>
|
||||||
#import <SOGo/NSObject+DAV.h>
|
#import <SOGo/NSObject+DAV.h>
|
||||||
|
#import <SOGo/WORequest+SOGo.h>
|
||||||
|
|
||||||
#import "SOGoContactGCSEntry.h"
|
#import "SOGoContactGCSEntry.h"
|
||||||
#import "SOGoContactGCSList.h"
|
#import "SOGoContactGCSList.h"
|
||||||
|
|
|
@ -31,8 +31,8 @@
|
||||||
|
|
||||||
@interface SOGoContactLDIFEntry : SOGoObject <SOGoContactObject>
|
@interface SOGoContactLDIFEntry : SOGoObject <SOGoContactObject>
|
||||||
{
|
{
|
||||||
|
BOOL isNew;
|
||||||
NSDictionary *ldifEntry;
|
NSDictionary *ldifEntry;
|
||||||
NGVCard *vcard;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (SOGoContactLDIFEntry *) contactEntryWithName: (NSString *) newName
|
+ (SOGoContactLDIFEntry *) contactEntryWithName: (NSString *) newName
|
||||||
|
@ -42,6 +42,9 @@
|
||||||
withLDIFEntry: (NSDictionary *) newEntry
|
withLDIFEntry: (NSDictionary *) newEntry
|
||||||
inContainer: (id) newContainer;
|
inContainer: (id) newContainer;
|
||||||
|
|
||||||
|
- (BOOL) isNew;
|
||||||
|
- (void) setIsNew: (BOOL) newIsNew;
|
||||||
|
|
||||||
- (NSString *) davEntityTag;
|
- (NSString *) davEntityTag;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -29,9 +29,13 @@
|
||||||
#import <NGCards/CardVersitRenderer.h>
|
#import <NGCards/CardVersitRenderer.h>
|
||||||
|
|
||||||
#import <SOGo/SOGoBuild.h>
|
#import <SOGo/SOGoBuild.h>
|
||||||
|
#import <SOGo/SOGoSource.h>
|
||||||
|
#import <SOGo/SOGoPermissions.h>
|
||||||
|
|
||||||
|
#import "NGVCard+SOGo.h"
|
||||||
#import "SOGoContactGCSEntry.h"
|
#import "SOGoContactGCSEntry.h"
|
||||||
#import "SOGoContactLDIFEntry.h"
|
#import "SOGoContactLDIFEntry.h"
|
||||||
|
#import "SOGoContactSourceFolder.h"
|
||||||
|
|
||||||
@implementation SOGoContactLDIFEntry
|
@implementation SOGoContactLDIFEntry
|
||||||
|
|
||||||
|
@ -56,7 +60,7 @@
|
||||||
if ((self = [self initWithName: newName inContainer: newContainer]))
|
if ((self = [self initWithName: newName inContainer: newContainer]))
|
||||||
{
|
{
|
||||||
ASSIGN (ldifEntry, newEntry);
|
ASSIGN (ldifEntry, newEntry);
|
||||||
vcard = nil;
|
isNew = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
@ -64,169 +68,34 @@
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
[vcard release];
|
|
||||||
[ldifEntry release];
|
[ldifEntry release];
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL) isNew
|
||||||
|
{
|
||||||
|
return isNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setIsNew: (BOOL) newIsNew
|
||||||
|
{
|
||||||
|
isNew = newIsNew;
|
||||||
|
}
|
||||||
|
|
||||||
- (NSString *) contentAsString
|
- (NSString *) contentAsString
|
||||||
{
|
{
|
||||||
return [[self vCard] versitString];
|
return [[self vCard] versitString];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _setPhonesOfVCard: (NGVCard *) vCard
|
|
||||||
{
|
|
||||||
NSString *info;
|
|
||||||
|
|
||||||
info = [ldifEntry objectForKey: @"telephonenumber"];
|
|
||||||
if (info)
|
|
||||||
[vCard addTel: info
|
|
||||||
types: [NSArray arrayWithObjects: @"work", @"voice", @"pref", nil]];
|
|
||||||
info = [ldifEntry objectForKey: @"homephone"];
|
|
||||||
if (info)
|
|
||||||
[vCard addTel: info
|
|
||||||
types: [NSArray arrayWithObjects: @"home", @"voice", nil]];
|
|
||||||
info = [ldifEntry objectForKey: @"fax"];
|
|
||||||
if (info)
|
|
||||||
[vCard addTel: info
|
|
||||||
types: [NSArray arrayWithObjects: @"work", @"fax", nil]];
|
|
||||||
info = [ldifEntry objectForKey: @"pager"];
|
|
||||||
if (info)
|
|
||||||
[vCard addTel: info
|
|
||||||
types: [NSArray arrayWithObjects: @"pager", nil]];
|
|
||||||
info = [ldifEntry objectForKey: @"mobile"];
|
|
||||||
if (info)
|
|
||||||
[vCard addTel: info
|
|
||||||
types: [NSArray arrayWithObjects: @"cell", @"voice", nil]];
|
|
||||||
|
|
||||||
// telephoneNumber: work phone
|
|
||||||
// homePhone: home phone
|
|
||||||
// fax: fax phone
|
|
||||||
// pager: page phone
|
|
||||||
// mobile: mobile phone
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NGVCard *) vCard
|
- (NGVCard *) vCard
|
||||||
{
|
{
|
||||||
NSString *info, *surname, *streetAddress, *location, *region, *postalCode, *country, *org, *orgunit;
|
NGVCard *vcard;
|
||||||
CardElement *element;
|
|
||||||
unsigned int count;
|
|
||||||
|
|
||||||
if (!vcard)
|
vcard = [NGVCard cardWithUid: [self nameInContainer]];
|
||||||
{
|
|
||||||
vcard = [[NGVCard alloc] initWithUid: [self nameInContainer]];
|
|
||||||
[vcard setVClass: @"PUBLIC"];
|
|
||||||
[vcard setProdID: [NSString
|
[vcard setProdID: [NSString
|
||||||
stringWithFormat: @"-//Inverse inc./SOGo %@//EN",
|
stringWithFormat: @"-//Inverse inc./SOGo %@//EN",
|
||||||
SOGoVersion]];
|
SOGoVersion]];
|
||||||
[vcard setProfile: @"VCARD"];
|
[vcard updateFromLDIFRecord: [self ldifRecord]];
|
||||||
info = [ldifEntry objectForKey: @"c_cn"];
|
|
||||||
if (![info length])
|
|
||||||
{
|
|
||||||
info = [ldifEntry objectForKey: @"displayname"];
|
|
||||||
if (![info length])
|
|
||||||
info = [ldifEntry objectForKey: @"cn"];
|
|
||||||
}
|
|
||||||
[vcard setFn: info];
|
|
||||||
surname = [ldifEntry objectForKey: @"sn"];
|
|
||||||
if (!surname)
|
|
||||||
surname = [ldifEntry objectForKey: @"surname"];
|
|
||||||
[vcard setNWithFamily: surname
|
|
||||||
given: [ldifEntry objectForKey: @"givenname"]
|
|
||||||
additional: nil
|
|
||||||
prefixes: nil
|
|
||||||
suffixes: nil];
|
|
||||||
info = [ldifEntry objectForKey: @"title"];
|
|
||||||
if (info)
|
|
||||||
[vcard setTitle: info];
|
|
||||||
info = [ldifEntry objectForKey: @"mozillanickname"];
|
|
||||||
if (info)
|
|
||||||
[vcard setNickname: info];
|
|
||||||
|
|
||||||
/* If "c_info" is defined, we set as the NOTE value in order for
|
|
||||||
Thunderbird (or any other CardDAV client) to display it. */
|
|
||||||
info = [ldifEntry objectForKey: @"c_info"];
|
|
||||||
if (![info length])
|
|
||||||
info = [ldifEntry objectForKey: @"description"];
|
|
||||||
if ([info length])
|
|
||||||
[vcard setNote: info];
|
|
||||||
|
|
||||||
info = [ldifEntry objectForKey: @"mail"];
|
|
||||||
if (info)
|
|
||||||
[vcard addEmail: info
|
|
||||||
types: [NSArray arrayWithObjects: @"internet", @"pref", nil]];
|
|
||||||
[self _setPhonesOfVCard: vcard];
|
|
||||||
|
|
||||||
streetAddress = [ldifEntry objectForKey: @"street"];
|
|
||||||
if (!streetAddress)
|
|
||||||
streetAddress = [ldifEntry objectForKey: @"streetaddress"];
|
|
||||||
|
|
||||||
location = [ldifEntry objectForKey: @"l"];
|
|
||||||
if (!location)
|
|
||||||
location = [ldifEntry objectForKey: @"locality"];
|
|
||||||
|
|
||||||
region = [ldifEntry objectForKey: @"st"];
|
|
||||||
if (!region)
|
|
||||||
region = [ldifEntry objectForKey: @"region"];
|
|
||||||
|
|
||||||
postalCode = [ldifEntry objectForKey: @"postalcode"];
|
|
||||||
if (!postalCode)
|
|
||||||
postalCode = [ldifEntry objectForKey: @"zip"];
|
|
||||||
|
|
||||||
country = [ldifEntry objectForKey: @"c"];
|
|
||||||
if (!country)
|
|
||||||
country = [ldifEntry objectForKey: @"countryname"];
|
|
||||||
|
|
||||||
element = [CardElement elementWithTag: @"adr"];
|
|
||||||
[element setValue: 0 ofAttribute: @"type" to: @"work"];
|
|
||||||
|
|
||||||
if (streetAddress)
|
|
||||||
[element setSingleValue: streetAddress atIndex: 2 forKey: @""];
|
|
||||||
if (location)
|
|
||||||
[element setSingleValue: location atIndex: 3 forKey: @""];
|
|
||||||
if (region)
|
|
||||||
[element setSingleValue: region atIndex: 4 forKey: @""];
|
|
||||||
if (postalCode)
|
|
||||||
[element setSingleValue: postalCode atIndex: 5 forKey: @""];
|
|
||||||
if (country)
|
|
||||||
[element setSingleValue: country atIndex: 6 forKey: @""];
|
|
||||||
|
|
||||||
if (streetAddress || location || region || postalCode || country)
|
|
||||||
[vcard addChild: element];
|
|
||||||
|
|
||||||
// We handle the org/orgunit stuff
|
|
||||||
element = [CardElement elementWithTag: @"org"];
|
|
||||||
org = [ldifEntry objectForKey: @"o"];
|
|
||||||
orgunit = [ldifEntry objectForKey: @"ou"];
|
|
||||||
if (!orgunit)
|
|
||||||
orgunit = [ldifEntry objectForKey: @"orgunit"];
|
|
||||||
|
|
||||||
if (org)
|
|
||||||
[element setSingleValue: org atIndex: 0 forKey: @""];
|
|
||||||
if (orgunit)
|
|
||||||
[element setSingleValue: orgunit atIndex: 1 forKey: @""];
|
|
||||||
|
|
||||||
if (org || orgunit)
|
|
||||||
[vcard addChild: element];
|
|
||||||
|
|
||||||
info = [ldifEntry objectForKey: @"calFBURL"];
|
|
||||||
if (info)
|
|
||||||
[vcard addChildWithTag: @"FBURL"
|
|
||||||
types: nil
|
|
||||||
singleValue: info];
|
|
||||||
for (count = 1; count < 5; count++)
|
|
||||||
{
|
|
||||||
info = [ldifEntry objectForKey:
|
|
||||||
[NSString stringWithFormat: @"mozillacustom%d",
|
|
||||||
count]];
|
|
||||||
if (info)
|
|
||||||
[vcard addChildWithTag: [NSString stringWithFormat: @"CUSTOM%d",
|
|
||||||
count]
|
|
||||||
types: nil
|
|
||||||
singleValue: info];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return vcard;
|
return vcard;
|
||||||
}
|
}
|
||||||
|
@ -236,6 +105,21 @@
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) setLDIFRecord: (NSDictionary *) newLDIFRecord
|
||||||
|
{
|
||||||
|
ASSIGN (ldifEntry, newLDIFRecord);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSDictionary *) ldifRecord
|
||||||
|
{
|
||||||
|
return ldifEntry;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) hasPhoto
|
||||||
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
- (NSString *) davEntityTag
|
- (NSString *) davEntityTag
|
||||||
{
|
{
|
||||||
unsigned int hash;
|
unsigned int hash;
|
||||||
|
@ -251,13 +135,47 @@
|
||||||
return @"text/x-vcard";
|
return @"text/x-vcard";
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray *) aclsForUser: (NSString *) uid
|
- (NSException *) save
|
||||||
{
|
{
|
||||||
return nil;
|
return [(SOGoContactSourceFolder *) container saveLDIFEntry: self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) save
|
- (NSException *) delete
|
||||||
{
|
{
|
||||||
|
return [(SOGoContactSourceFolder *) container deleteLDIFEntry: self];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* acl */
|
||||||
|
|
||||||
|
- (NSArray *) aclsForUser: (NSString *) uid
|
||||||
|
{
|
||||||
|
NSMutableArray *acls;
|
||||||
|
NSArray *containerAcls;
|
||||||
|
|
||||||
|
acls = [NSMutableArray array];
|
||||||
|
/* this is unused... */
|
||||||
|
// ownAcls = [container aclsForUser: uid
|
||||||
|
// forObjectAtPath: [self pathArrayToSOGoObject]];
|
||||||
|
// [acls addObjectsFromArray: ownAcls];
|
||||||
|
containerAcls = [container aclsForUser: uid];
|
||||||
|
if ([containerAcls count] > 0)
|
||||||
|
{
|
||||||
|
[acls addObjectsFromArray: containerAcls];
|
||||||
|
/* The creation of an object is actually a "modification" to an
|
||||||
|
unexisting object. When the object is new, we give the
|
||||||
|
"ObjectCreator" the "ObjectModifier" role temporarily while we
|
||||||
|
disallow the "ObjectModifier" users to modify them, unless they are
|
||||||
|
ObjectCreators too. */
|
||||||
|
if (isNew)
|
||||||
|
{
|
||||||
|
if ([containerAcls containsObject: SOGoRole_ObjectCreator])
|
||||||
|
[acls addObject: SOGoRole_ObjectEditor];
|
||||||
|
else
|
||||||
|
[acls removeObject: SOGoRole_ObjectEditor];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return acls;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* DAV */
|
/* DAV */
|
||||||
|
|
|
@ -22,25 +22,20 @@
|
||||||
#ifndef __Contacts_SOGoContactObject_H__
|
#ifndef __Contacts_SOGoContactObject_H__
|
||||||
#define __Contacts_SOGoContactObject_H__
|
#define __Contacts_SOGoContactObject_H__
|
||||||
|
|
||||||
/*
|
|
||||||
SOGoContactObject
|
|
||||||
|
|
||||||
Represents a single contact. This SOPE controller object manages all the
|
|
||||||
attendee storages (that is, it might store into multiple folders for meeting
|
|
||||||
appointments!).
|
|
||||||
|
|
||||||
Note: SOGoContactObject do not need to exist yet. They can also be "new"
|
|
||||||
appointments with an externally generated unique key.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@class NSDictionary;
|
@class NSDictionary;
|
||||||
@class NSString;
|
|
||||||
@class NGVCard;
|
@class NGVCard;
|
||||||
|
|
||||||
@protocol SOGoContactObject
|
@protocol SOGoContactObject
|
||||||
|
|
||||||
- (NGVCard *) vCard;
|
- (NGVCard *) vCard;
|
||||||
- (void) save;
|
- (BOOL) hasPhoto;
|
||||||
|
|
||||||
|
/* web editing */
|
||||||
|
- (void) setLDIFRecord: (NSDictionary *) newLDIFRecord;
|
||||||
|
- (NSDictionary *) ldifRecord;
|
||||||
|
|
||||||
|
- (NSException *) save;
|
||||||
|
- (NSException *) delete;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -26,13 +26,14 @@
|
||||||
#import "SOGoContactFolder.h"
|
#import "SOGoContactFolder.h"
|
||||||
#import "SOGoFolder+CardDAV.h"
|
#import "SOGoFolder+CardDAV.h"
|
||||||
|
|
||||||
@class NSMutableDictionary;
|
#import <SOGo/SOGoSource.h>
|
||||||
|
|
||||||
#import "../SOGo/SOGoSource.h"
|
@class NSMutableDictionary;
|
||||||
|
@class SOGoContactLDIFEntry;
|
||||||
|
|
||||||
@interface SOGoContactSourceFolder : SOGoFolder <SOGoContactFolder>
|
@interface SOGoContactSourceFolder : SOGoFolder <SOGoContactFolder>
|
||||||
{
|
{
|
||||||
id source;
|
id <SOGoSource> source;
|
||||||
NSMutableDictionary *childRecords;
|
NSMutableDictionary *childRecords;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +43,10 @@
|
||||||
- (id) initWithName: (NSString *) newName
|
- (id) initWithName: (NSString *) newName
|
||||||
andDisplayName: (NSString *) newDisplayName
|
andDisplayName: (NSString *) newDisplayName
|
||||||
inContainer: (id) newContainer;
|
inContainer: (id) newContainer;
|
||||||
- (void) setSource: (id) newSource;
|
- (void) setSource: (id <SOGoSource>) newSource;
|
||||||
|
|
||||||
|
- (NSException *) saveLDIFEntry: (SOGoContactLDIFEntry *) ldifEntry;
|
||||||
|
- (NSException *) deleteLDIFEntry: (SOGoContactLDIFEntry *) ldifEntry;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#import <SaxObjC/XMLNamespaces.h>
|
#import <SaxObjC/XMLNamespaces.h>
|
||||||
|
|
||||||
#import <SOGo/SOGoPermissions.h>
|
#import <SOGo/SOGoPermissions.h>
|
||||||
|
#import <SOGo/SOGoSource.h>
|
||||||
#import <SOGo/NSArray+Utilities.h>
|
#import <SOGo/NSArray+Utilities.h>
|
||||||
#import <SOGo/NSDictionary+Utilities.h>
|
#import <SOGo/NSDictionary+Utilities.h>
|
||||||
#import <SOGo/NSString+Utilities.h>
|
#import <SOGo/NSString+Utilities.h>
|
||||||
|
@ -96,11 +97,16 @@
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setSource: (id) newSource
|
- (void) setSource: (id <SOGoSource>) newSource
|
||||||
{
|
{
|
||||||
ASSIGN (source, newSource);
|
ASSIGN (source, newSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (id <SOGoSource>) source
|
||||||
|
{
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
- (NSString *) groupDavResourceType
|
- (NSString *) groupDavResourceType
|
||||||
{
|
{
|
||||||
return @"vcard-collection";
|
return @"vcard-collection";
|
||||||
|
@ -126,7 +132,9 @@
|
||||||
acquire: (BOOL) acquire
|
acquire: (BOOL) acquire
|
||||||
{
|
{
|
||||||
NSDictionary *ldifEntry;
|
NSDictionary *ldifEntry;
|
||||||
id obj;
|
SOGoContactLDIFEntry *obj;
|
||||||
|
NSString *url;
|
||||||
|
BOOL isNew = NO;
|
||||||
|
|
||||||
/* first check attributes directly bound to the application */
|
/* first check attributes directly bound to the application */
|
||||||
obj = [super lookupName: objectName inContext: lookupContext acquire: NO];
|
obj = [super lookupName: objectName inContext: lookupContext acquire: NO];
|
||||||
|
@ -139,11 +147,24 @@
|
||||||
ldifEntry = [source lookupContactEntry: objectName];
|
ldifEntry = [source lookupContactEntry: objectName];
|
||||||
if (ldifEntry)
|
if (ldifEntry)
|
||||||
[childRecords setObject: ldifEntry forKey: objectName];
|
[childRecords setObject: ldifEntry forKey: objectName];
|
||||||
|
else if ([self isValidContentName: objectName])
|
||||||
|
{
|
||||||
|
url = [[[lookupContext request] uri] urlWithoutParameters];
|
||||||
|
if ([url hasSuffix: @"AsContact"])
|
||||||
|
{
|
||||||
|
ldifEntry = [NSMutableDictionary dictionary];
|
||||||
|
isNew = YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (ldifEntry)
|
if (ldifEntry)
|
||||||
|
{
|
||||||
obj = [SOGoContactLDIFEntry contactEntryWithName: objectName
|
obj = [SOGoContactLDIFEntry contactEntryWithName: objectName
|
||||||
withLDIFEntry: ldifEntry
|
withLDIFEntry: ldifEntry
|
||||||
inContainer: self];
|
inContainer: self];
|
||||||
|
if (isNew)
|
||||||
|
[obj setIsNew: YES];
|
||||||
|
}
|
||||||
else
|
else
|
||||||
obj = [NSException exceptionWithHTTPStatus: 404];
|
obj = [NSException exceptionWithHTTPStatus: 404];
|
||||||
}
|
}
|
||||||
|
@ -156,6 +177,19 @@
|
||||||
return [source allEntryIDs];
|
return [source allEntryIDs];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSException *) saveLDIFEntry: (SOGoContactLDIFEntry *) ldifEntry
|
||||||
|
{
|
||||||
|
return (([ldifEntry isNew])
|
||||||
|
? [source addContactEntry: [ldifEntry ldifRecord]
|
||||||
|
withID: [ldifEntry nameInContainer]]
|
||||||
|
: [source updateContactEntry: [ldifEntry ldifRecord]]);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSException *) deleteLDIFEntry: (SOGoContactLDIFEntry *) ldifEntry
|
||||||
|
{
|
||||||
|
return [source removeContactEntryWithID: [ldifEntry nameInContainer]];
|
||||||
|
}
|
||||||
|
|
||||||
- (NSDictionary *) _flattenedRecord: (NSDictionary *) oldRecord
|
- (NSDictionary *) _flattenedRecord: (NSDictionary *) oldRecord
|
||||||
{
|
{
|
||||||
NSMutableDictionary *newRecord;
|
NSMutableDictionary *newRecord;
|
||||||
|
@ -324,10 +358,26 @@
|
||||||
return [NSArray arrayWithObject: SoRole_Authenticated];
|
return [NSArray arrayWithObject: SoRole_Authenticated];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: this might change one day when we support LDAP acls */
|
|
||||||
- (NSArray *) aclsForUser: (NSString *) uid
|
- (NSArray *) aclsForUser: (NSString *) uid
|
||||||
{
|
{
|
||||||
return nil;
|
NSArray *acls, *modifiers;
|
||||||
|
static NSArray *modifierRoles = nil;
|
||||||
|
|
||||||
|
if (!modifierRoles)
|
||||||
|
modifierRoles = [[NSArray alloc] initWithObjects: @"Owner",
|
||||||
|
@"ObjectViewer",
|
||||||
|
@"ObjectEditor", @"ObjectCreator",
|
||||||
|
@"ObjectEraser", nil];
|
||||||
|
|
||||||
|
modifiers = [source modifiers];
|
||||||
|
if ([modifiers containsObject: uid])
|
||||||
|
acls = [modifierRoles copy];
|
||||||
|
else
|
||||||
|
acls = [NSArray new];
|
||||||
|
|
||||||
|
[acls autorelease];
|
||||||
|
|
||||||
|
return acls;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -118,10 +118,10 @@
|
||||||
|
|
||||||
newString = [theString lowercaseString];
|
newString = [theString lowercaseString];
|
||||||
|
|
||||||
return ([theString isEqualToString: @"sn"]
|
return ([newString isEqualToString: @"sn"]
|
||||||
|| [theString isEqualToString: @"givenname"]
|
|| [newString isEqualToString: @"givenname"]
|
||||||
|| [theString isEqualToString: @"mail"]
|
|| [newString isEqualToString: @"mail"]
|
||||||
|| [theString isEqualToString: @"telephonenumber"]);
|
|| [newString isEqualToString: @"telephonenumber"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSDictionary *) _parseContactFilter: (id <DOMElement>) filterElement
|
- (NSDictionary *) _parseContactFilter: (id <DOMElement>) filterElement
|
||||||
|
|
|
@ -28,6 +28,7 @@ SOGo_HEADER_FILES = \
|
||||||
\
|
\
|
||||||
SOGoUserManager.h \
|
SOGoUserManager.h \
|
||||||
LDAPSource.h \
|
LDAPSource.h \
|
||||||
|
LDAPSourceSchema.h \
|
||||||
SQLSource.h \
|
SQLSource.h \
|
||||||
SOGoUserProfile.h \
|
SOGoUserProfile.h \
|
||||||
SOGoDateFormatter.h \
|
SOGoDateFormatter.h \
|
||||||
|
@ -97,6 +98,7 @@ SOGo_OBJC_FILES = \
|
||||||
SOGoStartupLogger.m \
|
SOGoStartupLogger.m \
|
||||||
SOGoUserManager.m \
|
SOGoUserManager.m \
|
||||||
LDAPSource.m \
|
LDAPSource.m \
|
||||||
|
LDAPSourceSchema.m \
|
||||||
SQLSource.m \
|
SQLSource.m \
|
||||||
SOGoUserProfile.m \
|
SOGoUserProfile.m \
|
||||||
SOGoSQLUserProfile.m \
|
SOGoSQLUserProfile.m \
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "SOGoSource.h"
|
#include "SOGoSource.h"
|
||||||
#include "SOGoConstants.h"
|
#include "SOGoConstants.h"
|
||||||
|
|
||||||
|
@class LDAPSourceSchema;
|
||||||
@class NSDictionary;
|
@class NSDictionary;
|
||||||
@class NSString;
|
@class NSString;
|
||||||
@class NGLdapConnection;
|
@class NGLdapConnection;
|
||||||
|
@ -52,6 +53,7 @@
|
||||||
NSString *_scope;
|
NSString *_scope;
|
||||||
|
|
||||||
NSString *baseDN;
|
NSString *baseDN;
|
||||||
|
LDAPSourceSchema *schema;
|
||||||
NSString *IDField; // the first part of a user DN
|
NSString *IDField; // the first part of a user DN
|
||||||
NSString *CNField;
|
NSString *CNField;
|
||||||
NSString *UIDField;
|
NSString *UIDField;
|
||||||
|
@ -63,6 +65,9 @@
|
||||||
NSString *domain;
|
NSString *domain;
|
||||||
NSString *contactInfoAttribute;
|
NSString *contactInfoAttribute;
|
||||||
|
|
||||||
|
NSDictionary *contactMapping;
|
||||||
|
NSArray *contactObjectClasses;
|
||||||
|
|
||||||
NSDictionary *modulesConstraints;
|
NSDictionary *modulesConstraints;
|
||||||
|
|
||||||
NSMutableArray *searchAttributes;
|
NSMutableArray *searchAttributes;
|
||||||
|
@ -74,6 +79,9 @@
|
||||||
/* resources handling */
|
/* resources handling */
|
||||||
NSString *kindField;
|
NSString *kindField;
|
||||||
NSString *multipleBookingsField;
|
NSString *multipleBookingsField;
|
||||||
|
|
||||||
|
/* ACL */
|
||||||
|
NSArray *modifiers;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setBindDN: (NSString *) newBindDN
|
- (void) setBindDN: (NSString *) newBindDN
|
||||||
|
@ -95,6 +103,11 @@
|
||||||
kindField: (NSString *) newKindField
|
kindField: (NSString *) newKindField
|
||||||
andMultipleBookingsField: (NSString *) newMultipleBookingsField;
|
andMultipleBookingsField: (NSString *) newMultipleBookingsField;
|
||||||
|
|
||||||
|
/* This enable the convertion of a contact entry with inetOrgPerson and mozillaAbPerson
|
||||||
|
to and from an LDAP record */
|
||||||
|
- (void) setContactMapping: (NSDictionary *) newMapping
|
||||||
|
andObjectClasses: (NSArray *) newObjectClasses;
|
||||||
|
|
||||||
- (NGLdapEntry *) lookupGroupEntryByUID: (NSString *) theUID;
|
- (NGLdapEntry *) lookupGroupEntryByUID: (NSString *) theUID;
|
||||||
- (NGLdapEntry *) lookupGroupEntryByEmail: (NSString *) theEmail;
|
- (NGLdapEntry *) lookupGroupEntryByEmail: (NSString *) theEmail;
|
||||||
- (NGLdapEntry *) lookupGroupEntryByAttribute: (NSString *) theAttribute
|
- (NGLdapEntry *) lookupGroupEntryByAttribute: (NSString *) theAttribute
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#import <NGLdap/NGLdapEntry.h>
|
#import <NGLdap/NGLdapEntry.h>
|
||||||
#import <NGLdap/NGLdapModification.h>
|
#import <NGLdap/NGLdapModification.h>
|
||||||
|
|
||||||
|
#import "LDAPSourceSchema.h"
|
||||||
#import "NSArray+Utilities.h"
|
#import "NSArray+Utilities.h"
|
||||||
#import "NSString+Utilities.h"
|
#import "NSString+Utilities.h"
|
||||||
#import "SOGoDomainDefaults.h"
|
#import "SOGoDomainDefaults.h"
|
||||||
|
@ -44,89 +45,76 @@
|
||||||
|
|
||||||
#import "../../Main/SOGo.h"
|
#import "../../Main/SOGo.h"
|
||||||
|
|
||||||
|
static Class NSStringK;
|
||||||
|
|
||||||
#define SafeLDAPCriteria(x) [[[x stringByReplacingString: @"\\" withString: @"\\\\"] \
|
#define SafeLDAPCriteria(x) [[[x stringByReplacingString: @"\\" withString: @"\\\\"] \
|
||||||
stringByReplacingString: @"'" withString: @"\\'"] \
|
stringByReplacingString: @"'" withString: @"\\'"] \
|
||||||
stringByReplacingString: @"%" withString: @"%%"]
|
stringByReplacingString: @"%" withString: @"%%"]
|
||||||
static NSArray *commonSearchFields;
|
|
||||||
|
@interface NGLdapAttribute (SOGoLDAP)
|
||||||
|
|
||||||
|
- (id) _asArrayOrString;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation NGLdapAttribute (SOGoLDAP)
|
||||||
|
|
||||||
|
- (id) _asArrayOrString
|
||||||
|
{
|
||||||
|
id value;
|
||||||
|
NSArray *arrayValue;
|
||||||
|
|
||||||
|
arrayValue = [self allStringValues];
|
||||||
|
if ([arrayValue count] == 1)
|
||||||
|
value = [arrayValue objectAtIndex: 0];
|
||||||
|
else
|
||||||
|
value = arrayValue;
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface NGLdapEntry (SOGoLDAP)
|
||||||
|
|
||||||
|
- (NSMutableDictionary *) _asDictionary;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation NGLdapEntry (SOGoLDAP)
|
||||||
|
|
||||||
|
- (NSMutableDictionary *) _asDictionary
|
||||||
|
{
|
||||||
|
NSMutableDictionary *ldapRecord;
|
||||||
|
NSDictionary *ldapAttributes;
|
||||||
|
NSArray *keys;
|
||||||
|
NSString *key;
|
||||||
|
NSUInteger count, max;
|
||||||
|
id value;
|
||||||
|
|
||||||
|
ldapAttributes = [self attributes];
|
||||||
|
keys = [ldapAttributes allKeys];
|
||||||
|
max = [keys count];
|
||||||
|
|
||||||
|
ldapRecord = [NSMutableDictionary dictionaryWithCapacity: max];
|
||||||
|
for (count = 0; count < max; count++)
|
||||||
|
{
|
||||||
|
key = [keys objectAtIndex: count];
|
||||||
|
value = [[ldapAttributes objectForKey: key] _asArrayOrString];
|
||||||
|
if (value)
|
||||||
|
[ldapRecord setObject: value forKey: [key lowercaseString]];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ldapRecord;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
@implementation LDAPSource
|
@implementation LDAPSource
|
||||||
|
|
||||||
+ (void) initialize
|
+ (void) initialize
|
||||||
{
|
{
|
||||||
if (!commonSearchFields)
|
NSStringK = [NSString class];
|
||||||
{
|
|
||||||
commonSearchFields = [NSArray arrayWithObjects:
|
|
||||||
@"title",
|
|
||||||
@"company",
|
|
||||||
@"o",
|
|
||||||
@"displayname",
|
|
||||||
@"modifytimestamp",
|
|
||||||
@"mozillahomestate",
|
|
||||||
@"mozillahomeurl",
|
|
||||||
@"homeurl",
|
|
||||||
@"st",
|
|
||||||
@"region",
|
|
||||||
@"mozillacustom2",
|
|
||||||
@"custom2",
|
|
||||||
@"mozillahomecountryname",
|
|
||||||
@"description",
|
|
||||||
@"notes",
|
|
||||||
@"department",
|
|
||||||
@"departmentnumber",
|
|
||||||
@"ou",
|
|
||||||
@"orgunit",
|
|
||||||
@"mobile",
|
|
||||||
@"cellphone",
|
|
||||||
@"carphone",
|
|
||||||
@"mozillacustom1",
|
|
||||||
@"custom1",
|
|
||||||
@"mozillanickname",
|
|
||||||
@"xmozillanickname",
|
|
||||||
@"mozillaworkurl",
|
|
||||||
@"workurl",
|
|
||||||
@"fax",
|
|
||||||
@"facsimiletelephonenumber",
|
|
||||||
@"telephonenumber",
|
|
||||||
@"mozillahomestreet",
|
|
||||||
@"mozillasecondemail",
|
|
||||||
@"xmozillasecondemail",
|
|
||||||
@"mozillacustom4",
|
|
||||||
@"custom4",
|
|
||||||
@"nsaimid",
|
|
||||||
@"nscpaimscreenname",
|
|
||||||
@"street",
|
|
||||||
@"streetaddress",
|
|
||||||
@"postofficebox",
|
|
||||||
@"homephone",
|
|
||||||
@"cn",
|
|
||||||
@"commonname",
|
|
||||||
@"givenname",
|
|
||||||
@"mozillahomepostalcode",
|
|
||||||
@"mozillahomelocalityname",
|
|
||||||
@"mozillaworkstreet2",
|
|
||||||
@"mozillausehtmlmail",
|
|
||||||
@"xmozillausehtmlmail",
|
|
||||||
@"mozillahomestreet2",
|
|
||||||
@"postalcode",
|
|
||||||
@"zip",
|
|
||||||
@"c",
|
|
||||||
@"countryname",
|
|
||||||
@"pager",
|
|
||||||
@"pagerphone",
|
|
||||||
@"mail",
|
|
||||||
@"sn",
|
|
||||||
@"surname",
|
|
||||||
@"mozillacustom3",
|
|
||||||
@"custom3",
|
|
||||||
@"l",
|
|
||||||
@"locality",
|
|
||||||
@"birthyear",
|
|
||||||
@"serialnumber",
|
|
||||||
@"calfburl",
|
|
||||||
@"proxyaddresses",
|
|
||||||
nil];
|
|
||||||
[commonSearchFields retain];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -162,11 +150,13 @@ static NSArray *commonSearchFields;
|
||||||
domain = nil;
|
domain = nil;
|
||||||
|
|
||||||
baseDN = nil;
|
baseDN = nil;
|
||||||
|
schema = nil;
|
||||||
IDField = @"cn"; /* the first part of a user DN */
|
IDField = @"cn"; /* the first part of a user DN */
|
||||||
CNField = @"cn";
|
CNField = @"cn";
|
||||||
UIDField = @"uid";
|
UIDField = @"uid";
|
||||||
mailFields = [NSArray arrayWithObject: @"mail"];
|
mailFields = [NSArray arrayWithObject: @"mail"];
|
||||||
[mailFields retain];
|
[mailFields retain];
|
||||||
|
contactMapping = nil;
|
||||||
searchFields = [NSArray arrayWithObjects: @"sn", @"displayname", @"telephonenumber", nil];
|
searchFields = [NSArray arrayWithObjects: @"sn", @"displayname", @"telephonenumber", nil];
|
||||||
[searchFields retain];
|
[searchFields retain];
|
||||||
IMAPHostField = nil;
|
IMAPHostField = nil;
|
||||||
|
@ -182,6 +172,7 @@ static NSArray *commonSearchFields;
|
||||||
multipleBookingsField = nil;
|
multipleBookingsField = nil;
|
||||||
|
|
||||||
_dnCache = [[NSMutableDictionary alloc] init];
|
_dnCache = [[NSMutableDictionary alloc] init];
|
||||||
|
modifiers = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
@ -192,6 +183,7 @@ static NSArray *commonSearchFields;
|
||||||
//
|
//
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
|
[schema release];
|
||||||
[bindDN release];
|
[bindDN release];
|
||||||
[password release];
|
[password release];
|
||||||
[sourceBindDN release];
|
[sourceBindDN release];
|
||||||
|
@ -202,6 +194,7 @@ static NSArray *commonSearchFields;
|
||||||
[IDField release];
|
[IDField release];
|
||||||
[CNField release];
|
[CNField release];
|
||||||
[UIDField release];
|
[UIDField release];
|
||||||
|
[contactMapping release];
|
||||||
[mailFields release];
|
[mailFields release];
|
||||||
[searchFields release];
|
[searchFields release];
|
||||||
[IMAPHostField release];
|
[IMAPHostField release];
|
||||||
|
@ -216,6 +209,7 @@ static NSArray *commonSearchFields;
|
||||||
[_dnCache release];
|
[_dnCache release];
|
||||||
[kindField release];
|
[kindField release];
|
||||||
[multipleBookingsField release];
|
[multipleBookingsField release];
|
||||||
|
[modifiers release];
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,6 +245,9 @@ static NSArray *commonSearchFields;
|
||||||
kindField: [udSource objectForKey: @"KindFieldName"]
|
kindField: [udSource objectForKey: @"KindFieldName"]
|
||||||
andMultipleBookingsField: [udSource objectForKey: @"MultipleBookingsFieldName"]];
|
andMultipleBookingsField: [udSource objectForKey: @"MultipleBookingsFieldName"]];
|
||||||
|
|
||||||
|
[self setContactMapping: [udSource objectForKey: @"mapping"]
|
||||||
|
andObjectClasses: [udSource objectForKey: @"objectClasses"]];
|
||||||
|
|
||||||
if ([sourceDomain length])
|
if ([sourceDomain length])
|
||||||
{
|
{
|
||||||
dd = [SOGoDomainDefaults defaultsForDomain: sourceDomain];
|
dd = [SOGoDomainDefaults defaultsForDomain: sourceDomain];
|
||||||
|
@ -286,6 +283,8 @@ static NSArray *commonSearchFields;
|
||||||
|
|
||||||
if ([udSource objectForKey: @"passwordPolicy"])
|
if ([udSource objectForKey: @"passwordPolicy"])
|
||||||
passwordPolicy = [[udSource objectForKey: @"passwordPolicy"] boolValue];
|
passwordPolicy = [[udSource objectForKey: @"passwordPolicy"] boolValue];
|
||||||
|
|
||||||
|
ASSIGN (modifiers, [udSource objectForKey: @"modifiers"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
@ -345,15 +344,15 @@ andMultipleBookingsField: (NSString *) newMultipleBookingsField
|
||||||
{
|
{
|
||||||
ASSIGN(baseDN, [newBaseDN lowercaseString]);
|
ASSIGN(baseDN, [newBaseDN lowercaseString]);
|
||||||
if (newIDField)
|
if (newIDField)
|
||||||
ASSIGN(IDField, newIDField);
|
ASSIGN(IDField, [newIDField lowercaseString]);
|
||||||
if (newCNField)
|
if (newCNField)
|
||||||
ASSIGN(CNField, newCNField);
|
ASSIGN(CNField, [newCNField lowercaseString]);
|
||||||
if (newUIDField)
|
if (newUIDField)
|
||||||
ASSIGN(UIDField, newUIDField);
|
ASSIGN(UIDField, [newUIDField lowercaseString]);
|
||||||
if (newIMAPHostField)
|
if (newIMAPHostField)
|
||||||
ASSIGN(IMAPHostField, newIMAPHostField);
|
ASSIGN(IMAPHostField, [newIMAPHostField lowercaseString]);
|
||||||
if (newIMAPLoginField)
|
if (newIMAPLoginField)
|
||||||
ASSIGN(IMAPLoginField, newIMAPLoginField);
|
ASSIGN(IMAPLoginField, [newIMAPLoginField lowercaseString]);
|
||||||
if (newMailFields)
|
if (newMailFields)
|
||||||
ASSIGN(mailFields, newMailFields);
|
ASSIGN(mailFields, newMailFields);
|
||||||
if (newSearchFields)
|
if (newSearchFields)
|
||||||
|
@ -382,9 +381,16 @@ andMultipleBookingsField: (NSString *) newMultipleBookingsField
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (newKindField)
|
if (newKindField)
|
||||||
ASSIGN(kindField, newKindField);
|
ASSIGN(kindField, [newKindField lowercaseString]);
|
||||||
if (newMultipleBookingsField)
|
if (newMultipleBookingsField)
|
||||||
ASSIGN(multipleBookingsField, newMultipleBookingsField);
|
ASSIGN(multipleBookingsField, [newMultipleBookingsField lowercaseString]);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setContactMapping: (NSDictionary *) newMapping
|
||||||
|
andObjectClasses: (NSArray *) newObjectClasses
|
||||||
|
{
|
||||||
|
ASSIGN (contactMapping, newMapping);
|
||||||
|
ASSIGN (contactObjectClasses, newObjectClasses);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -438,7 +444,9 @@ andMultipleBookingsField: (NSString *) newMultipleBookingsField
|
||||||
}
|
}
|
||||||
NS_HANDLER
|
NS_HANDLER
|
||||||
{
|
{
|
||||||
NSLog(@"Could not bind to the LDAP server %@ (%d) using the bind DN: %@", hostname, port, bindDN);
|
[self errorWithFormat: @"Could not bind to the LDAP server %@ (%d)"
|
||||||
|
@" using the bind DN: %@",
|
||||||
|
hostname, port, bindDN];
|
||||||
ldapConnection = nil;
|
ldapConnection = nil;
|
||||||
}
|
}
|
||||||
NS_ENDHANDLER;
|
NS_ENDHANDLER;
|
||||||
|
@ -738,44 +746,6 @@ andMultipleBookingsField: (NSString *) newMultipleBookingsField
|
||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray *) _searchAttributes
|
|
||||||
{
|
|
||||||
if (!searchAttributes)
|
|
||||||
{
|
|
||||||
searchAttributes = [NSMutableArray new];
|
|
||||||
[searchAttributes addObject: @"objectClass"];
|
|
||||||
if (CNField)
|
|
||||||
[searchAttributes addObject: CNField];
|
|
||||||
if (UIDField)
|
|
||||||
[searchAttributes addObject: UIDField];
|
|
||||||
[searchAttributes addObjectsFromArray: mailFields];
|
|
||||||
[searchAttributes addObjectsFromArray: [self _constraintsFields]];
|
|
||||||
[searchAttributes addObjectsFromArray: commonSearchFields];
|
|
||||||
[searchAttributes addObjectUniquely: IDField];
|
|
||||||
|
|
||||||
// Add SOGoLDAPContactInfoAttribute from user defaults
|
|
||||||
if ([contactInfoAttribute length])
|
|
||||||
[searchAttributes addObjectUniquely: contactInfoAttribute];
|
|
||||||
|
|
||||||
// Add IMAP hostname from user defaults
|
|
||||||
if ([IMAPHostField length])
|
|
||||||
[searchAttributes addObjectUniquely: IMAPHostField];
|
|
||||||
|
|
||||||
// Add IMAP login from user defaults
|
|
||||||
if ([IMAPLoginField length])
|
|
||||||
[searchAttributes addObjectUniquely: IMAPLoginField];
|
|
||||||
|
|
||||||
// Add the resources handling attributes
|
|
||||||
if ([kindField length])
|
|
||||||
[searchAttributes addObjectUniquely: kindField];
|
|
||||||
|
|
||||||
if ([multipleBookingsField length])
|
|
||||||
[searchAttributes addObjectUniquely: multipleBookingsField];
|
|
||||||
}
|
|
||||||
|
|
||||||
return searchAttributes;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSArray *) allEntryIDs
|
- (NSArray *) allEntryIDs
|
||||||
{
|
{
|
||||||
NSEnumerator *entries;
|
NSEnumerator *entries;
|
||||||
|
@ -814,7 +784,7 @@ andMultipleBookingsField: (NSString *) newMultipleBookingsField
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _fillEmailsOfEntry: (NGLdapEntry *) ldapEntry
|
- (void) _fillEmailsOfEntry: (NGLdapEntry *) ldapEntry
|
||||||
intoContactEntry: (NSMutableDictionary *) contactEntry
|
intoLDIFRecord: (NSMutableDictionary *) ldifRecord
|
||||||
{
|
{
|
||||||
NSEnumerator *emailFields;
|
NSEnumerator *emailFields;
|
||||||
NSString *currentFieldName, *ldapValue;
|
NSString *currentFieldName, *ldapValue;
|
||||||
|
@ -829,27 +799,27 @@ andMultipleBookingsField: (NSString *) newMultipleBookingsField
|
||||||
allStringValues];
|
allStringValues];
|
||||||
[emails addObjectsFromArray: allValues];
|
[emails addObjectsFromArray: allValues];
|
||||||
}
|
}
|
||||||
[contactEntry setObject: emails forKey: @"c_emails"];
|
[ldifRecord setObject: emails forKey: @"c_emails"];
|
||||||
[emails release];
|
[emails release];
|
||||||
|
|
||||||
if (IMAPHostField)
|
if (IMAPHostField)
|
||||||
{
|
{
|
||||||
ldapValue = [[ldapEntry attributeWithName: IMAPHostField] stringValueAtIndex: 0];
|
ldapValue = [[ldapEntry attributeWithName: IMAPHostField] stringValueAtIndex: 0];
|
||||||
if ([ldapValue length] > 0)
|
if ([ldapValue length] > 0)
|
||||||
[contactEntry setObject: ldapValue forKey: @"c_imaphostname"];
|
[ldifRecord setObject: ldapValue forKey: @"c_imaphostname"];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IMAPLoginField)
|
if (IMAPLoginField)
|
||||||
{
|
{
|
||||||
ldapValue = [[ldapEntry attributeWithName: IMAPLoginField] stringValueAtIndex: 0];
|
ldapValue = [[ldapEntry attributeWithName: IMAPLoginField] stringValueAtIndex: 0];
|
||||||
if ([ldapValue length] > 0)
|
if ([ldapValue length] > 0)
|
||||||
[contactEntry setObject: ldapValue forKey: @"c_imaplogin"];
|
[ldifRecord setObject: ldapValue forKey: @"c_imaplogin"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _fillConstraints: (NGLdapEntry *) ldapEntry
|
- (void) _fillConstraints: (NGLdapEntry *) ldapEntry
|
||||||
forModule: (NSString *) module
|
forModule: (NSString *) module
|
||||||
intoContactEntry: (NSMutableDictionary *) contactEntry
|
intoLDIFRecord: (NSMutableDictionary *) ldifRecord
|
||||||
{
|
{
|
||||||
NSDictionary *constraints;
|
NSDictionary *constraints;
|
||||||
NSEnumerator *matches;
|
NSEnumerator *matches;
|
||||||
|
@ -875,21 +845,94 @@ andMultipleBookingsField: (NSString *) newMultipleBookingsField
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[contactEntry setObject: [NSNumber numberWithBool: result]
|
[ldifRecord setObject: [NSNumber numberWithBool: result]
|
||||||
forKey: [NSString stringWithFormat: @"%@Access", module]];
|
forKey: [NSString stringWithFormat: @"%@Access", module]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* conversion LDAP -> SOGo inetOrgPerson entry */
|
||||||
|
- (void) _applyContactMappingToResult: (NSMutableDictionary *) ldifRecord
|
||||||
|
{
|
||||||
|
NSArray *sourceFields;
|
||||||
|
NSArray *keys;
|
||||||
|
NSString *key, *field, *value;
|
||||||
|
NSUInteger count, max, fieldCount, fieldMax;
|
||||||
|
BOOL filled;
|
||||||
|
|
||||||
|
keys = [contactMapping allKeys];
|
||||||
|
max = [keys count];
|
||||||
|
for (count = 0; count < max; count++)
|
||||||
|
{
|
||||||
|
key = [keys objectAtIndex: count];
|
||||||
|
sourceFields = [contactMapping objectForKey: key];
|
||||||
|
if ([sourceFields isKindOfClass: NSStringK])
|
||||||
|
sourceFields = [NSArray arrayWithObject: sourceFields];
|
||||||
|
fieldMax = [sourceFields count];
|
||||||
|
filled = NO;
|
||||||
|
for (fieldCount = 0;
|
||||||
|
!filled && fieldCount < fieldMax;
|
||||||
|
fieldCount++)
|
||||||
|
{
|
||||||
|
field = [[sourceFields objectAtIndex: fieldCount] lowercaseString];
|
||||||
|
value = [ldifRecord objectForKey: field];
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
[ldifRecord setObject: value forKey: [key lowercaseString]];
|
||||||
|
filled = YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* conversion SOGo inetOrgPerson entry -> LDAP */
|
||||||
|
- (void) _applyContactMappingToOutput: (NSMutableDictionary *) ldifRecord
|
||||||
|
{
|
||||||
|
NSArray *sourceFields;
|
||||||
|
NSArray *keys;
|
||||||
|
NSString *key, *lowerKey, *field, *value;
|
||||||
|
NSUInteger count, max, fieldCount, fieldMax;
|
||||||
|
|
||||||
|
if (contactObjectClasses)
|
||||||
|
[ldifRecord setObject: contactObjectClasses
|
||||||
|
forKey: @"objectclass"];
|
||||||
|
|
||||||
|
keys = [contactMapping allKeys];
|
||||||
|
max = [keys count];
|
||||||
|
for (count = 0; count < max; count++)
|
||||||
|
{
|
||||||
|
key = [keys objectAtIndex: count];
|
||||||
|
lowerKey = [key lowercaseString];
|
||||||
|
value = [ldifRecord objectForKey: lowerKey];
|
||||||
|
if ([value length] > 0)
|
||||||
|
{
|
||||||
|
sourceFields = [contactMapping objectForKey: key];
|
||||||
|
if ([sourceFields isKindOfClass: NSStringK])
|
||||||
|
sourceFields = [NSArray arrayWithObject: sourceFields];
|
||||||
|
|
||||||
|
fieldMax = [sourceFields count];
|
||||||
|
for (fieldCount = 0; fieldCount < fieldMax; fieldCount++)
|
||||||
|
{
|
||||||
|
field = [[sourceFields objectAtIndex: fieldCount]
|
||||||
|
lowercaseString];
|
||||||
|
[ldifRecord setObject: value forKey: field];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (NSDictionary *) _convertLDAPEntryToContact: (NGLdapEntry *) ldapEntry
|
- (NSDictionary *) _convertLDAPEntryToContact: (NGLdapEntry *) ldapEntry
|
||||||
{
|
{
|
||||||
NSMutableDictionary *contactEntry;
|
NSMutableDictionary *ldifRecord;
|
||||||
NSEnumerator *attributes;
|
NSString *value;
|
||||||
NSString *currentAttribute, *value;
|
static NSArray *resourceKinds = nil;
|
||||||
NSMutableArray *classes;
|
NSMutableArray *classes;
|
||||||
id o;
|
id o;
|
||||||
|
|
||||||
contactEntry = [NSMutableDictionary dictionary];
|
if (!resourceKinds)
|
||||||
[contactEntry setObject: [ldapEntry dn] forKey: @"dn"];
|
resourceKinds = [[NSArray alloc] initWithObjects: @"location", @"thing",
|
||||||
attributes = [[self _searchAttributes] objectEnumerator];
|
@"group", nil];
|
||||||
|
|
||||||
|
ldifRecord = [ldapEntry _asDictionary];
|
||||||
|
[ldifRecord setObject: [ldapEntry dn] forKey: @"dn"];
|
||||||
|
|
||||||
// We get our objectClass attribute values. We lowercase
|
// We get our objectClass attribute values. We lowercase
|
||||||
// everything for ease of search after.
|
// everything for ease of search after.
|
||||||
|
@ -909,9 +952,6 @@ andMultipleBookingsField: (NSString *) newMultipleBookingsField
|
||||||
|
|
||||||
if (classes)
|
if (classes)
|
||||||
{
|
{
|
||||||
[contactEntry setObject: classes
|
|
||||||
forKey: @"objectclasses"];
|
|
||||||
|
|
||||||
// We check if our entry is a group. If so, we set the
|
// We check if our entry is a group. If so, we set the
|
||||||
// 'isGroup' custom attribute.
|
// 'isGroup' custom attribute.
|
||||||
if ([classes containsObject: @"group"] ||
|
if ([classes containsObject: @"group"] ||
|
||||||
|
@ -919,7 +959,7 @@ andMultipleBookingsField: (NSString *) newMultipleBookingsField
|
||||||
[classes containsObject: @"groupofuniquenames"] ||
|
[classes containsObject: @"groupofuniquenames"] ||
|
||||||
[classes containsObject: @"posixgroup"])
|
[classes containsObject: @"posixgroup"])
|
||||||
{
|
{
|
||||||
[contactEntry setObject: [NSNumber numberWithInt: 1]
|
[ldifRecord setObject: [NSNumber numberWithInt: 1]
|
||||||
forKey: @"isGroup"];
|
forKey: @"isGroup"];
|
||||||
}
|
}
|
||||||
// We check if our entry is a resource. We also support
|
// We check if our entry is a resource. We also support
|
||||||
|
@ -927,22 +967,11 @@ andMultipleBookingsField: (NSString *) newMultipleBookingsField
|
||||||
// value - see below.
|
// value - see below.
|
||||||
else if ([classes containsObject: @"calendarresource"])
|
else if ([classes containsObject: @"calendarresource"])
|
||||||
{
|
{
|
||||||
[contactEntry setObject: [NSNumber numberWithInt: 1]
|
[ldifRecord setObject: [NSNumber numberWithInt: 1]
|
||||||
forKey: @"isResource"];
|
forKey: @"isResource"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((currentAttribute = [attributes nextObject]))
|
|
||||||
{
|
|
||||||
value = [[ldapEntry attributeWithName: currentAttribute]
|
|
||||||
stringValueAtIndex: 0];
|
|
||||||
|
|
||||||
// It's important here to set our attributes' key in lowercase.
|
|
||||||
if (value)
|
|
||||||
{
|
|
||||||
currentAttribute = [currentAttribute lowercaseString];
|
|
||||||
[contactEntry setObject: value forKey: currentAttribute];
|
|
||||||
|
|
||||||
// We check if that entry corresponds to a resource. For this,
|
// We check if that entry corresponds to a resource. For this,
|
||||||
// kindField must be defined and it must hold one of those values
|
// kindField must be defined and it must hold one of those values
|
||||||
//
|
//
|
||||||
|
@ -950,32 +979,28 @@ andMultipleBookingsField: (NSString *) newMultipleBookingsField
|
||||||
// thing
|
// thing
|
||||||
// group
|
// group
|
||||||
//
|
//
|
||||||
if (kindField &&
|
if ([kindField length] > 0)
|
||||||
[kindField caseInsensitiveCompare: currentAttribute] == NSOrderedSame)
|
|
||||||
{
|
{
|
||||||
if ([value caseInsensitiveCompare: @"location"] == NSOrderedSame ||
|
value = [ldifRecord objectForKey: [kindField lowercaseString]];
|
||||||
[value caseInsensitiveCompare: @"thing"] == NSOrderedSame ||
|
if ([value isKindOfClass: NSStringK]
|
||||||
[value caseInsensitiveCompare: @"group"] == NSOrderedSame)
|
&& [resourceKinds containsObject: value])
|
||||||
{
|
[ldifRecord setObject: [NSNumber numberWithInt: 1]
|
||||||
[contactEntry setObject: [NSNumber numberWithInt: 1]
|
|
||||||
forKey: @"isResource"];
|
forKey: @"isResource"];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// We check for the number of simultanous bookings that is allowed.
|
// We check for the number of simultanous bookings that is allowed.
|
||||||
// A value of 0 means that there's no limit.
|
// A value of 0 means that there's no limit.
|
||||||
if (multipleBookingsField &&
|
if ([multipleBookingsField length] > 0)
|
||||||
[multipleBookingsField caseInsensitiveCompare: currentAttribute] == NSOrderedSame)
|
|
||||||
{
|
{
|
||||||
[contactEntry setObject: [NSNumber numberWithInt: [value intValue]]
|
value = [ldifRecord objectForKey: [multipleBookingsField lowercaseString]];
|
||||||
|
[ldifRecord setObject: [NSNumber numberWithInt: [value intValue]]
|
||||||
forKey: @"numberOfSimultaneousBookings"];
|
forKey: @"numberOfSimultaneousBookings"];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
value = [[ldapEntry attributeWithName: IDField] stringValueAtIndex: 0];
|
value = [[ldapEntry attributeWithName: IDField] stringValueAtIndex: 0];
|
||||||
if (!value)
|
if (!value)
|
||||||
value = @"";
|
value = @"";
|
||||||
[contactEntry setObject: value forKey: @"c_name"];
|
[ldifRecord setObject: value forKey: @"c_name"];
|
||||||
value = [[ldapEntry attributeWithName: UIDField] stringValueAtIndex: 0];
|
value = [[ldapEntry attributeWithName: UIDField] stringValueAtIndex: 0];
|
||||||
if (!value)
|
if (!value)
|
||||||
value = @"";
|
value = @"";
|
||||||
|
@ -984,11 +1009,14 @@ andMultipleBookingsField: (NSString *) newMultipleBookingsField
|
||||||
// Eventually, we could check at this point if the entry is a group
|
// Eventually, we could check at this point if the entry is a group
|
||||||
// and prefix the UID with a "@"
|
// and prefix the UID with a "@"
|
||||||
// }
|
// }
|
||||||
[contactEntry setObject: value forKey: @"c_uid"];
|
[ldifRecord setObject: value forKey: @"c_uid"];
|
||||||
value = [[ldapEntry attributeWithName: CNField] stringValueAtIndex: 0];
|
value = [[ldapEntry attributeWithName: CNField] stringValueAtIndex: 0];
|
||||||
if (!value)
|
if (!value)
|
||||||
value = @"";
|
value = @"";
|
||||||
[contactEntry setObject: value forKey: @"c_cn"];
|
[ldifRecord setObject: value forKey: @"c_cn"];
|
||||||
|
/* if "displayName" is not set, we use CNField because it must exist */
|
||||||
|
if (![ldifRecord objectForKey: @"displayname"])
|
||||||
|
[ldifRecord setObject: value forKey: @"displayname"];
|
||||||
|
|
||||||
if (contactInfoAttribute)
|
if (contactInfoAttribute)
|
||||||
{
|
{
|
||||||
|
@ -999,21 +1027,24 @@ andMultipleBookingsField: (NSString *) newMultipleBookingsField
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
value = @"";
|
value = @"";
|
||||||
[contactEntry setObject: value forKey: @"c_info"];
|
[ldifRecord setObject: value forKey: @"c_info"];
|
||||||
|
|
||||||
if (domain)
|
if (domain)
|
||||||
value = domain;
|
value = domain;
|
||||||
else
|
else
|
||||||
value = @"";
|
value = @"";
|
||||||
[contactEntry setObject: value forKey: @"c_domain"];
|
[ldifRecord setObject: value forKey: @"c_domain"];
|
||||||
|
|
||||||
[self _fillEmailsOfEntry: ldapEntry intoContactEntry: contactEntry];
|
[self _fillEmailsOfEntry: ldapEntry intoLDIFRecord: ldifRecord];
|
||||||
[self _fillConstraints: ldapEntry forModule: @"Calendar"
|
[self _fillConstraints: ldapEntry forModule: @"Calendar"
|
||||||
intoContactEntry: (NSMutableDictionary *) contactEntry];
|
intoLDIFRecord: (NSMutableDictionary *) ldifRecord];
|
||||||
[self _fillConstraints: ldapEntry forModule: @"Mail"
|
[self _fillConstraints: ldapEntry forModule: @"Mail"
|
||||||
intoContactEntry: (NSMutableDictionary *) contactEntry];
|
intoLDIFRecord: (NSMutableDictionary *) ldifRecord];
|
||||||
|
|
||||||
return contactEntry;
|
if (contactMapping)
|
||||||
|
[self _applyContactMappingToResult: ldifRecord];
|
||||||
|
|
||||||
|
return ldifRecord;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray *) fetchContactsMatching: (NSString *) match
|
- (NSArray *) fetchContactsMatching: (NSString *) match
|
||||||
|
@ -1031,7 +1062,8 @@ andMultipleBookingsField: (NSString *) newMultipleBookingsField
|
||||||
{
|
{
|
||||||
ldapConnection = [self _ldapConnection];
|
ldapConnection = [self _ldapConnection];
|
||||||
qualifier = [self _qualifierForFilter: match];
|
qualifier = [self _qualifierForFilter: match];
|
||||||
attributes = [self _searchAttributes];
|
// attributes = [self _searchAttributes];
|
||||||
|
attributes = [NSArray arrayWithObject: @"*"];
|
||||||
|
|
||||||
if ([_scope caseInsensitiveCompare: @"BASE"] == NSOrderedSame)
|
if ([_scope caseInsensitiveCompare: @"BASE"] == NSOrderedSame)
|
||||||
entries = [ldapConnection baseSearchAtBaseDN: baseDN
|
entries = [ldapConnection baseSearchAtBaseDN: baseDN
|
||||||
|
@ -1053,25 +1085,20 @@ andMultipleBookingsField: (NSString *) newMultipleBookingsField
|
||||||
return contacts;
|
return contacts;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSDictionary *) lookupContactEntry: (NSString *) theID
|
- (NGLdapEntry *) _lookupLDAPEntry: (EOQualifier *) qualifier
|
||||||
{
|
{
|
||||||
NGLdapEntry *ldapEntry;
|
|
||||||
NGLdapConnection *ldapConnection;
|
NGLdapConnection *ldapConnection;
|
||||||
NSEnumerator *entries;
|
|
||||||
EOQualifier *qualifier;
|
|
||||||
NSArray *attributes;
|
NSArray *attributes;
|
||||||
NSString *s;
|
NSEnumerator *entries;
|
||||||
NSDictionary *contactEntry;
|
|
||||||
|
|
||||||
contactEntry = nil;
|
// attributes = [self _searchAttributes];
|
||||||
|
|
||||||
if ([theID length] > 0)
|
|
||||||
{
|
|
||||||
ldapConnection = [self _ldapConnection];
|
ldapConnection = [self _ldapConnection];
|
||||||
s = [NSString stringWithFormat: @"(%@='%@')",
|
if (!schema)
|
||||||
IDField, SafeLDAPCriteria(theID)];
|
{
|
||||||
qualifier = [EOQualifier qualifierWithQualifierFormat: s];
|
schema = [LDAPSourceSchema new];
|
||||||
attributes = [self _searchAttributes];
|
[schema readSchemaFromConnection: ldapConnection];
|
||||||
|
}
|
||||||
|
attributes = [NSArray arrayWithObject: @"*"];
|
||||||
|
|
||||||
if ([_scope caseInsensitiveCompare: @"BASE"] == NSOrderedSame)
|
if ([_scope caseInsensitiveCompare: @"BASE"] == NSOrderedSame)
|
||||||
entries = [ldapConnection baseSearchAtBaseDN: baseDN
|
entries = [ldapConnection baseSearchAtBaseDN: baseDN
|
||||||
|
@ -1086,50 +1113,48 @@ andMultipleBookingsField: (NSString *) newMultipleBookingsField
|
||||||
qualifier: qualifier
|
qualifier: qualifier
|
||||||
attributes: attributes];
|
attributes: attributes];
|
||||||
|
|
||||||
ldapEntry = [entries nextObject];
|
return [entries nextObject];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSDictionary *) lookupContactEntry: (NSString *) theID
|
||||||
|
{
|
||||||
|
NGLdapEntry *ldapEntry;
|
||||||
|
EOQualifier *qualifier;
|
||||||
|
NSString *s;
|
||||||
|
NSDictionary *ldifRecord;
|
||||||
|
|
||||||
|
ldifRecord = nil;
|
||||||
|
|
||||||
|
if ([theID length] > 0)
|
||||||
|
{
|
||||||
|
s = [NSString stringWithFormat: @"(%@='%@')",
|
||||||
|
IDField, SafeLDAPCriteria(theID)];
|
||||||
|
qualifier = [EOQualifier qualifierWithQualifierFormat: s];
|
||||||
|
ldapEntry = [self _lookupLDAPEntry: qualifier];
|
||||||
if (ldapEntry)
|
if (ldapEntry)
|
||||||
contactEntry = [self _convertLDAPEntryToContact: ldapEntry];
|
ldifRecord = [self _convertLDAPEntryToContact: ldapEntry];
|
||||||
}
|
}
|
||||||
|
|
||||||
return contactEntry;
|
return ldifRecord;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSDictionary *) lookupContactEntryWithUIDorEmail: (NSString *) uid
|
- (NSDictionary *) lookupContactEntryWithUIDorEmail: (NSString *) uid
|
||||||
{
|
{
|
||||||
NGLdapConnection *ldapConnection;
|
|
||||||
NGLdapEntry *ldapEntry;
|
NGLdapEntry *ldapEntry;
|
||||||
NSEnumerator *entries;
|
|
||||||
EOQualifier *qualifier;
|
EOQualifier *qualifier;
|
||||||
NSArray *attributes;
|
NSDictionary *ldifRecord;
|
||||||
NSDictionary *contactEntry;
|
|
||||||
|
|
||||||
contactEntry = nil;
|
ldifRecord = nil;
|
||||||
|
|
||||||
if ([uid length] > 0)
|
if ([uid length] > 0)
|
||||||
{
|
{
|
||||||
ldapConnection = [self _ldapConnection];
|
|
||||||
qualifier = [self _qualifierForUIDFilter: uid];
|
qualifier = [self _qualifierForUIDFilter: uid];
|
||||||
attributes = [self _searchAttributes];
|
ldapEntry = [self _lookupLDAPEntry: qualifier];
|
||||||
|
|
||||||
if ([_scope caseInsensitiveCompare: @"BASE"] == NSOrderedSame)
|
|
||||||
entries = [ldapConnection baseSearchAtBaseDN: baseDN
|
|
||||||
qualifier: qualifier
|
|
||||||
attributes: attributes];
|
|
||||||
else if ([_scope caseInsensitiveCompare: @"ONE"] == NSOrderedSame)
|
|
||||||
entries = [ldapConnection flatSearchAtBaseDN: baseDN
|
|
||||||
qualifier: qualifier
|
|
||||||
attributes: attributes];
|
|
||||||
else
|
|
||||||
entries = [ldapConnection deepSearchAtBaseDN: baseDN
|
|
||||||
qualifier: qualifier
|
|
||||||
attributes: attributes];
|
|
||||||
|
|
||||||
ldapEntry = [entries nextObject];
|
|
||||||
if (ldapEntry)
|
if (ldapEntry)
|
||||||
contactEntry = [self _convertLDAPEntryToContact: ldapEntry];
|
ldifRecord = [self _convertLDAPEntryToContact: ldapEntry];
|
||||||
}
|
}
|
||||||
|
|
||||||
return contactEntry;
|
return ldifRecord;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *) lookupLoginByDN: (NSString *) theDN
|
- (NSString *) lookupLoginByDN: (NSString *) theDN
|
||||||
|
@ -1171,43 +1196,24 @@ andMultipleBookingsField: (NSString *) newMultipleBookingsField
|
||||||
- (NGLdapEntry *) lookupGroupEntryByAttribute: (NSString *) theAttribute
|
- (NGLdapEntry *) lookupGroupEntryByAttribute: (NSString *) theAttribute
|
||||||
andValue: (NSString *) theValue
|
andValue: (NSString *) theValue
|
||||||
{
|
{
|
||||||
NSMutableArray *attributes;
|
|
||||||
NSEnumerator *entries;
|
|
||||||
EOQualifier *qualifier;
|
EOQualifier *qualifier;
|
||||||
NSString *s;
|
NSString *s;
|
||||||
NGLdapConnection *ldapConnection;
|
|
||||||
NGLdapEntry *ldapEntry;
|
NGLdapEntry *ldapEntry;
|
||||||
|
|
||||||
if ([theValue length] > 0)
|
if ([theValue length] > 0)
|
||||||
{
|
{
|
||||||
ldapConnection = [self _ldapConnection];
|
|
||||||
|
|
||||||
s = [NSString stringWithFormat: @"(%@='%@')",
|
s = [NSString stringWithFormat: @"(%@='%@')",
|
||||||
theAttribute, SafeLDAPCriteria(theValue)];
|
theAttribute, SafeLDAPCriteria(theValue)];
|
||||||
qualifier = [EOQualifier qualifierWithQualifierFormat: s];
|
qualifier = [EOQualifier qualifierWithQualifierFormat: s];
|
||||||
|
|
||||||
// We look for additional attributes - the ones related to group
|
// We look for additional attributes - the ones related to group
|
||||||
// membership
|
// membership
|
||||||
attributes = [NSMutableArray arrayWithArray: [self _searchAttributes]];
|
// attributes = [NSMutableArray arrayWithArray: [self _searchAttributes]];
|
||||||
[attributes addObject: @"member"];
|
// [attributes addObject: @"member"];
|
||||||
[attributes addObject: @"uniqueMember"];
|
// [attributes addObject: @"uniqueMember"];
|
||||||
[attributes addObject: @"memberUid"];
|
// [attributes addObject: @"memberUid"];
|
||||||
[attributes addObject: @"memberOf"];
|
// [attributes addObject: @"memberOf"];
|
||||||
|
ldapEntry = [self _lookupLDAPEntry: qualifier];
|
||||||
if ([_scope caseInsensitiveCompare: @"BASE"] == NSOrderedSame)
|
|
||||||
entries = [ldapConnection baseSearchAtBaseDN: baseDN
|
|
||||||
qualifier: qualifier
|
|
||||||
attributes: attributes];
|
|
||||||
else if ([_scope caseInsensitiveCompare: @"ONE"] == NSOrderedSame)
|
|
||||||
entries = [ldapConnection flatSearchAtBaseDN: baseDN
|
|
||||||
qualifier: qualifier
|
|
||||||
attributes: attributes];
|
|
||||||
else
|
|
||||||
entries = [ldapConnection deepSearchAtBaseDN: baseDN
|
|
||||||
qualifier: qualifier
|
|
||||||
attributes: attributes];
|
|
||||||
|
|
||||||
ldapEntry = [entries nextObject];
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ldapEntry = nil;
|
ldapEntry = nil;
|
||||||
|
@ -1225,4 +1231,247 @@ andMultipleBookingsField: (NSString *) newMultipleBookingsField
|
||||||
return baseDN;
|
return baseDN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSArray *) modifiers
|
||||||
|
{
|
||||||
|
return modifiers;
|
||||||
|
}
|
||||||
|
|
||||||
|
static NSArray *
|
||||||
|
_convertRecordToLDAPAttributes (LDAPSourceSchema *schema, NSDictionary *ldifRecord)
|
||||||
|
{
|
||||||
|
/* convert resulting record to NGLdapEntry:
|
||||||
|
- ignore fields with empty values
|
||||||
|
- ignore extra fields
|
||||||
|
- use correct case for LDAP attribute matching classes */
|
||||||
|
NSMutableArray *attributes;
|
||||||
|
NGLdapAttribute *attribute;
|
||||||
|
NSArray *classes, *fields, *values;
|
||||||
|
NSString *field, *lowerField, *value;
|
||||||
|
NSUInteger count, max, valueCount, valueMax;
|
||||||
|
|
||||||
|
attributes = [NSMutableArray new];
|
||||||
|
|
||||||
|
classes = [ldifRecord objectForKey: @"objectclass"];
|
||||||
|
if ([classes isKindOfClass: NSStringK])
|
||||||
|
classes = [NSArray arrayWithObject: classes];
|
||||||
|
fields = [schema fieldsForClasses: classes];
|
||||||
|
|
||||||
|
max = [fields count];
|
||||||
|
for (count = 0; count < max; count++)
|
||||||
|
{
|
||||||
|
attribute = nil;
|
||||||
|
field = [fields objectAtIndex: count];
|
||||||
|
lowerField = [field lowercaseString];
|
||||||
|
if (![lowerField isEqualToString: @"dn"])
|
||||||
|
{
|
||||||
|
values = [ldifRecord objectForKey: lowerField];
|
||||||
|
if ([values isKindOfClass: NSStringK])
|
||||||
|
values = [NSArray arrayWithObject: values];
|
||||||
|
valueMax = [values count];
|
||||||
|
for (valueCount = 0; valueCount < valueMax; valueCount++)
|
||||||
|
{
|
||||||
|
value = [values objectAtIndex: valueCount];
|
||||||
|
if ([value length] > 0)
|
||||||
|
{
|
||||||
|
if (!attribute)
|
||||||
|
{
|
||||||
|
attribute = [[NGLdapAttribute alloc]
|
||||||
|
initWithAttributeName: field];
|
||||||
|
[attributes addObject: attribute];
|
||||||
|
[attribute release];
|
||||||
|
}
|
||||||
|
[attribute addStringValue: value];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return attributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSException *) addContactEntry: (NSDictionary *) roLdifRecord
|
||||||
|
withID: (NSString *) aId
|
||||||
|
{
|
||||||
|
NSException *result = nil;
|
||||||
|
NGLdapEntry *newEntry;
|
||||||
|
NSMutableDictionary *ldifRecord;
|
||||||
|
NSArray *attributes;
|
||||||
|
NSString *dn, *cnValue;
|
||||||
|
NGLdapConnection *ldapConnection;
|
||||||
|
|
||||||
|
if ([aId length] > 0)
|
||||||
|
{
|
||||||
|
ldapConnection = [self _ldapConnection];
|
||||||
|
if (!schema)
|
||||||
|
{
|
||||||
|
schema = [LDAPSourceSchema new];
|
||||||
|
[schema readSchemaFromConnection: ldapConnection];
|
||||||
|
}
|
||||||
|
|
||||||
|
ldifRecord = [roLdifRecord mutableCopy];
|
||||||
|
[ldifRecord autorelease];
|
||||||
|
[ldifRecord setObject: aId forKey: UIDField];
|
||||||
|
|
||||||
|
/* if CN is not set, we use aId because it must exist */
|
||||||
|
if (![ldifRecord objectForKey: CNField])
|
||||||
|
{
|
||||||
|
cnValue = [ldifRecord objectForKey: @"displayname"];
|
||||||
|
if ([cnValue length] == 0)
|
||||||
|
cnValue = aId;
|
||||||
|
[ldifRecord setObject: aId forKey: @"cn"];
|
||||||
|
}
|
||||||
|
|
||||||
|
[self _applyContactMappingToOutput: ldifRecord];
|
||||||
|
|
||||||
|
/* since the id might have changed due to the mapping above, we
|
||||||
|
reload the record ID */
|
||||||
|
aId = [ldifRecord objectForKey: UIDField];
|
||||||
|
dn = [NSString stringWithFormat: @"%@=%@,%@", IDField, aId, baseDN];
|
||||||
|
attributes = _convertRecordToLDAPAttributes (schema, ldifRecord);
|
||||||
|
|
||||||
|
newEntry = [[NGLdapEntry alloc] initWithDN: dn
|
||||||
|
attributes: attributes];
|
||||||
|
[newEntry autorelease];
|
||||||
|
[attributes release];
|
||||||
|
NS_DURING
|
||||||
|
{
|
||||||
|
[ldapConnection addEntry: newEntry];
|
||||||
|
}
|
||||||
|
NS_HANDLER
|
||||||
|
{
|
||||||
|
result = localException;
|
||||||
|
}
|
||||||
|
NS_ENDHANDLER;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
[self errorWithFormat: @"no value for id field '%@'", IDField];
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static NSArray *
|
||||||
|
_makeLDAPChanges (NGLdapConnection *ldapConnection,
|
||||||
|
NSString *dn, NSArray *attributes)
|
||||||
|
{
|
||||||
|
NSMutableArray *changes, *attributeNames, *origAttributeNames;
|
||||||
|
NGLdapEntry *origEntry;
|
||||||
|
NSArray *values;
|
||||||
|
NGLdapAttribute *attribute, *origAttribute;
|
||||||
|
NSString *name;
|
||||||
|
NSDictionary *origAttributes;
|
||||||
|
NSUInteger count, max, valueCount, valueMax;
|
||||||
|
BOOL allStrings;
|
||||||
|
|
||||||
|
/* additions and modifications */
|
||||||
|
origEntry = [ldapConnection entryAtDN: dn
|
||||||
|
attributes: [NSArray arrayWithObject: @"*"]];
|
||||||
|
origAttributes = [origEntry attributes];
|
||||||
|
|
||||||
|
max = [attributes count];
|
||||||
|
changes = [NSMutableArray arrayWithCapacity: max];
|
||||||
|
attributeNames = [NSMutableArray arrayWithCapacity: max];
|
||||||
|
for (count = 0; count < max; count++)
|
||||||
|
{
|
||||||
|
attribute = [attributes objectAtIndex: count];
|
||||||
|
name = [attribute attributeName];
|
||||||
|
[attributeNames addObject: name];
|
||||||
|
origAttribute = [origAttributes objectForKey: name];
|
||||||
|
if (origAttribute)
|
||||||
|
{
|
||||||
|
if (![origAttribute isEqual: attribute])
|
||||||
|
[changes
|
||||||
|
addObject: [NGLdapModification replaceModification: attribute]];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
[changes addObject: [NGLdapModification addModification: attribute]];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* deletions */
|
||||||
|
origAttributeNames = [[origAttributes allKeys] mutableCopy];
|
||||||
|
[origAttributeNames autorelease];
|
||||||
|
[origAttributeNames removeObjectsInArray: attributeNames];
|
||||||
|
max = [origAttributeNames count];
|
||||||
|
for (count = 0; count < max; count++)
|
||||||
|
{
|
||||||
|
name = [origAttributeNames objectAtIndex: count];
|
||||||
|
origAttribute = [origAttributes objectForKey: name];
|
||||||
|
/* the attribute must only have string values, otherwise it will anyway
|
||||||
|
be missing from the new record */
|
||||||
|
allStrings = YES;
|
||||||
|
values = [origAttribute allValues];
|
||||||
|
valueMax = [values count];
|
||||||
|
for (valueCount = 0; allStrings && valueCount < valueMax; valueCount++)
|
||||||
|
if (![[values objectAtIndex: valueCount] isKindOfClass: NSStringK])
|
||||||
|
allStrings = NO;
|
||||||
|
if (allStrings)
|
||||||
|
[changes
|
||||||
|
addObject: [NGLdapModification deleteModification: origAttribute]];
|
||||||
|
}
|
||||||
|
|
||||||
|
return changes;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSException *) updateContactEntry: (NSDictionary *) roLdifRecord
|
||||||
|
{
|
||||||
|
NSException *result = nil;
|
||||||
|
NSString *dn;
|
||||||
|
NSMutableDictionary *ldifRecord;
|
||||||
|
NSArray *attributes, *changes;
|
||||||
|
NGLdapConnection *ldapConnection;
|
||||||
|
|
||||||
|
dn = [roLdifRecord objectForKey: @"dn"];
|
||||||
|
if ([dn length] > 0)
|
||||||
|
{
|
||||||
|
ldapConnection = [self _ldapConnection];
|
||||||
|
if (!schema)
|
||||||
|
{
|
||||||
|
schema = [LDAPSourceSchema new];
|
||||||
|
[schema readSchemaFromConnection: ldapConnection];
|
||||||
|
}
|
||||||
|
|
||||||
|
ldifRecord = [roLdifRecord mutableCopy];
|
||||||
|
[ldifRecord autorelease];
|
||||||
|
[self _applyContactMappingToOutput: ldifRecord];
|
||||||
|
attributes = _convertRecordToLDAPAttributes (schema, ldifRecord);
|
||||||
|
|
||||||
|
changes = _makeLDAPChanges (ldapConnection, dn, attributes);
|
||||||
|
|
||||||
|
NS_DURING
|
||||||
|
{
|
||||||
|
[ldapConnection modifyEntryWithDN: dn
|
||||||
|
changes: changes];
|
||||||
|
}
|
||||||
|
NS_HANDLER
|
||||||
|
{
|
||||||
|
result = localException;
|
||||||
|
}
|
||||||
|
NS_ENDHANDLER;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
[self errorWithFormat: @"expected dn for modified record"];
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSException *) removeContactEntryWithID: (NSString *) aId
|
||||||
|
{
|
||||||
|
NSException *result = nil;
|
||||||
|
NGLdapConnection *ldapConnection;
|
||||||
|
NSString *dn;
|
||||||
|
|
||||||
|
ldapConnection = [self _ldapConnection];
|
||||||
|
dn = [NSString stringWithFormat: @"%@=%@,%@", IDField, aId, baseDN];
|
||||||
|
NS_DURING
|
||||||
|
{
|
||||||
|
[ldapConnection removeEntryWithDN: dn];
|
||||||
|
}
|
||||||
|
NS_HANDLER
|
||||||
|
{
|
||||||
|
result = localException;
|
||||||
|
}
|
||||||
|
NS_ENDHANDLER;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
/* LDAPSourceSchema.h - this file is part of SOGo
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011 Inverse inc
|
||||||
|
*
|
||||||
|
* Author: Wolfgang Sourdeau <wsourdeau@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 LDAPSOURCESCHEMA_H
|
||||||
|
#define LDAPSOURCESCHEMA_H
|
||||||
|
|
||||||
|
#import <Foundation/NSObject.h>
|
||||||
|
|
||||||
|
@class NSMutableDictionary;
|
||||||
|
@class NGLdapConnection;
|
||||||
|
|
||||||
|
@interface LDAPSourceSchema : NSObject
|
||||||
|
{
|
||||||
|
NSMutableDictionary *schema;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) readSchemaFromConnection: (NGLdapConnection *) conn;
|
||||||
|
|
||||||
|
- (NSArray *) fieldsForClass: (NSString *) className;
|
||||||
|
|
||||||
|
/* merged list of attributes with unique names */
|
||||||
|
- (NSArray *) fieldsForClasses: (NSArray *) className;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif /* LDAPSOURCESCHEMA_H */
|
|
@ -0,0 +1,295 @@
|
||||||
|
/* LDAPSourceSchema.m - this file is part of SOGo
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011 Inverse inc
|
||||||
|
*
|
||||||
|
* Author: Wolfgang Sourdeau <wsourdeau@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/NSString.h>
|
||||||
|
#import <Foundation/NSValue.h>
|
||||||
|
|
||||||
|
#import <EOControl/EOQualifier.h>
|
||||||
|
|
||||||
|
#import <NGLdap/NGLdapConnection.h>
|
||||||
|
#import <NGLdap/NGLdapAttribute.h>
|
||||||
|
#import <NGLdap/NGLdapEntry.h>
|
||||||
|
|
||||||
|
#import "LDAPSourceSchema.h"
|
||||||
|
#import "NSDictionary+Utilities.h"
|
||||||
|
|
||||||
|
static EOQualifier *allOCQualifier = nil;
|
||||||
|
|
||||||
|
@implementation LDAPSourceSchema
|
||||||
|
|
||||||
|
+ (void) initialize
|
||||||
|
{
|
||||||
|
allOCQualifier = [[EOKeyValueQualifier alloc]
|
||||||
|
initWithKey: @"objectClass"
|
||||||
|
operatorSelector: EOQualifierOperatorEqual
|
||||||
|
value: @"*"];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) init
|
||||||
|
{
|
||||||
|
if ((self = [super init]))
|
||||||
|
{
|
||||||
|
schema = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) dealloc
|
||||||
|
{
|
||||||
|
[schema release];
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
|
static NSArray *
|
||||||
|
schemaTokens (NSString *schema)
|
||||||
|
{
|
||||||
|
unichar *characters;
|
||||||
|
NSUInteger count, max, parenLevel = 0, firstChar = (NSUInteger) -1;
|
||||||
|
NSMutableArray *arrayString, *parentArray, *currentArray = nil;
|
||||||
|
NSArray *topArray = nil;
|
||||||
|
NSString *token;
|
||||||
|
|
||||||
|
arrayString = [NSMutableArray array];
|
||||||
|
|
||||||
|
max = [schema length];
|
||||||
|
characters = malloc ((max + 1) * sizeof (unichar));
|
||||||
|
characters[max] = 0;
|
||||||
|
[schema getCharacters: characters];
|
||||||
|
|
||||||
|
for (count = 0; count < max; count++)
|
||||||
|
{
|
||||||
|
switch (characters[count])
|
||||||
|
{
|
||||||
|
case '(':
|
||||||
|
// NSLog (@"increase");
|
||||||
|
parenLevel++;
|
||||||
|
parentArray = currentArray;
|
||||||
|
currentArray = [NSMutableArray array];
|
||||||
|
if (parentArray == nil)
|
||||||
|
topArray = currentArray;
|
||||||
|
[parentArray addObject: currentArray];
|
||||||
|
[arrayString addObject: currentArray];
|
||||||
|
break;
|
||||||
|
case ')':
|
||||||
|
// NSLog (@"decrease");
|
||||||
|
parenLevel--;
|
||||||
|
[arrayString removeLastObject];
|
||||||
|
currentArray = [arrayString lastObject];
|
||||||
|
break;
|
||||||
|
case ' ':
|
||||||
|
if (firstChar != (NSUInteger) -1)
|
||||||
|
{
|
||||||
|
token = [NSString stringWithCharacters: characters + firstChar
|
||||||
|
length: (count - firstChar)];
|
||||||
|
if (![token isEqualToString: @"$"])
|
||||||
|
[currentArray addObject: token];
|
||||||
|
// NSLog (@"added token: %@", token);
|
||||||
|
firstChar = (NSUInteger) -1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (currentArray && (firstChar == (NSUInteger) -1))
|
||||||
|
firstChar = count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free (characters);
|
||||||
|
|
||||||
|
return topArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline id
|
||||||
|
schemaValue (NSArray *tokens, NSString *key)
|
||||||
|
{
|
||||||
|
NSUInteger idx;
|
||||||
|
id value;
|
||||||
|
|
||||||
|
idx = [tokens indexOfObject: key];
|
||||||
|
if (idx != NSNotFound)
|
||||||
|
value = [tokens objectAtIndex: (idx + 1)];
|
||||||
|
else
|
||||||
|
value = nil;
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
static NSMutableDictionary *
|
||||||
|
parseSchema (NSString *schema)
|
||||||
|
{
|
||||||
|
NSArray *tokens;
|
||||||
|
NSMutableDictionary *schemaDict;
|
||||||
|
NSMutableArray *fields;
|
||||||
|
id value;
|
||||||
|
|
||||||
|
schemaDict = [NSMutableDictionary dictionaryWithCapacity: 6];
|
||||||
|
tokens = schemaTokens (schema);
|
||||||
|
// [schemaDict setObject: [tokens objectAtIndex: 0]
|
||||||
|
// forKey: @"oid"];
|
||||||
|
value = schemaValue (tokens, @"NAME");
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
/* sometimes, objectClasses can have two names */
|
||||||
|
if ([value isKindOfClass: [NSString class]])
|
||||||
|
value = [NSArray arrayWithObject: value];
|
||||||
|
[schemaDict setObject: value forKey: @"names"];
|
||||||
|
}
|
||||||
|
|
||||||
|
value = schemaValue (tokens, @"SUP");
|
||||||
|
if (value)
|
||||||
|
[schemaDict setObject: value forKey: @"sup"];
|
||||||
|
|
||||||
|
fields = [NSMutableArray new];
|
||||||
|
[schemaDict setObject: fields forKey: @"fields"];
|
||||||
|
[fields release];
|
||||||
|
value = schemaValue (tokens, @"MUST");
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
if ([value isKindOfClass: [NSArray class]])
|
||||||
|
[fields addObjectsFromArray: value];
|
||||||
|
else
|
||||||
|
[fields addObject: value];
|
||||||
|
}
|
||||||
|
value = schemaValue (tokens, @"MAY");
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
if ([value isKindOfClass: [NSArray class]])
|
||||||
|
[fields addObjectsFromArray: value];
|
||||||
|
else
|
||||||
|
[fields addObject: value];
|
||||||
|
}
|
||||||
|
|
||||||
|
return schemaDict;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
fillSchemaFromEntry (NSMutableDictionary *schema, NGLdapEntry *entry)
|
||||||
|
{
|
||||||
|
NSEnumerator *strings;
|
||||||
|
NGLdapAttribute *attr;
|
||||||
|
NSMutableDictionary *schemaDict;
|
||||||
|
NSArray *names;
|
||||||
|
NSString *string, *name;
|
||||||
|
NSUInteger count, max;
|
||||||
|
|
||||||
|
attr = [entry attributeWithName: @"objectclasses"];
|
||||||
|
strings = [attr stringValueEnumerator];
|
||||||
|
while ((string = [strings nextObject]))
|
||||||
|
{
|
||||||
|
schemaDict = parseSchema (string);
|
||||||
|
names = [schemaDict objectForKey: @"names"];
|
||||||
|
max = [names count];
|
||||||
|
for (count = 0; count < max; count++)
|
||||||
|
{
|
||||||
|
name = [[names objectAtIndex: count] lowercaseString];
|
||||||
|
if ([name hasPrefix: @"'"] && [name hasSuffix: @"'"])
|
||||||
|
name
|
||||||
|
= [name substringWithRange: NSMakeRange (1, [name length] - 2)];
|
||||||
|
[schema setObject: schemaDict forKey: name];
|
||||||
|
}
|
||||||
|
/* the list of names is no longer required from the schema itself */
|
||||||
|
[schemaDict removeObjectForKey: @"names"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) readSchemaFromConnection: (NGLdapConnection *) conn
|
||||||
|
{
|
||||||
|
NSEnumerator *entries;
|
||||||
|
NGLdapEntry *entry;
|
||||||
|
NSString *dn;
|
||||||
|
|
||||||
|
ASSIGN (schema, [NSMutableDictionary new]);
|
||||||
|
[schema release];
|
||||||
|
|
||||||
|
entries = [conn baseSearchAtBaseDN: @""
|
||||||
|
qualifier: allOCQualifier
|
||||||
|
attributes: [NSArray arrayWithObject: @"subschemaSubentry"]];
|
||||||
|
entry = [entries nextObject];
|
||||||
|
if (entry)
|
||||||
|
{
|
||||||
|
dn = [[entry attributeWithName: @"subschemaSubentry"]
|
||||||
|
stringValueAtIndex: 0];
|
||||||
|
if (dn)
|
||||||
|
{
|
||||||
|
entries = [conn baseSearchAtBaseDN: dn
|
||||||
|
qualifier: allOCQualifier
|
||||||
|
attributes: [NSArray arrayWithObject: @"objectclasses"]];
|
||||||
|
entry = [entries nextObject];
|
||||||
|
if (entry)
|
||||||
|
fillSchemaFromEntry (schema, entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
fillFieldsForClass (NSMutableDictionary *schema, NSString *schemaName,
|
||||||
|
NSMutableArray *fields)
|
||||||
|
{
|
||||||
|
NSDictionary *schemaDict;
|
||||||
|
NSString *sup;
|
||||||
|
NSArray *schemaFields;
|
||||||
|
|
||||||
|
schemaDict = [schema objectForKey: [schemaName lowercaseString]];
|
||||||
|
if (schemaDict)
|
||||||
|
{
|
||||||
|
schemaFields = [schemaDict objectForKey: @"fields"];
|
||||||
|
if ([schemaFields count] > 0)
|
||||||
|
[fields addObjectsFromArray: schemaFields];
|
||||||
|
sup = [schemaDict objectForKey: @"sup"];
|
||||||
|
if ([sup length] > 0)
|
||||||
|
fillFieldsForClass (schema, sup, fields);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSArray *) fieldsForClass: (NSString *) className
|
||||||
|
{
|
||||||
|
NSMutableArray *fields;
|
||||||
|
|
||||||
|
fields = [NSMutableArray arrayWithCapacity: 128];
|
||||||
|
fillFieldsForClass (schema, className, fields);
|
||||||
|
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSArray *) fieldsForClasses: (NSArray *) classNames
|
||||||
|
{
|
||||||
|
NSMutableDictionary *fieldHash;
|
||||||
|
NSNumber *yesValue;
|
||||||
|
NSString *name;
|
||||||
|
NSUInteger count, max;
|
||||||
|
|
||||||
|
yesValue = [NSNumber numberWithBool: YES];
|
||||||
|
|
||||||
|
fieldHash = [NSMutableDictionary dictionary];
|
||||||
|
max = [classNames count];
|
||||||
|
for (count = 0; count < max; count++)
|
||||||
|
{
|
||||||
|
name = [classNames objectAtIndex: count];
|
||||||
|
[fieldHash setObject: yesValue forKeys: [self fieldsForClass: name]];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [fieldHash allKeys];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
|
@ -35,8 +35,7 @@
|
||||||
- (NSString *) jsonRepresentation;
|
- (NSString *) jsonRepresentation;
|
||||||
- (NSString *) keysWithFormat: (NSString *) keyFormat;
|
- (NSString *) keysWithFormat: (NSString *) keyFormat;
|
||||||
|
|
||||||
// LDIF methods
|
- (NSComparisonResult) caseInsensitiveDisplayNameCompare: (NSDictionary *) theDictionary;
|
||||||
- (NSString *) userRecordAsLDIFEntry;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -26,12 +26,8 @@
|
||||||
#import <Foundation/NSException.h>
|
#import <Foundation/NSException.h>
|
||||||
#import <Foundation/NSNull.h>
|
#import <Foundation/NSNull.h>
|
||||||
#import <Foundation/NSString.h>
|
#import <Foundation/NSString.h>
|
||||||
#import <Foundation/NSCharacterSet.h>
|
|
||||||
|
|
||||||
#import <NGExtensions/NGBase64Coding.h>
|
|
||||||
|
|
||||||
#import "NSArray+Utilities.h"
|
#import "NSArray+Utilities.h"
|
||||||
#import "NSObject+Utilities.h"
|
|
||||||
#import "NSString+Utilities.h"
|
#import "NSString+Utilities.h"
|
||||||
|
|
||||||
#import "NSDictionary+Utilities.h"
|
#import "NSDictionary+Utilities.h"
|
||||||
|
@ -109,84 +105,6 @@
|
||||||
return [[self objectForKey: @"cn"] caseInsensitiveCompare: [theDictionary objectForKey: @"cn"]];
|
return [[self objectForKey: @"cn"] caseInsensitiveCompare: [theDictionary objectForKey: @"cn"]];
|
||||||
}
|
}
|
||||||
|
|
||||||
// LDIF Methods
|
|
||||||
#warning We might want to support more than just strings here
|
|
||||||
- (void) _appendLDIFKey: (NSString *) key
|
|
||||||
value: (NSString *) value
|
|
||||||
toString: (NSMutableString *) ldifString
|
|
||||||
{
|
|
||||||
if ([value isKindOfClass: [NSString class]])
|
|
||||||
{
|
|
||||||
if ([value _isLDIFSafe])
|
|
||||||
[ldifString appendFormat: @"%@: %@\n", key, value];
|
|
||||||
else
|
|
||||||
[ldifString appendFormat: @"%@:: %@\n",
|
|
||||||
key, [value stringByEncodingBase64]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) _appendLDIFKey: (NSString *) key
|
|
||||||
toString: (NSMutableString *) ldifString
|
|
||||||
{
|
|
||||||
id value;
|
|
||||||
int count, max;
|
|
||||||
|
|
||||||
value = [self objectForKey: key];
|
|
||||||
if ([value isKindOfClass: [NSArray class]])
|
|
||||||
{
|
|
||||||
max = [value count];
|
|
||||||
for (count = 0; count < max; count++)
|
|
||||||
[self _appendLDIFKey: key value: [value objectAtIndex: count]
|
|
||||||
toString: ldifString];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
[self _appendLDIFKey: key value: [self objectForKey: key]
|
|
||||||
toString: ldifString];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) _appendObjectClassesToString: (NSMutableString *) ldifString
|
|
||||||
{
|
|
||||||
NSEnumerator *classes;
|
|
||||||
NSString *currentClass;
|
|
||||||
|
|
||||||
classes = [[self objectForKey: @"objectClasses"] objectEnumerator];
|
|
||||||
while ((currentClass = [classes nextObject]))
|
|
||||||
[self _appendLDIFKey: @"objectClass" value: currentClass
|
|
||||||
toString: ldifString];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSString *) userRecordAsLDIFEntry
|
|
||||||
{
|
|
||||||
NSMutableString *ldifString;
|
|
||||||
NSEnumerator *keys;
|
|
||||||
NSString *currentKey;
|
|
||||||
|
|
||||||
// {CalendarAccess = YES; MailAccess = YES; c_cn = "Wolfgang Sourdeau"; c_emails = ("wolfgang@test.com"); c_name = "wolfgang@test.com"; c_uid = "wolfgang@test.com"; cn = "wolfgang@test.com"; displayName = "Wolfgang Sourdeau"; dn = "cn=wolfgang@test.com,ou=evariste,o=inverse.ca"; givenName = Wolfgang; mail = "wolfgang@test.com"; objectClass = organizationalPerson; sn = Sourdeau; }
|
|
||||||
|
|
||||||
ldifString = [NSMutableString string];
|
|
||||||
[self _appendLDIFKey: @"dn" toString: ldifString];
|
|
||||||
[self _appendObjectClassesToString: ldifString];
|
|
||||||
|
|
||||||
keys = [[self allKeys] objectEnumerator];
|
|
||||||
while ((currentKey = [keys nextObject]))
|
|
||||||
{
|
|
||||||
if (!([currentKey isEqualToString: @"CalendarAccess"]
|
|
||||||
|| [currentKey isEqualToString: @"MailAccess"]
|
|
||||||
|| [currentKey isEqualToString: @"ContactAccess"]
|
|
||||||
|| [currentKey hasPrefix: @"objectClass"]
|
|
||||||
|| [currentKey hasPrefix: @"c_"]
|
|
||||||
|| [currentKey isEqualToString: @"dn"]
|
|
||||||
|| [currentKey isEqualToString: @"isGroup"]
|
|
||||||
|| [currentKey isEqualToString: @"isResource"]
|
|
||||||
|| [currentKey isEqualToString: @"numberOfSimultaneousBookings"]
|
|
||||||
|| [currentKey isEqualToString: @"canAuthenticate"]))
|
|
||||||
[self _appendLDIFKey: currentKey toString: ldifString];
|
|
||||||
}
|
|
||||||
|
|
||||||
return ldifString;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation NSMutableDictionary (SOGoDictionaryUtilities)
|
@implementation NSMutableDictionary (SOGoDictionaryUtilities)
|
||||||
|
|
|
@ -62,8 +62,6 @@
|
||||||
|
|
||||||
- (int) timeValue;
|
- (int) timeValue;
|
||||||
|
|
||||||
- (BOOL) _isLDIFSafe;
|
|
||||||
|
|
||||||
- (BOOL) isJSONString;
|
- (BOOL) isJSONString;
|
||||||
|
|
||||||
- (id) objectFromJSONString;
|
- (id) objectFromJSONString;
|
||||||
|
|
|
@ -486,44 +486,6 @@ static int cssEscapingCount;
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
static NSMutableCharacterSet *safeLDIFChars = nil;
|
|
||||||
static NSMutableCharacterSet *safeLDIFStartChars = nil;
|
|
||||||
|
|
||||||
- (void) _initSafeLDIFChars
|
|
||||||
{
|
|
||||||
safeLDIFChars = [NSMutableCharacterSet new];
|
|
||||||
[safeLDIFChars addCharactersInRange: NSMakeRange (0x01, 9)];
|
|
||||||
[safeLDIFChars addCharactersInRange: NSMakeRange (0x0b, 2)];
|
|
||||||
[safeLDIFChars addCharactersInRange: NSMakeRange (0x0e, 114)];
|
|
||||||
|
|
||||||
safeLDIFStartChars = [safeLDIFChars mutableCopy];
|
|
||||||
[safeLDIFStartChars removeCharactersInString: @" :<"];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL) _isLDIFSafe
|
|
||||||
{
|
|
||||||
int count, max;
|
|
||||||
BOOL rc;
|
|
||||||
|
|
||||||
if (!safeLDIFChars)
|
|
||||||
[self _initSafeLDIFChars];
|
|
||||||
|
|
||||||
rc = YES;
|
|
||||||
|
|
||||||
max = [self length];
|
|
||||||
if (max > 0)
|
|
||||||
{
|
|
||||||
if ([safeLDIFStartChars characterIsMember: [self characterAtIndex: 0]])
|
|
||||||
for (count = 1; rc && count < max; count++)
|
|
||||||
rc = [safeLDIFChars
|
|
||||||
characterIsMember: [self characterAtIndex: count]];
|
|
||||||
else
|
|
||||||
rc = NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL) isJSONString
|
- (BOOL) isJSONString
|
||||||
{
|
{
|
||||||
NSDictionary *jsonData;
|
NSDictionary *jsonData;
|
||||||
|
|
|
@ -28,9 +28,10 @@
|
||||||
#import "SOGoConstants.h"
|
#import "SOGoConstants.h"
|
||||||
|
|
||||||
@class NSDictionary;
|
@class NSDictionary;
|
||||||
|
@class NSException;
|
||||||
@class NSString;
|
@class NSString;
|
||||||
|
|
||||||
@protocol SOGoSource
|
@protocol SOGoSource <NSObject>
|
||||||
|
|
||||||
+ (id) sourceFromUDSource: (NSDictionary *) udSource
|
+ (id) sourceFromUDSource: (NSDictionary *) udSource
|
||||||
inDomain: (NSString *) domain;
|
inDomain: (NSString *) domain;
|
||||||
|
@ -57,6 +58,12 @@
|
||||||
- (NSArray *) allEntryIDs;
|
- (NSArray *) allEntryIDs;
|
||||||
- (NSArray *) fetchContactsMatching: (NSString *) filter;
|
- (NSArray *) fetchContactsMatching: (NSString *) filter;
|
||||||
- (NSString *) sourceID;
|
- (NSString *) sourceID;
|
||||||
|
- (NSArray *) modifiers;
|
||||||
|
|
||||||
|
- (NSException *) addContactEntry: (NSDictionary *) roLdifRecord
|
||||||
|
withID: (NSString *) aId;
|
||||||
|
- (NSException *) updateContactEntry: (NSDictionary *) ldifRecord;
|
||||||
|
- (NSException *) removeContactEntryWithID: (NSString *) aId;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import <Foundation/NSArray.h>
|
#import <Foundation/NSArray.h>
|
||||||
#import <Foundation/NSObject.h>
|
|
||||||
#import <Foundation/NSDictionary.h>
|
#import <Foundation/NSDictionary.h>
|
||||||
|
#import <Foundation/NSException.h>
|
||||||
|
#import <Foundation/NSObject.h>
|
||||||
#import <Foundation/NSString.h>
|
#import <Foundation/NSString.h>
|
||||||
#import <Foundation/NSValue.h>
|
#import <Foundation/NSValue.h>
|
||||||
#import <Foundation/NSURL.h>
|
#import <Foundation/NSURL.h>
|
||||||
|
@ -379,6 +380,7 @@
|
||||||
{
|
{
|
||||||
NSMutableDictionary *response;
|
NSMutableDictionary *response;
|
||||||
NSMutableArray *qualifiers;
|
NSMutableArray *qualifiers;
|
||||||
|
NSArray *fieldNames;
|
||||||
EOAdaptorChannel *channel;
|
EOAdaptorChannel *channel;
|
||||||
EOQualifier *loginQualifier, *qualifier;
|
EOQualifier *loginQualifier, *qualifier;
|
||||||
GCSChannelManager *cm;
|
GCSChannelManager *cm;
|
||||||
|
@ -463,6 +465,16 @@
|
||||||
[response autorelease];
|
[response autorelease];
|
||||||
[channel cancelFetch];
|
[channel cancelFetch];
|
||||||
|
|
||||||
|
/* Convert all c_ fields to obtain their ldif equivalent */
|
||||||
|
fieldNames = [response allKeys];
|
||||||
|
for (i = 0; i < [fieldNames count]; i++)
|
||||||
|
{
|
||||||
|
field = [fieldNames objectAtIndex: i];
|
||||||
|
if ([field hasPrefix: @"c_"])
|
||||||
|
[response setObject: [response objectForKey: field]
|
||||||
|
forKey: [field substringFromIndex: 2]];
|
||||||
|
}
|
||||||
|
|
||||||
// We have to do this here since we do not manage modules
|
// We have to do this here since we do not manage modules
|
||||||
// constraints right now over a SQL backend.
|
// constraints right now over a SQL backend.
|
||||||
[response setObject: [NSNumber numberWithBool: YES] forKey: @"CalendarAccess"];
|
[response setObject: [NSNumber numberWithBool: YES] forKey: @"CalendarAccess"];
|
||||||
|
@ -684,4 +696,49 @@
|
||||||
return _sourceID;
|
return _sourceID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSArray *) modifiers
|
||||||
|
{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSException *) addContactEntry: (NSDictionary *) roLdifRecord
|
||||||
|
withID: (NSString *) aId
|
||||||
|
{
|
||||||
|
NSString *reason;
|
||||||
|
|
||||||
|
reason = [NSString stringWithFormat: @"method '%@' is not available"
|
||||||
|
@" for class '%@'", NSStringFromSelector (_cmd),
|
||||||
|
NSStringFromClass (isa)];
|
||||||
|
|
||||||
|
return [NSException exceptionWithName: @"SQLSourceIOException"
|
||||||
|
reason: reason
|
||||||
|
userInfo: nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSException *) updateContactEntry: (NSDictionary *) roLdifRecord
|
||||||
|
{
|
||||||
|
NSString *reason;
|
||||||
|
|
||||||
|
reason = [NSString stringWithFormat: @"method '%@' is not available"
|
||||||
|
@" for class '%@'", NSStringFromSelector (_cmd),
|
||||||
|
NSStringFromClass (isa)];
|
||||||
|
|
||||||
|
return [NSException exceptionWithName: @"SQLSourceIOException"
|
||||||
|
reason: reason
|
||||||
|
userInfo: nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSException *) removeContactEntryWithID: (NSString *) aId
|
||||||
|
{
|
||||||
|
NSString *reason;
|
||||||
|
|
||||||
|
reason = [NSString stringWithFormat: @"method '%@' is not available"
|
||||||
|
@" for class '%@'", NSStringFromSelector (_cmd),
|
||||||
|
NSStringFromClass (isa)];
|
||||||
|
|
||||||
|
return [NSException exceptionWithName: @"SQLSourceIOException"
|
||||||
|
reason: reason
|
||||||
|
userInfo: nil];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -30,6 +30,7 @@ import sys
|
||||||
|
|
||||||
xmlns_dav = "DAV:"
|
xmlns_dav = "DAV:"
|
||||||
xmlns_caldav = "urn:ietf:params:xml:ns:caldav"
|
xmlns_caldav = "urn:ietf:params:xml:ns:caldav"
|
||||||
|
xmlns_carddav = "urn:ietf:params:xml:ns:carddav"
|
||||||
xmlns_inversedav = "urn:inverse:params:xml:ns:inverse-dav"
|
xmlns_inversedav = "urn:inverse:params:xml:ns:inverse-dav"
|
||||||
|
|
||||||
url_re = None
|
url_re = None
|
||||||
|
@ -401,6 +402,25 @@ class CalDAVCalendarQuery(WebDAVREPORT):
|
||||||
filter_node.append(cal_filter_node)
|
filter_node.append(cal_filter_node)
|
||||||
self.top_node.append(filter_node)
|
self.top_node.append(filter_node)
|
||||||
|
|
||||||
|
class CardDAVAddressBookQuery(WebDAVREPORT):
|
||||||
|
def __init__(self, url, properties, searchProperty = None, searchValue = None):
|
||||||
|
WebDAVQuery.__init__(self, url)
|
||||||
|
query_tag = self.ns_mgr.register("addressbook-query", xmlns_carddav)
|
||||||
|
ns_key = self.ns_mgr.xmlns[xmlns_carddav]
|
||||||
|
self.top_node = _WD_XMLTreeElement(query_tag)
|
||||||
|
if properties is not None and len(properties) > 0:
|
||||||
|
self._initProperties(properties)
|
||||||
|
|
||||||
|
if searchProperty is not None:
|
||||||
|
filter_node = _WD_XMLTreeElement("%s:filter" % ns_key)
|
||||||
|
self.top_node.append(filter_node)
|
||||||
|
propfilter_node = _WD_XMLTreeElement("%s:prop-filter" % ns_key, { "name": searchProperty })
|
||||||
|
filter_node.append(propfilter_node)
|
||||||
|
match_node = _WD_XMLTreeElement("%s:text-match" % ns_key,
|
||||||
|
{ "collation": "i;unicasemap", "match-type": "starts-with" })
|
||||||
|
propfilter_node.append(match_node)
|
||||||
|
match_node.appendSubtree(None, searchValue)
|
||||||
|
|
||||||
class MailDAVMailQuery(WebDAVREPORT):
|
class MailDAVMailQuery(WebDAVREPORT):
|
||||||
def __init__(self, url, properties, filters = None,
|
def __init__(self, url, properties, filters = None,
|
||||||
sort = None, ascending = True):
|
sort = None, ascending = True):
|
||||||
|
|
|
@ -4,6 +4,7 @@ include ../config.make
|
||||||
include $(GNUSTEP_MAKEFILES)/common.make
|
include $(GNUSTEP_MAKEFILES)/common.make
|
||||||
include ../Version
|
include ../Version
|
||||||
|
|
||||||
|
###
|
||||||
SOGO_TOOL = sogo-tool
|
SOGO_TOOL = sogo-tool
|
||||||
$(SOGO_TOOL)_INSTALL_DIR = $(SOGO_ADMIN_TOOLS)
|
$(SOGO_TOOL)_INSTALL_DIR = $(SOGO_ADMIN_TOOLS)
|
||||||
$(SOGO_TOOL)_OBJC_FILES += \
|
$(SOGO_TOOL)_OBJC_FILES += \
|
||||||
|
@ -18,7 +19,9 @@ $(SOGO_TOOL)_OBJC_FILES += \
|
||||||
SOGoToolRenameUser.m \
|
SOGoToolRenameUser.m \
|
||||||
SOGoToolUserPreferences.m \
|
SOGoToolUserPreferences.m \
|
||||||
SOGoToolExpireAutoReply.m
|
SOGoToolExpireAutoReply.m
|
||||||
|
TOOL_NAME += $(SOGO_TOOL)
|
||||||
|
|
||||||
|
###
|
||||||
SOGO_SLAPD_SOCKD = sogo-slapd-sockd
|
SOGO_SLAPD_SOCKD = sogo-slapd-sockd
|
||||||
$(SOGO_SLAPD_SOCKD)_INSTALL_DIR = $(SOGO_ADMIN_TOOLS)
|
$(SOGO_SLAPD_SOCKD)_INSTALL_DIR = $(SOGO_ADMIN_TOOLS)
|
||||||
$(SOGO_SLAPD_SOCKD)_OBJC_FILES += \
|
$(SOGO_SLAPD_SOCKD)_OBJC_FILES += \
|
||||||
|
@ -27,15 +30,17 @@ $(SOGO_SLAPD_SOCKD)_OBJC_FILES += \
|
||||||
SOGoSockD.m \
|
SOGoSockD.m \
|
||||||
SOGoSockDScanner.m \
|
SOGoSockDScanner.m \
|
||||||
SOGoSockDOperation.m \
|
SOGoSockDOperation.m \
|
||||||
|
TOOL_NAME += $(SOGO_SLAPD_SOCKD)
|
||||||
|
|
||||||
|
###
|
||||||
SOGO_EALARMS_NOTIFY = sogo-ealarms-notify
|
SOGO_EALARMS_NOTIFY = sogo-ealarms-notify
|
||||||
$(SOGO_EALARMS_NOTIFY)_INSTALL_DIR = $(SOGO_ADMIN_TOOLS)
|
$(SOGO_EALARMS_NOTIFY)_INSTALL_DIR = $(SOGO_ADMIN_TOOLS)
|
||||||
$(SOGO_EALARMS_NOTIFY)_OBJC_FILES += \
|
$(SOGO_EALARMS_NOTIFY)_OBJC_FILES += \
|
||||||
sogo-ealarms-notify.m \
|
sogo-ealarms-notify.m \
|
||||||
\
|
\
|
||||||
SOGoEAlarmsNotifier.m
|
SOGoEAlarmsNotifier.m
|
||||||
|
TOOL_NAME += $(SOGO_EALARMS_NOTIFY)
|
||||||
|
|
||||||
TOOL_NAME = $(SOGO_TOOL) $(SOGO_SLAPD_SOCKD) $(SOGO_EALARMS_NOTIFY)
|
|
||||||
|
|
||||||
-include GNUmakefile.preamble
|
-include GNUmakefile.preamble
|
||||||
include $(GNUSTEP_MAKEFILES)/tool.make
|
include $(GNUSTEP_MAKEFILES)/tool.make
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#import <NGStreams/NGActiveSocket.h>
|
#import <NGStreams/NGActiveSocket.h>
|
||||||
#import <Contacts/SOGoContactFolder.h>
|
#import <Contacts/SOGoContactFolder.h>
|
||||||
#import <Contacts/SOGoContactFolders.h>
|
#import <Contacts/SOGoContactFolders.h>
|
||||||
|
#import <Contacts/NSString+LDIF.h>
|
||||||
#import <SOGo/SOGoProductLoader.h>
|
#import <SOGo/SOGoProductLoader.h>
|
||||||
#import <SOGo/SOGoUserFolder.h>
|
#import <SOGo/SOGoUserFolder.h>
|
||||||
#import <SOGo/NSDictionary+Utilities.h>
|
#import <SOGo/NSDictionary+Utilities.h>
|
||||||
|
@ -120,13 +121,13 @@ Class SOGoContactSourceFolderKlass = Nil;
|
||||||
value = [entry objectForKey: key];
|
value = [entry objectForKey: key];
|
||||||
if ([value isKindOfClass: [NSString class]] && [value length] > 0)
|
if ([value isKindOfClass: [NSString class]] && [value length] > 0)
|
||||||
{
|
{
|
||||||
if ([value _isLDIFSafe])
|
if ([value mustEncodeLDIFValue])
|
||||||
[result appendFormat: @"%@: %@\n",
|
|
||||||
[key substringFromIndex: 2], value];
|
|
||||||
else
|
|
||||||
[result appendFormat: @"%@:: %@\n",
|
[result appendFormat: @"%@:: %@\n",
|
||||||
[key substringFromIndex: 2],
|
[key substringFromIndex: 2],
|
||||||
[value stringByEncodingBase64]];
|
[value stringByEncodingBase64]];
|
||||||
|
else
|
||||||
|
[result appendFormat: @"%@: %@\n",
|
||||||
|
[key substringFromIndex: 2], value];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[result appendString: @"\n"];
|
[result appendString: @"\n"];
|
||||||
|
|
|
@ -37,11 +37,12 @@
|
||||||
#import <SOGo/SOGoUserManager.h>
|
#import <SOGo/SOGoUserManager.h>
|
||||||
#import <SOGo/LDAPSource.h>
|
#import <SOGo/LDAPSource.h>
|
||||||
#import <SOGo/NSArray+Utilities.h>
|
#import <SOGo/NSArray+Utilities.h>
|
||||||
#import <SOGo/NSDictionary+Utilities.h>
|
#import <SOGo/SOGoProductLoader.h>
|
||||||
#import <SOGo/SOGoUser.h>
|
#import <SOGo/SOGoUser.h>
|
||||||
#import <SOGo/SOGoUserDefaults.h>
|
#import <SOGo/SOGoUserDefaults.h>
|
||||||
#import <SOGo/SOGoUserProfile.h>
|
#import <SOGo/SOGoUserProfile.h>
|
||||||
#import <SOGo/SOGoUserSettings.h>
|
#import <SOGo/SOGoUserSettings.h>
|
||||||
|
#import <Contacts/NSDictionary+LDIF.h>
|
||||||
|
|
||||||
#import "SOGoTool.h"
|
#import "SOGoTool.h"
|
||||||
|
|
||||||
|
@ -61,6 +62,12 @@
|
||||||
|
|
||||||
@implementation SOGoToolBackup
|
@implementation SOGoToolBackup
|
||||||
|
|
||||||
|
+ (void) initialize
|
||||||
|
{
|
||||||
|
[[SOGoProductLoader productLoader]
|
||||||
|
loadProducts: [NSArray arrayWithObject: @"Contacts.SOGo"]];
|
||||||
|
}
|
||||||
|
|
||||||
+ (NSString *) command
|
+ (NSString *) command
|
||||||
{
|
{
|
||||||
return @"backup";
|
return @"backup";
|
||||||
|
@ -376,7 +383,7 @@
|
||||||
userEntry = [currentSource lookupContactEntry: uid];
|
userEntry = [currentSource lookupContactEntry: uid];
|
||||||
if (userEntry)
|
if (userEntry)
|
||||||
{
|
{
|
||||||
[userRecord setObject: [userEntry userRecordAsLDIFEntry]
|
[userRecord setObject: [userEntry ldifRecordAsString]
|
||||||
forKey: @"ldif_record"];
|
forKey: @"ldif_record"];
|
||||||
done = YES;
|
done = YES;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,8 @@
|
||||||
|
|
||||||
categories = [[self categories] mutableCopy];
|
categories = [[self categories] mutableCopy];
|
||||||
[categories autorelease];
|
[categories autorelease];
|
||||||
|
if (!categories)
|
||||||
|
categories = [NSMutableArray array];
|
||||||
if (set)
|
if (set)
|
||||||
{
|
{
|
||||||
if (![categories containsObject: category])
|
if (![categories containsObject: category])
|
||||||
|
|
|
@ -27,22 +27,18 @@
|
||||||
@class NSString;
|
@class NSString;
|
||||||
@class NSMutableDictionary;
|
@class NSMutableDictionary;
|
||||||
|
|
||||||
@class NGVCard;
|
|
||||||
|
|
||||||
@class SOGoContactFolder;
|
@class SOGoContactFolder;
|
||||||
|
|
||||||
@interface UIxContactEditor : UIxComponent
|
@interface UIxContactEditor : UIxComponent
|
||||||
{
|
{
|
||||||
id addressBookItem;
|
id addressBookItem;
|
||||||
NSString *preferredEmail;
|
|
||||||
NSString *item;
|
NSString *item;
|
||||||
NGVCard *card;
|
NSMutableDictionary *ldifRecord; /* contains the values for editing */
|
||||||
NSMutableArray *photosURL;
|
|
||||||
NSMutableDictionary *snapshot; /* contains the values for editing */
|
|
||||||
SOGoContactFolder *componentAddressBook;
|
SOGoContactFolder *componentAddressBook;
|
||||||
NSArray *contactCategories;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSMutableDictionary *) ldifRecord;
|
||||||
|
|
||||||
- (void) setAddressBookItem: (id) _item;
|
- (void) setAddressBookItem: (id) _item;
|
||||||
- (id) addressBookItem;
|
- (id) addressBookItem;
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,6 @@
|
||||||
#import <NGExtensions/NSNull+misc.h>
|
#import <NGExtensions/NSNull+misc.h>
|
||||||
|
|
||||||
#import <NGCards/NGVCard.h>
|
#import <NGCards/NGVCard.h>
|
||||||
#import <NGCards/NGVCardPhoto.h>
|
|
||||||
#import <NGCards/NSArray+NGCards.h>
|
|
||||||
|
|
||||||
#import <SOGo/NSArray+Utilities.h>
|
#import <SOGo/NSArray+Utilities.h>
|
||||||
#import <SOGo/NSString+Utilities.h>
|
#import <SOGo/NSString+Utilities.h>
|
||||||
|
@ -50,20 +48,23 @@
|
||||||
|
|
||||||
#import "UIxContactEditor.h"
|
#import "UIxContactEditor.h"
|
||||||
|
|
||||||
|
static Class SOGoContactGCSEntryK = Nil;
|
||||||
|
|
||||||
@implementation UIxContactEditor
|
@implementation UIxContactEditor
|
||||||
|
|
||||||
|
+ (void) initialize
|
||||||
|
{
|
||||||
|
SOGoContactGCSEntryK = [SOGoContactGCSEntry class];
|
||||||
|
}
|
||||||
|
|
||||||
- (id) init
|
- (id) init
|
||||||
{
|
{
|
||||||
if ((self = [super init]))
|
if ((self = [super init]))
|
||||||
{
|
{
|
||||||
snapshot = [[NSMutableDictionary alloc] initWithCapacity: 16];
|
ldifRecord = nil;
|
||||||
preferredEmail = nil;
|
|
||||||
photosURL = nil;
|
|
||||||
addressBookItem = nil;
|
addressBookItem = nil;
|
||||||
item = nil;
|
item = nil;
|
||||||
card = nil;
|
|
||||||
componentAddressBook = nil;
|
componentAddressBook = nil;
|
||||||
contactCategories = nil;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
@ -71,18 +72,35 @@
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
[snapshot release];
|
[ldifRecord release];
|
||||||
[preferredEmail release];
|
|
||||||
[photosURL release];
|
|
||||||
[addressBookItem release];
|
[addressBookItem release];
|
||||||
[item release];
|
[item release];
|
||||||
[componentAddressBook release];
|
[componentAddressBook release];
|
||||||
[contactCategories release];
|
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* accessors */
|
/* accessors */
|
||||||
|
|
||||||
|
- (NSMutableDictionary *) ldifRecord
|
||||||
|
{
|
||||||
|
NSDictionary *clientLDIFRecord;
|
||||||
|
NSString *queryValue;
|
||||||
|
|
||||||
|
if (!ldifRecord)
|
||||||
|
{
|
||||||
|
clientLDIFRecord = [[self clientObject] ldifRecord];
|
||||||
|
ldifRecord = [clientLDIFRecord mutableCopy];
|
||||||
|
queryValue = [self queryParameterForKey: @"contactEmail"];
|
||||||
|
if ([queryValue length] > 0)
|
||||||
|
[ldifRecord setObject: queryValue forKey: @"mail"];
|
||||||
|
queryValue = [self queryParameterForKey: @"contactFN"];
|
||||||
|
if ([queryValue length] > 0)
|
||||||
|
[ldifRecord setObject: queryValue forKey: @"displayname"];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ldifRecord;
|
||||||
|
}
|
||||||
|
|
||||||
- (void) setAddressBookItem: (id) _item
|
- (void) setAddressBookItem: (id) _item
|
||||||
{
|
{
|
||||||
ASSIGN (addressBookItem, _item);
|
ASSIGN (addressBookItem, _item);
|
||||||
|
@ -130,27 +148,6 @@
|
||||||
|
|
||||||
/* load/store content format */
|
/* load/store content format */
|
||||||
|
|
||||||
// - (void) _fixupSnapshot
|
|
||||||
// {
|
|
||||||
// NSString *currentKey, *currentString;
|
|
||||||
// NSMutableString *newString;
|
|
||||||
// NSArray *keys;
|
|
||||||
// unsigned int count, max;
|
|
||||||
|
|
||||||
// keys = [snapshot allKeys];
|
|
||||||
// max = [keys count];
|
|
||||||
// for (count = 0; count < max; count++)
|
|
||||||
// {
|
|
||||||
// currentKey = [keys objectAtIndex: count];
|
|
||||||
// currentString = [snapshot objectForKey: currentKey];
|
|
||||||
// newString = [currentString mutableCopy];
|
|
||||||
// [newString autorelease];
|
|
||||||
// [newString replaceString: @";" withString: @"\\;"];
|
|
||||||
// if (![newString isEqualToString: currentString])
|
|
||||||
// [snapshot setObject: newString forKey: currentKey];
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
/* helper */
|
/* helper */
|
||||||
|
|
||||||
- (NSString *) _completeURIForMethod: (NSString *) _method
|
- (NSString *) _completeURIForMethod: (NSString *) _method
|
||||||
|
@ -179,12 +176,7 @@
|
||||||
|
|
||||||
- (BOOL) isNew
|
- (BOOL) isNew
|
||||||
{
|
{
|
||||||
id co;
|
return ([[self clientObject] isNew]);
|
||||||
|
|
||||||
co = [self clientObject];
|
|
||||||
|
|
||||||
return ([co isKindOfClass: [SOGoContentObject class]]
|
|
||||||
&& [co isNew]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray *) addressBooksList
|
- (NSArray *) addressBooksList
|
||||||
|
@ -205,10 +197,9 @@
|
||||||
while (currentFolder)
|
while (currentFolder)
|
||||||
{
|
{
|
||||||
if ([currentFolder isEqual: folder] ||
|
if ([currentFolder isEqual: folder] ||
|
||||||
([currentFolder isKindOfClass: [SOGoContactGCSFolder class]] &&
|
|
||||||
![sm validatePermission: SoPerm_AddDocumentsImagesAndFiles
|
![sm validatePermission: SoPerm_AddDocumentsImagesAndFiles
|
||||||
onObject: currentFolder
|
onObject: currentFolder
|
||||||
inContext: context]))
|
inContext: context])
|
||||||
[addressBooksList addObject: currentFolder];
|
[addressBooksList addObject: currentFolder];
|
||||||
currentFolder = [folders nextObject];
|
currentFolder = [folders nextObject];
|
||||||
}
|
}
|
||||||
|
@ -245,26 +236,30 @@
|
||||||
return fDisplayName;
|
return fDisplayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setContactCategories: (NSString *) jsonCategories
|
- (BOOL) supportCategories
|
||||||
|
{
|
||||||
|
return [[self clientObject] isKindOfClass: SOGoContactGCSEntryK];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setJsonContactCategories: (NSString *) jsonCategories
|
||||||
{
|
{
|
||||||
NSArray *newCategories;
|
NSArray *newCategories;
|
||||||
|
|
||||||
newCategories = [jsonCategories objectFromJSONString];
|
newCategories = [jsonCategories objectFromJSONString];
|
||||||
if ([newCategories isKindOfClass: [NSArray class]])
|
if ([newCategories isKindOfClass: [NSArray class]])
|
||||||
ASSIGN (contactCategories, newCategories);
|
[[self ldifRecord] setObject: newCategories
|
||||||
|
forKey: @"vcardcategories"];
|
||||||
|
else
|
||||||
|
[[self ldifRecord] removeObjectForKey: @"vcardcategories"];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *) contactCategories
|
- (NSString *) jsonContactCategories
|
||||||
{
|
{
|
||||||
NSString *jsonCats;
|
NSArray *categories;
|
||||||
|
|
||||||
if (!contactCategories)
|
categories = [[self ldifRecord] objectForKey: @"vcardcategories"];
|
||||||
ASSIGN (contactCategories, [card categories]);
|
|
||||||
jsonCats = [contactCategories jsonRepresentation];
|
|
||||||
if (!jsonCats)
|
|
||||||
jsonCats = @"[]";
|
|
||||||
|
|
||||||
return jsonCats;
|
return [categories jsonRepresentation];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray *) _languageContactsCategories
|
- (NSArray *) _languageContactsCategories
|
||||||
|
@ -279,11 +274,11 @@
|
||||||
return [categoryLabels trimmedComponents];
|
return [categoryLabels trimmedComponents];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray *) _fetchAndCombineCategoriesList: (NSArray *) contactCats
|
- (NSArray *) _fetchAndCombineCategoriesList
|
||||||
{
|
{
|
||||||
NSString *ownerLogin;
|
NSString *ownerLogin;
|
||||||
SOGoUserDefaults *ud;
|
SOGoUserDefaults *ud;
|
||||||
NSArray *cats, *newCats;
|
NSArray *cats, *newCats, *contactCategories;
|
||||||
|
|
||||||
ownerLogin = [[self clientObject] ownerInContext: context];
|
ownerLogin = [[self clientObject] ownerInContext: context];
|
||||||
ud = [[SOGoUser userWithLogin: ownerLogin] userDefaults];
|
ud = [[SOGoUser userWithLogin: ownerLogin] userDefaults];
|
||||||
|
@ -291,9 +286,10 @@
|
||||||
if (!cats)
|
if (!cats)
|
||||||
cats = [self _languageContactsCategories];
|
cats = [self _languageContactsCategories];
|
||||||
|
|
||||||
if (contactCats)
|
contactCategories = [[self ldifRecord] objectForKey: @"vcardcategories"];
|
||||||
|
if (contactCategories)
|
||||||
{
|
{
|
||||||
newCats = [cats mergedArrayWithArray: contactCats];
|
newCats = [cats mergedArrayWithArray: contactCategories];
|
||||||
if ([newCats count] != [cats count])
|
if ([newCats count] != [cats count])
|
||||||
{
|
{
|
||||||
cats = [newCats sortedArrayUsingSelector:
|
cats = [newCats sortedArrayUsingSelector:
|
||||||
|
@ -311,7 +307,7 @@
|
||||||
NSArray *cats;
|
NSArray *cats;
|
||||||
NSString *list;
|
NSString *list;
|
||||||
|
|
||||||
cats = [self _fetchAndCombineCategoriesList: [card categories]];
|
cats = [self _fetchAndCombineCategoriesList];
|
||||||
list = [cats jsonRepresentation];
|
list = [cats jsonRepresentation];
|
||||||
if (!list)
|
if (!list)
|
||||||
list = @"[]";
|
list = @"[]";
|
||||||
|
@ -328,311 +324,7 @@
|
||||||
|
|
||||||
actionName = [[request requestHandlerPath] lastPathComponent];
|
actionName = [[request requestHandlerPath] lastPathComponent];
|
||||||
|
|
||||||
return ([[self clientObject] isKindOfClass: [SOGoContactGCSEntry class]]
|
return ([actionName hasPrefix: @"save"]);
|
||||||
&& [actionName hasPrefix: @"save"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) _setSnapshotValue: (NSString *) key
|
|
||||||
to: (NSString *) aValue
|
|
||||||
{
|
|
||||||
if (!aValue)
|
|
||||||
aValue = @"";
|
|
||||||
|
|
||||||
[snapshot setObject: aValue forKey: key];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSMutableDictionary *) snapshot
|
|
||||||
{
|
|
||||||
return snapshot;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSString *) _simpleValueForType: (NSString *) aType
|
|
||||||
inArray: (NSArray *) anArray
|
|
||||||
excluding: (NSString *) aTypeToExclude
|
|
||||||
{
|
|
||||||
NSArray *elements;
|
|
||||||
NSString *value;
|
|
||||||
|
|
||||||
elements = [anArray cardElementsWithAttribute: @"type"
|
|
||||||
havingValue: aType];
|
|
||||||
|
|
||||||
value = nil;
|
|
||||||
|
|
||||||
if ([elements count] > 0)
|
|
||||||
{
|
|
||||||
CardElement *ce;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < [elements count]; i++)
|
|
||||||
{
|
|
||||||
ce = [elements objectAtIndex: i];
|
|
||||||
value = [ce flattenedValuesForKey: @""];
|
|
||||||
|
|
||||||
if (!aTypeToExclude)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (![ce hasAttribute: @"type" havingValue: aTypeToExclude])
|
|
||||||
break;
|
|
||||||
|
|
||||||
value = nil;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) _setupEmailFields
|
|
||||||
{
|
|
||||||
NSArray *elements;
|
|
||||||
NSString *workMail, *homeMail, *prefMail, *potential;
|
|
||||||
unsigned int max;
|
|
||||||
|
|
||||||
elements = [card childrenWithTag: @"email"];
|
|
||||||
max = [elements count];
|
|
||||||
workMail = [self _simpleValueForType: @"work"
|
|
||||||
inArray: elements excluding: nil];
|
|
||||||
homeMail = [self _simpleValueForType: @"home"
|
|
||||||
inArray: elements excluding: nil];
|
|
||||||
prefMail = [self _simpleValueForType: @"pref"
|
|
||||||
inArray: elements excluding: nil];
|
|
||||||
|
|
||||||
if (max > 0)
|
|
||||||
{
|
|
||||||
potential = [[elements objectAtIndex: 0] flattenedValuesForKey: @""];
|
|
||||||
if (!workMail)
|
|
||||||
{
|
|
||||||
if (homeMail && homeMail == potential)
|
|
||||||
{
|
|
||||||
if (max > 1)
|
|
||||||
workMail = [[elements objectAtIndex: 1] flattenedValuesForKey: @""];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
workMail = potential;
|
|
||||||
}
|
|
||||||
if (!homeMail && max > 1)
|
|
||||||
{
|
|
||||||
if (workMail && workMail == potential)
|
|
||||||
homeMail = [[elements objectAtIndex: 1] flattenedValuesForKey: @""];
|
|
||||||
else
|
|
||||||
homeMail = potential;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prefMail)
|
|
||||||
{
|
|
||||||
if (prefMail == workMail)
|
|
||||||
preferredEmail = @"work";
|
|
||||||
else if (prefMail == homeMail)
|
|
||||||
preferredEmail = @"home";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[self _setSnapshotValue: @"workMail" to: workMail];
|
|
||||||
[self _setSnapshotValue: @"homeMail" to: homeMail];
|
|
||||||
|
|
||||||
[self _setSnapshotValue: @"mozillaUseHtmlMail"
|
|
||||||
to: [[card uniqueChildWithTag: @"x-mozilla-html"] flattenedValuesForKey: @""]];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) _setupOrgFields
|
|
||||||
{
|
|
||||||
NSMutableArray *orgServices;
|
|
||||||
CardElement *org;
|
|
||||||
NSString *service;
|
|
||||||
NSUInteger count, max;
|
|
||||||
|
|
||||||
org = [card org];
|
|
||||||
[self _setSnapshotValue: @"workCompany"
|
|
||||||
to: [org flattenedValueAtIndex: 0 forKey: @""]];
|
|
||||||
max = [[org valuesForKey: @""] count];
|
|
||||||
if (max > 1)
|
|
||||||
{
|
|
||||||
orgServices = [NSMutableArray arrayWithCapacity: max];
|
|
||||||
for (count = 1; count < max; count++)
|
|
||||||
{
|
|
||||||
service = [org flattenedValueAtIndex: count forKey: @""];
|
|
||||||
if ([service length] > 0)
|
|
||||||
[orgServices addObject: service];
|
|
||||||
}
|
|
||||||
|
|
||||||
[self _setSnapshotValue: @"workService"
|
|
||||||
to: [orgServices componentsJoinedByString: @", "]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSString *) preferredEmail
|
|
||||||
{
|
|
||||||
return preferredEmail;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) setPreferredEmail: (NSString *) aString
|
|
||||||
{
|
|
||||||
preferredEmail = aString;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) _retrieveQueryParameter: (NSString *) queryKey
|
|
||||||
intoSnapshotValue: (NSString *) snapshotKey
|
|
||||||
{
|
|
||||||
NSString *queryValue;
|
|
||||||
|
|
||||||
queryValue = [self queryParameterForKey: queryKey];
|
|
||||||
if (queryValue && [queryValue length] > 0)
|
|
||||||
[self _setSnapshotValue: snapshotKey to: queryValue];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) initSnapshot
|
|
||||||
{
|
|
||||||
NSArray *elements;
|
|
||||||
CardElement *element;
|
|
||||||
|
|
||||||
element = [card n];
|
|
||||||
[self _setSnapshotValue: @"sn"
|
|
||||||
to: [element flattenedValueAtIndex: 0 forKey: @""]];
|
|
||||||
[self _setSnapshotValue: @"givenName"
|
|
||||||
to: [element flattenedValueAtIndex: 1 forKey: @""]];
|
|
||||||
[self _setSnapshotValue: @"fn" to: [card fn]];
|
|
||||||
[self _setSnapshotValue: @"nickname" to: [card nickname]];
|
|
||||||
|
|
||||||
elements = [card childrenWithTag: @"tel"];
|
|
||||||
// We do this (exclude FAX) in order to avoid setting the WORK number as the FAX
|
|
||||||
// one if we do see the FAX field BEFORE the WORK number.
|
|
||||||
[self _setSnapshotValue: @"telephoneNumber"
|
|
||||||
to: [self _simpleValueForType: @"work" inArray: elements excluding: @"fax"]];
|
|
||||||
[self _setSnapshotValue: @"homeTelephoneNumber"
|
|
||||||
to: [self _simpleValueForType: @"home" inArray: elements excluding: @"fax"]];
|
|
||||||
[self _setSnapshotValue: @"mobile"
|
|
||||||
to: [self _simpleValueForType: @"cell" inArray: elements excluding: nil]];
|
|
||||||
[self _setSnapshotValue: @"facsimileTelephoneNumber"
|
|
||||||
to: [self _simpleValueForType: @"fax" inArray: elements excluding: nil]];
|
|
||||||
[self _setSnapshotValue: @"pager"
|
|
||||||
to: [self _simpleValueForType: @"pager" inArray: elements excluding: nil]];
|
|
||||||
|
|
||||||
// If we don't have a "home" and "work" phone number but
|
|
||||||
// we have a "voice" one defined, we set it to the "work" value
|
|
||||||
// This can happen when we have :
|
|
||||||
// VERSION:2.1
|
|
||||||
// N:name;surname;;;;
|
|
||||||
// TEL;VOICE;HOME:
|
|
||||||
// TEL;VOICE;WORK:
|
|
||||||
// TEL;PAGER:
|
|
||||||
// TEL;FAX;WORK:
|
|
||||||
// TEL;CELL:514 123 1234
|
|
||||||
// TEL;VOICE:450 456 6789
|
|
||||||
// ADR;HOME:;;;;;;
|
|
||||||
// ADR;WORK:;;;;;;
|
|
||||||
// ADR:;;;;;;
|
|
||||||
if ([[snapshot objectForKey: @"telephoneNumber"] length] == 0 &&
|
|
||||||
[[snapshot objectForKey: @"homeTelephoneNumber"] length] == 0 &&
|
|
||||||
[elements count] > 0)
|
|
||||||
{
|
|
||||||
[self _setSnapshotValue: @"telephoneNumber"
|
|
||||||
to: [self _simpleValueForType: @"voice" inArray: elements excluding: nil]];
|
|
||||||
}
|
|
||||||
|
|
||||||
[self _setupEmailFields];
|
|
||||||
|
|
||||||
[self _setSnapshotValue: @"screenName"
|
|
||||||
to: [[card uniqueChildWithTag: @"x-aim"] flattenedValuesForKey: @""]];
|
|
||||||
|
|
||||||
elements = [card childrenWithTag: @"adr"
|
|
||||||
andAttribute: @"type" havingValue: @"work"];
|
|
||||||
if (elements && [elements count] > 0)
|
|
||||||
{
|
|
||||||
element = [elements objectAtIndex: 0];
|
|
||||||
[self _setSnapshotValue: @"workExtendedAddress"
|
|
||||||
to: [element flattenedValueAtIndex: 1 forKey: @""]];
|
|
||||||
[self _setSnapshotValue: @"workStreetAddress"
|
|
||||||
to: [element flattenedValueAtIndex: 2 forKey: @""]];
|
|
||||||
[self _setSnapshotValue: @"workCity"
|
|
||||||
to: [element flattenedValueAtIndex: 3 forKey: @""]];
|
|
||||||
[self _setSnapshotValue: @"workState"
|
|
||||||
to: [element flattenedValueAtIndex: 4 forKey: @""]];
|
|
||||||
[self _setSnapshotValue: @"workPostalCode"
|
|
||||||
to: [element flattenedValueAtIndex: 5 forKey: @""]];
|
|
||||||
[self _setSnapshotValue: @"workCountry"
|
|
||||||
to: [element flattenedValueAtIndex: 6 forKey: @""]];
|
|
||||||
}
|
|
||||||
|
|
||||||
elements = [card childrenWithTag: @"adr"
|
|
||||||
andAttribute: @"type" havingValue: @"home"];
|
|
||||||
if (elements && [elements count] > 0)
|
|
||||||
{
|
|
||||||
element = [elements objectAtIndex: 0];
|
|
||||||
[self _setSnapshotValue: @"homeExtendedAddress"
|
|
||||||
to: [element flattenedValueAtIndex: 1 forKey: @""]];
|
|
||||||
[self _setSnapshotValue: @"homeStreetAddress"
|
|
||||||
to: [element flattenedValueAtIndex: 2 forKey: @""]];
|
|
||||||
[self _setSnapshotValue: @"homeCity"
|
|
||||||
to: [element flattenedValueAtIndex: 3 forKey: @""]];
|
|
||||||
[self _setSnapshotValue: @"homeState"
|
|
||||||
to: [element flattenedValueAtIndex: 4 forKey: @""]];
|
|
||||||
[self _setSnapshotValue: @"homePostalCode"
|
|
||||||
to: [element flattenedValueAtIndex: 5 forKey: @""]];
|
|
||||||
[self _setSnapshotValue: @"homeCountry"
|
|
||||||
to: [element flattenedValueAtIndex: 6 forKey: @""]];
|
|
||||||
}
|
|
||||||
|
|
||||||
elements = [card childrenWithTag: @"url"];
|
|
||||||
[self _setSnapshotValue: @"workURL"
|
|
||||||
to: [self _simpleValueForType: @"work" inArray: elements excluding: nil]];
|
|
||||||
[self _setSnapshotValue: @"homeURL"
|
|
||||||
to: [self _simpleValueForType: @"home" inArray: elements excluding: nil]];
|
|
||||||
|
|
||||||
// If we don't have a "work" or "home" URL but we still have
|
|
||||||
// an URL field present, let's add it to the "home" value
|
|
||||||
if ([[snapshot objectForKey: @"workURL"] length] == 0 &&
|
|
||||||
[[snapshot objectForKey: @"homeURL"] length] == 0 &&
|
|
||||||
[elements count] > 0)
|
|
||||||
{
|
|
||||||
[self _setSnapshotValue: @"homeURL"
|
|
||||||
to: [[elements objectAtIndex: 0] flattenedValuesForKey: @""]];
|
|
||||||
}
|
|
||||||
// If we do have a "work" URL but no "home" URL but two
|
|
||||||
// values URLs present, let's add the second one as the home URL
|
|
||||||
else if ([[snapshot objectForKey: @"workURL"] length] > 0 &&
|
|
||||||
[[snapshot objectForKey: @"homeURL"] length] == 0 &&
|
|
||||||
[elements count] > 1)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < [elements count]; i++)
|
|
||||||
{
|
|
||||||
if ([[[elements objectAtIndex: i] flattenedValuesForKey: @""]
|
|
||||||
caseInsensitiveCompare: [snapshot objectForKey: @"workURL"]] != NSOrderedSame)
|
|
||||||
{
|
|
||||||
[self _setSnapshotValue: @"homeURL"
|
|
||||||
to: [[elements objectAtIndex: i] flattenedValuesForKey: @""]];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[self _setSnapshotValue: @"calFBURL"
|
|
||||||
to: [[card uniqueChildWithTag: @"FBURL"] flattenedValuesForKey: @""]];
|
|
||||||
|
|
||||||
[self _setSnapshotValue: @"title" to: [card title]];
|
|
||||||
[self _setupOrgFields];
|
|
||||||
|
|
||||||
[self _setSnapshotValue: @"bday" to: [card bday]];
|
|
||||||
[self _setSnapshotValue: @"tz" to: [card tz]];
|
|
||||||
[self _setSnapshotValue: @"note" to: [card note]];
|
|
||||||
|
|
||||||
[self _retrieveQueryParameter: @"contactEmail"
|
|
||||||
intoSnapshotValue: @"workMail"];
|
|
||||||
[self _retrieveQueryParameter: @"contactFN"
|
|
||||||
intoSnapshotValue: @"fn"];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (id <WOActionResults>) defaultAction
|
|
||||||
{
|
|
||||||
card = [[self clientObject] vCard];
|
|
||||||
if (card)
|
|
||||||
[self initSnapshot];
|
|
||||||
else
|
|
||||||
return [NSException exceptionWithHTTPStatus:404 /* Not Found */
|
|
||||||
reason: @"could not open contact"];
|
|
||||||
|
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *) viewActionName
|
- (NSString *) viewActionName
|
||||||
|
@ -647,186 +339,35 @@
|
||||||
return @"editAsContact";
|
return @"editAsContact";
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) canCreateOrModify
|
- (BOOL) supportPhotos
|
||||||
{
|
{
|
||||||
SOGoObject *co;
|
return [[self clientObject] isKindOfClass: SOGoContactGCSEntryK];
|
||||||
|
|
||||||
co = [self clientObject];
|
|
||||||
|
|
||||||
return ([co isKindOfClass: [SOGoContentObject class]]
|
|
||||||
&& [super canCreateOrModify]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray *) photosURL
|
- (BOOL) hasPhoto
|
||||||
|
{
|
||||||
|
return [[self clientObject] hasPhoto];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *) photoURL
|
||||||
{
|
{
|
||||||
NSArray *photoElements;
|
|
||||||
NSURL *soURL;
|
NSURL *soURL;
|
||||||
NSString *baseInlineURL, *photoURL;
|
|
||||||
NGVCardPhoto *photo;
|
|
||||||
int count, max;
|
|
||||||
|
|
||||||
if (!photosURL)
|
|
||||||
{
|
|
||||||
soURL = [[self clientObject] soURL];
|
soURL = [[self clientObject] soURL];
|
||||||
baseInlineURL = [soURL absoluteString];
|
|
||||||
photoElements = [card childrenWithTag: @"photo"];
|
|
||||||
max = [photoElements count];
|
|
||||||
photosURL = [[NSMutableArray alloc] initWithCapacity: max];
|
|
||||||
for (count = 0; count < max; count++)
|
|
||||||
{
|
|
||||||
photo = [photoElements objectAtIndex: count];
|
|
||||||
if ([photo isInline])
|
|
||||||
photoURL = [NSString stringWithFormat: @"%@/photo%d",
|
|
||||||
baseInlineURL, count];
|
|
||||||
else
|
|
||||||
photoURL = [photo flattenedValuesForKey: @""];
|
|
||||||
[photosURL addObject: photoURL];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return photosURL;
|
return [NSString stringWithFormat: @"%@/photo", [soURL absoluteString]];
|
||||||
}
|
|
||||||
|
|
||||||
- (CardElement *) _elementWithTag: (NSString *) tag
|
|
||||||
ofType: (NSString *) type
|
|
||||||
{
|
|
||||||
NSArray *elements;
|
|
||||||
CardElement *element;
|
|
||||||
|
|
||||||
elements = [card childrenWithTag: tag
|
|
||||||
andAttribute: @"type" havingValue: type];
|
|
||||||
if ([elements count] > 0)
|
|
||||||
element = [elements objectAtIndex: 0];
|
|
||||||
else
|
|
||||||
{
|
|
||||||
element = [CardElement new];
|
|
||||||
[element autorelease];
|
|
||||||
[element setTag: tag];
|
|
||||||
[element addType: type];
|
|
||||||
[card addChild: element];
|
|
||||||
}
|
|
||||||
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) _savePhoneValues
|
|
||||||
{
|
|
||||||
CardElement *phone;
|
|
||||||
|
|
||||||
phone = [self _elementWithTag: @"tel" ofType: @"work"];
|
|
||||||
[phone setSingleValue: [snapshot objectForKey: @"telephoneNumber"] forKey: @""];
|
|
||||||
phone = [self _elementWithTag: @"tel" ofType: @"home"];
|
|
||||||
[phone setSingleValue: [snapshot objectForKey: @"homeTelephoneNumber"] forKey: @""];
|
|
||||||
phone = [self _elementWithTag: @"tel" ofType: @"cell"];
|
|
||||||
[phone setSingleValue: [snapshot objectForKey: @"mobile"] forKey: @""];
|
|
||||||
phone = [self _elementWithTag: @"tel" ofType: @"fax"];
|
|
||||||
[phone setSingleValue: [snapshot objectForKey: @"facsimileTelephoneNumber"]
|
|
||||||
forKey: @""];
|
|
||||||
phone = [self _elementWithTag: @"tel" ofType: @"pager"];
|
|
||||||
[phone setSingleValue: [snapshot objectForKey: @"pager"] forKey: @""];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) _saveEmails
|
|
||||||
{
|
|
||||||
CardElement *workMail, *homeMail;
|
|
||||||
|
|
||||||
workMail = [self _elementWithTag: @"email" ofType: @"work"];
|
|
||||||
[workMail setSingleValue: [snapshot objectForKey: @"workMail"] forKey: @""];
|
|
||||||
homeMail = [self _elementWithTag: @"email" ofType: @"home"];
|
|
||||||
[homeMail setSingleValue: [snapshot objectForKey: @"homeMail"] forKey: @""];
|
|
||||||
if (preferredEmail)
|
|
||||||
{
|
|
||||||
if ([preferredEmail isEqualToString: @"work"])
|
|
||||||
[card setPreferred: workMail];
|
|
||||||
else
|
|
||||||
[card setPreferred: homeMail];
|
|
||||||
}
|
|
||||||
|
|
||||||
[[card uniqueChildWithTag: @"x-mozilla-html"]
|
|
||||||
setSingleValue: [snapshot objectForKey: @"mozillaUseHtmlMail"]
|
|
||||||
forKey: @""];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) _saveSnapshot
|
|
||||||
{
|
|
||||||
CardElement *element;
|
|
||||||
NSArray *units;
|
|
||||||
|
|
||||||
[card setNWithFamily: [snapshot objectForKey: @"sn"]
|
|
||||||
given: [snapshot objectForKey: @"givenName"]
|
|
||||||
additional: nil
|
|
||||||
prefixes: nil
|
|
||||||
suffixes: nil];
|
|
||||||
[card setNickname: [snapshot objectForKey: @"nickname"]];
|
|
||||||
[card setFn: [snapshot objectForKey: @"fn"]];
|
|
||||||
[card setTitle: [snapshot objectForKey: @"title"]];
|
|
||||||
[card setBday: [snapshot objectForKey: @"bday"]];
|
|
||||||
[card setNote: [snapshot objectForKey: @"note"]];
|
|
||||||
[card setTz: [snapshot objectForKey: @"tz"]];
|
|
||||||
|
|
||||||
element = [self _elementWithTag: @"adr" ofType: @"home"];
|
|
||||||
[element setSingleValue: [snapshot objectForKey: @"homeExtendedAddress"]
|
|
||||||
atIndex: 1 forKey: @""];
|
|
||||||
[element setSingleValue: [snapshot objectForKey: @"homeStreetAddress"]
|
|
||||||
atIndex: 2 forKey: @""];
|
|
||||||
[element setSingleValue: [snapshot objectForKey: @"homeCity"]
|
|
||||||
atIndex: 3 forKey: @""];
|
|
||||||
[element setSingleValue: [snapshot objectForKey: @"homeState"]
|
|
||||||
atIndex: 4 forKey: @""];
|
|
||||||
[element setSingleValue: [snapshot objectForKey: @"homePostalCode"]
|
|
||||||
atIndex: 5 forKey: @""];
|
|
||||||
[element setSingleValue: [snapshot objectForKey: @"homeCountry"]
|
|
||||||
atIndex: 6 forKey: @""];
|
|
||||||
|
|
||||||
element = [self _elementWithTag: @"adr" ofType: @"work"];
|
|
||||||
[element setSingleValue: [snapshot objectForKey: @"workExtendedAddress"]
|
|
||||||
atIndex: 1 forKey: @""];
|
|
||||||
[element setSingleValue: [snapshot objectForKey: @"workStreetAddress"]
|
|
||||||
atIndex: 2 forKey: @""];
|
|
||||||
[element setSingleValue: [snapshot objectForKey: @"workCity"]
|
|
||||||
atIndex: 3 forKey: @""];
|
|
||||||
[element setSingleValue: [snapshot objectForKey: @"workState"]
|
|
||||||
atIndex: 4 forKey: @""];
|
|
||||||
[element setSingleValue: [snapshot objectForKey: @"workPostalCode"]
|
|
||||||
atIndex: 5 forKey: @""];
|
|
||||||
[element setSingleValue: [snapshot objectForKey: @"workCountry"]
|
|
||||||
atIndex: 6 forKey: @""];
|
|
||||||
|
|
||||||
element = [CardElement simpleElementWithTag: @"fburl"
|
|
||||||
value: [snapshot objectForKey: @"calFBURL"]];
|
|
||||||
[card setUniqueChild: element];
|
|
||||||
|
|
||||||
units = [NSArray arrayWithObject: [snapshot objectForKey: @"workService"]];
|
|
||||||
[card setOrg: [snapshot objectForKey: @"workCompany"]
|
|
||||||
units: units];
|
|
||||||
|
|
||||||
[self _savePhoneValues];
|
|
||||||
[self _saveEmails];
|
|
||||||
[[self _elementWithTag: @"url" ofType: @"home"]
|
|
||||||
setSingleValue: [snapshot objectForKey: @"homeURL"] forKey: @""];
|
|
||||||
[[self _elementWithTag: @"url" ofType: @"work"]
|
|
||||||
setSingleValue: [snapshot objectForKey: @"workURL"] forKey: @""];
|
|
||||||
|
|
||||||
[[card uniqueChildWithTag: @"x-aim"]
|
|
||||||
setSingleValue: [snapshot objectForKey: @"screenName"]
|
|
||||||
forKey: @""];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id <WOActionResults>) saveAction
|
- (id <WOActionResults>) saveAction
|
||||||
{
|
{
|
||||||
SOGoContactGCSEntry *contact;
|
SOGoObject <SOGoContactObject> *contact;
|
||||||
id result;
|
id result;
|
||||||
NSString *jsRefreshMethod;
|
NSString *jsRefreshMethod;
|
||||||
SoSecurityManager *sm;
|
SoSecurityManager *sm;
|
||||||
|
|
||||||
contact = [self clientObject];
|
contact = [self clientObject];
|
||||||
card = [contact vCard];
|
[contact setLDIFRecord: ldifRecord];
|
||||||
if (card)
|
[self _fetchAndCombineCategoriesList];
|
||||||
{
|
|
||||||
// [self _fixupSnapshot];
|
|
||||||
[self _saveSnapshot];
|
|
||||||
[card setCategories: contactCategories];
|
|
||||||
[self _fetchAndCombineCategoriesList: contactCategories];
|
|
||||||
[contact save];
|
[contact save];
|
||||||
|
|
||||||
if (componentAddressBook && componentAddressBook != [self componentAddressBook])
|
if (componentAddressBook && componentAddressBook != [self componentAddressBook])
|
||||||
|
@ -852,11 +393,6 @@
|
||||||
[contact nameInContainer]];
|
[contact nameInContainer]];
|
||||||
result = [self jsCloseWithRefreshMethod: jsRefreshMethod];
|
result = [self jsCloseWithRefreshMethod: jsRefreshMethod];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
result = [NSException exceptionWithHTTPStatus: 400 /* Bad Request */
|
|
||||||
reason: @"method cannot be invoked on "
|
|
||||||
@"the specified object"];
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -866,17 +402,15 @@
|
||||||
NSString *email, *cn, *url;
|
NSString *email, *cn, *url;
|
||||||
NSMutableString *address;
|
NSMutableString *address;
|
||||||
|
|
||||||
card = [[self clientObject] vCard];
|
[self ldifRecord];
|
||||||
[self initSnapshot];
|
email = [ldifRecord objectForKey: @"mail"];
|
||||||
if ([preferredEmail isEqualToString: @"home"])
|
if ([email length] == 0)
|
||||||
email = [snapshot objectForKey: @"homeMail"];
|
email = [ldifRecord objectForKey: @"mozillasecondemail"];
|
||||||
else
|
|
||||||
email = [snapshot objectForKey: @"workMail"];
|
|
||||||
|
|
||||||
if (email)
|
if (email)
|
||||||
{
|
{
|
||||||
address = [NSMutableString string];
|
address = [NSMutableString string];
|
||||||
cn = [card fn];
|
cn = [ldifRecord objectForKey: @"cn"];
|
||||||
if ([cn length] > 0)
|
if ([cn length] > 0)
|
||||||
[address appendFormat: @"%@ <%@>", cn, email];
|
[address appendFormat: @"%@ <%@>", cn, email];
|
||||||
else
|
else
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#import <Contacts/SOGoContactObject.h>
|
#import <Contacts/SOGoContactObject.h>
|
||||||
#import <Contacts/SOGoContactFolder.h>
|
#import <Contacts/SOGoContactFolder.h>
|
||||||
#import <Contacts/SOGoContactFolders.h>
|
#import <Contacts/SOGoContactFolders.h>
|
||||||
|
#import <Contacts/NSDictionary+LDIF.h>
|
||||||
|
|
||||||
#import <SoObjects/Contacts/NGVCard+SOGo.h>
|
#import <SoObjects/Contacts/NGVCard+SOGo.h>
|
||||||
#import <SoObjects/Contacts/NGVList+SOGo.h>
|
#import <SoObjects/Contacts/NGVList+SOGo.h>
|
||||||
|
@ -76,9 +77,10 @@
|
||||||
inContext: [self context]
|
inContext: [self context]
|
||||||
acquire: NO];
|
acquire: NO];
|
||||||
if ([currentChild respondsToSelector: @selector (vCard)])
|
if ([currentChild respondsToSelector: @selector (vCard)])
|
||||||
[content appendFormat: [[currentChild vCard] ldifString]];
|
[content appendFormat: [[currentChild ldifRecord] ldifRecordAsString]];
|
||||||
else if ([currentChild respondsToSelector: @selector (vList)])
|
else if ([currentChild respondsToSelector: @selector (vList)])
|
||||||
[content appendFormat: [[currentChild vList] ldifString]];
|
[content appendFormat: [[currentChild vList] ldifString]];
|
||||||
|
[content appendString: @"\n"];
|
||||||
}
|
}
|
||||||
|
|
||||||
response = [context response];
|
response = [context response];
|
||||||
|
|
|
@ -52,6 +52,7 @@
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
|
[card release];
|
||||||
[photosURL release];
|
[photosURL release];
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
@ -377,9 +378,7 @@
|
||||||
{
|
{
|
||||||
NSString *data;
|
NSString *data;
|
||||||
|
|
||||||
data = nil;
|
if ([url length] > 0)
|
||||||
|
|
||||||
if (url)
|
|
||||||
{
|
{
|
||||||
if (![[url lowercaseString] rangeOfString: @"://"].length)
|
if (![[url lowercaseString] rangeOfString: @"://"].length)
|
||||||
url = [NSString stringWithFormat: @"http://%@", url];
|
url = [NSString stringWithFormat: @"http://%@", url];
|
||||||
|
@ -388,6 +387,8 @@
|
||||||
@"<a href=\"%@\" target=\"_blank\">%@</a>",
|
@"<a href=\"%@\" target=\"_blank\">%@</a>",
|
||||||
url, url];
|
url, url];
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
data = nil;
|
||||||
|
|
||||||
return [self _cardStringWithLabel: nil value: data];
|
return [self _cardStringWithLabel: nil value: data];
|
||||||
}
|
}
|
||||||
|
@ -646,30 +647,12 @@
|
||||||
|
|
||||||
/* action */
|
/* action */
|
||||||
|
|
||||||
- (id <WOActionResults>) vcardAction
|
|
||||||
{
|
|
||||||
#warning this method is unused
|
|
||||||
WOResponse *response;
|
|
||||||
|
|
||||||
card = [[self clientObject] vCard];
|
|
||||||
if (card)
|
|
||||||
{
|
|
||||||
response = [context response];
|
|
||||||
[response setHeader: @"text/vcard" forKey: @"Content-type"];
|
|
||||||
[response appendContentString: [card versitString]];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return [NSException exceptionWithHTTPStatus: 404 /* Not Found */
|
|
||||||
reason:@"could not locate contact"];
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (id <WOActionResults>) defaultAction
|
- (id <WOActionResults>) defaultAction
|
||||||
{
|
{
|
||||||
card = [[self clientObject] vCard];
|
card = [[self clientObject] vCard];
|
||||||
if (card)
|
if (card)
|
||||||
{
|
{
|
||||||
|
[card retain];
|
||||||
phones = nil;
|
phones = nil;
|
||||||
homeAdr = nil;
|
homeAdr = nil;
|
||||||
workAdr = nil;
|
workAdr = nil;
|
||||||
|
|
|
@ -234,13 +234,27 @@
|
||||||
SOGoContactLDIFEntry = {
|
SOGoContactLDIFEntry = {
|
||||||
methods = {
|
methods = {
|
||||||
view = {
|
view = {
|
||||||
protectedBy = "<public>";
|
protectedBy = "Access Contents Information";
|
||||||
pageName = "UIxContactView";
|
pageName = "UIxContactView";
|
||||||
};
|
};
|
||||||
edit = {
|
edit = {
|
||||||
protectedBy = "<public>";
|
protectedBy = "Access Contents Information";
|
||||||
pageName = "UIxContactEditor";
|
pageName = "UIxContactEditor";
|
||||||
};
|
};
|
||||||
|
editAsContact = {
|
||||||
|
protectedBy = "Access Contents Information";
|
||||||
|
pageName = "UIxContactEditor";
|
||||||
|
};
|
||||||
|
save = {
|
||||||
|
protectedBy = "Change Images And Files";
|
||||||
|
pageName = "UIxContactEditor";
|
||||||
|
actionName = "save";
|
||||||
|
};
|
||||||
|
saveAsContact = {
|
||||||
|
protectedBy = "Change Images And Files";
|
||||||
|
pageName = "UIxContactEditor";
|
||||||
|
actionName = "save";
|
||||||
|
};
|
||||||
write = {
|
write = {
|
||||||
protectedBy = "<public>";
|
protectedBy = "<public>";
|
||||||
pageName = "UIxContactEditor";
|
pageName = "UIxContactEditor";
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version='1.0' standalone='yes'?>
|
<?xml version='1.0'?>
|
||||||
<!DOCTYPE var:component>
|
<!DOCTYPE var:component>
|
||||||
<var:component
|
<var:component
|
||||||
xmlns="http://www.w3.org/1999/xhtml"
|
xmlns="http://www.w3.org/1999/xhtml"
|
||||||
|
@ -30,12 +30,16 @@
|
||||||
<li target="baseInfos">
|
<li target="baseInfos">
|
||||||
<span><var:string label:value="Contact" /></span>
|
<span><var:string label:value="Contact" /></span>
|
||||||
</li>
|
</li>
|
||||||
<li target="categoryInfos">
|
<var:if condition="supportCategories"
|
||||||
<span><var:string label:value="Categories" /></span></li>
|
><li target="categoryInfos">
|
||||||
|
<span><var:string label:value="Categories" /></span></li
|
||||||
|
></var:if>
|
||||||
<li target="addressesInfos">
|
<li target="addressesInfos">
|
||||||
<span><var:string label:value="Address" /></span></li>
|
<span><var:string label:value="Address" /></span></li>
|
||||||
<li target="photos">
|
<var:if condition="supportPhotos"
|
||||||
<span><var:string label:value="Photos" /></span></li>
|
><li target="photos">
|
||||||
|
<span><var:string label:value="Photos" /></span></li
|
||||||
|
></var:if>
|
||||||
<li target="otherInfos">
|
<li target="otherInfos">
|
||||||
<span><var:string label:value="Other" /></span></li>
|
<span><var:string label:value="Other" /></span></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -46,34 +50,34 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label><var:string label:value="First:" />
|
<label><var:string label:value="First:" />
|
||||||
<input type="text" class="textField" name="givenName"
|
<input type="text" class="textField" name="givenname"
|
||||||
id="givenName"
|
id="givenname"
|
||||||
var:value="snapshot.givenName" />
|
var:value="ldifRecord.givenname"
|
||||||
</label>
|
/></label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label><var:string label:value="Last:" />
|
<label><var:string label:value="Last:" />
|
||||||
<input type="text" class="textField" name="sn" id="sn"
|
<input type="text" class="textField" name="sn" id="sn"
|
||||||
var:value="snapshot.sn" />
|
var:value="ldifRecord.sn"
|
||||||
</label>
|
/></label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label><var:string label:value="Display:" />
|
<label><var:string label:value="Display:" />
|
||||||
<input type="text" class="textField" name="fn" id="fn"
|
<input type="text" class="textField" name="displayname" id="displayname"
|
||||||
var:value="snapshot.fn" />
|
var:value="ldifRecord.displayname"
|
||||||
</label>
|
/></label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label><var:string label:value="Nickname:" />
|
<label><var:string label:value="Nickname:" />
|
||||||
<input type="text" class="textField" name="nickname" id="nickname"
|
<input type="text" class="textField" name="mozillanickname" id="mozillanickname"
|
||||||
var:value="snapshot.nickname" />
|
var:value="ldifRecord.mozillanickname"
|
||||||
</label>
|
/></label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
@ -82,26 +86,26 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label><var:string label:value="Email:" />
|
<label><var:string label:value="Email:" />
|
||||||
<input type="text" class="textField" name="workMail" id="workMail"
|
<input type="text" class="textField" name="mail" id="mail"
|
||||||
var:value="snapshot.workMail" />
|
var:value="ldifRecord.mail"
|
||||||
</label>
|
/></label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label><var:string label:value="Additional Email:" />
|
<label><var:string label:value="Additional Email:" />
|
||||||
<input type="text" class="textField" name="homeMail"
|
<input type="text" class="textField" name="mozillasecondemail"
|
||||||
id="homeMail" var:value="snapshot.homeMail" />
|
id="mozillasecondemail" var:value="ldifRecord.mozillasecondemail"
|
||||||
</label>
|
/></label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label><var:string label:value="Screen Name:"
|
<label><var:string label:value="Screen Name:"
|
||||||
/>
|
/>
|
||||||
<input type="text" class="textField" name="screenName"
|
<input type="text" class="textField" name="nsaimid"
|
||||||
id="screenName" var:value="snapshot.screenName" />
|
id="nsaimid" var:value="ldifRecord.nsaimid"
|
||||||
</label>
|
/></label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -111,9 +115,8 @@
|
||||||
<var:popup list="htmlMailFormatList" item="item"
|
<var:popup list="htmlMailFormatList" item="item"
|
||||||
label:noSelectionString="htmlMailFormat_UNKNOWN"
|
label:noSelectionString="htmlMailFormat_UNKNOWN"
|
||||||
string="itemHtmlMailFormatText"
|
string="itemHtmlMailFormatText"
|
||||||
selection="snapshot.mozillaUseHtmlMail"
|
selection="ldifRecord.mozillausehtmlmail"
|
||||||
/>
|
/></label>
|
||||||
</label>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
@ -123,9 +126,9 @@
|
||||||
<td>
|
<td>
|
||||||
<label><var:string label:value="Work:" />
|
<label><var:string label:value="Work:" />
|
||||||
<input type="text" class="textField"
|
<input type="text" class="textField"
|
||||||
name="telephoneNumber"
|
name="telephonenumber"
|
||||||
id="telephoneNumber"
|
id="telephonenumber"
|
||||||
var:value="snapshot.telephoneNumber"
|
var:value="ldifRecord.telephonenumber"
|
||||||
/></label>
|
/></label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -133,24 +136,19 @@
|
||||||
<td>
|
<td>
|
||||||
<label><var:string label:value="Home:" />
|
<label><var:string label:value="Home:" />
|
||||||
<input type="text" class="textField"
|
<input type="text" class="textField"
|
||||||
name="homeTelephoneNumber"
|
name="homephone" id="homephone"
|
||||||
id="homeTelephoneNumber"
|
var:value="ldifRecord.homephone"
|
||||||
var:value="snapshot.homeTelephoneNumber"
|
/></label>
|
||||||
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label><var:string label:value="Fax:" />
|
<label><var:string label:value="Fax:" />
|
||||||
<input type="text" class="textField"
|
<input type="text" class="textField"
|
||||||
name="facsimileTelephoneNumber"
|
name="facsimiletelephonenumber"
|
||||||
id="facsimileTelephoneNumber"
|
id="facsimiletelephonenumber"
|
||||||
var:value="snapshot.facsimileTelephoneNumber"
|
var:value="ldifRecord.facsimiletelephonenumber"
|
||||||
|
/></label>
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -159,24 +157,23 @@
|
||||||
<input type="text" class="textField"
|
<input type="text" class="textField"
|
||||||
name="pager"
|
name="pager"
|
||||||
id="pager"
|
id="pager"
|
||||||
var:value="snapshot.pager"
|
var:value="ldifRecord.pager"
|
||||||
|
/></label>
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<label><var:string label:value="Mobile:" />
|
<label><var:string label:value="Mobile:" />
|
||||||
<input type="text" class="textField" name="mobile" id="mobile"
|
<input type="text" class="textField" name="mobile" id="mobile"
|
||||||
var:value="snapshot.mobile" />
|
var:value="ldifRecord.mobile"
|
||||||
</label>
|
/></label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="categoryInfos" class="tab">
|
<var:if condition="supportCategories"
|
||||||
|
><div id="categoryInfos" class="tab">
|
||||||
<div id="categoryContainer">
|
<div id="categoryContainer">
|
||||||
</div>
|
</div>
|
||||||
<var:if condition="canCreateOrModify"
|
<var:if condition="canCreateOrModify"
|
||||||
|
@ -187,10 +184,10 @@
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var gCategories = <var:string value="contactCategoriesList" const:escapeHTML="NO"/>;
|
var gCategories = <var:string value="contactCategoriesList" const:escapeHTML="NO"/>;
|
||||||
</script>
|
</script>
|
||||||
<input type="hidden" id="contactCategories"
|
<input type="hidden" id="jsonContactCategories"
|
||||||
const:name="contactCategories"
|
const:name="jsonContactCategories"
|
||||||
var:value="contactCategories" />
|
var:value="jsonContactCategories" />
|
||||||
</div>
|
</div></var:if>
|
||||||
|
|
||||||
<div id="addressesInfos" class="tab">
|
<div id="addressesInfos" class="tab">
|
||||||
<span class="caption"><var:string label:value="Home" /></span>
|
<span class="caption"><var:string label:value="Home" /></span>
|
||||||
|
@ -198,64 +195,64 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<label><var:string label:value="Address:" />
|
<label><var:string label:value="Address:" />
|
||||||
<input type="text" class="textField" name="homeStreetAddress"
|
<input type="text" class="textField" name="mozillahomestreet"
|
||||||
id="homeStreetAddress"
|
id="mozillahomestreet"
|
||||||
var:value="snapshot.homeStreetAddress" />
|
var:value="ldifRecord.mozillahomestreet"
|
||||||
</label>
|
/></label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<label>
|
<label>
|
||||||
<input type="text" class="textField" name="homeExtendedAddress"
|
<input type="text" class="textField" namCe="mozillahomestreet2"
|
||||||
id="homeExtendedAddress"
|
id="mozillahomestreet2"
|
||||||
var:value="snapshot.homeExtendedAddress" />
|
var:value="ldifRecord.mozillahomestreet2"
|
||||||
</label>
|
/></label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<label><var:string label:value="City:" />
|
<label><var:string label:value="City:" />
|
||||||
<input type="text" class="textField" name="homeCity"
|
<input type="text" class="textField" name="mozillahomelocalityname"
|
||||||
id="homeCity"
|
id="mozillahomelocalityname"
|
||||||
var:value="snapshot.homeCity" />
|
var:value="ldifRecord.mozillahomelocalityname"
|
||||||
</label>
|
/></label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="firstColumn">
|
<td class="firstColumn">
|
||||||
<label><var:string label:value="State_Province:" />
|
<label><var:string label:value="State_Province:" />
|
||||||
<input type="text" class="textField" name="homeState"
|
<input type="text" class="textField" name="mozillahomestate"
|
||||||
id="homeState"
|
id="mozillahomestate"
|
||||||
var:value="snapshot.homeState" />
|
var:value="ldifRecord.mozillahomestate"
|
||||||
</label>
|
/></label>
|
||||||
</td>
|
</td>
|
||||||
<td class="secondColumn">
|
<td class="secondColumn">
|
||||||
<label><var:string
|
<label><var:string
|
||||||
label:value="ZIP_Postal Code:"
|
label:value="ZIP_Postal Code:"
|
||||||
/>
|
/>
|
||||||
<input type="text" class="textField" name="homePostalCode"
|
<input type="text" class="textField" name="mozillahomepostalcode"
|
||||||
id="homePostalCode"
|
id="mozillahomepostalcode"
|
||||||
var:value="snapshot.homePostalCode" />
|
var:value="ldifRecord.mozillahomepostalcode"
|
||||||
</label>
|
/></label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<label><var:string label:value="Country:" />
|
<label><var:string label:value="Country:" />
|
||||||
<input type="text" class="textField" name="homeCountry"
|
<input type="text" class="textField" name="mozillahomecountryname"
|
||||||
id="homeCountry"
|
id="mozillahomecountryname"
|
||||||
var:value="snapshot.homeCountry" />
|
var:value="ldifRecord.mozillahomecountryname"
|
||||||
</label>
|
/></label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<label>
|
<label>
|
||||||
<var:string label:value="Web Page:" />
|
<var:string label:value="Web Page:" />
|
||||||
<input type="text" class="textField" name="homeURL"
|
<input type="text" class="textField" name="mozillahomeurl"
|
||||||
var:value="snapshot.homeURL" />
|
var:value="ldifRecord.mozillahomeurl"
|
||||||
</label>
|
/></label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
@ -267,128 +264,116 @@
|
||||||
<var:string label:value="Title:" />
|
<var:string label:value="Title:" />
|
||||||
<input type="text" class="textField" name="title"
|
<input type="text" class="textField" name="title"
|
||||||
id="title"
|
id="title"
|
||||||
var:value="snapshot.title" />
|
var:value="ldifRecord.title"
|
||||||
</label>
|
/></label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<label>
|
<label>
|
||||||
<var:string label:value="Department:" />
|
<var:string label:value="Department:" />
|
||||||
<input type="text" class="textField" name="workService"
|
<input type="text" class="textField" name="ou"
|
||||||
id="workService"
|
id="ou"
|
||||||
var:value="snapshot.workService" />
|
var:value="ldifRecord.ou"
|
||||||
</label>
|
/></label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<label><var:string label:value="Organization:" />
|
<label><var:string label:value="Organization:" />
|
||||||
<input type="text" class="textField" name="workCompany"
|
<input type="text" class="textField" name="o"
|
||||||
id="workCompany"
|
id="o" var:value="ldifRecord.o"
|
||||||
var:value="snapshot.workCompany" />
|
/></label>
|
||||||
</label>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<label><var:string label:value="Address:" />
|
<label><var:string label:value="Address:" />
|
||||||
<input type="text" class="textField" name="workStreetAddress"
|
<input type="text" class="textField" name="street"
|
||||||
id="workStreetAddress"
|
id="street"
|
||||||
var:value="snapshot.workStreetAddress" />
|
var:value="ldifRecord.street"
|
||||||
</label>
|
/></label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<label>
|
<label>
|
||||||
<input type="text" class="textField" name="workExtendedAddress"
|
<input type="text" class="textField" name="mozillaworkstreet2"
|
||||||
id="workExtendedAddress"
|
id="mozillaworkstreet2" var:value="ldifRecord.mozillaworkstreet2"
|
||||||
var:value="snapshot.workExtendedAddress" />
|
/></label>
|
||||||
</label>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<label><var:string label:value="City:" />
|
<label><var:string label:value="City:" />
|
||||||
<input type="text" class="textField" name="workCity"
|
<input type="text" class="textField" name="l"
|
||||||
id="workCity"
|
id="l" var:value="ldifRecord.l"
|
||||||
var:value="snapshot.workCity" />
|
/></label>
|
||||||
</label>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="firstColumn">
|
<td class="firstColumn">
|
||||||
<label><var:string label:value="State_Province:" />
|
<label><var:string label:value="State_Province:" />
|
||||||
<input type="text" class="textField" name="workState"
|
<input type="text" class="textField" name="st"
|
||||||
id="workState"
|
id="st" var:value="ldifRecord.st"
|
||||||
var:value="snapshot.workState" />
|
/></label>
|
||||||
</label>
|
|
||||||
</td>
|
</td>
|
||||||
<td class="secondColumn">
|
<td class="secondColumn">
|
||||||
<label><var:string
|
<label><var:string
|
||||||
label:value="ZIP_Postal Code:"
|
label:value="ZIP_Postal Code:"
|
||||||
/>
|
/>
|
||||||
<input type="text" class="textField" name="workPostalCode"
|
<input type="text" class="textField" name="postalCode"
|
||||||
id="workPostalCode"
|
id="postalCode" var:value="ldifRecord.postalCode"
|
||||||
var:value="snapshot.workPostalCode" />
|
/></label>
|
||||||
</label>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<label><var:string label:value="Country:" />
|
<label><var:string label:value="Country:" />
|
||||||
<input type="text" class="textField" name="workCountry"
|
<input type="text" class="textField" name="c"
|
||||||
id="workCountry"
|
id="c" var:value="ldifRecord.c"
|
||||||
var:value="snapshot.workCountry" />
|
/></label>
|
||||||
</label>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<label><var:string label:value="Web Page:" />
|
<label><var:string label:value="Web Page:" />
|
||||||
<input type="text" class="textField" name="workURL"
|
<input type="text" class="textField" name="mozillaworkurl"
|
||||||
var:value="snapshot.workURL" />
|
var:value="ldifRecord.mozillaworkurl"
|
||||||
</label>
|
/></label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="photos" class="tab">
|
<var:if condition="supportPhotos"
|
||||||
<var:foreach list="photosURL" item="currentPhotoURL">
|
><div id="photos" class="tab">
|
||||||
<img var:src="currentPhotoURL" class="contactPhoto"/><br
|
<var:if condition="hasPhoto"
|
||||||
/></var:foreach>
|
><img var:src="photoURL" class="contactPhoto"
|
||||||
</div>
|
/></var:if>
|
||||||
|
</div
|
||||||
|
></var:if>
|
||||||
|
|
||||||
<div id="otherInfos" class="tab">
|
<div id="otherInfos" class="tab">
|
||||||
<table class="framenocaption">
|
<table class="framenocaption">
|
||||||
<tr>
|
<tr>
|
||||||
<td class="firstColumn">
|
<td>
|
||||||
<label><var:string label:value="Birthday (yyyy-mm-dd):" />
|
<label><var:string label:value="Birthday (yyyy-mm-dd):"/>
|
||||||
|
<input type="text" class="textField" name="birthyear" id="birthyear"
|
||||||
|
var:value="ldifRecord.birthyear"
|
||||||
|
/></label>
|
||||||
|
-
|
||||||
|
<input type="text" class="textField" name="birthmonth" id="birthmonth"
|
||||||
|
var:value="ldifRecord.birthmonth" />
|
||||||
|
-
|
||||||
<input type="text" class="textField" name="birthday" id="birthday"
|
<input type="text" class="textField" name="birthday" id="birthday"
|
||||||
var:value="snapshot.bday" />
|
var:value="ldifRecord.birthday"/>
|
||||||
</label>
|
|
||||||
</td>
|
|
||||||
<td class="secondColumn">
|
|
||||||
<label><var:string label:value="Timezone:" />
|
|
||||||
<input type="text" class="textField" name="tz" id="tz"
|
|
||||||
var:value="snapshot.tz" />
|
|
||||||
</label>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2">
|
<td>
|
||||||
<label><var:string label:value="Freebusy URL:" />
|
|
||||||
<input type="text" class="textField" name="calFBURL" id="calFBURL"
|
|
||||||
var:value="snapshot.calFBURL" />
|
|
||||||
</label>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan="2">
|
|
||||||
<label><var:string label:value="Note:" />
|
<label><var:string label:value="Note:" />
|
||||||
<textarea var:value="snapshot.note" name="note" id="note"></textarea>
|
<textarea var:value="ldifRecord.description" name="note" id="note"></textarea>
|
||||||
</label>
|
</label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -512,9 +512,6 @@ function onToolbarDeleteSelectedContactsConfirm(dialogId) {
|
||||||
var contactsList = $('contactsList');
|
var contactsList = $('contactsList');
|
||||||
var rows = contactsList.getSelectedRowsId();
|
var rows = contactsList.getSelectedRowsId();
|
||||||
for (var i = 0; i < rows.length; i++) {
|
for (var i = 0; i < rows.length; i++) {
|
||||||
var row = $(rows[i]);
|
|
||||||
row.deselect();
|
|
||||||
row.hide();
|
|
||||||
delete cachedContacts[Contact.currentAddressBook + "/" + rows[i]];
|
delete cachedContacts[Contact.currentAddressBook + "/" + rows[i]];
|
||||||
var urlstr = (URLForFolderID(Contact.currentAddressBook) + "/"
|
var urlstr = (URLForFolderID(Contact.currentAddressBook) + "/"
|
||||||
+ rows[i] + "/delete");
|
+ rows[i] + "/delete");
|
||||||
|
@ -532,6 +529,7 @@ function onContactDeleteEventCallback(http) {
|
||||||
$("contactView").update();
|
$("contactView").update();
|
||||||
Contact.currentContact = null;
|
Contact.currentContact = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Contact.deleteContactsRequestCount--;
|
Contact.deleteContactsRequestCount--;
|
||||||
if (Contact.deleteContactsRequestCount == 0) {
|
if (Contact.deleteContactsRequestCount == 0) {
|
||||||
var nextRow = row.next("tr");
|
var nextRow = row.next("tr");
|
||||||
|
@ -543,8 +541,11 @@ function onContactDeleteEventCallback(http) {
|
||||||
loadContact(Contact.currentContact);
|
loadContact(Contact.currentContact);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (row) {
|
||||||
|
row.deselect();
|
||||||
row.parentNode.removeChild(row);
|
row.parentNode.removeChild(row);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (parseInt(http.status) == 403) {
|
else if (parseInt(http.status) == 403) {
|
||||||
var row = $(http.callbackData);
|
var row = $(http.callbackData);
|
||||||
row.show();
|
row.show();
|
||||||
|
|
|
@ -69,3 +69,9 @@ INPUT.comboBoxField, #emptyCategory
|
||||||
|
|
||||||
#otherInfos TEXTAREA
|
#otherInfos TEXTAREA
|
||||||
{ width: 70%; }
|
{ width: 70%; }
|
||||||
|
|
||||||
|
#birthday, #birthmonth
|
||||||
|
{ width: 18px; }
|
||||||
|
|
||||||
|
#birthyear
|
||||||
|
{ width: 36px; }
|
||||||
|
|
|
@ -22,9 +22,9 @@
|
||||||
02111-1307, USA.
|
02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var dateRegex = /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/;
|
var dateRegex = /^(([0-9]{2})?[0-9])?[0-9]-[0-9]?[0-9]-[0-9]?[0-9]$/;
|
||||||
|
|
||||||
var displayNameChanged = false;
|
var displaynameChanged = false;
|
||||||
|
|
||||||
var tabIndex = 0;
|
var tabIndex = 0;
|
||||||
|
|
||||||
|
@ -37,43 +37,43 @@ function unescapeCallbackParameter(s) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyContact(type, email, uid, sn,
|
function copyContact(type, email, uid, sn,
|
||||||
cn, givenName, telephoneNumber, facsimileTelephoneNumber,
|
displayname, givenname, telephonenumber, facsimiletelephonenumber,
|
||||||
mobile, postalAddress, homePostalAddress,
|
mobile, postalAddress, homePostalAddress,
|
||||||
departmentNumber, l)
|
departmentnumber, l)
|
||||||
{
|
{
|
||||||
// var type = arguments[0];
|
// var type = arguments[0];
|
||||||
// var email = arguments[1];
|
// var email = arguments[1];
|
||||||
// var uid = arguments[2];
|
// var uid = arguments[2];
|
||||||
// var sn = arguments[3];
|
// var sn = arguments[3];
|
||||||
// var givenName = arguments[4];
|
// var givenname = arguments[4];
|
||||||
// var telephoneNumber = arguments[5];
|
// var telephonenumber = arguments[5];
|
||||||
// var facsimileTelephoneNumber = arguments[6];
|
// var facsimiletelephonenumber = arguments[6];
|
||||||
// var mobile = arguments[7];
|
// var mobile = arguments[7];
|
||||||
// var postalAddress = arguments[8];
|
// var postaladdress = arguments[8];
|
||||||
// var homePostalAddress = arguments[9];
|
// var homepostaladdress = arguments[9];
|
||||||
// var departmentNumber = arguments[10];
|
// var departmentnumber = arguments[10];
|
||||||
// var l = arguments[11];
|
// var l = arguments[11];
|
||||||
var e;
|
var e;
|
||||||
e = $('cn');
|
e = $('displayname');
|
||||||
e.setAttribute('value', unescapeCallbackParameter(cn));
|
e.setAttribute('value', unescapeCallbackParameter(displayname));
|
||||||
e = $('email');
|
e = $('email');
|
||||||
e.setAttribute('value', email);
|
e.setAttribute('value', email);
|
||||||
e = $('sn');
|
e = $('sn');
|
||||||
e.setAttribute('value', unescapeCallbackParameter(sn));
|
e.setAttribute('value', unescapeCallbackParameter(sn));
|
||||||
e = $('givenName');
|
e = $('givenname');
|
||||||
e.setAttribute('value', unescapeCallbackParameter(givenName));
|
e.setAttribute('value', unescapeCallbackParameter(givenname));
|
||||||
e = $('telephoneNumber');
|
e = $('telephonenumber');
|
||||||
e.setAttribute('value', telephoneNumber);
|
e.setAttribute('value', telephonenumber);
|
||||||
e = $('facsimileTelephoneNumber');
|
e = $('facsimiletelephonenumber');
|
||||||
e.setAttribute('value', facsimileTelephoneNumber);
|
e.setAttribute('value', facsimileTelephonenumber);
|
||||||
e = $('mobile');
|
e = $('mobile');
|
||||||
e.setAttribute('value', mobile);
|
e.setAttribute('value', mobile);
|
||||||
e = $('postalAddress');
|
e = $('postaladdress');
|
||||||
e.setAttribute('value', unescapeCallbackParameter(postalAddress));
|
e.setAttribute('value', unescapeCallbackParameter(postalAddress));
|
||||||
e = $('homePostalAddress');
|
e = $('homepostaladdress');
|
||||||
e.setAttribute('value', unescapeCallbackParameter(homePostalAddress));
|
e.setAttribute('value', unescapeCallbackParameter(homePostalAddress));
|
||||||
e = $('departmentNumber');
|
e = $('departmentnumber');
|
||||||
e.setAttribute('value', unescapeCallbackParameter(departmentNumber));
|
e.setAttribute('value', unescapeCallbackParameter(departmentnumber));
|
||||||
e = $('l');
|
e = $('l');
|
||||||
e.setAttribute('value', unescapeCallbackParameter(l));
|
e.setAttribute('value', unescapeCallbackParameter(l));
|
||||||
};
|
};
|
||||||
|
@ -81,23 +81,25 @@ function copyContact(type, email, uid, sn,
|
||||||
function validateContactEditor() {
|
function validateContactEditor() {
|
||||||
var rc = true;
|
var rc = true;
|
||||||
|
|
||||||
var e = $('workMail');
|
var e = $('mail');
|
||||||
if (e.value.length > 0
|
if (e.value.length > 0
|
||||||
&& !emailRE.test(e.value)) {
|
&& !emailRE.test(e.value)) {
|
||||||
alert(_("invalidemailwarn"));
|
alert(_("invalidemailwarn"));
|
||||||
rc = false;
|
rc = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
e = $('homeMail');
|
e = $('mozillasecondemail');
|
||||||
if (e.value.length > 0
|
if (e.value.length > 0
|
||||||
&& !emailRE.test(e.value)) {
|
&& !emailRE.test(e.value)) {
|
||||||
alert(_("invalidemailwarn"));
|
alert(_("invalidemailwarn"));
|
||||||
rc = false;
|
rc = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
e = $('birthday');
|
var byear = $('birthyear');
|
||||||
if (e.value.length > 0
|
var bmonth = $('birthmonth');
|
||||||
&& !dateRegex.test(e.value)) {
|
var bday = $('birthday');
|
||||||
|
var bdayValue = byear.value + "-" + bmonth.value + "-" + bday.value;
|
||||||
|
if (bdayValue != "--" && !dateRegex.test(bdayValue)) {
|
||||||
alert(_("invaliddatewarn"));
|
alert(_("invaliddatewarn"));
|
||||||
rc = false;
|
rc = false;
|
||||||
}
|
}
|
||||||
|
@ -105,25 +107,25 @@ function validateContactEditor() {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onFnKeyDown() {
|
function onDisplaynameKeyDown() {
|
||||||
var fn = $("fn");
|
var fn = $("displayname");
|
||||||
fn.onkeydown = null;
|
fn.onkeydown = null;
|
||||||
displayNameChanged = true;
|
displaynameChanged = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onFnNewValue(event) {
|
function onDisplaynameNewValue(event) {
|
||||||
if (!displayNameChanged) {
|
if (!displaynameChanged) {
|
||||||
var sn = $("sn").value.trim();
|
var sn = $("sn").value.trim();
|
||||||
var givenName = $("givenName").value.trim();
|
var givenname = $("givenname").value.trim();
|
||||||
|
|
||||||
var fullName = givenName;
|
var fullname = givenname;
|
||||||
if (fullName && sn)
|
if (fullname && sn)
|
||||||
fullName += ' ';
|
fullname += ' ';
|
||||||
fullName += sn;
|
fullname += sn;
|
||||||
|
|
||||||
$("fn").value = fullName;
|
$("displayname").value = fullname;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -144,7 +146,7 @@ function onEditorSubmitClick(event) {
|
||||||
|
|
||||||
function saveCategories() {
|
function saveCategories() {
|
||||||
var container = $("categoryContainer");
|
var container = $("categoryContainer");
|
||||||
var catsInput = $("contactCategories");
|
var catsInput = $("jsonContactCategories");
|
||||||
if (container && catsInput) {
|
if (container && catsInput) {
|
||||||
var newCategories = $([]);
|
var newCategories = $([]);
|
||||||
var inputs = container.select("INPUT");
|
var inputs = container.select("INPUT");
|
||||||
|
@ -164,8 +166,8 @@ function onDocumentKeydown(event) {
|
||||||
var target = Event.element(event);
|
var target = Event.element(event);
|
||||||
if (target.tagName == "INPUT" || target.tagName == "SELECT") {
|
if (target.tagName == "INPUT" || target.tagName == "SELECT") {
|
||||||
if (event.keyCode == Event.KEY_RETURN) {
|
if (event.keyCode == Event.KEY_RETURN) {
|
||||||
var fcn = onEditorSubmitClick.bind($("submitButton"));
|
var fdisplayname = onEditorSubmitClick.bind($("submitButton"));
|
||||||
fcn();
|
fdisplayname();
|
||||||
Event.stop(event);
|
Event.stop(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -267,10 +269,10 @@ function initEditorForm() {
|
||||||
var controller = new SOGoTabsController();
|
var controller = new SOGoTabsController();
|
||||||
controller.attachToTabsContainer(tabsContainer);
|
controller.attachToTabsContainer(tabsContainer);
|
||||||
|
|
||||||
displayNameChanged = ($("fn").value.length > 0);
|
displaynameChanged = ($("displayname").value.length > 0);
|
||||||
$("fn").onkeydown = onFnKeyDown;
|
$("displayname").onkeydown = onDisplaynameKeyDown;
|
||||||
$("sn").onkeyup = onFnNewValue;
|
$("sn").onkeyup = onDisplaynameNewValue;
|
||||||
$("givenName").onkeyup = onFnNewValue;
|
$("givenname").onkeyup = onDisplaynameNewValue;
|
||||||
|
|
||||||
$("cancelButton").observe("click", onEditorCancelClick);
|
$("cancelButton").observe("click", onEditorCancelClick);
|
||||||
var submitButton = $("submitButton");
|
var submitButton = $("submitButton");
|
||||||
|
@ -280,8 +282,10 @@ function initEditorForm() {
|
||||||
|
|
||||||
Event.observe(document, "keydown", onDocumentKeydown);
|
Event.observe(document, "keydown", onDocumentKeydown);
|
||||||
|
|
||||||
|
if (typeof(gCategories) != "undefined") {
|
||||||
regenerateCategoriesMenu();
|
regenerateCategoriesMenu();
|
||||||
var catsInput = $("contactCategories");
|
}
|
||||||
|
var catsInput = $("jsonContactCategories");
|
||||||
if (catsInput && catsInput.value.length > 0) {
|
if (catsInput && catsInput.value.length > 0) {
|
||||||
var contactCats = $(catsInput.value.evalJSON(false));
|
var contactCats = $(catsInput.value.evalJSON(false));
|
||||||
for (var i = 0; i < contactCats.length; i++) {
|
for (var i = 0; i < contactCats.length; i++) {
|
||||||
|
|
6
Version
6
Version
|
@ -2,6 +2,6 @@
|
||||||
# This file is included by library makefiles to set the version information
|
# This file is included by library makefiles to set the version information
|
||||||
# of the executable.
|
# of the executable.
|
||||||
|
|
||||||
MAJOR_VERSION=1
|
MAJOR_VERSION=2
|
||||||
MINOR_VERSION=3
|
MINOR_VERSION=0
|
||||||
SUBMINOR_VERSION=12
|
SUBMINOR_VERSION=0
|
||||||
|
|
Loading…
Reference in New Issue