From b3e824b042eebcc99aa5c626e9f62be4ed2653ec Mon Sep 17 00:00:00 2001 From: wolfgang Date: Wed, 11 Apr 2007 20:13:07 +0000 Subject: [PATCH] git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1045 d1b88da0-ebda-0310-925b-ed51d893ca5b --- ChangeLog | 24 ++ .../Appointments/SOGoAppointmentFolder.h | 10 +- .../Appointments/SOGoAppointmentFolder.m | 104 +++++---- .../Appointments/SOGoAppointmentObject.h | 10 +- .../Appointments/SOGoAppointmentObject.m | 65 +----- .../Appointments/SOGoCalendarComponent.h | 2 + .../Appointments/SOGoCalendarComponent.m | 91 ++++++-- SoObjects/Appointments/SOGoFreeBusyObject.m | 10 +- .../Appointments/SOGoGroupAppointmentFolder.m | 4 +- SoObjects/Appointments/SOGoTaskObject.h | 18 +- SoObjects/Appointments/SOGoTaskObject.m | 64 +----- SoObjects/Contacts/SOGoContactFolders.m | 23 +- SoObjects/Contacts/SOGoContactLDAPFolder.m | 4 +- SoObjects/Mailer/SOGoDraftObject.m | 6 +- SoObjects/Mailer/SOGoMailAccount.m | 14 +- SoObjects/Mailer/SOGoMailAccounts.m | 28 +-- SoObjects/Mailer/SOGoMailBaseObject.m | 2 +- SoObjects/SOGo/NSString+Utilities.h | 4 + SoObjects/SOGo/NSString+Utilities.m | 9 + SoObjects/SOGo/SOGoContentObject.m | 1 - SoObjects/SOGo/SOGoGroupFolder.m | 5 +- SoObjects/SOGo/SOGoObject.h | 6 +- SoObjects/SOGo/SOGoObject.m | 94 ++------ SoObjects/SOGo/SOGoUser.h | 34 ++- SoObjects/SOGo/SOGoUser.m | 141 +++++++++--- SoObjects/SOGo/SOGoUserFolder.m | 90 ++++---- UI/MailPartViewers/UIxMailPartICalViewer.m | 16 +- UI/MainUI/SOGoUserHomePage.m | 5 +- UI/MainUI/product.plist | 14 +- UI/SOGoUI/UIxComponent.m | 41 ++-- UI/Scheduler/GNUmakefile | 1 - UI/Scheduler/UIxAppointmentEditor.m | 16 +- UI/Scheduler/UIxAppointmentProposal.m | 53 +++-- UI/Scheduler/UIxAppointmentView.h | 22 +- UI/Scheduler/UIxAppointmentView.m | 14 +- UI/Scheduler/UIxCalAptListView.m | 8 +- UI/Scheduler/UIxCalDateSelector.m | 2 +- UI/Scheduler/UIxCalMonthView.m | 6 +- UI/Scheduler/UIxCalSelectTab.m | 115 ---------- UI/Scheduler/UIxCalView.h | 2 + UI/Scheduler/UIxCalView.m | 21 +- UI/Scheduler/UIxCalendarSelector.m | 3 +- UI/Scheduler/UIxComponentEditor.m | 7 +- UI/Scheduler/UIxTaskEditor.m | 12 +- UI/Scheduler/UIxTaskProposal.m | 83 ++++--- UI/Scheduler/UIxTaskView.m | 20 +- UI/Scheduler/UIxTimeDateControl.m | 14 +- .../SchedulerUI/UIxCalMonthOverview.wox | 216 ------------------ UI/Templates/SchedulerUI/UIxCalSelectTab.wox | 26 --- 49 files changed, 627 insertions(+), 953 deletions(-) delete mode 100644 UI/Scheduler/UIxCalSelectTab.m delete mode 100644 UI/Templates/SchedulerUI/UIxCalMonthOverview.wox delete mode 100644 UI/Templates/SchedulerUI/UIxCalSelectTab.wox diff --git a/ChangeLog b/ChangeLog index 60b5ef6e..f3d2c8f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +2007-04-11 Wolfgang Sourdeau + + * SoObjects/SOGo/NSString+Utilities.m ([NSString -boolValue]): new + method that SOGo will need with non-gnustep Foundation + implementation. + ([NSString -stringByAppendingPathComponent:component]): new method + that SOGo will need when building with libFoundation. Method + removed later since it is available from + Foundation/NSPathUtilities.h. + + * SoObjects/SOGo/SOGoUser.m ([SOGoUser -timeZone]): method moved + from SOGoObject.m. + + * SoObjects/SOGo/SOGoObject.m: new ivar "context" that permits + every subclass to access [WOApplication context] without having to + invoke it more than once. + + * SoObjects/Appointments/SOGoCalendarComponent.m + ([SOGoCalendarComponent -changeParticipationStatus:_status]): + moved method from SOGoTaskObject and SOGoAppointmentObject up to + their parent class. + + * UI/Scheduler/UIxCalSelectTab.m: removed module. + 2007-04-10 Wolfgang Sourdeau * SoObjects/Contacts/SOGoContactGCSEntry.m ([SOGoContactGCSEntry diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.h b/SoObjects/Appointments/SOGoAppointmentFolder.h index b072bb20..0ca7c086 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.h +++ b/SoObjects/Appointments/SOGoAppointmentFolder.h @@ -38,11 +38,17 @@ #import "SOGo/SOGoFolder.h" -@class NSString, NSArray, NSCalendarDate, NSException, NSMutableDictionary; +@class NSArray; +@class NSCalendarDate; +@class NSException; +@class NSMutableDictionary; +@class NSString; +@class NSTimeZone; @class GCSFolder; @interface SOGoAppointmentFolder : SOGoFolder { + NSTimeZone *timeZone; NSMutableDictionary *uidToFilename; } @@ -106,7 +112,7 @@ - (NSArray *) fetchAllSOGoAppointments; -- (NSArray *) calendarFoldersInContext: (WOContext *) context; +- (NSArray *) calendarFolders; @end diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index 80691900..b877f300 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -84,12 +84,23 @@ static NSNumber *sharedYes = nil; // SOGoRole_Assistant, nil] // asDefaultForPermission: SoPerm_View]; - sharedYes = [[NSNumber numberWithBool:YES] retain]; + sharedYes = [[NSNumber numberWithBool: YES] retain]; +} + +- (id) initWithName: (NSString *) name + inContainer: (id) newContainer +{ + if ((self = [super initWithName: name inContainer: newContainer])) + { + timeZone = [[context activeUser] timeZone]; + } + + return self; } - (void) dealloc { - [self->uidToFilename release]; + [uidToFilename release]; [super dealloc]; } @@ -108,8 +119,7 @@ static NSNumber *sharedYes = nil; NSString *s; s = [[self container] nameInContainer]; -#warning HH DEBUG - [self logWithFormat:@"CAL UID: %@", s]; +// [self logWithFormat:@"CAL UID: %@", s]; return [s isNotNull] ? [NSArray arrayWithObjects:&s count:1] : nil; } @@ -237,7 +247,6 @@ static NSNumber *sharedYes = nil; - (void) _appendComponentsMatchingFilters: (NSArray *) filters toResponse: (WOResponse *) response - inContext: (WOContext *) context { NSArray *apts; unsigned int count, max; @@ -266,7 +275,7 @@ static NSNumber *sharedYes = nil; } } -- (id) davCalendarQuery: (id) context +- (id) davCalendarQuery: (id) queryContext { WOResponse *r; NSArray *filters; @@ -285,8 +294,7 @@ static NSNumber *sharedYes = nil; document = [[context request] contentAsDOMDocument]; filters = [self _parseCalendarFilters: [document documentElement]]; [self _appendComponentsMatchingFilters: filters - toResponse: r - inContext: context]; + toResponse: r]; [r appendContentString:@"\r\n"]; return r; @@ -342,7 +350,6 @@ static NSNumber *sharedYes = nil; } - (BOOL) requestNamedIsHandledLater: (NSString *) name - inContext: (WOContext *) context { return [name isEqualToString: @"OPTIONS"]; } @@ -356,7 +363,7 @@ static NSNumber *sharedYes = nil; BOOL handledLater; /* first check attributes directly bound to the application */ - handledLater = [self requestNamedIsHandledLater: _key inContext: _ctx]; + handledLater = [self requestNamedIsHandledLater: _key]; if (handledLater) obj = nil; else @@ -467,7 +474,7 @@ static NSNumber *sharedYes = nil; if (![_uid isNotNull]) return nil; - if ((rname = [self->uidToFilename objectForKey:_uid]) != nil) + if ((rname = [uidToFilename objectForKey:_uid]) != nil) return [rname isNotNull] ? rname : nil; if ((folder = [self ocsFolder]) == nil) { @@ -476,13 +483,13 @@ static NSNumber *sharedYes = nil; return nil; } - if (self->uidToFilename == nil) - self->uidToFilename = [[NSMutableDictionary alloc] initWithCapacity:16]; + if (uidToFilename == nil) + uidToFilename = [[NSMutableDictionary alloc] initWithCapacity:16]; if ((rname = [self resourceNameForEventUID:_uid inFolder:folder]) == nil) - [self->uidToFilename setObject:[NSNull null] forKey:_uid]; + [uidToFilename setObject:[NSNull null] forKey:_uid]; else - [self->uidToFilename setObject:rname forKey:_uid]; + [uidToFilename setObject:rname forKey:_uid]; return rname; } @@ -527,7 +534,7 @@ static NSNumber *sharedYes = nil; if ((tmp = [_record objectForKey:@"startdate"])) { tmp = [[NSCalendarDate alloc] initWithTimeIntervalSince1970: (NSTimeInterval)[tmp unsignedIntValue]]; - [tmp setTimeZone: [self userTimeZone]]; + [tmp setTimeZone: timeZone]; if (tmp) [md setObject:tmp forKey:@"startDate"]; [tmp release]; } @@ -537,7 +544,7 @@ static NSNumber *sharedYes = nil; if ((tmp = [_record objectForKey:@"enddate"])) { tmp = [[NSCalendarDate alloc] initWithTimeIntervalSince1970: (NSTimeInterval)[tmp unsignedIntValue]]; - [tmp setTimeZone: [self userTimeZone]]; + [tmp setTimeZone: timeZone]; if (tmp) [md setObject:tmp forKey:@"endDate"]; [tmp release]; } @@ -557,15 +564,41 @@ static NSNumber *sharedYes = nil; /* cycle is in _r */ tmp = [_r startDate]; - [tmp setTimeZone:[self userTimeZone]]; + [tmp setTimeZone: timeZone]; [md setObject:tmp forKey:@"startDate"]; tmp = [_r endDate]; - [tmp setTimeZone:[self userTimeZone]]; + [tmp setTimeZone: timeZone]; [md setObject:tmp forKey:@"endDate"]; return md; } +- (NSArray *) fixupRecords: (NSArray *) records + fetchRange: (NGCalendarDateRange *) r +{ + // TODO: is the result supposed to be sorted by date? + NSMutableArray *ma; + unsigned count, max; + id row; // TODO: what is the type of the record? + + if (records) + { + max = [records count]; + ma = [NSMutableArray arrayWithCapacity: max]; + for (count = 0; count < max; count++) + { + row = [self fixupRecord: [records objectAtIndex: count] + fetchRange: r]; + if (row) + [ma addObject: row]; + } + } + else + ma = nil; + + return ma; +} + - (void) _flattenCycleRecord: (NSDictionary *) _row forRange: (NGCalendarDateRange *) _r intoArray: (NSMutableArray *) _ma @@ -611,28 +644,6 @@ static NSNumber *sharedYes = nil; } } -- (NSArray *) fixupRecords: (NSArray *) _records - fetchRange: (NGCalendarDateRange *) _r -{ - // TODO: is the result supposed to be sorted by date? - NSMutableArray *ma; - unsigned i, count; - - if (_records == nil) return nil; - if ((count = [_records count]) == 0) - return _records; - - ma = [NSMutableArray arrayWithCapacity:count]; - for (i = 0; i < count; i++) { - id row; // TODO: what is the type of the record? - - row = [_records objectAtIndex:i]; - row = [self fixupRecord:row fetchRange:_r]; - if (row != nil) [ma addObject:row]; - } - return ma; -} - - (NSArray *) fixupCyclicRecords: (NSArray *) _records fetchRange: (NGCalendarDateRange *) _r { @@ -692,10 +703,8 @@ static NSNumber *sharedYes = nil; - (NSString *) _privacySqlString { NSString *privacySqlString, *owner, *currentUser, *email; - WOContext *context; SOGoUser *activeUser; - context = [[WOApplication application] context]; activeUser = [context activeUser]; currentUser = [activeUser login]; owner = [self ownerInContext: context]; @@ -876,10 +885,8 @@ static NSNumber *sharedYes = nil; Class objectClass; unsigned int count, max; NSString *currentId, *currentUser; - WOContext *context; id deleteObject; - context = [[WOApplication application] context]; currentUser = [[context activeUser] login]; max = [ids count]; @@ -927,11 +934,9 @@ static NSNumber *sharedYes = nil; if (![_uid isNotNull]) return nil; - if (_ctx == nil) _ctx = [[WOApplication application] context]; - /* create subcontext, so that we don't destroy our environment */ - if ((ctx = [_ctx createSubContext]) == nil) { + if ((ctx = [context createSubContext]) == nil) { [self errorWithFormat:@"could not create SOPE subcontext!"]; return nil; } @@ -1166,7 +1171,7 @@ static NSNumber *sharedYes = nil; return firstShouldBeActive; } -- (NSArray *) calendarFoldersInContext: (WOContext *) context +- (NSArray *) calendarFolders { NSMutableDictionary *userCalendar, *calendarDict; NSMutableArray *calendarFolders; @@ -1177,7 +1182,6 @@ static NSNumber *sharedYes = nil; [calendarFolders autorelease]; activeUser = [context activeUser]; - userCalendar = [NSMutableDictionary new]; [userCalendar autorelease]; [userCalendar setObject: @"/" forKey: @"folder"]; diff --git a/SoObjects/Appointments/SOGoAppointmentObject.h b/SoObjects/Appointments/SOGoAppointmentObject.h index 17e9b24b..d6fe91e8 100644 --- a/SoObjects/Appointments/SOGoAppointmentObject.h +++ b/SoObjects/Appointments/SOGoAppointmentObject.h @@ -48,22 +48,18 @@ /* folder management */ -- (id) lookupHomeFolderForUID: (NSString *) _uid inContext: (id)_ctx; +- (id) lookupHomeFolderForUID: (NSString *) _uid + inContext: (id) _ctx; - (NSArray *) lookupCalendarFoldersForUIDs: (NSArray *) _uids inContext: (id) _ctx; /* "iCal multifolder saves" */ -- (NSException *) saveContentString: (NSString *)_iCal +- (NSException *) saveContentString: (NSString *) _iCal baseSequence: (int) _v; - (NSException *) deleteWithBaseSequence: (int) _v; - - (NSException *) saveContentString: (NSString *) _iCalString; -- (NSException *) changeParticipationStatus: (NSString *) _status - inContext: (id) _ctx; - - @end #endif /* __Appointments_SOGoAppointmentObject_H__ */ diff --git a/SoObjects/Appointments/SOGoAppointmentObject.m b/SoObjects/Appointments/SOGoAppointmentObject.m index 4fbebbdb..ea76ffb2 100644 --- a/SoObjects/Appointments/SOGoAppointmentObject.m +++ b/SoObjects/Appointments/SOGoAppointmentObject.m @@ -112,11 +112,8 @@ NSEnumerator *e; id folder; NSException *allErrors = nil; - id ctx; - - ctx = [[WOApplication application] context]; - e = [[self lookupCalendarFoldersForUIDs:_uids inContext:ctx] + e = [[self lookupCalendarFoldersForUIDs:_uids inContext: context] objectEnumerator]; while ((folder = [e nextObject]) != nil) { NSException *error; @@ -125,7 +122,7 @@ if (![folder isNotNull]) /* no folder was found for given UID */ continue; - apt = [folder lookupName: [self nameInContainer] inContext:ctx + apt = [folder lookupName: [self nameInContainer] inContext: context acquire: NO]; if ([apt isKindOfClass: [NSException class]]) { @@ -160,17 +157,14 @@ NSEnumerator *e; id folder; NSException *allErrors = nil; - id ctx; - - ctx = [[WOApplication application] context]; - e = [[self lookupCalendarFoldersForUIDs:_uids inContext:ctx] + e = [[self lookupCalendarFoldersForUIDs:_uids inContext: context] objectEnumerator]; while ((folder = [e nextObject])) { NSException *error; SOGoAppointmentObject *apt; - apt = [folder lookupName:[self nameInContainer] inContext:ctx + apt = [folder lookupName:[self nameInContainer] inContext: context acquire:NO]; if ([apt isKindOfClass: [NSException class]]) { [self logWithFormat: @"%@", [(NSException *) apt reason]]; @@ -428,57 +422,6 @@ return [self saveContentString: _iCalString baseSequence: 0]; } -- (NSException *) changeParticipationStatus: (NSString *) _status - inContext: (id) _ctx -{ - iCalEvent *apt; - iCalPerson *p; - NSString *newContent; - NSException *ex; - NSString *myEMail; - - ex = nil; - - // TODO: do we need to use SOGoAppointment? (prefer iCalEvent?) - apt = (iCalEvent *) [self component: NO]; - - if (apt) - { - myEMail = [[_ctx activeUser] email]; - p = [apt findParticipantWithEmail: myEMail]; - if (p) - { - // TODO: send iMIP reply mails? - - [p setPartStat:_status]; - newContent = [[apt parent] versitString]; - if (newContent) - { - ex = [self saveContentString:newContent]; - if (ex) - // TODO: why is the exception wrapped? - /* Server Error */ - ex = [NSException exceptionWithHTTPStatus: 500 - reason: [ex reason]]; - } - else - ex - = [NSException exceptionWithHTTPStatus: 500 /* Server Error */ - reason: @"Could not generate iCalendar data ..."]; - } - else - ex = [NSException exceptionWithHTTPStatus: 404 /* Not Found */ - reason: @"user does not participate in this " - @"appointment"]; - } - else - ex = [NSException exceptionWithHTTPStatus:500 /* Server Error */ - reason:@"unable to parse appointment record"]; - - return ex; -} - - /* message type */ - (NSString *) outlookMessageClass diff --git a/SoObjects/Appointments/SOGoCalendarComponent.h b/SoObjects/Appointments/SOGoCalendarComponent.h index 80230884..1f7299bc 100644 --- a/SoObjects/Appointments/SOGoCalendarComponent.h +++ b/SoObjects/Appointments/SOGoCalendarComponent.h @@ -48,6 +48,8 @@ - (NSException *) delete; +- (NSException *) changeParticipationStatus: (NSString *) _status; + /* mail notifications */ - (BOOL) sendEMailNotifications; - (void) sendEMailUsingTemplateNamed: (NSString *) _pageName diff --git a/SoObjects/Appointments/SOGoCalendarComponent.m b/SoObjects/Appointments/SOGoCalendarComponent.m index 12ba6c6e..d240805a 100644 --- a/SoObjects/Appointments/SOGoCalendarComponent.m +++ b/SoObjects/Appointments/SOGoCalendarComponent.m @@ -29,9 +29,9 @@ #import #import -#import -#import -#import +#import +#import +#import #import "common.h" @@ -113,7 +113,6 @@ static BOOL sendEMailNotifications = NO; NSString *tmpContent, *email; iCalCalendar *tmpCalendar; iCalRepeatableEntityObject *tmpComponent; - WOContext *context; if (!calContent) { @@ -125,7 +124,6 @@ static BOOL sendEMailNotifications = NO; tmpComponent = (iCalRepeatableEntityObject *) [tmpCalendar firstChildWithTag: [self componentTag]]; if (![tmpComponent isPublic]) { - context = [[WOApplication application] context]; email = [[context activeUser] email]; if (!([tmpComponent isOrganizer: email] || [tmpComponent isParticipant: email])) @@ -231,14 +229,12 @@ static BOOL sendEMailNotifications = NO; { NSString *baseURL; NSString *uid; - WOContext *ctx; NSArray *traversalObjects; /* generate URL from traversal stack */ - ctx = [[WOApplication application] context]; - traversalObjects = [ctx objectTraversalStack]; + traversalObjects = [context objectTraversalStack]; if ([traversalObjects count] > 0) - baseURL = [[traversalObjects objectAtIndex:0] baseURLInContext:ctx]; + baseURL = [[traversalObjects objectAtIndex:0] baseURLInContext: context]; else { baseURL = @"http://localhost/"; @@ -252,11 +248,66 @@ static BOOL sendEMailNotifications = NO; : nil); } +- (NSException *) changeParticipationStatus: (NSString *) _status +{ + iCalRepeatableEntityObject *component; + iCalPerson *p; + NSString *newContent; + NSException *ex; + NSString *myEMail; + + ex = nil; + + component = [self component: NO]; + if (component) + { + myEMail = [[context activeUser] email]; + p = [component findParticipantWithEmail: myEMail]; + if (p) + { + // TODO: send iMIP reply mails? + [p setPartStat: _status]; + newContent = [[component parent] versitString]; + if (newContent) + { + ex = [self saveContentString:newContent]; + if (ex) + // TODO: why is the exception wrapped? + /* Server Error */ + ex = [NSException exceptionWithHTTPStatus: 500 + reason: [ex reason]]; + } + else + ex + = [NSException exceptionWithHTTPStatus: 500 /* Server Error */ + reason: @"Could not generate iCalendar data ..."]; + } + else + ex = [NSException exceptionWithHTTPStatus: 404 /* Not Found */ + reason: @"user does not participate in this " + @"calendar component"]; + } + else + ex = [NSException exceptionWithHTTPStatus: 500 /* Server Error */ + reason: @"unable to parse component record"]; + + return ex; +} + - (BOOL) sendEMailNotifications { return sendEMailNotifications; } +- (NSTimeZone *) timeZoneForUser: (NSString *) email +{ + NSString *uid; + + uid = [[AgenorUserManager sharedUserManager] getUIDForEmail: email]; + + return [[SOGoUser userWithLogin: uid andRoles: nil] timeZone]; +} + - (void) sendEMailUsingTemplateNamed: (NSString *) _pageName forOldObject: (iCalRepeatableEntityObject *) _oldObject andNewObject: (iCalRepeatableEntityObject *) _newObject @@ -264,7 +315,7 @@ static BOOL sendEMailNotifications = NO; { NSString *pageName; iCalPerson *organizer; - NSString *cn, *sender, *iCalString; + NSString *cn, *email, *sender, *iCalString; NGSendMail *sendmail; WOApplication *app; unsigned i, count; @@ -308,12 +359,12 @@ static BOOL sendEMailNotifications = NO; /* construct recipient */ cn = [attendee cn]; + email = [attendee rfc822Email]; if (cn) recipient = [NSString stringWithFormat: @"%@ <%@>", - cn, - [attendee rfc822Email]]; + cn, email]; else - recipient = [attendee rfc822Email]; + recipient = email; /* create page name */ // TODO: select user's default language? @@ -321,11 +372,11 @@ static BOOL sendEMailNotifications = NO; mailTemplateDefaultLanguage, _pageName]; /* construct message content */ - p = [app pageWithName: pageName inContext: [WOContext context]]; + p = [app pageWithName: pageName inContext: context]; [p setNewApt: _newObject]; [p setOldApt: _oldObject]; [p setHomePageURL: [self homePageURLForPerson: attendee]]; - [p setViewTZ: [self userTimeZone: cn]]; + [p setViewTZ: [self timeZoneForUser: email]]; subject = [p getSubject]; text = [p getBody]; @@ -375,14 +426,13 @@ static BOOL sendEMailNotifications = NO; /* send the damn thing */ [sendmail sendMimePart: msg - toRecipients: [NSArray arrayWithObject: [attendee rfc822Email]] + toRecipients: [NSArray arrayWithObject: email] sender: [organizer rfc822Email]]; } } } - (NSArray *) rolesOfUser: (NSString *) login - inContext: (WOContext *) context { AgenorUserManager *um; iCalRepeatableEntityObject *component; @@ -403,15 +453,14 @@ static BOOL sendEMailNotifications = NO; [sogoRoles addObject: SOGoRole_Organizer]; else if ([component isParticipant: email]) [sogoRoles addObject: SOGoRole_Participant]; - else if ([[container ownerInContext: nil] isEqualToString: login]) + else if ([[container ownerInContext: context] isEqualToString: login]) [sogoRoles addObject: SoRole_Owner]; } else { - user = [[SOGoUser alloc] initWithLogin: login roles: nil]; + user = [SOGoUser userWithLogin: login andRoles: nil]; [sogoRoles addObjectsFromArray: [user rolesForObject: container inContext: context]]; - [user release]; } return sogoRoles; @@ -431,7 +480,7 @@ static BOOL sendEMailNotifications = NO; = ([organizerEmail caseInsensitiveCompare: email] == NSOrderedSame); else isOrganizerOrOwner - = [[container ownerInContext: nil] isEqualToString: login]; + = [[container ownerInContext: context] isEqualToString: login]; return isOrganizerOrOwner; } diff --git a/SoObjects/Appointments/SOGoFreeBusyObject.m b/SoObjects/Appointments/SOGoFreeBusyObject.m index 1c469aa0..5edd59e4 100644 --- a/SoObjects/Appointments/SOGoFreeBusyObject.m +++ b/SoObjects/Appointments/SOGoFreeBusyObject.m @@ -47,14 +47,17 @@ - (NSString *) contentAsString { NSCalendarDate *today, *startDate, *endDate; + NSTimeZone *timeZone; today = [[NSCalendarDate calendarDate] beginOfDay]; - [today setTimeZone: [self userTimeZone]]; + timeZone = [[context activeUser] timeZone]; + [today setTimeZone: timeZone]; startDate = [today dateByAddingYears: 0 months: 0 days: -14 hours: 0 minutes: 0 seconds: 0]; endDate = [startDate dateByAddingYears: 0 months: 1 days: 0 hours: 0 minutes: 0 seconds: 0]; + return [self contentAsStringFrom: startDate to: endDate]; } @@ -72,16 +75,13 @@ { id calFolder; SoSecurityManager *sm; - WOApplication *woApp; NSArray *infos; - woApp = [WOApplication application]; - calFolder = [container lookupName: @"Calendar" inContext: nil acquire: NO]; sm = [SoSecurityManager sharedSecurityManager]; if (![sm validatePermission: SOGoPerm_FreeBusyLookup onObject: calFolder - inContext: [woApp context]]) + inContext: context]) infos = [calFolder fetchFreeBusyInfosFrom: _startDate to: _endDate]; else diff --git a/SoObjects/Appointments/SOGoGroupAppointmentFolder.m b/SoObjects/Appointments/SOGoGroupAppointmentFolder.m index c154c5b3..099fdf4f 100644 --- a/SoObjects/Appointments/SOGoGroupAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoGroupAppointmentFolder.m @@ -130,10 +130,8 @@ NSMutableArray *result; NSMutableDictionary *uidToRecord; unsigned i, count; - WOContext *context; SoSecurityManager *securityManager; - context = [[WOApplication application] context]; securityManager = [SoSecurityManager sharedSecurityManager]; folders = [[self container] memberFolders]; @@ -166,7 +164,7 @@ onObject: aptFolder inContext: context]) { [self debugWithFormat:@"no permission to read the content of calendar: %@", - [folders objectAtIndex:i]]; + [folders objectAtIndex:i]]; continue; } diff --git a/SoObjects/Appointments/SOGoTaskObject.h b/SoObjects/Appointments/SOGoTaskObject.h index 23436263..9f57bf58 100644 --- a/SoObjects/Appointments/SOGoTaskObject.h +++ b/SoObjects/Appointments/SOGoTaskObject.h @@ -46,19 +46,17 @@ /* folder management */ -- (id)lookupHomeFolderForUID:(NSString *)_uid inContext:(id)_ctx; -- (NSArray *)lookupCalendarFoldersForUIDs:(NSArray *)_uids inContext:(id)_ctx; +- (id) lookupHomeFolderForUID: (NSString *) _uid + inContext: (id) _ctx; +- (NSArray *) lookupCalendarFoldersForUIDs: (NSArray *) _uids + inContext: (id) _ctx; /* "iCal multifolder saves" */ -- (NSException *)saveContentString:(NSString *)_iCal baseSequence:(int)_v; -- (NSException *)deleteWithBaseSequence:(int)_v; - -- (NSException *)saveContentString:(NSString *)_iCalString; - -- (NSException *)changeParticipationStatus:(NSString *)_status - inContext:(id)_ctx; - +- (NSException *) saveContentString: (NSString *) _iCal + baseSequence: (int) _v; +- (NSException *) deleteWithBaseSequence: (int) _v; +- (NSException *) saveContentString: (NSString *) _iCalString; @end diff --git a/SoObjects/Appointments/SOGoTaskObject.m b/SoObjects/Appointments/SOGoTaskObject.m index c364b922..861b32c0 100644 --- a/SoObjects/Appointments/SOGoTaskObject.m +++ b/SoObjects/Appointments/SOGoTaskObject.m @@ -121,6 +121,7 @@ static NSString *mailTemplateDefaultLanguage = nil; // TODO: what does this do? lookup the home of the organizer? return [[self container] lookupHomeFolderForUID:_uid inContext:_ctx]; } + - (NSArray *)lookupCalendarFoldersForUIDs:(NSArray *)_uids inContext:(id)_ctx { return [[self container] lookupCalendarFoldersForUIDs:_uids inContext:_ctx]; } @@ -131,11 +132,8 @@ static NSString *mailTemplateDefaultLanguage = nil; NSEnumerator *e; id folder; NSException *allErrors = nil; - id ctx; - ctx = [[WOApplication application] context]; - - e = [[self lookupCalendarFoldersForUIDs:_uids inContext:ctx] + e = [[self lookupCalendarFoldersForUIDs: _uids inContext: context] objectEnumerator]; while ((folder = [e nextObject]) != nil) { NSException *error; @@ -144,7 +142,7 @@ static NSString *mailTemplateDefaultLanguage = nil; if (![folder isNotNull]) /* no folder was found for given UID */ continue; - task = [folder lookupName:[self nameInContainer] inContext:ctx + task = [folder lookupName:[self nameInContainer] inContext: context acquire:NO]; if ([task isKindOfClass: [NSException class]]) { @@ -173,18 +171,16 @@ static NSString *mailTemplateDefaultLanguage = nil; NSEnumerator *e; id folder; NSException *allErrors = nil; - id ctx; - - ctx = [[WOApplication application] context]; - e = [[self lookupCalendarFoldersForUIDs:_uids inContext:ctx] + e = [[self lookupCalendarFoldersForUIDs: _uids inContext: context] objectEnumerator]; while ((folder = [e nextObject])) { NSException *error; SOGoTaskObject *task; - task = [folder lookupName:[self nameInContainer] inContext:ctx - acquire:NO]; + task = [folder lookupName: [self nameInContainer] + inContext: context + acquire: NO]; if (![task isNotNull]) { [self logWithFormat:@"Note: did not find '%@' in folder: %@", [self nameInContainer], folder]; @@ -452,52 +448,6 @@ static NSString *mailTemplateDefaultLanguage = nil; return [self saveContentString:_iCalString baseSequence:0]; } -- (NSException *)changeParticipationStatus:(NSString *)_status - inContext:(id)_ctx -{ - iCalToDo *task; - iCalPerson *p; - NSString *newContent; - NSException *ex; - NSString *myEMail; - - // TODO: do we need to use SOGoTask? (prefer iCalToDo?) - task = (iCalToDo *) [self component: NO]; - - if (task == nil) { - return [NSException exceptionWithHTTPStatus:500 /* Server Error */ - reason:@"unable to parse task record"]; - } - - myEMail = [[_ctx activeUser] email]; - if ((p = [task findParticipantWithEmail:myEMail]) == nil) { - return [NSException exceptionWithHTTPStatus:404 /* Not Found */ - reason:@"user does not participate in this " - @"task"]; - } - - [p setPartStat:_status]; - newContent = [[task parent] versitString]; - - // TODO: send iMIP reply mails? - -// [task release]; task = nil; - - if (newContent == nil) { - return [NSException exceptionWithHTTPStatus:500 /* Server Error */ - reason:@"Could not generate iCalendar data ..."]; - } - - if ((ex = [self saveContentString:newContent]) != nil) { - // TODO: why is the exception wrapped? - return [NSException exceptionWithHTTPStatus:500 /* Server Error */ - reason:[ex reason]]; - } - - return nil /* means: no error */; -} - - /* message type */ - (NSString *)outlookMessageClass { diff --git a/SoObjects/Contacts/SOGoContactFolders.m b/SoObjects/Contacts/SOGoContactFolders.m index fb81bb53..6e61cc67 100644 --- a/SoObjects/Contacts/SOGoContactFolders.m +++ b/SoObjects/Contacts/SOGoContactFolders.m @@ -169,7 +169,7 @@ } } -- (void) initContactSourcesInContext: (WOContext *) context; +- (void) initContactSources { if (!contactFolders) { @@ -180,18 +180,18 @@ } - (id) lookupName: (NSString *) name - inContext: (WOContext *) context + inContext: (WOContext *) lookupContext acquire: (BOOL) acquire { id obj; id folder; /* first check attributes directly bound to the application */ - obj = [super lookupName: name inContext: context acquire: NO]; + obj = [super lookupName: name inContext: lookupContext acquire: NO]; if (!obj) { if (!contactFolders) - [self initContactSourcesInContext: context]; + [self initContactSources]; folder = [contactFolders objectForKey: name]; obj = ((folder) @@ -204,32 +204,21 @@ - (NSArray *) toManyRelationshipKeys { - WOContext *context; - if (!contactFolders) - { - context = [[WOApplication application] context]; - [self initContactSourcesInContext: context]; - } + [self initContactSources]; return [contactFolders allKeys]; } - (NSArray *) contactFolders { - WOContext *context; - if (!contactFolders) - { - context = [[WOApplication application] context]; - [self initContactSourcesInContext: context]; - } + [self initContactSources]; return [contactFolders allValues]; } - (NSString *) roleOfUser: (NSString *) uid - inContext: (WOContext *) context { NSArray *roles, *traversalPath; NSString *objectName, *role; diff --git a/SoObjects/Contacts/SOGoContactLDAPFolder.m b/SoObjects/Contacts/SOGoContactLDAPFolder.m index fb51aa20..3338f05c 100644 --- a/SoObjects/Contacts/SOGoContactLDAPFolder.m +++ b/SoObjects/Contacts/SOGoContactLDAPFolder.m @@ -281,7 +281,7 @@ } - (id) lookupName: (NSString *) name - inContext: (WOContext *) context + inContext: (WOContext *) lookupContext acquire: (BOOL) acquire { id obj; @@ -290,7 +290,7 @@ // NSLog (@"looking up name '%@'...", name); /* first check attributes directly bound to the application */ - obj = [super lookupName: name inContext: context acquire: NO]; + obj = [super lookupName: name inContext: lookupContext acquire: NO]; if (!obj) { [self _loadEntries: name]; diff --git a/SoObjects/Mailer/SOGoDraftObject.m b/SoObjects/Mailer/SOGoDraftObject.m index e82cd1ff..9f66bb9e 100644 --- a/SoObjects/Mailer/SOGoDraftObject.m +++ b/SoObjects/Mailer/SOGoDraftObject.m @@ -344,7 +344,6 @@ static NSString *fromInternetSuffixPattern = nil; { NSDictionary *lInfo; NGMimeMessage *message; - WOContext *ctx; NSString *fromInternetSuffix; BOOL addSuffix; id body; @@ -352,12 +351,11 @@ static NSString *fromInternetSuffixPattern = nil; if ((lInfo = [self fetchInfo]) == nil) return nil; - ctx = [[WOApplication application] context]; - addSuffix = [ctx isAccessFromIntranet] ? NO : YES; + addSuffix = [context isAccessFromIntranet] ? NO : YES; if (addSuffix) { fromInternetSuffix = [fromInternetSuffixPattern stringByReplacingVariablesWithBindings: - [ctx request] + [context request] stringForUnknownBindings:@""]; addSuffix = [fromInternetSuffix length] > 0 ? YES : NO; diff --git a/SoObjects/Mailer/SOGoMailAccount.m b/SoObjects/Mailer/SOGoMailAccount.m index 8a362fdd..a1c6285d 100644 --- a/SoObjects/Mailer/SOGoMailAccount.m +++ b/SoObjects/Mailer/SOGoMailAccount.m @@ -124,16 +124,8 @@ static BOOL useAltNamespace = NO; /* identity */ - (SOGoMailIdentity *)preferredIdentity { - WOContext *ctx; - - if ((ctx = [[WOApplication application] context]) == nil) { - [self logWithFormat:@"ERROR(%s): cannot procede without context!", - __PRETTY_FUNCTION__]; - return nil; - } - - return [[ctx activeUser] primaryMailIdentityForAccount: - [self nameInContainer]]; + return [[context activeUser] primaryMailIdentityForAccount: + [self nameInContainer]]; } /* hierarchy */ @@ -161,7 +153,7 @@ static BOOL useAltNamespace = NO; NSString *s; NSArray *creds; - rq = [[(WOApplication *)[WOApplication application] context] request]; + rq = [context request]; s = [rq headerForKey:@"x-webobjects-remote-user"]; if ([s length] > 0) diff --git a/SoObjects/Mailer/SOGoMailAccounts.m b/SoObjects/Mailer/SOGoMailAccounts.m index d88bb9d5..ed041aa3 100644 --- a/SoObjects/Mailer/SOGoMailAccounts.m +++ b/SoObjects/Mailer/SOGoMailAccounts.m @@ -32,8 +32,7 @@ static NSString *AgenorShareLoginMarker = @".-."; /* detect webmail being accessed from the outside */ - (BOOL)isInternetRequest { - return [[(WOApplication *)[WOApplication application] context] - isAccessFromIntranet] ? NO : YES; + return ([context isAccessFromIntranet] ? NO : YES); } /* listing the available mailboxes */ @@ -41,28 +40,15 @@ static NSString *AgenorShareLoginMarker = @".-."; - (BOOL)isInHomeFolderBranchOfLoggedInAccount:(id)_ctx { id user; - if (_ctx == nil) _ctx = [[WOApplication application] context]; - if (_ctx == nil) { - [self errorWithFormat:@"Missing context!"]; - return NO; - } - user = [_ctx activeUser]; return [[[self container] nameInContainer] isEqualToString:[user login]]; } - (NSArray *)toManyRelationshipKeys { - WOContext *ctx; id user; id account; NSArray *shares; - if ((ctx = [[WOApplication application] context]) == nil) { - [self logWithFormat:@"ERROR(%s): cannot procede without context!", - __PRETTY_FUNCTION__]; - return nil; - } - /* Note: this is not strictly correct. The accounts being retrieved should be the accounts based on the container object of this folder. Given @@ -73,10 +59,10 @@ static NSString *AgenorShareLoginMarker = @".-."; functionality which isn't perfect either. => TODO */ - user = [ctx activeUser]; + user = [context activeUser]; /* for now: return nothing if the home-folder does not belong to the login */ - if (![self isInHomeFolderBranchOfLoggedInAccount:ctx]) { + if (![self isInHomeFolderBranchOfLoggedInAccount: context]) { [self warnWithFormat:@"User %@ tried to access mail hierarchy of %@", [user login], [[self container] nameInContainer]]; return nil; @@ -97,17 +83,11 @@ static NSString *AgenorShareLoginMarker = @".-."; - (NSArray *)fetchIdentitiesWithOnlyEmitterAccess:(BOOL)_flag { WOContext *ctx; - if ((ctx = [[WOApplication application] context]) == nil) { - [self logWithFormat:@"ERROR(%s): cannot procede without context!", - __PRETTY_FUNCTION__]; - return nil; - } - if ([self isInternetRequest]) { /* only show primary mailbox in Internet */ // just return the primary identity id identity; - identity = [[ctx activeUser] primaryMailIdentity]; + identity = [[context activeUser] primaryMailIdentity]; return [identity isNotNull] ? [NSArray arrayWithObject:identity] : nil; } diff --git a/SoObjects/Mailer/SOGoMailBaseObject.m b/SoObjects/Mailer/SOGoMailBaseObject.m index 26d996b8..7fbbbfc6 100644 --- a/SoObjects/Mailer/SOGoMailBaseObject.m +++ b/SoObjects/Mailer/SOGoMailBaseObject.m @@ -149,7 +149,7 @@ static BOOL debugOn = YES; NSString *auth; NSArray *creds; - rq = [[(WOApplication *)[WOApplication application] context] request]; + rq = [context request]; if ((auth = [rq headerForKey:@"authorization"]) == nil) { /* no basic auth */ return nil; diff --git a/SoObjects/SOGo/NSString+Utilities.h b/SoObjects/SOGo/NSString+Utilities.h index 285c3296..ff120c2f 100644 --- a/SoObjects/SOGo/NSString+Utilities.h +++ b/SoObjects/SOGo/NSString+Utilities.h @@ -38,6 +38,10 @@ - (NSString *) davMethodToObjC; +#ifndef GNUSTEP_BASE_LIBRARY +- (BOOL) boolValue; +#endif + @end #endif /* NSSTRING_URL_H */ diff --git a/SoObjects/SOGo/NSString+Utilities.m b/SoObjects/SOGo/NSString+Utilities.m index 77c4e458..66ddda63 100644 --- a/SoObjects/SOGo/NSString+Utilities.m +++ b/SoObjects/SOGo/NSString+Utilities.m @@ -20,6 +20,7 @@ * Boston, MA 02111-1307, USA. */ +#import #import #import "NSString+Utilities.h" @@ -100,4 +101,12 @@ return newName; } +#ifndef GNUSTEP_BASE_LIBRARY +- (BOOL) boolValue +{ + return !([self isEqualToString: @"0"] + || [self isEqualToString: @"NO"]); +} +#endif + @end diff --git a/SoObjects/SOGo/SOGoContentObject.m b/SoObjects/SOGo/SOGoContentObject.m index 3c7cc1a1..bfacb66c 100644 --- a/SoObjects/SOGo/SOGoContentObject.m +++ b/SoObjects/SOGo/SOGoContentObject.m @@ -241,7 +241,6 @@ /* security */ - (NSArray *) rolesOfUser: (NSString *) login - inContext: (WOContext *) context { NSMutableArray *sogoRoles; SOGoUser *user; diff --git a/SoObjects/SOGo/SOGoGroupFolder.m b/SoObjects/SOGo/SOGoGroupFolder.m index 189f0781..054e4681 100644 --- a/SoObjects/SOGo/SOGoGroupFolder.m +++ b/SoObjects/SOGo/SOGoGroupFolder.m @@ -92,7 +92,6 @@ static NGLogger *logger = nil; } - (void)_setupFolders { - WOContext *ctx; NSMutableDictionary *md; NSMutableArray *ma; NSArray *luids; @@ -103,8 +102,6 @@ static NGLogger *logger = nil; if ((luids = [self uids]) == nil) return; - ctx = [[WOApplication application] context]; - count = [luids count]; ma = [NSMutableArray arrayWithCapacity:count + 1]; md = [NSMutableDictionary dictionaryWithCapacity:count]; @@ -114,7 +111,7 @@ static NGLogger *logger = nil; id folder; uid = [luids objectAtIndex:i]; - folder = [self _primaryLookupFolderForUID:uid inContext:ctx]; + folder = [self _primaryLookupFolderForUID:uid inContext: context]; if ([folder isNotNull]) { [md setObject:folder forKey:uid]; diff --git a/SoObjects/SOGo/SOGoObject.h b/SoObjects/SOGo/SOGoObject.h index e06864b2..b09b636c 100644 --- a/SoObjects/SOGo/SOGoObject.h +++ b/SoObjects/SOGo/SOGoObject.h @@ -44,9 +44,9 @@ @interface SOGoObject : NSObject { + WOContext *context; NSString *nameInContainer; id container; - NSTimeZone *userTimeZone; NSString *customOwner; } @@ -59,10 +59,6 @@ - (NSString *) nameInContainer; - (id) container; -- (NSTimeZone *) serverTimeZone; -- (NSTimeZone *) userTimeZone; -- (NSTimeZone *) userTimeZone: (NSString *) username; - /* ownership */ - (void) setOwner: (NSString *) newOwner; diff --git a/SoObjects/SOGo/SOGoObject.m b/SoObjects/SOGo/SOGoObject.m index 5e0ba15c..a0be8285 100644 --- a/SoObjects/SOGo/SOGoObject.m +++ b/SoObjects/SOGo/SOGoObject.m @@ -140,7 +140,6 @@ @implementation SOGoObject static BOOL kontactGroupDAV = YES; -static NSTimeZone *serverTimeZone = nil; + (int)version { return 0; @@ -148,8 +147,6 @@ static NSTimeZone *serverTimeZone = nil; + (void) initialize { - NSString *tzName; - NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; kontactGroupDAV = @@ -168,15 +165,6 @@ static NSTimeZone *serverTimeZone = nil; asDefaultForPermission: SoPerm_View]; [[self soClassSecurityInfo] declareRole: SoRole_Owner asDefaultForPermission: SoPerm_WebDAVAccess]; - - if (!serverTimeZone) - { - tzName = [ud stringForKey: @"SOGoServerTimeZone"]; - if (!tzName) - tzName = @"Canada/Eastern"; - serverTimeZone = [NSTimeZone timeZoneWithName: tzName]; - [serverTimeZone retain]; - } } + (void) _fillDictionary: (NSMutableDictionary *) dictionary @@ -237,20 +225,11 @@ static NSTimeZone *serverTimeZone = nil; } /* DAV ACL properties */ -- (NSString *) _principalForUser: (NSString *) user +- (NSString *) davOwner { - WOContext *context; - - context = [[WOApplication application] context]; - return [NSString stringWithFormat: @"%@users/%@", [self rootURLInContext: context], - user]; -} - -- (NSString *) davOwner -{ - return [self _principalForUser: [self ownerInContext: nil]]; + [self ownerInContext: nil]]; } - (NSString *) davAclRestrictions @@ -267,9 +246,7 @@ static NSTimeZone *serverTimeZone = nil; - (SOGoDAVSet *) davPrincipalCollectionSet { NSString *usersUrl; - WOContext *context; - context = [[WOApplication application] context]; usersUrl = [NSString stringWithFormat: @"%@users", [self rootURLInContext: context]]; @@ -282,12 +259,10 @@ static NSTimeZone *serverTimeZone = nil; SOGoAuthenticator *sAuth; SoUser *user; NSArray *roles; - WOContext *context; SoClassSecurityInfo *sInfo; NSArray *davPermissions; sAuth = [SOGoAuthenticator sharedSOGoAuthenticator]; - context = [[WOApplication application] context]; user = [sAuth userInContext: context]; roles = [user rolesForObject: self inContext: context]; sInfo = [[self class] soClassSecurityInfo]; @@ -318,7 +293,7 @@ static NSTimeZone *serverTimeZone = nil; NSArray *privileges; NSMutableString *currentAce; NSMutableArray *davAces; - NSString *currentKey; + NSString *currentKey, *principal; SOGoDAVSet *privilegesDS; davAces = [NSMutableArray array]; @@ -332,9 +307,15 @@ static NSTimeZone *serverTimeZone = nil; appendFormat: @"", [currentKey substringFromIndex: 1]]; else - [currentAce - appendFormat: @"%@", - [self _principalForUser: currentKey]]; + { + principal = [NSString stringWithFormat: @"%@users/%@", + [self rootURLInContext: context], + currentKey]; + [currentAce + appendFormat: @"%@", + principal]; + } + privileges = [[aclsDictionary objectForKey: currentKey] stringsWithFormat: @""]; privilegesDS = [SOGoDAVSet davSetWithArray: privileges @@ -395,16 +376,18 @@ static NSTimeZone *serverTimeZone = nil; /* end of properties */ -- (BOOL)doesRetainContainer { +- (BOOL) doesRetainContainer +{ return YES; } - (id)initWithName:(NSString *)_name inContainer:(id)_container { if ((self = [super init])) { + context = [[WOApplication application] context]; + [context retain]; nameInContainer = [_name copy]; container = [self doesRetainContainer] ? [_container retain] : _container; - userTimeZone = nil; customOwner = nil; } return self; @@ -415,12 +398,10 @@ static NSTimeZone *serverTimeZone = nil; } - (void)dealloc { - if (customOwner) - [customOwner release]; + [context release]; + [customOwner release]; if ([self doesRetainContainer]) [container release]; - if (userTimeZone) - [userTimeZone release]; [nameInContainer release]; [super dealloc]; } @@ -709,45 +690,6 @@ static NSTimeZone *serverTimeZone = nil; return nil; } -- (NSTimeZone *) serverTimeZone -{ - return serverTimeZone; -} - -/* TODO: should be moved into SOGoUser */ -- (NSTimeZone *) userTimeZone -{ - NSUserDefaults *userPrefs; - WOContext *context; - - if (!userTimeZone) - { - context = [[WOApplication application] context]; - userPrefs = [[context activeUser] userDefaults]; - userTimeZone = [NSTimeZone - timeZoneWithName: [userPrefs stringForKey: @"timezonename"]]; - if (!userTimeZone) - userTimeZone = [self serverTimeZone]; - [userTimeZone retain]; - } - - return userTimeZone; -} - -- (NSTimeZone *) userTimeZone: (NSString *) username -{ - NSUserDefaults *userPrefs; - AgenorUserManager *am; - - am = [AgenorUserManager sharedUserManager]; - userPrefs = [am getUserDefaultsForUID: username]; - userTimeZone = [NSTimeZone timeZoneWithName: [userPrefs stringForKey: @"timezonename"]]; - if (!userTimeZone) - userTimeZone = [self serverTimeZone]; - - return userTimeZone; -} - /* description */ - (void)appendAttributesToDescription:(NSMutableString *)_ms { diff --git a/SoObjects/SOGo/SOGoUser.h b/SoObjects/SOGo/SOGoUser.h index 62dc2ed9..3b87aa84 100644 --- a/SoObjects/SOGo/SOGoUser.h +++ b/SoObjects/SOGo/SOGoUser.h @@ -34,7 +34,12 @@ context.activeUser */ -@class NSString, NSArray, NSDictionary, NSURL, NSUserDefaults; +@class NSString; +@class NSArray; +@class NSDictionary; +@class NSURL; +@class NSUserDefaults; +@class NSTimeZone; @class WOContext; @interface SOGoUser : SoUser @@ -43,31 +48,38 @@ NSString *email; NSUserDefaults *userDefaults; NSUserDefaults *userSettings; + NSTimeZone *userTimeZone; } ++ (SOGoUser *) userWithLogin: (NSString *) login + andRoles: (NSArray *) roles; + /* properties */ -- (NSString *)email; -- (NSString *)cn; -- (NSURL *)freeBusyURL; +- (NSString *) email; +- (NSString *) cn; +- (NSURL *) freeBusyURL; /* shares and identities */ -- (NSString *)primaryIMAP4AccountString; -- (NSString *)primaryMailServer; -- (NSArray *)additionalIMAP4AccountStrings; -- (NSArray *)additionalEMailAddresses; -- (NSDictionary *)additionalIMAP4AccountsAndEMails; +- (NSString *) primaryIMAP4AccountString; +- (NSString *) primaryMailServer; +- (NSArray *) additionalIMAP4AccountStrings; +- (NSArray *) additionalEMailAddresses; +- (NSDictionary *) additionalIMAP4AccountsAndEMails; /* defaults */ - (NSUserDefaults *) userDefaults; - (NSUserDefaults *) userSettings; +- (NSTimeZone *) timeZone; +- (NSTimeZone *) serverTimeZone; + /* folders */ -- (id)homeFolderInContext:(id)_ctx; -- (id)schedulingCalendarInContext:(id)_ctx; +- (id) homeFolderInContext: (id) _ctx; +- (id) schedulingCalendarInContext: (id) _ctx; - (NSArray *) rolesForObject: (NSObject *) object inContext: (WOContext *) context; diff --git a/SoObjects/SOGo/SOGoUser.m b/SoObjects/SOGo/SOGoUser.m index 6d863d53..e10b9931 100644 --- a/SoObjects/SOGo/SOGoUser.m +++ b/SoObjects/SOGo/SOGoUser.m @@ -26,17 +26,43 @@ #import "SOGoUser.h" +static NSTimeZone *serverTimeZone = nil; + @interface NSObject (SOGoRoles) -- (NSString *) roleOfUser: (NSString *) uid - inContext: (WOContext *) context; -- (NSArray *) rolesOfUser: (NSString *) uid - inContext: (WOContext *) context; +- (NSString *) roleOfUser: (NSString *) uid; +- (NSArray *) rolesOfUser: (NSString *) uid; @end @implementation SOGoUser ++ (void) initialize +{ + NSString *tzName; + + if (!serverTimeZone) + { + tzName = [[NSUserDefaults standardUserDefaults] + stringForKey: @"SOGoServerTimeZone"]; + if (!tzName) + tzName = @"Canada/Eastern"; + serverTimeZone = [NSTimeZone timeZoneWithName: tzName]; + [serverTimeZone retain]; + } +} + ++ (SOGoUser *) userWithLogin: (NSString *) login + andRoles: (NSArray *) roles +{ + SOGoUser *user; + + user = [[self alloc] initWithLogin: login roles: roles]; + [user autorelease]; + + return user; +} + - (id) init { if ((self = [super init])) @@ -48,56 +74,77 @@ return self; } -- (void)dealloc { - [self->userDefaults release]; - [self->userSettings release]; - [self->cn release]; - [self->email release]; +- (void) dealloc +{ + [userDefaults release]; + [userSettings release]; + [cn release]; + [email release]; [super dealloc]; } /* internals */ -- (AgenorUserManager *)userManager { +- (AgenorUserManager *) userManager +{ static AgenorUserManager *um = nil; if (um == nil) um = [[AgenorUserManager sharedUserManager] retain]; + return um; } /* properties */ -- (NSString *)email { - if (self->email == nil) - self->email = [[[self userManager] getEmailForUID:[self login]] copy]; - return self->email; +- (NSString *) email +{ + if (email == nil) + { + email = [[self userManager] getEmailForUID: [self login]]; + [email retain]; + } + + return email; } -- (NSString *)cn { - if (self->cn == nil) - self->cn = [[[self userManager] getCNForUID:[self login]] copy]; - return self->cn; +- (NSString *) cn +{ + if (cn == nil) + { + cn = [[self userManager] getCNForUID: [self login]]; + [cn retain]; + } + + return cn; } -- (NSString *)primaryIMAP4AccountString { - return [[self userManager] getIMAPAccountStringForUID:[self login]]; +- (NSString *) primaryIMAP4AccountString +{ + return [[self userManager] getIMAPAccountStringForUID: [self login]]; } -- (NSString *)primaryMailServer { - return [[self userManager] getServerForUID:[self login]]; + +- (NSString *) primaryMailServer +{ + return [[self userManager] getServerForUID: [self login]]; } -- (NSArray *)additionalIMAP4AccountStrings { - return [[self userManager]getSharedMailboxAccountStringsForUID:[self login]]; +- (NSArray *) additionalIMAP4AccountStrings +{ + return [[self userManager]getSharedMailboxAccountStringsForUID: [self login]]; } -- (NSArray *)additionalEMailAddresses { - return [[self userManager] getSharedMailboxEMailsForUID:[self login]]; + +- (NSArray *) additionalEMailAddresses +{ + return [[self userManager] getSharedMailboxEMailsForUID: [self login]]; } -- (NSDictionary *)additionalIMAP4AccountsAndEMails { - return [[self userManager] getSharedMailboxesAndEMailsForUID:[self login]]; +- (NSDictionary *) additionalIMAP4AccountsAndEMails +{ + return [[self userManager] getSharedMailboxesAndEMailsForUID: [self login]]; } -- (NSURL *)freeBusyURL { - return [[self userManager] getFreeBusyURLForUID:[self login]]; +- (NSURL *) freeBusyURL +{ + return [[self userManager] getFreeBusyURLForUID: [self login]]; } /* defaults */ @@ -124,12 +171,37 @@ return userSettings; } +- (NSTimeZone *) timeZone +{ + NSString *timeZoneName; + + if (!userTimeZone) + { + timeZoneName = [[self userDefaults] stringForKey: @"TimeZone"]; + if ([timeZoneName length] > 0) + userTimeZone = [NSTimeZone timeZoneWithName: timeZoneName]; + else + userTimeZone = nil; + if (!userTimeZone) + userTimeZone = [self serverTimeZone]; + [userTimeZone retain]; + } + + return userTimeZone; +} + +- (NSTimeZone *) serverTimeZone +{ + return serverTimeZone; +} + /* folders */ // TODO: those methods should check whether the traversal stack in the context // already contains proper folders to improve caching behaviour -- (id)homeFolderInContext:(id)_ctx { +- (id) homeFolderInContext: (id) _ctx +{ /* Note: watch out for cyclic references */ // TODO: maybe we should add an [activeUser reset] method to SOPE id folder; @@ -148,7 +220,8 @@ return folder; } -- (id)schedulingCalendarInContext:(id)_ctx { +- (id) schedulingCalendarInContext: (id) _ctx +{ /* Note: watch out for cyclic references */ id folder; @@ -196,13 +269,13 @@ } if ([object respondsToSelector: @selector (rolesOfUser:inContext:)]) { - sogoRoles = [object rolesOfUser: login inContext: context]; + sogoRoles = [object rolesOfUser: login]; if (sogoRoles) [rolesForObject addObjectsFromArray: sogoRoles]; } if ([object respondsToSelector: @selector (roleOfUser:inContext:)]) { - role = [object roleOfUser: login inContext: context]; + role = [object roleOfUser: login]; if (role) [rolesForObject addObject: role]; } diff --git a/SoObjects/SOGo/SOGoUserFolder.m b/SoObjects/SOGo/SOGoUserFolder.m index d0d6a34e..8664beed 100644 --- a/SoObjects/SOGo/SOGoUserFolder.m +++ b/SoObjects/SOGo/SOGoUserFolder.m @@ -67,10 +67,10 @@ return self; } -- (SOGoGroupsFolder *) lookupGroupsFolder -{ - return [self lookupName: @"Groups" inContext: nil acquire: NO]; -} +// - (SOGoGroupsFolder *) lookupGroupsFolder +// { +// return [self lookupName: @"Groups" inContext: nil acquire: NO]; +// } /* pathes */ @@ -131,11 +131,11 @@ return contacts; } -- (id) groupsFolder: (NSString *) _key - inContext: (WOContext *) _ctx -{ - return [$(@"SOGoGroupsFolder") objectWithName: _key inContainer: self]; -} +// - (id) groupsFolder: (NSString *) _key +// inContext: (WOContext *) _ctx +// { +// return [$(@"SOGoGroupsFolder") objectWithName: _key inContainer: self]; +// } - (id) mailAccountsFolder: (NSString *) _key inContext: (WOContext *) _ctx @@ -168,12 +168,12 @@ } else if ([_key isEqualToString: @"Contacts"]) obj = [self privateContacts: _key inContext: _ctx]; - else if ([_key isEqualToString: @"Groups"]) - obj = [self groupsFolder: _key inContext: _ctx]; +// else if ([_key isEqualToString: @"Groups"]) +// obj = [self groupsFolder: _key inContext: _ctx]; else if ([_key isEqualToString: @"Mail"]) obj = [self mailAccountsFolder: _key inContext: _ctx]; else if ([_key isEqualToString: @"freebusy.ifb"]) - obj = [self freeBusyObject:_key inContext:_ctx]; + obj = [self freeBusyObject:_key inContext: _ctx]; else obj = [NSException exceptionWithHTTPStatus: 404 /* Not Found */]; } @@ -181,38 +181,38 @@ return obj; } -/* FIXME: here is a vault of hackish ways to gain access to subobjects by - granting ro access to the homepage depending on the subobject in question. - This is wrong and dangerous. */ -- (NSString *) roleOfUser: (NSString *) uid - inContext: (WOContext *) context -{ - NSArray *roles, *traversalPath; - NSString *objectName, *role; - - role = nil; - traversalPath = [context objectForKey: @"SoRequestTraversalPath"]; - if ([traversalPath count] > 1) - { - objectName = [traversalPath objectAtIndex: 1]; - if ([objectName isEqualToString: @"Calendar"] - || [objectName isEqualToString: @"Contacts"]) - { - roles = [[context activeUser] - rolesForObject: [self lookupName: objectName - inContext: context - acquire: NO] - inContext: context]; - if ([roles containsObject: SOGoRole_Assistant] - || [roles containsObject: SOGoRole_Delegate]) - role = SOGoRole_Assistant; - } - else if ([objectName isEqualToString: @"freebusy.ifb"]) - role = SOGoRole_Assistant; - } - - return role; -} +// /* FIXME: here is a vault of hackish ways to gain access to subobjects by +// granting ro access to the homepage depending on the subobject in question. +// This is wrong and dangerous. */ +// - (NSString *) roleOfUser: (NSString *) uid +// inContext: (WOContext *) context +// { +// NSArray *roles, *traversalPath; +// NSString *objectName, *role; + +// role = nil; +// traversalPath = [context objectForKey: @"SoRequestTraversalPath"]; +// if ([traversalPath count] > 1) +// { +// objectName = [traversalPath objectAtIndex: 1]; +// if ([objectName isEqualToString: @"Calendar"] +// || [objectName isEqualToString: @"Contacts"]) +// { +// roles = [[context activeUser] +// rolesForObject: [self lookupName: objectName +// inContext: context +// acquire: NO] +// inContext: context]; +// if ([roles containsObject: SOGoRole_Assistant] +// || [roles containsObject: SOGoRole_Delegate]) +// role = SOGoRole_Assistant; +// } +// else if ([objectName isEqualToString: @"freebusy.ifb"]) +// role = SOGoRole_Assistant; +// } + +// return role; +// } /* WebDAV */ @@ -244,10 +244,8 @@ collections itself. So for use its the home folder, the public folder and the groups folder. */ - WOContext *context; NSArray *tag; - context = [[WOApplication application] context]; tag = [NSArray arrayWithObjects: @"href", @"DAV:", @"D", [self baseURLInContext: context], nil]; diff --git a/UI/MailPartViewers/UIxMailPartICalViewer.m b/UI/MailPartViewers/UIxMailPartICalViewer.m index f8a0e549..5a3285e1 100644 --- a/UI/MailPartViewers/UIxMailPartICalViewer.m +++ b/UI/MailPartViewers/UIxMailPartICalViewer.m @@ -154,19 +154,27 @@ return self->item; } -- (NSCalendarDate *)startTime { +- (NSCalendarDate *) startTime +{ NSCalendarDate *date; + NSTimeZone *timeZone; date = [[self authorativeEvent] startDate]; - [date setTimeZone:[[self clientObject] userTimeZone]]; + timeZone = [[context activeUser] timeZone]; + [date setTimeZone: timeZone]; + return date; } -- (NSCalendarDate *)endTime { +- (NSCalendarDate *) endTime +{ NSCalendarDate *date; + NSTimeZone *timeZone; date = [[self authorativeEvent] endDate]; - [date setTimeZone:[[self clientObject] userTimeZone]]; + timeZone = [[context activeUser] timeZone]; + [date setTimeZone: timeZone]; + return date; } diff --git a/UI/MainUI/SOGoUserHomePage.m b/UI/MainUI/SOGoUserHomePage.m index 7731f9ea..cbab3761 100644 --- a/UI/MainUI/SOGoUserHomePage.m +++ b/UI/MainUI/SOGoUserHomePage.m @@ -28,6 +28,7 @@ #import #import +#import #import #import @@ -112,9 +113,11 @@ NSCalendarDate *startDate, *endDate; NSString *queryDay, *additionalDays; NSTimeZone *uTZ; + SOGoUser *user; co = [self clientObject]; - uTZ = [co userTimeZone]; + user = [context activeUser]; + uTZ = [user timeZone]; queryDay = [self queryParameterForKey: @"sday"]; if ([queryDay length]) diff --git a/UI/MainUI/product.plist b/UI/MainUI/product.plist index 6895273f..8cca37cd 100644 --- a/UI/MainUI/product.plist +++ b/UI/MainUI/product.plist @@ -17,13 +17,9 @@ }; SOGoUserFolder = { superclass = "SOGoFolder"; + protectedBy = ""; + defaultAccess = "allow"; /* protectedBy = "HomePage Access"; */ - defaultRoles = { - "Homepage Access" = ( "Owner", "Assistant", "Delegate", "FreeBusy" ); - "WebDAV Access" = ( "Owner", "Assistant", "Delegate", "FreeBusy" ); - "Access Contents Information" = ( "Owner", "Assistant", "Delegate", - "FreeBusy" ); - }; }; SOGoFolder = { superclass = "SOGoObject"; @@ -68,12 +64,6 @@ SOGoRootPage = { }; SOGoUserFolder = { - methods = { - view = { - protectedBy = "View"; - pageName = "SOGoUserHomePage"; - }; - }; }; SOGoGroupsFolder = { methods = { diff --git a/UI/SOGoUI/UIxComponent.m b/UI/SOGoUI/UIxComponent.m index 0758c504..d18e248a 100644 --- a/UI/SOGoUI/UIxComponent.m +++ b/UI/SOGoUI/UIxComponent.m @@ -19,22 +19,27 @@ 02111-1307, USA. */ -#import "SOGoJSStringFormatter.h" -#import "common.h" - +#import +#import +#import +#import +#import #import +#import #import - -#import - -#import -#import -#import -#import - -#import "UIxJSClose.h" +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import #import "UIxComponent.h" +#import "UIxJSClose.h" @interface UIxComponent (PrivateAPI) - (void)_parseQueryString:(NSString *)_s; @@ -362,7 +367,7 @@ static BOOL uixDebugEnabled = NO; { NSString *dst, *rel; - dst = [[self userFolderPath] stringByAppendingPathComponent:_sub]; + dst = [[self userFolderPath] stringByAppendingPathComponent: _sub]; rel = [dst urlPathRelativeToPath:[self ownPath]]; return rel; @@ -370,13 +375,16 @@ static BOOL uixDebugEnabled = NO; - (NSCalendarDate *) selectedDate { + NSTimeZone *userTimeZone; + if (!_selectedDate) { + userTimeZone = [[context activeUser] timeZone]; _selectedDate = [NSCalendarDate dateFromShortDateString: [self queryParameterForKey: @"day"] andShortTimeString: [self queryParameterForKey: @"hm"] - inTimeZone: [[self clientObject] userTimeZone]]; + inTimeZone: userTimeZone]; [_selectedDate retain]; } @@ -385,7 +393,10 @@ static BOOL uixDebugEnabled = NO; - (NSString *) dateStringForDate: (NSCalendarDate *) _date { - [_date setTimeZone: [[self clientObject] userTimeZone]]; + NSTimeZone *userTimeZone; + + userTimeZone = [[context activeUser] timeZone]; + [_date setTimeZone: userTimeZone]; return [_date descriptionWithCalendarFormat:@"%Y%m%d"]; } diff --git a/UI/Scheduler/GNUmakefile b/UI/Scheduler/GNUmakefile index d3594c4b..092d61cd 100644 --- a/UI/Scheduler/GNUmakefile +++ b/UI/Scheduler/GNUmakefile @@ -38,7 +38,6 @@ SchedulerUI_OBJC_FILES = \ UIxTaskView.m \ UIxTaskEditor.m \ UIxTaskProposal.m \ - UIxCalSelectTab.m \ UIxCalDateLabel.m \ UIxDatePicker.m \ UIxTimeDateControl.m \ diff --git a/UI/Scheduler/UIxAppointmentEditor.m b/UI/Scheduler/UIxAppointmentEditor.m index 17c12eaa..3f1fa9b0 100644 --- a/UI/Scheduler/UIxAppointmentEditor.m +++ b/UI/Scheduler/UIxAppointmentEditor.m @@ -249,13 +249,15 @@ - (NSCalendarDate *) newStartDate { NSCalendarDate *newStartDate, *now; + NSTimeZone *timeZone; int hour; newStartDate = [self selectedDate]; if ([[self queryParameterForKey: @"hm"] length] == 0) { now = [NSCalendarDate calendarDate]; - [now setTimeZone: [[self clientObject] userTimeZone]]; + timeZone = [[context activeUser] timeZone]; + [now setTimeZone: timeZone]; if ([now isDateOnSameDay: newStartDate]) { hour = [now hourOfDay]; @@ -365,23 +367,23 @@ // TODO: add tentatively -- (id) acceptOrDeclineAction: (BOOL) _accept +- (id) acceptOrDeclineAction: (BOOL) accept { - [[self clientObject] changeParticipationStatus: - _accept ? @"ACCEPTED" : @"DECLINED" - inContext: [self context]]; + [[self clientObject] changeParticipationStatus: (accept + ? @"ACCEPTED" + : @"DECLINED")]; return self; } - (id) acceptAction { - return [self acceptOrDeclineAction:YES]; + return [self acceptOrDeclineAction: YES]; } - (id) declineAction { - return [self acceptOrDeclineAction:NO]; + return [self acceptOrDeclineAction: NO]; } @end diff --git a/UI/Scheduler/UIxAppointmentProposal.m b/UI/Scheduler/UIxAppointmentProposal.m index 978a0314..f81d87eb 100644 --- a/UI/Scheduler/UIxAppointmentProposal.m +++ b/UI/Scheduler/UIxAppointmentProposal.m @@ -170,30 +170,44 @@ [self setStartDateMonth:[NSNumber numberWithInt:[_date monthOfYear]]]; [self setStartDateYear:[NSNumber numberWithInt:[_date yearOfCommonEra]]]; } -- (NSCalendarDate *)startDate { + +- (NSCalendarDate *) startDate +{ + NSTimeZone *timeZone; + + timeZone = [[context activeUser] timeZone]; + return [NSCalendarDate dateWithYear:[[self startDateYear] intValue] month:[[self startDateMonth] intValue] day:[[self startDateDay] intValue] hour:[[self startDateHour] intValue] minute:[[self startDateMinute] intValue] second:0 - timeZone:[[self clientObject] userTimeZone]]; + timeZone: timeZone]; } -- (void)setEndDate:(NSCalendarDate *)_date { + +- (void) setEndDate: (NSCalendarDate *) _date +{ [self setEndDateHour:[NSNumber numberWithInt:[_date hourOfDay]]]; [self setEndDateMinute:[NSNumber numberWithInt:[_date minuteOfHour]]]; [self setEndDateDay:[NSNumber numberWithInt:[_date dayOfMonth]]]; [self setEndDateMonth:[NSNumber numberWithInt:[_date monthOfYear]]]; [self setEndDateYear:[NSNumber numberWithInt:[_date yearOfCommonEra]]]; } -- (NSCalendarDate *)endDate { + +- (NSCalendarDate *) endDate +{ + NSTimeZone *timeZone; + + timeZone = [[context activeUser] timeZone]; + return [NSCalendarDate dateWithYear:[[self endDateYear] intValue] month:[[self endDateMonth] intValue] day:[[self endDateDay] intValue] hour:[[self endDateHour] intValue] minute:[[self endDateMinute] intValue] second:59 - timeZone:[[self clientObject] userTimeZone]]; + timeZone: timeZone]; } - (void)setDuration:(id)_duration { @@ -273,28 +287,31 @@ // TODO: from startdate to enddate NSMutableArray *ma; NSCalendarDate *base, *stop, *current; - + NSTimeZone *timeZone; + + timeZone = [[context activeUser] timeZone]; base = [NSCalendarDate dateWithYear:[[self startDateYear] intValue] month:[[self startDateMonth] intValue] day:[[self startDateDay] intValue] hour:12 minute:0 second:0 - timeZone:[[self clientObject] userTimeZone]]; + timeZone: timeZone]; stop = [NSCalendarDate dateWithYear:[[self endDateYear] intValue] month:[[self endDateMonth] intValue] day:[[self endDateDay] intValue] hour:12 minute:0 second:0 - timeZone:[[self clientObject] userTimeZone]]; - - ma = [NSMutableArray arrayWithCapacity:16]; + timeZone: timeZone]; + ma = [NSMutableArray arrayWithCapacity: 16]; current = base; - while ([current compare:stop] != NSOrderedDescending) { - [current setTimeZone:[[self clientObject] userTimeZone]]; - [ma addObject:current]; + while ([current compare:stop] != NSOrderedDescending) + { + [current setTimeZone: timeZone]; + [ma addObject:current]; /* Note: remember the timezone behaviour of the method below! */ - current = [current dateByAddingYears:0 months:0 days:1]; - } + current = [current dateByAddingYears:0 months:0 days:1]; + } + return ma; } @@ -323,6 +340,7 @@ - (BOOL)isSlotRangeGreen:(NGCalendarDateRange *)_slotRange { NGCalendarDateRange *aptRange; NSCalendarDate *aptStartDate, *aptEndDate; + NSTimeZone *timeZone; if (_slotRange == nil) return NO; @@ -334,8 +352,9 @@ aptEndDate = [[NSCalendarDate alloc] initWithTimeIntervalSince1970: [aptStartDate timeIntervalSince1970] + [self durationAsTimeInterval]]; - [aptStartDate setTimeZone:[[self clientObject] userTimeZone]]; - [aptEndDate setTimeZone:[[self clientObject] userTimeZone]]; + timeZone = [[context activeUser] timeZone]; + [aptStartDate setTimeZone: timeZone]; + [aptEndDate setTimeZone: timeZone]; aptRange = [NGCalendarDateRange calendarDateRangeWithStartDate:aptStartDate endDate:aptEndDate]; [aptEndDate release]; aptEndDate = nil; diff --git a/UI/Scheduler/UIxAppointmentView.h b/UI/Scheduler/UIxAppointmentView.h index 306e0640..f1d23785 100644 --- a/UI/Scheduler/UIxAppointmentView.h +++ b/UI/Scheduler/UIxAppointmentView.h @@ -18,22 +18,22 @@ id item; } -- (iCalEvent *)appointment; +- (iCalEvent *) appointment; /* permissions */ -- (BOOL)canAccessApt; -- (BOOL)canEditApt; +- (BOOL) canAccessApt; +- (BOOL) canEditApt; -- (SOGoDateFormatter *)dateFormatter; -- (NSCalendarDate *)startTime; -- (NSCalendarDate *)endTime; +- (SOGoDateFormatter *) dateFormatter; +- (NSCalendarDate *) startTime; +- (NSCalendarDate *) endTime; -- (NSString *)attributesTabLink; -- (NSString *)participantsTabLink; +- (NSString *) attributesTabLink; +- (NSString *) participantsTabLink; -- (NSString *)completeHrefForMethod:(NSString *)_method - withParameter:(NSString *)_param - forKey:(NSString *)_key; +- (NSString *) completeHrefForMethod: (NSString *) _method + withParameter: (NSString *) _param + forKey: (NSString *) _key; @end diff --git a/UI/Scheduler/UIxAppointmentView.m b/UI/Scheduler/UIxAppointmentView.m index d1aeb426..8adb3a9b 100644 --- a/UI/Scheduler/UIxAppointmentView.m +++ b/UI/Scheduler/UIxAppointmentView.m @@ -97,17 +97,23 @@ - (NSCalendarDate *)startTime { NSCalendarDate *date; - + NSTimeZone *timeZone; + + timeZone = [[context activeUser] timeZone]; date = [[self appointment] startDate]; - [date setTimeZone:[[self clientObject] userTimeZone]]; + [date setTimeZone: timeZone]; + return date; } - (NSCalendarDate *)endTime { NSCalendarDate *date; - + NSTimeZone *timeZone; + + timeZone = [[context activeUser] timeZone]; date = [[self appointment] endDate]; - [date setTimeZone:[[self clientObject] userTimeZone]]; + [date setTimeZone: timeZone]; + return date; } diff --git a/UI/Scheduler/UIxCalAptListView.m b/UI/Scheduler/UIxCalAptListView.m index 5da22d54..92d227d8 100644 --- a/UI/Scheduler/UIxCalAptListView.m +++ b/UI/Scheduler/UIxCalAptListView.m @@ -129,7 +129,7 @@ date = [NSCalendarDate dateWithTimeIntervalSince1970: [[currentAppointment objectForKey: @"startdate"] intValue]]; - [date setTimeZone: [[self clientObject] userTimeZone]]; + [date setTimeZone: timeZone]; return [[self itemDateFormatter] stringForObjectValue: date]; } @@ -141,7 +141,7 @@ date = [NSCalendarDate dateWithTimeIntervalSince1970: [[currentAppointment objectForKey: @"enddate"] intValue]]; - [date setTimeZone: [[self clientObject] userTimeZone]]; + [date setTimeZone: timeZone]; return [[self itemDateFormatter] stringForObjectValue: date]; } @@ -158,7 +158,7 @@ intDate = [[currentAppointment objectForKey: @"startdate"] intValue]; date = [NSCalendarDate dateWithTimeIntervalSince1970: intDate]; - [date setTimeZone: [[self clientObject] userTimeZone]]; + [date setTimeZone: timeZone]; return [NSString stringWithFormat: @"%d%.2d%.2d", [date yearOfCommonEra], @@ -173,7 +173,7 @@ intDate = [[currentAppointment objectForKey: @"startdate"] intValue]; date = [NSCalendarDate dateWithTimeIntervalSince1970: intDate]; - [date setTimeZone: [[self clientObject] userTimeZone]]; + [date setTimeZone: timeZone]; return [NSString stringWithFormat: @"%.2d%.2d", [date hourOfDay], diff --git a/UI/Scheduler/UIxCalDateSelector.m b/UI/Scheduler/UIxCalDateSelector.m index 6ab548c8..bfb2efc1 100644 --- a/UI/Scheduler/UIxCalDateSelector.m +++ b/UI/Scheduler/UIxCalDateSelector.m @@ -33,7 +33,7 @@ - (void) setSelectedDate: (NSCalendarDate *) _date { ASSIGN (selectedDate, _date); - [selectedDate setTimeZone: [[self clientObject] userTimeZone]]; + [selectedDate setTimeZone: timeZone]; } - (NSCalendarDate *) selectedDate diff --git a/UI/Scheduler/UIxCalMonthView.m b/UI/Scheduler/UIxCalMonthView.m index e5c82ecd..53bd5a75 100644 --- a/UI/Scheduler/UIxCalMonthView.m +++ b/UI/Scheduler/UIxCalMonthView.m @@ -36,14 +36,10 @@ - (id) init { - NSTimeZone *tz; - if ((self = [super init])) { - tz = [[self clientObject] userTimeZone]; - monthAptFormatter - = [[SOGoAptFormatter alloc] initWithDisplayTimeZone: tz]; + = [[SOGoAptFormatter alloc] initWithDisplayTimeZone: timeZone]; [monthAptFormatter setShortMonthTitleOnly]; dateFormatter = [[SOGoDateFormatter alloc] initWithLocale: [self locale]]; diff --git a/UI/Scheduler/UIxCalSelectTab.m b/UI/Scheduler/UIxCalSelectTab.m deleted file mode 100644 index f77e7b3f..00000000 --- a/UI/Scheduler/UIxCalSelectTab.m +++ /dev/null @@ -1,115 +0,0 @@ -/* - Copyright (C) 2004 SKYRIX Software AG - - This file is part of OpenGroupware.org. - - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - OGo 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 Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. -*/ -// $Id$ - - -#include -#include -#include - - -@interface UIxCalSelectTab : UIxComponent -{ - NSString *selection; - NSCalendarDate *currentDate; -} - -@end - - -@implementation UIxCalSelectTab - -- (void)dealloc { - [self->selection release]; - [self->currentDate release]; - [super dealloc]; -} - -- (void)setSelection:(NSString *)_selection { - ASSIGN(self->selection, _selection); -} - -- (NSString *)selection { - return self->selection; -} - -- (void)setCurrentDate:(NSCalendarDate *)_date { - [_date setTimeZone:[[self clientObject] userTimeZone]]; - ASSIGN(self->currentDate, _date); -} - -- (NSCalendarDate *)currentDate { - return self->currentDate; -} - - -/* labels */ - - -- (NSString *)dayLabel { - return [NSString stringWithFormat:@"%d", - [self->currentDate dayOfMonth]]; -} - -- (NSString *)weekLabel { - NSString *wlbl; - - wlbl = [self labelForKey:@"Week"]; - return [NSString stringWithFormat:@"%@ %d", - wlbl, - [self->currentDate weekOfYear]]; -} - -- (NSString *)monthLabel { - return [NSString stringWithFormat:@"%@", - [self localizedNameForMonthOfYear:[self->currentDate monthOfYear]]]; -} - -- (NSString *)yearLabel { - return [NSString stringWithFormat:@"%d", - [self->currentDate yearOfCommonEra]]; -} - - -/* hrefs */ - -- (NSString *)scheduletabLink { - return [self completeHrefForMethod:@"schedule"]; -} - -- (NSString *)daytabLink { - return [self completeHrefForMethod:@"dayoverview"]; -} - -- (NSString *)weektabLink { - return [self completeHrefForMethod:@"weekoverview"]; -} - -- (NSString *)monthtabLink { - return [self completeHrefForMethod:@"monthoverview"]; -} - -- (NSString *)yeartabLink { - return [self completeHrefForMethod:@"yearoverview"]; -} - - -@end diff --git a/UI/Scheduler/UIxCalView.h b/UI/Scheduler/UIxCalView.h index 9cf7c7bb..253e30f2 100644 --- a/UI/Scheduler/UIxCalView.h +++ b/UI/Scheduler/UIxCalView.h @@ -17,6 +17,7 @@ @class NSDictionary; @class NSMutableDictionary; @class NSString; +@class NSTimeZone; @class SOGoAptFormatter; @class SOGoAppointmentFolder; @@ -29,6 +30,7 @@ NSArray *allDayApts; id appointment; NSCalendarDate *currentDay; + NSTimeZone *timeZone; SOGoAptFormatter *aptFormatter; SOGoAptFormatter *aptTooltipFormatter; SOGoAptFormatter *privateAptFormatter; diff --git a/UI/Scheduler/UIxCalView.m b/UI/Scheduler/UIxCalView.m index 726fca51..0d1c9426 100644 --- a/UI/Scheduler/UIxCalView.m +++ b/UI/Scheduler/UIxCalView.m @@ -43,17 +43,16 @@ static BOOL shouldDisplayWeekend = NO; self = [super init]; if (self) { - NSTimeZone *tz; - - tz = [[self clientObject] userTimeZone]; + timeZone = [[context activeUser] timeZone]; + [timeZone retain]; aptFormatter - = [[SOGoAptFormatter alloc] initWithDisplayTimeZone: tz]; + = [[SOGoAptFormatter alloc] initWithDisplayTimeZone: timeZone]; aptTooltipFormatter - = [[SOGoAptFormatter alloc] initWithDisplayTimeZone: tz]; + = [[SOGoAptFormatter alloc] initWithDisplayTimeZone: timeZone]; privateAptFormatter - = [[SOGoAptFormatter alloc] initWithDisplayTimeZone: tz]; + = [[SOGoAptFormatter alloc] initWithDisplayTimeZone: timeZone]; privateAptTooltipFormatter - = [[SOGoAptFormatter alloc] initWithDisplayTimeZone: tz]; + = [[SOGoAptFormatter alloc] initWithDisplayTimeZone: timeZone]; [self configureFormatters]; componentsData = [NSMutableDictionary new]; } @@ -72,6 +71,7 @@ static BOOL shouldDisplayWeekend = NO; [aptTooltipFormatter release]; [privateAptFormatter release]; [privateAptTooltipFormatter release]; + [timeZone release]; [super dealloc]; } @@ -322,8 +322,8 @@ static BOOL shouldDisplayWeekend = NO; - (void) setCurrentDay:(NSCalendarDate *) _day { - [_day setTimeZone: [[self clientObject] userTimeZone]]; - ASSIGN(currentDay, _day); + [_day setTimeZone: timeZone]; + ASSIGN (currentDay, _day); } - (NSCalendarDate *) currentDay @@ -478,8 +478,7 @@ static BOOL shouldDisplayWeekend = NO; clientObject = [self clientObject]; - folders = [[clientObject calendarFoldersInContext: context] - objectEnumerator]; + folders = [[clientObject calendarFolders] objectEnumerator]; currentFolderDict = [folders nextObject]; while (currentFolderDict) { diff --git a/UI/Scheduler/UIxCalendarSelector.m b/UI/Scheduler/UIxCalendarSelector.m index d28e9484..5903aecb 100644 --- a/UI/Scheduler/UIxCalendarSelector.m +++ b/UI/Scheduler/UIxCalendarSelector.m @@ -112,8 +112,7 @@ colorForNumber (unsigned int number) NSDictionary *currentFolder; unsigned int count; - calendarFolders - = [[self clientObject] calendarFoldersInContext: context]; + calendarFolders = [[self clientObject] calendarFolders]; if (!colors) { colors = [NSMutableDictionary new]; diff --git a/UI/Scheduler/UIxComponentEditor.m b/UI/Scheduler/UIxComponentEditor.m index 11258889..7ddb35d5 100644 --- a/UI/Scheduler/UIxComponentEditor.m +++ b/UI/Scheduler/UIxComponentEditor.m @@ -24,6 +24,7 @@ #import #import #import +#import #import #import #import @@ -45,6 +46,7 @@ #import #import #import +#import #import "UIxComponent+Agenor.h" @@ -310,8 +312,7 @@ { calendarList = [NSMutableArray new]; folder = [[self clientObject] container]; - allCalendars - = [[folder calendarFoldersInContext: context] objectEnumerator]; + allCalendars = [[folder calendarFolders] objectEnumerator]; currentCalendar = [allCalendars nextObject]; while (currentCalendar) { @@ -743,7 +744,7 @@ co = [self clientObject]; if (![co - respondsToSelector: @selector(changeParticipationStatus:inContext:)]) + respondsToSelector: @selector(changeParticipationStatus:)]) return [NSException exceptionWithHTTPStatus:400 /* Bad Request */ reason: @"method cannot be invoked on the specified object"]; diff --git a/UI/Scheduler/UIxTaskEditor.m b/UI/Scheduler/UIxTaskEditor.m index 4a34ac6b..360cdf01 100644 --- a/UI/Scheduler/UIxTaskEditor.m +++ b/UI/Scheduler/UIxTaskEditor.m @@ -290,12 +290,15 @@ { NSCalendarDate *newStartDate, *now; int hour; + NSTimeZone *timeZone; + + timeZone = [[context activeUser] timeZone]; newStartDate = [self selectedDate]; if ([[self queryParameterForKey: @"hm"] length] == 0) { now = [NSCalendarDate calendarDate]; - [now setTimeZone: [[self clientObject] userTimeZone]]; + [now setTimeZone: timeZone]; if ([now isDateOnSameDay: newStartDate]) { hour = [now hourOfDay]; @@ -434,20 +437,19 @@ - (id) acceptOrDeclineAction: (BOOL) _accept { [[self clientObject] changeParticipationStatus: - _accept ? @"ACCEPTED" : @"DECLINED" - inContext: [self context]]; + _accept ? @"ACCEPTED" : @"DECLINED"]; return self; } - (id) acceptAction { - return [self acceptOrDeclineAction:YES]; + return [self acceptOrDeclineAction: YES]; } - (id) declineAction { - return [self acceptOrDeclineAction:NO]; + return [self acceptOrDeclineAction: NO]; } - (id) changeStatusAction diff --git a/UI/Scheduler/UIxTaskProposal.m b/UI/Scheduler/UIxTaskProposal.m index c558ccdd..bdd092d0 100644 --- a/UI/Scheduler/UIxTaskProposal.m +++ b/UI/Scheduler/UIxTaskProposal.m @@ -170,30 +170,44 @@ [self setStartDateMonth:[NSNumber numberWithInt:[_date monthOfYear]]]; [self setStartDateYear:[NSNumber numberWithInt:[_date yearOfCommonEra]]]; } -- (NSCalendarDate *)startDate { + +- (NSCalendarDate *) startDate +{ + NSTimeZone *timeZone; + + timeZone = [[context activeUser] timeZone]; + return [NSCalendarDate dateWithYear:[[self startDateYear] intValue] month:[[self startDateMonth] intValue] day:[[self startDateDay] intValue] hour:[[self startDateHour] intValue] minute:[[self startDateMinute] intValue] second:0 - timeZone:[[self clientObject] userTimeZone]]; + timeZone: timeZone]; } -- (void)setEndDate:(NSCalendarDate *)_date { + +- (void) setEndDate: (NSCalendarDate *) _date +{ [self setEndDateHour:[NSNumber numberWithInt:[_date hourOfDay]]]; [self setEndDateMinute:[NSNumber numberWithInt:[_date minuteOfHour]]]; [self setEndDateDay:[NSNumber numberWithInt:[_date dayOfMonth]]]; [self setEndDateMonth:[NSNumber numberWithInt:[_date monthOfYear]]]; [self setEndDateYear:[NSNumber numberWithInt:[_date yearOfCommonEra]]]; } -- (NSCalendarDate *)endDate { + +- (NSCalendarDate *) endDate +{ + NSTimeZone *timeZone; + + timeZone = [[context activeUser] timeZone]; + return [NSCalendarDate dateWithYear:[[self endDateYear] intValue] month:[[self endDateMonth] intValue] day:[[self endDateDay] intValue] hour:[[self endDateHour] intValue] minute:[[self endDateMinute] intValue] second:59 - timeZone:[[self clientObject] userTimeZone]]; + timeZone: timeZone]; } - (void)setDuration:(id)_duration { @@ -269,32 +283,36 @@ return ma; } -- (NSArray *)days { +- (NSArray *) days +{ // TODO: from startdate to enddate NSMutableArray *ma; - NSCalendarDate *base, *stop, *current; - - base = [NSCalendarDate dateWithYear:[[self startDateYear] intValue] - month:[[self startDateMonth] intValue] - day:[[self startDateDay] intValue] - hour:12 minute:0 second:0 - timeZone:[[self clientObject] userTimeZone]]; - stop = [NSCalendarDate dateWithYear:[[self endDateYear] intValue] - month:[[self endDateMonth] intValue] - day:[[self endDateDay] intValue] - hour:12 minute:0 second:0 - timeZone:[[self clientObject] userTimeZone]]; + NSCalendarDate *base, *stop, *current; + NSTimeZone *timeZone; + + timeZone = [[context activeUser] timeZone]; + base = [NSCalendarDate dateWithYear: [[self startDateYear] intValue] + month: [[self startDateMonth] intValue] + day: [[self startDateDay] intValue] + hour: 12 minute: 0 second: 0 + timeZone: timeZone]; + stop = [NSCalendarDate dateWithYear: [[self endDateYear] intValue] + month: [[self endDateMonth] intValue] + day: [[self endDateDay] intValue] + hour: 12 minute: 0 second: 0 + timeZone: timeZone]; ma = [NSMutableArray arrayWithCapacity:16]; current = base; while ([current compare:stop] != NSOrderedDescending) { - [current setTimeZone:[[self clientObject] userTimeZone]]; + [current setTimeZone: timeZone]; [ma addObject:current]; /* Note: remember the timezone behaviour of the method below! */ current = [current dateByAddingYears:0 months:0 days:1]; } + return ma; } @@ -320,27 +338,32 @@ return idx == NSNotFound ? YES : NO; } -- (BOOL)isSlotRangeGreen:(NGCalendarDateRange *)_slotRange { +- (BOOL)isSlotRangeGreen: (NGCalendarDateRange *) _slotRange +{ NGCalendarDateRange *aptRange; NSCalendarDate *aptStartDate, *aptEndDate; + NSTimeZone *timeZone; if (_slotRange == nil) return NO; - + + timeZone = [[context activeUser] timeZone]; /* calculate the interval requested by the user (can be larger) */ aptStartDate = [_slotRange startDate]; // TODO: gives warning on MacOSX - aptEndDate = [[NSCalendarDate alloc] initWithTimeIntervalSince1970: - [aptStartDate timeIntervalSince1970] - + [self durationAsTimeInterval]]; - [aptStartDate setTimeZone:[[self clientObject] userTimeZone]]; - [aptEndDate setTimeZone:[[self clientObject] userTimeZone]]; - aptRange = [NGCalendarDateRange calendarDateRangeWithStartDate:aptStartDate - endDate:aptEndDate]; - [aptEndDate release]; aptEndDate = nil; + aptEndDate + = [[NSCalendarDate alloc] + initWithTimeIntervalSince1970: ([aptStartDate timeIntervalSince1970] + + [self durationAsTimeInterval])]; + [aptStartDate setTimeZone: timeZone]; + [aptEndDate setTimeZone: timeZone]; + aptRange = [NGCalendarDateRange calendarDateRangeWithStartDate: aptStartDate + endDate: aptEndDate]; + [aptEndDate release]; + aptEndDate = nil; - return [self isRangeGreen:aptRange]; + return [self isRangeGreen: aptRange]; } - (BOOL)isFirstHalfGreen { diff --git a/UI/Scheduler/UIxTaskView.m b/UI/Scheduler/UIxTaskView.m index c2004dd8..32303413 100644 --- a/UI/Scheduler/UIxTaskView.m +++ b/UI/Scheduler/UIxTaskView.m @@ -95,19 +95,27 @@ return dateFormatter; } -- (NSCalendarDate *)startTime { +- (NSCalendarDate *) startTime +{ NSCalendarDate *date; - + NSTimeZone *timeZone; + + timeZone = [[context activeUser] timeZone]; date = [[self task] startDate]; - [date setTimeZone:[[self clientObject] userTimeZone]]; + [date setTimeZone: timeZone]; + return date; } -- (NSCalendarDate *)endTime { +- (NSCalendarDate *) endTime +{ NSCalendarDate *date; - + NSTimeZone *timeZone; + + timeZone = [[context activeUser] timeZone]; date = [[self task] due]; - [date setTimeZone:[[self clientObject] userTimeZone]]; + [date setTimeZone: timeZone]; + return date; } diff --git a/UI/Scheduler/UIxTimeDateControl.m b/UI/Scheduler/UIxTimeDateControl.m index f4606cf0..5b364665 100644 --- a/UI/Scheduler/UIxTimeDateControl.m +++ b/UI/Scheduler/UIxTimeDateControl.m @@ -69,12 +69,15 @@ return label; } -- (void)setDate:(NSCalendarDate *)_date { - NSLog (@"^^^^^^ %@: setDate: %@", self, _date); +- (void) setDate: (NSCalendarDate *) _date +{ + NSTimeZone *timeZone; int minuteValue; + + timeZone = [[context activeUser] timeZone]; if (!_date) _date = [NSCalendarDate date]; - [_date setTimeZone: [[self clientObject] userTimeZone]]; + [_date setTimeZone: timeZone]; [self _setDate: _date]; minuteValue = [_date minuteOfHour]; @@ -251,8 +254,9 @@ { NSCalendarDate *d; unsigned _year, _month, _day, _hour, _minute, _second; + NSTimeZone *timeZone; - NSLog (@"******************** %@: take values...", self); + timeZone = [[context activeUser] timeZone]; /* call super, so that the form values are applied on the popups */ [super takeValuesFromRequest:_rq inContext:_ctx]; @@ -270,7 +274,7 @@ d = [NSCalendarDate dateWithYear: _year month:_month day:_day hour:_hour minute:_minute second:_second - timeZone: [[self clientObject] userTimeZone]]; + timeZone: timeZone]; [self _setDate: d]; } } diff --git a/UI/Templates/SchedulerUI/UIxCalMonthOverview.wox b/UI/Templates/SchedulerUI/UIxCalMonthOverview.wox deleted file mode 100644 index 795e5f79..00000000 --- a/UI/Templates/SchedulerUI/UIxCalMonthOverview.wox +++ /dev/null @@ -1,216 +0,0 @@ - - - - - - - - - - - - - -
- -
- - - - - -
- - - - -
-
- - - - - - - - - - - -
- - - - - - -
- - - - - - - -
- - - -
-
- - - - - - - -
-
-
- - - - - - - - - - - - - - -
-
-
-
-
- - - -
- - -
-
-
- - - -
diff --git a/UI/Templates/SchedulerUI/UIxCalSelectTab.wox b/UI/Templates/SchedulerUI/UIxCalSelectTab.wox deleted file mode 100644 index fcc60180..00000000 --- a/UI/Templates/SchedulerUI/UIxCalSelectTab.wox +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - -- 2.39.5