Remove a purple_str_to_time call that will eventually be replaced by the history api.

Sat, 08 Jan 2022 20:52:48 -0600

author
Gary Kramlich <grim@reaperworld.com>
date
Sat, 08 Jan 2022 20:52:48 -0600
changeset 41238
f32016157ca8
parent 41237
5098e0dd3a09
child 41239
735f7114318d

Remove a purple_str_to_time call that will eventually be replaced by the history api.

Remove some purple_str_to_time calls that will eventually be replaced by the history api.

Testing Done:
Joined an XMPP muc and verified that history was still added.

Reviewed at https://reviews.imfreedom.org/r/1212/

libpurple/protocols/jabber/chat.c file | annotate | diff | comparison | revisions
pidgin/gtkconv.c file | annotate | diff | comparison | revisions
--- a/libpurple/protocols/jabber/chat.c	Sat Jan 08 15:35:51 2022 -0600
+++ b/libpurple/protocols/jabber/chat.c	Sat Jan 08 20:52:48 2022 -0600
@@ -268,14 +268,6 @@
 
 	char *jid;
 
-	char *history_maxchars;
-	char *history_maxstanzas;
-	char *history_seconds;
-	char *history_since;
-
-	struct tm history_since_datetime;
-	const char *history_since_string = NULL;
-
 	chat = jabber_chat_new(js, room, server, handle, password, data);
 	if (chat == NULL)
 		return NULL;
@@ -292,22 +284,6 @@
 	purple_xmlnode_set_attrib(presence, "to", jid);
 	g_free(jid);
 
-	history_maxchars   = g_hash_table_lookup(data, "history_maxchars");
-	history_maxstanzas = g_hash_table_lookup(data, "history_maxstanzas");
-	history_seconds    = g_hash_table_lookup(data, "history_seconds");
-	history_since      = g_hash_table_lookup(data, "history_since");
-
-	if (history_since) {
-		if (purple_str_to_time(history_since, TRUE, &history_since_datetime, NULL, NULL) != 0) {
-			history_since_string = purple_utf8_strftime("%Y-%m-%dT%H:%M:%SZ", &history_since_datetime);
-		} else {
-			history_since_string = NULL;
-
-			purple_debug_error("jabber", "Invalid date format for history_since"
-			                             " while requesting history: %s", history_since);
-		}
-	}
-
 	x = purple_xmlnode_new_child(presence, "x");
 	purple_xmlnode_set_namespace(x, "http://jabber.org/protocol/muc");
 
@@ -316,27 +292,6 @@
 		purple_xmlnode_insert_data(p, password, -1);
 	}
 
-	if ((history_maxchars && *history_maxchars)
-	    || (history_maxstanzas && *history_maxstanzas)
-	    || (history_seconds && *history_seconds)
-	    || (history_since_string && *history_since_string)) {
-
-		PurpleXmlNode *history = purple_xmlnode_new_child(x, "history");
-
-		if (history_maxchars && *history_maxchars) {
-			purple_xmlnode_set_attrib(history, "maxchars", history_maxchars);
-		}
-		if (history_maxstanzas && *history_maxstanzas) {
-			purple_xmlnode_set_attrib(history, "maxstanzas", history_maxstanzas);
-		}
-		if (history_seconds && *history_seconds) {
-			purple_xmlnode_set_attrib(history, "seconds", history_seconds);
-		}
-		if (history_since_string && *history_since_string) {
-			purple_xmlnode_set_attrib(history, "since", history_since_string);
-		}
-	}
-
 	jabber_send(js, presence);
 	purple_xmlnode_free(presence);
 
--- a/pidgin/gtkconv.c	Sat Jan 08 15:35:51 2022 -0600
+++ b/pidgin/gtkconv.c	Sat Jan 08 20:52:48 2022 -0600
@@ -2240,48 +2240,6 @@
 		gtkconv_set_unseen(gtkconv, unseen);
 	}
 
-	/* on rejoin only request message history from after this message */
-	if (flags & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV) &&
-		PURPLE_IS_CHAT_CONVERSATION(conv)) {
-		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);
-			GDateTime *dt = NULL;
-			time_t now, history_since, prev_history_since = 0;
-			struct tm *history_since_tm;
-			const char *history_since_s, *prev_history_since_s;
-
-			dt = purple_message_get_timestamp(pmsg);
-			history_since = g_date_time_to_unix(dt) + 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 (!purple_strequal(prev_history_since_s,
-				history_since_s))
-				g_hash_table_replace(comps,
-					g_strdup("history_since"),
-					g_strdup(history_since_s));
-		}
-	}
-
 	purple_signal_emit(pidgin_conversations_get_handle(),
 		(PURPLE_IS_IM_CONVERSATION(conv) ? "displayed-im-msg" : "displayed-chat-msg"),
 		conv, pmsg);

mercurial