Please use gnustep-base instead.
#endif
+#import <unistd.h>
+
+#import <Foundation/NSBundle.h>
#import <Foundation/NSClassDescription.h>
#import <Foundation/NSString.h>
#import <Foundation/NSUserDefaults.h>
#import <Foundation/NSURL.h>
#import <Foundation/NSValue.h>
+#import <NGObjWeb/SoClass.h>
#import <NGObjWeb/SoClassSecurityInfo.h>
#import <NGObjWeb/SoObject+SoDAV.h>
#import <NGObjWeb/WEClientCapabilities.h>
#import <NGObjWeb/WOApplication.h>
#import <NGObjWeb/WOContext.h>
+#import <NGObjWeb/WOResourceManager.h>
#import <NGObjWeb/WOResponse.h>
#import <NGObjWeb/WORequest.h>
#import <NGObjWeb/WORequest+So.h>
#import <NGObjWeb/NSException+HTTP.h>
#import <NGExtensions/NSObject+Logs.h>
#import <NGExtensions/NSString+misc.h>
+#import <DOM/DOMProtocols.h>
#import <NGCards/NSDictionary+NGCards.h>
#import <UI/SOGoUI/SOGoACLAdvisory.h>
#import "SOGoPermissions.h"
#import "SOGoUser.h"
-#import "SOGoAuthenticator.h"
+#import "SOGoDAVAuthenticator.h"
#import "SOGoUserFolder.h"
#import "SOGoDAVRendererTypes.h"
#import "NSArray+Utilities.h"
+#import "NSCalendarDate+SOGo.h"
+#import "NSDictionary+Utilities.h"
#import "NSString+Utilities.h"
#import "SOGoObject.h"
// SoClass security declarations
// require View permission to access the root (bound to authenticated ...)
- [[self soClassSecurityInfo] declareObjectProtected: SoPerm_View];
+// [[self soClassSecurityInfo] declareObjectProtected: SoPerm_View];
// to allow public access to all contained objects (subkeys)
- [[self soClassSecurityInfo] setDefaultAccess: @"allow"];
+// [[self soClassSecurityInfo] setDefaultAccess: @"allow"];
// /* require Authenticated role for View and WebDAV */
// [[self soClassSecurityInfo] declareRole: SoRole_Owner
// asDefaultForPermission: SoPerm_WebDAVAccess];
}
++ (NSString *) globallyUniqueObjectId
+{
+ /*
+ 4C08AE1A-A808-11D8-AC5A-000393BBAFF6
+ SOGo-Web-28273-18283-288182
+ printf( "%x", *(int *) &f);
+ */
+ static int pid = 0;
+ static int sequence = 0;
+ static float rndm = 0;
+ float f;
+
+ if (pid == 0)
+ { /* break if we fork ;-) */
+ pid = getpid();
+ rndm = random();
+ }
+ sequence++;
+ f = [[NSDate date] timeIntervalSince1970];
+
+ return [NSString stringWithFormat:@"%0X-%0X-%0X-%0X",
+ pid, (int) f, sequence++, random];
+}
+
+- (NSString *) globallyUniqueObjectId
+{
+ return [[self class] globallyUniqueObjectId];
+}
+
+ (void) _fillDictionary: (NSMutableDictionary *) dictionary
withDAVMethods: (NSString *) firstMethod, ...
{
- (SOGoDAVSet *) davCurrentUserPrivilegeSet
{
- SOGoAuthenticator *sAuth;
+ SOGoDAVAuthenticator *sAuth;
SoUser *user;
NSArray *roles;
SoClassSecurityInfo *sInfo;
NSArray *davPermissions;
- sAuth = [SOGoAuthenticator sharedSOGoAuthenticator];
+ sAuth = [SOGoDAVAuthenticator sharedSOGoDAVAuthenticator];
user = [sAuth userInContext: context];
roles = [user rolesForObject: self inContext: context];
sInfo = [[self class] soClassSecurityInfo];
return container;
}
+- (NSArray *) pathArrayToSOGoObject
+{
+ NSMutableArray *realPathArray;
+ NSString *objectName;
+ NSArray *objectDescription;
+
+ realPathArray
+ = [NSMutableArray arrayWithArray: [self pathArrayToSoObject]];
+ if ([realPathArray count] > 2)
+ {
+ objectName = [realPathArray objectAtIndex: 2];
+ if ([objectName isKindOfClass: [NSString class]])
+ {
+ objectDescription = [objectName componentsSeparatedByString: @"_"];
+ if ([objectDescription count] > 1)
+ {
+ [realPathArray replaceObjectAtIndex: 0
+ withObject: [objectDescription objectAtIndex: 0]];
+ [realPathArray replaceObjectAtIndex: 2
+ withObject: [objectDescription objectAtIndex: 1]];
+ }
+ }
+ }
+
+ return realPathArray;
+}
+
/* ownership */
- (void) setOwner: (NSString *) newOwner
return ma;
}
+- (id) lookupName: (NSString *) lookupName
+ inContext: (id) localContext
+ acquire: (BOOL) acquire
+{
+ id obj;
+
+ obj = [[self soClass] lookupKey: lookupName inContext: localContext];
+ if (obj)
+ [obj bindToObject: self inContext: localContext];
+
+ return obj;
+}
+
/* looking up shared objects */
-- (SOGoUserFolder *)lookupUserFolder {
+- (SOGoUserFolder *) lookupUserFolder
+{
if (![container respondsToSelector:_cmd])
return nil;
return [container lookupUserFolder];
}
-- (SOGoGroupsFolder *)lookupGroupsFolder {
+- (SOGoGroupsFolder *) lookupGroupsFolder
+{
return [[self lookupUserFolder] lookupGroupsFolder];
}
return @"text/plain";
}
+- (NSString *) davLastModified
+{
+ return [[NSCalendarDate date] rfc822DateString];
+}
+
- (WOResponse *) _webDAVResponse: (WOContext *) localContext
{
WOResponse *response;
return response;
}
+- (NSString *) _parseXMLCommand: (id <DOMDocument>) document
+{
+ NSString *command;
+
+ command = [[document firstChild] nodeName];
+
+ return [NSString stringWithFormat: @"%@:", command];
+}
+
+- (id) POSTAction: (id) localContext
+{
+ id obj;
+ NSString *cType, *command;
+ id <DOMDocument> document;
+ SEL commandSel;
+ WORequest *rq;
+
+ obj = nil;
+
+ rq = [localContext request];
+ if ([rq isSoWebDAVRequest])
+ {
+ cType = [rq headerForKey: @"content-type"];
+ if ([cType isEqualToString: @"application/xml"])
+ {
+ document = [rq contentAsDOMDocument];
+ command = [[self _parseXMLCommand: document] davMethodToObjC];
+ commandSel = NSSelectorFromString (command);
+ if ([self respondsToSelector: commandSel])
+ obj = [self performSelector: commandSel withObject: localContext];
+ }
+ }
+
+ return obj;
+}
+
- (id) GETAction: (id) localContext
{
// TODO: I guess this should really be done by SOPE (redirect to
/* acls */
+/* roles required to obtain the "authorized subscriber" role */
+- (NSArray *) subscriptionRoles
+{
+ return [container subscriptionRoles];
+}
+
- (NSArray *) aclUsers
{
[self subclassResponsibility: _cmd];
@"/"]];
if ([baseURL hasPrefix: @"http"])
{
- [path removeObjectAtIndex: 2];
[path removeObjectAtIndex: 1];
[path removeObjectAtIndex: 0];
+ [path replaceObjectAtIndex: 0 withObject: @""];
}
urlMethod = [path objectAtIndex: 2];
if (![urlMethod isEqualToString: expected])
return nil;
}
+- (NSString *) labelForKey: (NSString *) key
+{
+ NSString *userLanguage, *label;
+ NSArray *paths;
+ NSBundle *bundle;
+ NSDictionary *strings;
+
+ bundle = [NSBundle bundleForClass: [self class]];
+ if (!bundle)
+ bundle = [NSBundle mainBundle];
+
+ userLanguage = [[context activeUser] language];
+ paths = [bundle pathsForResourcesOfType: @"strings"
+ inDirectory: [NSString stringWithFormat: @"%@.lproj",
+ userLanguage]
+ forLocalization: userLanguage];
+ if ([paths count] > 0)
+ {
+ strings = [NSDictionary
+ dictionaryFromStringsFile: [paths objectAtIndex: 0]];
+ label = [strings objectForKey: key];
+ if (!label)
+ label = key;
+ }
+ else
+ label = key;
+
+ return label;
+}
+
/* description */
- (void)appendAttributesToDescription:(NSMutableString *)_ms {
return ms;
}
+- (NSString *) loggingPrefix
+{
+ return [NSString stringWithFormat:@"<0x%08X[%@]:%@>",
+ self, NSStringFromClass([self class]),
+ [self nameInContainer]];
+}
+
@end /* SOGoObject */