Imported Upstream version 0.42.2
Yavor Doganov
12 years ago
25 | 25 | |
26 | 26 | + (NSString *)storeName |
27 | 27 | { |
28 | return _(@"my address book"); | |
28 | return _(@"My address book"); | |
29 | 29 | } |
30 | 30 | |
31 | 31 | + (NSString *)storeTypeName |
0 | /* emacs buffer mode hint -*- objc -*- */ | |
1 | ||
2 | #import <Foundation/Foundation.h> | |
3 | #import "config.h" | |
4 | ||
5 | @class Date; | |
6 | @class Element; | |
7 | ||
8 | @interface Alarm : NSObject <NSCoding> | |
9 | { | |
10 | icalcomponent *_ic; | |
11 | Element *_element; | |
12 | } | |
13 | ||
14 | + (id)alarm; | |
15 | - (NSAttributedString *)desc; | |
16 | - (void)setDesc:(NSAttributedString *)desc; | |
17 | - (NSString *)summary; | |
18 | - (void)setSummary:(NSString *)summary; | |
19 | - (BOOL)isAbsoluteTrigger; | |
20 | - (Date *)absoluteTrigger; | |
21 | - (void)setAbsoluteTrigger:(Date *)trigger; | |
22 | - (NSTimeInterval)relativeTrigger; | |
23 | - (void)setRelativeTrigger:(NSTimeInterval)trigger; | |
24 | - (enum icalproperty_action)action; | |
25 | - (void)setAction:(enum icalproperty_action)action; | |
26 | - (NSString *)emailAddress; | |
27 | - (void)setEmailAddress:(NSString *)emailAddress; | |
28 | - (NSString *)sound; | |
29 | - (void)setSound:(NSString *)sound; | |
30 | - (NSURL *)url; | |
31 | - (void)setUrl:(NSURL *)url; | |
32 | - (int)repeatCount; | |
33 | - (void)setRepeatCount:(int)count; | |
34 | - (NSTimeInterval)repeatInterval; | |
35 | - (void)setRepeatInterval:(NSTimeInterval)interval; | |
36 | - (Element *)element; | |
37 | - (void)setElement:(Element *)element; | |
38 | - (Date *)triggerDateRelativeTo:(Date *)date; | |
39 | - (NSString *)shortDescription; | |
40 | ||
41 | - (id)initWithICalComponent:(icalcomponent *)ic; | |
42 | - (icalcomponent *)asICalComponent; | |
43 | - (int)iCalComponentType; | |
44 | @end |
0 | /* emacs buffer mode hint -*- objc -*- */ | |
1 | ||
2 | #import "Alarm.h" | |
3 | #import "Date.h" | |
4 | #import "Element.h" | |
5 | #import "HourFormatter.h" | |
6 | ||
7 | @implementation Alarm | |
8 | - (void)deleteProperty:(icalproperty_kind)kind fromComponent:(icalcomponent *)ic | |
9 | { | |
10 | icalproperty *prop = icalcomponent_get_first_property(ic, kind); | |
11 | if (prop) | |
12 | icalcomponent_remove_property(ic, prop); | |
13 | } | |
14 | ||
15 | - (void)encodeWithCoder:(NSCoder *)coder | |
16 | { | |
17 | [coder encodeObject:[NSString stringWithCString:icalcomponent_as_ical_string(_ic)] forKey:@"alarmComponent"]; | |
18 | } | |
19 | ||
20 | - (id)initWithCoder:(NSCoder *)coder | |
21 | { | |
22 | _ic = icalcomponent_new_from_string([[coder decodeObjectForKey:@"alarmComponent"] cString]); | |
23 | return self; | |
24 | } | |
25 | ||
26 | - (void)dealloc | |
27 | { | |
28 | icalcomponent_free(_ic); | |
29 | [super dealloc]; | |
30 | } | |
31 | ||
32 | - (id)init | |
33 | { | |
34 | self = [super init]; | |
35 | if (self) { | |
36 | _element = nil; | |
37 | _ic = icalcomponent_new([self iCalComponentType]); | |
38 | if (!_ic) { | |
39 | NSLog(@"Error while creating an VALARM component"); | |
40 | DESTROY(self); | |
41 | } | |
42 | } | |
43 | return self; | |
44 | } | |
45 | ||
46 | + (id)alarm | |
47 | { | |
48 | return AUTORELEASE([[Alarm alloc] init]); | |
49 | } | |
50 | ||
51 | - (NSAttributedString *)desc | |
52 | { | |
53 | icalproperty *prop = icalcomponent_get_first_property(_ic, ICAL_DESCRIPTION_PROPERTY); | |
54 | if (prop) | |
55 | return AUTORELEASE([[NSAttributedString alloc] initWithString:[NSString stringWithUTF8String:icalproperty_get_description(prop)]]); | |
56 | return nil; | |
57 | } | |
58 | ||
59 | - (void)setDesc:(NSAttributedString *)desc | |
60 | { | |
61 | [self deleteProperty:ICAL_DESCRIPTION_PROPERTY fromComponent:_ic]; | |
62 | if (desc) | |
63 | icalcomponent_add_property(_ic, icalproperty_new_description([[desc string] UTF8String])); | |
64 | } | |
65 | ||
66 | - (NSString *)summary | |
67 | { | |
68 | icalproperty *prop = icalcomponent_get_first_property(_ic, ICAL_SUMMARY_PROPERTY); | |
69 | if (!prop) { | |
70 | NSLog(@"Error : no summary property"); | |
71 | return nil; | |
72 | } | |
73 | return [NSString stringWithUTF8String:icalproperty_get_summary(prop)]; | |
74 | } | |
75 | ||
76 | - (void)setSummary:(NSString *)summary | |
77 | { | |
78 | [self deleteProperty:ICAL_SUMMARY_PROPERTY fromComponent:_ic]; | |
79 | if (summary) | |
80 | icalcomponent_add_property(_ic, icalproperty_new_summary([summary UTF8String])); | |
81 | } | |
82 | ||
83 | - (BOOL)isAbsoluteTrigger | |
84 | { | |
85 | struct icaltriggertype trigger; | |
86 | icalproperty *prop = icalcomponent_get_first_property(_ic, ICAL_TRIGGER_PROPERTY); | |
87 | ||
88 | if (!prop) { | |
89 | NSLog(@"Error : no trigger property"); | |
90 | return NO; | |
91 | } | |
92 | trigger = icalproperty_get_trigger(prop); | |
93 | if (icaltime_is_null_time(trigger.time)) | |
94 | return NO; | |
95 | return YES; | |
96 | } | |
97 | ||
98 | - (Date *)absoluteTrigger | |
99 | { | |
100 | struct icaltriggertype trigger; | |
101 | icalproperty *prop = icalcomponent_get_first_property(_ic, ICAL_TRIGGER_PROPERTY); | |
102 | ||
103 | if (!prop) { | |
104 | NSLog(@"Error : no trigger property"); | |
105 | return nil; | |
106 | } | |
107 | trigger = icalproperty_get_trigger(prop); | |
108 | return AUTORELEASE([[Date alloc] initWithICalTime:trigger.time]); | |
109 | } | |
110 | ||
111 | - (void)setAbsoluteTrigger:(Date *)date | |
112 | { | |
113 | struct icaltriggertype trigger; | |
114 | ||
115 | [self deleteProperty:ICAL_TRIGGER_PROPERTY fromComponent:_ic]; | |
116 | memset(&trigger, 0, sizeof(trigger)); | |
117 | trigger.time = [date UTCICalTime]; | |
118 | icalcomponent_add_property(_ic, icalproperty_new_trigger(trigger)); | |
119 | } | |
120 | ||
121 | - (NSTimeInterval)relativeTrigger | |
122 | { | |
123 | struct icaltriggertype trigger; | |
124 | icalproperty *prop = icalcomponent_get_first_property(_ic, ICAL_TRIGGER_PROPERTY); | |
125 | ||
126 | if (!prop) { | |
127 | NSLog(@"Error : no trigger property"); | |
128 | return -1; | |
129 | } | |
130 | trigger = icalproperty_get_trigger(prop); | |
131 | return icaldurationtype_as_int(trigger.duration); | |
132 | } | |
133 | ||
134 | - (void)setRelativeTrigger:(NSTimeInterval)duration | |
135 | { | |
136 | struct icaltriggertype trigger; | |
137 | ||
138 | [self deleteProperty:ICAL_TRIGGER_PROPERTY fromComponent:_ic]; | |
139 | memset(&trigger, 0, sizeof(trigger)); | |
140 | trigger.duration = icaldurationtype_from_int(duration); | |
141 | icalcomponent_add_property(_ic, icalproperty_new_trigger(trigger)); | |
142 | } | |
143 | ||
144 | - (enum icalproperty_action)action | |
145 | { | |
146 | icalproperty *prop = icalcomponent_get_first_property(_ic, ICAL_ACTION_PROPERTY); | |
147 | ||
148 | if (!prop) { | |
149 | NSLog(@"Error : no ACTION property"); | |
150 | return -1; | |
151 | } | |
152 | return icalproperty_get_action(prop); | |
153 | } | |
154 | ||
155 | - (void)setAction:(enum icalproperty_action)action | |
156 | { | |
157 | [self deleteProperty:ICAL_ACTION_PROPERTY fromComponent:_ic]; | |
158 | icalcomponent_add_property(_ic, icalproperty_new_action(action)); | |
159 | } | |
160 | ||
161 | - (NSString *)emailAddress | |
162 | { | |
163 | icalproperty *prop = icalcomponent_get_first_property(_ic, ICAL_ATTENDEE_PROPERTY); | |
164 | ||
165 | if (prop) | |
166 | return [NSString stringWithUTF8String:icalproperty_get_attendee(prop)]; | |
167 | return nil; | |
168 | } | |
169 | ||
170 | - (void)setEmailAddress:(NSString *)emailAddress | |
171 | { | |
172 | [self deleteProperty:ICAL_ATTENDEE_PROPERTY fromComponent:_ic]; | |
173 | if (emailAddress) { | |
174 | icalcomponent_add_property(_ic, icalproperty_new_attendee([emailAddress UTF8String])); | |
175 | [self setAction:ICAL_ACTION_EMAIL]; | |
176 | } | |
177 | } | |
178 | ||
179 | - (NSString *)sound | |
180 | { | |
181 | /* FIXME */ | |
182 | return nil; | |
183 | } | |
184 | ||
185 | - (void)setSound:(NSString *)sound | |
186 | { | |
187 | /* FIXME */ | |
188 | if (sound) { | |
189 | [self setAction:ICAL_ACTION_AUDIO]; | |
190 | } | |
191 | } | |
192 | ||
193 | - (NSURL *)url | |
194 | { | |
195 | /* FIXME */ | |
196 | return nil; | |
197 | } | |
198 | ||
199 | - (void)setUrl:(NSURL *)url | |
200 | { | |
201 | /* FIXME */ | |
202 | if (url) { | |
203 | [self setAction:ICAL_ACTION_PROCEDURE]; | |
204 | } | |
205 | } | |
206 | ||
207 | - (int)repeatCount | |
208 | { | |
209 | icalproperty *prop = icalcomponent_get_first_property(_ic, ICAL_REPEAT_PROPERTY); | |
210 | ||
211 | if (prop) | |
212 | return icalproperty_get_repeat(prop); | |
213 | return 0; | |
214 | } | |
215 | ||
216 | - (void)setRepeatCount:(int)count | |
217 | { | |
218 | [self deleteProperty:ICAL_REPEAT_PROPERTY fromComponent:_ic]; | |
219 | if (count > 0) | |
220 | icalcomponent_add_property(_ic, icalproperty_new_repeat(count)); | |
221 | } | |
222 | ||
223 | - (NSTimeInterval)repeatInterval | |
224 | { | |
225 | icalproperty *prop = icalcomponent_get_first_property(_ic, ICAL_DURATION_PROPERTY); | |
226 | ||
227 | if (prop) | |
228 | return icaldurationtype_as_int(icalproperty_get_duration(prop)); | |
229 | return 0; | |
230 | } | |
231 | ||
232 | - (void)setRepeatInterval:(NSTimeInterval)interval | |
233 | { | |
234 | [self deleteProperty:ICAL_DURATION_PROPERTY fromComponent:_ic]; | |
235 | if (interval > 0) | |
236 | icalcomponent_add_property(_ic, icalproperty_new_duration(icaldurationtype_from_int(interval))); | |
237 | } | |
238 | ||
239 | - (Element *)element | |
240 | { | |
241 | return _element; | |
242 | } | |
243 | ||
244 | - (void)setElement:(Element *)element | |
245 | { | |
246 | _element = element; | |
247 | NSDebugLog(@"Added %@ to element %@", [self description], [element UID]); | |
248 | } | |
249 | ||
250 | - (Date *)triggerDateRelativeTo:(Date *)date | |
251 | { | |
252 | return [Date dateWithTimeInterval:[self relativeTrigger] sinceDate:date]; | |
253 | } | |
254 | ||
255 | - (NSString *)description | |
256 | { | |
257 | if ([self isAbsoluteTrigger]) | |
258 | return [NSString stringWithFormat:@"Absolute trigger set to %@ repeat %d interval %f description <%@>", [[self absoluteTrigger] description], [self repeatCount], [self repeatInterval], [self desc]]; | |
259 | return [NSString stringWithFormat:@"Relative trigger delay %f repeat %d interval %f description <%@>", [self relativeTrigger], [self repeatCount], [self repeatInterval], [self desc]]; | |
260 | } | |
261 | ||
262 | - (NSString *)shortDescription | |
263 | { | |
264 | NSTimeInterval trigger; | |
265 | ||
266 | if ([self isAbsoluteTrigger]) | |
267 | return [NSString stringWithFormat:_(@"Trigger on %@"), [[[self absoluteTrigger] calendarDate] descriptionWithCalendarFormat:[[NSUserDefaults standardUserDefaults] objectForKey:NSShortTimeDateFormatString]]]; | |
268 | trigger = [self relativeTrigger]; | |
269 | if (trigger >= 0) | |
270 | return [NSString stringWithFormat:_(@"Trigger %@ after the event"), [HourFormatter stringForObjectValue:[NSNumber numberWithInt:trigger]]]; | |
271 | return [NSString stringWithFormat:_(@"Trigger %@ before the event"), [HourFormatter stringForObjectValue:[NSNumber numberWithInt:-trigger]]]; | |
272 | } | |
273 | ||
274 | - (id)copyWithZone:(NSZone *)zone | |
275 | { | |
276 | return [[Alarm allocWithZone:zone] initWithICalComponent:[self asICalComponent]]; | |
277 | } | |
278 | ||
279 | ||
280 | - (id)initWithICalComponent:(icalcomponent *)ic | |
281 | { | |
282 | if ((self = [super init])) { | |
283 | _element = nil; | |
284 | _ic = icalcomponent_new_clone(ic); | |
285 | if (!_ic) { | |
286 | NSLog(@"Error creating Alarm from iCal component"); | |
287 | NSLog(@"\n\n%s", icalcomponent_as_ical_string(ic)); | |
288 | DESTROY(self); | |
289 | } | |
290 | } | |
291 | return self; | |
292 | } | |
293 | ||
294 | - (icalcomponent *)asICalComponent | |
295 | { | |
296 | return icalcomponent_new_clone(_ic); | |
297 | } | |
298 | ||
299 | - (int)iCalComponentType | |
300 | { | |
301 | return ICAL_VALARM_COMPONENT; | |
302 | } | |
303 | @end |
0 | /* emacs buffer mode hint -*- objc -*- */ | |
1 | ||
2 | #import "Alarm.h" | |
3 | ||
4 | @interface AlarmBackend : NSObject | |
5 | + (NSString *)backendName; | |
6 | - (enum icalproperty_action)backendType; | |
7 | - (void)display:(Alarm *)alarm; | |
8 | @end |
1 | 1 | |
2 | 2 | #import <Foundation/Foundation.h> |
3 | 3 | |
4 | @class Element; | |
5 | @class Alarm; | |
6 | ||
4 | 7 | @interface AlarmEditor : NSObject |
5 | 8 | { |
9 | id window; | |
6 | 10 | id panel; |
7 | id calendar; | |
8 | 11 | id type; |
9 | 12 | id action; |
13 | id table; | |
14 | id add; | |
15 | id remove; | |
16 | id relativeSlider; | |
17 | id relativeText; | |
18 | id radio; | |
19 | id date; | |
20 | id time; | |
21 | NSMutableArray *_alarms; | |
22 | Alarm *_current; | |
23 | Alarm *_simple; | |
10 | 24 | } |
11 | 25 | |
12 | - (void)show; | |
26 | + (NSArray *)editAlarms:(NSArray *)alarms; | |
27 | - (void)addAlarm:(id)sender; | |
28 | - (void)removeAlarm:(id)sender; | |
29 | - (void)changeDelay:(id)sender; | |
30 | - (void)selectType:(id)sender; | |
31 | - (void)switchBeforeAfter:(id)sender; | |
13 | 32 | @end |
0 | 0 | #import <AppKit/AppKit.h> |
1 | 1 | #import "AlarmEditor.h" |
2 | #import "Element.h" | |
3 | #import "Alarm.h" | |
4 | #import "HourFormatter.h" | |
2 | 5 | |
3 | 6 | @implementation AlarmEditor |
7 | - (void)setupForSelection | |
8 | { | |
9 | NSTimeInterval relativeTrigger; | |
10 | Date *d; | |
11 | ||
12 | if ([_alarms count] == 0) { | |
13 | [action setEnabled:NO]; | |
14 | [type setEnabled:NO]; | |
15 | [relativeSlider setEnabled:NO]; | |
16 | [radio setEnabled:NO]; | |
17 | [date setEnabled:NO]; | |
18 | [time setEnabled:NO]; | |
19 | [date setObjectValue:nil]; | |
20 | [date setObjectValue:nil]; | |
21 | [remove setEnabled:NO]; | |
22 | _current = nil; | |
23 | return; | |
24 | } | |
25 | [action setEnabled:YES]; | |
26 | [type setEnabled:YES]; | |
27 | [remove setEnabled:YES]; | |
28 | _current = [_alarms objectAtIndex:[table selectedRow]]; | |
29 | if ([_current isAbsoluteTrigger]) { | |
30 | [relativeSlider setEnabled:NO]; | |
31 | [radio setEnabled:NO]; | |
32 | [date setEnabled:YES]; | |
33 | [time setEnabled:YES]; | |
34 | d = [_current absoluteTrigger]; | |
35 | [date setObjectValue:[d calendarDate]]; | |
36 | [time setIntValue:[d hourOfDay] * 3600 + [d minuteOfHour] * 60]; | |
37 | [type selectItemAtIndex:1]; | |
38 | } else { | |
39 | [relativeSlider setEnabled:YES]; | |
40 | [radio setEnabled:YES]; | |
41 | [date setEnabled:NO]; | |
42 | [time setEnabled:NO]; | |
43 | [date setObjectValue:nil]; | |
44 | [date setObjectValue:nil]; | |
45 | [type selectItemAtIndex:0]; | |
46 | relativeTrigger = [_current relativeTrigger]; | |
47 | if (relativeTrigger >= 0) { | |
48 | [radio selectCellWithTag:1]; | |
49 | [relativeSlider setFloatValue:relativeTrigger]; | |
50 | } else { | |
51 | [radio selectCellWithTag:0]; | |
52 | [relativeSlider setFloatValue:-relativeTrigger]; | |
53 | } | |
54 | [relativeText setFloatValue:[relativeSlider floatValue]]; | |
55 | } | |
56 | } | |
57 | ||
4 | 58 | - (id)init |
5 | 59 | { |
6 | self = [super init]; | |
7 | if (self) { | |
8 | if (![NSBundle loadNibNamed:@"Alarm" owner:self]) { | |
9 | [self release]; | |
10 | return nil; | |
11 | } | |
60 | HourFormatter *formatter; | |
61 | NSDateFormatter *dateFormatter; | |
62 | ||
63 | if (![NSBundle loadNibNamed:@"Alarm" owner:self]) | |
64 | return nil; | |
65 | if ((self = [super init])) { | |
66 | _current = nil; | |
67 | _simple = RETAIN([Alarm alarm]); | |
68 | [_simple setRelativeTrigger:-15*60]; | |
69 | [_simple setAction:ICAL_ACTION_DISPLAY]; | |
70 | ||
71 | [table setDelegate:self]; | |
72 | ||
73 | [type removeAllItems]; | |
74 | [type addItemsWithTitles:[NSArray arrayWithObjects:_(@"Relative"), _(@"Absolute"), nil]]; | |
75 | [action removeAllItems]; | |
76 | [action addItemsWithTitles:[NSArray arrayWithObjects:_(@"Display"), _(@"Sound"), _(@"Email"), _(@"Procedure"), nil]]; | |
77 | ||
78 | [table setUsesAlternatingRowBackgroundColors:YES]; | |
79 | [table sizeLastColumnToFit]; | |
80 | ||
81 | formatter = AUTORELEASE([[HourFormatter alloc] init]); | |
82 | dateFormatter = AUTORELEASE([[NSDateFormatter alloc] initWithDateFormat:[[NSUserDefaults standardUserDefaults] objectForKey:NSShortDateFormatString] allowNaturalLanguage:NO]); | |
83 | [[relativeText cell] setFormatter:formatter]; | |
84 | [time setFormatter:formatter]; | |
85 | [date setFormatter:dateFormatter]; | |
12 | 86 | } |
13 | 87 | return self; |
14 | 88 | } |
15 | 89 | |
16 | - (void)show | |
17 | { | |
18 | [NSApp runModalForWindow:panel]; | |
90 | - (id)initWithAlarms:(NSArray *)alarms | |
91 | { | |
92 | if ((self = [self init])) { | |
93 | _alarms = [[NSMutableArray alloc] initWithArray:alarms copyItems:YES]; | |
94 | [table reloadData]; | |
95 | [self setupForSelection]; | |
96 | } | |
97 | return self; | |
98 | } | |
99 | ||
100 | - (NSArray *)run | |
101 | { | |
102 | [NSApp runModalForWindow:window]; | |
103 | return [NSArray arrayWithArray:_alarms]; | |
104 | } | |
105 | ||
106 | + (NSArray *)editAlarms:(NSArray *)alarms | |
107 | { | |
108 | AlarmEditor *editor; | |
109 | NSArray *modified; | |
110 | ||
111 | if ((editor = [[AlarmEditor alloc] initWithAlarms:alarms])) { | |
112 | modified = [editor run]; | |
113 | [editor release]; | |
114 | return modified; | |
115 | } | |
116 | return nil; | |
117 | } | |
118 | ||
119 | - (void)dealloc | |
120 | { | |
121 | DESTROY(_simple); | |
122 | DESTROY(_alarms); | |
123 | [super dealloc]; | |
124 | } | |
125 | ||
126 | - (void)addAlarm:(id)sender | |
127 | { | |
128 | [_alarms addObject:AUTORELEASE([_simple copy])]; | |
129 | [table reloadData]; | |
130 | [table selectRow:[_alarms count]-1 byExtendingSelection:NO]; | |
131 | } | |
132 | ||
133 | - (void)removeAlarm:(id)sender | |
134 | { | |
135 | [_alarms removeObjectAtIndex:[table selectedRow]]; | |
136 | [table reloadData]; | |
137 | [self tableViewSelectionDidChange:nil]; | |
138 | } | |
139 | ||
140 | - (void)selectType:(id)sender | |
141 | { | |
142 | Date *d; | |
143 | ||
144 | if ([type indexOfSelectedItem] == 1) { | |
145 | d = [Date now]; | |
146 | [d changeDayBy:7]; | |
147 | [date setObjectValue:[d calendarDate]]; | |
148 | [time setFloatValue:([d hourOfDay]*60 + [d minuteOfHour]) / 60.0]; | |
149 | [_current setAbsoluteTrigger:d]; | |
150 | [table reloadData]; | |
151 | } else { | |
152 | [self changeDelay:nil]; | |
153 | } | |
154 | [self setupForSelection]; | |
155 | } | |
156 | ||
157 | - (void)changeDelay:(id)sender | |
158 | { | |
159 | [relativeText setIntValue:[relativeSlider intValue]]; | |
160 | if ([[radio selectedCell] tag] == 0) | |
161 | [_current setRelativeTrigger:-[relativeSlider intValue]]; | |
162 | else | |
163 | [_current setRelativeTrigger:[relativeSlider intValue]]; | |
164 | [table reloadData]; | |
165 | } | |
166 | ||
167 | - (void)switchBeforeAfter:(id)sender | |
168 | { | |
169 | [self changeDelay:self]; | |
170 | } | |
171 | ||
172 | - (void)tableViewSelectionDidChange:(NSNotification *)aNotification | |
173 | { | |
174 | [self setupForSelection]; | |
175 | } | |
176 | ||
177 | - (void)controlTextDidEndEditing:(NSNotification *)aNotification | |
178 | { | |
179 | Date *d; | |
180 | ||
181 | if (_current && [date objectValue] && [time objectValue]) { | |
182 | d = [Date dateWithCalendarDate:[date objectValue] withTime:NO]; | |
183 | d = [Date dateWithTimeInterval:[time intValue] sinceDate:d]; | |
184 | [_current setAbsoluteTrigger:d]; | |
185 | [table reloadData]; | |
186 | } | |
19 | 187 | } |
20 | 188 | @end |
21 | 189 | |
190 | @implementation AlarmEditor(NSTableViewDataSource) | |
191 | - (int)numberOfRowsInTableView:(NSTableView *)aTableView | |
192 | { | |
193 | return [_alarms count]; | |
194 | } | |
195 | - (BOOL)tableView:(NSTableView *)tableView acceptDrop:(id)info row:(int)row dropOperation:(NSTableViewDropOperation)operation | |
196 | { | |
197 | return NO; | |
198 | } | |
199 | - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex | |
200 | { | |
201 | return [[_alarms objectAtIndex:rowIndex] shortDescription]; | |
202 | } | |
203 | @end |
2 | 2 | #import <Foundation/NSObject.h> |
3 | 3 | #import "ConfigManager.h" |
4 | 4 | |
5 | @interface AlarmManager : NSObject <ConfigListener> | |
5 | extern NSString * const SAEventReminderWillRun; | |
6 | ||
7 | @interface AlarmManager : NSObject | |
6 | 8 | { |
7 | 9 | NSMutableDictionary *_activeAlarms; |
8 | BOOL _active; | |
10 | id _defaultBackend; | |
9 | 11 | } |
10 | 12 | |
13 | + (NSArray *)backends; | |
14 | + (id)backendForName:(NSString *)name; | |
11 | 15 | + (AlarmManager *)globalManager; |
16 | - (id)defaultBackend; | |
17 | - (NSString *)defaultBackendName; | |
18 | - (void)setDefaultBackend:(NSString *)name; | |
19 | - (BOOL)alarmsEnabled; | |
20 | - (void)setAlarmsEnabled:(BOOL)value; | |
12 | 21 | @end |
3 | 3 | #import "ConfigManager.h" |
4 | 4 | #import "MemoryStore.h" |
5 | 5 | #import "Element.h" |
6 | #import "SAAlarm.h" | |
7 | #import "defines.h" | |
8 | ||
6 | #import "Alarm.h" | |
7 | #import "AlarmBackend.h" | |
8 | ||
9 | NSString * const ACTIVATE_ALARMS = @"activateAlarms"; | |
10 | NSString * const DEFAULT_ALARM_BACKEND = @"defaultAlarmBackend"; | |
11 | ||
12 | NSString * const SAEventReminderWillRun = @"SAEventReminderWillRun"; | |
13 | ||
14 | static NSMutableDictionary *backendsArray; | |
9 | 15 | static AlarmManager *singleton; |
10 | 16 | |
11 | 17 | @interface AlarmManager(Private) |
18 | + (void)addBackendClass:(Class)class; | |
12 | 19 | - (void)removeAlarms; |
13 | 20 | - (void)createAlarms; |
14 | 21 | @end |
15 | 22 | |
16 | 23 | @implementation AlarmManager(Private) |
17 | - (void)runAlarm:(SAAlarm *)alarm | |
18 | { | |
19 | NSLog([alarm description]); | |
20 | if ([alarm isAbsoluteTrigger]) { | |
21 | } else { | |
22 | } | |
23 | } | |
24 | ||
25 | - (void)addAlarm:(SAAlarm *)alarm forUID:(NSString *)uid | |
24 | + (void)addBackendClass:(Class)class | |
25 | { | |
26 | id backend; | |
27 | ||
28 | backend = [class new]; | |
29 | if (backend) { | |
30 | [backendsArray setObject:backend forKey:[class backendName]]; | |
31 | [backend release]; | |
32 | NSLog(@"Alarm backend <%@> registered", [class backendName]); | |
33 | } | |
34 | } | |
35 | ||
36 | - (void)runAlarm:(Alarm *)alarm | |
37 | { | |
38 | [[NSNotificationCenter defaultCenter] postNotificationName:SAEventReminderWillRun object:alarm]; | |
39 | if (_defaultBackend) | |
40 | [_defaultBackend display:alarm]; | |
41 | } | |
42 | ||
43 | - (void)addAlarm:(Alarm *)alarm forUID:(NSString *)uid | |
26 | 44 | { |
27 | 45 | NSMutableArray *alarms = [_activeAlarms objectForKey:uid]; |
28 | 46 | |
37 | 55 | { |
38 | 56 | NSMutableArray *alarms = [_activeAlarms objectForKey:uid]; |
39 | 57 | NSEnumerator *enumerator; |
40 | SAAlarm *alarm; | |
58 | Alarm *alarm; | |
41 | 59 | |
42 | 60 | if (alarms) { |
43 | 61 | enumerator = [alarms objectEnumerator]; |
49 | 67 | } |
50 | 68 | } |
51 | 69 | |
52 | - (BOOL)addAbsoluteAlarm:(SAAlarm *)alarm | |
53 | { | |
54 | NSDate *date = [[alarm absoluteTrigger] calendarDate]; | |
55 | ||
56 | if ([date timeIntervalSinceNow] < 0) | |
70 | - (BOOL)addAbsoluteAlarm:(Alarm *)alarm | |
71 | { | |
72 | NSTimeInterval delay; | |
73 | ||
74 | delay = [[alarm absoluteTrigger] timeIntervalSinceNow]; | |
75 | if (delay < 0) | |
57 | 76 | return NO; |
58 | [self performSelector:@selector(absoluteTrigger:) | |
77 | [self performSelector:@selector(runAlarm:) | |
59 | 78 | withObject:alarm |
60 | afterDelay:[date timeIntervalSinceNow]]; | |
79 | afterDelay:delay]; | |
61 | 80 | return YES; |
62 | 81 | } |
63 | 82 | |
64 | - (BOOL)addRelativeAlarm:(SAAlarm *)alarm | |
65 | { | |
66 | return NO; | |
83 | - (BOOL)addRelativeAlarm:(Alarm *)alarm | |
84 | { | |
85 | Date *activation = [[alarm element] nextActivationDate]; | |
86 | NSTimeInterval delay; | |
87 | ||
88 | if (!activation) | |
89 | return NO; | |
90 | if ([[Date now] compareTime:activation] == NSOrderedDescending) | |
91 | return NO; | |
92 | activation = [Date dateWithTimeInterval:[alarm relativeTrigger] sinceDate:activation]; | |
93 | delay = [activation timeIntervalSinceNow]; | |
94 | if (delay < 1 && delay > -600) | |
95 | delay = 1; | |
96 | if (delay < 0) | |
97 | return NO; | |
98 | [self performSelector:@selector(runAlarm:) | |
99 | withObject:alarm | |
100 | afterDelay:delay]; | |
101 | return YES; | |
67 | 102 | } |
68 | 103 | |
69 | 104 | - (void)setAlarmsForElement:(Element *)element |
70 | 105 | { |
71 | 106 | NSEnumerator *enumAlarm; |
72 | SAAlarm *alarm; | |
107 | Alarm *alarm; | |
73 | 108 | BOOL added; |
74 | 109 | |
75 | 110 | if (![[element store] displayed] || ![element hasAlarms]) |
76 | 111 | return; |
77 | 112 | enumAlarm = [[element alarms] objectEnumerator]; |
78 | 113 | while ((alarm = [enumAlarm nextObject])) { |
114 | NSAssert([alarm element] != nil, @"Alarm is not linked with an element"); | |
79 | 115 | if ([alarm isAbsoluteTrigger]) |
80 | 116 | added = [self addAbsoluteAlarm:alarm]; |
81 | 117 | else |
94 | 130 | [self setAlarmsForElement:element]; |
95 | 131 | } |
96 | 132 | |
133 | - (void)dataChanged:(NSNotification *)not | |
134 | { | |
135 | [self createAlarms]; | |
136 | } | |
137 | ||
97 | 138 | - (void)elementAdded:(NSNotification *)not |
98 | 139 | { |
99 | if (_active) { | |
140 | if ([self alarmsEnabled]) { | |
100 | 141 | MemoryStore *store = [not object]; |
101 | 142 | NSString *uid = [[not userInfo] objectForKey:@"UID"]; |
102 | 143 | |
103 | NSLog(@"Add alarms for %@", uid); | |
104 | 144 | [self setAlarmsForElement:[store elementWithUID:uid]]; |
105 | 145 | } |
106 | 146 | } |
107 | 147 | |
108 | 148 | - (void)elementRemoved:(NSNotification *)not |
109 | 149 | { |
110 | if (_active) { | |
111 | NSString *uid = [[not userInfo] objectForKey:@"UID"]; | |
112 | ||
113 | NSLog(@"Remove alarms for %@", uid); | |
114 | [self removeAlarmsforUID:uid]; | |
115 | } | |
150 | if ([self alarmsEnabled]) | |
151 | [self removeAlarmsforUID:[[not userInfo] objectForKey:@"UID"]]; | |
116 | 152 | } |
117 | 153 | |
118 | 154 | - (void)elementUpdated:(NSNotification *)not |
119 | 155 | { |
120 | if (_active) { | |
156 | if ([self alarmsEnabled]) { | |
121 | 157 | MemoryStore *store = [not object]; |
122 | 158 | NSString *uid = [[not userInfo] objectForKey:@"UID"]; |
123 | 159 | |
124 | NSLog(@"Update alarms for %@", uid); | |
125 | 160 | [self removeAlarmsforUID:uid]; |
126 | 161 | [self setAlarmsForElement:[store elementWithUID:uid]]; |
127 | 162 | } |
129 | 164 | |
130 | 165 | - (NSDictionary *)defaults |
131 | 166 | { |
132 | return [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO] forKey:ALARMS]; | |
133 | } | |
134 | ||
167 | return [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects: [NSNumber numberWithBool:NO], [AlarmBackend backendName], nil] | |
168 | forKeys:[NSArray arrayWithObjects: ACTIVATE_ALARMS, DEFAULT_ALARM_BACKEND, nil]]; | |
169 | } | |
170 | ||
171 | /* FIXME : what happens when a store is reloaded ? */ | |
135 | 172 | - (id)init |
136 | 173 | { |
137 | 174 | NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; |
140 | 177 | self = [super init]; |
141 | 178 | if (self) { |
142 | 179 | [cm registerDefaults:[self defaults]]; |
143 | [cm registerClient:self forKey:ALARMS]; | |
144 | _active = [[cm objectForKey:ALARMS] boolValue]; | |
180 | [self setDefaultBackend:[cm objectForKey:DEFAULT_ALARM_BACKEND]]; | |
181 | ||
145 | 182 | _activeAlarms = [[NSMutableDictionary alloc] initWithCapacity:32]; |
183 | [nc addObserver:self | |
184 | selector:@selector(dataChanged:) | |
185 | name:SADataChangedInStore | |
186 | object:nil]; | |
146 | 187 | [nc addObserver:self |
147 | 188 | selector:@selector(elementAdded:) |
148 | 189 | name:SAElementAddedToStore |
155 | 196 | selector:@selector(elementUpdated:) |
156 | 197 | name:SAElementUpdatedInStore |
157 | 198 | object:nil]; |
158 | if (_active) | |
159 | [self createAlarms]; | |
160 | /* FIXME : what happens when a store is reloaded ? */ | |
199 | ||
200 | [self createAlarms]; | |
201 | NSLog(@"Alarms are %@", [self alarmsEnabled] ? @"enabled" : @"disabled"); | |
161 | 202 | } |
162 | 203 | return self; |
163 | 204 | } |
165 | 206 | - (void)dealloc |
166 | 207 | { |
167 | 208 | [[NSNotificationCenter defaultCenter] removeObserver:self]; |
168 | [[ConfigManager globalConfig] unregisterClient:self]; | |
169 | 209 | RELEASE(_activeAlarms); |
170 | 210 | [super dealloc]; |
171 | 211 | } |
175 | 215 | StoreManager *sm = [StoreManager globalManager]; |
176 | 216 | |
177 | 217 | [self removeAlarms]; |
178 | [self setAlarmsForElements:[sm allEvents]]; | |
179 | [self setAlarmsForElements:[sm allTasks]]; | |
218 | if ([self alarmsEnabled]) { | |
219 | [self setAlarmsForElements:[sm allEvents]]; | |
220 | [self setAlarmsForElements:[sm allTasks]]; | |
221 | } | |
180 | 222 | } |
181 | 223 | |
182 | 224 | - (void)removeAlarms |
189 | 231 | @implementation AlarmManager |
190 | 232 | + (void)initialize |
191 | 233 | { |
192 | if ([AlarmManager class] == self) | |
234 | NSArray *classes; | |
235 | NSEnumerator *enumerator; | |
236 | Class backendClass; | |
237 | ||
238 | if ([AlarmManager class] == self) { | |
239 | classes = GSObjCAllSubclassesOfClass([AlarmBackend class]); | |
240 | backendsArray = [[NSMutableDictionary alloc] initWithCapacity:[classes count]+1]; | |
241 | enumerator = [classes objectEnumerator]; | |
242 | while ((backendClass = [enumerator nextObject])) | |
243 | [self addBackendClass:backendClass]; | |
244 | [self addBackendClass:[AlarmBackend class]]; | |
193 | 245 | singleton = [[AlarmManager alloc] init]; |
246 | } | |
247 | } | |
248 | ||
249 | + (NSArray *)backends | |
250 | { | |
251 | return [backendsArray allValues]; | |
252 | } | |
253 | ||
254 | + (id)backendForName:(NSString *)name | |
255 | { | |
256 | return [backendsArray objectForKey:name]; | |
194 | 257 | } |
195 | 258 | |
196 | 259 | + (AlarmManager *)globalManager |
198 | 261 | return singleton; |
199 | 262 | } |
200 | 263 | |
201 | - (void)config:(ConfigManager *)config dataDidChangedForKey:(NSString *)key | |
202 | { | |
203 | _active = [[config objectForKey:ALARMS] boolValue]; | |
204 | if (_active) | |
264 | - (id)defaultBackend | |
265 | { | |
266 | return _defaultBackend; | |
267 | } | |
268 | ||
269 | - (NSString *)defaultBackendName | |
270 | { | |
271 | return [[_defaultBackend class] backendName]; | |
272 | } | |
273 | ||
274 | - (void)setDefaultBackend:(NSString *)name | |
275 | { | |
276 | id bck = [AlarmManager backendForName:name]; | |
277 | if (bck != nil) { | |
278 | _defaultBackend = bck; | |
279 | [[ConfigManager globalConfig] setObject:name forKey:DEFAULT_ALARM_BACKEND]; | |
280 | NSLog(@"Default alarm backend is <%@>", name); | |
281 | } | |
282 | } | |
283 | ||
284 | - (BOOL)alarmsEnabled | |
285 | { | |
286 | return [[[ConfigManager globalConfig] objectForKey:ACTIVATE_ALARMS] boolValue]; | |
287 | } | |
288 | ||
289 | - (void)setAlarmsEnabled:(BOOL)value | |
290 | { | |
291 | if (value) | |
205 | 292 | [self createAlarms]; |
206 | 293 | else |
207 | 294 | [self removeAlarms]; |
295 | [[ConfigManager globalConfig] setInteger:value forKey:ACTIVATE_ALARMS]; | |
296 | NSLog(@"Alarms are %@", value ? @"enabled" : @"disabled"); | |
208 | 297 | } |
209 | 298 | @end |
299 | ||
300 | ||
301 | @implementation AlarmBackend | |
302 | + (NSString *)backendName | |
303 | { | |
304 | return @"Log backend"; | |
305 | } | |
306 | - (enum icalproperty_action)backendType | |
307 | { | |
308 | return ICAL_ACTION_DISPLAY; | |
309 | } | |
310 | - (void)display:(Alarm *)alarm | |
311 | { | |
312 | NSLog([alarm description]); | |
313 | } | |
314 | @end |
10 | 10 | #import "SelectionManager.h" |
11 | 11 | #import "ConfigManager.h" |
12 | 12 | |
13 | @interface AppController : NSObject <ConfigListener> | |
13 | @interface AppController : NSObject | |
14 | 14 | { |
15 | 15 | IBOutlet CalendarView *calendar; |
16 | 16 | IBOutlet DayView *dayView; |
23 | 23 | |
24 | 24 | PreferencesController *_pc; |
25 | 25 | StoreManager *_sm; |
26 | SelectionManager *selectionManager; | |
26 | SelectionManager *_selm; | |
27 | 27 | Date *_selectedDay; |
28 | 28 | DataTree *_summaryRoot; |
29 | 29 | DataTree *_today; |
10 | 10 | #import "iCalTree.h" |
11 | 11 | #import "SelectionManager.h" |
12 | 12 | #import "AlarmManager.h" |
13 | #import "Alarm.h" | |
13 | 14 | #import "defines.h" |
14 | 15 | |
15 | @interface AppIcon : NSView | |
16 | { | |
17 | NSTimer *timer; | |
16 | @interface AppIcon : NSView <ConfigListener> | |
17 | { | |
18 | ConfigManager *_cm; | |
19 | NSDictionary *_attrs; | |
20 | NSTimer *_timer; | |
21 | BOOL _showDate; | |
22 | BOOL _showTime; | |
23 | NSImage *_bell; | |
18 | 24 | } |
19 | 25 | @end |
20 | 26 | @implementation AppIcon |
27 | - (void)setup | |
28 | { | |
29 | _showDate = [[_cm objectForKey:APPICON_DATE] boolValue]; | |
30 | _showTime = [[_cm objectForKey:APPICON_TIME] boolValue]; | |
31 | if (_showTime) { | |
32 | if (_timer == nil) | |
33 | _timer = [NSTimer scheduledTimerWithTimeInterval:1 | |
34 | target:self | |
35 | selector:@selector(secondChanged:) | |
36 | userInfo:nil | |
37 | repeats:YES]; | |
38 | } else { | |
39 | [_timer invalidate]; | |
40 | _timer = nil; | |
41 | } | |
42 | [self setNeedsDisplay:YES]; | |
43 | } | |
44 | - (void)dealloc | |
45 | { | |
46 | [_cm unregisterClient:self]; | |
47 | [_attrs release]; | |
48 | [_timer invalidate]; | |
49 | [super dealloc]; | |
50 | } | |
51 | - (id)initWithFrame:(NSRect)frame | |
52 | { | |
53 | self = [super initWithFrame:frame]; | |
54 | if (self) { | |
55 | _attrs = [[NSDictionary alloc] initWithObjectsAndKeys:[NSFont systemFontOfSize:8],NSFontAttributeName,nil]; | |
56 | _bell = [NSImage imageNamed:@"bell"]; | |
57 | _cm = [ConfigManager globalConfig]; | |
58 | [_cm registerClient:self forKey:APPICON_DATE]; | |
59 | [_cm registerClient:self forKey:APPICON_TIME]; | |
60 | [self setup]; | |
61 | } | |
62 | return self; | |
63 | } | |
64 | - (void)config:(ConfigManager *)config dataDidChangedForKey:(NSString *)key | |
65 | { | |
66 | [self setup]; | |
67 | } | |
21 | 68 | - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent |
22 | 69 | { |
23 | 70 | return YES; |
28 | 75 | } |
29 | 76 | - (void)drawRect:(NSRect)rect |
30 | 77 | { |
31 | ConfigManager *config = [ConfigManager globalConfig]; | |
78 | NSUserDefaults *def = [NSUserDefaults standardUserDefaults]; | |
32 | 79 | NSCalendarDate *now = [[Date now] calendarDate]; |
33 | NSDictionary *attrs; | |
34 | 80 | NSString *aString; |
35 | 81 | |
36 | attrs = [NSMutableDictionary dictionaryWithObject:[NSFont systemFontOfSize: 8] forKey:NSFontAttributeName]; | |
37 | if ([[config objectForKey:APPICON_DATE] boolValue]) { | |
38 | aString = [now descriptionWithCalendarFormat:[[NSUserDefaults standardUserDefaults] objectForKey:NSShortDateFormatString]]; | |
39 | [aString drawAtPoint:NSMakePoint(8, 3) withAttributes:attrs]; | |
40 | } | |
41 | if ([[config objectForKey:APPICON_TIME] boolValue]) { | |
42 | aString = [now descriptionWithCalendarFormat:[[NSUserDefaults standardUserDefaults] objectForKey:NSTimeFormatString]]; | |
43 | [aString drawAtPoint:NSMakePoint(11, 48) withAttributes:attrs]; | |
44 | if (timer == nil) | |
45 | timer = [NSTimer scheduledTimerWithTimeInterval:1 | |
46 | target:self | |
47 | selector:@selector(secondChanged:) | |
48 | userInfo:nil | |
49 | repeats:YES]; | |
82 | if (_showDate) { | |
83 | aString = [now descriptionWithCalendarFormat:[def objectForKey:NSShortDateFormatString]]; | |
84 | [aString drawAtPoint:NSMakePoint(8, 3) withAttributes:_attrs]; | |
85 | } | |
86 | if (_showTime) { | |
87 | aString = [now descriptionWithCalendarFormat:[def objectForKey:NSTimeFormatString]]; | |
88 | [aString drawAtPoint:NSMakePoint(11, 49) withAttributes:_attrs]; | |
89 | } | |
90 | //[_bell dissolveToPoint:NSMakePoint(35, 35) fraction:1.0]; | |
91 | } | |
92 | - (void)mouseDown:(NSEvent *)theEvent | |
93 | { | |
94 | if ([theEvent clickCount] > 1) { | |
95 | [NSApp unhide:self]; | |
50 | 96 | } else { |
51 | if (timer) | |
52 | [timer invalidate]; | |
53 | timer = nil; | |
54 | } | |
55 | } | |
56 | - (void)mouseDown:(NSEvent *)theEvent | |
57 | { | |
58 | if ([theEvent clickCount] > 1) | |
59 | [NSApp unhide:self]; | |
97 | /* Code copied from Switcher in GAP */ | |
98 | NSPoint lastLocation; | |
99 | NSPoint location; | |
100 | unsigned eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask | NSPeriodicMask | NSOtherMouseUpMask | NSRightMouseUpMask; | |
101 | NSDate *theDistantFuture = [NSDate distantFuture]; | |
102 | BOOL done = NO; | |
103 | ||
104 | lastLocation = [theEvent locationInWindow]; | |
105 | [NSEvent startPeriodicEventsAfterDelay: 0.02 withPeriod: 0.02]; | |
106 | ||
107 | while (!done) { | |
108 | theEvent = [NSApp nextEventMatchingMask: eventMask | |
109 | untilDate: theDistantFuture | |
110 | inMode: NSEventTrackingRunLoopMode | |
111 | dequeue: YES]; | |
112 | switch ([theEvent type]) { | |
113 | case NSRightMouseUp: | |
114 | case NSOtherMouseUp: | |
115 | case NSLeftMouseUp: | |
116 | done = YES; | |
117 | break; | |
118 | case NSPeriodic: | |
119 | location = [_window mouseLocationOutsideOfEventStream]; | |
120 | if (NSEqualPoints(location, lastLocation) == NO) { | |
121 | NSPoint origin = [_window frame].origin; | |
122 | origin.x += (location.x - lastLocation.x); | |
123 | origin.y += (location.y - lastLocation.y); | |
124 | [_window setFrameOrigin: origin]; | |
125 | } | |
126 | break; | |
127 | default: | |
128 | break; | |
129 | } | |
130 | } | |
131 | [NSEvent stopPeriodicEvents]; | |
132 | } | |
60 | 133 | } |
61 | 134 | @end |
62 | 135 | |
132 | 205 | [soonStart changeDayBy:2]; |
133 | 206 | [soonEnd changeDayBy:5]; |
134 | 207 | while ((event = [enumerator nextObject])) { |
208 | if (![[event store] displayed]) | |
209 | continue; | |
135 | 210 | if ([event isScheduledForDay:today]) |
136 | 211 | [_today addChild:[DataTree dataTreeWithAttributes:[self attributesFrom:event and:today]]]; |
137 | 212 | if ([event isScheduledForDay:tomorrow]) |
146 | 221 | [_tomorrow sortChildrenUsingFunction:compareDataTreeElements context:nil]; |
147 | 222 | [_soon sortChildrenUsingFunction:compareDataTreeElements context:nil]; |
148 | 223 | [_tasks removeChildren]; |
149 | enumerator = [[_sm allTasks] objectEnumerator]; | |
224 | enumerator = [[_sm visibleTasks] objectEnumerator]; | |
150 | 225 | while ((task = [enumerator nextObject])) { |
151 | 226 | if ([task state] != TK_COMPLETED) |
152 | 227 | [_tasks addChild:[DataTree dataTreeWithAttributes:[self attributesFromTask:task]]]; |
178 | 253 | { |
179 | 254 | self = [super init]; |
180 | 255 | if (self) { |
181 | ConfigManager *config = [ConfigManager globalConfig]; | |
182 | [config registerDefaults:[self defaults]]; | |
183 | [config registerClient:self forKey:APPICON_DATE]; | |
184 | [config registerClient:self forKey:APPICON_TIME]; | |
185 | selectionManager = [SelectionManager globalManager]; | |
256 | [[ConfigManager globalConfig] registerDefaults:[self defaults]]; | |
257 | _selm = [SelectionManager globalManager]; | |
186 | 258 | _sm = [StoreManager globalManager]; |
187 | 259 | _pc = [PreferencesController new]; |
188 | 260 | [self initSummary]; |
197 | 269 | [[taskView tableColumnWithIdentifier:@"state"] setDataCell:cell]; |
198 | 270 | [[taskView tableColumnWithIdentifier:@"state"] setMaxWidth:128]; |
199 | 271 | [taskView setAutoresizesAllColumnsToFit:YES]; |
200 | /* | |
201 | * FIXME : this shouldn't be needed but I can't make it | |
202 | * work by editing the interface with Gorm... | |
203 | * [[taskView superview] superview] is the ScrollView | |
204 | * | |
205 | * Edit : I don't know if the bug comes from Gorm or | |
206 | * NSTabView but here's an explanation : there is a NSView | |
207 | * between NSTabView and each tab view (NSTabView -> NSView -> DayView, | |
208 | * NSTabView -> NSView -> WeekView etc) and, except for the first tab, | |
209 | * the intermediate view's autoresizingMask is 0 | |
210 | */ | |
211 | [[[[taskView superview] superview] superview] setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable]; | |
212 | [[weekView superview] setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable]; | |
213 | 272 | [taskView setUsesAlternatingRowBackgroundColors:YES]; |
214 | 273 | [taskView setTarget:self]; |
215 | 274 | [taskView setDoubleAction:@selector(editAppointment:)]; |
217 | 276 | [summary setTarget:self]; |
218 | 277 | [summary setDoubleAction:@selector(editAppointment:)]; |
219 | 278 | [window setFrameAutosaveName:@"mainWindow"]; |
279 | [window makeKeyAndOrderFront:self]; | |
220 | 280 | } |
221 | 281 | |
222 | 282 | - (void)applicationDidFinishLaunching:(NSNotification *)not |
241 | 301 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dataChanged:) name:SADataChangedInStoreManager object:nil]; |
242 | 302 | /* FIXME : this is overkill, we should only refresh the views for visual changes */ |
243 | 303 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dataChanged:) name:SAStatusChangedForStore object:nil]; |
244 | /* Set the selected day : this will update all views and titles (but not the summary */ | |
304 | /* Set the selected day : this will update all views and titles (but not the summary) */ | |
305 | [calendar setDateSource:self]; | |
245 | 306 | [calendar setDate:[Date today]]; |
246 | 307 | /* |
247 | 308 | * If stores are loaded before this is executed (it happens |
251 | 312 | * empty so this is needed here. |
252 | 313 | */ |
253 | 314 | [self updateSummaryData]; |
315 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reminderWillRun:) name:SAEventReminderWillRun object:nil]; | |
254 | 316 | /* This will init the alarms for all loaded elements needing one */ |
255 | 317 | [AlarmManager globalManager]; |
256 | 318 | } |
257 | 319 | |
258 | - (void)applicationWillTerminate:(NSNotification*)aNotification | |
259 | { | |
260 | [[ConfigManager globalConfig] unregisterClient:self]; | |
320 | - (void)applicationWillTerminate:(NSNotification *)aNotification | |
321 | { | |
261 | 322 | [[NSNotificationCenter defaultCenter] removeObserver:self]; |
262 | [_summaryRoot release]; | |
263 | [_pc release]; | |
264 | /* | |
265 | * FIXME : we shouldn't have to release the store | |
266 | * manager as we don't retain it. It's a global | |
267 | * instance that should synchronise itself when | |
268 | * it's freed | |
269 | */ | |
270 | [_sm release]; | |
323 | [_sm synchronise]; | |
324 | RELEASE(_summaryRoot); | |
325 | RELEASE(_pc); | |
326 | RELEASE(_appicon); | |
271 | 327 | RELEASE(_selectedDay); |
272 | 328 | } |
273 | 329 | |
303 | 359 | [_pc showPreferences]; |
304 | 360 | } |
305 | 361 | |
362 | NSComparisonResult compareEventTime(id a, id b, void *context) | |
363 | { | |
364 | return [[a startDate] compareTime:[b startDate]]; | |
365 | } | |
366 | ||
306 | 367 | - (int)_sensibleStartForDuration:(int)duration |
307 | 368 | { |
308 | 369 | int minute = [dayView firstHour] * 60; |
309 | NSEnumerator *enumerator = [[_sm scheduledAppointmentsForDay:_selectedDay] objectEnumerator]; | |
370 | NSEnumerator *enumerator = [[[[_sm visibleAppointmentsForDay:_selectedDay] allObjects] | |
371 | sortedArrayUsingFunction:compareEventTime context:nil] objectEnumerator]; | |
310 | 372 | Event *apt; |
311 | 373 | |
312 | 374 | while ((apt = [enumerator nextObject])) { |
370 | 432 | |
371 | 433 | - (void)editAppointment:(id)sender |
372 | 434 | { |
373 | id lastSelection = [selectionManager lastObject]; | |
435 | id lastSelection = [_selm lastObject]; | |
374 | 436 | |
375 | 437 | if (lastSelection) { |
376 | 438 | if ([lastSelection isKindOfClass:[Event class]]) |
384 | 446 | |
385 | 447 | - (void)delAppointment:(id)sender |
386 | 448 | { |
387 | NSEnumerator *enumerator = [selectionManager enumerator]; | |
449 | NSEnumerator *enumerator = [_selm enumerator]; | |
388 | 450 | Element *el; |
389 | 451 | |
390 | 452 | while ((el = [enumerator nextObject])) |
391 | 453 | [[el store] remove:el]; |
392 | [selectionManager clear]; | |
454 | [_selm clear]; | |
393 | 455 | } |
394 | 456 | |
395 | 457 | - (void)exportAppointment:(id)sender; |
396 | 458 | { |
397 | NSEnumerator *enumerator = [selectionManager enumerator]; | |
459 | NSEnumerator *enumerator = [_selm enumerator]; | |
398 | 460 | NSSavePanel *panel = [NSSavePanel savePanel]; |
399 | 461 | NSString *str; |
400 | 462 | iCalTree *tree; |
401 | 463 | Element *el; |
402 | 464 | |
403 | if ([selectionManager count] > 0) { | |
465 | if ([_selm count] > 0) { | |
404 | 466 | [panel setRequiredFileType:@"ics"]; |
405 | 467 | [panel setTitle:_(@"Export as")]; |
406 | if ([panel runModalForDirectory:nil file:[[selectionManager lastObject] summary]] == NSOKButton) { | |
468 | if ([panel runModalForDirectory:nil file:[[_selm lastObject] summary]] == NSOKButton) { | |
407 | 469 | tree = [iCalTree new]; |
408 | 470 | while ((el = [enumerator nextObject])) |
409 | 471 | [tree add:el]; |
427 | 489 | |
428 | 490 | - (void)copy:(id)sender |
429 | 491 | { |
430 | [selectionManager copySelection]; | |
492 | [_selm copySelection]; | |
431 | 493 | } |
432 | 494 | |
433 | 495 | - (void)cut:(id)sender |
434 | 496 | { |
435 | [selectionManager cutSelection]; | |
497 | [_selm cutSelection]; | |
436 | 498 | } |
437 | 499 | |
438 | 500 | - (void)paste:(id)sender |
439 | 501 | { |
440 | if ([selectionManager copiedCount] > 0) { | |
441 | NSEnumerator *enumerator = [[selectionManager paste] objectEnumerator]; | |
502 | if ([_selm copiedCount] > 0) { | |
503 | NSEnumerator *enumerator = [[_selm paste] objectEnumerator]; | |
442 | 504 | Date *date = [[calendar date] copy]; |
443 | 505 | Event *el; |
444 | 506 | id <MemoryStore> store; |
448 | 510 | while ((el = [enumerator nextObject])) { |
449 | 511 | /* FIXME : store property could be handled by Event:copy ? */ |
450 | 512 | store = [el store]; |
513 | ||
514 | /* FIXME : this isn't enough : we have to find a writable store or error out */ | |
515 | if (![store writable]) | |
516 | store = [_sm defaultStore]; | |
517 | ||
451 | 518 | start = [[el startDate] minuteOfDay]; |
452 | if ([selectionManager lastOperation] == SMCopy) | |
519 | if ([_selm lastOperation] == SMCopy) | |
453 | 520 | el = [el copy]; |
454 | 521 | [date setMinute:start]; |
455 | 522 | [el setStartDate:date]; |
456 | if ([selectionManager lastOperation] == SMCopy) { | |
523 | if ([_selm lastOperation] == SMCopy) { | |
457 | 524 | [store add:el]; |
458 | 525 | /* |
459 | 526 | * FIXME : the new event is now in store's dictionary, we |
531 | 598 | - (BOOL)validateMenuItem:(id <NSMenuItem>)menuItem |
532 | 599 | { |
533 | 600 | SEL action = [menuItem action]; |
534 | ||
535 | if (sel_eq(action, @selector(copy:))) | |
536 | return [selectionManager count] > 0; | |
537 | if (sel_eq(action, @selector(cut:))) | |
538 | return [selectionManager count] > 0; | |
539 | if (sel_eq(action, @selector(editAppointment:))) | |
540 | return [selectionManager count] == 1; | |
541 | if (sel_eq(action, @selector(delAppointment:))) | |
542 | return [selectionManager count] > 0; | |
543 | if (sel_eq(action, @selector(exportAppointment:))) | |
544 | return [selectionManager count] > 0; | |
545 | if (sel_eq(action, @selector(paste:))) | |
546 | return [selectionManager copiedCount] > 0; | |
601 | NSEnumerator *enumerator; | |
602 | Element *el; | |
603 | ||
604 | if (sel_isEqual(action, @selector(copy:))) | |
605 | return [_selm count] > 0; | |
606 | if (sel_isEqual(action, @selector(cut:))) { | |
607 | if ([_selm count] == 0) | |
608 | return NO; | |
609 | enumerator = [[_selm selection] objectEnumerator]; | |
610 | while ((el = [enumerator nextObject])) { | |
611 | if (![[el store] writable]) | |
612 | return NO; | |
613 | } | |
614 | return YES; | |
615 | } | |
616 | if (sel_isEqual(action, @selector(editAppointment:))) | |
617 | return [_selm count] == 1; | |
618 | if (sel_isEqual(action, @selector(delAppointment:))) | |
619 | return [_selm count] > 0; | |
620 | if (sel_isEqual(action, @selector(exportAppointment:))) | |
621 | return [_selm count] > 0; | |
622 | if (sel_isEqual(action, @selector(paste:))) | |
623 | return [_selm copiedCount] > 0; | |
547 | 624 | return YES; |
548 | 625 | } |
549 | 626 | |
553 | 630 | * FIXME : if a selected event was deleted by another application, |
554 | 631 | * the selection will reference a non existing object |
555 | 632 | */ |
633 | [calendar reloadData]; | |
556 | 634 | [dayView reloadData]; |
557 | 635 | [weekView reloadData]; |
558 | 636 | [taskView reloadData]; |
560 | 638 | [self updateSummaryData]; |
561 | 639 | } |
562 | 640 | |
641 | - (BOOL)showElement:(Element *)element onDay:(Date *)day | |
642 | { | |
643 | NSString *tabIdentifier = [[tabs selectedTabViewItem] identifier]; | |
644 | ||
645 | NSAssert(element != nil, @"An object must be passed"); | |
646 | NSAssert([day isDate], @"This method uses a day, not a date"); | |
647 | if ([element isKindOfClass:[Event class]]) { | |
648 | [calendar setDate:day]; | |
649 | if (![tabIdentifier isEqualToString:@"Day"] && ![tabIdentifier isEqualToString:@"Week"]) | |
650 | [tabs selectTabViewItemWithIdentifier:@"Day"]; | |
651 | [_selm select:element]; | |
652 | return YES; | |
653 | } | |
654 | if ([element isKindOfClass:[Task class]]) { | |
655 | if (![tabIdentifier isEqualToString:@"Tasks"]) | |
656 | [tabs selectTabViewItemWithIdentifier:@"Tasks"]; | |
657 | [_selm select:element]; | |
658 | return YES; | |
659 | } | |
660 | return NO; | |
661 | } | |
662 | ||
663 | - (void)reminderWillRun:(NSNotification *)not | |
664 | { | |
665 | Alarm *alarm = [not object]; | |
666 | ||
667 | [self showElement:[alarm element] onDay:[Date today]]; | |
668 | } | |
669 | ||
563 | 670 | - (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType |
564 | 671 | { |
565 | if ([selectionManager count] && (!sendType || [sendType isEqual:NSFilenamesPboardType] || [sendType isEqual:NSStringPboardType])) | |
672 | if ([_selm count] && (!sendType || [sendType isEqual:NSFilenamesPboardType] || [sendType isEqual:NSStringPboardType])) | |
566 | 673 | return self; |
567 | 674 | return nil; |
568 | 675 | } |
569 | 676 | - (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard types:(NSArray *)types |
570 | 677 | { |
571 | NSEnumerator *enumerator = [selectionManager enumerator]; | |
678 | NSEnumerator *enumerator = [_selm enumerator]; | |
572 | 679 | Element *el; |
573 | 680 | NSString *ical; |
574 | 681 | NSString *filename; |
576 | 683 | NSFileWrapper *fw; |
577 | 684 | BOOL written; |
578 | 685 | |
579 | if ([selectionManager count] == 0) | |
686 | if ([_selm count] == 0) | |
580 | 687 | return NO; |
581 | 688 | NSAssert([types count] == 1, @"It seems our assumption was wrong"); |
582 | 689 | tree = AUTORELEASE([iCalTree new]); |
590 | 697 | NSLog(@"Unable to encode into NSFileWrapper"); |
591 | 698 | return NO; |
592 | 699 | } |
593 | filename = [NSString stringWithFormat:@"%@/%@.ics", NSTemporaryDirectory(), [[selectionManager lastObject] summary]]; | |
700 | filename = [NSString stringWithFormat:@"%@/%@.ics", NSTemporaryDirectory(), [[_selm lastObject] summary]]; | |
594 | 701 | written = [fw writeToFile:filename atomically:YES updateFilenames:YES]; |
595 | 702 | [fw release]; |
596 | 703 | if (!written) { |
606 | 713 | } |
607 | 714 | return NO; |
608 | 715 | } |
609 | ||
610 | - (void)config:(ConfigManager *)config dataDidChangedForKey:(NSString *)key | |
611 | { | |
612 | [_appicon setNeedsDisplay:YES]; | |
613 | } | |
614 | 716 | @end |
615 | 717 | |
616 | 718 | @implementation AppController(NSOutlineViewDataSource) |
642 | 744 | - (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item |
643 | 745 | { |
644 | 746 | id object = [item valueForKey:@"object"]; |
645 | NSString *tabIdentifier = [[tabs selectedTabViewItem] identifier]; | |
646 | Date *date; | |
647 | ||
648 | if (object && [object isKindOfClass:[Event class]]) { | |
649 | date = [[item valueForKey:@"date"] copy]; | |
650 | [date setIsDate:YES]; | |
651 | [calendar setDate:date]; | |
652 | [date release]; | |
653 | if (![tabIdentifier isEqualToString:@"Day"] && ![tabIdentifier isEqualToString:@"Week"]) | |
654 | [tabs selectTabViewItemWithIdentifier:@"Day"]; | |
655 | [selectionManager set:object]; | |
656 | return YES; | |
657 | } | |
658 | if (object && [object isKindOfClass:[Task class]]) { | |
659 | if (![tabIdentifier isEqualToString:@"Tasks"]) | |
660 | [tabs selectTabViewItemWithIdentifier:@"Tasks"]; | |
661 | [selectionManager set:object]; | |
662 | return YES; | |
663 | } | |
747 | ||
748 | if (object && [object isKindOfClass:[Event class]]) | |
749 | return [self showElement:object onDay:[Date dayWithDate:[item valueForKey:@"date"]]]; | |
750 | if (object && [object isKindOfClass:[Task class]]) | |
751 | return [self showElement:object onDay:[calendar date]]; | |
664 | 752 | return NO; |
753 | } | |
754 | @end | |
755 | ||
756 | @implementation AppController(CalendarViewDataSource) | |
757 | - (CVCellStatus)calendarView:(CalendarView *)view cellStatusForDate:(Date *)date | |
758 | { | |
759 | if ([[_sm visibleAppointmentsForDay:date] count] > 0) | |
760 | return CVHasDataCell; | |
761 | return CVEmptyCell; | |
665 | 762 | } |
666 | 763 | @end |
667 | 764 | |
729 | 826 | @implementation AppController(NSTableDataSource) |
730 | 827 | - (int)numberOfRowsInTableView:(NSTableView *)aTableView |
731 | 828 | { |
732 | return [[_sm allTasks] count]; | |
829 | return [[_sm visibleTasks] count]; | |
733 | 830 | } |
734 | 831 | - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex |
735 | 832 | { |
736 | Task *task = [[_sm allTasks] objectAtIndex:rowIndex]; | |
833 | Task *task = [[_sm visibleTasks] objectAtIndex:rowIndex]; | |
737 | 834 | |
738 | 835 | if ([[aTableColumn identifier] isEqualToString:@"summary"]) |
739 | 836 | return [task summary]; |
741 | 838 | } |
742 | 839 | - (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex |
743 | 840 | { |
744 | Task *task = [[_sm allTasks] objectAtIndex:rowIndex]; | |
841 | Task *task = [[_sm visibleTasks] objectAtIndex:rowIndex]; | |
745 | 842 | |
746 | 843 | if ([[task store] writable]) { |
747 | 844 | [task setState:[anObject intValue]]; |
753 | 850 | Task *task; |
754 | 851 | |
755 | 852 | if ([[aTableColumn identifier] isEqualToString:@"state"]) { |
756 | task = [[_sm allTasks] objectAtIndex:rowIndex]; | |
853 | task = [[_sm visibleTasks] objectAtIndex:rowIndex]; | |
757 | 854 | [aCell setEnabled:[[task store] writable]]; |
758 | 855 | } |
759 | 856 | } |
761 | 858 | { |
762 | 859 | int index = [taskView selectedRow]; |
763 | 860 | if (index > -1) |
764 | [selectionManager set:[[_sm allTasks] objectAtIndex:index]]; | |
861 | [_selm select:[[_sm visibleTasks] objectAtIndex:index]]; | |
765 | 862 | } |
766 | 863 | @end |
767 | 864 |
20 | 20 | id timeText; |
21 | 21 | Date *startDate; |
22 | 22 | Event *_event; |
23 | NSArray *_modifiedAlarms; | |
23 | 24 | } |
24 | 25 | |
25 | 26 | + (AppointmentEditor *)editorForEvent:(Event *)event; |
28 | 29 | - (void)selectFrequency:(id)sender; |
29 | 30 | - (void)toggleUntil:(id)sender; |
30 | 31 | - (void)toggleAllDay:(id)sender; |
32 | - (void)editAlarms:(id)sender; | |
31 | 33 | @end |
4 | 4 | #import "HourFormatter.h" |
5 | 5 | #import "AgendaStore.h" |
6 | 6 | #import "ConfigManager.h" |
7 | #import "AlarmEditor.h" | |
7 | 8 | #import "defines.h" |
8 | 9 | |
9 | 10 | static NSMutableDictionary *editors; |
46 | 47 | self = [self init]; |
47 | 48 | if (self) { |
48 | 49 | ASSIGN(_event , event); |
50 | ASSIGNCOPY(_modifiedAlarms, [event alarms]); | |
49 | 51 | [title setStringValue:[event summary]]; |
50 | [duration setFloatValue:[event duration] / 60.0]; | |
51 | [durationText setFloatValue:[event duration] / 60.0]; | |
52 | [duration setIntValue:[event duration] * 60]; | |
53 | [durationText setIntValue:[event duration] * 60]; | |
52 | 54 | [location setStringValue:[event location]]; |
53 | 55 | [allDay setState:[event allDay]]; |
54 | [time setFloatValue:([[event startDate] hourOfDay]*60 + [[event startDate] minuteOfHour]) / 60.0]; | |
55 | [timeText setFloatValue:([[event startDate] hourOfDay]*60 + [[event startDate] minuteOfHour]) / 60.0]; | |
56 | [time setIntValue:[[event startDate] minuteOfDay] * 60]; | |
57 | [timeText setIntValue:[[event startDate] minuteOfDay] * 60]; | |
56 | 58 | if (![event rrule]) |
57 | 59 | [repeat selectItemAtIndex:0]; |
58 | 60 | else |
93 | 95 | - (void)dealloc |
94 | 96 | { |
95 | 97 | RELEASE(_event); |
98 | RELEASE(_modifiedAlarms); | |
96 | 99 | [super dealloc]; |
97 | 100 | } |
98 | 101 | |
122 | 125 | Date *date; |
123 | 126 | |
124 | 127 | [_event setSummary:[title stringValue]]; |
125 | [_event setDuration:[duration floatValue] * 60.0]; | |
128 | [_event setDuration:[duration intValue] / 60]; | |
126 | 129 | |
127 | 130 | if (![repeat indexOfSelectedItem]) { |
128 | 131 | [_event setRRule:nil]; |
140 | 143 | if (![_event allDay]) { |
141 | 144 | date = [[_event startDate] copy]; |
142 | 145 | [date setIsDate:NO]; |
143 | [date setMinute:[time floatValue] * 60.0]; | |
146 | [date setMinute:[time intValue] / 60]; | |
144 | 147 | [_event setStartDate:date]; |
145 | 148 | [date release]; |
146 | 149 | } |
150 | [_event setAlarms:_modifiedAlarms]; | |
147 | 151 | aStore = [sm storeForName:[store titleOfSelectedItem]]; |
148 | 152 | if (!originalStore) |
149 | 153 | [aStore add:_event]; |
153 | 157 | [originalStore remove:_event]; |
154 | 158 | [aStore add:_event]; |
155 | 159 | } |
160 | [window close]; | |
156 | 161 | [editors removeObjectForKey:[_event UID]]; |
162 | /* After this point the panel instance is released */ | |
163 | } | |
164 | ||
165 | - (void)cancel:(id)sender | |
166 | { | |
157 | 167 | [window close]; |
158 | } | |
159 | ||
160 | - (void)cancel:(id)sender | |
161 | { | |
162 | 168 | [editors removeObjectForKey:[_event UID]]; |
163 | [window close]; | |
164 | } | |
165 | ||
166 | - (void)controlTextDidChange:(NSNotification *)aNotification | |
169 | } | |
170 | ||
171 | - (void)controlTextDidEndEditing:(NSNotification *)aNotification | |
167 | 172 | { |
168 | 173 | id end = [endDate objectValue]; |
169 | ||
170 | if (end == nil || ![end isKindOfClass:[NSDate class]]) | |
171 | [ok setEnabled:NO]; | |
172 | else | |
173 | [ok setEnabled:[self canBeModified]]; | |
174 | [ok setEnabled: ([self canBeModified] && (end != nil))]; | |
174 | 175 | } |
175 | 176 | |
176 | 177 | - (void)selectFrequency:(id)sender |
228 | 229 | } |
229 | 230 | } |
230 | 231 | |
232 | - (void)editAlarms:(id)sender | |
233 | { | |
234 | NSArray *alarms; | |
235 | ||
236 | alarms = [AlarmEditor editAlarms:_modifiedAlarms]; | |
237 | if (alarms) | |
238 | ASSIGN(_modifiedAlarms, alarms); | |
239 | [window makeKeyAndOrderFront:self]; | |
240 | } | |
241 | ||
231 | 242 | - (BOOL)textView:(NSTextView *)aTextView doCommandBySelector:(SEL)aSelector |
232 | 243 | { |
233 | 244 | if ([NSStringFromSelector(aSelector) isEqualToString:@"insertTab:"]) { |
16 | 16 | Event *_apt; |
17 | 17 | } |
18 | 18 | - (NSImage *)repeatImage; |
19 | - (NSImage *)alarmImage; | |
19 | 20 | - (id)initWithFrame:(NSRect)frameRect appointment:(Event *)apt; |
20 | 21 | - (Event *)appointment; |
21 | 22 | - (void)tooltipSetup; |
3 | 3 | #import "defines.h" |
4 | 4 | |
5 | 5 | static NSImage *_repeatImage; |
6 | static NSImage *_alarmImage; | |
6 | 7 | |
7 | 8 | @implementation AppointmentView |
8 | 9 | + (void)initialize |
9 | 10 | { |
10 | if (!_repeatImage) { | |
11 | _repeatImage = [[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForImageResource:@"repeat"]]; | |
12 | [_repeatImage setFlipped:YES]; | |
13 | } | |
11 | _repeatImage = [NSImage imageNamed:@"repeat"]; | |
12 | _alarmImage = [NSImage imageNamed:@"small-bell"]; | |
14 | 13 | } |
15 | 14 | |
16 | 15 | - (NSImage *)repeatImage |
17 | 16 | { |
18 | 17 | return _repeatImage; |
18 | } | |
19 | ||
20 | - (NSImage *)alarmImage | |
21 | { | |
22 | return _alarmImage; | |
19 | 23 | } |
20 | 24 | |
21 | 25 | - (id)initWithFrame:(NSRect)frameRect appointment:(Event *)apt |
0 | 0 | /* emacs objective-c mode -*- objc -*- */ |
1 | 1 | |
2 | 2 | #import <AppKit/AppKit.h> |
3 | ||
4 | typedef enum { | |
5 | CVEmptyCell = 0, | |
6 | CVHasDataCell | |
7 | } CVCellStatus; | |
3 | 8 | |
4 | 9 | @interface CalendarView : NSView |
5 | 10 | { |
16 | 21 | IBOutlet id delegate; |
17 | 22 | NSTimer *_dayTimer; |
18 | 23 | int bezeledCell; |
24 | id _dataSource; | |
19 | 25 | } |
20 | 26 | |
21 | 27 | - (id)initWithFrame:(NSRect)frame; |
22 | 28 | - (Date *)date; |
29 | - (void)setDate:(Date *)date; | |
23 | 30 | - (NSString *)dateAsString; |
24 | 31 | - (id)delegate; |
25 | - (void)setDate:(Date *)date; | |
26 | 32 | - (void)setDelegate:(id)delegate; |
33 | - (id)dataSource; | |
34 | - (void)setDateSource:(id)dataSource; | |
35 | - (void)reloadData; | |
27 | 36 | @end |
28 | 37 | |
29 | 38 | @interface NSObject(CalendarViewDelegate) |
31 | 40 | - (void)calendarView:(CalendarView *)cs currentDateChanged:(Date *)date; |
32 | 41 | - (void)calendarView:(CalendarView *)cs userActionForDate:(Date *)date; |
33 | 42 | @end |
43 | ||
44 | @interface NSObject(CalendarViewDataSource) | |
45 | - (CVCellStatus)calendarView:(CalendarView *)view cellStatusForDate:(Date *)date; | |
46 | @end |
0 | 0 | #import <AppKit/AppKit.h> |
1 | 1 | #import "Date.h" |
2 | 2 | #import "CalendarView.h" |
3 | #import "StoreManager.h" | |
4 | 3 | |
5 | 4 | @interface DayFormatter : NSFormatter |
6 | 5 | @end |
8 | 7 | - (NSString *)stringForObjectValue:(id)anObject |
9 | 8 | { |
10 | 9 | NSAssert([anObject isKindOfClass:[Date class]], @"Needs a Date as input"); |
11 | return [NSString stringWithFormat:@"%2d", [anObject dayOfMonth]]; | |
10 | return [NSString stringWithFormat:@"%2d", [(Date *)anObject dayOfMonth]]; | |
12 | 11 | } |
13 | 12 | - (BOOL)getObjectValue:(id *)anObject forString:(NSString *)string errorDescription:(NSString **)error |
14 | 13 | { |
28 | 27 | static NSImage *_2right; |
29 | 28 | + (void)initialize |
30 | 29 | { |
31 | NSString *path; | |
32 | ||
33 | path = [[NSBundle mainBundle] pathForImageResource:@"1left"]; | |
34 | _1left = [[NSImage alloc] initWithContentsOfFile:path]; | |
35 | path = [[NSBundle mainBundle] pathForImageResource:@"2left"]; | |
36 | _2left = [[NSImage alloc] initWithContentsOfFile:path]; | |
37 | path = [[NSBundle mainBundle] pathForImageResource:@"1right"]; | |
38 | _1right = [[NSImage alloc] initWithContentsOfFile:path]; | |
39 | path = [[NSBundle mainBundle] pathForImageResource:@"2right"]; | |
40 | _2right = [[NSImage alloc] initWithContentsOfFile:path]; | |
30 | _1left = [NSImage imageNamed:@"1left"]; | |
31 | _2left = [NSImage imageNamed:@"2left"]; | |
32 | _1right = [NSImage imageNamed:@"1right"]; | |
33 | _2right = [NSImage imageNamed:@"2right"]; | |
41 | 34 | } |
42 | 35 | |
43 | 36 | - (void)dealloc |
44 | 37 | { |
45 | [[NSNotificationCenter defaultCenter] removeObserver:self]; | |
38 | [_dayTimer invalidate]; | |
46 | 39 | RELEASE(date); |
47 | 40 | RELEASE(monthDisplayed); |
48 | [_dayTimer invalidate]; | |
49 | 41 | RELEASE(_dayTimer); |
50 | 42 | RELEASE(delegate); |
51 | [boldFont release]; | |
52 | [normalFont release]; | |
53 | [title release]; | |
54 | [matrix release]; | |
55 | [obl release]; | |
56 | [tbl release]; | |
57 | [obr release]; | |
58 | [tbr release]; | |
43 | RELEASE(_dataSource); | |
44 | RELEASE(boldFont); | |
45 | RELEASE(normalFont); | |
46 | RELEASE(title); | |
47 | RELEASE(matrix); | |
48 | RELEASE(obl); | |
49 | RELEASE(tbl); | |
50 | RELEASE(obr); | |
51 | RELEASE(tbr); | |
59 | 52 | [super dealloc]; |
60 | 53 | } |
61 | 54 | |
72 | 65 | NSArray *days = [[NSUserDefaults standardUserDefaults] objectForKey:NSShortWeekDayNameArray]; |
73 | 66 | boldFont = RETAIN([NSFont boldSystemFontOfSize:11]); |
74 | 67 | normalFont = RETAIN([NSFont systemFontOfSize:11]); |
75 | delegate = nil; | |
76 | 68 | |
77 | 69 | title = [[NSTextField alloc] initWithFrame: NSMakeRect(32, 128, 168, 20)]; |
78 | 70 | [title setEditable:NO]; |
164 | 156 | userInfo:nil |
165 | 157 | repeats:YES]; |
166 | 158 | [[NSRunLoop currentRunLoop] addTimer:_dayTimer forMode:NSDefaultRunLoopMode]; |
167 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dataChanged:) name:SADataChangedInStoreManager object:nil]; | |
168 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dataChanged:) name:SAStatusChangedForStore object:nil]; | |
169 | 159 | } |
170 | 160 | return self; |
171 | 161 | } |
208 | 198 | NSColor *clear = [NSColor clearColor]; |
209 | 199 | NSColor *white = [NSColor whiteColor]; |
210 | 200 | NSColor *black = [NSColor blackColor]; |
211 | StoreManager *sm = [StoreManager globalManager]; | |
212 | 201 | |
213 | 202 | [self clearSelectedDay]; |
214 | 203 | today = [Date today]; |
229 | 218 | [cell setDrawsBackground:NO]; |
230 | 219 | } |
231 | 220 | [cell setObjectValue:AUTORELEASE([day copy])]; |
232 | if ([[sm scheduledAppointmentsForDay:day] count]) | |
221 | if (_dataSource && | |
222 | [_dataSource respondsToSelector:@selector(calendarView:cellStatusForDate:)] && | |
223 | [_dataSource calendarView:self cellStatusForDate:day] & CVHasDataCell) | |
233 | 224 | [cell setFont:boldFont]; |
234 | 225 | else |
235 | 226 | [cell setFont: normalFont]; |
307 | 298 | return delegate; |
308 | 299 | } |
309 | 300 | |
301 | - (id)dataSource | |
302 | { | |
303 | return _dataSource; | |
304 | } | |
305 | - (void)setDateSource:(id)dataSource | |
306 | { | |
307 | ASSIGN(_dataSource, dataSource); | |
308 | [self updateView]; | |
309 | } | |
310 | ||
311 | - (void)reloadData | |
312 | { | |
313 | [self updateView]; | |
314 | } | |
315 | ||
310 | 316 | - (void)setDate:(Date *)nDate |
311 | 317 | { |
312 | 318 | NSAssert([nDate isDate], @"Calender expects a date"); |
325 | 331 | { |
326 | 332 | return [[date calendarDate] descriptionWithCalendarFormat:[[NSUserDefaults standardUserDefaults] objectForKey:NSDateFormatString]]; |
327 | 333 | } |
328 | ||
329 | - (void)dataChanged:(NSNotification *)not | |
330 | { | |
331 | [self updateView]; | |
332 | } | |
333 | 334 | @end |
14 | 14 | NSMutableDictionary *_dict; |
15 | 15 | } |
16 | 16 | |
17 | - (ConfigManager *)initForKey:(NSString *)key withParent:(ConfigManager *)parent; | |
18 | 17 | + (ConfigManager *)globalConfig; |
18 | - (id)initForKey:(NSString *)key; | |
19 | 19 | - (void)registerDefaults:(NSDictionary *)defaults; |
20 | 20 | - (void)registerClient:(id <ConfigListener>)client forKey:(NSString *)key; |
21 | 21 | - (void)unregisterClient:(id <ConfigListener>)client forKey:(NSString *)key; |
0 | 0 | #import <Foundation/Foundation.h> |
1 | #import "NSColor+SimpleAgenda.h" | |
1 | 2 | #import "ConfigManager.h" |
2 | 3 | |
3 | 4 | static ConfigManager *singleton; |
4 | static NSMutableDictionary *_cpkey; | |
5 | static NSMutableDictionary *cpkey; | |
5 | 6 | |
6 | 7 | @implementation ConfigManager(Private) |
7 | 8 | - (ConfigManager *)initRoot |
8 | 9 | { |
9 | self = [super init]; | |
10 | if (self) { | |
11 | _dict = [NSMutableDictionary new]; | |
12 | _defaults = [NSMutableDictionary new]; | |
13 | [_dict setDictionary:[[NSUserDefaults standardUserDefaults] | |
14 | persistentDomainForName:[[NSProcessInfo processInfo] processName]]]; | |
15 | } | |
10 | if ((self = [self init])) | |
11 | [_dict setDictionary:[[NSUserDefaults standardUserDefaults] | |
12 | persistentDomainForName:[[NSProcessInfo processInfo] processName]]]; | |
16 | 13 | return self; |
17 | 14 | } |
18 | 15 | @end |
21 | 18 | + (void)initialize |
22 | 19 | { |
23 | 20 | if ([ConfigManager class] == self) { |
24 | _cpkey = [NSMutableDictionary new]; | |
21 | cpkey = [NSMutableDictionary new]; | |
25 | 22 | singleton = [[ConfigManager alloc] initRoot]; |
26 | 23 | } |
27 | 24 | } |
28 | 25 | |
29 | - (ConfigManager *)initForKey:(NSString *)key withParent:(ConfigManager *)parent | |
26 | + (ConfigManager *)globalConfig | |
30 | 27 | { |
31 | NSAssert(key != nil, @"ConfigManager initForKey called with nil key"); | |
32 | self = [super init]; | |
33 | if (self) { | |
28 | return singleton; | |
29 | } | |
30 | ||
31 | - (id)init | |
32 | { | |
33 | if ((self = [super init])) { | |
34 | 34 | _dict = [NSMutableDictionary new]; |
35 | 35 | _defaults = [NSMutableDictionary new]; |
36 | if (parent == nil) | |
37 | parent = [ConfigManager globalConfig]; | |
36 | } | |
37 | return self; | |
38 | } | |
39 | ||
40 | - (id)initForKey:(NSString *)key | |
41 | { | |
42 | ConfigManager *parent = [ConfigManager globalConfig]; | |
43 | ||
44 | if ((self = [self init])) { | |
38 | 45 | [_dict setDictionary:[parent dictionaryForKey:key]]; |
39 | 46 | ASSIGN(_parent, parent); |
40 | 47 | ASSIGNCOPY(_key, key); |
42 | 49 | return self; |
43 | 50 | } |
44 | 51 | |
45 | + (ConfigManager *)globalConfig | |
46 | { | |
47 | return singleton; | |
48 | } | |
49 | ||
50 | 52 | - (void)dealloc |
51 | 53 | { |
52 | RELEASE(_key); | |
53 | RELEASE(_parent); | |
54 | [_defaults release]; | |
55 | [_dict release]; | |
54 | DESTROY(_key); | |
55 | DESTROY(_parent); | |
56 | DESTROY(_defaults); | |
57 | DESTROY(_dict); | |
56 | 58 | [super dealloc]; |
57 | 59 | } |
58 | 60 | |
59 | 61 | - (void)notifyListenerForKey:(NSString *)key |
60 | 62 | { |
61 | NSEnumerator *enumerator; | |
62 | 63 | id <ConfigListener> listener; |
63 | NSValue *value; | |
64 | NSPointerArray *array; | |
65 | NSUInteger index; | |
64 | 66 | |
65 | NSAssert(key != nil, @"Missing key"); | |
66 | enumerator = [[_cpkey objectForKey:key] objectEnumerator]; | |
67 | while ((value = [enumerator nextObject])) { | |
68 | listener = [value nonretainedObjectValue]; | |
69 | [listener config:self dataDidChangedForKey:key]; | |
67 | array = [cpkey objectForKey:key]; | |
68 | for (index = 0; index < [array count]; index++) { | |
69 | listener = [array pointerAtIndex:index]; | |
70 | if (listener) | |
71 | [listener config:self dataDidChangedForKey:key]; | |
70 | 72 | } |
71 | 73 | } |
72 | 74 | |
106 | 108 | |
107 | 109 | - (int)integerForKey:(NSString *)key |
108 | 110 | { |
109 | id object; | |
111 | id object = [self objectForKey:key]; | |
110 | 112 | |
111 | object = [self objectForKey:key]; | |
112 | 113 | if (object != nil) |
113 | 114 | return [object intValue]; |
114 | 115 | return 0; |
121 | 122 | |
122 | 123 | - (NSDictionary *)dictionaryForKey:(NSString *)key |
123 | 124 | { |
124 | id object; | |
125 | id object = [self objectForKey:key]; | |
125 | 126 | |
126 | object = [self objectForKey:key]; | |
127 | 127 | if (object != nil && [object isKindOfClass:[NSDictionary class]]) |
128 | 128 | return object; |
129 | 129 | return nil; |
148 | 148 | [self setObject:[value description] forKey:key]; |
149 | 149 | } |
150 | 150 | |
151 | - (void)registerClient:(id <ConfigListener>)client forKey:(NSString*)key | |
151 | - (void)registerClient:(id <ConfigListener>)client forKey:(NSString *)key | |
152 | 152 | { |
153 | NSAssert(key != nil, @"You have to register for a specific key"); | |
154 | NSMutableSet *listeners = [_cpkey objectForKey:key]; | |
153 | NSPointerArray *listeners = [cpkey objectForKey:key]; | |
155 | 154 | |
156 | if (listeners) | |
157 | [listeners addObject:[NSValue valueWithNonretainedObject:client]]; | |
158 | else | |
159 | listeners = [NSMutableSet setWithObject:[NSValue valueWithNonretainedObject:client]]; | |
160 | [_cpkey setObject:listeners forKey:key]; | |
161 | ||
155 | if (!listeners) { | |
156 | listeners = [NSPointerArray pointerArrayWithWeakObjects]; | |
157 | [cpkey setObject:listeners forKey:key]; | |
158 | } | |
159 | [listeners addPointer:client]; | |
162 | 160 | } |
163 | 161 | |
164 | - (void)unregisterClient:(id <ConfigListener>)client forKey:(NSString*)key | |
162 | - (void)unregisterClient:(id <ConfigListener>)client forKey:(NSString *)key | |
165 | 163 | { |
166 | NSMutableSet *set = [_cpkey objectForKey:key]; | |
167 | NSSet *copy; | |
168 | NSEnumerator *enumerator; | |
169 | NSValue *v; | |
164 | NSPointerArray *array = [cpkey objectForKey:key]; | |
165 | NSUInteger index; | |
170 | 166 | |
171 | if (set) { | |
172 | copy = [NSSet setWithSet:set]; | |
173 | enumerator = [copy objectEnumerator]; | |
174 | while ((v = [enumerator nextObject])) { | |
175 | if (client == [v nonretainedObjectValue]) | |
176 | [set removeObject:v]; | |
167 | if (array) { | |
168 | for (index = 0; index < [array count]; index++) { | |
169 | if ([array pointerAtIndex:index] == client) | |
170 | [array replacePointerAtIndex:index withPointer:NULL]; | |
177 | 171 | } |
172 | [array compact]; | |
178 | 173 | } |
179 | 174 | } |
180 | 175 | |
181 | 176 | - (void)unregisterClient:(id <ConfigListener>)client |
182 | 177 | { |
183 | NSMutableSet *set; | |
184 | NSSet *copy; | |
185 | NSValue *v; | |
186 | NSEnumerator *enumerator = [_cpkey objectEnumerator]; | |
187 | NSEnumerator *en; | |
178 | NSEnumerator *enumerator = [cpkey objectEnumerator]; | |
179 | NSPointerArray *array; | |
180 | NSUInteger index; | |
188 | 181 | |
189 | while ((set = [enumerator nextObject])) { | |
190 | copy = [NSSet setWithSet:set]; | |
191 | en = [copy objectEnumerator]; | |
192 | while ((v = [en nextObject])) { | |
193 | if (client == [v nonretainedObjectValue]) | |
194 | [set removeObject:v]; | |
182 | while ((array = [enumerator nextObject])) { | |
183 | for (index = 0; index < [array count]; index++) { | |
184 | if ([array pointerAtIndex:index] == client) | |
185 | [array replacePointerAtIndex:index withPointer:NULL]; | |
195 | 186 | } |
187 | [array compact]; | |
196 | 188 | } |
197 | 189 | } |
198 | 190 | @end |
0 | #import <Foundation/Foundation.h> | |
1 | #import <DBusKit/DBusKit.h> | |
2 | #import "AlarmBackend.h" | |
3 | #import "Alarm.h" | |
4 | #import "Element.h" | |
5 | ||
6 | @protocol Notifications | |
7 | - (NSArray *)GetCapabilities; | |
8 | - (NSNumber *)Notify:(NSString *)appname :(uint)replaceid :(NSString *)appicon :(NSString *)summary :(NSString *)body :(NSArray *)actions :(NSDictionary *)hints :(int)expires; | |
9 | @end | |
10 | ||
11 | @interface DBusBackend : AlarmBackend | |
12 | @end | |
13 | ||
14 | static NSString * const DBUS_BUS = @"org.freedesktop.Notifications"; | |
15 | static NSString * const DBUS_PATH = @"/org/freedesktop/Notifications"; | |
16 | ||
17 | @implementation DBusBackend | |
18 | + (NSString *)backendName | |
19 | { | |
20 | return @"DBus desktop notification"; | |
21 | } | |
22 | ||
23 | - (enum icalproperty_action)backendType | |
24 | { | |
25 | return ICAL_ACTION_DISPLAY; | |
26 | } | |
27 | ||
28 | - (id)init | |
29 | { | |
30 | NSConnection *c; | |
31 | id <NSObject,Notifications> remote; | |
32 | NSArray *caps; | |
33 | ||
34 | self = [super init]; | |
35 | if (self) { | |
36 | NS_DURING | |
37 | { | |
38 | c = [NSConnection connectionWithReceivePort:[DKPort port] sendPort:[[DKPort alloc] initWithRemote:DBUS_BUS]]; | |
39 | if (!c) { | |
40 | NSLog(@"Unable to create a connection to %@", DBUS_BUS); | |
41 | DESTROY(self); | |
42 | } | |
43 | remote = (id <NSObject,Notifications>)[c proxyAtPath:DBUS_PATH]; | |
44 | if (!remote) { | |
45 | NSLog(@"Unable to create a proxy for %@", DBUS_PATH); | |
46 | DESTROY(self); | |
47 | } | |
48 | caps = [remote GetCapabilities]; | |
49 | if (!caps) { | |
50 | NSLog(@"No response to GetCapabilities method"); | |
51 | DESTROY(self); | |
52 | } | |
53 | [c invalidate]; | |
54 | } | |
55 | NS_HANDLER | |
56 | { | |
57 | NSLog([localException description]); | |
58 | NSLog(@"Exception during DBus backend setup, backend disabled"); | |
59 | DESTROY(self); | |
60 | } | |
61 | NS_ENDHANDLER | |
62 | } | |
63 | return self; | |
64 | } | |
65 | ||
66 | - (void)display:(Alarm *)alarm | |
67 | { | |
68 | NSConnection *c; | |
69 | NSNumber *dnid; | |
70 | id <NSObject,Notifications> remote; | |
71 | Element *el = [alarm element]; | |
72 | NSString *desc; | |
73 | ||
74 | c = [NSConnection connectionWithReceivePort:[DKPort port] sendPort:[[DKPort alloc] initWithRemote:DBUS_BUS]]; | |
75 | remote = (id <NSObject,Notifications>)[c proxyAtPath:DBUS_PATH]; | |
76 | if ([el text]) | |
77 | desc = [NSString stringWithFormat:@"%@\n\n%@ : %@", [[[el nextActivationDate] calendarDate] descriptionWithCalendarFormat:[[NSUserDefaults standardUserDefaults] objectForKey:NSShortTimeDateFormatString]], [el summary], [[el text] string]]; | |
78 | else | |
79 | desc = [NSString stringWithFormat:@"%@\n\n%@", [[[el nextActivationDate] calendarDate] descriptionWithCalendarFormat:[[NSUserDefaults standardUserDefaults] objectForKey:NSShortTimeDateFormatString]], [el summary]]; | |
80 | dnid = [remote Notify:@"SimpleAgenda" | |
81 | :0 | |
82 | :@"" | |
83 | :_(@"SimpleAgenda Reminder !") | |
84 | :desc | |
85 | :[NSArray array] | |
86 | :[NSDictionary dictionary] | |
87 | :-1]; | |
88 | [c invalidate]; | |
89 | } | |
90 | @end |
11 | 11 | + (id)today; |
12 | 12 | + (id)dateWithTimeInterval:(NSTimeInterval)seconds sinceDate:(Date *)refDate; |
13 | 13 | + (id)dateWithCalendarDate:(NSCalendarDate *)cd withTime:(BOOL)time; |
14 | + (id)dayWithDate:(Date *)date; | |
14 | 15 | - (NSCalendarDate *)calendarDate; |
15 | 16 | - (NSComparisonResult)compare:(id)aDate; |
16 | 17 | - (NSComparisonResult)compareTime:(id)aTime; |
38 | 39 | - (void)setIsDate:(BOOL)date; |
39 | 40 | - (NSTimeInterval)timeIntervalSince1970; |
40 | 41 | - (NSTimeInterval)timeIntervalSinceDate:(Date *)anotherDate; |
42 | - (NSTimeInterval)timeIntervalSinceNow; | |
43 | - (BOOL)belongsToDay:(Date *)day; | |
41 | 44 | @end |
42 | 45 | |
43 | 46 | @interface Date(iCalendar) |
44 | 47 | - (id)initWithICalTime:(struct icaltimetype)time; |
45 | - (struct icaltimetype)iCalTime; | |
48 | - (struct icaltimetype)UTCICalTime; | |
49 | - (struct icaltimetype)localICalTime; | |
46 | 50 | @end |
144 | 144 | /* To be able to add hours and minutes, it has to be a datetime */ |
145 | 145 | d-> _time.is_date = 0; |
146 | 146 | d->_time = icaltime_add(d->_time, icaldurationtype_from_int(seconds)); |
147 | /* | |
148 | * FIXME : this is wrong is refDate is a date but seconds | |
149 | * not a multiple of 86400 | |
150 | */ | |
151 | d->_time.is_date = refDate->_time.is_date; | |
147 | if (!d->_time.hour && !d->_time.minute && !d->_time.second) | |
148 | d->_time.is_date = 1; | |
149 | else | |
150 | d->_time.is_date = 0; | |
152 | 151 | return AUTORELEASE(d); |
153 | 152 | } |
154 | 153 | |
172 | 171 | return AUTORELEASE(d); |
173 | 172 | } |
174 | 173 | |
174 | + (id)dayWithDate:(Date *)date | |
175 | { | |
176 | Date *d = [date copy]; | |
177 | [d setIsDate:YES]; | |
178 | return AUTORELEASE(d); | |
179 | } | |
180 | ||
175 | 181 | - (NSCalendarDate *)calendarDate |
176 | 182 | { |
177 | 183 | return [NSCalendarDate dateWithYear:_time.year |
319 | 325 | { |
320 | 326 | return icaldurationtype_as_int(icaltime_subtract(_time, anotherDate->_time)); |
321 | 327 | } |
328 | ||
329 | - (NSTimeInterval)timeIntervalSinceNow | |
330 | { | |
331 | return [self timeIntervalSinceDate:[Date now]]; | |
332 | } | |
333 | ||
334 | - (BOOL)belongsToDay:(Date *)day | |
335 | { | |
336 | NSAssert([day isDate], @"This method expects a date, not a datetime"); | |
337 | return _time.year == day->_time.year && _time.month == day->_time.month && _time.day == day->_time.day; | |
338 | } | |
322 | 339 | @end |
323 | 340 | |
324 | 341 | /* |
334 | 351 | _time = icaltime_convert_to_zone(time, gl_tz); |
335 | 352 | return self; |
336 | 353 | } |
337 | - (struct icaltimetype)iCalTime | |
354 | - (struct icaltimetype)UTCICalTime | |
338 | 355 | { |
339 | 356 | return icaltime_convert_to_zone(_time, gl_utc); |
340 | 357 | } |
341 | @end | |
358 | - (struct icaltimetype)localICalTime | |
359 | { | |
360 | return _time; | |
361 | } | |
362 | @end |
0 | 0 | /* emacs buffer mode hint -*- objc -*- */ |
1 | 1 | |
2 | #import <Foundation/Foundation.h> | |
2 | 3 | #import "AgendaStore.h" |
3 | 4 | #import "DayView.h" |
4 | 5 | #import "ConfigManager.h" |
29 | 30 | #define RADIUS 5 |
30 | 31 | - (void)drawRect:(NSRect)rect |
31 | 32 | { |
33 | NSPoint point; | |
32 | 34 | NSString *title; |
33 | 35 | NSString *label; |
34 | 36 | Date *start = [_apt startDate]; |
85 | 87 | PSfill(); |
86 | 88 | } |
87 | 89 | [label drawInRect:TextRect(rect) withAttributes:textAttributes]; |
88 | if ([_apt rrule]) | |
90 | point = NSMakePoint(rect.size.width - 18, rect.size.height - 16); | |
91 | if ([_apt rrule]) { | |
89 | 92 | [[self repeatImage] compositeToPoint:NSMakePoint(rect.size.width - 18, rect.size.height - 18) operation:NSCompositeSourceOver]; |
93 | point = NSMakePoint(rect.size.width - 30, rect.size.height - 16); | |
94 | } | |
95 | if ([_apt hasAlarms]) | |
96 | [[self alarmImage] compositeToPoint:point operation:NSCompositeSourceOver]; | |
90 | 97 | } |
91 | 98 | |
92 | 99 | - (void)mouseDown:(NSEvent *)theEvent |
345 | 352 | - (void)selectAppointmentView:(AppointmentView *)aptv |
346 | 353 | { |
347 | 354 | _selected = aptv; |
348 | [[SelectionManager globalManager] set:[aptv appointment]]; | |
355 | [[SelectionManager globalManager] select:[aptv appointment]]; | |
349 | 356 | if ([delegate respondsToSelector:@selector(viewSelectEvent:)]) |
350 | 357 | [delegate viewSelectEvent:[aptv appointment]]; |
351 | 358 | [self setNeedsDisplay:YES]; |
359 | 366 | NSSet *events; |
360 | 367 | BOOL found; |
361 | 368 | |
362 | events = [[StoreManager globalManager] scheduledAppointmentsForDay:_date]; | |
369 | events = [[StoreManager globalManager] visibleAppointmentsForDay:_date]; | |
363 | 370 | enumerator = [[self subviews] objectEnumerator]; |
364 | 371 | while ((aptv = [enumerator nextObject])) { |
365 | 372 | if (![events containsObject:[aptv appointment]] || ![[[aptv appointment] store] displayed]) { |
13 | 13 | ICAL_CLASS_NONE = 10010 |
14 | 14 | */ |
15 | 15 | |
16 | @class SAAlarm; | |
16 | @class Alarm; | |
17 | 17 | |
18 | 18 | @interface Element : NSObject <NSCoding> |
19 | 19 | { |
45 | 45 | |
46 | 46 | - (BOOL)hasAlarms; |
47 | 47 | - (NSArray *)alarms; |
48 | - (void)addAlarm:(SAAlarm *)alarm; | |
49 | - (void)removeAlarm:(SAAlarm *)alarm; | |
48 | - (void)setAlarms:(NSArray *)alarms; | |
49 | - (void)addAlarm:(Alarm *)alarm; | |
50 | - (void)removeAlarm:(Alarm *)alarm; | |
51 | - (Date *)nextActivationDate; | |
50 | 52 | |
51 | 53 | - (NSArray *)categories; |
52 | 54 | - (void)setCategories:(NSArray *)categories; |
0 | 0 | #import <Foundation/Foundation.h> |
1 | 1 | #import "Date.h" |
2 | 2 | #import "Element.h" |
3 | #import "SAAlarm.h" | |
3 | #import "Alarm.h" | |
4 | 4 | #import "NSString+SimpleAgenda.h" |
5 | 5 | |
6 | 6 | @implementation Element |
7 | 7 | - (void)encodeWithCoder:(NSCoder *)coder |
8 | 8 | { |
9 | 9 | [coder encodeObject:_summary forKey:@"title"]; |
10 | [coder encodeObject:[_text string] forKey:@"descriptionText"]; | |
10 | if (_text) | |
11 | [coder encodeObject:[_text string] forKey:@"descriptionText"]; | |
11 | 12 | [coder encodeObject:_uid forKey:@"uid"]; |
12 | 13 | [coder encodeInt:_classification forKey:@"classification"]; |
13 | 14 | if (_stamp) |
14 | 15 | [coder encodeObject:_stamp forKey:@"dtstamp"]; |
15 | 16 | [coder encodeObject:_categories forKey:@"categories"]; |
17 | [coder encodeObject:_alarms forKey:@"alarms"]; | |
16 | 18 | } |
17 | 19 | |
18 | 20 | - (id)initWithCoder:(NSCoder *)coder |
19 | 21 | { |
20 | 22 | _summary = [[coder decodeObjectForKey:@"title"] retain]; |
21 | _text = [[NSAttributedString alloc] initWithString:[coder decodeObjectForKey:@"descriptionText"]]; | |
23 | if ([coder containsValueForKey:@"descriptionText"]) | |
24 | _text = [[NSAttributedString alloc] initWithString:[coder decodeObjectForKey:@"descriptionText"]]; | |
25 | else | |
26 | _text = nil; | |
22 | 27 | if ([coder containsValueForKey:@"uid"]) |
23 | 28 | _uid = [[coder decodeObjectForKey:@"uid"] retain]; |
24 | 29 | else |
35 | 40 | _categories = [[coder decodeObjectForKey:@"categories"] retain]; |
36 | 41 | else |
37 | 42 | _categories = [NSMutableArray new]; |
43 | [self setAlarms:[coder decodeObjectForKey:@"alarms"]]; | |
38 | 44 | return self; |
39 | 45 | } |
40 | 46 | |
41 | 47 | - (id)init |
42 | 48 | { |
43 | self = [super init]; | |
44 | if (self) { | |
45 | _alarms = [NSMutableArray new]; | |
46 | _categories = [NSMutableArray new]; | |
47 | _classification = ICAL_CLASS_PUBLIC; | |
48 | ASSIGNCOPY(_stamp, [Date now]); | |
49 | } | |
49 | if (!(self = [super init])) | |
50 | return nil; | |
51 | _alarms = [NSMutableArray new]; | |
52 | _categories = [NSMutableArray new]; | |
53 | _classification = ICAL_CLASS_PUBLIC; | |
54 | _text = nil; | |
55 | ASSIGNCOPY(_stamp, [Date now]); | |
50 | 56 | return self; |
51 | 57 | } |
52 | 58 | |
150 | 156 | return [NSArray arrayWithArray:_alarms]; |
151 | 157 | } |
152 | 158 | |
153 | - (void)addAlarm:(SAAlarm *)alarm | |
159 | - (void)setAlarms:(NSArray *)alarms | |
160 | { | |
161 | NSEnumerator *enumerator; | |
162 | Alarm *alarm; | |
163 | ||
164 | DESTROY(_alarms); | |
165 | ASSIGNCOPY(_alarms, alarms); | |
166 | enumerator = [_alarms objectEnumerator]; | |
167 | while ((alarm = [enumerator nextObject])) | |
168 | [alarm setElement:self]; | |
169 | } | |
170 | ||
171 | - (void)addAlarm:(Alarm *)alarm | |
154 | 172 | { |
155 | 173 | [alarm setElement:self]; |
156 | 174 | [_alarms addObject:alarm]; |
157 | 175 | } |
158 | 176 | |
159 | - (void)removeAlarm:(SAAlarm *)alarm | |
177 | - (void)removeAlarm:(Alarm *)alarm | |
160 | 178 | { |
161 | 179 | /* FIXME : do something */ |
180 | } | |
181 | ||
182 | - (Date *)nextActivationDate | |
183 | { | |
184 | return nil; | |
162 | 185 | } |
163 | 186 | |
164 | 187 | - (NSArray *)categories |
187 | 210 | - (id)initWithICalComponent:(icalcomponent *)ic |
188 | 211 | { |
189 | 212 | icalproperty *prop; |
213 | icalcomponent *subc; | |
214 | Alarm *alarm; | |
190 | 215 | |
191 | 216 | self = [self init]; |
192 | 217 | if (self == nil) |
215 | 240 | prop = icalcomponent_get_first_property(ic, ICAL_CATEGORIES_PROPERTY); |
216 | 241 | if (prop) |
217 | 242 | [self setCategories:[[NSString stringWithUTF8String:icalproperty_get_categories(prop)] componentsSeparatedByString:@","]]; |
243 | ||
244 | subc = icalcomponent_get_first_component(ic, ICAL_VALARM_COMPONENT); | |
245 | for (; subc != NULL; subc = icalcomponent_get_next_component(ic, ICAL_VALARM_COMPONENT)) { | |
246 | alarm = [[Alarm alloc] initWithICalComponent:subc]; | |
247 | if (alarm) { | |
248 | [self addAlarm:alarm]; | |
249 | RELEASE(alarm); | |
250 | } | |
251 | } | |
218 | 252 | return self; |
253 | ||
219 | 254 | init_error: |
220 | 255 | NSLog(@"Error creating Element from iCal component"); |
221 | 256 | [self release]; |
238 | 273 | |
239 | 274 | - (void)deleteProperty:(icalproperty_kind)kind fromComponent:(icalcomponent *)ic |
240 | 275 | { |
241 | icalproperty *prop; | |
242 | prop = icalcomponent_get_first_property(ic, kind); | |
276 | icalproperty *prop = icalcomponent_get_first_property(ic, kind); | |
243 | 277 | if (prop) |
244 | 278 | icalcomponent_remove_property(ic, prop); |
245 | 279 | } |
246 | 280 | |
247 | 281 | - (BOOL)updateICalComponent:(icalcomponent *)ic |
248 | 282 | { |
283 | NSEnumerator *enumerator; | |
284 | Alarm *alarm; | |
285 | icalcomponent *subc; | |
286 | ||
249 | 287 | [self deleteProperty:ICAL_UID_PROPERTY fromComponent:ic]; |
250 | 288 | icalcomponent_add_property(ic, icalproperty_new_uid([[self UID] cString])); |
251 | 289 | [self deleteProperty:ICAL_SUMMARY_PROPERTY fromComponent:ic]; |
255 | 293 | if ([self text]) |
256 | 294 | icalcomponent_add_property(ic, icalproperty_new_description([[[self text] string] UTF8String])); |
257 | 295 | [self deleteProperty:ICAL_DTSTAMP_PROPERTY fromComponent:ic]; |
258 | icalcomponent_add_property(ic, icalproperty_new_dtstamp([_stamp iCalTime])); | |
296 | icalcomponent_add_property(ic, icalproperty_new_dtstamp([_stamp UTCICalTime])); | |
259 | 297 | [self deleteProperty:ICAL_CLASS_PROPERTY fromComponent:ic]; |
260 | 298 | icalcomponent_add_property(ic, icalproperty_new_class([self classification])); |
261 | 299 | [self deleteProperty:ICAL_CATEGORIES_PROPERTY fromComponent:ic]; |
262 | 300 | icalcomponent_add_property(ic, icalproperty_new_categories([[[self categories] componentsJoinedByString:@","] UTF8String])); |
301 | ||
302 | subc = icalcomponent_get_first_component(ic, ICAL_VALARM_COMPONENT); | |
303 | for (; subc != NULL; subc = icalcomponent_get_next_component(ic, ICAL_VALARM_COMPONENT)) | |
304 | icalcomponent_remove_component(ic, subc); | |
305 | enumerator = [[self alarms] objectEnumerator]; | |
306 | while ((alarm = [enumerator nextObject])) { | |
307 | subc = [alarm asICalComponent]; | |
308 | icalcomponent_add_component(ic, subc); | |
309 | icalcomponent_free(subc); | |
310 | } | |
263 | 311 | return YES; |
264 | 312 | } |
265 | 313 |
0 | 0 | #import <Foundation/Foundation.h> |
1 | #import <string.h> | |
1 | 2 | #import "Event.h" |
2 | 3 | #import "DateRange.h" |
3 | 4 | |
78 | 79 | break; |
79 | 80 | } |
80 | 81 | return NSMakeRange(0, 0); |
82 | } | |
83 | ||
84 | - (Date *)nextActivationDate | |
85 | { | |
86 | if (!_rrule) | |
87 | return _startDate; | |
88 | return nil; | |
81 | 89 | } |
82 | 90 | |
83 | 91 | - (NSString *)location |
226 | 234 | return nil; |
227 | 235 | } |
228 | 236 | |
229 | - (icalcomponent *)asICalComponent | |
230 | { | |
231 | icalcomponent *ic = icalcomponent_new(ICAL_VEVENT_COMPONENT); | |
232 | if (!ic) { | |
233 | NSLog(@"Couldn't create iCalendar component"); | |
234 | return NULL; | |
235 | } | |
236 | if (![self updateICalComponent:ic]) { | |
237 | icalcomponent_free(ic); | |
238 | return NULL; | |
239 | } | |
240 | return ic; | |
241 | } | |
242 | ||
243 | 237 | - (BOOL)updateICalComponent:(icalcomponent *)ic |
244 | 238 | { |
245 | 239 | Date *end; |
253 | 247 | icalcomponent_add_property(ic, icalproperty_new_location([[self location] UTF8String])); |
254 | 248 | |
255 | 249 | [self deleteProperty:ICAL_DTSTART_PROPERTY fromComponent:ic]; |
256 | icalcomponent_add_property(ic, icalproperty_new_dtstart([_startDate iCalTime])); | |
250 | icalcomponent_add_property(ic, icalproperty_new_dtstart([_startDate UTCICalTime])); | |
257 | 251 | |
258 | 252 | [self deleteProperty:ICAL_DTEND_PROPERTY fromComponent:ic]; |
259 | 253 | [self deleteProperty:ICAL_DURATION_PROPERTY fromComponent:ic]; |
260 | 254 | if (![self allDay]) |
261 | icalcomponent_add_property(ic, icalproperty_new_dtend(icaltime_add([_startDate iCalTime], icaldurationtype_from_int(_duration * 60)))); | |
255 | icalcomponent_add_property(ic, icalproperty_new_dtend(icaltime_add([_startDate UTCICalTime], icaldurationtype_from_int(_duration * 60)))); | |
262 | 256 | else { |
263 | 257 | end = [_startDate copy]; |
264 | 258 | [end incrementDay]; |
265 | icalcomponent_add_property(ic, icalproperty_new_dtend([end iCalTime])); | |
259 | icalcomponent_add_property(ic, icalproperty_new_dtend([end UTCICalTime])); | |
266 | 260 | [end release]; |
267 | 261 | /* OGo workaround ? */ |
268 | 262 | prop = icalcomponent_get_first_property(ic, ICAL_X_PROPERTY); |
0 | 0 | /*** |
1 | 1 | French.lproj/Localizable.strings |
2 | updated by make_strings 2010-03-11 10:46:44 +0100 | |
2 | updated by make_strings 2011-01-28 11:25:26 +0100 | |
3 | 3 | add comments above this one |
4 | 4 | ***/ |
5 | 5 | |
6 | 6 | |
7 | 7 | /*** Keys found in multiple places ***/ |
8 | 8 | |
9 | /* File: DayView.m:42 */ | |
10 | /* File: WeekView.m:32 */ | |
9 | /* File: DayView.m:43 */ | |
10 | /* File: WeekView.m:33 */ | |
11 | 11 | "All day : %@" = "Toute la journ\U00E9e : %@"; |
12 | ||
13 | /* File: Alarm.m:271 */ | |
14 | /* File: SAAlarm.m:271 */ | |
15 | /* Flag: unmatched */ | |
16 | "Trigger %@ after the event" | |
17 | = "Se d\U00E9clenche %@ apr\U00E8s l'\U00E9v\U00E9nement"; | |
18 | ||
19 | /* File: Alarm.m:272 */ | |
20 | /* File: SAAlarm.m:272 */ | |
21 | /* Flag: unmatched */ | |
22 | "Trigger %@ before the event" | |
23 | = "Se d\U00E9clenche %@ avant l'\U00E9v\U00E9nement"; | |
24 | ||
25 | /* File: Alarm.m:268 */ | |
26 | /* File: SAAlarm.m:268 */ | |
27 | /* Flag: unmatched */ | |
28 | "Trigger on %@" = "Se d\U00E9clenche le %@"; | |
12 | 29 | |
13 | 30 | |
14 | 31 | /*** Strings from ABStore.m ***/ |
15 | 32 | /* File: ABStore.m:58 */ |
16 | 33 | "Birthday" = "Anniversaire"; |
17 | 34 | /* File: ABStore.m:29 */ |
18 | "my address book" = "mon carnet d'adresses"; | |
35 | "My address book" = "Mon carnet d'adresses"; | |
36 | ||
37 | ||
38 | /*** Strings from AlarmEditor.m ***/ | |
39 | /* File: AlarmEditor.m:75 */ | |
40 | "Absolute" = "Absolue"; | |
41 | /* File: AlarmEditor.m:77 */ | |
42 | "Display" = "Affichage"; | |
43 | /* File: AlarmEditor.m:77 */ | |
44 | "Email" = "Email"; | |
45 | /* File: AlarmEditor.m:77 */ | |
46 | "Procedure" = "Action"; | |
47 | /* File: AlarmEditor.m:75 */ | |
48 | "Relative" = "Relative"; | |
49 | /* File: AlarmEditor.m:77 */ | |
50 | "Sound" = "Son"; | |
19 | 51 | |
20 | 52 | |
21 | 53 | /*** Strings from AppController.m ***/ |
22 | /* File: AppController.m:406 */ | |
54 | /* File: AppController.m:475 */ | |
23 | 55 | "Export as" = "Exporter sous"; |
24 | /* File: AppController.m:363 */ | |
56 | /* File: AppController.m:432 */ | |
25 | 57 | "New task" = "Nouvelle t\U00E2che"; |
26 | /* File: AppController.m:82 */ | |
58 | /* File: AppController.m:155 */ | |
27 | 59 | "Open tasks" = "T\U00E2ches en cours"; |
28 | /* File: AppController.m:155 */ | |
60 | /* File: AppController.m:230 */ | |
29 | 61 | "Open tasks (%d)" = "T\U00E2ches en cours (%d)"; |
30 | /* File: AppController.m:514 */ | |
31 | /* File: AppController.m:81 */ | |
62 | /* File: AppController.m:588 */ | |
63 | /* File: AppController.m:154 */ | |
32 | 64 | "Search results" = "R\U00E9sultats recherche"; |
33 | /* File: AppController.m:512 */ | |
65 | /* File: AppController.m:586 */ | |
34 | 66 | "Search results (%d items)" = "R\U00E9sultats (%d \U00E9l\U00E9ments)"; |
35 | /* File: AppController.m:80 */ | |
67 | /* File: AppController.m:153 */ | |
36 | 68 | "Soon" = "Bient\U00F4t"; |
37 | /* File: AppController.m:680 */ | |
38 | /* File: AppController.m:169 */ | |
69 | /* File: AppController.m:784 */ | |
70 | /* File: AppController.m:244 */ | |
39 | 71 | "Tasks" = "T\U00E2ches"; |
40 | /* File: AppController.m:78 */ | |
72 | /* File: AppController.m:151 */ | |
41 | 73 | "Today" = "Aujourd'hui"; |
42 | /* File: AppController.m:79 */ | |
74 | /* File: AppController.m:152 */ | |
43 | 75 | "Tomorrow" = "Demain"; |
44 | /* File: AppController.m:682 */ | |
45 | /* File: AppController.m:167 */ | |
76 | /* File: AppController.m:786 */ | |
77 | /* File: AppController.m:242 */ | |
46 | 78 | "Week %d" = "Semaine %d"; |
47 | /* File: AppController.m:339 */ | |
79 | /* File: AppController.m:408 */ | |
48 | 80 | "edit summary..." = "modifier le r\U00E9sum\U00E9..."; |
49 | /* File: AppController.m:715 */ | |
50 | /* File: AppController.m:331 */ | |
81 | /* File: AppController.m:400 */ | |
82 | /* File: AppController.m:819 */ | |
51 | 83 | "edit title..." = "modifier le titre..."; |
84 | ||
85 | ||
86 | /*** Strings from DBusBackend.m ***/ | |
87 | /* File: DBusBackend.m:84 */ | |
88 | "SimpleAgenda Reminder !" = "Rappel SimpleAgenda !"; | |
52 | 89 | |
53 | 90 | |
54 | 91 | /*** Strings from Task.m ***/ |
57 | 94 | /* File: Task.m:30 */ |
58 | 95 | "Completed" = "Termin\U00E9"; |
59 | 96 | /* File: Task.m:30 */ |
97 | "Needs action" = "En attente"; | |
98 | /* File: Task.m:30 */ | |
60 | 99 | "None" = "Aucun"; |
61 | 100 | /* File: Task.m:30 */ |
62 | 101 | "Started" = "D\U00E9marr\U00E9"; |
3 | 3 | # |
4 | 4 | # Application |
5 | 5 | # |
6 | VERSION = 0.41 | |
6 | VERSION = 0.42.2 | |
7 | 7 | PACKAGE_NAME = SimpleAgenda |
8 | 8 | APP_NAME = SimpleAgenda |
9 | 9 | SimpleAgenda_APPLICATION_ICON = Calendar.tiff |
25 | 25 | Resources/1left.tiff \ |
26 | 26 | Resources/1right.tiff \ |
27 | 27 | Resources/2left.tiff \ |
28 | Resources/2right.tiff | |
28 | Resources/2right.tiff \ | |
29 | Resources/bell.tiff \ | |
30 | Resources/small-bell.tiff | |
29 | 31 | |
30 | 32 | SimpleAgenda_LANGUAGES = English French |
31 | 33 | |
61 | 63 | RecurrenceRule.m \ |
62 | 64 | NSColor+SimpleAgenda.m \ |
63 | 65 | DateRange.m \ |
64 | SAAlarm.m \ | |
66 | Alarm.m \ | |
65 | 67 | AlarmManager.m \ |
66 | 68 | NSString+SimpleAgenda.m \ |
67 | AlarmEditor.m | |
69 | AlarmEditor.m \ | |
70 | SoundBackend.m | |
68 | 71 | |
69 | 72 | ifeq ($(ADDRESSES),yes) |
70 | 73 | SimpleAgenda_OBJC_FILES += ABStore.m |
74 | endif | |
75 | ||
76 | ifeq ($(DBUSKIT),yes) | |
77 | SimpleAgenda_OBJC_FILES += DBusBackend.m | |
71 | 78 | endif |
72 | 79 | |
73 | 80 | # |
11 | 11 | ADDITIONAL_CFLAGS += |
12 | 12 | |
13 | 13 | # Additional flags to pass to the linker |
14 | ADDITIONAL_LDFLAGS += -lical | |
14 | ADDITIONAL_TOOL_LIBS += -lical | |
15 | 15 | ifeq ($(LIBUUID),yes) |
16 | ADDITIONAL_LDFLAGS += -luuid | |
16 | ADDITIONAL_TOOL_LIBS += -luuid | |
17 | 17 | endif |
18 | 18 | ifeq ($(ADDRESSES),yes) |
19 | ADDITIONAL_LDFLAGS += -lAddresses | |
19 | ADDITIONAL_TOOL_LIBS += -lAddresses | |
20 | endif | |
21 | ifeq ($(DBUSKIT),yes) | |
22 | ADDITIONAL_TOOL_LIBS += -lDBusKit | |
20 | 23 | endif |
21 | 24 | |
22 | 25 | # Additional include directories the compiler should search |
6 | 6 | #import "iCalTree.h" |
7 | 7 | #import "defines.h" |
8 | 8 | |
9 | @interface GroupDAVStore : MemoryStore <AgendaStore> | |
9 | @interface GroupDAVStore : MemoryStore <AgendaStore, ConfigListener> | |
10 | 10 | { |
11 | 11 | NSURL *_url; |
12 | 12 | WebDAVResource *_calendar; |
109 | 109 | set = (GSXPathNodeSet *)[xpc evaluateExpression:@"//response[propstat/prop/resourcetype/vtodo-collection]/href/text()"]; |
110 | 110 | for (i = 0; i < [set count]; i++) |
111 | 111 | [task addItemWithTitle:[[set nodeAtIndex:i] content]]; |
112 | [xpc release]; | |
112 | RELEASE(xpc); | |
113 | if ([calendar numberOfItems] > 0) | |
114 | [calendar selectItemAtIndex:1]; | |
115 | if ([task numberOfItems] > 0) | |
116 | [task selectItemAtIndex:1]; | |
113 | 117 | } |
114 | 118 | } |
115 | 119 | [resource release]; |
144 | 148 | @implementation GroupDAVStore |
145 | 149 | - (NSDictionary *)defaults |
146 | 150 | { |
147 | return [NSDictionary dictionaryWithObjectsAndKeys:[[NSColor blueColor] description], ST_COLOR, | |
148 | [[NSColor darkGrayColor] description], ST_TEXT_COLOR, | |
151 | return [NSDictionary dictionaryWithObjectsAndKeys:[[NSColor redColor] description], ST_COLOR, | |
152 | [[NSColor whiteColor] description], ST_TEXT_COLOR, | |
149 | 153 | [NSNumber numberWithBool:NO], ST_RW, |
150 | 154 | [NSNumber numberWithBool:YES], ST_DISPLAY, |
151 | 155 | [NSNumber numberWithBool:YES], ST_ENABLED, |
161 | 165 | _hrefresource = [[NSMutableDictionary alloc] initWithCapacity:512]; |
162 | 166 | _modifiedhref = [NSMutableArray new]; |
163 | 167 | _loadedData = [[NSMutableSet alloc] initWithCapacity:512]; |
168 | [_config registerClient:self forKey:ST_REFRESH]; | |
169 | [_config registerClient:self forKey:ST_REFRESH_INTERVAL]; | |
170 | [_config registerClient:self forKey:ST_ENABLED]; | |
164 | 171 | [NSThread detachNewThreadSelector:@selector(initStoreAsync:) toTarget:self withObject:nil]; |
165 | 172 | [self initTimer]; |
166 | 173 | } |
188 | 195 | if ([dialog task]) |
189 | 196 | taskURL = [NSURL URLWithString:[dialog task] possiblyRelativeToURL:baseURL]; |
190 | 197 | [dialog release]; |
191 | cm = [[ConfigManager alloc] initForKey:name withParent:nil]; | |
198 | cm = [[ConfigManager alloc] initForKey:name]; | |
192 | 199 | [cm setObject:[dialog url] forKey:ST_URL]; |
193 | 200 | if (calendarURL) |
194 | [cm setObject:[calendarURL description] forKey:ST_CALENDAR_URL]; | |
201 | [cm setObject:[calendarURL absoluteString] forKey:ST_CALENDAR_URL]; | |
195 | 202 | if (taskURL) |
196 | [cm setObject:[taskURL description] forKey:ST_TASK_URL]; | |
203 | [cm setObject:[taskURL absoluteString] forKey:ST_TASK_URL]; | |
197 | 204 | [cm setObject:[[self class] description] forKey:ST_CLASS]; |
198 | 205 | [cm setObject:[NSNumber numberWithBool:YES] forKey:ST_RW]; |
199 | 206 | return YES; |
204 | 211 | |
205 | 212 | + (NSString *)storeTypeName |
206 | 213 | { |
207 | return @"GroupDAV store"; | |
214 | return @"GroupDAV"; | |
208 | 215 | } |
209 | 216 | |
210 | 217 | - (void)dealloc |
245 | 252 | /* Reloading all data is a way to handle href and uid modification done by the server */ |
246 | 253 | [self fetchData]; |
247 | 254 | else |
248 | NSLog(@"Error %d writing event to %@", [resource httpStatus], [url absoluteString]); | |
255 | NSLog(@"Error %d writing event to %@", [resource httpStatus], [url anonymousAbsoluteString]); | |
249 | 256 | } |
250 | 257 | [tree release]; |
251 | 258 | [resource release]; |
312 | 319 | [copy release]; |
313 | 320 | return YES; |
314 | 321 | } |
322 | ||
323 | - (void)config:(ConfigManager *)config dataDidChangedForKey:(NSString *)key | |
324 | { | |
325 | if (config == _config && [key isEqualToString:ST_ENABLED] && [self enabled]) { | |
326 | [self read]; | |
327 | [self initTimer]; | |
328 | } | |
329 | } | |
315 | 330 | @end |
316 | 331 | |
317 | 332 | |
339 | 354 | if (elementURL) |
340 | 355 | [result addObject:[elementURL absoluteString]]; |
341 | 356 | } |
342 | [xpc release]; | |
357 | RELEASE(xpc); | |
343 | 358 | } |
344 | 359 | return result; |
345 | 360 | } |
389 | 404 | } |
390 | 405 | - (void)fetchData |
391 | 406 | { |
407 | if (![self enabled]) | |
408 | return; | |
392 | 409 | [_loadedData removeAllObjects]; |
393 | 410 | if (_calendar) |
394 | 411 | [self fetchList:[self itemsUnderRessource:_calendar]]; |
400 | 417 | else |
401 | 418 | [self performSelectorOnMainThread:@selector(fillWithElements:) withObject:_loadedData waitUntilDone:YES]; |
402 | 419 | } |
403 | NSLog(@"GroupDAVStore from %@ : loaded %d appointment(s)", [_url absoluteString], [[self events] count]); | |
404 | NSLog(@"GroupDAVStore from %@ : loaded %d tasks(s)", [_url absoluteString], [[self tasks] count]); | |
405 | } | |
406 | @end | |
420 | NSLog(@"GroupDAVStore from %@ : loaded %d appointment(s)", [_url anonymousAbsoluteString], [[self events] count]); | |
421 | NSLog(@"GroupDAVStore from %@ : loaded %d tasks(s)", [_url anonymousAbsoluteString], [[self tasks] count]); | |
422 | } | |
423 | @end |
2 | 2 | #import <Foundation/Foundation.h> |
3 | 3 | |
4 | 4 | @interface HourFormatter : NSFormatter |
5 | + (NSString *)stringForObjectValue:(id)anObject; | |
5 | 6 | @end |
2 | 2 | #import "HourFormatter.h" |
3 | 3 | |
4 | 4 | @implementation HourFormatter |
5 | + (NSString *)stringForObjectValue:(id)anObject | |
6 | { | |
7 | int hours; | |
8 | int minutes; | |
9 | ||
10 | if (![anObject isKindOfClass:[NSNumber class]]) | |
11 | return nil; | |
12 | hours = [anObject intValue] / 3600; | |
13 | minutes = [anObject intValue] / 60 - hours * 60; | |
14 | return [NSString stringWithFormat:@"%dh%02d", hours, minutes]; | |
15 | } | |
5 | 16 | |
6 | 17 | - (NSString *)stringForObjectValue:(id)anObject |
7 | 18 | { |
8 | if (![anObject isKindOfClass:[NSNumber class]]) | |
9 | return nil; | |
10 | int m = ([anObject floatValue] - [anObject intValue]) * 100; | |
11 | return [NSString stringWithFormat:@"%dh%02d", [anObject intValue], 60 * m / 100]; | |
19 | return [HourFormatter stringForObjectValue:anObject]; | |
12 | 20 | } |
13 | 21 | |
14 | 22 | - (BOOL)getObjectValue:(id *)anObject forString:(NSString *)string errorDescription:(NSString **)error |
15 | 23 | { |
16 | return NO; | |
24 | NSNumberFormatter *nf; | |
25 | NSNumber *hours; | |
26 | NSNumber *minutes; | |
27 | NSArray *components = [string componentsSeparatedByString:@"h"]; | |
28 | ||
29 | if (!components || [components count] != 2) { | |
30 | if (error) | |
31 | *error = [[NSError alloc] initWithDomain:@"Bad time formatting : cannot find hours and minutes separated by h" code:1 userInfo:nil]; | |
32 | else | |
33 | NSLog(@"Bad time formatting : cannot find hours and minutes separated by h"); | |
34 | return NO; | |
35 | } | |
36 | nf = AUTORELEASE([[NSNumberFormatter alloc] init]); | |
37 | hours = [nf numberFromString:[components objectAtIndex:0]]; | |
38 | minutes = [nf numberFromString:[components objectAtIndex:1]]; | |
39 | if (!hours || !minutes) { | |
40 | if (error) | |
41 | *error = [[NSError alloc] initWithDomain:@"Bad time formatting" code:2 userInfo:nil]; | |
42 | else | |
43 | NSLog(@"Bad time formatting"); | |
44 | return NO; | |
45 | } | |
46 | if ([hours intValue] < 0 || [hours intValue] > 23) { | |
47 | if (error) | |
48 | *error = [[NSError alloc] initWithDomain:@"Hours must be between 0 and 23" code:3 userInfo:nil]; | |
49 | else | |
50 | NSLog(@"Hours must be between 0 and 23"); | |
51 | return NO; | |
52 | } | |
53 | if ([minutes intValue] < 0 || [minutes intValue] > 59) { | |
54 | if (error) | |
55 | *error = [[NSError alloc] initWithDomain:@"Minutes must be between 0 and 59" code:4 userInfo:nil]; | |
56 | else | |
57 | NSLog(@"Minutes must be between 0 and 59"); | |
58 | return NO; | |
59 | } | |
60 | *anObject = [[NSNumber alloc] initWithInt:[hours intValue] * 3600 + [minutes intValue] * 60.0]; | |
61 | return YES; | |
17 | 62 | } |
18 | 63 | |
19 | 64 | - (NSAttributedString *)attributedStringForObjectValue:(id)anObject withDefaultAttributes:(NSDictionary *)attributes |
20 | 65 | { |
21 | 66 | return nil; |
22 | 67 | } |
23 | ||
24 | 68 | @end |
44 | 44 | { |
45 | 45 | ConfigManager *cm; |
46 | 46 | |
47 | cm = [[ConfigManager alloc] initForKey:name withParent:nil]; | |
47 | cm = [[ConfigManager alloc] initForKey:name]; | |
48 | 48 | [cm setObject:[name copy] forKey:ST_FILE]; |
49 | 49 | [cm setObject:[[self class] description] forKey:ST_CLASS]; |
50 | 50 | [cm release]; |
53 | 53 | |
54 | 54 | + (NSString *)storeTypeName |
55 | 55 | { |
56 | return @"Simple file store"; | |
56 | return @"Local file"; | |
57 | 57 | } |
58 | 58 | |
59 | 59 | - (void)dealloc |
21 | 21 | self = [super init]; |
22 | 22 | if (self) { |
23 | 23 | _name = [name copy]; |
24 | _config = [[ConfigManager alloc] initForKey:name withParent:nil]; | |
24 | _config = [[ConfigManager alloc] initForKey:name]; | |
25 | 25 | /* |
26 | 26 | * Don't remove this even if it's seems silly : it will |
27 | 27 | * call the subclass's -defaults method which will have |
0 | version 0.42.2 (2012/02/02) | |
1 | * Bug fix backport from trunk : 'Reload all' wouldn't work if ABStore | |
2 | was compiled in | |
3 | ||
4 | version 0.42.1 (2012/01/29) | |
5 | * Bug fixes backport from trunk (store removal and element encoding) | |
6 | ||
7 | version 0.42 (2011/04/27) | |
8 | * Bug fixes and code cleanups | |
9 | * Handle read only stores when cut & pasting elements | |
10 | * Simple reminders/alarms handling with multiple backends | |
11 | * Alarm editor for events and tasks with basic functionalities | |
12 | * New images from OpenClipArt (bell_gold.svg) | |
13 | * Fix ticket #12 : timezone problems with recurrent events | |
14 | * Use calendar instead of store and agenda in the ui | |
15 | * Handle due date in tasks | |
16 | * Fix URL handling for GroupDAV calendars, tested against | |
17 | Citadel and OGO | |
18 | * Enable copy/paste on multiple elements (select with control key) | |
19 | * Don't write authentication informations on the stdout (see ticket #17) | |
20 | ||
0 | 21 | version 0.41 (2010/03/15) |
1 | 22 | * Threads/memory pools/notifications fixes |
2 | 23 | * Fix silly bugs in the makefile when using conditions : we |
0 | 0 | /* emacs buffer mode hint -*- objc -*- */ |
1 | 1 | |
2 | #import <AppKit/AppKit.h> | |
2 | #import <AppKit/NSColor.h> | |
3 | ||
4 | /* | |
5 | * This method is available but not defined. Avoid | |
6 | * a compilation warning by declaring it here. | |
7 | */ | |
8 | @interface NSColor(NotDefinedMethods) | |
9 | + (NSColor *)colorFromString:(NSString *)string; | |
10 | @end | |
3 | 11 | |
4 | 12 | @interface NSColor(SimpleAgenda) |
5 | 13 | - (NSColor *)colorModifiedWithDeltaRed:(float)red green:(float)green blue:(float)blue alpha:(float)alpha; |
35 | 35 | IBOutlet id uiPreferences; |
36 | 36 | IBOutlet id showDateAppIcon; |
37 | 37 | IBOutlet id showTimeAppIcon; |
38 | IBOutlet id alarmPreferences; | |
39 | IBOutlet id alarmEnabled; | |
40 | IBOutlet id alarmBackendPopUp; | |
38 | 41 | StoreManager *_sm; |
39 | 42 | } |
40 | 43 | |
57 | 60 | - (void)toggleTooltip:(id)sender; |
58 | 61 | - (void)toggleShowDate:(id)sender; |
59 | 62 | - (void)toggleShowTime:(id)sender; |
63 | - (void)toggleAlarms:(id)sender; | |
64 | - (void)selectAlarmBackend:(id)sender; | |
60 | 65 | @end |
2 | 2 | #import "PreferencesController.h" |
3 | 3 | #import "HourFormatter.h" |
4 | 4 | #import "ConfigManager.h" |
5 | #import "AlarmManager.h" | |
6 | #import "AlarmBackend.h" | |
5 | 7 | #import "defines.h" |
6 | 8 | |
7 | 9 | @implementation PreferencesController |
21 | 23 | RETAIN(globalPreferences); |
22 | 24 | RETAIN(storePreferences); |
23 | 25 | RETAIN(storeFactory); |
26 | RETAIN(uiPreferences); | |
27 | RETAIN(alarmPreferences); | |
24 | 28 | [self selectItem:itemPopUp]; |
25 | 29 | [panel setFrameAutosaveName:@"preferencesPanel"]; |
26 | 30 | /* FIXME : could we call setupDefaultStore directly ? */ |
41 | 45 | RELEASE(globalPreferences); |
42 | 46 | RELEASE(storePreferences); |
43 | 47 | RELEASE(storeFactory); |
48 | RELEASE(uiPreferences); | |
49 | RELEASE(alarmPreferences); | |
44 | 50 | [super dealloc]; |
45 | 51 | } |
46 | 52 | |
86 | 92 | |
87 | 93 | - (void)showPreferences |
88 | 94 | { |
89 | NSEnumerator *backends = [[StoreManager backends] objectEnumerator]; | |
90 | 95 | ConfigManager *config = [ConfigManager globalConfig]; |
96 | NSEnumerator *backends; | |
91 | 97 | int start = [config integerForKey:FIRST_HOUR]; |
92 | 98 | int end = [config integerForKey:LAST_HOUR]; |
93 | 99 | int step = [config integerForKey:MIN_STEP]; |
94 | 100 | Class backend; |
95 | ||
96 | [dayStart setIntValue:start]; | |
97 | [dayEnd setIntValue:end]; | |
98 | [dayStartText setIntValue:start]; | |
99 | [dayEndText setIntValue:end]; | |
100 | [minStep setDoubleValue:step/60.0]; | |
101 | [minStepText setDoubleValue:step/60.0]; | |
101 | NSString *name; | |
102 | ||
103 | [dayStart setIntValue:start*3600]; | |
104 | [dayEnd setIntValue:end*3600]; | |
105 | [dayStartText setIntValue:start*3600]; | |
106 | [dayEndText setIntValue:end*3600]; | |
107 | [minStep setIntValue:step * 60]; | |
108 | [minStepText setIntValue:step * 60]; | |
102 | 109 | [showTooltip setState:[config integerForKey:TOOLTIP]]; |
103 | 110 | [showDateAppIcon setState:[config integerForKey:APPICON_DATE]]; |
104 | 111 | [showTimeAppIcon setState:[config integerForKey:APPICON_TIME]]; |
105 | 112 | |
113 | [alarmEnabled setState:[[AlarmManager globalManager] alarmsEnabled]]; | |
114 | [alarmBackendPopUp removeAllItems]; | |
115 | backends = [[AlarmManager backends] objectEnumerator]; | |
116 | while ((backend = [backends nextObject])) | |
117 | [alarmBackendPopUp addItemWithTitle:[[backend class] backendName]]; | |
118 | ||
119 | name = [[AlarmManager globalManager] defaultBackendName]; | |
120 | if ([alarmBackendPopUp itemWithTitle:name]) | |
121 | [alarmBackendPopUp selectItemWithTitle:name]; | |
122 | ||
106 | 123 | [self setupStores]; |
107 | 124 | [storeClass removeAllItems]; |
125 | backends = [[StoreManager backends] objectEnumerator]; | |
108 | 126 | while ((backend = [backends nextObject])) |
109 | 127 | if ([backend isUserInstanciable]) |
110 | 128 | [storeClass addItemWithTitle:[backend storeTypeName]]; |
121 | 139 | [storeRefresh setState:[store periodicRefresh]]; |
122 | 140 | [refreshInterval setEnabled:[store periodicRefresh]]; |
123 | 141 | [refreshIntervalText setEnabled:[store periodicRefresh]]; |
124 | [refreshIntervalText setDoubleValue:[store refreshInterval]/3600.0]; | |
125 | [refreshInterval setDoubleValue:[store refreshInterval]/3600.0]; | |
142 | [refreshIntervalText setIntValue:[store refreshInterval]]; | |
143 | [refreshInterval setIntValue:[store refreshInterval]]; | |
126 | 144 | } else { |
127 | 145 | [storeRefresh setEnabled:NO]; |
128 | 146 | [storeRefresh setState:NO]; |
129 | 147 | [refreshInterval setEnabled:NO]; |
130 | 148 | [refreshIntervalText setEnabled:NO]; |
131 | [refreshIntervalText setDoubleValue:0]; | |
132 | [refreshInterval setDoubleValue:0]; | |
149 | [refreshIntervalText setIntValue:0]; | |
150 | [refreshInterval setIntValue:0]; | |
133 | 151 | } |
134 | 152 | } |
135 | 153 | |
164 | 182 | |
165 | 183 | - (void)changeStart:(id)sender |
166 | 184 | { |
167 | int value = [dayStart intValue]; | |
185 | int value = [dayStart intValue] / 3600; | |
168 | 186 | if (value != [[ConfigManager globalConfig] integerForKey:FIRST_HOUR]) { |
169 | [dayStartText setIntValue:value]; | |
187 | [dayStartText setIntValue:value * 3600]; | |
170 | 188 | [[ConfigManager globalConfig] setInteger:value forKey:FIRST_HOUR]; |
171 | 189 | } |
172 | 190 | } |
173 | 191 | |
174 | 192 | - (void)changeEnd:(id)sender |
175 | 193 | { |
176 | int value = [dayEnd intValue]; | |
194 | int value = [dayEnd intValue] / 3600; | |
177 | 195 | if (value != [[ConfigManager globalConfig] integerForKey:LAST_HOUR]) { |
178 | [dayEndText setIntValue:value]; | |
196 | [dayEndText setIntValue:value * 3600]; | |
179 | 197 | [[ConfigManager globalConfig] setInteger:value forKey:LAST_HOUR]; |
180 | 198 | } |
181 | 199 | } |
182 | 200 | |
183 | 201 | - (void)changeStep:(id)sender |
184 | 202 | { |
185 | double value = [minStep doubleValue]; | |
186 | if (value * 60 != [[ConfigManager globalConfig] integerForKey:MIN_STEP]) { | |
187 | [minStepText setDoubleValue:value]; | |
188 | [[ConfigManager globalConfig] setInteger:value * 60 forKey:MIN_STEP]; | |
203 | int value = [minStep intValue] / 60; | |
204 | if (value != [[ConfigManager globalConfig] integerForKey:MIN_STEP]) { | |
205 | [minStepText setIntValue:value * 60]; | |
206 | [[ConfigManager globalConfig] setInteger:value forKey:MIN_STEP]; | |
189 | 207 | } |
190 | 208 | } |
191 | 209 | |
192 | 210 | - (void)changeInterval:(id)sender |
193 | 211 | { |
194 | double value = [refreshInterval doubleValue]; | |
212 | int value = [refreshInterval intValue]; | |
195 | 213 | id <PeriodicRefresh> store = (id <PeriodicRefresh>)[_sm storeForName:[storePopUp titleOfSelectedItem]]; |
196 | [store setRefreshInterval:value * 3600]; | |
197 | [refreshIntervalText setDoubleValue:value]; | |
198 | [refreshInterval setDoubleValue:value]; | |
214 | [store setRefreshInterval:value]; | |
215 | [refreshIntervalText setIntValue:value]; | |
216 | [refreshInterval setIntValue:value]; | |
199 | 217 | } |
200 | 218 | |
201 | 219 | - (void)selectDefaultStore:(id)sender |
244 | 262 | [[ConfigManager globalConfig] setInteger:[showTimeAppIcon state] forKey:APPICON_TIME]; |
245 | 263 | } |
246 | 264 | |
265 | - (void)toggleAlarms:(id)sender | |
266 | { | |
267 | [[AlarmManager globalManager] setAlarmsEnabled:[alarmEnabled state]]; | |
268 | } | |
269 | ||
270 | - (void)selectAlarmBackend:(id)sender | |
271 | { | |
272 | [[AlarmManager globalManager] setDefaultBackend:[alarmBackendPopUp titleOfSelectedItem]]; | |
273 | } | |
274 | ||
247 | 275 | /* We only allow the removal of non-default stores */ |
248 | 276 | - (void)removeStore:(id)sender |
249 | 277 | { |
250 | 278 | id <AgendaStore> store = [_sm storeForName:[storePopUp titleOfSelectedItem]]; |
251 | 279 | ConfigManager *config = [ConfigManager globalConfig]; |
252 | NSMutableArray *storeArray = [config objectForKey:STORES]; | |
280 | NSMutableArray *storeArray = [NSMutableArray arrayWithArray:[config objectForKey:STORES]]; | |
253 | 281 | |
254 | 282 | [storeArray removeObject:[store description]]; |
255 | 283 | [config setObject:storeArray forKey:STORES]; |
276 | 304 | [createButton setEnabled:NO]; |
277 | 305 | } |
278 | 306 | |
307 | - (void)setContent:(id)content | |
308 | { | |
309 | id old = [slot contentView]; | |
310 | ||
311 | if (old == content) | |
312 | return; | |
313 | [slot setContentView: content]; | |
314 | [itemPopUp setNextKeyView:[slot contentView]]; | |
315 | } | |
316 | ||
317 | ||
279 | 318 | - (void)selectItem:(id)sender |
280 | 319 | { |
281 | 320 | switch ([sender indexOfSelectedItem]) { |
282 | 321 | case 0: |
283 | [slot setContentView:globalPreferences]; | |
322 | [self setContent:globalPreferences]; | |
284 | 323 | break; |
285 | 324 | case 1: |
286 | [slot setContentView:storePreferences]; | |
325 | [self setContent:storePreferences]; | |
287 | 326 | break; |
288 | 327 | case 2: |
289 | [slot setContentView:storeFactory]; | |
328 | [self setContent:storeFactory]; | |
290 | 329 | break; |
291 | 330 | case 3: |
292 | [slot setContentView:uiPreferences]; | |
293 | break; | |
294 | } | |
295 | [itemPopUp setNextKeyView:[slot contentView]]; | |
331 | [self setContent:uiPreferences]; | |
332 | break; | |
333 | case 4: | |
334 | [self setContent:alarmPreferences]; | |
335 | break; | |
336 | } | |
296 | 337 | } |
297 | 338 | |
298 | 339 | - (void)controlTextDidChange:(NSNotification *)notification |
10 | 10 | * create, resize and move appointments easily |
11 | 11 | * export individual elements as files and to pasteboard |
12 | 12 | * import .ics files |
13 | * simple text search | |
13 | * simple text search | |
14 | * alarms with multiples backends | |
14 | 15 | |
15 | 16 | Dependencies |
16 | 17 | ============ |
17 | 18 | |
18 | GNUstep Startup 0.19.0 | |
19 | libical 0.27 | |
19 | GNUstep stable version released on 2011/04/14 | |
20 | (make 2.6.0, base 1.22.0, gui 0.20.0, back 0.20.0) | |
21 | libical 0.27 or later | |
20 | 22 | libuuid (optional) |
23 | Addresses framework (optional) | |
24 | DBusKit 0.1 (optional) | |
21 | 25 | |
22 | 26 | |
23 | 27 | Website |
9 | 9 | @implementation DateRecurrenceEnumerator |
10 | 10 | - (id)initWithRule:(RecurrenceRule *)rule start:(Date *)start; |
11 | 11 | { |
12 | self = [super init]; | |
13 | /* | |
14 | * It's OK to use Date iCaltime: here as timezone modifications | |
15 | * only affect datetimes, not dates | |
16 | */ | |
17 | if (self) | |
18 | _iterator = icalrecur_iterator_new([rule iCalRRule], [start iCalTime]); | |
12 | if ((self = [super init])) | |
13 | _iterator = icalrecur_iterator_new([rule iCalRRule], [start localICalTime]); | |
19 | 14 | return self; |
20 | 15 | } |
21 | 16 | - (id)nextObject |
44 | 39 | @implementation DateRangeRecurrenceEnumerator |
45 | 40 | - (id)initWithRule:(RecurrenceRule *)rule start:(Date *)start length:(NSTimeInterval)length; |
46 | 41 | { |
47 | self = [super init]; | |
48 | if (self) { | |
49 | _iterator = icalrecur_iterator_new([rule iCalRRule], [start iCalTime]); | |
42 | if ((self = [super init])) { | |
43 | _iterator = icalrecur_iterator_new([rule iCalRRule], [start localICalTime]); | |
50 | 44 | _length = length; |
51 | 45 | } |
52 | 46 | return self; |
80 | 74 | - (id)initWithFrequency:(recurrenceFrequency)frequency |
81 | 75 | { |
82 | 76 | NSAssert(frequency < recurrenceFrequenceOther, @"Wrong frequency"); |
83 | self = [self init]; | |
84 | if (self) | |
77 | if ((self = [self init])) | |
85 | 78 | recur.freq = frequency; |
86 | 79 | return self; |
87 | 80 | } |
89 | 82 | { |
90 | 83 | NSAssert(frequency < recurrenceFrequenceOther, @"Wrong frequency"); |
91 | 84 | NSAssert([endDate isDate], @"Works on dates"); |
92 | self = [self init]; | |
93 | if (self) { | |
85 | if ((self = [self init])) { | |
94 | 86 | /* |
95 | 87 | * It's OK to use Date iCaltime: here as timezone modifications |
96 | 88 | * only affect datetimes, not dates |
97 | 89 | */ |
98 | recur.until = [endDate iCalTime]; | |
90 | recur.until = [endDate UTCICalTime]; | |
99 | 91 | recur.freq = frequency; |
100 | 92 | } |
101 | 93 | return self; |
103 | 95 | - (id)initWithFrequency:(recurrenceFrequency)frequency count:(int)count |
104 | 96 | { |
105 | 97 | NSAssert(frequency < recurrenceFrequenceOther, @"Wrong frequency"); |
106 | self = [self init]; | |
107 | if (self) { | |
98 | if ((self = [self init])) { | |
108 | 99 | recur.count = count; |
109 | 100 | recur.freq = frequency; |
110 | 101 | } |
144 | 135 | @implementation RecurrenceRule(iCalendar) |
145 | 136 | - (id)initWithICalRRule:(struct icalrecurrencetype)rrule |
146 | 137 | { |
147 | self = [super init]; | |
148 | if (self) | |
138 | if ((self = [super init])) | |
149 | 139 | recur = rrule; |
150 | 140 | return self; |
151 | 141 | } |
152 | 142 | - (id)initWithICalString:(NSString *)rrule |
153 | 143 | { |
154 | self = [super init]; | |
155 | if (self) | |
144 | if ((self = [super init])) | |
156 | 145 | recur = icalrecurrencetype_from_string([rrule cString]); |
157 | 146 | return self; |
158 | 147 | } |
Binary diff not shown
Binary diff not shown
1 | 1 | "## Comment" = "Do NOT change this file, Gorm maintains it"; |
2 | 2 | AlarmEditor = { |
3 | 3 | Actions = ( |
4 | "addAlarm:", | |
5 | "selectType:", | |
6 | "removeAlarm:", | |
7 | "changeDelay:", | |
8 | "switchBeforeAfter:" | |
4 | 9 | ); |
5 | 10 | Outlets = ( |
6 | 11 | panel, |
7 | calendar, | |
8 | 12 | type, |
9 | action | |
13 | action, | |
14 | window, | |
15 | table, | |
16 | add, | |
17 | remove, | |
18 | relativeSlider, | |
19 | relativeText, | |
20 | radio, | |
21 | date, | |
22 | time | |
10 | 23 | ); |
11 | 24 | Super = NSObject; |
12 | 25 | }; |
22 | 35 | }; |
23 | 36 | FirstResponder = { |
24 | 37 | Actions = ( |
25 | "setDelegate:" | |
38 | "addAlarm:", | |
39 | "changeDelay:", | |
40 | "removeAlarm:", | |
41 | "selectType:", | |
42 | "setDelegate:", | |
43 | "switchBeforeAfter:" | |
26 | 44 | ); |
27 | 45 | Super = NSObject; |
28 | 46 | }; |
Binary diff not shown
Binary diff not shown
5 | 5 | "validate:", |
6 | 6 | "selectFrequency:", |
7 | 7 | "toggleUntil:", |
8 | "toggleAllDay:" | |
8 | "toggleAllDay:", | |
9 | "editAlarms:" | |
9 | 10 | ); |
10 | 11 | Outlets = ( |
11 | 12 | description, |
26 | 27 | }; |
27 | 28 | FirstResponder = { |
28 | 29 | Actions = ( |
30 | "editAlarms:", | |
31 | "selectFrequency:", | |
29 | 32 | "toggleAllDay:", |
30 | "selectFrequency:", | |
31 | 33 | "toggleUntil:", |
32 | 34 | "validate:" |
33 | 35 | ); |
Binary diff not shown
Binary diff not shown
Binary diff not shown
Binary diff not shown
Binary diff not shown
6 | 6 | "changeStart:", |
7 | 7 | "changeStep:", |
8 | 8 | "createStore:", |
9 | "toggleEnabled:", | |
9 | "selectAlarmBackend:", | |
10 | 10 | "removeStore:", |
11 | 11 | "selectDefaultStore:", |
12 | 12 | "selectItem:", |
13 | 13 | "selectStore:", |
14 | 14 | "setColor:", |
15 | "toggleAlarms:", | |
15 | 16 | "toggleDisplay:", |
17 | "toggleEnabled:", | |
16 | 18 | "toggleRefresh:", |
17 | 19 | "toggleShowDate:", |
18 | 20 | "toggleShowTime:", |
40 | 42 | "toggleTooltip:", |
41 | 43 | "toggleShowTime:", |
42 | 44 | "toggleShowDate:", |
43 | "toggleEnabled:" | |
45 | "toggleEnabled:", | |
46 | "toggleAlarms:", | |
47 | "selectAlarmBackend:" | |
44 | 48 | ); |
45 | 49 | Outlets = ( |
46 | 50 | panel, |
72 | 76 | showTimeAppIcon, |
73 | 77 | showDateAppIcon, |
74 | 78 | uiPreferences, |
75 | storeEnabled | |
79 | storeEnabled, | |
80 | alarmPreferences, | |
81 | alarmEnabled, | |
82 | alarmBackendPopUp | |
76 | 83 | ); |
77 | 84 | Super = NSObject; |
78 | 85 | }; |
Binary diff not shown
Binary diff not shown
1 | 1 | "## Comment" = "Do NOT change this file, Gorm maintains it"; |
2 | 2 | FirstResponder = { |
3 | 3 | Actions = ( |
4 | "editAlarms:", | |
5 | "toggleDueDate:", | |
4 | 6 | "validate:" |
5 | 7 | ); |
6 | 8 | Super = NSObject; |
8 | 10 | TaskEditor = { |
9 | 11 | Actions = ( |
10 | 12 | "validate:", |
11 | "cancel:" | |
13 | "cancel:", | |
14 | "editAlarms:", | |
15 | "toggleDueDate:" | |
12 | 16 | ); |
13 | 17 | Outlets = ( |
14 | 18 | window, |
16 | 20 | summary, |
17 | 21 | store, |
18 | 22 | state, |
19 | ok | |
23 | ok, | |
24 | dueDate, | |
25 | dueTime, | |
26 | toggleDueDate, | |
27 | alarms | |
20 | 28 | ); |
21 | 29 | Super = NSObject; |
22 | 30 | }; |
Binary diff not shown
Binary diff not shown
Binary diff not shown
10 | 10 | Actions = ( |
11 | 11 | ); |
12 | 12 | Outlets = ( |
13 | _delegate | |
13 | "_delegate" | |
14 | 14 | ); |
15 | 15 | Super = NSObject; |
16 | 16 | }; |
Binary diff not shown
Binary diff not shown
Binary diff not shown
0 | /* emacs buffer mode hint -*- objc -*- */ | |
1 | ||
2 | #import <Foundation/Foundation.h> | |
3 | ||
4 | extern NSString * const SAActionDisplay; | |
5 | extern NSString * const SAActionEmail; | |
6 | extern NSString * const SAActionProcedure; | |
7 | extern NSString * const SAActionSound; | |
8 | ||
9 | @class Date; | |
10 | @class Element; | |
11 | ||
12 | @interface SAAlarm : NSObject | |
13 | { | |
14 | Date *_absoluteTrigger; | |
15 | NSTimeInterval _relativeTrigger; | |
16 | NSString *_action; | |
17 | NSString *_emailaddress; | |
18 | NSString *_sound; | |
19 | NSURL *_url; | |
20 | int _repeatCount; | |
21 | NSTimeInterval _repeatInterval; | |
22 | Element *_element; | |
23 | } | |
24 | ||
25 | + (id)alarm; | |
26 | - (BOOL)isAbsoluteTrigger; | |
27 | - (Date *)absoluteTrigger; | |
28 | - (void)setAbsoluteTrigger:(Date *)trigger; | |
29 | - (NSTimeInterval)relativeTrigger; | |
30 | - (void)setRelativeTrigger:(NSTimeInterval)trigger; | |
31 | - (NSString *)action; | |
32 | - (void)setAction:(NSString *)action; | |
33 | - (NSString *)emailAddress; | |
34 | - (void)setEmailAddress:(NSString *)emailAddress; | |
35 | - (NSString *)sound; | |
36 | - (void)setSound:(NSString *)sound; | |
37 | - (NSURL *)url; | |
38 | - (void)setUrl:(NSURL *)url; | |
39 | - (int)repeatCount; | |
40 | - (void)setRepeatCount:(int)count; | |
41 | - (NSTimeInterval)repeatInterval; | |
42 | - (void)setRepeatInterval:(NSTimeInterval)interval; | |
43 | - (Element *)element; | |
44 | - (void)setElement:(Element *)element; | |
45 | - (Date *)triggerDateRelativeTo:(Date *)date; | |
46 | @end |
0 | /* emacs buffer mode hint -*- objc -*- */ | |
1 | ||
2 | #import "SAAlarm.h" | |
3 | #import "Date.h" | |
4 | ||
5 | NSString * const SAActionDisplay = @"DISPLAY"; | |
6 | NSString * const SAActionEmail = @"EMAIL"; | |
7 | NSString * const SAActionProcedure = @"PROCEDURE"; | |
8 | NSString * const SAActionSound = @"AUDIO"; | |
9 | ||
10 | @implementation SAAlarm | |
11 | - (void)dealloc | |
12 | { | |
13 | DESTROY(_absoluteTrigger); | |
14 | DESTROY(_action); | |
15 | DESTROY(_emailaddress); | |
16 | DESTROY(_sound); | |
17 | DESTROY(_url); | |
18 | [super dealloc]; | |
19 | } | |
20 | ||
21 | - (id)init | |
22 | { | |
23 | self = [super init]; | |
24 | _absoluteTrigger = nil; | |
25 | _relativeTrigger = 0; | |
26 | _emailaddress = nil; | |
27 | _sound = nil; | |
28 | _url = nil; | |
29 | _element = nil; | |
30 | return self; | |
31 | } | |
32 | ||
33 | + (id)alarm | |
34 | { | |
35 | return AUTORELEASE([[SAAlarm alloc] init]); | |
36 | } | |
37 | ||
38 | - (BOOL)isAbsoluteTrigger | |
39 | { | |
40 | return _absoluteTrigger != nil; | |
41 | } | |
42 | ||
43 | - (Date *)absoluteTrigger | |
44 | { | |
45 | return _absoluteTrigger; | |
46 | } | |
47 | ||
48 | - (void)setAbsoluteTrigger:(Date *)trigger | |
49 | { | |
50 | ASSIGNCOPY(_absoluteTrigger, trigger); | |
51 | _relativeTrigger = 0; | |
52 | } | |
53 | ||
54 | - (NSTimeInterval)relativeTrigger | |
55 | { | |
56 | return _relativeTrigger; | |
57 | } | |
58 | ||
59 | - (void)setRelativeTrigger:(NSTimeInterval)trigger | |
60 | { | |
61 | _relativeTrigger = trigger; | |
62 | DESTROY(_absoluteTrigger); | |
63 | } | |
64 | ||
65 | - (NSString *)action | |
66 | { | |
67 | return _action; | |
68 | } | |
69 | ||
70 | - (void)setAction:(NSString *)action | |
71 | { | |
72 | ASSIGN(_action, action); | |
73 | } | |
74 | ||
75 | - (NSString *)emailAddress | |
76 | { | |
77 | return _emailaddress; | |
78 | } | |
79 | ||
80 | - (void)setEmailAddress:(NSString *)emailAddress | |
81 | { | |
82 | ASSIGN(_emailaddress, emailAddress); | |
83 | DESTROY(_sound); | |
84 | DESTROY(_url); | |
85 | [self setAction:SAActionEmail]; | |
86 | } | |
87 | ||
88 | - (NSString *)sound | |
89 | { | |
90 | return _sound; | |
91 | } | |
92 | ||
93 | - (void)setSound:(NSString *)sound | |
94 | { | |
95 | ASSIGN(_sound, sound); | |
96 | DESTROY(_emailaddress); | |
97 | DESTROY(_url); | |
98 | [self setAction:SAActionSound]; | |
99 | } | |
100 | ||
101 | - (NSURL *)url | |
102 | { | |
103 | return _url; | |
104 | } | |
105 | ||
106 | - (void)setUrl:(NSURL *)url | |
107 | { | |
108 | ASSIGN(_url, url); | |
109 | DESTROY(_emailaddress); | |
110 | DESTROY(_sound); | |
111 | [self setAction:SAActionProcedure]; | |
112 | } | |
113 | ||
114 | - (int)repeatCount | |
115 | { | |
116 | return _repeatCount; | |
117 | } | |
118 | ||
119 | - (void)setRepeatCount:(int)count | |
120 | { | |
121 | _repeatCount = count; | |
122 | } | |
123 | ||
124 | - (NSTimeInterval)repeatInterval | |
125 | { | |
126 | return _repeatInterval; | |
127 | } | |
128 | ||
129 | - (void)setRepeatInterval:(NSTimeInterval)interval | |
130 | { | |
131 | _repeatInterval = interval; | |
132 | } | |
133 | ||
134 | - (Element *)element | |
135 | { | |
136 | return _element; | |
137 | } | |
138 | ||
139 | - (void)setElement:(Element *)element | |
140 | { | |
141 | _element = element; | |
142 | } | |
143 | ||
144 | - (Date *)triggerDateRelativeTo:(Date *)date | |
145 | { | |
146 | return [Date dateWithTimeInterval:_relativeTrigger sinceDate:date]; | |
147 | } | |
148 | ||
149 | - (NSString *)description | |
150 | { | |
151 | if ([self isAbsoluteTrigger]) | |
152 | return [NSString stringWithFormat:@"Absolute trigger set to %@ repeat %d interval %f", [_absoluteTrigger description], _repeatCount, _repeatInterval]; | |
153 | return [NSString stringWithFormat:@"Relative trigger delay %f repeat %d interval %f", _relativeTrigger, _repeatCount, _repeatInterval]; | |
154 | } | |
155 | @end |
16 | 16 | + (SelectionManager *)globalManager; |
17 | 17 | - (int)count; |
18 | 18 | - (int)copiedCount; |
19 | - (void)add:(id)object; | |
20 | - (void)set:(id)object; | |
19 | - (void)select:(id)object; | |
21 | 20 | - (void)clear; |
22 | 21 | - (id)lastObject; |
23 | 22 | - (void)copySelection; |
0 | 0 | #import <Foundation/Foundation.h> |
1 | #import <AppKit/AppKit.h> | |
1 | 2 | #import "SelectionManager.h" |
2 | 3 | |
3 | 4 | static SelectionManager *singleton; |
43 | 44 | return [_copyarea count]; |
44 | 45 | } |
45 | 46 | |
46 | - (void)add:(id)object | |
47 | - (void)select:(id)object | |
47 | 48 | { |
48 | [_objects addObject:object]; | |
49 | } | |
50 | ||
51 | - (void)set:(id)object | |
52 | { | |
53 | [_objects removeAllObjects]; | |
54 | [_objects addObject:object]; | |
49 | if (!([[NSApp currentEvent] modifierFlags] & NSControlKeyMask)) | |
50 | [_objects removeAllObjects]; | |
51 | if (![_objects containsObject:object]) | |
52 | [_objects addObject:object]; | |
55 | 53 | } |
56 | 54 | |
57 | 55 | - (void)clear |
1 | 1 | ApplicationDescription = "Simple agenda and calendar application"; |
2 | 2 | ApplicationIcon = Calendar.tiff; |
3 | 3 | ApplicationName = SimpleAgenda; |
4 | ApplicationRelease = 0.41; | |
4 | ApplicationRelease = 0.42.2; | |
5 | 5 | Authors = ( |
6 | 6 | "Philippe Roussel <p.o.roussel@free.fr>" |
7 | 7 | ); |
8 | Copyright = "Copyright (C) 2007-2010"; | |
8 | Copyright = "Copyright (C) 2007-2012"; | |
9 | 9 | CopyrightDescription = "Released under GPL Version 2 or any later version"; |
10 | FullVersionID = 0.41; | |
10 | FullVersionID = 0.42.2; | |
11 | 11 | NSExecutable = SimpleAgenda; |
12 | 12 | NSIcon = Calendar.tiff; |
13 | 13 | NSMainNibFile = Agenda.gorm; |
30 | 30 | ); |
31 | 31 | NSTypes = ( |
32 | 32 | { |
33 | NSDocumentClass = ""; | |
34 | NSHumanReadableName = ""; | |
35 | 33 | NSIcon = "ical-file.tiff"; |
36 | NSName = ""; | |
37 | NSRole = ""; | |
38 | 34 | NSUnixExtensions = ( |
39 | 35 | ics |
40 | 36 | ); |
0 | #import <AppKit/NSSound.h> | |
1 | #import "AlarmBackend.h" | |
2 | #import "Alarm.h" | |
3 | ||
4 | @interface SoundBackend : AlarmBackend | |
5 | { | |
6 | NSSound *sound; | |
7 | } | |
8 | @end | |
9 | ||
10 | static NSMutableArray *sounds; | |
11 | ||
12 | @implementation SoundBackend | |
13 | + (void)initialize | |
14 | { | |
15 | NSFileManager *fm = [NSFileManager defaultManager]; | |
16 | NSString *path, *file; | |
17 | NSArray *paths, *files; | |
18 | NSEnumerator *enumerator, *fenum; | |
19 | ||
20 | if ([SoundBackend class] == self) { | |
21 | sounds = [[NSMutableArray alloc] initWithCapacity:8]; | |
22 | paths = NSStandardLibraryPaths(); | |
23 | enumerator = [paths objectEnumerator]; | |
24 | while ((path = [enumerator nextObject])) { | |
25 | path = [path stringByAppendingPathComponent:@"/Sounds/"]; | |
26 | files = [fm directoryContentsAtPath:path]; | |
27 | if (files) { | |
28 | fenum = [files objectEnumerator]; | |
29 | while ((file = [fenum nextObject])) { | |
30 | if ([NSSound soundNamed:[file stringByDeletingPathExtension]]) | |
31 | [sounds addObject:[file stringByDeletingPathExtension]]; | |
32 | } | |
33 | } | |
34 | } | |
35 | } | |
36 | } | |
37 | ||
38 | + (NSString *)backendName | |
39 | { | |
40 | return @"Sound notification"; | |
41 | } | |
42 | ||
43 | - (enum icalproperty_action)backendType | |
44 | { | |
45 | return ICAL_ACTION_AUDIO; | |
46 | } | |
47 | ||
48 | - (id)init | |
49 | { | |
50 | self = [super init]; | |
51 | if (self) { | |
52 | sound = [NSSound soundNamed:@"Basso"]; | |
53 | if (!sound) { | |
54 | [self release]; | |
55 | self = nil; | |
56 | } | |
57 | } | |
58 | return self; | |
59 | } | |
60 | ||
61 | - (void)display:(Alarm *)alarm | |
62 | { | |
63 | [sound play]; | |
64 | } | |
65 | @end |
8 | 8 | @interface StoreManager : NSObject |
9 | 9 | { |
10 | 10 | NSMutableDictionary *_stores; |
11 | NSMutableDictionary *_cache; | |
11 | NSMutableDictionary *_dayEventsCache; | |
12 | NSMutableArray *_eventCache; | |
12 | 13 | id _defaultStore; |
13 | 14 | } |
14 | 15 | |
22 | 23 | - (void)setDefaultStore:(NSString *)name; |
23 | 24 | - (id <AgendaStore>)defaultStore; |
24 | 25 | - (NSEnumerator *)storeEnumerator; |
25 | /* FIXME : add enabledStoreEnumerator ? */ | |
26 | 26 | - (void)synchronise; |
27 | 27 | - (void)refresh; |
28 | 28 | - (id <AgendaStore>)storeContainingElement:(Element *)elt; |
29 | 29 | - (NSArray *)allEvents; |
30 | 30 | - (NSArray *)allTasks; |
31 | 31 | - (NSSet *)scheduledAppointmentsForDay:(Date *)date; |
32 | - (NSSet *)visibleAppointmentsForDay:(Date *)date; | |
33 | - (NSArray *)visibleTasks; | |
32 | 34 | @end |
67 | 67 | ConfigManager *config = [ConfigManager globalConfig]; |
68 | 68 | id store; |
69 | 69 | |
70 | self = [super init]; | |
71 | if (self) { | |
70 | if ((self = [super init])) { | |
72 | 71 | [config registerDefaults:[self defaults]]; |
73 | 72 | [[NSNotificationCenter defaultCenter] addObserver:self |
74 | 73 | selector:@selector(dataChanged:) |
91 | 90 | name:SAEnabledStatusChangedForStore |
92 | 91 | object:nil]; |
93 | 92 | _stores = [[NSMutableDictionary alloc] initWithCapacity:1]; |
94 | _cache = [[NSMutableDictionary alloc] initWithCapacity:256]; | |
93 | _dayEventsCache = [[NSMutableDictionary alloc] initWithCapacity:256]; | |
94 | _eventCache = [[NSMutableArray alloc] initWithCapacity:512]; | |
95 | 95 | /* Create user defined stores */ |
96 | 96 | storeArray = [config objectForKey:STORES]; |
97 | 97 | defaultStore = [config objectForKey:ST_DEFAULT]; |
117 | 117 | [[NSNotificationCenter defaultCenter] removeObserver:self]; |
118 | 118 | [self synchronise]; |
119 | 119 | RELEASE(_defaultStore); |
120 | [_stores release]; | |
121 | [_cache release]; | |
120 | RELEASE(_stores); | |
121 | RELEASE(_dayEventsCache); | |
122 | RELEASE(_eventCache); | |
122 | 123 | [super dealloc]; |
123 | 124 | } |
124 | 125 | |
125 | 126 | - (void)dataChanged:(NSNotification *)not |
126 | 127 | { |
127 | [_cache removeAllObjects]; | |
128 | [_dayEventsCache removeAllObjects]; | |
129 | [_eventCache removeAllObjects]; | |
128 | 130 | [[NSNotificationCenter defaultCenter] postNotificationName:SADataChangedInStoreManager object:self]; |
129 | 131 | } |
130 | 132 | |
141 | 143 | if (store) { |
142 | 144 | [_stores setObject:store forKey:name]; |
143 | 145 | NSLog(@"Added %@ to StoreManager", name); |
144 | } else | |
146 | } else { | |
145 | 147 | NSLog(@"Unable to initialize store %@", name); |
148 | } | |
146 | 149 | } |
147 | 150 | } |
148 | 151 | |
193 | 196 | id <AgendaStore> store; |
194 | 197 | |
195 | 198 | while ((store = [enumerator nextObject])) |
196 | [store read]; | |
199 | if ([store conformsToProtocol:@protocol(StoreBackend)]) | |
200 | [store read]; | |
197 | 201 | } |
198 | 202 | |
199 | 203 | - (id <AgendaStore>)storeContainingElement:(Element *)elt |
209 | 213 | |
210 | 214 | - (NSArray *)allEvents |
211 | 215 | { |
212 | NSMutableArray *all = [NSMutableArray arrayWithCapacity:128]; | |
213 | NSEnumerator *enumerator = [_stores objectEnumerator]; | |
214 | id <AgendaStore> store; | |
215 | ||
216 | while ((store = [enumerator nextObject])) | |
217 | if ([store enabled] && [store displayed]) | |
218 | [all addObjectsFromArray:[store events]]; | |
216 | NSEnumerator *enumerator; | |
217 | id <AgendaStore> store; | |
218 | ||
219 | if ([_eventCache count]) | |
220 | return _eventCache; | |
221 | enumerator = [_stores objectEnumerator]; | |
222 | while ((store = [enumerator nextObject])) | |
223 | if ([store enabled]) | |
224 | [_eventCache addObjectsFromArray:[store events]]; | |
225 | return _eventCache; | |
226 | } | |
227 | ||
228 | - (NSArray *)allTasks | |
229 | { | |
230 | NSMutableArray *all = [NSMutableArray arrayWithCapacity:32]; | |
231 | NSEnumerator *enumerator = [_stores objectEnumerator]; | |
232 | id <AgendaStore> store; | |
233 | ||
234 | while ((store = [enumerator nextObject])) | |
235 | if ([store enabled]) | |
236 | [all addObjectsFromArray:[store tasks]]; | |
219 | 237 | return all; |
220 | 238 | } |
221 | 239 | |
222 | - (NSArray *)allTasks; | |
223 | { | |
224 | NSMutableArray *all = [NSMutableArray arrayWithCapacity:128]; | |
240 | - (NSArray *)visibleTasks | |
241 | { | |
242 | NSMutableArray *all = [NSMutableArray arrayWithCapacity:32]; | |
225 | 243 | NSEnumerator *enumerator = [_stores objectEnumerator]; |
226 | 244 | id <AgendaStore> store; |
227 | 245 | |
238 | 256 | Event *event; |
239 | 257 | |
240 | 258 | NSAssert(date != nil, @"No date specified, am I supposed to guess ?"); |
241 | dayEvents = [_cache objectForKey:date]; | |
259 | dayEvents = [_dayEventsCache objectForKey:date]; | |
242 | 260 | if (dayEvents) |
243 | 261 | return dayEvents; |
244 | 262 | |
247 | 265 | while ((event = [enumerator nextObject])) |
248 | 266 | if ([event isScheduledForDay:date]) |
249 | 267 | [dayEvents addObject:event]; |
250 | [_cache setObject:dayEvents forKey:date]; | |
268 | [_dayEventsCache setObject:dayEvents forKey:date]; | |
251 | 269 | return dayEvents; |
252 | 270 | } |
271 | ||
272 | - (NSSet *)visibleAppointmentsForDay:(Date *)date | |
273 | { | |
274 | NSMutableSet *visible = [NSMutableSet setWithCapacity:4]; | |
275 | NSEnumerator *enumerator; | |
276 | Event *event; | |
277 | ||
278 | enumerator = [[self scheduledAppointmentsForDay:date] objectEnumerator]; | |
279 | while ((event = [enumerator nextObject])) { | |
280 | if ([[event store] displayed]) | |
281 | [visible addObject:event]; | |
282 | } | |
283 | return visible; | |
284 | } | |
253 | 285 | @end |
0 | 0 | In no particular order : |
1 | 1 | |
2 | 2 | * redesign networking |
3 | ||
4 | * alerts and user notification (visual, by mail etc) | |
5 | 3 | |
6 | 4 | * month view |
7 | 5 |
4 | 4 | |
5 | 5 | enum taskState |
6 | 6 | { |
7 | TK_NONE = 0, | |
8 | TK_INPROCESS, | |
9 | TK_COMPLETED, | |
10 | TK_CANCELED | |
7 | TK_NONE = 0, | |
8 | TK_INPROCESS, | |
9 | TK_COMPLETED, | |
10 | TK_CANCELED, | |
11 | TK_NEEDSACTION | |
11 | 12 | }; |
12 | 13 | |
13 | 14 | @interface Task : Element |
14 | 15 | { |
15 | 16 | enum taskState _state; |
16 | Date *_completionDate; | |
17 | Date *_dueDate; | |
17 | 18 | } |
18 | 19 | |
19 | 20 | + (NSArray *)stateNamesArray; |
20 | 21 | - (enum taskState)state; |
21 | 22 | - (NSString *)stateAsString; |
22 | 23 | - (void)setState:(enum taskState)state; |
23 | - (Date *)completionDate; | |
24 | - (void)setCompletionDate:(Date *)cd; | |
24 | - (Date *)dueDate; | |
25 | - (void)setDueDate:(Date *)cd; | |
25 | 26 | @end |
26 | 27 | |
27 | 28 | @interface Task(iCalendar) |
5 | 5 | { |
6 | 6 | [super encodeWithCoder:coder]; |
7 | 7 | [coder encodeInt:_state forKey:@"state"]; |
8 | if (_completionDate != nil) | |
9 | [coder encodeObject:_completionDate forKey:@"completion"]; | |
8 | if (_dueDate != nil) | |
9 | [coder encodeObject:_dueDate forKey:@"dueDate"]; | |
10 | 10 | } |
11 | 11 | - (id)initWithCoder:(NSCoder *)coder |
12 | 12 | { |
13 | 13 | [super initWithCoder:coder]; |
14 | 14 | _state = [coder decodeIntForKey:@"state"]; |
15 | if ([coder containsValueForKey:@"completion"]) | |
16 | _completionDate = [[coder decodeObjectForKey:@"completion"] retain]; | |
15 | if ([coder containsValueForKey:@"dueDate"]) | |
16 | _dueDate = [[coder decodeObjectForKey:@"dueDate"] retain]; | |
17 | 17 | else |
18 | _completionDate = nil; | |
18 | _dueDate = nil; | |
19 | 19 | return self; |
20 | 20 | } |
21 | 21 | @end |
25 | 25 | @implementation Task |
26 | 26 | + (void)initialize |
27 | 27 | { |
28 | if (stateName == nil) | |
29 | stateName = [[NSArray alloc] initWithObjects:_(@"None"), _(@"Started"), _(@"Completed"), _(@"Canceled"), nil]; | |
28 | if ([Task class] == self) | |
29 | stateName = [[NSArray alloc] initWithObjects:_(@"None"), _(@"Started"), _(@"Completed"), _(@"Canceled"), _(@"Needs action"), nil]; | |
30 | 30 | } |
31 | 31 | |
32 | 32 | + (NSArray *)stateNamesArray |
36 | 36 | |
37 | 37 | - (id)init |
38 | 38 | { |
39 | self = [super init]; | |
40 | if (self) { | |
39 | if ((self = [super init])) { | |
41 | 40 | _state = TK_NONE; |
42 | _completionDate = nil; | |
41 | _dueDate = nil; | |
43 | 42 | } |
44 | 43 | return self; |
45 | 44 | } |
45 | ||
46 | 46 | - (void)dealloc |
47 | 47 | { |
48 | RELEASE(_completionDate); | |
48 | RELEASE(_dueDate); | |
49 | 49 | [super dealloc]; |
50 | 50 | } |
51 | ||
51 | 52 | - (enum taskState)state |
52 | 53 | { |
53 | 54 | return _state; |
54 | 55 | } |
56 | ||
55 | 57 | - (NSString *)stateAsString |
56 | 58 | { |
57 | 59 | return [stateName objectAtIndex:_state]; |
58 | 60 | } |
61 | ||
59 | 62 | - (void)setState:(enum taskState)state |
60 | 63 | { |
61 | 64 | _state = state; |
62 | if (state == TK_COMPLETED) | |
63 | [self setCompletionDate:[Date today]]; | |
64 | else | |
65 | [self setCompletionDate:nil]; | |
66 | 65 | } |
67 | - (Date *)completionDate | |
66 | ||
67 | - (Date *)dueDate | |
68 | 68 | { |
69 | return _completionDate; | |
69 | return _dueDate; | |
70 | 70 | } |
71 | - (void)setCompletionDate:(Date *)cd | |
71 | ||
72 | - (void)setDueDate:(Date *)cd | |
72 | 73 | { |
73 | if (_completionDate != nil) | |
74 | RELEASE(_completionDate); | |
74 | DESTROY(_dueDate); | |
75 | 75 | if (cd != nil) |
76 | ASSIGNCOPY(_completionDate, cd); | |
77 | else | |
78 | _completionDate = nil; | |
76 | ASSIGNCOPY(_dueDate, cd); | |
79 | 77 | } |
78 | ||
79 | - (Date *)nextActivationDate | |
80 | { | |
81 | /* FIXME */ | |
82 | return _dueDate; | |
83 | } | |
84 | ||
80 | 85 | - (NSString *)description |
81 | 86 | { |
82 | 87 | return [self summary]; |
88 | 93 | { |
89 | 94 | icalproperty *prop; |
90 | 95 | |
91 | self = [super initWithICalComponent:ic]; | |
92 | if (self == nil) | |
93 | return nil; | |
94 | prop = icalcomponent_get_first_property(ic, ICAL_STATUS_PROPERTY); | |
95 | if (prop) { | |
96 | switch (icalproperty_get_status(prop)) | |
97 | { | |
98 | case ICAL_STATUS_COMPLETED: | |
99 | [self setState:TK_COMPLETED]; | |
100 | break; | |
101 | case ICAL_STATUS_CANCELLED: | |
102 | [self setState:TK_CANCELED]; | |
103 | break; | |
104 | case ICAL_STATUS_INPROCESS: | |
105 | [self setState:TK_INPROCESS]; | |
106 | break; | |
107 | default: | |
108 | [self setState:TK_NONE]; | |
109 | } | |
96 | if ((self = [super initWithICalComponent:ic])) { | |
97 | prop = icalcomponent_get_first_property(ic, ICAL_STATUS_PROPERTY); | |
98 | if (prop) { | |
99 | switch (icalproperty_get_status(prop)) | |
100 | { | |
101 | case ICAL_STATUS_COMPLETED: | |
102 | [self setState:TK_COMPLETED]; | |
103 | break; | |
104 | case ICAL_STATUS_CANCELLED: | |
105 | [self setState:TK_CANCELED]; | |
106 | break; | |
107 | case ICAL_STATUS_INPROCESS: | |
108 | [self setState:TK_INPROCESS]; | |
109 | break; | |
110 | case ICAL_STATUS_NEEDSACTION: | |
111 | [self setState:TK_NEEDSACTION]; | |
112 | break; | |
113 | default: | |
114 | [self setState:TK_NONE]; | |
115 | } | |
116 | } | |
117 | else | |
118 | [self setState:TK_NONE]; | |
119 | prop = icalcomponent_get_first_property(ic, ICAL_DUE_PROPERTY); | |
120 | if (prop) | |
121 | [self setDueDate:AUTORELEASE([[Date alloc] initWithICalTime:icalproperty_get_due(prop)])]; | |
110 | 122 | } |
111 | else | |
112 | [self setState:TK_NONE]; | |
113 | 123 | return self; |
114 | 124 | } |
115 | 125 | |
116 | - (icalcomponent *)asICalComponent | |
117 | { | |
118 | icalcomponent *ic = icalcomponent_new(ICAL_VTODO_COMPONENT); | |
119 | if (!ic) { | |
120 | NSLog(@"Couldn't create iCalendar component"); | |
121 | return NULL; | |
122 | } | |
123 | [self updateICalComponent:ic]; | |
124 | return ic; | |
125 | } | |
126 | ||
127 | static int statusCorr[] = {ICAL_STATUS_NONE, ICAL_STATUS_INPROCESS, ICAL_STATUS_COMPLETED, ICAL_STATUS_CANCELLED}; | |
126 | static int statusCorr[] = {ICAL_STATUS_NONE, ICAL_STATUS_INPROCESS, ICAL_STATUS_COMPLETED, ICAL_STATUS_CANCELLED, ICAL_STATUS_NEEDSACTION}; | |
128 | 127 | |
129 | 128 | - (BOOL)updateICalComponent:(icalcomponent *)ic |
130 | 129 | { |
132 | 131 | return NO; |
133 | 132 | [self deleteProperty:ICAL_STATUS_PROPERTY fromComponent:ic]; |
134 | 133 | icalcomponent_add_property(ic, icalproperty_new_status(statusCorr[[self state]])); |
134 | [self deleteProperty:ICAL_DUE_PROPERTY fromComponent:ic]; | |
135 | if (_dueDate) | |
136 | icalcomponent_add_property(ic, icalproperty_new_due([_dueDate UTCICalTime])); | |
135 | 137 | return YES; |
136 | 138 | } |
137 | 139 |
11 | 11 | id store; |
12 | 12 | id state; |
13 | 13 | id ok; |
14 | id toggleDueDate; | |
15 | id dueDate; | |
16 | id dueTime; | |
17 | id alarms; | |
14 | 18 | Task *_task; |
19 | NSArray *_modifiedAlarms; | |
15 | 20 | } |
16 | 21 | |
17 | 22 | + (TaskEditor *)editorForTask:(Task *)task; |
18 | 23 | - (void)validate:(id)sender; |
19 | 24 | - (void)cancel:(id)sender; |
25 | - (void)editAlarms:(id)sender; | |
26 | - (void)toggleDueDate:(id)sender; | |
20 | 27 | @end |
3 | 3 | #import "TaskEditor.h" |
4 | 4 | #import "StoreManager.h" |
5 | 5 | #import "Task.h" |
6 | #import "AlarmEditor.h" | |
7 | #import "HourFormatter.h" | |
8 | #import "Date.h" | |
6 | 9 | |
7 | 10 | static NSMutableDictionary *editors; |
8 | 11 | |
15 | 18 | |
16 | 19 | - (id)init |
17 | 20 | { |
18 | self = [super init]; | |
19 | if (self) { | |
20 | if (![NSBundle loadNibNamed:@"Task" owner:self]) | |
21 | return nil; | |
21 | HourFormatter *formatter; | |
22 | NSDateFormatter *dateFormatter; | |
23 | ||
24 | if (![NSBundle loadNibNamed:@"Task" owner:self]) | |
25 | return nil; | |
26 | if ((self = [super init])) { | |
27 | formatter = AUTORELEASE([[HourFormatter alloc] init]); | |
28 | dateFormatter = AUTORELEASE([[NSDateFormatter alloc] initWithDateFormat:[[NSUserDefaults standardUserDefaults] objectForKey:NSShortDateFormatString] allowNaturalLanguage:NO]); | |
29 | [dueTime setFormatter:formatter]; | |
30 | [dueDate setFormatter:dateFormatter]; | |
22 | 31 | } |
23 | 32 | return self; |
24 | 33 | } |
33 | 42 | self = [self init]; |
34 | 43 | if (self) { |
35 | 44 | ASSIGN(_task, task); |
45 | ASSIGNCOPY(_modifiedAlarms, [task alarms]); | |
36 | 46 | [summary setStringValue:[task summary]]; |
37 | 47 | |
38 | 48 | [[description textStorage] deleteCharactersInRange:NSMakeRange(0, [[description textStorage] length])]; |
55 | 65 | [state addItemsWithTitles:[Task stateNamesArray]]; |
56 | 66 | [state selectItemWithTitle:[task stateAsString]]; |
57 | 67 | [ok setEnabled:[self canBeModified]]; |
68 | if ([task dueDate]) { | |
69 | [dueDate setObjectValue:[[task dueDate] calendarDate]]; | |
70 | [dueTime setIntValue:[[task dueDate] hourOfDay] * 3600 + [[task dueDate] minuteOfHour] * 60]; | |
71 | [toggleDueDate setState:YES]; | |
72 | } | |
73 | [dueDate setEnabled:[toggleDueDate state]]; | |
74 | [dueTime setEnabled:[toggleDueDate state]]; | |
58 | 75 | [window makeKeyAndOrderFront:self]; |
59 | 76 | } |
60 | 77 | return self; |
62 | 79 | |
63 | 80 | - (void)dealloc |
64 | 81 | { |
65 | RELEASE(_task); | |
66 | [super dealloc]; | |
82 | RELEASE(_task); | |
83 | RELEASE(_modifiedAlarms); | |
84 | [super dealloc]; | |
67 | 85 | } |
68 | 86 | |
69 | 87 | + (void)initialize |
89 | 107 | StoreManager *sm = [StoreManager globalManager]; |
90 | 108 | id <MemoryStore> originalStore = [_task store]; |
91 | 109 | id <MemoryStore> aStore; |
110 | Date *date; | |
92 | 111 | |
93 | 112 | [_task setSummary:[summary stringValue]]; |
94 | 113 | [_task setText:[[description textStorage] copy]]; |
95 | 114 | [_task setState:[state indexOfSelectedItem]]; |
115 | [_task setAlarms:_modifiedAlarms]; | |
116 | if ([toggleDueDate state]) { | |
117 | date = [Date dateWithCalendarDate:[dueDate objectValue] withTime:NO]; | |
118 | date = [Date dateWithTimeInterval:[dueTime intValue] sinceDate:date]; | |
119 | [_task setDueDate:date]; | |
120 | } else { | |
121 | [_task setDueDate:nil]; | |
122 | } | |
96 | 123 | aStore = [sm storeForName:[store titleOfSelectedItem]]; |
97 | 124 | if (!originalStore) |
98 | 125 | [aStore add:_task]; |
102 | 129 | [originalStore remove:_task]; |
103 | 130 | [aStore add:_task]; |
104 | 131 | } |
132 | [window close]; | |
105 | 133 | [editors removeObjectForKey:[_task UID]]; |
106 | [window close]; | |
107 | 134 | } |
108 | 135 | |
109 | 136 | - (void)cancel:(id)sender |
110 | 137 | { |
138 | [window close]; | |
111 | 139 | [editors removeObjectForKey:[_task UID]]; |
112 | [window close]; | |
140 | } | |
141 | ||
142 | - (void)editAlarms:(id)sender | |
143 | { | |
144 | NSArray *alarmArray; | |
145 | ||
146 | alarmArray = [AlarmEditor editAlarms:_modifiedAlarms]; | |
147 | if (alarmArray) | |
148 | ASSIGN(_modifiedAlarms, alarmArray); | |
149 | [window makeKeyAndOrderFront:self]; | |
150 | } | |
151 | ||
152 | - (void)toggleDueDate:(id)sender | |
153 | { | |
154 | Date *date; | |
155 | ||
156 | [dueDate setEnabled:[toggleDueDate state]]; | |
157 | [dueTime setEnabled:[toggleDueDate state]]; | |
158 | if ([toggleDueDate state]) { | |
159 | date = [Date now]; | |
160 | [date changeDayBy:7]; | |
161 | [dueDate setObjectValue:[date calendarDate]]; | |
162 | [dueTime setIntValue:[date hourOfDay] * 3600 + [date minuteOfHour] * 60]; | |
163 | } else { | |
164 | [dueDate setObjectValue:nil]; | |
165 | [dueTime setObjectValue:nil]; | |
166 | } | |
113 | 167 | } |
114 | 168 | |
115 | 169 | - (BOOL)textView:(NSTextView *)aTextView doCommandBySelector:(SEL)aSelector |
15 | 15 | NSString *_user; |
16 | 16 | NSString *_password; |
17 | 17 | NSData *_data; |
18 | BOOL _debug; | |
19 | 18 | } |
20 | 19 | |
21 | 20 | - (id)initWithURL:(NSURL *)url; |
22 | 21 | - (id)initWithURL:(NSURL *)anUrl authFromURL:(NSURL *)parent; |
23 | - (void)setDebug:(BOOL)debug; | |
24 | 22 | - (BOOL)readable; |
25 | 23 | /* WARNING Destructive */ |
26 | 24 | - (BOOL)writableWithData:(NSData *)data; |
37 | 35 | @interface NSURL(SimpleAgenda) |
38 | 36 | + (BOOL)stringIsValidURL:(NSString *)string; |
39 | 37 | + (NSURL *)URLWithString:(NSString *)string possiblyRelativeToURL:(NSURL *)base; |
40 | - (NSURL *)redirection; | |
38 | - (NSString *)anonymousAbsoluteString; | |
41 | 39 | @end |
42 | 40 | |
43 | 41 | @interface GSXMLDocument(SimpleAgenda) |
2 | 2 | #import "WebDAVResource.h" |
3 | 3 | |
4 | 4 | @implementation WebDAVResource |
5 | - (void)debugLog:(NSString *)format,... | |
6 | { | |
7 | va_list ap; | |
8 | if (_debug) { | |
9 | va_start(ap, format); | |
10 | NSLogv(format, ap); | |
11 | va_end(ap); | |
12 | } | |
13 | } | |
14 | 5 | - (void)dealloc |
15 | 6 | { |
16 | 7 | DESTROY(_user); |
19 | 10 | DESTROY(_url); |
20 | 11 | DESTROY(_lastModified); |
21 | 12 | DESTROY(_data); |
13 | DESTROY(_reason); | |
14 | DESTROY(_etag); | |
22 | 15 | [super dealloc]; |
23 | 16 | } |
24 | 17 | |
25 | - (void)fixURLScheme | |
26 | { | |
27 | if ([[_url scheme] hasPrefix:@"webcal"]) | |
28 | ASSIGN(_url, [NSURL URLWithString:[[_url absoluteString] stringByReplacingString:@"webcal" withString:@"http"]]); | |
18 | - (void)setURL:(NSURL *)anURL | |
19 | { | |
20 | if ([[anURL scheme] hasPrefix:@"webcal"]) | |
21 | ASSIGN(_url, [NSURL URLWithString:[[anURL absoluteString] stringByReplacingString:@"webcal" withString:@"http"]]); | |
22 | else | |
23 | ASSIGN(_url, anURL); | |
24 | _handleClass = [NSURLHandle URLHandleClassForURL:_url]; | |
25 | if ([_url user]) | |
26 | ASSIGN(_user, [_url user]); | |
27 | if ([_url password]) | |
28 | ASSIGN(_password, [_url password]); | |
29 | 29 | } |
30 | 30 | |
31 | 31 | - (id)initWithURL:(NSURL *)anUrl |
32 | 32 | { |
33 | 33 | self = [super init]; |
34 | 34 | if (self) { |
35 | /* FIXME : this causes a bogus GET for every resource creation */ | |
36 | _url = [anUrl redirection]; | |
37 | [self fixURLScheme]; | |
38 | _handleClass = [NSURLHandle URLHandleClassForURL:_url]; | |
39 | 35 | _lock = [NSLock new]; |
40 | _user = nil; | |
41 | _password = nil; | |
42 | 36 | _data = nil; |
43 | _debug = NO; | |
37 | [self setURL:anUrl]; | |
44 | 38 | } |
45 | 39 | return self; |
46 | 40 | } |
53 | 47 | ASSIGN(_password, [parent password]); |
54 | 48 | } |
55 | 49 | return self; |
56 | } | |
57 | ||
58 | - (void)setDebug:(BOOL)debug | |
59 | { | |
60 | _debug = debug; | |
61 | 50 | } |
62 | 51 | |
63 | 52 | /* FIXME : ugly hack to work around NSURLHandle shortcomings */ |
84 | 73 | NSURLHandle *handle; |
85 | 74 | |
86 | 75 | [_lock lock]; |
76 | restart: | |
87 | 77 | handle = [[_handleClass alloc] initWithURL:_url cached:NO]; |
88 | 78 | [handle writeProperty:method forKey:GSHTTPPropertyMethodKey]; |
89 | 79 | if (attributes) { |
97 | 87 | [handle writeProperty:[NSString stringWithFormat:@"([%@])", _etag] forKey:@"If"]; |
98 | 88 | if (body) |
99 | 89 | [handle writeData:body]; |
100 | [self debugLog:@"%@ %@ (%@)", [_url absoluteString], method, [attributes description]]; | |
90 | NSDebugLog(@"%@ %@ (%@)", [_url anonymousAbsoluteString], method, [attributes description]); | |
101 | 91 | DESTROY(_data); |
102 | 92 | data = [handle resourceData]; |
103 | 93 | /* FIXME : this is more than ugly */ |
105 | 95 | _httpStatus = data ? 200 : 199; |
106 | 96 | else |
107 | 97 | _httpStatus = [[handle propertyForKeyIfAvailable:NSHTTPPropertyStatusCodeKey] intValue]; |
108 | if (data) | |
109 | [self debugLog:@"%@ =>\n%@", method, AUTORELEASE([[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding])]; | |
110 | else | |
111 | [self debugLog:@"%@ status %d", method, _httpStatus]; | |
98 | ||
99 | /* FIXME : why do we have to check for httpStatus == 0 */ | |
100 | if ((_httpStatus == 0 ||_httpStatus == 301 || _httpStatus == 302) && [handle propertyForKey:@"Location"] != nil) { | |
101 | NSDebugLog(@"Redirection to %@", [handle propertyForKey:@"Location"]); | |
102 | [self setURL:[NSURL URLWithString:[handle propertyForKey:@"Location"]]]; | |
103 | goto restart; | |
104 | } | |
105 | ||
106 | NSDebugLog(@"%@ status %d", method, _httpStatus); | |
112 | 107 | property = [handle propertyForKeyIfAvailable:NSHTTPPropertyStatusReasonKey]; |
113 | 108 | if (property) |
114 | 109 | ASSIGN(_reason, property); |
232 | 227 | result = (GSXPathString *)[xpc evaluateExpression:GETLASTMODIFIED]; |
233 | 228 | if (result) |
234 | 229 | ASSIGN(_lastModified, [result stringValue]); |
230 | RELEASE(xpc); | |
235 | 231 | } |
236 | 232 | } |
237 | 233 | } |
245 | 241 | |
246 | 242 | NS_DURING |
247 | 243 | { |
248 | url = [NSURL URLWithString:string]; | |
249 | valid = url ? YES : NO; | |
244 | /* We want an absolute URL */ | |
245 | if ((url = [NSURL URLWithString:string]) && [url scheme]) | |
246 | valid = YES; | |
250 | 247 | } |
251 | 248 | NS_HANDLER |
252 | 249 | { |
261 | 258 | if ([NSURL stringIsValidURL:string]) |
262 | 259 | url = [NSURL URLWithString:string]; |
263 | 260 | else |
264 | url = [NSURL URLWithString:[[base absoluteString] stringByReplacingString:[base path] withString:string]]; | |
261 | url = [NSURL URLWithString:string relativeToURL:base]; | |
265 | 262 | return url; |
266 | 263 | } |
267 | - (NSURL *)redirection | |
268 | { | |
269 | NSString *location; | |
270 | ||
271 | location = [self propertyForKey:@"Location"]; | |
272 | if (location) { | |
273 | NSLog(@"Redirected to %@", location); | |
274 | return [[NSURL URLWithString:location] redirection]; | |
275 | } | |
276 | return [self copy]; | |
264 | - (NSString *)anonymousAbsoluteString | |
265 | { | |
266 | NSString *as = [self absoluteString]; | |
267 | ||
268 | if (![self user] && ![self password]) | |
269 | return as; | |
270 | return [as stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"%@:%@@", [self user], [self password]] | |
271 | withString:@""]; | |
277 | 272 | } |
278 | 273 | @end |
279 | 274 |
19 | 19 | #define RADIUS 5 |
20 | 20 | - (void)drawRect:(NSRect)rect |
21 | 21 | { |
22 | NSPoint point; | |
22 | 23 | NSString *title; |
23 | 24 | NSString *label; |
24 | 25 | Date *start = [_apt startDate]; |
59 | 60 | PSsetlinewidth(CEC_BORDERSIZE); |
60 | 61 | PSstroke(); |
61 | 62 | [label drawInRect:TextRect(rect) withAttributes:textAttributes]; |
62 | if ([_apt rrule] != nil) | |
63 | point = NSMakePoint(rect.size.width - 18, rect.size.height - 16); | |
64 | if ([_apt rrule]) { | |
63 | 65 | [[self repeatImage] compositeToPoint:NSMakePoint(rect.size.width - 18, rect.size.height - 18) operation:NSCompositeSourceOver]; |
66 | point = NSMakePoint(rect.size.width - 30, rect.size.height - 16); | |
67 | } | |
68 | if ([_apt hasAlarms]) | |
69 | [[self alarmImage] compositeToPoint:point operation:NSCompositeSourceOver]; | |
64 | 70 | } |
65 | 71 | |
66 | 72 | - (void)mouseDown:(NSEvent *)theEvent |
222 | 228 | { |
223 | 229 | if ([delegate respondsToSelector:@selector(viewSelectDate:)]) |
224 | 230 | [delegate viewSelectDate:[(WeekDayView *)[aptv superview] day]]; |
225 | [[SelectionManager globalManager] set:[aptv appointment]]; | |
231 | [[SelectionManager globalManager] select:[aptv appointment]]; | |
226 | 232 | if ([delegate respondsToSelector:@selector(viewSelectEvent:)]) |
227 | 233 | [delegate viewSelectEvent:[aptv appointment]]; |
228 | 234 | [self setNeedsDisplay:YES]; |
238 | 244 | enumerator = [[self subviews] objectEnumerator]; |
239 | 245 | while ((wdv = [enumerator nextObject])) { |
240 | 246 | [wdv clear]; |
241 | events = [[StoreManager globalManager] scheduledAppointmentsForDay:[wdv day]]; | |
247 | events = [[StoreManager globalManager] visibleAppointmentsForDay:[wdv day]]; | |
242 | 248 | enm = [events objectEnumerator]; |
243 | 249 | while ((apt = [enm nextObject])) |
244 | 250 | [wdv addAppointment:apt]; |
3 | 3 | GNUSTEP_SH_EXPORT_ALL_VARIABLES=yes |
4 | 4 | . "$GNUSTEP_MAKEFILES/GNUstep.sh" |
5 | 5 | unset GNUSTEP_SH_EXPORT_ALL_VARIABLES |
6 | ||
7 | # For backwards compatibility, define GNUSTEP_SYSTEM_HEADERS from | |
8 | # GNUSTEP_SYSTEM_ROOT if not set yet. | |
9 | if test x"$GNUSTEP_SYSTEM_HEADERS" = x""; then | |
10 | GNUSTEP_SYSTEM_HEADERS="$GNUSTEP_SYSTEM_ROOT/Library/Headers" | |
11 | fi | |
12 | if test x"$GNUSTEP_LOCAL_HEADERS" = x""; then | |
13 | GNUSTEP_LOCAL_HEADERS="$GNUSTEP_LOCAL_ROOT/Library/Headers" | |
14 | fi | |
15 | ||
16 | if test x"$GNUSTEP_SYSTEM_LIBRARIES" = x""; then | |
17 | GNUSTEP_SYSTEM_LIBRARIES="$GNUSTEP_SYSTEM_ROOT/Library/Libraries" | |
18 | fi | |
19 | if test x"$GNUSTEP_LOCAL_LIBRARIES" = x""; then | |
20 | GNUSTEP_LOCAL_LIBRARIES="$GNUSTEP_LOCAL_ROOT/Library/Libraries" | |
21 | fi | |
22 | 6 | |
23 | OLD_CFLAGS=$CFLAGS | |
24 | CFLAGS="-xobjective-c" | |
25 | PREFIX="-I" | |
26 | OLD_CPPFLAGS="$CPPFLAGS" | |
27 | CPPFLAGS="$CPPFLAGS $PREFIX$GNUSTEP_SYSTEM_HEADERS $PREFIX$GNUSTEP_LOCAL_HEADERS" | |
7 | OLD_CFLAGS=$CFLAGS | |
8 | CFLAGS="-xobjective-c " | |
9 | CFLAGS+=`gnustep-config --objc-flags` | |
28 | 10 | |
29 | 11 | OLD_LDFLAGS="$LD_FLAGS" |
30 | PREFIX="-L" | |
31 | LDFLAGS="$LDFLAGS $PREFIX$GNUSTEP_SYSTEM_LIBRARIES $PREFIX$GNUSTEP_LOCAL_LIBRARIES" | |
12 | LDFLAGS=`gnustep-config --objc-libs` | |
32 | 13 | OLD_LIBS="$LIBS" |
33 | LIBS="-lgnustep-base" | |
14 | LIBS="-lgnustep-base -lAddresses" | |
34 | 15 | AC_MSG_CHECKING([for Addresses framework]) |
35 | ||
36 | LIBS="$LIBS -lAddresses" | |
37 | 16 | |
38 | 17 | AC_LINK_IFELSE( |
39 | 18 | AC_LANG_PROGRAM( |
46 | 25 | have_addresses=no) |
47 | 26 | |
48 | 27 | LIBS="$OLD_LIBS" |
49 | CPPFLAGS="$OLD_CPPFLAGS" | |
50 | 28 | LDFLAGS="$OLD_LDFLAGS" |
51 | 29 | CFLAGS="$OLD_CFLAGS" |
52 | 30 | |
53 | 31 | AC_MSG_RESULT($have_addresses) |
54 | 32 | ]) |
33 | ||
34 | AC_DEFUN(AC_CHECK_DBUSKIT,[ | |
35 | ||
36 | GNUSTEP_SH_EXPORT_ALL_VARIABLES=yes | |
37 | . "$GNUSTEP_MAKEFILES/GNUstep.sh" | |
38 | unset GNUSTEP_SH_EXPORT_ALL_VARIABLES | |
39 | ||
40 | OLD_CFLAGS=$CFLAGS | |
41 | CFLAGS="-xobjective-c " | |
42 | CFLAGS+=`gnustep-config --objc-flags` | |
43 | ||
44 | OLD_LDFLAGS="$LD_FLAGS" | |
45 | LDFLAGS=`gnustep-config --objc-libs` | |
46 | OLD_LIBS="$LIBS" | |
47 | LIBS="-lgnustep-base -lDBusKit" | |
48 | AC_MSG_CHECKING([for DBusKit framework]) | |
49 | ||
50 | AC_LINK_IFELSE( | |
51 | AC_LANG_PROGRAM( | |
52 | [[#import <Foundation/Foundation.h> | |
53 | #import <DBusKit/DBusKit.h>]], | |
54 | [[[[DKPort sessionBusPort]];]]), | |
55 | $1; | |
56 | have_dbuskit=yes, | |
57 | $2; | |
58 | have_dbuskit=no) | |
59 | ||
60 | LIBS="$OLD_LIBS" | |
61 | LDFLAGS="$OLD_LDFLAGS" | |
62 | CFLAGS="$OLD_CFLAGS" | |
63 | ||
64 | AC_MSG_RESULT($have_dbuskit) | |
65 | ]) |
59 | 59 | #else |
60 | 60 | #import <ical.h> |
61 | 61 | #endif |
62 | ||
63 | /* | |
64 | * Workaround a build failure found by Sergey Golovin : | |
65 | * it seems MIN and MAX macros are not always defined | |
66 | */ | |
67 | #ifndef MAX | |
68 | #import <GNUstepBase/preface.h> | |
69 | #endif |
0 | 0 | #! /bin/sh |
1 | 1 | # Guess values for system-dependent variables and create Makefiles. |
2 | # Generated by GNU Autoconf 2.64. | |
2 | # Generated by GNU Autoconf 2.67. | |
3 | # | |
3 | 4 | # |
4 | 5 | # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, |
5 | # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software | |
6 | # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software | |
6 | 7 | # Foundation, Inc. |
8 | # | |
7 | 9 | # |
8 | 10 | # This configure script is free software; the Free Software Foundation |
9 | 11 | # gives unlimited permission to copy, distribute and modify it. |
313 | 315 | test -d "$as_dir" && break |
314 | 316 | done |
315 | 317 | test -z "$as_dirs" || eval "mkdir $as_dirs" |
316 | } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" | |
318 | } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" | |
317 | 319 | |
318 | 320 | |
319 | 321 | } # as_fn_mkdir_p |
353 | 355 | fi # as_fn_arith |
354 | 356 | |
355 | 357 | |
356 | # as_fn_error ERROR [LINENO LOG_FD] | |
357 | # --------------------------------- | |
358 | # as_fn_error STATUS ERROR [LINENO LOG_FD] | |
359 | # ---------------------------------------- | |
358 | 360 | # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are |
359 | 361 | # provided, also output the error to LOG_FD, referencing LINENO. Then exit the |
360 | # script with status $?, using 1 if that was 0. | |
362 | # script with STATUS, using 1 if that was 0. | |
361 | 363 | as_fn_error () |
362 | 364 | { |
363 | as_status=$?; test $as_status -eq 0 && as_status=1 | |
364 | if test "$3"; then | |
365 | as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack | |
366 | $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 | |
365 | as_status=$1; test $as_status -eq 0 && as_status=1 | |
366 | if test "$4"; then | |
367 | as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack | |
368 | $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 | |
367 | 369 | fi |
368 | $as_echo "$as_me: error: $1" >&2 | |
370 | $as_echo "$as_me: error: $2" >&2 | |
369 | 371 | as_fn_exit $as_status |
370 | 372 | } # as_fn_error |
371 | 373 | |
523 | 525 | as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" |
524 | 526 | |
525 | 527 | |
526 | exec 7<&0 </dev/null 6>&1 | |
528 | test -n "$DJDIR" || exec 7<&0 </dev/null | |
529 | exec 6>&1 | |
527 | 530 | |
528 | 531 | # Name of the host. |
529 | # hostname on some systems (SVR3.2, Linux) returns a bogus exit status, | |
532 | # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, | |
530 | 533 | # so uname gets run too. |
531 | 534 | ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` |
532 | 535 | |
590 | 593 | |
591 | 594 | ac_subst_vars='LTLIBOBJS |
592 | 595 | LIBOBJS |
596 | additional_lib_dir | |
597 | additional_include_dir | |
598 | have_dbuskit | |
593 | 599 | have_addresses |
594 | 600 | have_libuuid |
595 | 601 | EGREP |
643 | 649 | ac_subst_files='' |
644 | 650 | ac_user_opts=' |
645 | 651 | enable_option_checking |
652 | with_ical_include | |
653 | with_ical_library | |
654 | enable_dbuskit | |
646 | 655 | ' |
647 | 656 | ac_precious_vars='build_alias |
648 | 657 | host_alias |
715 | 724 | fi |
716 | 725 | |
717 | 726 | case $ac_option in |
718 | *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; | |
719 | *) ac_optarg=yes ;; | |
727 | *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; | |
728 | *=) ac_optarg= ;; | |
729 | *) ac_optarg=yes ;; | |
720 | 730 | esac |
721 | 731 | |
722 | 732 | # Accept the important Cygnus configure options, so we can diagnose typos. |
761 | 771 | ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` |
762 | 772 | # Reject names that are not valid shell variable names. |
763 | 773 | expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && |
764 | as_fn_error "invalid feature name: $ac_useropt" | |
774 | as_fn_error $? "invalid feature name: $ac_useropt" | |
765 | 775 | ac_useropt_orig=$ac_useropt |
766 | 776 | ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` |
767 | 777 | case $ac_user_opts in |
787 | 797 | ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` |
788 | 798 | # Reject names that are not valid shell variable names. |
789 | 799 | expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && |
790 | as_fn_error "invalid feature name: $ac_useropt" | |
800 | as_fn_error $? "invalid feature name: $ac_useropt" | |
791 | 801 | ac_useropt_orig=$ac_useropt |
792 | 802 | ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` |
793 | 803 | case $ac_user_opts in |
991 | 1001 | ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` |
992 | 1002 | # Reject names that are not valid shell variable names. |
993 | 1003 | expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && |
994 | as_fn_error "invalid package name: $ac_useropt" | |
1004 | as_fn_error $? "invalid package name: $ac_useropt" | |
995 | 1005 | ac_useropt_orig=$ac_useropt |
996 | 1006 | ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` |
997 | 1007 | case $ac_user_opts in |
1007 | 1017 | ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` |
1008 | 1018 | # Reject names that are not valid shell variable names. |
1009 | 1019 | expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && |
1010 | as_fn_error "invalid package name: $ac_useropt" | |
1020 | as_fn_error $? "invalid package name: $ac_useropt" | |
1011 | 1021 | ac_useropt_orig=$ac_useropt |
1012 | 1022 | ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` |
1013 | 1023 | case $ac_user_opts in |
1037 | 1047 | | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) |
1038 | 1048 | x_libraries=$ac_optarg ;; |
1039 | 1049 | |
1040 | -*) as_fn_error "unrecognized option: \`$ac_option' | |
1041 | Try \`$0 --help' for more information." | |
1050 | -*) as_fn_error $? "unrecognized option: \`$ac_option' | |
1051 | Try \`$0 --help' for more information" | |
1042 | 1052 | ;; |
1043 | 1053 | |
1044 | 1054 | *=*) |
1046 | 1056 | # Reject names that are not valid shell variable names. |
1047 | 1057 | case $ac_envvar in #( |
1048 | 1058 | '' | [0-9]* | *[!_$as_cr_alnum]* ) |
1049 | as_fn_error "invalid variable name: \`$ac_envvar'" ;; | |
1059 | as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; | |
1050 | 1060 | esac |
1051 | 1061 | eval $ac_envvar=\$ac_optarg |
1052 | 1062 | export $ac_envvar ;; |
1064 | 1074 | |
1065 | 1075 | if test -n "$ac_prev"; then |
1066 | 1076 | ac_option=--`echo $ac_prev | sed 's/_/-/g'` |
1067 | as_fn_error "missing argument to $ac_option" | |
1077 | as_fn_error $? "missing argument to $ac_option" | |
1068 | 1078 | fi |
1069 | 1079 | |
1070 | 1080 | if test -n "$ac_unrecognized_opts"; then |
1071 | 1081 | case $enable_option_checking in |
1072 | 1082 | no) ;; |
1073 | fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;; | |
1083 | fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; | |
1074 | 1084 | *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; |
1075 | 1085 | esac |
1076 | 1086 | fi |
1093 | 1103 | [\\/$]* | ?:[\\/]* ) continue;; |
1094 | 1104 | NONE | '' ) case $ac_var in *prefix ) continue;; esac;; |
1095 | 1105 | esac |
1096 | as_fn_error "expected an absolute directory name for --$ac_var: $ac_val" | |
1106 | as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" | |
1097 | 1107 | done |
1098 | 1108 | |
1099 | 1109 | # There might be people who depend on the old broken behavior: `$host' |
1107 | 1117 | if test "x$host_alias" != x; then |
1108 | 1118 | if test "x$build_alias" = x; then |
1109 | 1119 | cross_compiling=maybe |
1110 | $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. | |
1111 | If a cross compiler is detected then cross compile mode will be used." >&2 | |
1120 | $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. | |
1121 | If a cross compiler is detected then cross compile mode will be used" >&2 | |
1112 | 1122 | elif test "x$build_alias" != "x$host_alias"; then |
1113 | 1123 | cross_compiling=yes |
1114 | 1124 | fi |
1123 | 1133 | ac_pwd=`pwd` && test -n "$ac_pwd" && |
1124 | 1134 | ac_ls_di=`ls -di .` && |
1125 | 1135 | ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || |
1126 | as_fn_error "working directory cannot be determined" | |
1136 | as_fn_error $? "working directory cannot be determined" | |
1127 | 1137 | test "X$ac_ls_di" = "X$ac_pwd_ls_di" || |
1128 | as_fn_error "pwd does not report name of working directory" | |
1138 | as_fn_error $? "pwd does not report name of working directory" | |
1129 | 1139 | |
1130 | 1140 | |
1131 | 1141 | # Find the source files, if location was not specified. |
1164 | 1174 | fi |
1165 | 1175 | if test ! -r "$srcdir/$ac_unique_file"; then |
1166 | 1176 | test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." |
1167 | as_fn_error "cannot find sources ($ac_unique_file) in $srcdir" | |
1177 | as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" | |
1168 | 1178 | fi |
1169 | 1179 | ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" |
1170 | 1180 | ac_abs_confdir=`( |
1171 | cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg" | |
1181 | cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" | |
1172 | 1182 | pwd)` |
1173 | 1183 | # When building in place, set srcdir=. |
1174 | 1184 | if test "$ac_abs_confdir" = "$ac_pwd"; then |
1208 | 1218 | --help=short display options specific to this package |
1209 | 1219 | --help=recursive display the short help of all the included packages |
1210 | 1220 | -V, --version display version information and exit |
1211 | -q, --quiet, --silent do not print \`checking...' messages | |
1221 | -q, --quiet, --silent do not print \`checking ...' messages | |
1212 | 1222 | --cache-file=FILE cache test results in FILE [disabled] |
1213 | 1223 | -C, --config-cache alias for \`--cache-file=config.cache' |
1214 | 1224 | -n, --no-create do not create output files |
1257 | 1267 | |
1258 | 1268 | cat <<\_ACEOF |
1259 | 1269 | |
1270 | Optional Features: | |
1271 | --disable-option-checking ignore unrecognized --enable/--with options | |
1272 | --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) | |
1273 | --enable-FEATURE[=ARG] include FEATURE [ARG=yes] | |
1274 | --disable-dbuskit disable DBusKit based alarm notification | |
1275 | ||
1276 | Optional Packages: | |
1277 | --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] | |
1278 | --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) | |
1279 | --with-ical-include=DIR include path for ical headers | |
1280 | --with-ical-library=DIR library path for ical libraries | |
1281 | ||
1260 | 1282 | Some influential environment variables: |
1261 | 1283 | CC C compiler command |
1262 | 1284 | CFLAGS C compiler flags |
1263 | 1285 | LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a |
1264 | 1286 | nonstandard directory <lib dir> |
1265 | 1287 | LIBS libraries to pass to the linker, e.g. -l<library> |
1266 | CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I<include dir> if | |
1288 | CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if | |
1267 | 1289 | you have headers in a nonstandard directory <include dir> |
1268 | 1290 | CPP C preprocessor |
1269 | 1291 | |
1334 | 1356 | if $ac_init_version; then |
1335 | 1357 | cat <<\_ACEOF |
1336 | 1358 | configure |
1337 | generated by GNU Autoconf 2.64 | |
1338 | ||
1339 | Copyright (C) 2009 Free Software Foundation, Inc. | |
1359 | generated by GNU Autoconf 2.67 | |
1360 | ||
1361 | Copyright (C) 2010 Free Software Foundation, Inc. | |
1340 | 1362 | This configure script is free software; the Free Software Foundation |
1341 | 1363 | gives unlimited permission to copy, distribute and modify it. |
1342 | 1364 | _ACEOF |
1381 | 1403 | ac_retval=1 |
1382 | 1404 | fi |
1383 | 1405 | eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} |
1384 | return $ac_retval | |
1406 | as_fn_set_status $ac_retval | |
1385 | 1407 | |
1386 | 1408 | } # ac_fn_c_try_compile |
1387 | 1409 | |
1406 | 1428 | mv -f conftest.er1 conftest.err |
1407 | 1429 | fi |
1408 | 1430 | $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 |
1409 | test $ac_status = 0; } >/dev/null && { | |
1431 | test $ac_status = 0; } > conftest.i && { | |
1410 | 1432 | test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || |
1411 | 1433 | test ! -s conftest.err |
1412 | 1434 | }; then : |
1418 | 1440 | ac_retval=1 |
1419 | 1441 | fi |
1420 | 1442 | eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} |
1421 | return $ac_retval | |
1443 | as_fn_set_status $ac_retval | |
1422 | 1444 | |
1423 | 1445 | } # ac_fn_c_try_cpp |
1424 | 1446 | |
1430 | 1452 | ac_fn_c_check_header_mongrel () |
1431 | 1453 | { |
1432 | 1454 | as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack |
1433 | if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : | |
1455 | if eval "test \"\${$3+set}\"" = set; then : | |
1434 | 1456 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 |
1435 | 1457 | $as_echo_n "checking for $2... " >&6; } |
1436 | if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : | |
1458 | if eval "test \"\${$3+set}\"" = set; then : | |
1437 | 1459 | $as_echo_n "(cached) " >&6 |
1438 | 1460 | fi |
1439 | 1461 | eval ac_res=\$$3 |
1469 | 1491 | else |
1470 | 1492 | ac_header_preproc=no |
1471 | 1493 | fi |
1472 | rm -f conftest.err conftest.$ac_ext | |
1494 | rm -f conftest.err conftest.i conftest.$ac_ext | |
1473 | 1495 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 |
1474 | 1496 | $as_echo "$ac_header_preproc" >&6; } |
1475 | 1497 | |
1496 | 1518 | esac |
1497 | 1519 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 |
1498 | 1520 | $as_echo_n "checking for $2... " >&6; } |
1499 | if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : | |
1521 | if eval "test \"\${$3+set}\"" = set; then : | |
1500 | 1522 | $as_echo_n "(cached) " >&6 |
1501 | 1523 | else |
1502 | 1524 | eval "$3=\$ac_header_compiler" |
1547 | 1569 | fi |
1548 | 1570 | rm -rf conftest.dSYM conftest_ipa8_conftest.oo |
1549 | 1571 | eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} |
1550 | return $ac_retval | |
1572 | as_fn_set_status $ac_retval | |
1551 | 1573 | |
1552 | 1574 | } # ac_fn_c_try_run |
1553 | 1575 | |
1560 | 1582 | as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack |
1561 | 1583 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 |
1562 | 1584 | $as_echo_n "checking for $2... " >&6; } |
1563 | if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : | |
1585 | if eval "test \"\${$3+set}\"" = set; then : | |
1564 | 1586 | $as_echo_n "(cached) " >&6 |
1565 | 1587 | else |
1566 | 1588 | cat confdefs.h - <<_ACEOF >conftest.$ac_ext |
1624 | 1646 | # left behind by Apple's compiler. We do this before executing the actions. |
1625 | 1647 | rm -rf conftest.dSYM conftest_ipa8_conftest.oo |
1626 | 1648 | eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} |
1627 | return $ac_retval | |
1649 | as_fn_set_status $ac_retval | |
1628 | 1650 | |
1629 | 1651 | } # ac_fn_c_try_link |
1630 | 1652 | cat >config.log <<_ACEOF |
1632 | 1654 | running configure, to aid debugging if configure makes a mistake. |
1633 | 1655 | |
1634 | 1656 | It was created by $as_me, which was |
1635 | generated by GNU Autoconf 2.64. Invocation command line was | |
1657 | generated by GNU Autoconf 2.67. Invocation command line was | |
1636 | 1658 | |
1637 | 1659 | $ $0 $@ |
1638 | 1660 | |
1742 | 1764 | { |
1743 | 1765 | echo |
1744 | 1766 | |
1745 | cat <<\_ASBOX | |
1746 | ## ---------------- ## | |
1767 | $as_echo "## ---------------- ## | |
1747 | 1768 | ## Cache variables. ## |
1748 | ## ---------------- ## | |
1749 | _ASBOX | |
1769 | ## ---------------- ##" | |
1750 | 1770 | echo |
1751 | 1771 | # The following way of writing the cache mishandles newlines in values, |
1752 | 1772 | ( |
1780 | 1800 | ) |
1781 | 1801 | echo |
1782 | 1802 | |
1783 | cat <<\_ASBOX | |
1784 | ## ----------------- ## | |
1803 | $as_echo "## ----------------- ## | |
1785 | 1804 | ## Output variables. ## |
1786 | ## ----------------- ## | |
1787 | _ASBOX | |
1805 | ## ----------------- ##" | |
1788 | 1806 | echo |
1789 | 1807 | for ac_var in $ac_subst_vars |
1790 | 1808 | do |
1797 | 1815 | echo |
1798 | 1816 | |
1799 | 1817 | if test -n "$ac_subst_files"; then |
1800 | cat <<\_ASBOX | |
1801 | ## ------------------- ## | |
1818 | $as_echo "## ------------------- ## | |
1802 | 1819 | ## File substitutions. ## |
1803 | ## ------------------- ## | |
1804 | _ASBOX | |
1820 | ## ------------------- ##" | |
1805 | 1821 | echo |
1806 | 1822 | for ac_var in $ac_subst_files |
1807 | 1823 | do |
1815 | 1831 | fi |
1816 | 1832 | |
1817 | 1833 | if test -s confdefs.h; then |
1818 | cat <<\_ASBOX | |
1819 | ## ----------- ## | |
1834 | $as_echo "## ----------- ## | |
1820 | 1835 | ## confdefs.h. ## |
1821 | ## ----------- ## | |
1822 | _ASBOX | |
1836 | ## ----------- ##" | |
1823 | 1837 | echo |
1824 | 1838 | cat confdefs.h |
1825 | 1839 | echo |
1874 | 1888 | ac_site_file1=NONE |
1875 | 1889 | ac_site_file2=NONE |
1876 | 1890 | if test -n "$CONFIG_SITE"; then |
1877 | ac_site_file1=$CONFIG_SITE | |
1891 | # We do not want a PATH search for config.site. | |
1892 | case $CONFIG_SITE in #(( | |
1893 | -*) ac_site_file1=./$CONFIG_SITE;; | |
1894 | */*) ac_site_file1=$CONFIG_SITE;; | |
1895 | *) ac_site_file1=./$CONFIG_SITE;; | |
1896 | esac | |
1878 | 1897 | elif test "x$prefix" != xNONE; then |
1879 | 1898 | ac_site_file1=$prefix/share/config.site |
1880 | 1899 | ac_site_file2=$prefix/etc/config.site |
1885 | 1904 | for ac_site_file in "$ac_site_file1" "$ac_site_file2" |
1886 | 1905 | do |
1887 | 1906 | test "x$ac_site_file" = xNONE && continue |
1888 | if test -r "$ac_site_file"; then | |
1907 | if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then | |
1889 | 1908 | { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 |
1890 | 1909 | $as_echo "$as_me: loading site script $ac_site_file" >&6;} |
1891 | 1910 | sed 's/^/| /' "$ac_site_file" >&5 |
1892 | . "$ac_site_file" | |
1911 | . "$ac_site_file" \ | |
1912 | || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 | |
1913 | $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} | |
1914 | as_fn_error $? "failed to load site script $ac_site_file | |
1915 | See \`config.log' for more details" "$LINENO" 5 ; } | |
1893 | 1916 | fi |
1894 | 1917 | done |
1895 | 1918 | |
1896 | 1919 | if test -r "$cache_file"; then |
1897 | # Some versions of bash will fail to source /dev/null (special | |
1898 | # files actually), so we avoid doing that. | |
1899 | if test -f "$cache_file"; then | |
1920 | # Some versions of bash will fail to source /dev/null (special files | |
1921 | # actually), so we avoid doing that. DJGPP emulates it as a regular file. | |
1922 | if test /dev/null != "$cache_file" && test -f "$cache_file"; then | |
1900 | 1923 | { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 |
1901 | 1924 | $as_echo "$as_me: loading cache $cache_file" >&6;} |
1902 | 1925 | case $cache_file in |
1965 | 1988 | $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} |
1966 | 1989 | { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 |
1967 | 1990 | $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} |
1968 | as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 | |
1991 | as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 | |
1969 | 1992 | fi |
1970 | 1993 | ## -------------------- ## |
1971 | 1994 | ## Main body of script. ## |
1982 | 2005 | ac_config_headers="$ac_config_headers config.h" |
1983 | 2006 | |
1984 | 2007 | |
2008 | old_cppflags=$CPPFLAGS | |
2009 | old_ldflags=$LDFLAGS | |
2010 | ||
2011 | additional_include_dir= | |
2012 | additional_lib_dir= | |
2013 | ||
2014 | ||
2015 | # Check whether --with-ical-include was given. | |
2016 | if test "${with_ical_include+set}" = set; then : | |
2017 | withval=$with_ical_include; additional_include_dir+=-I"$withval" | |
2018 | fi | |
2019 | ||
2020 | ||
2021 | # Check whether --with-ical-library was given. | |
2022 | if test "${with_ical_library+set}" = set; then : | |
2023 | withval=$with_ical_library; additional_lib_dir=-L"$withval" | |
2024 | fi | |
2025 | ||
2026 | CPPFLAGS="$CPPFLAGS $additional_include_dir" | |
2027 | LDFLAGS="$LDFLAGS $additional_lib_dir" | |
1985 | 2028 | ac_ext=c |
1986 | 2029 | ac_cpp='$CPP $CPPFLAGS' |
1987 | 2030 | ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' |
2282 | 2325 | |
2283 | 2326 | test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 |
2284 | 2327 | $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} |
2285 | as_fn_error "no acceptable C compiler found in \$PATH | |
2286 | See \`config.log' for more details." "$LINENO" 5; } | |
2328 | as_fn_error $? "no acceptable C compiler found in \$PATH | |
2329 | See \`config.log' for more details" "$LINENO" 5 ; } | |
2287 | 2330 | |
2288 | 2331 | # Provide some information about the compiler. |
2289 | 2332 | $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 |
2304 | 2347 | ... rest of stderr output deleted ... |
2305 | 2348 | 10q' conftest.err >conftest.er1 |
2306 | 2349 | cat conftest.er1 >&5 |
2307 | rm -f conftest.er1 conftest.err | |
2308 | 2350 | fi |
2351 | rm -f conftest.er1 conftest.err | |
2309 | 2352 | $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 |
2310 | 2353 | test $ac_status = 0; } |
2311 | 2354 | done |
2312 | 2355 | |
2313 | 2356 | cat confdefs.h - <<_ACEOF >conftest.$ac_ext |
2314 | 2357 | /* end confdefs.h. */ |
2315 | #include <stdio.h> | |
2358 | ||
2316 | 2359 | int |
2317 | 2360 | main () |
2318 | 2361 | { |
2319 | FILE *f = fopen ("conftest.out", "w"); | |
2320 | return ferror (f) || fclose (f) != 0; | |
2321 | 2362 | |
2322 | 2363 | ; |
2323 | 2364 | return 0; |
2324 | 2365 | } |
2325 | 2366 | _ACEOF |
2326 | 2367 | ac_clean_files_save=$ac_clean_files |
2327 | ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out conftest.out" | |
2368 | ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" | |
2328 | 2369 | # Try to create an executable without -o first, disregard a.out. |
2329 | 2370 | # It will help us diagnose broken compilers, and finding out an intuition |
2330 | 2371 | # of exeext. |
2331 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 | |
2332 | $as_echo_n "checking for C compiler default output file name... " >&6; } | |
2372 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 | |
2373 | $as_echo_n "checking whether the C compiler works... " >&6; } | |
2333 | 2374 | ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` |
2334 | 2375 | |
2335 | 2376 | # The possible output files: |
2391 | 2432 | else |
2392 | 2433 | ac_file='' |
2393 | 2434 | fi |
2435 | if test -z "$ac_file"; then : | |
2436 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 | |
2437 | $as_echo "no" >&6; } | |
2438 | $as_echo "$as_me: failed program was:" >&5 | |
2439 | sed 's/^/| /' conftest.$ac_ext >&5 | |
2440 | ||
2441 | { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 | |
2442 | $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} | |
2443 | as_fn_error 77 "C compiler cannot create executables | |
2444 | See \`config.log' for more details" "$LINENO" 5 ; } | |
2445 | else | |
2446 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 | |
2447 | $as_echo "yes" >&6; } | |
2448 | fi | |
2449 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 | |
2450 | $as_echo_n "checking for C compiler default output file name... " >&6; } | |
2394 | 2451 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 |
2395 | 2452 | $as_echo "$ac_file" >&6; } |
2396 | if test -z "$ac_file"; then : | |
2397 | $as_echo "$as_me: failed program was:" >&5 | |
2398 | sed 's/^/| /' conftest.$ac_ext >&5 | |
2399 | ||
2400 | { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 | |
2401 | $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} | |
2402 | { as_fn_set_status 77 | |
2403 | as_fn_error "C compiler cannot create executables | |
2404 | See \`config.log' for more details." "$LINENO" 5; }; } | |
2405 | fi | |
2406 | 2453 | ac_exeext=$ac_cv_exeext |
2407 | 2454 | |
2408 | # Check that the compiler produces executables we can run. If not, either | |
2409 | # the compiler is broken, or we cross compile. | |
2410 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 | |
2411 | $as_echo_n "checking whether the C compiler works... " >&6; } | |
2412 | # If not cross compiling, check that we can run a simple program. | |
2413 | if test "$cross_compiling" != yes; then | |
2414 | if { ac_try='./$ac_file' | |
2415 | { { case "(($ac_try" in | |
2416 | *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; | |
2417 | *) ac_try_echo=$ac_try;; | |
2418 | esac | |
2419 | eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" | |
2420 | $as_echo "$ac_try_echo"; } >&5 | |
2421 | (eval "$ac_try") 2>&5 | |
2422 | ac_status=$? | |
2423 | $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 | |
2424 | test $ac_status = 0; }; }; then | |
2425 | cross_compiling=no | |
2426 | else | |
2427 | if test "$cross_compiling" = maybe; then | |
2428 | cross_compiling=yes | |
2429 | else | |
2430 | { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 | |
2431 | $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} | |
2432 | as_fn_error "cannot run C compiled programs. | |
2433 | If you meant to cross compile, use \`--host'. | |
2434 | See \`config.log' for more details." "$LINENO" 5; } | |
2435 | fi | |
2436 | fi | |
2437 | fi | |
2438 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 | |
2439 | $as_echo "yes" >&6; } | |
2440 | ||
2441 | rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out conftest.out | |
2455 | rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out | |
2442 | 2456 | ac_clean_files=$ac_clean_files_save |
2443 | # Check that the compiler produces executables we can run. If not, either | |
2444 | # the compiler is broken, or we cross compile. | |
2445 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 | |
2446 | $as_echo_n "checking whether we are cross compiling... " >&6; } | |
2447 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 | |
2448 | $as_echo "$cross_compiling" >&6; } | |
2449 | ||
2450 | 2457 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 |
2451 | 2458 | $as_echo_n "checking for suffix of executables... " >&6; } |
2452 | 2459 | if { { ac_try="$ac_link" |
2476 | 2483 | else |
2477 | 2484 | { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 |
2478 | 2485 | $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} |
2479 | as_fn_error "cannot compute suffix of executables: cannot compile and link | |
2480 | See \`config.log' for more details." "$LINENO" 5; } | |
2481 | fi | |
2482 | rm -f conftest$ac_cv_exeext | |
2486 | as_fn_error $? "cannot compute suffix of executables: cannot compile and link | |
2487 | See \`config.log' for more details" "$LINENO" 5 ; } | |
2488 | fi | |
2489 | rm -f conftest conftest$ac_cv_exeext | |
2483 | 2490 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 |
2484 | 2491 | $as_echo "$ac_cv_exeext" >&6; } |
2485 | 2492 | |
2486 | 2493 | rm -f conftest.$ac_ext |
2487 | 2494 | EXEEXT=$ac_cv_exeext |
2488 | 2495 | ac_exeext=$EXEEXT |
2496 | cat confdefs.h - <<_ACEOF >conftest.$ac_ext | |
2497 | /* end confdefs.h. */ | |
2498 | #include <stdio.h> | |
2499 | int | |
2500 | main () | |
2501 | { | |
2502 | FILE *f = fopen ("conftest.out", "w"); | |
2503 | return ferror (f) || fclose (f) != 0; | |
2504 | ||
2505 | ; | |
2506 | return 0; | |
2507 | } | |
2508 | _ACEOF | |
2509 | ac_clean_files="$ac_clean_files conftest.out" | |
2510 | # Check that the compiler produces executables we can run. If not, either | |
2511 | # the compiler is broken, or we cross compile. | |
2512 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 | |
2513 | $as_echo_n "checking whether we are cross compiling... " >&6; } | |
2514 | if test "$cross_compiling" != yes; then | |
2515 | { { ac_try="$ac_link" | |
2516 | case "(($ac_try" in | |
2517 | *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; | |
2518 | *) ac_try_echo=$ac_try;; | |
2519 | esac | |
2520 | eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" | |
2521 | $as_echo "$ac_try_echo"; } >&5 | |
2522 | (eval "$ac_link") 2>&5 | |
2523 | ac_status=$? | |
2524 | $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 | |
2525 | test $ac_status = 0; } | |
2526 | if { ac_try='./conftest$ac_cv_exeext' | |
2527 | { { case "(($ac_try" in | |
2528 | *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; | |
2529 | *) ac_try_echo=$ac_try;; | |
2530 | esac | |
2531 | eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" | |
2532 | $as_echo "$ac_try_echo"; } >&5 | |
2533 | (eval "$ac_try") 2>&5 | |
2534 | ac_status=$? | |
2535 | $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 | |
2536 | test $ac_status = 0; }; }; then | |
2537 | cross_compiling=no | |
2538 | else | |
2539 | if test "$cross_compiling" = maybe; then | |
2540 | cross_compiling=yes | |
2541 | else | |
2542 | { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 | |
2543 | $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} | |
2544 | as_fn_error $? "cannot run C compiled programs. | |
2545 | If you meant to cross compile, use \`--host'. | |
2546 | See \`config.log' for more details" "$LINENO" 5 ; } | |
2547 | fi | |
2548 | fi | |
2549 | fi | |
2550 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 | |
2551 | $as_echo "$cross_compiling" >&6; } | |
2552 | ||
2553 | rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out | |
2554 | ac_clean_files=$ac_clean_files_save | |
2489 | 2555 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 |
2490 | 2556 | $as_echo_n "checking for suffix of object files... " >&6; } |
2491 | 2557 | if test "${ac_cv_objext+set}" = set; then : |
2528 | 2594 | |
2529 | 2595 | { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 |
2530 | 2596 | $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} |
2531 | as_fn_error "cannot compute suffix of object files: cannot compile | |
2532 | See \`config.log' for more details." "$LINENO" 5; } | |
2597 | as_fn_error $? "cannot compute suffix of object files: cannot compile | |
2598 | See \`config.log' for more details" "$LINENO" 5 ; } | |
2533 | 2599 | fi |
2534 | 2600 | rm -f conftest.$ac_cv_objext conftest.$ac_ext |
2535 | 2601 | fi |
2792 | 2858 | # Broken: fails on valid input. |
2793 | 2859 | continue |
2794 | 2860 | fi |
2795 | rm -f conftest.err conftest.$ac_ext | |
2861 | rm -f conftest.err conftest.i conftest.$ac_ext | |
2796 | 2862 | |
2797 | 2863 | # OK, works on sane cases. Now check whether nonexistent headers |
2798 | 2864 | # can be detected and how. |
2808 | 2874 | ac_preproc_ok=: |
2809 | 2875 | break |
2810 | 2876 | fi |
2811 | rm -f conftest.err conftest.$ac_ext | |
2877 | rm -f conftest.err conftest.i conftest.$ac_ext | |
2812 | 2878 | |
2813 | 2879 | done |
2814 | 2880 | # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. |
2815 | rm -f conftest.err conftest.$ac_ext | |
2881 | rm -f conftest.i conftest.err conftest.$ac_ext | |
2816 | 2882 | if $ac_preproc_ok; then : |
2817 | 2883 | break |
2818 | 2884 | fi |
2851 | 2917 | # Broken: fails on valid input. |
2852 | 2918 | continue |
2853 | 2919 | fi |
2854 | rm -f conftest.err conftest.$ac_ext | |
2920 | rm -f conftest.err conftest.i conftest.$ac_ext | |
2855 | 2921 | |
2856 | 2922 | # OK, works on sane cases. Now check whether nonexistent headers |
2857 | 2923 | # can be detected and how. |
2867 | 2933 | ac_preproc_ok=: |
2868 | 2934 | break |
2869 | 2935 | fi |
2870 | rm -f conftest.err conftest.$ac_ext | |
2936 | rm -f conftest.err conftest.i conftest.$ac_ext | |
2871 | 2937 | |
2872 | 2938 | done |
2873 | 2939 | # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. |
2874 | rm -f conftest.err conftest.$ac_ext | |
2940 | rm -f conftest.i conftest.err conftest.$ac_ext | |
2875 | 2941 | if $ac_preproc_ok; then : |
2876 | 2942 | |
2877 | 2943 | else |
2878 | 2944 | { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 |
2879 | 2945 | $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} |
2880 | as_fn_error "C preprocessor \"$CPP\" fails sanity check | |
2881 | See \`config.log' for more details." "$LINENO" 5; } | |
2946 | as_fn_error $? "C preprocessor \"$CPP\" fails sanity check | |
2947 | See \`config.log' for more details" "$LINENO" 5 ; } | |
2882 | 2948 | fi |
2883 | 2949 | |
2884 | 2950 | ac_ext=c |
2939 | 3005 | done |
2940 | 3006 | IFS=$as_save_IFS |
2941 | 3007 | if test -z "$ac_cv_path_GREP"; then |
2942 | as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 | |
3008 | as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 | |
2943 | 3009 | fi |
2944 | 3010 | else |
2945 | 3011 | ac_cv_path_GREP=$GREP |
3005 | 3071 | done |
3006 | 3072 | IFS=$as_save_IFS |
3007 | 3073 | if test -z "$ac_cv_path_EGREP"; then |
3008 | as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 | |
3074 | as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 | |
3009 | 3075 | fi |
3010 | 3076 | else |
3011 | 3077 | ac_cv_path_EGREP=$EGREP |
3137 | 3203 | as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` |
3138 | 3204 | ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default |
3139 | 3205 | " |
3140 | eval as_val=\$$as_ac_Header | |
3141 | if test "x$as_val" = x""yes; then : | |
3206 | if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : | |
3142 | 3207 | cat >>confdefs.h <<_ACEOF |
3143 | 3208 | #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 |
3144 | 3209 | _ACEOF |
3166 | 3231 | _ACEOF |
3167 | 3232 | |
3168 | 3233 | else |
3169 | as_fn_error "ical.h not found. You must have libical >= 0.27 installed." "$LINENO" 5 | |
3234 | as_fn_error $? "ical.h not found. You must have libical >= 0.27 installed." "$LINENO" 5 | |
3170 | 3235 | fi |
3171 | 3236 | |
3172 | 3237 | done |
3174 | 3239 | fi |
3175 | 3240 | |
3176 | 3241 | done |
3242 | ||
3243 | CPPFLAGS=$old_cppflags | |
3244 | LDFLAGS=$old_ldflags | |
3177 | 3245 | |
3178 | 3246 | for ac_header in uuid/uuid.h |
3179 | 3247 | do : |
3195 | 3263 | . "$GNUSTEP_MAKEFILES/GNUstep.sh" |
3196 | 3264 | unset GNUSTEP_SH_EXPORT_ALL_VARIABLES |
3197 | 3265 | |
3198 | # For backwards compatibility, define GNUSTEP_SYSTEM_HEADERS from | |
3199 | # GNUSTEP_SYSTEM_ROOT if not set yet. | |
3200 | if test x"$GNUSTEP_SYSTEM_HEADERS" = x""; then | |
3201 | GNUSTEP_SYSTEM_HEADERS="$GNUSTEP_SYSTEM_ROOT/Library/Headers" | |
3202 | fi | |
3203 | if test x"$GNUSTEP_LOCAL_HEADERS" = x""; then | |
3204 | GNUSTEP_LOCAL_HEADERS="$GNUSTEP_LOCAL_ROOT/Library/Headers" | |
3205 | fi | |
3206 | ||
3207 | if test x"$GNUSTEP_SYSTEM_LIBRARIES" = x""; then | |
3208 | GNUSTEP_SYSTEM_LIBRARIES="$GNUSTEP_SYSTEM_ROOT/Library/Libraries" | |
3209 | fi | |
3210 | if test x"$GNUSTEP_LOCAL_LIBRARIES" = x""; then | |
3211 | GNUSTEP_LOCAL_LIBRARIES="$GNUSTEP_LOCAL_ROOT/Library/Libraries" | |
3212 | fi | |
3213 | ||
3214 | 3266 | OLD_CFLAGS=$CFLAGS |
3215 | CFLAGS="-xobjective-c" | |
3216 | PREFIX="-I" | |
3217 | OLD_CPPFLAGS="$CPPFLAGS" | |
3218 | CPPFLAGS="$CPPFLAGS $PREFIX$GNUSTEP_SYSTEM_HEADERS $PREFIX$GNUSTEP_LOCAL_HEADERS" | |
3267 | CFLAGS="-xobjective-c " | |
3268 | CFLAGS+=`gnustep-config --objc-flags` | |
3219 | 3269 | |
3220 | 3270 | OLD_LDFLAGS="$LD_FLAGS" |
3221 | PREFIX="-L" | |
3222 | LDFLAGS="$LDFLAGS $PREFIX$GNUSTEP_SYSTEM_LIBRARIES $PREFIX$GNUSTEP_LOCAL_LIBRARIES" | |
3271 | LDFLAGS=`gnustep-config --objc-libs` | |
3223 | 3272 | OLD_LIBS="$LIBS" |
3224 | LIBS="-lgnustep-base" | |
3273 | LIBS="-lgnustep-base -lAddresses" | |
3225 | 3274 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Addresses framework" >&5 |
3226 | 3275 | $as_echo_n "checking for Addresses framework... " >&6; } |
3227 | ||
3228 | LIBS="$LIBS -lAddresses" | |
3229 | 3276 | |
3230 | 3277 | cat confdefs.h - <<_ACEOF >conftest.$ac_ext |
3231 | 3278 | /* end confdefs.h. */ |
3250 | 3297 | conftest$ac_exeext conftest.$ac_ext |
3251 | 3298 | |
3252 | 3299 | LIBS="$OLD_LIBS" |
3253 | CPPFLAGS="$OLD_CPPFLAGS" | |
3254 | 3300 | LDFLAGS="$OLD_LDFLAGS" |
3255 | 3301 | CFLAGS="$OLD_CFLAGS" |
3256 | 3302 | |
3257 | 3303 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_addresses" >&5 |
3258 | 3304 | $as_echo "$have_addresses" >&6; } |
3305 | ||
3306 | ||
3307 | # Check whether --enable-dbuskit was given. | |
3308 | if test "${enable_dbuskit+set}" = set; then : | |
3309 | enableval=$enable_dbuskit; | |
3310 | else | |
3311 | enable_dbuskit=yes | |
3312 | fi | |
3313 | ||
3314 | if test "x$enable_dbuskit" != xno; then | |
3315 | ||
3316 | ||
3317 | GNUSTEP_SH_EXPORT_ALL_VARIABLES=yes | |
3318 | . "$GNUSTEP_MAKEFILES/GNUstep.sh" | |
3319 | unset GNUSTEP_SH_EXPORT_ALL_VARIABLES | |
3320 | ||
3321 | OLD_CFLAGS=$CFLAGS | |
3322 | CFLAGS="-xobjective-c " | |
3323 | CFLAGS+=`gnustep-config --objc-flags` | |
3324 | ||
3325 | OLD_LDFLAGS="$LD_FLAGS" | |
3326 | LDFLAGS=`gnustep-config --objc-libs` | |
3327 | OLD_LIBS="$LIBS" | |
3328 | LIBS="-lgnustep-base -lDBusKit" | |
3329 | { $as_echo "$as_me:${as_lineno-$LINENO}: checking for DBusKit framework" >&5 | |
3330 | $as_echo_n "checking for DBusKit framework... " >&6; } | |
3331 | ||
3332 | cat confdefs.h - <<_ACEOF >conftest.$ac_ext | |
3333 | /* end confdefs.h. */ | |
3334 | #import <Foundation/Foundation.h> | |
3335 | #import <DBusKit/DBusKit.h> | |
3336 | int | |
3337 | main () | |
3338 | { | |
3339 | [DKPort sessionBusPort]; | |
3340 | ; | |
3341 | return 0; | |
3342 | } | |
3343 | _ACEOF | |
3344 | if ac_fn_c_try_link "$LINENO"; then : | |
3345 | have_dbuskit=yes; | |
3346 | have_dbuskit=yes | |
3347 | else | |
3348 | have_dbuskit=no; | |
3349 | have_dbuskit=no | |
3350 | fi | |
3351 | rm -f core conftest.err conftest.$ac_objext \ | |
3352 | conftest$ac_exeext conftest.$ac_ext | |
3353 | ||
3354 | LIBS="$OLD_LIBS" | |
3355 | LDFLAGS="$OLD_LDFLAGS" | |
3356 | CFLAGS="$OLD_CFLAGS" | |
3357 | ||
3358 | { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_dbuskit" >&5 | |
3359 | $as_echo "$have_dbuskit" >&6; } | |
3360 | ||
3361 | else | |
3362 | { $as_echo "$as_me:${as_lineno-$LINENO}: DBusKit disabled" >&5 | |
3363 | $as_echo "$as_me: DBusKit disabled" >&6;} | |
3364 | have_dbuskit=no | |
3365 | fi | |
3366 | ||
3367 | ||
3368 | ||
3369 | ||
3259 | 3370 | |
3260 | 3371 | |
3261 | 3372 | |
3345 | 3456 | |
3346 | 3457 | ac_libobjs= |
3347 | 3458 | ac_ltlibobjs= |
3459 | U= | |
3348 | 3460 | for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue |
3349 | 3461 | # 1. Remove the extension, and $U if already installed. |
3350 | 3462 | ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' |
3506 | 3618 | (unset CDPATH) >/dev/null 2>&1 && unset CDPATH |
3507 | 3619 | |
3508 | 3620 | |
3509 | # as_fn_error ERROR [LINENO LOG_FD] | |
3510 | # --------------------------------- | |
3621 | # as_fn_error STATUS ERROR [LINENO LOG_FD] | |
3622 | # ---------------------------------------- | |
3511 | 3623 | # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are |
3512 | 3624 | # provided, also output the error to LOG_FD, referencing LINENO. Then exit the |
3513 | # script with status $?, using 1 if that was 0. | |
3625 | # script with STATUS, using 1 if that was 0. | |
3514 | 3626 | as_fn_error () |
3515 | 3627 | { |
3516 | as_status=$?; test $as_status -eq 0 && as_status=1 | |
3517 | if test "$3"; then | |
3518 | as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack | |
3519 | $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 | |
3628 | as_status=$1; test $as_status -eq 0 && as_status=1 | |
3629 | if test "$4"; then | |
3630 | as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack | |
3631 | $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 | |
3520 | 3632 | fi |
3521 | $as_echo "$as_me: error: $1" >&2 | |
3633 | $as_echo "$as_me: error: $2" >&2 | |
3522 | 3634 | as_fn_exit $as_status |
3523 | 3635 | } # as_fn_error |
3524 | 3636 | |
3714 | 3826 | test -d "$as_dir" && break |
3715 | 3827 | done |
3716 | 3828 | test -z "$as_dirs" || eval "mkdir $as_dirs" |
3717 | } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" | |
3829 | } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" | |
3718 | 3830 | |
3719 | 3831 | |
3720 | 3832 | } # as_fn_mkdir_p |
3768 | 3880 | # values after options handling. |
3769 | 3881 | ac_log=" |
3770 | 3882 | This file was extended by $as_me, which was |
3771 | generated by GNU Autoconf 2.64. Invocation command line was | |
3883 | generated by GNU Autoconf 2.67. Invocation command line was | |
3772 | 3884 | |
3773 | 3885 | CONFIG_FILES = $CONFIG_FILES |
3774 | 3886 | CONFIG_HEADERS = $CONFIG_HEADERS |
3807 | 3919 | |
3808 | 3920 | -h, --help print this help, then exit |
3809 | 3921 | -V, --version print version number and configuration settings, then exit |
3922 | --config print configuration, then exit | |
3810 | 3923 | -q, --quiet, --silent |
3811 | 3924 | do not print progress messages |
3812 | 3925 | -d, --debug don't remove temporary files |
3826 | 3939 | |
3827 | 3940 | _ACEOF |
3828 | 3941 | cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 |
3942 | ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" | |
3829 | 3943 | ac_cs_version="\\ |
3830 | 3944 | config.status |
3831 | configured by $0, generated by GNU Autoconf 2.64, | |
3832 | with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" | |
3833 | ||
3834 | Copyright (C) 2009 Free Software Foundation, Inc. | |
3945 | configured by $0, generated by GNU Autoconf 2.67, | |
3946 | with options \\"\$ac_cs_config\\" | |
3947 | ||
3948 | Copyright (C) 2010 Free Software Foundation, Inc. | |
3835 | 3949 | This config.status script is free software; the Free Software Foundation |
3836 | 3950 | gives unlimited permission to copy, distribute and modify it." |
3837 | 3951 | |
3846 | 3960 | while test $# != 0 |
3847 | 3961 | do |
3848 | 3962 | case $1 in |
3849 | --*=*) | |
3963 | --*=?*) | |
3850 | 3964 | ac_option=`expr "X$1" : 'X\([^=]*\)='` |
3851 | 3965 | ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` |
3966 | ac_shift=: | |
3967 | ;; | |
3968 | --*=) | |
3969 | ac_option=`expr "X$1" : 'X\([^=]*\)='` | |
3970 | ac_optarg= | |
3852 | 3971 | ac_shift=: |
3853 | 3972 | ;; |
3854 | 3973 | *) |
3864 | 3983 | ac_cs_recheck=: ;; |
3865 | 3984 | --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) |
3866 | 3985 | $as_echo "$ac_cs_version"; exit ;; |
3986 | --config | --confi | --conf | --con | --co | --c ) | |
3987 | $as_echo "$ac_cs_config"; exit ;; | |
3867 | 3988 | --debug | --debu | --deb | --de | --d | -d ) |
3868 | 3989 | debug=: ;; |
3869 | 3990 | --file | --fil | --fi | --f ) |
3870 | 3991 | $ac_shift |
3871 | 3992 | case $ac_optarg in |
3872 | 3993 | *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; |
3994 | '') as_fn_error $? "missing file argument" ;; | |
3873 | 3995 | esac |
3874 | 3996 | as_fn_append CONFIG_FILES " '$ac_optarg'" |
3875 | 3997 | ac_need_defaults=false;; |
3882 | 4004 | ac_need_defaults=false;; |
3883 | 4005 | --he | --h) |
3884 | 4006 | # Conflict between --help and --header |
3885 | as_fn_error "ambiguous option: \`$1' | |
4007 | as_fn_error $? "ambiguous option: \`$1' | |
3886 | 4008 | Try \`$0 --help' for more information.";; |
3887 | 4009 | --help | --hel | -h ) |
3888 | 4010 | $as_echo "$ac_cs_usage"; exit ;; |
3891 | 4013 | ac_cs_silent=: ;; |
3892 | 4014 | |
3893 | 4015 | # This is an error. |
3894 | -*) as_fn_error "unrecognized option: \`$1' | |
4016 | -*) as_fn_error $? "unrecognized option: \`$1' | |
3895 | 4017 | Try \`$0 --help' for more information." ;; |
3896 | 4018 | |
3897 | 4019 | *) as_fn_append ac_config_targets " $1" |
3943 | 4065 | "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; |
3944 | 4066 | "local.make") CONFIG_FILES="$CONFIG_FILES local.make" ;; |
3945 | 4067 | |
3946 | *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; | |
4068 | *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5 ;; | |
3947 | 4069 | esac |
3948 | 4070 | done |
3949 | 4071 | |
3980 | 4102 | { |
3981 | 4103 | tmp=./conf$$-$RANDOM |
3982 | 4104 | (umask 077 && mkdir "$tmp") |
3983 | } || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5 | |
4105 | } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 | |
3984 | 4106 | |
3985 | 4107 | # Set up the scripts for CONFIG_FILES section. |
3986 | 4108 | # No need to generate them if there are no CONFIG_FILES. |
3997 | 4119 | fi |
3998 | 4120 | ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null` |
3999 | 4121 | if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then |
4000 | ac_cs_awk_cr='\r' | |
4122 | ac_cs_awk_cr='\\r' | |
4001 | 4123 | else |
4002 | 4124 | ac_cs_awk_cr=$ac_cr |
4003 | 4125 | fi |
4011 | 4133 | echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && |
4012 | 4134 | echo "_ACEOF" |
4013 | 4135 | } >conf$$subs.sh || |
4014 | as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 | |
4015 | ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` | |
4136 | as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 | |
4137 | ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` | |
4016 | 4138 | ac_delim='%!_!# ' |
4017 | 4139 | for ac_last_try in false false false false false :; do |
4018 | 4140 | . ./conf$$subs.sh || |
4019 | as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 | |
4141 | as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 | |
4020 | 4142 | |
4021 | 4143 | ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` |
4022 | 4144 | if test $ac_delim_n = $ac_delim_num; then |
4023 | 4145 | break |
4024 | 4146 | elif $ac_last_try; then |
4025 | as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 | |
4147 | as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 | |
4026 | 4148 | else |
4027 | 4149 | ac_delim="$ac_delim!$ac_delim _$ac_delim!! " |
4028 | 4150 | fi |
4044 | 4166 | t delim |
4045 | 4167 | :nl |
4046 | 4168 | h |
4047 | s/\(.\{148\}\).*/\1/ | |
4169 | s/\(.\{148\}\)..*/\1/ | |
4048 | 4170 | t more1 |
4049 | 4171 | s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ |
4050 | 4172 | p |
4058 | 4180 | t nl |
4059 | 4181 | :delim |
4060 | 4182 | h |
4061 | s/\(.\{148\}\).*/\1/ | |
4183 | s/\(.\{148\}\)..*/\1/ | |
4062 | 4184 | t more2 |
4063 | 4185 | s/["\\]/\\&/g; s/^/"/; s/$/"/ |
4064 | 4186 | p |
4111 | 4233 | else |
4112 | 4234 | cat |
4113 | 4235 | fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ |
4114 | || as_fn_error "could not setup config files machinery" "$LINENO" 5 | |
4115 | _ACEOF | |
4116 | ||
4117 | # VPATH may cause trouble with some makes, so we remove $(srcdir), | |
4118 | # ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and | |
4236 | || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 | |
4237 | _ACEOF | |
4238 | ||
4239 | # VPATH may cause trouble with some makes, so we remove sole $(srcdir), | |
4240 | # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and | |
4119 | 4241 | # trailing colons and then remove the whole line if VPATH becomes empty |
4120 | 4242 | # (actually we leave an empty line to preserve line numbers). |
4121 | 4243 | if test "x$srcdir" = x.; then |
4122 | ac_vpsub='/^[ ]*VPATH[ ]*=/{ | |
4123 | s/:*\$(srcdir):*/:/ | |
4124 | s/:*\${srcdir}:*/:/ | |
4125 | s/:*@srcdir@:*/:/ | |
4126 | s/^\([^=]*=[ ]*\):*/\1/ | |
4244 | ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ | |
4245 | h | |
4246 | s/// | |
4247 | s/^/:/ | |
4248 | s/[ ]*$/:/ | |
4249 | s/:\$(srcdir):/:/g | |
4250 | s/:\${srcdir}:/:/g | |
4251 | s/:@srcdir@:/:/g | |
4252 | s/^:*// | |
4127 | 4253 | s/:*$// |
4254 | x | |
4255 | s/\(=[ ]*\).*/\1/ | |
4256 | G | |
4257 | s/\n// | |
4128 | 4258 | s/^[^=]*=[ ]*$// |
4129 | 4259 | }' |
4130 | 4260 | fi |
4152 | 4282 | if test -z "$ac_t"; then |
4153 | 4283 | break |
4154 | 4284 | elif $ac_last_try; then |
4155 | as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5 | |
4285 | as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 | |
4156 | 4286 | else |
4157 | 4287 | ac_delim="$ac_delim!$ac_delim _$ac_delim!! " |
4158 | 4288 | fi |
4237 | 4367 | _ACAWK |
4238 | 4368 | _ACEOF |
4239 | 4369 | cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 |
4240 | as_fn_error "could not setup config headers machinery" "$LINENO" 5 | |
4370 | as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 | |
4241 | 4371 | fi # test -n "$CONFIG_HEADERS" |
4242 | 4372 | |
4243 | 4373 | |
4250 | 4380 | esac |
4251 | 4381 | case $ac_mode$ac_tag in |
4252 | 4382 | :[FHL]*:*);; |
4253 | :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;; | |
4383 | :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5 ;; | |
4254 | 4384 | :[FH]-) ac_tag=-:-;; |
4255 | 4385 | :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; |
4256 | 4386 | esac |
4278 | 4408 | [\\/$]*) false;; |
4279 | 4409 | *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; |
4280 | 4410 | esac || |
4281 | as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;; | |
4411 | as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5 ;; | |
4282 | 4412 | esac |
4283 | 4413 | case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac |
4284 | 4414 | as_fn_append ac_file_inputs " '$ac_f'" |
4305 | 4435 | |
4306 | 4436 | case $ac_tag in |
4307 | 4437 | *:-:* | *:-) cat >"$tmp/stdin" \ |
4308 | || as_fn_error "could not create $ac_file" "$LINENO" 5 ;; | |
4438 | || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; | |
4309 | 4439 | esac |
4310 | 4440 | ;; |
4311 | 4441 | esac |
4431 | 4561 | $ac_datarootdir_hack |
4432 | 4562 | " |
4433 | 4563 | eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ |
4434 | || as_fn_error "could not create $ac_file" "$LINENO" 5 | |
4564 | || as_fn_error $? "could not create $ac_file" "$LINENO" 5 | |
4435 | 4565 | |
4436 | 4566 | test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && |
4437 | 4567 | { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && |
4438 | 4568 | { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && |
4439 | 4569 | { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' |
4440 | which seems to be undefined. Please make sure it is defined." >&5 | |
4570 | which seems to be undefined. Please make sure it is defined" >&5 | |
4441 | 4571 | $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' |
4442 | which seems to be undefined. Please make sure it is defined." >&2;} | |
4572 | which seems to be undefined. Please make sure it is defined" >&2;} | |
4443 | 4573 | |
4444 | 4574 | rm -f "$tmp/stdin" |
4445 | 4575 | case $ac_file in |
4446 | 4576 | -) cat "$tmp/out" && rm -f "$tmp/out";; |
4447 | 4577 | *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; |
4448 | 4578 | esac \ |
4449 | || as_fn_error "could not create $ac_file" "$LINENO" 5 | |
4579 | || as_fn_error $? "could not create $ac_file" "$LINENO" 5 | |
4450 | 4580 | ;; |
4451 | 4581 | :H) |
4452 | 4582 | # |
4457 | 4587 | $as_echo "/* $configure_input */" \ |
4458 | 4588 | && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" |
4459 | 4589 | } >"$tmp/config.h" \ |
4460 | || as_fn_error "could not create $ac_file" "$LINENO" 5 | |
4590 | || as_fn_error $? "could not create $ac_file" "$LINENO" 5 | |
4461 | 4591 | if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then |
4462 | 4592 | { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 |
4463 | 4593 | $as_echo "$as_me: $ac_file is unchanged" >&6;} |
4464 | 4594 | else |
4465 | 4595 | rm -f "$ac_file" |
4466 | 4596 | mv "$tmp/config.h" "$ac_file" \ |
4467 | || as_fn_error "could not create $ac_file" "$LINENO" 5 | |
4597 | || as_fn_error $? "could not create $ac_file" "$LINENO" 5 | |
4468 | 4598 | fi |
4469 | 4599 | else |
4470 | 4600 | $as_echo "/* $configure_input */" \ |
4471 | 4601 | && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ |
4472 | || as_fn_error "could not create -" "$LINENO" 5 | |
4602 | || as_fn_error $? "could not create -" "$LINENO" 5 | |
4473 | 4603 | fi |
4474 | 4604 | ;; |
4475 | 4605 | |
4484 | 4614 | ac_clean_files=$ac_clean_files_save |
4485 | 4615 | |
4486 | 4616 | test $ac_write_fail = 0 || |
4487 | as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5 | |
4617 | as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 | |
4488 | 4618 | |
4489 | 4619 | |
4490 | 4620 | # configure is writing to config.log, and then calls config.status. |
4505 | 4635 | exec 5>>config.log |
4506 | 4636 | # Use ||, not &&, to avoid exiting from the if with $? = 1, which |
4507 | 4637 | # would make configure fail if this is the last instruction. |
4508 | $ac_cs_success || as_fn_exit $? | |
4638 | $ac_cs_success || as_fn_exit 1 | |
4509 | 4639 | fi |
4510 | 4640 | if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then |
4511 | 4641 | { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 |
6 | 6 | AC_CONFIG_SRCDIR([MemoryStore.h]) |
7 | 7 | AC_CONFIG_HEADER([config.h]) |
8 | 8 | |
9 | old_cppflags=$CPPFLAGS | |
10 | old_ldflags=$LDFLAGS | |
11 | ||
12 | additional_include_dir= | |
13 | additional_lib_dir= | |
14 | ||
15 | AC_ARG_WITH(ical-include, [ --with-ical-include=DIR include path for ical headers], additional_include_dir+=-I"$withval", ) | |
16 | AC_ARG_WITH(ical-library, [ --with-ical-library=DIR library path for ical libraries], additional_lib_dir=-L"$withval", ) | |
17 | CPPFLAGS="$CPPFLAGS $additional_include_dir" | |
18 | LDFLAGS="$LDFLAGS $additional_lib_dir" | |
9 | 19 | AC_CHECK_HEADERS([libical/ical.h], ,[AC_CHECK_HEADERS([ical.h], ,[AC_MSG_ERROR(ical.h not found. You must have libical >= 0.27 installed.)])]) |
20 | CPPFLAGS=$old_cppflags | |
21 | LDFLAGS=$old_ldflags | |
22 | ||
10 | 23 | AC_CHECK_HEADERS([uuid/uuid.h], have_libuuid=yes, have_libuuid=no) |
11 | 24 | AC_CHECK_ADDRESSES(have_addresses=yes, have_addresses=no) |
25 | ||
26 | AC_ARG_ENABLE([dbuskit], | |
27 | [AC_HELP_STRING([--disable-dbuskit], | |
28 | [disable DBusKit based alarm notification])], | |
29 | [], | |
30 | [enable_dbuskit=yes]) | |
31 | if test "x$enable_dbuskit" != xno; then | |
32 | AC_CHECK_DBUSKIT(have_dbuskit=yes, have_dbuskit=no) | |
33 | else | |
34 | AC_MSG_NOTICE([DBusKit disabled]) | |
35 | have_dbuskit=no | |
36 | fi | |
37 | ||
12 | 38 | AC_SUBST(have_libuuid) |
13 | 39 | AC_SUBST(have_addresses) |
40 | AC_SUBST(have_dbuskit) | |
41 | AC_SUBST(additional_include_dir) | |
42 | AC_SUBST(additional_lib_dir) | |
43 | ||
14 | 44 | |
15 | 45 | AC_CONFIG_FILES([local.make]) |
16 | 46 | AC_OUTPUT |
3 | 3 | #define LAST_HOUR @"lastHour" |
4 | 4 | #define MIN_STEP @"minimumStep" |
5 | 5 | #define TOOLTIP @"showTooltip" |
6 | #define ALARMS @"activateAlarms" | |
7 | 6 | |
8 | 7 | #define STORE_CLASSES @"storeClasses" |
9 | 8 |
52 | 52 | - (void)okClicked:(id)sender |
53 | 53 | { |
54 | 54 | BOOL readable; |
55 | NSURL *tmp; | |
56 | 55 | WebDAVResource *resource; |
57 | 56 | |
58 | tmp = [NSURL URLWithString:[url stringValue]]; | |
59 | resource = AUTORELEASE([[WebDAVResource alloc] initWithURL:tmp]); | |
57 | resource = AUTORELEASE([[WebDAVResource alloc] initWithURL:[NSURL URLWithString:[url stringValue]]]); | |
60 | 58 | readable = [resource readable]; |
61 | 59 | /* Read will fail if there's no resource yet, try to create an empty one */ |
62 | if (!readable) { | |
60 | if (!readable && [resource httpStatus] != 401) { | |
63 | 61 | [resource writableWithData:[NSData data]]; |
64 | 62 | readable = [resource readable]; |
65 | 63 | } |
66 | 64 | if (readable) |
67 | 65 | [NSApp stopModalWithCode:1]; |
68 | 66 | else { |
69 | [error setStringValue:[NSString stringWithFormat:@"Unable to read from this URL : %@", [tmp propertyForKey:NSHTTPPropertyStatusReasonKey]]]; | |
67 | [error setStringValue:[NSString stringWithFormat:@"Unable to read from this URL : %@", [[resource url] propertyForKey:NSHTTPPropertyStatusReasonKey]]]; | |
70 | 68 | [warning setHidden:NO]; |
71 | 69 | } |
72 | 70 | } |
103 | 101 | - (NSDictionary *)defaults |
104 | 102 | { |
105 | 103 | return [NSDictionary dictionaryWithObjectsAndKeys:[[NSColor blueColor] description], ST_COLOR, |
106 | [[NSColor darkGrayColor] description], ST_TEXT_COLOR, | |
104 | [[NSColor whiteColor] description], ST_TEXT_COLOR, | |
107 | 105 | [NSNumber numberWithBool:NO], ST_RW, |
108 | 106 | [NSNumber numberWithBool:YES], ST_DISPLAY, |
109 | 107 | [NSNumber numberWithBool:NO], ST_REFRESH, |
120 | 118 | _resource = [[WebDAVResource alloc] initWithURL:_url]; |
121 | 119 | [_config registerClient:self forKey:ST_REFRESH]; |
122 | 120 | [_config registerClient:self forKey:ST_REFRESH_INTERVAL]; |
121 | [_config registerClient:self forKey:ST_ENABLED]; | |
123 | 122 | [NSThread detachNewThreadSelector:@selector(initStoreAsync:) toTarget:self withObject:nil]; |
124 | 123 | [self initTimer]; |
125 | 124 | } |
148 | 147 | writable = [resource writableWithData:[resource data]]; |
149 | 148 | [resource release]; |
150 | 149 | [dialog release]; |
151 | cm = [[ConfigManager alloc] initForKey:name withParent:nil]; | |
150 | cm = [[ConfigManager alloc] initForKey:name]; | |
152 | 151 | [cm setObject:[storeURL description] forKey:ST_URL]; |
153 | 152 | [cm setObject:[[self class] description] forKey:ST_CLASS]; |
154 | 153 | [cm setObject:[NSNumber numberWithBool:writable] forKey:ST_RW]; |
161 | 160 | |
162 | 161 | + (NSString *)storeTypeName |
163 | 162 | { |
164 | return @"iCalendar store"; | |
163 | return @"iCalendar"; | |
165 | 164 | } |
166 | 165 | |
167 | 166 | - (void)dealloc |
221 | 220 | if ([_resource put:data attributes:nil]) { |
222 | 221 | [_resource updateAttributes]; |
223 | 222 | [self setModified:NO]; |
224 | NSLog(@"iCalStore written to %@", [_url absoluteString]); | |
223 | NSLog(@"iCalStore written to %@", [_url anonymousAbsoluteString]); | |
225 | 224 | return YES; |
226 | 225 | } |
227 | 226 | if ([_resource httpStatus] == 412) { |
228 | 227 | NSRunAlertPanel(@"Error : data source modified", @"To prevent losing modifications, this agenda\nwill be updated and marked as read-only. ", @"Ok", nil, nil); |
229 | 228 | [self read]; |
230 | 229 | } |
231 | NSLog(@"Unable to write to %@, make this store read only", [_url absoluteString]); | |
230 | NSLog(@"Unable to write to %@, make this store read only", [_url anonymousAbsoluteString]); | |
232 | 231 | [self setWritable:NO]; |
233 | 232 | return NO; |
234 | 233 | } |
255 | 254 | { |
256 | 255 | [_config setInteger:interval forKey:ST_REFRESH_INTERVAL]; |
257 | 256 | } |
258 | - (void)config:(ConfigManager*)config dataDidChangedForKey:(NSString *)key | |
259 | { | |
260 | [self initTimer]; | |
257 | - (void)config:(ConfigManager *)config dataDidChangedForKey:(NSString *)key | |
258 | { | |
259 | if (config == _config && [key isEqualToString:ST_ENABLED] && [self enabled]) { | |
260 | [self read]; | |
261 | [self initTimer]; | |
262 | } | |
261 | 263 | } |
262 | 264 | @end |
263 | 265 | |
265 | 267 | @implementation iCalStore(Private) |
266 | 268 | - (void)fetchData |
267 | 269 | { |
268 | if ([_resource get]) | |
269 | if ([NSThread isMainThread]) | |
270 | [self parseData:[_resource data]]; | |
270 | if ([self enabled]) { | |
271 | if ([_resource get]) | |
272 | if ([NSThread isMainThread]) | |
273 | [self parseData:[_resource data]]; | |
274 | else | |
275 | [self performSelectorOnMainThread:@selector(parseData:) withObject:[_resource data] waitUntilDone:NO]; | |
271 | 276 | else |
272 | [self performSelectorOnMainThread:@selector(parseData:) withObject:[_resource data] waitUntilDone:NO]; | |
273 | else | |
274 | [self setEnabled:NO]; | |
277 | [self setEnabled:NO]; | |
278 | } | |
275 | 279 | } |
276 | 280 | - (void)parseData:(NSData *)data |
277 | 281 | { |
278 | 282 | if ([_tree parseData:data]) { |
279 | 283 | [self fillWithElements:[_tree components]]; |
280 | NSLog(@"iCalStore from %@ : loaded %d appointment(s)", [_url absoluteString], [[self events] count]); | |
281 | NSLog(@"iCalStore from %@ : loaded %d tasks(s)", [_url absoluteString], [[self tasks] count]); | |
284 | NSLog(@"iCalStore from %@ : loaded %d appointment(s)", [_url anonymousAbsoluteString], [[self events] count]); | |
285 | NSLog(@"iCalStore from %@ : loaded %d tasks(s)", [_url anonymousAbsoluteString], [[self tasks] count]); | |
282 | 286 | } else |
283 | NSLog(@"Couldn't parse data from %@", [_url absoluteString]); | |
287 | NSLog(@"Couldn't parse data from %@", [_url anonymousAbsoluteString]); | |
284 | 288 | } |
285 | 289 | - (void)initTimer |
286 | 290 | { |