PageRenderTime 32ms CodeModel.GetById 13ms app.highlight 16ms RepoModel.GetById 1ms app.codeStats 0ms

/Mobile/iPhone/StoffiRemote/StoffiRemote/OAuthTestViewController.m

http://yet-another-music-application.googlecode.com/
Objective C | 112 lines | 64 code | 21 blank | 27 comment | 5 complexity | 2dd3299df5b4326857096f51afa9b762 MD5 | raw file
  1//
  2//  OAuthTestViewController.m
  3//  StoffiRemote
  4//
  5//  Created by Fredrik Gadnell on 9/19/11.
  6//  Copyright 2011 __MyCompanyName__. All rights reserved.
  7//
  8
  9#import "OAuthTestViewController.h"
 10
 11@implementation OAuthTestViewController
 12
 13- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
 14{
 15    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
 16    if (self) {
 17        self.view.backgroundColor = [UIColor darkGrayColor];
 18        
 19        UIButton *loginButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
 20        loginButton.frame = CGRectMake(100, 100, 80, 40);
 21        [loginButton setTitle:@"Login" forState:UIControlStateNormal];
 22        [loginButton addTarget:self action:@selector(loginButtonPressed) forControlEvents:UIControlEventTouchUpInside];
 23        
 24        UIButton *requestButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
 25        requestButton.frame = CGRectMake(100, 160, 80, 40);
 26        [requestButton setTitle:@"Request" forState:UIControlStateNormal];
 27        [requestButton addTarget:self action:@selector(requestButtonPressed) forControlEvents:UIControlEventTouchUpInside];
 28        
 29        [self.view addSubview:loginButton];
 30        [self.view addSubview:requestButton];
 31    }
 32    return self;
 33}
 34
 35- (void)loginButtonPressed {
 36    [[StoffiOAuthManager sharedManager] signInToStoffiWithDelegate:self];
 37}
 38
 39- (void)requestButtonPressed {
 40    RESTRequest *request = [[RESTClient sharedClient] get:@"/share" delegate:self];
 41    request.shouldLog = YES;
 42}
 43
 44- (void)restRequestDidFail {
 45    NSLog(@"OAuthTestVC: Did receive callback from RestRequest: Request failed");
 46}
 47
 48- (void)restRequestDidLoadResult:(id)jsonObject {
 49    NSLog(@"OAuthTestVC: Did receive callbak from RestRequest: %@", jsonObject);
 50}
 51
 52- (void)viewController:(GTMOAuthViewControllerTouch *)viewController
 53      finishedWithAuth:(GTMOAuthAuthentication *)auth
 54                 error:(NSError *)error 
 55{
 56    if (error != nil) {
 57        // Authentication failed
 58        NSLog(@"Auth failed");
 59    } else {
 60        // Authentication succeeded
 61        NSLog(@"Auth succeeded");
 62    }
 63}
 64
 65- (void)didLogin {
 66    NSLog(@"OAuthTestViewController did login!");
 67}
 68
 69- (void)dealloc
 70{
 71    [super dealloc];
 72}
 73
 74- (void)didReceiveMemoryWarning
 75{
 76    // Releases the view if it doesn't have a superview.
 77    [super didReceiveMemoryWarning];
 78    
 79    // Release any cached data, images, etc that aren't in use.
 80}
 81
 82#pragma mark - View lifecycle
 83
 84/*
 85// Implement loadView to create a view hierarchy programmatically, without using a nib.
 86- (void)loadView
 87{
 88}
 89*/
 90
 91/*
 92// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
 93- (void)viewDidLoad
 94{
 95    [super viewDidLoad];
 96}
 97*/
 98
 99- (void)viewDidUnload
100{
101    [super viewDidUnload];
102    // Release any retained subviews of the main view.
103    // e.g. self.myOutlet = nil;
104}
105
106- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
107{
108    // Return YES for supported orientations
109    return (interfaceOrientation == UIInterfaceOrientationPortrait);
110}
111
112@end