mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
Use logging service for VFS related messages
This commit is contained in:
parent
1b96a21993
commit
7387bf6330
5 changed files with 43 additions and 33 deletions
|
|
@ -253,7 +253,7 @@
|
|||
LOGW(@"[VFS] Can not active for simulators.");
|
||||
[VFSUtil setVfsEnabbledWithEnabled:false groupName:kLinphoneMsgNotificationAppGroupId];
|
||||
} else if (!VFSUtil.activateVFS) {
|
||||
[VFSUtil oslogWithLog:@"[VFS] Error unable to activate." level:OS_LOG_TYPE_ERROR];
|
||||
[VFSUtil log:@"[VFS] Error unable to activate." :OS_LOG_TYPE_ERROR];
|
||||
[VFSUtil setVfsEnabbledWithEnabled:false groupName:kLinphoneMsgNotificationAppGroupId];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -798,7 +798,7 @@
|
|||
[VFSUtil setVfsEnabbledWithEnabled:false groupName:kLinphoneMsgNotificationAppGroupId];
|
||||
[self setBool:FALSE forKey:@"vfs_enabled_mode"];
|
||||
} else if (!VFSUtil.activateVFS) {
|
||||
[VFSUtil oslogWithLog:@"[VFS] Error unable to activate." level:OS_LOG_TYPE_ERROR];
|
||||
[VFSUtil log:@"[VFS] Error unable to activate ! Warning disabling VFS enabled preference." :OS_LOG_TYPE_ERROR];
|
||||
[VFSUtil setVfsEnabbledWithEnabled:false groupName:kLinphoneMsgNotificationAppGroupId];
|
||||
[self setBool:FALSE forKey:@"vfs_enabled_mode"];
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,21 +1,21 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
* 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 UIKit
|
||||
import Foundation
|
||||
|
|
@ -116,7 +116,7 @@ import os
|
|||
kSecAttrAccount as String: key.data(using: .utf8)!,
|
||||
kSecAttrAccessGroup as String : accessGroup]
|
||||
SecItemDelete(delQuery as CFDictionary)
|
||||
|
||||
|
||||
|
||||
let insertQUery: [String: Any] = [kSecClass as String: kSecClassGenericPassword,
|
||||
kSecAttrAccessGroup as String : accessGroup,
|
||||
|
|
@ -156,46 +156,55 @@ import os
|
|||
@objc static func activateVFS() -> Bool {
|
||||
do {
|
||||
if (getSecuredPreference(key: prefName) == nil) {
|
||||
oslog(log: "[VFS] no secret key set, building one.", level: .info)
|
||||
log("[VFS] no secret key set, building one.", .info)
|
||||
try generateKey(requiresBiometry: false)
|
||||
guard let encryptedHash = encrypt(clearText: randomSha512()) else {
|
||||
return false
|
||||
}
|
||||
if (!addSecuredPreference(key: prefName, value: encryptedHash)) {
|
||||
oslog(log: "[VFS] Unable to save encrypted key in secured defaults.", level: .error)
|
||||
log("[VFS] Unable to save encrypted key in secured defaults.", .error)
|
||||
}
|
||||
}
|
||||
guard let encryptedKey = getSecuredPreference(key: prefName) else {
|
||||
oslog(log: "[VFS] Unable to retrieve encrypted key.", level: .error)
|
||||
log("[VFS] Unable to retrieve encrypted key.", .error)
|
||||
return false
|
||||
}
|
||||
let secret = decrypt(encryptedText: encryptedKey)
|
||||
Factory.Instance.setVfsEncryption(encryptionModule: 2, secret: secret, secretSize: 32)
|
||||
oslog(log: "[VFS] activated", level: .info)
|
||||
log("[VFS] activated", .info)
|
||||
return true
|
||||
} catch {
|
||||
oslog(log: "[VFS] Error setting up VFS: \(error)", level: .info)
|
||||
log("[VFS] Error setting up VFS: \(error)", .info)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@objc static func vfsEnabled(groupName: String) -> Bool {
|
||||
let defaults = UserDefaults.init(suiteName: groupName)
|
||||
if (defaults == nil) {
|
||||
log("Unable to get VFS enabled preference userDefaults is null",.error);
|
||||
}
|
||||
return defaults?.bool(forKey: "vfs_enabled_preference") == true
|
||||
}
|
||||
|
||||
@objc static func setVfsEnabbled(enabled: Bool, groupName: String) {
|
||||
let defaults = UserDefaults.init(suiteName: groupName)
|
||||
if (defaults == nil) {
|
||||
log("Unable to set VFS enabled preferece userDefaults is null",.error);
|
||||
}
|
||||
defaults?.setValue(enabled, forKey: "vfs_enabled_preference")
|
||||
}
|
||||
|
||||
@objc static func oslog(log:String, level: OSLogType) {
|
||||
if #available(iOS 10.0, *) {
|
||||
os_log("%{public}@", type: level,log)
|
||||
} else {
|
||||
NSLog(log)
|
||||
@objc static func log(_ log:String, _ level: OSLogType) {
|
||||
switch (level) {
|
||||
case.info:LoggingService.Instance.message(message: log)
|
||||
case.debug:LoggingService.Instance.debug(message: log)
|
||||
case.error:LoggingService.Instance.error(message: log)
|
||||
case.fault:LoggingService.Instance.fatal(message: log)
|
||||
default:LoggingService.Instance.message(message: log)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import UIKit
|
|||
import UserNotifications
|
||||
import UserNotificationsUI
|
||||
import linphonesw
|
||||
import os
|
||||
#if USE_CRASHLYTICS
|
||||
import Firebase
|
||||
#endif
|
||||
|
|
@ -133,7 +134,7 @@ class NotificationViewController: UIViewController, UNNotificationContentExtensi
|
|||
|
||||
func startCore() throws {
|
||||
if (VFSUtil.vfsEnabled(groupName: APP_GROUP_ID) && !VFSUtil.activateVFS()) {
|
||||
VFSUtil.oslog(log: "[VFS] Error unable to activate.", level: .error)
|
||||
VFSUtil.log("[VFS] Error unable to activate.", .error)
|
||||
}
|
||||
config = Config.newForSharedCore(appGroupId: APP_GROUP_ID, configFilename: "linphonerc", factoryConfigFilename: "")
|
||||
log = LoggingService.Instance /*enable liblinphone logs.*/
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class NotificationService: UNNotificationServiceExtension {
|
|||
NSLog("[msgNotificationService] start msgNotificationService extension")
|
||||
|
||||
if (VFSUtil.vfsEnabled(groupName: APP_GROUP_ID) && !VFSUtil.activateVFS()) {
|
||||
VFSUtil.oslog(log: "[VFS] Error unable to activate.", level: .error)
|
||||
VFSUtil.log("[VFS] Error unable to activate.", .error)
|
||||
}
|
||||
|
||||
if let bestAttemptContent = bestAttemptContent {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue