| 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 | | |
|---|
| 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 | | |
|---|
| 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 { |
|---|
| 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 | | < |
|---|