Display unhandled purple conversation writes in the next run loop. Fixes #13190.
authorZachary West <zacw@adium.im>
Sun Nov 01 14:04:11 2009 -0500 (2009-11-01)
changeset 2724165b2bbc8f20
parent 2723 6fa58273701e
child 2725 df393573b242
Display unhandled purple conversation writes in the next run loop. Fixes #13190.
Frameworks/AIUtilities Framework/Source/AIObjectAdditions.h
Frameworks/AIUtilities Framework/Source/AIObjectAdditions.m
Plugins/Purple Service/CBPurpleAccount.h
Plugins/Purple Service/CBPurpleAccount.m
Plugins/Purple Service/adiumPurpleConversation.m
     1.1 --- a/Frameworks/AIUtilities Framework/Source/AIObjectAdditions.h	Sun Nov 01 11:15:19 2009 -0500
     1.2 +++ b/Frameworks/AIUtilities Framework/Source/AIObjectAdditions.h	Sun Nov 01 14:04:11 2009 -0500
     1.3 @@ -29,10 +29,13 @@
     1.4  - (void)mainPerformSelector:(SEL)aSelector withObjects:(id)argument1, ... NS_REQUIRES_NIL_TERMINATION;
     1.5  
     1.6  - (void)mainPerformSelector:(SEL)aSelector withObject:(id)argument1 withObject:(id)argument2 withObject:(id)argument3 withObject:(id)argument4 waitUntilDone:(BOOL)flag;
     1.7 +
     1.8  - (void)performSelector:(SEL)aSelector withObject:(id)argument1 withObject:(id)argument2 afterDelay:(NSTimeInterval)delay;
     1.9  
    1.10  - (void)performSelector:(SEL)aSelector withObject:(id)argument1 withObject:(id)argument2 withObject:(id)argument3 afterDelay:(NSTimeInterval)delay;
    1.11  - (void)performSelector:(SEL)aSelector withObject:(id)argument1 withObject:(id)argument2 withObject:(id)argument3;
    1.12  
    1.13 +- (void)performSelector:(SEL)aSelector withObject:(id)argument1 withObject:(id)argument2 withObject:(id)argument3 withObject:(id)argument4 afterDelay:(NSTimeInterval)delay;
    1.14 +
    1.15  - (void)handleInvocation:(NSInvocation *)anInvocation;
    1.16  @end
     2.1 --- a/Frameworks/AIUtilities Framework/Source/AIObjectAdditions.m	Sun Nov 01 11:15:19 2009 -0500
     2.2 +++ b/Frameworks/AIUtilities Framework/Source/AIObjectAdditions.m	Sun Nov 01 14:04:11 2009 -0500
     2.3 @@ -261,6 +261,21 @@
     2.4  	[self performSelector:@selector(handleInvocation:) withObject:invocation];	
     2.5  }
     2.6  
     2.7 +- (void)performSelector:(SEL)aSelector withObject:(id)argument1 withObject:(id)argument2 withObject:(id)argument3 withObject:(id)argument4 afterDelay:(NSTimeInterval)delay
     2.8 +{
     2.9 +	NSInvocation *invocation;
    2.10 +	invocation = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:aSelector]];
    2.11 +	
    2.12 +	[invocation setSelector:aSelector];
    2.13 +	[invocation setArgument:&argument1 atIndex:2];
    2.14 +	[invocation setArgument:&argument2 atIndex:3];
    2.15 +	[invocation setArgument:&argument3 atIndex:4];
    2.16 +	[invocation setArgument:&argument4 atIndex:5];
    2.17 +	[invocation retainArguments];
    2.18 +	
    2.19 +	[self performSelector:@selector(handleInvocation:) withObject:invocation afterDelay:delay];	
    2.20 +}
    2.21 +
    2.22  - (void)handleInvocation:(NSInvocation *)anInvocation
    2.23  {
    2.24  	[anInvocation invokeWithTarget:self];
     3.1 --- a/Plugins/Purple Service/CBPurpleAccount.h	Sun Nov 01 11:15:19 2009 -0500
     3.2 +++ b/Plugins/Purple Service/CBPurpleAccount.h	Sun Nov 01 14:04:11 2009 -0500
     3.3 @@ -146,7 +146,7 @@
     3.4  - (void)receivedEventForChat:(AIChat *)chat
     3.5  					 message:(NSString *)message
     3.6  						date:(NSDate *)date
     3.7 -					   flags:(PurpleMessageFlags)flags;
     3.8 +					   flags:(NSNumber *)flagsNumber;
     3.9  - (void)receivedIMChatMessage:(NSDictionary *)messageDict inChat:(AIChat *)chat;
    3.10  - (void)receivedMultiChatMessage:(NSDictionary *)messageDict inChat:(AIChat *)chat;
    3.11  - (void)leftChat:(AIChat *)chat;
     4.1 --- a/Plugins/Purple Service/CBPurpleAccount.m	Sun Nov 01 11:15:19 2009 -0500
     4.2 +++ b/Plugins/Purple Service/CBPurpleAccount.m	Sun Nov 01 14:04:11 2009 -0500
     4.3 @@ -1175,8 +1175,10 @@
     4.4  - (void)receivedEventForChat:(AIChat *)chat
     4.5  					 message:(NSString *)message
     4.6  						date:(NSDate *)date
     4.7 -					   flags:(PurpleMessageFlags)flags
     4.8 +					   flags:(NSNumber *)flagsNumber
     4.9  {
    4.10 +	PurpleMessageFlags flags = [flagsNumber integerValue];
    4.11 +	
    4.12  	AIContentEvent *event = [AIContentEvent eventInChat:chat
    4.13  											 withSource:nil
    4.14  											destination:self
     5.1 --- a/Plugins/Purple Service/adiumPurpleConversation.m	Sun Nov 01 11:15:19 2009 -0500
     5.2 +++ b/Plugins/Purple Service/adiumPurpleConversation.m	Sun Nov 01 14:04:11 2009 -0500
     5.3 @@ -85,7 +85,7 @@
     5.4  			[account receivedEventForChat:groupChatLookupFromConv(conv)
     5.5  								  message:messageString
     5.6  									 date:date
     5.7 -									flags:flags];
     5.8 +									flags:[NSNumber numberWithInteger:flags]];
     5.9  		} else {
    5.10  			NSAttributedString	*attributedMessage = [AIHTMLDecoder decodeHTML:messageString];
    5.11  			NSNumber			*purpleMessageFlags = [NSNumber numberWithInt:flags];
    5.12 @@ -213,15 +213,15 @@
    5.13  		 */
    5.14  		if (errorType != AIChatUnknownError) {
    5.15  			[accountLookup(purple_conversation_get_account(conv)) performSelector:@selector(errorForChat:type:)
    5.16 -			 withObject:chat
    5.17 -			 withObject:[NSNumber numberWithInt:errorType]
    5.18 -			 afterDelay:0];
    5.19 +																	   withObject:chat
    5.20 +																	   withObject:[NSNumber numberWithInt:errorType]
    5.21 +																	   afterDelay:0];
    5.22  		} else {
    5.23  			[adium.contentController performSelector:@selector(displayEvent:ofType:inChat:)
    5.24 -			 withObject:messageString
    5.25 -			 withObject:@"libpurpleMessage"
    5.26 -			 withObject:chat
    5.27 -			 afterDelay:0];
    5.28 +										  withObject:messageString
    5.29 +										  withObject:@"libpurpleMessage"
    5.30 +										  withObject:chat
    5.31 +										  afterDelay:0];
    5.32  		}
    5.33  		
    5.34  		AILog(@"*** Conversation error %@: %@", chat, messageString);
    5.35 @@ -264,10 +264,12 @@
    5.36  		if (shouldDisplayMessage) {
    5.37  			CBPurpleAccount *account = accountLookup(purple_conversation_get_account(conv));
    5.38  			
    5.39 -			[account receivedEventForChat:chat
    5.40 -								  message:messageString
    5.41 -									 date:[NSDate dateWithTimeIntervalSince1970:mtime]
    5.42 -									flags:flags];
    5.43 +			[account performSelector:@selector(receivedEventForChat:message:date:flags:)
    5.44 +						  withObject:chat
    5.45 +						  withObject:messageString
    5.46 +						  withObject:[NSDate dateWithTimeIntervalSince1970:mtime]
    5.47 +						  withObject:[NSNumber numberWithInteger:flags]
    5.48 +						  afterDelay:0];
    5.49  		}
    5.50  	}
    5.51  }