adium 3556:ee701d0f4a2b: For multi-user chats: Allow account typ...

commits at adium.im commits at adium.im
Sat Nov 20 05:44:39 UTC 2010


details:	http://hg.adium.im/adium/rev/ee701d0f4a2b
revision:	3556:ee701d0f4a2b
author:		Stephen Holt <sholt at adium.im>
date:		Fri Nov 19 21:44:32 2010 -0800

For multi-user chats: Allow account type to hide displaying of a message until we receive it from the server.  Fixes #12088. Fixes #8852.

By default messages are displayed on output, but for IRC and XMPP MUCs, we wait for a response from the server to display messages.  This allows utilities like IRC bouncers/proxies to work as expected.

diffs (120 lines):

diff -r 53bf60073071 -r ee701d0f4a2b Frameworks/Adium Framework/Source/AIAccount.h
--- a/Frameworks/Adium Framework/Source/AIAccount.h	Thu Nov 18 23:44:18 2010 -0800
+++ b/Frameworks/Adium Framework/Source/AIAccount.h	Fri Nov 19 21:44:32 2010 -0800
@@ -311,6 +311,7 @@
 - (BOOL)rejoinChat:(AIChat*)chat;
 - (BOOL)groupChatsSupportTopic;
 - (void)setTopic:(NSString *)topic forChat:(AIChat *)chat;
+- (BOOL)shouldDisplayOutgoingMUCMessages;
 /*!
  * @brief Should an autoreply be sent to this message?
  *
diff -r 53bf60073071 -r ee701d0f4a2b Frameworks/Adium Framework/Source/AIAccount.m
--- a/Frameworks/Adium Framework/Source/AIAccount.m	Thu Nov 18 23:44:18 2010 -0800
+++ b/Frameworks/Adium Framework/Source/AIAccount.m	Fri Nov 19 21:44:32 2010 -0800
@@ -713,6 +713,14 @@
 	return YES;
 }
 
+/*!
+ * @brief Hide outgoing messages (ex: because the server will echo them back to us)
+ */
+- (BOOL)shouldDisplayOutgoingMUCMessages
+{
+	return YES;
+}
+
 //Presence Tracking ----------------------------------------------------------------------------------------------------
 #pragma mark Presence Tracking
 /*!
diff -r 53bf60073071 -r ee701d0f4a2b Plugins/Purple Service/CBPurpleAccount.m
--- a/Plugins/Purple Service/CBPurpleAccount.m	Thu Nov 18 23:44:18 2010 -0800
+++ b/Plugins/Purple Service/CBPurpleAccount.m	Fri Nov 19 21:44:32 2010 -0800
@@ -1199,8 +1199,12 @@
 }
 
 - (void)receivedMultiChatMessage:(NSDictionary *)messageDict inChat:(AIChat *)chat
-{	
-	PurpleMessageFlags	flags = [(NSNumber*)[messageDict objectForKey:@"PurpleMessageFlags"] intValue];
+{
+  PurpleMessageFlags	flags = [(NSNumber*)[messageDict objectForKey:@"PurpleMessageFlags"] intValue];
+  
+  if ((![self shouldDisplayOutgoingMUCMessages] && ((flags & PURPLE_MESSAGE_SEND) || (flags & PURPLE_MESSAGE_DELAYED))) ||
+	  (!(flags & PURPLE_MESSAGE_SEND) || (flags & PURPLE_MESSAGE_DELAYED))) {
+	
 	NSAttributedString	*attributedMessage = [messageDict objectForKey:@"AttributedMessage"];;
 	NSString			*source = [messageDict objectForKey:@"Source"];
 	
@@ -1209,6 +1213,7 @@
 		   fromListContact:[self contactWithUID:source]
 					 flags:flags
 					  date:[messageDict objectForKey:@"Date"]];
+  }
 }
 
 - (void)_receivedMessage:(NSAttributedString *)attributedMessage inChat:(AIChat *)chat fromListContact:(AIListContact *)sourceContact flags:(PurpleMessageFlags)flags date:(NSDate *)date
@@ -1261,6 +1266,10 @@
 	if ([inContentMessage isAutoreply]) {
 		flags |= PURPLE_MESSAGE_AUTO_RESP;
 	}
+  
+	if (![self shouldDisplayOutgoingMUCMessages]) {
+		inContentMessage.displayContent = NO;
+	}
 
 	[purpleAdapter sendEncodedMessage:[inContentMessage encodedMessage]
 						 fromAccount:self
diff -r 53bf60073071 -r ee701d0f4a2b Plugins/Purple Service/ESIRCAccount.m
--- a/Plugins/Purple Service/ESIRCAccount.m	Thu Nov 18 23:44:18 2010 -0800
+++ b/Plugins/Purple Service/ESIRCAccount.m	Fri Nov 19 21:44:32 2010 -0800
@@ -78,6 +78,11 @@
 	return [super openChat:chat];
 }
 
+- (BOOL)shouldDisplayOutgoingMUCMessages
+{
+  return NO;
+}
+
 /*!
  * @brief Open the info inspector when getting info
  *
diff -r 53bf60073071 -r ee701d0f4a2b Plugins/Purple Service/ESPurpleJabberAccount.m
--- a/Plugins/Purple Service/ESPurpleJabberAccount.m	Thu Nov 18 23:44:18 2010 -0800
+++ b/Plugins/Purple Service/ESPurpleJabberAccount.m	Fri Nov 19 21:44:32 2010 -0800
@@ -621,6 +621,11 @@
 	}
 }
 
+- (BOOL)shouldDisplayOutgoingMUCMessages
+{
+  return NO;
+}
+
 #pragma mark Status
 /*!
  * @brief Return the purple status type to be used for a status
diff -r 53bf60073071 -r ee701d0f4a2b Plugins/Purple Service/adiumPurpleConversation.m
--- a/Plugins/Purple Service/adiumPurpleConversation.m	Thu Nov 18 23:44:18 2010 -0800
+++ b/Plugins/Purple Service/adiumPurpleConversation.m	Fri Nov 19 21:44:32 2010 -0800
@@ -61,11 +61,7 @@
 								   const char *message, PurpleMessageFlags flags,
 								   time_t mtime)
 {
-	/* We only care about this if:
-	 *	1) It does not have the PURPLE_MESSAGE_SEND flag, which is set if Purple is sending a sent message back to us -or-
-	 *  2) It is a delayed (history) message from a chat
-	 */
-	if (!(flags & PURPLE_MESSAGE_SEND) || (flags & PURPLE_MESSAGE_DELAYED)) {
+
 		NSDictionary	*messageDict;
 		NSString		*messageString;
 
@@ -105,7 +101,6 @@
 
 			[accountLookup(purple_conversation_get_account(conv)) receivedMultiChatMessage:messageDict inChat:groupChatLookupFromConv(conv)];
 		}
-	}
 }
 
 static void adiumPurpleConvWriteIm(PurpleConversation *conv, const char *who,




More information about the commits mailing list