Created
May 23, 2011 11:35
-
-
Save longlongjump/986571 to your computer and use it in GitHub Desktop.
service example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// StatusOnAppDelegate.m | |
// StatusOn | |
// | |
// Created by Sergey Gavrilyuk on 5/16/11. | |
// Copyright 2011 SoftTechnics. All rights reserved. | |
// | |
#import "StatusOnAppDelegate.h" | |
#import "JSON.h" | |
#import "SOLoginViewCtrl.h" | |
#import "SOLicenseAgreementViewCtrl.h" | |
#import <QuartzCore/QuartzCore.h> | |
#import "SORegInfo.h" | |
#import "StatusOnService.h" | |
StatusOnService *service = nil; | |
@implementation StatusOnAppDelegate | |
@synthesize window; | |
@synthesize tabBarController, navigationController; | |
#pragma mark - | |
#pragma mark Application lifecycle | |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
{ | |
// Override point for customization after application launch. | |
// Add the tab bar controller's view to the window and display. | |
if(YES) | |
{ | |
//login screen | |
fCurrentViewCtrl = [[SOLoginViewCtrl alloc] initWithNibName:@"SOLoginViewCtrl" bundle:nil] ; | |
} | |
else | |
{ | |
fCurrentViewCtrl = [tabBarController retain]; | |
} | |
[self.window addSubview:fCurrentViewCtrl.view]; | |
[self.window makeKeyAndVisible]; | |
service = [[StatusOnService alloc] init]; | |
// service.password = @"dcfcd07e645d245babe887e5e2daa016"; | |
//service.username = @"vlad.linsky@yahoo.com"; | |
service.language = @"en"; | |
service.UDID = @"21020"; | |
service.logging = YES; | |
/*[service requestWithUrl:[service userWithId:@"666"] | |
delegate:self | |
finishSelector:@selector(requestFinished:) | |
failSelector:@selector(requestFailed:)];*/ | |
UserEntry *user = [UserEntry entry]; | |
user.nickname = @"lollol"; | |
user.surname = @"2lollol"; | |
user.firstName = @"lolol"; | |
user.email = @"lolmail@lolol.lo"; | |
user.password = @"password1111"; | |
[service insertNewUser:user | |
delegate:self | |
finishSelector:@selector(requestUserInsertFinished:) | |
failSelector:@selector(requestFailed:)]; | |
[service userWithId:@"1" | |
delegate:self | |
finishSelector:@selector(requestWithGetUser:) | |
failSelector:@selector(requestFailed:)]; | |
[service authWithFacebookConnect:NO | |
delegate:self | |
finishSelector:@selector(requestAuth:) | |
failSelector:@selector(requestFailed:)]; | |
return YES; | |
} | |
-(void)requestAuth:(StatusOnRequest*)request | |
{ | |
NSLog(@"%@",[request dictResponse]); | |
} | |
-(void)requestUserInsertFinished:(StatusOnRequest*)request | |
{ | |
NSLog(@"%@",[request dictResponse]); | |
NSString *user_id = [[[request dictResponse] valueForKey:@"user_id"] stringValue]; | |
[service userWithId:user_id | |
delegate:self | |
finishSelector:@selector(requestWithGetUser:) | |
failSelector:@selector(requestFailed:)]; | |
} | |
-(void)requestWithGetUser:(StatusOnRequest*)request | |
{ | |
NSLog(@"%@",[[request dictResponse] valueForKeyPath:@"user_data"] ); | |
UserEntry *user = [UserEntry entry]; | |
user.nickname = @"icanhazcheez"; | |
user.surname = @"2lollol"; | |
user.firstName = @"lolol"; | |
service.password = @"dasdasdasdas"; | |
service.username = @"lololo@lol.lo"; | |
[service updateUser:user | |
delegate:self | |
finishSelector:@selector(requestUpdateFinished:) | |
failSelector:@selector(requestFailed:)]; | |
} | |
-(void)requestUpdateFinished:(StatusOnRequest *)request | |
{ | |
NSLog(@"%@",[request dictResponse]); | |
} | |
-(void)requestFinished:(StatusOnRequest*)request | |
{ | |
} | |
-(void)requestFailed:(StatusOnRequest*)request | |
{ | |
if ([[request error] isKindOfClass:[StatusOnServerError class]]) | |
{ | |
StatusOnServerError *error = (StatusOnServerError *)[request error]; | |
NSLog(@"%@", [error errorMessage]); | |
} | |
else | |
{ | |
NSLog(@"%@",[request error]); | |
} | |
} | |
- (void)setProgress:(float)newProgress | |
{ | |
NSLog(@"%f",newProgress); | |
} | |
- (void)applicationWillResignActive:(UIApplication *)application { | |
/* | |
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. | |
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. | |
*/ | |
} | |
- (void)applicationDidEnterBackground:(UIApplication *)application { | |
/* | |
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. | |
If your application supports background execution, called instead of applicationWillTerminate: when the user quits. | |
*/ | |
} | |
- (void)applicationWillEnterForeground:(UIApplication *)application { | |
/* | |
Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background. | |
*/ | |
} | |
- (void)applicationDidBecomeActive:(UIApplication *)application { | |
/* | |
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. | |
*/ | |
} | |
- (void)applicationWillTerminate:(UIApplication *)application { | |
/* | |
Called when the application is about to terminate. | |
See also applicationDidEnterBackground:. | |
*/ | |
} | |
#pragma mark - | |
#pragma mark UITabBarControllerDelegate methods | |
/* | |
// Optional UITabBarControllerDelegate method. | |
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController { | |
} | |
*/ | |
/* | |
// Optional UITabBarControllerDelegate method. | |
- (void)tabBarController:(UITabBarController *)tabBarController didEndCustomizingViewControllers:(NSArray *)viewControllers changed:(BOOL)changed { | |
} | |
*/ | |
#pragma mark - | |
#pragma mark Memory management | |
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { | |
/* | |
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later. | |
*/ | |
} | |
- (void)dealloc | |
{ | |
[fCurrentViewCtrl release]; | |
[tabBarController release]; | |
[window release]; | |
[super dealloc]; | |
} | |
#pragma mark - | |
#pragma mark specific app functions | |
-(void) startRegistrationProcessWithRegistrationInfo:(SORegInfo*) info | |
{ | |
[UIView beginAnimations:nil context:nil]; | |
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView: self.window cache:YES]; | |
[UIView setAnimationDuration:.99]; | |
[fCurrentViewCtrl.view removeFromSuperview]; | |
[fCurrentViewCtrl release]; | |
SOLicenseAgreementViewCtrl* licenseViewCtrl = [[SOLicenseAgreementViewCtrl alloc] initWithNibName:@"SOLicenseAgreementViewCtrl" bundle:nil]; | |
[self.navigationController setViewControllers:[NSArray arrayWithObject:licenseViewCtrl]]; | |
licenseViewCtrl.registrationInfo = info; | |
fCurrentViewCtrl = self.navigationController; | |
[licenseViewCtrl release]; | |
[self.window addSubview: fCurrentViewCtrl.view]; | |
[UIView commitAnimations]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment