Browse Source

remove netQueueUploadCamera

Marino Faggiana 8 years ago
parent
commit
23cd47e955

+ 2 - 3
iOSClient/AppDelegate.h

@@ -89,9 +89,8 @@
 @property (nonatomic, strong) NSOperationQueue *netQueueDownloadWWan;
 @property (nonatomic, strong) NSOperationQueue *netQueueDownloadWWan;
 @property (nonatomic, strong) NSOperationQueue *netQueueUpload;
 @property (nonatomic, strong) NSOperationQueue *netQueueUpload;
 @property (nonatomic, strong) NSOperationQueue *netQueueUploadWWan;
 @property (nonatomic, strong) NSOperationQueue *netQueueUploadWWan;
-@property (nonatomic, strong) NSOperationQueue *netQueueUploadCamera;
 
 
-@property NSUInteger queueNunDownload, queueNumDownloadWWan, queueNumUpload, queueNumUploadWWan, queueNumUploadCamera;
+@property NSUInteger queueNunDownload, queueNumDownloadWWan, queueNumUpload, queueNumUploadWWan;
 
 
 // Networking 
 // Networking 
 @property (nonatomic, copy) void (^backgroundSessionCompletionHandler)(void);
 @property (nonatomic, copy) void (^backgroundSessionCompletionHandler)(void);
@@ -182,7 +181,7 @@
 // Operation Networking
 // Operation Networking
 - (void)cancelAllOperations;
 - (void)cancelAllOperations;
 - (void)addNetworkingOperationQueue:(NSOperationQueue *)netQueue delegate:(id)delegate metadataNet:(CCMetadataNet *)metadataNet oneByOne:(BOOL)oneByOne;
 - (void)addNetworkingOperationQueue:(NSOperationQueue *)netQueue delegate:(id)delegate metadataNet:(CCMetadataNet *)metadataNet oneByOne:(BOOL)oneByOne;
-- (void)loadTableAutomaticUploadForSelector:(NSString *)selector numeRecors:(NSUInteger)numRecords;
+- (void)loadTableAutomaticUploadForSelector:(NSString *)selector;
 - (BOOL)verifyExistsFileName:(NSString *)fileName withSelector:(NSString *)selector inOperationsQueue:(NSOperationQueue *)queue;
 - (BOOL)verifyExistsFileName:(NSString *)fileName withSelector:(NSString *)selector inOperationsQueue:(NSOperationQueue *)queue;
 
 
 - (void)dropAutomaticUploadWithSelector:(NSString *)selector;
 - (void)dropAutomaticUploadWithSelector:(NSString *)selector;

+ 16 - 30
iOSClient/AppDelegate.m

@@ -127,10 +127,6 @@
     _netQueueUploadWWan.name = netQueueUploadWWanName;
     _netQueueUploadWWan.name = netQueueUploadWWanName;
     _netQueueUploadWWan.maxConcurrentOperationCount = maxConcurrentOperationDownloadUpload;
     _netQueueUploadWWan.maxConcurrentOperationCount = maxConcurrentOperationDownloadUpload;
     
     
-    _netQueueUploadCamera = [[NSOperationQueue alloc] init];
-    _netQueueUploadCamera.name = netQueueUploadCameraName;
-    _netQueueUploadCamera.maxConcurrentOperationCount = maxConcurrentOperationUploadCamera;
-    
 #ifdef CC
 #ifdef CC
     // Inizialize DBSession for Dropbox
     // Inizialize DBSession for Dropbox
     NSString *appKey = appKeyCryptoCloud;
     NSString *appKey = appKeyCryptoCloud;
@@ -683,9 +679,7 @@
     
     
     _queueNumUpload = [[CCCoreData getTableMetadataUploadAccount:self.activeAccount] count];
     _queueNumUpload = [[CCCoreData getTableMetadataUploadAccount:self.activeAccount] count];
     _queueNumUploadWWan = [[CCCoreData getTableMetadataUploadWWanAccount:self.activeAccount] count];
     _queueNumUploadWWan = [[CCCoreData getTableMetadataUploadWWanAccount:self.activeAccount] count];
-    
-    _queueNumUploadCamera = 0;
-    
+        
     // Clear list folder in Synchronization
     // Clear list folder in Synchronization
     [self.listFolderSynchronization removeAllObjects];
     [self.listFolderSynchronization removeAllObjects];
         
         
@@ -777,25 +771,8 @@
 #endif
 #endif
      }
      }
 
 
-    // netQueueUploadCameraAllPhoto
-    for (NSOperation *operation in [app.netQueueUploadCamera operations]) {
-        
-        /*** NEXTCLOUD OWNCLOUD ***/
-        
-        if ([app.typeCloud isEqualToString:typeCloudOwnCloud] || [app.typeCloud isEqualToString:typeCloudNextcloud])
-            if (((OCnetworking *)operation).isExecuting == NO) _queueNumUploadCamera++;
-        
-#ifdef CC
-        
-        /*** DROPBOX ***/
-        
-        if ([app.typeCloud isEqualToString:typeCloudDropbox])
-            if (((DBnetworking *)operation).isExecuting == NO) _queueNumUploadCameraAllPhoto++;
-#endif
-    }
-
     // Total
     // Total
-    NSUInteger total = _queueNunDownload + _queueNumDownloadWWan + _queueNumUpload + _queueNumUploadWWan + _queueNumUploadCamera;
+    NSUInteger total = _queueNunDownload + _queueNumDownloadWWan + _queueNumUpload + _queueNumUploadWWan + [CCCoreData countTableAutomaticUploadForAccount:self.activeAccount];
     
     
     [UIApplication sharedApplication].applicationIconBadgeNumber = total;
     [UIApplication sharedApplication].applicationIconBadgeNumber = total;
     
     
@@ -1019,7 +996,6 @@
     [_netQueueDownloadWWan cancelAllOperations];
     [_netQueueDownloadWWan cancelAllOperations];
     [_netQueueUpload cancelAllOperations];
     [_netQueueUpload cancelAllOperations];
     [_netQueueUploadWWan cancelAllOperations];
     [_netQueueUploadWWan cancelAllOperations];
-    [_netQueueUploadCamera cancelAllOperations];
     
     
     [self performSelector:@selector(updateApplicationIconBadgeNumber) withObject:nil afterDelay:0.5];
     [self performSelector:@selector(updateApplicationIconBadgeNumber) withObject:nil afterDelay:0.5];
 }
 }
@@ -1094,14 +1070,24 @@
     return NO;
     return NO;
 }
 }
 
 
-- (void)loadTableAutomaticUploadForSelector:(NSString *)selector numeRecors:(NSUInteger)numRecords
+- (void)loadTableAutomaticUploadForSelector:(NSString *)selector
 {
 {
-    NSArray *metadatasNet = [CCCoreData getTableUploadFromAccount:self.activeAccount selector:selector numRecords:numRecords context:nil];
+    NSUInteger numRecords = 1;
+    NSArray *metadatasNet = [CCCoreData getTableAutomaticUploadForAccount:self.activeAccount selector:selector numRecords:numRecords context:nil];
     
     
     // Add Network queue
     // Add Network queue
 
 
-    for (CCMetadataNet *metadataNet in metadatasNet)
-        [self addNetworkingOperationQueue:self.netQueueUploadCamera delegate:app.activeMain metadataNet:metadataNet oneByOne:YES];
+    for (CCMetadataNet *metadataNet in metadatasNet) {
+        
+        NSOperationQueue *queue;
+        
+        if ([metadataNet.session containsString:@"wwan"])
+            queue = app.netQueueUploadWWan;
+        else
+            queue = app.netQueueUpload;
+        
+        [self addNetworkingOperationQueue:queue delegate:app.activeMain metadataNet:metadataNet oneByOne:YES];
+    }
 }
 }
 
 
 - (void)verifyDownloadUploadInProgress
 - (void)verifyDownloadUploadInProgress

+ 0 - 2
iOSClient/CCGlobal.h

@@ -193,11 +193,9 @@ extern NSString *const BKPasscodeKeychainServiceName;
 #define netQueueDownloadWWanName        @"it.twsweb.cryptocloud.queueDownloadWWan"
 #define netQueueDownloadWWanName        @"it.twsweb.cryptocloud.queueDownloadWWan"
 #define netQueueUploadName              @"it.twsweb.cryptocloud.queueUpload"
 #define netQueueUploadName              @"it.twsweb.cryptocloud.queueUpload"
 #define netQueueUploadWWanName          @"it.twsweb.cryptocloud.queueUploadWWan"
 #define netQueueUploadWWanName          @"it.twsweb.cryptocloud.queueUploadWWan"
-#define netQueueUploadCameraName        @"it.twsweb.cryptocloud.queueUploadCamera"
 
 
 #define maxConcurrentOperation 10
 #define maxConcurrentOperation 10
 #define maxConcurrentOperationDownloadUpload 10
 #define maxConcurrentOperationDownloadUpload 10
-#define maxConcurrentOperationUploadCamera 1
 
 
 // Error
 // Error
 #define CCErrorTaskNil -9999
 #define CCErrorTaskNil -9999

+ 4 - 2
iOSClient/FileSystem/CCCoreData.h

@@ -178,8 +178,10 @@
 
 
 // ===== Upload =====
 // ===== Upload =====
 
 
-+ (void)addUpload:(CCMetadataNet *)metadataNet activeAccount:(NSString *)activeAccount context:(NSManagedObjectContext *)context;
-+ (NSArray *)getTableUploadFromAccount:(NSString *)activeAccount selector:(NSString *)selector numRecords:(NSUInteger)numRecords context:(NSManagedObjectContext *)context;
++ (void)addTableAutomaticUpload:(CCMetadataNet *)metadataNet activeAccount:(NSString *)activeAccount context:(NSManagedObjectContext *)context;
++ (NSArray *)getTableAutomaticUploadForAccount:(NSString *)activeAccount selector:(NSString *)selector numRecords:(NSUInteger)numRecords context:(NSManagedObjectContext *)context;
++ (NSUInteger)countTableAutomaticUploadForAccount:(NSString *)activeAccount;
++ (void)deleteTableAutomaticUploadFromAccount:(NSString *)activeAccount fileName:(NSString *)fileName serverUrl:(NSString *)serverUrl selector:(NSString*)selector context:(NSManagedObjectContext *)context;
 
 
 // ===== GPS =====
 // ===== GPS =====
 
 

+ 20 - 2
iOSClient/FileSystem/CCCoreData.m

@@ -1473,7 +1473,7 @@
 #pragma mark ===== Upload =====
 #pragma mark ===== Upload =====
 #pragma --------------------------------------------------------------------------------------------
 #pragma --------------------------------------------------------------------------------------------
 
 
-+ (void)addUpload:(CCMetadataNet *)metadataNet activeAccount:(NSString *)activeAccount context:(NSManagedObjectContext *)context
++ (void)addTableAutomaticUpload:(CCMetadataNet *)metadataNet activeAccount:(NSString *)activeAccount context:(NSManagedObjectContext *)context
 {
 {
     TableAutomaticUpload *record;
     TableAutomaticUpload *record;
     
     
@@ -1502,7 +1502,7 @@
     }
     }
 }
 }
 
 
-+ (NSArray *)getTableUploadFromAccount:(NSString *)activeAccount selector:(NSString *)selector numRecords:(NSUInteger)numRecords context:(NSManagedObjectContext *)context
++ (NSArray *)getTableAutomaticUploadForAccount:(NSString *)activeAccount selector:(NSString *)selector numRecords:(NSUInteger)numRecords context:(NSManagedObjectContext *)context
 {
 {
     if (numRecords == 0)
     if (numRecords == 0)
         return nil;
         return nil;
@@ -1538,6 +1538,24 @@
     return metadatasNet;
     return metadatasNet;
 }
 }
 
 
++ (NSUInteger)countTableAutomaticUploadForAccount:(NSString *)activeAccount
+{
+    NSUInteger count = [TableAutomaticUpload MR_countOfEntitiesWithPredicate:[NSPredicate predicateWithFormat:@"(account == %@) AND (startUpload == 0)", activeAccount]];
+    
+    return count;
+}
+
++ (void)deleteTableAutomaticUploadFromAccount:(NSString *)activeAccount fileName:(NSString *)fileName serverUrl:(NSString *)serverUrl selector:(NSString*)selector context:(NSManagedObjectContext *)context
+{
+    if (context == nil)
+        context = [NSManagedObjectContext MR_context];
+    
+    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@) AND (fileName == %@) AND (serverUrl == %@)", activeAccount, fileName, serverUrl];
+    [TableAutomaticUpload MR_deleteAllMatchingPredicate:predicate inContext:context];
+    
+    [context MR_saveToPersistentStoreAndWait];
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== GPS =====
 #pragma mark ===== GPS =====
 #pragma --------------------------------------------------------------------------------------------
 #pragma --------------------------------------------------------------------------------------------

+ 10 - 1
iOSClient/Main/CCMain.m

@@ -1406,6 +1406,15 @@
 
 
 - (void)uploadFileSuccess:(NSString *)fileID serverUrl:(NSString *)serverUrl selector:(NSString *)selector selectorPost:(NSString *)selectorPost
 - (void)uploadFileSuccess:(NSString *)fileID serverUrl:(NSString *)serverUrl selector:(NSString *)selector selectorPost:(NSString *)selectorPost
 {
 {
+    CCMetadata *metadata = [CCCoreData getMetadataWithPreficate:[NSPredicate predicateWithFormat:@"(fileID == %@) AND (account == %@)", fileID, app.activeAccount] context:nil];
+    
+    // Automatic upload
+    if([selector isEqualToString:selectorUploadCameraSnapshot] || [selector isEqualToString:selectorUploadCameraAllPhoto]) {
+        
+        [CCCoreData deleteTableAutomaticUploadFromAccount:app.activeAccount fileName:metadata.fileNamePrint serverUrl:serverUrl selector:selector context:nil];
+        [app loadTableAutomaticUploadForSelector:selector];
+    }
+    
     if ([selectorPost isEqualToString:selectorReadFolderForced] ) {
     if ([selectorPost isEqualToString:selectorReadFolderForced] ) {
             
             
         [self readFolderWithForced:YES];
         [self readFolderWithForced:YES];
@@ -3182,7 +3191,7 @@
     if (app.reSelectMenu.isOpen || app.reMainMenu.isOpen)
     if (app.reSelectMenu.isOpen || app.reMainMenu.isOpen)
         return;
         return;
     
     
-    if ([app.netQueue operationCount] > 0 || [app.netQueueDownload operationCount] > 0 || [app.netQueueDownloadWWan operationCount] > 0 || [app.netQueueUpload operationCount] > 0 || [app.netQueueUploadWWan operationCount] > 0 || [app.netQueueUploadCamera operationCount] > 0) {
+    if ([app.netQueue operationCount] > 0 || [app.netQueueDownload operationCount] > 0 || [app.netQueueDownloadWWan operationCount] > 0 || [app.netQueueUpload operationCount] > 0 || [app.netQueueUploadWWan operationCount] > 0 || [CCCoreData countTableAutomaticUploadForAccount:app.activeAccount] > 0) {
         
         
         [app messageNotification:@"_transfers_in_queue_" description:nil visible:YES delay:dismissAfterSecond type:TWMessageBarMessageTypeInfo];
         [app messageNotification:@"_transfers_in_queue_" description:nil visible:YES delay:dismissAfterSecond type:TWMessageBarMessageTypeInfo];
         return;
         return;

+ 3 - 12
iOSClient/PhotosCameraUpload/CCPhotosCameraUpload.m

@@ -1209,7 +1209,6 @@
         PHAssetMediaType assetMediaType = asset.mediaType;
         PHAssetMediaType assetMediaType = asset.mediaType;
         NSString *session;
         NSString *session;
         NSString *fileNameUpload = [CCUtility createFileNameFromAsset:asset];
         NSString *fileNameUpload = [CCUtility createFileNameFromAsset:asset];
-        NSOperationQueue *queue;
         
         
         // Select type of session
         // Select type of session
         if (assetsFull) {
         if (assetsFull) {
@@ -1252,22 +1251,14 @@
         metadataNet.session = session;
         metadataNet.session = session;
         metadataNet.taskStatus = taskStatusResume;
         metadataNet.taskStatus = taskStatusResume;
         
         
-        // Select type of queue
-        if (assetsFull)
-            queue = app.netQueueUploadCamera;
-        else if ([session containsString:@"wwan"])
-            queue = app.netQueueUploadWWan;
-        else
-            queue = app.netQueueUpload;
-        
-        [CCCoreData addUpload:metadataNet activeAccount:app.activeAccount context:nil];
+        [CCCoreData addTableAutomaticUpload:metadataNet activeAccount:app.activeAccount context:nil];
     }
     }
     
     
     // start upload
     // start upload
     if (assetsFull)
     if (assetsFull)
-        [app loadTableAutomaticUploadForSelector:selectorUploadCameraAllPhoto numeRecors:(maxConcurrentOperationUploadCamera - [app.netQueueUploadCamera operationCount])];
+        [app loadTableAutomaticUploadForSelector:selectorUploadCameraAllPhoto];
     else
     else
-        [app loadTableAutomaticUploadForSelector:selectorUploadCameraSnapshot numeRecors:(maxConcurrentOperationUploadCamera - [app.netQueueUploadCamera operationCount])];
+        [app loadTableAutomaticUploadForSelector:selectorUploadCameraSnapshot];
 
 
     // end loading
     // end loading
     [self endLoadingAssets];
     [self endLoadingAssets];

+ 1 - 1
iOSClient/Settings/CCManageAccount.m

@@ -326,7 +326,7 @@
 
 
 - (void)ChangeDefaultAccount:(NSString *)account
 - (void)ChangeDefaultAccount:(NSString *)account
 {
 {
-    if ([app.netQueue operationCount] > 0 || [app.netQueueDownload operationCount] > 0 || [app.netQueueDownloadWWan operationCount] > 0 || [app.netQueueUpload operationCount] > 0 || [app.netQueueUploadWWan operationCount] > 0 || [app.netQueueUploadCamera operationCount] > 0) {
+    if ([app.netQueue operationCount] > 0 || [app.netQueueDownload operationCount] > 0 || [app.netQueueDownloadWWan operationCount] > 0 || [app.netQueueUpload operationCount] > 0 || [app.netQueueUploadWWan operationCount] > 0 || [CCCoreData countTableAutomaticUploadForAccount:app.activeAccount] > 0) {
         
         
         [app messageNotification:@"_transfers_in_queue_" description:nil visible:YES delay:dismissAfterSecond type:TWMessageBarMessageTypeInfo];
         [app messageNotification:@"_transfers_in_queue_" description:nil visible:YES delay:dismissAfterSecond type:TWMessageBarMessageTypeInfo];
         [self UpdateForm];
         [self UpdateForm];