Monotone-Parent: 17441bc6502df80d7fa89d2f1beee98ac6e2c5d9

Monotone-Revision: c4c95e670daa9c22e838239469a51f3d23b84ab0

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2007-09-14T21:59:00
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2007-09-14 21:59:00 +00:00
parent 321e9b964e
commit beac7e7aea
3 changed files with 109 additions and 3 deletions

View File

@@ -1,3 +1,14 @@
2007-09-14 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* SoObjects/SOGo/SOGoObject.m ([SOGoObject -labelForKey:key]): new
method that returns translated strings for controller bundles
(same as what UIxComponent does for view bundles).
([SOGoObject -pathArrayToSOGoObject]): new method that returns
the real path to a subscribed folder (if subscribed).
([SOGoObject +globallyUniqueObjectId]): move method from SOGoFolder.
([SOGoObject -globallyUniqueObjectId]): new instance method
calling its class equivalent.
2007-09-12 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* UI/MainUI/SOGoRootPage.m ([SOGoRootPage -defaultAction]): test

View File

@@ -61,6 +61,9 @@
id container;
}
+ (NSString *) globallyUniqueObjectId;
- (NSString *) globallyUniqueObjectId;
+ (id) objectWithName: (NSString *)_name inContainer:(id)_container;
- (id) initWithName: (NSString *) _name inContainer:(id)_container;
@@ -70,11 +73,15 @@
- (NSString *) nameInContainer;
- (id) container;
- (NSArray *) pathArrayToSOGoObject;
- (NSURL *) davURL;
- (NSURL *) soURL;
- (NSURL *) soURLToBaseContainerForUser: (NSString *) uid;
- (NSURL *) soURLToBaseContainerForCurrentUser;
- (NSString *) labelForKey: (NSString *) key;
/* ownership */
- (void) setOwner: (NSString *) newOwner;
@@ -100,7 +107,7 @@
/* etag support */
- (NSException *)matchesRequestConditionInContext:(id)_ctx;
- (NSException *) matchesRequestConditionInContext:(id)_ctx;
/* acls */

View File

@@ -24,6 +24,9 @@
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>
@@ -35,6 +38,7 @@
#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>
@@ -52,6 +56,7 @@
#import "SOGoDAVRendererTypes.h"
#import "NSArray+Utilities.h"
#import "NSDictionary+Utilities.h"
#import "NSString+Utilities.h"
#import "SOGoObject.h"
@@ -179,6 +184,35 @@ static BOOL kontactGroupDAV = YES;
// 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, ...
{
@@ -447,6 +481,30 @@ static BOOL kontactGroupDAV = YES;
return container;
}
- (NSArray *) pathArrayToSOGoObject
{
NSMutableArray *realPathArray;
NSString *objectName;
NSArray *objectDescription;
realPathArray
= [NSMutableArray arrayWithArray: [self pathArrayToSoObject]];
if ([realPathArray count] > 2)
{
objectName = [realPathArray objectAtIndex: 2];
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
@@ -493,14 +551,16 @@ static BOOL kontactGroupDAV = YES;
/* 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];
}
@@ -905,6 +965,34 @@ static BOOL kontactGroupDAV = YES;
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 {