Skip to content

Commit

Permalink
(feat) first pass at support for recurring events/tasks email alarms …
Browse files Browse the repository at this point in the history
…(fixes #1053)
  • Loading branch information
extrafu committed Nov 2, 2016
1 parent 8cadf5c commit 78045b1
Show file tree
Hide file tree
Showing 17 changed files with 209 additions and 244 deletions.
3 changes: 3 additions & 0 deletions NEWS
@@ -1,6 +1,9 @@
3.2.2 (2016-11-DD)
------------------

New features
- [core] support repetitive email alarms on tasks and events (#1053)

Bug fixes
- [web] fixed mail settings persistence when sorting by arrival date

Expand Down
6 changes: 1 addition & 5 deletions SOPE/GDLContentStore/GCSAlarmsFolder.h
@@ -1,8 +1,6 @@
/* GCSAlarmsFolder.h - this file is part of $PROJECT_NAME_HERE$
*
* Copyright (C) 2010 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* Copyright (C) 2010-2016 Inverse inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -60,8 +58,6 @@
- (void) deleteRecordForEntryWithCName: (NSString *) cname
inCalendarAtPath: (NSString *) path;

- (void) deleteRecordsForEntriesUntilDate: (NSCalendarDate *) date;

@end

#endif /* GCSALARMSFOLDER_H */
34 changes: 1 addition & 33 deletions SOPE/GDLContentStore/GCSAlarmsFolder.m
@@ -1,6 +1,6 @@
/* GCSAlarmsFolder.m - this file is part of SOGo
*
* Copyright (C) 2010-2014 Inverse inc.
* Copyright (C) 2010-2016 Inverse inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -409,36 +409,4 @@ - (void) deleteRecordForEntryWithCName: (NSString *) cname
}
}

- (void) deleteRecordsForEntriesUntilDate: (NSCalendarDate *) date
{
EOAdaptorChannel *tc;
EOAdaptorContext *context;
EOEntity *entity;
EOSQLQualifier *qualifier;
NSException *error;

tc = [self _acquireStoreChannel];
if (tc)
{
context = [tc adaptorContext];
entity = [self _storeTableEntityForChannel: tc];
qualifier = [[EOSQLQualifier alloc] initWithEntity: entity
qualifierFormat:
@"c_alarm_date <= %d",
(int) [date timeIntervalSince1970]];
[qualifier autorelease];
[context beginTransaction];
error = [tc deleteRowsDescribedByQualifierX: qualifier];
if (error)
{
[context rollbackTransaction];
[self errorWithFormat:@"%s: cannot delete record: %@",
__PRETTY_FUNCTION__, error];
}
else
[context commitTransaction];
[self _releaseChannel: tc];
}
}

@end
16 changes: 15 additions & 1 deletion SOPE/GDLContentStore/GCSFolder.m
Expand Up @@ -1017,7 +1017,21 @@ - (NSException *) writeContent: (NSString *) _content
|| *_baseVersion == [storedVersion unsignedIntValue])
{
/* extract quick info */
quickRow = [theComponent performSelector: @selector(quickRecordFromContent:container:) withObject: _content withObject: theContainer];
NSMethodSignature *aSignature;
NSInvocation *anInvocation;
SEL aSelector;

aSelector = @selector(quickRecordFromContent:container:nameInContainer:);
aSignature = [[theComponent class] instanceMethodSignatureForSelector: aSelector];
anInvocation = [NSInvocation invocationWithMethodSignature:aSignature];
[anInvocation setSelector: aSelector];
[anInvocation setTarget: theComponent];
[anInvocation setArgument:&_content atIndex: 2];
[anInvocation setArgument:&theContainer atIndex: 3];
[anInvocation setArgument:&_name atIndex: 4];
[anInvocation invoke];
[anInvocation getReturnValue: &quickRow];

if (quickRow)
{
[quickRow setObject:_name forKey:@"c_name"];
Expand Down
6 changes: 3 additions & 3 deletions SoObjects/Appointments/SOGoAppointmentFolder.m
Expand Up @@ -954,7 +954,7 @@ - (void) _computeAlarmForRow: (NSMutableDictionary *) row
// alarm defined.
if ([[component alarms] count])
{
alarm = [component firstDisplayOrAudioAlarm];
alarm = [component firstSupportedAlarm];
[row setObject: [NSNumber numberWithInt: [[alarm nextAlarmDate] timeIntervalSince1970]]
forKey: @"c_nextalarm"];
}
Expand Down Expand Up @@ -1030,7 +1030,7 @@ - (void) _appendCycleException: (iCalRepeatableEntityObject *) component
(endDate && [dateRange containsDate: endDate]))
{
// We must pass nil to :container here in order to avoid re-entrancy issues.
newRecord = [self _fixupRecord: [component quickRecordFromContent: nil container: nil]];
newRecord = [self _fixupRecord: [component quickRecordFromContent: nil container: nil nameInContainer: nil]];
[ma replaceObjectAtIndex: recordIndex withObject: newRecord];
}
else
Expand All @@ -1047,7 +1047,7 @@ - (void) _appendCycleException: (iCalRepeatableEntityObject *) component
// The recurrence id of the exception is outside the date range;
// simply add the exception to the records array.
// We must pass nil to :container here in order to avoid re-entrancy issues.
newRecord = [self _fixupRecord: [component quickRecordFromContent: nil container: nil]];
newRecord = [self _fixupRecord: [component quickRecordFromContent: nil container: nil nameInContainer: nil]];
if ([newRecord objectForKey: @"startDate"] && [newRecord objectForKey: @"endDate"]) {
newRecordRange = [NGCalendarDateRange
calendarDateRangeWithStartDate: [newRecord objectForKey: @"startDate"]
Expand Down
26 changes: 0 additions & 26 deletions SoObjects/Appointments/SOGoCalendarComponent.m
Expand Up @@ -683,15 +683,6 @@ - (void) updateComponent: (iCalRepeatableEntityObject *) newObject
newUid = [newUid substringToIndex: [newUid length]-4];
[newObject setUid: newUid];
}

if ([[SOGoSystemDefaults sharedSystemDefaults] enableEMailAlarms])
{
SOGoEMailAlarmsManager *eaMgr;

eaMgr = [SOGoEMailAlarmsManager sharedEMailAlarmsManager];
[eaMgr handleAlarmsInCalendar: [newObject parent]
fromComponent: self];
}
}

- (NSException *) saveCalendar: (iCalCalendar *) newCalendar
Expand Down Expand Up @@ -1459,23 +1450,6 @@ - (NSException *) prepareDelete
return nil;
}

- (id) PUTAction: (WOContext *) localContext
{
if ([[SOGoSystemDefaults sharedSystemDefaults] enableEMailAlarms])
{
SOGoEMailAlarmsManager *eaMgr;
iCalCalendar *putCalendar;
WORequest *rq;

rq = [localContext request];
putCalendar = [iCalCalendar parseSingleFromSource: [rq contentAsString]];
eaMgr = [SOGoEMailAlarmsManager sharedEMailAlarmsManager];
[eaMgr handleAlarmsInCalendar: putCalendar
fromComponent: self];
}

return [super PUTAction: localContext];
}

// /* Overriding this method dramatically speeds up PROPFIND request, but may
// otherwise be a bad idea... Wait and see. */
Expand Down
5 changes: 2 additions & 3 deletions SoObjects/Appointments/SOGoEMailAlarmsManager.h
@@ -1,6 +1,6 @@
/* SOGoEMailAlarmsManager.h - this file is part of SOGo
*
* Copyright (C) 2010-2014 Inverse inc.
* Copyright (C) 2010-2016 Inverse inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -42,8 +42,7 @@
/* fetch and cleanup */
- (NSArray *) scheduledAlarmsFromDate: (NSCalendarDate *) fromDate
toDate: (NSCalendarDate *) toDate
withOwners: (NSMutableArray **) owners;
- (void) deleteAlarmsUntilDate: (NSCalendarDate *) untilDate;
withMetadata: (NSMutableArray *) metadata;

@end

Expand Down

0 comments on commit 78045b1

Please sign in to comment.