Changeset 1232
- Timestamp:
- 05/18/04 18:46:01 (5 years ago)
- Files:
-
- WiredClient/trunk/WCChat.m (modified) (8 diffs)
- WiredClient/trunk/WCClient.h (modified) (2 diffs)
- WiredClient/trunk/WCClient.m (modified) (4 diffs)
- WiredClient/trunk/WCConnection.h (modified) (2 diffs)
- WiredClient/trunk/WCUser.h (modified) (3 diffs)
- WiredClient/trunk/WCUser.m (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
WiredClient/trunk/WCChat.m
r1229 r1232 1 /* $Id: WCChat.m,v 1.3 6 2004/05/18 00:48:05morris Exp $ */1 /* $Id: WCChat.m,v 1.37 2004/05/18 16:46:00 morris Exp $ */ 2 2 3 3 /* … … 194 194 195 195 - (void)chatShouldAddUser:(NSNotification *)notification { 196 NSString *argument, *cid, *uid, *idle, *admin, *icon, *nick, *login, *address, *host, * image = NULL;196 NSString *argument, *cid, *uid, *idle, *admin, *icon, *nick, *login, *address, *host, *status = NULL, *image = NULL; 197 197 NSArray *fields; 198 198 NSData *data; … … 222 222 // --- protocol 1.1 223 223 if([_connection protocol] >= 1.1) { 224 image = [fields objectAtIndex:9]; 224 status = [fields objectAtIndex:9]; 225 image = [fields objectAtIndex:10]; 225 226 } 226 227 … … 242 243 // --- protocol 1.1 243 244 if([_connection protocol] >= 1.1) { 245 // --- set status 246 [user setStatus:status]; 247 244 248 // --- decode data 245 249 data = [NSData dataWithBase64EncodedString:image]; … … 418 422 419 423 - (void)userHasChanged:(NSNotification *)notification { 420 NSString *argument, *uid, *idle, *admin, *icon, *nick, * image;424 NSString *argument, *uid, *idle, *admin, *icon, *nick, *status = NULL, *image = NULL; 421 425 NSArray *fields; 422 426 NSData *data; … … 442 446 // --- protocol 1.1 443 447 if([_connection protocol] >= 1.1) { 444 image = [fields objectAtIndex:5]; 448 status = [fields objectAtIndex:5]; 449 image = [fields objectAtIndex:6]; 445 450 } 446 451 … … 467 472 // --- protocol 1.1 468 473 if([_connection protocol] >= 1.1) { 474 // --- set status 475 [user setStatus:status]; 476 469 477 // --- decode data 470 478 data = [NSData dataWithBase64EncodedString:image]; … … 1330 1338 return YES; 1331 1339 } 1340 else if([command isEqualToString:@"/status"] && [argument length] > 0) { 1341 [[_connection client] sendCommand:WCStatusCommand withArgument:argument]; 1342 1343 return YES; 1344 } 1332 1345 else if([command isEqualToString:@"/stats"]) { 1333 1346 [[_connection client] sendCommand:WCSayCommand withArgument:[NSString stringWithFormat: WiredClient/trunk/WCClient.h
r1197 r1232 1 /* $Id: WCClient.h,v 1. 6 2004/05/17 11:14:40morris Exp $ */1 /* $Id: WCClient.h,v 1.7 2004/05/18 16:46:01 morris Exp $ */ 2 2 3 3 /* … … 91 91 #define WCServersCommand @"SERVERS" 92 92 #define WCStatCommand @"STAT" 93 #define WCStatusCommand @"STATUS" 93 94 #define WCTransferCommand @"TRANSFER" 94 95 #define WCUserCommand @"USER" WiredClient/trunk/WCClient.m
r1222 r1232 1 /* $Id: WCClient.m,v 1. 19 2004/05/17 23:57:49morris Exp $ */1 /* $Id: WCClient.m,v 1.20 2004/05/18 16:46:01 morris Exp $ */ 2 2 3 3 /* … … 77 77 object:NULL]; 78 78 79 [[NSNotificationCenter defaultCenter] 80 addObserver:self 81 selector:@selector(connectionGotServerInfo:) 82 name:WCConnectionGotServerInfo 83 object:NULL]; 84 85 [[NSNotificationCenter defaultCenter] 86 addObserver:self 87 selector:@selector(nickDidChange:) 88 name:WCNickDidChange 89 object:NULL]; 90 91 [[NSNotificationCenter defaultCenter] 92 addObserver:self 93 selector:@selector(iconDidChange:) 94 name:WCIconDidChange 95 object:NULL]; 79 if([_connection type] == WCConnectionTypeServer) { 80 [[NSNotificationCenter defaultCenter] 81 addObserver:self 82 selector:@selector(connectionGotServerInfo:) 83 name:WCConnectionGotServerInfo 84 object:NULL]; 85 86 [[NSNotificationCenter defaultCenter] 87 addObserver:self 88 selector:@selector(nickDidChange:) 89 name:WCNickDidChange 90 object:NULL]; 91 92 [[NSNotificationCenter defaultCenter] 93 addObserver:self 94 selector:@selector(iconDidChange:) 95 name:WCIconDidChange 96 object:NULL]; 97 } 98 else if([_connection type] == WCConnectionTypeTracker) { 99 [[NSNotificationCenter defaultCenter] 100 addObserver:self 101 selector:@selector(connectionGotTrackerInfo:) 102 name:WCConnectionGotTrackerInfo 103 object:NULL]; 104 } 96 105 97 106 return self; … … 180 189 name = [fields objectAtIndex:2]; 181 190 182 if([_connection type] == WCConnectionTypeServer) { 183 // --- check protocol version 184 if([protocol doubleValue] > WCServerProtocolVersion) { 185 [[_connection error] setError:WCApplicationErrorProtocolMismatch]; 186 [[_connection error] raiseError]; 187 } 188 189 // --- set values 190 [[_connection server] setName:name]; 191 [[_connection server] setProtocol:[protocol doubleValue]]; 192 193 // --- rest of login 194 [self sendCommand:WCNickCommand withArgument:[WCSettings objectForKey:WCNick]]; 195 196 // --- protocol 1.1 197 if([[_connection server] protocol] >= 1.1) { 198 [self sendCommand:WCIconCommand withArgument:[NSString stringWithFormat: 199 @"%@%@%@", 200 [WCSettings objectForKey:WCIcon], 201 WCFieldSeparator, 202 [WCSettings objectForKey:WCCustomIcon]]]; 203 } else { 204 [self sendCommand:WCIconCommand withArgument:[WCSettings objectForKey:WCIcon]]; 205 } 206 207 [self sendCommand:WCClientCommand withArgument:[WCSharedMain clientVersion]]; 208 209 [self sendCommand:WCUserCommand withArgument:[[url user] length] > 0 210 ? [[url user] stringByReplacingURLPercentEscapes] 211 : @"guest"]; 212 [self sendCommand:WCPassCommand withArgument:[[url password] length] > 0 213 ? [[[url password] stringByReplacingURLPercentEscapes] SHA1] 214 : @""]; 215 [self sendCommand:WCPrivilegesCommand]; 216 [self sendCommand:WCWhoCommand withArgument:[NSString stringWithFormat:@"%d", 1]]; 217 218 if([[WCSettings objectForKey:WCLoadNewsOnLogin] boolValue]) 219 [self sendCommand:WCNewsCommand]; 220 221 // --- protocol 1.1 222 if([[_connection server] protocol] >= 1.1) 223 [self sendCommand:WCBannerCommand]; 224 } 225 else if([_connection type] == WCConnectionTypeServer) { 226 // --- check protocol version 227 if([protocol doubleValue] > WCTrackerProtocolVersion) { 228 [[_connection error] setError:WCApplicationErrorProtocolMismatch]; 229 [[_connection error] raiseError]; 230 } 231 232 // --- set values 233 [[_connection tracker] setName:name]; 234 [[_connection tracker] setProtocol:[protocol doubleValue]]; 191 // --- check protocol version 192 if([protocol doubleValue] > WCServerProtocolVersion) { 193 [[_connection error] setError:WCApplicationErrorProtocolMismatch]; 194 [[_connection error] raiseError]; 195 } 196 197 // --- set values 198 [[_connection server] setName:name]; 199 [[_connection server] setProtocol:[protocol doubleValue]]; 200 201 // --- rest of login 202 [self sendCommand:WCNickCommand withArgument:[WCSettings objectForKey:WCNick]]; 203 204 // --- protocol 1.1 205 if([[_connection server] protocol] >= 1.1) { 206 [self sendCommand:WCIconCommand withArgument:[NSString stringWithFormat: 207 @"%@%@%@", 208 [WCSettings objectForKey:WCIcon], 209 WCFieldSeparator, 210 [WCSettings objectForKey:WCCustomIcon]]]; 211 [self sendCommand:WCStatusCommand withArgument:@"hi"]; 212 } else { 213 [self sendCommand:WCIconCommand withArgument:[WCSettings objectForKey:WCIcon]]; 214 } 215 216 [self sendCommand:WCClientCommand withArgument:[WCSharedMain clientVersion]]; 217 218 [self sendCommand:WCUserCommand withArgument:[[url user] length] > 0 219 ? [[url user] stringByReplacingURLPercentEscapes] 220 : @"guest"]; 221 [self sendCommand:WCPassCommand withArgument:[[url password] length] > 0 222 ? [[[url password] stringByReplacingURLPercentEscapes] SHA1] 223 : @""]; 224 [self sendCommand:WCPrivilegesCommand]; 225 [self sendCommand:WCWhoCommand withArgument:[NSString stringWithFormat:@"%d", 1]]; 226 227 if([[WCSettings objectForKey:WCLoadNewsOnLogin] boolValue]) 228 [self sendCommand:WCNewsCommand]; 229 230 // --- protocol 1.1 231 if([[_connection server] protocol] >= 1.1) 232 [self sendCommand:WCBannerCommand]; 233 } 234 235 236 237 - (void)connectionGotTrackerInfo:(NSNotification *)notification { 238 NSArray *fields; 239 NSString *argument, *protocol, *name; 240 WCConnection *connection; 241 242 // --- get objects 243 connection = [[notification object] objectAtIndex:0]; 244 argument = [[notification object] objectAtIndex:1]; 245 246 if(connection != _connection) 247 return; 248 249 // --- separate the fields 250 fields = [argument componentsSeparatedByString:WCFieldSeparator]; 251 protocol = [fields objectAtIndex:1]; 252 name = [fields objectAtIndex:2]; 253 254 // --- set values 255 [[_connection tracker] setName:name]; 256 [[_connection tracker] setProtocol:[protocol doubleValue]]; 257 258 // --- check protocol version 259 if([[_connection tracker] protocol] > WCTrackerProtocolVersion) { 260 [[_connection error] setError:WCApplicationErrorProtocolMismatch]; 261 [[_connection error] raiseError]; 235 262 } 236 263 } … … 478 505 switch(message) { 479 506 case 200: 480 [[NSNotificationCenter defaultCenter] 481 mainThreadPostNotificationName:WCConnectionGotServerInfo 482 object:[NSArray arrayWithObjects:_connection, argument, NULL]]; 507 if([_connection type] == WCConnectionTypeServer) { 508 [[NSNotificationCenter defaultCenter] 509 mainThreadPostNotificationName:WCConnectionGotServerInfo 510 object:[NSArray arrayWithObjects:_connection, argument, NULL]]; 511 } 512 else if([_connection type] == WCConnectionTypeTracker) { 513 [[NSNotificationCenter defaultCenter] 514 mainThreadPostNotificationName:WCConnectionGotTrackerInfo 515 object:[NSArray arrayWithObjects:_connection, argument, NULL]]; 516 } 483 517 break; 484 518 WiredClient/trunk/WCConnection.h
r1187 r1232 1 /* $Id: WCConnection.h,v 1. 6 2004/05/16 15:21:37morris Exp $ */1 /* $Id: WCConnection.h,v 1.7 2004/05/18 16:46:01 morris Exp $ */ 2 2 3 3 /* … … 68 68 #define WCConnectionPrivilegesDidChange @"WCConnectionPrivilegesDidChange" 69 69 70 #define WCConnectionGotTrackerInfo @"WCConnectionGotTrackerInfo" 71 70 72 71 73 - (id) initServerConnectionWithURL:(NSURL *)url; WiredClient/trunk/WCUser.h
r1214 r1232 1 /* $Id: WCUser.h,v 1. 4 2004/05/17 18:29:56morris Exp $ */1 /* $Id: WCUser.h,v 1.5 2004/05/18 16:46:01 morris Exp $ */ 2 2 3 3 /* … … 36 36 NSString *_address; 37 37 NSString *_host; 38 NSString *_status; 39 NSImage *_iconImage; 38 40 NSDate *_joinTime; 39 NSImage *_iconImage;40 41 } 41 42 … … 66 67 - (NSString *) host; 67 68 69 - (void) setStatus:(NSString *)value; 70 - (NSString *) status; 71 68 72 - (void) setJoinTime:(NSDate *)value; 69 73 - (NSDate *) joinTime; WiredClient/trunk/WCUser.m
r1220 r1232 1 /* $Id: WCUser.m,v 1. 6 2004/05/17 23:06:06morris Exp $ */1 /* $Id: WCUser.m,v 1.7 2004/05/18 16:46:00 morris Exp $ */ 2 2 3 3 /* … … 61 61 _address = [[coder decodeObject] retain]; 62 62 _host = [[coder decodeObject] retain]; 63 _status = [[coder decodeObject] retain]; 64 _iconImage = [[coder decodeObject] retain]; 63 65 _joinTime = [[coder decodeObject] retain]; 64 _iconImage = [[coder decodeObject] retain];65 66 66 67 return self; … … 79 80 [coder encodeObject:_address]; 80 81 [coder encodeObject:_host]; 82 [coder encodeObject:_status]; 83 [coder encodeObject:_iconImage]; 81 84 [coder encodeObject:_joinTime]; 82 [coder encodeObject:_iconImage];83 85 } 84 86 … … 221 223 - (NSString *)host { 222 224 return _host; 225 } 226 227 228 229 #pragma mark - 230 231 - (void)setStatus:(NSString *)value { 232 [value retain]; 233 [_status release]; 234 235 _status = value; 236 } 237 238 239 240 - (NSString *)status { 241 return _status; 223 242 } 224 243
