diff src/protocols/bonjour/dns_sd.c @ 13909:8264f52a1142

[gaim-migrate @ 16406] More of sf patch #1490646, from Jonty Wareing & Jono Cole "The screen name + hostname of the sending user is sent in the outgoing jabber message, fixing a sporadic problem with iChat. The port in use has been fixed to the one described in the Bonjour specification and can no longer be changed in the prpl preferences - modifiying this just stops the client from being able to start a chat. The option for a buddy icon has been removed for now as no code actually uses it yet - we plan to change this in the future. This update also introduces automatic local port retry for up to ten attempts if the port is in use (e.g. if multiple instances of gaim are running)." committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Mon, 03 Jul 2006 00:37:41 +0000
parents b986b6e2441b
children
line wrap: on
line diff
--- a/src/protocols/bonjour/dns_sd.c	Sun Jul 02 23:56:08 2006 +0000
+++ b/src/protocols/bonjour/dns_sd.c	Mon Jul 03 00:37:41 2006 +0000
@@ -21,27 +21,6 @@
 #include "buddy.h"
 #include "debug.h"
 
-/* Private data */
-
-typedef struct _dns_sd_packet
-{
-	gchar *name;
-	gchar *txtvers;
-	gchar *version;
-	gchar *first;
-	gchar *last;
-	gint port_p2pj;
-	gchar *phsh;
-	gchar *status;
-	gchar *message;
-	gchar *email;
-	gchar *vc;
-	gchar *jid;
-	gchar *AIM;
-} dns_sd_packet;
-
-/* End private data */
-
 /* Private functions */
 
 static sw_result HOWL_API
@@ -83,7 +62,6 @@
 	gchar *txtvers = NULL;
 	gchar *version = NULL;
 	gchar *first = NULL;
-	gint port_p2pj = -1;
 	gchar *phsh = NULL;
 	gchar *status = NULL;
 	gchar *email = NULL;
@@ -119,8 +97,6 @@
 				version = g_strdup(value);
 			} else if (strcmp(key, "1st") == 0) {
 				first = g_strdup(value);
-			} else if (strcmp(key, "port.p2pj") == 0) {
-				port_p2pj = atoi(value);
 			} else if (strcmp(key, "status") == 0) {
 				status = g_strdup(value);
 			} else if (strcmp(key, "email") == 0) {
@@ -143,7 +119,7 @@
 
 	/* Put the parameters of the text_record in a buddy and add the buddy to */
 	/* the buddy list */
-	buddy = bonjour_buddy_new(name, first, port_p2pj, phsh,
+	buddy = bonjour_buddy_new(name, first, port, phsh,
 							  status, email, last, jid, AIM, vc, ip, msg);
 
 	if (bonjour_buddy_check(buddy) == FALSE)
@@ -200,7 +176,7 @@
 			gaim_debug_warning("bonjour", "_browser_reply --> Remove domain\n");
 			break;
 		case SW_DISCOVERY_BROWSE_ADD_SERVICE:
-			/* A new peer has join the network and uses iChat bonjour */
+			/* A new peer has joined the network and uses iChat bonjour */
 			gaim_debug_info("bonjour", "_browser_reply --> Add service\n");
 			if (g_ascii_strcasecmp(name, account->username) != 0)
 			{
@@ -235,6 +211,7 @@
 {
 	sw_text_record dns_data;
 	sw_result publish_result = SW_OKAY;
+	char portstring[6];
 
 	/* Fill the data for the service */
 	if (sw_text_record_init(&dns_data) != SW_OKAY)
@@ -243,16 +220,20 @@
 		return -1;
 	}
 
+	/* Convert the port to a string */
+	snprintf(portstring, sizeof(portstring), "%d", data->port_p2pj);
+
+	/* Publish standard records */
 	sw_text_record_add_key_and_string_value(dns_data, "txtvers", data->txtvers);
 	sw_text_record_add_key_and_string_value(dns_data, "version", data->version);
 	sw_text_record_add_key_and_string_value(dns_data, "1st", data->first);
 	sw_text_record_add_key_and_string_value(dns_data, "last", data->last);
-	/* sw_text_record_add_key_and_string_value(dns_data, "port.p2pj", itoa(data->port_p2pj)); */
-	sw_text_record_add_key_and_string_value(dns_data, "port.p2pj", BONJOUR_DEFAULT_PORT);
+	sw_text_record_add_key_and_string_value(dns_data, "port.p2pj", portstring);
 	sw_text_record_add_key_and_string_value(dns_data, "phsh", data->phsh);
 	sw_text_record_add_key_and_string_value(dns_data, "status", data->status);
 	sw_text_record_add_key_and_string_value(dns_data, "vc", data->vc);
 
+	/* Publish extra records */
 	if ((data->email != NULL) && (*data->email != '\0'))
 		sw_text_record_add_key_and_string_value(dns_data, "email", data->email);
 
@@ -280,7 +261,7 @@
 	}
 	if (publish_result != SW_OKAY)
 	{
-		gaim_debug_error("bonjour", "Unable to publish or change the status of the _presence._tcp service.");
+		gaim_debug_error("bonjour", "Unable to publish or change the status of the _presence._tcp service.\n");
 		return -1;
 	}