forked from mirrors/linphone-iphone
Handle [misc]max_calls configuration flag inside the application
This commit is contained in:
parent
79d5e0ab8b
commit
d70c60d5fa
3 changed files with 26 additions and 2 deletions
|
|
@ -843,6 +843,11 @@
|
|||
- (void)ConfigurationStateUpdateEvent:(NSNotification *)notif {
|
||||
LinphoneConfiguringState state = [[notif.userInfo objectForKey:@"state"] intValue];
|
||||
if (state == LinphoneConfiguringSuccessful) {
|
||||
if (linphone_config_has_entry(LinphoneManager.instance.configDb, "misc", "max_calls")) { // Not doable on core on iOS (requires CallKit) -> flag moved to app section, and have app handle it in ProviderDelegate
|
||||
linphone_config_set_int(LinphoneManager.instance.configDb, "app", "max_calls", linphone_config_get_int(LinphoneManager.instance.configDb,"misc", "max_calls",10));
|
||||
linphone_config_clean_entry(LinphoneManager.instance.configDb, "misc", "max_calls");
|
||||
|
||||
}
|
||||
[NSNotificationCenter.defaultCenter removeObserver:self name:kLinphoneConfiguringStateUpdate object:nil];
|
||||
[_waitingIndicator dismissViewControllerAnimated:YES completion:nil];
|
||||
UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Success", nil)
|
||||
|
|
|
|||
|
|
@ -1810,7 +1810,10 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
|
|||
factory = factoryIpad;
|
||||
}
|
||||
_configDb = linphone_config_new_for_shared_core(kLinphoneMsgNotificationAppGroupId.UTF8String, @"linphonerc".UTF8String, factory.UTF8String);
|
||||
linphone_config_clean_entry(_configDb, "misc", "max_calls");
|
||||
if (linphone_config_has_entry(_configDb, "misc", "max_calls")) { // Not doable on core on iOS (requires CallKit) -> flag moved to app section, and have app handle it in ProviderDelegate
|
||||
linphone_config_set_int(_configDb, "app", "max_calls", linphone_config_get_int(_configDb,"misc", "max_calls",10));
|
||||
linphone_config_clean_entry(_configDb, "misc", "max_calls");
|
||||
}
|
||||
}
|
||||
#pragma mark - Audio route Functions
|
||||
|
||||
|
|
|
|||
|
|
@ -95,9 +95,21 @@ class ProviderDelegate: NSObject {
|
|||
update.remoteHandle = CXHandle(type:.generic, value: handle)
|
||||
update.hasVideo = hasVideo
|
||||
update.localizedCallerName = displayName
|
||||
|
||||
|
||||
let callInfo = callInfos[uuid]
|
||||
let callId = callInfo?.callId
|
||||
|
||||
if (ConfigManager.instance().config?.hasEntry(section: "app", key: "max_calls") == 1) { // moved from misc to app section intentionally upon app start or remote configuration
|
||||
if let maxCalls = ConfigManager.instance().config?.getInt(section: "app",key: "max_calls",defaultValue: 10), Core.get().callsNb > maxCalls {
|
||||
Log.directLog(BCTBX_LOG_MESSAGE, text: "CallKit: declining call, as max calls (\(maxCalls)) reached call-id: [\(String(describing: callId))] and UUID: [\(uuid.description)]")
|
||||
decline(uuid: uuid)
|
||||
DispatchQueue.main.async {
|
||||
try?call?.decline(reason: .Busy)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
Log.directLog(BCTBX_LOG_MESSAGE, text: "CallKit: report new incoming call with call-id: [\(String(describing: callId))] and UUID: [\(uuid.description)]")
|
||||
//CallManager.instance().setHeldOtherCalls(exceptCallid: callId ?? "")
|
||||
provider.reportNewIncomingCall(with: uuid, update: update) { error in
|
||||
|
|
@ -144,6 +156,10 @@ class ProviderDelegate: NSObject {
|
|||
func endCall(uuid: UUID) {
|
||||
provider.reportCall(with: uuid, endedAt: .init(), reason: .failed)
|
||||
}
|
||||
|
||||
func decline(uuid: UUID) {
|
||||
provider.reportCall(with: uuid, endedAt: .init(), reason: .unanswered)
|
||||
}
|
||||
|
||||
func endCallNotExist(uuid: UUID, timeout: DispatchTime) {
|
||||
DispatchQueue.main.asyncAfter(deadline: timeout) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue