Revision cb6abe72 pithos-macos/PithosBrowserController.m

b/pithos-macos/PithosBrowserController.m
211 211
    [activityProgressIndicator setMaxValue:1.0];
212 212
    activityFacility = [PithosActivityFacility defaultPithosActivityFacility];
213 213
    
214
    self.accountNode = [[[PithosAccountNode alloc] initWithPithos:pithos] autorelease];
214
    self.accountNode = [[PithosAccountNode alloc] initWithPithos:pithos];
215 215
    containersNode = [[PithosEmptyNode alloc] initWithDisplayName:@"CONTAINERS" icon:nil];
216 216
    containersNodeChildren = [[NSMutableArray alloc] init];
217 217
    sharedNode = [[PithosEmptyNode alloc] initWithDisplayName:@"SHARED" icon:nil];
......
223 223
    othersSharedNode.displayName = @"shared to me";
224 224
    othersSharedNode.icon = [[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(kGroupIcon)];
225 225
    
226
    [[[outlineView tableColumns] objectAtIndex:0] setDataCell:[[[PithosOutlineViewCell alloc] init] autorelease]];
226
    [[[outlineView tableColumns] objectAtIndex:0] setDataCell:[[PithosOutlineViewCell alloc] init]];
227 227
    
228 228
    // Register for updates
229 229
    // PithosAccountNode accountNode updates outlineView container nodes 
......
250 250
    }
251 251

  
252 252
    [refreshTimer invalidate];
253
    [refreshTimer release];
254 253
    
255 254
    [moveNetworkQueue reset];
256 255
    [copyNetworkQueue reset];
......
346 345
//    [activityFacility reset];
347 346
    activityFacility.delegate = self;
348 347
            
349
    refreshTimer = [[NSTimer scheduledTimerWithTimeInterval:REFRESH_TIMER_INTERVAL 
348
    refreshTimer = [NSTimer scheduledTimerWithTimeInterval:REFRESH_TIMER_INTERVAL 
350 349
                                                     target:self 
351 350
                                                   selector:@selector(forceRefresh:) 
352 351
                                                   userInfo:self 
353
                                                    repeats:YES] retain];
352
                                                    repeats:YES];
354 353
    @synchronized(self) {
355 354
        browserActive = YES;
356 355
    }
......
377 376
- (void)dealloc {
378 377
    [[NSNotificationCenter defaultCenter] removeObserver:self];
379 378
    [self resetBrowser];
380
    [moveQueue release];
381
    [copyQueue release];
382
    [deleteQueue release];
383
    [uploadQueue release];
384
    [downloadQueue release];
385
    [moveNetworkQueue release];
386
    [copyNetworkQueue release];
387
    [deleteNetworkQueue release];
388
    [uploadNetworkQueue release];
389
    [downloadNetworkQueue release];
390
    [clipboardParentNode release];
391
    [clipboardNodes release];
392
    [draggedParentNode release];
393
    [draggedNodes release];
394
    [sharedPreviewController release];
395
    [othersSharedNode release];
396
    [mySharedNode release];
397
    [sharedNode release];
398
    [containersNodeChildren release];
399
    [containersNode release];
400
    [accountNode release];
401
    [rootNode release];
402
    [pithos release];
403
    [super dealloc];
404 379
}
405 380

  
406 381
- (void)setPithos:(ASIPithos *)aPithos {
......
410 385
            ![aPithos.storageURLPrefix isEqualToString:pithos.storageURLPrefix] ||
411 386
            ![aPithos.publicURLPrefix isEqualToString:pithos.publicURLPrefix]) {
412 387
            [self resetBrowser];
413
            [pithos release];
414
            pithos = [aPithos retain];
388
            pithos = aPithos;
415 389
            [self startBrowser];
416 390
        } else {
417 391
            [self startBrowser];
......
630 604
                                              isDirectory:&isDirectory 
631 605
                                           sharingAccount:nil]) {
632 606
                    dispatch_async(dispatch_get_main_queue(), ^{
633
                        NSAlert *alert = [[[NSAlert alloc] init] autorelease];
607
                        NSAlert *alert = [[NSAlert alloc] init];
634 608
                        [alert setMessageText:@"Name Taken"];
635 609
                        [alert setInformativeText:[NSString stringWithFormat:@"The name '%@' is already taken. Please choose a different name", newName]];
636 610
                        [alert addButtonWithTitle:@"OK"];
......
698 672
                                              isDirectory:&isDirectory 
699 673
                                           sharingAccount:nil]) {
700 674
                    dispatch_async(dispatch_get_main_queue(), ^{
701
                        NSAlert *alert = [[[NSAlert alloc] init] autorelease];
675
                        NSAlert *alert = [[NSAlert alloc] init];
702 676
                        [alert setMessageText:@"Name Taken"];
703 677
                        [alert setInformativeText:[NSString stringWithFormat:@"The name '%@' is already taken. Please choose a different name", newName]];
704 678
                        [alert addButtonWithTitle:@"OK"];
......
801 775
        [names addObject:node.displayName];
802 776
        // If the node is a subdir ask if the whole tree should be downloaded
803 777
        if ([node class] == [PithosSubdirNode class]) {
804
            NSAlert *alert = [[[NSAlert alloc] init] autorelease];
778
            NSAlert *alert = [[NSAlert alloc] init];
805 779
            [alert setMessageText:@"Download directory"];
806 780
            [alert setInformativeText:[NSString stringWithFormat:@"'%@' is a directory, do you want to download its contents?", node.displayName]];
807 781
            [alert addButtonWithTitle:@"OK"];
......
942 916
    } else {
943 917
        [menuNodes addObject:[browser itemAtIndexPath:clickedNodeIndexPath]];
944 918
    }
945
    NSMenuItem *menuItem = [[[NSMenuItem alloc] init] autorelease];
919
    NSMenuItem *menuItem = [[NSMenuItem alloc] init];
946 920
    menuItem.representedObject = menuNodes;
947 921
    [self menuDownload:menuItem];
948 922
}
......
1166 1140
                [uploadQueue addOperation:operation];
1167 1141
            } else {
1168 1142
                // Upload directory, confirm first
1169
                NSAlert *alert = [[[NSAlert alloc] init] autorelease];
1143
                NSAlert *alert = [[NSAlert alloc] init];
1170 1144
                [alert setMessageText:@"Upload directory"];
1171 1145
                [alert setInformativeText:[NSString stringWithFormat:@"'%@' is a directory, do you want to upload it and its contents?", filePath]];
1172 1146
                [alert addButtonWithTitle:@"OK"];
......
1562 1536
        return;
1563 1537
    }
1564 1538
    // Add an operation to the callbackQueue with a completionBlock for the case of cancellation
1565
    NSInvocationOperation *operation = [[[NSInvocationOperation alloc] initWithTarget:self 
1539
    NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self 
1566 1540
                                                                             selector:NSSelectorFromString([request.userInfo objectForKey:@"didFinishSelector"]) 
1567
                                                                               object:request] autorelease];
1541
                                                                               object:request];
1568 1542
    operation.completionBlock = ^{
1569 1543
        @autoreleasepool {
1570 1544
            if ([[request.userInfo objectForKey:@"operation"] isCancelled]) {
......
1606 1580
            return;
1607 1581
        }
1608 1582
        // Add an operation to the callbackQueue with a completionBlock for the case of cancellation
1609
        NSInvocationOperation *operation = [[[NSInvocationOperation alloc] initWithTarget:self 
1583
        NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self 
1610 1584
                                                                                 selector:NSSelectorFromString([request.userInfo objectForKey:@"didFailSelector"]) 
1611
                                                                                   object:request] autorelease];
1585
                                                                                   object:request];
1612 1586
        operation.completionBlock = ^{
1613 1587
            @autoreleasepool {
1614 1588
                if ([[request.userInfo objectForKey:@"operation"] isCancelled]) {
......
1639 1613
        }
1640 1614
        NSUInteger retries = [[request.userInfo objectForKey:@"retries"] unsignedIntegerValue];
1641 1615
        if (retries > 0) {
1642
            ASIPithosRequest *newRequest = (ASIPithosRequest *)[[PithosUtilities copyRequest:request] autorelease];
1616
            ASIPithosRequest *newRequest = (ASIPithosRequest *)[PithosUtilities copyRequest:request];
1643 1617
            [(NSMutableDictionary *)(newRequest.userInfo)setObject:[NSNumber numberWithUnsignedInteger:(--retries)] forKey:@"retries"];
1644 1618
            [(NSMutableDictionary *)(newRequest.userInfo)setObject:[NSNumber numberWithBool:NO] forKey:@"unexpectedResponseStatus"];
1645 1619
            [[newRequest.userInfo objectForKey:@"networkQueue"] addOperation:[PithosUtilities prepareRequest:newRequest priority:[[newRequest.userInfo objectForKey:@"priority"] integerValue]]];
......
1680 1654
                if (![fileManager fileExistsAtPath:filePath]) {
1681 1655
                    if (![fileManager createFileAtPath:filePath contents:nil attributes:nil]) {
1682 1656
                        dispatch_async(dispatch_get_main_queue(), ^{
1683
                            NSAlert *alert = [[[NSAlert alloc] init] autorelease];
1657
                            NSAlert *alert = [[NSAlert alloc] init];
1684 1658
                            [alert setMessageText:@"Create File Error"];
1685 1659
                            [alert setInformativeText:[NSString stringWithFormat:@"Cannot create zero length file at %@", filePath]];
1686 1660
                            [alert addButtonWithTitle:@"OK"];
......
1770 1744
                dispatch_async(dispatch_get_main_queue(), ^{
1771 1745
                    [activityFacility endActivity:activity 
1772 1746
                                      withMessage:[objectRequest.userInfo objectForKey:@"failedActivityMessage"]]; 
1773
                    NSAlert *alert = [[[NSAlert alloc] init] autorelease];
1747
                    NSAlert *alert = [[NSAlert alloc] init];
1774 1748
                    [alert setMessageText:@"Upload Timeout"];
1775 1749
                    [alert setInformativeText:[NSString stringWithFormat:@"Upload iteration limit reached for object with path '%@'", 
1776 1750
                                               [objectRequest.userInfo objectForKey:@"objectName"]]];
......
2175 2149
            return;
2176 2150
        // New Folder
2177 2151
        if (!menuNode.shared && !menuNode.sharingAccount) {
2178
            menuItem = [[[NSMenuItem alloc] initWithTitle:@"New Folder" action:@selector(menuNewFolder:) keyEquivalent:@""] autorelease];
2152
            menuItem = [[NSMenuItem alloc] initWithTitle:@"New Folder" action:@selector(menuNewFolder:) keyEquivalent:@""];
2179 2153
            [menuItem setRepresentedObject:menuNode];
2180 2154
            [menu addItem:menuItem];
2181 2155
            [menu addItem:[NSMenuItem separatorItem]];
2182 2156
        }
2183 2157
        // Refresh
2184
        menuItem = [[[NSMenuItem alloc] initWithTitle:@"Refresh" action:@selector(refresh:) keyEquivalent:@""] autorelease];
2158
        menuItem = [[NSMenuItem alloc] initWithTitle:@"Refresh" action:@selector(refresh:) keyEquivalent:@""];
2185 2159
        [menu addItem:menuItem];
2186 2160
        [menu addItem:[NSMenuItem separatorItem]];
2187 2161
        // Get Info
2188
        menuItem = [[[NSMenuItem alloc] initWithTitle:(([menuNode class] == [PithosContainerNode class]) ? @"Info" : @"Info and Sharing") 
2162
        menuItem = [[NSMenuItem alloc] initWithTitle:(([menuNode class] == [PithosContainerNode class]) ? @"Info" : @"Info and Sharing") 
2189 2163
                                               action:@selector(menuGetInfo:) 
2190
                                        keyEquivalent:@""] autorelease];
2164
                                        keyEquivalent:@""];
2191 2165
        [menuItem setRepresentedObject:[NSArray arrayWithObject:menuNode]];
2192 2166
        [menu addItem:menuItem];
2193 2167
        // Paste
......
2204 2178
                else
2205 2179
                    menuItemTitle = @"Paste Items";
2206 2180
                [menu addItem:[NSMenuItem separatorItem]];
2207
                menuItem = [[[NSMenuItem alloc] initWithTitle:menuItemTitle action:@selector(menuPaste:) keyEquivalent:@""] autorelease];
2181
                menuItem = [[NSMenuItem alloc] initWithTitle:menuItemTitle action:@selector(menuPaste:) keyEquivalent:@""];
2208 2182
                [menuItem setRepresentedObject:menuNode];
2209 2183
                [menu addItem:menuItem];
2210 2184
            }
......
2215 2189
        PithosNode *firstMenuNode = [menuNodes objectAtIndex:0];
2216 2190
        // Download
2217 2191
        if (([firstMenuNode class] != [PithosContainerNode class]) && ([firstMenuNode class] != [PithosAccountNode class])) {
2218
            menuItem = [[[NSMenuItem alloc] initWithTitle:@"Download" action:@selector(menuDownload:) keyEquivalent:@""] autorelease];
2192
            menuItem = [[NSMenuItem alloc] initWithTitle:@"Download" action:@selector(menuDownload:) keyEquivalent:@""];
2219 2193
            [menuItem setRepresentedObject:menuNodes];
2220 2194
            [menu addItem:menuItem];
2221 2195
            [menu addItem:[NSMenuItem separatorItem]];
......
2224 2198
        // Delete
2225 2199
        if (!firstMenuNode.shared && !firstMenuNode.sharingAccount && ([rootNode class] == [PithosContainerNode class])) {
2226 2200
            if ([rootNode.pithosContainer.name isEqualToString:@"pithos"]) {
2227
                menuItem = [[[NSMenuItem alloc] initWithTitle:@"Move to Trash" 
2201
                menuItem = [[NSMenuItem alloc] initWithTitle:@"Move to Trash" 
2228 2202
                                                       action:@selector(menuMoveToTrash:) 
2229
                                                keyEquivalent:@""] autorelease];
2203
                                                keyEquivalent:@""];
2230 2204
                [menuItem setRepresentedObject:menuNodes];
2231 2205
                [menu addItem:menuItem];
2232 2206
            }
2233
            menuItem = [[[NSMenuItem alloc] initWithTitle:@"Delete" action:@selector(menuDelete:) keyEquivalent:@""] autorelease];
2207
            menuItem = [[NSMenuItem alloc] initWithTitle:@"Delete" action:@selector(menuDelete:) keyEquivalent:@""];
2234 2208
            [menuItem setRepresentedObject:menuNodes];
2235 2209
            [menu addItem:menuItem];
2236 2210
            [menu addItem:[NSMenuItem separatorItem]];
2237 2211
        }
2238 2212
        // Refresh
2239
        menuItem = [[[NSMenuItem alloc] initWithTitle:@"Refresh" action:@selector(refresh:) keyEquivalent:@""] autorelease];
2213
        menuItem = [[NSMenuItem alloc] initWithTitle:@"Refresh" action:@selector(refresh:) keyEquivalent:@""];
2240 2214
        [menu addItem:menuItem];
2241 2215
        // Get Info
2242 2216
        if (!firstMenuNode.sharingAccount || ([firstMenuNode class] != [PithosAccountNode class])) {
2243 2217
            [menu addItem:[NSMenuItem separatorItem]];
2244
            menuItem = [[[NSMenuItem alloc] initWithTitle:(([firstMenuNode class] == [PithosContainerNode class]) ? @"Info" : @"Info and Sharing") 
2218
            menuItem = [[NSMenuItem alloc] initWithTitle:(([firstMenuNode class] == [PithosContainerNode class]) ? @"Info" : @"Info and Sharing") 
2245 2219
                                                   action:@selector(menuGetInfo:) 
2246
                                            keyEquivalent:@""] autorelease];
2220
                                            keyEquivalent:@""];
2247 2221
            [menuItem setRepresentedObject:menuNodes];
2248 2222
            [menu addItem:menuItem];
2249 2223
            
......
2256 2230
                menuItemTitle = [NSString stringWithFormat:@"Cut \"%@\"", ((PithosNode *)[menuNodes objectAtIndex:0]).displayName];
2257 2231
            else 
2258 2232
                menuItemTitle = [NSString stringWithFormat:@"Cut %lu Items", menuNodesCount];
2259
            menuItem = [[[NSMenuItem alloc] initWithTitle:menuItemTitle action:@selector(menuCut:) keyEquivalent:@""] autorelease];
2233
            menuItem = [[NSMenuItem alloc] initWithTitle:menuItemTitle action:@selector(menuCut:) keyEquivalent:@""];
2260 2234
            [menuItem setRepresentedObject:menuNodes];
2261 2235
            [menu addItem:menuItem];
2262 2236
        }
......
2267 2241
                menuItemTitle = [NSString stringWithFormat:@"Copy \"%@\"", ((PithosNode *)[menuNodes objectAtIndex:0]).displayName];
2268 2242
            else 
2269 2243
                menuItemTitle = [NSString stringWithFormat:@"Copy %lu Items", menuNodesCount];
2270
            menuItem = [[[NSMenuItem alloc] initWithTitle:menuItemTitle action:@selector(menuCopy:) keyEquivalent:@""] autorelease];
2244
            menuItem = [[NSMenuItem alloc] initWithTitle:menuItemTitle action:@selector(menuCopy:) keyEquivalent:@""];
2271 2245
            [menuItem setRepresentedObject:menuNodes];
2272 2246
            [menu addItem:menuItem];
2273 2247
        }
......
2283 2257
                    menuItemTitle = @"Paste Item";
2284 2258
                else
2285 2259
                    menuItemTitle = @"Paste Items";
2286
                menuItem = [[[NSMenuItem alloc] initWithTitle:menuItemTitle action:@selector(menuPaste:) keyEquivalent:@""] autorelease];
2260
                menuItem = [[NSMenuItem alloc] initWithTitle:menuItemTitle action:@selector(menuPaste:) keyEquivalent:@""];
2287 2261
                [menuItem setRepresentedObject:firstMenuNode];
2288 2262
                [menu addItem:menuItem];
2289 2263
            }
......
2752 2726
    }
2753 2727
    
2754 2728
    if (!message)
2755
        message = [[[[UsingSizeTransformer alloc] init] autorelease] transformedValue:accountNode.pithosAccount];
2729
        message = [[[UsingSizeTransformer alloc] init] transformedValue:accountNode.pithosAccount];
2756 2730
    [activityTextField setStringValue:message];
2757 2731
}
2758 2732

  

Also available in: Unified diff