Changeset 3520
- Timestamp:
- 01/01/07 01:03:45 (2 years ago)
- Files:
-
- trunk/Controllers/MVConnectionsController.m (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Controllers/MVConnectionsController.m
r3491 r3520 319 319 320 320 - (IBAction) connectNewConnection:(id) sender { 321 MVChatConnection *connection = nil;322 323 321 if( ! [[newNickname stringValue] length] ) { 324 322 [[self window] makeFirstResponder:newNickname]; … … 365 363 366 364 NSEnumerator *enumerator = [_bookmarks objectEnumerator]; 367 id data = nil; 368 369 while( ( data = [enumerator nextObject] ) ) { 370 if( [[(MVChatConnection *)[data objectForKey:@"connection"] server] isEqualToString:[newAddress stringValue]] && 371 [[(MVChatConnection *)[data objectForKey:@"connection"] nickname] isEqualToString:[newNickname stringValue]] ) { 372 if( [(MVChatConnection *)[data objectForKey:@"connection"] isConnected] ) { 365 NSDictionary *info = nil; 366 367 while( ( info = [enumerator nextObject] ) ) { 368 MVChatConnection *connection = [info objectForKey:@"connection"]; 369 370 if( [[connection server] isEqualToString:[newAddress stringValue]] && [connection serverPort] == [newPort intValue] && 371 [[connection nickname] isEqualToString:[newNickname stringValue]] && 372 [[connection username] isEqualToString:[newUsername stringValue]] && 373 [[connection password] isEqualToString:[newServerPassword stringValue]] ) { 374 if( [connection isConnected] ) { 373 375 NSRunCriticalAlertPanel( NSLocalizedString( @"Already connected", "already connected dialog title" ), NSLocalizedString( @"The chat server with the nickname you specified is already connected to from this computer. Use another nickname if you desire multiple connections.", "chat already connected message" ), nil, nil, nil ); 374 376 [openConnection makeFirstResponder:newNickname]; 375 377 } else { 376 [connections selectRow:[_bookmarks indexOfObject: data] byExtendingSelection:NO];378 [connections selectRow:[_bookmarks indexOfObject:info] byExtendingSelection:NO]; 377 379 [self _connect:nil]; 378 380 [[self window] makeKeyAndOrderFront:nil]; 379 381 [openConnection orderOut:nil]; 380 382 } 383 381 384 return; 382 385 } … … 387 390 MVChatConnectionType type = ( [[newType selectedItem] tag] == 1 ? MVChatConnectionIRCType : MVChatConnectionSILCType ); 388 391 389 connection = [[[MVChatConnection alloc] initWithType:type] autorelease];392 MVChatConnection *connection = [[[MVChatConnection alloc] initWithType:type] autorelease]; 390 393 [connection setEncoding:[[NSUserDefaults standardUserDefaults] integerForKey:@"JVChatEncoding"]]; 391 394 [connection setOutgoingChatFormat:[[NSUserDefaults standardUserDefaults] integerForKey:@"JVChatFormat"]]; … … 709 712 - (void) handleURL:(NSURL *) url andConnectIfPossible:(BOOL) connect { 710 713 if( [MVChatConnection supportsURLScheme:[url scheme]] ) { 711 MVChatConnection *connection = nil;712 714 NSString *target = nil; 713 715 BOOL handled = NO; … … 720 722 721 723 NSEnumerator *enumerator = [_bookmarks objectEnumerator]; 722 id data = nil; 723 724 while( ( data = [enumerator nextObject] ) ) { 725 connection = [data objectForKey:@"connection"]; 726 if( [[connection server] isEqualToString:[url host]] 727 && ( ! [url user] || [[connection nickname] isEqualToString:[url user]] ) 728 && ( ! [connection serverPort] || ! [[url port] unsignedShortValue] || [connection serverPort] == [[url port] unsignedShortValue] ) ) { 724 NSDictionary *info = nil; 725 726 while( ( info = [enumerator nextObject] ) ) { 727 MVChatConnection *connection = [info objectForKey:@"connection"]; 728 729 if( [[connection server] isEqualToString:[url host]] && 730 ( ! [[url user] length] || [[connection nickname] isEqualToString:[url user]] ) && 731 ( ! [[url port] unsignedShortValue] || [connection serverPort] == [[url port] unsignedShortValue] ) ) { 729 732 730 733 if( ! [connection isConnected] && connect ) { … … 737 740 else [[self window] orderFront:nil]; 738 741 739 [connections selectRow:[_bookmarks indexOfObject:data] byExtendingSelection:NO]; 742 [connections selectRow:[_bookmarks indexOfObject:info] byExtendingSelection:NO]; 743 740 744 handled = YES; 741 745 break; … … 743 747 } 744 748 745 if( ! handled && ! [ url user] ) {749 if( ! handled && ! [[url user] length] ) { 746 750 [newAddress setObjectValue:[url host]]; 747 751 … … 754 758 755 759 handled = YES; 756 } else if( ! handled && [ url user] ) {757 connection = [[[MVChatConnection alloc] initWithURL:url] autorelease];760 } else if( ! handled && [[url user] length] ) { 761 MVChatConnection *connection = [[[MVChatConnection alloc] initWithURL:url] autorelease]; 758 762 [connection setEncoding:[[NSUserDefaults standardUserDefaults] integerForKey:@"JVChatEncoding"]]; 759 763 [connection setOutgoingChatFormat:[[NSUserDefaults standardUserDefaults] integerForKey:@"JVChatFormat"]];
