2007-11-18 11:16:25 +01:00
|
|
|
/* iCalPerson+SOGo.m - this file is part of SOGo
|
|
|
|
*
|
2009-09-25 16:42:33 +02:00
|
|
|
* Copyright (C) 2007-2009 Inverse inc.
|
2007-11-18 11:16:25 +01:00
|
|
|
*
|
|
|
|
* 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/NSString.h>
|
2009-09-25 16:42:33 +02:00
|
|
|
#import <SOGo/SOGoUserManager.h>
|
2007-11-18 11:16:25 +01:00
|
|
|
|
|
|
|
#import "iCalPerson+SOGo.h"
|
|
|
|
|
2009-09-25 16:42:33 +02:00
|
|
|
static SOGoUserManager *um = nil;
|
2007-11-18 11:16:25 +01:00
|
|
|
|
|
|
|
@implementation iCalPerson (SOGoExtension)
|
|
|
|
|
|
|
|
- (NSString *) mailAddress
|
|
|
|
{
|
|
|
|
NSString *cn, *email, *mailAddress;
|
|
|
|
|
|
|
|
cn = [self cnWithoutQuotes];
|
|
|
|
email = [self rfc822Email];
|
|
|
|
if ([cn length])
|
|
|
|
mailAddress = [NSString stringWithFormat:@"%@ <%@>", cn, email];
|
|
|
|
else
|
|
|
|
mailAddress = email;
|
|
|
|
|
|
|
|
return mailAddress;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) uid
|
|
|
|
{
|
|
|
|
if (!um)
|
2009-09-25 16:42:33 +02:00
|
|
|
um = [SOGoUserManager sharedUserManager];
|
2007-11-18 11:16:25 +01:00
|
|
|
|
|
|
|
return [um getUIDForEmail: [self rfc822Email]];
|
|
|
|
}
|
|
|
|
|
2008-11-05 22:04:16 +01:00
|
|
|
- (BOOL) hasSentBy
|
|
|
|
{
|
|
|
|
NSString *mail;
|
|
|
|
|
2009-07-23 19:34:17 +02:00
|
|
|
mail = [self value: 0 ofAttribute: @"SENT-BY"];
|
2008-11-05 22:04:16 +01:00
|
|
|
|
|
|
|
return ([mail length] > 7);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) sentBy
|
|
|
|
{
|
|
|
|
NSString *mail;
|
|
|
|
|
2009-07-23 19:34:17 +02:00
|
|
|
mail = [self value: 0 ofAttribute: @"SENT-BY"];
|
2008-11-05 22:04:16 +01:00
|
|
|
|
|
|
|
if ([mail length] > 7)
|
|
|
|
{
|
2008-11-13 17:03:41 +01:00
|
|
|
if ([mail characterAtIndex: 0] == '"' && [mail hasSuffix: @"\""])
|
2008-11-05 22:04:16 +01:00
|
|
|
mail = [mail substringWithRange: NSMakeRange(1, [mail length]-2)];
|
|
|
|
|
|
|
|
return [mail substringFromIndex: 7];
|
|
|
|
}
|
|
|
|
|
|
|
|
return @"";
|
|
|
|
}
|
|
|
|
|
2007-11-18 11:16:25 +01:00
|
|
|
@end
|