Convert to Objective-C ARC
[pithos-macos] / pithos-macos / PithosPreferencesController.m
index 35f24f2..c978c02 100644 (file)
@@ -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:@"<my account>" 
                                                                         icon:[[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(kUserIcon)]];
     
     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]));
 }
     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";
         
 #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];
 }
     [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];
     [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;
         }
     }
     [delegate.pithosAccountsDictionary removeObjectForKey:removedPithosAccount.name];
     [delegate removedPithosAccount:removedPithosAccount];
     [delegate savePithosAccounts:self];
-    [removedPithosAccount release];
     [self updateAccounts];
 }
 
 - (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];
     self.syncDirectoryPath = selectedPithosAccount.syncDirectoryPath;
     self.syncAccountsDictionary = selectedPithosAccount.syncAccountsDictionary;
     self.syncAccountsRootFilesNodes = [NSMutableDictionary dictionary];
-    [self selectedPithosAccountNodeChildrenUpdated:nil];
+    self.syncSkipHidden = selectedPithosAccount.syncSkipHidden;
 }
 
 - (IBAction)syncRefresh:(id)sender {
                 // 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;
             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;
                 if (!rootFilesNode) {
                     if (![syncAccountsRootFilesNodes objectForKey:accountName])
                         [syncAccountsRootFilesNodes setObject:[NSMutableDictionary dictionary] forKey:accountName];
-                    rootFilesNode = [[[PithosEmptyNode alloc] initWithDisplayName:@"<root files>" 
-                                                                             icon:[[NSWorkspace sharedWorkspace] iconForFileType:@""]] 
-                                     autorelease];
+                    rootFilesNode = [[PithosEmptyNode alloc] initWithDisplayName:@"<root files>" 
+                                                                             icon:[[NSWorkspace sharedWorkspace] iconForFileType:@""]];
                     rootFilesNode.parent = containerNode;
                     [[syncAccountsRootFilesNodes objectForKey:accountName] setObject:rootFilesNode forKey:containerNode.displayName];
                 }
                         }
                         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] && 
                         }
                         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])