Changeset 3597
- Timestamp:
- 03/04/07 12:14:06 (2 years ago)
- Files:
-
- trunk/Chat Core.exp (modified) (1 diff)
- trunk/Chat Core/MVChatConnection.h (modified) (2 diffs)
- trunk/Chat Core/MVChatConnection.m (modified) (1 diff)
- trunk/Chat Core/MVChatRoom.h (modified) (1 diff)
- trunk/Chat Core/MVChatRoom.m (modified) (1 diff)
- trunk/Chat Core/MVICBChatConnection.m (modified) (3 diffs)
- trunk/Chat Core/MVIRCChatConnection.m (modified) (1 diff)
- trunk/Chat Core/MVSILCChatConnection.m (modified) (1 diff)
- trunk/Controllers/JVChatController.m (modified) (1 diff)
- trunk/Controllers/MVConnectionsController.m (modified) (1 diff)
- trunk/Panels/JVChatConsolePanel.m (modified) (1 diff)
- trunk/Panels/JVChatRoomPanel.h (modified) (1 diff)
- trunk/Panels/JVChatRoomPanel.m (modified) (2 diffs)
- trunk/Panels/JVDirectChatPanel.m (modified) (1 diff)
- trunk/Resources/info.colloquy.plist (modified) (1 diff)
- trunk/Resources/notifications.plist (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Chat Core.exp
r3582 r3597 51 51 _MVChatRoomUserBanRemovedNotification 52 52 _MVChatRoomUserBannedNotification 53 _MVChatRoomUserBrickedNotification 53 54 _MVChatRoomUserJoinedNotification 54 55 _MVChatRoomUserKickedNotification trunk/Chat Core/MVChatConnection.h
r3593 r3597 49 49 MVChatConnectionBannedFromServerError = -13, 50 50 MVChatConnectionServerPasswordIncorrectError = -14, 51 MVChatConnectionProtocolError = -15 51 MVChatConnectionProtocolError = -15, 52 MVChatConnectionOutOfBricksError = -16 52 53 } MVChatConnectionError; 53 54 … … 351 352 #pragma mark - 352 353 354 - (void) sendUserCommand:(NSString *) command withArguments:(NSString *) args; 355 356 #pragma mark - 357 353 358 - (void) sendRawMessage:(id) raw; 354 359 - (void) sendRawMessage:(id) raw immediately:(BOOL) now; trunk/Chat Core/MVChatConnection.m
r3582 r3597 497 497 #pragma mark - 498 498 499 - (void) sendUserCommand:(NSString *) command withArguments:(NSString *) args { 500 // subclass this method 501 [self doesNotRecognizeSelector:_cmd]; 502 } 503 504 #pragma mark - 505 499 506 - (void) sendRawMessage:(id) raw { 500 507 [self sendRawMessage:raw immediately:NO]; trunk/Chat Core/MVChatRoom.h
r3589 r3597 43 43 extern NSString *MVChatRoomUserBanRemovedNotification; 44 44 extern NSString *MVChatRoomUserModeChangedNotification; 45 extern NSString *MVChatRoomUserBrickedNotification; 45 46 46 47 extern NSString *MVChatRoomGotMessageNotification; trunk/Chat Core/MVChatRoom.m
r3590 r3597 30 30 NSString *MVChatRoomUserBanRemovedNotification = @"MVChatRoomUserBanRemovedNotification"; 31 31 NSString *MVChatRoomUserModeChangedNotification = @"MVChatRoomUserModeChangedNotification"; 32 NSString *MVChatRoomUserBrickedNotification = @"MVChatRoomUserBrickedNotification"; 32 33 33 34 NSString *MVChatRoomGotMessageNotification = @"MVChatRoomGotMessageNotification"; trunk/Chat Core/MVICBChatConnection.m
r3594 r3597 258 258 } 259 259 260 - (void) sendUserCommand:(NSString *) command withArguments:(NSString *) args { 261 if( [command compare:@"brick" ] == 0 ) { 262 [self ctsCommandPersonal:@"server" withMessage:[NSString stringWithFormat:@"%@ %@", command, args]]; 263 } else { 264 // XXX Unknown command. 265 } 266 } 267 260 268 - (void) sendRawMessage:(id) raw immediately:(BOOL) now { 261 269 NSParameterAssert( raw ); … … 887 895 withObject:nil waitUntilDone:NO]; 888 896 } 897 } else if( [message compare:@"You are out of bricks."] == 0 ) { 898 NSError *error = [NSError errorWithDomain:MVChatConnectionErrorDomain 899 code:MVChatConnectionOutOfBricksError 900 userInfo:nil]; 901 [self performSelectorOnMainThread:@selector( _postError: ) 902 withObject:error waitUntilDone:NO]; 889 903 } else if( [message compare:@"You aren't the moderator."] == 0 ) { 890 904 // XXX … … 1077 1091 object:_room 1078 1092 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:sender, @"user", nil]]; 1093 } 1094 1095 - (void) stcStatusPacketFYI:(NSArray *) fields { 1096 NSString *msg = [fields objectAtIndex:1]; 1097 1098 NSRange r; 1099 1100 if( [msg compare:@"A brick flies off into the ether."] == 0 ) { 1101 [[NSNotificationCenter defaultCenter] 1102 postNotificationOnMainThreadWithName:MVChatRoomUserBrickedNotification 1103 object:_room userInfo:nil]; 1104 } else if( hasSubstring(msg, @" has been bricked.", &r) ) { 1105 NSString *nick = [msg substringToIndex:r.location]; 1106 MVChatUser *who = [self chatUserWithUniqueIdentifier:nick]; 1107 1108 [[NSNotificationCenter defaultCenter] 1109 postNotificationOnMainThreadWithName:MVChatRoomUserBrickedNotification 1110 object:_room 1111 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:who, @"user", nil]]; 1112 } else { 1113 MVChatUser *user = [self chatUserWithUniqueIdentifier:@"server"]; 1114 NSData *msgdata = [NSData dataWithBytes:[msg cString] length:[msg length]]; 1115 1116 NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys: 1117 msgdata, @"message", 1118 [NSString locallyUniqueString], @"identifier", 1119 @"yes", @"notice", 1120 nil]; 1121 [[NSNotificationCenter defaultCenter] 1122 postNotificationOnMainThreadWithName:MVChatConnectionGotPrivateMessageNotification 1123 object:user userInfo:userInfo]; 1124 } 1125 } 1126 1127 - (void) stcStatusPacketMessage:(NSArray *) fields { 1128 NSString *msg = [fields objectAtIndex:1]; 1129 1130 /* 1131 * Known message notifications. Maybe they should be handled in some 1132 * other way, but for now we just report these as notices: 1133 * 1134 * You owe %d bricks. 1135 * You have no bricks remaining. 1136 * You have %d bricks remaining. 1137 */ 1138 1139 MVChatUser *user = [self chatUserWithUniqueIdentifier:@"server"]; 1140 NSData *msgdata = [NSData dataWithBytes:[msg cString] length:[msg length]]; 1141 1142 NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys: 1143 msgdata, @"message", 1144 [NSString locallyUniqueString], @"identifier", 1145 @"yes", @"notice", 1146 nil]; 1147 [[NSNotificationCenter defaultCenter] 1148 postNotificationOnMainThreadWithName:MVChatConnectionGotPrivateMessageNotification 1149 object:user userInfo:userInfo]; 1079 1150 } 1080 1151 trunk/Chat Core/MVIRCChatConnection.m
r3589 r3597 329 329 - (unsigned short) serverPort { 330 330 return _serverPort; 331 } 332 333 #pragma mark - 334 335 - (void) sendUserCommand:(NSString *) command withArguments:(NSString *) args { 336 if( args && [args length] > 0 ) 337 [self sendRawMessage:[NSString stringWithFormat:@"%@ %@", command, args]]; 338 else 339 [self sendRawMessage:command]; 331 340 } 332 341 trunk/Chat Core/MVSILCChatConnection.m
r3530 r3597 1225 1225 #pragma mark - 1226 1226 1227 - (void) sendUserCommand:(NSString *) command withArguments:(NSString *) args { 1228 if( args && [args length] > 0 ) 1229 [self sendRawMessage:[NSString stringWithFormat:@"%@ %@", command, args]]; 1230 else 1231 [self sendRawMessage:command]; 1232 } 1233 1234 #pragma mark - 1235 1227 1236 - (void) sendRawMessage:(NSString *) raw immediately:(BOOL) now { 1228 1237 NSParameterAssert( raw != nil ); trunk/Controllers/JVChatController.m
r3589 r3597 655 655 [alert runModal]; 656 656 } 657 } else if( [error code] == MVChatConnectionOutOfBricksError ) { 658 NSAlert *alert = [[[NSAlert alloc] init] autorelease]; 659 [alert setMessageText:[NSString stringWithFormat:NSLocalizedString( @"Out of bricks", "out of bricks alert dialog title" )]]; 660 [alert setInformativeText:[NSString stringWithFormat:NSLocalizedString( @"The user you specified could not be bricked because you are out of bricks. You can regain some more when somebody else bricks you.", "out of bricks alert dialog message" )]]; 661 [alert setAlertStyle:NSInformationalAlertStyle]; 662 [alert runModal]; 657 663 } else if( [error code] == MVChatConnectionProtocolError ) { 658 664 NSString *reason = [[error userInfo] objectForKey:@"reason"]; trunk/Controllers/MVConnectionsController.m
r3594 r3597 1897 1897 NSArray *results = [[MVChatPluginManager defaultManager] makePluginsPerformInvocation:invocation stoppingOnFirstSuccessfulReturn:YES]; 1898 1898 if( ! [[results lastObject] boolValue] ) 1899 [connection send RawMessage:[command stringByAppendingFormat:@" %@", arguments]];1899 [connection sendUserCommand:command withArguments:arguments]; 1900 1900 } else if( [command length] ) { 1901 [connection send RawMessage:command];1901 [connection sendUserCommand:command withArguments:nil]; 1902 1902 } 1903 1903 } trunk/Panels/JVChatConsolePanel.m
r3582 r3597 360 360 361 361 if( ! [[results lastObject] boolValue] ) 362 [[self connection] send RawMessage:[command stringByAppendingFormat:@" %@", [arguments string]]];362 [[self connection] sendUserCommand:command withArguments:[arguments string]]; 363 363 } else { 364 [[self connection] send RawMessage:[subMsg string]];364 [[self connection] sendUserCommand:[subMsg string] withArguments:nil]; 365 365 } 366 366 } trunk/Panels/JVChatRoomPanel.h
r3545 r3597 44 44 - (void) kickedFromRoom:(JVChatRoomPanel *) room by:(JVChatRoomMember *) by forReason:(NSAttributedString *) reason; 45 45 46 - (void) userBricked:(MVChatUser *) user inRoom:(JVChatRoomPanel *) room; 47 46 48 - (void) topicChangedTo:(NSAttributedString *) topic inRoom:(JVChatRoomPanel *) room by:(JVChatRoomMember *) member; 47 49 @end trunk/Panels/JVChatRoomPanel.m
r3589 r3597 62 62 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector( _bannedMembersSynced: ) name:MVChatRoomBannedUsersSyncedNotification object:target]; 63 63 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector( _memberNicknameChanged: ) name:MVChatUserNicknameChangedNotification object:nil]; 64 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector( _userBricked: ) name:MVChatRoomUserBrickedNotification object:target]; 64 65 } 65 66 … … 1007 1008 [_nextMessageAlertMembers removeObject:mbr]; 1008 1009 [_windowController reloadListItem:self andChildren:YES]; 1010 } 1011 1012 - (void) _userBricked:(NSNotification *) notification { 1013 MVChatUser *user = [[notification userInfo] objectForKey:@"user"]; 1014 1015 NSString *message = nil; 1016 NSString *ctxmessage = nil; 1017 if( user ) { 1018 if( [user isLocalUser] ) { 1019 message = [NSString stringWithFormat:NSLocalizedString( @"You have been bricked.", "you have been bricked status message" )]; 1020 ctxmessage = [NSString stringWithFormat:NSLocalizedString( @"You have been bricked.", "bubble message user bricked string" )]; 1021 } else { 1022 NSString *name = [user nickname]; 1023 message = [NSString stringWithFormat:NSLocalizedString( @"<span class=\"member\">%@</span> has been bricked.", "a user has been bricked status message" ), name]; 1024 ctxmessage = [NSString stringWithFormat:NSLocalizedString( @"%@ has been bricked.", "bubble message user bricked string" ), name]; 1025 } 1026 1027 [self addEventMessageToDisplay:message withName:@"userBricked" andAttributes:[NSDictionary dictionaryWithObjectsAndKeys:user, @"who", nil]]; 1028 } else { 1029 message = [NSString stringWithFormat:NSLocalizedString( @"A brick flies off into the ether.", "a brick flies off into the ether status message" )]; 1030 ctxmessage = [NSString stringWithFormat:NSLocalizedString( @"A brick flies off into the ether.", "bubble message nobody bricked string" )]; 1031 1032 [self addEventMessageToDisplay:message withName:@"userBricked" andAttributes:nil]; 1033 } 1034 NSAssert( message, @"message not initialized in conditional" ); 1035 NSAssert( ctxmessage, @"ctxmessage not initialized in conditional" ); 1036 1037 NSMethodSignature *signature = [NSMethodSignature methodSignatureWithReturnAndArgumentTypes:@encode( void ), @encode( MVChatUser * ), @encode( JVChatRoomPanel * ), nil]; 1038 NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; 1039 1040 [invocation setSelector:@selector( userBricked:inRoom: )]; 1041 [invocation setArgument:&user atIndex:2]; 1042 [invocation setArgument:&self atIndex:3]; 1043 1044 [[MVChatPluginManager defaultManager] makePluginsPerformInvocation:invocation]; 1045 1046 NSMutableDictionary *context = [NSMutableDictionary dictionary]; 1047 [context setObject:NSLocalizedString( @"Chat User Bricked", "user bricked title" ) forKey:@"title"]; 1048 [context setObject:ctxmessage forKey:@"description"]; 1049 [context setObject:self forKey:@"target"]; 1050 [context setObject:NSStringFromSelector( @selector( activate: ) ) forKey:@"action"]; 1009 1051 } 1010 1052 trunk/Panels/JVDirectChatPanel.m
r3589 r3597 1034 1034 1035 1035 if( ! ( handled = [self processUserCommand:command withArguments:arguments] ) && [[self connection] isConnected] ) 1036 [[self connection] send RawMessage:[command stringByAppendingFormat:@" %@", [arguments string]]];1036 [[self connection] sendUserCommand:command withArguments:[arguments string]]; 1037 1037 } else { 1038 1038 if( [[subMsg string] hasPrefix:@"//"] ) [subMsg deleteCharactersInRange:NSMakeRange( 0, 1 )]; trunk/Resources/info.colloquy.plist
r3579 r3597 203 203 <key>showBubbleOnlyIfBackground</key> 204 204 <true/> 205 </dict> 206 <key>JVNotificationSettings JVChatUserBricked</key> 207 <dict> 208 <key>playSound</key> 209 <true/> 210 <key>soundPath</key> 211 <string>Clap.aiff</string> 205 212 </dict> 206 213 <key>JVNotificationSettings JVChatMentioned</key> trunk/Resources/notifications.plist
r3579 r3597 176 176 </dict> 177 177 <dict> 178 <key>identifier</key> 179 <string>JVChatUserBricked</string> 180 <key>title</key> 181 <string>User Was Bricked</string> 182 </dict> 183 <dict> 178 184 <key>seperator</key> 179 185 <true />
