Permalink
Browse files

Working on credentials

  • Loading branch information...
1 parent 941d614 commit fd3b604ccdd841e502f133025f46f7541d71a46c @soffes committed Aug 29, 2010
@@ -0,0 +1,14 @@
+//
+// CloudAppCredentials.h
+// CloudApp
+//
+// Created by Sam Soffes on 8/29/10.
+// Copyright Sam Soffes 2010. All rights reserved.
+//
+
+@interface CloudAppCredentials : RMUploadCredentials
+
+@property (copy) NSString *username;
+@property (copy) NSString *digest;
+
+@end
@@ -0,0 +1,79 @@
+//
+// CloudAppCredentials.m
+// CloudApp
+//
+// Created by Sam Soffes on 8/29/10.
+// Copyright Sam Soffes 2010. All rights reserved.
+//
+
+#import "CloudAppCredentials.h"
+
+NSString *const CloudAppCredentialsUsernameKey = @"username";
+NSString *const CloudAppCredentialsDigestKey = @"digest";
+
+@implementation CloudAppCredentials
+
+@synthesize username;
+@synthesize digest;
+
++ (NSSet *)_propertyKeys {
+ return [NSSet setWithObjects:
+ CloudAppCredentialsUsernameKey,
+ CloudAppCredentialsDigestKey,
+ nil];
+}
+
+
++ (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key {
+ NSMutableSet *keyPaths = [[super keyPathsForValuesAffectingValueForKey:key] mutableCopy];
+
+ if ([key isEqualToString:RMUploadCredentialsDirtyKey]) {
+ [keyPaths unionSet:[NSSet setWithObjects:
+ CloudAppCredentialsUsernameKey,
+ CloudAppCredentialsDigestKey,
+ nil]];
+ }
+
+ if ([key isEqualToString:RMUploadCredentialsUserIdentifierKey]) {
+ [keyPaths addObject:CloudAppCredentialsUsernameKey];
+ }
+
+ return keyPaths;
+}
+
+
+- (id)initWithPropertyListRepresentation:(id)values {
+ if ((self = [super initWithPropertyListRepresentation:[values objectForKey:@"super"]])) {
+ if ([values valueForKey:CloudAppCredentialsUsernameKey] != nil) {
+ self.username = [values valueForKey:CloudAppCredentialsUsernameKey];
+ }
+
+ if ([values valueForKey:CloudAppCredentialsDigestKey] != nil) {
+ self.digest = [values valueForKey:CloudAppCredentialsDigestKey];
+ }
+ }
+ return self;
+}
+
+
+- (id)propertyListRepresentation {
+ NSMutableDictionary *plist = [NSMutableDictionary dictionary];
+ [plist setObject:[super propertyListRepresentation] forKey:@"super"];
+
+ if (self.username != nil) {
+ [plist setObject:self.username forKey:CloudAppCredentialsUsernameKey];
+ }
+
+ if (self.digest != nil) {
+ [plist setObject:self.digest forKey:CloudAppCredentialsDigestKey];
+ }
+
+ return plist;
+}
+
+
+- (NSString *)userIdentifier {
+ return self.username;
+}
+
+@end
@@ -0,0 +1,26 @@
+//
+// CloudAppCredentialsViewController.h
+// CloudApp
+//
+// Created by Sam Soffes on 8/29/10.
+// Copyright Sam Soffes 2010. All rights reserved.
+//
+
+@class CloudAppCredentials;
+@class ASIHTTPRequest;
+
+@interface CloudAppCredentialsViewController : RMUploadPresetConfigurationViewController {
+
+ ASIHTTPRequest *_request;
+}
+
+@property (retain) CloudAppCredentials *representedObject;
+
+@property (readonly) IBOutlet NSTextField *loginUsernameField;
+@property (readonly) IBOutlet NSTextField *loginPasswordField;
+
+@property (readonly, assign, getter=isAuthenticating) BOOL authenticating;
+
+- (IBAction)nextStage:(id)sender;
+
+@end
@@ -0,0 +1,56 @@
+//
+// CloudAppCredentialsViewController.m
+// CloudApp
+//
+// Created by Sam Soffes on 8/29/10.
+// Copyright Sam Soffes 2010. All rights reserved.
+//
+
+#import "CloudAppCredentialsViewController.h"
+#import "CloudAppCredentials.h"
+
+@interface CloudAppCredentialsViewController ()
+@property (readwrite, assign, getter=isAuthenticating) BOOL authenticating;
+@end
+
+@implementation CloudAppCredentialsViewController
+
+@dynamic representedObject;
+@synthesize loginUsernameField;
+@synthesize loginPasswordField;
+@synthesize authenticating = _authenticating;
+
+- (id)init {
+ if ((self = [super initWithNibName:@"CredentialsView" bundle:[NSBundle bundleWithIdentifier:CloudAppBundleIdentifier]])) {
+
+ }
+ return self;
+}
+
+
+- (IBAction)nextStage:(id)sender {
+ BOOL (^validateTextField)(NSTextField *) = ^ (NSTextField *field) {
+ [field validateEditing];
+ if ([field stringValue] != nil && [[field stringValue] length] > 0) return YES;
+
+// [self highlightErrorInView:field];
+
+ NSDictionary *validationNotificationInfo = [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSError errorWithDomain:RMUploadKitBundleIdentifier code:RMUploadPresetConfigurationViewControllerErrorValidation userInfo:nil], RMUploadPresetConfigurationViewControllerDidCompleteErrorKey,
+ nil];
+ [[NSNotificationCenter defaultCenter] postNotificationName:RMUploadPresetConfigurationViewControllerDidCompleteNotificationName object:self userInfo:validationNotificationInfo];
+
+ return NO;
+ };
+ if (!validateTextField([self loginUsernameField])) return;
+ if (!validateTextField([self loginPasswordField])) return;
+
+
+ // Add `Accept: application/json`
+// RMEmberContext *context = [RMUploaderEmber newContextWithCredentials:nil];
+// [self setLoginConnection:[RMUploadURLConnection connectionWithRequest:[context requestLoginWithUsername:[[self loginUsernameField] stringValue] password:[[self loginPasswordField] stringValue]] delegate:self]];
+
+ [self setAuthenticating:YES];
+}
+
+@end
View
@@ -7,12 +7,20 @@
//
#import "CloudAppPlugin.h"
+#import "CloudAppCredentialsViewController.h"
+#import "CloudAppPresetViewController.h"
@implementation CloudAppPlugin
+- (RMUploadPresetConfigurationViewController *)credentialsConfigurationViewControllerForCredentials:(RMUploadCredentials *)credentials {
+ CloudAppCredentialsViewController *viewController = [[CloudAppCredentialsViewController alloc] init];
+ return viewController;
+}
+
+
- (RMUploadPresetConfigurationViewController *)presetConfigurationViewControllerForPreset:(RMUploadPreset *)preset {
- NSViewController *controller = [[NSViewController alloc] initWithNibName:@"PresetConfig" bundle:[NSBundle bundleWithIdentifier:CloudAppBundleIdentifier]];
- return (RMUploadPresetConfigurationViewController *)controller;
+ CloudAppPresetViewController *controller = [[CloudAppPresetViewController alloc] init];
+ return controller;
}
@end
View
@@ -8,6 +8,7 @@
#import "CloudAppPreset.h"
#import "CloudAppUploadTask.h"
+#import "CloudAppCredentials.h"
@implementation CloudAppPreset
@@ -21,27 +22,22 @@ + (Class)uploadTaskClass {
}
-//+ (Class)credentialsClass {
-// return [CloudAppCredentials class];
-//}
++ (Class)credentialsClass {
+ return [CloudAppCredentials class];
+}
- (id)initWithPropertyListRepresentation:(id)values {
- id superRepresentation = [values objectForKey:@"super"];
- self = [super initWithPropertyListRepresentation:superRepresentation];
- if (self == nil) return nil;
-
- // Note: set any properties from the values container
-
+ if ((self = [super initWithPropertyListRepresentation:[values objectForKey:@"super"]])) {
+ // Note: set any properties from the values container
+ }
return self;
}
- (id)propertyListRepresentation {
- id superRepresentation = [super propertyListRepresentation];
-
NSMutableDictionary *plist = [NSMutableDictionary dictionary];
- [plist setObject:superRepresentation forKey:@"super"];
+ [plist setObject:[super propertyListRepresentation] forKey:@"super"];
// Note: set any properties into the values container
@@ -0,0 +1,13 @@
+//
+// CloudAppPresetViewController.h
+// CloudApp
+//
+// Created by Sam Soffes on 8/29/10.
+// Copyright 2010 Sam Soffes. All rights reserved.
+//
+
+@interface CloudAppPresetViewController : RMUploadPresetConfigurationViewController {
+
+}
+
+@end
@@ -0,0 +1,20 @@
+//
+// CloudAppPresetViewController.m
+// CloudApp
+//
+// Created by Sam Soffes on 8/29/10.
+// Copyright 2010 Sam Soffes. All rights reserved.
+//
+
+#import "CloudAppPresetViewController.h"
+
+@implementation CloudAppPresetViewController
+
+- (id)init {
+ if ((self = [super initWithNibName:@"PresetView" bundle:[NSBundle bundleWithIdentifier:CloudAppBundleIdentifier]])) {
+
+ }
+ return self;
+}
+
+@end
Oops, something went wrong.

0 comments on commit fd3b604

Please sign in to comment.