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 {