Changeset 3081
- Timestamp:
- 12/25/05 08:13:10 (3 years ago)
- Files:
-
- branches/cocoa-networking/Chat Core.xcodeproj/project.pbxproj (modified) (4 diffs)
- branches/cocoa-networking/Chat Core/MVChatConnectionPrivate.h (added)
- branches/cocoa-networking/Chat Core/MVChatRoom.m (modified) (1 diff)
- branches/cocoa-networking/Chat Core/MVChatRoomPrivate.h (added)
- branches/cocoa-networking/Chat Core/MVChatUserPrivate.h (added)
- branches/cocoa-networking/Chat Core/MVFileTransferPrivate.h (added)
- branches/cocoa-networking/Chat Core/MVIRCChatConnection.h (modified) (3 diffs)
- branches/cocoa-networking/Chat Core/MVIRCChatConnection.m (modified) (12 diffs)
- branches/cocoa-networking/Chat Core/MVIRCChatRoom.h (modified) (2 diffs)
- branches/cocoa-networking/Chat Core/MVIRCChatRoom.m (modified) (1 diff)
- branches/cocoa-networking/Chat Core/MVIRCChatUser.h (modified) (2 diffs)
- branches/cocoa-networking/Chat Core/MVIRCFileTransfer.h (modified) (1 diff)
- branches/cocoa-networking/Chat Core/MVSILCChatConnection.h (modified) (2 diffs)
- branches/cocoa-networking/Chat Core/MVSILCChatRoom.h (modified) (2 diffs)
- branches/cocoa-networking/Chat Core/MVSILCChatUser.h (modified) (2 diffs)
- branches/cocoa-networking/Chat Core/MVSILCFileTransfer.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/cocoa-networking/Chat Core.xcodeproj/project.pbxproj
r3075 r3081 46 46 1CD020C0057593F9000F93B4 /* NSColorAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 1CD020BD057593A9000F93B4 /* NSColorAdditions.m */; }; 47 47 1CDDD9AD0718BD2E00FE11C3 /* MVChatRoom.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C5CC07A06FFCB0B0006C5B1 /* MVChatRoom.h */; settings = {ATTRIBUTES = (Public, ); }; }; 48 1CE4630F095ECCFE00AB7732 /* MVChatUserPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CE4630E095ECCFE00AB7732 /* MVChatUserPrivate.h */; }; 49 1CE4631E095ECD7300AB7732 /* MVChatRoomPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CE4631D095ECD7300AB7732 /* MVChatRoomPrivate.h */; }; 50 1CE4632F095ECDE600AB7732 /* MVFileTransferPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CE4632E095ECDE600AB7732 /* MVFileTransferPrivate.h */; }; 51 1CE4633C095ECE4F00AB7732 /* MVChatConnectionPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CE4633B095ECE4F00AB7732 /* MVChatConnectionPrivate.h */; }; 48 52 1CEEB166095BE36700166A54 /* AsyncSocket.m in Sources */ = {isa = PBXBuildFile; fileRef = 1CEEB164095BE36700166A54 /* AsyncSocket.m */; }; 49 53 1CEEB173095BE3A000166A54 /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1CEEB167095BE3A000166A54 /* CoreServices.framework */; }; … … 319 323 1CD020BC057593A9000F93B4 /* NSColorAdditions.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = NSColorAdditions.h; path = Additions/NSColorAdditions.h; sourceTree = "<group>"; }; 320 324 1CD020BD057593A9000F93B4 /* NSColorAdditions.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = NSColorAdditions.m; path = Additions/NSColorAdditions.m; sourceTree = "<group>"; }; 325 1CE4630E095ECCFE00AB7732 /* MVChatUserPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MVChatUserPrivate.h; path = "Chat Core/MVChatUserPrivate.h"; sourceTree = "<group>"; }; 326 1CE4631D095ECD7300AB7732 /* MVChatRoomPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MVChatRoomPrivate.h; path = "Chat Core/MVChatRoomPrivate.h"; sourceTree = "<group>"; }; 327 1CE4632E095ECDE600AB7732 /* MVFileTransferPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MVFileTransferPrivate.h; path = "Chat Core/MVFileTransferPrivate.h"; sourceTree = "<group>"; }; 328 1CE4633B095ECE4F00AB7732 /* MVChatConnectionPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MVChatConnectionPrivate.h; path = "Chat Core/MVChatConnectionPrivate.h"; sourceTree = "<group>"; }; 321 329 1CEEB163095BE36700166A54 /* AsyncSocket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AsyncSocket.h; path = "Chat Core/AsyncSocket.h"; sourceTree = "<group>"; }; 322 330 1CEEB164095BE36700166A54 /* AsyncSocket.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AsyncSocket.m; path = "Chat Core/AsyncSocket.m"; sourceTree = "<group>"; }; … … 716 724 F52D043001873FC401EE70DE /* MVChatConnection.m */, 717 725 F52D043101873FC401EE70DE /* MVChatConnection.h */, 726 1CE4633B095ECE4F00AB7732 /* MVChatConnectionPrivate.h */, 718 727 1C5CC07B06FFCB0B0006C5B1 /* MVChatRoom.m */, 719 728 1C5CC07A06FFCB0B0006C5B1 /* MVChatRoom.h */, 729 1CE4631D095ECD7300AB7732 /* MVChatRoomPrivate.h */, 720 730 1C5CBF3406FF986E0006C5B1 /* MVChatUser.m */, 721 731 1C5CBF3306FF986E0006C5B1 /* MVChatUser.h */, 732 1CE4630E095ECCFE00AB7732 /* MVChatUserPrivate.h */, 722 733 1C943AAA063C260800618CD9 /* MVFileTransfer.m */, 723 734 1C943AA9063C260800618CD9 /* MVFileTransfer.h */, 735 1CE4632E095ECDE600AB7732 /* MVFileTransferPrivate.h */, 724 736 1C2EF7EC0427A40B00000102 /* MVChatPluginManager.m */, 725 737 1C2EF7EB0427A40B00000102 /* MVChatPluginManager.h */, … … 788 800 1C7C776907DBBA4500FB5F83 /* NSScriptCommandAdditions.h in Headers */, 789 801 1C63E9ED086E59D700A40DD4 /* ChatCore.h in Headers */, 802 1CE4630F095ECCFE00AB7732 /* MVChatUserPrivate.h in Headers */, 803 1CE4631E095ECD7300AB7732 /* MVChatRoomPrivate.h in Headers */, 804 1CE4632F095ECDE600AB7732 /* MVFileTransferPrivate.h in Headers */, 805 1CE4633C095ECE4F00AB7732 /* MVChatConnectionPrivate.h in Headers */, 790 806 ); 791 807 runOnlyForDeploymentPostprocessing = 0; branches/cocoa-networking/Chat Core/MVChatRoom.m
r3072 r3081 533 533 } 534 534 535 - (void) _setModes:(unsigned long) modes forMemberUser:(MVChatUser *) user { 536 @synchronized( _memberModes ) { 537 [_memberModes setObject:[NSNumber numberWithUnsignedLong:modes] forKey:[user uniqueIdentifier]]; 538 } 539 } 540 535 541 - (void) _setMode:(MVChatRoomMemberMode) mode forMemberUser:(MVChatUser *) user { 536 542 @synchronized( _memberModes ) { branches/cocoa-networking/Chat Core/MVIRCChatConnection.h
r3080 r3081 1 1 #import "MVChatConnection.h" 2 #import "MVChatConnectionPrivate.h" 2 3 3 4 @class AsyncSocket; … … 27 28 @interface MVChatConnection (MVIRCChatConnectionPrivate) 28 29 - (void) _readNextMessageFromServer; 29 - (void) _handleCommand:(id) command parameters:(NSArray *) parameters fromSender:(NSString *) sender username:(NSString *) user host:(NSString *) host;30 30 31 31 + (NSData *) _flattenedIRCDataForMessage:(NSAttributedString *) message withEncoding:(NSStringEncoding) enc andChatFormat:(MVChatMessageFormat) format; … … 36 36 - (void) _updateKnownUser:(MVChatUser *) user withNewNickname:(NSString *) nickname; 37 37 @end 38 39 #pragma mark -40 41 @interface MVChatConnection (MVIRCChatConnectionPrivateSuper)42 - (void) _willConnect;43 - (void) _didConnect;44 - (void) _didNotConnect;45 - (void) _willDisconnect;46 - (void) _didDisconnect;47 - (void) _postError:(NSError *) error;48 - (void) _setStatus:(MVChatConnectionStatus) status;49 50 - (void) _addJoinedRoom:(MVChatRoom *) room;51 - (void) _removeJoinedRoom:(MVChatRoom *) room;52 @endbranches/cocoa-networking/Chat Core/MVIRCChatConnection.m
r3080 r3081 149 149 #define ERR_LISTSYNTAX 521 150 150 151 /* static void MVChatConnecting( SERVER_REC *server ) { 152 MVIRCChatConnection *self = [MVIRCChatConnection _connectionForServer:server]; 153 if( ! self ) return; 154 [self performSelectorOnMainThread:@selector( _willConnect ) withObject:nil waitUntilDone:NO]; 155 } 156 157 static void MVChatConnected( SERVER_REC *server ) { 158 MVIRCChatConnection *self = [MVIRCChatConnection _connectionForServer:server]; 159 if( ! self ) return; 160 [self performSelectorOnMainThread:@selector( _didConnect ) withObject:nil waitUntilDone:NO]; 161 } 162 163 static void MVChatDisconnect( SERVER_REC *server ) { 164 MVIRCChatConnection *self = [MVIRCChatConnection _connectionForServer:server]; 165 if( ! self ) return; 166 167 if( server -> connection_lost ) 168 [self _setStatus:MVChatConnectionServerDisconnectedStatus]; 169 170 [self _setIrssiConnection:NULL]; 171 [self performSelectorOnMainThread:@selector( _didDisconnect ) withObject:nil waitUntilDone:NO]; 172 } 173 174 static void MVChatConnectFailed( SERVER_REC *server ) { 175 MVIRCChatConnection *self = [MVIRCChatConnection _connectionForServer:server]; 176 if( ! self ) return; 177 178 server_ref( server ); 179 180 [self _setIrssiConnection:NULL]; 181 [self performSelectorOnMainThread:@selector( _didNotConnect ) withObject:nil waitUntilDone:NO]; 182 } 183 184 static void MVChatRawIncomingMessage( SERVER_REC *server, char *data ) { 185 MVIRCChatConnection *self = [MVIRCChatConnection _connectionForServer:server]; 186 if( ! self ) return; 187 188 NSNotification *note = [NSNotification notificationWithName:MVChatConnectionGotRawMessageNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[self stringWithEncodedBytes:data], @"message", [NSNumber numberWithBool:NO], @"outbound", nil]]; 189 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 190 } 191 192 static void MVChatRawOutgoingMessage( SERVER_REC *server, char *data ) { 193 MVIRCChatConnection *self = [MVIRCChatConnection _connectionForServer:server]; 194 if( ! self ) return; 195 196 NSNotification *note = [NSNotification notificationWithName:MVChatConnectionGotRawMessageNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[self stringWithEncodedBytes:data], @"message", [NSNumber numberWithBool:YES], @"outbound", nil]]; 197 [[NSNotificationCenter defaultCenter] postNotificationOnMainThread:note]; 198 } 199 200 #pragma mark - 201 202 static void MVChatNickTaken( IRC_SERVER_REC *server, const char *data, const char *by, const char *address ) { 151 /*static void MVChatNickTaken( IRC_SERVER_REC *server, const char *data, const char *by, const char *address ) { 203 152 MVIRCChatConnection *self = [MVIRCChatConnection _connectionForServer:(SERVER_REC *)server]; 204 153 if( ! self ) return; … … 1130 1079 [self _didNotConnect]; 1131 1080 1132 /* IrssiLock(); 1133 1134 if( ! _chatConnectionSettings ) { 1135 IrssiUnlock(); 1136 [self _didNotConnect]; 1137 return; 1138 } 1139 1140 CHAT_PROTOCOL_REC *proto = chat_protocol_find_id( _chatConnectionSettings -> chat_type ); 1141 1142 if( ! proto ) { 1143 IrssiUnlock(); 1144 [self _didNotConnect]; 1145 return; 1146 } 1147 1081 /* 1148 1082 // Setup the proxy header with the most current connection address and port. 1149 1083 if( _proxy == MVChatConnectionHTTPSProxy || _proxy == MVChatConnectionHTTPProxy ) { … … 1160 1094 _chatConnectionSettings -> proxy_string_after = NULL; 1161 1095 } 1162 1163 SERVER_REC *newConnection = proto -> server_init_connect( _chatConnectionSettings ); 1164 [self _setIrssiConnection:newConnection]; 1165 if( ! newConnection ) { 1166 IrssiUnlock(); 1167 [self _didNotConnect]; 1168 return; 1169 } 1170 1171 proto -> server_connect( _chatConnection ); 1172 1173 rawlog_destroy( _chatConnection -> rawlog ); 1174 _chatConnection -> rawlog = NULL; 1175 1176 IrssiUnlock(); */ 1096 */ 1177 1097 } 1178 1098 … … 1352 1272 1353 1273 #pragma mark - 1354 1355 - (void) sendMessage:(NSAttributedString *) message withEncoding:(NSStringEncoding) encoding toTarget:(NSString *) target asAction:(BOOL) action {1356 NSData *msg = [[self class] _flattenedIRCDataForMessage:message withEncoding:encoding andChatFormat:[self outgoingChatFormat]];1357 if( action ) {1358 NSString *prefix = [[NSString allocWithZone:nil] initWithFormat:@"PRIVMSG %@ :\001ACTION ", target];1359 [self sendRawMessageWithComponents:prefix, msg, @"\001", nil];1360 [prefix release];1361 } else {1362 NSString *prefix = [[NSString allocWithZone:nil] initWithFormat:@"PRIVMSG %@ :", target];1363 [self sendRawMessageWithComponents:prefix, msg, nil];1364 [prefix release];1365 }1366 }1367 1274 1368 1275 - (void) sendRawMessage:(id) raw immediately:(BOOL) now { … … 1530 1437 if( _status != MVChatConnectionServerDisconnectedStatus ) 1531 1438 _status = MVChatConnectionDisconnectedStatus; 1439 1440 id old = _localUser; 1441 _localUser = nil; 1442 [old release]; 1443 1532 1444 [self _didDisconnect]; 1533 1445 } … … 1537 1449 [self sendRawMessageWithFormat:@"NICK %@", [self nickname]]; 1538 1450 [self sendRawMessageWithFormat:@"USER %@ %@ %@ :%@", [self username], [[NSHost currentHost] name], [self server], [self realName]]; 1451 1452 id old = _localUser; 1453 _localUser = [[MVIRCChatUser allocWithZone:nil] initLocalUserWithConnection:self]; 1454 [old release]; 1455 1539 1456 [self _didConnect]; 1540 1457 [self _readNextMessageFromServer]; … … 1552 1469 char *currentParameter = NULL; 1553 1470 1554 NSString *senderString = nil;1555 NSString *usernameString = nil;1556 NSString *hostString = nil;1557 id commandObject = nil;1558 1471 NSMutableArray *parameters = [[NSMutableArray allocWithZone:nil] initWithCapacity:15]; 1559 1472 … … 1636 1549 1637 1550 end: 1638 if( sender ) senderString = [[NSString allocWithZone:nil] initWithBytes:sender encoding:[self encoding]];1639 if( user ) usernameString = [[NSString allocWithZone:nil] initWithBytes:user encoding:[self encoding]];1640 if( host ) hostString = [[NSString allocWithZone:nil] initWithBytes:host encoding:[self encoding]];1641 1551 if( command ) { 1642 if( strlen( command ) == 3 && isdigit( command[0] ) && isdigit( command[1] ) && isdigit( command[2] ) ) { 1643 unsigned long commandNumber = strtoul( command, NULL, 10 ); 1644 commandObject = [[NSNumber allocWithZone:nil] initWithUnsignedLong:commandNumber]; 1645 } else commandObject = [[NSString allocWithZone:nil] initWithBytes:command encoding:[self encoding]]; 1646 } 1647 1648 [self _handleCommand:commandObject parameters:parameters fromSender:senderString username:usernameString host:hostString]; 1552 NSString *commandString = [[NSString allocWithZone:nil] initWithBytes:command encoding:[self encoding]]; 1553 NSString *selectorString = [[NSString allocWithZone:nil] initWithFormat:@"_handle%@WithParameters:fromSender:", [commandString capitalizedString]]; 1554 SEL selector = NSSelectorFromString( selectorString ); 1555 [selectorString release]; 1556 [commandString release]; 1557 1558 if( [self respondsToSelector:selector] ) { 1559 NSString *senderString = nil; 1560 if( sender ) senderString = [[NSString allocWithZone:nil] initWithBytes:sender encoding:[self encoding]]; 1561 1562 MVChatUser *chatUser = nil; 1563 if( user ) { 1564 chatUser = [self chatUserWithUniqueIdentifier:senderString]; 1565 if( ! [chatUser address] && host ) [chatUser _setAddress:[self stringWithEncodedBytes:host]]; 1566 if( ! [chatUser username] ) [chatUser _setUsername:[self stringWithEncodedBytes:user]]; 1567 } 1568 1569 [self performSelector:selector withObject:parameters withObject:( chatUser ? (id) chatUser : (id) senderString )]; 1570 [senderString release]; 1571 } 1572 } 1649 1573 1650 1574 [[NSNotificationCenter defaultCenter] postNotificationName:MVChatConnectionGotRawMessageNotification object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:rawString, @"message", [NSNumber numberWithBool:NO], @"outbound", nil]]; 1575 1651 1576 [rawString release]; 1652 1653 [senderString release];1654 [usernameString release];1655 [hostString release];1656 [commandObject release];1657 1577 [parameters release]; 1658 1578 … … 1666 1586 } 1667 1587 1668 - (void) _handleCommand:(id) command parameters:(NSArray *) parameters fromSender:(NSString *) sender username:(NSString *) user host:(NSString *) host {1669 NSLog(@"%@ %@ %@ %@ %@", sender, user, host, command, [parameters description] );1670 }1671 1672 /* + (MVIRCChatConnection *) _connectionForServer:(SERVER_REC *) server {1673 if( ! server ) return nil;1674 1675 MVIRCChatConnectionModuleData *data = MODULE_DATA( server );1676 if( data ) return [[(data -> connection) retain] autorelease];1677 1678 return nil;1679 }1680 1681 + (void) _registerCallbacks {1682 signal_add_last( "server looking", (SIGNAL_FUNC) MVChatConnecting );1683 signal_add_last( "server connected", (SIGNAL_FUNC) MVChatConnected );1684 signal_add_last( "server disconnected", (SIGNAL_FUNC) MVChatDisconnect );1685 signal_add_last( "server connect failed", (SIGNAL_FUNC) MVChatConnectFailed );1686 1687 signal_add( "server incoming", (SIGNAL_FUNC) MVChatRawIncomingMessage );1688 signal_add( "server outgoing", (SIGNAL_FUNC) MVChatRawOutgoingMessage );1689 1690 signal_add_last( "channel joined", (SIGNAL_FUNC) MVChatJoinedRoom );1691 signal_add_last( "channel wholist", (SIGNAL_FUNC) MVChatJoinedWhoList );1692 signal_add_last( "event topic", (SIGNAL_FUNC) MVChatRoomTopicChanged );1693 signal_add_last( "channel destroyed", (SIGNAL_FUNC) MVChatLeftRoom );1694 signal_add_last( "channel mode changed", (SIGNAL_FUNC) MVChatGotRoomMode );1695 1696 signal_add_last( "ban new", (SIGNAL_FUNC) MVChatBanNew );1697 signal_add_last( "ban remove", (SIGNAL_FUNC) MVChatBanRemove );1698 1699 signal_add_last( "event join", (SIGNAL_FUNC) MVChatUserJoinedRoom );1700 signal_add_last( "event part", (SIGNAL_FUNC) MVChatUserLeftRoom );1701 signal_add_last( "event quit", (SIGNAL_FUNC) MVChatUserQuit );1702 signal_add_last( "event kick", (SIGNAL_FUNC) MVChatUserKicked );1703 signal_add_last( "event invite", (SIGNAL_FUNC) MVChatInvited );1704 signal_add_last( "event nick", (SIGNAL_FUNC) MVChatUserNicknameChanged );1705 1706 signal_add_last( "event privmsg", (SIGNAL_FUNC) MVChatGetMessage );1707 signal_add_last( "event notice", (SIGNAL_FUNC) MVChatGetAutoMessage );1708 signal_add_last( "ctcp action", (SIGNAL_FUNC) MVChatGetActionMessage );1709 1710 signal_add_last( "nick mode changed", (SIGNAL_FUNC) MVChatGotUserMode );1711 1712 signal_add_last( "away mode changed", (SIGNAL_FUNC) MVChatSelfAwayChanged );1713 1714 signal_add_last( "notifylist joined", (SIGNAL_FUNC) MVChatBuddyOnline );1715 signal_add_last( "notifylist left", (SIGNAL_FUNC) MVChatBuddyOffline );1716 signal_add_last( "notifylist away changed", (SIGNAL_FUNC) MVChatBuddyAway );1717 signal_add_last( "notifylist unidle", (SIGNAL_FUNC) MVChatBuddyUnidle );1718 1719 signal_add_last( "event 301", (SIGNAL_FUNC) MVChatUserAway );1720 signal_add_last( "event 311", (SIGNAL_FUNC) MVChatUserWhois );1721 signal_add_last( "event 312", (SIGNAL_FUNC) MVChatUserServer );1722 signal_add_last( "event 313", (SIGNAL_FUNC) MVChatUserOperator );1723 signal_add_last( "event 317", (SIGNAL_FUNC) MVChatUserIdle );1724 signal_add_last( "event 318", (SIGNAL_FUNC) MVChatUserWhoisComplete );1725 signal_add_last( "event 319", (SIGNAL_FUNC) MVChatUserChannels );1726 signal_add_last( "event 320", (SIGNAL_FUNC) MVChatUserIdentified );1727 signal_add_last( "event 322", (SIGNAL_FUNC) MVChatListRoom );1728 signal_add_last( "event 368", (SIGNAL_FUNC) MVChatBanListFinished );1729 signal_add_last( "chanquery ban end", (SIGNAL_FUNC) MVChatBanListFinished );1730 signal_add_first( "event 433", (SIGNAL_FUNC) MVChatNickTaken );1731 signal_add_last( "event 001", (SIGNAL_FUNC) MVChatNickFinal );1732 1733 // add all error codes we want to handle1734 signal_add_last( "event 401", (SIGNAL_FUNC) MVChatErrorNoSuchUser );1735 signal_add_last( "event 421", (SIGNAL_FUNC) MVChatErrorUnknownCommand );1736 1737 // catch the notifylist whois ones as well1738 signal_add_last( "notifylist event whois end", (SIGNAL_FUNC) MVChatUserWhoisComplete );1739 signal_add_last( "notifylist event whois away", (SIGNAL_FUNC) MVChatUserAway );1740 signal_add_last( "notifylist event whois", (SIGNAL_FUNC) MVChatUserWhois );1741 signal_add_last( "notifylist event whois idle", (SIGNAL_FUNC) MVChatUserIdle );1742 1743 signal_add_first( "ctcp msg", (SIGNAL_FUNC) MVChatSubcodeRequest );1744 signal_add_first( "ctcp reply", (SIGNAL_FUNC) MVChatSubcodeReply );1745 1746 signal_add_last( "dcc request", (SIGNAL_FUNC) MVChatFileTransferRequest );1747 }1748 1749 + (void) _deregisterCallbacks {1750 signals_remove_module( MODULE_NAME );1751 }1752 */1753 1588 + (NSData *) _flattenedIRCDataForMessage:(NSAttributedString *) message withEncoding:(NSStringEncoding) enc andChatFormat:(MVChatMessageFormat) format { 1754 1589 NSString *cformat = nil; … … 1783 1618 1784 1619 [super _didConnect]; 1785 }1786 1787 - (void) _didNotConnect {1788 [self _setIrssiConnection:NULL];1789 [super _didNotConnect];1790 }1791 1792 - (void) _didDisconnect {1793 if( _status == MVChatConnectionServerDisconnectedStatus ||1794 ( _chatConnection && _chatConnection -> connection_lost ) ) {1795 if( _status != MVChatConnectionSuspendedStatus )1796 _status = MVChatConnectionServerDisconnectedStatus;1797 if( ABS( [_lastConnectAttempt timeIntervalSinceNow] ) > 300. )1798 [self performSelector:@selector( connect ) withObject:nil afterDelay:5.];1799 [self scheduleReconnectAttemptEvery:30.];1800 }1801 1802 [self _setIrssiConnection:NULL];1803 [super _didDisconnect];1804 1620 } 1805 1621 … … 1896 1712 return; 1897 1713 } 1898 } 1899 1900 #pragma mark - 1714 } */ 1901 1715 1902 1716 - (void) _updateKnownUser:(MVChatUser *) user withNewNickname:(NSString *) nickname { … … 1909 1723 [user release]; 1910 1724 } 1911 } */ 1725 } 1726 1727 - (void) _sendMessage:(NSAttributedString *) message withEncoding:(NSStringEncoding) encoding toTarget:(NSString *) target asAction:(BOOL) action { 1728 NSData *msg = [[self class] _flattenedIRCDataForMessage:message withEncoding:encoding andChatFormat:[self outgoingChatFormat]]; 1729 if( action ) { 1730 NSString *prefix = [[NSString allocWithZone:nil] initWithFormat:@"PRIVMSG %@ :\001ACTION ", target]; 1731 [self sendRawMessageWithComponents:prefix, msg, @"\001", nil]; 1732 [prefix release]; 1733 } else { 1734 NSString *prefix = [[NSString allocWithZone:nil] initWithFormat:@"PRIVMSG %@ :", target]; 1735 [self sendRawMessageWithComponents:prefix, msg, nil]; 1736 [prefix release]; 1737 } 1738 } 1912 1739 @end 1740 1741 #pragma mark - 1742 1743 @implementation MVIRCChatConnection (MVIRCChatConnectionProtocolHandlers) 1744 - (void) _handleJoinWithParameters:(NSArray *) parameters fromSender:(id) sender { 1745 if( [parameters count] ) { 1746 NSString *name = [[NSString allocWithZone:nil] initWithData:[parameters objectAtIndex:0] encoding:[self encoding]]; 1747 MVChatRoom *room = [self joinedChatRoomWithName:name]; 1748 1749 if( [sender isLocalUser] ) { 1750 if( ! room ) { 1751 room = [[MVIRCChatRoom allocWithZone:nil] initWithName:name andConnection:self]; 1752 [self _addJoinedRoom:room]; 1753 [room release]; 1754 } 1755 1756 [room _setDateJoined:[NSDate date]]; 1757 [room _setDateParted:nil]; 1758 [room _setNamesSynced:NO]; 1759 [room _clearMemberUsers]; 1760 [room _clearBannedUsers]; 1761 [name release]; 1762 1763 [self sendRawMessageWithFormat:@"WHO %@", name]; 1764 } else { 1765 // user joined room 1766 } 1767 } 1768 } 1769 1770 - (void) _handle353WithParameters:(NSArray *) parameters fromSender:(id) sender { // RPL_NAMREPLY 1771 if( [parameters count] == 4 ) { 1772 MVChatRoom *room = [self joinedChatRoomWithName:[parameters objectAtIndex:2]]; 1773 if( room && ! [room _namesSynced] ) { 1774 NSString *names = [[NSString allocWithZone:nil] initWithData:[parameters objectAtIndex:3] encoding:[self encoding]]; 1775 NSArray *members = [names componentsSeparatedByString:@" "]; 1776 NSEnumerator *enumerator = [members objectEnumerator]; 1777 NSString *memberName = nil; 1778 1779 while( ( memberName = [enumerator nextObject] ) ) { 1780 unsigned int i = 0, len = [memberName length]; 1781 if( ! len ) break; 1782 1783 unsigned long modes = MVChatRoomMemberNoModes; 1784 BOOL done = NO; 1785 1786 while( i < len && ! done ) { 1787 unichar c = [memberName characterAtIndex:i]; 1788 switch( c ) { 1789 case '+': modes |= MVChatRoomMemberVoicedMode; break; 1790 case '%': modes |= MVChatRoomMemberHalfOperatorMode; break; 1791 case '@': modes |= MVChatRoomMemberOperatorMode; break; 1792 default: done = YES; break; 1793 } 1794 if( ! done ) i++; 1795 } 1796 1797 if( i > 0 ) memberName = [memberName substringFromIndex:i]; 1798 MVChatUser *member = [self chatUserWithUniqueIdentifier:memberName]; 1799 [room _addMemberUser:member]; 1800 [room _setModes:modes forMemberUser:member]; 1801 } 1802 1803 [names release]; 1804 } 1805 } 1806 } 1807 1808 - (void) _handle366WithParameters:(NSArray *) parameters fromSender:(id) sender { // RPL_ENDOFNAMES 1809 if( [parameters count] >= 2 ) { 1810 MVChatRoom *room = [self joinedChatRoomWithName:[parameters objectAtIndex:1]]; 1811 if( room && ! [room _namesSynced] ) { 1812 [room _setNamesSynced:YES]; 1813 [[NSNotificationCenter defaultCenter] postNotificationName:MVChatRoomJoinedNotification object:room]; 1814 } 1815 } 1816 } 1817 1818 - (void) _handle352WithParameters:(NSArray *) parameters fromSender:(id) sender { // RPL_WHOREPLY 1819 if( [parameters count] >= 6 ) { 1820 MVChatRoom *room = [self joinedChatRoomWithName:[parameters objectAtIndex:1]]; 1821 MVChatUser *member = [self chatUserWithUniqueIdentifier:[parameters objectAtIndex:5]]; 1822 [member _setUsername:[parameters objectAtIndex:2]]; 1823 [member _setAddress:[parameters objectAtIndex:3]]; 1824 } 1825 } 1826 1827 - (void) _handle315WithParameters:(NSArray *) parameters fromSender:(id) sender { // RPL_ENDOFWHO 1828 if( [parameters count] >= 2 ) { 1829 MVChatRoom *room = [self joinedChatRoomWithName:[parameters objectAtIndex:1]]; 1830 if( room ) [[NSNotificationCenter defaultCenter] postNotificationName:MVChatRoomMemberUsersSyncedNotification object:room]; 1831 } 1832 } 1833 @end branches/cocoa-networking/Chat Core/MVIRCChatRoom.h
r3072 r3081 1 1 #import "MVChatRoom.h" 2 #import "MVChatRoomPrivate.h" 2 3 3 4 @class MVIRCChatConnection; 4 5 5 @interface MVIRCChatRoom : MVChatRoom {} 6 @interface MVIRCChatRoom : MVChatRoom { 7 BOOL _namesSynced; 8 } 6 9 - (id) initWithName:(NSString *) name andConnection:(MVIRCChatConnection *) connection; 7 10 @end … … 9 12 #pragma mark - 10 13 11 @interface MVChatRoom (MVChatRoomPrivate) 12 - (void) _updateMemberUser:(MVChatUser *) user fromOldUniqueIdentifier:(id) identifier; 13 - (void) _clearMemberUsers; 14 - (void) _clearBannedUsers; 15 - (void) _addMemberUser:(MVChatUser *) user; 16 - (void) _removeMemberUser:(MVChatUser *) user; 17 - (void) _addBanForUser:(MVChatUser *) user; 18 - (void) _removeBanForUser:(MVChatUser *) user; 19 - (void) _setMode:(MVChatRoomMemberMode) mode forMemberUser:(MVChatUser *) user; 20 - (void) _removeMode:(MVChatRoomMemberMode) mode forMemberUser:(MVChatUser *) user; 21 - (void) _setMode:(MVChatRoomMode) mode withAttribute:(id) attribute; 22 - (void) _removeMode:(MVChatRoomMode) mode; 23 - (void) _clearModes; 24 - (void) _setDateJoined:(NSDate *) date; 25 - (void) _setDateParted:(NSDate *) date; 26 - (void) _setTopic:(NSData *) topic byAuthor:(MVChatUser *) author withDate:(NSDate *) date; 14 @interface MVChatRoom (MVIRCChatRoomPrivate) 15 - (BOOL) _namesSynced; 16 - (void) _setNamesSynced:(BOOL) synced; 27 17 @end branches/cocoa-networking/Chat Core/MVIRCChatRoom.m
r3080 r3081 226 226 } 227 227 @end 228 229 #pragma mark - 230 231 @implementation MVIRCChatRoom (MVIRCChatRoomPrivate) 232 - (BOOL) _namesSynced { 233 return _namesSynced; 234 } 235 236 - (void) _setNamesSynced:(BOOL) synced { 237 _namesSynced = synced; 238 } 239 @end branches/cocoa-networking/Chat Core/MVIRCChatUser.h
r3072 r3081 1 1 #import "MVChatUser.h" 2 #import "MVChatUserPrivate.h" 2 3 3 4 @class MVIRCChatConnection; … … 7 8 - (id) initWithNickname:(NSString *) nickname andConnection:(MVIRCChatConnection *) connection; 8 9 @end 9 10 #pragma mark -11 12 @interface MVChatUser (MVChatUserPrivate)13 - (void) _setUniqueIdentifier:(id) identifier;14 - (void) _setNickname:(NSString *) name;15 - (void) _setRealName:(NSString *) name;16 - (void) _setUsername:(NSString *) name;17 - (void) _setAddress:(NSString *) address;18 - (void) _setServerAddress:(NSString *) address;19 - (void) _setPublicKey:(NSData *) key;20 - (void) _setFingerprint:(NSString *) fingerprint;21 - (void) _setServerOperator:(BOOL) operator;22 - (void) _setIdentified:(BOOL) identified;23 - (void) _setIdleTime:(NSTimeInterval) time;24 - (void) _setStatus:(MVChatUserStatus) status;25 - (void) _setDateConnected:(NSDate *) date;26 - (void) _setDateDisconnected:(NSDate *) date;27 - (void) _setDateUpdated:(NSDate *) date;28 @endbranches/cocoa-networking/Chat Core/MVIRCFileTransfer.h
r3075 r3081 1 1 #import "MVFileTransfer.h" 2 #import "MVFileTransferPrivate.h" 2 3 3 @interface MVIRCUploadFileTransfer : MVUploadFileTransfer { 4 } 4 @interface MVIRCUploadFileTransfer : MVUploadFileTransfer {} 5 5 @end 6 6 7 7 #pragma mark - 8 8 9 @interface MVIRCDownloadFileTransfer : MVDownloadFileTransfer { 10 } 9 @interface MVIRCDownloadFileTransfer : MVDownloadFileTransfer {} 11 10 @end branches/cocoa-networking/Chat Core/MVSILCChatConnection.h
r3072 r3081 1 #import "MVChatConnection.h" 2 #import "MVChatConnectionPrivate.h" 1 3 #include <libsilc/silcincludes.h> 2 4 #include <libsilcclient/silcclient.h> 3 #import "MVChatConnection.h"4 5 5 6 #define SilcLock(client) silc_mutex_lock(silc_schedule_get_callback_lock((client)->schedule)) … … 65 66 - (NSString *) _publicKeyFilename:(SilcSocketType) connType andPublicKey:(unsigned char *) pk withLen:(SilcUInt32) pkLen usingSilcConn:(SilcClientConnection) conn; 66 67 @end 67 68 #pragma mark -69 70 @interface MVChatConnection (MVSILCChatConnectionPrivateSuper)71 - (void) _willConnect;72 - (void) _didConnect;73 - (void) _didNotConnect;74 - (void) _willDisconnect;75 - (void) _didDisconnect;76 - (void) _postError:(NSError *) error;77 - (void) _setStatus:(MVChatConnectionStatus) status;78 79 - (void) _addJoinedRoom:(MVChatRoom *) room;80 - (void) _removeJoinedRoom:(MVChatRoom *) room;81 @endbranches/cocoa-networking/Chat Core/MVSILCChatRoom.h
r3072 r3081 1 1 #import "MVChatRoom.h" 2 #import "MVChatRoomPrivate.h" 2 3 #include <libsilcclient/client.h> 3 4 #include <libsilc/silcincludes.h> … … 17 18 - (void) updateWithChannelEntry:(SilcChannelEntry) channelEntry; 18 19 @end 19 20 #pragma mark -21 22 @interface MVChatRoom (MVChatRoomPrivate)23 - (void) _updateMemberUser:(MVChatUser *) user fromOldUniqueIdentifier:(id) identifier;24 - (void) _clearMemberUsers;25 - (void) _clearBannedUsers;26 - (void) _addMemberUser:(MVChatUser *) user;27 - (void) _removeMemberUser:(MVChatUser *) user;28 - (void) _addBanForUser:(MVChatUser *) user;29 - (void) _removeBanForUser:(MVChatUser *) user;30 - (void) _setMode:(MVChatRoomMemberMode) mode forMemberUser:(MVChatUser *) user;31 - (void) _removeMode:(MVChatRoomMemberMode) mode forMemberUser:(MVChatUser *) user;32 - (void) _setMode:(MVChatRoomMode) mode withAttribute:(id) attribute;33 - (void) _removeMode:(MVChatRoomMode) mode;34 - (void) _clearModes;35 - (void) _setDateJoined:(NSDate *) date;36 - (void) _setDateParted:(NSDate *) date;37 - (void) _setTopic:(NSData *) topic byAuthor:(MVChatUser *) author withDate:(NSDate *) date;38 @endbranches/cocoa-networking/Chat Core/MVSILCChatUser.h
r3072 r3081 1 1 #import "MVChatUser.h" 2 #import "MVChatUserPrivate.h" 2 3 #include <libsilcclient/client.h> 3 4 #include <libsilc/silcincludes.h> … … 14 15 - (SilcClientEntry) _getClientEntry; 15 16 @end 16 17 #pragma mark -18 19 @interface MVChatUser (MVChatUserPrivate)20 - (void) _setUniqueIdentifier:(id) identifier;21 - (void) _setNickname:(NSString *) name;22 - (void) _setRealName:(NSString *) name;23 - (void) _setUsername:(NSString *) name;24 - (void) _setAddress:(NSString *) address;25 - (void) _setServerAddress:(NSString *) address;26 - (void) _setPublicKey:(NSData *) key;27 - (void) _setFingerprint:(NSString *) fingerprint;28 - (void) _setServerOperator:(BOOL) operator;29 - (void) _setIdentified:(BOOL) identified;30 - (void) _setIdleTime:(NSTimeInterval) time;31 - (void) _setStatus:(MVChatUserStatus) status;32 - (void) _setDateConnected:(NSDate *) date;33 - (void) _setDateDisconnected:(NSDate *) date;34 - (void) _setDateUpdated:(NSDate *) date;35 @endbranches/cocoa-networking/Chat Core/MVSILCFileTransfer.h
r3072 r3081 1 #import "MVFileTransfer.h" 2 #import "MVFileTransferPrivate.h" 1 3 #include <libsilc/silcincludes.h> 2 4 #include <libsilcclient/silcclient.h> 3 #import "MVFileTransfer.h"4 5 5 6 @interface MVSILCUploadFileTransfer : MVUploadFileTransfer { … … 19 20 #pragma mark - 20 21 21 @interface MVFileTransfer (MVSILCFileTransferPrivate)22 - (void) _setStatus:(MVFileTransferStatus) status;23 - (void) _postError:(NSError *) error;24 @end25 26 #pragma mark -27 28 22 @interface MVSILCUploadFileTransfer (MVSILCUploadFileTransferPrivate) 29 23 - (SilcUInt32) _sessionID;
