Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bookmarks improvements #changed #659

Merged
merged 50 commits into from
Dec 29, 2020
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
2a3a4dd
WIP
jamesstout Dec 6, 2020
2b6a52c
WIP
jamesstout Dec 7, 2020
19e0871
WIP
jamesstout Dec 7, 2020
c1d6aee
WIP
jamesstout Dec 7, 2020
87d09cc
WIP
jamesstout Dec 7, 2020
aef142d
Merge branch 'main' into stale-bookmarks
jamesstout Dec 15, 2020
96105c3
WIP
jamesstout Dec 15, 2020
249c1a4
Merge branch 'main' into stale-bookmarks
jamesstout Dec 16, 2020
4c0776a
WIP - doesn’t work
jamesstout Dec 16, 2020
5873a58
guard around substringFromIndex
jamesstout Dec 16, 2020
04b4acf
WIP
jamesstout Dec 16, 2020
2cd3a20
WIP
jamesstout Dec 17, 2020
5323d8b
Merge branch 'main' into stale-bookmarks
jamesstout Dec 18, 2020
0b28ba1
WIP
jamesstout Dec 18, 2020
1df6fab
WIP
jamesstout Dec 18, 2020
ea38524
Merge branch 'main' into stale-bookmarks
jamesstout Dec 18, 2020
ceade42
Merge branch 'main' into stale-bookmarks
jamesstout Dec 18, 2020
3cd6ca9
added bookMarkFor a file
jamesstout Dec 18, 2020
d8ec37a
SPBookmarksChanged notification
jamesstout Dec 18, 2020
ab7bcd7
changed bookmarks init
jamesstout Dec 18, 2020
2751601
use revokeBookmarkWithFilename
jamesstout Dec 18, 2020
20f5138
logging
jamesstout Dec 18, 2020
5a351fd
tidied revokeBookmarkWithFilename
jamesstout Dec 18, 2020
43d7281
Merge branch 'main' into stale-bookmarks
jamesstout Dec 18, 2020
2e2340b
prompt user to recreate stale secure bookmarks
jamesstout Dec 18, 2020
b551f6c
rm logging
jamesstout Dec 18, 2020
dcfea6c
logging
jamesstout Dec 18, 2020
9b57ea9
addObserver for SPBookmarksChangedNotification
jamesstout Dec 18, 2020
5454df5
Merge branch 'main' into stale-bookmarks
jamesstout Dec 18, 2020
26a5313
feedback from Kaspik
jamesstout Dec 19, 2020
8b4f1fc
changed indentation
jamesstout Dec 19, 2020
8762dfb
more feedback
jamesstout Dec 19, 2020
b2bc87d
better logging
jamesstout Dec 19, 2020
a4d97ed
more kaspik feedback addressed
jamesstout Dec 19, 2020
b8bf7ef
bit of indenting
jamesstout Dec 19, 2020
98e35a2
PR feedback
jamesstout Dec 22, 2020
be65388
doesn't work ...
jamesstout Dec 22, 2020
b38122b
doesn't work as expected either
jamesstout Dec 22, 2020
8ae67dd
Merge branch 'main' into stale-bookmarks
jamesstout Dec 24, 2020
95e651a
Merge branch 'main' into stale-bookmarks
jamesstout Dec 24, 2020
228ef3f
Merge branch 'main' into stale-bookmarks
jamesstout Dec 25, 2020
dfc091c
Merge branch 'main' into stale-bookmarks
Kaspik Dec 27, 2020
24d9e81
combine guards (per @kaspik)
jamesstout Dec 27, 2020
3d2483e
ahhh!
jamesstout Dec 27, 2020
97d3184
Further feedback from @kaspik
jamesstout Dec 27, 2020
0cce102
display a window with a reminder of their stale bookmarks
jamesstout Dec 27, 2020
83a2b26
Merge branch 'main' into stale-bookmarks
jamesstout Dec 29, 2020
d0e6eb0
format
jamesstout Dec 29, 2020
8731ca5
added migrateBookmarks
jamesstout Dec 29, 2020
000b931
Merge branch 'main' into stale-bookmarks
jamesstout Dec 29, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions Resources/Localization/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -3173,3 +3173,10 @@

/* connection view : ssl : key file picker : wrong format error title */
"“%@” is not a valid private key file." = "“%@” is not a valid private key file.";

/* text shown when there are stale bookmarks */
jamesstout marked this conversation as resolved.
Show resolved Hide resolved
"App Sandbox Issue" = "App Sandbox Issue";
"Stale Bookmarks" = "Stale Bookmarks";
"You have stale secure bookmarks:\n\n%@\n\nWould you like to re-request access now?" = "You have stale secure bookmarks:\n\n%@\n\nWould you like to re-request access now?";
"Yes" = "Yes";
"A reminder of your stale secure bookmarks:\n\n%@\n" = "A reminder of your stale secure bookmarks:\n\n%@\n";
7 changes: 7 additions & 0 deletions Resources/Localization/es-ES.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -3173,3 +3173,10 @@

/* connection view : ssl : key file picker : wrong format error title */
"“%@” is not a valid private key file." = "“%@” is not a valid private key file.";

/* text shown when there are stale bookmarks */
"App Sandbox Issue" = "App Sandbox Issue";
jamesstout marked this conversation as resolved.
Show resolved Hide resolved
"Stale Bookmarks" = "Stale Bookmarks";
"You have stale secure bookmarks:\n\n%@\n\nWould you like to re-request access now?" = "You have stale secure bookmarks:\n\n%@\n\nWould you like to re-request access now?";
"Yes" = "Yes";
"A reminder of your stale secure bookmarks:\n\n%@\n" = "A reminder of your stale secure bookmarks:\n\n%@\n";
88 changes: 14 additions & 74 deletions Source/Controllers/DataExport/SPExportController.m
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ - (instancetype)init
exporters = [[NSMutableArray alloc] init];
exportFiles = [[NSMutableArray alloc] init];
operationQueue = [[NSOperationQueue alloc] init];
bookmarks = [[NSMutableArray alloc] init];
bookmarks = [NSMutableArray arrayWithArray:SecureBookmarkManager.sharedInstance.bookmarks];

showAdvancedView = NO;
showCustomFilenameView = NO;
serverLowerCaseTableNameValue = NSNotFound;
Expand Down Expand Up @@ -288,16 +288,7 @@ - (void)exportTables:(NSArray *)exportTables asFormat:(SPExportType)format using

// initially popuplate the tables list
[self refreshTableList:nil];

id o;
if((o = [prefs objectForKey:SPSecureBookmarks])){
[bookmarks setArray:o];
}
else{
SPLog(@"Could not load SPSecureBookmarks from prefs");
CLS_LOG(@"Could not load SPSecureBookmarks from prefs");
}


// overwrite defaults with user settings from last export
[self applySettingsFromDictionary:[prefs objectForKey:SPLastExportSettings] error:NULL];

Expand Down Expand Up @@ -630,47 +621,11 @@ - (IBAction)changeExportOutputPath:(id)sender
}

[self->exportPathField setStringValue:path];

// the code always seems to go into this block as the
// user has selected the folder and we have com.apple.security.files.user-selected.read-write
if([self->changeExportOutputPathPanel.URL startAccessingSecurityScopedResource] == YES){
SPLog(@"got access to: %@", self->changeExportOutputPathPanel.URL.absoluteString);
CLS_LOG(@"got access to: %@", self->changeExportOutputPathPanel.URL.absoluteString);

BOOL __block beenHereBefore = NO;

// have we been here before?
[self.bookmarks enumerateObjectsUsingBlock:^(NSDictionary *dict, NSUInteger idx, BOOL *stop) {

if(dict[self->changeExportOutputPathPanel.URL.absoluteString] != nil){
NSLog(@"beenHereBefore: %@", dict[self->changeExportOutputPathPanel.URL.absoluteString]);
beenHereBefore = YES;
*stop = YES;
}
}];

if(beenHereBefore == NO){
// create a bookmark
NSError *error = nil;
NSData *tmpAppScopedBookmark = [self->changeExportOutputPathPanel.URL bookmarkDataWithOptions:NSURLBookmarkCreationWithSecurityScope // this needs to be read-write
includingResourceValuesForKeys:nil
relativeToURL:nil
error:&error];
// save to prefs
if(tmpAppScopedBookmark && !error) {
[self->bookmarks addObject:@{self->changeExportOutputPathPanel.URL.absoluteString : tmpAppScopedBookmark}];
[self->prefs setObject:self->bookmarks forKey:SPSecureBookmarks];
}
else{
SPLog(@"Problem creating bookmark - %@ : %@",self->changeExportOutputPathPanel.URL.absoluteString, [error localizedDescription]);
CLS_LOG(@"Problem creating bookmark - %@ : %@",self->changeExportOutputPathPanel.URL.absoluteString, [error localizedDescription]);
}
}
}
else{
SPLog(@"Problem startAccessingSecurityScopedResource for - %@",self->changeExportOutputPathPanel.URL.absoluteString);
CLS_LOG(@"Problem startAccessingSecurityScopedResource for - %@",self->changeExportOutputPathPanel.URL.absoluteString);
}

// this needs to be read-write
if([SecureBookmarkManager.sharedInstance addBookMarkForUrl:self->changeExportOutputPathPanel.URL options:(NSURLBookmarkCreationWithSecurityScope)] == YES){
SPLog(@"addBookMarkForUrl success");
}
}
}];
}
Expand Down Expand Up @@ -3162,27 +3117,12 @@ - (BOOL)applySettingsFromDictionary:(NSDictionary *)dict error:(NSError **)err
// look up that bookmark and request access
if(bookmarks.count > 0){
if((o = [dict objectForKey:@"exportPath"])) [exportPathField setStringValue:o];

NSError __block *error = nil;

[self.bookmarks enumerateObjectsUsingBlock:^(NSDictionary *dict2, NSUInteger idx, BOOL *stop) {

NSString *tmpStr = [NSURL fileURLWithPath:[exportPathField stringValue] isDirectory:YES].absoluteString;

if(dict2[tmpStr] != nil){
self.userChosenDirectory = [NSURL URLByResolvingBookmarkData:dict2[tmpStr]
options:NSURLBookmarkResolutionWithSecurityScope
relativeToURL:nil
bookmarkDataIsStale:nil
error:&error];
*stop = YES;
}
}];

// if no bookmark was found this just calls against nil
if(!error){
[userChosenDirectory startAccessingSecurityScopedResource];
}

NSString *tmpStr = [NSURL fileURLWithPath:[exportPathField stringValue] isDirectory:YES].absoluteString;
jamesstout marked this conversation as resolved.
Show resolved Hide resolved

// ret value can be nil
userChosenDirectory = [SecureBookmarkManager.sharedInstance bookMarkForFilename:tmpStr];

}

SPExportType et;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ typedef NS_ENUM(NSInteger, SPConnectionTimeZoneMode) {
@property (readwrite, copy) NSString *connectionSSHKeychainItemAccount;
@property (readwrite) BOOL useCompression;
@property (readwrite, strong) NSMutableArray<NSDictionary<NSString *, id> *> *bookmarks;
@property (readwrite, strong) NSMutableArray<NSURL *> *resolvedBookmarks;

@property (readonly) BOOL isConnecting;
@property (readonly) BOOL isEditingConnection;
Expand Down Expand Up @@ -260,7 +259,6 @@ typedef NS_ENUM(NSInteger, SPConnectionTimeZoneMode) {
-(BOOL)validateCertFile:(NSURL *)url error:(NSError **)outError;
-(BOOL)validateKeyFile:(NSURL *)url error:(NSError **)outError;
-(void)showValidationAlertForError:(NSError*)err;
-(void)reRequestSecureAccess;
-(BOOL)connected;

// Favorites interaction
Expand Down