Changeset 3722

Show
Ignore:
Timestamp:
09/13/07 01:39:44 (1 year ago)
Author:
timothy
Message:

Adding some defines to allow disabling of features and/or chat protocols at compile time. Also allos Chat Core to work without NSAttributedString.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Chat Core/ChatCore.h

    r3539 r3722  
    11#import <ChatCore/MVUtilities.h> 
     2#import <ChatCore/MVChatString.h> 
    23 
    34#import <ChatCore/MVChatConnection.h> 
  • trunk/Chat Core/MVChatConnection.h

    r3638 r3722  
     1#import <ChatCore/MVChatString.h> 
     2 
    13typedef enum { 
    24        MVChatConnectionUnsupportedType = 0, 
     
    102104        NSDate *_lastConnectAttempt; 
    103105        NSTimer *_reconnectTimer; 
    104         NSAttributedString *_awayMessage; 
     106        MVChatString *_awayMessage; 
     107 
    105108        NSMutableDictionary *_persistentInformation; 
    106109        NSError *_lastError; 
     
    188191@property(readonly) NSSet *chatUserWatchRules; 
    189192 
    190 @property(bycopy) NSAttributedString *awayStatusMessage; 
     193@property(bycopy) MVChatString *awayStatusMessage; 
    191194 
    192195@property(readonly) BOOL connected; 
     
    320323#pragma mark - 
    321324 
    322 - (NSAttributedString *) awayStatusMessage; 
    323 - (void) setAwayStatusMessage:(NSAttributedString *) message; 
     325- (MVChatString *) awayStatusMessage; 
     326- (void) setAwayStatusMessage:(MVChatString *) message; 
    324327 
    325328#pragma mark - 
     
    345348- (void) connectToServer:(NSString *) server onPort:(unsigned short) port asUser:(NSString *) nickname; 
    346349- (void) disconnect; 
    347 - (void) disconnectWithReason:(NSAttributedString *) reason; 
     350- (void) disconnectWithReason:(MVChatString *) reason; 
    348351 
    349352#pragma mark - 
  • trunk/Chat Core/MVChatConnection.m

    r3638 r3722  
    11#import "MVChatConnection.h" 
     2#import "MVChatConnectionPrivate.h" 
    23#import "MVChatRoom.h" 
    34#import "MVChatRoomPrivate.h" 
    45#import "MVChatUser.h" 
    56#import "MVChatUserPrivate.h" 
    6 #import "MVICBChatConnection.h" 
    7 #import "MVIRCChatConnection.h" 
    8 #import "MVSILCChatConnection.h" 
    9 #import "MVXMPPChatConnection.h" 
    107#import "MVFileTransfer.h" 
    11 #import "MVChatPluginManager.h" 
    128#import "MVChatUserWatchRule.h" 
    139#import "NSStringAdditions.h" 
    14 #import "NSAttributedStringAdditions.h" 
    15 #import "NSMethodSignatureAdditions.h" 
    16 #import "NSScriptCommandAdditions.h" 
    1710#import "NSNotificationAdditions.h" 
    1811#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 
    1942 
    2043NSString *MVChatConnectionWillConnectNotification = @"MVChatConnectionWillConnectNotification"; 
     
    5881+ (BOOL) supportsURLScheme:(NSString *) scheme { 
    5982        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; 
    6198} 
    6299 
    63100+ (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 
    68117        return nil; 
    69118} 
     
    103152        [self release]; 
    104153 
    105         if( connectionType == MVChatConnectionICBType ) { 
     154        switch(connectionType) { 
     155#if ENABLE(ICB) 
     156        case MVChatConnectionICBType: 
    106157                self = [[MVICBChatConnection allocWithZone:nil] init]; 
    107         } else if( connectionType == MVChatConnectionIRCType ) { 
     158                break; 
     159#endif 
     160#if ENABLE(IRC) 
     161        case MVChatConnectionIRCType: 
    108162                self = [[MVIRCChatConnection allocWithZone:nil] init]; 
    109         } else if ( connectionType == MVChatConnectionSILCType ) { 
     163                break; 
     164#endif 
     165#if ENABLE(SILC) 
     166        case MVChatConnectionSILCType: 
    110167                self = [[MVSILCChatConnection allocWithZone:nil] init]; 
    111         } else if ( connectionType == MVChatConnectionXMPPType ) { 
     168                break; 
     169#endif 
     170#if ENABLE(XMPP) 
     171        case MVChatConnectionXMPPType: 
    112172                self = [[MVXMPPChatConnection allocWithZone:nil] init]; 
    113         } else self = nil; 
     173                break; 
     174#endif 
     175        default: 
     176                self = nil; 
     177        } 
    114178 
    115179        return self; 
     
    120184 
    121185        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 
    126203 
    127204        if( ( self = [self initWithServer:[serverURL host] type:connectionType port:( [[serverURL port] unsignedIntValue] % 65536 ) user:[serverURL user]] ) ) { 
     
    251328} 
    252329 
    253 - (void) disconnectWithReason:(NSAttributedString *) reason { 
     330- (void) disconnectWithReason:(MVChatString *) reason { 
    254331// subclass this method 
    255332        [self doesNotRecognizeSelector:_cmd]; 
     
    738815#pragma mark - 
    739816 
    740 - (NSAttributedString *) awayStatusMessage { 
     817- (MVChatString *) awayStatusMessage { 
    741818        return _awayMessage; 
    742819} 
    743820 
    744 - (void) setAwayStatusMessage:(NSAttributedString *) message { 
     821- (void) setAwayStatusMessage:(MVChatString *) message { 
    745822// subclass this method 
    746823        [self doesNotRecognizeSelector:_cmd]; 
     
    830907        [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatConnectionDidConnectNotification object:self]; 
    831908 
     909#if ENABLE(PLUGINS) 
    832910        NSMethodSignature *signature = [NSMethodSignature methodSignatureWithReturnAndArgumentTypes:@encode( void ), @encode( MVChatConnection * ), nil]; 
    833911        NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; 
     
    837915 
    838916        [[MVChatPluginManager defaultManager] makePluginsPerformInvocation:invocation]; 
     917#endif 
    839918} 
    840919 
     
    848927        [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:MVChatConnectionWillDisconnectNotification object:self]; 
    849928 
     929#if ENABLE(PLUGINS) 
    850930        NSMethodSignature *signature = [NSMethodSignature methodSignatureWithReturnAndArgumentTypes:@encode( void ), @encode( MVChatConnection * ), nil]; 
    851931        NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; 
     
    855935 
    856936        [[MVChatPluginManager defaultManager] makePluginsPerformInvocation:invocation]; 
     937#endif 
    857938} 
    858939 
     
    9731054#pragma mark - 
    9741055 
     1056#if ENABLE(SCRIPTING) 
    9751057@implementation MVChatConnection (MVChatConnectionScripting) 
    9761058- (NSNumber *) uniqueIdentifier { 
     
    10191101 
    10201102- (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 
    10221108} 
    10231109 
    10241110- (void) setScriptTypedAwayMessage:(id) message { 
     1111#if USE(ATTRIBUTED_CHAT_STRING) 
    10251112        NSString *msg = message; 
    10261113        if( [message isKindOfClass:[NSTextStorage class]] ) msg = [message string]; 
    10271114        NSAttributedString *attributeMsg = [NSAttributedString attributedStringWithHTMLFragment:msg baseURL:nil]; 
    10281115        [self setAwayStatusMessage:attributeMsg]; 
     1116#elif USE(PLAIN_CHAT_STRING) 
     1117        if( [message isKindOfClass:[NSString class]] ); 
     1118                [self setAwayStatusMessage:message]; 
     1119#endif 
    10291120} 
    10301121 
     
    11901281        } 
    11911282 
     1283#if USE(ATTRIBUTED_CHAT_STRING) 
    11921284        NSAttributedString *realMessage = [NSAttributedString attributedStringWithHTMLFragment:message baseURL:nil]; 
     1285#elif USE(PLAIN_CHAT_STRING) 
     1286        NSString *realMessage = message; 
     1287#endif 
     1288 
    11931289        NSStringEncoding realEncoding = NSUTF8StringEncoding; 
    11941290        BOOL realAction = ( action ? [action boolValue] : NO ); 
     
    13791475} 
    13801476@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 
    132#import "MVChatConnection.h" 
    233 
  • trunk/Chat Core/MVChatRoom.h

    r3638 r3722  
     1#import <ChatCore/MVChatString.h> 
     2 
    13typedef enum { 
    24        MVChatRoomNoModes = 0, 
     
    144146- (void) join; 
    145147- (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; 
    153156 
    154157- (void) sendSubcodeRequest:(NSString *) command withArguments:(id) arguments; 
     
    175178- (BOOL) hasUser:(MVChatUser *) user; 
    176179 
    177 - (void) kickOutMemberUser:(MVChatUser *) user forReason:(NSAttributedString *) reason; 
     180- (void) kickOutMemberUser:(MVChatUser *) user forReason:(MVChatString *) reason; 
    178181 
    179182- (void) addBanForUser:(MVChatUser *) user; 
  • trunk/Chat Core/MVChatRoom.m

    r3638 r3722  
    186186} 
    187187 
    188 - (void) partWithReason:(NSAttributedString *) reason { 
     188- (void) partWithReason:(MVChatString *) reason { 
    189189// subclass this method, don't call super 
    190190        [self doesNotRecognizeSelector:_cmd]; 
     
    225225#pragma mark - 
    226226 
    227 - (void) sendMessage:(NSAttributedString *) message asAction:(BOOL) action { 
     227- (void) sendMessage:(MVChatString *) message asAction:(BOOL) action { 
    228228        [self sendMessage:message withEncoding:[self encoding] asAction:action]; 
    229229} 
    230230 
    231 - (void) sendMessage:(NSAttributedString *) message withEncoding:(NSStringEncoding) encoding asAction:(BOOL) action { 
     231- (void) sendMessage:(MVChatString *) message withEncoding:(NSStringEncoding) encoding asAction:(BOOL) action { 
    232232        [self sendMessage:message withEncoding:encoding withAttributes:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:action] forKey:@"action"]]; 
    233233} 
    234234 
    235 - (void) sendMessage:(NSAttributedString *) message withEncoding:(NSStringEncoding) encoding withAttributes:(NSDictionary *) attributes { 
     235- (void) sendMessage:(MVChatString *) message withEncoding:(NSStringEncoding) encoding withAttributes:(NSDictionary *) attributes { 
    236236        // subclass this method, don't call super 
    237237        [self doesNotRecognizeSelector:_cmd]; 
     
    256256#endif 
    257257 
    258 - (void) setTopic:(NSAttributedString *) topic { 
     258- (void) setTopic:(MVChatString *) topic { 
    259259// subclass this method, if needed 
    260260} 
     
    448448#pragma mark - 
    449449 
    450 - (void) kickOutMemberUser:(MVChatUser *) user forReason:(NSAttributedString *) reason { 
     450- (void) kickOutMemberUser:(MVChatUser *) user forReason:(MVChatString *) reason { 
    451451        NSParameterAssert( user != nil ); 
    452452// subclass this method, call super first 
  • trunk/Chat Core/MVChatUser.h

    r3589 r3722  
     1#import <ChatCore/MVChatString.h> 
     2 
    13typedef enum { 
    24        MVChatRemoteUserType = 'remT', 
     
    180182- (void) setAttribute:(id) attribute forKey:(id) key; 
    181183 
    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 
    184187- (MVUploadFileTransfer *) sendFile:(NSString *) path passively:(BOOL) passive; 
    185188 
  • trunk/Chat Core/MVChatUser.m

    r3638 r3722  
    421421#pragma mark - 
    422422 
    423 - (void) sendMessage:(NSAttributedString *) message withEncoding:(NSStringEncoding) encoding asAction:(BOOL) action { 
     423- (void) sendMessage:(MVChatString *) message withEncoding:(NSStringEncoding) encoding asAction:(BOOL) action { 
    424424        [self sendMessage:message withEncoding:encoding withAttributes:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:action] forKey:@"action"]]; 
    425425} 
    426426 
    427 - (void) sendMessage:(NSAttributedString *) message withEncoding:(NSStringEncoding) encoding withAttributes:(NSDictionary *) attributes { 
     427- (void) sendMessage:(MVChatString *) message withEncoding:(NSStringEncoding) encoding withAttributes:(NSDictionary *) attributes { 
    428428        // subclass this method, don't call super 
    429429        [self doesNotRecognizeSelector:_cmd]; 
  • trunk/Chat Core/MVDirectChatConnection.h

    r3589 r3722  
    5757- (MVChatMessageFormat) outgoingChatFormat; 
    5858 
    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; 
    6161@end 
  • trunk/Chat Core/MVDirectChatConnection.m

    r3626 r3722  
    77#import "MVFileTransfer.h" 
    88#import "MVChatUser.h" 
     9#import "MVChatString.h" 
    910#import "MVUtilities.h" 
    1011#import "NSNotificationAdditions.h" 
    1112#import "NSStringAdditions.h" 
     13 
     14#if USE(ATTRIBUTED_CHAT_STRING) 
    1215#import "NSAttributedStringAdditions.h" 
     16#endif 
    1317 
    1418NSString *MVDirectChatConnectionOfferNotification = @"MVDirectChatConnectionOfferNotification"; 
     
    155159#pragma mark - 
    156160 
    157 - (void) sendMessage:(NSAttributedString *) message asAction:(BOOL) action { 
     161- (void) sendMessage:(MVChatString *) message asAction:(BOOL) action { 
    158162        [self sendMessage:message withEncoding:[self encoding] asAction:action]; 
    159163} 
    160164 
    161 - (void) sendMessage:(NSAttributedString *) message withEncoding:(NSStringEncoding) encoding asAction:(BOOL) action { 
     165- (void) sendMessage:(MVChatString *) message withEncoding:(NSStringEncoding) encoding asAction:(BOOL) action { 
    162166        [self sendMessage:message withEncoding:encoding withAttributes:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:action] forKey:@"action"]]; 
    163167} 
    164168 
    165 - (void) sendMessage:(NSAttributedString *) message withEncoding:(NSStringEncoding) encoding withAttributes:(NSDictionary *)attributes { 
     169- (void) sendMessage:(MVChatString *) message withEncoding:(NSStringEncoding) encoding withAttributes:(NSDictionary *)attributes { 
    166170        NSParameterAssert( message != nil ); 
    167171 
     
    169173                return; 
    170174 
     175#if USE(ATTRIBUTED_CHAT_STRING) 
    171176        NSString *cformat = nil; 
    172177 
     
    186191        NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInt:encoding], @"StringEncoding", cformat, @"FormatType", nil]; 
    187192        NSData *msg = [message chatFormatWithOptions:options]; 
     193#elif USE(PLAIN_CHAT_STRING) 
     194        NSData *msg = [message dataUsingEncoding:encoding allowLossyConversion:YES]; 
     195#endif 
    188196 
    189197        if( [[attributes objectForKey:@"action"] boolValue] ) { 
  • trunk/Chat Core/MVDirectClientConnection.m

    r3713 r3722  
    2121} 
    2222 
     23#if ENABLE(AUTO_PORT_MAPPING) 
    2324static int natTraversalStatus( tr_upnp_t *upnp, tr_natpmp_t *natpmp ) { 
    2425        int statuses[] = { 
     
    4445        return TR_NAT_TRAVERSAL_ERROR; 
    4546} 
     47#endif 
    4648 
    4749#pragma mark - 
     
    6062        [_connection disconnect]; 
    6163 
     64#if ENABLE(AUTO_PORT_MAPPING) 
    6265        if( _upnp ) tr_upnpClose( _upnp ); 
    6366        _upnp = NULL; 
     
    6568        if( _natpmp ) tr_natpmpClose( _natpmp ); 
    6669        _natpmp = NULL; 
     70#endif 
    6771 
    6872        [super finalize]; 
     
    8589        _threadWaitLock = nil; 
    8690 
     91#if ENABLE(AUTO_PORT_MAPPING) 
    8792        if( _upnp ) tr_upnpClose( _upnp ); 
    8893        _upnp = NULL; 
     
    9095        if( _natpmp ) tr_natpmpClose( _natpmp ); 
    9196        _natpmp = NULL; 
     97#endif 
    9298 
    9399        _connectionThread = nil; 
     
    275281        } 
    276282 
     283#if ENABLE(AUTO_PORT_MAPPING) 
    277284        if( success && [MVFileTransfer isAutoPortMappingEnabled] ) { 
    278285                tr_msgInit(); 
     
    296303                } while( ( status == 1 || status == 3 ) && ABS( [mappingStart timeIntervalSinceNow] ) < 5. );  
    297304        } 
     305#endif 
    298306 
    299307        if( success && [_delegate respondsToSelector:@selector( directClientConnection:acceptingConnectionsToHost:port: )] ) 
     
    304312        [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector( _finish ) object:nil];        
    305313 
     314#if ENABLE(AUTO_PORT_MAPPING) 
    306315        if( _upnp ) tr_upnpClose( _upnp ); 
    307316        _upnp = NULL; 
     
    309318        if( _natpmp ) tr_natpmpClose( _natpmp ); 
    310319        _natpmp = NULL; 
     320#endif 
    311321 
    312322        id old = _acceptConnection; 
     
    345355 
    346356        while( ! _done ) { 
     357#if ENABLE(AUTO_PORT_MAPPING) 
    347358                if( _upnp ) tr_upnpPulse( _upnp ); 
    348359                if( _natpmp ) tr_natpmpPulse( _natpmp ); 
     360#endif 
    349361 
    350362                pool = [[NSAutoreleasePool allocWithZone:nil] init]; 
  • trunk/Chat Core/MVFileTransfer.m

    r3530 r3722  
    11#import "MVFileTransfer.h" 
    2 #import "MVIRCFileTransfer.h" 
    3 #import "MVSILCFileTransfer.h" 
     2#import "MVChatConnectionPrivate.h" 
    43#import "MVChatConnection.h" 
    5 #import "MVIRCChatConnection.h" 
    64#import "MVChatUser.h" 
    75#import "MVUtilities.h" 
    86#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 
    916 
    1017NSString *MVDownloadFileTransferOfferNotification = @"MVDownloadFileTransferOfferNotification"; 
     
    3239 
    3340+ (BOOL) isAutoPortMappingEnabled { 
     41#if ENABLE(AUTO_PORT_MAPPING) 
    3442        return autoPortMapping; 
     43#else 
     44        return NO; 
     45#endif 
    3546} 
    3647 
     
    191202@implementation MVUploadFileTransfer 
    192203+ (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: 
    194207                return [MVIRCUploadFileTransfer transferWithSourceFile:path toUser:user passively:passive]; 
    195         } else if ( [[user connection] type] == MVChatConnectionSILCType ) { 
     208#endif 
     209#if ENABLE(SILC) 
     210        case MVChatConnectionSILCType: 
    196211                return [MVSILCUploadFileTransfer transferWithSourceFile:path toUser:user passively:passive]; 
     212#endif 
     213        default: 
     214                return nil; 
    197215        } 
    198  
    199         return nil; 
    200216} 
    201217 
  • trunk/Chat Core/MVICBChatConnection.h

    r3594 r3722  
    6161+ (NSArray *) defaultServerPorts; 
    6262 
    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; 
    8663- (MVChatRoom *) chatRoomWithUniqueIdentifier:(id) identifier; 
    87 - (void) fetchChatRoomList; 
    88 - (void) setAwayStatusMessage:(NSAttributedString *) message; 
    89  
    9064@end 
    9165 
  • trunk/Chat Core/MVICBChatConnection.m

    r3714 r3722  
    161161#pragma mark Modifiers 
    162162 
    163 - (void) setAwayStatusMessage:(NSAttributedString *) message { 
     163- (void) setAwayStatusMessage:(MVChatString *) message { 
    164164} 
    165165 
     
    242242} 
    243243 
    244 - (void) disconnectWithReason:(NSAttributedString *) reason { 
     244- (void) disconnectWithReason:(MVChatString *) reason { 
    245245        [self cancelPendingReconnectAttempts]; 
    246246        if( _sendQueueProcessing && _connectionThread ) 
  • trunk/Chat Core/MVICBChatRoom.h

    r3589 r3722  
    4242- (id) initWithName:(NSString *) name 
    4343       andConnection:(MVICBChatConnection *) connection; 
    44  
    45 - (void) partWithReason:(NSAttributedString *) reason; 
    46 - (void) setTopic:(NSAttributedString *) newTopic; 
    47 - (void) sendMessage:(NSAttributedString *) message 
    48          withEncoding:(NSStringEncoding) encoding withAttributes:(NSDictionary *) attributes; 
    4944@end 
  • trunk/Chat Core/MVICBChatRoom.m

    r3589 r3722  
    3535#import "MVICBChatConnection.h" 
    3636#import "MVICBChatRoom.h" 
     37#import "MVChatString.h" 
    3738 
    3839@implementation MVICBChatRoom 
     
    5253#pragma mark Generic room handling 
    5354 
    54 - (void) partWithReason:(NSAttributedString *) reason { 
     55- (void) partWithReason:(MVChatString *) reason { 
    5556} 
    5657 
    57 - (void) setTopic:(NSAttributedString *) newTopic { 
     58- (void) setTopic:(MVChatString *) newTopic { 
    5859        NSParameterAssert( newTopic ); 
    5960        [(MVICBChatConnection *)_connection ctsCommandTopicSet:[newTopic string]]; 
    6061} 
    6162 
    62 - (void) sendMessage:(NSAttributedString *) message 
     63- (void) sendMessage:(MVChatString *) message 
    6364         withEncoding:(NSStringEncoding) encoding withAttributes:(NSDictionary *) attributes { 
    6465        if( [_memberUsers count] > 1 ) 
  • trunk/Chat Core/MVICBChatUser.m

    r3589 r3722  
    3535#import "MVICBChatConnection.h" 
    3636#import "MVICBChatUser.h" 
     37#import "MVChatString.h" 
    3738 
    3839@implementation MVICBChatUser 
     
    6869#pragma mark Message handling 
    6970 
    70 - (void) sendMessage:(NSAttributedString *) message 
     71- (void) sendMessage:(MVChatString *) message 
    7172         withEncoding:(NSStringEncoding) encoding 
    7273                 withAttributes:(NSDictionary *) attributes { 
  • trunk/Chat Core/MVIRCChatConnection.h

    r3637 r3722  
    4343 
    4444- (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; 
    4848 
    4949- (void) _processErrorCode:(int) errorCode withContext:(char *) context; 
  • trunk/Chat Core/MVIRCChatConnection.m

    r3715 r3722  
    55#import "MVIRCNumerics.h" 
    66#import "MVDirectChatConnectionPrivate.h" 
     7#import "MVChatString.h" 
    78 
    89#import "AsyncSocket.h" 
    910#import "InterThreadMessaging.h" 
    1011#import "MVChatuserWatchRule.h" 
    11 #import "MVChatPluginManager.h" 
    12 #import "NSAttributedStringAdditions.h" 
    13 #import "NSColorAdditions.h" 
    1412#import "NSMethodSignatureAdditions.h" 
    1513#import "NSNotificationAdditions.h" 
     
    1715#import "NSDataAdditions.h" 
    1816#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 
    1925 
    2026#define JVMinimumSendQueueDelay 0.2 
     
    209215} 
    210216 
    211 - (void) disconnectWithReason:(NSAttributedString *) reason { 
     217- (void) disconnectWithReason:(MVChatString *) reason { 
    212218        [self performSelectorOnMainThread:@selector( cancelPendingReconnectAttempts ) withObject:nil waitUntilDone:YES]; 
    213219 
     
    216222 
    217223        if( _status == MVChatConnectionConnectedStatus ) { 
    218                 if( [[reason string] length] ) { 
     224                if( [reason length] ) { 
    219225                        NSData *msg = [[self class] _flattenedIRCDataForMessage:reason withEncoding:[self encoding] andChatFormat:[self outgoingChatFormat]]; 
    220226                        [self sendRawMessageImmediatelyWithComponents:@"QUIT :", msg, nil]; 
     
    502508#pragma mark - 
    503509 
    504 - (void) setAwayStatusMessage:(NSAttributedString *) message { 
    505         if( [[message string] length] ) { 
     510- (void) setAwayStatusMessage:(MVChatString *) message { 
     511        if( [message length] ) { 
    506512                MVSafeCopyAssign( &_awayMessage, message ); 
    507513 
     
    915921#pragma mark - 
    916922 
    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 { 
    918925        NSString *cformat = nil; 
    919926 
     
    934941        return [message chatFormatWithOptions:options]; 
    935942} 
    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 { 
    938950        NSParameterAssert( [target isKindOfClass:[MVChatUser class]] || [target isKindOfClass:[MVChatRoom class]] ); 
    939951 
    940952        NSMutableData *msg = [[[self class] _flattenedIRCDataForMessage:message withEncoding:msgEncoding andChatFormat:[self outgoingChatFormat]] mutableCopyWithZone:nil]; 
    941953 
     954#if ENABLE(PLUGINS) 
    942955        NSMethodSignature *signature = [NSMethodSignature methodSignatureWithReturnAndArgumentTypes:@encode( void ), @encode( NSMutableData * ), @encode( id ), @encode( NSDictionary * ), nil]; 
    943956        NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; 
     
    948961 
    949962        [[MVChatPluginManager defaultManager] makePluginsPerformInvocation:invocation]; 
     963#endif 
     964 
    950965        if( ! [msg length] ) { 
    951966                [msg release]; 
     
    10741089 
    10751090        [self _stopSendQueue]; 
     1091 
    10761092        @synchronized( _sendQueue ) { 
    10771093                if( [_sendQueue count] ) 
     
    14751491        [msgAttributes setObject:[NSNumber numberWithBool:NO] forKey:@"notice"]; 
    14761492 
     1493#if ENABLE(PLUGINS) 
    14771494        NSMethodSignature *signature = [NSMethodSignature methodSignatureWithReturnAndArgumentTypes:@encode( void ), @encode( NSMutableData * ), @encode( MVChatUser * ), @encode( id ), @encode( NSMutableDictionary * ), nil]; 
    14781495        NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; 
     
    14841501 
    14851502        [[MVChatPluginManager defaultManager] makePluginsPerformInvocation:invocation]; 
     1503#endif 
     1504 
    14861505        if( ! [message length] ) return; 
    14871506 
     
    15461565        [msgAttributes setObject:[NSNumber numberWithBool:YES] forKey:@"notice"]; 
    15471566 
     1567#if ENABLE(PLUGINS) 
    15481568        NSMethodSignature *signature = [NSMethodSignature methodSignatureWithReturnAndArgumentTypes:@encode( void ), @encode( NSMutableData * ), @encode( MVChatUser * ), @encode( id ), @encode( NSMutableDictionary * ), nil]; 
    15491569        NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; 
     
    15551575 
    15561576        [[MVChatPluginManager defaultManager] makePluginsPerformInvocation:invocation]; 
     1577#endif 
     1578 
    15571579        if( ! [message length] ) return; 
    15581580 
     
    15641586                if( [[sender nickname] isEqualToString:@"NickServ"] ) { 
    15651587                        NSString *msg = [self _newStringWithBytes:[message bytes] length:[message length]]; 
    1566  
    15671588                        if( [msg hasCaseInsensitiveSubstring:@"NickServ"] && [msg hasCaseInsensitiveSubstring:@"IDENTIFY"] ) { 
    15681589                                if( ! [self nicknamePassword] ) { 
     
    16551676        [[NSNotificationCenter defaultCenter] postNotificationName:( request ? MVChatConnectionSubcodeRequestNotification : MVChatConnectionSubcodeReplyNotification ) object:sender userInfo:[NSDictionary dictionaryWithObjectsAndKeys:command, @"command", arguments, @"arguments", nil]]; 
    16561677 
     1678#if ENABLE(PLUGINS) 
    16571679        NSMethodSignature *signature = [NSMethodSignature methodSignatureWithReturnAndArgumentTypes:@encode( BOOL ), @encode( NSString * ), @encode( NSString * ), @encode( MVChatUser * ), nil]; 
    16581680        NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; 
     
    16701692                return; 
    16711693        } 
     1694#endif 
    16721695 
    16731696        if( request ) { 
     
    21062129        NSMutableData *topic = [[topicInfo objectForKey:@"topic"] mutableCopyWithZone:nil]; 
    21072130 
     2131#if ENABLE(PLUGINS) 
    21082132        NSMethodSignature *signature = [NSMethodSignature methodSignatureWithReturnAndArgumentTypes:@encode( void ), @encode( NSMutableData * ), @encode( MVChatRoom * ), @encode( MVChatUser * ), nil]; 
    21092133        NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature]; 
     
    21142138 
    21152139        [[MVChatPluginManager defaultManager] makePluginsPerformInvocation:invocation]; 
     2140#endif 
    21162141 
    21172142        [room _setTopic:topic]; 
  • trunk/Chat Core/MVIRCChatRoom.m

    r3589 r3722  
    3535