root/apps/iphone/my.tel/trunk/Classes/MytelAppDelegate.m
@
675
| Revision 675, 2.1 kB (checked in by henri, 3 years ago) |
|---|
| Line | |
|---|---|
| 1 | // |
| 2 | // MyTelAppDelegate.m |
| 3 | // My.tel |
| 4 | // |
| 5 | // Created by Henri Asseily on 11/11/08. |
| 6 | // Copyright Telnic Ltd. 2008. All rights reserved. |
| 7 | // |
| 8 | |
| 9 | #import "MyTelAppDelegate.h" |
| 10 | |
| 11 | @implementation MyTelAppDelegate |
| 12 | |
| 13 | @synthesize window; |
| 14 | @synthesize rootController; |
| 15 | @synthesize navC; |
| 16 | |
| 17 | - (void)applicationDidFinishLaunching:(UIApplication *)application { |
| 18 | // Check if we're in offline debugging mode |
| 19 | NSArray *args = [[NSProcessInfo processInfo] arguments]; |
| 20 | NSEnumerator *e = [args objectEnumerator]; |
| 21 | NSString *theArg; |
| 22 | offlineMode = FALSE; |
| 23 | while (theArg = [e nextObject]) { |
| 24 | if ([theArg isEqualToString:@"OFFLINE"]) { |
| 25 | offlineMode = TRUE; |
| 26 | NSLog(@"\n----------------\nRUNNING IN OFFLINE MODE\n----------------\n"); |
| 27 | break; |
| 28 | } |
| 29 | } |
| 30 | if (!offlineMode) { |
| 31 | // Start the networking by opening a write stream |
| 32 | NetworkUtility *nUtil = [NetworkUtility sharedInstance]; |
| 33 | if ([nUtil startNetwork] == NotReachable) { |
| 34 | NSDictionary *dict = [NSDictionary dictionaryWithObject:@"Network Error: No Internet Connection" forKey:NSLocalizedDescriptionKey]; |
| 35 | NSError *error; |
| 36 | error = [NSError errorWithDomain:@"org.telnic.my.tel" code:666 userInfo:dict]; |
| 37 | UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"" |
| 38 | message:[error localizedDescription] |
| 39 | delegate:nil |
| 40 | cancelButtonTitle:NSLocalizedString(@"OK", nil) |
| 41 | otherButtonTitles:nil]; |
| 42 | [alertView show]; |
| 43 | [alertView release]; |
| 44 | } |
| 45 | } |
| 46 | self.rootController = [[[RootViewController alloc] initWithStyle:UITableViewStyleGrouped] autorelease]; |
| 47 | self.navC = [[[UINavigationController alloc] initWithRootViewController:self.rootController] autorelease]; |
| 48 | [window addSubview:self.navC.view]; |
| 49 | } |
| 50 | |
| 51 | - (void)applicationDidBecomeActive:(UIApplication *)application { |
| 52 | // Re-login to make sure the session is ok |
| 53 | // Nothing will happen if no account is set up |
| 54 | [self.rootController loginToAccountAtIndex:self.rootController.currentAccountIndex forced:YES]; |
| 55 | } |
| 56 | |
| 57 | |
| 58 | - (BOOL)offlineMode { |
| 59 | return offlineMode; |
| 60 | } |
| 61 | |
| 62 | - (void)refreshLogin { |
| 63 | [self.rootController loginToCurrentAccount]; |
| 64 | } |
| 65 | |
| 66 | - (void)dealloc { |
| 67 | [rootController release]; |
| 68 | [window release]; |
| 69 | [super dealloc]; |
| 70 | } |
| 71 | |
| 72 | @end |
| 73 |
Note: See TracBrowser
for help on using the browser.








