Browse Source

Debug function for TestFlight

Marino Faggiana 8 years ago
parent
commit
d2a075e009

+ 4 - 1
iOSClient/AppDelegate.h

@@ -55,6 +55,9 @@
 // For debug
 @property BOOL isRunningTestFlight;
 
+// Timer 5 sec.
+@property (nonatomic, strong) NSTimer *timerVerifyProcess;
+
 // For LMMediaPlayerView
 @property (strong, nonatomic) UIWindow *window;
 
@@ -184,7 +187,7 @@
 // Operation Networking
 - (void)cancelAllOperations;
 - (void)addNetworkingOperationQueue:(NSOperationQueue *)netQueue delegate:(id)delegate metadataNet:(CCMetadataNet *)metadataNet oneByOne:(BOOL)oneByOne;
-- (BOOL)verifyExistsInQueue:(NSOperationQueue *)queue selector:(NSString *)selector;
+- (NSMutableArray *)verifyExistsInQueuesUploadSelector:(NSString *)selector;
 - (void)loadTableAutomaticUploadForSelector:(NSString *)selector;
 
 - (void)dropAutomaticUploadWithSelector:(NSString *)selector;

+ 36 - 9
iOSClient/AppDelegate.m

@@ -88,7 +88,7 @@
     [MagicalRecord setLoggingLevel:MagicalRecordLoggingLevelOff];
 #endif
     
-    //
+    // Test Flight
     NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
     NSString *receiptURLString = [receiptURL path];
     _isRunningTestFlight =  ([receiptURLString rangeOfString:@"sandboxReceipt"].location != NSNotFound);
@@ -245,7 +245,10 @@
         if (shortcutItem)
             [self handleShortCutItem:shortcutItem];
     }
-        
+    
+    // Start timer Verify Process
+    self.timerVerifyProcess = [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(verifyProcess) userInfo:nil repeats:YES];
+    
     return YES;
 }
 
@@ -381,8 +384,22 @@
     
     // Initialize Camera Upload
     //[[NSNotificationCenter defaultCenter] postNotificationName:@"initStateCameraUpload" object:@{@"afterDelay": @(2)}];
+}
 
+#pragma --------------------------------------------------------------------------------------------
+#pragma mark ===== Verify Process =====
+#pragma --------------------------------------------------------------------------------------------
+
+- (void)verifyProcess
+{
+    NSMutableArray *metadatasNet = [self verifyExistsInQueuesUploadSelector:selectorUploadAutomaticAll];
+    
+    NSLog(@"5 sec. %lu", [metadatasNet count]);
+    
+    
+    
 }
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Setting Active Account =====
 #pragma --------------------------------------------------------------------------------------------
@@ -1033,15 +1050,21 @@
     [netQueue addOperation:operation];
 }
 
-- (BOOL)verifyExistsInQueue:(NSOperationQueue *)queue selector:(NSString *)selector
+- (NSMutableArray *)verifyExistsInQueuesUploadSelector:(NSString *)selector
 {
+    NSMutableArray *metadatasNet = [[NSMutableArray alloc] init];
+    
     /*** NEXTCLOUD OWNCLOUD ***/
     
     if ([app.typeCloud isEqualToString:typeCloudOwnCloud] || [app.typeCloud isEqualToString:typeCloudNextcloud]) {
         
-        for (OCnetworking *operation in [queue operations])
+        for (OCnetworking *operation in [self.netQueueUpload operations])
             if ([operation.metadataNet.selector isEqualToString:selector])
-                return YES;
+                [metadatasNet addObject:operation.metadataNet];
+        
+        for (OCnetworking *operation in [self.netQueueUploadWWan operations])
+            if ([operation.metadataNet.selector isEqualToString:selector])
+                [metadatasNet addObject:operation.metadataNet];
     }
     
 #ifdef CC
@@ -1050,14 +1073,18 @@
     
     if ([app.typeCloud isEqualToString:typeCloudDropbox]) {
         
-        for (DBnetworking *operation in [queue operations])
+        for (DBnetworking *operation in [self.netQueueUpload operations])
+            if ([operation.metadataNet.selector isEqualToString:selector])
+                [metadatasNet addObject:operation.metadataNet];
+        
+        for (DBnetworking *operation in [self.netQueueUploadWWan operations])
             if ([operation.metadataNet.selector isEqualToString:selector])
-                return YES;
+                [metadatasNet addObject:operation.metadataNet];
     }
     
 #endif
     
-    return NO;
+    return metadatasNet;
 }
 
 - (void)loadTableAutomaticUploadForSelector:(NSString *)selector
@@ -1078,7 +1105,7 @@
     
     // Add Network queue
     
-    CCMetadataNet *metadataNet = [CCCoreData getTableAutomaticUploadForAccount:self.activeAccount selector:selector context:nil];
+    CCMetadataNet *metadataNet = [CCCoreData getTableAutomaticUploadForAccount:self.activeAccount selector:selector delete:YES context:nil];
     
     if (metadataNet) {
         

+ 1 - 1
iOSClient/FileSystem/CCCoreData.h

@@ -179,7 +179,7 @@
 // ===== Automatic Upload =====
 
 + (void)addTableAutomaticUpload:(CCMetadataNet *)metadataNet account:(NSString *)account context:(NSManagedObjectContext *)context;
-+ (CCMetadataNet *)getTableAutomaticUploadForAccount:(NSString *)account selector:(NSString *)selector context:(NSManagedObjectContext *)context;
++ (CCMetadataNet *)getTableAutomaticUploadForAccount:(NSString *)account selector:(NSString *)selector delete:(BOOL)delete context:(NSManagedObjectContext *)context;
 + (NSUInteger)countTableAutomaticUploadForAccount:(NSString *)account selector:(NSString *)selector;
 
 // ===== GPS =====

+ 6 - 4
iOSClient/FileSystem/CCCoreData.m

@@ -1497,7 +1497,7 @@
     [context MR_saveToPersistentStoreAndWait];
 }
 
-+ (CCMetadataNet *)getTableAutomaticUploadForAccount:(NSString *)account selector:(NSString *)selector context:(NSManagedObjectContext *)context
++ (CCMetadataNet *)getTableAutomaticUploadForAccount:(NSString *)account selector:(NSString *)selector delete:(BOOL)delete context:(NSManagedObjectContext *)context
 {
     if (context == nil)
         context = [NSManagedObjectContext MR_context];
@@ -1518,9 +1518,11 @@
         metadataNet.session = record.session;
         metadataNet.taskStatus = taskStatusResume;                          // Default
         
-        [record MR_deleteEntityInContext:context];                          // Remove record
-        [context MR_saveToPersistentStoreAndWait];
-
+        if (delete) {                                                       // Remove record
+            [record MR_deleteEntityInContext:context];
+            [context MR_saveToPersistentStoreAndWait];
+        }
+        
         return metadataNet;
     }
     

+ 14 - 2
iOSClient/Main/CCMain.m

@@ -324,8 +324,20 @@
         [app loadTableAutomaticUploadForSelector:selectorUploadAutomaticAll];
         
         // message TestFlight
-        if (app.isRunningTestFlight)
-            [app messageNotification:@"_info_" description:@"This version is beta and only fot TestFlight, send report at ios@nextcloud.com" visible:YES delay:dismissAfterSecond type:TWMessageBarMessageTypeInfo];
+        if (app.isRunningTestFlight) {
+            
+            NSString *messageDebug;
+            
+            //[app messageNotification:@"_info_" description:@"This version is beta and only fot TestFlight, send report at ios@nextcloud.com" visible:YES delay:dismissAfterSecond type:TWMessageBarMessageTypeInfo];
+            
+            NSMutableArray *metadatasNet = [app verifyExistsInQueuesUploadSelector:selectorUploadAutomaticAll];
+            CCMetadataNet *metadataNet = [CCCoreData getTableAutomaticUploadForAccount:app.activeAccount selector:selectorUploadAutomaticAll delete:NO context:nil];
+            
+            messageDebug = [NSString stringWithFormat:@"DEBUG UploadAutomaticAll : %lu - %@", [metadatasNet count], metadataNet];
+                            
+            [app messageNotification:@"_info_" description:messageDebug visible:YES delay:dismissAfterSecond type:TWMessageBarMessageTypeInfo];
+            
+        }
         
     } else {