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 <SoObjects/SOGo/NSString+Utilities.h>
33 #import "SOGoAptMailNotification.h"
35 @interface SOGoAptMailNotification (PrivateAPI)
37 - (void)setIsSubject:(BOOL)_isSubject;
40 @implementation SOGoAptMailNotification
42 static NSCharacterSet *wsSet = nil;
43 static NSTimeZone *EST = nil;
46 static BOOL didInit = NO;
51 wsSet = [[NSCharacterSet whitespaceAndNewlineCharacterSet] retain];
52 EST = [[NSTimeZone timeZoneWithAbbreviation:@"EST"] retain];
56 [self->oldApt release];
57 [self->newApt release];
58 [self->homePageURL release];
59 [self->viewTZ release];
61 [self->oldStartDate release];
62 [self->newStartDate release];
69 - (void)setOldApt:(iCalEntityObject *)_oldApt {
70 ASSIGN(self->oldApt, _oldApt);
77 - (void)setNewApt:(iCalEntityObject *) _newApt
79 ASSIGN(self->newApt, _newApt);
82 - (NSString *)homePageURL {
83 return self->homePageURL;
85 - (void)setHomePageURL:(NSString *)_homePageURL {
86 ASSIGN(self->homePageURL, _homePageURL);
89 - (NSString *)appointmentURL {
92 aptUID = [[self newApt] uid];
93 return [NSString stringWithFormat:@"%@/Calendar/%@/edit?mail-invitation=yes",
98 - (NSTimeZone *)viewTZ {
99 if (self->viewTZ) return self->viewTZ;
102 - (void)setViewTZ:(NSTimeZone *)_viewTZ {
103 ASSIGN(self->viewTZ, _viewTZ);
107 return self->isSubject;
109 - (void)setIsSubject:(BOOL)_isSubject {
110 self->isSubject = _isSubject;
116 - (NSCalendarDate *)oldStartDate {
117 if (!self->oldStartDate) {
118 ASSIGN(self->oldStartDate, [[self oldApt] startDate]);
119 [self->oldStartDate setTimeZone:[self viewTZ]];
121 return self->oldStartDate;
124 - (NSCalendarDate *)newStartDate {
125 if (!self->newStartDate) {
126 ASSIGN(self->newStartDate, [[self newApt] startDate]);
127 [self->newStartDate setTimeZone:[self viewTZ]];
129 return self->newStartDate;
132 /* Generate Response */
134 - (NSString *)getSubject {
137 [self setIsSubject:YES];
138 subject = [[[self generateResponse] contentAsString]
139 stringByTrimmingCharactersInSet:wsSet];
141 [self errorWithFormat:@"Failed to properly generate subject! Please check "
142 @"template for component '%@'!",
144 subject = @"ERROR: missing subject!";
147 return [subject asQPSubjectString: @"utf-8"];
150 - (NSString *)getBody {
151 [self setIsSubject:NO];
152 return [[self generateResponse] contentAsString];