From: helge Date: Wed, 30 Jun 2004 15:21:37 +0000 (+0000) Subject: git-svn-id: http://svn.opengroupware.org/SOGo/trunk@126 d1b88da0-ebda-0310-925b-ed51d... X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f8240092a6d19fed8c96aa4e4ba210b9cdea491;p=scalable-opengroupware.org git-svn-id: http://svn.opengroupware.org/SOGo/trunk@126 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m b/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m index 9ae531e5..4c9eef0d 100644 --- a/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -21,6 +21,7 @@ // $Id$ #include "SOGoAppointmentFolder.h" +#include #include "common.h" #include #include @@ -96,17 +97,85 @@ printf( "%x", *(int *) &f); /* fetching */ +- (NSMutableDictionary *)fixupRecord:(NSDictionary *)_record { + NSMutableDictionary *md; + id tmp; + + md = [[_record mutableCopy] autorelease]; + + if ((tmp = [_record objectForKey:@"startdate"])) { + tmp = [[NSCalendarDate alloc] initWithTimeIntervalSince1970: + (NSTimeInterval)[tmp unsignedIntValue]]; + if (tmp) [md setObject:tmp forKey:@"startDate"]; + [tmp release]; + } + else + [self logWithFormat:@"missing 'startdate' in record?"]; + + if ((tmp = [_record objectForKey:@"enddate"])) { + tmp = [[NSCalendarDate alloc] initWithTimeIntervalSince1970: + (NSTimeInterval)[tmp unsignedIntValue]]; + if (tmp) [md setObject:tmp forKey:@"endDate"]; + [tmp release]; + } + else + [self logWithFormat:@"missing 'enddate' in record?"]; + + return md; +} + +- (NSArray *)fixupRecords:(NSArray *)_records { + 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; + + row = [self fixupRecord:[_records objectAtIndex:i]]; + if (row) [ma addObject:row]; + } + return ma; +} + - (NSArray *)fetchCoreInfosFrom:(NSCalendarDate *)_startDate to:(NSCalendarDate *)_endDate { - id appointments; + OCSFolder *folder; + EOQualifier *qualifier; + NSArray *fields, *records; + NSString *sql; + + if ((folder = [self ocsFolder]) == nil) { + [self logWithFormat:@"ERROR(%s): missing folder for fetch!", + __PRETTY_FUNCTION__]; + return nil; + } [self logWithFormat:@"should fetch (%@ => %@) ...", _startDate, _endDate]; -#warning TODO: IMPLEMENT! + sql = [NSString stringWithFormat:@"(startdate < %d) AND (enddate > %d)", + (unsigned int)[_endDate timeIntervalSince1970], + (unsigned int)[_startDate timeIntervalSince1970]]; + qualifier = [EOQualifier qualifierWithQualifierFormat:sql]; + + fields = [NSArray arrayWithObjects: + @"uid", @"startdate", @"enddate", + @"title", @"participants", nil]; + + records = [folder fetchFields:fields matchingQualifier:qualifier]; + if (records == nil) { + [self logWithFormat:@"ERROR(%s): fetch failed!", __PRETTY_FUNCTION__]; + return nil; + } - [self logWithFormat:@"fetched %i records.", [appointments count]]; - return appointments; + records = [self fixupRecords:records]; + [self logWithFormat:@"fetched %i records: %@", [records count], records]; + return records; } @end /* SOGoAppointmentFolder */ diff --git a/SOGo/UI/Scheduler/ChangeLog b/SOGo/UI/Scheduler/ChangeLog index 55c14f34..8ce1d802 100644 --- a/SOGo/UI/Scheduler/ChangeLog +++ b/SOGo/UI/Scheduler/ChangeLog @@ -1,5 +1,7 @@ 2004-06-30 Helge Hess + * UIxAppointmentView.wox: made the attendee emails clickable + * UIxCalView.m: removed -fetchGIDs, moved -fetchCoreInfos to client object diff --git a/SOGo/UI/Scheduler/UIxAppointmentFormatter.m b/SOGo/UI/Scheduler/UIxAppointmentFormatter.m index 13804487..b2f937d1 100644 --- a/SOGo/UI/Scheduler/UIxAppointmentFormatter.m +++ b/SOGo/UI/Scheduler/UIxAppointmentFormatter.m @@ -58,7 +58,6 @@ return AUTORELEASE([[UIxAppointmentFormatter alloc] init]); } -#if !LIB_FOUNDATION_BOEHM_GC - (void)dealloc { RELEASE(self->formatString); RELEASE(self->dateFormat); @@ -71,7 +70,6 @@ [super dealloc]; } -#endif // accessors diff --git a/SOGo/UI/Scheduler/UIxAppointmentView.m b/SOGo/UI/Scheduler/UIxAppointmentView.m index 45fb80a8..62fd16a2 100644 --- a/SOGo/UI/Scheduler/UIxAppointmentView.m +++ b/SOGo/UI/Scheduler/UIxAppointmentView.m @@ -31,6 +31,14 @@ } +- (NSString *)attendeeEmail { + NSString *s; + + s = [[self attendee] email]; + if (![s hasPrefix:@"mailto:"]) return s; + return [s substringFromIndex:7]; +} + /* backend */ - (SOGoAppointment *)appointment { diff --git a/SOGo/UI/Scheduler/UIxAppointmentView.wox b/SOGo/UI/Scheduler/UIxAppointmentView.wox index 2764e2e9..775a5c5f 100644 --- a/SOGo/UI/Scheduler/UIxAppointmentView.wox +++ b/SOGo/UI/Scheduler/UIxAppointmentView.wox @@ -131,7 +131,8 @@ - + diff --git a/SOGo/UI/Scheduler/UIxCalView.m b/SOGo/UI/Scheduler/UIxCalView.m index 9510fc33..26120a93 100644 --- a/SOGo/UI/Scheduler/UIxCalView.m +++ b/SOGo/UI/Scheduler/UIxCalView.m @@ -42,18 +42,30 @@ } - (NSString *)shortTextForApt { - UIxAppointmentFormatter *f; - - f = [UIxAppointmentFormatter formatterWithFormat: +#if 1 + NSCalendarDate *startDate; + NSString *ms; + + startDate = [[self appointment] valueForKey:@"startDate"]; + ms = [NSString stringWithFormat:@"%02i:%02i %@", + [startDate hourOfDay], + [startDate minuteOfHour], + [[self appointment] valueForKey:@"title"]]; + return ms; +#else + UIxAppointmentFormatter *f; + + f = [UIxAppointmentFormatter formatterWithFormat: @"%S - %E;\n%T;\n%L;\n%5P;\n%50R"]; - [f setRelationDate:[self referenceDateForFormatter]]; - [f setShowFullNames:[self showFullNames]]; - if([self showAMPMDates]) + [f setRelationDate:[self referenceDateForFormatter]]; + [f setShowFullNames:[self showFullNames]]; + if([self showAMPMDates]) [f switchToAMPMTimes:YES]; - return [NSString stringWithFormat:@"%@:\n%@", + return [NSString stringWithFormat:@"%@:\n%@", [self aptTypeLabel], [f stringForObjectValue:self->appointment]]; +#endif } - (NSString *)shortTitleForApt { @@ -165,8 +177,13 @@ } - (NSArray *)fetchCoreInfos { - return [[self clientObject] fetchCoreInfosFrom:[self startDate] - to:[self endDate]]; + if (self->appointments) + return self->appointments; + + self->appointments = + [[[self clientObject] fetchCoreInfosFrom:[self startDate] + to:[self endDate]] retain]; + return self->appointments; } /* date selection & conversion */ diff --git a/SOGo/UI/Scheduler/UIxCalWeekOverview.wox b/SOGo/UI/Scheduler/UIxCalWeekOverview.wox index 37417854..b07f74e8 100644 --- a/SOGo/UI/Scheduler/UIxCalWeekOverview.wox +++ b/SOGo/UI/Scheduler/UIxCalWeekOverview.wox @@ -115,7 +115,8 @@ - +