forked from mirrors/linphone-iphone
Fix calls not working after core is destroyed by the app (remote prov)
This commit is contained in:
parent
d96408e777
commit
4a429c85ae
2 changed files with 15 additions and 7 deletions
|
|
@ -1433,6 +1433,7 @@ void popup_link_account_cb(LinphoneAccountCreator *creator, LinphoneAccountCreat
|
||||||
|
|
||||||
[ConfigManager.instance setDbWithDb:_configDb];
|
[ConfigManager.instance setDbWithDb:_configDb];
|
||||||
[CallManager.instance setCoreWithCore:theLinphoneCore];
|
[CallManager.instance setCoreWithCore:theLinphoneCore];
|
||||||
|
[CallsViewModelBridge updateCore];
|
||||||
|
|
||||||
[LinphoneManager.instance startLinphoneCore];
|
[LinphoneManager.instance startLinphoneCore];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,7 @@ class CallsViewModel {
|
||||||
let callConnectedEvent = MutableLiveData<Call>()
|
let callConnectedEvent = MutableLiveData<Call>()
|
||||||
let callUpdateEvent = MutableLiveData<Call>()
|
let callUpdateEvent = MutableLiveData<Call>()
|
||||||
let noMoreCallEvent = MutableLiveData(false)
|
let noMoreCallEvent = MutableLiveData(false)
|
||||||
|
|
||||||
var core : Core { get { Core.get() } }
|
|
||||||
|
|
||||||
static let shared = CallsViewModel()
|
static let shared = CallsViewModel()
|
||||||
|
|
||||||
private var coreDelegate : CoreDelegateStub?
|
private var coreDelegate : CoreDelegateStub?
|
||||||
|
|
@ -97,7 +95,7 @@ class CallsViewModel {
|
||||||
|
|
||||||
Core.get().addDelegate(delegate: coreDelegate!)
|
Core.get().addDelegate(delegate: coreDelegate!)
|
||||||
|
|
||||||
if let currentCall = core.currentCall {
|
if let currentCall = Core.get().currentCall {
|
||||||
currentCallData.value??.destroy()
|
currentCallData.value??.destroy()
|
||||||
currentCallData.value = CallData(call:currentCall)
|
currentCallData.value = CallData(call:currentCall)
|
||||||
}
|
}
|
||||||
|
|
@ -117,7 +115,7 @@ class CallsViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func initCallList() {
|
private func initCallList() {
|
||||||
core.calls.forEach { addCallToList(call: $0) }
|
Core.get().calls.forEach { addCallToList(call: $0) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private func removeCallFromList(call: Call) {
|
private func removeCallFromList(call: Call) {
|
||||||
|
|
@ -149,7 +147,7 @@ class CallsViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func updateInactiveCallsCount() {
|
private func updateInactiveCallsCount() {
|
||||||
inactiveCallsCount.value = core.callsNb - 1
|
inactiveCallsCount.value = Core.get().callsNb - 1
|
||||||
}
|
}
|
||||||
|
|
||||||
private func updateCallsAndChatCount() {
|
private func updateCallsAndChatCount() {
|
||||||
|
|
@ -181,7 +179,7 @@ class CallsViewModel {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let firstCall = core.calls.filter {$0.state != .Error && $0.state != .End && $0.state != .Released}.first
|
let firstCall = Core.get().calls.filter {$0.state != .Error && $0.state != .End && $0.state != .Released}.first
|
||||||
if (firstCall != nil && currentCallData.value??.call.getCobject != firstCall?.getCobject) {
|
if (firstCall != nil && currentCallData.value??.call.getCobject != firstCall?.getCobject) {
|
||||||
Log.i("[Calls] Using \(firstCall?.callLog?.callId) as \"current\" call")
|
Log.i("[Calls] Using \(firstCall?.callLog?.callId) as \"current\" call")
|
||||||
callToUse = firstCall
|
callToUse = firstCall
|
||||||
|
|
@ -204,9 +202,18 @@ class CallsViewModel {
|
||||||
ControlsViewModel.shared.updateMicState()
|
ControlsViewModel.shared.updateMicState()
|
||||||
//updateUnreadChatCount()
|
//updateUnreadChatCount()
|
||||||
}
|
}
|
||||||
|
func updateCore() {
|
||||||
|
Core.get().removeDelegate(delegate: coreDelegate!)
|
||||||
|
Core.get().addDelegate(delegate: coreDelegate!)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc class CallsViewModelBridge : NSObject {
|
@objc class CallsViewModelBridge : NSObject {
|
||||||
|
|
||||||
|
@objc static func updateCore() {
|
||||||
|
CallsViewModel.shared.updateCore()
|
||||||
|
}
|
||||||
|
|
||||||
@objc static func callViewToDisplay() -> UICompositeViewDescription? {
|
@objc static func callViewToDisplay() -> UICompositeViewDescription? {
|
||||||
if let call = CallsViewModel.shared.currentCallData.value??.call {
|
if let call = CallsViewModel.shared.currentCallData.value??.call {
|
||||||
if (call.conference != nil) {
|
if (call.conference != nil) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue