Changeset 1267

Show
Ignore:
Timestamp:
05/19/04 23:34:28 (5 years ago)
Author:
morris
Message:

add support for COMMENT command

Files:

Legend:

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

    r1086 r1267  
    1 /* $Id: WCAccount.h,v 1.2 2004/03/27 21:36:15 morris Exp $ */ 
     1/* $Id: WCAccount.h,v 1.3 2004/05/19 21:34:28 morris Exp $ */ 
    22 
    33/* 
     
    5757- (BOOL)                                        uploadAnywhere; 
    5858- (BOOL)                                        createFolders; 
    59 - (BOOL)                                        moveFiles; 
     59- (BOOL)                                        changeFiles; 
    6060- (BOOL)                                        deleteFiles; 
    6161- (BOOL)                                        viewDropBoxes; 
  • WiredClient/trunk/WCClient.h

    r1232 r1267  
    1 /* $Id: WCClient.h,v 1.7 2004/05/18 16:46:01 morris Exp $ */ 
     1/* $Id: WCClient.h,v 1.8 2004/05/19 21:34:28 morris Exp $ */ 
    22 
    33/* 
     
    5555#define                                                 WCClearNewsCommand              @"CLEARNEWS" 
    5656#define                                                 WCClientCommand                 @"CLIENT" 
     57#define                                                 WCCommentCommand                @"COMMENT" 
    5758#define                                                 WCCreateUserCommand             @"CREATEUSER" 
    5859#define                                                 WCCreateGroupCommand    @"CREATEGROUP" 
  • WiredClient/trunk/WCFile.h

    r1155 r1267  
    1 /* $Id: WCFile.h,v 1.4 2004/05/13 17:58:09 morris Exp $ */ 
     1/* $Id: WCFile.h,v 1.5 2004/05/19 21:34:28 morris Exp $ */ 
    22 
    33/* 
     
    3737        NSDate                                  *_modified; 
    3838        NSString                                *_checksum; 
     39        NSString                                *_comment; 
    3940} 
    4041 
     
    7273- (NSString *)                          checksum; 
    7374 
     75- (void)                                        setComment:(NSString *)value; 
     76- (NSString *)                          comment; 
     77 
    7478- (NSString *)                          kind; 
    7579- (NSString *)                          humanReadableSize; 
  • WiredClient/trunk/WCFile.m

    r1155 r1267  
    1 /* $Id: WCFile.m,v 1.5 2004/05/13 17:58:09 morris Exp $ */ 
     1/* $Id: WCFile.m,v 1.6 2004/05/19 21:34:28 morris Exp $ */ 
    22 
    33/* 
     
    5050        [_kind release]; 
    5151        [_checksum release]; 
     52        [_comment release]; 
    5253         
    5354        [super dealloc]; 
     
    7172        _modified       = [[coder decodeObject] retain]; 
    7273        _checksum       = [[coder decodeObject] retain]; 
     74        _comment        = [[coder decodeObject] retain]; 
    7375         
    7476        return self; 
     
    8890        [coder encodeObject:_modified]; 
    8991        [coder encodeObject:_checksum]; 
     92        [coder encodeObject:_comment]; 
    9093} 
    9194 
     
    215218- (NSString *)checksum { 
    216219        return _checksum; 
     220} 
     221 
     222 
     223 
     224#pragma mark - 
     225 
     226- (void)setComment:(NSString *)value { 
     227        [value retain]; 
     228        [_comment release]; 
     229         
     230        _comment = value; 
     231} 
     232 
     233 
     234 
     235- (NSString *)comment { 
     236        return _comment; 
    217237} 
    218238 
  • WiredClient/trunk/WCFileInfo.h

    r944 r1267  
    1 /* $Id: WCFileInfo.h,v 1.1 2004/03/08 19:23:43 morris Exp $ */ 
     1/* $Id: WCFileInfo.h,v 1.2 2004/05/19 21:34:28 morris Exp $ */ 
    22 
    33/* 
     
    4747        IBOutlet NSTextField            *_checksumTitleTextField; 
    4848        IBOutlet NSTextField            *_checksumTextField; 
     49        IBOutlet NSTextField            *_commentTitleTextField; 
     50        IBOutlet NSTextField            *_commentTextField; 
    4951 
    5052        WCFile                                          *_file; 
  • WiredClient/trunk/WCFileInfo.m

    r1251 r1267  
    1 /* $Id: WCFileInfo.m,v 1.4 2004/05/18 23:52:29 morris Exp $ */ 
     1/* $Id: WCFileInfo.m,v 1.5 2004/05/19 21:34:28 morris Exp $ */ 
    22 
    33/* 
     
    9999 
    100100- (void)windowWillClose:(NSNotification *)notification { 
    101         NSString                *oldFileName, *newFileName, *filePath; 
    102          
    103         oldFileName     = [[_file path] lastPathComponent]; 
    104         newFileName     = [_fileTextField stringValue]; 
    105         filePath                = [[_file path] stringByDeletingLastPathComponent]; 
     101        NSString                *path; 
     102         
     103        path = [[_file path] stringByDeletingLastPathComponent]; 
    106104         
    107105        // --- compare the existing file name with the one in the text field 
    108         if([[self window] isVisible] && [[_connection account] moveFiles] && 
    109            ![oldFileName isEqualToString:newFileName]) { 
     106        if([[self window] isVisible] && 
     107           [[_connection account] changeFiles] && 
     108           ![[[_file path] lastPathComponent] isEqualToString:[_fileTextField stringValue]]) { 
    110109                // --- send the move command 
    111110                [[_connection client] sendCommand:[NSString stringWithFormat: 
     
    114113                        [_file path], 
    115114                        WCFieldSeparator, 
    116                         [filePath stringByAppendingPathComponent:newFileName]]]; 
     115                        [path stringByAppendingPathComponent:[_fileTextField stringValue]]]]; 
    117116         
    118117                // --- reload all files affected 
    119118                [[NSNotificationCenter defaultCenter] 
    120119                        postNotificationName:WCFilesShouldReload 
    121                         object:[NSArray arrayWithObjects:_connection, filePath, NULL]]; 
    122         } 
    123          
     120                        object:[NSArray arrayWithObjects:_connection, path, NULL]]; 
     121        } 
     122         
     123        // --- compare the existing comment with the one in the text field 
     124        if([[self window] isVisible] && 
     125           [[_connection account] changeFiles] && 
     126           [_connection protocol] >= 1.1 && 
     127           ![[_file comment] isEqualToString:[_commentTextField stringValue]]) { 
     128                // --- send the comment command 
     129                [[_connection client] sendCommand:[NSString stringWithFormat: 
     130                        @"%@ %@%@%@", 
     131                        WCCommentCommand, 
     132                        [_file path], 
     133                        WCFieldSeparator, 
     134                        [_commentTextField stringValue]]]; 
     135        } 
     136 
    124137        [super windowWillClose:notification]; 
    125138 
     
    138151- (void)fileInfoShouldShowInfo:(NSNotification *)notification { 
    139152        NSArray                         *fields; 
    140         NSString                        *argument, *size, *type, *created, *modified, *checksum, *path
     153        NSString                        *argument, *path, *size, *type, *created, *modified, *checksum, *comment = NULL
    141154        NSScanner                       *scanner; 
    142155        NSImage                         *icon = NULL; 
     
    144157        WCConnection            *connection; 
    145158        unsigned long long      size_l; 
    146         int                                     last = 0
     159        int                                     last = 68
    147160         
    148161        // --- get parameters 
     
    161174        modified        = [fields objectAtIndex:4]; 
    162175        checksum        = [fields objectAtIndex:5]; 
     176         
     177        /* protocol 1.1 */ 
     178        if([_connection protocol] >= 1.1) 
     179                comment = [fields objectAtIndex:6]; 
    163180 
    164181        if(![path isEqualToString:[_file path]]) 
     
    179196        [_checksumTextField setStringValue:checksum]; 
    180197 
     198        /* protocol 1.1 */ 
     199        if([_connection protocol] >= 1.1) { 
     200                [_file setComment:comment]; 
     201                [_commentTextField setStringValue:comment]; 
     202        } 
     203 
    181204        switch([_file type]) { 
    182205                case WCFileTypeDirectory: 
     
    226249        } 
    227250         
     251        // --- resize 
     252//      [_commentTextField setFrameWithControl:_commentTitleTextField atOffset:&last]; 
     253 
    228254        // --- remove checksum 
    229255        if([_file type] == WCFileTypeFile) { 
     
    255281         
    256282        // --- set editable 
    257         [_fileTextField setEditable:[[_connection account] moveFiles]]; 
     283        [_fileTextField setEditable:[[_connection account] changeFiles]]; 
     284        [_commentTextField setEditable: 
     285                [_connection protocol] >= 1.1 && [[_connection account] changeFiles]]; 
    258286 
    259287        // --- resize and show window