# HG changeset patch
# Node ID 62c97b47ded6
# Parent  a3d036e859b1
diff --git a/ChangeLog.API b/ChangeLog.API
--- a/ChangeLog.API
+++ b/ChangeLog.API
@@ -393,11 +393,13 @@
 		* PURPLE_CMD_FUNC
 		* purple_connection_error_reason
 		* PURPLE_CONNECTION_FLAG_ALLOW_CUSTOM_SMILEY
+		* purple_connection_get_protocol_data
 		* purple_connection_new
 		* purple_connection_new_unregister
 		* purple_connection_notice
 		* purple_connection_destroy
 		* purple_connection_set_account
+		* purple_connection_set_protocol_data
 		* purple_connection_ssl_error
 		* PurpleConnectionUiOps->connect_progress
 		* PurpleConnectionUiOps->notice
diff --git a/libpurple/connection.h b/libpurple/connection.h
--- a/libpurple/connection.h
+++ b/libpurple/connection.h
@@ -176,12 +176,6 @@
 	void (*_purple_reserved4)(void);
 };
 
-/******************************************************************************
- * To be deleted in the future
- *****************************************************************************/
-PURPLE_AVAILABLE_IN_3_0
-void _purple_assert_connection_is_valid(PurpleConnection *gc, const gchar *file, int line);
-
 /**************************************************************************/
 /* Connection API                                                         */
 /**************************************************************************/
@@ -265,18 +259,6 @@
 void purple_connection_set_display_name(PurpleConnection *gc, const char *name);
 
 /**
- * purple_connection_set_protocol_data:
- * @connection: The PurpleConnection.
- * @proto_data: The protocol data to set for the connection.
- *
- * Sets the protocol data for a connection.
- *
- * Since: 2.6
- */
-PURPLE_AVAILABLE_IN_2_6
-void purple_connection_set_protocol_data(PurpleConnection *connection, void *proto_data);
-
-/**
  * purple_connection_get_state:
  * @gc: The connection.
  *
@@ -425,19 +407,6 @@
 const char *purple_connection_get_display_name(PurpleConnection *gc);
 
 /**
- * purple_connection_get_protocol_data:
- * @gc: The PurpleConnection.
- *
- * Gets the protocol data from a connection.
- *
- * Returns: The protocol data for the connection.
- *
- * Since: 2.6
- */
-PURPLE_AVAILABLE_IN_2_6
-void *purple_connection_get_protocol_data(PurpleConnection *gc);
-
-/**
  * purple_connection_error:
  * @gc:          the connection which is closing.
  * @reason:      why the connection is closing.
@@ -528,18 +497,6 @@
 PURPLE_AVAILABLE_IN_ALL
 gboolean purple_connection_error_is_fatal(PurpleConnectionError reason);
 
-/**
- * purple_connection_update_last_received:
- * @gc:   The connection.
- *
- * Indicate that a packet was received on the connection.
- * Set by the protocol to avoid sending unneeded keepalives.
- *
- * Since: 3.0
- */
-PURPLE_AVAILABLE_IN_3_0
-void purple_connection_update_last_received(PurpleConnection *gc);
-
 /**************************************************************************/
 /* Connections API                                                        */
 /**************************************************************************/
diff --git a/libpurple/connection.c b/libpurple/connection.c
--- a/libpurple/connection.c
+++ b/libpurple/connection.c
@@ -60,11 +60,7 @@
 	GSList *active_chats;         /* A list of active chats
 	                                  (#PurpleChatConversation structs). */
 
-	/* TODO Remove this and use protocol-specific subclasses. */
-	void *proto_data;             /* Protocol-specific data.           */
-
 	char *display_name;           /* How you appear to other people.   */
-	GSource *keepalive;           /* Keep-alive.                       */
 
 	/* Wants to Die state.  This is set when the user chooses to log out, or
 	 * when the protocol is disconnected and should not be automatically
@@ -107,49 +103,6 @@
 /**************************************************************************
  * Connection API
  **************************************************************************/
-static gboolean
-send_keepalive(gpointer data) {
-	PurpleConnection *connection = data;
-	PurpleConnectionPrivate *priv = NULL;
-
-	priv = purple_connection_get_instance_private(data);
-
-	purple_protocol_server_keepalive(PURPLE_PROTOCOL_SERVER(priv->protocol),
-	                                 connection);
-
-	return TRUE;
-}
-
-static void
-update_keepalive(PurpleConnection *connection, gboolean on) {
-	PurpleConnectionPrivate *priv = NULL;
-	PurpleProtocolServer *server = NULL;
-
-	priv = purple_connection_get_instance_private(connection);
-
-	if(!PURPLE_PROTOCOL_IMPLEMENTS(priv->protocol, SERVER, keepalive)) {
-		return;
-	}
-
-	server = PURPLE_PROTOCOL_SERVER(priv->protocol);
-
-	if(on && !priv->keepalive) {
-		int interval = purple_protocol_server_get_keepalive_interval(server);
-		int source = 0;
-
-		purple_debug_info("connection", "Activating keepalive to %d seconds.",
-		                  interval);
-
-		source = g_timeout_add_seconds(interval, send_keepalive, connection);
-		priv->keepalive = g_main_context_find_source_by_id(NULL, source);
-	} else if (!on && priv->keepalive) {
-		purple_debug_info("connection", "Deactivating keepalive.\n");
-
-		g_source_destroy(priv->keepalive);
-
-		priv->keepalive = NULL;
-	}
-}
 
 /*
  * d:)->-<
@@ -203,8 +156,6 @@
 		purple_signal_emit(handle, "signed-on", connection);
 		purple_signal_emit_return_1(handle, "autojoin", connection);
 
-		update_keepalive(connection, TRUE);
-
 		/* check if connections_connected is NULL, if so we need to emit the
 		 * online signal.
 		 */
@@ -259,19 +210,6 @@
 	                         properties[PROP_DISPLAY_NAME]);
 }
 
-void
-purple_connection_set_protocol_data(PurpleConnection *connection,
-                                    void *proto_data)
-{
-	PurpleConnectionPrivate *priv = NULL;
-
-	g_return_if_fail(PURPLE_IS_CONNECTION(connection));
-
-	priv = purple_connection_get_instance_private(connection);
-
-	priv->proto_data = proto_data;
-}
-
 PurpleConnectionState
 purple_connection_get_state(PurpleConnection *connection) {
 	PurpleConnectionPrivate *priv = NULL;
@@ -377,17 +315,6 @@
 	return priv->display_name;
 }
 
-void *
-purple_connection_get_protocol_data(PurpleConnection *connection) {
-	PurpleConnectionPrivate *priv = NULL;
-
-	g_return_val_if_fail(PURPLE_IS_CONNECTION(connection), NULL);
-
-	priv = purple_connection_get_instance_private(connection);
-
-	return priv->proto_data;
-}
-
 void
 _purple_connection_remove_active_chat(PurpleConnection *connection,
                                       PurpleChatConversation *chat)
@@ -596,34 +523,6 @@
 	}
 }
 
-void
-purple_connection_update_last_received(PurpleConnection *connection) {
-	PurpleConnectionPrivate *priv = NULL;
-
-	g_return_if_fail(PURPLE_IS_CONNECTION(connection));
-
-	priv = purple_connection_get_instance_private(connection);
-
-	/*
-	 * For safety, actually this function shouldn't be called when the
-	 * keepalive mechanism is inactive.
-	 */
-	if(priv->keepalive) {
-		/* The #GTimeoutSource API doesn't expose a function to reset when a
-		 * #GTimeoutSource will dispatch the next time, but because it works to
-		 * directly call g_source_set_ready_time() on a #GTimeoutSource, and since
-		 * it seems unlikely that the implementation will change, we just do that
-		 * for now as a workaround for this API shortcoming.
-		 */
-		gint64 seconds_from_now = purple_protocol_server_get_keepalive_interval(PURPLE_PROTOCOL_SERVER(priv->protocol));
-
-		g_source_set_ready_time(
-			priv->keepalive,
-			g_get_monotonic_time() + (seconds_from_now * G_USEC_PER_SEC)
-		);
-	}
-}
-
 /**************************************************************************
  * GBoxed code
  **************************************************************************/
@@ -1031,8 +930,6 @@
 	g_slist_free_full(priv->active_chats,
 	                  (GDestroyNotify)purple_chat_conversation_leave);
 
-	update_keepalive(connection, FALSE);
-
 	/* Dispatch to the connection's disconnect method. */
 	klass = PURPLE_CONNECTION_GET_CLASS(connection);
 	if(klass != NULL && klass->disconnect != NULL) {
@@ -1089,21 +986,6 @@
  **************************************************************************/
 
 void
-_purple_assert_connection_is_valid(PurpleConnection *gc, const gchar *file,
-                                   int line)
-{
-	if(gc && g_list_find(purple_connections_get_all(), gc)) {
-		return;
-	}
-
-	purple_debug_fatal("connection", "PURPLE_ASSERT_CONNECTION_IS_VALID(%p)"
-		" failed at %s:%d", gc, file, line);
-
-	/* ugh - gk 2021-10-28 */
-	exit(-1);
-}
-
-void
 purple_connections_disconnect_all(void) {
 	GList *l;
 
diff --git a/libpurple/purpleprotocolserver.h b/libpurple/purpleprotocolserver.h
--- a/libpurple/purpleprotocolserver.h
+++ b/libpurple/purpleprotocolserver.h
@@ -72,9 +72,6 @@
 	void (*remove_buddy)(PurpleProtocolServer *protocol_server, PurpleConnection *connection, PurpleBuddy *buddy, PurpleGroup *group);
 	void (*remove_buddies)(PurpleProtocolServer *protocol_server, PurpleConnection *connection, GList *buddies, GList *groups);
 
-	void (*keepalive)(PurpleProtocolServer *protocol_server, PurpleConnection *connection);
-	gint (*get_keepalive_interval)(PurpleProtocolServer *protocol_server);
-
 	void (*alias_buddy)(PurpleProtocolServer *protocol_server, PurpleConnection *connection, const gchar *who, const gchar *alias);
 
 	void (*group_buddy)(PurpleProtocolServer *protocol_server, PurpleConnection *connection, const gchar *who, const gchar *old_group, const gchar *new_group);
@@ -212,47 +209,6 @@
 void purple_protocol_server_remove_buddies(PurpleProtocolServer *protocol_server, PurpleConnection *connection, GList *buddies, GList *groups);
 
 /**
- * purple_protocol_server_keepalive:
- * @protocol_server: The #PurpleProtocolServer instance.
- * @connection: The #PurpleConnection instance.
- *
- * Tell @protocol_server to send its keep alive to the server.
- *
- * Since: 3.0
- */
-PURPLE_AVAILABLE_IN_3_0
-void purple_protocol_server_keepalive(PurpleProtocolServer *protocol_server, PurpleConnection *connection);
-
-/**
- * purple_protocol_server_get_keepalive_interval:
- * @protocol_server: The #PurpleProtocolServer instance.
- *
- * Returns a custom interval, in seconds, that libpurple should tell
- * @protocol_server to send its keepalive.
- *
- * Returns: The interval, in seconds, that the keep-alive function should be
- *          called.
- *
- * Since: 3.0
- */
-PURPLE_AVAILABLE_IN_3_0
-gint purple_protocol_server_get_keepalive_interval(PurpleProtocolServer *protocol_server);
-
-/**
- * purple_protocol_server_alias_buddy:
- * @protocol_server: The #PurpleProtocolServer instance.
- * @connection: The #PurpleConnection instance.
- * @who: The name of the user to alias.
- * @alias: The new alias for @who.
- *
- * Sets the server side alias for @who to @alias.
- *
- * Since: 3.0
- */
-PURPLE_AVAILABLE_IN_3_0
-void purple_protocol_server_alias_buddy(PurpleProtocolServer *protocol_server, PurpleConnection *connection, const gchar *who, const gchar *alias);
-
-/**
  * purple_protocol_server_group_buddy:
  * @protocol_server: The #PurpleProtocolServer instance.
  * @connection: The #PurpleConnection instance.
diff --git a/libpurple/purpleprotocolserver.c b/libpurple/purpleprotocolserver.c
--- a/libpurple/purpleprotocolserver.c
+++ b/libpurple/purpleprotocolserver.c
@@ -180,53 +180,6 @@
 }
 
 void
-purple_protocol_server_keepalive(PurpleProtocolServer *protocol_server,
-                                 PurpleConnection *connection)
-{
-	PurpleProtocolServerInterface *iface = NULL;
-
-	g_return_if_fail(PURPLE_IS_PROTOCOL_SERVER(protocol_server));
-	g_return_if_fail(PURPLE_IS_CONNECTION(connection));
-
-	iface = PURPLE_PROTOCOL_SERVER_GET_IFACE(protocol_server);
-	if(iface != NULL && iface->keepalive != NULL) {
-		iface->keepalive(protocol_server, connection);
-	}
-}
-
-gint
-purple_protocol_server_get_keepalive_interval(PurpleProtocolServer *protocol_server)
-{
-	PurpleProtocolServerInterface *iface = NULL;
-
-	g_return_val_if_fail(PURPLE_IS_PROTOCOL_SERVER(protocol_server), -1);
-
-	iface = PURPLE_PROTOCOL_SERVER_GET_IFACE(protocol_server);
-	if(iface != NULL && iface->get_keepalive_interval != NULL) {
-		return iface->get_keepalive_interval(protocol_server);
-	}
-
-	return -1;
-}
-
-void
-purple_protocol_server_alias_buddy(PurpleProtocolServer *protocol_server,
-                                   PurpleConnection *connection,
-                                   const gchar *who, const gchar *alias)
-{
-	PurpleProtocolServerInterface *iface = NULL;
-
-	g_return_if_fail(PURPLE_IS_PROTOCOL_SERVER(protocol_server));
-	g_return_if_fail(PURPLE_IS_CONNECTION(connection));
-	g_return_if_fail(who != NULL);
-
-	iface = PURPLE_PROTOCOL_SERVER_GET_IFACE(protocol_server);
-	if(iface != NULL && iface->alias_buddy != NULL) {
-		iface->alias_buddy(protocol_server, connection, who, alias);
-	}
-}
-
-void
 purple_protocol_server_group_buddy(PurpleProtocolServer *protocol_server,
                                    PurpleConnection *connection,
                                    const gchar *who, const gchar *old_group,
