Browse Source

replace db

Marino Faggiana 8 years ago
parent
commit
8eed826220

+ 4 - 1
iOSClient/Favorites/CCFavorites.m

@@ -157,8 +157,11 @@
 
 - (void)documentInteractionControllerDidDismissOptionsMenu:(UIDocumentInteractionController *)controller
 {
+    tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountActive];
+    
     // evitiamo il rimando della eventuale photo e/o video
-    if ([CCCoreData getCameraUploadActiveAccount:app.activeAccount]) {
+    //if ([CCCoreData getCameraUploadActiveAccount:app.activeAccount]) {
+    if (tableAccount.cameraUpload) {
         
         [CCCoreData setCameraUploadDatePhoto:[NSDate date]];
         [CCCoreData setCameraUploadDateVideo:[NSDate date]];

+ 1 - 1
iOSClient/FileSystem/CCCoreData.h

@@ -59,7 +59,7 @@
 //+ (NSString *)getCameraUploadFolderPathActiveAccount:(NSString *)activeAccount activeUrl:(NSString *)activeUrl;
 //+ (NSString *)getCameraUploadFolderNamePathActiveAccount:(NSString *)activeAccount activeUrl:(NSString *)activeUrl;
 
-+ (BOOL)getCameraUploadActiveAccount:(NSString *)activeAccount;
+//+ (BOOL)getCameraUploadActiveAccount:(NSString *)activeAccount;
 + (BOOL)getCameraUploadBackgroundActiveAccount:(NSString *)activeAccount;
 + (BOOL)getCameraUploadCreateSubfolderActiveAccount:(NSString *)activeAccount;
 + (BOOL)getCameraUploadFullPhotosActiveAccount:(NSString *)activeAccount;

+ 2 - 2
iOSClient/FileSystem/CCCoreData.m

@@ -204,7 +204,7 @@
     NSString *folderPhotos = [CCUtility stringAppendServerUrl:cameraFolderPath addFileName:cameraFolderName];
     return folderPhotos;
 }
-*/
+
 + (BOOL)getCameraUploadActiveAccount:(NSString *)activeAccount
 {
     NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@)", activeAccount];
@@ -213,7 +213,7 @@
     if (record) return [record.cameraUpload boolValue];
     else return NO;
 }
-
+*/
 + (BOOL)getCameraUploadBackgroundActiveAccount:(NSString *)activeAccount
 {
     NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@)", activeAccount];

+ 4 - 1
iOSClient/Local storage/CCLocalStorage.m

@@ -150,8 +150,11 @@
 
 - (void)documentInteractionControllerDidDismissOptionsMenu:(UIDocumentInteractionController *)controller
 {
+    tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountActive];
+    
     // evitiamo il rimando della eventuale photo e/o video
-    if ([CCCoreData getCameraUploadActiveAccount:app.activeAccount]) {
+    //if ([CCCoreData getCameraUploadActiveAccount:app.activeAccount]) {
+    if (tableAccount.cameraUpload) {
         
         [CCCoreData setCameraUploadDatePhoto:[NSDate date]];
         [CCCoreData setCameraUploadDateVideo:[NSDate date]];

+ 6 - 1
iOSClient/Main/CCDetail.m

@@ -197,8 +197,13 @@
 
 - (void)documentInteractionControllerDidDismissOptionsMenu:(UIDocumentInteractionController *)controller
 {
+    tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountActive];
+    
     // evitiamo il rimando della eventuale photo e/o video
-    if ([CCCoreData getCameraUploadActiveAccount:app.activeAccount]) {
+    //if ([CCCoreData getCameraUploadActiveAccount:app.activeAccount]) {
+        
+    if (tableAccount.cameraUpload) {
+        
         
         [CCCoreData setCameraUploadDatePhoto:[NSDate date]];
         [CCCoreData setCameraUploadDateVideo:[NSDate date]];

+ 10 - 0
iOSClient/Main/CCMain.m

@@ -778,11 +778,21 @@
 - (void)documentInteractionControllerDidDismissOptionsMenu:(UIDocumentInteractionController *)controller
 {
     // evitiamo il rimando della eventuale photo e/o video
+    tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountActive];
+    if (tableAccount.cameraUpload) {
+        
+        [CCCoreData setCameraUploadDatePhoto:[NSDate date]];
+        [CCCoreData setCameraUploadDateVideo:[NSDate date]];
+
+    }
+    
+    /*
     if ([CCCoreData getCameraUploadActiveAccount:app.activeAccount]) {
         
         [CCCoreData setCameraUploadDatePhoto:[NSDate date]];
         [CCCoreData setCameraUploadDateVideo:[NSDate date]];
     }
+    */
 }
 
 #pragma --------------------------------------------------------------------------------------------

+ 9 - 3
iOSClient/ManageLocation+ManageAsset/CCManageAsset.m

@@ -22,8 +22,8 @@
 //
 
 #import "CCManageAsset.h"
-
 #import "AppDelegate.h"
+#import "NCBridgeSwift.h"
 
 @implementation CCManageAsset
 
@@ -38,8 +38,10 @@
 {
     self.assetsNewToUpload = [[NSMutableArray alloc] init];
     ALAssetsLibrary *assetLibrary = [CCUtility defaultAssetsLibrary];
+    tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountActive];
     
-    if ([CCCoreData getCameraUploadActiveAccount:app.activeAccount]) {
+    //if ([CCCoreData getCameraUploadActiveAccount:app.activeAccount]) {
+    if (tableAccount.cameraUpload) {
         
         dispatch_semaphore_t semaphoreGroup = dispatch_semaphore_create(0);
         
@@ -74,8 +76,12 @@
 
 - (NSMutableArray *)getArrayNewAssetsFromGroup:(ALAssetsGroup *)group datePhoto:(NSDate *)datePhoto dateVideo:(NSDate *)dateVideo
 {
-    if (![CCCoreData getCameraUploadActiveAccount:app.activeAccount])
+    tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountActive];
+    if (!tableAccount.cameraUpload)
         return nil;
+
+   // if (![CCCoreData getCameraUploadActiveAccount:app.activeAccount])
+   //     return nil;
     
     NSMutableArray *tmpAssetsNew = [[NSMutableArray alloc] init];
     

+ 25 - 4
iOSClient/PhotosCameraUpload/CCPhotosCameraUpload.m

@@ -269,7 +269,11 @@
     paragraph.alignment = NSTextAlignmentCenter;
     NSString *text;
     
-    if ([CCCoreData getCameraUploadActiveAccount:app.activeAccount])
+    NSArray *results = [[NCManageDatabase sharedInstance] getAccounts:app.activeAccount];
+    tableAccount *account = [results objectAtIndex:0];
+    
+    //if ([CCCoreData getCameraUploadActiveAccount:app.activeAccount])
+    if (account.cameraUpload)
         text = [NSString stringWithFormat:@"%@", @"\n\n\n\n"];
     else
         text = [NSString stringWithFormat:@"\n%@\n", NSLocalizedString(@"_tutorial_camera_upload_view_", nil)];
@@ -281,7 +285,12 @@
 
 - (UIImage *)buttonImageForEmptyDataSet:(UIScrollView *)scrollView forState:(UIControlState)state
 {
-    if ([CCCoreData getCameraUploadActiveAccount:app.activeAccount] == NO) {
+    NSArray *results = [[NCManageDatabase sharedInstance] getAccounts:app.activeAccount];
+    tableAccount *account = [results objectAtIndex:0];
+    
+    //if ([CCCoreData getCameraUploadActiveAccount:app.activeAccount] == NO) {
+        
+    if (!account.cameraUpload) {
     
         UIImage *buttonImage = [CCGraphics changeThemingColorImage:[UIImage imageNamed:@"button"] color:[NCBrandColor sharedInstance].brand];
         
@@ -762,7 +771,13 @@
 
 - (void)initStateCameraUpload
 {
-    if([CCCoreData getCameraUploadActiveAccount:app.activeAccount]) {
+    NSArray *results = [[NCManageDatabase sharedInstance] getAccounts:app.activeAccount];
+    tableAccount *account = [results objectAtIndex:0];
+
+    
+   // if([CCCoreData getCameraUploadActiveAccount:app.activeAccount]) {
+    
+    if (account.cameraUpload) {
         
         [self setupCameraUpload];
         
@@ -1005,7 +1020,13 @@
     [[CCNetworking sharedNetworking] automaticUploadInError];
     
     // solo in background
-    if([CCCoreData getCameraUploadActiveAccount:app.activeAccount] && [CCCoreData getCameraUploadBackgroundActiveAccount:app.activeAccount ] && [[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground) {
+    tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountActive];
+    
+    
+    //if([CCCoreData getCameraUploadActiveAccount:app.activeAccount] && [CCCoreData getCameraUploadBackgroundActiveAccount:app.activeAccount ] && [[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground) {
+    
+    if (tableAccount.cameraUpload && tableAccount.cameraUploadBackground && [[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground) {
+    
         
         if ([ALAssetsLibrary authorizationStatus] == ALAuthorizationStatusAuthorized) {
             

+ 19 - 10
iOSClient/Settings/CCManageCameraUpload.m

@@ -71,7 +71,10 @@
     section.footerTitle = NSLocalizedString(@"_photo_folder_photocamera_", nil);
 
     row = [XLFormRowDescriptor formRowDescriptorWithTag:@"cameraupload" rowType:XLFormRowDescriptorTypeBooleanSwitch title:NSLocalizedString(@"_upload_camera_", nil)];
-    if ([CCCoreData getCameraUploadActiveAccount:app.activeAccount]) row.value = @1;
+    
+    tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountActive];
+    if (tableAccount.cameraUpload) row.value = @1;
+    //if ([CCCoreData getCameraUploadActiveAccount:app.activeAccount]) row.value = @1;
     else row.value = @0;
     [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
     [section addFormRow:row];
@@ -352,8 +355,10 @@
 
     
     // - STATUS ---------------------
+    tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountActive];
     
-    if ([CCCoreData getCameraUploadActiveAccount:app.activeAccount])
+    //if ([CCCoreData getCameraUploadActiveAccount:app.activeAccount])
+    if (tableAccount.cameraUpload)
         [rowCameraupload setValue:@1]; else [rowCameraupload setValue:@0];
     
     if ([CCCoreData getCameraUploadPhotoActiveAccount:app.activeAccount])
@@ -402,30 +407,32 @@
 
 - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
 {
+    tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountActive];
     NSString *sectionName;
+    
     switch (section)
     {
         case 0:
             sectionName = NSLocalizedString(@"_uploading_from_camera_", nil);
             break;
         case 1:
-            if ([CCCoreData getCameraUploadActiveAccount:app.activeAccount]) sectionName = NSLocalizedString(@"_upload_automatic_photos_", nil);
+            if (tableAccount.cameraUpload) sectionName = NSLocalizedString(@"_upload_automatic_photos_", nil);
             else sectionName = @"";
             break;
         case 2:
-            if ([CCCoreData getCameraUploadActiveAccount:app.activeAccount]) sectionName = NSLocalizedString(@"_upload_automatic_videos_", nil);
+            if (tableAccount.cameraUpload) sectionName = NSLocalizedString(@"_upload_automatic_videos_", nil);
             else sectionName = @"";
             break;
         case 3:
-            if ([CCCoreData getCameraUploadActiveAccount:app.activeAccount]) sectionName = NSLocalizedString(@"_upload_camera_background_", nil);
+            if (tableAccount.cameraUpload) sectionName = NSLocalizedString(@"_upload_camera_background_", nil);
             else sectionName = @"";
             break;
         case 4:
-            if ([CCCoreData getCameraUploadActiveAccount:app.activeAccount]) sectionName = NSLocalizedString(@"_upload_camera_fullphotos_", nil);
+            if (tableAccount.cameraUpload) sectionName = NSLocalizedString(@"_upload_camera_fullphotos_", nil);
             else sectionName = @"";
             break;
         case 5:
-            if ([CCCoreData getCameraUploadActiveAccount:app.activeAccount]) sectionName = NSLocalizedString(@"_upload_camera_create_subfolder_", nil);
+            if (tableAccount.cameraUpload) sectionName = NSLocalizedString(@"_upload_camera_create_subfolder_", nil);
             else sectionName = @"";
             break;
     }
@@ -434,22 +441,24 @@
 
 - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section
 {
+    tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountActive];
     NSString *sectionName;
+    
     switch (section)
     {
         case 0:
             sectionName = [CCUtility localizableBrand:@"_photo_folder_photocamera_" table:nil];
             break;
         case 3:
-            if ([CCCoreData getCameraUploadActiveAccount:app.activeAccount]) sectionName = [CCUtility localizableBrand:@"_photo_folder_background_" table:nil];
+            if (tableAccount.cameraUpload) sectionName = [CCUtility localizableBrand:@"_photo_folder_background_" table:nil];
             else sectionName = @"";
             break;
         case 4:
-            if ([CCCoreData getCameraUploadActiveAccount:app.activeAccount]) sectionName =  [CCUtility localizableBrand:@"_upload_camera_fullphotos_footer_" table:nil];
+            if (tableAccount.cameraUpload) sectionName =  [CCUtility localizableBrand:@"_upload_camera_fullphotos_footer_" table:nil];
             else sectionName = @"";
             break;
         case 5:
-            if ([CCCoreData getCameraUploadActiveAccount:app.activeAccount]) sectionName =  [CCUtility localizableBrand:@"_upload_camera_create_subfolder_footer_" table:nil];
+            if (tableAccount.cameraUpload) sectionName =  [CCUtility localizableBrand:@"_upload_camera_create_subfolder_footer_" table:nil];
             else sectionName = @"";
             break;
     }