]> err.no Git - scalable-opengroupware.org/commitdiff
minor code cleanups
authorhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Tue, 22 Feb 2005 15:33:04 +0000 (15:33 +0000)
committerhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Tue, 22 Feb 2005 15:33:04 +0000 (15:33 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@600 d1b88da0-ebda-0310-925b-ed51d893ca5b

SOGo/SoObjects/Appointments/ChangeLog
SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m
SOGo/SoObjects/Appointments/SOGoAppointmentObject.m
SOGo/SoObjects/Appointments/Version

index 07d3f48d6d95db2255c326e1fc74efb5753737af..16cf5827b4c3f12d55752abd3b302e87d8ff1c45 100644 (file)
@@ -1,3 +1,7 @@
+2005-02-22  Helge Hess  <helge.hess@skyrix.com>
+
+       * SOGoAppointmentFolder.m: minor code cleanups (v0.9.27)
+
 2005-02-17  Helge Hess  <helge.hess@opengroupware.org>
 
        * fixed for removal of SOGoLogic (v0.9.26)
index 6a20cf0ced596382f4c345f2edff6cc748065805..92c9390173dbe5c1ce4326d17d3996868caed4ce 100644 (file)
@@ -174,9 +174,40 @@ static NSTimeZone *MET    = nil;
   return md;
 }
 
+- (void)_flattenCycleRecord:(NSDictionary *)row
+  forRange:(NGCalendarDateRange *)_r
+  intoArray:(NSMutableArray *)ma
+{
+  NSString  *uid;
+  id        aptObject;
+  iCalEvent *apt;
+  NSArray   *ranges;
+  unsigned  k, rCount;
+      
+  uid        = [row valueForKey:@"uid"];
+  
+#warning FIXME: lookup done by name, not by UID
+  // TODO: this is wrong, we need to lookup the appointment by UID, not name
+  aptObject  = [self appointmentWithName:uid inContext:nil];
+  
+  apt        = [aptObject event];
+  ranges     = [apt recurrenceRangesWithinCalendarDateRange:_r];
+  rCount     = [ranges count];
+  for (k = 0; k < rCount; k++) {
+    NGCalendarDateRange *rRange;
+    id fixedRow;
+    
+    rRange   = [ranges objectAtIndex:k];
+    fixedRow = [self fixupRecord:row fetchRange:rRange];
+    if (fixedRow != nil) [ma addObject:fixedRow];
+  }
+}
+
 - (NSArray *)fixupRecords:(NSArray *)_records
   fetchRange:(NGCalendarDateRange *)_r
 {
+  // TODO: is the result supposed to be sorted by date?
+  // TODO: move cycle handling out of fixup
   NSMutableArray *ma;
   unsigned i, count;
 
@@ -184,35 +215,19 @@ static NSTimeZone *MET    = nil;
   if ((count = [_records count]) == 0)
     return _records;
   
+  // TODO: inefficient, does a lot of fetches for cycles, separate cycle
+  //       handling from fixup!
   ma = [NSMutableArray arrayWithCapacity:count];
   for (i = 0; i < count; i++) {
-    id row;
-
+    id row; // TODO: what is the type of the record?
+    
     row = [_records objectAtIndex:i];
     if ([[row valueForKey:@"iscycle"] intValue] != 0) {
-      NSString  *uid;
-      id        aptObject;
-      iCalEvent *apt;
-      NSArray   *ranges;
-      unsigned  k, rCount;
-      
-      uid        = [row valueForKey:@"uid"];
-      aptObject  = [self appointmentWithName:uid inContext:nil];
-      apt        = [aptObject event];
-      ranges     = [apt recurrenceRangesWithinCalendarDateRange:_r];
-      rCount     = [ranges count];
-      for (k = 0; k < rCount; k++) {
-        NGCalendarDateRange *rRange;
-        id fixedRow;
-
-        rRange   = [ranges objectAtIndex:k];
-        fixedRow = [self fixupRecord:row fetchRange:rRange];
-        if (fixedRow) [ma addObject:fixedRow];
-      }
+      [self _flattenCycleRecord:row forRange:_r intoArray:ma];
     }
     else {
       row = [self fixupRecord:row fetchRange:_r];
-      if (row) [ma addObject:row];
+      if (row != nil) [ma addObject:row];
     }
   }
   return ma;
@@ -270,37 +285,32 @@ static NSTimeZone *MET    = nil;
       __PRETTY_FUNCTION__];
     return nil;
   }
-  return [self fetchFields:_fields
-               fromFolder:folder
-               from:_startDate
-               to:_endDate];
+  return [self fetchFields:_fields fromFolder:folder
+               from:_startDate to:_endDate];
 }
 
 
 - (NSArray *)fetchFreebusyInfosFrom:(NSCalendarDate *)_startDate
   to:(NSCalendarDate *)_endDate
 {
-  static NSArray *infos = nil;
-  if(!infos) {
-    infos = [[NSArray arrayWithObjects:@"uid", @"startdate", @"enddate",
-                                       nil] retain];
+  static NSArray *infos = nil; // TODO: move to a plist file
+  if (infos == nil) {
+    infos = [[NSArray alloc] initWithObjects:@"uid", @"startdate", @"enddate",
+                                       nil];
   }
-  return [self fetchFields:infos
-               from:_startDate
-               to:_endDate];
+  return [self fetchFields:infos from:_startDate to:_endDate];
 }
 
 
 - (NSArray *)fetchOverviewInfosFrom:(NSCalendarDate *)_startDate
   to:(NSCalendarDate *)_endDate
 {
-  static NSArray *infos = nil;
-  if(!infos) {
-    infos = [[NSArray arrayWithObjects:@"uid", @"startdate", @"enddate",
-                                       @"title", @"location", @"orgmail",
-                                       @"status", @"ispublic", @"iscycle",
-                                       @"isallday",
-                                       nil] retain];
+  static NSArray *infos = nil; // TODO: move to a plist file
+  if (infos == nil) {
+    infos = [[NSArray alloc] initWithObjects:
+                        @"uid", @"startdate", @"enddate", @"title", 
+                        @"location", @"orgmail", @"status", @"ispublic", 
+                        @"iscycle", @"isallday", nil];
   }
   return [self fetchFields:infos
                from:_startDate
@@ -310,15 +320,15 @@ static NSTimeZone *MET    = nil;
 - (NSArray *)fetchCoreInfosFrom:(NSCalendarDate *)_startDate
   to:(NSCalendarDate *)_endDate 
 {
-  static NSArray *infos = nil;
-  if(!infos) {
-    infos = [[NSArray arrayWithObjects:@"uid", @"startdate", @"enddate",
-                                       @"title", @"location", @"orgmail",
-                                       @"status", @"ispublic", @"iscycle",
-                                       @"isallday", @"isopaque",
-                                       @"participants", @"partmails",
-                                       @"partstates", @"sequence",
-                                       nil] retain];
+  static NSArray *infos = nil; // TODO: move to a plist file
+  if (infos == nil) {
+    infos = [[NSArray alloc] initWithObjects:@"uid", @"startdate", @"enddate",
+                               @"title", @"location", @"orgmail",
+                               @"status", @"ispublic", @"iscycle",
+                               @"isallday", @"isopaque",
+                               @"participants", @"partmails",
+                               @"partstates", @"sequence",
+                             nil];
   }
   return [self fetchFields:infos
                from:_startDate
index 90492304ef3db5a439bc9c4099ab105ee44d5207..66f149b858b6b26923c8af9bd8f77e917be9fcae 100644 (file)
@@ -148,6 +148,7 @@ static NGLogger                  *logger = nil;
 /* folder management */
 
 - (id)lookupHomeFolderForUID:(NSString *)_uid inContext:(id)_ctx {
+  // 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 {
@@ -166,7 +167,7 @@ static NGLogger                  *logger = nil;
   
   e = [[self lookupCalendarFoldersForUIDs:_uids inContext:ctx]
             objectEnumerator];
-  while ((folder = [e nextObject])) {
+  while ((folder = [e nextObject]) != nil) {
     NSException           *error;
     SOGoAppointmentObject *apt;
     
index 00badea12a1ff81a68dc75c935a67f5e4e09e384..00d21930e702ea9c7403c9a34dceae484b94998f 100644 (file)
@@ -1,6 +1,6 @@
 # Version file
 
-SUBMINOR_VERSION:=26
+SUBMINOR_VERSION:=27
 
 # v0.9.26 requires libSOGo v0.9.30
 # v0.9.19 requires NGiCal  v4.5.36