From dc3d206984e5a476185e34f9bdf9f4c2dee3b735 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Thu, 9 Aug 2007 20:59:30 +0000 Subject: [PATCH] Monotone-Parent: 890780f417605e8803bbe725196d6f559c8a11c7 Monotone-Revision: e0eb29facb0dd67a0b0623858dfb42b49f7e090b Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-08-09T20:59:30 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 5 +++++ SoObjects/SOGo/NSString+Utilities.h | 3 +++ SoObjects/SOGo/NSString+Utilities.m | 19 +++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/ChangeLog b/ChangeLog index 1fdc36ba7..c9653a6b3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2007-08-09 Wolfgang Sourdeau + * SoObjects/SOGo/NSString+Utilities.m ([NSString + -pureEMailAddress]): new utility method inspired by the + "_rawSender" private method in SOGoDraftObject, which it now + replaces. + * SoObjects/SOGo/SOGoMailer.m: new abstraction class module that provides a common API for sending emails, no matter what the transport is. diff --git a/SoObjects/SOGo/NSString+Utilities.h b/SoObjects/SOGo/NSString+Utilities.h index 31c913ef6..7cd8042b4 100644 --- a/SoObjects/SOGo/NSString+Utilities.h +++ b/SoObjects/SOGo/NSString+Utilities.h @@ -43,6 +43,9 @@ - (NSString *) jsonRepresentation; +/* bare email addresses */ +- (NSString *) pureEMailAddress; + #ifndef GNUSTEP_BASE_LIBRARY - (BOOL) boolValue; #endif diff --git a/SoObjects/SOGo/NSString+Utilities.m b/SoObjects/SOGo/NSString+Utilities.m index 2f1d617c0..38c09bad5 100644 --- a/SoObjects/SOGo/NSString+Utilities.m +++ b/SoObjects/SOGo/NSString+Utilities.m @@ -249,6 +249,25 @@ static NSMutableCharacterSet *urlAfterEndingChars = nil; return [NSString stringWithFormat: @"\"%@\"", representation]; } +- (NSString *) pureEMailAddress +{ + NSString *pureAddress; + NSRange delimiter; + + delimiter = [self rangeOfString: @"<"]; + if (delimiter.location == NSNotFound) + pureAddress = self; + else + { + pureAddress = [self substringFromIndex: NSMaxRange (delimiter)]; + delimiter = [pureAddress rangeOfString: @">"]; + if (delimiter.location != NSNotFound) + pureAddress = [pureAddress substringToIndex: delimiter.location]; + } + + return pureAddress; +} + #if LIB_FOUNDATION_LIBRARY - (BOOL) boolValue {