Changeset 3942

Show
Ignore:
Timestamp:
03/21/06 20:22:52 (3 years ago)
Author:
morris
Message:

Fix files drop validation

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • WiredClient/trunk/WCFile.h

    r3902 r3942  
    7878- (NSString *)kind; 
    7979- (BOOL)isFolder; 
     80- (BOOL)isUploadsFolder; 
    8081- (NSImage *)iconWithWidth:(double)width; 
    8182 
  • WiredClient/trunk/WCFile.m

    r3902 r3942  
    471471 
    472472 
     473- (BOOL)isUploadsFolder { 
     474        return ([self type] == WCFileUploads || [self type] == WCFileDropBox); 
     475} 
     476 
     477 
     478 
    473479- (NSImage *)iconWithWidth:(double)width { 
    474480        NSImage         *icon; 
  • WiredClient/trunk/WCFiles.m

    r3902 r3942  
    787787 
    788788                [[[self connection] cache] removeFilesForPath:[[self _currentPath] path]]; 
     789                 
     790                NSLog(@"before %@", [self _currentPath]); 
    789791 
    790792                [self _changeDirectory:[self _currentPath]]; 
    791793                [self _validate]; 
     794 
     795                NSLog(@"after %@", [self _currentPath]); 
    792796 
    793797                [[self connection] removeObserver:self name:WCFilesShouldReload]; 
     
    12321236        NSPasteboard    *pasteboard; 
    12331237        NSArray                 *types; 
    1234         WCFile                  *destination; 
     1238        WCFile                  *file, *path, *destination; 
    12351239 
    12361240        pasteboard = [info draggingPasteboard]; 
    12371241        types = [pasteboard types]; 
    12381242 
    1239         destination = proposedRow >= 0 
    1240                ? [self _fileAtIndex:proposedRow] 
    1241                : [self _currentPath]
    1242  
     1243        file = (proposedRow >= 0) ? [self _fileAtIndex:proposedRow] : NULL; 
     1244        path = [self _currentPath]; 
     1245        destination = file ? file : path
     1246         
    12431247        if([types containsObject:NSFilenamesPboardType]) { 
    12441248                if(![[[self connection] account] upload]) 
    12451249                        return NSDragOperationNone; 
    12461250 
    1247                 if([destination type] != WCFileUploads && [destination type] != WCFileDropBox) { 
     1251                if((file && ![file isUploadsFolder]) || (!file && ![path isUploadsFolder])) { 
    12481252                        if(![[[self connection] account] uploadAnywhere]) 
    12491253                                return NSDragOperationNone; 
    12501254                } 
    1251         } 
    1252  
    1253         if(operation == NSTableViewDropAbove) { 
    1254                 if(!destination || destination == [self _currentPath]) 
    1255                         [_filesTableView setDropRow:-1 dropOperation:NSTableViewDropOn]; 
    1256                 else 
     1255                 
     1256                if(file && [file isUploadsFolder] && operation == NSTableViewDropAbove) { 
     1257                        if(![path isUploadsFolder]) { 
     1258                                if(![[[self connection] account] uploadAnywhere]) 
     1259                                        return NSDragOperationNone; 
     1260                        } 
     1261                } 
     1262        } 
     1263        else if([types containsObject:WCFilePboardType]) { 
     1264                if(![[[self connection] account] alterFiles]) 
    12571265                        return NSDragOperationNone; 
    12581266        } 
    12591267 
    1260         if([destination type] == WCFileFile
     1268        if([destination type] == WCFileFile || operation == NSTableViewDropAbove
    12611269                [_filesTableView setDropRow:-1 dropOperation:NSTableViewDropOn]; 
    12621270