From de06385293d0f677f055ff7eb68a5286dee79a71 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 21 May 2010 16:03:29 +0200 Subject: [PATCH] start multitasking support --- Classes/linphoneAppDelegate.h | 2 ++ Classes/linphoneAppDelegate.m | 24 ++++++++++++++++++++++++ linphone-Info.plist | 5 +++++ linphone.xcodeproj/project.pbxproj | 6 +++--- 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/Classes/linphoneAppDelegate.h b/Classes/linphoneAppDelegate.h index 177fea373..eaed31802 100644 --- a/Classes/linphoneAppDelegate.h +++ b/Classes/linphoneAppDelegate.h @@ -47,6 +47,8 @@ bool isDebug; bool isStarted; + bool backgroundSupported; + LinphoneCore* myLinphoneCore; SCNetworkReachabilityContext proxyReachabilityContext; SCNetworkReachabilityRef proxyReachability; diff --git a/Classes/linphoneAppDelegate.m b/Classes/linphoneAppDelegate.m index 6ed2e8251..0e6d344ac 100644 --- a/Classes/linphoneAppDelegate.m +++ b/Classes/linphoneAppDelegate.m @@ -27,6 +27,10 @@ #import "MoreViewController.h" extern void ms_au_register_card(); +void linphone_iphone_keepAliveHandler () { + ms_message("keepalive handler invoked"); +}; + //generic log handler for debug version void linphone_iphone_log_handler(int lev, const char *fmt, va_list args){ NSString* format = [[NSString alloc] initWithCString:fmt encoding:[NSString defaultCStringEncoding]]; @@ -91,6 +95,20 @@ LinphoneCoreVTable linphonec_vtable = { @synthesize myPeoplePickerController; @synthesize myPhoneViewController; +- (void)applicationDidEnterBackground:(UIApplication *)application { + + + if (backgroundSupported) { + if ([[UIApplication sharedApplication] setKeepAliveTimeout:(NSTimeInterval)300 + handler:^{ms_warning("Handler invoked");}]) { + ms_warning("keepalive handler succesfully registered"); + } else { + ms_warning("keepalive handler cannot be registered"); + } + + } + +} - (void)applicationDidFinishLaunching:(UIApplication *)application { @@ -101,6 +119,10 @@ LinphoneCoreVTable linphonec_vtable = { #define HISTORY_TAB_INDEX 0 #define MORE_TAB_INDEX 3 + UIDevice* device = [UIDevice currentDevice]; + backgroundSupported = false; + if ([device respondsToSelector:@selector(isMultitaskingSupported)]) + backgroundSupported = device.multitaskingSupported; myPhoneViewController = (PhoneViewController*) [myTabBarController.viewControllers objectAtIndex: DIALER_TAB_INDEX]; @@ -313,6 +335,7 @@ extern void libmsilbc_init(); LinphoneAddress* addr=linphone_address_new(linphone_proxy_config_get_addr(proxyCfg)); proxyReachability=SCNetworkReachabilityCreateWithName(nil, linphone_address_get_domain(addr)); + [self doRegister]; } else if (configCheckDisable == false) { @@ -475,4 +498,5 @@ bool networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach SCNetworkReachabilityGetFlags (proxyReachability,&reachabilityFlags); networkReachabilityCallBack(proxyReachability,reachabilityFlags,self); } + @end diff --git a/linphone-Info.plist b/linphone-Info.plist index 51ba515eb..43aedc875 100644 --- a/linphone-Info.plist +++ b/linphone-Info.plist @@ -33,5 +33,10 @@ wifi microphone + UIBackgroundModes + + audio + voip + diff --git a/linphone.xcodeproj/project.pbxproj b/linphone.xcodeproj/project.pbxproj index 67f86a4b9..aaed3e0ff 100755 --- a/linphone.xcodeproj/project.pbxproj +++ b/linphone.xcodeproj/project.pbxproj @@ -712,7 +712,7 @@ LINK_WITH_STANDARD_LIBRARIES = YES; PREBINDING = NO; "PROVISIONING_PROFILE[sdk=iphoneos*]" = "09801E17-63DB-47FD-A203-166EDD1E55A1"; - SDKROOT = iphoneos3.1; + SDKROOT = iphoneos3.2; }; name = Distribution; }; @@ -753,7 +753,7 @@ LIBRARY_SEARCH_PATHS = ""; LINK_WITH_STANDARD_LIBRARIES = YES; PREBINDING = NO; - SDKROOT = iphoneos3.1; + SDKROOT = iphoneos3.2; }; name = Debug; }; @@ -766,7 +766,7 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; PREBINDING = NO; - SDKROOT = iphoneos3.1; + SDKROOT = iphoneos3.2; }; name = Release; };