Changeset 4e04194 for protocols/yahoo/libyahoo2.c
- Timestamp:
- 2009-11-23T23:00:54Z (15 years ago)
- Branches:
- master
- Children:
- cd741d8
- Parents:
- b3117f2 (diff), fb51d85 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/yahoo/libyahoo2.c
rb3117f2 r4e04194 90 90 #include "base64.h" 91 91 #include "http_client.h" 92 93 static void yahoo_process_auth_response(struct http_request *req);94 92 95 93 #ifdef USE_STRUCT_CALLBACKS … … 212 210 YAHOO_SERVICE_CHATPING, 213 211 YAHOO_SERVICE_COMMENT = 0xa8, 214 YAHOO_SERVICE_GAME_INVITE = 0xb7, 215 YAHOO_SERVICE_STEALTH_PERM = 0xb9, 216 YAHOO_SERVICE_STEALTH_SESSION = 0xba, 217 YAHOO_SERVICE_AVATAR = 0xbc, 212 YAHOO_SERVICE_STEALTH = 0xb9, 218 213 YAHOO_SERVICE_PICTURE_CHECKSUM = 0xbd, 219 214 YAHOO_SERVICE_PICTURE = 0xbe, 220 215 YAHOO_SERVICE_PICTURE_UPDATE = 0xc1, 221 216 YAHOO_SERVICE_PICTURE_UPLOAD = 0xc2, 222 YAHOO_SERVICE_YAB_UPDATE = 0xc4, 223 YAHOO_SERVICE_Y6_VISIBLE_TOGGLE = 0xc5, /* YMSG13, key 13: 2 = invisible, 1 = visible */ 224 YAHOO_SERVICE_Y6_STATUS_UPDATE = 0xc6, /* YMSG13 */ 225 YAHOO_SERVICE_PICTURE_STATUS = 0xc7, /* YMSG13, key 213: 0 = none, 1 = avatar, 2 = picture */ 226 YAHOO_SERVICE_VERIFY_ID_EXISTS = 0xc8, 227 YAHOO_SERVICE_AUDIBLE = 0xd0, 228 YAHOO_SERVICE_Y7_PHOTO_SHARING = 0xd2, 229 YAHOO_SERVICE_Y7_CONTACT_DETAILS = 0xd3,/* YMSG13 */ 230 YAHOO_SERVICE_Y7_CHAT_SESSION = 0xd4, 231 YAHOO_SERVICE_Y7_AUTHORIZATION = 0xd6, /* YMSG13 */ 232 YAHOO_SERVICE_Y7_FILETRANSFER = 0xdc, /* YMSG13 */ 233 YAHOO_SERVICE_Y7_FILETRANSFERINFO, /* YMSG13 */ 234 YAHOO_SERVICE_Y7_FILETRANSFERACCEPT, /* YMSG13 */ 235 YAHOO_SERVICE_Y7_MINGLE = 0xe1, /* YMSG13 */ 236 YAHOO_SERVICE_Y7_CHANGE_GROUP = 0xe7, /* YMSG13 */ 237 YAHOO_SERVICE_Y8_STATUS = 0xf0, /* YMSG15 */ 238 YAHOO_SERVICE_Y8_LIST = 0Xf1, /* YMSG15 */ 239 YAHOO_SERVICE_WEBLOGIN = 0x0226, 240 YAHOO_SERVICE_SMS_MSG = 0x02ea 217 YAHOO_SERVICE_Y6_VISIBILITY=0xc5, 218 YAHOO_SERVICE_Y6_STATUS_UPDATE=0xc6, 219 YAHOO_PHOTOSHARE_INIT=0xd2, 220 YAHOO_SERVICE_CONTACT_YMSG13=0xd6, 221 YAHOO_PHOTOSHARE_PREV=0xd7, 222 YAHOO_PHOTOSHARE_KEY=0xd8, 223 YAHOO_PHOTOSHARE_TRANS=0xda, 224 YAHOO_FILE_TRANSFER_INIT_YMSG13=0xdc, 225 YAHOO_FILE_TRANSFER_GET_YMSG13=0xdd, 226 YAHOO_FILE_TRANSFER_PUT_YMSG13=0xde, 227 YAHOO_SERVICE_YMSG15_STATUS=0xf0, 228 YAHOO_SERVICE_YMSG15_BUDDY_LIST=0xf1, 241 229 }; 242 230 … … 776 764 yahoo_send_data(yid->fd, data, len); 777 765 else 778 yahoo_add_to_send_queue(yid, data, len);766 yahoo_add_to_send_queue(yid, data, len); 779 767 FREE(data); 780 768 } … … 1496 1484 1497 1485 if (u->name != NULL) { 1498 if (pkt->service == YAHOO_SERVICE_LOGOFF || u->flags == 0) {1486 if (pkt->service == YAHOO_SERVICE_LOGOFF) { /* || u->flags == 0) { Not in YMSG16 */ 1499 1487 YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, u->name, YAHOO_STATUS_OFFLINE, NULL, 1, 0, 0); 1500 1488 } else { 1489 /* Key 47 always seems to be 1 for YMSG16 */ 1490 if(!u->state) 1491 u->away = 0; 1492 else 1493 u->away = 1; 1494 1501 1495 YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, u->name, u->state, u->msg, u->away, u->idle, u->mobile); 1502 1496 } … … 2313 2307 } 2314 2308 2309 struct yahoo_https_auth_data 2310 { 2311 struct yahoo_input_data *yid; 2312 char *token; 2313 char *chal; 2314 }; 2315 2316 static void yahoo_https_auth_token_init(struct yahoo_https_auth_data *had); 2317 static void yahoo_https_auth_token_finish(struct http_request *req); 2318 static void yahoo_https_auth_init(struct yahoo_https_auth_data *had); 2319 static void yahoo_https_auth_finish(struct http_request *req); 2320 2321 /* Extract a value from a login.yahoo.com response. Assume CRLF-linebreaks 2322 and FAIL miserably if they're not there... */ 2323 static char *yahoo_ha_find_key(char *response, char *key) 2324 { 2325 char *s, *end; 2326 int len = strlen(key); 2327 2328 s = response; 2329 do { 2330 if (strncmp(s, key, len) == 0 && s[len] == '=') { 2331 s += len + 1; 2332 if ((end = strchr(s, '\r'))) 2333 return g_strndup(s, end - s); 2334 else 2335 return g_strdup(s); 2336 } 2337 2338 if ((s = strchr(s, '\n'))) 2339 s ++; 2340 } while (s && *s); 2341 2342 return NULL; 2343 } 2344 2345 static enum yahoo_status yahoo_https_status_parse(int code) 2346 { 2347 switch (code) 2348 { 2349 case 1212: return YAHOO_LOGIN_PASSWD; 2350 case 1213: return YAHOO_LOGIN_LOCK; 2351 case 1235: return YAHOO_LOGIN_UNAME; 2352 default: return (enum yahoo_status) code; 2353 } 2354 } 2355 2315 2356 static void yahoo_process_auth_0x10(struct yahoo_input_data *yid, const char *seed, const char *sn) 2316 2357 { 2358 struct yahoo_https_auth_data *had = g_new0(struct yahoo_https_auth_data, 1); 2359 2360 had->yid = yid; 2361 had->chal = g_strdup(seed); 2362 2363 yahoo_https_auth_token_init(had); 2364 } 2365 2366 static void yahoo_https_auth_token_init(struct yahoo_https_auth_data *had) 2367 { 2368 struct yahoo_input_data *yid = had->yid; 2369 struct yahoo_data *yd = yid->yd; 2370 struct http_request *req; 2371 char *login, *passwd, *chal; 2317 2372 char *url; 2318 2319 yid->yd->login_cookie = strdup(seed); 2320 2321 url = g_strdup_printf( 2322 "https://login.yahoo.com/config/pwtoken_get?" 2323 "src=ymsgr&ts=&login=%s&passwd=%s&chal=%s", 2324 yid->yd->user, yid->yd->password, seed); 2325 2326 http_dorequest_url(url, yahoo_process_auth_response, yid); 2373 2374 login = g_strndup(yd->user, 3 * strlen(yd->user)); 2375 http_encode(login); 2376 passwd = g_strndup(yd->password, 3 * strlen(yd->password)); 2377 http_encode(passwd); 2378 chal = g_strndup(had->chal, 3 * strlen(had->chal)); 2379 http_encode(chal); 2380 2381 url = g_strdup_printf("https://login.yahoo.com/config/pwtoken_get?src=ymsgr&ts=%d&login=%s&passwd=%s&chal=%s", 2382 (int) time(NULL), login, passwd, chal); 2383 2384 req = http_dorequest_url(url, yahoo_https_auth_token_finish, had); 2327 2385 2328 2386 g_free(url); 2387 g_free(chal); 2388 g_free(passwd); 2389 g_free(login); 2390 } 2391 2392 static void yahoo_https_auth_token_finish(struct http_request *req) 2393 { 2394 struct yahoo_https_auth_data *had = req->data; 2395 struct yahoo_input_data *yid = had->yid; 2396 struct yahoo_data *yd = yid->yd; 2397 int st; 2398 2399 if (req->status_code != 200) { 2400 YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, 2000 + req->status_code, NULL); 2401 goto fail; 2402 } 2403 2404 if (sscanf(req->reply_body, "%d", &st) != 1 || st != 0) { 2405 YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, yahoo_https_status_parse(st), NULL); 2406 goto fail; 2407 } 2408 2409 if ((had->token = yahoo_ha_find_key(req->reply_body, "ymsgr")) == NULL) { 2410 YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, 3001, NULL); 2411 goto fail; 2412 } 2413 2414 return yahoo_https_auth_init(had); 2415 2416 fail: 2417 g_free(had->token); 2418 g_free(had->chal); 2419 g_free(had); 2420 } 2421 2422 static void yahoo_https_auth_init(struct yahoo_https_auth_data *had) 2423 { 2424 struct http_request *req; 2425 char *url; 2426 2427 url = g_strdup_printf("https://login.yahoo.com/config/pwtoken_login?src=ymsgr&ts=%d&token=%s", 2428 (int) time(NULL), had->token); 2429 2430 req = http_dorequest_url(url, yahoo_https_auth_finish, had); 2431 2432 g_free(url); 2433 } 2434 2435 static void yahoo_https_auth_finish(struct http_request *req) 2436 { 2437 struct yahoo_https_auth_data *had = req->data; 2438 struct yahoo_input_data *yid = had->yid; 2439 struct yahoo_data *yd = yid->yd; 2440 struct yahoo_packet *pack; 2441 char *crumb; 2442 int st; 2443 2444 md5_byte_t result[16]; 2445 md5_state_t ctx; 2446 2447 unsigned char yhash[32]; 2448 2449 if (req->status_code != 200) { 2450 YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, 2000 + req->status_code, NULL); 2451 goto fail; 2452 } 2453 2454 if (sscanf(req->reply_body, "%d", &st) != 1 || st != 0) { 2455 YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, yahoo_https_status_parse(st), NULL); 2456 goto fail; 2457 } 2458 2459 if ((yd->cookie_y = yahoo_ha_find_key(req->reply_body, "Y")) == NULL || 2460 (yd->cookie_t = yahoo_ha_find_key(req->reply_body, "T")) == NULL || 2461 (crumb = yahoo_ha_find_key(req->reply_body, "crumb")) == NULL) { 2462 YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, 3002, NULL); 2463 goto fail; 2464 } 2465 2466 md5_init(&ctx); 2467 md5_append(&ctx, (unsigned char*) crumb, 11); 2468 md5_append(&ctx, (unsigned char*) had->chal, strlen(had->chal)); 2469 md5_finish(&ctx, result); 2470 to_y64(yhash, result, 16); 2471 2472 pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, yd->initial_status, yd->session_id); 2473 yahoo_packet_hash(pack, 1, yd->user); 2474 yahoo_packet_hash(pack, 0, yd->user); 2475 yahoo_packet_hash(pack, 277, yd->cookie_y); 2476 yahoo_packet_hash(pack, 278, yd->cookie_t); 2477 yahoo_packet_hash(pack, 307, (char*) yhash); 2478 yahoo_packet_hash(pack, 244, "524223"); 2479 yahoo_packet_hash(pack, 2, yd->user); 2480 yahoo_packet_hash(pack, 2, "1"); 2481 yahoo_packet_hash(pack, 98, "us"); 2482 yahoo_packet_hash(pack, 135, "7.5.0.647"); 2483 2484 yahoo_send_packet(yid, pack, 0); 2485 2486 yahoo_packet_free(pack); 2487 2488 fail: 2489 g_free(crumb); 2490 g_free(had->token); 2491 g_free(had->chal); 2492 g_free(had); 2329 2493 } 2330 2494 … … 2358 2522 break; 2359 2523 case 2: 2360 /* HTTPS */2361 2524 yahoo_process_auth_0x10(yid, seed, sn); 2362 2525 break; … … 2515 2678 2516 2679 yd->buddies = y_list_append(yd->buddies, bud); 2517 2680 2518 2681 /* Possibly called already, but at least the call above doesn't 2519 2682 seem to happen every time (not anytime I tried). */ … … 2522 2685 2523 2686 /* YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, who, status, NULL, (status==YAHOO_STATUS_AVAILABLE?0:1)); */ 2687 } 2688 2689 static void yahoo_process_contact_ymsg13(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 2690 { 2691 char* who=NULL; 2692 char* me=NULL; 2693 char* msg=NULL; 2694 YList *l; 2695 for (l = pkt->hash; l; l = l->next) { 2696 struct yahoo_pair *pair = l->data; 2697 if (pair->key == 4) 2698 who = pair->value; 2699 else if (pair->key == 5) 2700 me = pair->value; 2701 else 2702 DEBUG_MSG(("unknown key: %d = %s", pair->key, pair->value)); 2703 } 2704 2705 if(pkt->status==3) 2706 YAHOO_CALLBACK(ext_yahoo_contact_auth_request)(yid->yd->client_id, me, who, msg); 2524 2707 } 2525 2708 … … 2735 2918 2736 2919 YList *l; 2737 yahoo_dump_unhandled(pkt);2920 // yahoo_dump_unhandled(pkt); 2738 2921 for (l = pkt->hash; l; l = l->next) { 2739 2922 struct yahoo_pair *pair = l->data; … … 2757 2940 { 2758 2941 DEBUG_MSG(("yahoo_packet_process: 0x%02x", pkt->service)); 2942 yahoo_dump_unhandled(pkt); 2759 2943 switch (pkt->service) 2760 2944 { … … 2769 2953 case YAHOO_SERVICE_IDDEACT: 2770 2954 case YAHOO_SERVICE_Y6_STATUS_UPDATE: 2771 case YAHOO_SERVICE_Y 8_STATUS:2955 case YAHOO_SERVICE_YMSG15_STATUS: 2772 2956 yahoo_process_status(yid, pkt); 2773 2957 break; … … 2783 2967 yahoo_process_mail(yid, pkt); 2784 2968 break; 2969 case YAHOO_SERVICE_REJECTCONTACT: 2785 2970 case YAHOO_SERVICE_NEWCONTACT: 2786 2971 yahoo_process_contact(yid, pkt); … … 2823 3008 yahoo_process_buddyadd(yid, pkt); 2824 3009 break; 3010 case YAHOO_SERVICE_CONTACT_YMSG13: 3011 yahoo_process_contact_ymsg13(yid,pkt); 3012 break; 2825 3013 case YAHOO_SERVICE_REMBUDDY: 2826 3014 yahoo_process_buddydel(yid, pkt); … … 2851 3039 case YAHOO_SERVICE_CHATLOGOFF: 2852 3040 case YAHOO_SERVICE_CHATMSG: 2853 case YAHOO_SERVICE_REJECTCONTACT:2854 3041 case YAHOO_SERVICE_PEERTOPEER: 2855 3042 WARNING(("unhandled service 0x%02x", pkt->service)); … … 2865 3052 yahoo_process_picture_upload(yid, pkt); 2866 3053 break; 2867 case YAHOO_SERVICE_Y 8_LIST: /* Buddy List */3054 case YAHOO_SERVICE_YMSG15_BUDDY_LIST: /* Buddy List */ 2868 3055 yahoo_process_buddy_list(yid, pkt); 2869 3056 default: … … 3643 3830 } 3644 3831 3645 /* #define LOG(x...) printf x */3646 3647 static void yahoo_process_auth_response(struct http_request *req)3648 {3649 char *line_end;3650 char *token;3651 char *cookie;3652 3653 int error_code = 0;3654 int is_ymsgr = 0;3655 3656 struct yahoo_input_data *yid = req->data;3657 3658 char crypt_hash[25];3659 3660 md5_byte_t result[16];3661 md5_state_t ctx;3662 3663 struct yahoo_packet *packet = NULL;3664 3665 if (y_list_find(inputs, yid) == NULL)3666 return;3667 3668 if (req->status_code != 200) {3669 error_code = 3000 + req->status_code;3670 goto FAIL;3671 }3672 3673 token = req->reply_body;3674 line_end = strstr(token, "\r\n");3675 3676 if (line_end) {3677 *line_end = '\0';3678 3679 line_end += 2;3680 }3681 3682 if (sscanf(token, "%d", &error_code) != 1) {3683 error_code = 3000;3684 goto FAIL;3685 }3686 3687 switch(error_code) {3688 case 0:3689 /* successful */3690 break;3691 3692 case 1212:3693 LOG(("Incorrect ID or password\n"));3694 error_code = YAHOO_LOGIN_PASSWD;3695 goto FAIL;3696 3697 case 1213:3698 LOG(("Security lock from too many failed login attempts\n"));3699 error_code = YAHOO_LOGIN_LOCK;3700 goto FAIL;3701 3702 case 1214:3703 LOG(("Security lock\n"));3704 goto FAIL;3705 3706 case 1235:3707 LOG(("User ID not taken yet\n"));3708 error_code = YAHOO_LOGIN_UNAME;3709 goto FAIL;3710 3711 case 1216:3712 LOG(("Seems to be a lock, but shows the same generic User ID/Password failure\n"));3713 goto FAIL;3714 3715 default:3716 /* Unknown error code */3717 LOG(("Unknown Error\n"));3718 goto FAIL;3719 }3720 3721 if ( !strncmp(line_end, "ymsgr=", 6) ) {3722 is_ymsgr = 1;3723 }3724 else if ( strncmp(line_end, "crumb=", 6) ) {3725 LOG(("Oops! There was no ymsgr=. Where do I get my token from now :("));3726 LOG(("I got this:\n\n%s\n",line_end));3727 error_code = 2201;3728 goto FAIL;3729 }3730 3731 token = line_end+6;3732 3733 line_end = strstr(token, "\r\n");3734 3735 if(line_end) {3736 *line_end = '\0';3737 line_end += 2;3738 }3739 3740 /* Go for the crumb */3741 if(is_ymsgr) {3742 char *url;3743 3744 url = g_strdup_printf(3745 "https://login.yahoo.com/config/pwtoken_login?"3746 "src=ymsgr&ts=&token=%s", token);3747 3748 http_dorequest_url(url, yahoo_process_auth_response, yid);3749 3750 g_free(url);3751 3752 return;3753 }3754 3755 /* token is actually crumb */3756 3757 if(!line_end) {3758 /* We did not get our cookies. Cry. */3759 }3760 3761 if((cookie = strstr(req->reply_headers, "Set-Cookie: Y=")) &&3762 (line_end = strstr(cookie + 14, "\r\n"))) {3763 *line_end = '\0';3764 yid->yd->cookie_y = strdup(cookie + 14);3765 *line_end = ';';3766 } else {3767 /* Cry. */3768 LOG(("NO Y Cookie!"));3769 error_code = 2202;3770 goto FAIL;3771 }3772 3773 if((cookie = strstr(req->reply_headers, "Set-Cookie: T=")) &&3774 (line_end = strstr(cookie + 14, "\r\n"))) {3775 *line_end = '\0';3776 yid->yd->cookie_t = strdup(cookie + 14);3777 *line_end = ';';3778 } else {3779 /* Cry. */3780 LOG(("NO T Cookie!"));3781 error_code = 2203;3782 goto FAIL;3783 }3784 3785 md5_init(&ctx);3786 md5_append(&ctx, (md5_byte_t *)token, strlen(token));3787 md5_append(&ctx, (md5_byte_t *)yid->yd->login_cookie, strlen(yid->yd->login_cookie));3788 md5_finish(&ctx, result);3789 3790 to_y64((unsigned char*)crypt_hash, result, 16);3791 3792 packet = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, yid->yd->initial_status, yid->yd->session_id);3793 yahoo_packet_hash(packet, 1, yid->yd->user);3794 yahoo_packet_hash(packet, 0, yid->yd->user);3795 yahoo_packet_hash(packet, 277, yid->yd->cookie_y);3796 yahoo_packet_hash(packet, 278, yid->yd->cookie_t);3797 yahoo_packet_hash(packet, 307, crypt_hash);3798 yahoo_packet_hash(packet, 244, "2097087"); /* Rekkanoryo says this is the build number */3799 yahoo_packet_hash(packet, 2, yid->yd->user);3800 yahoo_packet_hash(packet, 2, "1");3801 yahoo_packet_hash(packet, 98, "us"); /* TODO Put country code */3802 yahoo_packet_hash(packet, 135, "9.0.0.1389");3803 3804 yahoo_send_packet(yid, packet, 0);3805 3806 yahoo_packet_free(packet);3807 3808 /* We don't need this anymore */3809 free(yid->yd->login_cookie);3810 yid->yd->login_cookie = NULL;3811 3812 return;3813 3814 FAIL:3815 YAHOO_CALLBACK(ext_yahoo_login_response)(yid->yd->client_id, error_code, NULL);3816 }3817 3818 3819 3832 static void (*yahoo_process_connection[])(struct yahoo_input_data *, int over) = { 3820 3833 yahoo_process_pager_connection, … … 4045 4058 4046 4059 yahoo_packet_hash(pkt, 5, who); 4047 yahoo_packet_hash(pkt, 4, from?from:yd->user);4060 yahoo_packet_hash(pkt, 1, from?from:yd->user); 4048 4061 yahoo_packet_hash(pkt, 14, " "); 4049 4062 yahoo_packet_hash(pkt, 13, typ ? "1" : "0"); … … 4060 4073 struct yahoo_data *yd; 4061 4074 struct yahoo_packet *pkt = NULL; 4062 int service;4075 int old_status; 4063 4076 char s[4]; 4064 4077 … … 4068 4081 yd = yid->yd; 4069 4082 4070 if (msg) { 4083 old_status = yd->current_status; 4084 4085 if (msg && strncmp(msg,"Invisible",9)) { 4071 4086 yd->current_status = YAHOO_STATUS_CUSTOM; 4072 4087 } else { … … 4074 4089 } 4075 4090 4076 if (yd->current_status == YAHOO_STATUS_AVAILABLE) 4077 service = YAHOO_SERVICE_ISBACK; 4078 else 4079 service = YAHOO_SERVICE_ISAWAY; 4091 /* Thank you libpurple :) */ 4092 if (yd->current_status == YAHOO_STATUS_INVISIBLE) { 4093 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBILITY, YAHOO_STATUS_AVAILABLE, 0); 4094 yahoo_packet_hash(pkt, 13, "2"); 4095 yahoo_send_packet(yid, pkt, 0); 4096 yahoo_packet_free(pkt); 4097 4098 return; 4099 } 4100 4101 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, yd->current_status, yd->session_id); 4102 snprintf(s, sizeof(s), "%d", yd->current_status); 4103 yahoo_packet_hash(pkt, 10, s); 4080 4104 4081 if ((away == 2) && (yd->current_status == YAHOO_STATUS_AVAILABLE)) { 4082 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_BRB, yd->session_id); 4083 yahoo_packet_hash(pkt, 10, "999"); 4084 yahoo_packet_hash(pkt, 47, "2"); 4085 }else { 4086 pkt = yahoo_packet_new(service, YAHOO_STATUS_AVAILABLE, yd->session_id); 4087 snprintf(s, sizeof(s), "%d", yd->current_status); 4088 yahoo_packet_hash(pkt, 10, s); 4089 if (yd->current_status == YAHOO_STATUS_CUSTOM) { 4090 yahoo_packet_hash(pkt, 19, msg); 4091 yahoo_packet_hash(pkt, 47, (away == 2)? "2": (away) ?"1":"0"); 4092 } else { 4093 yahoo_packet_hash(pkt, 47, (away == 2)? "2": (away) ?"1":"0"); 4094 } 4095 4096 4097 4098 } 4105 if (yd->current_status == YAHOO_STATUS_CUSTOM) { 4106 yahoo_packet_hash(pkt, 19, msg); 4107 } else { 4108 yahoo_packet_hash(pkt, 19, ""); 4109 } 4110 4111 yahoo_packet_hash(pkt, 47, (away == 2)? "2": (away) ?"1":"0"); 4099 4112 4100 4113 yahoo_send_packet(yid, pkt, 0); 4101 4114 yahoo_packet_free(pkt); 4115 4116 if(old_status == YAHOO_STATUS_INVISIBLE) { 4117 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBILITY, YAHOO_STATUS_AVAILABLE, 0); 4118 yahoo_packet_hash(pkt, 13, "1"); 4119 yahoo_send_packet(yid, pkt, 0); 4120 yahoo_packet_free(pkt); 4121 } 4102 4122 } 4103 4123 … … 4114 4134 LOG(("yahoo_logoff: current status: %d", yd->current_status)); 4115 4135 4116 if(yd->current_status != -1) { 4136 if(yd->current_status != -1 && 0) { 4137 /* Meh. Don't send this. The event handlers are not going to 4138 get to do this so it'll just leak memory. And the TCP 4139 connection reset will hopefully be clear enough. */ 4117 4140 pkt = yahoo_packet_new(YAHOO_SERVICE_LOGOFF, YAHOO_STATUS_AVAILABLE, yd->session_id); 4118 4141 yd->current_status = -1; … … 4347 4370 return; 4348 4371 4349 pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, yd->session_id); 4350 yahoo_packet_hash(pkt, 1, yd->user); 4351 yahoo_packet_hash(pkt, 7, who); 4352 yahoo_packet_hash(pkt, 65, group); 4372 pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YPACKET_STATUS_DEFAULT, yd->session_id); 4373 4353 4374 if (msg != NULL) /* add message/request "it's me add me" */ 4354 4375 yahoo_packet_hash(pkt, 14, msg); 4376 else 4377 yahoo_packet_hash(pkt,14,""); 4378 4379 yahoo_packet_hash(pkt, 65, group); 4380 yahoo_packet_hash(pkt, 97, "1"); 4381 yahoo_packet_hash(pkt, 1, yd->user); 4382 yahoo_packet_hash(pkt, 302, "319"); 4383 yahoo_packet_hash(pkt, 300, "319"); 4384 yahoo_packet_hash(pkt, 7, who); 4385 yahoo_packet_hash(pkt, 334, "0"); 4386 yahoo_packet_hash(pkt, 301, "319"); 4387 yahoo_packet_hash(pkt, 303, "319"); 4388 4389 4355 4390 yahoo_send_packet(yid, pkt, 0); 4356 4391 yahoo_packet_free(pkt); … … 4374 4409 yahoo_send_packet(yid, pkt, 0); 4375 4410 yahoo_packet_free(pkt); 4411 } 4412 4413 void yahoo_accept_buddy_ymsg13(int id,const char* me,const char* who){ 4414 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4415 struct yahoo_data *yd; 4416 4417 if(!yid) 4418 return; 4419 yd = yid->yd; 4420 4421 struct yahoo_packet* pkt=NULL; 4422 pkt= yahoo_packet_new(YAHOO_SERVICE_CONTACT_YMSG13,YAHOO_STATUS_AVAILABLE,0); 4423 4424 yahoo_packet_hash(pkt,1,me ?: yd->user); 4425 yahoo_packet_hash(pkt,5,who); 4426 yahoo_packet_hash(pkt,13,"1"); 4427 yahoo_packet_hash(pkt,334,"0"); 4428 yahoo_send_packet(yid, pkt, 0); 4429 yahoo_packet_free(pkt); 4430 } 4431 4432 void yahoo_reject_buddy_ymsg13(int id,const char* me,const char* who,const char* msg){ 4433 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4434 struct yahoo_data *yd; 4435 4436 if(!yid) 4437 return; 4438 yd = yid->yd; 4439 4440 struct yahoo_packet* pkt=NULL; 4441 pkt= yahoo_packet_new(YAHOO_SERVICE_CONTACT_YMSG13,YAHOO_STATUS_AVAILABLE,0); 4442 4443 yahoo_packet_hash(pkt,1,me ?: yd->user); 4444 yahoo_packet_hash(pkt,5,who); 4445 // yahoo_packet_hash(pkt,241,YAHOO_PROTO_VER); 4446 yahoo_packet_hash(pkt,13,"2"); 4447 yahoo_packet_hash(pkt,334,"0"); 4448 yahoo_packet_hash(pkt,97,"1"); 4449 yahoo_packet_hash(pkt,14,msg?:""); 4450 4451 yahoo_send_packet(yid, pkt, 0); 4452 yahoo_packet_free(pkt); 4453 4376 4454 } 4377 4455 … … 4431 4509 return; 4432 4510 4433 pkt = yahoo_packet_new(YAHOO_SERVICE_STEALTH _PERM, YAHOO_STATUS_AVAILABLE, yd->session_id);4511 pkt = yahoo_packet_new(YAHOO_SERVICE_STEALTH, YAHOO_STATUS_AVAILABLE, yd->session_id); 4434 4512 yahoo_packet_hash(pkt, 1, yd->user); 4435 4513 yahoo_packet_hash(pkt, 7, who);
Note: See TracChangeset
for help on using the changeset viewer.