This commit is contained in:
Jehan Monnier 2010-05-27 10:34:56 +02:00
parent 216c691405
commit 0070d59d1d
2 changed files with 54 additions and 7 deletions

View file

@ -97,17 +97,28 @@ LinphoneCoreVTable linphonec_vtable = {
- (void)applicationDidEnterBackground:(UIApplication *)application {
#if __IPHONE_OS_VERSION_MIN_REQUIRED > 40000
<#statements#>
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 40000
if (backgroundSupported) {
if ([[UIApplication sharedApplication] setKeepAliveTimeout:(NSTimeInterval)300
handler:^{ms_warning("Handler invoked");}]) {
LinphoneProxyConfig* proxyCfg = linphone_core_get_default_proxy(myLinphoneCore, &proxyCfg);
if (backgroundSupported && proxyCfg) {
if ([[UIApplication sharedApplication] setKeepAliveTimeout:(NSTimeInterval)linphone_proxy_config_get_expires(proxyCfg)
handler:^{
ms_warning("keepalive handler");
linphone_core_set_network_reachable(myLinphoneCore,false);
linphone_core_iterate(myLinphoneCore);
linphone_core_set_network_reachable(myLinphoneCore,true);
linphone_core_iterate(myLinphoneCore);
}
]) {
ms_warning("keepalive handler succesfully registered");
} else {
ms_warning("keepalive handler cannot be registered");
}
}
#endif
@ -189,6 +200,7 @@ LinphoneCoreVTable linphonec_vtable = {
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
if (isStarted) {
ms_message("becomming active, make sure we are registered");
[self doRegister];
@ -414,8 +426,21 @@ extern void libmsilbc_init();
linphone_core_enable_payload_type(myLinphoneCore,pt, TRUE);
}
}
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 40000
int sipsock = linphone_core_get_sip_socket(myLinphoneCore);
CFReadStreamRef readStream;
CFWriteStreamRef writeStream;
CFStreamCreatePairWithSocket(NULL, (CFSocketNativeHandle)sipsock, &readStream, &writeStream);
if (!CFReadStreamSetProperty(readStream, kCFStreamNetworkServiceType, kCFStreamNetworkServiceTypeVoIP)) {
ms_error("cannot set service type to voip for read stream");
}
if (!CFWriteStreamSetProperty(writeStream, kCFStreamNetworkServiceType, kCFStreamNetworkServiceTypeVoIP)) {
ms_error("cannot set service type to voip for write stream");
}
#endif
// start scheduler
[NSTimer scheduledTimerWithTimeInterval:0.1
@ -441,11 +466,28 @@ extern void libmsilbc_init();
, sizeof (audioRouteOverride)
, &audioRouteOverride);
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 40000
if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) {
// Create a new notification
UILocalNotification* notif = [[[UILocalNotification alloc] init] autorelease];
if (notif)
{
notif.repeatInterval = 0;
notif.alertBody =[NSString stringWithFormat:@" %@ is calling you",from];
[[UIApplication sharedApplication] presentLocalNotificationNow:notif];
}
}
#endif
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:[NSString stringWithFormat:@" %@ is calling you",from]
delegate:self cancelButtonTitle:@"Decline" destructiveButtonTitle:@"Answer" otherButtonTitles:nil];
actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
[actionSheet showFromTabBar:myTabBarController.tabBar];
[actionSheet release];
}

View file

@ -49,6 +49,7 @@
2274550810700509006EC466 /* linphonerc in Resources */ = {isa = PBXBuildFile; fileRef = 2274550710700509006EC466 /* linphonerc */; };
227BCDC210D4004600FBFD76 /* CallHistoryTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 227BCDC010D4004600FBFD76 /* CallHistoryTableViewController.m */; };
227BCDC310D4004600FBFD76 /* CallHistoryTableViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 227BCDC110D4004600FBFD76 /* CallHistoryTableViewController.xib */; };
228697C411AC29B800E9E0CA /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 228697C311AC29B800E9E0CA /* CFNetwork.framework */; };
22B5EFA310CE50BD00777D97 /* AddressBookUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 22B5EFA210CE50BD00777D97 /* AddressBookUI.framework */; };
22B5EFE510CE5E5800777D97 /* ContactPickerDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 22B5EFE410CE5E5800777D97 /* ContactPickerDelegate.m */; };
22B5F03510CE6B2F00777D97 /* AddressBook.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 22B5F03410CE6B2F00777D97 /* AddressBook.framework */; };
@ -221,6 +222,7 @@
227BCDBF10D4004600FBFD76 /* CallHistoryTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CallHistoryTableViewController.h; sourceTree = "<group>"; };
227BCDC010D4004600FBFD76 /* CallHistoryTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CallHistoryTableViewController.m; sourceTree = "<group>"; };
227BCDC110D4004600FBFD76 /* CallHistoryTableViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = CallHistoryTableViewController.xib; sourceTree = "<group>"; };
228697C311AC29B800E9E0CA /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; };
22B5EFA210CE50BD00777D97 /* AddressBookUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AddressBookUI.framework; path = System/Library/Frameworks/AddressBookUI.framework; sourceTree = SDKROOT; };
22B5EFE310CE5E5800777D97 /* ContactPickerDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContactPickerDelegate.h; sourceTree = "<group>"; };
22B5EFE410CE5E5800777D97 /* ContactPickerDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ContactPickerDelegate.m; sourceTree = "<group>"; };
@ -270,6 +272,7 @@
2264B6D211200342002C2C53 /* SystemConfiguration.framework in Frameworks */,
223148E41178A08200637D6A /* libilbc.a in Frameworks */,
223148E61178A09900637D6A /* libmsilbc.a in Frameworks */,
228697C411AC29B800E9E0CA /* CFNetwork.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -528,6 +531,7 @@
22B5F03410CE6B2F00777D97 /* AddressBook.framework */,
2264B6D111200342002C2C53 /* SystemConfiguration.framework */,
2258633C11410BAC00C5A737 /* README */,
228697C311AC29B800E9E0CA /* CFNetwork.framework */,
);
name = CustomTemplate;
sourceTree = "<group>";
@ -692,7 +696,7 @@
);
PRODUCT_NAME = linphone;
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
SDKROOT = iphoneos3.0;
SDKROOT = iphoneos4.0;
STANDARD_C_PLUS_PLUS_LIBRARY_TYPE = dynamic;
};
name = Debug;
@ -712,6 +716,7 @@
"\"$(SRCROOT)/../liblinphone-sdk/apple-darwin/lib/mediastreamer/plugins\"",
);
PRODUCT_NAME = linphone;
SDKROOT = iphoneos4.0;
};
name = Release;
};
@ -752,7 +757,7 @@
);
PRODUCT_NAME = linphone;
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
SDKROOT = iphoneos3.0;
SDKROOT = iphoneos4.0;
STANDARD_C_PLUS_PLUS_LIBRARY_TYPE = dynamic;
};
name = Distribution;