-2005-07-15 Marcus Mueller <znek@mulle-kybernetik.com>
+2005-07-15 Helge Hess <helge.hess@opengroupware.org>
- * v4.5.52
-
- * iCalEntityObject.[hm]: added -increaseSequence
+ * v4.5.53
- * v4.5.51
+ * iCalCalendar.m: added +parseCalendarFromSource: convenience method
+
+ * NGVCard.m: properly reset sax driver after parsing
+
+2005-07-15 Marcus Mueller <znek@mulle-kybernetik.com>
+
+ * iCalEntityObject.[hm]: added -increaseSequence (v4.5.52)
* iCalPerson.m: fixed -hasSameEmailAddress: to lowercase email
- addresses before attempting comparison
+ addresses before attempting comparison (v4.5.51)
2005-07-15 Helge Hess <helge.hess@opengroupware.org>
* v4.5.50
-
+
* NGiCal.xmap: fixed mapping of 'method' property (is an attribute of
the calendar)
* iCalCalendar.m: use ASSIGNCOPY in accessors, added 'method' to
-description
-
+
2005-07-14 Marcus Mueller <znek@mulle-kybernetik.com>
* v4.5.49
createXMLReaderForMimeType:@"text/x-vcard"]
retain];
if (parser == nil) {
- NSLog(@"%s: did not find a parser for text/x-vcard !",
+ NSLog(@"ERROR(%s): did not find a parser for text/x-vcard!",
__PRETTY_FUNCTION__);
return nil;
}
+ (NSArray *)parseVCardsFromSource:(id)_src {
static id<NSObject,SaxXMLReader> parser;
+ NSArray *vCards;
if ((parser = [self vCardParser]) == nil)
return nil;
[parser parseFromSource:_src];
- return [sax vCards];
+ vCards = [[sax vCards] retain];
+ [sax reset];
+ return [vCards autorelease];
}
- (id)initWithUid:(NSString *)_uid version:(NSString *)_version {
#include <NGiCal/iCalObject.h>
@class NSString, NSMutableArray, NSArray, NSEnumerator, NSMutableDictionary;
-@class iCalEvent, iCalToDo, iCalJournal, iCalFreeBusy;
+@class iCalEvent, iCalToDo, iCalJournal, iCalFreeBusy, iCalEntityObject;
@interface iCalCalendar : iCalObject
{
NSMutableDictionary *timezones;
}
++ (iCalCalendar *)parseCalendarFromSource:(id)_src;
+- (id)initWithEntityObject:(iCalEntityObject *)_entityObject;
+
/* accessors */
- (NSString *)calscale;
*/
#include "iCalCalendar.h"
+#include <SaxObjC/SaxObjC.h>
+#include "iCalEntityObject.h"
#include "common.h"
+@interface iCalCalendar(Privates)
+- (void)addToEvents:(iCalEvent *)_event;
+- (void)addToTimezones:(id)_tz;
+- (void)addToTodos:(iCalToDo *)_todo;
+- (void)addToJournals:(iCalJournal *)_obj;
+- (void)addToFreeBusys:(iCalFreeBusy *)_obj;
+@end
+
@implementation iCalCalendar
+static id<NSObject,SaxXMLReader> parser = nil; // THREAD
+static SaxObjectDecoder *sax = nil; // THREAD
+
++ (id<NSObject,SaxXMLReader>)iCalParser {
+ if (sax == nil) {
+ sax = [[SaxObjectDecoder alloc] initWithMappingNamed:@"NGiCal"];;
+ if (sax == nil) {
+ NSLog(@"ERROR(%s): could not create iCal SAX handler!",
+ __PRETTY_FUNCTION__);
+ }
+ }
+ if (sax != nil && parser == nil) {
+ parser =
+ [[[SaxXMLReaderFactory standardXMLReaderFactory]
+ createXMLReaderForMimeType:@"text/calendar"]
+ retain];
+ if (parser == nil) {
+ NSLog(@"ERROR(%s): did not find a parser for text/calendar!",
+ __PRETTY_FUNCTION__);
+ return nil;
+ }
+
+ [parser setContentHandler:sax];
+ [parser setErrorHandler:sax];
+ }
+ return parser;
+}
+
++ (iCalCalendar *)parseCalendarFromSource:(id)_src {
+ static id<NSObject,SaxXMLReader> parser;
+ id root, cal;
+
+ if ((parser = [self iCalParser]) == nil)
+ return nil;
+
+ [parser parseFromSource:_src];
+ root = [[sax rootObject] retain];
+ [sax reset];
+
+ if (root == nil)
+ return nil;
+ if ([root isKindOfClass:self])
+ return [root autorelease];
+
+ if (![root isKindOfClass:[iCalEntityObject class]]) {
+ NSLog(@"ERROR(%s): parsed object is of an unexpected class %@: %@",
+ __PRETTY_FUNCTION__, NSStringFromClass([root class]), root);
+ [root release];
+ return nil;
+ }
+
+ /* so we just got an iCalEntityObject, wrap that manually into a cal */
+ cal = [[[self alloc] initWithEntityObject:root] autorelease];
+ [root release]; root = nil;
+ return cal;
+}
+
+- (id)initWithEntityObject:(iCalEntityObject *)_entityObject {
+ if ((self = [self init])) {
+ if ([_entityObject isKindOfClass:[iCalEvent class]])
+ [self addToEvents:(iCalEvent *)_entityObject];
+ else if ([_entityObject isKindOfClass:[iCalToDo class]])
+ [self addToTodos:(iCalToDo *)_entityObject];
+ else if ([_entityObject isKindOfClass:[iCalJournal class]])
+ [self addToJournals:(iCalJournal *)_entityObject];
+ else if ([_entityObject isKindOfClass:[iCalFreeBusy class]])
+ [self addToFreeBusys:(iCalFreeBusy *)_entityObject];
+ else if ([_entityObject isNotNull]) {
+ [self errorWithFormat:@"Unexpected entity object: %@", _entityObject];
+ [self release];
+ return nil;
+ }
+ }
+ return self;
+}
+
- (void)dealloc {
[self->version release];
[self->calscale release];
return self->journals;
}
-- (void)addToFreeBusys:(iCalJournal *)_obj {
+- (void)addToFreeBusys:(iCalFreeBusy *)_obj {
if (_obj == nil) return;
if (self->freeBusys == nil)
self->freeBusys = [[NSMutableArray alloc] initWithCapacity:4];