Permalink
Browse files

Updated to ARC, added basic Entity management and extended user manag…

…ement
  • Loading branch information...
Zoltán Váradi
Zoltán Váradi committed Jun 24, 2013
1 parent 666af43 commit ac46a0f7dbb166e868a453684cc5f0b41630c446
Showing with 522 additions and 161 deletions.
  1. +0 −1 DIOSComment.m
  2. +64 −0 DIOSEntity.h
  3. +135 −0 DIOSEntity.m
  4. +0 −1 DIOSFile.m
  5. +1 −2 DIOSNode.m
  6. +5 −2 DIOSSession.m
  7. +1 −1 DIOSSystem.m
  8. +0 −2 DIOSTaxonomy.m
  9. +27 −6 DIOSUser.h
  10. +289 −146 DIOSUser.m
View
@@ -141,7 +141,6 @@ + (void)commentIndexWithPage:(NSString *)page
[commentIndexDict setValue:parameteres forKey:@"parameters"];
[commentIndexDict setValue:pageSize forKey:@"pagesize"];
[self commentIndex:commentIndexDict success:success failure:failure];
- [commentIndexDict release];
}
+ (void)commentIndex:(NSDictionary *)params
View
@@ -0,0 +1,64 @@
+//
+// DIOSEntity.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 *****
+
+#import "AFHTTPRequestOperation.h"
+
+@interface DIOSEntity : NSObject {
+}
++ (void)entityGet:(NSDictionary *)entity
+ name:(NSString*)eName
+ eid:(NSString*)eId
+ success:(void (^)(AFHTTPRequestOperation *operation, id responseObject)) success
+ failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure;
+
++ (void)entitySave:(NSDictionary *)entity
+ name:(NSString*)eName
+ success:(void (^)(AFHTTPRequestOperation *operation, id responseObject)) success
+ failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure;
+
++ (void)entityUpdate:(NSDictionary *)entity
+ name:(NSString*)eName
+ eid:(NSString*)eId
+ success:(void (^)(AFHTTPRequestOperation *operation, id responseObject)) success
+ failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure;
+
++ (void)entityDelete:(NSDictionary *)entity
+ name:(NSString*)eName
+ eid:(NSString*)eId
+ success:(void (^)(AFHTTPRequestOperation *operation, id responseObject)) success
+ failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure;
+@end
View
@@ -0,0 +1,135 @@
+// DIOSEntity.m
+//
+// ***** 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 *****
+
+#import "DIOSEntity.h"
+#import "DIOSSession.h"
+#import "AFJSONRequestOperation.h"
+@implementation DIOSEntity
+
+#pragma mark nodeGets
++ (void)entityGet:(NSDictionary *)entity
+ name:(NSString*)eName
+ eid:(NSString*)eId
+ success:(void (^)(AFHTTPRequestOperation *operation, id responseObject)) success
+ failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure {
+
+ NSString *path = [NSString stringWithFormat:@"%@/%@/%@", kDiosEndpoint, eName, [entity objectForKey:eId]];
+
+ if ([[DIOSSession sharedSession] signRequests]) {
+ [[DIOSSession sharedSession] sendSignedRequestWithPath:path
+ method:@"GET"
+ params:entity
+ success:success
+ failure:failure];
+ } else {
+ [[DIOSSession sharedSession] getPath:path
+ parameters:nil
+ success:success
+ failure:failure];
+ }
+}
+
+#pragma mark nodeSave
++ (void)entitySave:(NSDictionary *)entity
+ name:(NSString*)eName
+ success:(void (^)(AFHTTPRequestOperation *operation, id responseObject)) success
+ failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure {
+
+ NSString *path = [NSString stringWithFormat:@"%@/%@", kDiosEndpoint, eName];
+
+ if ([[DIOSSession sharedSession] signRequests]) {
+ [[DIOSSession sharedSession] sendSignedRequestWithPath:path
+ method:@"POST"
+ params:entity
+ success:success
+ failure:failure];
+ }
+ else {
+ [[DIOSSession sharedSession] postPath:path
+ parameters:entity
+ success:success
+ failure:failure];
+ }
+}
+
+#pragma mark nodeUpdate
++ (void)entityUpdate:(NSDictionary *)entity
+ name:(NSString*)eName
+ eid:(NSString*)eId
+ success:(void (^)(AFHTTPRequestOperation *operation, id responseObject)) success
+ failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure {
+
+ NSString *path = [NSString stringWithFormat:@"%@/%@/%@", kDiosEndpoint, eName, [entity objectForKey:eId]];
+
+ if ([[DIOSSession sharedSession] signRequests]) {
+ [[DIOSSession sharedSession] sendSignedRequestWithPath:path
+ method:@"PUT"
+ params:entity
+ success:success
+ failure:failure];
+ }
+ else {
+ [[DIOSSession sharedSession] putPath:path
+ parameters:entity
+ success:success
+ failure:failure];
+ }
+
+}
+
+#pragma mark nodeDelete
++ (void)entityDelete:(NSDictionary *)entity
+ name:(NSString*)eName
+ eid:(NSString*)eId
+ success:(void (^)(AFHTTPRequestOperation *operation, id responseObject)) success
+ failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure {
+
+ NSString *path = [NSString stringWithFormat:@"%@/%@/%@", kDiosEndpoint, eName, [entity objectForKey:eId]];
+
+ if ([[DIOSSession sharedSession] signRequests]) {
+ [[DIOSSession sharedSession] sendSignedRequestWithPath:path
+ method:@"DELETE"
+ params:entity
+ success:success
+ failure:failure];
+ } else {
+ [[DIOSSession sharedSession] deletePath:path
+ parameters:entity
+ success:success
+ failure:failure];
+ }
+}
+@end
View
@@ -81,7 +81,6 @@ + (UIImageView *) getImageViewForFileImage:(NSDictionary *) file; {
NSURL *url = [NSURL URLWithString:[file objectForKey:@"uri_full"]];
UIImageView *remoteImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
[remoteImage setImageWithURL:url];
- [remoteImage release];
return remoteImage;
}
@end
View
@@ -36,7 +36,7 @@
#import "DIOSNode.h"
#import "DIOSSession.h"
-#import "AFJSONUtilities.h"
+#import "AFJSONRequestOperation.h"
@implementation DIOSNode
#pragma mark nodeGets
@@ -139,7 +139,6 @@ + (void)nodeIndexWithPage:(NSString *)page
[nodeIndexDict setValue:parameteres forKey:@"parameters"];
[nodeIndexDict setValue:pageSize forKey:@"pagesize"];
[self nodeIndex:nodeIndexDict success:success failure:failure];
- [nodeIndexDict release];
}
+ (void)nodeIndex:(NSDictionary *)params
View
@@ -122,6 +122,9 @@ - (void) sendSignedRequestWithPath:(NSString*)path
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure {
NSURLRequest *request = [self signedRequestWithMethod:method path:path parameters:params];
+ NSLog(@"send signedrequest #######REQUEST######## :%@", request);
+ NSLog(@"params: %@", params);
+
AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure];
[self enqueueHTTPRequestOperation:operation];
}
@@ -284,7 +287,7 @@ - (void)addGeneratedTimestampAndNonceInto:(NSMutableDictionary *)dictionary {
NSString *timestamp = [NSString stringWithFormat:@"%d", epochTime];
CFUUIDRef theUUID = CFUUIDCreate(NULL);
CFStringRef string = CFUUIDCreateString(NULL, theUUID);
- NSString *nonce = (NSString *)string;
+ NSString *nonce = (NSString *)CFBridgingRelease(string);
CFRelease(theUUID);
[dictionary setObject:nonce forKey:@"oauth_nonce"];
@@ -332,7 +335,7 @@ - (NSString *) baseURLforAddress:(NSURL *)url {
// Hyphen, Period, Understore & Tilde are expressly legal
const CFStringRef legalURLCharactersToBeEscaped = CFSTR(":/=,!$&'()*+;[]@#?");
- return ( NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, ( CFStringRef)string, NULL, legalURLCharactersToBeEscaped, kCFStringEncodingUTF8);
+ return ( NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, ( CFStringRef)string, NULL, legalURLCharactersToBeEscaped, kCFStringEncodingUTF8));
}
@end
// The function below was inspired on
View
@@ -46,7 +46,7 @@ @implementation DIOSSystem
#pragma mark UserGets
+ (void)systemConnectwithSuccess: (void (^)(AFHTTPRequestOperation *operation, id responseObject)) success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure {
-
+
[[DIOSSession sharedSession] postPath:[NSString stringWithFormat:@"%@/system/connect", kDiosEndpoint]
parameters:nil
success:success
View
@@ -50,7 +50,6 @@ + (void)getTreeWithVid:(NSString *)vid
[params setValue:parent forKey:@"parent"];
[params setValue:maxDepth forKey:@"max_depth"];
[self getTreeWithParams:params success:success failure:failure];
- [params release];
}
+ (void)getTreeWithParams:(NSDictionary *)params
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject)) success
@@ -85,7 +84,6 @@ + (void)selectNodesWithTid:(NSString *)tid
[params setValue:pager forKey:@"pager"];
[params setValue:order forKey:@"prder"];
[self selectNodesWithParams:params success:success failure:failure];
- [params release];
}
+ (void)selectNodesWithParams:(NSDictionary *)params
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject)) success
View
@@ -37,7 +37,10 @@
#import "AFHTTPRequestOperation.h"
+static NSUInteger USERNAME_MAX_LENGTH = 60;
+
@interface DIOSUser : NSObject
+
+ (void)userGet:(NSDictionary *)user
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject)) success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure;
@@ -47,8 +50,8 @@
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure;
+ (void)userRegister:(NSDictionary *)user
- success:(void (^)(AFHTTPRequestOperation *operation, id responseObject)) success
- failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure;
+ success:(void (^)(AFHTTPRequestOperation *operation, id responseObject)) success
+ failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure;
+ (void)userUpdate:(NSDictionary *)user
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject)) success
@@ -59,9 +62,9 @@
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure;
+ (void)userIndexWithPage:(NSString *)page
- fields:(NSString *)fields
- parameters:(NSArray *)parameteres
- pageSize:(NSString *)pageSize
+ fields:(NSString *)fields
+ parameters:(NSArray *)parameteres
+ pageSize:(NSString *)pageSize
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject)) success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure;
@@ -78,5 +81,23 @@
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure;
+ (void)userLogoutWithSuccessBlock:(void (^)(AFHTTPRequestOperation *operation, id responseObject)) success
- failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure;
+ failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure;
+
++ (void)userMakeSureUserIsLoggedInWithUsername:(NSString *)username andPassword:(NSString *)password
+ success:(void (^)(AFHTTPRequestOperation *operation, id responseObject)) success
+ failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure;
+
+
++ (void)userMakeSureUserIsLoggedOutWithSucess:(void (^)(AFHTTPRequestOperation *operation, id responseObject)) success
+ failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure;
+
++ (void)userSendPasswordRecoveryEmailWithEmailAddress: (NSString*) email
+ success:(void (^)(AFHTTPRequestOperation *operation, id responseObject)) success
+ failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure;
+
++ (BOOL)userValidateUserName:(NSString*)name error:(NSError**)error;
+
++ (BOOL)userValidateUserEmail:(NSString*)email error:(NSError**)error;
+
+
@end
Oops, something went wrong.

0 comments on commit ac46a0f

Please sign in to comment.