Changeset 4182

Show
Ignore:
Timestamp:
06/02/06 17:30:43 (2 years ago)
Author:
morris
Message:

Add WCFilesController, a common abstract class for WCFiles and WCSearch

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • WiredClient/trunk/English.lproj/Files.nib/classes.nib

    r4180 r4182  
    2626                deleteFiles = id;  
    2727                down = id;  
    28                 download = id;  
    2928                forward = id;  
    30                 getInfo = id;  
    3129                list = id;  
    3230                preview = id;  
     
    4341                "_createFolderPopUpButton" = NSPopUpButton;  
    4442                "_createFolderTextField" = NSTextField;  
    45                 "_createdTableColumn" = NSTableColumn;  
    4643                "_deleteButton" = NSButton;  
    4744                "_downloadButton" = NSButton;  
    4845                "_filesBrowser" = NSBrowser;  
    4946                "_filesTabView" = NSTabView;  
    50                 "_filesTableView" = WITableView;  
    5147                "_forwardButton" = NSButton;  
    5248                "_infoButton" = NSButton;  
     49                "_previewButton" = NSButton;  
     50                "_reloadButton" = NSButton;  
     51                "_styleMatrix" = NSMatrix;  
     52                "_titleBarMenu" = NSMenu;  
     53                "_uploadButton" = NSButton;  
     54            };  
     55            SUPERCLASS = WCFiles2;  
     56        },  
     57        { 
     58            ACTIONS = {download = id; getInfo = id; };  
     59            CLASS = WCFiles2;  
     60            LANGUAGE = ObjC;  
     61            OUTLETS = { 
     62                "_createdTableColumn" = NSTableColumn;  
     63                "_filesTableView" = WITableView;  
    5364                "_kindTableColumn" = NSTableColumn;  
    5465                "_modifiedTableColumn" = NSTableColumn;  
    5566                "_nameTableColumn" = NSTableColumn;  
    56                 "_previewButton" = NSButton;  
    5767                "_progressIndicator" = NSProgressIndicator;  
    58                 "_reloadButton" = NSButton;  
    5968                "_sizeTableColumn" = NSTableColumn;  
    6069                "_statusTextField" = NSTextField;  
    61                 "_styleMatrix" = NSMatrix;  
    62                 "_titleBarMenu" = NSMenu;  
    63                 "_uploadButton" = NSButton;  
    6470            };  
    6571            SUPERCLASS = WCConnectionController;  
  • WiredClient/trunk/English.lproj/Files.nib/info.nib

    r4180 r4182  
    44<dict> 
    55        <key>IBDocumentLocation</key> 
    6         <string>124 163 398 359 0 0 1920 1178 </string> 
     6        <string>302 134 398 359 0 0 1920 1178 </string> 
    77        <key>IBEditorPositions</key> 
    88        <dict> 
     
    1818        <key>IBOpenObjects</key> 
    1919        <array> 
     20                <integer>5</integer> 
    2021                <integer>52</integer> 
    2122                <integer>161</integer> 
    22                 <integer>5</integer> 
    2323        </array> 
    2424        <key>IBSystem Version</key> 
  • WiredClient/trunk/English.lproj/Search.nib/classes.nib

    r3621 r4182  
    1515        },  
    1616        { 
    17             ACTIONS = {download = id; getInfo = id; open = id; revealInFiles = id; search = id; };  
    18             CLASS = WCSearch;  
     17            ACTIONS = {download = id; getInfo = id; };  
     18            CLASS = WCFiles2;  
    1919            LANGUAGE = ObjC;  
    2020            OUTLETS = { 
    2121                "_createdTableColumn" = NSTableColumn;  
    22                 "_downloadMenuItem" = NSMenuItem;  
    23                 "_getInfoMenuItem" = NSMenuItem;  
    24                 "_kindPopUpButton" = NSPopUpButton;  
     22                "_filesTableView" = WITableView;  
    2523                "_kindTableColumn" = NSTableColumn;  
    2624                "_modifiedTableColumn" = NSTableColumn;  
    2725                "_nameTableColumn" = NSTableColumn;  
    28                 "_openMenuItem" = NSMenuItem;  
    2926                "_progressIndicator" = NSProgressIndicator;  
    30                 "_revealInFilesMenuItem" = NSMenuItem;  
    31                 "_searchButton" = NSButton;  
    32                 "_searchTableView" = WITableView;  
    33                 "_searchTextField" = NSTextField;  
    3427                "_sizeTableColumn" = NSTableColumn;  
    3528                "_statusTextField" = NSTextField;  
    3629            };  
    3730            SUPERCLASS = WCConnectionController;  
     31        },  
     32        {CLASS = WCFilesTableView; LANGUAGE = ObjC; SUPERCLASS = WITableView; },  
     33        { 
     34            ACTIONS = {open = id; revealInFiles = id; search = id; };  
     35            CLASS = WCSearch;  
     36            LANGUAGE = ObjC;  
     37            OUTLETS = { 
     38                "_kindPopUpButton" = NSPopUpButton;  
     39                "_searchButton" = NSButton;  
     40                "_searchTextField" = NSTextField;  
     41            };  
     42            SUPERCLASS = WCFiles2;  
    3843        },  
    3944        { 
  • WiredClient/trunk/English.lproj/Search.nib/info.nib

    r4146 r4182  
    88        <dict> 
    99                <key>75</key> 
    10                 <string>79 790 132 118 0 0 1280 1002 </string> 
     10                <string>123 947 132 118 0 0 1920 1178 </string> 
    1111        </dict> 
    1212        <key>IBFramework Version</key> 
     
    1616        <key>IBOpenObjects</key> 
    1717        <array> 
     18                <integer>7</integer> 
    1819                <integer>75</integer> 
    1920        </array> 
  • WiredClient/trunk/French.lproj/Search.nib/classes.nib

    r4147 r4182  
    1414            SUPERCLASS = WIWindowController;  
    1515        },  
     16        {CLASS = WCFilesTableView; LANGUAGE = ObjC; SUPERCLASS = WITableView; },  
    1617        { 
    1718            ACTIONS = {download = id; getInfo = id; open = id; revealInFiles = id; search = id; };  
  • WiredClient/trunk/French.lproj/Search.nib/info.nib

    r4147 r4182  
    44<dict> 
    55        <key>IBDocumentLocation</key> 
    6         <string>688 85 403 352 0 0 1280 1002 </string> 
     6        <string>965 80 403 352 0 0 1920 1178 </string> 
    77        <key>IBEditorPositions</key> 
    88        <dict> 
    99                <key>75</key> 
    10                 <string>859 450 206 118 0 0 1280 1002 </string> 
     10                <string>1371 540 206 118 0 0 1920 1178 </string> 
    1111        </dict> 
    1212        <key>IBFramework Version</key> 
  • WiredClient/trunk/Japanese.lproj/Search.nib/classes.nib

    r4143 r4182  
    1414            SUPERCLASS = WIWindowController;  
    1515        },  
     16        {CLASS = WCFilesTableView; LANGUAGE = ObjC; SUPERCLASS = WITableView; },  
    1617        { 
    1718            ACTIONS = {download = id; getInfo = id; open = id; revealInFiles = id; search = id; };  
  • WiredClient/trunk/WCFiles.h

    r3570 r4182  
    2727 */ 
    2828 
     29#import "WCFilesController.h" 
     30 
    2931@class WCFile; 
    3032 
    31 @interface WCFiles : WCConnectionController { 
     33@interface WCFiles : WCFilesController { 
    3234        IBOutlet NSTabView                              *_filesTabView; 
    33  
    34         IBOutlet WITableView                    *_filesTableView; 
    35         IBOutlet NSTableColumn                  *_nameTableColumn; 
    36         IBOutlet NSTableColumn                  *_kindTableColumn; 
    37         IBOutlet NSTableColumn                  *_createdTableColumn; 
    38         IBOutlet NSTableColumn                  *_modifiedTableColumn; 
    39         IBOutlet NSTableColumn                  *_sizeTableColumn; 
    4035 
    4136        IBOutlet NSBrowser                              *_filesBrowser; 
     
    5853        IBOutlet NSButton                               *_deleteButton; 
    5954 
    60         IBOutlet NSTextField                    *_statusTextField; 
    61         IBOutlet NSProgressIndicator    *_progressIndicator; 
    62  
    6355        int                                                             _type; 
    6456         
     
    7062        NSString                                                *_selectPath; 
    7163 
    72         int                                                             _column; 
    73  
    7464        NSMutableArray                                  *_history; 
    7565        unsigned int                                    _historyPosition; 
     
    7868 
    7969#define WCFilesShouldReload                     @"WCFilesShouldReload" 
    80  
    81 #define WCFilePboardType                        @"WCFilePboardType" 
    8270 
    8371#define WCFilePathKey                           @"WCFilePathKey" 
     
    9482- (IBAction)list:(id)sender; 
    9583- (IBAction)browser:(id)sender; 
    96 - (IBAction)download:(id)sender; 
    9784- (IBAction)upload:(id)sender; 
    98 - (IBAction)getInfo:(id)sender; 
    9985- (IBAction)preview:(id)sender; 
    10086- (IBAction)createFolder:(id)sender; 
  • WiredClient/trunk/WCFiles.m

    r4180 r4182  
    3333#import "WCFiles.h" 
    3434#import "WCFilesBrowserCell.h" 
    35 #import "WCPreferences.h" 
    3635#import "WCPreview.h" 
    3736#import "WCTransfers.h" 
     
    4443- (WCFile *)_currentPath; 
    4544 
    46 - (WCFile *)_fileAtIndex:(unsigned int)index; 
    47 - (NSArray *)_files; 
    48 - (WCFile *)_selectedFile; 
    49 - (NSArray *)_selectedFiles; 
    50 - (void)_sortFiles; 
    51  
    52 - (void)_update; 
    5345- (void)_updateMenu; 
    5446- (void)_updateFiles; 
    55 - (void)_updateStatus; 
    5647- (void)_showList; 
    5748- (void)_showBrowser; 
     
    6152- (void)_openFile:(WCFile *)file overrideNewWindow:(BOOL)override; 
    6253 
    63 - (void)_validate; 
    6454- (BOOL)_validateUpload; 
    6555- (BOOL)_validateCreateFolder; 
     
    8171        _history                = [[NSMutableArray alloc] init]; 
    8272        _allFiles               = [[NSMutableDictionary alloc] init]; 
    83         _listFiles              = [[NSMutableArray alloc] init]; 
    8473        _browserFiles   = [[NSMutableDictionary alloc] init]; 
    8574         
     
    9079         
    9180        [self _changeDirectory:[self _currentPath]]; 
    92         [self _validate]; 
    93  
     81         
     82        [self validate]; 
    9483        [self setReleasedWhenClosed:YES]; 
    9584        [self showWindow:self]; 
    9685         
    97         [[NSNotificationCenter defaultCenter] 
    98                 addObserver:self 
    99                    selector:@selector(preferencesDidChange:) 
    100                            name:WCPreferencesDidChange]; 
    101  
    10286        [[self connection] addObserver:self 
    10387                                                  selector:@selector(filesShouldReload:) 
     
    116100        [path retain]; 
    117101         
    118         switch(_type) { 
    119                 case WCFilesStyleList: 
    120                         [_listPath release]; 
    121                         _listPath = path; 
    122                         break; 
    123                          
    124                 case WCFilesStyleBrowser: 
    125                         [_browserPath release]; 
    126                         _browserPath = path; 
    127                         break; 
     102        if(_type == WCFilesStyleList) { 
     103                [_listPath release]; 
     104                _listPath = path; 
     105        } 
     106        else if(_type == WCFilesStyleBrowser) { 
     107                [_browserPath release]; 
     108                _browserPath = path; 
    128109        } 
    129110} 
     
    132113 
    133114- (WCFile *)_currentPath { 
    134         switch(_type) { 
    135                 case WCFilesStyleList: 
    136                         return _listPath; 
    137                         break; 
    138                          
    139                 case WCFilesStyleBrowser: 
    140                         return _browserPath; 
    141                         break; 
    142         } 
     115        if(_type == WCFilesStyleList) 
     116                return _listPath; 
     117        else if(_type == WCFilesStyleBrowser) 
     118                return _browserPath; 
    143119         
    144120        return NULL; 
     
    148124 
    149125#pragma mark - 
    150  
    151 - (WCFile *)_fileAtIndex:(unsigned int)index { 
    152         unsigned int    i; 
    153          
    154         i = ([_filesTableView sortOrder] == WISortDescending) 
    155                 ? [_listFiles count] - index - 1 
    156                 : index; 
    157          
    158         if(i < [_listFiles count]) 
    159                 return [_listFiles objectAtIndex:i]; 
    160          
    161         return NULL; 
    162 } 
    163  
    164  
    165  
    166 - (NSArray *)_files { 
    167         switch(_type) { 
    168                 case WCFilesStyleList: 
    169                         return _listFiles; 
    170                         break; 
    171                          
    172                 case WCFilesStyleBrowser: 
    173                         return [_browserFiles objectForKey:[[self _currentPath] path]]; 
    174                         break; 
    175         } 
    176          
    177         return NULL; 
    178 } 
    179  
    180  
    181  
    182 - (WCFile *)_selectedFile { 
    183         if(_type == WCFilesStyleList) { 
    184                 int                     row; 
    185  
    186                 row = [_filesTableView selectedRow]; 
    187  
    188                 if(row < 0) 
    189                         return NULL; 
    190  
    191                 return [self _fileAtIndex:row]; 
    192         } 
    193         else if(_type == WCFilesStyleBrowser) { 
    194                 return [[_filesBrowser selectedCell] representedObject]; 
    195         } 
    196          
    197         return NULL; 
    198 } 
    199  
    200  
    201  
    202 - (NSArray *)_selectedFiles { 
    203         NSEnumerator            *enumerator; 
    204         NSMutableArray          *array; 
    205         NSNumber                        *row; 
    206         id                                      cell; 
    207  
    208         array = [NSMutableArray array]; 
    209  
    210         if(_type == WCFilesStyleList) { 
    211                 enumerator = [_filesTableView selectedRowEnumerator]; 
    212  
    213                 while((row = [enumerator nextObject])) 
    214                         [array addObject:[self _fileAtIndex:[row intValue]]]; 
    215         } 
    216         else if(_type == WCFilesStyleBrowser) { 
    217                 enumerator = [[_filesBrowser selectedCells] objectEnumerator]; 
    218                  
    219                 while((cell = [enumerator nextObject])) 
    220                         [array addObject:[cell representedObject]]; 
    221         } 
    222          
    223         return array; 
    224 } 
    225  
    226  
    227  
    228 - (void)_sortFiles { 
    229         NSTableColumn   *tableColumn; 
    230          
    231         tableColumn = [_filesTableView highlightedTableColumn]; 
    232          
    233         if(tableColumn == _nameTableColumn) 
    234                 [_listFiles sortUsingSelector:@selector(compareName:)]; 
    235         else if(tableColumn == _kindTableColumn) 
    236                 [_listFiles sortUsingSelector:@selector(compareKind:)]; 
    237         else if(tableColumn == _createdTableColumn) 
    238                 [_listFiles sortUsingSelector:@selector(compareCreationDate:)]; 
    239         else if(tableColumn == _modifiedTableColumn) 
    240                 [_listFiles sortUsingSelector:@selector(compareModificationDate:)]; 
    241         else if(tableColumn == _sizeTableColumn) 
    242                 [_listFiles sortUsingSelector:@selector(compareSize:)]; 
    243          
    244         [[_browserFiles objectForKey:[[self _currentPath] path]] sortUsingSelector:@selector(compareName:)]; 
    245 } 
    246  
    247  
    248  
    249 #pragma mark - 
    250  
    251 - (void)_update { 
    252         [_filesTableView setFont:[WCSettings objectForKey:WCFilesFont]]; 
    253          
    254         [_filesTableView setUsesAlternatingRowBackgroundColors:[WCSettings boolForKey:WCFilesAlternateRows]]; 
    255         [_filesTableView setNeedsDisplay:YES]; 
    256          
    257         [_filesBrowser setNeedsDisplay:YES]; 
    258 } 
    259  
    260  
    261126 
    262127- (void)_updateMenu { 
     
    312177 
    313178- (void)_updateFiles { 
    314         [self _updateStatus]; 
    315         [self _sortFiles]; 
     179        [self updateStatus]; 
     180        [self sortFiles]; 
    316181 
    317182        [_filesTableView reloadData]; 
     
    337202 
    338203 
    339 - (void)_updateStatus { 
    340         NSEnumerator            *enumerator; 
    341         NSArray                         *files; 
    342         WCFile                          *file; 
    343         unsigned long long      size = 0; 
    344          
    345         files = [self _files]; 
    346         enumerator = [files objectEnumerator]; 
    347          
    348         while((file = [enumerator nextObject])) { 
    349                 if([file type] == WCFileFile) 
    350                         size += [file size]; 
    351         } 
    352          
    353         if([self _validateUpload]) { 
    354                 [_statusTextField setStringValue:[NSSWF: 
    355                         NSLS(@"%d %@, %@ total, %@ available", @"Files info (count, 'item(s)', size, available)"), 
    356                         [files count], 
    357                         [files count] == 1 
    358                                 ? NSLS(@"item", @"Item singular") 
    359                                 : NSLS(@"items", @"Item plural"), 
    360                         [NSString humanReadableStringForSize:size], 
    361                         [NSString humanReadableStringForSize:[[self _currentPath] free]]]]; 
    362         } else { 
    363                 [_statusTextField setStringValue:[NSSWF: 
    364                         NSLS(@"%d %@, %@ total", @"Files info (count, 'item(s)', size)"), 
    365                         [files count], 
    366                         [files count] == 1 
    367                                 ? NSLS(@"item", @"Item singular") 
    368                                 : NSLS(@"items", @"Item plural"), 
    369                         [NSString humanReadableStringForSize:size]]]; 
    370         } 
    371 } 
    372  
    373  
    374  
    375204- (void)_showList { 
    376205        _type = WCFilesStyleList; 
     
    380209         
    381210        [self _changeDirectory:_listPath]; 
    382         [self _validate]; 
     211        [self validate]; 
    383212 
    384213        [WCSettings setInt:_type forKey:WCFilesStyle]; 
     
    395224         
    396225        [self _changeDirectory:_browserPath]; 
    397         [self _validate]; 
     226        [self validate]; 
    398227 
    399228        [WCSettings setInt:_type forKey:WCFilesStyle]; 
     
    428257        [self _setCurrentPath:path]; 
    429258 
    430         [self _validate]; 
     259        [self validate]; 
     260        [self updateStatus]; 
     261 
    431262        [self _updateMenu]; 
    432         [self _updateStatus]; 
    433263         
    434264        [[self window] setTitle:[[self _currentPath] path] withSubtitle:[[self connection] name]]; 
     
    442272         
    443273        [_allFiles removeAllObjects]; 
    444         [_listFiles removeAllObjects]; 
     274        [_files removeAllObjects]; 
    445275        [_browserFiles removeObjectForKey:[path path]]; 
    446276         
     
    454284 
    455285        if((files = [[[self connection] cache] filesForPath:[path path] free:&free])) { 
    456                 [_listFiles setArray:files]; 
     286                [_files addObjectsFromArray:files]; 
    457287                [_browserFiles setObject:[[files mutableCopy] autorelease] forKey:[path path]]; 
    458288                 
     
    496326                                         
    497327                                        [self _changeDirectory:file]; 
    498                                         [self _validate]; 
     328                                        [self validate]; 
    499329                                } 
    500330                        } 
     
    509339 
    510340 
    511  
    512341#pragma mark - 
    513342 
    514 - (void)_validate { 
     343- (BOOL)_validateUpload { 
     344        WCAccount               *account; 
     345        WCFileType              type; 
     346         
     347        account = [[self connection] account]; 
     348        type = [[self _currentPath] type]; 
     349 
     350        return ([account uploadAnywhere] || 
     351                   ([account upload] && (type == WCFileUploads || type == WCFileDropBox))); 
     352
     353 
     354 
     355 
     356- (BOOL)_validateCreateFolder { 
     357        WCAccount               *account; 
     358        WCFileType              type; 
     359 
     360        account = [[self connection] account]; 
     361        type = [[self _currentPath] type]; 
     362 
     363        return ([account createFolders] || 
     364                        [account uploadAnywhere] || 
     365                        ([account upload] && (type == WCFileUploads || type == WCFileDropBox))); 
     366
     367 
     368@end 
     369 
     370 
     371@implementation WCFiles 
     372 
     373+ (id)filesWithConnection:(WCServerConnection *)connection path:(WCFile *)path { 
     374        return [[[self alloc] _initFilesWithConnection:connection path:path selectPath:NULL] autorelease]; 
     375
     376 
     377 
     378 
     379+ (id)filesWithConnection:(WCServerConnection *)connection path:(WCFile *)path selectPath:(NSString *)selectPath { 
     380        return [[[self alloc] _initFilesWithConnection:connection path:path selectPath:selectPath] autorelease]; 
     381
     382 
     383 
     384 
     385- (void)dealloc { 
     386        [_history release]; 
     387        [_allFiles release]; 
     388        [_browserFiles release]; 
     389         
     390        [_listPath release]; 
     391        [_browserPath release]; 
     392 
     393        [super dealloc]; 
     394
     395 
     396 
     397 
     398#pragma mark - 
     399 
     400- (void)windowDidLoad { 
     401        WIIconCell              *iconCell; 
     402 
     403        iconCell = [[WIIconCell alloc] init]; 
     404        [_nameTableColumn setDataCell:iconCell]; 
     405        [iconCell release]; 
     406 
     407        [_filesBrowser setCellClass:[WCFilesBrowserCell class]]; 
     408        [_filesBrowser setMatrixClass:[WIMatrix class]]; 
     409 
     410        [_filesBrowser setTarget:self]; 
     411        [_filesBrowser setAction:@selector(browserDidSingleClick:)]; 
     412        [_filesBrowser setDoubleAction:@selector(open:)]; 
     413        [_filesBrowser setColumnsAutosaveName:@"Files"]; 
     414        [_filesBrowser loadColumnZero]; 
     415 
     416        [_filesTableView registerForDraggedTypes: 
     417                [NSArray arrayWithObjects:WCFilePboardType, NSFilenamesPboardType, NULL]]; 
     418 
     419        [_filesTableView setDoubleAction:@selector(open:)]; 
     420        [_filesTableView setDeleteAction:@selector(deleteFiles:)]; 
     421        [_filesTableView setBackAction:@selector(back:)]; 
     422        [_filesTableView setForwardAction:@selector(forward:)]; 
     423         
     424        [_titleBarMenu removeAllItems]; 
     425 
     426        [self setShouldCascadeWindows:YES]; 
     427        [self setWindowFrameAutosaveName:@"Files"]; 
     428 
     429        [[self window] setTitle:[[self _currentPath] path] withSubtitle:[[self connection] name]]; 
     430 
     431        if(_type == WCFilesStyleList)  
     432                [self _showList]; 
     433        else if(_type == WCFilesStyleBrowser)  
     434                [self _showBrowser]; 
     435         
     436        [_styleMatrix selectCellWithTag:_type]; 
     437         
     438        [super windowDidLoad]; 
     439
     440 
     441 
     442 
     443- (void)windowWillClose:(NSNotification *)notification { 
     444        [_filesTableView setDataSource:NULL]; 
     445
     446 
     447 
     448 
     449- (NSMenu *)windowTitleBarMenu:(WIWindow *)window { 
     450        return _titleBarMenu; 
     451
     452 
     453 
     454 
     455- (NSRect)windowWillUseStandardFrame:(NSWindow *)window defaultFrame:(NSRect)defaultFrame { 
     456        NSRect          frame; 
     457         
     458        frame = [[self window] frame]; 
     459        frame.origin.y = defaultFrame.origin.y; 
     460        frame.size.height = defaultFrame.size.height; 
     461         
     462        return frame; 
     463
     464 
     465 
     466 
     467- (void)windowTemplateShouldLoad:(NSMutableDictionary *)windowTemplate { 
     468        [_filesTableView setPropertiesFromDictionary:[windowTemplate objectForKey:@"WCFilesTableView"]]; 
     469
     470 
     471 
     472 
     473- (void)windowTemplateShouldSave:(NSMutableDictionary *)windowTemplate { 
     474        [windowTemplate setObject:[_filesTableView propertiesDictionary] forKey:@"WCFilesTableView"]; 
     475
     476 
     477 
     478 
     479- (void)connectionDidClose:(NSNotification *)notification { 
     480        [self validate]; 
     481
     482 
     483 
     484 
     485- (void)connectionWillTerminate:(NSNotification *)notification { 
     486        [self close]; 
     487
     488 
     489 
     490 
     491- (void)serverConnectionPrivilegesDidChange:(NSNotification *)notification { 
     492        [self validate]; 
     493
     494 
     495 
     496 
     497- (void)serverConnectionLoggedIn:(NSNotification *)notification { 
     498        [self validate]; 
     499
     500 
     501 
     502 
     503- (void)serverConnectionServerInfoDidChange:(NSNotification *)notification { 
     504        [[self window] setTitle:[[self _currentPath] path] withSubtitle:[[self connection] name]]; 
     505
     506 
     507 
     508 
     509- (void)filesReceivedFile:(NSNotification *)notification { 
     510        WCFile          *file; 
     511 
     512        file = [WCFile fileWithListArguments:[[notification userInfo] objectForKey:WCArgumentsKey]]; 
     513         
     514        if(![[[file path] stringByDeletingLastPathComponent] isEqualToString:[[self _currentPath] path]]) 
     515                return; 
     516 
     517        if(![_allFiles objectForKey:[file name]]) 
     518                [_allFiles setObject:file forKey:[file name]]; 
     519
     520 
     521 
     522 
     523- (void)filesCompletedFiles:(NSNotification *)notification { 
     524        NSString        *path, *free; 
     525        NSArray         *fields; 
     526 
     527        fields  = [[notification userInfo] objectForKey:WCArgumentsKey]; 
     528        path    = [fields safeObjectAtIndex:0]; 
     529        free    = [fields safeObjectAtIndex:1]; 
     530 
     531        if(![path isEqualToString:[[self _currentPath] path]]) 
     532                return; 
     533 
     534        [[self _currentPath] setFree:[free unsignedLongLongValue]]; 
     535 
     536        [_files setArray:[_allFiles allValues]]; 
     537         
     538        [_browserFiles setObject:[[[_allFiles allValues] mutableCopy] autorelease] 
     539                                          forKey:path]; 
     540 
     541        [[[self connection] cache] setFiles:[[[_allFiles allValues] mutableCopy] autorelease] 
     542                                                                   free:[[self _currentPath] free] 
     543                                                                forPath:[[self _currentPath] path]]; 
     544         
     545        [self _updateFiles]; 
     546 
     547        [[self connection] removeObserver:self name:WCFilesReceivedFile]; 
     548        [[self connection] removeObserver:self name:WCFilesCompletedFiles]; 
     549
     550 
     551 
     552 
     553- (void)filesShouldReload:(NSNotification *)notification { 
     554        NSString        *path, *selectPath; 
     555 
     556        path = [[notification userInfo] objectForKey:WCFilePathKey]; 
     557        selectPath = [[notification userInfo] objectForKey:WCFileSelectPathKey]; 
     558 
     559        if([path isEqualToString:[[self _currentPath] path]]) { 
     560                _selectPath = [selectPath retain]; 
     561 
     562                [[[self connection] cache] removeFilesForPath:[[self _currentPath] path]]; 
     563                 
     564                [self _changeDirectory:[self _currentPath]]; 
     565                [self validate]; 
     566 
     567                [[self connection] removeObserver:self name:WCFilesShouldReload]; 
     568        } 
     569
     570 
     571 
     572 
     573- (void)controlTextDidChange:(NSNotification *)notification { 
     574        NSControl               *control; 
     575         
     576        control = [notification object]; 
     577         
     578        if(control == _createFolderTextField) { 
     579                [_createFolderPopUpButton selectItemWithTag: 
     580                        [WCFile folderTypeForString:[_createFolderTextField stringValue]]]; 
     581        } 
     582
     583 
     584 
     585 
     586#pragma mark - 
     587 
     588- (WCFile *)selectedFile { 
     589        if(_type == WCFilesStyleList) 
     590                return [super selectedFile]; 
     591        else if(_type == WCFilesStyleBrowser) 
     592                return [[_filesBrowser selectedCell] representedObject]; 
     593         
     594        return NULL; 
     595
     596 
     597 
     598 
     599- (NSArray *)selectedFiles { 
     600        NSEnumerator            *enumerator; 
     601        NSMutableArray          *array; 
     602        id                                      cell; 
     603 
     604        if(_type == WCFilesStyleList) { 
     605                return [super selectedFiles]; 
     606        } 
     607        else if(_type == WCFilesStyleBrowser) { 
     608                array = [NSMutableArray array]; 
     609                enumerator = [[_filesBrowser selectedCells] objectEnumerator]; 
     610                 
     611                while((cell = [enumerator nextObject])) 
     612                        [array addObject:[cell representedObject]]; 
     613                 
     614                return array; 
     615        } 
     616         
     617        return NULL; 
     618
     619 
     620 
     621- (NSArray *)shownFiles { 
     622        if(_type == WCFilesStyleList) 
     623                return [super shownFiles]; 
     624        else if(_type == WCFilesStyleBrowser) 
     625                return [_browserFiles objectForKey:[[self _currentPath] path]]; 
     626         
     627        return NULL; 
     628
     629 
     630 
     631 
     632- (void)sortFiles { 
     633        [super sortFiles]; 
     634         
     635        [[_browserFiles objectForKey:[[self _currentPath] path]] sortUsingSelector:@selector(compareName:)]; 
     636
     637 
     638 
     639 
     640#pragma mark - 
     641 
     642- (void)update { 
     643        [_filesBrowser setNeedsDisplay:YES]; 
     644         
     645        [super update]; 
     646
     647 
     648 
     649 
     650- (void)updateStatus { 
     651        if([self _validateUpload]) 
     652                [super updateStatusWithFree:[[self _currentPath] free]]; 
     653        else 
     654                [super updateStatus]; 
     655
     656 
     657 
     658 
     659- (void)validate { 
    515660        NSArray                 *files; 
    516661        WCAccount               *account; 
     
    520665        connected       = [[self connection] isConnected]; 
    521666        account         = [[self connection] account]; 
    522         files           = [self _selectedFiles]; 
     667        files           = [self selectedFiles]; 
    523668 
    524669        switch([files count]) { 
     
    556701        [_createFolderButton setEnabled:([self _validateCreateFolder] && connected)]; 
    557702        [_reloadButton setEnabled:connected]; 
    558 
    559  
    560  
    561  
    562 - (BOOL)_validateUpload { 
    563         WCAccount               *account; 
    564         WCFileType              type; 
    565          
    566         account = [[self connection] account]; 
    567         type = [[self _currentPath] type]; 
    568  
    569         return ([account uploadAnywhere] || 
    570                    ([account upload] && (type == WCFileUploads || type == WCFileDropBox))); 
    571 
    572  
    573  
    574  
    575 - (BOOL)_validateCreateFolder { 
    576         WCAccount               *account; 
    577         WCFileType              type; 
    578  
    579         account = [[self connection] account]; 
    580         type = [[self _currentPath] type]; 
    581  
    582         return ([account createFolders] || 
    583                         [account uploadAnywhere] || 
    584                         ([account upload] && (type == WCFileUploads || type == WCFileDropBox))); 
    585 
    586  
    587 @end 
    588  
    589  
    590 @implementation WCFiles 
    591  
    592 + (id)filesWithConnection:(WCServerConnection *)connection path:(WCFile *)path { 
    593         return [[[self alloc] _initFilesWithConnection:connection path:path selectPath:NULL] autorelease]; 
    594 
    595  
    596  
    597  
    598 + (id)filesWithConnection:(WCServerConnection *)connection path:(WCFile *)path selectPath:(NSString *)selectPath { 
    599         return [[[self alloc] _initFilesWithConnection:connection path:path selectPath:selectPath] autorelease]; 
    600 
    601  
    602  
    603  
    604 - (void)dealloc { 
    605         [[NSNotificationCenter defaultCenter] removeObserver:self]; 
    606          
    607         [_history release]; 
    608         [_allFiles release]; 
    609         [_listFiles release]; 
    610         [_browserFiles release]; 
    611          
    612         [_listPath release]; 
    613         [_browserPath release]; 
    614  
    615         [super dealloc]; 
    616 
    617  
    618  
    619  
    620 #pragma mark - 
    621  
    622 - (void)windowDidLoad { 
    623         WIIconCell              *iconCell; 
    624  
    625         iconCell = [[WIIconCell alloc] init]; 
    626         [_nameTableColumn setDataCell:iconCell]; 
    627         [iconCell release]; 
    628  
    629         [_filesBrowser setCellClass:[WCFilesBrowserCell class]]; 
    630         [_filesBrowser setMatrixClass:[WIMatrix class]]; 
    631  
    632         [_filesBrowser setTarget:self]; 
    633         [_filesBrowser setAction:@selector(browserDidSingleClick:)]; 
    634         [_filesBrowser setDoubleAction:@selector(open:)]; 
    635         [_filesBrowser setColumnsAutosaveName:@"Files"]; 
    636         [_filesBrowser loadColumnZero]; 
    637  
    638         [_filesTableView registerForDraggedTypes: 
    639                 [NSArray arrayWithObjects:WCFilePboardType, NSFilenamesPboardType, NULL]]; 
    640  
    641         [_filesTableView setDoubleAction:@selector(open:)]; 
    642         [_filesTableView setDeleteAction:@selector(deleteFiles:)]; 
    643         [_filesTableView setBackAction:@selector(back:)]; 
    644         [_filesTableView setForwardAction:@selector(forward:)]; 
    645          <