pidgin: 8c680753: Remove deprecated purple_network_listen_...

andrew.victor at mxit.com andrew.victor at mxit.com
Sat Sep 24 17:20:57 EDT 2011


----------------------------------------------------------------------
Revision: 8c6807531aee7d0e0d3c6357048d1a4914d03d93
Parent:   faf284dcf09c007e89366920d31394d6e087d796
Author:   andrew.victor at mxit.com
Date:     09/24/11 17:10:41
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/8c6807531aee7d0e0d3c6357048d1a4914d03d93

Changelog: 

Remove deprecated purple_network_listen_map_external().
Update purple_network_listen() and purple_network_listen_range() to have a boolean
 parameter that indicates if the port should be mapped externally.


Changes against parent faf284dcf09c007e89366920d31394d6e087d796

  patched  ChangeLog.API
  patched  libpurple/network.c
  patched  libpurple/network.h
  patched  libpurple/plugins/perl/common/Network.xs
  patched  libpurple/protocols/bonjour/bonjour_ft.c
  patched  libpurple/protocols/bonjour/jabber.c
  patched  libpurple/protocols/irc/dcc_send.c
  patched  libpurple/protocols/jabber/si.c
  patched  libpurple/protocols/msn/slpcall.c
  patched  libpurple/protocols/oscar/peer.c
  patched  libpurple/protocols/simple/simple.c
  patched  libpurple/protocols/yahoo/libymsg.c
  patched  libpurple/protocols/yahoo/yahoo_filexfer.c
  patched  libpurple/stun.c

-------------- next part --------------
============================================================
--- libpurple/protocols/yahoo/libymsg.c	05520ec5e9c9f80894f9aacbc4492861d0956a1b
+++ libpurple/protocols/yahoo/libymsg.c	dc1fad091353067e1fc0384795508a374a37b606
@@ -2770,7 +2770,7 @@ void yahoo_send_p2p_pkt(PurpleConnection
 	if (yd->listen_data)
 		purple_debug_warning("yahoo","p2p: Failed to create p2p server - server already exists\n");
 	else {
-		yd->listen_data = purple_network_listen(YAHOO_PAGER_PORT_P2P, AF_UNSPEC, SOCK_STREAM, yahoo_p2p_server_listen_cb, p2p_data);
+		yd->listen_data = purple_network_listen(YAHOO_PAGER_PORT_P2P, AF_UNSPEC, SOCK_STREAM, TRUE, yahoo_p2p_server_listen_cb, p2p_data);
 		if (yd->listen_data == NULL)
 			purple_debug_warning("yahoo","p2p: Failed to created p2p server\n");
 	}
============================================================
--- libpurple/protocols/jabber/si.c	757f5493d4e34009b2a32e6959641f565e547d13
+++ libpurple/protocols/jabber/si.c	634915774a1c9629da2a9b376d4de15668d2e02a
@@ -959,7 +959,7 @@ jabber_si_xfer_bytestreams_send_init(Pur
 		purple_debug_info("jabber", "Skipping attempting local streamhost.\n");
 		jsx->listen_data = NULL;
 	} else
-		jsx->listen_data = purple_network_listen_range(0, 0, AF_UNSPEC, SOCK_STREAM,
+		jsx->listen_data = purple_network_listen_range(0, 0, AF_UNSPEC, SOCK_STREAM, TRUE,
 				jabber_si_xfer_bytestreams_listen_cb, xfer);
 
 	if (jsx->listen_data == NULL) {
============================================================
--- libpurple/protocols/yahoo/yahoo_filexfer.c	9771c56d431e7a0ec5a8b78b7a3e16bdb3b68374
+++ libpurple/protocols/yahoo/yahoo_filexfer.c	f9716c31a9e9903dc19c6727d1a03a374667a7f4
@@ -1216,7 +1216,7 @@ static void yahoo_xfer_send_cb_15(gpoint
 		close(source);
 		xfer->fd = -1;
 		/* start local server, listen for connections */
-		purple_network_listen(xd->yahoo_local_p2p_ft_server_port, AF_UNSPEC, SOCK_STREAM, yahoo_p2p_ft_server_listen_cb, xfer);
+		purple_network_listen(xd->yahoo_local_p2p_ft_server_port, AF_UNSPEC, SOCK_STREAM, TRUE, yahoo_p2p_ft_server_listen_cb, xfer);
 	}
 	else
 	{
@@ -1570,7 +1570,7 @@ static void yahoo_p2p_client_send_ft_inf
 
 	p2p_data = g_hash_table_lookup(yd->peers, purple_xfer_get_remote_user(xfer));
 	if( p2p_data->connection_type == YAHOO_P2P_WE_ARE_SERVER )
-		if(purple_network_listen_range(0, 0, AF_UNSPEC, SOCK_STREAM, yahoo_p2p_ft_server_listen_cb, xfer))
+		if(purple_network_listen_range(0, 0, AF_UNSPEC, SOCK_STREAM, TRUE, yahoo_p2p_ft_server_listen_cb, xfer))
 			return;
 
 	pkt = yahoo_packet_new(YAHOO_SERVICE_FILETRANS_INFO_15, YAHOO_STATUS_AVAILABLE, yd->session_id);
@@ -1871,7 +1871,7 @@ void yahoo_process_filetrans_info_15(Pur
 			purple_xfer_cancel_remote(xfer);
 			return;
 		}
-		if(!purple_network_listen_range(0, 0, AF_UNSPEC, SOCK_STREAM, yahoo_p2p_ft_server_listen_cb, xfer)) {
+		if(!purple_network_listen_range(0, 0, AF_UNSPEC, SOCK_STREAM, TRUE, yahoo_p2p_ft_server_listen_cb, xfer)) {
 			purple_xfer_cancel_remote(xfer);
 			return;
 		}
============================================================
--- libpurple/network.c	f669e498f223f6bc99686de7aed5d600585f1ad7
+++ libpurple/network.c	d97e5b18399b91ec3352209717aaff0ab5ac60c4
@@ -391,14 +391,9 @@ purple_network_finish_pmp_map_cb(gpointe
 	return FALSE;
 }
 
-static gboolean listen_map_external = TRUE;
-void purple_network_listen_map_external(gboolean map_external)
-{
-	listen_map_external = map_external;
-}
-
 static PurpleNetworkListenData *
-purple_network_do_listen(unsigned short port, int socket_family, int socket_type, PurpleNetworkListenCallback cb, gpointer cb_data)
+purple_network_do_listen(unsigned short port, int socket_family, int socket_type, gboolean map_external,
+                             PurpleNetworkListenCallback cb, gpointer cb_data)
 {
 	int listenfd = -1;
 	int flags;
@@ -503,7 +498,7 @@ purple_network_do_listen(unsigned short 
 	listen_data->cb_data = cb_data;
 	listen_data->socket_type = socket_type;
 
-	if (!purple_socket_speaks_ipv4(listenfd) || !listen_map_external ||
+	if (!purple_socket_speaks_ipv4(listenfd) || !map_external ||
 			!purple_prefs_get_bool("/purple/network/map_ports"))
 	{
 		purple_debug_info("network", "Skipping external port mapping.\n");
@@ -531,19 +526,19 @@ PurpleNetworkListenData *
 }
 
 PurpleNetworkListenData *
-purple_network_listen(unsigned short port, int socket_family,
-                             int socket_type, PurpleNetworkListenCallback cb,
+purple_network_listen(unsigned short port, int socket_family, int socket_type,
+                             gboolean map_external, PurpleNetworkListenCallback cb,
                              gpointer cb_data)
 {
 	g_return_val_if_fail(port != 0, NULL);
 
-	return purple_network_do_listen(port, socket_family, socket_type,
+	return purple_network_do_listen(port, socket_family, socket_type, map_external,
 	                                cb, cb_data);
 }
 
 PurpleNetworkListenData *
 purple_network_listen_range(unsigned short start, unsigned short end,
-                                   int socket_family, int socket_type,
+                                   int socket_family, int socket_type, gboolean map_external,
                                    PurpleNetworkListenCallback cb,
                                    gpointer cb_data)
 {
@@ -558,7 +553,7 @@ purple_network_listen_range(unsigned sho
 	}
 
 	for (; start <= end; start++) {
-		ret = purple_network_do_listen(start, AF_UNSPEC, socket_type, cb, cb_data);
+		ret = purple_network_do_listen(start, AF_UNSPEC, socket_type, map_external, cb, cb_data);
 		if (ret != NULL)
 			break;
 	}
============================================================
--- libpurple/network.h	0ff713f4deb627f9a0c37aab2571e51bfa380437
+++ libpurple/network.h	90f2147481ed4bf41825c7bcfd271d875482e8f9
@@ -118,18 +118,6 @@ const char *purple_network_get_my_ip(int
 const char *purple_network_get_my_ip(int fd);
 
 /**
- * Should calls to purple_network_listen() and purple_network_listen_range()
- * map the port externally using NAT-PMP or UPnP?
- * The default value is TRUE
- *
- * @param map_external Should the open port be mapped externally?
- * @deprecated In 3.0.0 a boolean will be added to the functions mentioned
- *             above to perform the same function.
- * @since 2.3.0
- */
-void purple_network_listen_map_external(gboolean map_external);
-
-/**
  * Attempts to open a listening port ONLY on the specified port number.
  * You probably want to use purple_network_listen_range() instead of this.
  * This function is useful, for example, if you wanted to write a telnet
@@ -156,6 +144,8 @@ void purple_network_listen_map_external(
  *                      need a second listener to support both v4 and v6.
  * @param socket_type The type of socket to open for listening.
  *   This will be either SOCK_STREAM for TCP or SOCK_DGRAM for UDP.
+ * @param map_external Should the open port be mapped externally using
+ *           NAT-PNP or UPnP?  (default should be TRUE)
  * @param cb The callback to be invoked when the port to listen on is available.
  *           The file descriptor of the listening socket will be specified in
  *           this callback, or -1 if no socket could be established.
@@ -166,8 +156,8 @@ PurpleNetworkListenData *purple_network_
  *         socket to listen on.
  */
 PurpleNetworkListenData *purple_network_listen(unsigned short port,
-	int socket_family, int socket_type, PurpleNetworkListenCallback cb,
-	gpointer cb_data);
+	int socket_family, int socket_type, gboolean map_external,
+	PurpleNetworkListenCallback cb, gpointer cb_data);
 
 /**
  * Opens a listening port selected from a range of ports.  The range of
@@ -201,6 +191,8 @@ PurpleNetworkListenData *purple_network_
  *                      need a second listener to support both v4 and v6.
  * @param socket_type The type of socket to open for listening.
  *   This will be either SOCK_STREAM for TCP or SOCK_DGRAM for UDP.
+ * @param map_external Should the open port be mapped externally using
+ *           NAT-PNP or UPnP?  (default should be TRUE)
  * @param cb The callback to be invoked when the port to listen on is available.
  *           The file descriptor of the listening socket will be specified in
  *           this callback, or -1 if no socket could be established.
@@ -212,7 +204,8 @@ PurpleNetworkListenData *purple_network_
  */
 PurpleNetworkListenData *purple_network_listen_range(
 	unsigned short start, unsigned short end, int socket_family,
-	int socket_type, PurpleNetworkListenCallback cb, gpointer cb_data);
+	int socket_type, gboolean map_external,
+	PurpleNetworkListenCallback cb, gpointer cb_data);
 
 /**
  * This can be used to cancel any in-progress listener connection
============================================================
--- libpurple/protocols/irc/dcc_send.c	5257407106cab679c74d37c0da173f3fb6276f16
+++ libpurple/protocols/irc/dcc_send.c	b95d79f5b3d1084934371b43fc06728f7a0917a9
@@ -339,7 +339,7 @@ static void irc_dccsend_send_init(Purple
 	purple_xfer_ref(xfer);
 
 	/* Create a listening socket */
-	xd->listen_data = purple_network_listen_range(0, 0, AF_UNSPEC, SOCK_STREAM,
+	xd->listen_data = purple_network_listen_range(0, 0, AF_UNSPEC, SOCK_STREAM, TRUE,
 			irc_dccsend_network_listen_cb, xfer);
 	if (xd->listen_data == NULL) {
 		purple_xfer_unref(xfer);
============================================================
--- ChangeLog.API	30c67b20ea12376fbf6eebe346db8316cdaa39c7
+++ ChangeLog.API	2604cbeb7211598f51399ce0d9a59d6b099fa28f
@@ -128,6 +128,7 @@ version 3.0.0 (??/??/????):
 		* purple_conv_chat_set_users
 		* purple_core_migrate
 		* purple_dnsquery_a_account
+		* purple_network_listen_map_external
 		* purple_notify_searchresults_column_get_title
 		* purple_notify_searchresults_get_columns_count
 		* purple_notify_searchresults_get_rows_count
============================================================
--- libpurple/protocols/msn/slpcall.c	635419bf04fce505cf84137cb6f25428987b16cd
+++ libpurple/protocols/msn/slpcall.c	d75de8bfd9456a1f9b24f71634c0cee4f0d20101
@@ -733,6 +733,7 @@ got_invite(MsnSlpCall *slpcall,
 				0, 0,
 				AF_UNSPEC,
 				SOCK_STREAM,
+				TRUE,
 				msn_dc_listen_socket_created_cb,
 				dc
 			);
@@ -835,6 +836,7 @@ got_ok(MsnSlpCall *slpcall,
 			0, 0,
 			AF_UNSPEC,
 			SOCK_STREAM,
+			TRUE,
 			msn_dc_listen_socket_created_cb,
 			dc
 		);
============================================================
--- libpurple/plugins/perl/common/Network.xs	e0211e1f1e983623d8e86aa484f49b6a32891d51
+++ libpurple/plugins/perl/common/Network.xs	72efac700fe94ae2733782d1b407dbce0dc9f0ba
@@ -23,19 +23,21 @@ Purple::NetworkListenData
 	const char *ip
 
 Purple::NetworkListenData
-purple_network_listen(port, socket_family, socket_type, cb, cb_data)
+purple_network_listen(port, socket_family, socket_type, map_external, cb, cb_data)
 	unsigned short port
 	int socket_family
 	int socket_type
+	gboolean map_external
 	Purple::NetworkListenCallback cb
 	gpointer cb_data
 
 Purple::NetworkListenData
-purple_network_listen_range(start, end, socket_family, socket_type, cb, cb_data)
+purple_network_listen_range(start, end, socket_family, socket_type, map_external, cb, cb_data)
 	unsigned short start
 	unsigned short end
 	int socket_family
 	int socket_type
+	gboolean map_external
 	Purple::NetworkListenCallback cb
 	gpointer cb_data
 
============================================================
--- libpurple/protocols/simple/simple.c	1f878b0100eb7517de58a8e1bde053b9a8adc8bf
+++ libpurple/protocols/simple/simple.c	a84a57e583a309f3c9465226de323d0ccc57ffb0
@@ -1823,7 +1823,7 @@ static void simple_udp_host_resolved(GSL
 	}
 
 	/* create socket for incoming connections */
-	sip->listen_data = purple_network_listen_range(5060, 5160, AF_UNSPEC, SOCK_DGRAM,
+	sip->listen_data = purple_network_listen_range(5060, 5160, AF_UNSPEC, SOCK_DGRAM, TRUE,
 				simple_udp_host_resolved_listen_cb, sip);
 	if (sip->listen_data == NULL) {
 		purple_connection_error(sip->gc,
@@ -1893,7 +1893,7 @@ static void srvresolved(PurpleSrvRespons
 	/* TCP case */
 	if(!sip->udp) {
 		/* create socket for incoming connections */
-		sip->listen_data = purple_network_listen_range(5060, 5160, AF_UNSPEC, SOCK_STREAM,
+		sip->listen_data = purple_network_listen_range(5060, 5160, AF_UNSPEC, SOCK_STREAM, TRUE,
 					simple_tcp_connect_listen_cb, sip);
 		if (sip->listen_data == NULL) {
 			purple_connection_error(sip->gc,
============================================================
--- libpurple/stun.c	97045cab022058fea0872d500571d0635bae34b2
+++ libpurple/stun.c	5d17b53067f34846fab9ae4cd91a234c51d56632
@@ -338,7 +338,7 @@ static void hbn_cb(GSList *hosts, gpoint
 		return;
 	}
 
-	if (!purple_network_listen_range(12108, 12208, AF_UNSPEC, SOCK_DGRAM, hbn_listen_cb, hosts)) {
+	if (!purple_network_listen_range(12108, 12208, AF_UNSPEC, SOCK_DGRAM, TRUE, hbn_listen_cb, hosts)) {
 		while (hosts) {
 			hosts = g_slist_delete_link(hosts, hosts);
 			g_free(hosts->data);
============================================================
--- libpurple/protocols/bonjour/jabber.c	4345fdaf582ab7952737bc7eba2a6c5934eba019
+++ libpurple/protocols/bonjour/jabber.c	fc0a9c3dedd1a5e188cf97fe38af662e437c08eb
@@ -744,7 +744,7 @@ start_serversocket_listening(int port, i
 
 #if 0
 	/* TODO: Why isn't this being used? */
-	data->socket = purple_network_listen(jdata->port, AF_UNSPEC, SOCK_STREAM);
+	data->socket = purple_network_listen(jdata->port, AF_UNSPEC, SOCK_STREAM, TRUE);
 
 	if (jdata->socket == -1)
 	{
============================================================
--- libpurple/protocols/oscar/peer.c	157932f39c5345c33cade079c22b7ddeaf2812fa
+++ libpurple/protocols/oscar/peer.c	078ad3358973f338ea3de25f9a041b0bea9154c1
@@ -842,7 +842,7 @@ peer_connection_trynext(PeerConnection *
 		 */
 		conn->flags |= PEER_CONNECTION_FLAG_IS_INCOMING;
 
-		conn->listen_data = purple_network_listen_range(5190, 5290, AF_UNSPEC, SOCK_STREAM,
+		conn->listen_data = purple_network_listen_range(5190, 5290, AF_UNSPEC, SOCK_STREAM, TRUE,
 				peer_connection_establish_listener_cb, conn);
 		if (conn->listen_data != NULL)
 		{
============================================================
--- libpurple/protocols/bonjour/bonjour_ft.c	36d4acd7474d548aac6e2a5016f23a19bc157904
+++ libpurple/protocols/bonjour/bonjour_ft.c	f23c490839f68136278bd42d781ffa5c8ed06bcc
@@ -792,10 +792,8 @@ bonjour_bytestreams_init(PurpleXfer *xfe
 	purple_debug_info("bonjour", "Bonjour-bytestreams-init.\n");
 	xf = purple_xfer_get_protocol_data(xfer);
 
-	purple_network_listen_map_external(FALSE);
-	xf->listen_data = purple_network_listen_range(0, 0, AF_UNSPEC, SOCK_STREAM,
+	xf->listen_data = purple_network_listen_range(0, 0, AF_UNSPEC, SOCK_STREAM, FALSE,
 						      bonjour_bytestreams_listen, xfer);
-	purple_network_listen_map_external(TRUE);
 	if (xf->listen_data == NULL)
 		purple_xfer_cancel_local(xfer);
 


More information about the Commits mailing list