soc.2008.yahoo: 5565413d: Remove some bugs related to inserting so...
sulabh at soc.pidgin.im
sulabh at soc.pidgin.im
Tue Jul 22 15:46:36 EDT 2008
-----------------------------------------------------------------
Revision: 5565413d2cdefc3d89e5588066f115ea43ee462e
Ancestor: ea7309049612b4f3068e248583b0278fe933bc74
Author: sulabh at soc.pidgin.im
Date: 2008-07-21T09:07:42
Branch: im.pidgin.soc.2008.yahoo
URL: http://d.pidgin.im/viewmtn/revision/info/5565413d2cdefc3d89e5588066f115ea43ee462e
Modified files:
libpurple/protocols/yahoo/yahoo.c
ChangeLog:
Remove some bugs related to inserting some data into hash table, data for connected peers
-------------- next part --------------
============================================================
--- libpurple/protocols/yahoo/yahoo.c 18db2197209b9dba3f87fab7cc48e320f5abf60d
+++ libpurple/protocols/yahoo/yahoo.c 10b90bce9a9ce44a8f6f49f288249c073caf6c46
@@ -2377,6 +2377,7 @@ static void yahoo_p2p_process_p2pfilexfe
PurpleAccount *account;
int val_13_to_send = 0;
struct yahoo_data *yd;
+ YahooFriend *f;
if(!(p2p_data = data))
return ;
@@ -2433,6 +2434,21 @@ static void yahoo_p2p_process_p2pfilexfe
/* build the raw packet and send it to the host */
yahoo_p2p_write_pkt(source, pkt_to_send);
yahoo_packet_free(pkt_to_send);
+
+ if( val_13_to_send == 7 )
+ if( !g_hash_table_lookup(yd->peers, p2p_data->host_username) ) {
+ g_hash_table_insert(yd->peers, g_strdup(p2p_data->host_username), p2p_data);
+ /* If the peer is a friend, set him connected */
+ f = yahoo_friend_find(p2p_data->gc, p2p_data->host_username);
+ if (f) {
+ if(p2p_data->connection_type == YAHOO_P2P_WE_ARE_SERVER) {
+ p2p_data->session_id = f->session_id;
+ yahoo_friend_set_p2p_status(f, YAHOO_P2PSTATUS_WE_ARE_SERVER);
+ }
+ else
+ yahoo_friend_set_p2p_status(f, YAHOO_P2PSTATUS_WE_ARE_CLIENT);
+ }
+ }
}
/* callback function associated with receiving of data, not considering receipt of multiple YMSG packets in a single TCP packet */
@@ -2458,7 +2474,10 @@ static void yahoo_p2p_read_pkt_cb(gpoint
{
purple_debug_warning("yahoo","p2p: Error in connection, or host disconnected\n");
/* remove from p2p connection lists, also calls yahoo_p2p_disconnect_destroy_data */
- g_hash_table_remove(yd->peers,p2p_data->host_username);
+ if( g_hash_table_lookup(yd->peers, p2p_data->host_username) )
+ g_hash_table_remove(yd->peers,p2p_data->host_username);
+ else
+ yahoo_p2p_disconnect_destroy_data(data);
return;
}
@@ -2516,7 +2535,6 @@ static void yahoo_p2p_server_send_connec
{
int acceptfd;
struct yahoo_p2p_data *p2p_data;
- YahooFriend *f;
struct yahoo_data *yd;
if(!(p2p_data = data))
@@ -2537,16 +2555,9 @@ static void yahoo_p2p_server_send_connec
close(yd->yahoo_local_p2p_server_fd);
yd->yahoo_local_p2p_server_fd = -1;
- if( (f = yahoo_friend_find(p2p_data->gc, p2p_data->host_username)) ) {
- p2p_data->session_id = f->session_id;
- yahoo_friend_set_p2p_status(f, YAHOO_P2PSTATUS_WE_ARE_SERVER);
- }
-
/* Add an Input Read event to the file descriptor */
p2p_data->input_event = purple_input_add(acceptfd, PURPLE_INPUT_READ, yahoo_p2p_read_pkt_cb, data);
p2p_data->source = acceptfd;
-
- g_hash_table_insert(yd->peers, g_strdup(p2p_data->host_username), p2p_data);
}
static void yahoo_p2p_server_listen_cb(int listenfd, gpointer data)
@@ -2582,8 +2593,14 @@ static void yahoo_send_p2p_pkt(PurpleCon
struct yahoo_packet *pkt;
PurpleAccount *account;
struct yahoo_data *yd = gc->proto_data;
- struct yahoo_p2p_data *p2p_data = g_new0(struct yahoo_p2p_data, 1);
+ struct yahoo_p2p_data *p2p_data;
+ f = yahoo_friend_find(gc, who);
+ account = purple_connection_get_account(gc);
+ /* send packet to only those friends who arent p2p connected and to whom we havent already sent. Do not send if this condition doesn't hold good */
+ if( !( f && (yahoo_friend_get_p2p_status(f) == YAHOO_P2PSTATUS_NOT_CONNECTED) && (f->p2p_packet_sent == 0)) )
+ return;
+
public_ip = purple_network_get_public_ip();
if( (sscanf(public_ip, "%u.%u.%u.%u", &temp[0], &temp[1], &temp[2], &temp[3])) !=4 )
return ;
@@ -2592,13 +2609,6 @@ static void yahoo_send_p2p_pkt(PurpleCon
sprintf(temp_str, "%d", ip);
base64_ip = purple_base64_encode( (guchar *)temp_str, strlen(temp_str) );
- f = yahoo_friend_find(gc, who);
- account = purple_connection_get_account(gc);
-
- /* send packet to only those friends who arent p2p connected and to whom we havent already sent. Do not send if this condition doesn't hold good */
- if( !( f && (yahoo_friend_get_p2p_status(f) == YAHOO_P2PSTATUS_NOT_CONNECTED) && (f->p2p_packet_sent == 0)) )
- return;
-
pkt = yahoo_packet_new(YAHOO_SERVICE_PEERTOPEER, YAHOO_STATUS_AVAILABLE, 0);
yahoo_packet_hash(pkt, "sssissis",
1, purple_normalize(account, purple_account_get_username(account)),
@@ -2613,6 +2623,8 @@ static void yahoo_send_p2p_pkt(PurpleCon
f->p2p_packet_sent = 1; /* set p2p_packet_sent to sent */
+ p2p_data = g_new0(struct yahoo_p2p_data, 1);
+
p2p_data->gc = gc;
p2p_data->host_ip = NULL;
p2p_data->host_username = (char *)g_malloc(strlen(who));
@@ -2631,7 +2643,6 @@ static void yahoo_p2p_init_cb(gpointer d
struct yahoo_p2p_data *p2p_data;
struct yahoo_packet *pkt_to_send;
PurpleAccount *account;
- YahooFriend *f;
struct yahoo_data *yd;
if(!(p2p_data = data))
@@ -2650,13 +2661,6 @@ static void yahoo_p2p_init_cb(gpointer d
p2p_data->input_event = purple_input_add(source, PURPLE_INPUT_READ, yahoo_p2p_read_pkt_cb, data);
p2p_data->source = source;
- g_hash_table_insert(yd->peers, g_strdup(p2p_data->host_username), p2p_data);
-
- /* If the peer is a friend, set him connected */
- f = yahoo_friend_find(p2p_data->gc, p2p_data->host_username);
- if (f)
- yahoo_friend_set_p2p_status(f, YAHOO_P2PSTATUS_WE_ARE_CLIENT);
-
account = purple_connection_get_account(p2p_data->gc);
/* Build the yahoo packet */
@@ -2684,6 +2688,10 @@ static void yahoo_process_p2p(PurpleConn
PurpleAccount *account;
YahooFriend *f;
+ /* if status is YAHOO_STATUS_BUSY, don't do anything, peer wont connect */
+ if(pkt->status == YAHOO_STATUS_BUSY)
+ return ;
+
while (l) {
struct yahoo_pair *pair = l->data;
More information about the Commits
mailing list