Changeset 3564

Show
Ignore:
Timestamp:
01/22/07 14:46:50 (2 years ago)
Author:
timothy
Message:

Pass NSAttributedStrings to JavaScript? plugins as HTML strings.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Plug-Ins/JavaScript Support/JVJavaScriptChatPlugin.m

    r3482 r3564  
    1818#import "MVConnectionsController.h" 
    1919#import "MVFileTransferController.h" 
     20#import "NSAttributedStringAdditions.h" 
    2021#import "NSStringAdditions.h" 
    2122 
     
    452453 
    453454- (BOOL) processUserCommand:(NSString *) command withArguments:(NSAttributedString *) arguments toConnection:(MVChatConnection *) connection inView:(id <JVChatViewController>) view { 
    454         NSArray *args = [NSArray arrayWithObjects:command, ( arguments ? (id)[arguments string] : (id)[NSNull null] ), ( connection ? (id)connection : (id)[NSNull null] ), ( view ? (id)view : (id)[NSNull null] ), nil]; 
     455        NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"IgnoreFonts", [NSNumber numberWithBool:YES], @"IgnoreFontSizes", nil]; 
     456        NSString *argumentsHTML = [arguments HTMLFormatWithOptions:options]; 
     457        argumentsHTML = [argumentsHTML stringByStrippingIllegalXMLCharacters]; 
     458 
     459        NSArray *args = [NSArray arrayWithObjects:command, ( argumentsHTML ? (id)argumentsHTML : (id)[NSNull null] ), ( connection ? (id)connection : (id)[NSNull null] ), ( view ? (id)view : (id)[NSNull null] ), nil]; 
    455460        id result = [self callScriptFunctionNamed:@"processUserCommand" withArguments:args forSelector:_cmd]; 
    456461        return ( [result isKindOfClass:[NSNumber class]] ? [result boolValue] : NO ); 
     
    479484 
    480485- (void) memberParted:(JVChatRoomMember *) member fromRoom:(JVChatRoomPanel *) room forReason:(NSAttributedString *) reason { 
    481         NSArray *args = [NSArray arrayWithObjects:member, room, ( reason ? (id)[reason string] : (id)[NSNull null] ), nil]; 
     486        NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"IgnoreFonts", [NSNumber numberWithBool:YES], @"IgnoreFontSizes", nil]; 
     487        NSString *reasonHTML = [reason HTMLFormatWithOptions:options]; 
     488        reasonHTML = [reasonHTML stringByStrippingIllegalXMLCharacters]; 
     489 
     490        NSArray *args = [NSArray arrayWithObjects:member, room, ( reasonHTML ? (id)reasonHTML : (id)[NSNull null] ), nil]; 
    482491        [self callScriptFunctionNamed:@"memberParted" withArguments:args forSelector:_cmd]; 
    483492} 
    484493 
    485494- (void) memberKicked:(JVChatRoomMember *) member fromRoom:(JVChatRoomPanel *) room by:(JVChatRoomMember *) by forReason:(NSAttributedString *) reason { 
    486         NSArray *args = [NSArray arrayWithObjects:member, room, ( by ? (id)by : (id)[NSNull null] ), ( reason ? (id)[reason string] : (id)[NSNull null] ), nil]; 
     495        NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"IgnoreFonts", [NSNumber numberWithBool:YES], @"IgnoreFontSizes", nil]; 
     496        NSString *reasonHTML = [reason HTMLFormatWithOptions:options]; 
     497        reasonHTML = [reasonHTML stringByStrippingIllegalXMLCharacters]; 
     498 
     499        NSArray *args = [NSArray arrayWithObjects:member, room, ( by ? (id)by : (id)[NSNull null] ), ( reasonHTML ? (id)reasonHTML : (id)[NSNull null] ), nil]; 
    487500        [self callScriptFunctionNamed:@"memberKicked" withArguments:args forSelector:_cmd]; 
    488501} 
     
    499512 
    500513- (void) kickedFromRoom:(JVChatRoomPanel *) room by:(JVChatRoomMember *) by forReason:(NSAttributedString *) reason { 
    501         NSArray *args = [NSArray arrayWithObjects:room, ( by ? (id)by : (id)[NSNull null] ), ( reason ? (id)[reason string] : (id)[NSNull null] ), nil]; 
     514        NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"IgnoreFonts", [NSNumber numberWithBool:YES], @"IgnoreFontSizes", nil]; 
     515        NSString *reasonHTML = [reason HTMLFormatWithOptions:options]; 
     516        reasonHTML = [reasonHTML stringByStrippingIllegalXMLCharacters]; 
     517 
     518        NSArray *args = [NSArray arrayWithObjects:room, ( by ? (id)by : (id)[NSNull null] ), ( reasonHTML ? (id)reasonHTML : (id)[NSNull null] ), nil]; 
    502519        [self callScriptFunctionNamed:@"kickedFromRoom" withArguments:args forSelector:_cmd]; 
    503520} 
    504521 
    505522- (void) topicChangedTo:(NSAttributedString *) topic inRoom:(JVChatRoomPanel *) room by:(JVChatRoomMember *) member { 
    506         NSArray *args = [NSArray arrayWithObjects:[topic string], room, ( member ? (id)member : (id)[NSNull null] ), nil]; 
     523        NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"IgnoreFonts", [NSNumber numberWithBool:YES], @"IgnoreFontSizes", nil]; 
     524        NSString *topicHTML = [topic HTMLFormatWithOptions:options]; 
     525        topicHTML = [topicHTML stringByStrippingIllegalXMLCharacters]; 
     526 
     527        NSArray *args = [NSArray arrayWithObjects:topicHTML, room, ( member ? (id)member : (id)[NSNull null] ), nil]; 
    507528        [self callScriptFunctionNamed:@"topicChanged" withArguments:args forSelector:_cmd]; 
    508529}