2006-06-15 21:34:10 +02:00
|
|
|
/*
|
|
|
|
Copyright (C) 2000-2005 SKYRIX Software AG
|
2008-10-01 18:14:56 +02:00
|
|
|
Copyright (C) 2006-2008 Inverse inc.
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
This file is part of OpenGroupware.org.
|
|
|
|
|
|
|
|
OGo is free software; you can redistribute it and/or modify it under
|
|
|
|
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.
|
|
|
|
|
|
|
|
OGo 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 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>
|
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>
|
2006-10-20 23:13:18 +02:00
|
|
|
#import <NGCards/iCalEntityObject.h>
|
2008-10-01 21:32:14 +02:00
|
|
|
#import <NGCards/iCalPerson.h>
|
2006-09-28 19:24:12 +02:00
|
|
|
|
2007-08-24 00:11:55 +02:00
|
|
|
#import <SoObjects/SOGo/NSString+Utilities.h>
|
|
|
|
|
2006-09-28 19:24:12 +02:00
|
|
|
#import "SOGoAptMailNotification.h"
|
2006-06-15 21:34:10 +02:00
|
|
|
|
|
|
|
@interface SOGoAptMailNotification (PrivateAPI)
|
|
|
|
|
2008-10-01 18:14:56 +02:00
|
|
|
- (BOOL) isSubject;
|
|
|
|
- (void) setIsSubject: (BOOL) newIsSubject;
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2008-10-01 18:14:56 +02:00
|
|
|
@end
|
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 18:14:56 +02:00
|
|
|
static NSCharacterSet *wsSet = nil;
|
|
|
|
static NSTimeZone *UTC = nil;
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2008-10-01 18:14:56 +02:00
|
|
|
+ (void) initialize
|
|
|
|
{
|
|
|
|
if (!wsSet)
|
|
|
|
{
|
|
|
|
wsSet = [[NSCharacterSet whitespaceAndNewlineCharacterSet] retain];
|
|
|
|
UTC = [[NSTimeZone timeZoneWithAbbreviation: @"UTC"] retain];
|
|
|
|
}
|
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;
|
|
|
|
}
|
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
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
2008-10-01 21:32:14 +02:00
|
|
|
- (iCalEntityObject *) 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
|
|
|
|
2008-11-18 01:06:37 +01:00
|
|
|
- (void) setApt: (iCalEntityObject *) theApt
|
2008-10-01 18:14:56 +02:00
|
|
|
{
|
2008-11-18 01:06:37 +01:00
|
|
|
ASSIGN(apt, theApt);
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2008-11-18 01:06:37 +01:00
|
|
|
- (iCalEntityObject *) previousApt
|
|
|
|
{
|
|
|
|
return previousApt;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setPreviousApt: (iCalEntityObject *) theApt
|
|
|
|
{
|
|
|
|
ASSIGN(previousApt, theApt);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
- (NSTimeZone *) viewTZ
|
|
|
|
{
|
|
|
|
if (self->viewTZ) return self->viewTZ;
|
|
|
|
return UTC;
|
|
|
|
}
|
|
|
|
- (void) setViewTZ: (NSTimeZone *) _viewTZ
|
|
|
|
{
|
|
|
|
ASSIGN(self->viewTZ, _viewTZ);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSCalendarDate *) oldStartDate
|
|
|
|
{
|
|
|
|
if (!self->oldStartDate)
|
|
|
|
{
|
|
|
|
ASSIGN(self->oldStartDate, [[self previousApt] startDate]);
|
|
|
|
[self->oldStartDate setTimeZone: [self viewTZ]];
|
|
|
|
}
|
|
|
|
return self->oldStartDate;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSCalendarDate *) newStartDate
|
|
|
|
{
|
|
|
|
if (!self->newStartDate)
|
|
|
|
{
|
|
|
|
ASSIGN(self->newStartDate, [[self apt] startDate]);
|
|
|
|
[self->newStartDate setTimeZone:[self viewTZ]];
|
|
|
|
}
|
|
|
|
return self->newStartDate;
|
|
|
|
}
|
2008-10-01 18:14:56 +02:00
|
|
|
|
|
|
|
- (BOOL) isSubject
|
|
|
|
{
|
|
|
|
return isSubject;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2008-10-01 18:14:56 +02:00
|
|
|
- (void) setIsSubject: (BOOL) newIsSubject
|
|
|
|
{
|
|
|
|
isSubject = newIsSubject;
|
|
|
|
}
|
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
|
|
|
|
{
|
|
|
|
ASSIGN(organizerName, theString);
|
|
|
|
}
|
|
|
|
|
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-11-05 22:04:16 +01:00
|
|
|
- (BOOL) hasSentBy
|
|
|
|
{
|
|
|
|
return [[apt organizer] hasSentBy];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) sentBy
|
|
|
|
{
|
|
|
|
return [[apt organizer] sentBy];
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
NSString *subject;
|
|
|
|
|
2008-10-01 18:14:56 +02:00
|
|
|
[self setIsSubject: YES];
|
2006-06-15 21:34:10 +02:00
|
|
|
subject = [[[self generateResponse] contentAsString]
|
2008-10-01 21:32:14 +02:00
|
|
|
stringByTrimmingCharactersInSet: wsSet];
|
2008-10-01 18:14:56 +02:00
|
|
|
if (!subject)
|
|
|
|
{
|
|
|
|
[self errorWithFormat:@"Failed to properly generate subject! Please check "
|
|
|
|
@"template for component '%@'!",
|
|
|
|
[self name]];
|
|
|
|
subject = @"ERROR: missing subject!";
|
|
|
|
}
|
2007-08-24 00:11:55 +02:00
|
|
|
|
|
|
|
return [subject asQPSubjectString: @"utf-8"];
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2008-10-01 18:14:56 +02:00
|
|
|
- (NSString *) getBody
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
[self setIsSubject:NO];
|
2008-10-01 18:14:56 +02:00
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
return [[self generateResponse] contentAsString];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|