From deeb67836366b61ea2075d7177368de40372c2dd Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Tue, 10 Jan 2017 10:34:07 +0100 Subject: [PATCH 01/13] Cancel timer when auto-answe to notificationr --- Classes/LinphoneAppDelegate.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index 2c2682b0e..69660ef11 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -110,6 +110,11 @@ } instance->currentCallContextBeforeGoingBackground.call = 0; } else if (linphone_call_get_state(call) == LinphoneCallIncomingReceived) { + LinphoneCallAppData *data = (__bridge LinphoneCallAppData *)linphone_call_get_user_data(call); + if (data && data->timer) { + [data->timer invalidate]; + data->timer = nil; + } if ((floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max)) { if ([LinphoneManager.instance lpConfigBoolForKey:@"autoanswer_notif_preference"]) { linphone_core_accept_call(LC, call); From e04d9751e4c13e434120b944a4b64f1a20430433 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Tue, 10 Jan 2017 12:08:06 +0100 Subject: [PATCH 02/13] release: version 3.16.1 build 0 --- CHANGELOG.md | 2 +- Classes/LinphoneManager.m | 4 +++- linphone-Info.plist | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10db23829..7d29ca030 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ Group changes to describe their impact on the project, as follows: ## [Unreleased] -## [3.16] - 2017-09-01 +## [3.16.1] - 2017-09-01 ### Added - Support of CallKit diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index d60560963..4ede19f59 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -1355,7 +1355,9 @@ static void linphone_iphone_call_encryption_changed(LinphoneCore *lc, LinphoneCa NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:[NSValue valueWithPointer:call] forKey:@"call"]; [dict setObject:[NSNumber numberWithBool:on] forKey:@"on"]; - [dict setObject:[NSString stringWithUTF8String:authentication_token] forKey:@"token"]; + if (authentication_token) { + [dict setObject:[NSString stringWithUTF8String:authentication_token] forKey:@"token"]; + } [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneCallEncryptionChanged object:self userInfo:dict]; } diff --git a/linphone-Info.plist b/linphone-Info.plist index fa833f85b..03244188e 100644 --- a/linphone-Info.plist +++ b/linphone-Info.plist @@ -24,7 +24,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 3.16 + 3.16.1 CFBundleURLTypes @@ -53,7 +53,7 @@ CFBundleVersion - 8 + 1 ITSAppUsesNonExemptEncryption ITSEncryptionExportComplianceCode From 6a19baec92172c176a6ed5fd74d6473768b25c85 Mon Sep 17 00:00:00 2001 From: Brieuc Viel Date: Tue, 11 Apr 2017 16:32:17 +0200 Subject: [PATCH 03/13] Removed submodule ortp & ms2 because still in submodule linphone --- .gitmodules | 6 ------ submodules/mediastreamer2 | 1 - submodules/ortp | 1 - 3 files changed, 8 deletions(-) delete mode 160000 submodules/mediastreamer2 delete mode 160000 submodules/ortp diff --git a/.gitmodules b/.gitmodules index 0e5457618..9e25e15cb 100644 --- a/.gitmodules +++ b/.gitmodules @@ -105,9 +105,3 @@ [submodule "submodules/externals/libjpeg-turbo"] path = submodules/externals/libjpeg-turbo url = git://git.linphone.org/libjpeg-turbo.git -[submodule "submodules/mediastreamer2"] - path = submodules/mediastreamer2 - url = gitosis@git.linphone.org:mediastreamer2 -[submodule "submodules/ortp"] - path = submodules/ortp - url = gitosis@git.linphone.org:ortp diff --git a/submodules/mediastreamer2 b/submodules/mediastreamer2 deleted file mode 160000 index 21a3e023a..000000000 --- a/submodules/mediastreamer2 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 21a3e023adef4fe2568340af28cd3487e268ba2e diff --git a/submodules/ortp b/submodules/ortp deleted file mode 160000 index 67c0672e2..000000000 --- a/submodules/ortp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 67c0672e2680baa85a74d8966b813fac259649df From 90aeeb43523a594c95b217b59d5b944e2d7111bb Mon Sep 17 00:00:00 2001 From: Brieuc Viel Date: Wed, 12 Apr 2017 13:54:16 +0200 Subject: [PATCH 04/13] [imdm] fix markAsRead method and prepare for beta v. --- Classes/Contact.m | 8 ++++---- Classes/LinphoneUI/UIAvatarPresence.m | 5 +++-- Classes/LinphoneUI/UIChatBubbleTextCell.m | 4 ++-- submodules/cmake-builder | 2 +- submodules/linphone | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Classes/Contact.m b/Classes/Contact.m index 6e99cccf0..bac49ea09 100644 --- a/Classes/Contact.m +++ b/Classes/Contact.m @@ -197,8 +197,8 @@ if (_person) { normSip = [self setOrCreateSipContactEntry:index withValue:sip]; NSDictionary *lDict = @{ - (NSString *)kABPersonInstantMessageUsernameKey : normSip ? normSip : sip, - (NSString *)kABPersonInstantMessageServiceKey : LinphoneManager.instance.contactSipField + (NSString *) kABPersonInstantMessageUsernameKey : normSip ? normSip : sip, (NSString *) + kABPersonInstantMessageServiceKey : LinphoneManager.instance.contactSipField }; ret = [self replaceInProperty:kABPersonInstantMessageProperty value:(__bridge CFTypeRef)(lDict) atIndex:index]; @@ -358,8 +358,8 @@ CFErrorRef error = NULL; NSDictionary *lDict = @{ - (NSString *)kABPersonInstantMessageUsernameKey : value, - (NSString *)kABPersonInstantMessageServiceKey : [LinphoneManager instance].contactSipField + (NSString *) kABPersonInstantMessageUsernameKey : value, (NSString *) + kABPersonInstantMessageServiceKey : [LinphoneManager instance].contactSipField }; if (![self replaceInProperty:kABPersonInstantMessageProperty value:(__bridge CFTypeRef)(lDict) atIndex:index]) { diff --git a/Classes/LinphoneUI/UIAvatarPresence.m b/Classes/LinphoneUI/UIAvatarPresence.m index 2074bbde6..dc626f94f 100644 --- a/Classes/LinphoneUI/UIAvatarPresence.m +++ b/Classes/LinphoneUI/UIAvatarPresence.m @@ -57,10 +57,11 @@ INIT_WITH_COMMON_CF { _friend ? linphone_presence_model_get_basic_status(linphone_friend_get_presence_model(_friend)) : LinphonePresenceBasicStatusClosed; const LinphonePresenceModel *model = _friend ? linphone_friend_get_presence_model(_friend) : NULL; - LinphonePresenceActivity *activity = model ? linphone_presence_model_get_activity(model):NULL; + LinphonePresenceActivity *activity = model ? linphone_presence_model_get_activity(model) : NULL; LOGE(@"Friend %s status is now %s/%s since %@", _friend ? linphone_friend_get_name(_friend) : "NULL", - basic == LinphonePresenceBasicStatusOpen ? "open" : "closed", activity? linphone_presence_activity_to_string(activity):"Unknown", + basic == LinphonePresenceBasicStatusOpen ? "open" : "closed", + activity ? linphone_presence_activity_to_string(activity) : "Unknown", [NSDate dateWithTimeIntervalSince1970:linphone_presence_model_get_timestamp(model)]); NSString *imageName; diff --git a/Classes/LinphoneUI/UIChatBubbleTextCell.m b/Classes/LinphoneUI/UIChatBubbleTextCell.m index 8cca9e4b7..326441ad7 100644 --- a/Classes/LinphoneUI/UIChatBubbleTextCell.m +++ b/Classes/LinphoneUI/UIChatBubbleTextCell.m @@ -150,8 +150,8 @@ [_messageText setAccessibilityLabel:@"Outgoing message"]; } else { [_messageText setAccessibilityLabel:@"Incoming message"]; - if (!([UIApplication sharedApplication].applicationState != UIApplicationStateBackground || - [UIApplication sharedApplication].applicationState != UIApplicationStateInactive)) { + if (!([UIApplication sharedApplication].applicationState == UIApplicationStateBackground || + [UIApplication sharedApplication].applicationState == UIApplicationStateInactive)) { VIEW(ChatConversationView).markAsRead; } } diff --git a/submodules/cmake-builder b/submodules/cmake-builder index bc6df3cfa..adfd9bf28 160000 --- a/submodules/cmake-builder +++ b/submodules/cmake-builder @@ -1 +1 @@ -Subproject commit bc6df3cfa2c2f8cc54fb225735374c246b68721b +Subproject commit adfd9bf2811f94337364642d2115c93c8ef5d05f diff --git a/submodules/linphone b/submodules/linphone index 0ea7e7cf0..332351d29 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 0ea7e7cf0eb3b1ac9e1462a1126f8b1543f02ea3 +Subproject commit 332351d294fd94acf78e947bae91bd7d7d143132 From 3ebe626e459bc4ad51f9695d3c55073bd7c7ceb3 Mon Sep 17 00:00:00 2001 From: Brieuc Viel Date: Thu, 13 Apr 2017 08:42:31 +0200 Subject: [PATCH 05/13] update build number [Switch submodule branch] --- linphone-Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linphone-Info.plist b/linphone-Info.plist index 0ddc1170c..8ee2cf81e 100644 --- a/linphone-Info.plist +++ b/linphone-Info.plist @@ -53,7 +53,7 @@ CFBundleVersion - 1 + 2 ITSAppUsesNonExemptEncryption ITSEncryptionExportComplianceCode From 775aa4b687e66592c6c9b33cd136f8bd07b1267a Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Thu, 13 Apr 2017 17:13:37 +0200 Subject: [PATCH 06/13] Change log API NSLog --- Classes/Utils/Log.m | 95 +++++++++++++++------------------------------ 1 file changed, 31 insertions(+), 64 deletions(-) diff --git a/Classes/Utils/Log.m b/Classes/Utils/Log.m index f89f2d095..0441d51b5 100644 --- a/Classes/Utils/Log.m +++ b/Classes/Utils/Log.m @@ -79,79 +79,46 @@ void linphone_iphone_log_handler(const char *domain, OrtpLogLevel lev, const char *fmt, va_list args) { NSString *format = [[NSString alloc] initWithUTF8String:fmt]; NSString *formatedString = [[NSString alloc] initWithFormat:format arguments:args]; + NSString *lvl; if (!domain) domain = "lib"; // since \r are interpreted like \n, avoid double new lines when logging network packets (belle-sip) // output format is like: I/ios/some logs. We truncate domain to **exactly** DOMAIN_SIZE characters to have // fixed-length aligned logs - - if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_9_x_Max) { - os_log_t log = os_log_create("subsystem", "Notice"); - os_log_type_t type = OS_LOG_TYPE_INFO; - switch (lev) { - case ORTP_FATAL: - type = OS_LOG_TYPE_FAULT; - log = os_log_create("subsystem", "Fatal"); - break; - case ORTP_ERROR: - type = OS_LOG_TYPE_ERROR; - log = os_log_create("subsystem", "Error"); - break; - case ORTP_WARNING: - type = OS_LOG_TYPE_DEFAULT; - log = os_log_create("subsystem", "Warning"); - break; - case ORTP_MESSAGE: - type = OS_LOG_TYPE_INFO; - log = os_log_create("subsystem", "Notice"); - break; - case ORTP_DEBUG: - case ORTP_TRACE: - type = OS_LOG_TYPE_INFO; - log = os_log_create("subsystem", "Debug"); - break; - case ORTP_LOGLEV_END: - return; - } - if ([formatedString containsString:@"\n"]) { - NSArray *myWords = [[formatedString stringByReplacingOccurrencesOfString:@"\r\n" withString:@"\n"] - componentsSeparatedByString:@"\n"]; - for (int i = 0; i < myWords.count; i++) { - NSString *tab = i > 0 ? @"\t" : @""; - if (((NSString *)myWords[i]).length > 0) { - os_log_with_type(log, type, "%{public}s%{public}s", tab.UTF8String, - ((NSString *)myWords[i]).UTF8String); - } + switch (lev) { + case ORTP_FATAL: + lvl = @"Fatal"; + break; + case ORTP_ERROR: + lvl = @"Error"; + break; + case ORTP_WARNING: + lvl = @"Warning"; + break; + case ORTP_MESSAGE: + lvl = @"Message"; + break; + case ORTP_DEBUG: + lvl = @"Debug"; + break; + case ORTP_TRACE: + lvl = @"Trace"; + break; + case ORTP_LOGLEV_END: + return; + } + if ([formatedString containsString:@"\n"]) { + NSArray *myWords = [[formatedString stringByReplacingOccurrencesOfString:@"\r\n" withString:@"\n"] + componentsSeparatedByString:@"\n"]; + for (int i = 0; i < myWords.count; i++) { + NSString *tab = i > 0 ? @"\t" : @""; + if (((NSString *)myWords[i]).length > 0) { + NSLog(@"[%@] %@%@", lvl, tab, (NSString *)myWords[i]); } - } else { - os_log_with_type(log, type, "%{public}s/%{public}s", domain, - [formatedString stringByReplacingOccurrencesOfString:@"\r\n" withString:@"\n"].UTF8String); } } else { - int lvl = ASL_LEVEL_NOTICE; - switch (lev) { - case ORTP_FATAL: - lvl = ASL_LEVEL_CRIT; - break; - case ORTP_ERROR: - lvl = ASL_LEVEL_ERR; - break; - case ORTP_WARNING: - lvl = ASL_LEVEL_WARNING; - break; - case ORTP_MESSAGE: - lvl = ASL_LEVEL_NOTICE; - break; - case ORTP_DEBUG: - case ORTP_TRACE: - lvl = ASL_LEVEL_INFO; - break; - case ORTP_LOGLEV_END: - return; - } - asl_log(NULL, NULL, lvl, "%*.*s/%s", DOMAIN_SIZE, DOMAIN_SIZE, domain, - [formatedString stringByReplacingOccurrencesOfString:@"\r\n" withString:@"\n"].UTF8String); + NSLog(@"[%@] %@", lvl, [formatedString stringByReplacingOccurrencesOfString:@"\r\n" withString:@"\n"]); } } From 29068d9402f7e11096f3c6ea9c1f4c55f71c44e5 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Thu, 13 Apr 2017 15:49:17 +0200 Subject: [PATCH 07/13] Fix crash when cancelling the call too soon --- Classes/LinphoneManager.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 6acfc3cdc..8a497898c 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -861,7 +861,8 @@ static void linphone_iphone_display_status(struct _LinphoneCore *lc, const char LinphoneManager.instance.connectivity = none; } LinphoneCallLog *callLog2 = linphone_call_get_call_log(call); - NSString *callId2 = [NSString stringWithUTF8String:linphone_call_log_get_call_id(callLog2)]; + const char *call_id2 = linphone_call_log_get_call_id(callLog2); + NSString *callId2 = call_id2 ? [NSString stringWithUTF8String:call_id2] : @""; NSUUID *uuid = (NSUUID *)[self.providerDelegate.uuids objectForKey:callId2]; if (uuid) { // For security reasons do not display name @@ -2667,6 +2668,7 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) { self.providerDelegate.callKitCalls++; NSUUID *uuid = [NSUUID UUID]; [LinphoneManager.instance.providerDelegate.uuids setObject:uuid forKey:@""]; + [LinphoneManager.instance.providerDelegate.calls setObject:@"" forKey:uuid]; LinphoneManager.instance.providerDelegate.pendingAddr = linphone_address_clone(iaddr); NSString *address = [FastAddressBook displayNameForAddress:iaddr]; CXHandle *handle = [[CXHandle alloc] initWithType:CXHandleTypeGeneric value:address]; From 47cf9350c86863e6d1b63c948320b2e95cdeed03 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Fri, 14 Apr 2017 11:48:36 +0200 Subject: [PATCH 08/13] Do not display video pop up when asking call is within a conference --- Classes/CallView.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Classes/CallView.m b/Classes/CallView.m index 94744a9e9..c922897a1 100644 --- a/Classes/CallView.m +++ b/Classes/CallView.m @@ -596,6 +596,9 @@ static void hideSpinner(LinphoneCall *call, void *user_data) { #pragma mark - ActionSheet Functions - (void)displayAskToEnableVideoCall:(LinphoneCall *)call { + if (linphone_call_params_get_local_conference_mode(linphone_call_get_current_params(call))) { + return; + } if (linphone_core_get_video_policy(LC)->automatically_accept && !([UIApplication sharedApplication].applicationState == UIApplicationStateBackground)) return; From 613ed78cb017adc4dc8b8e3b0449d1ab42729abf Mon Sep 17 00:00:00 2001 From: Brieuc Viel Date: Fri, 14 Apr 2017 12:05:25 +0200 Subject: [PATCH 09/13] [chat] fix scroolToLastUnread message not take error and not delivered into account anymore --- Classes/ChatConversationTableView.m | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Classes/ChatConversationTableView.m b/Classes/ChatConversationTableView.m index ba958810d..c13f906e9 100644 --- a/Classes/ChatConversationTableView.m +++ b/Classes/ChatConversationTableView.m @@ -113,15 +113,18 @@ if (messageList == nil || _chatRoom == nil) { return; } - int index = -1; size_t count = bctbx_list_size(messageList); // Find first unread & set all entry read for (int i = 0; i < count; ++i) { int read = linphone_chat_message_is_read(bctbx_list_nth_data(messageList, i)); - if (read == 0) { - if (index == -1) + LinphoneChatMessageState state = linphone_chat_message_get_state(bctbx_list_nth_data(messageList, i)); + if (read == 0 && + !(state == LinphoneChatMessageStateFileTransferError || state == LinphoneChatMessageStateNotDelivered)) { + if (index == -1) { index = i; + break; + } } } if (index == -1 && count > 0) { From 9edbaeb98986a1d426e6002bb8405627767006fc Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Fri, 14 Apr 2017 15:06:07 +0200 Subject: [PATCH 10/13] update linphone --- submodules/linphone | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/linphone b/submodules/linphone index 332351d29..0a79d79d0 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 332351d294fd94acf78e947bae91bd7d7d143132 +Subproject commit 0a79d79d0f6c93d0d502e58732e367e59c7c745d From e6dd123ba521b2557764ec92994757a5c688c56a Mon Sep 17 00:00:00 2001 From: Brieuc Viel Date: Fri, 14 Apr 2017 15:55:08 +0200 Subject: [PATCH 11/13] [chat] fix scroolToLastUnread message not take error and not delivered into account anymore --- Classes/ChatConversationView.m | 1 + linphone-Info.plist | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Classes/ChatConversationView.m b/Classes/ChatConversationView.m index 58afb88d9..953a1aaa2 100644 --- a/Classes/ChatConversationView.m +++ b/Classes/ChatConversationView.m @@ -364,6 +364,7 @@ static UICompositeViewDescription *compositeDescription = nil; } [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneMessageReceived object:self]; [_tableController addChatEntry:chat]; + [self setComposingVisible:FALSE withDelay:0]; [_tableController scrollToLastUnread:TRUE]; } } diff --git a/linphone-Info.plist b/linphone-Info.plist index 8ee2cf81e..2b7d2b222 100644 --- a/linphone-Info.plist +++ b/linphone-Info.plist @@ -53,7 +53,7 @@ CFBundleVersion - 2 + 3 ITSAppUsesNonExemptEncryption ITSEncryptionExportComplianceCode From e3660e8b456cc186b9e0ab084ee79c133f87530f Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Tue, 18 Apr 2017 15:42:09 +0200 Subject: [PATCH 12/13] add deliver_imdn to rc-factory --- Classes/LinphoneAppDelegate.m | 21 ++++++++++++--------- Classes/LinphoneManager.m | 4 ++++ Resources/linphonerc-factory | 1 + 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index fc3cb4c7e..c64e089ad 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -469,15 +469,7 @@ } } - if (callId) { - int index = -1; - NSDictionary *dict = LinphoneManager.instance.pushDict; - if ([[dict allKeys] containsObject:callId]) { - index = [(NSNumber *)[LinphoneManager.instance.pushDict objectForKey:callId] intValue] + 1; - } else { - index = 1; - } - [LinphoneManager.instance.pushDict setValue:[NSNumber numberWithInt:index] forKey:callId]; + if (callId && [self addLongTaskIDforCallID:callId]) { if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground && loc_key && index > 0) { if ([loc_key isEqualToString:@"IC_MSG"]) { @@ -492,6 +484,17 @@ LOGI(@"Notification %@ processed", userInfo.description); } +- (BOOL)addLongTaskIDforCallID:(NSString *)callId { + NSDictionary *dict = LinphoneManager.instance.pushDict; + if ([[dict allKeys] indexOfObject:callId] != NSNotFound) { + return FALSE; + } + + LOGI(@"Adding long running task for call id : %@ with index : 1", callId); + [dict setValue:[NSNumber numberWithInt:1] forKey:callId]; + return TRUE; +} + - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { LOGI(@"%@ : %@", NSStringFromSelector(_cmd), userInfo); diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 8a497898c..751b994d9 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -668,6 +668,7 @@ static void linphone_iphone_display_status(struct _LinphoneCore *lc, const char LinphoneCallLog *callLog = linphone_call_get_call_log(call); NSString *callId = [NSString stringWithUTF8String:linphone_call_log_get_call_id(callLog)]; int index = [(NSNumber *)[_pushDict objectForKey:callId] intValue] - 1; + LOGI(@"Decrementing index of long running task for call id : %@ with index : %d", callId, index); [_pushDict setValue:[NSNumber numberWithInt:index] forKey:callId]; BOOL need_bg_task = FALSE; for (NSString *key in [_pushDict allKeys]) { @@ -1190,6 +1191,7 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, const char NSString *remote_uri = [NSString stringWithUTF8String:c_address]; ms_free(c_address); int index = [(NSNumber *)[_pushDict objectForKey:callID] intValue] - 1; + LOGI(@"Decrementing index of long running task for call id : %@ with index : %d", callID, index); [_pushDict setValue:[NSNumber numberWithInt:index] forKey:callID]; BOOL need_bg_task = FALSE; for (NSString *key in [_pushDict allKeys]) { @@ -1352,7 +1354,9 @@ static void linphone_iphone_message_received_unable_decrypt(LinphoneCore *lc, Li LinphoneChatMessage *message) { NSString *msgId = [NSString stringWithUTF8String:linphone_chat_message_get_custom_header(message, "Call-ID")]; + int index = [(NSNumber *)[LinphoneManager.instance.pushDict objectForKey:msgId] intValue] - 1; + LOGI(@"Decrementing index of long running task for call id : %@ with index : %d", msgId, index); [LinphoneManager.instance.pushDict setValue:[NSNumber numberWithInt:index] forKey:msgId]; BOOL need_bg_task = FALSE; for (NSString *key in [LinphoneManager.instance.pushDict allKeys]) { diff --git a/Resources/linphonerc-factory b/Resources/linphonerc-factory index d19b01d10..ff3807dcd 100644 --- a/Resources/linphonerc-factory +++ b/Resources/linphonerc-factory @@ -25,6 +25,7 @@ username_length=-1 sip_random_port=0 #whether SIP passwords must be encrypted in configuration storage file store_ha1_passwd=0 +deliver_imdn=1 [misc] #by default it is set to 30 by liblinphone From f3ce7ada2d00ca72776e8f7d7a60b4a796cef1a6 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Wed, 19 Apr 2017 16:04:59 +0200 Subject: [PATCH 13/13] Better management of app states --- Classes/CallView.m | 6 +- Classes/ChatConversationTableView.m | 3 +- Classes/ChatConversationView.m | 3 +- Classes/InAppProductsManager.m | 2 +- Classes/LinphoneAppDelegate.m | 82 +-------- Classes/LinphoneManager.m | 206 +++++++++++----------- Classes/LinphoneUI/StatusBarView.m | 2 +- Classes/LinphoneUI/UIChatBubbleTextCell.m | 3 +- Classes/PhoneMainView.m | 6 +- Classes/ProviderDelegate.m | 14 +- 10 files changed, 126 insertions(+), 201 deletions(-) diff --git a/Classes/CallView.m b/Classes/CallView.m index c922897a1..bfb54521f 100644 --- a/Classes/CallView.m +++ b/Classes/CallView.m @@ -567,7 +567,7 @@ static void hideSpinner(LinphoneCall *call, void *user_data) { if ((linphone_core_video_display_enabled(LC) && !linphone_call_params_video_enabled(current) && linphone_call_params_video_enabled(remote)) && (!linphone_core_get_video_policy(LC)->automatically_accept || - (([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) && + (([UIApplication sharedApplication].applicationState != UIApplicationStateActive) && floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_9_x_Max))) { linphone_core_defer_call_update(LC, call); [self displayAskToEnableVideoCall:call]; @@ -600,12 +600,12 @@ static void hideSpinner(LinphoneCall *call, void *user_data) { return; } if (linphone_core_get_video_policy(LC)->automatically_accept && - !([UIApplication sharedApplication].applicationState == UIApplicationStateBackground)) + !([UIApplication sharedApplication].applicationState != UIApplicationStateActive)) return; NSString *username = [FastAddressBook displayNameForAddress:linphone_call_get_remote_address(call)]; NSString *title = [NSString stringWithFormat:NSLocalizedString(@"%@ would like to enable video", nil), username]; - if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground && + if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive && floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_9_x_Max) { UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init]; content.title = NSLocalizedString(@"Video request", nil); diff --git a/Classes/ChatConversationTableView.m b/Classes/ChatConversationTableView.m index c13f906e9..6e5747caf 100644 --- a/Classes/ChatConversationTableView.m +++ b/Classes/ChatConversationTableView.m @@ -130,8 +130,7 @@ if (index == -1 && count > 0) { index = (int)count - 1; } - if (!([UIApplication sharedApplication].applicationState == UIApplicationStateBackground || - [UIApplication sharedApplication].applicationState == UIApplicationStateInactive)) { + if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) { linphone_chat_room_mark_as_read(_chatRoom); } TabBarView *tab = (TabBarView *)[PhoneMainView.instance.mainViewController diff --git a/Classes/ChatConversationView.m b/Classes/ChatConversationView.m index 953a1aaa2..41a404042 100644 --- a/Classes/ChatConversationView.m +++ b/Classes/ChatConversationView.m @@ -358,8 +358,7 @@ static UICompositeViewDescription *compositeDescription = nil; if (fromStr && cr_from_string) { if (strcasecmp(cr_from_string, fromStr) == 0) { - if (!([UIApplication sharedApplication].applicationState == UIApplicationStateBackground || - [UIApplication sharedApplication].applicationState == UIApplicationStateInactive)) { + if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) { linphone_chat_room_mark_as_read(room); } [NSNotificationCenter.defaultCenter postNotificationName:kLinphoneMessageReceived object:self]; diff --git a/Classes/InAppProductsManager.m b/Classes/InAppProductsManager.m index 412afbdb3..d367464b3 100644 --- a/Classes/InAppProductsManager.m +++ b/Classes/InAppProductsManager.m @@ -404,7 +404,7 @@ expireText = [NSString stringWithFormat:NSLocalizedString(@"Your account has expired.", nil), days]; } - if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground){ + if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive) { UILocalNotification *notification = [[UILocalNotification alloc] init]; if (notification) { diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index c64e089ad..03265eebc 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -306,7 +306,7 @@ [LinphoneManager.instance setProviderDelegate:self.del]; } - if (state == UIApplicationStateBackground) { + if (state != UIApplicationStateActive) { // we've been woken up directly to background; if (!start_at_boot || !background_mode) { // autoboot disabled or no background, and no push: do nothing and wait for a real launch @@ -470,7 +470,7 @@ } if (callId && [self addLongTaskIDforCallID:callId]) { - if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground && loc_key && + if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive && loc_key && index > 0) { if ([loc_key isEqualToString:@"IC_MSG"]) { [LinphoneManager.instance startPushLongRunningTask:FALSE]; @@ -515,78 +515,6 @@ return NULL; } -/* -- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { - LOGI(@"%@ - state = %ld", NSStringFromSelector(_cmd), (long)application.applicationState); - - if ([notification.category isEqual:LinphoneManager.instance.iapManager.notificationCategory]){ - [PhoneMainView.instance changeCurrentView:ShopView.compositeViewDescription]; - return; - } - - [self fixRing]; - - if ([notification.userInfo objectForKey:@"callId"] != nil) { - BOOL bypass_incoming_view = TRUE; - // some local notifications have an internal timer to relaunch themselves at specified intervals - if ([[notification.userInfo objectForKey:@"timer"] intValue] == 1) { - [LinphoneManager.instance cancelLocalNotifTimerForCallId:[notification.userInfo objectForKey:@"callId"]]; - bypass_incoming_view = [LinphoneManager.instance lpConfigBoolForKey:@"autoanswer_notif_preference"]; - } - if (bypass_incoming_view) { - [LinphoneManager.instance acceptCallForCallId:[notification.userInfo objectForKey:@"callId"]]; - } - } else if ([notification.userInfo objectForKey:@"from_addr"] != nil) { - NSString *chat = notification.alertBody; - NSString *remote_uri = (NSString *)[notification.userInfo objectForKey:@"from_addr"]; - NSString *from = (NSString *)[notification.userInfo objectForKey:@"from"]; - NSString *callID = (NSString *)[notification.userInfo objectForKey:@"call-id"]; - LinphoneChatRoom *room = [self findChatRoomForContact:remote_uri]; - if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground || - ((PhoneMainView.instance.currentView != ChatsListView.compositeViewDescription) && - ((PhoneMainView.instance.currentView != ChatConversationView.compositeViewDescription))) || - (PhoneMainView.instance.currentView == ChatConversationView.compositeViewDescription && - room != PhoneMainView.instance.currentRoom)) { - // Create a new notification - - if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) { - // Do nothing - } else { - UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init]; - content.title = NSLocalizedString(@"Message received", nil); - if ([LinphoneManager.instance lpConfigBoolForKey:@"show_msg_in_notif" withDefault:YES]) { - content.subtitle = from; - content.body = chat; - } else { - content.body = from; - } - content.sound = [UNNotificationSound soundNamed:@"msg.caf"]; - content.categoryIdentifier = @"msg_cat"; - content.userInfo = @{ @"from" : from, @"from_addr" : remote_uri, @"call-id" : callID }; - content.accessibilityLabel = @"Message notif"; - UNNotificationRequest *req = - [UNNotificationRequest requestWithIdentifier:@"call_request" content:content trigger:NULL]; - req.accessibilityLabel = @"Message notif"; - [[UNUserNotificationCenter currentNotificationCenter] - addNotificationRequest:req - withCompletionHandler:^(NSError *_Nullable error) { - // Enable or disable features based on authorization. - if (error) { - LOGD(@"Error while adding notification request :"); - LOGD(error.description); - } - }]; - } - } - } else if ([notification.userInfo objectForKey:@"callLog"] != nil) { - NSString *callLog = (NSString *)[notification.userInfo objectForKey:@"callLog"]; - HistoryDetailsView *view = VIEW(HistoryDetailsView); - [view setCallLogId:callLog]; - [PhoneMainView.instance changeCurrentView:view.compositeViewDescription]; - } -} -*/ - #pragma mark - PushNotification Functions - (void)application:(UIApplication *)application @@ -903,8 +831,7 @@ didReceiveNotificationResponse:(UNNotificationResponse *)response NSString *from = [notification.userInfo objectForKey:@"from_addr"]; LinphoneChatRoom *room = linphone_core_get_chat_room_from_uri(LC, [from UTF8String]); if (room) { - if (!([UIApplication sharedApplication].applicationState == UIApplicationStateBackground || - [UIApplication sharedApplication].applicationState == UIApplicationStateInactive)) + if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) linphone_chat_room_mark_as_read(room); TabBarView *tab = (TabBarView *)[PhoneMainView.instance.mainViewController getCachedController:NSStringFromClass(TabBarView.class)]; @@ -954,8 +881,7 @@ didReceiveNotificationResponse:(UNNotificationResponse *)response if (linphone_core_lime_enabled(LC) == LinphoneLimeMandatory && !linphone_chat_room_lime_available(room)) { [LinphoneManager.instance alertLIME:room]; } - if (!([UIApplication sharedApplication].applicationState == UIApplicationStateBackground || - [UIApplication sharedApplication].applicationState == UIApplicationStateInactive)) { + if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) { linphone_chat_room_mark_as_read(room); } [PhoneMainView.instance updateApplicationBadgeNumber]; diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 751b994d9..0f577597b 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -625,7 +625,7 @@ static void linphone_iphone_display_status(struct _LinphoneCore *lc, const char - (void)userNotifContinue:(NSTimer *)timer { UNNotificationContent *content = [timer userInfo]; - if (content && [UIApplication sharedApplication].applicationState == UIApplicationStateBackground) { + if (content && [UIApplication sharedApplication].applicationState != UIApplicationStateActive) { LOGI(@"cancelling/presenting user notif"); UNNotificationRequest *req = [UNNotificationRequest requestWithIdentifier:@"call_request" content:content trigger:NULL]; @@ -663,8 +663,6 @@ static void linphone_iphone_display_status(struct _LinphoneCore *lc, const char NSString *address = [FastAddressBook displayNameForAddress:addr]; if (state == LinphoneCallIncomingReceived) { - // TESTING !! - // linphone_call_accept_early_media(call); LinphoneCallLog *callLog = linphone_call_get_call_log(call); NSString *callId = [NSString stringWithUTF8String:linphone_call_log_get_call_id(callLog)]; int index = [(NSNumber *)[_pushDict objectForKey:callId] intValue] - 1; @@ -698,116 +696,118 @@ static void linphone_iphone_display_status(struct _LinphoneCore *lc, const char return; } - if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_9_x_Max && call && - (linphone_core_get_calls_nb(LC) < 2)) { + if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_9_x_Max) { + if (call && (linphone_core_get_calls_nb(LC) < 2)) { #if !TARGET_IPHONE_SIMULATOR - NSString *callId = - [NSString stringWithUTF8String:linphone_call_log_get_call_id(linphone_call_get_call_log(call))]; + NSString *callId = + [NSString stringWithUTF8String:linphone_call_log_get_call_id(linphone_call_get_call_log(call))]; - NSUUID *uuid = [NSUUID UUID]; - [LinphoneManager.instance.providerDelegate.calls setObject:callId forKey:uuid]; - [LinphoneManager.instance.providerDelegate.uuids setObject:uuid forKey:callId]; - BOOL video = FALSE; - video = (([UIApplication sharedApplication].applicationState != UIApplicationStateBackground) && - linphone_core_get_video_policy(LC)->automatically_accept && - linphone_call_params_video_enabled(linphone_call_get_remote_params(call))); - [LinphoneManager.instance.providerDelegate reportIncomingCallwithUUID:uuid handle:address video:video]; + NSUUID *uuid = [NSUUID UUID]; + [LinphoneManager.instance.providerDelegate.calls setObject:callId forKey:uuid]; + [LinphoneManager.instance.providerDelegate.uuids setObject:uuid forKey:callId]; + BOOL video = FALSE; + video = ([UIApplication sharedApplication].applicationState == UIApplicationStateActive && + linphone_core_get_video_policy(LC)->automatically_accept && + linphone_call_params_video_enabled(linphone_call_get_remote_params(call))); + [LinphoneManager.instance.providerDelegate reportIncomingCallwithUUID:uuid handle:address video:video]; #else - [PhoneMainView.instance displayIncomingCall:call]; + [PhoneMainView.instance displayIncomingCall:call]; #endif - } else if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) { - // Create a UNNotification - UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init]; - content.title = NSLocalizedString(@"Incoming call", nil); - content.body = address; - content.sound = [UNNotificationSound soundNamed:@"notes_of_the_optimistic.caf"]; - content.categoryIdentifier = @"call_cat"; - content.userInfo = @{ @"CallId" : callId }; - UNNotificationRequest *req = - [UNNotificationRequest requestWithIdentifier:@"call_request" content:content trigger:NULL]; - [[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:req - withCompletionHandler:^(NSError *err){ - }]; - } + } else if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive) { + // Create a UNNotification + UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init]; + content.title = NSLocalizedString(@"Incoming call", nil); + content.body = address; + content.sound = [UNNotificationSound soundNamed:@"notes_of_the_optimistic.caf"]; + content.categoryIdentifier = @"call_cat"; + content.userInfo = @{ @"CallId" : callId }; + UNNotificationRequest *req = + [UNNotificationRequest requestWithIdentifier:@"call_request" content:content trigger:NULL]; + [[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:req + withCompletionHandler:^(NSError *err){ + }]; + } + } else { + if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive) { + // if (![LinphoneManager.instance popPushCallID:callId]) { + // case where a remote notification is not already received + // Create a new local notification + if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) { + UIMutableUserNotificationAction *answer = [[UIMutableUserNotificationAction alloc] init]; + answer.identifier = @"answer"; + answer.title = NSLocalizedString(@"Answer", nil); + answer.activationMode = UIUserNotificationActivationModeForeground; + answer.destructive = NO; + answer.authenticationRequired = YES; - if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) { - // if (![LinphoneManager.instance popPushCallID:callId]) { - // case where a remote notification is not already received - // Create a new local notification - if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) { - UIMutableUserNotificationAction *answer = [[UIMutableUserNotificationAction alloc] init]; - answer.identifier = @"answer"; - answer.title = NSLocalizedString(@"Answer", nil); - answer.activationMode = UIUserNotificationActivationModeForeground; - answer.destructive = NO; - answer.authenticationRequired = YES; + UIMutableUserNotificationAction *decline = [[UIMutableUserNotificationAction alloc] init]; + decline.identifier = @"decline"; + decline.title = NSLocalizedString(@"Decline", nil); + decline.activationMode = UIUserNotificationActivationModeBackground; + decline.destructive = YES; + decline.authenticationRequired = NO; - UIMutableUserNotificationAction *decline = [[UIMutableUserNotificationAction alloc] init]; - decline.identifier = @"decline"; - decline.title = NSLocalizedString(@"Decline", nil); - decline.activationMode = UIUserNotificationActivationModeBackground; - decline.destructive = YES; - decline.authenticationRequired = NO; + NSArray *callactions = @[ decline, answer ]; - NSArray *callactions = @[ decline, answer ]; + UIMutableUserNotificationCategory *callcat = [[UIMutableUserNotificationCategory alloc] init]; + callcat.identifier = @"incoming_call"; + [callcat setActions:callactions forContext:UIUserNotificationActionContextDefault]; + [callcat setActions:callactions forContext:UIUserNotificationActionContextMinimal]; - UIMutableUserNotificationCategory *callcat = [[UIMutableUserNotificationCategory alloc] init]; - callcat.identifier = @"incoming_call"; - [callcat setActions:callactions forContext:UIUserNotificationActionContextDefault]; - [callcat setActions:callactions forContext:UIUserNotificationActionContextMinimal]; + NSSet *categories = [NSSet setWithObjects:callcat, nil]; - NSSet *categories = [NSSet setWithObjects:callcat, nil]; + UIUserNotificationSettings *set = [UIUserNotificationSettings + settingsForTypes:(UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | + UIUserNotificationTypeSound) + categories:categories]; + [[UIApplication sharedApplication] registerUserNotificationSettings:set]; + data->notification = [[UILocalNotification alloc] init]; + if (data->notification) { + // iOS8 doesn't need the timer trick for the local notification. + data->notification.category = @"incoming_call"; + if ([[UIDevice currentDevice].systemVersion floatValue] >= 8 && + [self lpConfigBoolForKey:@"repeat_call_notification"] == NO) { + NSString *ring = ([LinphoneManager bundleFile:[self lpConfigStringForKey:@"local_ring" + inSection:@"sound"] + .lastPathComponent] + ?: [LinphoneManager bundleFile:@"notes_of_the_optimistic.caf"]) + .lastPathComponent; + data->notification.soundName = ring; + } else { + data->notification.soundName = @"shortring.caf"; + data->timer = [NSTimer scheduledTimerWithTimeInterval:5 + target:self + selector:@selector(localNotifContinue:) + userInfo:data->notification + repeats:TRUE]; + } - UIUserNotificationSettings *set = [UIUserNotificationSettings - settingsForTypes:(UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | - UIUserNotificationTypeSound) - categories:categories]; - [[UIApplication sharedApplication] registerUserNotificationSettings:set]; - data->notification = [[UILocalNotification alloc] init]; - if (data->notification) { - // iOS8 doesn't need the timer trick for the local notification. - data->notification.category = @"incoming_call"; - if ([[UIDevice currentDevice].systemVersion floatValue] >= 8 && - [self lpConfigBoolForKey:@"repeat_call_notification"] == NO) { - NSString *ring = - ([LinphoneManager bundleFile:[self lpConfigStringForKey:@"local_ring" inSection:@"sound"].lastPathComponent] - ?: [LinphoneManager bundleFile:@"notes_of_the_optimistic.caf"]) - .lastPathComponent; - data->notification.soundName = ring; - } else { - data->notification.soundName = @"shortring.caf"; - data->timer = [NSTimer scheduledTimerWithTimeInterval:5 - target:self - selector:@selector(localNotifContinue:) - userInfo:data->notification - repeats:TRUE]; - } + data->notification.repeatInterval = 0; - data->notification.repeatInterval = 0; + data->notification.alertBody = + [NSString stringWithFormat:NSLocalizedString(@"IC_MSG", nil), address]; + // data->notification.alertAction = NSLocalizedString(@"Answer", nil); + data->notification.userInfo = @{ @"callId" : callId, @"timer" : [NSNumber numberWithInt:1] }; + data->notification.applicationIconBadgeNumber = 1; + UIApplication *app = [UIApplication sharedApplication]; + LOGI([app currentUserNotificationSettings].description); + [app presentLocalNotificationNow:data->notification]; - data->notification.alertBody = - [NSString stringWithFormat:NSLocalizedString(@"IC_MSG", nil), address]; - //data->notification.alertAction = NSLocalizedString(@"Answer", nil); - data->notification.userInfo = @{ @"callId" : callId, @"timer" : [NSNumber numberWithInt:1] }; - data->notification.applicationIconBadgeNumber = 1; - UIApplication *app = [UIApplication sharedApplication]; - LOGI([app currentUserNotificationSettings].description); - [app presentLocalNotificationNow:data->notification]; + if (!incallBgTask) { + incallBgTask = + [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ + LOGW(@"Call cannot ring any more, too late"); + [[UIApplication sharedApplication] endBackgroundTask:incallBgTask]; + incallBgTask = 0; + }]; - if (!incallBgTask) { - incallBgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ - LOGW(@"Call cannot ring any more, too late"); - [[UIApplication sharedApplication] endBackgroundTask:incallBgTask]; - incallBgTask = 0; - }]; - - if (data->timer) { - [[NSRunLoop currentRunLoop] addTimer:data->timer forMode:NSRunLoopCommonModes]; + if (data->timer) { + [[NSRunLoop currentRunLoop] addTimer:data->timer forMode:NSRunLoopCommonModes]; + } } } } - } - + } } } @@ -835,7 +835,7 @@ static void linphone_iphone_display_status(struct _LinphoneCore *lc, const char } if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_9_x_Max) { - if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) { + if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive) { if (data->timer) { [data->timer invalidate]; data->timer = nil; @@ -1122,7 +1122,7 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, const char // dont pop up if we are in background, in any case we will refresh registers when entering // the application again - if ([[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground) { + if ([[UIApplication sharedApplication] applicationState] != UIApplicationStateActive) { return; } @@ -1208,7 +1208,7 @@ static void linphone_iphone_popup_password_request(LinphoneCore *lc, const char } if (linphone_chat_message_is_file_transfer(msg) || linphone_chat_message_is_text(msg)) { - if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground || + if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive || ((PhoneMainView.instance.currentView != ChatsListView.compositeViewDescription) && ((PhoneMainView.instance.currentView != ChatConversationView.compositeViewDescription))) || (PhoneMainView.instance.currentView == ChatConversationView.compositeViewDescription && @@ -1382,7 +1382,7 @@ static void linphone_iphone_message_received_unable_decrypt(LinphoneCore *lc, Li strAddr]; NSString *action = NSLocalizedString(@"Call", nil); - if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) { + if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive) { if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_9_x_Max) { UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init]; content.title = title; @@ -1501,7 +1501,7 @@ static void linphone_iphone_call_encryption_changed(LinphoneCore *lc, LinphoneCa @"Please call this contact and verify his ZRTP key before sending your messages.", nil); - if ([UIApplication sharedApplication].applicationState != UIApplicationStateBackground) { + if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) { UIAlertController *errView = [UIAlertController alertControllerWithTitle:title message:body preferredStyle:UIAlertControllerStyleAlert]; @@ -2249,7 +2249,7 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) { [[UIApplication sharedApplication] endBackgroundTask:pushBgTask]; pushBgTask = 0; pushBgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ - if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) { + if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive) { if (msg) { LOGW(@"Incomming message couldn't be received"); UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init]; diff --git a/Classes/LinphoneUI/StatusBarView.m b/Classes/LinphoneUI/StatusBarView.m index 43db8ee5e..797e6d116 100644 --- a/Classes/LinphoneUI/StatusBarView.m +++ b/Classes/LinphoneUI/StatusBarView.m @@ -335,7 +335,7 @@ nil), myCode, correspondantCode]; - if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground && + if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive && floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_9_x_Max) { UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init]; content.title = NSLocalizedString(@"ZRTP verification", nil); diff --git a/Classes/LinphoneUI/UIChatBubbleTextCell.m b/Classes/LinphoneUI/UIChatBubbleTextCell.m index 326441ad7..703e4c6ed 100644 --- a/Classes/LinphoneUI/UIChatBubbleTextCell.m +++ b/Classes/LinphoneUI/UIChatBubbleTextCell.m @@ -150,8 +150,7 @@ [_messageText setAccessibilityLabel:@"Outgoing message"]; } else { [_messageText setAccessibilityLabel:@"Incoming message"]; - if (!([UIApplication sharedApplication].applicationState == UIApplicationStateBackground || - [UIApplication sharedApplication].applicationState == UIApplicationStateInactive)) { + if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) { VIEW(ChatConversationView).markAsRead; } } diff --git a/Classes/PhoneMainView.m b/Classes/PhoneMainView.m index aa873f26a..e4340da5d 100644 --- a/Classes/PhoneMainView.m +++ b/Classes/PhoneMainView.m @@ -274,7 +274,7 @@ static RootViewManager *rootViewManagerInstance = nil; linphone_chat_room_get_peer_address(view.chatRoom))) return; - if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) + if ([UIApplication sharedApplication].applicationState != UIApplicationStateActive) return; LinphoneManager *lm = LinphoneManager.instance; @@ -287,7 +287,7 @@ static RootViewManager *rootViewManagerInstance = nil; - (void)registrationUpdate:(NSNotification *)notif { LinphoneRegistrationState state = [[notif.userInfo objectForKey:@"state"] intValue]; if (state == LinphoneRegistrationFailed && ![currentView equal:AssistantView.compositeViewDescription] && - [UIApplication sharedApplication].applicationState != UIApplicationStateBackground) { + [UIApplication sharedApplication].applicationState == UIApplicationStateActive) { UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Registration failure", nil) message:[notif.userInfo objectForKey:@"message"] preferredStyle:UIAlertControllerStyleAlert]; @@ -732,7 +732,7 @@ static RootViewManager *rootViewManagerInstance = nil; LinphoneCallLog *callLog = linphone_call_get_call_log(call); NSString *callId = [NSString stringWithUTF8String:linphone_call_log_get_call_id(callLog)]; - if ([UIApplication sharedApplication].applicationState != UIApplicationStateBackground) { + if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) { LinphoneManager *lm = LinphoneManager.instance; BOOL callIDFromPush = [lm popPushCallID:callId]; BOOL autoAnswer = [lm lpConfigBoolForKey:@"autoanswer_notif_preference"]; diff --git a/Classes/ProviderDelegate.m b/Classes/ProviderDelegate.m index e7936cd3e..83811eecb 100644 --- a/Classes/ProviderDelegate.m +++ b/Classes/ProviderDelegate.m @@ -88,7 +88,7 @@ NSString *callID = [self.calls objectForKey:uuid]; // first, make sure this callid is not already involved in a call LinphoneCall *call = [LinphoneManager.instance callByCallId:callID]; if (call != NULL) { - BOOL video = (!([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) && + BOOL video = ([UIApplication sharedApplication].applicationState == UIApplicationStateActive && linphone_core_get_video_policy(LC)->automatically_accept && linphone_call_params_video_enabled(linphone_call_get_remote_params((LinphoneCall *)call))); self.pendingCall = call; @@ -129,12 +129,14 @@ } else { NSUUID *uuid = action.callUUID; NSString *callID = [self.calls objectForKey:uuid]; - LinphoneCall *call = [LinphoneManager.instance callByCallId:callID]; - if (call) { - linphone_call_terminate((LinphoneCall *)call); + if (callID) { + LinphoneCall *call = [LinphoneManager.instance callByCallId:callID]; + if (call) { + linphone_call_terminate((LinphoneCall *)call); + } + [self.uuids removeObjectForKey:callID]; + [self.calls removeObjectForKey:uuid]; } - [self.uuids removeObjectForKey:callID]; - [self.calls removeObjectForKey:uuid]; } }