Changeset 3643
- Timestamp:
- 04/18/07 23:53:34 (1 year ago)
- Files:
-
- trunk/Chat Core/MVXMPPChatConnection.m (modified) (7 diffs)
- trunk/Chat Core/MVXMPPChatUser.h (modified) (1 diff)
- trunk/Chat Core/MVXMPPChatUser.m (modified) (2 diffs)
- trunk/Frameworks/Acid/Acid.xcodeproj/project.pbxproj (modified) (4 diffs)
- trunk/Frameworks/Acid/jabber/JabberSocket.m (modified) (1 diff)
- trunk/Panels/JVDirectChatPanel.m (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Chat Core/MVXMPPChatConnection.m
r3638 r3643 88 88 [self _willConnect]; 89 89 90 MVSafeAdoptAssign( &_localID, [[JabberID alloc] initWithFormat:@"%@@%@/colloquy", _username, _server] ); 91 MVSafeAdoptAssign( &_localUser, [[MVXMPPChatUser allocWithZone:nil] initLocalUserWithConnection:self] ); 92 93 [_session startSession:_localID onPort:_serverPort]; 90 JabberID *localId = nil; 91 NSRange atRange = [_username rangeOfString:@"@" options:NSLiteralSearch]; 92 if( atRange.location == NSNotFound ) 93 localId = [[JabberID alloc] initWithFormat:@"%@@%@/colloquy", _username, _server]; 94 else localId = [[JabberID alloc] initWithFormat:@"%@/colloquy", _username]; 95 96 MVChatUser *localUser = [[MVXMPPChatUser allocWithZone:nil] initWithJabberID:localId andConnection:self]; 97 [localUser _setType:MVChatLocalUserType]; 98 99 MVSafeAdoptAssign( &_localID, localId ); 100 MVSafeAdoptAssign( &_localUser, localUser ); 101 102 [_session setUseSSL:_secure]; 103 [_session startSession:_localID onPort:_serverPort withServer:_server]; 94 104 } 95 105 … … 235 245 } 236 246 247 NSString *localUserStringId = [[NSString allocWithZone:nil] initWithFormat:@"%@/%@", room, [self nickname]]; 237 248 JabberPresence *presence = [[JabberPresence allocWithZone:nil] initWithQName:JABBER_PRESENCE_QN]; 238 [presence putAttribute:@"from" withValue:[_localID escapedCompleteID]];239 240 NSString *localUserStringId = [[NSString allocWithZone:nil] initWithFormat:@"%@/%@", room, [self nickname]];241 249 [presence putAttribute:@"to" withValue:localUserStringId]; 242 250 … … 283 291 284 292 - (void) authorizationReady:(NSNotification *) notification { 285 [[notification object] authenticateWithPassword:_password]; 293 if( _password ) 294 [[notification object] authenticateWithPassword:_password]; 286 295 } 287 296 … … 305 314 306 315 - (void) incomingPacket:(NSNotification *) notification { 307 NSString *string = [[NSString alloc] initWithData:[notification object] encoding:NSUTF8StringEncoding];316 NSString *string = [[NSString alloc] initWithData:[notification object] encoding:NSUTF8StringEncoding]; 308 317 [[NSNotificationCenter defaultCenter] postNotificationName:MVChatConnectionGotRawMessageNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:string, @"message", [NSNumber numberWithBool:NO], @"outbound", nil]]; 309 318 [string release]; … … 311 320 312 321 - (void) incomingMessage:(NSNotification *) notification { 313 JabberMessage *message = [notification object]; 314 315 switch( [message eventType] ) { 316 case JMEVENT_COMPOSING_REQUEST: 322 JabberMessage *message = [notification object]; 323 324 if( [[message type] isEqualToString:@"error"] ) { 325 // handle error 326 return; 327 } 328 329 switch( [message eventType] ) { 330 case JMEVENT_COMPOSING_REQUEST: 317 331 // fall through 318 case JMEVENT_NONE: {332 case JMEVENT_NONE: { 319 333 MVChatRoom *room = nil; 320 334 MVChatUser *sender = nil; … … 354 368 [msgData release]; 355 369 [msgAttributes release]; 356 break;357 } 358 359 case JMEVENT_COMPOSING:360 break;361 case JMEVENT_COMPOSING_CANCEL:362 break;363 }370 break; 371 } 372 373 case JMEVENT_COMPOSING: 374 break; 375 case JMEVENT_COMPOSING_CANCEL: 376 break; 377 } 364 378 } 365 379 366 380 - (void) incomingPresence:(NSNotification *) notification { 367 JabberPresence *presence = [notification object];381 JabberPresence *presence = [notification object]; 368 382 JabberID *roomID = [[presence from] userhostJID]; 369 383 MVChatRoom *room = [self joinedChatRoomWithUniqueIdentifier:roomID]; … … 423 437 - (XMLElement *) _capabilitiesElement { 424 438 XMLElement *caps = [[XMLElement allocWithZone:nil] initWithQName:JABBER_CLIENTCAP_QN]; 425 [caps putAttribute:@"node" withValue:@"http://colloquy.info/caps"];426 [caps putAttribute:@"ver" withValue:@"2.1"];439 [caps putAttribute:@"node" withValue:@"http://colloquy.info/caps"]; 440 [caps putAttribute:@"ver" withValue:@"2.1"]; 427 441 return [caps autorelease]; 428 442 } trunk/Chat Core/MVXMPPChatUser.h
r3638 r3643 9 9 BOOL _roomMember; 10 10 } 11 - (id) initLocalUserWithConnection:(MVXMPPChatConnection *) connection;12 11 - (id) initWithJabberID:(JabberID *) identifier andConnection:(MVXMPPChatConnection *) connection; 13 12 @end trunk/Chat Core/MVXMPPChatUser.m
r3638 r3643 6 6 7 7 @implementation MVXMPPChatUser 8 - (id) initLocalUserWithConnection:(MVXMPPChatConnection *) userConnection {9 if( ( self = [self initWithJabberID:[userConnection _localUserID] andConnection:userConnection] ) )10 _type = MVChatLocalUserType;11 return self;12 }13 14 8 - (id) initWithJabberID:(JabberID *) identifier andConnection:(MVXMPPChatConnection *) userConnection { 15 9 if( ( self = [self init] ) ) { … … 44 38 if( _roomMember ) 45 39 return [_uniqueIdentifier resource]; 46 if( _type == MVChatLocalUserType )47 return [[self connection] username];48 40 return [_uniqueIdentifier username]; 49 41 } trunk/Frameworks/Acid/Acid.xcodeproj/project.pbxproj
r3641 r3643 52 52 DDBE55910BD1845D004ED228 /* libssl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = DDBE55900BD1845D004ED228 /* libssl.dylib */; }; 53 53 DDBE55BA0BD187D5004ED228 /* libcrypto.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = DDBE55B90BD187D5004ED228 /* libcrypto.dylib */; }; 54 DDE46AAD0BD7246C0064D202 /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DDE46AAC0BD7246C0064D202 /* CoreServices.framework */; }; 54 55 DDF45AC40BD5CC500050911E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D69BFE84028FC02AAC07 /* Foundation.framework */; }; 55 56 DDF45BBD0BD5CD6D0050911E /* AsyncSocket.h in Headers */ = {isa = PBXBuildFile; fileRef = DDF45BBC0BD5CD6D0050911E /* AsyncSocket.h */; }; … … 127 128 DDBE55B90BD187D5004ED228 /* libcrypto.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcrypto.dylib; path = /usr/lib/libcrypto.dylib; sourceTree = "<absolute>"; }; 128 129 DDCB77A00BD5CB8700693892 /* Acid.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Acid.pch; sourceTree = "<group>"; }; 130 DDE46AAC0BD7246C0064D202 /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = /System/Library/Frameworks/CoreServices.framework; sourceTree = "<absolute>"; }; 129 131 DDF45BBC0BD5CD6D0050911E /* AsyncSocket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AsyncSocket.h; path = "../../Chat Core/AsyncSocket.h"; sourceTree = SOURCE_ROOT; }; 130 132 DDF45C0C0BD5CF0E0050911E /* Common Settings.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = "Common Settings.xcconfig"; path = "../../Settings/Common Settings.xcconfig"; sourceTree = SOURCE_ROOT; }; … … 139 141 DDBE55BA0BD187D5004ED228 /* libcrypto.dylib in Frameworks */, 140 142 DDF45AC40BD5CC500050911E /* Foundation.framework in Frameworks */, 143 DDE46AAD0BD7246C0064D202 /* CoreServices.framework in Frameworks */, 141 144 ); 142 145 runOnlyForDeploymentPostprocessing = 0; … … 202 205 DDBE55B90BD187D5004ED228 /* libcrypto.dylib */, 203 206 DDBE55900BD1845D004ED228 /* libssl.dylib */, 207 DDE46AAC0BD7246C0064D202 /* CoreServices.framework */, 204 208 0867D69BFE84028FC02AAC07 /* Foundation.framework */, 205 209 ); trunk/Frameworks/Acid/jabber/JabberSocket.m
r3641 r3643 101 101 {} 102 102 103 - (BOOL) socketWillConnect:(AsyncSocket *)sock { 104 if( _useSSL ) { 105 CFReadStreamSetProperty( [sock getCFReadStream], kCFStreamPropertySocketSecurityLevel, kCFStreamSocketSecurityLevelNegotiatedSSL ); 106 CFWriteStreamSetProperty( [sock getCFWriteStream], kCFStreamPropertySocketSecurityLevel, kCFStreamSocketSecurityLevelNegotiatedSSL ); 107 108 NSMutableDictionary *settings = [[NSMutableDictionary allocWithZone:nil] init]; 109 [settings setObject:[NSNumber numberWithBool:YES] forKey:(NSString *)kCFStreamSSLAllowsAnyRoot]; 110 111 CFReadStreamSetProperty( [sock getCFReadStream], kCFStreamPropertySSLSettings, (CFDictionaryRef) settings ); 112 CFWriteStreamSetProperty( [sock getCFWriteStream], kCFStreamPropertySSLSettings, (CFDictionaryRef) settings ); 113 } 114 115 return YES; 116 } 117 103 118 - (void) socket:(AsyncSocket *)sock didConnectToHost:(NSString *)host port:(UInt16)port 104 119 { trunk/Panels/JVDirectChatPanel.m
r3637 r3643 181 181 int org = [[NSUserDefaults standardUserDefaults] integerForKey:@"JVChatTranscriptFolderOrganization"]; 182 182 if( org == 1 ) { 183 logs = [logs stringByAppendingPathComponent:[[self connection] server]];183 logs = [logs stringByAppendingPathComponent:[[self user] serverAddress]]; 184 184 if( ! [fileManager fileExistsAtPath:logs] ) [fileManager createDirectoryAtPath:logs attributes:nil]; 185 185 } else if( org == 2 ) { 186 logs = [logs stringByAppendingPathComponent:[NSString stringWithFormat:@"%@ (%@)", [self target], [[self connection] server]]];186 logs = [logs stringByAppendingPathComponent:[NSString stringWithFormat:@"%@ (%@)", [self target], [[self user] serverAddress]]]; 187 187 if( ! [fileManager fileExistsAtPath:logs] ) [fileManager createDirectoryAtPath:logs attributes:nil]; 188 188 } else if( org == 3 ) { 189 logs = [logs stringByAppendingPathComponent:[[self connection] server]];189 logs = [logs stringByAppendingPathComponent:[[self user] serverAddress]]; 190 190 if( ! [fileManager fileExistsAtPath:logs] ) [fileManager createDirectoryAtPath:logs attributes:nil]; 191 191 … … 204 204 205 205 if( org ) logName = [NSString stringWithFormat:@"%@.colloquyTranscript", [self target]]; 206 else logName = [NSString stringWithFormat:@"%@ (%@).colloquyTranscript", [self target], [[self connection] server]];206 else logName = [NSString stringWithFormat:@"%@ (%@).colloquyTranscript", [self target], [[self user] serverAddress]]; 207 207 nameFound = ! [fileManager fileExistsAtPath:[logs stringByAppendingPathComponent:logName]]; 208 208 209 209 while( ! nameFound ) { 210 210 if( org ) logName = [NSString stringWithFormat:@"%@ %d.colloquyTranscript", [self target], i++]; 211 else logName = [NSString stringWithFormat:@"%@ (%@) %d.colloquyTranscript", [self target], [[self connection] server], i++];211 else logName = [NSString stringWithFormat:@"%@ (%@) %d.colloquyTranscript", [self target], [[self user] serverAddress], i++]; 212 212 nameFound = ! [fileManager fileExistsAtPath:[logs stringByAppendingPathComponent:logName]]; 213 213 } 214 214 } else if( session == 1 ) { 215 215 if( org ) logName = [NSString stringWithFormat:@"%@.colloquyTranscript", [self target]]; 216 else logName = [NSString stringWithFormat:@"%@ (%@).colloquyTranscript", [self target], [[self connection] server]];216 else logName = [NSString stringWithFormat:@"%@ (%@).colloquyTranscript", [self target], [[self user] serverAddress]]; 217 217 } else if( session == 2 ) { 218 218 if( org ) logName = [NSMutableString stringWithFormat:@"%@ %@.colloquyTranscript", [self target], dateString]; 219 else logName = [NSMutableString stringWithFormat:@"%@ (%@) %@.colloquyTranscript", [self target], [[self connection] server], dateString];219 else logName = [NSMutableString stringWithFormat:@"%@ (%@) %@.colloquyTranscript", [self target], [[self user] serverAddress], dateString]; 220 220 [(NSMutableString *)logName replaceOccurrencesOfString:@"/" withString:@"-" options:NSLiteralSearch range:NSMakeRange( 0, [logName length] )]; 221 221 [(NSMutableString *)logName replaceOccurrencesOfString:@":" withString:@"-" options:NSLiteralSearch range:NSMakeRange( 0, [logName length] )]; … … 282 282 283 283 /* if( [self isMemberOfClass:[JVDirectChatPanel class]] ) { 284 NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@://%@/%@", [[self connection] urlScheme], [[self connection] server], [[[self target] description] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];285 286 NSString *path = [[NSString stringWithFormat:@"~/Library/Application Support/Colloquy/Recent Acquaintances/%@ (%@).inetloc", [self target], [[self connection] server]] stringByExpandingTildeInPath];284 NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@://%@/%@", [[self connection] urlScheme], [[self user] serverAddress], [[[self target] description] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]]; 285 286 NSString *path = [[NSString stringWithFormat:@"~/Library/Application Support/Colloquy/Recent Acquaintances/%@ (%@).inetloc", [self target], [[self user] serverAddress]] stringByExpandingTildeInPath]; 287 287 288 288 [url writeToInternetLocationFile:path]; … … 392 392 - (NSString *) windowTitle { 393 393 /* if( _buddy && [_buddy preferredNameWillReturn] != JVBuddyActiveNickname ) 394 return [NSString stringWithFormat:@"%@ (%@)", [_buddy preferredName], [[self connection] server]]; */394 return [NSString stringWithFormat:@"%@ (%@)", [_buddy preferredName], [[self user] serverAddress]]; */ 395 395 396 396 if( [[self target] isKindOfClass:[MVDirectChatConnection class]] ) { … … 401 401 } 402 402 403 return [NSString stringWithFormat:@"%@ (%@)", [self title], [[self connection] server]];403 return [NSString stringWithFormat:@"%@ (%@)", [self title], [[self user] serverAddress]]; 404 404 } 405 405 406 406 - (NSString *) information { 407 407 /* if( _buddy && [_buddy preferredNameWillReturn] != JVBuddyActiveNickname && ! [[self target] isEqualToString:[_buddy preferredName]] ) 408 return [NSString stringWithFormat:@"%@ (%@)", [self target], [[self connection] server]]; */408 return [NSString stringWithFormat:@"%@ (%@)", [self target], [[self user] serverAddress]]; */ 409 409 if( [[self target] isKindOfClass:[MVDirectChatConnection class]] ) { 410 410 if( [(MVDirectChatConnection *)[self target] status] == MVDirectChatConnectionWaitingStatus ) … … 428 428 429 429 /* if( _buddy && [_buddy preferredNameWillReturn] != JVBuddyActiveNickname ) 430 return [NSString stringWithFormat:@"%@\n%@ (%@)\n%@", [_buddy preferredName], [self target], [[self connection] server], messageCount]; */430 return [NSString stringWithFormat:@"%@\n%@ (%@)\n%@", [_buddy preferredName], [self target], [[self user] serverAddress], messageCount]; */ 431 431 432 432 if( [[self target] isKindOfClass:[MVDirectChatConnection class]] ) { … … 445 445 } 446 446 447 return [NSString stringWithFormat:@"%@ (%@)\n%@", [self title], [[self connection] server], messageCount];447 return [NSString stringWithFormat:@"%@ (%@)\n%@", [self title], [[self user] serverAddress], messageCount]; 448 448 } 449 449 … … 527 527 if( [[self target] isKindOfClass:[MVDirectChatConnection class]] ) 528 528 return [NSString stringWithFormat:@"Direct Chat %@", [self user]]; 529 return [NSString stringWithFormat:@"Direct Chat %@ (%@)", [self user], [[self connection] server]];529 return [NSString stringWithFormat:@"Direct Chat %@ (%@)", [self user], [[self user] serverAddress]]; 530 530 } 531 531
