# HG changeset patch
# Node ID 57f1099f3729
# Parent  9dc5d28fca99
diff --git a/ChangeLog.API b/ChangeLog.API
--- a/ChangeLog.API
+++ b/ChangeLog.API
@@ -641,6 +641,11 @@
 		* purple_roomlist_get_protocol_data
 		* purple_roomlist_set_protocol_data
 		* purple_running_osx
+		* purple_serv_add_deny
+		* purple_serv_add_permit
+		* purple_serv_remove_deny
+		* purple_serv_remove_permit
+		* purple_serv_set_permit_deny
 		* PurpleSetPublicAliasFailureCallback
 		* PurpleSetPublicAliasSuccessCallback
 		* purple_smiley_get_type
diff --git a/libpurple/account.c b/libpurple/account.c
--- a/libpurple/account.c
+++ b/libpurple/account.c
@@ -37,6 +37,7 @@
 #include "purpleprivate.h"
 #include "purpleprotocolclient.h"
 #include "purpleprotocolmanager.h"
+#include "purpleprotocolprivacy.h"
 #include "purpleprotocolserver.h"
 #include "request.h"
 #include "server.h"
@@ -1764,8 +1765,13 @@
 
 	account->permit = g_slist_append(account->permit, name);
 
-	if (!local_only && purple_account_is_connected(account))
-		purple_serv_add_permit(purple_account_get_connection(account), who);
+	if (!local_only && purple_account_is_connected(account)) {
+		PurpleConnection *connection = purple_account_get_connection(account);
+		PurpleProtocol *protocol = purple_connection_get_protocol(connection);
+		PurpleProtocolPrivacy *privacy = PURPLE_PROTOCOL_PRIVACY(protocol);
+
+		purple_protocol_privacy_add_permit(privacy, connection, who);
+	}
 
 	if (ui_ops != NULL && ui_ops->permit_added != NULL)
 		ui_ops->permit_added(account, who);
@@ -1809,7 +1815,11 @@
 	account->permit = g_slist_delete_link(account->permit, l);
 
 	if (!local_only && purple_account_is_connected(account)) {
-		purple_serv_remove_permit(purple_account_get_connection(account), who);
+		PurpleConnection *connection = purple_account_get_connection(account);
+		PurpleProtocol *protocol = purple_connection_get_protocol(connection);
+		PurpleProtocolPrivacy *privacy = PURPLE_PROTOCOL_PRIVACY(protocol);
+
+		purple_protocol_privacy_remove_permit(privacy, connection, who);
 	}
 
 	if (ui_ops != NULL && ui_ops->permit_removed != NULL) {
@@ -1850,8 +1860,13 @@
 
 	account->deny = g_slist_append(account->deny, name);
 
-	if (!local_only && purple_account_is_connected(account))
-		purple_serv_add_deny(purple_account_get_connection(account), who);
+	if (!local_only && purple_account_is_connected(account)) {
+		PurpleConnection *connection = purple_account_get_connection(account);
+		PurpleProtocol *protocol = purple_connection_get_protocol(connection);
+		PurpleProtocolPrivacy *privacy = PURPLE_PROTOCOL_PRIVACY(protocol);
+
+		purple_protocol_privacy_add_deny(privacy, connection, who);
+	}
 
 	if (ui_ops != NULL && ui_ops->deny_added != NULL)
 		ui_ops->deny_added(account, who);
@@ -1893,7 +1908,11 @@
 	account->deny = g_slist_delete_link(account->deny, l);
 
 	if (!local_only && purple_account_is_connected(account)) {
-		purple_serv_remove_deny(purple_account_get_connection(account), name);
+		PurpleConnection *connection = purple_account_get_connection(account);
+		PurpleProtocol *protocol = purple_connection_get_protocol(connection);
+		PurpleProtocolPrivacy *privacy = PURPLE_PROTOCOL_PRIVACY(protocol);
+
+		purple_protocol_privacy_remove_deny(privacy, connection, name);
 	}
 
 	if (ui_ops != NULL && ui_ops->deny_removed != NULL) {
@@ -1953,8 +1972,18 @@
 	}
 
 	/* Notify the server if the privacy setting was changed */
-	if (type != purple_account_get_privacy_type(account) && purple_account_is_connected(account))
-		purple_serv_set_permit_deny(purple_account_get_connection(account));
+	if(type != purple_account_get_privacy_type(account) &&
+	   purple_account_is_connected(account))
+	{
+		PurpleProtocol *protocol = purple_account_get_protocol(account);
+
+		if(PURPLE_IS_PROTOCOL_PRIVACY(protocol)) {
+			PurpleConnection *connection = purple_account_get_connection(account);
+
+			purple_protocol_privacy_set_permit_deny(PURPLE_PROTOCOL_PRIVACY(protocol),
+			                                        connection);
+		}
+	}
 }
 
 void
@@ -1998,8 +2027,18 @@
 	}
 
 	/* Notify the server if the privacy setting was changed */
-	if (type != purple_account_get_privacy_type(account) && purple_account_is_connected(account))
-		purple_serv_set_permit_deny(purple_account_get_connection(account));
+	if(type != purple_account_get_privacy_type(account) &&
+	   purple_account_is_connected(account))
+	{
+		PurpleProtocol *protocol = purple_account_get_protocol(account);
+
+		if(PURPLE_IS_PROTOCOL_PRIVACY(protocol)) {
+			PurpleConnection *connection = purple_account_get_connection(account);
+
+			purple_protocol_privacy_set_permit_deny(PURPLE_PROTOCOL_PRIVACY(protocol),
+			                                        connection);
+		}
+	}
 }
 
 GSList *
diff --git a/libpurple/connection.c b/libpurple/connection.c
--- a/libpurple/connection.c
+++ b/libpurple/connection.c
@@ -30,6 +30,7 @@
 #include "proxy.h"
 #include "purpleenums.h"
 #include "purpleprivate.h"
+#include "purpleprotocolprivacy.h"
 #include "purpleprotocolserver.h"
 #include "request.h"
 #include "server.h"
@@ -161,10 +162,12 @@
 	if(gc->state == PURPLE_CONNECTION_CONNECTED) {
 		PurpleAccount *account;
 		PurplePresence *presence;
+		PurpleProtocol *protocol;
 		gboolean emit_online = FALSE;
 		gpointer handle = NULL;
 
 		account = purple_connection_get_account(gc);
+		protocol = purple_connection_get_protocol(gc);
 		presence = purple_account_get_presence(account);
 		handle = purple_connections_get_handle();
 
@@ -180,7 +183,10 @@
 		purple_signal_emit(handle, "signed-on", gc);
 		purple_signal_emit_return_1(handle, "autojoin", gc);
 
-		purple_serv_set_permit_deny(gc);
+		if(PURPLE_IS_PROTOCOL_PRIVACY(protocol)) {
+			purple_protocol_privacy_set_permit_deny(PURPLE_PROTOCOL_PRIVACY(protocol),
+			                                        gc);
+		}
 
 		update_keepalive(gc, TRUE);
 
diff --git a/libpurple/server.h b/libpurple/server.h
--- a/libpurple/server.h
+++ b/libpurple/server.h
@@ -95,54 +95,6 @@
 void purple_serv_set_info(PurpleConnection *gc, const char *info);
 
 /******************************************************************************
- * Privacy interface
- *****************************************************************************/
-
-/**
- * purple_serv_add_permit:
- * @gc:     The connection over which to send the typing notification.
- * @name:   The name of the remote user.
- *
- * Add the buddy on the required authorized list.
- */
-void purple_serv_add_permit(PurpleConnection *gc, const char *name);
-
-/**
- * purple_serv_add_deny:
- * @gc:     The connection over which to send the typing notification.
- * @name:   The name of the remote user.
- *
- * Add the buddy on the required blocked list.
- */
-void purple_serv_add_deny(PurpleConnection *gc, const char *name);
-
-/**
- * purple_serv_remove_permit:
- * @gc:     The connection over which to send the typing notification.
- * @name:   The name of the remote user.
- *
- * Remove the buddy from the required authorized list.
- */
-void purple_serv_remove_permit(PurpleConnection *gc, const char *name);
-
-/**
- * purple_serv_remove_deny:
- * @gc:     The connection over which to send the typing notification.
- * @name:   The name of the remote user.
- *
- * Remove the buddy from the required blocked list.
- */
-void purple_serv_remove_deny(PurpleConnection *gc, const char *name);
-
-/**
- * purple_serv_set_permit_deny:
- * @gc:     The connection over which to send the typing notification.
- *
- * Update the server with the privacy information on the permit and deny lists.
- */
-void purple_serv_set_permit_deny(PurpleConnection *gc);
-
-/******************************************************************************
  * Chat Interface
  *****************************************************************************/
 
diff --git a/libpurple/server.c b/libpurple/server.c
--- a/libpurple/server.c
+++ b/libpurple/server.c
@@ -336,65 +336,6 @@
 	}
 }
 
-void purple_serv_add_permit(PurpleConnection *gc, const char *name)
-{
-	if (gc) {
-		PurpleProtocol *protocol = purple_connection_get_protocol(gc);
-		PurpleProtocolPrivacy *privacy = PURPLE_PROTOCOL_PRIVACY(protocol);
-
-		purple_protocol_privacy_add_permit(privacy, gc, name);
-	}
-}
-
-void purple_serv_add_deny(PurpleConnection *gc, const char *name)
-{
-	if (gc) {
-		PurpleProtocol *protocol = purple_connection_get_protocol(gc);
-		PurpleProtocolPrivacy *privacy = PURPLE_PROTOCOL_PRIVACY(protocol);
-
-		purple_protocol_privacy_add_deny(privacy, gc, name);
-	}
-}
-
-void purple_serv_remove_permit(PurpleConnection *gc, const char *name)
-{
-	if (gc) {
-		PurpleProtocol *protocol = purple_connection_get_protocol(gc);
-		PurpleProtocolPrivacy *privacy = PURPLE_PROTOCOL_PRIVACY(protocol);
-
-		purple_protocol_privacy_remove_permit(privacy, gc, name);
-	}
-}
-
-void purple_serv_remove_deny(PurpleConnection *gc, const char *name)
-{
-	if (gc) {
-		PurpleProtocol *protocol = purple_connection_get_protocol(gc);
-		PurpleProtocolPrivacy *privacy = PURPLE_PROTOCOL_PRIVACY(protocol);
-
-		purple_protocol_privacy_remove_deny(privacy, gc, name);
-	}
-}
-
-void
-purple_serv_set_permit_deny(PurpleConnection *gc) {
-	if(gc) {
-		PurpleProtocol *protocol = purple_connection_get_protocol(gc);
-
-		if(PURPLE_IS_PROTOCOL_PRIVACY(protocol)) {
-			PurpleProtocolPrivacy *privacy = PURPLE_PROTOCOL_PRIVACY(protocol);
-
-			/*
-			 * this is called when either you import a buddy list, and make lots
-			 * of changes that way, or when the user toggles the permit/deny mode
-			 * in the prefs. In either case you should probably be resetting and
-			 * resending the permit/deny info when you get this.
-			 */
-			purple_protocol_privacy_set_permit_deny(privacy, gc);
-		}
-	}
-}
-
 void purple_serv_join_chat(PurpleConnection *gc, GHashTable *data)
 {
 	PurpleProtocol *protocol;
diff --git a/pidgin/gtkprivacy.c b/pidgin/gtkprivacy.c
--- a/pidgin/gtkprivacy.c
+++ b/pidgin/gtkprivacy.c
@@ -162,10 +162,23 @@
 	PidginPrivacyDialog *dialog = data;
 	PurpleAccountPrivacyType new_type =
 		menu_entries[gtk_drop_down_get_selected(GTK_DROP_DOWN(obj))].type;
+	PurpleProtocol *protocol = NULL;
 	gboolean buttons_sensitive;
 
 	purple_account_set_privacy_type(dialog->account, new_type);
-	purple_serv_set_permit_deny(purple_account_get_connection(dialog->account));
+
+	protocol = purple_account_get_protocol(dialog->account);
+	if(PURPLE_IS_PROTOCOL_PRIVACY(protocol)) {
+		PurpleConnection *connection = NULL;
+
+		connection = purple_account_get_connection(dialog->account);
+		if(PURPLE_IS_CONNECTION(connection)) {
+			PurpleProtocolPrivacy *privacy = NULL;
+
+			privacy = PURPLE_PROTOCOL_PRIVACY(protocol);
+			purple_protocol_privacy_set_permit_deny(privacy, connection);
+		}
+	}
 
 	gtk_widget_hide(dialog->allow_widget);
 	gtk_widget_hide(dialog->block_widget);
