Răsfoiți Sursa

modify general call for external service

Marino Faggiana 7 ani în urmă
părinte
comite
fb3a7eb1e1
3 a modificat fișierele cu 41 adăugiri și 51 ștergeri
  1. 0 3
      iOSClient/AppDelegate.h
  2. 19 41
      iOSClient/AppDelegate.m
  3. 22 7
      iOSClient/Main/CCMain.m

+ 0 - 3
iOSClient/AppDelegate.h

@@ -131,9 +131,6 @@
 // Setting Active Account
 - (void)settingActiveAccount:(NSString *)activeAccount activeUrl:(NSString *)activeUrl activeUser:(NSString *)activeUser activeUserID:(NSString *)activeUserID activePassword:(NSString *)activePassword;
 
-// initializations 
-- (void)applicationInitialized;
-
 // Quick Actions - ShotcutItem
 - (void)configDynamicShortcutItems;
 - (BOOL)handleShortCutItem:(UIApplicationShortcutItem *)shortcutItem;

+ 19 - 41
iOSClient/AppDelegate.m

@@ -242,8 +242,15 @@
 //
 - (void)applicationWillEnterForeground:(UIApplication *)application
 {
-    // Initializations
-    [self applicationInitialized];
+    // Test Maintenance
+    if (self.activeAccount.length == 0 || self.maintenanceMode)
+        return;
+    
+    NSLog(@"[LOG] Request Server Capabilities");
+    [_activeMain requestServerCapabilities];
+    
+    NSLog(@"[LOG] Initialize Auto upload");
+    [[NCAutoUpload sharedInstance] initStateAutoUpload];    
 }
 
 //
@@ -251,7 +258,12 @@
 //
 - (void)applicationDidBecomeActive:(UIApplication *)application
 {
-   
+    // Test Maintenance
+    if (self.activeAccount.length == 0 || self.maintenanceMode)
+        return;
+    
+    // verify Upload
+    [self verifyUploadInErrorOrWait];
 }
 
 //
@@ -286,44 +298,6 @@
     NSLog(@"[LOG] bye bye, Nextcloud !");
 }
 
-//
-// Application Initialized
-//
-// Callers :
-//
-// CCMain : initializeMain
-// appDelegate : applicationWillEnterForeground
-//
-- (void)applicationInitialized
-{
-    // Test Maintenance
-    if (self.maintenanceMode)
-        return;
-
-    // verify Upload
-    [self verifyUploadInErrorOrWait];
-
-    NSLog(@"[LOG] Request Server Capabilities");
-    [_activeMain requestServerCapabilities];
-    
-    NSLog(@"[LOG] Refresh Active Main");
-    [_activeMain readFileReloadFolder];
-    
-    if ([[NCBrandOptions sharedInstance] use_middlewarePing]) {
-        NSLog(@"[LOG] Middleware Ping");
-        [_activeMain middlewarePing];
-    }
-        
-    NSLog(@"[LOG] Initialize Auto upload");
-    [[NCAutoUpload sharedInstance] initStateAutoUpload];
-    
-    NSLog(@"[LOG] Update contenttype image for Photos Tab");
-    [_activePhotos readPhotoVideo];
-    
-    NSLog(@"[LOG] Listning Favorites");
-    [_activeFavorites readListingFavorites];
-}
-
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Login =====
 #pragma --------------------------------------------------------------------------------------------
@@ -1538,6 +1512,10 @@
 
 - (void)verifyUploadInErrorOrWait
 {
+    // Test Maintenance
+    if (self.maintenanceMode || self.activeAccount.length == 0)
+        return;
+    
     NSMutableSet *directoryIDs = [NSMutableSet new];
     
     NSArray *metadatas = [[NCManageDatabase sharedInstance] getMetadatasWithPredicate:[NSPredicate predicateWithFormat:@"account = %@ AND session CONTAINS 'upload' AND (sessionTaskIdentifier = %i OR sessionTaskIdentifier = %i)", _activeAccount, k_taskIdentifierError, k_taskIdentifierWaitStart] sorted:nil ascending:NO];

+ 22 - 7
iOSClient/Main/CCMain.m

@@ -381,21 +381,25 @@
         // Load photo datasorce
         [appDelegate.activePhotos reloadDatasource];
         
+        // Read this folder
+        [self readFileReloadFolder];
+
         // remove all of detail
         [appDelegate.activeDetail removeAllView];
         
         // remove all Notification Messages
         [appDelegate.listOfNotifications removeAllObjects];
         
-        // Not Photos Video in library ? then align
+        // Not Photos Video in library ? then align and Init Auto Upload
         NSArray *recordsPhotoLibrary = [[NCManageDatabase sharedInstance] getPhotoLibraryWithPredicate:[NSPredicate predicateWithFormat:@"account = %@", appDelegate.activeAccount]];
         if ([recordsPhotoLibrary count] == 0) {
             [[NCAutoUpload sharedInstance] alignPhotoLibrary];
         }
+        [[NCAutoUpload sharedInstance] initStateAutoUpload];
+        
+        NSLog(@"[LOG] Request Server Capabilities");
+        [self requestServerCapabilities];
         
-        // Initializations
-        [appDelegate applicationInitialized];
-                
     } else {
         
         // reload datasource
@@ -1137,6 +1141,10 @@
         [appDelegate messageNotification:@"Account" description:@"Internal error : account not found" visible:true delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:0];
     }
 
+    // Required userd ID (search + favorite)
+    [appDelegate.activePhotos readPhotoVideo];    
+    [appDelegate.activeFavorites readListingFavorites];
+    
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
         
         NSString *address = [NSString stringWithFormat:@"%@/index.php/avatar/%@/128", appDelegate.activeUrl, appDelegate.activeUser];
@@ -1207,7 +1215,7 @@
         });
     });
 
-    // ------ SEARCH  ------------------------------------------------------------------------
+    // ------ SEARCH  -----------------------------------------------------------------------
     
     // Search bar if change version
     if ([[NCManageDatabase sharedInstance] getServerVersion] != capabilities.versionMajor) {
@@ -1215,6 +1223,13 @@
         [self cancelSearchBar];
     }
     
+    // ------ MIDDLEWARE PING ---------------------------------------------------------------
+    
+    if ([[NCBrandOptions sharedInstance] use_middlewarePing]) {
+        NSLog(@"[LOG] Middleware Ping");
+        [self middlewarePing];
+    }
+    
     // ------ GET SERVICE SERVER ------------------------------------------------------------
     
     // Read User Profile
@@ -1253,7 +1268,7 @@
 - (void)requestServerCapabilities
 {
     // test
-    if (appDelegate.activeAccount.length == 0)
+    if (appDelegate.activeAccount.length == 0 || appDelegate.maintenanceMode)
         return;
     
     CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:appDelegate.activeAccount];
@@ -1270,7 +1285,7 @@
 - (void)middlewarePing
 {
     // test
-    if (appDelegate.activeAccount.length == 0)
+    if (appDelegate.activeAccount.length == 0 || appDelegate.maintenanceMode)
         return;
     
     CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:appDelegate.activeAccount];