mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-04-14 01:38:51 +00:00
Monotone-Parent: b8c85ddcde506f67f18bf96dcff79741af94661b
Monotone-Revision: c3c38efee718461f598c3836c1cbe39986c23fd2 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-05-02T22:46:49 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
19
ChangeLog
19
ChangeLog
@@ -1,3 +1,22 @@
|
||||
2008-05-02 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* SoObjects/SOGo/SOGoDAVRendererTypes.[hm]: removed subclass
|
||||
module, superseded by the new method mentionned below.
|
||||
|
||||
* SoObjects/SOGo/SOGoWebDAVValue.m ([SOGoWebDAVValue
|
||||
-stringForTag:_keyrawName:setTaginContext:contextprefixes:prefixes]):
|
||||
a simple wrapper that returns an uninterpreted NSString to SOPE.
|
||||
|
||||
* SoObjects/SOGo/NSArray+DAV.[hm],
|
||||
* SoObjects/SOGo/NSDictionary+DAV.[hm],
|
||||
* SoObjects/SOGo/NSObject+DAV.[hm],
|
||||
* SoObjects/SOGo/NSString+DAV.[hm],
|
||||
* SoObjects/SOGo/NSURL+DAV.[hm]: new class category modules that
|
||||
handle the correct generation of DAV entries, with namespace
|
||||
accounting. Those were implemented to enable the use of a simple
|
||||
SoWebDAVValue as the root of the resulting string, thereby
|
||||
avoiding the xml escaping done by SOPE when returning a real NSString.
|
||||
|
||||
2008-04-25 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* SoObjects/SOGo/LDAPSource.m ([LDAPSource -fetchContactsMatching:match])
|
||||
|
||||
38
SoObjects/SOGo/NSArray+DAV.h
Normal file
38
SoObjects/SOGo/NSArray+DAV.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/* NSArray+DAV.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2008 Inverse groupe conseil
|
||||
*
|
||||
* 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 NSARRAY_DAV_H
|
||||
#define NSARRAY_DAV_H
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
|
||||
@class NSMutableDictionary;
|
||||
@class NSString;
|
||||
|
||||
@interface NSArray (SOGoWebDAVExtensions)
|
||||
|
||||
- (NSString *)
|
||||
asWebDavStringWithNamespaces: (NSMutableDictionary *) namespaces;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* NSARRAY_DAV_H */
|
||||
45
SoObjects/SOGo/NSArray+DAV.m
Normal file
45
SoObjects/SOGo/NSArray+DAV.m
Normal file
@@ -0,0 +1,45 @@
|
||||
/* NSArray+DAV.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2008 Inverse groupe conseil
|
||||
*
|
||||
* 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 "NSObject+DAV.h"
|
||||
|
||||
#import "NSArray+DAV.h"
|
||||
|
||||
@implementation NSArray (SOGoWebDAVExtensions)
|
||||
|
||||
- (NSString *)
|
||||
asWebDavStringWithNamespaces: (NSMutableDictionary *) namespaces
|
||||
{
|
||||
NSMutableString *webdavString;
|
||||
NSEnumerator *children;
|
||||
NSObject *child;
|
||||
|
||||
webdavString = [NSMutableString string];
|
||||
children = [self objectEnumerator];
|
||||
while ((child = [children nextObject]))
|
||||
[webdavString appendString:
|
||||
[child asWebDavStringWithNamespaces: namespaces]];
|
||||
|
||||
return webdavString;
|
||||
}
|
||||
|
||||
@end
|
||||
37
SoObjects/SOGo/NSDictionary+DAV.h
Normal file
37
SoObjects/SOGo/NSDictionary+DAV.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/* NSDictionary+DAV.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2008 Inverse groupe conseil
|
||||
*
|
||||
* 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_DAV_H
|
||||
#define NSDICTIONARY_DAV_H
|
||||
|
||||
#import <Foundation/NSDictionary.h>
|
||||
|
||||
@class NSString;
|
||||
|
||||
@interface NSDictionary (SOGoWebDAVExtensions)
|
||||
|
||||
- (NSString *)
|
||||
asWebDavStringWithNamespaces: (NSMutableDictionary *) namespaces;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* NSDICTIONARY_DAV_H */
|
||||
95
SoObjects/SOGo/NSDictionary+DAV.m
Normal file
95
SoObjects/SOGo/NSDictionary+DAV.m
Normal file
@@ -0,0 +1,95 @@
|
||||
/* NSDictionary+DAV.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2008 Inverse groupe conseil
|
||||
*
|
||||
* 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/NSEnumerator.h>
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
#import "NSDictionary+DAV.h"
|
||||
|
||||
@implementation NSDictionary (SOGoWebDAVExtensions)
|
||||
|
||||
- (NSString *) _namespaceDecl: (NSDictionary *) namespaces
|
||||
{
|
||||
NSMutableString *decl;
|
||||
NSEnumerator *keys;
|
||||
NSString *key;
|
||||
|
||||
decl = [NSMutableString string];
|
||||
keys = [[namespaces allKeys] objectEnumerator];
|
||||
while ((key = [keys nextObject]))
|
||||
[decl appendFormat: @" xmlns:%@=\"%@\"",
|
||||
[namespaces objectForKey: key], key];
|
||||
|
||||
return decl;
|
||||
}
|
||||
|
||||
- (NSString *) _newTagInNamespaces: (NSMutableDictionary *) namespaces
|
||||
forNS: (NSString *) newNS
|
||||
{
|
||||
NSString *newTag;
|
||||
|
||||
newTag = [NSString stringWithFormat: @"n%d", [namespaces count]];
|
||||
[namespaces setObject: newTag forKey: newNS];
|
||||
|
||||
return newTag;
|
||||
}
|
||||
|
||||
- (NSString *)
|
||||
asWebDavStringWithNamespaces: (NSMutableDictionary *) namespaces
|
||||
{
|
||||
NSMutableString *webdavString;
|
||||
NSString *nsTag, *ns, *subString, *element;
|
||||
BOOL firstLevel;
|
||||
|
||||
if (!namespaces)
|
||||
{
|
||||
firstLevel = YES;
|
||||
namespaces = [NSMutableDictionary new];
|
||||
[namespaces setObject: @"D" forKey: @"DAV:"];
|
||||
}
|
||||
else
|
||||
firstLevel = NO;
|
||||
|
||||
webdavString = [NSMutableString string];
|
||||
ns = [self objectForKey: @"ns"];
|
||||
nsTag = [namespaces objectForKey: ns];
|
||||
if (!nsTag)
|
||||
nsTag = [self _newTagInNamespaces: namespaces forNS: ns];
|
||||
element = [NSString stringWithFormat: @"%@:%@",
|
||||
nsTag, [self objectForKey: @"method"]];
|
||||
[webdavString appendFormat: @"<%@", element];
|
||||
subString = [[self objectForKey: @"content"]
|
||||
asWebDavStringWithNamespaces: namespaces];
|
||||
if (firstLevel)
|
||||
{
|
||||
[webdavString appendString: [self _namespaceDecl: namespaces]];
|
||||
[namespaces release];
|
||||
}
|
||||
if (subString)
|
||||
[webdavString appendFormat: @">%@</%@>", subString, element];
|
||||
else
|
||||
[webdavString appendString: @"/>"];
|
||||
|
||||
return webdavString;
|
||||
}
|
||||
|
||||
@end
|
||||
48
SoObjects/SOGo/NSObject+DAV.h
Normal file
48
SoObjects/SOGo/NSObject+DAV.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/* NSObject+DAV.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2008 Inverse groupe conseil
|
||||
*
|
||||
* 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 NSOBJECT_DAV_H
|
||||
#define NSOBJECT_DAV_H
|
||||
|
||||
#import <Foundation/NSObject.h>
|
||||
|
||||
@class NSMutableDictionary;
|
||||
@class NSString;
|
||||
@class SOGoWebDAVValue;
|
||||
|
||||
#define davElement(t,n) \
|
||||
[NSDictionary dictionaryWithObjectsAndKeys: t, @"method", n, @"ns", nil]
|
||||
|
||||
#define davElementWithContent(t,n,c) \
|
||||
[NSDictionary dictionaryWithObjectsAndKeys: t, @"method", \
|
||||
n, @"ns", \
|
||||
c, @"content", nil]
|
||||
|
||||
@interface NSObject (SOGoWebDAVExtensions)
|
||||
|
||||
- (NSString *)
|
||||
asWebDavStringWithNamespaces: (NSMutableDictionary *) namespaces;
|
||||
- (SOGoWebDAVValue *) asWebDAVValue;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* NSOBJECT_DAV_H */
|
||||
44
SoObjects/SOGo/NSObject+DAV.m
Normal file
44
SoObjects/SOGo/NSObject+DAV.m
Normal file
@@ -0,0 +1,44 @@
|
||||
/* NSObject+DAV.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2008 Inverse groupe conseil
|
||||
*
|
||||
* 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 "SOGoWebDAVValue.h"
|
||||
|
||||
#import "NSObject+DAV.h"
|
||||
|
||||
@implementation NSObject (SOGoWebDAVExtensions)
|
||||
|
||||
- (NSString *)
|
||||
asWebDavStringWithNamespaces: (NSMutableDictionary *) namespaces
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (SOGoWebDAVValue *) asWebDAVValue
|
||||
{
|
||||
return [SOGoWebDAVValue
|
||||
valueForObject: [self asWebDavStringWithNamespaces: nil]
|
||||
attributes: nil];
|
||||
}
|
||||
|
||||
@end
|
||||
37
SoObjects/SOGo/NSString+DAV.h
Normal file
37
SoObjects/SOGo/NSString+DAV.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/* NSString+DAV.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2008 Inverse groupe conseil
|
||||
*
|
||||
* 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_DAV_H
|
||||
#define NSSTRING_DAV_H
|
||||
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
@class NSMutableDictionary;
|
||||
|
||||
@interface NSString (SOGoWebDAVExtensions)
|
||||
|
||||
- (NSString *)
|
||||
asWebDavStringWithNamespaces: (NSMutableDictionary *) namespaces;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* NSSTRING_DAV_H */
|
||||
35
SoObjects/SOGo/NSString+DAV.m
Normal file
35
SoObjects/SOGo/NSString+DAV.m
Normal file
@@ -0,0 +1,35 @@
|
||||
/* NSString+DAV.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2008 Inverse groupe conseil
|
||||
*
|
||||
* 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 <NGExtensions/NSString+misc.h>
|
||||
|
||||
#import "NSString+DAV.h"
|
||||
|
||||
@implementation NSString (SOGoWebDAVExtensions)
|
||||
|
||||
- (NSString *)
|
||||
asWebDavStringWithNamespaces: (NSMutableDictionary *) namespaces
|
||||
{
|
||||
return [self stringByEscapingXMLString];
|
||||
}
|
||||
|
||||
@end
|
||||
37
SoObjects/SOGo/NSURL+DAV.h
Normal file
37
SoObjects/SOGo/NSURL+DAV.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/* NSURL+DAV.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2008 Inverse groupe conseil
|
||||
*
|
||||
* 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 NSURL_DAV_H
|
||||
#define NSURL_DAV_H
|
||||
|
||||
#import <Foundation/NSURL.h>
|
||||
|
||||
@class NSMutableDictionary;
|
||||
|
||||
@interface NSURL (SOGoWebDAVExtensions)
|
||||
|
||||
- (NSString *)
|
||||
asWebDavStringWithNamespaces: (NSMutableDictionary *) namespaces;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* NSURL_DAV_H */
|
||||
36
SoObjects/SOGo/NSURL+DAV.m
Normal file
36
SoObjects/SOGo/NSURL+DAV.m
Normal file
@@ -0,0 +1,36 @@
|
||||
/* NSURL+DAV.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2008 Inverse groupe conseil
|
||||
*
|
||||
* 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 <NGExtensions/NSString+misc.h>
|
||||
#import <NGExtensions/NSURL+misc.h>
|
||||
|
||||
#import "NSURL+DAV.h"
|
||||
|
||||
@implementation NSURL (SOGoWebDAVExtensions)
|
||||
|
||||
- (NSString *)
|
||||
asWebDavStringWithNamespaces: (NSMutableDictionary *) namespaces
|
||||
{
|
||||
return [[self absoluteString] stringByEscapingXMLString];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,60 +0,0 @@
|
||||
/* SOGoDAVRendererTypes.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2006 Inverse groupe conseil
|
||||
*
|
||||
* 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 SOGODAVRENDERERTYPES_H
|
||||
#define SOGODAVRENDERERTYPES_H
|
||||
|
||||
#import <NGObjWeb/SoWebDAVValue.h>
|
||||
|
||||
@class NSArray;
|
||||
@class NSDictionary;
|
||||
@class NSString;
|
||||
|
||||
@interface SOGoDAVSet : SoWebDAVValue
|
||||
{
|
||||
NSString *valueTag;
|
||||
NSArray *values;
|
||||
}
|
||||
|
||||
+ (id) davSetWithArray: (NSArray *) newValues
|
||||
ofValuesTaggedAs: (NSString *) newValueTag;
|
||||
|
||||
- (void) setValueTag: (NSString *) newValueTag;
|
||||
- (void) setValues: (NSArray *) newValues;
|
||||
|
||||
@end
|
||||
|
||||
@interface SOGoDAVDictionary : SoWebDAVValue
|
||||
{
|
||||
NSString *valueTag;
|
||||
NSDictionary *values;
|
||||
}
|
||||
|
||||
+ (id) davDictionary: (NSDictionary *) newValues
|
||||
taggedAs: (NSString *) newValueTag;
|
||||
|
||||
- (void) setValueTag: (NSString *) newValueTag;
|
||||
- (void) setValues: (NSDictionary *) newValues;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* SOGODAVRENDERERTYPES_H */
|
||||
@@ -1,198 +0,0 @@
|
||||
/* SOGoDAVRendererTypes.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2006, 2008 Inverse groupe conseil
|
||||
*
|
||||
* 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/NSEnumerator.h>
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
#import <NGExtensions/NSString+misc.h>
|
||||
|
||||
#import "SOGoDAVRendererTypes.h"
|
||||
|
||||
@implementation SOGoDAVSet
|
||||
|
||||
+ (id) davSetWithArray: (NSArray *) newValues
|
||||
ofValuesTaggedAs: (NSString *) newValueTag
|
||||
{
|
||||
id davSet;
|
||||
|
||||
davSet = [self new];
|
||||
[davSet setValueTag: newValueTag];
|
||||
[davSet setValues: newValues];
|
||||
[davSet autorelease];
|
||||
|
||||
return davSet;
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
valueTag = nil;
|
||||
values = nil;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[valueTag release];
|
||||
[values release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) setValueTag: (NSString *) newValueTag
|
||||
{
|
||||
ASSIGN (valueTag, newValueTag);
|
||||
}
|
||||
|
||||
- (void) setValues: (NSArray *) newValues
|
||||
{
|
||||
ASSIGN (values, newValues);
|
||||
}
|
||||
|
||||
- (NSString *) stringForTag: (NSString *) _key
|
||||
rawName: (NSString *) setTag
|
||||
inContext: (id) context
|
||||
prefixes: (NSDictionary *) prefixes
|
||||
{
|
||||
NSMutableString *resultString;
|
||||
id currentValue;
|
||||
NSString *valueString;
|
||||
NSEnumerator *valueEnum;
|
||||
|
||||
resultString = [NSMutableString new];
|
||||
[resultString autorelease];
|
||||
|
||||
// [resultString appendFormat: @"<%@>", setTag];
|
||||
valueEnum = [values objectEnumerator];
|
||||
while ((currentValue = [valueEnum nextObject]))
|
||||
{
|
||||
if ([currentValue isKindOfClass: [SoWebDAVValue class]])
|
||||
valueString
|
||||
= [currentValue stringForTag:
|
||||
[NSString stringWithFormat: @"{DAV:}%@", valueTag]
|
||||
rawName: [NSString stringWithFormat: @"D:%@", valueTag]
|
||||
inContext: context
|
||||
prefixes: prefixes];
|
||||
else
|
||||
valueString = [[currentValue description] stringByEscapingXMLString];
|
||||
|
||||
[resultString appendFormat: valueString];
|
||||
// [resultString appendFormat: @"<%@>%@</%@>",
|
||||
// valueTag, valueString, valueTag];
|
||||
}
|
||||
// [resultString appendFormat: @"</%@>", setTag];
|
||||
|
||||
NSLog(@"dav rendering for key '%@' and tag '%@':\n", _key, setTag,
|
||||
resultString);
|
||||
|
||||
return resultString;
|
||||
}
|
||||
|
||||
- (NSString *) stringValue
|
||||
{
|
||||
return [self stringForTag: valueTag rawName: valueTag
|
||||
inContext: nil prefixes: nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation SOGoDAVDictionary
|
||||
|
||||
+ (id) davDictionary: (NSDictionary *) newValues
|
||||
taggedAs: (NSString *) newValueTag;
|
||||
{
|
||||
SOGoDAVDictionary *davDictionary;
|
||||
|
||||
davDictionary = [self new];
|
||||
[davDictionary setValueTag: newValueTag];
|
||||
[davDictionary setValues: newValues];
|
||||
[davDictionary autorelease];
|
||||
|
||||
return davDictionary;
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
valueTag = nil;
|
||||
values = nil;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[valueTag release];
|
||||
[values release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) setValueTag: (NSString *) newValueTag
|
||||
{
|
||||
ASSIGN (valueTag, newValueTag);
|
||||
}
|
||||
|
||||
- (void) setValues: (NSDictionary *) newValues
|
||||
{
|
||||
ASSIGN (values, newValues);
|
||||
}
|
||||
|
||||
- (NSString *) stringForTag: (NSString *) _key
|
||||
rawName: (NSString *) setTag
|
||||
inContext: (id) context
|
||||
prefixes: (NSDictionary *) prefixes
|
||||
{
|
||||
NSMutableString *resultString;
|
||||
id currentValue;
|
||||
NSEnumerator *objects;
|
||||
NSString *currentKey, *valueString;
|
||||
|
||||
resultString = [NSMutableString string];
|
||||
|
||||
[resultString appendFormat: @"<%@>", valueTag];
|
||||
objects = [[values allKeys] objectEnumerator];
|
||||
while ((currentKey = [objects nextObject]))
|
||||
{
|
||||
currentValue = [values objectForKey: currentKey];
|
||||
if ([currentValue isKindOfClass: [SoWebDAVValue class]])
|
||||
valueString
|
||||
= [currentValue stringForTag:
|
||||
[NSString stringWithFormat: @"{DAV:}%@", valueTag]
|
||||
rawName: [NSString stringWithFormat: @"D:%@", valueTag]
|
||||
inContext: context
|
||||
prefixes: prefixes];
|
||||
else
|
||||
valueString = [[currentValue description] stringByEscapingXMLString];
|
||||
|
||||
[resultString appendFormat: @"<%@>%@</%@>", currentKey, valueString, currentKey];
|
||||
}
|
||||
[resultString appendFormat: @"</%@>", valueTag];
|
||||
|
||||
return resultString;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user