Changeset 3722
- Timestamp:
- 09/13/07 01:39:44 (1 year ago)
- Files:
-
- trunk/Chat Core/ChatCore.h (modified) (1 diff)
- trunk/Chat Core/MVChatConnection.h (modified) (5 diffs)
- trunk/Chat Core/MVChatConnection.m (modified) (14 diffs)
- trunk/Chat Core/MVChatConnectionPrivate.h (modified) (1 diff)
- trunk/Chat Core/MVChatRoom.h (modified) (3 diffs)
- trunk/Chat Core/MVChatRoom.m (modified) (4 diffs)
- trunk/Chat Core/MVChatUser.h (modified) (2 diffs)
- trunk/Chat Core/MVChatUser.m (modified) (1 diff)
- trunk/Chat Core/MVDirectChatConnection.h (modified) (1 diff)
- trunk/Chat Core/MVDirectChatConnection.m (modified) (4 diffs)
- trunk/Chat Core/MVDirectClientConnection.m (modified) (11 diffs)
- trunk/Chat Core/MVFileTransfer.m (modified) (3 diffs)
- trunk/Chat Core/MVICBChatConnection.h (modified) (1 diff)
- trunk/Chat Core/MVICBChatConnection.m (modified) (2 diffs)
- trunk/Chat Core/MVICBChatRoom.h (modified) (1 diff)
- trunk/Chat Core/MVICBChatRoom.m (modified) (2 diffs)
- trunk/Chat Core/MVICBChatUser.m (modified) (2 diffs)
- trunk/Chat Core/MVIRCChatConnection.h (modified) (1 diff)
- trunk/Chat Core/MVIRCChatConnection.m (modified) (18 diffs)
- trunk/Chat Core/MVIRCChatRoom.m (modified) (4 diffs)
- trunk/Chat Core/MVIRCChatUser.m (modified) (2 diffs)
- trunk/Chat Core/MVSILCChatConnection.h (modified) (1 diff)
- trunk/Chat Core/MVSILCChatConnection.m (modified) (7 diffs)
- trunk/Chat Core/MVSILCChatRoom.m (modified) (5 diffs)
- trunk/Chat Core/MVSILCChatUser.m (modified) (2 diffs)
- trunk/Chat Core/MVXMPPChatConnection.m (modified) (2 diffs)
- trunk/Chat Core/MVXMPPChatRoom.m (modified) (5 diffs)
- trunk/Chat Core/MVXMPPChatUser.m (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Chat Core/ChatCore.h
r3539 r3722 1 1 #import <ChatCore/MVUtilities.h> 2 #import <ChatCore/MVChatString.h> 2 3 3 4 #import <ChatCore/MVChatConnection.h> trunk/Chat Core/MVChatConnection.h
r3638 r3722 1 #import <ChatCore/MVChatString.h> 2 1 3 typedef enum { 2 4 MVChatConnectionUnsupportedType = 0, … … 102 104 NSDate *_lastConnectAttempt; 103 105 NSTimer *_reconnectTimer; 104 NSAttributedString *_awayMessage; 106 MVChatString *_awayMessage; 107 105 108 NSMutableDictionary *_persistentInformation; 106 109 NSError *_lastError; … … 188 191 @property(readonly) NSSet *chatUserWatchRules; 189 192 190 @property(bycopy) NSAttributedString *awayStatusMessage;193 @property(bycopy) MVChatString *awayStatusMessage; 191 194 192 195 @property(readonly) BOOL connected; … … 320 323 #pragma mark - 321 324 322 - ( NSAttributedString *) awayStatusMessage;323 - (void) setAwayStatusMessage:( NSAttributedString *) message;325 - (MVChatString *) awayStatusMessage; 326 - (void) setAwayStatusMessage:(MVChatString *) message; 324 327 325 328 #pragma mark - … … 345 348 - (void) connectToServer:(NSString *) server onPort:(unsigned short) port asUser:(NSString *) nickname; 346 349 - (void) disconnect; 347 - (void) disconnectWithReason:( NSAttributedString *) reason;350 - (void) disconnectWithReason:(MVChatString *) reason; 348 351 349 352 #pragma mark - trunk/Chat Core/MVChatConnection.m
r3638 r3722 1 1 #import "MVChatConnection.h" 2 #import "MVChatConnectionPrivate.h" 2 3 #import "MVChatRoom.h" 3 4 #import "MVChatRoomPrivate.h" 4 5 #import "MVChatUser.h" 5 6 #import "MVChatUserPrivate.h" 6 #import "MVICBChatConnection.h"7 #import "MVIRCChatConnection.h"8 #import "MVSILCChatConnection.h"9 #import "MVXMPPChatConnection.h"10 7 #import "MVFileTransfer.h" 11 #import "MVChatPluginManager.h"12 8 #import "MVChatUserWatchRule.h" 13 9 #import "NSStringAdditions.h" 14 #import "NSAttributedStringAdditions.h"15 #import "NSMethodSignatureAdditions.h"16 #import "NSScriptCommandAdditions.h"17 10 #import "NSNotificationAdditions.h" 18 11 #import "MVUtilities.h" 12 #import "MVChatString.h" 13 14 #if USE(ATTRIBUTED_CHAT_STRING) 15 #import "NSAttributedStringAdditions.h" 16 #endif 17 18 #if ENABLE(SCRIPTING) 19 #import "NSScriptCommandAdditions.h" 20 #endif 21 22 #if ENABLE(PLUGINS) 23 #import "NSMethodSignatureAdditions.h" 24 #import "MVChatPluginManager.h" 25 #endif 26 27 #if ENABLE(ICB) 28 #import "MVICBChatConnection.h" 29 #endif 30 31 #if ENABLE(IRC) 32 #import "MVIRCChatConnection.h" 33 #endif 34 35 #if ENABLE(SILC) 36 #import "MVSILCChatConnection.h" 37 #endif 38 39 #if ENABLE(XMPP) 40 #import "MVXMPPChatConnection.h" 41 #endif 19 42 20 43 NSString *MVChatConnectionWillConnectNotification = @"MVChatConnectionWillConnectNotification"; … … 58 81 + (BOOL) supportsURLScheme:(NSString *) scheme { 59 82 if( ! scheme ) return NO; 60 return ( [scheme isEqualToString:@"icb"] || [scheme isEqualToString:@"irc"] || [scheme isEqualToString:@"silc"] || [scheme isEqualToString:@"xmpp"] ); 83 84 return 85 #if ENABLE(ICB) 86 [scheme isEqualToString:@"icb"] || 87 #endif 88 #if ENABLE(IRC) 89 [scheme isEqualToString:@"irc"] || 90 #endif 91 #if ENABLE(SILC) 92 [scheme isEqualToString:@"silc"] || 93 #endif 94 #if ENABLE(XMPP) 95 [scheme isEqualToString:@"xmpp"] || 96 #endif 97 NO; 61 98 } 62 99 63 100 + (NSArray *) defaultServerPortsForType:(MVChatConnectionType) type { 64 if( type == MVChatConnectionICBType ) return [MVICBChatConnection defaultServerPorts]; 65 else if( type == MVChatConnectionIRCType ) return [MVIRCChatConnection defaultServerPorts]; 66 else if( type == MVChatConnectionSILCType ) return [MVSILCChatConnection defaultServerPorts]; 67 else if( type == MVChatConnectionXMPPType ) return [MVXMPPChatConnection defaultServerPorts]; 101 #if ENABLE(ICB) 102 if( type == MVChatConnectionICBType ) 103 return [MVICBChatConnection defaultServerPorts]; 104 #endif 105 #if ENABLE(IRC) 106 if( type == MVChatConnectionIRCType ) 107 return [MVIRCChatConnection defaultServerPorts]; 108 #endif 109 #if ENABLE(SILC) 110 if( type == MVChatConnectionSILCType ) 111 return [MVSILCChatConnection defaultServerPorts]; 112 #endif 113 #if ENABLE(XMPP) 114 if( type == MVChatConnectionXMPPType ) 115 return [MVXMPPChatConnection defaultServerPorts]; 116 #endif 68 117 return nil; 69 118 } … … 103 152 [self release]; 104 153 105 if( connectionType == MVChatConnectionICBType ) { 154 switch(connectionType) { 155 #if ENABLE(ICB) 156 case MVChatConnectionICBType: 106 157 self = [[MVICBChatConnection allocWithZone:nil] init]; 107 } else if( connectionType == MVChatConnectionIRCType ) { 158 break; 159 #endif 160 #if ENABLE(IRC) 161 case MVChatConnectionIRCType: 108 162 self = [[MVIRCChatConnection allocWithZone:nil] init]; 109 } else if ( connectionType == MVChatConnectionSILCType ) { 163 break; 164 #endif 165 #if ENABLE(SILC) 166 case MVChatConnectionSILCType: 110 167 self = [[MVSILCChatConnection allocWithZone:nil] init]; 111 } else if ( connectionType == MVChatConnectionXMPPType ) { 168 break; 169 #endif 170 #if ENABLE(XMPP) 171 case MVChatConnectionXMPPType: 112 172 self = [[MVXMPPChatConnection allocWithZone:nil] init]; 113 } else self = nil; 173 break; 174 #endif 175 default: 176 self = nil; 177 } 114 178 115 179 return self; … … 120 184 121 185 int connectionType = 0; 122 if( [[serverURL scheme] isEqualToString:@"icb"] ) connectionType = MVChatConnectionICBType; 123 else if( [[serverURL scheme] isEqualToString:@"irc"] ) connectionType = MVChatConnectionIRCType; 124 else if( [[serverURL scheme] isEqualToString:@"silc"] ) connectionType = MVChatConnectionSILCType; 125 else if( [[serverURL scheme] isEqualToString:@"xmpp"] ) connectionType = MVChatConnectionXMPPType; 186 187 #if ENABLE(ICB) 188 if( [[serverURL scheme] isEqualToString:@"icb"] ) 189 connectionType = MVChatConnectionICBType; 190 #endif 191 #if ENABLE(IRC) 192 if( [[serverURL scheme] isEqualToString:@"irc"] ) 193 connectionType = MVChatConnectionIRCType; 194 #endif 195 #if ENABLE(SILC) 196 if( [[serverURL scheme] isEqualToString:@"silc"] ) 197 connectionType = MVChatConnectionSILCType; 198 #endif 199 #if ENABLE(XMPP) 200 if( [[serverURL scheme] isEqualToString:@"xmpp"] ) 201 connectionType = MVChatConnectionXMPPType; 202 #endif 126 203 127 204 if( ( self = [self initWithServer:[serverURL host] type:connectionType port:( [[serverURL port] unsignedIntValue] % 65536 ) user:[serverURL user]] ) ) { … … 251 328 } 252 329 253 - (void) disconnectWithReason:( NSAttributedString *) reason {330 - (void) disconnectWithReason:(MVChatString *) reason { 254 331 // subclass this method 255 332 [self doesNotRecognizeSelector:_cmd]; … … 738 815 #pragma mark - 739 816 740 - ( NSAttributedString *) awayStatusMessage {817 - (MVChatString *) awayStatusMessage { 741 818 return _awayMessage; 742 819 } 743 820 744 - (void) setAwayStatusMessage:( NSAttributedString *) message {821 - (void) setAwayStatusMessage:(MVChatString *) message { 745 822 // subclass this method 746 823 [self doesNotRecognizeSelector:_cmd]; … … 830 907 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatConnectionDidConnectNotification object:self]; 831 908 909 #if ENABLE(PLUGINS) 832 910 NSMethodSignature *signature = [NSMethodSignature methodSignatureWithReturnAndArgumentTypes:@encode( void ), @encode( MVChatConnection * ), nil]; 833 911 NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; … … 837 915 838 916 [[MVChatPluginManager defaultManager] makePluginsPerformInvocation:invocation]; 917 #endif 839 918 } 840 919 … … 848 927 [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatConnectionWillDisconnectNotification object:self]; 849 928 929 #if ENABLE(PLUGINS) 850 930 NSMethodSignature *signature = [NSMethodSignature methodSignatureWithReturnAndArgumentTypes:@encode( void ), @encode( MVChatConnection * ), nil]; 851 931 NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; … … 855 935 856 936 [[MVChatPluginManager defaultManager] makePluginsPerformInvocation:invocation]; 937 #endif 857 938 } 858 939 … … 973 1054 #pragma mark - 974 1055 1056 #if ENABLE(SCRIPTING) 975 1057 @implementation MVChatConnection (MVChatConnectionScripting) 976 1058 - (NSNumber *) uniqueIdentifier { … … 1019 1101 1020 1102 - (NSTextStorage *) scriptTypedAwayMessage { 1021 return [[[NSTextStorage allocWithZone:nil] initWithAttributedString:_awayMessage] autorelease]; 1103 #if USE(ATTRIBUTED_CHAT_STRING) 1104 return [[[NSTextStorage allocWithZone:nil] initWithAttributedString:(NSAttributedString *)_awayMessage] autorelease]; 1105 #elif USE(PLAIN_CHAT_STRING) 1106 return [[[NSTextStorage allocWithZone:nil] initWithString:(NSString *)_awayMessage] autorelease]; 1107 #endif 1022 1108 } 1023 1109 1024 1110 - (void) setScriptTypedAwayMessage:(id) message { 1111 #if USE(ATTRIBUTED_CHAT_STRING) 1025 1112 NSString *msg = message; 1026 1113 if( [message isKindOfClass:[NSTextStorage class]] ) msg = [message string]; 1027 1114 NSAttributedString *attributeMsg = [NSAttributedString attributedStringWithHTMLFragment:msg baseURL:nil]; 1028 1115 [self setAwayStatusMessage:attributeMsg]; 1116 #elif USE(PLAIN_CHAT_STRING) 1117 if( [message isKindOfClass:[NSString class]] ); 1118 [self setAwayStatusMessage:message]; 1119 #endif 1029 1120 } 1030 1121 … … 1190 1281 } 1191 1282 1283 #if USE(ATTRIBUTED_CHAT_STRING) 1192 1284 NSAttributedString *realMessage = [NSAttributedString attributedStringWithHTMLFragment:message baseURL:nil]; 1285 #elif USE(PLAIN_CHAT_STRING) 1286 NSString *realMessage = message; 1287 #endif 1288 1193 1289 NSStringEncoding realEncoding = NSUTF8StringEncoding; 1194 1290 BOOL realAction = ( action ? [action boolValue] : NO ); … … 1379 1475 } 1380 1476 @end 1477 #endif trunk/Chat Core/MVChatConnectionPrivate.h
r3498 r3722 1 #define ENABLE(CHAT_FEATURE) (defined(ENABLE_##CHAT_FEATURE) && ENABLE_##CHAT_FEATURE) 2 #define USE(CHAT_FEATURE) (defined(USE_##CHAT_FEATURE) && USE_##CHAT_FEATURE) 3 4 #ifndef ENABLE_AUTO_PORT_MAPPING 5 #define ENABLE_AUTO_PORT_MAPPING 1 6 #endif 7 8 #ifndef ENABLE_SCRIPTING 9 #define ENABLE_SCRIPTING 1 10 #endif 11 12 #ifndef ENABLE_PLUGINS 13 #define ENABLE_PLUGINS 1 14 #endif 15 16 #ifndef ENABLE_IRC 17 #define ENABLE_IRC 1 18 #endif 19 20 #ifndef ENABLE_SILC 21 #define ENABLE_SILC 1 22 #endif 23 24 #ifndef ENABLE_ICB 25 #define ENABLE_ICB 1 26 #endif 27 28 #ifndef ENABLE_XMPP 29 #define ENABLE_XMPP 1 30 #endif 31 1 32 #import "MVChatConnection.h" 2 33 trunk/Chat Core/MVChatRoom.h
r3638 r3722 1 #import <ChatCore/MVChatString.h> 2 1 3 typedef enum { 2 4 MVChatRoomNoModes = 0, … … 144 146 - (void) join; 145 147 - (void) part; 146 - (void) partWithReason:(NSAttributedString *) reason; 147 148 - (void) setTopic:(NSAttributedString *) topic; 149 150 - (void) sendMessage:(NSAttributedString *) message asAction:(BOOL) action; 151 - (void) sendMessage:(NSAttributedString *) message withEncoding:(NSStringEncoding) encoding asAction:(BOOL) action; 152 - (void) sendMessage:(NSAttributedString *) message withEncoding:(NSStringEncoding) encoding withAttributes:(NSDictionary *) attributes; 148 149 - (void) partWithReason:(MVChatString *) reason; 150 151 - (void) setTopic:(MVChatString *) topic; 152 153 - (void) sendMessage:(MVChatString *) message asAction:(BOOL) action; 154 - (void) sendMessage:(MVChatString *) message withEncoding:(NSStringEncoding) encoding asAction:(BOOL) action; 155 - (void) sendMessage:(MVChatString *) message withEncoding:(NSStringEncoding) encoding withAttributes:(NSDictionary *) attributes; 153 156 154 157 - (void) sendSubcodeRequest:(NSString *) command withArguments:(id) arguments; … … 175 178 - (BOOL) hasUser:(MVChatUser *) user; 176 179 177 - (void) kickOutMemberUser:(MVChatUser *) user forReason:( NSAttributedString *) reason;180 - (void) kickOutMemberUser:(MVChatUser *) user forReason:(MVChatString *) reason; 178 181 179 182 - (void) addBanForUser:(MVChatUser *) user; trunk/Chat Core/MVChatRoom.m
r3638 r3722 186 186 } 187 187 188 - (void) partWithReason:( NSAttributedString *) reason {188 - (void) partWithReason:(MVChatString *) reason { 189 189 // subclass this method, don't call super 190 190 [self doesNotRecognizeSelector:_cmd]; … … 225 225 #pragma mark - 226 226 227 - (void) sendMessage:( NSAttributedString *) message asAction:(BOOL) action {227 - (void) sendMessage:(MVChatString *) message asAction:(BOOL) action { 228 228 [self sendMessage:message withEncoding:[self encoding] asAction:action]; 229 229 } 230 230 231 - (void) sendMessage:( NSAttributedString *) message withEncoding:(NSStringEncoding) encoding asAction:(BOOL) action {231 - (void) sendMessage:(MVChatString *) message withEncoding:(NSStringEncoding) encoding asAction:(BOOL) action { 232 232 [self sendMessage:message withEncoding:encoding withAttributes:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:action] forKey:@"action"]]; 233 233 } 234 234 235 - (void) sendMessage:( NSAttributedString *) message withEncoding:(NSStringEncoding) encoding withAttributes:(NSDictionary *) attributes {235 - (void) sendMessage:(MVChatString *) message withEncoding:(NSStringEncoding) encoding withAttributes:(NSDictionary *) attributes { 236 236 // subclass this method, don't call super 237 237 [self doesNotRecognizeSelector:_cmd]; … … 256 256 #endif 257 257 258 - (void) setTopic:( NSAttributedString *) topic {258 - (void) setTopic:(MVChatString *) topic { 259 259 // subclass this method, if needed 260 260 } … … 448 448 #pragma mark - 449 449 450 - (void) kickOutMemberUser:(MVChatUser *) user forReason:( NSAttributedString *) reason {450 - (void) kickOutMemberUser:(MVChatUser *) user forReason:(MVChatString *) reason { 451 451 NSParameterAssert( user != nil ); 452 452 // subclass this method, call super first trunk/Chat Core/MVChatUser.h
r3589 r3722 1 #import <ChatCore/MVChatString.h> 2 1 3 typedef enum { 2 4 MVChatRemoteUserType = 'remT', … … 180 182 - (void) setAttribute:(id) attribute forKey:(id) key; 181 183 182 - (void) sendMessage:(NSAttributedString *) message withEncoding:(NSStringEncoding) encoding asAction:(BOOL) action; 183 - (void) sendMessage:(NSAttributedString *) message withEncoding:(NSStringEncoding) encoding withAttributes:(NSDictionary *) attributes; 184 - (void) sendMessage:(MVChatString *) message withEncoding:(NSStringEncoding) encoding asAction:(BOOL) action; 185 - (void) sendMessage:(MVChatString *) message withEncoding:(NSStringEncoding) encoding withAttributes:(NSDictionary *) attributes; 186 184 187 - (MVUploadFileTransfer *) sendFile:(NSString *) path passively:(BOOL) passive; 185 188 trunk/Chat Core/MVChatUser.m
r3638 r3722 421 421 #pragma mark - 422 422 423 - (void) sendMessage:( NSAttributedString *) message withEncoding:(NSStringEncoding) encoding asAction:(BOOL) action {423 - (void) sendMessage:(MVChatString *) message withEncoding:(NSStringEncoding) encoding asAction:(BOOL) action { 424 424 [self sendMessage:message withEncoding:encoding withAttributes:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:action] forKey:@"action"]]; 425 425 } 426 426 427 - (void) sendMessage:( NSAttributedString *) message withEncoding:(NSStringEncoding) encoding withAttributes:(NSDictionary *) attributes {427 - (void) sendMessage:(MVChatString *) message withEncoding:(NSStringEncoding) encoding withAttributes:(NSDictionary *) attributes { 428 428 // subclass this method, don't call super 429 429 [self doesNotRecognizeSelector:_cmd]; trunk/Chat Core/MVDirectChatConnection.h
r3589 r3722 57 57 - (MVChatMessageFormat) outgoingChatFormat; 58 58 59 - (void) sendMessage:( NSAttributedString *) message withEncoding:(NSStringEncoding) encoding asAction:(BOOL) action;60 - (void) sendMessage:( NSAttributedString *) message withEncoding:(NSStringEncoding) encoding withAttributes:(NSDictionary *)attributes;59 - (void) sendMessage:(MVChatString *) message withEncoding:(NSStringEncoding) encoding asAction:(BOOL) action; 60 - (void) sendMessage:(MVChatString *) message withEncoding:(NSStringEncoding) encoding withAttributes:(NSDictionary *)attributes; 61 61 @end trunk/Chat Core/MVDirectChatConnection.m
r3626 r3722 7 7 #import "MVFileTransfer.h" 8 8 #import "MVChatUser.h" 9 #import "MVChatString.h" 9 10 #import "MVUtilities.h" 10 11 #import "NSNotificationAdditions.h" 11 12 #import "NSStringAdditions.h" 13 14 #if USE(ATTRIBUTED_CHAT_STRING) 12 15 #import "NSAttributedStringAdditions.h" 16 #endif 13 17 14 18 NSString *MVDirectChatConnectionOfferNotification = @"MVDirectChatConnectionOfferNotification"; … … 155 159 #pragma mark - 156 160 157 - (void) sendMessage:( NSAttributedString *) message asAction:(BOOL) action {161 - (void) sendMessage:(MVChatString *) message asAction:(BOOL) action { 158 162 [self sendMessage:message withEncoding:[self encoding] asAction:action]; 159 163 } 160 164 161 - (void) sendMessage:( NSAttributedString *) message withEncoding:(NSStringEncoding) encoding asAction:(BOOL) action {165 - (void) sendMessage:(MVChatString *) message withEncoding:(NSStringEncoding) encoding asAction:(BOOL) action { 162 166 [self sendMessage:message withEncoding:encoding withAttributes:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:action] forKey:@"action"]]; 163 167 } 164 168 165 - (void) sendMessage:( NSAttributedString *) message withEncoding:(NSStringEncoding) encoding withAttributes:(NSDictionary *)attributes {169 - (void) sendMessage:(MVChatString *) message withEncoding:(NSStringEncoding) encoding withAttributes:(NSDictionary *)attributes { 166 170 NSParameterAssert( message != nil ); 167 171 … … 169 173 return; 170 174 175 #if USE(ATTRIBUTED_CHAT_STRING) 171 176 NSString *cformat = nil; 172 177 … … 186 191 NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInt:encoding], @"StringEncoding", cformat, @"FormatType", nil]; 187 192 NSData *msg = [message chatFormatWithOptions:options]; 193 #elif USE(PLAIN_CHAT_STRING) 194 NSData *msg = [message dataUsingEncoding:encoding allowLossyConversion:YES]; 195 #endif 188 196 189 197 if( [[attributes objectForKey:@"action"] boolValue] ) { trunk/Chat Core/MVDirectClientConnection.m
r3713 r3722 21 21 } 22 22 23 #if ENABLE(AUTO_PORT_MAPPING) 23 24 static int natTraversalStatus( tr_upnp_t *upnp, tr_natpmp_t *natpmp ) { 24 25 int statuses[] = { … … 44 45 return TR_NAT_TRAVERSAL_ERROR; 45 46 } 47 #endif 46 48 47 49 #pragma mark - … … 60 62 [_connection disconnect]; 61 63 64 #if ENABLE(AUTO_PORT_MAPPING) 62 65 if( _upnp ) tr_upnpClose( _upnp ); 63 66 _upnp = NULL; … … 65 68 if( _natpmp ) tr_natpmpClose( _natpmp ); 66 69 _natpmp = NULL; 70 #endif 67 71 68 72 [super finalize]; … … 85 89 _threadWaitLock = nil; 86 90 91 #if ENABLE(AUTO_PORT_MAPPING) 87 92 if( _upnp ) tr_upnpClose( _upnp ); 88 93 _upnp = NULL; … … 90 95 if( _natpmp ) tr_natpmpClose( _natpmp ); 91 96 _natpmp = NULL; 97 #endif 92 98 93 99 _connectionThread = nil; … … 275 281 } 276 282 283 #if ENABLE(AUTO_PORT_MAPPING) 277 284 if( success && [MVFileTransfer isAutoPortMappingEnabled] ) { 278 285 tr_msgInit(); … … 296 303 } while( ( status == 1 || status == 3 ) && ABS( [mappingStart timeIntervalSinceNow] ) < 5. ); 297 304 } 305 #endif 298 306 299 307 if( success && [_delegate respondsToSelector:@selector( directClientConnection:acceptingConnectionsToHost:port: )] ) … … 304 312 [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector( _finish ) object:nil]; 305 313 314 #if ENABLE(AUTO_PORT_MAPPING) 306 315 if( _upnp ) tr_upnpClose( _upnp ); 307 316 _upnp = NULL; … … 309 318 if( _natpmp ) tr_natpmpClose( _natpmp ); 310 319 _natpmp = NULL; 320 #endif 311 321 312 322 id old = _acceptConnection; … … 345 355 346 356 while( ! _done ) { 357 #if ENABLE(AUTO_PORT_MAPPING) 347 358 if( _upnp ) tr_upnpPulse( _upnp ); 348 359 if( _natpmp ) tr_natpmpPulse( _natpmp ); 360 #endif 349 361 350 362 pool = [[NSAutoreleasePool allocWithZone:nil] init]; trunk/Chat Core/MVFileTransfer.m
r3530 r3722 1 1 #import "MVFileTransfer.h" 2 #import "MVIRCFileTransfer.h" 3 #import "MVSILCFileTransfer.h" 2 #import "MVChatConnectionPrivate.h" 4 3 #import "MVChatConnection.h" 5 #import "MVIRCChatConnection.h"6 4 #import "MVChatUser.h" 7 5 #import "MVUtilities.h" 8 6 #import "NSNotificationAdditions.h" 7 8 #if ENABLE(IRC) 9 #import "MVIRCFileTransfer.h" 10 #import "MVIRCChatConnection.h" 11 #endif 12 13 #if ENABLE(SILC) 14 #import "MVSILCFileTransfer.h" 15 #endif 9 16 10 17 NSString *MVDownloadFileTransferOfferNotification = @"MVDownloadFileTransferOfferNotification"; … … 32 39 33 40 + (BOOL) isAutoPortMappingEnabled { 41 #if ENABLE(AUTO_PORT_MAPPING) 34 42 return autoPortMapping; 43 #else 44 return NO; 45 #endif 35 46 } 36 47 … … 191 202 @implementation MVUploadFileTransfer 192 203 + (id) transferWithSourceFile:(NSString *) path toUser:(MVChatUser *) user passively:(BOOL) passive { 193 if( [[user connection] type] == MVChatConnectionIRCType ) { 204 switch([[user connection] type]) { 205 #if ENABLE(IRC) 206 case MVChatConnectionIRCType: 194 207 return [MVIRCUploadFileTransfer transferWithSourceFile:path toUser:user passively:passive]; 195 } else if ( [[user connection] type] == MVChatConnectionSILCType ) { 208 #endif 209 #if ENABLE(SILC) 210 case MVChatConnectionSILCType: 196 211 return [MVSILCUploadFileTransfer transferWithSourceFile:path toUser:user passively:passive]; 212 #endif 213 default: 214 return nil; 197 215 } 198 199 return nil;200 216 } 201 217 trunk/Chat Core/MVICBChatConnection.h
r3594 r3722 61 61 + (NSArray *) defaultServerPorts; 62 62 63 - (id) init;64 - (void) finalize;65 - (MVChatConnectionType) type;66 - (void) connect;67 - (void) disconnectWithReason:(NSAttributedString *) reason;68 - (NSString *) urlScheme;69 - (void) setUsername:(NSString *) newUsername;70 - (NSString *) username;71 - (void) setNickname:(NSString *) newNickname;72 - (NSString *) nickname;73 - (void) setPassword:(NSString *) newPassword;74 - (NSString *) password;75 - (void) setServer:(NSString *) newServer;76 - (NSString *) server;77 - (void) setServerPort:(unsigned short) port;78 - (unsigned short) serverPort;79 - (void) sendRawMessage:(id) raw immediately:(BOOL) now;80 - (void) joinChatRoomsNamed:(NSArray *) rooms;81 - (void) joinChatRoomNamed:(NSString *) room withPassphrase:82 (NSString *) passphrase;83 - (NSSet *) knownChatUsers;84 - (NSSet *) chatUsersWithNickname:(NSString *) nickname;85 - (MVChatUser *) chatUserWithUniqueIdentifier:(id) identifier;86 63 - (MVChatRoom *) chatRoomWithUniqueIdentifier:(id) identifier; 87 - (void) fetchChatRoomList;88 - (void) setAwayStatusMessage:(NSAttributedString *) message;89 90 64 @end 91 65 trunk/Chat Core/MVICBChatConnection.m
r3714 r3722 161 161 #pragma mark Modifiers 162 162 163 - (void) setAwayStatusMessage:( NSAttributedString *) message {163 - (void) setAwayStatusMessage:(MVChatString *) message { 164 164 } 165 165 … … 242 242 } 243 243 244 - (void) disconnectWithReason:( NSAttributedString *) reason {244 - (void) disconnectWithReason:(MVChatString *) reason { 245 245 [self cancelPendingReconnectAttempts]; 246 246 if( _sendQueueProcessing && _connectionThread ) trunk/Chat Core/MVICBChatRoom.h
r3589 r3722 42 42 - (id) initWithName:(NSString *) name 43 43 andConnection:(MVICBChatConnection *) connection; 44 45 - (void) partWithReason:(NSAttributedString *) reason;46 - (void) setTopic:(NSAttributedString *) newTopic;47 - (void) sendMessage:(NSAttributedString *) message48 withEncoding:(NSStringEncoding) encoding withAttributes:(NSDictionary *) attributes;49 44 @end trunk/Chat Core/MVICBChatRoom.m
r3589 r3722 35 35 #import "MVICBChatConnection.h" 36 36 #import "MVICBChatRoom.h" 37 #import "MVChatString.h" 37 38 38 39 @implementation MVICBChatRoom … … 52 53 #pragma mark Generic room handling 53 54 54 - (void) partWithReason:( NSAttributedString *) reason {55 - (void) partWithReason:(MVChatString *) reason { 55 56 } 56 57 57 - (void) setTopic:( NSAttributedString *) newTopic {58 - (void) setTopic:(MVChatString *) newTopic { 58 59 NSParameterAssert( newTopic ); 59 60 [(MVICBChatConnection *)_connection ctsCommandTopicSet:[newTopic string]]; 60 61 } 61 62 62 - (void) sendMessage:( NSAttributedString *) message63 - (void) sendMessage:(MVChatString *) message 63 64 withEncoding:(NSStringEncoding) encoding withAttributes:(NSDictionary *) attributes { 64 65 if( [_memberUsers count] > 1 ) trunk/Chat Core/MVICBChatUser.m
r3589 r3722 35 35 #import "MVICBChatConnection.h" 36 36 #import "MVICBChatUser.h" 37 #import "MVChatString.h" 37 38 38 39 @implementation MVICBChatUser … … 68 69 #pragma mark Message handling 69 70 70 - (void) sendMessage:( NSAttributedString *) message71 - (void) sendMessage:(MVChatString *) message 71 72 withEncoding:(NSStringEncoding) encoding 72 73 withAttributes:(NSDictionary *) attributes { trunk/Chat Core/MVIRCChatConnection.h
r3637 r3722 43 43 44 44 - (void) _handleCTCP:(NSMutableData *) data asRequest:(BOOL) request fromSender:(MVChatUser *) sender forRoom:(MVChatRoom *) room; 45 46 + (NSData *) _flattenedIRCDataForMessage:( NSAttributedString *) message withEncoding:(NSStringEncoding) enc andChatFormat:(MVChatMessageFormat) format;47 - (void) _sendMessage:( NSAttributedString *) message withEncoding:(NSStringEncoding) msgEncoding toTarget:(id) target withAttributes:(NSDictionary *) attributes;45 46 + (NSData *) _flattenedIRCDataForMessage:(MVChatString *) message withEncoding:(NSStringEncoding) enc andChatFormat:(MVChatMessageFormat) format; 47 - (void) _sendMessage:(MVChatString *) message withEncoding:(NSStringEncoding) msgEncoding toTarget:(id) target withAttributes:(NSDictionary *) attributes; 48 48 49 49 - (void) _processErrorCode:(int) errorCode withContext:(char *) context; trunk/Chat Core/MVIRCChatConnection.m
r3715 r3722 5 5 #import "MVIRCNumerics.h" 6 6 #import "MVDirectChatConnectionPrivate.h" 7 #import "MVChatString.h" 7 8 8 9 #import "AsyncSocket.h" 9 10 #import "InterThreadMessaging.h" 10 11 #import "MVChatuserWatchRule.h" 11 #import "MVChatPluginManager.h"12 #import "NSAttributedStringAdditions.h"13 #import "NSColorAdditions.h"14 12 #import "NSMethodSignatureAdditions.h" 15 13 #import "NSNotificationAdditions.h" … … 17 15 #import "NSDataAdditions.h" 18 16 #import "MVUtilities.h" 17 18 #if USE(ATTRIBUTED_CHAT_STRING) 19 #import "NSAttributedStringAdditions.h" 20 #endif 21 22 #if ENABLE(PLUGINS) 23 #import "MVChatPluginManager.h" 24 #endif 19 25 20 26 #define JVMinimumSendQueueDelay 0.2 … … 209 215 } 210 216 211 - (void) disconnectWithReason:( NSAttributedString *) reason {217 - (void) disconnectWithReason:(MVChatString *) reason { 212 218 [self performSelectorOnMainThread:@selector( cancelPendingReconnectAttempts ) withObject:nil waitUntilDone:YES]; 213 219 … … 216 222 217 223 if( _status == MVChatConnectionConnectedStatus ) { 218 if( [ [reason string]length] ) {224 if( [reason length] ) { 219 225 NSData *msg = [[self class] _flattenedIRCDataForMessage:reason withEncoding:[self encoding] andChatFormat:[self outgoingChatFormat]]; 220 226 [self sendRawMessageImmediatelyWithComponents:@"QUIT :", msg, nil]; … … 502 508 #pragma mark - 503 509 504 - (void) setAwayStatusMessage:( NSAttributedString *) message {505 if( [ [message string]length] ) {510 - (void) setAwayStatusMessage:(MVChatString *) message { 511 if( [message length] ) { 506 512 MVSafeCopyAssign( &_awayMessage, message ); 507 513 … … 915 921 #pragma mark - 916 922 917 + (NSData *) _flattenedIRCDataForMessage:(NSAttributedString *) message withEncoding:(NSStringEncoding) enc andChatFormat:(MVChatMessageFormat) format { 923 #if USE(ATTRIBUTED_CHAT_STRING) 924 + (NSData *) _flattenedIRCDataForMessage:(MVChatString *) message withEncoding:(NSStringEncoding) enc andChatFormat:(MVChatMessageFormat) format { 918 925 NSString *cformat = nil; 919 926 … … 934 941 return [message chatFormatWithOptions:options]; 935 942 } 936 937 - (void) _sendMessage:(NSAttributedString *) message withEncoding:(NSStringEncoding) msgEncoding toTarget:(id) target withAttributes:(NSDictionary *) attributes { 943 #elif USE(PLAIN_CHAT_STRING) 944 + (NSData *) _flattenedIRCDataForMessage:(MVChatString *) message withEncoding:(NSStringEncoding) enc andChatFormat:(MVChatMessageFormat) format { 945 return [message dataUsingEncoding:enc allowLossyConversion:YES]; 946 } 947 #endif 948 949 - (void) _sendMessage:(MVChatString *) message withEncoding:(NSStringEncoding) msgEncoding toTarget:(id) target withAttributes:(NSDictionary *) attributes { 938 950 NSParameterAssert( [target isKindOfClass:[MVChatUser class]] || [target isKindOfClass:[MVChatRoom class]] ); 939 951 940 952 NSMutableData *msg = [[[self class] _flattenedIRCDataForMessage:message withEncoding:msgEncoding andChatFormat:[self outgoingChatFormat]] mutableCopyWithZone:nil]; 941 953 954 #if ENABLE(PLUGINS) 942 955 NSMethodSignature *signature = [NSMethodSignature methodSignatureWithReturnAndArgumentTypes:@encode( void ), @encode( NSMutableData * ), @encode( id ), @encode( NSDictionary * ), nil]; 943 956 NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; … … 948 961 949 962 [[MVChatPluginManager defaultManager] makePluginsPerformInvocation:invocation]; 963 #endif 964 950 965 if( ! [msg length] ) { 951 966 [msg release]; … … 1074 1089 1075 1090 [self _stopSendQueue]; 1091 1076 1092 @synchronized( _sendQueue ) { 1077 1093 if( [_sendQueue count] ) … … 1475 1491 [msgAttributes setObject:[NSNumber numberWithBool:NO] forKey:@"notice"]; 1476 1492 1493 #if ENABLE(PLUGINS) 1477 1494 NSMethodSignature *signature = [NSMethodSignature methodSignatureWithReturnAndArgumentTypes:@encode( void ), @encode( NSMutableData * ), @encode( MVChatUser * ), @encode( id ), @encode( NSMutableDictionary * ), nil]; 1478 1495 NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; … … 1484 1501 1485 1502 [[MVChatPluginManager defaultManager] makePluginsPerformInvocation:invocation]; 1503 #endif 1504 1486 1505 if( ! [message length] ) return; 1487 1506 … … 1546 1565 [msgAttributes setObject:[NSNumber numberWithBool:YES] forKey:@"notice"]; 1547 1566 1567 #if ENABLE(PLUGINS) 1548 1568 NSMethodSignature *signature = [NSMethodSignature methodSignatureWithReturnAndArgumentTypes:@encode( void ), @encode( NSMutableData * ), @encode( MVChatUser * ), @encode( id ), @encode( NSMutableDictionary * ), nil]; 1549 1569 NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; … … 1555 1575 1556 1576 [[MVChatPluginManager defaultManager] makePluginsPerformInvocation:invocation]; 1577 #endif 1578 1557 1579 if( ! [message length] ) return; 1558 1580 … … 1564 1586 if( [[sender nickname] isEqualToString:@"NickServ"] ) { 1565 1587 NSString *msg = [self _newStringWithBytes:[message bytes] length:[message length]]; 1566 1567 1588 if( [msg hasCaseInsensitiveSubstring:@"NickServ"] && [msg hasCaseInsensitiveSubstring:@"IDENTIFY"] ) { 1568 1589 if( ! [self nicknamePassword] ) { … … 1655 1676 [[NSNotificationCenter defaultCenter] postNotificationName:( request ? MVChatConnectionSubcodeRequestNotification : MVChatConnectionSubcodeReplyNotification ) object:sender userInfo:[NSDictionary dictionaryWithObjectsAndKeys:command, @"command", arguments, @"arguments", nil]]; 1656 1677 1678 #if ENABLE(PLUGINS) 1657 1679 NSMethodSignature *signature = [NSMethodSignature methodSignatureWithReturnAndArgumentTypes:@encode( BOOL ), @encode( NSString * ), @encode( NSString * ), @encode( MVChatUser * ), nil]; 1658 1680 NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; … … 1670 1692 return; 1671 1693 } 1694 #endif 1672 1695 1673 1696 if( request ) { … … 2106 2129 NSMutableData *topic = [[topicInfo objectForKey:@"topic"] mutableCopyWithZone:nil]; 2107 2130 2131 #if ENABLE(PLUGINS) 2108 2132 NSMethodSignature *signature = [NSMethodSignature methodSignatureWithReturnAndArgumentTypes:@encode( void ), @encode( NSMutableData * ), @encode( MVChatRoom * ), @encode( MVChatUser * ), nil]; 2109 2133 NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; … … 2114 2138 2115 2139 [[MVChatPluginManager defaultManager] makePluginsPerformInvocation:invocation]; 2140 #endif 2116 2141 2117 2142 [room _setTopic:topic]; trunk/Chat Core/MVIRCChatRoom.m
r3589 r3722 35 35
