/pidgin/main: b40615082e93: Complete support for receiving a lim...

Tomasz Wasilczyk tomkiewicz at cpw.pidgin.im
Sat Feb 2 15:14:19 EST 2013


Changeset: b40615082e93123ebae34de0fa5c7f36acabe154
Author:	 Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date:	 2013-02-02 21:13 +0100
Branch:	 default
URL: http://hg.pidgin.im/pidgin/main/rev/b40615082e93

Description:

Complete support for receiving a limited amount of history when joining a room. Fixes #15458

diffstat:

 ChangeLog        |   2 ++
 pidgin/gtkconv.c |  41 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 0 deletions(-)

diffs (63 lines):

diff --git a/ChangeLog b/ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,8 @@ version 3.0.0 (??/??/????):
 	* Add email notification in the docklet area. (Alexei) (#3571)
 	* Add a pref to select the type messages in conversation that triggers 
 	  the docklet notification. (Momchil) (#12598)
+	* Complete support for receiving a limited amount of history when
+	  joining a room. (Kha) (#15458)
 
 	Finch:
 	* Support the conversation-extended signal for extending the
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -6714,6 +6714,47 @@ pidgin_conv_write_conv(PurpleConversatio
 	}
 #endif
 
+
+	/* on rejoin only request message history from after this message */
+	if (flags & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV) &&
+		purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) {
+		PurpleChat *chat = purple_blist_find_chat(
+			purple_conversation_get_account(conv),
+			purple_conversation_get_name(conv));
+		if (chat) {
+			GHashTable *comps = purple_chat_get_components(chat);
+			time_t now, history_since, prev_history_since = 0;
+			struct tm *history_since_tm;
+			const char *history_since_s, *prev_history_since_s;
+
+			history_since = mtime + 1;
+
+			prev_history_since_s = g_hash_table_lookup(comps,
+				"history_since");
+			if (prev_history_since_s != NULL)
+				prev_history_since = purple_str_to_time(
+					prev_history_since_s, TRUE, NULL, NULL,
+					NULL);
+
+			now = time(NULL);
+			/* in case of incorrectly stored timestamps */
+			if (prev_history_since > now)
+				prev_history_since = now;
+			/* in case of delayed messages */
+			if (history_since < prev_history_since)
+				history_since = prev_history_since;
+
+			history_since_tm = gmtime(&history_since);
+			history_since_s = purple_utf8_strftime(
+				"%Y-%m-%dT%H:%M:%SZ", history_since_tm);
+			if (g_strcmp0(prev_history_since_s,
+				history_since_s) != 0)
+				g_hash_table_replace(comps,
+					g_strdup("history_since"),
+					g_strdup(history_since_s));
+		}
+	}
+
 	purple_signal_emit(pidgin_conversations_get_handle(),
 		(type == PURPLE_CONV_TYPE_IM ? "displayed-im-msg" : "displayed-chat-msg"),
 		account, name, displaying, conv, flags);



More information about the Commits mailing list