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;
86 - (void)setHomePageURL:(NSString *)_homePageURL {
87 ASSIGN(self->homePageURL, _homePageURL);
90 - (NSString *)appointmentURL {
93 aptUID = [[self newApt] uid];
94 return [NSString stringWithFormat:@"%@/Calendar/personal/%@/edit?mail-invitation=yes",
99 - (NSTimeZone *)viewTZ {
100 if (self->viewTZ) return self->viewTZ;
103 - (void)setViewTZ:(NSTimeZone *)_viewTZ {
104 ASSIGN(self->viewTZ, _viewTZ);
108 return self->isSubject;
110 - (void)setIsSubject:(BOOL)_isSubject {
111 self->isSubject = _isSubject;
117 - (NSCalendarDate *)oldStartDate {
118 if (!self->oldStartDate) {
119 ASSIGN(self->oldStartDate, [[self oldApt] startDate]);
120 [self->oldStartDate setTimeZone:[self viewTZ]];
122 return self->oldStartDate;
125 - (NSCalendarDate *)newStartDate {
126 if (!self->newStartDate) {
127 ASSIGN(self->newStartDate, [[self newApt] startDate]);
128 [self->newStartDate setTimeZone:[self viewTZ]];
130 return self->newStartDate;
133 /* Generate Response */
135 - (NSString *)getSubject {
138 [self setIsSubject:YES];
139 subject = [[[self generateResponse] contentAsString]
140 stringByTrimmingCharactersInSet:wsSet];
142 [self errorWithFormat:@"Failed to properly generate subject! Please check "
143 @"template for component '%@'!",
145 subject = @"ERROR: missing subject!";
148 return [subject asQPSubjectString: @"utf-8"];
151 - (NSString *)getBody {
152 [self setIsSubject:NO];
153 return [[self generateResponse] contentAsString];