Monotone-Parent: 0400894ebb0d9305dae91e6efb9e8a62a36e6d5b Monotone-Revision: 814be30289e980e05d1340e3dc8d3bad9155344d Monotone-Author: ludovic@Sophos.ca Monotone-Date: 2008-11-18T00:06:37 Monotone-Branch: ca.inverse.sogo
194 lines
3.7 KiB
Objective-C
194 lines
3.7 KiB
Objective-C
/*
|
|
Copyright (C) 2000-2005 SKYRIX Software AG
|
|
Copyright (C) 2006-2008 Inverse inc.
|
|
|
|
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.
|
|
*/
|
|
|
|
#import <Foundation/NSCharacterSet.h>
|
|
#import <Foundation/NSCalendarDate.h>
|
|
#import <Foundation/NSTimeZone.h>
|
|
|
|
#import <NGObjWeb/WOActionResults.h>
|
|
#import <NGObjWeb/WOResponse.h>
|
|
#import <NGExtensions/NSObject+Logs.h>
|
|
#import <NGCards/iCalEntityObject.h>
|
|
#import <NGCards/iCalPerson.h>
|
|
|
|
#import <SoObjects/SOGo/NSString+Utilities.h>
|
|
|
|
#import "SOGoAptMailNotification.h"
|
|
|
|
@interface SOGoAptMailNotification (PrivateAPI)
|
|
|
|
- (BOOL) isSubject;
|
|
- (void) setIsSubject: (BOOL) newIsSubject;
|
|
|
|
@end
|
|
|
|
@implementation SOGoAptMailNotification
|
|
|
|
static NSCharacterSet *wsSet = nil;
|
|
static NSTimeZone *UTC = nil;
|
|
|
|
+ (void) initialize
|
|
{
|
|
if (!wsSet)
|
|
{
|
|
wsSet = [[NSCharacterSet whitespaceAndNewlineCharacterSet] retain];
|
|
UTC = [[NSTimeZone timeZoneWithAbbreviation: @"UTC"] retain];
|
|
}
|
|
}
|
|
|
|
- (id) init
|
|
{
|
|
if ((self = [super init]))
|
|
{
|
|
apt = nil;
|
|
}
|
|
|
|
return self;
|
|
}
|
|
|
|
- (void) dealloc
|
|
{
|
|
[apt release];
|
|
[previousApt release];
|
|
[organizerName release];
|
|
[viewTZ release];
|
|
[oldStartDate release];
|
|
[newStartDate release];
|
|
[super dealloc];
|
|
}
|
|
|
|
- (iCalEntityObject *) apt
|
|
{
|
|
return apt;
|
|
}
|
|
|
|
- (void) setApt: (iCalEntityObject *) theApt
|
|
{
|
|
ASSIGN(apt, theApt);
|
|
}
|
|
|
|
- (iCalEntityObject *) previousApt
|
|
{
|
|
return previousApt;
|
|
}
|
|
|
|
- (void) setPreviousApt: (iCalEntityObject *) theApt
|
|
{
|
|
ASSIGN(previousApt, theApt);
|
|
}
|
|
|
|
- (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;
|
|
}
|
|
|
|
- (BOOL) isSubject
|
|
{
|
|
return isSubject;
|
|
}
|
|
|
|
- (void) setIsSubject: (BOOL) newIsSubject
|
|
{
|
|
isSubject = newIsSubject;
|
|
}
|
|
|
|
- (NSString *) summary
|
|
{
|
|
return [apt summary];
|
|
}
|
|
|
|
- (void) setOrganizerName: (NSString *) theString
|
|
{
|
|
ASSIGN(organizerName, theString);
|
|
}
|
|
|
|
- (NSString *) organizerName
|
|
{
|
|
return organizerName;
|
|
}
|
|
|
|
- (BOOL) hasSentBy
|
|
{
|
|
return [[apt organizer] hasSentBy];
|
|
}
|
|
|
|
- (NSString *) sentBy
|
|
{
|
|
return [[apt organizer] sentBy];
|
|
}
|
|
|
|
/* Helpers */
|
|
|
|
/* Generate Response */
|
|
|
|
- (NSString *) getSubject
|
|
{
|
|
NSString *subject;
|
|
|
|
[self setIsSubject: YES];
|
|
subject = [[[self generateResponse] contentAsString]
|
|
stringByTrimmingCharactersInSet: wsSet];
|
|
if (!subject)
|
|
{
|
|
[self errorWithFormat:@"Failed to properly generate subject! Please check "
|
|
@"template for component '%@'!",
|
|
[self name]];
|
|
subject = @"ERROR: missing subject!";
|
|
}
|
|
|
|
return [subject asQPSubjectString: @"utf-8"];
|
|
}
|
|
|
|
- (NSString *) getBody
|
|
{
|
|
[self setIsSubject:NO];
|
|
|
|
return [[self generateResponse] contentAsString];
|
|
}
|
|
|
|
@end
|