Marino Faggiana 1 rok temu
rodzic
commit
64842604a3

+ 1 - 1
File Provider Extension/FileProviderData.swift

@@ -74,7 +74,7 @@ class fileProviderData: NSObject {
         // LOG
         if let pathDirectoryGroup = CCUtility.getDirectoryGroup()?.path {
             NextcloudKit.shared.nkCommonInstance.pathLog = pathDirectoryGroup
-            let levelLog = CCUtility.getLogLevel()
+            let levelLog = NCKeychain().logLevel
             NextcloudKit.shared.nkCommonInstance.levelLog = levelLog
             let version = NSString(format: NCBrandOptions.shared.textCopyrightNextcloudiOS as NSString, NCUtility.shared.getVersionApp()) as String
             NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] Start File Provider session with level \(levelLog) " + version + " (File Provider Extension)")

+ 1 - 1
Share/NCShareExtension.swift

@@ -111,7 +111,7 @@ class NCShareExtension: UIViewController {
         uploadView.addGestureRecognizer(uploadGesture)
 
         // LOG
-        let levelLog = CCUtility.getLogLevel()
+        let levelLog = NCKeychain().logLevel
         let isSimulatorOrTestFlight = NCUtility.shared.isSimulatorOrTestFlight()
         let versionNextcloudiOS = String(format: NCBrandOptions.shared.textCopyrightNextcloudiOS, NCUtility.shared.getVersionApp())
 

+ 1 - 1
Widget/Dashboard/DashboardData.swift

@@ -142,7 +142,7 @@ func getDashboardDataEntry(configuration: DashboardIntent?, isPreview: Bool, dis
         delegate: NCNetworking.shared)
 
     // LOG
-    let levelLog = CCUtility.getLogLevel()
+    let levelLog = NCKeychain().logLevel
     let isSimulatorOrTestFlight = NCUtility.shared.isSimulatorOrTestFlight()
     let versionNextcloudiOS = String(format: NCBrandOptions.shared.textCopyrightNextcloudiOS, NCUtility.shared.getVersionApp())
 

+ 1 - 1
Widget/Files/FilesData.swift

@@ -192,7 +192,7 @@ func getFilesDataEntry(configuration: AccountIntent?, isPreview: Bool, displaySi
     let requestBody = String(format: requestBodyRecent, "/files/" + account.userId, lessDateString)
 
     // LOG
-    let levelLog = CCUtility.getLogLevel()
+    let levelLog = NCKeychain().logLevel
     let isSimulatorOrTestFlight = NCUtility.shared.isSimulatorOrTestFlight()
     let versionNextcloudiOS = String(format: NCBrandOptions.shared.textCopyrightNextcloudiOS, NCUtility.shared.getVersionApp())
 

+ 1 - 1
iOSClient/AppDelegate.swift

@@ -109,7 +109,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
 
         } else {
 
-            levelLog = CCUtility.getLogLevel()
+            levelLog = NCKeychain().logLevel
             NextcloudKit.shared.nkCommonInstance.levelLog = levelLog
             NextcloudKit.shared.nkCommonInstance.copyLogToDocumentDirectory = true
             NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] Start session with level \(levelLog) " + versionNextcloudiOS)

+ 3 - 3
iOSClient/Settings/CCAdvanced.m

@@ -153,7 +153,7 @@
 
             [[[NextcloudKit shared] nkCommonInstance] clearFileLog];
             
-            NSInteger logLevel = [CCUtility getLogLevel];
+            NSInteger logLevel = [[NCKeychain alloc] init].logLevel;
             BOOL isSimulatorOrTestFlight = [[NCUtility shared] isSimulatorOrTestFlight];
             NSString *versionNextcloudiOS = [NSString stringWithFormat:[NCBrandOptions shared].textCopyrightNextcloudiOS, [[NCUtility shared] getVersionAppWithBuild:true]];
             if (isSimulatorOrTestFlight) {
@@ -169,7 +169,7 @@
         [row.cellConfig setObject:@(NSTextAlignmentCenter) forKey:@"textLabel.textAlignment"];
         [row.cellConfig setObject:UIColor.labelColor forKey:@"textLabel.textColor"];
         [row.cellConfig setObject:[UIFont systemFontOfSize:15.0] forKey:@"textLabel.font"];
-        NSInteger logLevel = [CCUtility getLogLevel];
+        NSInteger logLevel = [[NCKeychain alloc] init].logLevel;
         row.value = @(logLevel);
         [row.cellConfigAtConfigure setObject:@(2) forKey:@"slider.maximumValue"];
         [row.cellConfigAtConfigure setObject:@(0) forKey:@"slider.minimumValue"];
@@ -352,7 +352,7 @@
     if ([rowDescriptor.tag isEqualToString:@"logLevel"]) {
         
         NSInteger levelLog = [[rowDescriptor.value valueData] intValue];
-        [CCUtility setLogLevel:levelLog];
+        [[NCKeychain alloc] init].logLevel = levelLog;
         [[[NextcloudKit shared] nkCommonInstance] setLevelLog:levelLog];
     }
 

+ 0 - 3
iOSClient/Utility/CCUtility.h

@@ -70,9 +70,6 @@
 + (double)getQualityScanDocument;
 + (void)setQualityScanDocument:(double)value;
 
-+ (NSInteger)getLogLevel;
-+ (void)setLogLevel:(NSInteger)value;
-
 + (BOOL)getAccountRequest;
 + (void)setAccountRequest:(BOOL)set;
 

+ 0 - 17
iOSClient/Utility/CCUtility.m

@@ -216,23 +216,6 @@
     [UICKeyChainStore setString:valueString forKey:@"qualityScanDocument" service:NCGlobal.shared.serviceShareKeyChain];
 }
 
-+ (NSInteger)getLogLevel
-{
-    NSString *value = [UICKeyChainStore stringForKey:@"logLevel" service:NCGlobal.shared.serviceShareKeyChain];
-
-    if (value == nil) {
-        return 1;
-    } else {
-        return [value integerValue];
-    }
-}
-
-+ (void)setLogLevel:(NSInteger)value
-{
-    NSString *valueString = [@(value) stringValue];
-    [UICKeyChainStore setString:valueString forKey:@"logLevel" service:NCGlobal.shared.serviceShareKeyChain];
-}
-
 + (BOOL)getAccountRequest
 {
     return [[UICKeyChainStore stringForKey:@"accountRequest" service:NCGlobal.shared.serviceShareKeyChain] boolValue];

+ 13 - 0
iOSClient/Utility/NCKeychain.swift

@@ -188,6 +188,19 @@ import KeychainAccess
         }
     }
 
+    @objc var logLevel: Int {
+        get {
+            migrate(key: "logLevel")
+            if let value = try? keychain.get("logLevel"), let result = Int(value) {
+                return result
+            }
+            return 1
+        }
+        set {
+            keychain["logLevel"] = String(newValue)
+        }
+    }
+
     // MARK: -
 
     private func migrate(key: String) {