From 5557c01b99704d1b2288fc7192465330cf660b94 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Mon, 13 Aug 2012 15:29:44 +0000 Subject: [PATCH] Monotone-Parent: 61e6d0133bf0d45c09767727617ba746f65a28b9 Monotone-Revision: 54ac2dbf42dee286f64da8b9b3c4567570b00258 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2012-08-13T15:29:44 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 3 +++ SoObjects/SOGo/NSString+Utilities.h | 3 ++- SoObjects/SOGo/NSString+Utilities.m | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a3950b176..36869115b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2012-08-13 Wolfgang Sourdeau + * SoObjects/SOGo/NSString+Utilities.m + (-stringByReplacingPrefix:withPrefix:): new self-explicit method. + * OpenChange/SOGoMAPIDBFolder.m (-childKeysOfType:includeDeleted:matchingQualifier:andSortOrderings:): records now have a c_parent_path column in order to avoid fetch diff --git a/SoObjects/SOGo/NSString+Utilities.h b/SoObjects/SOGo/NSString+Utilities.h index 409c3fe86..df82535e2 100644 --- a/SoObjects/SOGo/NSString+Utilities.h +++ b/SoObjects/SOGo/NSString+Utilities.h @@ -74,7 +74,8 @@ /* substrings */ - (NSUInteger) countOccurrencesOfString: (NSString *) substring; - +- (NSString *) stringByReplacingPrefix: (NSString *) oldPrefix + withPrefix: (NSString *) newPrefix; /* Those methods provide symmetric enc-/decryption via a XOR operation */ - (NSString *) encryptWithKey: (NSString *) theKey; diff --git a/SoObjects/SOGo/NSString+Utilities.m b/SoObjects/SOGo/NSString+Utilities.m index ec04b9795..da5a69993 100644 --- a/SoObjects/SOGo/NSString+Utilities.m +++ b/SoObjects/SOGo/NSString+Utilities.m @@ -560,6 +560,24 @@ static int cssEscapingCount; return count; } +- (NSString *) stringByReplacingPrefix: (NSString *) oldPrefix + withPrefix: (NSString *) newPrefix +{ + NSUInteger oldPrefixLength; + NSString *newString; + + if (![self hasPrefix: oldPrefix]) + [NSException raise: NSInvalidArgumentException + format: @"string does not have the specified prefix"]; + + oldPrefixLength = [oldPrefix length]; + newString = [NSString stringWithFormat: @"%@%@", + newPrefix, + [self substringFromIndex: oldPrefixLength]]; + + return newString; +} + - (NSString *) encryptWithKey: (NSString *) theKey { NSMutableData *encryptedPassword;