Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

Commit

Permalink
Merge pull request #17 from owncloud/OC-542_Delete_folder_downloaded_…
Browse files Browse the repository at this point in the history
…files

Oc 542 delete folder downloaded files
  • Loading branch information
ggdiez committed Sep 4, 2013
2 parents 0013520 + 8ac2ea7 commit dbde9a8
Show file tree
Hide file tree
Showing 7 changed files with 176 additions and 86 deletions.
16 changes: 8 additions & 8 deletions Owncloud iOs Client.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2390,8 +2390,8 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_OBJC_ARC = YES;
CODE_SIGN_IDENTITY = "iPhone Developer: Rebeca Martín de León (H2KB6656VQ)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: Rebeca Martín de León (H2KB6656VQ)";
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"\"$(SYSTEM_APPS_DIR)/Xcode.app/Contents/Developer/Library/Frameworks\"",
Expand All @@ -2412,8 +2412,8 @@
"\"$(SRCROOT)\"",
);
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "E5DC1321-5626-4E77-B919-B7A4EDB44147";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "E5DC1321-5626-4E77-B919-B7A4EDB44147";
PROVISIONING_PROFILE = "";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
SDKROOT = iphoneos;
VALID_ARCHS = armv7;
WRAPPER_EXTENSION = app;
Expand All @@ -2424,8 +2424,8 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_OBJC_ARC = YES;
CODE_SIGN_IDENTITY = "iPhone Developer: Rebeca Martín de León (H2KB6656VQ)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: Rebeca Martín de León (H2KB6656VQ)";
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"\"$(SYSTEM_APPS_DIR)/Xcode.app/Contents/Developer/Library/Frameworks\"",
Expand All @@ -2441,8 +2441,8 @@
"\"$(SRCROOT)\"",
);
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "E5DC1321-5626-4E77-B919-B7A4EDB44147";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "E5DC1321-5626-4E77-B919-B7A4EDB44147";
PROVISIONING_PROFILE = "";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
SDKROOT = iphoneos;
VALID_ARCHS = armv7;
WRAPPER_EXTENSION = app;
Expand Down
12 changes: 12 additions & 0 deletions Owncloud iOs Client/DataBase/Queries/ManageFilesDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,16 @@
*/
+ (void) updateFilesWithFileId:(int) oldFileId withNewFileId:(int) fileId;


/*
* Method that give all files with a concrete download state and by active user
*/
+ (BOOL) isGetFilesByDownloadState:(enumDownload)downloadState andByUser:(UserDto *) currentUser andFolder:(NSString *) folder;


/*
* Method that update the download state of all files in a folder by active user
*/
+ (void) updateFilesByUser:(UserDto *) currentUser andFolder:(NSString *) folder toDownloadState:(enumDownload)downloadState;

@end
38 changes: 38 additions & 0 deletions Owncloud iOs Client/DataBase/Queries/ManageFilesDB.m
Original file line number Diff line number Diff line change
Expand Up @@ -809,4 +809,42 @@ + (void) updateFilesWithFileId:(int) oldFileId withNewFileId:(int) fileId {
}


+ (BOOL) isGetFilesByDownloadState:(enumDownload)downloadState andByUser:(UserDto *) currentUser andFolder:(NSString *) folder {

__block BOOL *output = NO;
DLog(@"getFilesByFileId:(int) fileId");

FMDatabaseQueue *queue = [AppDelegate sharedDatabase];

[queue inDatabase:^(FMDatabase *db) {
FMResultSet *rs = [db executeQuery:@"SELECT COUNT(*) as NUM FROM files WHERE is_download = ? AND user_id = ? AND file_path LIKE ? ORDER BY file_name ASC", [NSNumber numberWithInt:downloadState], [NSNumber numberWithInt:currentUser.idUser], [NSString stringWithFormat:@"%@%%", folder]];
while ([rs next]) {
int numberOfFiles = [rs intForColumn:@"NUM"];
if(numberOfFiles > 0) {
output = YES;
}
}
[rs close];
}];

return output;
}


+ (void) updateFilesByUser:(UserDto *) currentUser andFolder:(NSString *) folder toDownloadState:(enumDownload)downloadState {

FMDatabaseQueue *queue = [AppDelegate sharedDatabase];

[queue inTransaction:^(FMDatabase *db, BOOL *rollback) {
BOOL correctQuery=NO;

correctQuery = [db executeUpdate:@"UPDATE files SET is_download = ? WHERE user_id = ? AND file_path LIKE ? ", [NSNumber numberWithInt:downloadState], [NSNumber numberWithInt:currentUser.idUser], [NSString stringWithFormat:@"%@%%", folder]];

if (!correctQuery) {
DLog(@"Error in updateFilesByUserAndFolder");
}

}];
}

@end
1 change: 1 addition & 0 deletions Owncloud iOs Client/Tabs/FileTab/DeleteFile/DeleteFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
UIView *_viewToShow;
int _deleteFromFlag;
BOOL _deleteFromFilePreview;
BOOL _isFilesDownloadedInFolder;
UIActionSheet *_popupQuery;
}

Expand Down
Loading

0 comments on commit dbde9a8

Please sign in to comment.