From 2a9ccf8122fbea723785737482ce9d48813803bd Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Mon, 13 Jan 2014 10:18:20 -0500 Subject: [PATCH] Now able to grab the command from the URI --- ActiveSync/NSString+ActiveSync.h | 1 + ActiveSync/NSString+ActiveSync.m | 48 +++++++++++++++++++++++++------- 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/ActiveSync/NSString+ActiveSync.h b/ActiveSync/NSString+ActiveSync.h index dfdfdde03..70919cc81 100644 --- a/ActiveSync/NSString+ActiveSync.h +++ b/ActiveSync/NSString+ActiveSync.h @@ -32,6 +32,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVE - (NSString *) realCollectionIdWithFolderType: (SOGoMicrosoftActiveSyncFolderType *) folderType; - (NSCalendarDate *) calendarDate; - (NSString *) deviceId; +- (NSString *) command; @end diff --git a/ActiveSync/NSString+ActiveSync.m b/ActiveSync/NSString+ActiveSync.m index 363cb2e29..2f66cffe9 100644 --- a/ActiveSync/NSString+ActiveSync.m +++ b/ActiveSync/NSString+ActiveSync.m @@ -87,12 +87,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVE return o; } -// -// This method extracts the "DeviceId" from a URI: -// -// /SOGo/Microsoft-Server-ActiveSync?Cmd=FolderSync&User=sogo10&DeviceId=SEC17CD1A3E9E3F2&DeviceType=SAMSUNGSGHI317M -// -- (NSString *) deviceId +- (NSString *) _valueForParameter: (NSString *) theParameter { NSArray *components; NSString *s; @@ -104,10 +99,43 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVE { s = [components objectAtIndex: i]; - if ([[s uppercaseString] hasPrefix: @"DEVICEID="]) - return [s substringFromIndex: 9]; + if ([[s uppercaseString] hasPrefix: theParameter]) + return [s substringFromIndex: [theParameter length]]; } - - return @"Unknown"; + + return nil; } + +// +// This method extracts the "DeviceId" from a URI: +// +// /SOGo/Microsoft-Server-ActiveSync?Cmd=FolderSync&User=sogo10&DeviceId=SEC17CD1A3E9E3F2&DeviceType=SAMSUNGSGHI317M +// +- (NSString *) deviceId +{ + NSString *s; + + s = [self _valueForParameter: @"DEVICEID="]; + + if (!s) + s = @"Unknown"; + + return s; +} + +// +// +// +- (NSString *) command +{ + NSString *s; + + s = [self _valueForParameter: @"CMD="]; + + if (!s) + s = @"Unknown"; + + return s; +} + @end