adium 3728:8285f249de36: XMPP-MUC: Request only historic message...

commits at adium.im commits at adium.im
Fri Mar 11 11:46:40 UTC 2011


details:	http://hg.adium.im/adium/rev/8285f249de36
revision:	3728:8285f249de36
branch:		HistoricMUCMessages
author:		Thijs Alkemade <thijsalkemade at gmail.com>
date:		Fri Mar 11 12:41:22 2011 +0100

XMPP-MUC: Request only historic messages from since the last message we've received.

For now, only works when rejoining in the same session. It doesn't check the transcripts for the last message there.

(Will not actually work until libpurple is updated to 2.7.11, so creating a branch).

Refs #14219

diffs (87 lines):

diff -r 5b472d1e4bc4 -r 8285f249de36 Frameworks/Adium Framework/Source/AIChat.h
--- a/Frameworks/Adium Framework/Source/AIChat.h	Fri Mar 11 03:08:44 2011 +0100
+++ b/Frameworks/Adium Framework/Source/AIChat.h	Fri Mar 11 12:41:22 2011 +0100
@@ -126,6 +126,8 @@
 	
 	NSMutableSet		*customEmoticons;
 	
+	NSDate				*lastMessageDate;
+	
 	// Former properties
 	NSImage				*tabStateIcon;
 	
@@ -226,4 +228,6 @@
 
 @property (readonly, nonatomic) BOOL shouldLog;
 
+ at property (readwrite, copy, nonatomic) NSDate *lastMessageDate;
+
 @end
diff -r 5b472d1e4bc4 -r 8285f249de36 Frameworks/Adium Framework/Source/AIChat.m
--- a/Frameworks/Adium Framework/Source/AIChat.m	Fri Mar 11 03:08:44 2011 +0100
+++ b/Frameworks/Adium Framework/Source/AIChat.m	Fri Mar 11 12:41:22 2011 +0100
@@ -43,6 +43,8 @@
 
 @interface AIChat ()
 - (id)initForAccount:(AIAccount *)inAccount;
+- (void)contentObjectAdded:(NSNotification *)notification;
+
 - (void)clearUniqueChatID;
 - (void)clearListObjectStatuses;
 
@@ -78,11 +80,23 @@
 		pendingOutgoingContentObjects = [[NSMutableArray alloc] init];
 
 		AILog(@"[AIChat: %x initForAccount]",self);
+		
+		[[NSNotificationCenter defaultCenter] addObserver:self 
+												 selector:@selector(contentObjectAdded:) 
+													 name:Content_ContentObjectAdded 
+												   object:self];
 	}
 
     return self;
 }
 
+- (void)contentObjectAdded:(NSNotification *)notification
+{
+	AIContentMessage *content = [[notification userInfo] objectForKey:@"AIContentObject"];
+	
+	self.lastMessageDate = [content date];
+}
+
 /*!
  * @brief Deallocate
  */
@@ -501,6 +515,8 @@
 //Content --------------------------------------------------------------------------------------------------------------
 #pragma mark Content
 
+ at synthesize lastMessageDate;
+
 /*!
  * @brief Informs the chat that the core and the account are ready to begin filtering and sending a content object
  *
diff -r 5b472d1e4bc4 -r 8285f249de36 Plugins/Purple Service/SLPurpleCocoaAdapter.m
--- a/Plugins/Purple Service/SLPurpleCocoaAdapter.m	Fri Mar 11 03:08:44 2011 +0100
+++ b/Plugins/Purple Service/SLPurpleCocoaAdapter.m	Fri Mar 11 12:41:22 2011 +0100
@@ -589,6 +589,19 @@
 												 valueUTF8String);
 						}
 					}
+					
+					if (chat.lastMessageDate) {
+						
+						NSTimeInterval sinceLastMessage = [chat.lastMessageDate timeIntervalSince1970];
+						
+						NSString *historySince = [[NSDate dateWithTimeIntervalSince1970:sinceLastMessage + 1.0f] descriptionWithCalendarFormat:@"%Y-%m-%dT%H:%M:%SZ"
+																																	  timeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]
+																																		locale:nil];
+						g_hash_table_replace(components, g_strdup("history_since"), g_strdup([historySince UTF8String]));
+					} else {
+						AILogWithSignature(@"No last message found for history on %@", chat);
+					}
+
 
 					//In debug mode, verify we didn't miss any required values
 					if (AIDebugLoggingIsEnabled()) {




More information about the commits mailing list