X-Git-Url: https://code.grnet.gr/git/pithos-macos/blobdiff_plain/2f02f386cb26a7bf8d59a51c26f4a70c51fdf390..cb6abe7283fd973e5dacbbf7a8bc920fd2eed089:/pithos-macos/PithosPreferencesController.m diff --git a/pithos-macos/PithosPreferencesController.m b/pithos-macos/PithosPreferencesController.m index 35f24f2..c978c02 100644 --- a/pithos-macos/PithosPreferencesController.m +++ b/pithos-macos/PithosPreferencesController.m @@ -70,7 +70,7 @@ @synthesize accountsArrayController; @synthesize accountRemoveEnable; @synthesize serverURL, authUser, authToken, manual, loginEnable, loginCancelEnable; -@synthesize syncActive, syncDirectoryPath, syncAccountsDictionary, syncApplyEnable, syncCancelEnable, +@synthesize syncActive, syncSkipHidden, syncDirectoryPath, syncAccountsDictionary, syncApplyEnable, syncCancelEnable, syncAccountsOutlineView, syncAccountsRootFilesNodes; @synthesize groupsDictionaryController, selectedGroupMembersDictionaryController; @@ -91,7 +91,7 @@ // // Select the first tab when the window is loaded for the first time. // [[window valueForKeyPath:@"toolbar"] setSelectedItemIdentifier:@"0"]; - [[[syncAccountsOutlineView tableColumns] objectAtIndex:1] setDataCell:[[[PithosPreferencesSyncOutlineViewCell alloc] init] autorelease]]; + [[[syncAccountsOutlineView tableColumns] objectAtIndex:1] setDataCell:[[PithosPreferencesSyncOutlineViewCell alloc] init]]; syncAccountsMyAccountNode = [[PithosEmptyNode alloc] initWithDisplayName:@"" icon:[[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(kUserIcon)]]; @@ -155,12 +155,14 @@ BOOL isDirectory; self.syncApplyEnable = (selectedPithosAccount.active && ((selectedPithosAccount.syncActive != syncActive) || + (selectedPithosAccount.syncSkipHidden != syncSkipHidden) || (![selectedPithosAccount.syncDirectoryPath isEqualToString:syncDirectoryPath] && (![[NSFileManager defaultManager] fileExistsAtPath:syncDirectoryPath isDirectory:&isDirectory] || isDirectory)) || ![selectedPithosAccount.syncAccountsDictionary isEqualToDictionary:syncAccountsDictionary])); self.syncCancelEnable = (selectedPithosAccount.active && ((selectedPithosAccount.syncActive != syncActive) || + (selectedPithosAccount.syncSkipHidden != syncSkipHidden) || ![selectedPithosAccount.syncDirectoryPath isEqualToString:syncDirectoryPath] || ![selectedPithosAccount.syncAccountsDictionary isEqualToDictionary:syncAccountsDictionary])); } @@ -172,8 +174,7 @@ if (aSelectedPithosAccount && ![aSelectedPithosAccount isEqualTo:selectedPithosAccount]) { selectedPithosAccount.accountNode.childrenUpdatedNotificationName = nil; selectedPithosAccount.sharingAccountsNode.childrenUpdatedNotificationName = nil; - [selectedPithosAccount release]; - selectedPithosAccount = [aSelectedPithosAccount retain]; + selectedPithosAccount = aSelectedPithosAccount; selectedPithosAccount.accountNode.childrenUpdatedNotificationName = @"SelectedPithosAccountNodeChildrenUpdated"; selectedPithosAccount.sharingAccountsNode.childrenUpdatedNotificationName = @"SelectedPithosAccountNodeChildrenUpdated"; @@ -187,19 +188,16 @@ #pragma Login Properties - (void)setServerURL:(NSString *)aServerURL { - [serverURL release]; serverURL = [aServerURL copy]; [self updateLogin]; } - (void)setAuthUser:(NSString *)anAuthUser { - [authUser release]; authUser = [anAuthUser copy]; [self updateLogin]; } - (void)setAuthToken:(NSString *)anAuthToken { - [authToken release]; authToken = [anAuthToken copy]; [self updateLogin]; } @@ -220,14 +218,18 @@ [self updateSync]; } +- (void)setSyncSkipHidden:(BOOL)aSyncSkipHidden { + syncSkipHidden = aSyncSkipHidden; + [self updateSync]; + [self selectedPithosAccountNodeChildrenUpdated:nil]; +} + - (void)setSyncDirectoryPath:(NSString *)aSyncDirectoryPath { - [syncDirectoryPath release]; syncDirectoryPath = [aSyncDirectoryPath copy]; [self updateSync]; } - (void)setSyncAccountsDictionary:(NSMutableDictionary *)aSyncAccountsDictionary { - [syncAccountsDictionary release]; syncAccountsDictionary = [[NSMutableDictionary alloc] initWithCapacity:[aSyncAccountsDictionary count]]; for (NSString *accountName in aSyncAccountsDictionary) { NSDictionary *aSyncContainersDictionary = [aSyncAccountsDictionary objectForKey:accountName]; @@ -258,17 +260,16 @@ [self updateAccounts]; if (!accountRemoveEnable) return; - PithosAccount *removedPithosAccount = [selectedPithosAccount retain]; + PithosAccount *removedPithosAccount = selectedPithosAccount; pithos_macosAppDelegate *delegate = (pithos_macosAppDelegate *)[[NSApplication sharedApplication] delegate]; if ([delegate.currentPithosAccount isEqualTo:removedPithosAccount] && [delegate.pithosBrowserController operationsPending]) { - NSAlert *alert = [[[NSAlert alloc] init] autorelease]; + NSAlert *alert = [[NSAlert alloc] init]; [alert setMessageText:@"Operations Pending"]; [alert setInformativeText:@"There are pending operations in the browser, do you want to remove the account and cancel them?"]; [alert addButtonWithTitle:@"OK"]; [alert addButtonWithTitle:@"Cancel"]; NSInteger choice = [alert runModal]; if (choice == NSAlertSecondButtonReturn) { - [removedPithosAccount release]; return; } } @@ -276,7 +277,6 @@ [delegate.pithosAccountsDictionary removeObjectForKey:removedPithosAccount.name]; [delegate removedPithosAccount:removedPithosAccount]; [delegate savePithosAccounts:self]; - [removedPithosAccount release]; [self updateAccounts]; } @@ -312,7 +312,8 @@ - (IBAction)syncApply:(id)sender { [selectedPithosAccount updateSyncWithSyncActive:syncActive syncDirectoryPath:syncDirectoryPath - syncAccountsDictionary:syncAccountsDictionary]; + syncAccountsDictionary:syncAccountsDictionary + syncSkipHidden:syncSkipHidden]; [self updateSync]; pithos_macosAppDelegate *delegate = (pithos_macosAppDelegate *)[[NSApplication sharedApplication] delegate]; [delegate savePithosAccounts:self]; @@ -324,7 +325,7 @@ self.syncDirectoryPath = selectedPithosAccount.syncDirectoryPath; self.syncAccountsDictionary = selectedPithosAccount.syncAccountsDictionary; self.syncAccountsRootFilesNodes = [NSMutableDictionary dictionary]; - [self selectedPithosAccountNodeChildrenUpdated:nil]; + self.syncSkipHidden = selectedPithosAccount.syncSkipHidden; } - (IBAction)syncRefresh:(id)sender { @@ -395,7 +396,7 @@ // We add 1 for the root files node NSInteger subdirCount = 1; for (PithosNode *node in containerNode.children) { - if ([node class] == [PithosSubdirNode class]) + if (([node class] == [PithosSubdirNode class]) && (!syncSkipHidden || ![node.displayName hasPrefix:@"."])) subdirCount++; } return subdirCount; @@ -435,7 +436,7 @@ PithosContainerNode *containerNode = (PithosContainerNode *)item; NSInteger currentSubdirIndex = -1; for (PithosNode *node in containerNode.children) { - if ([node class] == [PithosSubdirNode class]) { + if (([node class] == [PithosSubdirNode class]) && (!syncSkipHidden || ![node.displayName hasPrefix:@"."])) { currentSubdirIndex++; if (currentSubdirIndex == index) return node; @@ -450,9 +451,8 @@ if (!rootFilesNode) { if (![syncAccountsRootFilesNodes objectForKey:accountName]) [syncAccountsRootFilesNodes setObject:[NSMutableDictionary dictionary] forKey:accountName]; - rootFilesNode = [[[PithosEmptyNode alloc] initWithDisplayName:@"" - icon:[[NSWorkspace sharedWorkspace] iconForFileType:@""]] - autorelease]; + rootFilesNode = [[PithosEmptyNode alloc] initWithDisplayName:@"" + icon:[[NSWorkspace sharedWorkspace] iconForFileType:@""]]; rootFilesNode.parent = containerNode; [[syncAccountsRootFilesNodes objectForKey:accountName] setObject:rootFilesNode forKey:containerNode.displayName]; } @@ -654,7 +654,8 @@ } NSMutableSet *newContainerExcludeDirectories = [NSMutableSet setWithObject:@""]; for (PithosNode *siblingNode in node.parent.children) { - if ([siblingNode class] == [PithosSubdirNode class]) { + if (([siblingNode class] == [PithosSubdirNode class]) && + (!syncSkipHidden || ![siblingNode.displayName hasPrefix:@"."])) { NSString *siblingDirectoryName = [[siblingNode.displayName lowercaseString] stringByReplacingOccurrencesOfString:@"/" withString:@":"]; if (![siblingDirectoryName isEqualToString:directoryName] && @@ -693,7 +694,8 @@ } NSMutableSet *newContainerExcludeDirectories = [NSMutableSet set]; for (PithosNode *siblingNode in node.parent.children) { - if ([siblingNode class] == [PithosSubdirNode class]) { + if (([siblingNode class] == [PithosSubdirNode class]) && + (!syncSkipHidden || ![siblingNode.displayName hasPrefix:@"."])) { NSString *siblingDirectoryName = [[siblingNode.displayName lowercaseString] stringByReplacingOccurrencesOfString:@"/" withString:@":"]; if (![newContainerExcludeDirectories containsObject:siblingDirectoryName])