soc.2008.yahoo: f1cf42e1: Fall back to establishing connection as ...

sulabh at soc.pidgin.im sulabh at soc.pidgin.im
Fri Jun 27 12:10:42 EDT 2008


-----------------------------------------------------------------
Revision: f1cf42e1a1410789df7034c41d49a24089e68a82
Ancestor: ae032bddaef48f9372454ad171acf0aee9f17d92
Author: sulabh at soc.pidgin.im
Date: 2008-06-27T16:02:30
Branch: im.pidgin.soc.2008.yahoo
URL: http://d.pidgin.im/viewmtn/revision/info/f1cf42e1a1410789df7034c41d49a24089e68a82

Modified files:
        libpurple/protocols/yahoo/yahoo.c
        libpurple/protocols/yahoo/yahoo_friend.h

ChangeLog: 

Fall back to establishing connection as a client when unable to act as a server.
Fixed a bug which resulted in segfault when signing out while p2p connection to a friend exists. 

-------------- next part --------------
============================================================
--- libpurple/protocols/yahoo/yahoo.c	d5370d567d14579fa23053b34f5d590145883f97
+++ libpurple/protocols/yahoo/yahoo.c	bb8356b3ece5f3e47b9b5afab8bb2822fa14ff48
@@ -2301,7 +2301,7 @@ static void yahoo_p2p_disconnect_destroy
 	close(user_data->source);
 	g_free(user_data->host_ip);
 	g_free(user_data->host_username);
-	g_free(user_data);	
+	g_free(user_data);
 }
 
 /*write pkt to the source*/
@@ -2495,7 +2495,7 @@ static void yahoo_p2p_init_cb(gpointer d
 		5, user_data->host_username,
 		241, 0,		/*Protocol identifier*/
 		49, "PEERTOPEER",
-		13, 1);		/*we receive key13=0, we send key13=1*/
+		13, 1);		/*we receive key13= 0 or 2, we send key13=1*/
 
 	yahoo_p2p_write_pkt(source, pkt_to_send);	/*build raw packet and send*/
 	yahoo_packet_free(pkt_to_send);
@@ -2509,9 +2509,9 @@ static void yahoo_process_p2p(PurpleConn
 	guchar *decoded;
 	gsize len;
 	gint val_13 = 0;
-	gint val_11;
+	gint val_11 = 0;
 	PurpleAccount *account;
-	struct yahoo_p2p_data *user_data = g_new0(struct yahoo_p2p_data, 1);
+	YahooFriend *f;
 
 	while (l) {
 		struct yahoo_pair *pair = l->data;
@@ -2521,9 +2521,7 @@ static void yahoo_process_p2p(PurpleConn
 			/* our identity */
 			break;
 		case 4:
-			who = (char *)g_malloc(strlen(pair->value));
-			strcpy(who, pair->value);
-			user_data->host_username = who;
+			who = pair->value;
 			break;
 		case 1:
 			/* who again, the master identity this time? */
@@ -2535,11 +2533,11 @@ static void yahoo_process_p2p(PurpleConn
 			break;
 		case 13:
 			val_13 = strtol(pair->value, NULL, 10);
-			user_data->val_13 = val_13;
 			break;
 		case 11:
-			val_11 = strtol(pair->value, NULL, 10);		/*sent with IMs and notifications over p2p*/
-			user_data->val_11 = val_11;
+			val_11 = strtol(pair->value, NULL, 10);		/*p2p identity of peer*/
+			if( (f = yahoo_friend_find(gc, who)) )
+				f->val_11 = val_11;
 			break;
 		/*
 			TODO: figure these out
@@ -2560,6 +2558,7 @@ static void yahoo_process_p2p(PurpleConn
 		char *tmp2;
 		YahooFriend *f;
 		char *host_ip;
+		struct yahoo_p2p_data *user_data = g_new0(struct yahoo_p2p_data, 1);
 
 		decoded = purple_base64_decode(base64, &len);
 		if (len) {
@@ -2581,6 +2580,17 @@ static void yahoo_process_p2p(PurpleConn
 
 		account = purple_connection_get_account(gc);
 
+		if(val_11==0)	{
+			if(!f)
+				return;
+			else
+				val_11 = f->val_11;
+		}
+
+		user_data->host_username = (char *)g_malloc(strlen(who));
+		strcpy(user_data->host_username, who);		
+		user_data->val_13 = val_13;
+		user_data->val_11 = val_11;
 		user_data->host_ip = host_ip;
 		user_data->session_id = pkt->id;
 		user_data->gc = gc;
@@ -2749,7 +2759,8 @@ static void yahoo_packet_process(PurpleC
 		break;
 	case YAHOO_SERVICE_P2PFILEXFER:
 		/* This case had no break and continued; thus keeping it this way.*/
-		yahoo_process_p2pfilexfer(gc, pkt);
+		yahoo_process_p2p(gc, pkt);	/*P2PFILEXFER handled the same way as process_p2p*/
+		yahoo_process_p2pfilexfer(gc, pkt);	/*redundant ??, need to have a break now*/
 	case YAHOO_SERVICE_FILETRANSFER:
 		yahoo_process_filetransfer(gc, pkt);
 		break;
@@ -3369,10 +3380,10 @@ static void yahoo_close(PurpleConnection
 	if (yd->in_chat)
 		yahoo_c_leave(gc, 1); /* 1 = YAHOO_CHAT_ID */
 
+	g_hash_table_destroy(yd->peers);
 	g_hash_table_destroy(yd->friends);
 	g_hash_table_destroy(yd->imvironments);
 	g_hash_table_destroy(yd->xfer_peer_idstring_map);
-	g_hash_table_destroy(yd->peers);
 	g_free(yd->chat_name);
 
 	g_free(yd->cookie_y);
============================================================
--- libpurple/protocols/yahoo/yahoo_friend.h	bb6dd113a0da81392cf598fc07547a13647da22e
+++ libpurple/protocols/yahoo/yahoo_friend.h	80c6513140892754ce3c3471dad57e2a477a4d37
@@ -58,7 +58,8 @@ typedef struct _YahooFriend {
 	long int version_id;
 	gchar *alias_id;
 	YahooP2PStatus p2p_status;
-	gboolean p2p_packet_sent;	/*0:not sent, 1=sent*/ 
+	gboolean p2p_packet_sent;	/*0:not sent, 1=sent*/
+	gint val_11;	/*value for key 11, p2p identifier*/
 } YahooFriend;
 
 YahooFriend *yahoo_friend_find(PurpleConnection *gc, const char *name);


More information about the Commits mailing list