2 Copyright (C) 2000-2005 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #import <Foundation/NSCharacterSet.h>
23 #import <Foundation/NSCalendarDate.h>
24 #import <Foundation/NSTimeZone.h>
26 #import <NGObjWeb/WOActionResults.h>
27 #import <NGObjWeb/WOMessage.h>
28 #import <NGExtensions/NSObject+Logs.h>
29 #import <NGCards/iCalEntityObject.h>
31 #import "SOGoAptMailNotification.h"
33 @interface SOGoAptMailNotification (PrivateAPI)
35 - (void)setIsSubject:(BOOL)_isSubject;
38 @implementation SOGoAptMailNotification
40 static NSCharacterSet *wsSet = nil;
41 static NSTimeZone *EST = nil;
44 static BOOL didInit = NO;
49 wsSet = [[NSCharacterSet whitespaceAndNewlineCharacterSet] retain];
50 EST = [[NSTimeZone timeZoneWithAbbreviation:@"EST"] retain];
54 [self->oldApt release];
55 [self->newApt release];
56 [self->homePageURL release];
57 [self->viewTZ release];
59 [self->oldStartDate release];
60 [self->newStartDate release];
67 - (void)setOldApt:(iCalEntityObject *)_oldApt {
68 ASSIGN(self->oldApt, _oldApt);
75 - (void)setNewApt:(iCalEntityObject *) _newApt
77 ASSIGN(self->newApt, _newApt);
80 - (NSString *)homePageURL {
81 return self->homePageURL;
83 - (void)setHomePageURL:(NSString *)_homePageURL {
84 ASSIGN(self->homePageURL, _homePageURL);
87 - (NSString *)appointmentURL {
90 aptUID = [[self newApt] uid];
91 return [NSString stringWithFormat:@"%@/Calendar/%@/edit?mail-invitation=yes",
96 - (NSTimeZone *)viewTZ {
97 if (self->viewTZ) return self->viewTZ;
100 - (void)setViewTZ:(NSTimeZone *)_viewTZ {
101 ASSIGN(self->viewTZ, _viewTZ);
105 return self->isSubject;
107 - (void)setIsSubject:(BOOL)_isSubject {
108 self->isSubject = _isSubject;
114 - (NSCalendarDate *)oldStartDate {
115 if (!self->oldStartDate) {
116 ASSIGN(self->oldStartDate, [[self oldApt] startDate]);
117 [self->oldStartDate setTimeZone:[self viewTZ]];
119 return self->oldStartDate;
122 - (NSCalendarDate *)newStartDate {
123 if (!self->newStartDate) {
124 ASSIGN(self->newStartDate, [[self newApt] startDate]);
125 [self->newStartDate setTimeZone:[self viewTZ]];
127 return self->newStartDate;
130 /* Generate Response */
132 - (NSString *)getSubject {
135 [self setIsSubject:YES];
136 subject = [[[self generateResponse] contentAsString]
137 stringByTrimmingCharactersInSet:wsSet];
139 [self errorWithFormat:@"Failed to properly generate subject! Please check "
140 @"template for component '%@'!",
142 subject = @"ERROR: missing subject!";
147 - (NSString *)getBody {
148 [self setIsSubject:NO];
149 return [[self generateResponse] contentAsString];