Monotone-Parent: f1f2cd2f6a1aaf50bfe29a44ad3feefaff4ebbb2 Monotone-Revision: ed66e83d2feb1a41dee7a2a6ca422f440f0e7b18 Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2009-11-18T22:54:12 Monotone-Branch: ca.inverse.sogo
265 lines
4.9 KiB
Objective-C
265 lines
4.9 KiB
Objective-C
/* SOGoAptMailICalReply - this file is part of SOGo
|
|
*
|
|
* Copyright (C) 2007-2009 Inverse inc.
|
|
*
|
|
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
|
*
|
|
* 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/NSCharacterSet.h>
|
|
#import <Foundation/NSCalendarDate.h>
|
|
#import <Foundation/NSTimeZone.h>
|
|
|
|
#import <NGObjWeb/WOActionResults.h>
|
|
#import <NGObjWeb/WOResponse.h>
|
|
#import <NGObjWeb/WOContext+SoObjects.h>
|
|
#import <NGExtensions/NSObject+Logs.h>
|
|
|
|
#import <NGCards/iCalEntityObject.h>
|
|
#import <NGCards/iCalPerson.h>
|
|
|
|
#import <SoObjects/SOGo/NSString+Utilities.h>
|
|
#import <SoObjects/SOGo/SOGoUser.h>
|
|
|
|
#import "iCalPerson+SOGo.h"
|
|
#import "SOGoAptMailICalReply.h"
|
|
|
|
@interface SOGoAptMailICalReply (PrivateAPI)
|
|
|
|
- (BOOL) isSubject;
|
|
|
|
@end
|
|
|
|
@implementation SOGoAptMailICalReply
|
|
|
|
static NSCharacterSet *wsSet = nil;
|
|
|
|
+ (void) initialize
|
|
{
|
|
static BOOL didInit = NO;
|
|
|
|
if (!didInit)
|
|
{
|
|
didInit = YES;
|
|
wsSet = [[NSCharacterSet whitespaceAndNewlineCharacterSet] retain];
|
|
}
|
|
}
|
|
|
|
- (id) init
|
|
{
|
|
if ((self = [super init]))
|
|
{
|
|
apt = nil;
|
|
attendee = nil;
|
|
}
|
|
|
|
return self;
|
|
}
|
|
|
|
- (void) dealloc
|
|
{
|
|
[apt release];
|
|
[attendee release];
|
|
[super dealloc];
|
|
}
|
|
|
|
- (void) setApt: (iCalEntityObject *) newApt
|
|
{
|
|
ASSIGN (apt, newApt);
|
|
}
|
|
|
|
- (iCalEntityObject *) apt
|
|
{
|
|
return apt;
|
|
}
|
|
|
|
- (void) setAttendee: (iCalPerson *) newAttendee
|
|
{
|
|
ASSIGN (attendee, newAttendee);
|
|
}
|
|
|
|
- (iCalPerson *) attendee
|
|
{
|
|
return attendee;
|
|
}
|
|
|
|
- (NSString *) attendeeName
|
|
{
|
|
NSString *name;
|
|
|
|
name = [attendee cn];
|
|
|
|
if (name && [name length])
|
|
return name;
|
|
|
|
return [attendee rfc822Email];
|
|
}
|
|
|
|
- (BOOL) hasSentBy
|
|
{
|
|
return [attendee hasSentBy];
|
|
}
|
|
|
|
- (NSString *) sentBy
|
|
{
|
|
return [attendee sentBy];
|
|
}
|
|
|
|
- (BOOL) hasAccepted
|
|
{
|
|
NSString *partStat;
|
|
|
|
partStat = [[attendee partStat] lowercaseString];
|
|
|
|
return [partStat isEqualToString: @"accepted"];
|
|
}
|
|
|
|
- (BOOL) hasDeclined
|
|
{
|
|
NSString *partStat;
|
|
|
|
partStat = [[attendee partStat] lowercaseString];
|
|
|
|
return [partStat isEqualToString: @"declined"];
|
|
}
|
|
|
|
- (BOOL) hasNotAcceptedNotDeclined
|
|
{
|
|
return !([self hasAccepted] || [self hasDeclined]);
|
|
}
|
|
|
|
- (NSCalendarDate *) startDate
|
|
{
|
|
NSCalendarDate *date;
|
|
SOGoUser *user;
|
|
|
|
date = [apt startDate];
|
|
user = [[self context] activeUser];
|
|
[date setTimeZone: [user timeZone]];
|
|
|
|
return date;
|
|
}
|
|
|
|
- (NSString *) summary
|
|
{
|
|
return [apt summary];
|
|
}
|
|
|
|
- (BOOL) isSubject
|
|
{
|
|
return isSubject;
|
|
}
|
|
|
|
/* Generate Response */
|
|
|
|
- (NSString *) getSubject
|
|
{
|
|
NSString *subject;
|
|
|
|
isSubject = 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
|
|
{
|
|
NSString *body;
|
|
|
|
isSubject = NO;
|
|
|
|
body = [[self generateResponse] contentAsString];
|
|
|
|
return [body stringByTrimmingCharactersInSet: wsSet];
|
|
}
|
|
|
|
@end
|
|
|
|
@interface SOGoAptMailEnglishICalReply : SOGoAptMailICalReply
|
|
@end
|
|
|
|
@implementation SOGoAptMailEnglishICalReply
|
|
@end
|
|
|
|
@interface SOGoAptMailBrazilianPortugueseICalReply : SOGoAptMailICalReply
|
|
@end
|
|
|
|
@implementation SOGoAptMailBrazilianPortugueseICalReply
|
|
@end
|
|
|
|
@interface SOGoAptMailCzechICalReply : SOGoAptMailICalReply
|
|
@end
|
|
|
|
@implementation SOGoAptMailCzechICalReply
|
|
@end
|
|
|
|
@interface SOGoAptMailFrenchICalReply : SOGoAptMailICalReply
|
|
@end
|
|
|
|
@implementation SOGoAptMailFrenchICalReply
|
|
@end
|
|
|
|
@interface SOGoAptMailGermanICalReply : SOGoAptMailICalReply
|
|
@end
|
|
|
|
@implementation SOGoAptMailGermanICalReply
|
|
@end
|
|
|
|
@interface SOGoAptMailHungarianICalReply : SOGoAptMailICalReply
|
|
@end
|
|
|
|
@implementation SOGoAptMailHungarianICalReply
|
|
@end
|
|
|
|
@interface SOGoAptMailItalianICalReply : SOGoAptMailICalReply
|
|
@end
|
|
|
|
@implementation SOGoAptMailItalianICalReply
|
|
@end
|
|
|
|
@interface SOGoAptMailRussianICalReply : SOGoAptMailICalReply
|
|
@end
|
|
|
|
@implementation SOGoAptMailRussianICalReply
|
|
@end
|
|
|
|
@interface SOGoAptMailSpanishICalReply : SOGoAptMailICalReply
|
|
@end
|
|
|
|
@implementation SOGoAptMailSpanishICalReply
|
|
@end
|
|
|
|
@interface SOGoAptMailSwedishICalReply : SOGoAptMailICalReply
|
|
@end
|
|
|
|
@implementation SOGoAptMailSwedishICalReply
|
|
@end
|
|
|
|
@interface SOGoAptMailWelshICalReply : SOGoAptMailICalReply
|
|
@end
|
|
|
|
@implementation SOGoAptMailWelshICalReply
|
|
@end
|