From 63cdf938508d031e9691af66fdc8eec8deb48897 Mon Sep 17 00:00:00 2001 From: helge Date: Thu, 1 Jul 2004 22:34:37 +0000 Subject: [PATCH] git-svn-id: http://svn.opengroupware.org/SOGo/trunk@135 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/Main/README | 5 + SOGo/Main/sogod.m | 12 ++ SOGo/SoObjects/Appointments/ChangeLog | 6 + .../Appointments/SOGoAppointmentFolder.m | 5 +- SOGo/SoObjects/SOGo/SOGoContentObject.h | 3 +- SOGo/SoObjects/SOGo/SOGoContentObject.m | 17 ++ SOGo/UI/Common/ChangeLog | 4 + SOGo/UI/Common/UIxTabView.m | 162 ++------------ SOGo/UI/Scheduler/UIxAppointmentEditor.m | 203 +++++++++--------- 9 files changed, 168 insertions(+), 249 deletions(-) create mode 100644 SOGo/SoObjects/Appointments/ChangeLog diff --git a/SOGo/Main/README b/SOGo/Main/README index 9d7a9ab6..e228602f 100644 --- a/SOGo/Main/README +++ b/SOGo/Main/README @@ -11,3 +11,8 @@ Setup Defaults write sogod NGBundlePath '"$HOME/Library/SOGo"' => otherwise some bundles will clash with "fat" OGo => the UIx .wox driver must be found + +Defaults +======== + + SOGoCrashOnSessionCreate - bool - crash the server is a session is created diff --git a/SOGo/Main/sogod.m b/SOGo/Main/sogod.m index 36f296f4..c1ff3ae8 100644 --- a/SOGo/Main/sogod.m +++ b/SOGo/Main/sogod.m @@ -36,10 +36,13 @@ @implementation SOGo static unsigned int vMemSizeLimit = 0; +static BOOL doCrashOnSessionCreate = NO; + (void)initialize { NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; id tmp; + + doCrashOnSessionCreate = [ud boolForKey:@"SOGoCrashOnSessionCreate"]; /* vMem size check - default is 200MB */ @@ -172,6 +175,15 @@ static unsigned int vMemSizeLimit = 0; return resp; } +/* session management */ + +- (WOSession *)createSessionForRequest:(WORequest *)_request { + [self logWithFormat:@"WARNING: session creation requested!"]; + if (doCrashOnSessionCreate) + abort(); + return [super createSessionForRequest:_request]; +} + @end /* SOGo */ diff --git a/SOGo/SoObjects/Appointments/ChangeLog b/SOGo/SoObjects/Appointments/ChangeLog new file mode 100644 index 00000000..b3888f90 --- /dev/null +++ b/SOGo/SoObjects/Appointments/ChangeLog @@ -0,0 +1,6 @@ +2004-07-01 Helge Hess + + * redirect to weekoverview if GET is run on the folder itself + + * created ChangeLog + diff --git a/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m b/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m index 3013b40b..6019eee5 100644 --- a/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -29,6 +29,8 @@ @implementation SOGoAppointmentFolder +static BOOL debugOn = NO; + + (NSString *)globallyUniqueObjectId { /* 4C08AE1A-A808-11D8-AC5A-000393BBAFF6 @@ -174,7 +176,8 @@ printf( "%x", *(int *) &f); } records = [self fixupRecords:records]; - [self logWithFormat:@"fetched %i records: %@", [records count], records]; + if (debugOn) + [self logWithFormat:@"fetched %i records: %@", [records count], records]; return records; } diff --git a/SOGo/SoObjects/SOGo/SOGoContentObject.h b/SOGo/SoObjects/SOGo/SOGoContentObject.h index c85ee07c..1bb949c0 100644 --- a/SOGo/SoObjects/SOGo/SOGoContentObject.h +++ b/SOGo/SoObjects/SOGo/SOGoContentObject.h @@ -25,7 +25,7 @@ #include -@class NSString; +@class NSString, NSException; @interface SOGoContentObject : SOGoObject { @@ -46,6 +46,7 @@ /* content */ - (NSString *)contentAsString; +- (NSException *)saveContentString:(NSString *)_str; @end diff --git a/SOGo/SoObjects/SOGo/SOGoContentObject.m b/SOGo/SoObjects/SOGo/SOGoContentObject.m index b9c3162d..4713650f 100644 --- a/SOGo/SoObjects/SOGo/SOGoContentObject.m +++ b/SOGo/SoObjects/SOGo/SOGoContentObject.m @@ -92,6 +92,23 @@ return self->content; } +- (NSException *)saveContentString:(NSString *)_str { + OCSFolder *folder; + NSException *ex; + + if ((folder = [self ocsFolder]) == nil) { + [self logWithFormat:@"did not find folder of appointment."]; + return nil; + } + + if ((ex = [folder writeContent:_str toName:[self nameInContainer]])) { + [self logWithFormat:@"write failed: %@", ex]; + return ex; + } + + return nil; +} + /* description */ - (void)appendAttributesToDescription:(NSMutableString *)_ms { diff --git a/SOGo/UI/Common/ChangeLog b/SOGo/UI/Common/ChangeLog index 50aaf591..3ef4e3b2 100644 --- a/SOGo/UI/Common/ChangeLog +++ b/SOGo/UI/Common/ChangeLog @@ -1,3 +1,7 @@ +2004-07-01 Helge Hess + + * UIxTabView.m: removed JavaScript and the involved access of -session + 2004-06-30 Helge Hess * product.plist: make categories on SOGoObject instead of SxFolder diff --git a/SOGo/UI/Common/UIxTabView.m b/SOGo/UI/Common/UIxTabView.m index ac635c3e..041761e2 100644 --- a/SOGo/UI/Common/UIxTabView.m +++ b/SOGo/UI/Common/UIxTabView.m @@ -291,11 +291,9 @@ static NSNumber *YesNumber; isActive:(BOOL)_isActive isLeft:(BOOL)_isLeft doScript:(BOOL)_doScript keys:(NSArray *)_keys { - NSString *headUri = nil; - NSString *label = nil; - NSString *scriptHref = nil; - NSString *styleName = nil; - + NSString *headUri = nil; + NSString *label = nil; + NSString *styleName = nil; WEClientCapabilities *ccaps; WOComponent *comp; @@ -337,14 +335,7 @@ static NSNumber *YesNumber; [_response appendContentString:@"isScript || _isActive)) { - scriptHref = - [self scriptHref:_info inContext:_ctx isLeft:_isLeft keys:_keys]; - [_response appendContentHTMLAttributeValue:scriptHref]; - } - else { - [_response appendContentHTMLAttributeValue:headUri]; - } + [_response appendContentHTMLAttributeValue:headUri]; [_response appendContentString:@"\" "]; [_response appendContentString: @@ -360,75 +351,6 @@ static NSNumber *YesNumber; [_response appendContentString:@""]; [_response appendContentString:@""]; - -#if 0 - if (_doScript && (_info->isScript || _isActive)) { - NSString *k; // key - NSString *s; // selected tab icon - NSString *u; // unselected tab icon - //NSString *out; - - k = _info->key; - s = _info->selIcon; // selectedTabIcon - u = (_isLeft) ? _info->leftIcon : _info->tabIcon; - - s = WEUriOfResource(s, _ctx); - u = WEUriOfResource(u, _ctx); - - s = ([s length] < 1) ? imgUri : s; - u = ([u length] < 1) ? imgUri : u; - -#if 0 - out = [NSString alloc]; - out = [out initWithFormat: - @"", - k, k, k, k, scriptHref, k, headUri, - k, k, k, k, - k, u, k, k, s - ]; - - [_response appendContentString:out]; - RELEASE(out); -#else -# define _appendStr_(_str_) [_response appendContentString:_str_] - _appendStr_(@""); -#undef _appendStr_ -#endif - } -#endif } - (void)appendSubmitButton:(UIxTabItemInfo *)_info @@ -441,7 +363,7 @@ static NSNumber *YesNumber; toResponse:_response inContext:_ctx isActive:_isActive isLeft:_left - doScript:_doScript keys:_keys]; + doScript:NO keys:_keys]; } - (void)_appendTabViewJSScriptToResponse:(WOResponse *)_response @@ -525,7 +447,7 @@ static NSNumber *YesNumber; inContext:_ctx isActive:isActive isLeft:(i == 0) ? YES : NO - doScript:doScript + doScript:NO keys:keys]; } else { @@ -535,7 +457,7 @@ static NSNumber *YesNumber; inContext:_ctx isActive:isActive isLeft:(i == 0) ? YES : NO - doScript:doScript + doScript:NO keys:keys]; } @@ -571,44 +493,23 @@ static NSNumber *YesNumber; /* left corner */ [_response appendContentString:@" "]; - if (doScript) { - [_response appendContentString:@"
"]; - [_response appendContentString:@" "]; - [_response appendContentString:@"
"]; - } - else if (isLeftActive) + if (isLeftActive) [_response appendContentString:@" "]; - if (doScript) { - [_response appendContentString:@"
"]; - } - - if (!isLeftActive || doScript) { + if (!isLeftActive) { NSString *uri; uri = [self->leftCornerIcon stringValueInComponent:[_ctx component]]; if ((uri = WEUriOfResource(uri, _ctx))) { [_response appendContentString:@"\"\""]; + [_response appendContentString:@"\" />"]; } else [_response appendContentString:@" "]; } - if (doScript) - [_response appendContentString:@"
"]; - - [_response appendContentString:@"\n"]; + + [_response appendContentString:@""]; /* right corner */ [_response appendContentString:@" "]; @@ -708,31 +609,14 @@ static NSNumber *YesNumber; WOComponent *cmp; NSString *bgcolor; BOOL isLeftActive; - BOOL doScript; id nestedState; NSString *activeKey; NSArray *keys; int tabViewCount; /* used for image id's and writing script once */ - doScript = NO; /* perform tab-clicks on browser (use javascript) */ tabViewCount = [[_ctx valueForKey:@"UIxTabViewScriptDone"] intValue]; cmp = [_ctx component]; - /* check for browser */ - { - WEClientCapabilities *ccaps; - //BOOL isJavaScriptBrowser; - - ccaps = [[_ctx request] clientCapabilities]; - doScript = [ccaps isInternetExplorer] && [ccaps isJavaScriptBrowser]; - doScript = (doScript && - [[[cmp session] - valueForKey:@"isJavaScriptEnabled"] boolValue]); - } - - /* disable javascript */ - doScript = NO; - /* save state */ nestedState = [self saveNestedStateInContext:_ctx]; @@ -760,17 +644,8 @@ static NSNumber *YesNumber; if ([self->selection isValueSettable]) [self->selection setValue:activeKey inComponent:[_ctx component]]; } - - if (doScript) { - doScript = [[keys valueForKey:@"isScript"] containsObject:YesNumber]; - [_ctx setObject:[NSNumber numberWithBool:doScript] - forKey:UIxTabView_SCRIPT]; - } - - /* start appending */ - if ((doScript) && (tabViewCount == 0)) - [self _appendTabViewJSScriptToResponse:_response inContext:_ctx]; + /* start appending */ /* count up for unique tabCorner/tabCornerLeft images */ [_ctx takeValue:[NSNumber numberWithInt:(tabViewCount + 1)] @@ -788,20 +663,11 @@ static NSNumber *YesNumber; [self _appendHeaderRowToResponse:_response inContext:_ctx keys:keys activeKey:activeKey - doScript:doScript]; + doScript:NO]; [_ctx deleteLastElementIDComponent]; // 'h' for head [_ctx removeObjectForKey:UIxTabView_HEAD]; -#if 0 - /* header foot row */ - - [self _appendHeaderFootRowToResponse:_response inContext:_ctx - bgcolor:bgcolor - doScript:doScript - isLeftActive:isLeftActive]; -#endif - /* body row */ [self _appendBodyRowToResponse:_response inContext:_ctx diff --git a/SOGo/UI/Scheduler/UIxAppointmentEditor.m b/SOGo/UI/Scheduler/UIxAppointmentEditor.m index db63474a..0a2bf309 100644 --- a/SOGo/UI/Scheduler/UIxAppointmentEditor.m +++ b/SOGo/UI/Scheduler/UIxAppointmentEditor.m @@ -164,38 +164,36 @@ /* helper */ - (NSString *)uriAsFormat { - NSString *uri, *qp; - NSRange r; + NSString *uri, *qp; + NSRange r; - uri = [[[self context] request] uri]; + uri = [[[self context] request] uri]; - /* first: identify query parameters */ - r = [uri rangeOfString:@"?" options:NSBackwardsSearch]; - if (r.length > 0) { - uri = [uri substringToIndex:r.location]; - qp = [uri substringFromIndex:r.location]; - } - else { - qp = nil; - } + /* first: identify query parameters */ + r = [uri rangeOfString:@"?" options:NSBackwardsSearch]; + if (r.length > 0) { + uri = [uri substringToIndex:r.location]; + qp = [uri substringFromIndex:r.location]; + } + else + qp = nil; - /* next: strip trailing slash */ - if([uri hasSuffix:@"/"]) - uri = [uri substringToIndex:([uri length] - 1)]; - r = [uri rangeOfString:@"/" options:NSBackwardsSearch]; + /* next: strip trailing slash */ + if ([uri hasSuffix:@"/"]) + uri = [uri substringToIndex:([uri length] - 1)]; + r = [uri rangeOfString:@"/" options:NSBackwardsSearch]; - /* then: cut of last path component */ - if(r.location == NSNotFound) { // no slash? are we at root? - uri = @"/"; - } - else { - uri = [uri substringToIndex:(r.location + 1)]; - } - /* next: append format token */ - uri = [uri stringByAppendingString:@"%@"]; - if(qp != nil) - uri = [uri stringByAppendingString:qp]; - return uri; + /* then: cut of last path component */ + if (r.length == 0) // no slash? are we at root? + uri = @"/"; + else + uri = [uri substringToIndex:(r.location + 1)]; + + /* next: append format token */ + uri = [uri stringByAppendingString:@"%@"]; + if(qp != nil) + uri = [uri stringByAppendingString:qp]; + return uri; } @@ -212,7 +210,7 @@ method? */ objectId = [NSClassFromString(@"SOGoAppointmentFolder") - globallyUniqueObjectId]; + globallyUniqueObjectId]; nextMethod = [NSString stringWithFormat:@"%@/edit", objectId]; uriFormat = [self uriAsFormat]; @@ -230,78 +228,85 @@ - (id)saveAction { - SOGoAppointment *apt; - NSString *iCalString, *summary, *location, *nextMethod, *uri, *uriFormat; - NSCalendarDate *sd, *ed; - NSArray *ps; - unsigned i, count; - WOResponse *r; - WORequest *req; - - req = [[self context] request]; - - /* get iCalString from hidden input */ - iCalString = [req formValueForKey:@"ical"]; - apt = [[SOGoAppointment alloc] initWithICalString:iCalString]; - - /* merge in form values */ - sd = [NSCalendarDate dateWithString:[req formValueForKey:@"startDate"] - calendarFormat:@"%Y-%m-%d %H:%M"]; - [apt setStartDate:sd]; - ed = [NSCalendarDate dateWithString:[req formValueForKey:@"endDate"] - calendarFormat:@"%Y-%m-%d %H:%M"]; - [apt setEndDate:ed]; - summary = [req formValueForKey:@"summary"]; - [apt setSummary:summary]; - location = [req formValueForKey:@"location"]; - [apt setLocation:location]; - - [apt removeAllAttendees]; /* clean up */ - ps = [[req formValueForKey:@"participants"] - componentsSeparatedByString:@"\n"]; - count = [ps count]; - for(i = 0; i < count; i++) { - NSString *email; - - email = [ps objectAtIndex:i]; - if([email length] > 0) { - iCalPerson *p; - NSRange cnr; - - p = [[iCalPerson alloc] init]; - [p setEmail:[NSString stringWithFormat:@"mailto:%@", email]]; - /* construct a fake CN */ - cnr = [email rangeOfString:@"@"]; - if(cnr.location != NSNotFound) { - [p setCn:[email substringToIndex:cnr.location]]; - } - [apt addToAttendees:p]; - [p release]; - } - } - - /* receive current representation for save operation */ - iCalString = [apt iCalString]; - [apt release]; - - - /* determine what's to do and where to go next */ - if([self isNewAppointment]) { - nextMethod = @"duhduh"; - } - else { - nextMethod = @"view"; - } + SOGoAppointment *apt; + NSString *iCalString; + NSString *summary, *location, *nextMethod, *uri, *uriFormat; + NSCalendarDate *sd, *ed; + NSArray *ps; + unsigned i, count; + WOResponse *r; + WORequest *req; - NSLog(@"%s new iCalString:\n%@", __PRETTY_FUNCTION__, iCalString); + req = [[self context] request]; - uriFormat = [self uriAsFormat]; - uri = [NSString stringWithFormat:uriFormat, nextMethod]; + /* get iCalString from hidden input */ + iCalString = [req formValueForKey:@"ical"]; + apt = [[SOGoAppointment alloc] initWithICalString:iCalString]; + + /* merge in form values */ + sd = [NSCalendarDate dateWithString:[req formValueForKey:@"startDate"] + calendarFormat:@"%Y-%m-%d %H:%M"]; + [apt setStartDate:sd]; + ed = [NSCalendarDate dateWithString:[req formValueForKey:@"endDate"] + calendarFormat:@"%Y-%m-%d %H:%M"]; + [apt setEndDate:ed]; + summary = [req formValueForKey:@"summary"]; + [apt setSummary:summary]; + location = [req formValueForKey:@"location"]; + [apt setLocation:location]; + + [apt removeAllAttendees]; /* clean up */ + ps = [[req formValueForKey:@"participants"] + componentsSeparatedByString:@"\n"]; + count = [ps count]; + for (i = 0; i < count; i++) { + NSString *email; + iCalPerson *p; + NSRange cnr; + + email = [ps objectAtIndex:i]; + if ([email length] == 0) + continue; + + p = [[iCalPerson alloc] init]; + [p setEmail:[@"mailto:" stringByAppendingString:[email stringValue]]]; + /* construct a fake CN */ + cnr = [email rangeOfString:@"@"]; + if (cnr.length > 0) + [p setCn:[email substringToIndex:cnr.location]]; + [apt addToAttendees:p]; + [p release]; + } + + /* receive current representation for save operation */ + iCalString = [apt iCalString]; + [apt release]; apt = nil; + + /* determine what's to do and where to go next */ + if([self isNewAppointment]) + nextMethod = @"duhduh"; + else + nextMethod = @"view"; + +#if 0 + NSLog(@"%s new iCalString:\n%@", __PRETTY_FUNCTION__, iCalString); +#else + { + NSException *ex; + + ex = [[self clientObject] saveContentString:iCalString]; + if (ex) return ex; + // TODO: add some error handling in form! (eg like in Zope) + } +#endif + + uriFormat = [self uriAsFormat]; + uri = [NSString stringWithFormat:uriFormat, nextMethod]; - r = [WOResponse responseWithRequest:req]; - [r setStatus:302 /* moved */]; - [r setHeader:uri forKey:@"location"]; - return r; + r = [WOResponse responseWithRequest:req]; + [r setStatus:302 /* moved */]; + [r setHeader:uri forKey:@"location"]; + return r; } -@end +@end /* UIxAppointmentEditor */ -- 2.39.2