mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-27 22:35:22 +00:00
Now possible to set alarms on event invitations
This commit is contained in:
@@ -9,6 +9,7 @@ Appointments_PRINCIPAL_CLASS = SOGoAppointmentsProduct
|
||||
Appointments_OBJC_FILES = \
|
||||
Product.m \
|
||||
NSArray+Appointments.m \
|
||||
iCalAlarm+SOGo.m \
|
||||
iCalCalendar+SOGo.m \
|
||||
iCalEntityObject+SOGo.m \
|
||||
iCalRepeatableEntityObject+SOGo.m \
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
@class WORequest;
|
||||
|
||||
@class iCalAlarm;
|
||||
@class iCalEvent;
|
||||
@class iCalCalendar;
|
||||
|
||||
@@ -38,9 +39,12 @@
|
||||
@interface SOGoAppointmentObject : SOGoCalendarComponent
|
||||
|
||||
- (NSException *) changeParticipationStatus: (NSString *) status
|
||||
withDelegate: (iCalPerson *) delegate;
|
||||
withDelegate: (iCalPerson *) delegate
|
||||
alarm: (iCalAlarm *) alarm;
|
||||
|
||||
- (NSException *) changeParticipationStatus: (NSString *) status
|
||||
withDelegate: (iCalPerson *) delegate
|
||||
alarm: (iCalAlarm *) alarm
|
||||
forRecurrenceId: (NSCalendarDate *) _recurrenceId;
|
||||
|
||||
//
|
||||
|
||||
@@ -1309,6 +1309,9 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
|
||||
return ex;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
- (NSDictionary *) _caldavSuccessCodeWithRecipient: (NSString *) recipient
|
||||
{
|
||||
NSMutableArray *element;
|
||||
@@ -1391,9 +1394,11 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
|
||||
//
|
||||
- (NSException *) changeParticipationStatus: (NSString *) status
|
||||
withDelegate: (iCalPerson *) delegate
|
||||
alarm: (iCalAlarm *) alarm
|
||||
{
|
||||
return [self changeParticipationStatus: status
|
||||
withDelegate: delegate
|
||||
alarm: alarm
|
||||
forRecurrenceId: nil];
|
||||
}
|
||||
|
||||
@@ -1402,6 +1407,7 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
|
||||
//
|
||||
- (NSException *) changeParticipationStatus: (NSString *) _status
|
||||
withDelegate: (iCalPerson *) delegate
|
||||
alarm: (iCalAlarm *) alarm
|
||||
forRecurrenceId: (NSCalendarDate *) _recurrenceId
|
||||
{
|
||||
iCalCalendar *calendar;
|
||||
@@ -1479,7 +1485,18 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
|
||||
// Over DAV, it'll be handled directly in PUTAction:
|
||||
if (![context request] || [[context request] handledByDefaultHandler]
|
||||
|| [[[context request] requestHandlerKey] isEqualToString: @"Microsoft-Server-ActiveSync"])
|
||||
ex = [self saveCalendar: [event parent]];
|
||||
{
|
||||
// If an alarm was specified, let's use it. This would happen if an attendee accepts/declines/etc. an
|
||||
// event invitation and also sets an alarm along the way. This would happen ONLY from the web interface.
|
||||
[event removeAllAlarms];
|
||||
|
||||
if (alarm)
|
||||
{
|
||||
[event addToAlarms: alarm];
|
||||
}
|
||||
|
||||
ex = [self saveCalendar: [event parent]];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1512,17 +1529,17 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
|
||||
[v caseInsensitiveCompare: @"CLIENT"] == NSOrderedSame)
|
||||
b = NO;
|
||||
}
|
||||
|
||||
//
|
||||
// If we have to deal with Thunderbird/Lightning, we always send invitation
|
||||
// reponses, as Lightning v2.6 (at least this version) sets SCHEDULE-AGENT
|
||||
// to NONE/CLIENT when responding to an external invitation received by
|
||||
// SOGo - so no invitation responses are ever sent by Lightning. See
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=865726 and
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=997784
|
||||
//
|
||||
userAgents = [[context request] headersForKey: @"User-Agent"];
|
||||
|
||||
|
||||
//
|
||||
// If we have to deal with Thunderbird/Lightning, we always send invitation
|
||||
// reponses, as Lightning v2.6 (at least this version) sets SCHEDULE-AGENT
|
||||
// to NONE/CLIENT when responding to an external invitation received by
|
||||
// SOGo - so no invitation responses are ever sent by Lightning. See
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=865726 and
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=997784
|
||||
//
|
||||
userAgents = [[context request] headersForKey: @"User-Agent"];
|
||||
|
||||
for (i = 0; i < [userAgents count]; i++)
|
||||
{
|
||||
if ([[userAgents objectAtIndex: i] rangeOfString: @"Thunderbird"].location != NSNotFound &&
|
||||
@@ -1533,7 +1550,6 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
@@ -1594,7 +1610,9 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
|
||||
{
|
||||
// The current user deletes the occurence; let the organizer know that
|
||||
// the user has declined this occurence.
|
||||
[self changeParticipationStatus: @"DECLINED" withDelegate: nil
|
||||
[self changeParticipationStatus: @"DECLINED"
|
||||
withDelegate: nil
|
||||
alarm: nil
|
||||
forRecurrenceId: recurrenceId];
|
||||
send_receipt = NO;
|
||||
}
|
||||
@@ -2161,12 +2179,14 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
|
||||
{
|
||||
[self changeParticipationStatus: @"DECLINED"
|
||||
withDelegate: nil // FIXME (specify delegate?)
|
||||
alarm: nil
|
||||
forRecurrenceId: [self _addedExDate: oldEvent newEvent: newEvent]];
|
||||
}
|
||||
else if (attendee)
|
||||
{
|
||||
[self changeParticipationStatus: [attendee partStat]
|
||||
withDelegate: delegate
|
||||
alarm: nil
|
||||
forRecurrenceId: recurrenceId];
|
||||
}
|
||||
// All attendees and the organizer field were removed. Apple iCal does
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
@class NSException;
|
||||
|
||||
@class iCalAlarm;
|
||||
@class iCalCalendar;
|
||||
@class iCalPerson;
|
||||
@class iCalRepeatableEntityObject;
|
||||
@@ -37,7 +38,8 @@
|
||||
- (BOOL) isNew;
|
||||
|
||||
- (NSException *) changeParticipationStatus: (NSString *) newPartStat
|
||||
withDelegate: (iCalPerson *) delegate;
|
||||
withDelegate: (iCalPerson *) delegate
|
||||
alarm: (iCalAlarm *) alarm;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -215,6 +215,7 @@
|
||||
they should be siblings or SOGoComponentOccurence the parent class of SOGoCalendarComponent...
|
||||
- (NSException *) changeParticipationStatus: (NSString *) newStatus
|
||||
withDelegate: (iCalPerson *) delegate
|
||||
alarm: (iCalAlarm *) alarm
|
||||
{
|
||||
NSCalendarDate *date;
|
||||
|
||||
@@ -222,6 +223,7 @@
|
||||
|
||||
return [container changeParticipationStatus: newStatus
|
||||
withDelegate: delegate
|
||||
alarm: alarm
|
||||
forRecurrenceId: date];
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/* iCalAlarm+SOGo.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2014 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
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#import <NGCards/iCalAlarm.h>
|
||||
|
||||
@class iCalRepeatableEntityObject;
|
||||
|
||||
@interface iCalAlarm (SOGoExtensions)
|
||||
|
||||
+ (id) alarmForEvent: (iCalRepeatableEntityObject *) theEntity
|
||||
owner: (NSString *) theOwner
|
||||
action: (NSString *) reminderAction
|
||||
unit: (NSString *) reminderUnit
|
||||
quantity: (NSString *) reminderQuantity
|
||||
reference: (NSString *) reminderReference
|
||||
reminderRelation: (NSString *) reminderRelation
|
||||
emailAttendees: (BOOL) reminderEmailAttendees
|
||||
emailOrganizer: (BOOL) reminderEmailOrganizer;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,127 @@
|
||||
/* iCalAlarm+SOGo.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2014 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
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#import "iCalAlarm+SOGo.h"
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
#import <SOGo/SOGoUser.h>
|
||||
|
||||
#import <NGCards/iCalPerson.h>
|
||||
#import <NGCards/iCalTrigger.h>
|
||||
|
||||
@implementation iCalAlarm (SOGoExtensions)
|
||||
|
||||
- (void) _appendAttendees: (NSArray *) attendees
|
||||
toEmailAlarm: (iCalAlarm *) alarm
|
||||
{
|
||||
NSMutableArray *aAttendees;
|
||||
int count, max;
|
||||
iCalPerson *currentAttendee, *aAttendee;
|
||||
|
||||
max = [attendees count];
|
||||
aAttendees = [NSMutableArray arrayWithCapacity: max];
|
||||
for (count = 0; count < max; count++)
|
||||
{
|
||||
currentAttendee = [attendees objectAtIndex: count];
|
||||
aAttendee = [iCalPerson elementWithTag: @"attendee"];
|
||||
[aAttendee setCn: [currentAttendee cn]];
|
||||
[aAttendee setEmail: [currentAttendee rfc822Email]];
|
||||
[aAttendees addObject: aAttendee];
|
||||
}
|
||||
[alarm setAttendees: aAttendees];
|
||||
}
|
||||
|
||||
- (void) _appendOrganizerToEmailAlarm: (iCalAlarm *) alarm
|
||||
owner: (NSString *) uid
|
||||
{
|
||||
NSDictionary *ownerIdentity;
|
||||
iCalPerson *aAttendee;
|
||||
|
||||
ownerIdentity = [[SOGoUser userWithLogin: uid roles: nil]
|
||||
defaultIdentity];
|
||||
aAttendee = [iCalPerson elementWithTag: @"attendee"];
|
||||
[aAttendee setCn: [ownerIdentity objectForKey: @"fullName"]];
|
||||
[aAttendee setEmail: [ownerIdentity objectForKey: @"email"]];
|
||||
[alarm addChild: aAttendee];
|
||||
}
|
||||
|
||||
+ (id) alarmForEvent: (iCalRepeatableEntityObject *) theEntity
|
||||
owner: (NSString *) theOwner
|
||||
action: (NSString *) reminderAction
|
||||
unit: (NSString *) reminderUnit
|
||||
quantity: (NSString *) reminderQuantity
|
||||
reference: (NSString *) reminderReference
|
||||
reminderRelation: (NSString *) reminderRelation
|
||||
emailAttendees: (BOOL) reminderEmailAttendees
|
||||
emailOrganizer: (BOOL) reminderEmailOrganizer
|
||||
{
|
||||
iCalTrigger *aTrigger;
|
||||
iCalAlarm *anAlarm;
|
||||
NSString *aValue;
|
||||
|
||||
anAlarm = [[self alloc] init];
|
||||
|
||||
aTrigger = [iCalTrigger elementWithTag: @"TRIGGER"];
|
||||
[aTrigger setValueType: @"DURATION"];
|
||||
[anAlarm setTrigger: aTrigger];
|
||||
|
||||
if ([reminderAction length] > 0 && [reminderUnit length] > 0)
|
||||
{
|
||||
[anAlarm setAction: [reminderAction uppercaseString]];
|
||||
if ([reminderAction isEqualToString: @"email"])
|
||||
{
|
||||
[anAlarm removeAllAttendees];
|
||||
if (reminderEmailAttendees)
|
||||
[anAlarm _appendAttendees: [theEntity attendees]
|
||||
toEmailAlarm: anAlarm];
|
||||
if (reminderEmailOrganizer)
|
||||
[anAlarm _appendOrganizerToEmailAlarm: anAlarm owner: theOwner];
|
||||
[anAlarm setSummary: [theEntity summary]];
|
||||
[anAlarm setComment: [theEntity comment]];
|
||||
}
|
||||
|
||||
if ([reminderReference caseInsensitiveCompare: @"BEFORE"] == NSOrderedSame)
|
||||
aValue = [NSString stringWithString: @"-P"];
|
||||
else
|
||||
aValue = [NSString stringWithString: @"P"];
|
||||
|
||||
if ([reminderUnit caseInsensitiveCompare: @"MINUTES"] == NSOrderedSame ||
|
||||
[reminderUnit caseInsensitiveCompare: @"HOURS"] == NSOrderedSame)
|
||||
aValue = [aValue stringByAppendingString: @"T"];
|
||||
|
||||
aValue = [aValue stringByAppendingFormat: @"%i%@",
|
||||
[reminderQuantity intValue],
|
||||
[reminderUnit substringToIndex: 1]];
|
||||
[aTrigger setSingleValue: aValue forKey: @""];
|
||||
[aTrigger setRelationType: reminderRelation];
|
||||
}
|
||||
else
|
||||
{
|
||||
[anAlarm release];
|
||||
anAlarm = nil;
|
||||
}
|
||||
|
||||
return AUTORELEASE(anAlarm);
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user