Skip to content

Commit

Permalink
Merge branch '6.x-3.x' into 7.x-3.x
Browse files Browse the repository at this point in the history
Conflicts:
	DIOSConnect.h
	DIOSConnect.m
  • Loading branch information
kylebrowning committed Oct 21, 2010
2 parents 5053fd3 + 1a19896 commit d7859d4
Show file tree
Hide file tree
Showing 6 changed files with 205 additions and 112 deletions.
69 changes: 69 additions & 0 deletions DIOSConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//
// DIOSConfig.h
//
// ***** BEGIN LICENSE BLOCK *****
// Version: MPL 1.1/GPL 2.0
//
// The contents of this file are subject to the Mozilla Public License Version
// 1.1 (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
// http://www.mozilla.org/MPL/
//
// Software distributed under the License is distributed on an "AS IS" basis,
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
// for the specific language governing rights and limitations under the
// License.
//
// The Original Code is Kyle Browning, released June 27, 2010.
//
// The Initial Developer of the Original Code is
// Kyle Browning
// Portions created by the Initial Developer are Copyright (C) 2010
// the Initial Developer. All Rights Reserved.
//
// Contributor(s):
//
// Alternatively, the contents of this file may be used under the terms of
// the GNU General Public License Version 2 or later (the "GPL"), in which
// case the provisions of the GPL are applicable instead of those above. If
// you wish to allow use of your version of this file only under the terms of
// the GPL and not to allow others to use your version of this file under the
// MPL, indicate your decision by deleting the provisions above and replacing
// them with the notice and other provisions required by the GPL. If you do
// not delete the provisions above, a recipient may use your version of this
// file under either the MPL or the GPL.
//
// ***** END LICENSE BLOCK *****

//#define STAGE
#define DEV


#ifdef STAGE

#define DRUPAL_API_KEY @""
#define DRUPAL_SERVICES_URL @"http://stage.example.com/services/plist"
#define DRUPAL_URL @"http://stage.example.com"
#define DRUPAL_DOMAIN @"stage.example.com"

#endif

#ifdef DEV

#define DRUPAL_API_KEY @"4b2d7ef98d720386e0d2022842847404"
#define DRUPAL_SERVICES_URL @"http://drupal7/test4"
#define DRUPAL_URL @"http://demo.kylebrowning.com/"
#define DRUPAL_DOMAIN @"testing"
//THis is the constant for none in Drupal7 http://api.drupal.org/api/constant/LANGUAGE_NONE/7
#define DRUPAL_LANGUAGE @"und"

#endif

#define DRUPAL_CELL_DEFAULT_IMAGE @"http://demo.kylebrowning.com/sites/default/files/imagecache/iphone/4986607783_45b49e2493_o.jpg"
#define DRUPAL_IMAGECACHE_URL @"sites/default/files/imagecache/iphone/"
#define DRUPAL_NC_SYSTEM @"DRUPALNCSYSTEM"
#define DRUPAL_METHOD_DONE @"DRUPALMETHODDONE"
#define DRUPAL_NODE_METHOD_DONE @"DRUPALNODEMETHODDONE"
#define DRUPAL_CATEGORY_VID @"1"
#define DRUPAL_VIEWS_IMAGE_FIELD @"files_node_data_field_image_filepath"
#define DRUPAL_NODE_IMAGE_FIELD @"field_image"
14 changes: 4 additions & 10 deletions DIOSConnect.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@
// ***** END LICENSE BLOCK *****
#import <Foundation/Foundation.h>

#define DRUPAL_API_KEY @"4b2d7ef98d720386e0d2022842847404"
#define DRUPAL_SERVICES_URL @"http://drupal7/test4"
#define DRUPAL_URL @"http://demo.kylebrowning.com/"
#define DRUPAL_DOMAIN @"testing"
//THis is the constant for none in Drupal7 http://api.drupal.org/api/constant/LANGUAGE_NONE/7
#define DRUPAL_LANGUAGE @"und"

@interface DIOSConnect : NSObject {
NSDictionary *connResult;
NSMutableDictionary *params;
Expand All @@ -65,16 +58,17 @@
@property (nonatomic, retain) NSString *methodUrl;
@property (nonatomic, retain) NSString *responseStatusMessage;
@property (nonatomic, retain) NSString *requestMethod;
@property (nonatomic, retain) NSError *error;
@property (nonatomic, readonly) NSError *error;

- (id) init;
- (void) initWithSessId:(NSString*)aSessId;
- (void) initWithUserInfo:(NSDictionary*)someUserInfo andSessId:(NSString*)sessId;
- (void) runMethod;
- (void) addParam:(id)value forKey:(NSString *)key;
- (void) removeParam:(NSString *)key;
- (void) connect;
- (void) loginWithUsername:(NSString*)userName andPassword:(NSString*)password;
- (void) logout;
- (NSDictionary *) loginWithUsername:(NSString*)userName andPassword:(NSString*)password;
- (NSDictionary *) logout;
- (void) connect;
- (NSString *) buildParams;
- (NSString *) genRandStringLength;
Expand Down
70 changes: 27 additions & 43 deletions DIOSConnect.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,13 @@
#import "DIOSConnect.h"
#import "ASIHTTPRequest.h"
#import "ASIFormDataRequest.h"

#import "NSData+Base64.h"
#import "DIOSConfig.h"
@implementation DIOSConnect
<<<<<<< HEAD
=======

>>>>>>> 6.x-3.x
@synthesize connResult, sessid, method, params, userInfo, methodUrl, responseStatusMessage, requestMethod, error;

/*
Expand All @@ -65,7 +70,7 @@ - (id) init {
//DIOSConnect should handle there rest.
- (id) initWithSession:(DIOSConnect*)aSession {
[super init];
if ([aSession isKindOfClass:[DIOSConnect class]]) {
if ([aSession respondsToSelector:@selector(userInfo)] && [aSession respondsToSelector:@selector(sessid)]) {
[self setUserInfo:[aSession userInfo]];
[self setSessid:[aSession sessid]];
}
Expand Down Expand Up @@ -109,50 +114,25 @@ - (NSString *)generateHash:(NSString *)inputString {
//NSLog(@"hash string: %@ length: %d",[hashedString lowercaseString],[hashedString length]);
return [hashedString lowercaseString];
}

- (NSString*)base64forData:(NSData*)theData {

const uint8_t* input = (const uint8_t*)[theData bytes];
NSInteger length = [theData length];

static char table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

NSMutableData* data = [NSMutableData dataWithLength:((length + 2) / 3) * 4];
uint8_t* output = (uint8_t*)data.mutableBytes;

NSInteger i;
for (i=0; i < length; i += 3) {
NSInteger value = 0;
NSInteger j;
for (j = i; j < (i + 3); j++) {
value <<= 8;

if (j < length) {
value |= (0xFF & input[j]);
}
-(NSString *) genRandStringLength {
NSString *letters = @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
NSMutableString *randomString = [NSMutableString stringWithCapacity: 10];
for (int i=0; i<10; i++) {
[randomString appendFormat: @"%c", [letters characterAtIndex: arc4random()%[letters length]]];
}

NSInteger theIndex = (i / 3) * 4;
output[theIndex + 0] = table[(value >> 18) & 0x3F];
output[theIndex + 1] = table[(value >> 12) & 0x3F];
output[theIndex + 2] = (i + 1) < length ? table[(value >> 6) & 0x3F] : '=';
output[theIndex + 3] = (i + 2) < length ? table[(value >> 0) & 0x3F] : '=';
}
return [[[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding] autorelease];
return randomString;
}
-(NSString *) genRandStringLength {
NSString *letters = @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
NSMutableString *randomString = [NSMutableString stringWithCapacity: 10];

for (int i=0; i<10; i++) {
[randomString appendFormat: @"%c", [letters characterAtIndex: arc4random()%[letters length]]];
}

return randomString;
- (void)setError:(NSError *)e
{
if (e != error) {
[error release];
error = [e retain];
}
}

//This runs our method and actually gets a response from drupal
-(void) runMethod {

[self setError:nil];
[self removeParam:@"sessid"];
[self addParam:[self sessid] forKey:@"sessid"];
Expand All @@ -173,6 +153,7 @@ -(void) runMethod {
[requestBinary addRequestHeader:@"Accept" value:@"application/plist"];
[requestBinary startSynchronous];
responseStatusMessage = [requestBinary responseStatusMessage];

[self setError:[requestBinary error]];

if (!error) {
Expand Down Expand Up @@ -242,7 +223,7 @@ - (void) setMethod:(NSString *)aMethod {
}
- (NSString *) buildParams {
NSString *finalParams;
NSMutableArray *arrayofParams = [[NSMutableArray alloc] init];
NSMutableArray *arrayofParams = nil;
NSEnumerator *enumerator = [params keyEnumerator];
NSString *aKey = nil;
NSString *value = nil;
Expand Down Expand Up @@ -270,6 +251,7 @@ - (NSString *)description {
return [NSString stringWithFormat:@"connresult = %@, userInfo = %@, params = %@, sessionid = %@, isRunning = %@", connResult, userInfo, params, sessid, (isRunning ? @"YES" : @"NO")];
}
- (void) dealloc {
[error release];
[connResult release];
[sessid release];
[method release];
Expand All @@ -289,12 +271,14 @@ - (void) initWithUserInfo:(NSDictionary*)someUserInfo andSessId:(NSString*)sessI
NSAssert(NO, @"DIOSConnect initWithUserInfo is deprecated, use initWithSession");
}
//DEPRECATED -- use DIOSUser
- (void) loginWithUsername:(NSString*)userName andPassword:(NSString*)password {
- (NSDictionary *) loginWithUsername:(NSString*)userName andPassword:(NSString*)password {
NSAssert(NO, @"DIOSConnect loginWithUsername is deprecated, use DIOSUser");
return nil;
}
//DEPRECATED -- use DIOSUser
- (void) logout {
- (NSDictionary *) logout {
NSAssert(NO, @"DIOSConnect logout is deprecated, use DIOSUser");
return nil;
}

- (void)serializedObject:(NSMutableDictionary *)object {
Expand Down
4 changes: 2 additions & 2 deletions DIOSTaxonomy.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ - (NSDictionary *)selectNodes:(NSString*)tids withFields:(NSString*)fields andOp
NSString *searchingForCommas = @",";
NSRange tidRange = [tids rangeOfString:searchingForCommas];
NSRange fieldsRange = [fields rangeOfString:searchingForCommas];
NSArray *newTids = [[NSArray alloc] init];
NSArray *newFields = [[NSArray alloc] init];
NSArray *newTids = nil;
NSArray *newFields = nil;
if (tidRange.location != NSNotFound) {
newTids = [tids componentsSeparatedByString:@","];
} else {
Expand Down
34 changes: 34 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// ***** BEGIN LICENSE BLOCK *****
// Version: MPL 1.1/GPL 2.0
//
// The contents of this file are subject to the Mozilla Public License Version
// 1.1 (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
// http://www.mozilla.org/MPL/
//
// Software distributed under the License is distributed on an "AS IS" basis,
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
// for the specific language governing rights and limitations under the
// License.
//
// The Original Code is Kyle Browning, released June 27, 2010.
//
// The Initial Developer of the Original Code is
// Kyle Browning
// Portions created by the Initial Developer are Copyright (C) 2010
// the Initial Developer. All Rights Reserved.
//
// Contributor(s):
//
// Alternatively, the contents of this file may be used under the terms of
// the GNU General Public License Version 2 or later (the "GPL"), in which
// case the provisions of the GPL are applicable instead of those above. If
// you wish to allow use of your version of this file only under the terms of
// the GPL and not to allow others to use your version of this file under the
// MPL, indicate your decision by deleting the provisions above and replacing
// them with the notice and other provisions required by the GPL. If you do
// not delete the provisions above, a recipient may use your version of this
// file under either the MPL or the GPL.
//
// ***** END LICENSE BLOCK *****
Loading

0 comments on commit d7859d4

Please sign in to comment.