2009-08-26 15:19:01 +02:00
|
|
|
/* SOGoAptMailReceipt.m - this file is part of SOGo
|
|
|
|
*
|
2012-01-03 22:47:18 +01:00
|
|
|
* Copyright (C) 2009-2012 Inverse inc.
|
2009-08-26 15:19:01 +02:00
|
|
|
*
|
|
|
|
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
2012-07-10 02:29:13 +02:00
|
|
|
* Ludovic Marcotte <lmarcotte@inverse.ca>
|
2009-08-26 15:19:01 +02:00
|
|
|
*
|
|
|
|
* This file is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This file 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#import <Foundation/NSCalendarDate.h>
|
2010-04-12 20:32:52 +02:00
|
|
|
#import <Foundation/NSCharacterSet.h>
|
2009-08-26 15:19:01 +02:00
|
|
|
|
|
|
|
#import <NGObjWeb/WOContext+SoObjects.h>
|
2010-04-12 20:32:52 +02:00
|
|
|
#import <NGObjWeb/WOResponse.h>
|
|
|
|
#import <NGExtensions/NSObject+Logs.h>
|
2009-08-26 15:19:01 +02:00
|
|
|
|
|
|
|
#import <NGCards/iCalEvent.h>
|
|
|
|
#import <NGCards/iCalPerson.h>
|
|
|
|
|
2012-07-11 20:57:27 +02:00
|
|
|
#import <SOGo/NSObject+Utilities.h>
|
2010-04-12 20:32:52 +02:00
|
|
|
#import <SOGo/NSString+Utilities.h>
|
2009-09-25 16:42:33 +02:00
|
|
|
#import <SOGo/SOGoUserManager.h>
|
2009-08-26 15:19:01 +02:00
|
|
|
#import <SOGo/SOGoDateFormatter.h>
|
|
|
|
#import <SOGo/SOGoUser.h>
|
2010-04-21 16:35:58 +02:00
|
|
|
#import <SOGo/SOGoUserDefaults.h>
|
2009-08-26 15:19:01 +02:00
|
|
|
|
|
|
|
#import "SOGoAptMailReceipt.h"
|
|
|
|
|
2009-09-25 16:42:33 +02:00
|
|
|
static SOGoUserManager *um = nil;
|
2010-04-12 20:32:52 +02:00
|
|
|
static NSCharacterSet *wsSet = nil;
|
2009-08-26 15:19:01 +02:00
|
|
|
|
|
|
|
@implementation SOGoAptMailReceipt
|
|
|
|
|
|
|
|
+ (void) initialize
|
|
|
|
{
|
|
|
|
if (!um)
|
2009-09-25 16:42:33 +02:00
|
|
|
um = [SOGoUserManager sharedUserManager];
|
2010-04-12 20:32:52 +02:00
|
|
|
|
|
|
|
if (!wsSet)
|
|
|
|
wsSet = [[NSCharacterSet whitespaceAndNewlineCharacterSet] retain];
|
2009-08-26 15:19:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (id) init
|
|
|
|
{
|
|
|
|
if ((self = [super init]))
|
|
|
|
{
|
|
|
|
originator = nil;
|
2012-07-10 02:29:13 +02:00
|
|
|
addedAttendees = nil;
|
|
|
|
deletedAttendees = nil;
|
|
|
|
updatedAttendees = nil;
|
2009-08-26 15:19:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
[originator release];
|
2012-07-10 02:29:13 +02:00
|
|
|
[addedAttendees release];
|
|
|
|
[deletedAttendees release];
|
|
|
|
[updatedAttendees release];
|
2009-08-26 15:19:01 +02:00
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
2010-04-12 20:32:52 +02:00
|
|
|
- (NSString *) getBody
|
|
|
|
{
|
|
|
|
NSString *body;
|
|
|
|
|
2010-11-05 23:56:08 +01:00
|
|
|
if (!values)
|
|
|
|
[self setupValues];
|
|
|
|
|
2010-04-12 20:32:52 +02:00
|
|
|
body = [[self generateResponse] contentAsString];
|
|
|
|
|
|
|
|
return [body stringByTrimmingCharactersInSet: wsSet];
|
|
|
|
}
|
|
|
|
|
2009-08-26 15:19:01 +02:00
|
|
|
- (void) setOriginator: (NSString *) newOriginator
|
|
|
|
{
|
|
|
|
ASSIGN (originator, newOriginator);
|
|
|
|
}
|
|
|
|
|
2012-07-10 02:29:13 +02:00
|
|
|
- (void) setAddedAttendees: (NSArray *) theAttendees;
|
2009-08-26 15:19:01 +02:00
|
|
|
{
|
2012-07-10 02:29:13 +02:00
|
|
|
ASSIGN (addedAttendees, theAttendees);
|
2009-08-26 15:19:01 +02:00
|
|
|
}
|
|
|
|
|
2012-07-10 02:29:13 +02:00
|
|
|
- (NSArray *) addedAttendees;
|
2009-08-26 15:19:01 +02:00
|
|
|
{
|
2012-07-10 02:29:13 +02:00
|
|
|
return addedAttendees;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setDeletedAttendees: (NSArray *) theAttendees;
|
|
|
|
{
|
|
|
|
ASSIGN (deletedAttendees, theAttendees);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) deletedAttendees;
|
|
|
|
{
|
|
|
|
return deletedAttendees;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) updatedAttendes
|
|
|
|
{
|
|
|
|
return updatedAttendees;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUpdatedAttendees: (NSArray *) theAttendees
|
|
|
|
{
|
|
|
|
ASSIGN (updatedAttendees, theAttendees);
|
2009-08-26 15:19:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setCurrentRecipient: (iCalPerson *) newCurrentRecipient
|
|
|
|
{
|
|
|
|
ASSIGN (currentRecipient, newCurrentRecipient);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (iCalPerson *) currentRecipient
|
|
|
|
{
|
|
|
|
return currentRecipient;
|
|
|
|
}
|
|
|
|
|
2012-07-10 02:29:13 +02:00
|
|
|
- (void) setOperation: (SOGoEventOperation) theOperation
|
|
|
|
{
|
|
|
|
operation = theOperation;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) subject
|
|
|
|
{
|
|
|
|
NSString *s;
|
|
|
|
switch (operation)
|
|
|
|
{
|
|
|
|
case EventCreated:
|
2012-07-11 20:57:27 +02:00
|
|
|
s = [self labelForKey: @"Receipt: event was created" inContext: context];
|
2012-07-10 02:29:13 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case EventDeleted:
|
2012-07-11 20:57:27 +02:00
|
|
|
s = [self labelForKey: @"Receipt: event was deleted" inContext: context];
|
2012-07-10 02:29:13 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case EventUpdated:
|
|
|
|
default:
|
2012-07-11 20:57:27 +02:00
|
|
|
s = [self labelForKey: @"Receipt: event was updated" inContext: context];
|
2012-07-10 02:29:13 +02:00
|
|
|
}
|
|
|
|
|
2012-07-11 20:57:27 +02:00
|
|
|
return [[s stringByTrimmingCharactersInSet: wsSet] asQPSubjectString: @"utf-8"];
|
2012-07-10 02:29:13 +02:00
|
|
|
}
|
|
|
|
|
2009-08-26 15:19:01 +02:00
|
|
|
- (NSString *) _formattedUserDate: (NSCalendarDate *) date
|
|
|
|
{
|
|
|
|
SOGoDateFormatter *formatter;
|
|
|
|
NSCalendarDate *tzDate;
|
|
|
|
SOGoUser *currentUser;
|
|
|
|
|
|
|
|
currentUser = [context activeUser];
|
|
|
|
|
|
|
|
tzDate = [date copy];
|
2010-05-25 21:40:46 +02:00
|
|
|
[tzDate setTimeZone: viewTZ];
|
2009-08-26 15:19:01 +02:00
|
|
|
[tzDate autorelease];
|
|
|
|
|
|
|
|
formatter = [currentUser dateFormatterInContext: context];
|
|
|
|
|
2012-01-03 22:47:18 +01:00
|
|
|
if ([apt isAllDay])
|
|
|
|
return [formatter formattedDate: tzDate];
|
|
|
|
else
|
|
|
|
return [NSString stringWithFormat: @"%@ - %@",
|
|
|
|
[formatter formattedDate: tzDate],
|
|
|
|
[formatter formattedTime: tzDate]];
|
2009-08-26 15:19:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) aptStartDate
|
|
|
|
{
|
|
|
|
return [self _formattedUserDate: [apt startDate]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) aptEndDate
|
|
|
|
{
|
|
|
|
return [self _formattedUserDate: [(iCalEvent *) apt endDate]];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|