Monotone-Parent: ee3257d96d3da0ff7f3c6c7cdfd328beb41195b8

Monotone-Revision: 91089a095425fe50c525dea5f59628b15c8b029c

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2006-07-11T17:29:09
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
Wolfgang Sourdeau 2006-07-11 17:29:09 +00:00
parent dcd08595d9
commit c6b60d8516
5 changed files with 167 additions and 0 deletions

View File

@ -1,5 +1,13 @@
2006-07-11 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* UI/Common/NSDictionary+URL.m ([NSDictionary -asURLParameters]):
returns a parameter string to add to a base URL.
* UI/Common/NSString+URL.m ([NSString
-composeURLWithAction:parameters:andHash:useHash]): new method to
compose a complete URL from an object URL with parameters and an
optional '#' character.
* UI/Common/UIxPageFrame.h: separated interface from
UIxPageFrame.m.

View File

@ -0,0 +1,36 @@
/* NSDictionary+URL.h - this file is part of SOGo
*
* Copyright (C) 2006 Inverse groupe conseil
*
* 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.
*/
#ifndef NSDICTIONARY_URL_H
#define NSDICTIONARY_URL_H
#import <Foundation/NSDictionary.h>
@class NSString;
@interface NSDictionary (SOGoURLExtension)
- (NSString *) asURLParameters;
@end
#endif /* NSDICTIONARY_URL_H */

View File

@ -0,0 +1,60 @@
/* NSDictionary+URL.m - this file is part of SOGo
*
* Copyright (C) 2006 Inverse groupe conseil
*
* 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>
#import <Foundation/NSEnumerator.h>
#import "NSDictionary+URL.h"
@implementation NSDictionary (SOGoURLExtension)
- (NSString *) asURLParameters
{
NSMutableString *urlParameters;
NSArray *keys;
NSEnumerator *keysEnum;
NSString *currentKey;
BOOL isFirst;
urlParameters = [NSMutableString new];
[urlParameters autorelease];
keys = [self allKeys];
if ([keys count] > 0)
{
isFirst = YES;
keysEnum = [keys objectEnumerator];
currentKey = [keysEnum nextObject];
while (currentKey)
{
[urlParameters appendFormat: @"%@%@=%@",
((isFirst) ? @"?" : @"&"),
currentKey, [self objectForKey: currentKey]];
isFirst = NO;
currentKey = [keysEnum nextObject];
}
}
return urlParameters;
}
@end

View File

@ -0,0 +1,37 @@
/* NSString+URL.h - this file is part of SOGo
*
* Copyright (C) 2006 Inverse groupe conseil
*
* 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.
*/
#ifndef NSSTRING_URL_H
#define NSSTRING_URL_H
#import <Foundation/NSString.h>
@class NSDictionary;
@interface NSString (SOGoURLExtension)
- (NSString *) composeURLWithAction: (NSString *) action
parameters: (NSDictionary *) urlParameters
andHash: (BOOL) useHash;
@end
#endif /* NSSTRING_URL_H */

View File

@ -0,0 +1,26 @@
#import "NSString+URL.h"
#import "NSDictionary+URL.h"
@implementation NSString (SOGoURLExtension)
- (NSString *) composeURLWithAction: (NSString *) action
parameters: (NSDictionary *) urlParameters
andHash: (BOOL) useHash
{
NSMutableString *completeURL;
completeURL = [NSMutableString new];
[completeURL autorelease];
[completeURL appendString: self];
if (![completeURL hasSuffix: @"/"])
[completeURL appendString: @"/"];
[completeURL appendString: action];
[completeURL appendString: [urlParameters asURLParameters]];
if (useHash)
[completeURL appendString: @"#"];
return completeURL;
}
@end