Merge branch 'master' of git://git.linphone.org/linphone-iphone into buschjaeger_new_ui

Conflicts:
	Classes/LinphoneManager.m
This commit is contained in:
Yann Diorcet 2013-01-29 16:38:32 +01:00
commit 0360583532

View file

@ -415,6 +415,37 @@ static void linphone_iphone_display_status(struct _LinphoneCore * lc, const char
linphone_call_set_user_pointer(call, data);
}
const LinphoneAddress *addr = linphone_call_get_remote_address(call);
NSString* address = nil;
if(addr != NULL) {
BOOL useLinphoneAddress = true;
// contact name
char* lAddress = linphone_address_as_string_uri_only(addr);
if(lAddress) {
// Find caller in outdoor stations
NSSet *outstations = configuration.outdoorStations;
for(OutdoorStation *os in outstations) {
if([[FastAddressBook normalizeSipURI:os.address] isEqualToString:[NSString stringWithUTF8String:lAddress]]) {
address = os.name;
useLinphoneAddress = false;
break;
}
}
ms_free(lAddress);
}
if(useLinphoneAddress) {
const char* lDisplayName = linphone_address_get_display_name(addr);
const char* lUserName = linphone_address_get_username(addr);
if (lDisplayName)
address = [NSString stringWithUTF8String:lDisplayName];
else if(lUserName)
address = [NSString stringWithUTF8String:lUserName];
}
}
if(address == nil) {
address = @"Unknown";
}
if (state == LinphoneCallIncomingReceived) {
/*first step is to re-enable ctcall center*/
@ -431,61 +462,32 @@ static void linphone_iphone_display_status(struct _LinphoneCore * lc, const char
if( [[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)]
&& [UIApplication sharedApplication].applicationState != UIApplicationStateActive) {
LinphoneCallLog* callLog=linphone_call_get_call_log(call);
NSString* callId = [NSString stringWithUTF8String:callLog->call_id];
const LinphoneAddress *addr = linphone_call_get_remote_address(call);
NSString* address = nil;
if(addr != NULL) {
BOOL useLinphoneAddress = true;
// contact name
char* lAddress = linphone_address_as_string_uri_only(addr);
if(lAddress) {
// Find caller in outdoor stations
NSSet *outstations = configuration.outdoorStations;
for(OutdoorStation *os in outstations) {
if([[FastAddressBook normalizeSipURI:os.address] isEqualToString:[NSString stringWithUTF8String:lAddress]]) {
address = os.name;
useLinphoneAddress = false;
break;
}
}
ms_free(lAddress);
}
if(useLinphoneAddress) {
const char* lDisplayName = linphone_address_get_display_name(addr);
const char* lUserName = linphone_address_get_username(addr);
if (lDisplayName)
address = [NSString stringWithUTF8String:lDisplayName];
else if(lUserName)
address = [NSString stringWithUTF8String:lUserName];
}
}
if(address == nil) {
address = @"Unknown";
}
NSString *ringtone = [NSString stringWithFormat:@"%@_loop.wav", [[NSUserDefaults standardUserDefaults] stringForKey:@"ringtone_preference"], nil];
if (![[LinphoneManager instance] shouldAutoAcceptCallForCallId:callId]){
// case where a remote notification is not already received
// Create a new local notification
data->notification = [[UILocalNotification alloc] init];
if (data->notification) {
data->notification.repeatInterval = 0;
data->notification.alertBody = [NSString stringWithFormat:@"%@", address];
data->notification.alertAction = NSLocalizedString(@"Answer", nil);
data->notification.soundName = ringtone;
data->notification.userInfo = [NSDictionary dictionaryWithObject:callId forKey:@"callId"];
[[UIApplication sharedApplication] presentLocalNotificationNow:data->notification];
if (!incallBgTask){
incallBgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler: ^{
[LinphoneLogger log:LinphoneLoggerWarning format:@"Call cannot ring any more, too late"];
}];
}
}
}
LinphoneCallLog* callLog=linphone_call_get_call_log(call);
NSString* callId=[NSString stringWithUTF8String:callLog->call_id];
if (![[LinphoneManager instance] shouldAutoAcceptCallForCallId:callId]){
NSString *ringtone = [NSString stringWithFormat:@"%@_loop.wav", [[NSUserDefaults standardUserDefaults] stringForKey:@"ringtone_preference"], nil];
// case where a remote notification is not already received
// Create a new local notification
data->notification = [[UILocalNotification alloc] init];
if (data->notification) {
data->notification.repeatInterval = 0;
data->notification.alertBody = [NSString stringWithFormat:@"%@", address];
data->notification.alertAction = NSLocalizedString(@"Answer", nil);
data->notification.soundName = ringtone;
data->notification.userInfo = [NSDictionary dictionaryWithObject:callId forKey:@"callId"];
[[UIApplication sharedApplication] presentLocalNotificationNow:data->notification];
if (!incallBgTask){
incallBgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler: ^{
[LinphoneLogger log:LinphoneLoggerWarning format:@"Call cannot ring any more, too late"];
}];
}
}
}
}
}
@ -508,13 +510,22 @@ static void linphone_iphone_display_status(struct _LinphoneCore * lc, const char
}
if(data != nil && data->notification != nil) {
LinphoneCallLog *log = linphone_call_get_call_log(call);
// cancel local notif if needed
[[UIApplication sharedApplication] cancelLocalNotification:data->notification];
[data->notification release];
data->notification = nil;
if(log == NULL || log->status != LinphoneCallMissed) {
// cancel local notif if needed
[[UIApplication sharedApplication] cancelLocalNotification:data->notification];
[data->notification release];
data->notification = nil;
if(log == NULL || log->status == LinphoneCallMissed) {
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.repeatInterval = 0;
notification.alertBody = [NSString stringWithFormat:@"%@", address];
notification.alertAction = NSLocalizedString(@"Show", nil);
notification.userInfo = [NSDictionary dictionaryWithObject:[NSString stringWithUTF8String:log->call_id] forKey:@"callLog"];
[[UIApplication sharedApplication] presentLocalNotificationNow:notification];
[notification release];
}
}
}
@ -868,7 +879,6 @@ static LinphoneCoreVTable linphonec_vtable = {
, [confiFileName cStringUsingEncoding:[NSString defaultCStringEncoding]]
, [factoryConfig cStringUsingEncoding:[NSString defaultCStringEncoding]]
,self);
linphone_core_set_user_agent(theLinphoneCore,"LinphoneIPhone",
[[[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString*)kCFBundleVersionKey] UTF8String]);
/* MODIFICATION: Disable addressbook