فهرست منبع

remove Account

Marino Faggiana 7 سال پیش
والد
کامیت
7f11f79a32
2فایلهای تغییر یافته به همراه0 افزوده شده و 511 حذف شده
  1. 0 41
      iOSClient/FileSystem/CCCoreData.h
  2. 0 470
      iOSClient/FileSystem/CCCoreData.m

+ 0 - 41
iOSClient/FileSystem/CCCoreData.h

@@ -45,48 +45,7 @@
 
 // ===== Account =====
 
-//+ (void)addAccount:(NSString *)account url:(NSString *)url user:(NSString *)user password:(NSString *)password;
-//+ (void)updateAccount:(NSString *)account withPassword:(NSString *)password;
-//+ (void)deleteAccount:(NSString *)account;
-//+ (TableAccount *)setActiveAccount:(NSString *)account;
-
 + (NSArray *)getAllAccount;
-//+ (TableAccount *)getTableAccountFromAccount:(NSString *)account;
-//+ (NSArray *)getAllTableAccount;
-//+ (TableAccount *)getActiveAccount;
-
-//+ (NSString *)getCameraUploadFolderNameActiveAccount:(NSString *)activeAccount;
-//+ (NSString *)getCameraUploadFolderPathActiveAccount:(NSString *)activeAccount activeUrl:(NSString *)activeUrl;
-//+ (NSString *)getCameraUploadFolderNamePathActiveAccount:(NSString *)activeAccount activeUrl:(NSString *)activeUrl;
-
-//+ (BOOL)getCameraUploadActiveAccount:(NSString *)activeAccount;
-//+ (BOOL)getCameraUploadBackgroundActiveAccount:(NSString *)activeAccount;
-//+ (BOOL)getCameraUploadCreateSubfolderActiveAccount:(NSString *)activeAccount;
-//+ (BOOL)getCameraUploadFullPhotosActiveAccount:(NSString *)activeAccount;
-//+ (BOOL)getCameraUploadPhotoActiveAccount:(NSString *)activeAccount;
-//+ (BOOL)getCameraUploadVideoActiveAccount:(NSString *)activeAccount;
-//+ (NSDate *)getCameraUploadDatePhotoActiveAccount:(NSString *)activeAccount;
-//+ (NSDate *)getCameraUploadDateVideoActiveAccount:(NSString *)activeAccount;
-//+ (BOOL)getCameraUploadWWanPhotoActiveAccount:(NSString *)activeAccount;
-//+ (BOOL)getCameraUploadWWanVideoActiveAccount:(NSString *)activeAccount;
-/*
-+ (void)setCameraUpload:(BOOL)state activeAccount:(NSString *)activeAccount;
-+ (void)setCameraUploadBackground:(BOOL)state activeAccount:(NSString *)activeAccount;
-+ (void)setCameraUploadCreateSubfolderActiveAccount:(BOOL)state activeAccount:(NSString *)activeAccount;
-+ (void)setCameraUploadFullPhotosActiveAccount:(BOOL)state activeAccount:(NSString *)activeAccount;
-+ (void)setCameraUploadPhoto:(BOOL)state activeAccount:(NSString *)activeAccount;
-+ (void)setCameraUploadVideo:(BOOL)video activeAccount:(NSString *)activeAccount;
-+ (void)setCameraUploadDatePhoto:(NSDate *)date;
-+ (void)setCameraUploadDateVideo:(NSDate *)date;
-+ (void)setCameraUploadDateAssetType:(PHAssetMediaType)assetMediaType assetDate:(NSDate *)assetDate activeAccount:(NSString *)activeAccount;
-+ (void)setCameraUploadWWanPhoto:(BOOL)wWan activeAccount:(NSString *)activeAccount;
-+ (void)setCameraUploadWWanVideo:(BOOL)wWan activeAccount:(NSString *)activeAccount;
-+ (void)setCameraUploadFolderName:(NSString *)fileName activeAccount:(NSString *)activeAccount;
-+ (void)setCameraUploadFolderPath:(NSString *)pathName activeUrl:(NSString *)activeUrl activeAccount:(NSString *)activeAccount;
-*/ 
-//+ (void)setCameraUploadSaveAlbum:(BOOL)saveAlbum activeAccount:(NSString *)activeAccount;
-
-//+ (void)setUserProfileActiveAccount:(NSString *)activeAccount userProfile:(OCUserProfile *)userProfile;
 
 // ===== Metadata =====
 

+ 0 - 470
iOSClient/FileSystem/CCCoreData.m

@@ -46,476 +46,6 @@
     return accounts;
 }
 
-/*
-+ (void)addAccount:(NSString *)account url:(NSString *)url user:(NSString *)user password:(NSString *)password
-{
-    NSManagedObjectContext *context = [NSManagedObjectContext MR_defaultContext];
-    
-    TableAccount *record = [TableAccount MR_createEntityInContext:context];
-        
-    record.account = account;
-    record.active = [NSNumber numberWithBool:NO];
-        
-    // Brand
-    if ([NCBrandOptions sharedInstance].use_default_automatic_upload) {
-        
-        record.cameraUpload = [NSNumber numberWithBool:YES];
-        record.cameraUploadPhoto = [NSNumber numberWithBool:YES];
-        record.cameraUploadVideo = [NSNumber numberWithBool:YES];
-        
-        record.cameraUploadDatePhoto = [NSDate date];
-        record.cameraUploadDateVideo = [NSDate date];
-        
-        record.cameraUploadWWAnPhoto = [NSNumber numberWithBool:NO];
-        record.cameraUploadWWAnVideo = [NSNumber numberWithBool:YES];
-        
-    } else {
-        
-        record.cameraUpload = [NSNumber numberWithBool:NO];
-        record.cameraUploadPhoto = [NSNumber numberWithBool:NO];
-        record.cameraUploadVideo = [NSNumber numberWithBool:NO];
-        
-        record.cameraUploadWWAnPhoto = [NSNumber numberWithBool:NO];
-        record.cameraUploadWWAnVideo = [NSNumber numberWithBool:NO];
-    }
-    
-    record.optimization = [NSDate date];
-    record.password = password;
-    record.url = url;
-    record.user = user;
-    
-    [context MR_saveToPersistentStoreAndWait];
-}
-
-
-+ (void)updateAccount:(NSString *)account withPassword:(NSString *)password
-{
-    NSManagedObjectContext *context = [NSManagedObjectContext MR_defaultContext];
-    
-    TableAccount *record = [TableAccount MR_findFirstByAttribute:@"account" withValue:account inContext:context];
-    
-    record.password = password;
-    
-    [context MR_saveToPersistentStoreAndWait];
-}
-
-
-+ (void)deleteAccount:(NSString *)account
-{
-    NSManagedObjectContext *context = [NSManagedObjectContext MR_defaultContext];
-
-    TableAccount *record = [TableAccount MR_findFirstByAttribute:@"account" withValue:account inContext:context];
-    [record MR_deleteEntityInContext:context];
-    
-    [context MR_saveToPersistentStoreAndWait];
-}
-
-
-+ (TableAccount *)setActiveAccount:(NSString *)account
-{
-    NSManagedObjectContext *context = [NSManagedObjectContext MR_defaultContext];
-
-    TableAccount *recordAccount = nil;
-    
-    NSArray *records = [TableAccount MR_findAllInContext:context];
-    
-    for (TableAccount *record in records) {
-        
-        if ([record.account isEqualToString:account]) {
-            
-            record.active = [NSNumber numberWithBool:YES];
-            recordAccount = record;
-            
-        } else {
-            
-            record.active = [NSNumber numberWithBool:NO];
-        }
-    }
-    
-    [context MR_saveToPersistentStoreAndWait];
-        
-    return [self getActiveAccount];
-}
-
-+ (NSArray *)getAllAccount
-{
-    NSMutableArray *accounts = [NSMutableArray new];
-    NSArray *records;
-    
-    NSManagedObjectContext *context = [NSManagedObjectContext MR_defaultContext];
-    
-    records = [TableAccount MR_findAllInContext:context];
-    
-    for (TableAccount *tableAccount in records)
-        [accounts addObject:tableAccount.account];
-    
-    return accounts;
-}
-
-+ (TableAccount *)getTableAccountFromAccount:(NSString *)account
-{
-    NSManagedObjectContext *context = [NSManagedObjectContext MR_defaultContext];
-
-    return [TableAccount MR_findFirstByAttribute:@"account" withValue:account inContext:context];
-}
-
-+ (NSArray *)getAllTableAccount
-{
-    NSManagedObjectContext *context = [NSManagedObjectContext MR_defaultContext];
-
-    NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"account" ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
-    NSArray *records;
-    
-    records = [TableAccount MR_findAllInContext:context];
-    
-    records = [NSMutableArray arrayWithArray:[records sortedArrayUsingDescriptors:[[NSArray alloc] initWithObjects:descriptor, nil]]];
-    
-    return records;
-}
-
-+ (TableAccount *)getActiveAccount
-{
-    NSManagedObjectContext *context = [NSManagedObjectContext MR_defaultContext];
-
-    TableAccount *record = [TableAccount MR_findFirstByAttribute:@"active" withValue:[NSNumber numberWithBool:YES] inContext:context];
-    
-    if (record) return record;
-    else return nil;
-}
-
-
-+ (NSString *)getCameraUploadFolderNameActiveAccount:(NSString *)activeAccount
-{
-    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@)", activeAccount];
-    TableAccount *record = [TableAccount MR_findFirstWithPredicate:predicate];
-    
-    if (record) {
-        
-        if ([record.cameraUploadFolderName length] > 0 ) return record.cameraUploadFolderName;
-        else return k_folderDefaultCameraUpload;
-        
-    } else return @"";
-}
-
-+ (NSString *)getCameraUploadFolderPathActiveAccount:(NSString *)activeAccount activeUrl:(NSString *)activeUrl
-{
-    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@)", activeAccount];
-    TableAccount *record = [TableAccount MR_findFirstWithPredicate:predicate];
-    
-    if (record) {
-        
-        if ([record.cameraUploadFolderPath length] > 0 ) return record.cameraUploadFolderPath;
-        else return [CCUtility getHomeServerUrlActiveUrl:activeUrl];
-        
-    } else return @"";
-}
-
-
-+ (NSString *)getCameraUploadFolderNamePathActiveAccount:(NSString *)activeAccount activeUrl:(NSString *)activeUrl
-{
-    NSString *cameraFolderName = [self getCameraUploadFolderNameActiveAccount:activeAccount];
-    NSString *cameraFolderPath = [self getCameraUploadFolderPathActiveAccount:activeAccount activeUrl:activeUrl];
-    
-    NSString *folderPhotos = [CCUtility stringAppendServerUrl:cameraFolderPath addFileName:cameraFolderName];
-    return folderPhotos;
-}
-
-+ (BOOL)getCameraUploadActiveAccount:(NSString *)activeAccount
-{
-    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@)", activeAccount];
-    TableAccount *record = [TableAccount MR_findFirstWithPredicate:predicate];
-    
-    if (record) return [record.cameraUpload boolValue];
-    else return NO;
-}
-
-+ (BOOL)getCameraUploadBackgroundActiveAccount:(NSString *)activeAccount
-{
-    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@)", activeAccount];
-    TableAccount *record = [TableAccount MR_findFirstWithPredicate:predicate];
-    
-    if (record) return [record.cameraUploadBackground boolValue];
-    else return NO;
-}
-
-+ (BOOL)getCameraUploadCreateSubfolderActiveAccount:(NSString *)activeAccount
-{
-    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@)", activeAccount];
-    TableAccount *record = [TableAccount MR_findFirstWithPredicate:predicate];
-    
-    if (record) return [record.cameraUploadCreateSubfolder boolValue];
-    else return NO;
-}
-
-+ (BOOL)getCameraUploadFullPhotosActiveAccount:(NSString *)activeAccount
-{
-    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@)", activeAccount];
-    TableAccount *record = [TableAccount MR_findFirstWithPredicate:predicate];
-    
-    if (record) return [record.cameraUploadFull boolValue];
-    else return NO;
-}
-
-+ (BOOL)getCameraUploadPhotoActiveAccount:(NSString *)activeAccount
-{
-    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@)", activeAccount];
-    TableAccount *record = [TableAccount MR_findFirstWithPredicate:predicate];
-    
-    if (record) return [record.cameraUploadPhoto boolValue];
-    else return NO;
-}
-
-+ (BOOL)getCameraUploadVideoActiveAccount:(NSString *)activeAccount
-{
-    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@)", activeAccount];
-    TableAccount *record = [TableAccount MR_findFirstWithPredicate:predicate];
-    
-    if (record) return [record.cameraUploadVideo boolValue];
-    else return NO;
-}
-
-+ (NSDate *)getCameraUploadDatePhotoActiveAccount:(NSString *)activeAccount
-{
-    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@)", activeAccount];
-    TableAccount *record = [TableAccount MR_findFirstWithPredicate:predicate];
-    
-    if (record) return record.cameraUploadDatePhoto;
-    else return nil;
-}
-
-+ (NSDate *)getCameraUploadDateVideoActiveAccount:(NSString *)activeAccount
-{
-    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@)", activeAccount];
-    TableAccount *record = [TableAccount MR_findFirstWithPredicate:predicate];
-    
-    if (record) return record.cameraUploadDateVideo;
-    else return nil;
-}
-
-+ (BOOL)getCameraUploadWWanPhotoActiveAccount:(NSString *)activeAccount
-{
-    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@)", activeAccount];
-    TableAccount *record = [TableAccount MR_findFirstWithPredicate:predicate];
-    
-    if (record) return [record.cameraUploadWWAnPhoto boolValue];
-    else return NO;
-}
-
-+ (BOOL)getCameraUploadWWanVideoActiveAccount:(NSString *)activeAccount
-{
-    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@)", activeAccount];
-    TableAccount *record = [TableAccount MR_findFirstWithPredicate:predicate];
-    
-    if (record) return [record.cameraUploadWWAnVideo boolValue];
-    else return NO;
-}
-
-// ******** SET *********
-
-+ (void)setCameraUpload:(BOOL)state activeAccount:(NSString *)activeAccount
-{
-    [MagicalRecord saveWithBlockAndWait:^(NSManagedObjectContext *localContext) {
-        
-        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@)", activeAccount];
-        TableAccount *record = [TableAccount MR_findFirstWithPredicate:predicate inContext:localContext];
-    
-        if (record)
-            record.cameraUpload = [NSNumber numberWithBool:state];
-    }];
-}
-
-+ (void)setCameraUploadBackground:(BOOL)state activeAccount:(NSString *)activeAccount
-{
-    [MagicalRecord saveWithBlockAndWait:^(NSManagedObjectContext *localContext) {
-        
-        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@)", activeAccount];
-        TableAccount *record = [TableAccount MR_findFirstWithPredicate:predicate inContext:localContext];
-    
-        if (record)
-            record.cameraUploadBackground = [NSNumber numberWithBool:state];
-    }];
-}
-
-+ (void)setCameraUploadCreateSubfolderActiveAccount:(BOOL)state activeAccount:(NSString *)activeAccount
-{
-    [MagicalRecord saveWithBlockAndWait:^(NSManagedObjectContext *localContext) {
-        
-        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@)", activeAccount];
-        TableAccount *record = [TableAccount MR_findFirstWithPredicate:predicate inContext:localContext];
-        
-        if (record)
-            record.cameraUploadCreateSubfolder = [NSNumber numberWithBool:state];
-    }];
-}
-
-+ (void)setCameraUploadFullPhotosActiveAccount:(BOOL)state activeAccount:(NSString *)activeAccount
-{
-     [MagicalRecord saveWithBlockAndWait:^(NSManagedObjectContext *localContext) {
-     
-         NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@)", activeAccount];
-         TableAccount *record = [TableAccount MR_findFirstWithPredicate:predicate inContext:localContext];
-     
-         if (record)
-             record.cameraUploadFull = [NSNumber numberWithBool:state];
-     }];
-}
-
-+ (void)setCameraUploadPhoto:(BOOL)state activeAccount:(NSString *)activeAccount
-{
-    [MagicalRecord saveWithBlockAndWait:^(NSManagedObjectContext *localContext) {
-        
-        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@)", activeAccount];
-        TableAccount *record = [TableAccount MR_findFirstWithPredicate:predicate inContext:localContext];
-    
-        if (record)
-            record.cameraUploadPhoto = [NSNumber numberWithBool:state];
-    }];
-}
-
-+ (void)setCameraUploadVideo:(BOOL)video activeAccount:(NSString *)activeAccount
-{
-    [MagicalRecord saveWithBlockAndWait:^(NSManagedObjectContext *localContext) {
-
-        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@)", activeAccount];
-        TableAccount *record = [TableAccount MR_findFirstWithPredicate:predicate inContext:localContext];
-    
-        if (record)
-            record.cameraUploadVideo = [NSNumber numberWithBool:video];
-    }];
-}
-
-+ (void)setCameraUploadDatePhoto:(NSDate *)date
-{
-    NSManagedObjectContext *context = [NSManagedObjectContext MR_defaultContext];
-
-    NSArray *records = [TableAccount MR_findAllInContext:context];
-    
-    for (TableAccount *record in records)
-        record.cameraUploadDatePhoto = date;
-    
-    [context MR_saveToPersistentStoreAndWait];
-}
-
-+ (void)setCameraUploadDateVideo:(NSDate *)date
-{
-    NSManagedObjectContext *context = [NSManagedObjectContext MR_defaultContext];
-
-    NSArray *records = [TableAccount MR_findAllInContext:context];
-    
-    for (TableAccount *record in records)
-        record.cameraUploadDateVideo = date;
-    
-    [context MR_saveToPersistentStoreAndWait];
-}
-
-+ (void)setCameraUploadDateAssetType:(PHAssetMediaType)assetMediaType assetDate:(NSDate *)assetDate activeAccount:(NSString *)activeAccount
-{
-    if (assetMediaType == PHAssetMediaTypeImage && [assetDate compare:[self getCameraUploadDatePhotoActiveAccount:activeAccount]] ==  NSOrderedDescending && assetDate) {
-        [self setCameraUploadDatePhoto:assetDate];
-    }
-    
-    if (assetMediaType == PHAssetMediaTypeVideo && [assetDate compare:[self getCameraUploadDateVideoActiveAccount:activeAccount]] ==  NSOrderedDescending && assetDate) {
-        [self setCameraUploadDateVideo:assetDate];
-    }
-}
-
-+ (void)setCameraUploadWWanPhoto:(BOOL)wWan activeAccount:(NSString *)activeAccount
-{
-    [MagicalRecord saveWithBlockAndWait:^(NSManagedObjectContext *localContext) {
-
-        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@)", activeAccount];
-        TableAccount *record = [TableAccount MR_findFirstWithPredicate:predicate inContext:localContext];
-    
-        if (record)
-            record.cameraUploadWWAnPhoto = [NSNumber numberWithBool:wWan];
-    }];
-}
-
-+ (void)setCameraUploadWWanVideo:(BOOL)wWan activeAccount:(NSString *)activeAccount
-{
-    [MagicalRecord saveWithBlockAndWait:^(NSManagedObjectContext *localContext) {
-
-        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@)", activeAccount];
-        TableAccount *record = [TableAccount MR_findFirstWithPredicate:predicate inContext:localContext];
-    
-        if (record)
-            record.cameraUploadWWAnVideo = [NSNumber numberWithBool:wWan];
-    }];
-}
-
-+ (void)setCameraUploadFolderName:(NSString *)fileName activeAccount:(NSString *)activeAccount
-{
-    if (fileName == nil)
-        fileName = [[NCManageDatabase sharedInstance] getAccountsCameraUploadFolderName:activeAccount activeUrl:nil];
-        //fileName = [self getCameraUploadFolderNameActiveAccount:activeAccount];
-    
-    [MagicalRecord saveWithBlockAndWait:^(NSManagedObjectContext *localContext) {
-
-        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@)", activeAccount];
-        TableAccount *record = [TableAccount MR_findFirstWithPredicate:predicate inContext:localContext];
-    
-        if (record)
-            record.cameraUploadFolderName = fileName;
-    }];
-}
-
-+ (void)setCameraUploadFolderPath:(NSString *)pathName activeUrl:(NSString *)activeUrl activeAccount:(NSString *)activeAccount
-{
-    //if (pathName == nil)
-        //pathName = [[NCManageDatabase sharedInstance] getAccountsCameraUploadFolderPath:_metadataNet.account activeUrl:_activeUrl];
-        //pathName = [self getCameraUploadFolderPathActiveAccount:activeAccount activeUrl:activeUrl];
-    
-    [MagicalRecord saveWithBlockAndWait:^(NSManagedObjectContext *localContext) {
-        
-        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@)", activeAccount];
-        TableAccount *record = [TableAccount MR_findFirstWithPredicate:predicate inContext:localContext];
-    
-        if (record)
-            record.cameraUploadFolderPath = pathName;
-    }];
-}
-
-
-+ (void)setCameraUploadSaveAlbum:(BOOL)saveAlbum activeAccount:(NSString *)activeAccount
-{
-    [MagicalRecord saveWithBlockAndWait:^(NSManagedObjectContext *localContext) {
-
-        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@)", activeAccount];
-        TableAccount *record = [TableAccount MR_findFirstWithPredicate:predicate inContext:localContext];
-    
-        if (record)
-            record.cameraUploadSaveAlbum = [NSNumber numberWithBool:saveAlbum];
-    }];
-}
-
-
-+ (void)setUserProfileActiveAccount:(NSString *)activeAccount userProfile:(OCUserProfile *)userProfile
-{
-    [MagicalRecord saveWithBlockAndWait:^(NSManagedObjectContext *localContext) {
-        
-        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(account == %@)", activeAccount];
-        TableAccount *record = [TableAccount MR_findFirstWithPredicate:predicate inContext:localContext];
-        
-        if (record) {
-            
-            record.enabled = [NSNumber numberWithBool:userProfile.enabled];
-            record.address = userProfile.address;
-            record.displayName = userProfile.displayName;
-            record.email = userProfile.email;
-            record.phone = userProfile.phone;
-            record.twitter = userProfile.twitter;
-            record.webpage = userProfile.webpage;
-            
-            record.quota = [NSNumber numberWithDouble:userProfile.quota];
-            record.quotaFree = [NSNumber numberWithDouble:userProfile.quotaFree];
-            record.quotaRelative = [NSNumber numberWithDouble:userProfile.quotaRelative];
-            record.quotaTotal = [NSNumber numberWithDouble:userProfile.quotaTotal];
-            record.quotaUsed = [NSNumber numberWithDouble:userProfile.quotaUsed];
-        }
-    }];
-}
-*/
-
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Metadata =====
 #pragma --------------------------------------------------------------------------------------------