forked from mirrors/linphone-iphone
use auto iteration
This commit is contained in:
parent
aee1b05517
commit
eee2ae66f3
6 changed files with 8 additions and 81 deletions
|
|
@ -112,6 +112,12 @@ import AVFoundation
|
|||
return nil
|
||||
}
|
||||
|
||||
@objc func stopLinphoneCore() {
|
||||
if (lc?.callsNb == 0) {
|
||||
lc?.stopAsync()
|
||||
}
|
||||
}
|
||||
|
||||
@objc static func callKitEnabled() -> Bool {
|
||||
#if !targetEnvironment(simulator)
|
||||
if ConfigManager.instance().lpConfigBoolForKey(key: "use_callkit", section: "app") {
|
||||
|
|
|
|||
|
|
@ -1,66 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2010-2020 Belledonne Communications SARL.
|
||||
*
|
||||
* This file is part of linphone-iphone
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
import linphonesw
|
||||
|
||||
@objc class CoreManager: NSObject {
|
||||
static var theCoreManager: CoreManager?
|
||||
var lc: Core?
|
||||
private var mIterateTimer: Timer?
|
||||
|
||||
@objc static func instance() -> CoreManager {
|
||||
if (theCoreManager == nil) {
|
||||
theCoreManager = CoreManager()
|
||||
}
|
||||
return theCoreManager!
|
||||
}
|
||||
|
||||
@objc func setCore(core: OpaquePointer) {
|
||||
lc = Core.getSwiftObject(cObject: core)
|
||||
}
|
||||
|
||||
@objc private func iterate() {
|
||||
lc?.iterate()
|
||||
}
|
||||
|
||||
@objc func startIterateTimer() {
|
||||
if (mIterateTimer?.isValid ?? false) {
|
||||
Log.directLog(BCTBX_LOG_DEBUG, text: "Iterate timer is already started, skipping ...")
|
||||
return
|
||||
}
|
||||
mIterateTimer = Timer.scheduledTimer(timeInterval: 0.02, target: self, selector: #selector(self.iterate), userInfo: nil, repeats: true)
|
||||
Log.directLog(BCTBX_LOG_DEBUG, text: "start iterate timer")
|
||||
|
||||
}
|
||||
|
||||
@objc func stopIterateTimer() {
|
||||
if let timer = mIterateTimer {
|
||||
Log.directLog(BCTBX_LOG_DEBUG, text: "stop iterate timer")
|
||||
timer.invalidate()
|
||||
}
|
||||
}
|
||||
|
||||
@objc func stopLinphoneCore() {
|
||||
if (lc?.callsNb == 0) {
|
||||
//stop iterate when core is off
|
||||
lc?.stopAsync()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -74,7 +74,7 @@
|
|||
// To avoid crash
|
||||
[PhoneMainView.instance changeCurrentView:DialerView.compositeViewDescription];
|
||||
}
|
||||
[CoreManager.instance stopLinphoneCore];
|
||||
[CallManager.instance stopLinphoneCore];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -586,10 +586,6 @@ static void linphone_iphone_global_state_changed(LinphoneCore *lc, LinphoneGloba
|
|||
NSDictionary *dict = [NSDictionary
|
||||
dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:state], @"state",
|
||||
[NSString stringWithUTF8String:message ? message : ""], @"message", nil];
|
||||
|
||||
if (theLinphoneCore && linphone_core_get_global_state(theLinphoneCore) == LinphoneGlobalOff) {
|
||||
[CoreManager.instance stopIterateTimer];
|
||||
}
|
||||
// dispatch the notification asynchronously
|
||||
dispatch_async(dispatch_get_main_queue(), ^(void) {
|
||||
if (theLinphoneCore && linphone_core_get_global_state(theLinphoneCore) != LinphoneGlobalOff)
|
||||
|
|
@ -1273,7 +1269,6 @@ void popup_link_account_cb(LinphoneAccountCreator *creator, LinphoneAccountCreat
|
|||
|
||||
- (void)startLinphoneCore {
|
||||
linphone_core_start([LinphoneManager getLc]);
|
||||
[CoreManager.instance startIterateTimer];
|
||||
}
|
||||
|
||||
- (void)createLinphoneCore {
|
||||
|
|
@ -1325,7 +1320,6 @@ void popup_link_account_cb(LinphoneAccountCreator *creator, LinphoneAccountCreat
|
|||
linphone_core_add_callbacks(theLinphoneCore, cbs);
|
||||
|
||||
[CallManager.instance setCoreWithCore:theLinphoneCore];
|
||||
[CoreManager.instance setCoreWithCore:theLinphoneCore];
|
||||
[ConfigManager.instance setDbWithDb:_configDb];
|
||||
|
||||
linphone_core_start(theLinphoneCore);
|
||||
|
|
@ -1368,12 +1362,9 @@ void popup_link_account_cb(LinphoneAccountCreator *creator, LinphoneAccountCreat
|
|||
/*call iterate once immediately in order to initiate background connections with sip server or remote provisioning
|
||||
* grab, if any */
|
||||
[self iterate];
|
||||
// start scheduler
|
||||
[CoreManager.instance startIterateTimer];
|
||||
}
|
||||
|
||||
- (void)destroyLinphoneCore {
|
||||
[CoreManager.instance stopIterateTimer];
|
||||
// just in case
|
||||
[self removeCTCallCenterCb];
|
||||
|
||||
|
|
|
|||
|
|
@ -426,7 +426,7 @@ static RootViewManager *rootViewManagerInstance = nil;
|
|||
if ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[PhoneMainView.instance popToView:DialerView.compositeViewDescription];
|
||||
[CoreManager.instance stopLinphoneCore];
|
||||
[CallManager.instance stopLinphoneCore];
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -764,7 +764,6 @@
|
|||
EA88F3AB241BD05200E66528 /* UserNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8C73477B1D9BA3A00022EE8C /* UserNotifications.framework */; };
|
||||
EA88F3AC241BD05200E66528 /* UserNotificationsUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E58962520DCE5700030868C /* UserNotificationsUI.framework */; };
|
||||
EA88F3AF241BD1F700E66528 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EA8CB82D239F96CA00C330CC /* MainInterface.storyboard */; };
|
||||
EA88F3B1241BDAA100E66528 /* CoreManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA88F3B0241BDAA100E66528 /* CoreManager.swift */; };
|
||||
EA8CB82C239F96CA00C330CC /* NotificationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA8CB82B239F96CA00C330CC /* NotificationViewController.swift */; };
|
||||
EA8CB833239F96CA00C330CC /* msgNotificationContent.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = EA8CB827239F96CA00C330CC /* msgNotificationContent.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
EAE6C88423FABF690076A018 /* Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAE6C88323FABF690076A018 /* Utils.swift */; };
|
||||
|
|
@ -1846,7 +1845,6 @@
|
|||
EA5F25D9232BD3E200475F2E /* msgNotificationService.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = msgNotificationService.appex; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
EA5F25DB232BD3E200475F2E /* NotificationService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationService.swift; sourceTree = "<group>"; };
|
||||
EA5F25DD232BD3E200475F2E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
EA88F3B0241BDAA100E66528 /* CoreManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreManager.swift; sourceTree = "<group>"; };
|
||||
EA8CB827239F96CA00C330CC /* msgNotificationContent.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = msgNotificationContent.appex; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
EA8CB82B239F96CA00C330CC /* NotificationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationViewController.swift; sourceTree = "<group>"; };
|
||||
EA8CB82E239F96CA00C330CC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/MainInterface.storyboard; sourceTree = "<group>"; };
|
||||
|
|
@ -2131,7 +2129,6 @@
|
|||
C6DA657B261C950C0020CB43 /* VFSUtil.swift */,
|
||||
614C087723D1A35F00217F80 /* ProviderDelegate.swift */,
|
||||
614C087923D1A37400217F80 /* CallManager.swift */,
|
||||
EA88F3B0241BDAA100E66528 /* CoreManager.swift */,
|
||||
6134812C2406CECC00695B41 /* ConfigManager.swift */,
|
||||
6134812E2407B35200695B41 /* AppManager.swift */,
|
||||
614C087623D1A35E00217F80 /* linphone-Bridging-Header.h */,
|
||||
|
|
@ -4193,7 +4190,6 @@
|
|||
2214EBF312F86360002A5394 /* UIMutedMicroButton.m in Sources */,
|
||||
8C9C5E111F83BD97006987FA /* UIChatCreateCollectionViewCell.m in Sources */,
|
||||
22968A5F12F875C600588287 /* UISpeakerButton.m in Sources */,
|
||||
EA88F3B1241BDAA100E66528 /* CoreManager.swift in Sources */,
|
||||
63701DDF1BA32039006A9AE3 /* UIConfirmationDialog.m in Sources */,
|
||||
6134812D2406CECC00695B41 /* ConfigManager.swift in Sources */,
|
||||
22C755601317E59C007BC101 /* UIBluetoothButton.m in Sources */,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue