]> err.no Git - scalable-opengroupware.org/commitdiff
added methods to render apts as just vevents
authorhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Tue, 19 Oct 2004 16:57:59 +0000 (16:57 +0000)
committerhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Tue, 19 Oct 2004 16:57:59 +0000 (16:57 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@410 d1b88da0-ebda-0310-925b-ed51d893ca5b

SOGoLogic/ChangeLog
SOGoLogic/SOGoAppointment.h
SOGoLogic/SOGoAppointment.m
SOGoLogic/SOGoAppointmentICalRenderer.h
SOGoLogic/SOGoAppointmentICalRenderer.m

index 6caa57141c6fea734d8748b4f2f4f7831cf075a0..5e2ddc316e0654f78802d4496f3f95ed9acebb89 100644 (file)
@@ -1,5 +1,14 @@
 2004-10-19  Helge Hess  <helge.hess@opengroupware.org>
 
+       * v0.9.21
+
+       * SOGoAppointment.m: added the -vEventString method (base on the new
+         renderer method)
+
+       * SOGoAppointmentICalRenderer.m :added -vEventStringForAppointment: 
+         method to render a SOGoAppointment as just a vevent (without the
+         vcalendar wrapper)
+
        * SOGoAppointment.m: added a -description (v0.9.20)
 
 2004-10-17  Marcus Mueller  <znek@mulle-kybernetik.com>
index d5cf0e0df8c80d9464f594ae48d492402eec93b6..4c99db61e6815e94075dd3213640b96b65b7f494 100644 (file)
@@ -98,6 +98,7 @@
 /* iCal generation */
 
 - (NSString *)iCalString;
+- (NSString *)vEventString;
 
 /* raw entity objects */
 
index de8dd2d001b47e64ac519bed00eab5dfe7961466..a92f42f8d9844f2771b9e3b0182c8c5d3a22101b 100644 (file)
@@ -125,6 +125,10 @@ static SaxObjectDecoder          *sax   = nil;
   return [[SOGoAppointmentICalRenderer sharedAppointmentRenderer]
                                       stringForAppointment:self];
 }
+- (NSString *)vEventString {
+  return [[SOGoAppointmentICalRenderer sharedAppointmentRenderer]
+                                      vEventStringForAppointment:self];
+}
 
 /* forwarded methods */
 
index 3eebed2dc53d00e7955c728b36606b1783686471..afdd2e6f342602e4d6b8ac1853d2553df0398790 100644 (file)
@@ -38,6 +38,7 @@
 
 + (id)sharedAppointmentRenderer;
 
+- (NSString *)vEventStringForAppointment:(SOGoAppointment *)_apt;
 - (NSString *)stringForAppointment:(SOGoAppointment *)_apt;
 
 @end
index 57e9aa845bb2ba6e26b70fd789fa1b5852446eab..b95b8a102ab7b1a0245c81ccdc10a2e289e8bb23 100644 (file)
@@ -35,6 +35,9 @@
 
 static SOGoAppointmentICalRenderer *renderer = nil;
 
+/* assume length of 1K - reasonable ? */
+static unsigned DefaultICalStringCapacity = 1024;
+
 + (id)sharedAppointmentRenderer {
   if (renderer == nil)
     renderer = [[self alloc] init];
@@ -183,28 +186,45 @@ static SOGoAppointmentICalRenderer *renderer = nil;
   [s appendString:@"END:VEVENT\r\n"];
 }
 
-- (NSString *)stringForAppointment:(SOGoAppointment *)_apt {
-  NSMutableString *s;
-
-  if (_apt == nil)
-    return nil;
+- (BOOL)isValidAppointment:(SOGoAppointment *)_apt {
+  if (![_apt isNotNull])
+    return NO;
   
   if ([[_apt uid] length] == 0) {
     [self logWithFormat:
            @"WARNING: got apt without uid, rejecting iCal generation: %@", 
            _apt];
-    return nil;
+    return NO;
   }
   if ([[[_apt startDate] icalString] length] == 0) {
     [self logWithFormat:
            @"WARNING: got apt without start date, "
            @"rejecting iCal generation: %@",
            _apt];
-    return nil;
+    return NO;
   }
   
-  /* assume length of 1K - reasonable ? */
-  s = [NSMutableString stringWithCapacity:1024];
+  return YES;
+}
+
+- (NSString *)vEventStringForAppointment:(SOGoAppointment *)_apt {
+  NSMutableString *s;
+  
+  if (![self isValidAppointment:_apt])
+    return nil;
+  
+  s = [NSMutableString stringWithCapacity:DefaultICalStringCapacity];
+  [self addVEventForAppointment:_apt toString:s];
+  return s;
+}
+
+- (NSString *)stringForAppointment:(SOGoAppointment *)_apt {
+  NSMutableString *s;
+  
+  if (![self isValidAppointment:_apt])
+    return nil;
+  
+  s = [NSMutableString stringWithCapacity:DefaultICalStringCapacity];
   [self addPreambleForAppointment:_apt  toString:s];
   [self addVEventForAppointment:_apt    toString:s];
   [self addPostambleForAppointment:_apt toString:s];