Mercurial > pidgin.yaz
comparison libpurple/protocols/yahoo/libymsg.c @ 27679:0ec880685f5f
Change a crapton of our Yahoo! packets to use the session ID we're assigned
during login. This makes us behave more like the official client, which saves
and uses the session ID for the life of the login session, and it doesn't
hurt anything that I've been able to see.
author | John Bailey <rekkanoryo@rekkanoryo.org> |
---|---|
date | Sat, 18 Jul 2009 03:36:33 +0000 |
parents | 4bd3f7d841e3 |
children | e1cd44c7c7af 482a5edc4799 975e213733e8 |
comparison
equal
deleted
inserted
replaced
27678:faf80efd10a9 | 27679:0ec880685f5f |
---|---|
1141 const char *who = add_req->who; | 1141 const char *who = add_req->who; |
1142 | 1142 |
1143 if (add_req->protocol == 2) | 1143 if (add_req->protocol == 2) |
1144 who += 4; | 1144 who += 4; |
1145 | 1145 |
1146 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH_REQ_15, YAHOO_STATUS_AVAILABLE, 0); | 1146 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH_REQ_15, YAHOO_STATUS_AVAILABLE, yd->session_id); |
1147 yahoo_packet_hash(pkt, "ssiii", | 1147 yahoo_packet_hash(pkt, "ssiii", |
1148 1, add_req->id, | 1148 1, add_req->id, |
1149 5, who, | 1149 5, who, |
1150 241, add_req->protocol, | 1150 241, add_req->protocol, |
1151 13, 1, | 1151 13, 1, |
1170 | 1170 |
1171 if (msg && *msg) | 1171 if (msg && *msg) |
1172 encoded_msg = yahoo_string_encode(add_req->gc, msg, NULL); | 1172 encoded_msg = yahoo_string_encode(add_req->gc, msg, NULL); |
1173 | 1173 |
1174 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH_REQ_15, | 1174 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH_REQ_15, |
1175 YAHOO_STATUS_AVAILABLE, 0); | 1175 YAHOO_STATUS_AVAILABLE, yd->session_id); |
1176 | 1176 |
1177 yahoo_packet_hash(pkt, "ssiiiis", | 1177 yahoo_packet_hash(pkt, "ssiiiis", |
1178 1, add_req->id, | 1178 1, add_req->id, |
1179 5, who, | 1179 5, who, |
1180 241, add_req->protocol, | 1180 241, add_req->protocol, |
3026 } | 3026 } |
3027 | 3027 |
3028 yd = gc->proto_data; | 3028 yd = gc->proto_data; |
3029 yd->fd = source; | 3029 yd->fd = source; |
3030 | 3030 |
3031 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, yd->current_status, 0); | 3031 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, yd->current_status, yd->session_id); |
3032 | 3032 |
3033 yahoo_packet_hash_str(pkt, 1, purple_normalize(gc->account, purple_account_get_username(purple_connection_get_account(gc)))); | 3033 yahoo_packet_hash_str(pkt, 1, purple_normalize(gc->account, purple_account_get_username(purple_connection_get_account(gc)))); |
3034 yahoo_packet_send_and_free(pkt, yd); | 3034 yahoo_packet_send_and_free(pkt, yd); |
3035 | 3035 |
3036 gc->inpa = purple_input_add(yd->fd, PURPLE_INPUT_READ, yahoo_pending, gc); | 3036 gc->inpa = purple_input_add(yd->fd, PURPLE_INPUT_READ, yahoo_pending, gc); |
3052 } | 3052 } |
3053 | 3053 |
3054 yd = gc->proto_data; | 3054 yd = gc->proto_data; |
3055 yd->fd = source; | 3055 yd->fd = source; |
3056 | 3056 |
3057 pkt = yahoo_packet_new(YAHOO_SERVICE_WEBLOGIN, YAHOO_STATUS_WEBLOGIN, 0); | 3057 pkt = yahoo_packet_new(YAHOO_SERVICE_WEBLOGIN, YAHOO_STATUS_WEBLOGIN, yd->session_id); |
3058 | 3058 |
3059 yahoo_packet_hash(pkt, "sss", 0, | 3059 yahoo_packet_hash(pkt, "sss", 0, |
3060 purple_normalize(gc->account, purple_account_get_username(purple_connection_get_account(gc))), | 3060 purple_normalize(gc->account, purple_account_get_username(purple_connection_get_account(gc))), |
3061 1, purple_normalize(gc->account, purple_account_get_username(purple_connection_get_account(gc))), | 3061 1, purple_normalize(gc->account, purple_account_get_username(purple_connection_get_account(gc))), |
3062 6, yd->auth); | 3062 6, yd->auth); |
3955 static void yahoo_act_id(PurpleConnection *gc, PurpleRequestFields *fields) | 3955 static void yahoo_act_id(PurpleConnection *gc, PurpleRequestFields *fields) |
3956 { | 3956 { |
3957 struct yahoo_data *yd = gc->proto_data; | 3957 struct yahoo_data *yd = gc->proto_data; |
3958 const char *name = yd->profiles[purple_request_fields_get_choice(fields, "id")]; | 3958 const char *name = yd->profiles[purple_request_fields_get_choice(fields, "id")]; |
3959 | 3959 |
3960 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_IDACT, YAHOO_STATUS_AVAILABLE, 0); | 3960 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_IDACT, YAHOO_STATUS_AVAILABLE, yd->session_id); |
3961 yahoo_packet_hash_str(pkt, 3, name); | 3961 yahoo_packet_hash_str(pkt, 3, name); |
3962 yahoo_packet_send_and_free(pkt, yd); | 3962 yahoo_packet_send_and_free(pkt, yd); |
3963 | 3963 |
3964 purple_connection_set_display_name(gc, name); | 3964 purple_connection_set_display_name(gc, name); |
3965 } | 3965 } |
4291 g_free(msg2); | 4291 g_free(msg2); |
4292 return -1; | 4292 return -1; |
4293 } | 4293 } |
4294 | 4294 |
4295 alias = purple_account_get_alias(account); | 4295 alias = purple_account_get_alias(account); |
4296 pkt = yahoo_packet_new(YAHOO_SERVICE_SMS_MSG, YAHOO_STATUS_AVAILABLE, 0); | 4296 pkt = yahoo_packet_new(YAHOO_SERVICE_SMS_MSG, YAHOO_STATUS_AVAILABLE, yd->session_id); |
4297 yahoo_packet_hash(pkt, "sssss", | 4297 yahoo_packet_hash(pkt, "sssss", |
4298 1, purple_connection_get_display_name(gc), | 4298 1, purple_connection_get_display_name(gc), |
4299 69, alias, | 4299 69, alias, |
4300 5, who + 1, | 4300 5, who + 1, |
4301 68, carrier, | 4301 68, carrier, |
4306 g_free(msg2); | 4306 g_free(msg2); |
4307 | 4307 |
4308 return ret; | 4308 return ret; |
4309 } | 4309 } |
4310 | 4310 |
4311 pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE, 0); | 4311 pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE, yd->session_id); |
4312 if(msn) { | 4312 if(msn) { |
4313 yahoo_packet_hash(pkt, "ss", 1, purple_connection_get_display_name(gc), 5, who+4); | 4313 yahoo_packet_hash(pkt, "ss", 1, purple_connection_get_display_name(gc), 5, who+4); |
4314 yahoo_packet_hash_int(pkt, 241, 2); | 4314 yahoo_packet_hash_int(pkt, 241, 2); |
4315 } | 4315 } |
4316 else { | 4316 else { |
4388 | 4388 |
4389 /* Don't do anything if sms is being typed */ | 4389 /* Don't do anything if sms is being typed */ |
4390 if( strncmp(who, "+", 1) == 0 ) | 4390 if( strncmp(who, "+", 1) == 0 ) |
4391 return 0; | 4391 return 0; |
4392 | 4392 |
4393 pkt = yahoo_packet_new(YAHOO_SERVICE_NOTIFY, YAHOO_STATUS_TYPING, 0); | 4393 pkt = yahoo_packet_new(YAHOO_SERVICE_NOTIFY, YAHOO_STATUS_TYPING, yd->session_id); |
4394 | 4394 |
4395 /* check to see if p2p link exists, send through it */ | 4395 /* check to see if p2p link exists, send through it */ |
4396 if( (p2p_data = g_hash_table_lookup(yd->peers, who)) && !msn ) { | 4396 if( (p2p_data = g_hash_table_lookup(yd->peers, who)) && !msn ) { |
4397 yahoo_packet_hash(pkt, "sssssis", 49, "TYPING", 1, purple_connection_get_display_name(gc), | 4397 yahoo_packet_hash(pkt, "sssssis", 49, "TYPING", 1, purple_connection_get_display_name(gc), |
4398 14, " ", 13, state == PURPLE_TYPING ? "1" : "0", | 4398 14, " ", 13, state == PURPLE_TYPING ? "1" : "0", |
4460 g_free(tmp); | 4460 g_free(tmp); |
4461 } | 4461 } |
4462 } | 4462 } |
4463 | 4463 |
4464 if (yd->current_status == YAHOO_STATUS_INVISIBLE) { | 4464 if (yd->current_status == YAHOO_STATUS_INVISIBLE) { |
4465 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBLE_TOGGLE, YAHOO_STATUS_AVAILABLE, 0); | 4465 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBLE_TOGGLE, YAHOO_STATUS_AVAILABLE, yd->session_id); |
4466 yahoo_packet_hash_str(pkt, 13, "2"); | 4466 yahoo_packet_hash_str(pkt, 13, "2"); |
4467 yahoo_packet_send_and_free(pkt, yd); | 4467 yahoo_packet_send_and_free(pkt, yd); |
4468 | 4468 |
4469 return; | 4469 return; |
4470 } | 4470 } |
4471 | 4471 |
4472 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, YAHOO_STATUS_AVAILABLE, 0); | 4472 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, YAHOO_STATUS_AVAILABLE, yd->session_id); |
4473 yahoo_packet_hash_int(pkt, 10, yd->current_status); | 4473 yahoo_packet_hash_int(pkt, 10, yd->current_status); |
4474 | 4474 |
4475 if (yd->current_status == YAHOO_STATUS_CUSTOM) { | 4475 if (yd->current_status == YAHOO_STATUS_CUSTOM) { |
4476 yahoo_packet_hash_str(pkt, 97, utf8 ? "1" : 0); | 4476 yahoo_packet_hash_str(pkt, 97, utf8 ? "1" : 0); |
4477 yahoo_packet_hash_str(pkt, 19, conv_msg); | 4477 yahoo_packet_hash_str(pkt, 19, conv_msg); |
4487 yahoo_packet_hash_str(pkt, 47, "1"); | 4487 yahoo_packet_hash_str(pkt, 47, "1"); |
4488 | 4488 |
4489 yahoo_packet_send_and_free(pkt, yd); | 4489 yahoo_packet_send_and_free(pkt, yd); |
4490 | 4490 |
4491 if (old_status == YAHOO_STATUS_INVISIBLE) { | 4491 if (old_status == YAHOO_STATUS_INVISIBLE) { |
4492 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBLE_TOGGLE, YAHOO_STATUS_AVAILABLE, 0); | 4492 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBLE_TOGGLE, YAHOO_STATUS_AVAILABLE, yd->session_id); |
4493 yahoo_packet_hash_str(pkt, 13, "1"); | 4493 yahoo_packet_hash_str(pkt, 13, "1"); |
4494 yahoo_packet_send_and_free(pkt, yd); | 4494 yahoo_packet_send_and_free(pkt, yd); |
4495 | 4495 |
4496 /* Any per-session presence settings are removed */ | 4496 /* Any per-session presence settings are removed */ |
4497 g_hash_table_foreach(yd->friends, yahoo_session_presence_remove, NULL); | 4497 g_hash_table_foreach(yd->friends, yahoo_session_presence_remove, NULL); |
4511 else if (!idle && yd->current_status == YAHOO_STATUS_IDLE) { | 4511 else if (!idle && yd->current_status == YAHOO_STATUS_IDLE) { |
4512 status = purple_presence_get_active_status(purple_account_get_presence(purple_connection_get_account(gc))); | 4512 status = purple_presence_get_active_status(purple_account_get_presence(purple_connection_get_account(gc))); |
4513 yd->current_status = get_yahoo_status_from_purple_status(status); | 4513 yd->current_status = get_yahoo_status_from_purple_status(status); |
4514 } | 4514 } |
4515 | 4515 |
4516 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, YAHOO_STATUS_AVAILABLE, 0); | 4516 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, YAHOO_STATUS_AVAILABLE, yd->session_id); |
4517 | 4517 |
4518 yahoo_packet_hash_int(pkt, 10, yd->current_status); | 4518 yahoo_packet_hash_int(pkt, 10, yd->current_status); |
4519 if (yd->current_status == YAHOO_STATUS_CUSTOM) { | 4519 if (yd->current_status == YAHOO_STATUS_CUSTOM) { |
4520 const char *tmp; | 4520 const char *tmp; |
4521 if (status == NULL) | 4521 if (status == NULL) |
4617 /* The native client will only send PING or CHATPING */ | 4617 /* The native client will only send PING or CHATPING */ |
4618 if (yd->chat_online) { | 4618 if (yd->chat_online) { |
4619 if (yd->wm) { | 4619 if (yd->wm) { |
4620 ycht_chat_send_keepalive(yd->ycht); | 4620 ycht_chat_send_keepalive(yd->ycht); |
4621 } else { | 4621 } else { |
4622 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATPING, YAHOO_STATUS_AVAILABLE, 0); | 4622 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATPING, YAHOO_STATUS_AVAILABLE, yd->session_id); |
4623 yahoo_packet_hash_str(pkt, 109, purple_connection_get_display_name(gc)); | 4623 yahoo_packet_hash_str(pkt, 109, purple_connection_get_display_name(gc)); |
4624 yahoo_packet_send_and_free(pkt, yd); | 4624 yahoo_packet_send_and_free(pkt, yd); |
4625 } | 4625 } |
4626 } else { | 4626 } else { |
4627 pkt = yahoo_packet_new(YAHOO_SERVICE_PING, YAHOO_STATUS_AVAILABLE, 0); | 4627 pkt = yahoo_packet_new(YAHOO_SERVICE_PING, YAHOO_STATUS_AVAILABLE, yd->session_id); |
4628 yahoo_packet_send_and_free(pkt, yd); | 4628 yahoo_packet_send_and_free(pkt, yd); |
4629 } | 4629 } |
4630 } | 4630 } |
4631 | 4631 |
4632 if ((now - yd->last_keepalive) >= KEEPALIVE_TIMEOUT) { | 4632 if ((now - yd->last_keepalive) >= KEEPALIVE_TIMEOUT) { |
4633 yd->last_keepalive = now; | 4633 yd->last_keepalive = now; |
4634 pkt = yahoo_packet_new(YAHOO_SERVICE_KEEPALIVE, YAHOO_STATUS_AVAILABLE, 0); | 4634 pkt = yahoo_packet_new(YAHOO_SERVICE_KEEPALIVE, YAHOO_STATUS_AVAILABLE, yd->session_id); |
4635 yahoo_packet_hash_str(pkt, 0, purple_connection_get_display_name(gc)); | 4635 yahoo_packet_hash_str(pkt, 0, purple_connection_get_display_name(gc)); |
4636 yahoo_packet_send_and_free(pkt, yd); | 4636 yahoo_packet_send_and_free(pkt, yd); |
4637 } | 4637 } |
4638 | 4638 |
4639 } | 4639 } |
4663 group = purple_group_get_name(g); | 4663 group = purple_group_get_name(g); |
4664 else | 4664 else |
4665 group = "Buddies"; | 4665 group = "Buddies"; |
4666 | 4666 |
4667 group2 = yahoo_string_encode(gc, group, NULL); | 4667 group2 = yahoo_string_encode(gc, group, NULL); |
4668 pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, 0); | 4668 pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, yd->session_id); |
4669 if(msn) { | 4669 if(msn) { |
4670 yahoo_packet_hash(pkt, "sssssssssss", | 4670 yahoo_packet_hash(pkt, "sssssssssss", |
4671 14, "", | 4671 14, "", |
4672 65, group2, | 4672 65, group2, |
4673 97, "1", | 4673 97, "1", |
4735 | 4735 |
4736 if (remove) | 4736 if (remove) |
4737 g_hash_table_remove(yd->friends, bname); | 4737 g_hash_table_remove(yd->friends, bname); |
4738 | 4738 |
4739 cg = yahoo_string_encode(gc, gname, NULL); | 4739 cg = yahoo_string_encode(gc, gname, NULL); |
4740 pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, 0); | 4740 pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, yd->session_id); |
4741 | 4741 |
4742 if(msn) | 4742 if(msn) |
4743 yahoo_packet_hash(pkt, "sss", 1, purple_connection_get_display_name(gc), | 4743 yahoo_packet_hash(pkt, "sss", 1, purple_connection_get_display_name(gc), |
4744 7, bname+4, 65, cg); | 4744 7, bname+4, 65, cg); |
4745 else | 4745 else |
4759 return; | 4759 return; |
4760 | 4760 |
4761 if (!who || who[0] == '\0') | 4761 if (!who || who[0] == '\0') |
4762 return; | 4762 return; |
4763 | 4763 |
4764 pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, YAHOO_STATUS_AVAILABLE, 0); | 4764 pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, YAHOO_STATUS_AVAILABLE, yd->session_id); |
4765 yahoo_packet_hash(pkt, "sss", 1, purple_connection_get_display_name(gc), | 4765 yahoo_packet_hash(pkt, "sss", 1, purple_connection_get_display_name(gc), |
4766 7, who, 13, "1"); | 4766 7, who, 13, "1"); |
4767 yahoo_packet_send_and_free(pkt, yd); | 4767 yahoo_packet_send_and_free(pkt, yd); |
4768 } | 4768 } |
4769 | 4769 |
4775 return; | 4775 return; |
4776 | 4776 |
4777 if (!who || who[0] == '\0') | 4777 if (!who || who[0] == '\0') |
4778 return; | 4778 return; |
4779 | 4779 |
4780 pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, YAHOO_STATUS_AVAILABLE, 0); | 4780 pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, YAHOO_STATUS_AVAILABLE, yd->session_id); |
4781 yahoo_packet_hash(pkt, "sss", 1, purple_connection_get_display_name(gc), 7, who, 13, "2"); | 4781 yahoo_packet_hash(pkt, "sss", 1, purple_connection_get_display_name(gc), 7, who, 13, "2"); |
4782 yahoo_packet_send_and_free(pkt, yd); | 4782 yahoo_packet_send_and_free(pkt, yd); |
4783 } | 4783 } |
4784 | 4784 |
4785 void yahoo_set_permit_deny(PurpleConnection *gc) | 4785 void yahoo_set_permit_deny(PurpleConnection *gc) |
4838 g_free(gpn); | 4838 g_free(gpn); |
4839 g_free(gpo); | 4839 g_free(gpo); |
4840 return; | 4840 return; |
4841 } | 4841 } |
4842 | 4842 |
4843 pkt = yahoo_packet_new(YAHOO_SERVICE_CHGRP_15, YAHOO_STATUS_AVAILABLE, 0); | 4843 pkt = yahoo_packet_new(YAHOO_SERVICE_CHGRP_15, YAHOO_STATUS_AVAILABLE, yd->session_id); |
4844 if(f->protocol) | 4844 if(f->protocol) |
4845 yahoo_packet_hash(pkt, "ssssissss", 1, purple_connection_get_display_name(gc), | 4845 yahoo_packet_hash(pkt, "ssssissss", 1, purple_connection_get_display_name(gc), |
4846 302, "240", 300, "240", 7, temp, 241, f->protocol, 224, gpo, 264, gpn, 301, | 4846 302, "240", 300, "240", 7, temp, 241, f->protocol, 224, gpo, 264, gpn, 301, |
4847 "240", 303, "240"); | 4847 "240", 303, "240"); |
4848 else | 4848 else |
4868 g_free(gpn); | 4868 g_free(gpn); |
4869 g_free(gpo); | 4869 g_free(gpo); |
4870 return; | 4870 return; |
4871 } | 4871 } |
4872 | 4872 |
4873 pkt = yahoo_packet_new(YAHOO_SERVICE_GROUPRENAME, YAHOO_STATUS_AVAILABLE, 0); | 4873 pkt = yahoo_packet_new(YAHOO_SERVICE_GROUPRENAME, YAHOO_STATUS_AVAILABLE, yd->session_id); |
4874 yahoo_packet_hash(pkt, "sss", 1, purple_connection_get_display_name(gc), | 4874 yahoo_packet_hash(pkt, "sss", 1, purple_connection_get_display_name(gc), |
4875 65, gpo, 67, gpn); | 4875 65, gpo, 67, gpn); |
4876 yahoo_packet_send_and_free(pkt, yd); | 4876 yahoo_packet_send_and_free(pkt, yd); |
4877 g_free(gpn); | 4877 g_free(gpn); |
4878 g_free(gpo); | 4878 g_free(gpo); |