Add a 'do not auto start application' setting

This commit is contained in:
Pierre-Eric Pelloux-Prayer 2012-03-27 11:28:36 +02:00
parent 9633d4ccb8
commit b38d2f89cf
4 changed files with 34 additions and 8 deletions

View file

@ -48,6 +48,8 @@
-(void) setupUI;
-(void) setupGSMInteraction;
-(void) startApplication;
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UITabBarController* myTabBarController;
@property (nonatomic, retain) ABPeoplePickerNavigationController* myPeoplePickerController;

View file

@ -94,6 +94,15 @@ int __aeabi_idiv(int a, int b) {
}
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)]
&& [UIApplication sharedApplication].applicationState == UIApplicationStateBackground
&& [[NSUserDefaults standardUserDefaults] boolForKey:@"disable_autoboot_preference"]) {
// autoboot disabled, doing nothing
return;
} else if ([LinphoneManager instance] == nil) {
[self startApplication];
}
[[LinphoneManager instance] becomeActive];
if (callCenter == nil) {
@ -223,22 +232,30 @@ int __aeabi_idiv(int a, int b) {
nil];
[self loadDefaultSettings: appDefaults];
if ([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)]
&& [UIApplication sharedApplication].applicationState == UIApplicationStateBackground
&& [[NSUserDefaults standardUserDefaults] boolForKey:@"disable_autoboot_preference"]) {
// autoboot disabled, doing nothing
} else {
[self startApplication];
}
return YES;
}
-(void) startApplication {
/* explicitely instanciate LinphoneManager */
LinphoneManager* lm = [[LinphoneManager alloc] init];
assert(lm == [LinphoneManager instance]);
[self setupUI];
[[LinphoneManager instance] startLibLinphone];
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeSound];
[self setupGSMInteraction];
return YES;
}

View file

@ -65,9 +65,6 @@ extern void libmsbcg729_init();
return self;
}
+(LinphoneManager*) instance {
if (theLinphoneManager==nil) {
[[LinphoneManager alloc] init];
}
return theLinphoneManager;
}

View file

@ -88,6 +88,16 @@
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
</dict>
<dict>
<key>DefaultValue</key>
<false/>
<key>Key</key>
<string>disable_autoboot_preference</string>
<key>Title</key>
<string>Disable application autostart</string>
<key>Type</key>
<string>PSToggleSwitchSpecifier</string>
</dict>
<dict>
<key>DefaultValue</key>
<true/>