2006-06-15 21:34:10 +02:00
|
|
|
/*
|
|
|
|
Copyright (C) 2000-2005 SKYRIX Software AG
|
2009-04-01 15:49:24 +02:00
|
|
|
Copyright (C) 2006-2009 Inverse inc.
|
2008-10-01 18:14:56 +02:00
|
|
|
|
2009-04-01 15:49:24 +02:00
|
|
|
This file is part of SOGo.
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2009-04-01 15:49:24 +02:00
|
|
|
SOGo is free software; you can redistribute it and/or modify it under
|
2006-06-15 21:34:10 +02:00
|
|
|
the terms of the GNU Lesser General Public License as published by the
|
|
|
|
Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
later version.
|
|
|
|
|
2009-04-01 15:49:24 +02:00
|
|
|
SOGo is distributed in the hope that it will be useful, but WITHOUT ANY
|
2006-06-15 21:34:10 +02:00
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
|
|
License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with OGo; see the file COPYING. If not, write to the
|
|
|
|
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2007-08-07 20:37:31 +02:00
|
|
|
#import <Foundation/NSCharacterSet.h>
|
|
|
|
#import <Foundation/NSCalendarDate.h>
|
|
|
|
#import <Foundation/NSTimeZone.h>
|
|
|
|
|
|
|
|
#import <NGObjWeb/WOActionResults.h>
|
2010-05-25 21:40:46 +02:00
|
|
|
#import <NGObjWeb/WOContext+SoObjects.h>
|
2008-07-29 18:36:16 +02:00
|
|
|
#import <NGObjWeb/WOResponse.h>
|
2007-08-07 20:37:31 +02:00
|
|
|
#import <NGExtensions/NSObject+Logs.h>
|
2010-04-09 20:45:14 +02:00
|
|
|
#import <NGCards/iCalEvent.h>
|
2008-10-01 21:32:14 +02:00
|
|
|
#import <NGCards/iCalPerson.h>
|
2006-09-28 19:24:12 +02:00
|
|
|
|
2010-04-09 20:45:14 +02:00
|
|
|
#import <SOGo/NSDictionary+Utilities.h>
|
|
|
|
#import <SOGo/NSObject+Utilities.h>
|
|
|
|
#import <SOGo/NSString+Utilities.h>
|
2010-05-25 21:40:46 +02:00
|
|
|
#import <SOGo/SOGoUser.h>
|
|
|
|
#import <SOGo/SOGoUserDefaults.h>
|
2007-08-24 00:11:55 +02:00
|
|
|
|
2009-04-01 15:49:24 +02:00
|
|
|
#import "iCalPerson+SOGo.h"
|
2006-09-28 19:24:12 +02:00
|
|
|
#import "SOGoAptMailNotification.h"
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2008-10-01 18:14:56 +02:00
|
|
|
@implementation SOGoAptMailNotification
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2008-10-01 21:32:14 +02:00
|
|
|
- (id) init
|
2008-10-01 18:14:56 +02:00
|
|
|
{
|
2008-10-01 21:32:14 +02:00
|
|
|
if ((self = [super init]))
|
|
|
|
{
|
|
|
|
apt = nil;
|
2010-04-09 20:45:14 +02:00
|
|
|
values = nil;
|
2008-10-01 21:32:14 +02:00
|
|
|
}
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2008-10-01 21:32:14 +02:00
|
|
|
return self;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
2007-11-12 20:54:16 +01:00
|
|
|
|
2008-10-01 21:32:14 +02:00
|
|
|
- (void) dealloc
|
2008-10-01 18:14:56 +02:00
|
|
|
{
|
2010-04-09 20:45:14 +02:00
|
|
|
[values release];
|
2008-10-01 21:32:14 +02:00
|
|
|
[apt release];
|
2008-11-18 01:06:37 +01:00
|
|
|
[previousApt release];
|
2008-10-24 18:12:21 +02:00
|
|
|
[organizerName release];
|
2008-11-18 01:06:37 +01:00
|
|
|
[viewTZ release];
|
|
|
|
[oldStartDate release];
|
|
|
|
[newStartDate release];
|
2008-10-01 21:32:14 +02:00
|
|
|
[super dealloc];
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2010-04-09 20:45:14 +02:00
|
|
|
- (iCalEvent *) apt
|
2008-10-01 18:14:56 +02:00
|
|
|
{
|
2008-10-01 21:32:14 +02:00
|
|
|
return apt;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
2008-10-01 18:14:56 +02:00
|
|
|
|
2010-04-09 20:45:14 +02:00
|
|
|
- (void) setApt: (iCalEvent *) theApt
|
2008-10-01 18:14:56 +02:00
|
|
|
{
|
2010-04-09 20:45:14 +02:00
|
|
|
ASSIGN (apt, theApt);
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2010-04-09 20:45:14 +02:00
|
|
|
- (iCalEvent *) previousApt
|
2008-11-18 01:06:37 +01:00
|
|
|
{
|
|
|
|
return previousApt;
|
|
|
|
}
|
|
|
|
|
2010-04-09 20:45:14 +02:00
|
|
|
- (void) setPreviousApt: (iCalEvent *) theApt
|
2008-11-18 01:06:37 +01:00
|
|
|
{
|
2010-04-09 20:45:14 +02:00
|
|
|
ASSIGN (previousApt, theApt);
|
2008-11-18 01:06:37 +01:00
|
|
|
}
|
|
|
|
|
2008-11-28 21:12:22 +01:00
|
|
|
- (BOOL) hasNewLocation
|
|
|
|
{
|
|
|
|
return ([[apt location] length] > 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) hasOldLocation
|
|
|
|
{
|
|
|
|
return ([[previousApt location] length] > 0);
|
|
|
|
}
|
|
|
|
|
2008-11-18 01:06:37 +01:00
|
|
|
- (NSCalendarDate *) oldStartDate
|
|
|
|
{
|
2010-04-09 20:45:14 +02:00
|
|
|
if (!oldStartDate)
|
2008-11-18 01:06:37 +01:00
|
|
|
{
|
2010-04-09 20:45:14 +02:00
|
|
|
ASSIGN (oldStartDate, [[self previousApt] startDate]);
|
2010-05-25 21:40:46 +02:00
|
|
|
[oldStartDate setTimeZone: viewTZ];
|
2008-11-18 01:06:37 +01:00
|
|
|
}
|
2010-04-09 20:45:14 +02:00
|
|
|
return oldStartDate;
|
2008-11-18 01:06:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSCalendarDate *) newStartDate
|
|
|
|
{
|
2010-04-09 20:45:14 +02:00
|
|
|
if (!newStartDate)
|
2008-11-18 01:06:37 +01:00
|
|
|
{
|
2010-04-09 20:45:14 +02:00
|
|
|
ASSIGN (newStartDate, [[self apt] startDate]);
|
2010-05-25 21:40:46 +02:00
|
|
|
[newStartDate setTimeZone: viewTZ];
|
2008-11-18 01:06:37 +01:00
|
|
|
}
|
2010-04-09 20:45:14 +02:00
|
|
|
return newStartDate;
|
2008-10-01 18:14:56 +02:00
|
|
|
}
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2008-10-01 21:32:14 +02:00
|
|
|
- (NSString *) summary
|
2008-10-01 18:14:56 +02:00
|
|
|
{
|
2008-10-01 21:32:14 +02:00
|
|
|
return [apt summary];
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2008-10-24 18:12:21 +02:00
|
|
|
- (void) setOrganizerName: (NSString *) theString
|
|
|
|
{
|
2010-04-09 20:45:14 +02:00
|
|
|
ASSIGN (organizerName, theString);
|
2008-10-24 18:12:21 +02:00
|
|
|
}
|
|
|
|
|
2008-10-01 21:32:14 +02:00
|
|
|
- (NSString *) organizerName
|
2008-10-01 18:14:56 +02:00
|
|
|
{
|
2008-10-24 18:12:21 +02:00
|
|
|
return organizerName;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2008-10-01 21:32:14 +02:00
|
|
|
/* Helpers */
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
/* Generate Response */
|
|
|
|
|
2008-10-01 18:14:56 +02:00
|
|
|
- (NSString *) getSubject
|
|
|
|
{
|
2010-04-09 20:45:14 +02:00
|
|
|
[self subclassResponsibility: _cmd];
|
2007-08-24 00:11:55 +02:00
|
|
|
|
2010-04-09 20:45:14 +02:00
|
|
|
return nil;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2008-10-01 18:14:56 +02:00
|
|
|
- (NSString *) getBody
|
|
|
|
{
|
2010-04-09 20:45:14 +02:00
|
|
|
[self subclassResponsibility: _cmd];
|
2009-08-25 23:28:24 +02:00
|
|
|
|
2010-04-09 20:45:14 +02:00
|
|
|
return nil;
|
|
|
|
}
|
2008-10-01 18:14:56 +02:00
|
|
|
|
2010-04-09 20:45:14 +02:00
|
|
|
- (void) setupValues
|
|
|
|
{
|
|
|
|
NSDictionary *sentByValues;
|
|
|
|
NSString *sentBy, *sentByText;
|
2010-05-25 21:40:46 +02:00
|
|
|
SOGoUser *user;
|
|
|
|
|
|
|
|
user = [context activeUser];
|
|
|
|
viewTZ = [[user userDefaults] timeZone];
|
|
|
|
[viewTZ retain];
|
2009-08-25 23:28:24 +02:00
|
|
|
|
2010-04-09 20:45:14 +02:00
|
|
|
values = [NSMutableDictionary new];
|
|
|
|
[values setObject: [self summary] forKey: @"Summary"];
|
|
|
|
if (organizerName)
|
|
|
|
{
|
|
|
|
[values setObject: organizerName forKey: @"Organizer"];
|
|
|
|
|
|
|
|
sentBy = [[apt organizer] sentBy];
|
|
|
|
if ([sentBy length])
|
|
|
|
{
|
|
|
|
sentByValues = [NSDictionary dictionaryWithObject: sentBy
|
|
|
|
forKey: @"SentBy"];
|
|
|
|
sentByText
|
|
|
|
= [sentByValues keysWithFormat: [self
|
2010-07-08 06:47:28 +02:00
|
|
|
labelForKey: @"(sent by %{SentBy}) "
|
2010-04-09 20:45:14 +02:00
|
|
|
inContext: context]];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
sentByText = @"";
|
|
|
|
[values setObject: sentByText forKey: @"SentByText"];
|
|
|
|
}
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|