-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathVEvent.m
129 lines (95 loc) · 2.93 KB
/
VEvent.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
//
// VEvent.m
// QSCalendarSupport
//
// Created by Brian Donovan on 31/03/05.
// Copyright 2005 __MyCompanyName__. All rights reserved.
//
#import "VEvent.h"
@implementation VEvent
+ (id)eventWithScanner:(NSScanner *)scanner {
return [[[VEvent alloc] initWithScanner:scanner] autorelease];
}
+ (id)eventWithString:(NSString *)string {
return [[[VEvent alloc] initWithString:string] autorelease];
}
+ (id)eventWithData:(NSData *)data {
return [[[VEvent alloc] initWithData:data] autorelease];
}
+ (id)eventWithFileObject:(VFileObject *)object {
return [[[VEvent alloc] initWithFileObject:object] autorelease];
}
- (id)initWithScanner:(NSScanner *)scanner {
if (!(self = [super init]))
return nil;
return [self initWithFileObject:[VFileObject objectWithScanner:scanner]];
}
- (id)initWithString:(NSString *)string {
if (!(self = [super init]))
return nil;
return [self initWithFileObject:[VFileObject objectWithString:string]];
}
- (id)initWithData:(NSData *)data {
if (!(self = [super init]))
return nil;
return [self initWithFileObject:[VFileObject objectWithData:data]];
}
- (id)initWithFileObject:(VFileObject *)object {
if (!(self = [super init]))
return nil;
if (!eqci([object type], VCALENDAREventType)) {
NSLog(@"Error: Parsed object is type %@, expecting %@", [object type], VCALENDAREventType);
[self autorelease];
return nil;
}
[self setType:VCALENDAREventType];
[self setContents:[object contents]];
return self;
}
- (NSCalendarDate *)startDate {
return [NSCalendarDate dateWithVFileDateProperty:[self firstPropertyForName:VCALENDARDateTimeStart]];
}
- (NSCalendarDate *)endDate {
return [NSCalendarDate dateWithVFileDateProperty:[self firstPropertyForName:VCALENDARDateTimeEnd]];
}
- (NSString *)location {
return [self parsedValueForProperty:VCALENDARLocation];
}
- (NSString *)status {
return [self parsedValueForProperty:VCALENDARStatus];
}
- (NSString *)uid {
return [self parsedValueForProperty:VCALENDARIdentifier];
}
- (NSDate *)timeStamp {
return [self parsedValueForProperty:VCALENDARTimestamp];
}
- (int)sequence {
return [[self parsedValueForProperty:VCALENDARSequence] intValue];
}
- (NSString *)description {
return [self parsedValueForProperty:VCALENDARDescription];
}
- (NSString *)summary {
return [self parsedValueForProperty:VCALENDARSummary];
}
- (NSArray *)attendees {
return [self propertiesForName:VCALENDARAttendee];
}
- (VFileProperty *)organizer {
return [self firstPropertyForName:VCALENDAROrganizer];
}
- (NSURL *)organizerAddress {
return [self parsedValueForProperty:VCALENDAROrganizer];
}
- (NSString *)organizerName {
return [[self organizer] firstValueForKey:VCALENDARCommonName];
}
- (id)parsedValueForProperty:(NSString *)propName {
if (eqci(propName, VCALENDAROrganizer)) {
return [NSURL URLWithString:[super parsedValueForProperty:propName]];
} else if (eqci(propName, VCALENDARSequence)) {
return [[super parsedValueForProperty:propName] convert
}
}
@end