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 #960 from owncloud/fix_server_capabilities_supported
Browse files Browse the repository at this point in the history
Fix server share capabilities supported
  • Loading branch information
jesmrec authored Nov 22, 2017
2 parents d452d7c + 3faf2af commit c08ff1e
Show file tree
Hide file tree
Showing 12 changed files with 104 additions and 62 deletions.
3 changes: 2 additions & 1 deletion Owncloud iOs Client/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,8 @@ extern NSString * NotReachableNetworkForDownloadsNotification;
* Method that switches the active user to that passed as a parameter
*
* @param user -> UserDto to set as active user
* @param isNewAccount -> BOOL if this user is a new account added
*/
- (void) switchActiveUserTo:(UserDto *) user inHardMode:(BOOL)hardMode withCompletionHandler:(void (^)(void)) completionHandler;
- (void) switchActiveUserTo:(UserDto *)user isNewAccount:(BOOL)isNewAccount withCompletionHandler:(void (^)(void)) completionHandler;

@end
8 changes: 6 additions & 2 deletions Owncloud iOs Client/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -2782,15 +2782,19 @@ -(void)badCertificateNotAcceptedByUser {

#pragma mark - Active User

- (void) switchActiveUserTo:(UserDto *)user inHardMode:(BOOL)hardMode withCompletionHandler:(void (^)(void)) completionHandler {
- (void) switchActiveUserTo:(UserDto *)user isNewAccount:(BOOL)isNewAccount withCompletionHandler:(void (^)(void)) completionHandler {

// all the switch is performed in background, without blocking the caller thread, that should be main
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

self.userSessionCurrentToken = nil;
// should be here or right after checking the user really changed? for the moment, here

if (self.activeUser.userId != user.userId || hardMode) {
if (!self.activeUser) {
self.activeUser = user;
}

if (self.activeUser.userId != user.userId || isNewAccount) {

//We delete the cookies on SAML
if (k_is_sso_active) {
Expand Down
4 changes: 4 additions & 0 deletions Owncloud iOs Client/DataBase/Queries/ManageDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,12 @@
/**
* Changes:
*
* Support version 3.7.0
* Alter Keychain items to use credentialsDto as value instead password
* Alter users table, added new field to store that the server has fed shares, share link option name and share link option upload only API support.
*/
+ (void) updateDBVersion21To22;



@end
33 changes: 31 additions & 2 deletions Owncloud iOs Client/DataBase/Queries/ManageDB.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ +(void) createDataBase {

BOOL correctQuery=NO;

correctQuery = [db executeUpdate:@"CREATE TABLE IF NOT EXISTS 'users' ('id' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE , 'url' VARCHAR, 'ssl' BOOL, 'activeaccount' BOOL, 'storage_occupied' LONG NOT NULL DEFAULT 0, 'storage' LONG NOT NULL DEFAULT 0, 'has_share_api_support' INTEGER NOT NULL DEFAULT 0, 'has_sharee_api_support' INTEGER NOT NULL DEFAULT 0, 'has_cookies_support' INTEGER NOT NULL DEFAULT 0, 'has_forbidden_characters_support' INTEGER NOT NULL DEFAULT 0, 'has_capabilities_support' INTEGER NOT NULL DEFAULT 0, 'image_instant_upload' BOOL NOT NULL DEFAULT 0, 'video_instant_upload' BOOL NOT NULL DEFAULT 0, 'background_instant_upload' BOOL NOT NULL DEFAULT 0, 'path_instant_upload' VARCHAR, 'only_wifi_instant_upload' BOOL NOT NULL DEFAULT 0, 'timestamp_last_instant_upload_image' DOUBLE, 'timestamp_last_instant_upload_video' DOUBLE, 'url_redirected' VARCHAR, 'sorting_type' INTEGER NOT NULL DEFAULT 0, 'predefined_url' VARCHAR)"];
correctQuery = [db executeUpdate:@"CREATE TABLE IF NOT EXISTS 'users' ('id' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE , 'url' VARCHAR, 'ssl' BOOL, 'activeaccount' BOOL, 'storage_occupied' LONG NOT NULL DEFAULT 0, 'storage' LONG NOT NULL DEFAULT 0, 'has_share_api_support' INTEGER NOT NULL DEFAULT 0, 'has_sharee_api_support' INTEGER NOT NULL DEFAULT 0, 'has_cookies_support' INTEGER NOT NULL DEFAULT 0, 'has_forbidden_characters_support' INTEGER NOT NULL DEFAULT 0, 'has_capabilities_support' INTEGER NOT NULL DEFAULT 0, 'image_instant_upload' BOOL NOT NULL DEFAULT 0, 'video_instant_upload' BOOL NOT NULL DEFAULT 0, 'background_instant_upload' BOOL NOT NULL DEFAULT 0, 'path_instant_upload' VARCHAR, 'only_wifi_instant_upload' BOOL NOT NULL DEFAULT 0, 'timestamp_last_instant_upload_image' DOUBLE, 'timestamp_last_instant_upload_video' DOUBLE, 'url_redirected' VARCHAR, 'sorting_type' INTEGER NOT NULL DEFAULT 0, 'predefined_url' VARCHAR, has_fed_shares_option_share_support INTEGER NOT NULL DEFAULT 0, has_public_share_link_option_name_support INTEGER NOT NULL DEFAULT 0, has_public_share_link_option_upload_only_support INTEGER NOT NULL DEFAULT 0)"];

if (!correctQuery) {
DLog(@"Error in createDataBase table users");
Expand Down Expand Up @@ -1262,10 +1262,39 @@ + (void) updateDBVersion20To21 {

+ (void) updateDBVersion21To22 {

//1.- Migrate the current password stored in keychain

//1.- Alter users table to add more supported share options

FMDatabaseQueue *queue = Managers.sharedDatabase;

[queue inTransaction:^(FMDatabase *db, BOOL *rollback) {

BOOL dbOperationSuccessful;

dbOperationSuccessful =[db executeUpdate:@"ALTER TABLE users ADD has_fed_shares_option_share_support INTEGER NOT NULL DEFAULT 0"];
if (!dbOperationSuccessful) {
DLog(@"Error update version 21 to 22 table users add column has_fed_shares_option_share_support");
}

dbOperationSuccessful =[db executeUpdate:@"ALTER TABLE users ADD has_public_share_link_option_name_support INTEGER NOT NULL DEFAULT 0"];
if (!dbOperationSuccessful) {
DLog(@"Error update version 21 to 22 table users add column has_public_share_link_option_name_support");
}

dbOperationSuccessful =[db executeUpdate:@"ALTER TABLE users ADD has_public_share_link_option_upload_only_support INTEGER NOT NULL DEFAULT 0"];
if (!dbOperationSuccessful) {
DLog(@"Error update version 21 to 22 table users add column has_public_share_link_option_upload_only_support");
}

}];


//2.- Migrate the current password stored in keychain

[OCKeychain updateAllKeychainItemsFromDBVersion21To22ToStoreCredentialsDtoAsValueAndAuthenticationType];



}


Expand Down
2 changes: 1 addition & 1 deletion Owncloud iOs Client/DataBase/Queries/ManageUsersDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
/*
* Method that returns last user inserted on the Database
*/
+ (UserDto *) getLastUserInserted;
+ (UserDto *) getLastUserInsertedWithoutCredentials;


//-----------------------------------
Expand Down
Loading

0 comments on commit c08ff1e

Please sign in to comment.