From 98449ef104f1732ebd6836efb9792c821f77941b Mon Sep 17 00:00:00 2001 From: Danmei Chen Date: Wed, 29 Jul 2020 10:37:51 +0200 Subject: [PATCH] update api --- Classes/AssistantView.m | 2 +- Classes/CallManager.swift | 4 +-- Classes/CallView.m | 4 +-- Classes/LinphoneAppDelegate.m | 8 ++--- Classes/LinphoneCoreSettingsStore.m | 4 +-- Classes/LinphoneManager.m | 16 +++++----- Classes/LinphoneUI/StatusBarView.m | 4 +-- Classes/LinphoneUI/UIVideoButton.m | 2 +- msgNotification/Utils.swift | 24 +++++++-------- .../NotificationViewController.swift | 26 ++++++++-------- .../NotificationService.swift | 30 +++++++++---------- 11 files changed, 62 insertions(+), 62 deletions(-) diff --git a/Classes/AssistantView.m b/Classes/AssistantView.m index 1fd1e5928..f00e7be8f 100644 --- a/Classes/AssistantView.m +++ b/Classes/AssistantView.m @@ -602,7 +602,7 @@ static UICompositeViewDescription *compositeDescription = nil; [self changeView:_remoteProvisioningLoginView back:FALSE animation:TRUE]; - linphone_proxy_config_destroy(default_conf); + linphone_proxy_config_unref(default_conf); } - (void)resetTextFields { diff --git a/Classes/CallManager.swift b/Classes/CallManager.swift index 7cb376bc8..5e144eabc 100644 --- a/Classes/CallManager.swift +++ b/Classes/CallManager.swift @@ -445,12 +445,12 @@ class CoreManagerDelegate: CoreDelegate { } } - override func onCallStateChanged(lc: Core, call: Call, cstate: Call.State, message: String) { + override func onCallStateChanged(core: Core, call: Call, state cstate: Call.State, message: String) { let addr = call.remoteAddress; let displayName = FastAddressBook.displayName(for: addr?.getCobject) ?? "Unknow" let callLog = call.callLog let callId = callLog?.callId - let video = UIApplication.shared.applicationState == .active && (lc.videoActivationPolicy?.automaticallyAccept ?? false) && (call.remoteParams?.videoEnabled ?? false) + let video = UIApplication.shared.applicationState == .active && (core.videoActivationPolicy?.automaticallyAccept ?? false) && (call.remoteParams?.videoEnabled ?? false) // we keep the speaker auto-enabled state in this static so that we don't // force-enable it on ICE re-invite if the user disabled it. CoreManagerDelegate.speaker_already_enabled = false diff --git a/Classes/CallView.m b/Classes/CallView.m index 0cc1db6d7..e00759d9f 100644 --- a/Classes/CallView.m +++ b/Classes/CallView.m @@ -687,7 +687,7 @@ static void hideSpinner(LinphoneCall *call, void *user_data) { if (call == linphone_core_get_current_call(LC)) { LinphoneCallParams *params = linphone_core_create_call_params(LC, call); linphone_call_accept_update(call, params); - linphone_call_params_destroy(params); + linphone_call_params_unref(params); [videoDismissTimer invalidate]; videoDismissTimer = nil; } @@ -698,7 +698,7 @@ static void hideSpinner(LinphoneCall *call, void *user_data) { LinphoneCallParams *params = linphone_core_create_call_params(LC, call); linphone_call_params_enable_video(params, TRUE); linphone_call_accept_update(call, params); - linphone_call_params_destroy(params); + linphone_call_params_unref(params); [videoDismissTimer invalidate]; videoDismissTimer = nil; } diff --git a/Classes/LinphoneAppDelegate.m b/Classes/LinphoneAppDelegate.m index 627d7d8d7..3fa616136 100644 --- a/Classes/LinphoneAppDelegate.m +++ b/Classes/LinphoneAppDelegate.m @@ -652,7 +652,7 @@ LinphoneCallParams *params = linphone_core_create_call_params(LC, call); linphone_call_accept_update(call, params); - linphone_call_params_destroy(params); + linphone_call_params_unref(params); } else if ([response.actionIdentifier isEqual:@"Accept"]) { LOGI(@"User accept video proposal"); if (call != linphone_core_get_current_call(LC)) @@ -663,7 +663,7 @@ LinphoneCallParams *params = linphone_core_create_call_params(LC, call); linphone_call_params_enable_video(params, TRUE); linphone_call_accept_update(call, params); - linphone_call_params_destroy(params); + linphone_call_params_unref(params); } else if ([response.actionIdentifier isEqual:@"Confirm"]) { if (linphone_core_get_current_call(LC) == call) linphone_call_set_authentication_token_verified(call, YES); @@ -706,7 +706,7 @@ LinphoneCallParams *params = linphone_core_create_call_params(LC, call); linphone_call_accept_update(call, params); - linphone_call_params_destroy(params); + linphone_call_params_unref(params); [videoDismissTimer invalidate]; } onConfirmationClick:^() { @@ -717,7 +717,7 @@ LinphoneCallParams *params = linphone_core_create_call_params(LC, call); linphone_call_params_enable_video(params, TRUE); linphone_call_accept_update(call, params); - linphone_call_params_destroy(params); + linphone_call_params_unref(params); [videoDismissTimer invalidate]; } inController:PhoneMainView.instance]; diff --git a/Classes/LinphoneCoreSettingsStore.m b/Classes/LinphoneCoreSettingsStore.m index 37566f274..9d0aacf72 100644 --- a/Classes/LinphoneCoreSettingsStore.m +++ b/Classes/LinphoneCoreSettingsStore.m @@ -551,7 +551,7 @@ const char *password = [accountPassword UTF8String]; const char *ha1 = [accountHa1 UTF8String]; - if (linphone_proxy_config_set_identity(proxyCfg, identity) == -1) { + if (linphone_proxy_config_set_identity_address(proxyCfg, linphoneAddress) == -1) { error = NSLocalizedString(@"Invalid username or domain", nil); goto bad_proxy; } @@ -586,7 +586,7 @@ [LinphoneManager.instance configurePushTokenForProxyConfig:proxyCfg]; linphone_proxy_config_enable_register(proxyCfg, is_enabled); - linphone_proxy_config_enable_avpf(proxyCfg, use_avpf); + linphone_proxy_config_set_avpf_mode(proxyCfg, use_avpf); linphone_proxy_config_set_expires(proxyCfg, expire); if (is_default) { linphone_core_set_default_proxy_config(LC, proxyCfg); diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 3fd69d5f5..e2b50a393 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -388,7 +388,7 @@ static int check_should_migrate_images(void *data, int argc, char **argv, char * withDefault:@"sip.linphone.org"] .UTF8String) != 0) { LOGI(@"Migrating proxy config to use AVPF"); - linphone_proxy_config_enable_avpf(proxy, TRUE); + linphone_proxy_config_set_avpf_mode(proxy, LinphoneAVPFEnabled); } proxies = proxies->next; } @@ -511,7 +511,7 @@ static void migrateWizardToAssistant(const char *entry, void *user_data) { + (void)dumpLcConfig { if (theLinphoneCore) { LpConfig *conf = LinphoneManager.instance.configDb; - char *config = lp_config_dump(conf); + char *config = linphone_config_dump(conf); LOGI(@"\n%s", config); ms_free(config); } @@ -1682,7 +1682,7 @@ 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); - lp_config_clean_entry(_configDb, "misc", "max_calls"); + linphone_config_clean_entry(_configDb, "misc", "max_calls"); } #pragma mark - Audio route Functions @@ -2015,7 +2015,7 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) { - (void)configureVbrCodecs { PayloadType *pt; - int bitrate = lp_config_get_int( + int bitrate = linphone_config_get_int( _configDb, "audio", "codec_bitrate_limit", kLinphoneAudioVbrCodecDefaultBitrate); /*default value is in linphonerc or linphonerc-factory*/ const MSList *audio_codecs = linphone_core_get_audio_codecs(theLinphoneCore); @@ -2070,7 +2070,7 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) { - (void)lpConfigSetString:(NSString *)value forKey:(NSString *)key inSection:(NSString *)section { if (!key) return; - lp_config_set_string(_configDb, [section UTF8String], [key UTF8String], value ? [value UTF8String] : NULL); + linphone_config_set_string(_configDb, [section UTF8String], [key UTF8String], value ? [value UTF8String] : NULL); } - (NSString *)lpConfigStringForKey:(NSString *)key { return [self lpConfigStringForKey:key withDefault:nil]; @@ -2084,7 +2084,7 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) { - (NSString *)lpConfigStringForKey:(NSString *)key inSection:(NSString *)section withDefault:(NSString *)defaultValue { if (!key) return defaultValue; - const char *value = lp_config_get_string(_configDb, [section UTF8String], [key UTF8String], NULL); + const char *value = linphone_config_get_string(_configDb, [section UTF8String], [key UTF8String], NULL); return value ? [NSString stringWithUTF8String:value] : defaultValue; } @@ -2094,7 +2094,7 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) { - (void)lpConfigSetInt:(int)value forKey:(NSString *)key inSection:(NSString *)section { if (!key) return; - lp_config_set_int(_configDb, [section UTF8String], [key UTF8String], (int)value); + linphone_config_set_int(_configDb, [section UTF8String], [key UTF8String], (int)value); } - (int)lpConfigIntForKey:(NSString *)key { return [self lpConfigIntForKey:key withDefault:-1]; @@ -2108,7 +2108,7 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) { - (int)lpConfigIntForKey:(NSString *)key inSection:(NSString *)section withDefault:(int)defaultValue { if (!key) return defaultValue; - return lp_config_get_int(_configDb, [section UTF8String], [key UTF8String], (int)defaultValue); + return linphone_config_get_int(_configDb, [section UTF8String], [key UTF8String], (int)defaultValue); } - (void)lpConfigSetBool:(BOOL)value forKey:(NSString *)key { diff --git a/Classes/LinphoneUI/StatusBarView.m b/Classes/LinphoneUI/StatusBarView.m index cad865c74..eb4bb89d6 100644 --- a/Classes/LinphoneUI/StatusBarView.m +++ b/Classes/LinphoneUI/StatusBarView.m @@ -72,7 +72,7 @@ // Update to default state LinphoneProxyConfig *config = linphone_core_get_default_proxy_config(LC); - messagesUnreadCount = lp_config_get_int(linphone_core_get_config(LC), "app", "voice_mail_messages_count", 0); + messagesUnreadCount = linphone_config_get_int(linphone_core_get_config(LC), "app", "voice_mail_messages_count", 0); [self proxyConfigUpdate:config]; [self updateUI:linphone_core_get_calls_nb(LC)]; @@ -149,7 +149,7 @@ LOGI(@"Received new NOTIFY from voice mail: there is/are now %d message(s) unread", messagesUnreadCount); // save in lpconfig for future - lp_config_set_int(linphone_core_get_config(LC), "app", "voice_mail_messages_count", messagesUnreadCount); + linphone_config_set_int(linphone_core_get_config(LC), "app", "voice_mail_messages_count", messagesUnreadCount); [self updateVoicemail]; } diff --git a/Classes/LinphoneUI/UIVideoButton.m b/Classes/LinphoneUI/UIVideoButton.m index 223f89452..76083379a 100644 --- a/Classes/LinphoneUI/UIVideoButton.m +++ b/Classes/LinphoneUI/UIVideoButton.m @@ -67,7 +67,7 @@ INIT_WITH_COMMON_CF { LinphoneCallParams *call_params = linphone_core_create_call_params(LC,call); linphone_call_params_enable_video(call_params, FALSE); linphone_core_update_call(LC, call, call_params); - linphone_call_params_destroy(call_params); + linphone_call_params_unref(call_params); } else { LOGW(@"Cannot toggle video button, because no current call"); } diff --git a/msgNotification/Utils.swift b/msgNotification/Utils.swift index 92c2bb056..761cd7ad6 100644 --- a/msgNotification/Utils.swift +++ b/msgNotification/Utils.swift @@ -46,29 +46,29 @@ class LinphoneLoggingServiceManager: LoggingServiceDelegate { } } - override func onLogMessageWritten(logService: LoggingService, domain: String, lev: LogLevel, message: String) { - let level: String + override func onLogMessageWritten(logService: LoggingService, domain: String, level: LogLevel, message: String) { + let levelStr: String - switch lev { + switch level { case .Debug: - level = "Debug" + levelStr = "Debug" case .Trace: - level = "Trace" + levelStr = "Trace" case .Message: - level = "Message" + levelStr = "Message" case .Warning: - level = "Warning" + levelStr = "Warning" case .Error: - level = "Error" + levelStr = "Error" case .Fatal: - level = "Fatal" + levelStr = "Fatal" default: - level = "unknown" + levelStr = "unknown" } #if USE_CRASHLYTICS - Crashlytics.crashlytics().log("\(level) [\(domain)] \(message)\n") + Crashlytics.crashlytics().log("\(levelStr) [\(domain)] \(message)\n") #endif - NSLog("\(level) [\(domain)] \(message)\n") + NSLog("\(levelStr) [\(domain)] \(message)\n") } } diff --git a/msgNotificationContent/NotificationViewController.swift b/msgNotificationContent/NotificationViewController.swift index 6003d398c..ca57528d8 100644 --- a/msgNotificationContent/NotificationViewController.swift +++ b/msgNotificationContent/NotificationViewController.swift @@ -82,7 +82,7 @@ class NotificationViewController: UIViewController, UNNotificationContentExtensi } if (needToStop) { - log.error(msg: "core stopped by app") + log.error(message: "core stopped by app") throw LinphoneError.timeout } else { completion(.dismiss) @@ -90,7 +90,7 @@ class NotificationViewController: UIViewController, UNNotificationContentExtensi } } catch { - log.error(msg: "error: \(error)") + log.error(message: "error: \(error)") completion(.dismissAndForwardAction) } } @@ -123,19 +123,19 @@ class NotificationViewController: UIViewController, UNNotificationContentExtensi msgDelegate = LinphoneChatMessageManager() let chatMsg = try room.createMessage(message: replyText) chatMsg.addDelegate(delegate: msgDelegate) - room.sendChatMessage(msg: chatMsg) + chatMsg.send() room.markAsRead() } for i in 0...50 where !isReplySent && !needToStop { - log.debug(msg: "reply \(i)") + log.debug(message: "reply \(i)") lc!.iterate() usleep(10000) } } func startCore() throws { - config = Config.newForSharedCore(appGroupId: APP_GROUP_ID, configFilename: "linphonerc", factoryPath: "") + config = Config.newForSharedCore(appGroupId: APP_GROUP_ID, configFilename: "linphonerc", factoryConfigFilename: "") log = LoggingService.Instance /*enable liblinphone logs.*/ logDelegate = try! LinphoneLoggingServiceManager(config: config, log: log, domain: "msgNotificationContent") lc = try! Factory.Instance.createSharedCoreWithConfig(config: config, systemContext: nil, appGroupId: APP_GROUP_ID, mainCore: false) @@ -144,27 +144,27 @@ class NotificationViewController: UIViewController, UNNotificationContentExtensi lc!.addDelegate(delegate: coreDelegate) try lc!.start() - log.message(msg: "core started") + log.message(message: "core started") if (needToStop) { - log.error(msg: "core stopped by app") + log.error(message: "core stopped by app") throw LinphoneError.timeout } } func stopCore() { lc!.stopAsync() - log.message(msg: "stop core") + log.message(message: "stop core") for i in 0...100 where !coreStopped { - log.debug(msg: "stop \(i)") + log.debug(message: "stop \(i)") lc!.iterate() usleep(50000) } } class LinphoneCoreManager: CoreDelegate { - override func onGlobalStateChanged(lc: Core, gstate: GlobalState, message: String) { - log.message(msg: "global state changed: \(gstate) : \(message) \n") + override func onGlobalStateChanged(core: Core, state gstate: GlobalState, message: String) { + log.message(message: "global state changed: \(gstate) : \(message) \n") if (gstate == .Shutdown) { needToStop = true } else if (gstate == .Off) { @@ -174,8 +174,8 @@ class NotificationViewController: UIViewController, UNNotificationContentExtensi } class LinphoneChatMessageManager: ChatMessageDelegate { - override func onMsgStateChanged(msg: ChatMessage, state: ChatMessage.State) { - log.message(msg: "msg state changed: \(state)\n") + override func onMsgStateChanged(message: ChatMessage, state: ChatMessage.State) { + log.message(message: "msg state changed: \(state)\n") if (state == .Delivered) { isReplySent = true } diff --git a/msgNotificationService/NotificationService.swift b/msgNotificationService/NotificationService.swift index b52a3761c..0bcf505a3 100644 --- a/msgNotificationService/NotificationService.swift +++ b/msgNotificationService/NotificationService.swift @@ -58,15 +58,15 @@ class NotificationService: UNNotificationServiceExtension { if let bestAttemptContent = bestAttemptContent { createCore() - NotificationService.log.message(msg: "received push payload : \(bestAttemptContent.userInfo.debugDescription)") + NotificationService.log.message(message: "received push payload : \(bestAttemptContent.userInfo.debugDescription)") if let chatRoomInviteAddr = bestAttemptContent.userInfo["chat-room-addr"] as? String, !chatRoomInviteAddr.isEmpty { - NotificationService.log.message(msg: "fetch chat room for invite, addr: \(chatRoomInviteAddr)") + NotificationService.log.message(message: "fetch chat room for invite, addr: \(chatRoomInviteAddr)") let chatRoom = lc!.getNewChatRoomFromConfAddr(chatRoomAddr: chatRoomInviteAddr) if let chatRoom = chatRoom { stopCore() - NotificationService.log.message(msg: "chat room invite received") + NotificationService.log.message(message: "chat room invite received") bestAttemptContent.title = NSLocalizedString("GC_MSG", comment: "") if (chatRoom.hasCapability(mask:ChatRoomCapabilities.OneToOne.rawValue)) { if (chatRoom.peerAddress?.displayName.isEmpty != true) { @@ -83,7 +83,7 @@ class NotificationService: UNNotificationServiceExtension { return } } else if let callId = bestAttemptContent.userInfo["call-id"] as? String { - NotificationService.log.message(msg: "fetch msg for callid ["+callId+"]") + NotificationService.log.message(message: "fetch msg for callid ["+callId+"]") let message = lc!.getNewMessageFromCallid(callId: callId) if let message = message { @@ -114,7 +114,7 @@ class NotificationService: UNNotificationServiceExtension { contentHandler(bestAttemptContent) return } else { - NotificationService.log.message(msg: "Message not found for callid ["+callId+"]") + NotificationService.log.message(message: "Message not found for callid ["+callId+"]") } } serviceExtensionTimeWillExpire() @@ -124,7 +124,7 @@ class NotificationService: UNNotificationServiceExtension { override func serviceExtensionTimeWillExpire() { // Called just before the extension will be terminated by the system. // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used. - NotificationService.log.warning(msg: "serviceExtensionTimeWillExpire") + NotificationService.log.warning(message: "serviceExtensionTimeWillExpire") stopCore() if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent { NSLog("[msgNotificationService] serviceExtensionTimeWillExpire") @@ -174,15 +174,15 @@ class NotificationService: UNNotificationServiceExtension { } } - NotificationService.log.message(msg: "msg: \(content) \n") + NotificationService.log.message(message: "msg: \(content) \n") return msgData; } func createCore() { NSLog("[msgNotificationService] create core") - let config = Config.newForSharedCore(appGroupId: APP_GROUP_ID, configFilename: "linphonerc", factoryPath: "") + let config = Config.newForSharedCore(appGroupId: APP_GROUP_ID, configFilename: "linphonerc", factoryConfigFilename: "") - if (NotificationService.log == nil || NotificationService.log.getDelegate() == nil) { + if (NotificationService.log == nil) { NotificationService.log = LoggingService.Instance /*enable liblinphone logs.*/ NotificationService.logDelegate = try! LinphoneLoggingServiceManager(config: config!, log: NotificationService.log, domain: "msgNotificationService") } @@ -190,7 +190,7 @@ class NotificationService: UNNotificationServiceExtension { } func stopCore() { - NotificationService.log.message(msg: "stop core") + NotificationService.log.message(message: "stop core") if let lc = lc { lc.stop() } @@ -201,14 +201,14 @@ class NotificationService: UNNotificationServiceExtension { count += lc!.unreadChatMessageCount count += lc!.missedCallsCount count += lc!.callsNb - NotificationService.log.message(msg: "badge: \(count)\n") + NotificationService.log.message(message: "badge: \(count)\n") return count } func getDisplayNameFromSipAddress(sipAddr: String?) -> String? { if let sipAddr = sipAddr { - NotificationService.log.message(msg: "looking for display name for \(sipAddr)") + NotificationService.log.message(message: "looking for display name for \(sipAddr)") if (sipAddr == "") { return nil } @@ -216,15 +216,15 @@ class NotificationService: UNNotificationServiceExtension { let addressBook = defaults?.dictionary(forKey: "addressBook") if (addressBook == nil) { - NotificationService.log.message(msg: "address book not found in userDefaults") + NotificationService.log.message(message: "address book not found in userDefaults") return nil } if let displayName = addressBook?[sipAddr] as? String { - NotificationService.log.message(msg: "display name for \(sipAddr): \(displayName)") + NotificationService.log.message(message: "display name for \(sipAddr): \(displayName)") return displayName } else { - NotificationService.log.message(msg: "display name for \(sipAddr) not found in userDefaults") + NotificationService.log.message(message: "display name for \(sipAddr) not found in userDefaults") return nil } }