comparison libpurple/protocols/yahoo/yahoo.c @ 25069:262ae5f56a9a

Better naming convention, prefix YAHOO_P2PSTATUS_ to values in the enum YahooP2PStatus
author Sulabh Mahajan <sulabh@soc.pidgin.im>
date Sat, 12 Jul 2008 18:55:29 +0000
parents 7bd420b3edb7
children c3c5e79b4ecc
comparison
equal deleted inserted replaced
25068:7bd420b3edb7 25069:262ae5f56a9a
518 purple_blist_add_buddy(b, NULL, g, NULL); 518 purple_blist_add_buddy(b, NULL, g, NULL);
519 } 519 }
520 yahoo_do_group_check(account, ht, norm_bud, yd->current_list15_grp); 520 yahoo_do_group_check(account, ht, norm_bud, yd->current_list15_grp);
521 521
522 /*set p2p status not connected and no p2p packet sent*/ 522 /*set p2p status not connected and no p2p packet sent*/
523 yahoo_friend_set_p2p_status(f, NOT_CONNECTED); 523 yahoo_friend_set_p2p_status(f, YAHOO_P2PSTATUS_NOT_CONNECTED);
524 f->p2p_packet_sent = 0; 524 f->p2p_packet_sent = 0;
525 525
526 } else { 526 } else {
527 /* This buddy is on the ignore list (and therefore in no group) */ 527 /* This buddy is on the ignore list (and therefore in no group) */
528 purple_debug_info("yahoo", "%s adding %s to the deny list because of the ignore list / no group was found\n", 528 purple_debug_info("yahoo", "%s adding %s to the deny list because of the ignore list / no group was found\n",
635 export = TRUE; 635 export = TRUE;
636 } 636 }
637 637
638 yahoo_do_group_check(account, ht, norm_bud, grp); 638 yahoo_do_group_check(account, ht, norm_bud, grp);
639 /*set p2p status not connected and no p2p packet sent*/ 639 /*set p2p status not connected and no p2p packet sent*/
640 yahoo_friend_set_p2p_status(f, NOT_CONNECTED); 640 yahoo_friend_set_p2p_status(f, YAHOO_P2PSTATUS_NOT_CONNECTED);
641 f->p2p_packet_sent = 0; 641 f->p2p_packet_sent = 0;
642 642
643 g_free(norm_bud); 643 g_free(norm_bud);
644 } 644 }
645 g_strfreev(buddies); 645 g_strfreev(buddies);
2243 f = yahoo_friend_find_or_new(gc, who); 2243 f = yahoo_friend_find_or_new(gc, who);
2244 yahoo_update_status(gc, who, f); 2244 yahoo_update_status(gc, who, f);
2245 2245
2246 if( !g_hash_table_lookup(yd->peers, who) ) { 2246 if( !g_hash_table_lookup(yd->peers, who) ) {
2247 /*we are not connected as client, so set friend to not connected*/ 2247 /*we are not connected as client, so set friend to not connected*/
2248 yahoo_friend_set_p2p_status(f, NOT_CONNECTED); 2248 yahoo_friend_set_p2p_status(f, YAHOO_P2PSTATUS_NOT_CONNECTED);
2249 f->p2p_packet_sent = 0; 2249 f->p2p_packet_sent = 0;
2250 } 2250 }
2251 else /*we are already connected. set friend to CONNECTED_AS_CLIENT*/ 2251 else /*we are already connected. set friend to YAHOO_P2PSTATUS_WE_ARE_CLIENT*/
2252 yahoo_friend_set_p2p_status(f, CONNECTED_AS_CLIENT); 2252 yahoo_friend_set_p2p_status(f, YAHOO_P2PSTATUS_WE_ARE_CLIENT);
2253 return; 2253 return;
2254 } 2254 }
2255 2255
2256 decoded_group = yahoo_string_decode(gc, group, FALSE); 2256 decoded_group = yahoo_string_decode(gc, group, FALSE);
2257 buf = g_strdup_printf(_("Could not add buddy %s to group %s to the server list on account %s."), 2257 buf = g_strdup_printf(_("Could not add buddy %s to group %s to the server list on account %s."),
2274 return ; 2274 return ;
2275 2275
2276 /*If friend, set him not connected*/ 2276 /*If friend, set him not connected*/
2277 f = yahoo_friend_find(p2p_data->gc, p2p_data->host_username); 2277 f = yahoo_friend_find(p2p_data->gc, p2p_data->host_username);
2278 if (f) 2278 if (f)
2279 yahoo_friend_set_p2p_status(f, NOT_CONNECTED); 2279 yahoo_friend_set_p2p_status(f, YAHOO_P2PSTATUS_NOT_CONNECTED);
2280 2280
2281 if(p2p_data->source >= 0) 2281 if(p2p_data->source >= 0)
2282 close(p2p_data->source); 2282 close(p2p_data->source);
2283 purple_input_remove(p2p_data->input_event); 2283 purple_input_remove(p2p_data->input_event);
2284 g_free(p2p_data->host_ip); 2284 g_free(p2p_data->host_ip);
2469 close(yd->yahoo_local_p2p_server_fd); 2469 close(yd->yahoo_local_p2p_server_fd);
2470 yd->yahoo_local_p2p_server_fd = -1; 2470 yd->yahoo_local_p2p_server_fd = -1;
2471 2471
2472 if( (f = yahoo_friend_find(p2p_data->gc, p2p_data->host_username)) ) { 2472 if( (f = yahoo_friend_find(p2p_data->gc, p2p_data->host_username)) ) {
2473 p2p_data->session_id = f->session_id; 2473 p2p_data->session_id = f->session_id;
2474 yahoo_friend_set_p2p_status(f, CONNECTED_AS_SERVER); 2474 yahoo_friend_set_p2p_status(f, YAHOO_P2PSTATUS_WE_ARE_SERVER);
2475 } 2475 }
2476 2476
2477 /*Add an Input Read event to the file descriptor*/ 2477 /*Add an Input Read event to the file descriptor*/
2478 p2p_data->input_event = purple_input_add(acceptfd, PURPLE_INPUT_READ, yahoo_p2p_read_pkt_cb, data); 2478 p2p_data->input_event = purple_input_add(acceptfd, PURPLE_INPUT_READ, yahoo_p2p_read_pkt_cb, data);
2479 p2p_data->source = acceptfd; 2479 p2p_data->source = acceptfd;
2526 2526
2527 f = yahoo_friend_find(gc, who); 2527 f = yahoo_friend_find(gc, who);
2528 account = purple_connection_get_account(gc); 2528 account = purple_connection_get_account(gc);
2529 2529
2530 /*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*/ 2530 /*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*/
2531 if( !( f && (yahoo_friend_get_p2p_status(f) == NOT_CONNECTED) && (f->p2p_packet_sent == 0)) ) 2531 if( !( f && (yahoo_friend_get_p2p_status(f) == YAHOO_P2PSTATUS_NOT_CONNECTED) && (f->p2p_packet_sent == 0)) )
2532 return; 2532 return;
2533 2533
2534 pkt = yahoo_packet_new(YAHOO_SERVICE_PEERTOPEER, YAHOO_STATUS_AVAILABLE, 0); 2534 pkt = yahoo_packet_new(YAHOO_SERVICE_PEERTOPEER, YAHOO_STATUS_AVAILABLE, 0);
2535 yahoo_packet_hash(pkt, "sssissis", 2535 yahoo_packet_hash(pkt, "sssissis",
2536 1, purple_normalize(account, purple_account_get_username(account)), 2536 1, purple_normalize(account, purple_account_get_username(account)),
2585 g_hash_table_insert(yd->peers, g_strdup(p2p_data->host_username), p2p_data); 2585 g_hash_table_insert(yd->peers, g_strdup(p2p_data->host_username), p2p_data);
2586 2586
2587 /*If the peer is a friend, set him connected*/ 2587 /*If the peer is a friend, set him connected*/
2588 f = yahoo_friend_find(p2p_data->gc, p2p_data->host_username); 2588 f = yahoo_friend_find(p2p_data->gc, p2p_data->host_username);
2589 if (f) 2589 if (f)
2590 yahoo_friend_set_p2p_status(f, CONNECTED_AS_CLIENT); 2590 yahoo_friend_set_p2p_status(f, YAHOO_P2PSTATUS_WE_ARE_CLIENT);
2591 2591
2592 account = purple_connection_get_account(p2p_data->gc); 2592 account = purple_connection_get_account(p2p_data->gc);
2593 2593
2594 /*Build the yahoo packet*/ 2594 /*Build the yahoo packet*/
2595 pkt_to_send = yahoo_packet_new(YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, yd->session_id); 2595 pkt_to_send = yahoo_packet_new(YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, yd->session_id);