Changeset 1916
- Timestamp:
- 09/19/04 19:18:14 (4 years ago)
- Files:
-
- trunk/Chat Core.xcode/project.pbxproj (modified) (3 diffs)
- trunk/Colloquy.xcode/project.pbxproj (modified) (2 diffs)
- trunk/MVFileTransfer.h (modified) (4 diffs)
- trunk/MVFileTransfer.m (modified) (18 diffs)
- trunk/MVFileTransferController.h (modified) (2 diffs)
- trunk/MVIRCChatConnection.m (modified) (2 diffs)
- trunk/MVIRCFileTransfer.h (added)
- trunk/MVIRCFileTransfer.m (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Chat Core.xcode/project.pbxproj
r1880 r1916 350 350 1C5A1A2506F8F4A000A51F10, 351 351 1C5A230A06FA4F2800A51F10, 352 1C74433D06FE3AB3009AA696, 352 353 ); 353 354 isa = PBXSourcesBuildPhase; … … 483 484 1C6C83A00632186900698F55 = { 484 485 fileRef = F52BA284037C13C201A35792; 486 isa = PBXBuildFile; 487 settings = { 488 }; 489 }; 490 1C74433A06FE3AB3009AA696 = { 491 fileEncoding = 4; 492 isa = PBXFileReference; 493 lastKnownFileType = sourcecode.c.h; 494 path = MVIRCFileTransfer.h; 495 refType = 4; 496 sourceTree = "<group>"; 497 }; 498 1C74433B06FE3AB3009AA696 = { 499 fileEncoding = 4; 500 isa = PBXFileReference; 501 lastKnownFileType = sourcecode.c.objc; 502 path = MVIRCFileTransfer.m; 503 refType = 4; 504 sourceTree = "<group>"; 505 }; 506 1C74433D06FE3AB3009AA696 = { 507 fileRef = 1C74433B06FE3AB3009AA696; 485 508 isa = PBXBuildFile; 486 509 settings = { … … 3323 3346 1C943AAA063C260800618CD9, 3324 3347 1C943AA9063C260800618CD9, 3348 1C74433B06FE3AB3009AA696, 3349 1C74433A06FE3AB3009AA696, 3325 3350 1C2EF7EC0427A40B00000102, 3326 3351 1C2EF7EB0427A40B00000102, trunk/Colloquy.xcode/project.pbxproj
r1880 r1916 1328 1328 refType = 2; 1329 1329 sourceTree = SOURCE_ROOT; 1330 }; 1331 1C74459106FE5842009AA696 = { 1332 fileEncoding = 4; 1333 isa = PBXFileReference; 1334 lastKnownFileType = sourcecode.c.h; 1335 path = MVIRCFileTransfer.h; 1336 refType = 4; 1337 sourceTree = "<group>"; 1338 }; 1339 1C74459206FE5842009AA696 = { 1340 fileEncoding = 4; 1341 isa = PBXFileReference; 1342 lastKnownFileType = sourcecode.c.objc; 1343 path = MVIRCFileTransfer.m; 1344 refType = 4; 1345 sourceTree = "<group>"; 1330 1346 }; 1331 1347 1C746A95050CF86B000001C8 = { … … 4516 4532 1C8CF8E2066530D60080A2F5, 4517 4533 1C8CF8E1066530D60080A2F5, 4534 1C74459206FE5842009AA696, 4535 1C74459106FE5842009AA696, 4518 4536 1C2EF7EC0427A40B00000102, 4519 4537 1C2EF7EB0427A40B00000102, trunk/MVFileTransfer.h
r1823 r1916 25 25 26 26 @interface MVFileTransfer : NSObject { 27 void *_dcc; /* FILE_DCC_REC */ 27 @protected 28 28 unsigned long long _finalSize; 29 29 unsigned long long _transfered; … … 41 41 + (NSRange) fileTransferPortRange; 42 42 43 + (void) updateExternalIPAddress; 44 45 - (id) initWithDCCFileRecord:(void *) record fromConnection:(MVChatConnection *) connection; 43 - (id) initWithUser:(NSString *) user fromConnection:(MVChatConnection *) connection; 46 44 47 45 - (BOOL) isUpload; … … 69 67 70 68 @interface MVUploadFileTransfer : MVFileTransfer { 71 int _transferQueue; 69 @protected 72 70 NSString *_source; 73 71 } … … 80 78 81 79 @interface MVDownloadFileTransfer : MVFileTransfer { 80 @protected 82 81 NSString *_destination; 83 82 NSString *_originalFileName; trunk/MVFileTransfer.m
r1862 r1916 1 1 #import "MVFileTransfer.h" 2 #import "MVIRCFileTransfer.h" 2 3 #import "MVChatConnection.h" 3 4 #import "NSNotificationAdditions.h" 4 5 #define MODULE_NAME "MVFileTransfer"6 7 #import "common.h"8 #import "core.h"9 #import "signals.h"10 #import "settings.h"11 #import "servers.h"12 #import "irc.h"13 #import "config.h"14 #import "dcc.h"15 #import "dcc-get.h"16 #import "dcc-send.h"17 #import "dcc-queue.h"18 #import "dcc-file.h"19 5 20 6 NSString *MVDownloadFileTransferOfferNotification = @"MVDownloadFileTransferOfferNotification"; … … 25 11 NSString *MVFileTransferErrorDomain = @"MVFileTransferErrorDomain"; 26 12 27 extern NSRecursiveLock *MVIRCChatConnectionThreadLock;28 29 void dcc_send_resume( GET_DCC_REC *dcc );30 void dcc_queue_send_next( int queue );31 32 typedef struct {33 MVFileTransfer *transfer;34 } MVFileTransferModuleData;35 36 #pragma mark -37 38 13 @interface MVFileTransfer (MVFileTransferPrivate) 39 + (id) _transferForDCCFileRecord:(FILE_DCC_REC *) record;40 - (FILE_DCC_REC *) _DCCFileRecord;41 - (void) _setDCCFileRecord:(FILE_DCC_REC *) record;42 14 - (void) _setConnection:(MVChatConnection *) connection; 43 15 - (void) _setStatus:(MVFileTransferStatus) status; 44 - (void) _destroying; 45 @end 46 47 #pragma mark - 48 49 @interface MVChatConnection (MVChatConnectionPrivate) 50 - (SERVER_REC *) _irssiConnection; 51 @end 52 53 #pragma mark - 54 55 static void MVFileTransferConnected( FILE_DCC_REC *dcc ) { 56 MVFileTransfer *self = [MVFileTransfer _transferForDCCFileRecord:dcc]; 57 if( ! self ) return; 58 59 [self _setStatus:MVFileTransferNormalStatus]; 60 61 NSNotification *note = [NSNotification notificationWithName:MVFileTransferStartedNotification object:self]; 62 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 63 } 64 65 static void MVFileTransferDestroyed( FILE_DCC_REC *dcc ) { 66 MVFileTransfer *self = [MVFileTransfer _transferForDCCFileRecord:dcc]; 67 if( ! self ) return; 68 69 if( [self status] == MVFileTransferNormalStatus ) { 70 [self _setStatus:MVFileTransferDoneStatus]; 71 NSNotification *note = [NSNotification notificationWithName:MVFileTransferFinishedNotification object:self]; 72 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 73 } 74 75 [MVIRCChatConnectionThreadLock unlock]; // prevents a deadlock, since waitUntilDone is required. threads synced 76 77 [self performSelectorOnMainThread:@selector( _destroying ) withObject:nil waitUntilDone:YES]; 78 79 [MVIRCChatConnectionThreadLock lock]; // lock back up like nothing happened 80 } 81 82 static void MVFileTransferClosed( FILE_DCC_REC *dcc ) { 83 MVFileTransfer *self = [MVFileTransfer _transferForDCCFileRecord:dcc]; 84 if( ! self ) return; 85 86 if( dcc -> size != dcc -> transfd ) { 87 NSDictionary *info = [NSDictionary dictionaryWithObjectsAndKeys:@"The file transfer terminated unexpectedly.", NSLocalizedDescriptionKey, nil]; 88 NSError *error = [NSError errorWithDomain:MVFileTransferErrorDomain code:MVFileTransferUnexpectedlyEndedError userInfo:info]; 89 [self performSelectorOnMainThread:@selector( _postError: ) withObject:error waitUntilDone:NO]; 90 } else { 91 [self _setStatus:MVFileTransferDoneStatus]; 92 NSNotification *note = [NSNotification notificationWithName:MVFileTransferFinishedNotification object:self]; 93 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 94 } 95 } 96 97 static void MVFileTransferErrorConnect( FILE_DCC_REC *dcc ) { 98 MVFileTransfer *self = [MVFileTransfer _transferForDCCFileRecord:dcc]; 99 if( ! self ) return; 100 101 NSDictionary *info = [NSDictionary dictionaryWithObjectsAndKeys:@"The file transfer connection could not be made.", NSLocalizedDescriptionKey, nil]; 102 NSError *error = [NSError errorWithDomain:MVFileTransferErrorDomain code:MVFileTransferConnectionError userInfo:info]; 103 [self performSelectorOnMainThread:@selector( _postError: ) withObject:error waitUntilDone:NO]; 104 } 105 106 static void MVFileTransferErrorFileCreate( FILE_DCC_REC *dcc, char *filename ) { 107 MVFileTransfer *self = [MVFileTransfer _transferForDCCFileRecord:dcc]; 108 if( ! self ) return; 109 110 NSDictionary *info = [NSDictionary dictionaryWithObjectsAndKeys:@"The file %@ could not be created, please make sure you have write permissions in the %@ folder.", NSLocalizedDescriptionKey, nil]; 111 NSError *error = [NSError errorWithDomain:MVFileTransferErrorDomain code:MVFileTransferFileCreationError userInfo:info]; 112 [self performSelectorOnMainThread:@selector( _postError: ) withObject:error waitUntilDone:NO]; 113 } 114 115 static void MVFileTransferErrorFileOpen( FILE_DCC_REC *dcc, char *filename, int errno ) { 116 MVFileTransfer *self = [MVFileTransfer _transferForDCCFileRecord:dcc]; 117 if( ! self ) return; 118 119 NSError *ferror = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:nil]; 120 NSDictionary *info = [NSDictionary dictionaryWithObjectsAndKeys:@"The file %@ could not be opened, please make sure you have read permissions for this file.", NSLocalizedDescriptionKey, ferror, @"NSUnderlyingErrorKey", nil]; 121 NSError *error = [NSError errorWithDomain:MVFileTransferErrorDomain code:MVFileTransferFileOpenError userInfo:info]; 122 [self performSelectorOnMainThread:@selector( _postError: ) withObject:error waitUntilDone:NO]; 123 } 124 125 static void MVFileTransferErrorSendExists( FILE_DCC_REC *dcc, char *nick, char *filename ) { 126 MVFileTransfer *self = [MVFileTransfer _transferForDCCFileRecord:dcc]; 127 if( ! self ) return; 128 129 NSDictionary *info = [NSDictionary dictionaryWithObjectsAndKeys:@"The file %@ is already being offerend to %@.", NSLocalizedDescriptionKey, nil]; 130 NSError *error = [NSError errorWithDomain:MVFileTransferErrorDomain code:MVFileTransferAlreadyExistsError userInfo:info]; 131 [self performSelectorOnMainThread:@selector( _postError: ) withObject:error waitUntilDone:NO]; 132 } 16 - (void) _postError:(NSError *) error; 17 @end 133 18 134 19 #pragma mark - 135 20 136 21 @implementation MVFileTransfer 137 + (void) initialize {138 [super initialize];139 static BOOL tooLate = NO;140 if( ! tooLate ) {141 [MVIRCChatConnectionThreadLock lock];142 signal_add_last( "dcc connected", (SIGNAL_FUNC) MVFileTransferConnected );143 signal_add_last( "dcc destroyed", (SIGNAL_FUNC) MVFileTransferDestroyed );144 signal_add_last( "dcc closed", (SIGNAL_FUNC) MVFileTransferClosed );145 signal_add_last( "dcc error connect", (SIGNAL_FUNC) MVFileTransferErrorConnect );146 signal_add_last( "dcc error file create", (SIGNAL_FUNC) MVFileTransferErrorFileCreate );147 signal_add_last( "dcc error file open", (SIGNAL_FUNC) MVFileTransferErrorFileOpen );148 signal_add_last( "dcc error send exists", (SIGNAL_FUNC) MVFileTransferErrorSendExists );149 [MVIRCChatConnectionThreadLock unlock];150 tooLate = YES;151 }152 }153 154 #pragma mark -155 156 22 + (void) setFileTransferPortRange:(NSRange) range { 157 unsigned short min = (unsigned short)range.location;158 unsigned short max = (unsigned short)(range.location + range.length);159 [MVIRCChatConnectionThreadLock lock];160 settings_set_str( "dcc_port", [[NSString stringWithFormat:@"%uh %uh", min, max] UTF8String] );161 [MVIRCChatConnectionThreadLock unlock];162 23 } 163 24 164 25 + (NSRange) fileTransferPortRange { 165 [MVIRCChatConnectionThreadLock lock]; 166 const char *range = settings_get_str( "dcc_port" ); 167 [MVIRCChatConnectionThreadLock unlock]; 168 169 unsigned short min = 1024; 170 unsigned short max = 1048; 171 172 if( range && strlen( range ) ) { 173 min = strtoul( range, NULL, 10 ); 174 char *temp = strchr( range, ' ' ); 175 if( ! temp ) temp = strchr( range, '-' ); 176 177 if( ! temp ) max = min; 178 else { 179 max = strtoul( temp + 1, NULL, 10 ); 180 if( ! max ) max = min; 181 } 182 183 if( max < min ) { 184 unsigned int t = min; 185 min = max; 186 max = t; 187 } 188 } 189 190 return NSMakeRange( (unsigned int) min, (unsigned int)( max - min ) ); 191 } 192 193 #pragma mark - 194 195 + (void) updateExternalIPAddress { 196 NSURL *url = [NSURL URLWithString:@"http://colloquy.info/ip.php"]; 197 NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:3.]; 198 NSMutableData *result = [[[NSURLConnection sendSynchronousRequest:request returningResponse:NULL error:NULL] mutableCopy] autorelease]; 199 [result appendBytes:"\0" length:1]; 200 if( [result length] ) { 201 [MVIRCChatConnectionThreadLock lock]; 202 settings_set_str( "dcc_own_ip", [result bytes] ); 203 [MVIRCChatConnectionThreadLock unlock]; 204 } 205 } 206 207 #pragma mark - 208 209 - (id) initWithDCCFileRecord:(void *) record fromConnection:(MVChatConnection *) connection { 26 return NSMakeRange( 1024, ( 65535 - 1024 ) ); 27 } 28 29 #pragma mark - 30 31 - (id) initWithUser:(NSString *) user fromConnection:(MVChatConnection *) connection { 210 32 if( ( self = [super init] ) ) { 211 _dcc = NULL;212 33 _connection = nil; 213 [self _setDCCFileRecord:record];214 34 [self _setConnection:connection]; 215 35 _status = MVFileTransferHoldingStatus; … … 218 38 _startDate = nil; 219 39 _host = nil; 220 _user = nil;40 _user = [user copy]; 221 41 _port = 0; 222 42 _startOffset = 0; … … 227 47 228 48 - (void) dealloc { 229 [self _setDCCFileRecord:NULL];230 231 49 [_startDate release]; 232 50 [_host release]; … … 251 69 252 70 - (BOOL) isPassive { 253 if( ! [self _DCCFileRecord] ) return _passive; 254 [MVIRCChatConnectionThreadLock lock]; 255 _passive = dcc_is_passive( [self _DCCFileRecord] ); 256 [MVIRCChatConnectionThreadLock unlock]; 257 return _passive; 71 // subclass if needed 72 return NO; 258 73 } 259 74 … … 269 84 270 85 - (unsigned long long) finalSize { 271 if( ! [self _DCCFileRecord] ) return _finalSize;272 [MVIRCChatConnectionThreadLock lock];273 _finalSize = [self _DCCFileRecord] -> size;274 [MVIRCChatConnectionThreadLock unlock];275 86 return _finalSize; 276 87 } 277 88 278 89 - (unsigned long long) transfered { 279 if( ! [self _DCCFileRecord] ) return _transfered;280 [MVIRCChatConnectionThreadLock lock];281 _transfered = [self _DCCFileRecord] -> transfd;282 [MVIRCChatConnectionThreadLock unlock];283 90 return _transfered; 284 91 } … … 287 94 288 95 - (NSDate *) startDate { 289 if( _startDate || ! [self _DCCFileRecord] ) return _startDate;290 [MVIRCChatConnectionThreadLock lock];291 if( [self _DCCFileRecord] -> starttime )292 _startDate = [[NSDate dateWithTimeIntervalSince1970:[self _DCCFileRecord] -> starttime] retain];293 [MVIRCChatConnectionThreadLock unlock];294 96 return _startDate; 295 97 } 296 98 297 99 - (unsigned long long) startOffset { 298 if( ! [self _DCCFileRecord] ) return _startOffset;299 [MVIRCChatConnectionThreadLock lock];300 _startOffset = [self _DCCFileRecord] -> skipped;301 [MVIRCChatConnectionThreadLock unlock];302 100 return _startOffset; 303 101 } … … 306 104 307 105 - (NSHost *) host { 308 if( _host || ! [self _DCCFileRecord] ) return _host;309 [MVIRCChatConnectionThreadLock lock];310 _host = [[NSHost hostWithAddress:[NSString stringWithUTF8String:[self _DCCFileRecord] -> addrstr]] retain];311 [MVIRCChatConnectionThreadLock unlock];312 106 return _host; 313 107 } 314 108 315 109 - (unsigned short) port { 316 if( _port || ! [self _DCCFileRecord] ) return _port;317 [MVIRCChatConnectionThreadLock lock];318 _port = [self _DCCFileRecord] -> port;319 [MVIRCChatConnectionThreadLock unlock];320 110 return _port; 321 111 } … … 328 118 329 119 - (NSString *) user { 330 if( _user || ! [self _DCCFileRecord] ) return _user;331 [MVIRCChatConnectionThreadLock lock];332 _user = [[[self connection] stringWithEncodedBytes:[self _DCCFileRecord] -> nick] retain];333 [MVIRCChatConnectionThreadLock unlock];334 120 return _user; 335 121 } … … 338 124 339 125 - (void) cancel { 340 if( ! [self _DCCFileRecord] ) return; 341 [MVIRCChatConnectionThreadLock lock]; 342 dcc_close( (DCC_REC *)[self _DCCFileRecord] ); 343 [MVIRCChatConnectionThreadLock unlock]; 344 [self _setStatus:MVFileTransferStoppedStatus]; 126 // subclass, don't call super 127 [self doesNotRecognizeSelector:_cmd]; 345 128 } 346 129 @end … … 349 132 350 133 @implementation MVFileTransfer (MVFileTransferPrivate) 351 + (id) _transferForDCCFileRecord:(FILE_DCC_REC *) record {352 if( ! record ) return nil;353 354 MVFileTransferModuleData *data = MODULE_DATA( record );355 if( data ) return data -> transfer;356 357 return nil;358 }359 360 - (FILE_DCC_REC *) _DCCFileRecord {361 return _dcc;362 }363 364 - (void) _setDCCFileRecord:(FILE_DCC_REC *) record {365 [MVIRCChatConnectionThreadLock lock];366 367 if( _dcc ) {368 MVFileTransferModuleData *data = MODULE_DATA( (FILE_DCC_REC *)_dcc );369 if( data ) data -> transfer = nil;370 g_free_not_null( data );371 }372 373 _dcc = record;374 375 if( record ) {376 MVFileTransferModuleData *data = g_new0( MVFileTransferModuleData, 1 );377 data -> transfer = self;378 MODULE_DATA_SET( ((DCC_REC *)record), data );379 }380 381 [MVIRCChatConnectionThreadLock unlock];382 }383 384 134 - (void) _setConnection:(MVChatConnection *) connection { 385 135 [_connection autorelease]; … … 391 141 } 392 142 393 - (void) _destroying {394 _passive = [self isPassive];395 _finalSize = [self finalSize];396 _transfered = [self transfered];397 _port = [self port];398 _startOffset = [self startOffset];399 400 // load the variables simply by calling the accessor401 [self startDate];402 [self host];403 [self user];404 405 [self _setDCCFileRecord:NULL];406 }407 408 143 - (void) _postError:(NSError *) error { 409 144 [self _setStatus:MVFileTransferErrorStatus]; … … 421 156 @implementation MVUploadFileTransfer 422 157 + (id) transferWithSourceFile:(NSString *) path toUser:(NSString *) nickname onConnection:(MVChatConnection *) connection passively:(BOOL) passive { 423 [super updateExternalIPAddress]; 424 425 [MVIRCChatConnectionThreadLock lock]; 426 427 int queue = dcc_queue_new(); 428 NSString *source = [[path stringByStandardizingPath] copy]; 429 430 char *tag = [connection _irssiConnection] -> tag; 431 432 if( ! passive ) dcc_queue_add( queue, DCC_QUEUE_NORMAL, [nickname UTF8String], [source fileSystemRepresentation], tag, NULL ); 433 else dcc_queue_add_passive( queue, DCC_QUEUE_NORMAL, [nickname UTF8String], [source fileSystemRepresentation], tag, NULL ); 434 435 dcc_queue_send_next( queue ); 436 437 DCC_REC *dcc = dcc_find_request( DCC_SEND_TYPE, [nickname UTF8String], [[source lastPathComponent] fileSystemRepresentation] ); 438 439 MVUploadFileTransfer *ret = [[[MVUploadFileTransfer alloc] initWithDCCFileRecord:dcc fromConnection:connection] autorelease]; 440 ret -> _source = [[source stringByStandardizingPath] copy]; 441 ret -> _transferQueue = queue; 442 443 [MVIRCChatConnectionThreadLock unlock]; 444 445 return ret; 158 if( [connection type] == MVChatConnectionIRCType ) { 159 return [MVIRCUploadFileTransfer transferWithSourceFile:path toUser:nickname onConnection:connection passively:passive]; 160 } 161 162 return nil; 163 } 164 165 #pragma mark - 166 167 - (id) initWithUser:(NSString *) user fromConnection:(MVChatConnection *) connection { 168 if( ( self = [super initWithUser:user fromConnection:connection] ) ) { 169 _source = nil; 170 } 171 172 return self; 173 } 174 175 - (void) dealloc { 176 [_source release]; 177 _source = nil; 178 [super dealloc]; 446 179 } 447 180 … … 461 194 #pragma mark - 462 195 463 static void MVDownloadFileTransferSpecifyPath( GET_DCC_REC *dcc ) {464 MVDownloadFileTransfer *self = [MVDownloadFileTransfer _transferForDCCFileRecord:(FILE_DCC_REC *)dcc];465 if( ! self ) return;466 g_free_not_null( dcc -> file );467 dcc -> file = g_strdup( [[self destination] fileSystemRepresentation] );468 }469 470 #pragma mark -471 472 @interface MVDownloadFileTransfer (MVDownloadFileTransferPrivate)473 - (GET_DCC_REC *) _DCCFileRecord;474 @end475 476 #pragma mark -477 478 196 @implementation MVDownloadFileTransfer 479 + (void) initialize { 480 [super initialize]; 481 static BOOL tooLate = NO; 482 if( ! tooLate ) { 483 [MVIRCChatConnectionThreadLock lock]; 484 signal_add_last( "dcc get receive", (SIGNAL_FUNC) MVDownloadFileTransferSpecifyPath ); 485 [MVIRCChatConnectionThreadLock unlock]; 486 tooLate = YES; 487 } 488 } 489 490 #pragma mark - 491 492 - (BOOL) isDownload { 493 return YES; 494 } 495 496 #pragma mark - 497 498 - (id) initWithDCCFileRecord:(void *) record fromConnection:(MVChatConnection *) connection { 499 if( ( self = [super initWithDCCFileRecord:record fromConnection:connection] ) ) { 197 - (id) initWithUser:(NSString *) user fromConnection:(MVChatConnection *) connection { 198 if( ( self = [super initWithUser:user fromConnection:connection] ) ) { 500 199 _destination = nil; 501 200 _originalFileName = nil; … … 520 219 [_destination autorelease]; 521 220 _destination = [[path stringByStandardizingPath] copy]; 522 523 if( ! [self _DCCFileRecord] ) return; 524 [MVIRCChatConnectionThreadLock lock]; 525 [self _DCCFileRecord] -> get_type = ( rename ? DCC_GET_RENAME : DCC_GET_OVERWRITE ); 526 [MVIRCChatConnectionThreadLock unlock]; 221 // subclass if needed, call super 527 222 } 528 223 … … 534 229 535 230 - (NSString *) originalFileName { 536 if( _originalFileName || ! [self _DCCFileRecord] ) return _originalFileName;537 [MVIRCChatConnectionThreadLock lock];538 _originalFileName = [[[self connection] stringWithEncodedBytes:[self _DCCFileRecord] -> arg] retain];539 [MVIRCChatConnectionThreadLock unlock];540 231 return _originalFileName; 541 232 } … … 543 234 #pragma mark - 544 235 236 - (BOOL) isDownload { 237 return YES; 238 } 239 240 #pragma mark - 241 545 242 - (void) reject { 546 if( ! [self _DCCFileRecord] ) return; 547 [MVIRCChatConnectionThreadLock lock]; 548 dcc_reject( (DCC_REC *)[self _DCCFileRecord], [self _DCCFileRecord] -> server ); 549 [MVIRCChatConnectionThreadLock unlock]; 243 // subclass, don't call super 244 [self doesNotRecognizeSelector:_cmd]; 550 245 } 551 246 … … 557 252 558 253 - (void) acceptByResumingIfPossible:(BOOL) resume { 559 if( ! [self _DCCFileRecord] ) return; 560 561 if( ! [[NSFileManager defaultManager] isReadableFileAtPath:[self destination]] ) 562 resume = NO; 563 564 [MVIRCChatConnectionThreadLock lock]; 565 566 if( resume ) dcc_send_resume( [self _DCCFileRecord] ); 567 else if( dcc_is_passive( [self _DCCFileRecord] ) ) dcc_get_passive( [self _DCCFileRecord] ); 568 else dcc_get_connect( [self _DCCFileRecord] ); 569 570 [MVIRCChatConnectionThreadLock unlock]; 571 } 572 @end 573 574 #pragma mark - 575 576 @implementation MVDownloadFileTransfer (MVDownloadFileTransferPrivate) 577 - (GET_DCC_REC *) _DCCFileRecord { 578 return (GET_DCC_REC *)[super _DCCFileRecord]; 579 } 580 581 - (void) _destroying { 582 [self originalFileName]; 583 [super _destroying]; 584 } 585 @end 254 // subclass, don't call super 255 [self doesNotRecognizeSelector:_cmd]; 256 } 257 @end trunk/MVFileTransferController.h
r1823 r1916 1 1 NSString *MVPrettyFileSize( unsigned long long size ); 2 2 NSString *MVReadableTime( NSTimeInterval date, BOOL longFormat ); 3 4 @class MVFileTransfer; 3 5 4 6 @interface MVFileTransferController : NSWindowController { … … 21 23 22 24 - (void) downloadFileAtURL:(NSURL *) url toLocalFile:(NSString *) path; 23 - (void) addFileTransfer:(id) tr tansfer;25 - (void) addFileTransfer:(id) transfer; 24 26 25 27 - (IBAction) stopSelectedTransfer:(id) sender; trunk/MVIRCChatConnection.m
r1913 r1916 3 3 #import "MVChatConnection.h" 4 4 #import "MVIRCChatConnection.h" 5 #import "MV FileTransfer.h"5 #import "MVIRCFileTransfer.h" 6 6 #import "MVChatPluginManager.h" 7 7 #import "MVChatScriptPlugin.h" … … 818 818 if( ! self ) return; 819 819 if( IS_DCC_GET( dcc ) ) { 820 MV DownloadFileTransfer *transfer = [[[MVDownloadFileTransfer alloc] initWithDCCFileRecord:dcc fromConnection:self] autorelease];820 MVIRCDownloadFileTransfer *transfer = [[[MVIRCDownloadFileTransfer alloc] initWithDCCFileRecord:dcc fromConnection:self] autorelease]; 821 821 NSNotification *note = [NSNotification notificationWithName:MVDownloadFileTransferOfferNotification object:transfer]; 822 822 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note];
