浏览代码

new counter queue

Marino Faggiana 8 年之前
父节点
当前提交
ccac133a2d
共有 4 个文件被更改,包括 46 次插入41 次删除
  1. 1 1
      Nextcloud.xcodeproj/project.pbxproj
  2. 5 2
      iOSClient/AppDelegate.h
  3. 20 28
      iOSClient/AppDelegate.m
  4. 20 10
      iOSClient/Transfers/CCTransfers.m

+ 1 - 1
Nextcloud.xcodeproj/project.pbxproj

@@ -3295,8 +3295,8 @@
 			isa = PBXGroup;
 			children = (
 				F7C742D31E7BD36600D9C973 /* Supporting Files */,
-				F76B3CCD1EAE01BD00921AC9 /* NCBrand.swift */,
 				F700222B1EC479840080073F /* Custom.xcassets */,
+				F76B3CCD1EAE01BD00921AC9 /* NCBrand.swift */,
 			);
 			path = Brand;
 			sourceTree = "<group>";

+ 5 - 2
iOSClient/AppDelegate.h

@@ -74,8 +74,6 @@
 @property (nonatomic, strong) NSOperationQueue *netQueueUpload;
 @property (nonatomic, strong) NSOperationQueue *netQueueUploadWWan;
 
-@property NSUInteger queueNunDownload, queueNumDownloadWWan, queueNumUpload, queueNumUploadWWan;
-
 // Networking 
 @property (nonatomic, copy) void (^backgroundSessionCompletionHandler)(void);
 @property (nonatomic, strong) NSDate *sessionDateLastUploadTasks;
@@ -169,5 +167,10 @@
 
 - (BOOL)createFolderSubFolderAutomaticUploadFolderPhotos:(NSString *)folderPhotos useSubFolder:(BOOL)useSubFolder assets:(NSArray *)assets selector:(NSString *)selector;
 
+- (NSInteger)getNumberDownloadInQueues;
+- (NSInteger)getNumberDownloadInQueuesWWan;
+- (NSInteger)getNumberUploadInQueues;
+- (NSInteger)getNumberUploadInQueuesWWan;
+
 @end
 

+ 20 - 28
iOSClient/AppDelegate.m

@@ -932,31 +932,11 @@
 
 - (void)updateApplicationIconBadgeNumber
 {
-    // Core Data
-    _queueNunDownload = [[CCCoreData getTableMetadataDownloadAccount:self.activeAccount] count];
-    _queueNumDownloadWWan = [[CCCoreData getTableMetadataDownloadWWanAccount:self.activeAccount] count];
+    NSInteger queueDownload = [self getNumberDownloadInQueues] + [self getNumberDownloadInQueuesWWan];
+    NSInteger queueUpload = [self getNumberUploadInQueues] + [self getNumberUploadInQueuesWWan];
     
-    _queueNumUpload = [[CCCoreData getTableMetadataUploadAccount:self.activeAccount] count];
-    _queueNumUploadWWan = [[CCCoreData getTableMetadataUploadWWanAccount:self.activeAccount] count];
-    
-    // netQueueDownload
-    for (NSOperation *operation in [app.netQueueDownload operations])
-        if (((OCnetworking *)operation).isExecuting == NO) _queueNunDownload++;
-    
-    // netQueueDownloadWWan
-    for (NSOperation *operation in [app.netQueueDownloadWWan operations])
-        if (((OCnetworking *)operation).isExecuting == NO) _queueNumDownloadWWan++;
-    
-    // netQueueUpload
-    for (NSOperation *operation in [app.netQueueUpload operations])
-        if (((OCnetworking *)operation).isExecuting == NO) _queueNumUpload++;
-
-    // netQueueUploadWWan
-    for (NSOperation *operation in [app.netQueueUploadWWan operations])
-        if (((OCnetworking *)operation).isExecuting == NO) _queueNumUploadWWan++;
-
     // Total
-    NSUInteger total = _queueNunDownload + _queueNumDownloadWWan + _queueNumUpload + _queueNumUploadWWan + [[NCManageDatabase sharedInstance] countAutomaticUploadForAccount:app.activeAccount selector:nil];
+    NSInteger total = queueDownload + queueUpload + [[NCManageDatabase sharedInstance] countAutomaticUploadForAccount:app.activeAccount selector:nil];
     
     [UIApplication sharedApplication].applicationIconBadgeNumber = total;
     
@@ -1286,33 +1266,45 @@
 - (NSInteger)getNumberDownloadInQueues
 {
     NSInteger queueNunDownload = [[CCCoreData getTableMetadataDownloadAccount:self.activeAccount] count];
-    NSInteger queueNumDownloadWWan = [[CCCoreData getTableMetadataDownloadWWanAccount:self.activeAccount] count];
     
     // netQueueDownload
     for (NSOperation *operation in [app.netQueueDownload operations])
         if (((OCnetworking *)operation).isExecuting == NO) queueNunDownload++;
     
+    return queueNunDownload;
+}
+
+- (NSInteger)getNumberDownloadInQueuesWWan
+{
+    NSInteger queueNumDownloadWWan = [[CCCoreData getTableMetadataDownloadWWanAccount:self.activeAccount] count];
+    
     // netQueueDownloadWWan
     for (NSOperation *operation in [app.netQueueDownloadWWan operations])
         if (((OCnetworking *)operation).isExecuting == NO) queueNumDownloadWWan++;
     
-    return queueNunDownload + queueNumDownloadWWan;
+    return queueNumDownloadWWan;
 }
 
 - (NSInteger)getNumberUploadInQueues
 {
     NSInteger queueNumUpload = [[CCCoreData getTableMetadataUploadAccount:self.activeAccount] count];
-    NSInteger queueNumUploadWWan = [[CCCoreData getTableMetadataUploadWWanAccount:self.activeAccount] count];
     
     // netQueueUpload
     for (NSOperation *operation in [app.netQueueUpload operations])
         if (((OCnetworking *)operation).isExecuting == NO) queueNumUpload++;
     
+    return queueNumUpload;
+}
+
+- (NSInteger)getNumberUploadInQueuesWWan
+{
+    NSInteger queueNumUploadWWan = [[CCCoreData getTableMetadataUploadWWanAccount:self.activeAccount] count];
+    
     // netQueueUploadWWan
     for (NSOperation *operation in [app.netQueueUploadWWan operations])
         if (((OCnetworking *)operation).isExecuting == NO) queueNumUploadWWan++;
     
-    return queueNumUpload + queueNumUploadWWan;
+    return queueNumUploadWWan;
 }
 
 - (void)loadAutomaticUpload
@@ -1346,7 +1338,7 @@
     // ------------------------- <selectorUploadAutomatic> -------------------------
     
     metadataNet = [[NCManageDatabase sharedInstance] getAutomaticUploadForAccount:self.activeAccount selector:selectorUploadAutomatic];
-    counterUpload = [self getNumberUploadInQueues];
+    counterUpload = [self getNumberUploadInQueues] + [self getNumberUploadInQueuesWWan];
     while (metadataNet && counterUpload < k_maxConcurrentOperationDownloadUpload) {
         
         [[CCNetworking sharedNetworking] uploadFileFromAssetLocalIdentifier:metadataNet.assetLocalIdentifier fileName:metadataNet.fileName serverUrl:metadataNet.serverUrl cryptated:metadataNet.cryptated session:metadataNet.session taskStatus:metadataNet.taskStatus selector:metadataNet.selector selectorPost:metadataNet.selectorPost errorCode:metadataNet.errorCode delegate:app.activeMain];

+ 20 - 10
iOSClient/Transfers/CCTransfers.m

@@ -341,6 +341,11 @@
     NSString *titleSection, *numberTitle;
     NSInteger typeOfSession = 0;
     
+    NSInteger queueDownload = [app getNumberDownloadInQueues];
+    NSInteger queueDownloadWWan = [app getNumberDownloadInQueuesWWan];
+    NSInteger queueUpload = [app getNumberUploadInQueues];
+    NSInteger queueUploadWWan = [app getNumberUploadInQueuesWWan];
+    
     if ([[_sectionDataSource.sections objectAtIndex:section] isKindOfClass:[NSString class]]) titleSection = [_sectionDataSource.sections objectAtIndex:section];
     if ([[_sectionDataSource.sections objectAtIndex:section] isKindOfClass:[NSDate class]]) titleSection = [CCUtility getTitleSectionDate:[_sectionDataSource.sections objectAtIndex:section]];
     
@@ -385,8 +390,8 @@
     elementLabel.textAlignment = NSTextAlignmentRight;
     elementLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
     
-    if ((typeOfSession == download && app.queueNunDownload > rowsCount) || (typeOfSession == downloadwwan && app.queueNumDownloadWWan > rowsCount) ||
-        (typeOfSession == upload   && app.queueNumUpload > rowsCount)   || (typeOfSession == uploadwwan && app.queueNumUploadWWan > rowsCount)) {
+    if ((typeOfSession == download && queueDownload > rowsCount) || (typeOfSession == downloadwwan && queueDownloadWWan > rowsCount) ||
+        (typeOfSession == upload   && queueUpload > rowsCount)   || (typeOfSession == uploadwwan && queueUploadWWan > rowsCount)) {
         numberTitle = [NSString stringWithFormat:@"%lu+", (unsigned long)rowsCount];
     } else {
         numberTitle = [NSString stringWithFormat:@"%lu", (unsigned long)rowsCount];
@@ -408,6 +413,11 @@
     NSString *titleSection;
     NSString *element_s;
     
+    NSInteger queueDownload = [app getNumberDownloadInQueues];
+    NSInteger queueDownloadWWan = [app getNumberDownloadInQueuesWWan];
+    NSInteger queueUpload = [app getNumberUploadInQueues];
+    NSInteger queueUploadWWan = [app getNumberUploadInQueuesWWan];
+    
     if ([[_sectionDataSource.sections objectAtIndex:section] isKindOfClass:[NSString class]]) titleSection = [_sectionDataSource.sections objectAtIndex:section];
     
     // Prepare view for title in footer
@@ -422,11 +432,11 @@
     if ([titleSection containsString:@"download"] && ![titleSection containsString:@"wwan"] && titleSection != nil) {
         
         // element or elements ?
-        if (app.queueNunDownload > 1) element_s = NSLocalizedString(@"_elements_",nil);
+        if (queueDownload > 1) element_s = NSLocalizedString(@"_elements_",nil);
         else element_s = NSLocalizedString(@"_element_",nil);
         
         // Num record to upload
-        NSMutableAttributedString *stringFooter= [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:NSLocalizedString(@"_tite_footer_download_", nil), app.queueNunDownload, element_s]];
+        NSMutableAttributedString *stringFooter= [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:NSLocalizedString(@"_tite_footer_download_", nil), queueDownload, element_s]];
         titleFooterLabel.attributedText = stringFooter;
         
         [view addSubview:titleFooterLabel];
@@ -437,14 +447,14 @@
     if ([titleSection containsString:@"download"] && [titleSection containsString:@"wwan"] && titleSection != nil) {
         
         // element or elements ?
-        if (app.queueNumDownloadWWan > 1) element_s = NSLocalizedString(@"_elements_",nil);
+        if (queueDownloadWWan > 1) element_s = NSLocalizedString(@"_elements_",nil);
         else element_s = NSLocalizedString(@"_element_",nil);
         
         // Add the symbol WiFi and Num record
         NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
         attachment.image = [UIImage imageNamed:@"WiFiSmall"];
         NSAttributedString *attachmentString = [NSAttributedString attributedStringWithAttachment:attachment];
-        NSMutableAttributedString *stringFooter= [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:NSLocalizedString(@"_tite_footer_download_wwan_", nil), app.queueNumDownloadWWan, element_s]];
+        NSMutableAttributedString *stringFooter= [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:NSLocalizedString(@"_tite_footer_download_wwan_", nil), queueDownloadWWan, element_s]];
         [stringFooter insertAttributedString:attachmentString atIndex:0];
         titleFooterLabel.attributedText = stringFooter;
         
@@ -456,11 +466,11 @@
     if ([titleSection containsString:@"upload"] && ![titleSection containsString:@"wwan"] && titleSection != nil) {
         
         // element or elements ?
-        if (app.queueNumUpload > 1) element_s = NSLocalizedString(@"_elements_",nil);
+        if (queueUpload > 1) element_s = NSLocalizedString(@"_elements_",nil);
         else element_s = NSLocalizedString(@"_element_",nil);
         
         // Num record to upload
-        NSMutableAttributedString *stringFooter= [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:NSLocalizedString(@"_tite_footer_upload_", nil), app.queueNumUpload, element_s]];
+        NSMutableAttributedString *stringFooter= [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:NSLocalizedString(@"_tite_footer_upload_", nil), queueUpload, element_s]];
         titleFooterLabel.attributedText = stringFooter;
         
         [view addSubview:titleFooterLabel];
@@ -471,14 +481,14 @@
     if ([titleSection containsString:@"upload"] && [titleSection containsString:@"wwan"] && titleSection != nil) {
         
         // element or elements ?
-        if (app.queueNumUploadWWan > 1) element_s = NSLocalizedString(@"_elements_",nil);
+        if (queueUploadWWan > 1) element_s = NSLocalizedString(@"_elements_",nil);
         else element_s = NSLocalizedString(@"_element_",nil);
         
         // Add the symbol WiFi and Num record
         NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
         attachment.image = [UIImage imageNamed:@"WiFiSmall"];
         NSAttributedString *attachmentString = [NSAttributedString attributedStringWithAttachment:attachment];
-        NSMutableAttributedString *stringFooter= [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:NSLocalizedString(@"_tite_footer_upload_wwan_", nil), app.queueNumUploadWWan,element_s]];
+        NSMutableAttributedString *stringFooter= [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:NSLocalizedString(@"_tite_footer_upload_wwan_", nil), queueUploadWWan,element_s]];
         [stringFooter insertAttributedString:attachmentString atIndex:0];
         titleFooterLabel.attributedText = stringFooter;