Changeset 3f81999 for protocols/yahoo
- Timestamp:
- 2010-06-03T10:31:46Z (15 years ago)
- Branches:
- master
- Children:
- 5f8ab6a9
- Parents:
- fc34fb5 (diff), 2e44b1f (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. - Location:
- protocols/yahoo
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/yahoo/libyahoo2.c
rfc34fb5 r3f81999 91 91 92 92 #include "base64.h" 93 #include "http_client.h" 93 94 94 95 #ifdef USE_STRUCT_CALLBACKS … … 171 172 YAHOO_SERVICE_GOTGROUPRENAME, /* < 1, 36(old), 37(new) */ 172 173 YAHOO_SERVICE_SYSMESSAGE = 0x14, 174 YAHOO_SERVICE_SKINNAME = 0x15, 173 175 YAHOO_SERVICE_PASSTHROUGH2 = 0x16, 174 176 YAHOO_SERVICE_CONFINVITE = 0x18, … … 194 196 YAHOO_SERVICE_LIST, 195 197 YAHOO_SERVICE_AUTH = 0x57, 198 YAHOO_SERVICE_AUTHBUDDY = 0x6d, 196 199 YAHOO_SERVICE_ADDBUDDY = 0x83, 197 200 YAHOO_SERVICE_REMBUDDY, … … 199 202 YAHOO_SERVICE_REJECTCONTACT, 200 203 YAHOO_SERVICE_GROUPRENAME = 0x89, /* > 1, 65(new), 66(0), 67(old) */ 204 YAHOO_SERVICE_Y7_PING = 0x8A, /* 0 - id and that's it?? */ 201 205 YAHOO_SERVICE_CHATONLINE = 0x96, /* > 109(id), 1, 6(abcde) < 0,1*/ 202 206 YAHOO_SERVICE_CHATGOTO, … … 204 208 YAHOO_SERVICE_CHATLEAVE, 205 209 YAHOO_SERVICE_CHATEXIT = 0x9b, 210 YAHOO_SERVICE_CHATADDINVITE = 0x9d, 206 211 YAHOO_SERVICE_CHATLOGOUT = 0xa0, 207 212 YAHOO_SERVICE_CHATPING, … … 211 216 YAHOO_SERVICE_PICTURE = 0xbe, 212 217 YAHOO_SERVICE_PICTURE_UPDATE = 0xc1, 213 YAHOO_SERVICE_PICTURE_UPLOAD = 0xc2 218 YAHOO_SERVICE_PICTURE_UPLOAD = 0xc2, 219 YAHOO_SERVICE_Y6_VISIBILITY=0xc5, 220 YAHOO_SERVICE_Y6_STATUS_UPDATE=0xc6, 221 YAHOO_PHOTOSHARE_INIT=0xd2, 222 YAHOO_SERVICE_CONTACT_YMSG13=0xd6, 223 YAHOO_PHOTOSHARE_PREV=0xd7, 224 YAHOO_PHOTOSHARE_KEY=0xd8, 225 YAHOO_PHOTOSHARE_TRANS=0xda, 226 YAHOO_FILE_TRANSFER_INIT_YMSG13=0xdc, 227 YAHOO_FILE_TRANSFER_GET_YMSG13=0xdd, 228 YAHOO_FILE_TRANSFER_PUT_YMSG13=0xde, 229 YAHOO_SERVICE_YMSG15_STATUS=0xf0, 230 YAHOO_SERVICE_YMSG15_BUDDY_LIST=0xf1, 214 231 }; 215 232 … … 735 752 736 753 memcpy(data + pos, "YMSG", 4); pos += 4; 737 pos += yahoo_put16(data + pos, 0x000c);754 pos += yahoo_put16(data + pos, YAHOO_PROTO_VER); 738 755 pos += yahoo_put16(data + pos, 0x0000); 739 756 pos += yahoo_put16(data + pos, pktlen + extra_pad); … … 749 766 yahoo_send_data(yid->fd, data, len); 750 767 else 751 yahoo_add_to_send_queue(yid, data, len);768 yahoo_add_to_send_queue(yid, data, len); 752 769 FREE(data); 753 770 } … … 1469 1486 1470 1487 if (u->name != NULL) { 1471 if (pkt->service == YAHOO_SERVICE_LOGOFF || u->flags == 0) {1488 if (pkt->service == YAHOO_SERVICE_LOGOFF) { /* || u->flags == 0) { Not in YMSG16 */ 1472 1489 YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, u->name, YAHOO_STATUS_OFFLINE, NULL, 1, 0, 0); 1473 1490 } else { 1491 /* Key 47 always seems to be 1 for YMSG16 */ 1492 if(!u->state) 1493 u->away = 0; 1494 else 1495 u->away = 1; 1496 1474 1497 YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, u->name, u->state, u->msg, u->away, u->idle, u->mobile); 1475 1498 } … … 1479 1502 y_list_free_1(t); 1480 1503 FREE(u); 1504 } 1505 } 1506 1507 static void yahoo_process_buddy_list(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 1508 { 1509 struct yahoo_data *yd = yid->yd; 1510 YList *l; 1511 int last_packet = 0; 1512 char *cur_group = NULL; 1513 struct yahoo_buddy *newbud = NULL; 1514 1515 /* we could be getting multiple packets here */ 1516 for (l = pkt->hash; l; l = l->next) { 1517 struct yahoo_pair *pair = l->data; 1518 1519 switch(pair->key) { 1520 case 300: 1521 case 301: 1522 case 302: 1523 case 303: 1524 if ( 315 == atoi(pair->value) ) 1525 last_packet = 1; 1526 break; 1527 case 65: 1528 g_free(cur_group); 1529 cur_group = strdup(pair->value); 1530 break; 1531 case 7: 1532 newbud = y_new0(struct yahoo_buddy, 1); 1533 newbud->id = strdup(pair->value); 1534 if(cur_group) 1535 newbud->group = strdup(cur_group); 1536 else { 1537 struct yahoo_buddy *lastbud = (struct yahoo_buddy *)y_list_nth( 1538 yd->buddies, y_list_length(yd->buddies)-1)->data; 1539 newbud->group = strdup(lastbud->group); 1540 } 1541 1542 yd->buddies = y_list_append(yd->buddies, newbud); 1543 1544 break; 1545 } 1546 } 1547 1548 g_free(cur_group); 1549 1550 /* we could be getting multiple packets here */ 1551 if (last_packet) 1552 return; 1553 1554 YAHOO_CALLBACK(ext_yahoo_got_buddies)(yd->client_id, yd->buddies); 1555 1556 /*** We login at the very end of the packet communication */ 1557 if (!yd->logged_in) { 1558 yd->logged_in = TRUE; 1559 if(yd->current_status < 0) 1560 yd->current_status = yd->initial_status; 1561 YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, YAHOO_LOGIN_OK, NULL); 1481 1562 } 1482 1563 } … … 1551 1632 } 1552 1633 1553 if(yd->cookie_y && yd->cookie_t && yd->cookie_c)1634 if(yd->cookie_y && yd->cookie_t) 1554 1635 YAHOO_CALLBACK(ext_yahoo_got_cookies)(yd->client_id); 1555 1636 … … 2228 2309 } 2229 2310 2311 struct yahoo_https_auth_data 2312 { 2313 struct yahoo_input_data *yid; 2314 char *token; 2315 char *chal; 2316 }; 2317 2318 static void yahoo_https_auth_token_init(struct yahoo_https_auth_data *had); 2319 static void yahoo_https_auth_token_finish(struct http_request *req); 2320 static void yahoo_https_auth_init(struct yahoo_https_auth_data *had); 2321 static void yahoo_https_auth_finish(struct http_request *req); 2322 2323 /* Extract a value from a login.yahoo.com response. Assume CRLF-linebreaks 2324 and FAIL miserably if they're not there... */ 2325 static char *yahoo_ha_find_key(char *response, char *key) 2326 { 2327 char *s, *end; 2328 int len = strlen(key); 2329 2330 s = response; 2331 do { 2332 if (strncmp(s, key, len) == 0 && s[len] == '=') { 2333 s += len + 1; 2334 if ((end = strchr(s, '\r'))) 2335 return g_strndup(s, end - s); 2336 else 2337 return g_strdup(s); 2338 } 2339 2340 if ((s = strchr(s, '\n'))) 2341 s ++; 2342 } while (s && *s); 2343 2344 return NULL; 2345 } 2346 2347 static enum yahoo_status yahoo_https_status_parse(int code) 2348 { 2349 switch (code) 2350 { 2351 case 1212: return YAHOO_LOGIN_PASSWD; 2352 case 1213: return YAHOO_LOGIN_LOCK; 2353 case 1235: return YAHOO_LOGIN_UNAME; 2354 default: return (enum yahoo_status) code; 2355 } 2356 } 2357 2358 static void yahoo_process_auth_0x10(struct yahoo_input_data *yid, const char *seed, const char *sn) 2359 { 2360 struct yahoo_https_auth_data *had = g_new0(struct yahoo_https_auth_data, 1); 2361 2362 had->yid = yid; 2363 had->chal = g_strdup(seed); 2364 2365 yahoo_https_auth_token_init(had); 2366 } 2367 2368 static void yahoo_https_auth_token_init(struct yahoo_https_auth_data *had) 2369 { 2370 struct yahoo_input_data *yid = had->yid; 2371 struct yahoo_data *yd = yid->yd; 2372 struct http_request *req; 2373 char *login, *passwd, *chal; 2374 char *url; 2375 2376 login = g_strndup(yd->user, 3 * strlen(yd->user)); 2377 http_encode(login); 2378 passwd = g_strndup(yd->password, 3 * strlen(yd->password)); 2379 http_encode(passwd); 2380 chal = g_strndup(had->chal, 3 * strlen(had->chal)); 2381 http_encode(chal); 2382 2383 url = g_strdup_printf("https://login.yahoo.com/config/pwtoken_get?src=ymsgr&ts=%d&login=%s&passwd=%s&chal=%s", 2384 (int) time(NULL), login, passwd, chal); 2385 2386 req = http_dorequest_url(url, yahoo_https_auth_token_finish, had); 2387 2388 g_free(url); 2389 g_free(chal); 2390 g_free(passwd); 2391 g_free(login); 2392 } 2393 2394 static void yahoo_https_auth_token_finish(struct http_request *req) 2395 { 2396 struct yahoo_https_auth_data *had = req->data; 2397 struct yahoo_input_data *yid = had->yid; 2398 struct yahoo_data *yd = yid->yd; 2399 int st; 2400 2401 if (req->status_code != 200) { 2402 YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, 2000 + req->status_code, NULL); 2403 goto fail; 2404 } 2405 2406 if (sscanf(req->reply_body, "%d", &st) != 1 || st != 0) { 2407 YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, yahoo_https_status_parse(st), NULL); 2408 goto fail; 2409 } 2410 2411 if ((had->token = yahoo_ha_find_key(req->reply_body, "ymsgr")) == NULL) { 2412 YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, 3001, NULL); 2413 goto fail; 2414 } 2415 2416 return yahoo_https_auth_init(had); 2417 2418 fail: 2419 g_free(had->token); 2420 g_free(had->chal); 2421 g_free(had); 2422 } 2423 2424 static void yahoo_https_auth_init(struct yahoo_https_auth_data *had) 2425 { 2426 struct http_request *req; 2427 char *url; 2428 2429 url = g_strdup_printf("https://login.yahoo.com/config/pwtoken_login?src=ymsgr&ts=%d&token=%s", 2430 (int) time(NULL), had->token); 2431 2432 req = http_dorequest_url(url, yahoo_https_auth_finish, had); 2433 2434 g_free(url); 2435 } 2436 2437 static void yahoo_https_auth_finish(struct http_request *req) 2438 { 2439 struct yahoo_https_auth_data *had = req->data; 2440 struct yahoo_input_data *yid = had->yid; 2441 struct yahoo_data *yd = yid->yd; 2442 struct yahoo_packet *pack; 2443 char *crumb; 2444 int st; 2445 2446 md5_byte_t result[16]; 2447 md5_state_t ctx; 2448 2449 unsigned char yhash[32]; 2450 2451 if (req->status_code != 200) { 2452 YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, 2000 + req->status_code, NULL); 2453 goto fail; 2454 } 2455 2456 if (sscanf(req->reply_body, "%d", &st) != 1 || st != 0) { 2457 YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, yahoo_https_status_parse(st), NULL); 2458 goto fail; 2459 } 2460 2461 if ((yd->cookie_y = yahoo_ha_find_key(req->reply_body, "Y")) == NULL || 2462 (yd->cookie_t = yahoo_ha_find_key(req->reply_body, "T")) == NULL || 2463 (crumb = yahoo_ha_find_key(req->reply_body, "crumb")) == NULL) { 2464 YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, 3002, NULL); 2465 goto fail; 2466 } 2467 2468 md5_init(&ctx); 2469 md5_append(&ctx, (unsigned char*) crumb, 11); 2470 md5_append(&ctx, (unsigned char*) had->chal, strlen(had->chal)); 2471 md5_finish(&ctx, result); 2472 to_y64(yhash, result, 16); 2473 2474 pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, yd->initial_status, yd->session_id); 2475 yahoo_packet_hash(pack, 1, yd->user); 2476 yahoo_packet_hash(pack, 0, yd->user); 2477 yahoo_packet_hash(pack, 277, yd->cookie_y); 2478 yahoo_packet_hash(pack, 278, yd->cookie_t); 2479 yahoo_packet_hash(pack, 307, (char*) yhash); 2480 yahoo_packet_hash(pack, 244, "524223"); 2481 yahoo_packet_hash(pack, 2, yd->user); 2482 yahoo_packet_hash(pack, 2, "1"); 2483 yahoo_packet_hash(pack, 98, "us"); 2484 yahoo_packet_hash(pack, 135, "7.5.0.647"); 2485 2486 yahoo_send_packet(yid, pack, 0); 2487 2488 yahoo_packet_free(pack); 2489 2490 fail: 2491 g_free(crumb); 2492 g_free(had->token); 2493 g_free(had->chal); 2494 g_free(had); 2495 } 2496 2230 2497 static void yahoo_process_auth(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 2231 2498 { … … 2255 2522 case 1: 2256 2523 yahoo_process_auth_0x0b(yid, seed, sn); 2524 break; 2525 case 2: 2526 yahoo_process_auth_0x10(yid, seed, sn); 2257 2527 break; 2258 2528 default: … … 2410 2680 2411 2681 yd->buddies = y_list_append(yd->buddies, bud); 2412 2682 2413 2683 /* Possibly called already, but at least the call above doesn't 2414 2684 seem to happen every time (not anytime I tried). */ … … 2417 2687 2418 2688 /* YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, who, status, NULL, (status==YAHOO_STATUS_AVAILABLE?0:1)); */ 2689 } 2690 2691 static void yahoo_process_contact_ymsg13(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 2692 { 2693 char* who=NULL; 2694 char* me=NULL; 2695 char* msg=NULL; 2696 YList *l; 2697 for (l = pkt->hash; l; l = l->next) { 2698 struct yahoo_pair *pair = l->data; 2699 if (pair->key == 4) 2700 who = pair->value; 2701 else if (pair->key == 5) 2702 me = pair->value; 2703 else 2704 DEBUG_MSG(("unknown key: %d = %s", pair->key, pair->value)); 2705 } 2706 2707 if(pkt->status==3) 2708 YAHOO_CALLBACK(ext_yahoo_contact_auth_request)(yid->yd->client_id, me, who, msg); 2419 2709 } 2420 2710 … … 2630 2920 2631 2921 YList *l; 2632 yahoo_dump_unhandled(pkt);2922 // yahoo_dump_unhandled(pkt); 2633 2923 for (l = pkt->hash; l; l = l->next) { 2634 2924 struct yahoo_pair *pair = l->data; … … 2652 2942 { 2653 2943 DEBUG_MSG(("yahoo_packet_process: 0x%02x", pkt->service)); 2944 yahoo_dump_unhandled(pkt); 2654 2945 switch (pkt->service) 2655 2946 { … … 2663 2954 case YAHOO_SERVICE_IDACT: 2664 2955 case YAHOO_SERVICE_IDDEACT: 2956 case YAHOO_SERVICE_Y6_STATUS_UPDATE: 2957 case YAHOO_SERVICE_YMSG15_STATUS: 2665 2958 yahoo_process_status(yid, pkt); 2666 2959 break; … … 2676 2969 yahoo_process_mail(yid, pkt); 2677 2970 break; 2971 case YAHOO_SERVICE_REJECTCONTACT: 2678 2972 case YAHOO_SERVICE_NEWCONTACT: 2679 2973 yahoo_process_contact(yid, pkt); … … 2716 3010 yahoo_process_buddyadd(yid, pkt); 2717 3011 break; 3012 case YAHOO_SERVICE_CONTACT_YMSG13: 3013 yahoo_process_contact_ymsg13(yid,pkt); 3014 break; 2718 3015 case YAHOO_SERVICE_REMBUDDY: 2719 3016 yahoo_process_buddydel(yid, pkt); … … 2744 3041 case YAHOO_SERVICE_CHATLOGOFF: 2745 3042 case YAHOO_SERVICE_CHATMSG: 2746 case YAHOO_SERVICE_REJECTCONTACT:2747 3043 case YAHOO_SERVICE_PEERTOPEER: 2748 3044 WARNING(("unhandled service 0x%02x", pkt->service)); … … 2758 3054 yahoo_process_picture_upload(yid, pkt); 2759 3055 break; 3056 case YAHOO_SERVICE_YMSG15_BUDDY_LIST: /* Buddy List */ 3057 yahoo_process_buddy_list(yid, pkt); 2760 3058 default: 2761 3059 WARNING(("unknown service 0x%02x", pkt->service)); … … 3541 3839 yahoo_process_webcam_connection, 3542 3840 yahoo_process_chatcat_connection, 3543 yahoo_process_search_connection 3841 yahoo_process_search_connection, 3544 3842 }; 3545 3843 … … 3559 3857 } while(len == -1 && errno == EINTR); 3560 3858 3561 if(len == -1 && errno == EAGAIN) /* we'll try again later */3859 if(len == -1 && (errno == EAGAIN||errno == EINTR)) /* we'll try again later */ 3562 3860 return 1; 3563 3861 … … 3762 4060 3763 4061 yahoo_packet_hash(pkt, 5, who); 3764 yahoo_packet_hash(pkt, 4, from?from:yd->user);4062 yahoo_packet_hash(pkt, 1, from?from:yd->user); 3765 4063 yahoo_packet_hash(pkt, 14, " "); 3766 4064 yahoo_packet_hash(pkt, 13, typ ? "1" : "0"); … … 3777 4075 struct yahoo_data *yd; 3778 4076 struct yahoo_packet *pkt = NULL; 3779 int service;4077 int old_status; 3780 4078 char s[4]; 3781 4079 … … 3785 4083 yd = yid->yd; 3786 4084 3787 if (msg) { 4085 old_status = yd->current_status; 4086 4087 if (msg && strncmp(msg,"Invisible",9)) { 3788 4088 yd->current_status = YAHOO_STATUS_CUSTOM; 3789 4089 } else { … … 3791 4091 } 3792 4092 3793 if (yd->current_status == YAHOO_STATUS_AVAILABLE) 3794 service = YAHOO_SERVICE_ISBACK; 3795 else 3796 service = YAHOO_SERVICE_ISAWAY; 4093 /* Thank you libpurple :) */ 4094 if (yd->current_status == YAHOO_STATUS_INVISIBLE) { 4095 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBILITY, YAHOO_STATUS_AVAILABLE, 0); 4096 yahoo_packet_hash(pkt, 13, "2"); 4097 yahoo_send_packet(yid, pkt, 0); 4098 yahoo_packet_free(pkt); 4099 4100 return; 4101 } 4102 4103 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, yd->current_status, yd->session_id); 4104 snprintf(s, sizeof(s), "%d", yd->current_status); 4105 yahoo_packet_hash(pkt, 10, s); 3797 4106 3798 if ((away == 2) && (yd->current_status == YAHOO_STATUS_AVAILABLE)) { 3799 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_BRB, yd->session_id); 3800 yahoo_packet_hash(pkt, 10, "999"); 3801 yahoo_packet_hash(pkt, 47, "2"); 3802 }else { 3803 pkt = yahoo_packet_new(service, YAHOO_STATUS_AVAILABLE, yd->session_id); 3804 snprintf(s, sizeof(s), "%d", yd->current_status); 3805 yahoo_packet_hash(pkt, 10, s); 3806 if (yd->current_status == YAHOO_STATUS_CUSTOM) { 3807 yahoo_packet_hash(pkt, 19, msg); 3808 yahoo_packet_hash(pkt, 47, (away == 2)? "2": (away) ?"1":"0"); 3809 } else { 3810 yahoo_packet_hash(pkt, 47, (away == 2)? "2": (away) ?"1":"0"); 3811 } 3812 3813 3814 3815 } 4107 if (yd->current_status == YAHOO_STATUS_CUSTOM) { 4108 yahoo_packet_hash(pkt, 19, msg); 4109 } else { 4110 yahoo_packet_hash(pkt, 19, ""); 4111 } 4112 4113 yahoo_packet_hash(pkt, 47, (away == 2)? "2": (away) ?"1":"0"); 3816 4114 3817 4115 yahoo_send_packet(yid, pkt, 0); 3818 4116 yahoo_packet_free(pkt); 4117 4118 if(old_status == YAHOO_STATUS_INVISIBLE) { 4119 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBILITY, YAHOO_STATUS_AVAILABLE, 0); 4120 yahoo_packet_hash(pkt, 13, "1"); 4121 yahoo_send_packet(yid, pkt, 0); 4122 yahoo_packet_free(pkt); 4123 } 3819 4124 } 3820 4125 … … 3831 4136 LOG(("yahoo_logoff: current status: %d", yd->current_status)); 3832 4137 3833 if(yd->current_status != -1) { 4138 if(yd->current_status != -1 && 0) { 4139 /* Meh. Don't send this. The event handlers are not going to 4140 get to do this so it'll just leak memory. And the TCP 4141 connection reset will hopefully be clear enough. */ 3834 4142 pkt = yahoo_packet_new(YAHOO_SERVICE_LOGOFF, YAHOO_STATUS_AVAILABLE, yd->session_id); 3835 4143 yd->current_status = -1; … … 4064 4372 return; 4065 4373 4066 pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, yd->session_id); 4067 yahoo_packet_hash(pkt, 1, yd->user); 4068 yahoo_packet_hash(pkt, 7, who); 4069 yahoo_packet_hash(pkt, 65, group); 4374 pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YPACKET_STATUS_DEFAULT, yd->session_id); 4375 4070 4376 if (msg != NULL) /* add message/request "it's me add me" */ 4071 4377 yahoo_packet_hash(pkt, 14, msg); 4378 else 4379 yahoo_packet_hash(pkt,14,""); 4380 4381 yahoo_packet_hash(pkt, 65, group); 4382 yahoo_packet_hash(pkt, 97, "1"); 4383 yahoo_packet_hash(pkt, 1, yd->user); 4384 yahoo_packet_hash(pkt, 302, "319"); 4385 yahoo_packet_hash(pkt, 300, "319"); 4386 yahoo_packet_hash(pkt, 7, who); 4387 yahoo_packet_hash(pkt, 334, "0"); 4388 yahoo_packet_hash(pkt, 301, "319"); 4389 yahoo_packet_hash(pkt, 303, "319"); 4390 4391 4072 4392 yahoo_send_packet(yid, pkt, 0); 4073 4393 yahoo_packet_free(pkt); … … 4091 4411 yahoo_send_packet(yid, pkt, 0); 4092 4412 yahoo_packet_free(pkt); 4413 } 4414 4415 void yahoo_accept_buddy_ymsg13(int id,const char* me,const char* who){ 4416 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4417 struct yahoo_data *yd; 4418 4419 if(!yid) 4420 return; 4421 yd = yid->yd; 4422 4423 struct yahoo_packet* pkt=NULL; 4424 pkt= yahoo_packet_new(YAHOO_SERVICE_CONTACT_YMSG13,YAHOO_STATUS_AVAILABLE,0); 4425 4426 yahoo_packet_hash(pkt,1,me ?: yd->user); 4427 yahoo_packet_hash(pkt,5,who); 4428 yahoo_packet_hash(pkt,13,"1"); 4429 yahoo_packet_hash(pkt,334,"0"); 4430 yahoo_send_packet(yid, pkt, 0); 4431 yahoo_packet_free(pkt); 4432 } 4433 4434 void yahoo_reject_buddy_ymsg13(int id,const char* me,const char* who,const char* msg){ 4435 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4436 struct yahoo_data *yd; 4437 4438 if(!yid) 4439 return; 4440 yd = yid->yd; 4441 4442 struct yahoo_packet* pkt=NULL; 4443 pkt= yahoo_packet_new(YAHOO_SERVICE_CONTACT_YMSG13,YAHOO_STATUS_AVAILABLE,0); 4444 4445 yahoo_packet_hash(pkt,1,me ?: yd->user); 4446 yahoo_packet_hash(pkt,5,who); 4447 // yahoo_packet_hash(pkt,241,YAHOO_PROTO_VER); 4448 yahoo_packet_hash(pkt,13,"2"); 4449 yahoo_packet_hash(pkt,334,"0"); 4450 yahoo_packet_hash(pkt,97,"1"); 4451 yahoo_packet_hash(pkt,14,msg?:""); 4452 4453 yahoo_send_packet(yid, pkt, 0); 4454 yahoo_packet_free(pkt); 4455 4093 4456 } 4094 4457 -
protocols/yahoo/yahoo.c
rfc34fb5 r3f81999 254 254 static GList *byahoo_away_states( struct im_connection *ic ) 255 255 { 256 GList *m = NULL; 257 258 m = g_list_append( m, "Available" ); 259 m = g_list_append( m, "Be Right Back" ); 260 m = g_list_append( m, "Busy" ); 261 m = g_list_append( m, "Not At Home" ); 262 m = g_list_append( m, "Not At Desk" ); 263 m = g_list_append( m, "Not In Office" ); 264 m = g_list_append( m, "On Phone" ); 265 m = g_list_append( m, "On Vacation" ); 266 m = g_list_append( m, "Out To Lunch" ); 267 m = g_list_append( m, "Stepped Out" ); 268 m = g_list_append( m, "Invisible" ); 269 m = g_list_append( m, GAIM_AWAY_CUSTOM ); 256 static GList *m = NULL; 257 258 if( m == NULL ) 259 { 260 m = g_list_append( m, "Available" ); 261 m = g_list_append( m, "Be Right Back" ); 262 m = g_list_append( m, "Busy" ); 263 m = g_list_append( m, "Not At Home" ); 264 m = g_list_append( m, "Not At Desk" ); 265 m = g_list_append( m, "Not In Office" ); 266 m = g_list_append( m, "On Phone" ); 267 m = g_list_append( m, "On Vacation" ); 268 m = g_list_append( m, "Out To Lunch" ); 269 m = g_list_append( m, "Stepped Out" ); 270 m = g_list_append( m, "Invisible" ); 271 m = g_list_append( m, GAIM_AWAY_CUSTOM ); 272 } 270 273 271 274 return m; … … 346 349 347 350 return c; 351 } 352 353 static void byahoo_auth_allow( struct im_connection *ic, const char *who ) 354 { 355 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; 356 357 yahoo_accept_buddy_ymsg13( yd->y2_id, NULL, who ); 358 } 359 360 static void byahoo_auth_deny( struct im_connection *ic, const char *who ) 361 { 362 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; 363 364 yahoo_reject_buddy_ymsg13( yd->y2_id, NULL, who, NULL ); 348 365 } 349 366 … … 374 391 ret->handle_cmp = g_strcasecmp; 375 392 393 ret->auth_allow = byahoo_auth_allow; 394 ret->auth_deny = byahoo_auth_deny; 395 376 396 register_protocol(ret); 377 397 } … … 453 473 struct byahoo_write_ready_data *d = data; 454 474 455 yahoo_write_ready( d->id, d->fd, d->data ); 456 457 return FALSE; 475 return yahoo_write_ready( d->id, d->fd, d->data ); 458 476 } 459 477 … … 923 941 } 924 942 943 void ext_yahoo_contact_auth_request( int id, const char *myid, const char *who, const char *msg ) 944 { 945 struct im_connection *ic = byahoo_get_ic_by_id( id ); 946 947 imcb_ask_auth( ic, who, NULL ); 948 } 949 925 950 void ext_yahoo_contact_added( int id, const char *myid, const char *who, const char *msg ) 926 951 { 927 /* Groups schmoups. If I want to handle groups properly I can get the928 buddy data from some internal libyahoo2 structure. */929 imcb_add_buddy( byahoo_get_ic_by_id( id ), (char*) who, NULL );952 struct im_connection *ic = byahoo_get_ic_by_id( id ); 953 954 imcb_add_buddy( ic, (char*) who, NULL ); 930 955 } 931 956 -
protocols/yahoo/yahoo2.h
rfc34fb5 r3f81999 217 217 void yahoo_buddyicon_request(int id, const char *who); 218 218 219 void yahoo_accept_buddy_ymsg13(int,const char*,const char*); 220 void yahoo_reject_buddy_ymsg13(int,const char*,const char*,const char*); 221 219 222 #include "yahoo_httplib.h" 220 223 -
protocols/yahoo/yahoo2_callbacks.h
rfc34fb5 r3f81999 361 361 362 362 /* 363 * Name: ext_yahoo_contact_auth_request 364 * Called when a contact wants to add you to his/her contact list 365 * Params: 366 * id - the id that identifies the server connection 367 * myid - the identity s/he added 368 * who - who did it 369 * msg - any message sent 370 */ 371 void YAHOO_CALLBACK_TYPE(ext_yahoo_contact_auth_request)(int id, const char *myid, const char *who, const char *msg); 372 373 374 /* 363 375 * Name: ext_yahoo_contact_added 364 376 * Called when a contact is added to your list -
protocols/yahoo/yahoo2_types.h
rfc34fb5 r3f81999 57 57 YAHOO_LOGIN_LOCK = 14, 58 58 YAHOO_LOGIN_DUPL = 99, 59 YAHOO_LOGIN_SOCK = -1 59 YAHOO_LOGIN_SOCK = -1, 60 }; 61 62 enum ypacket_status { 63 YPACKET_STATUS_DISCONNECTED = -1, 64 YPACKET_STATUS_DEFAULT = 0, 65 YPACKET_STATUS_SERVERACK = 1, 66 YPACKET_STATUS_GAME = 0x2, 67 YPACKET_STATUS_AWAY = 0x4, 68 YPACKET_STATUS_CONTINUED = 0x5, 69 YPACKET_STATUS_INVISIBLE = 12, 70 YPACKET_STATUS_NOTIFY = 0x16, /* TYPING */ 71 YPACKET_STATUS_WEBLOGIN = 0x5a55aa55, 72 YPACKET_STATUS_OFFLINE = 0x5a55aa56 60 73 }; 61 74 … … 85 98 }; 86 99 87 #define YAHOO_PROTO_VER 0x00 0b100 #define YAHOO_PROTO_VER 0x0010 88 101 89 102 /* Yahoo style/color directives */ … … 115 128 YAHOO_CONNECTION_WEBCAM, 116 129 YAHOO_CONNECTION_CHATCAT, 117 YAHOO_CONNECTION_SEARCH 130 YAHOO_CONNECTION_SEARCH, 131 YAHOO_CONNECTION_AUTH, 118 132 }; 119 133 … … 131 145 /* chat member attribs */ 132 146 #define YAHOO_CHAT_MALE 0x8000 133 #define YAHOO_CHAT_FEMALE 0x10000134 147 #define YAHOO_CHAT_FEMALE 0x10000 135 148 #define YAHOO_CHAT_DUNNO 0x400
Note: See TracChangeset
for help on using the changeset viewer.