mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-09-29 09:00:31 +00:00
Monotone-Parent: 0756417323a876b92e4f973205269864a2859da4
Monotone-Revision: d4ec4c64b7bfb4975be1924516e870493eb766a2 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2006-09-28T17:19:19 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
2006-09-28 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* OGoContentStore/OCSiCalFieldExtractor.m: use CardGroup's
|
||||
groupsOfClass:fromSource: to parse the given vcalendar.
|
||||
|
||||
* UI/Scheduler/iCalRecurrenceRule+SOGo.m: removed obsolete class.
|
||||
|
||||
* UI/Scheduler/SOGoAppointment+UIx.h: removed obsolete class.
|
||||
|
||||
@@ -21,59 +21,48 @@
|
||||
|
||||
#include "OCSiCalFieldExtractor.h"
|
||||
#include "common.h"
|
||||
#include <SaxObjC/SaxObjC.h>
|
||||
#include <NGCards/NGCards.h>
|
||||
#include "iCalEntityObject+OCS.h"
|
||||
#include "iCalRepeatableEntityObject+OCS.h"
|
||||
|
||||
@implementation OCSiCalFieldExtractor
|
||||
|
||||
static id<NSObject,SaxXMLReader> parser = nil;
|
||||
static SaxObjectDecoder *sax = nil;
|
||||
static OCSiCalFieldExtractor *extractor = nil;
|
||||
static NSCalendarDate *distantFuture = nil;
|
||||
static NSNumber *distantFutureNumber = nil;
|
||||
|
||||
+ (void)initialize {
|
||||
+ (void) initialize
|
||||
{
|
||||
static BOOL didInit = NO;
|
||||
|
||||
if (didInit) return;
|
||||
didInit = YES;
|
||||
|
||||
parser = [[[SaxXMLReaderFactory standardXMLReaderFactory]
|
||||
createXMLReaderForMimeType:@"text/calendar"]
|
||||
retain];
|
||||
if (parser == nil)
|
||||
NSLog(@"ERROR: did not find a parser for text/calendar!");
|
||||
sax = [[SaxObjectDecoder alloc] initWithMappingNamed:@"NGCards"];
|
||||
if (sax == nil)
|
||||
NSLog(@"ERROR: could not create the iCal SAX handler!");
|
||||
[parser setContentHandler:sax];
|
||||
[parser setErrorHandler:sax];
|
||||
|
||||
distantFuture = [[NSCalendarDate distantFuture] retain];
|
||||
/* INT_MAX due to Postgres constraint */
|
||||
distantFutureNumber = [[NSNumber numberWithUnsignedInt:INT_MAX] retain];
|
||||
}
|
||||
|
||||
+ (id)sharedICalFieldExtractor {
|
||||
if (extractor == nil) extractor = [[self alloc] init];
|
||||
return extractor;
|
||||
}
|
||||
+ (id) sharedICalFieldExtractor
|
||||
{
|
||||
if (extractor == nil)
|
||||
extractor = [self new];
|
||||
|
||||
- (void)dealloc {
|
||||
[super dealloc];
|
||||
return extractor;
|
||||
}
|
||||
|
||||
/* operations */
|
||||
|
||||
- (NSNumber *)numberForDate:(NSCalendarDate *)_date {
|
||||
- (NSNumber *) numberForDate: (NSCalendarDate *) _date
|
||||
{
|
||||
if (_date == distantFuture)
|
||||
return distantFutureNumber;
|
||||
|
||||
return [NSNumber numberWithUnsignedInt:[_date timeIntervalSince1970]];
|
||||
}
|
||||
|
||||
- (NSMutableDictionary *)extractQuickFieldsFromEvent:(iCalEvent *)_event {
|
||||
- (NSMutableDictionary *) extractQuickFieldsFromEvent: (iCalEvent *) _event
|
||||
{
|
||||
NSMutableDictionary *row;
|
||||
NSCalendarDate *startDate, *endDate;
|
||||
NSArray *attendees;
|
||||
@@ -219,29 +208,29 @@ static NSNumber *distantFutureNumber = nil;
|
||||
- (NSMutableDictionary *)extractQuickFieldsFromContent:(NSString *)_content {
|
||||
NSAutoreleasePool *pool;
|
||||
NSDictionary *fields;
|
||||
NSArray *cals;
|
||||
id cal;
|
||||
|
||||
if (parser == nil || sax == nil)
|
||||
return nil;
|
||||
if ([_content length] == 0)
|
||||
return nil;
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
cals = [CardGroup groupsOfClass: [iCalCalendar class]
|
||||
fromSource: _content];
|
||||
if ([cals count] > 0)
|
||||
{
|
||||
cal = [cals objectAtIndex: 0];
|
||||
|
||||
[parser parseFromSource:_content];
|
||||
cal = [sax rootObject];
|
||||
|
||||
fields = nil;
|
||||
if ([cal isKindOfClass:[iCalEvent class]])
|
||||
fields = [[self extractQuickFieldsFromEvent:cal] retain];
|
||||
else if ([cal isKindOfClass:[iCalCalendar class]])
|
||||
fields = [[self extractQuickFieldsFromCalendar:cal] retain];
|
||||
else if ([cal isNotNull]) {
|
||||
[self logWithFormat:@"ERROR: unexpected iCalendar parse result: %@",
|
||||
cal];
|
||||
}
|
||||
|
||||
[sax reset];
|
||||
fields = nil;
|
||||
if ([cal isKindOfClass:[iCalEvent class]])
|
||||
fields = [[self extractQuickFieldsFromEvent:cal] retain];
|
||||
else if ([cal isKindOfClass:[iCalCalendar class]])
|
||||
fields = [[self extractQuickFieldsFromCalendar:cal] retain];
|
||||
else if ([cal isNotNull]) {
|
||||
[self logWithFormat:@"ERROR: unexpected iCalendar parse result: %@",
|
||||
cal];
|
||||
}
|
||||
}
|
||||
|
||||
[pool release];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user