Changeset cfc8d58 for protocols/yahoo/libyahoo2.c
- Timestamp:
- 2007-04-16T04:31:52Z (18 years ago)
- Branches:
- master
- Children:
- b3cae44
- Parents:
- 6bbb939
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/yahoo/libyahoo2.c
r6bbb939 rcfc8d58 104 104 #define YAHOO_CALLBACK(x) x 105 105 #endif 106 107 static int yahoo_send_data(int fd, void *data, int len); 106 108 107 109 int yahoo_log_message(char * fmt, ...) … … 204 206 YAHOO_SERVICE_CHATLOGOUT = 0xa0, 205 207 YAHOO_SERVICE_CHATPING, 206 YAHOO_SERVICE_COMMENT = 0xa8 208 YAHOO_SERVICE_COMMENT = 0xa8, 209 YAHOO_SERVICE_STEALTH = 0xb9, 210 YAHOO_SERVICE_PICTURE_CHECKSUM = 0xbd, 211 YAHOO_SERVICE_PICTURE = 0xbe, 212 YAHOO_SERVICE_PICTURE_UPDATE = 0xc1, 213 YAHOO_SERVICE_PICTURE_UPLOAD = 0xc2 207 214 }; 208 215 … … 741 748 yahoo_packet_dump(data, len); 742 749 750 if( yid->type == YAHOO_CONNECTION_FT ) 751 yahoo_send_data(yid->fd, data, len); 752 else 743 753 yahoo_add_to_send_queue(yid, data, len); 744 754 FREE(data); … … 926 936 char *msg = NULL; 927 937 char *from = NULL; 938 char *to = NULL; 928 939 int stat = 0; 929 940 int accept = 0; … … 934 945 if (pair->key == 4) 935 946 from = pair->value; 947 if (pair->key == 5) 948 to = pair->value; 936 949 if (pair->key == 49) 937 950 msg = pair->value; … … 951 964 952 965 if (!strncasecmp(msg, "TYPING", strlen("TYPING"))) 953 YAHOO_CALLBACK(ext_yahoo_typing_notify)(yd->client_id, from, stat);966 YAHOO_CALLBACK(ext_yahoo_typing_notify)(yd->client_id, to, from, stat); 954 967 else if (!strncasecmp(msg, "GAME", strlen("GAME"))) 955 YAHOO_CALLBACK(ext_yahoo_game_notify)(yd->client_id, from, stat);968 YAHOO_CALLBACK(ext_yahoo_game_notify)(yd->client_id, to, from, stat); 956 969 else if (!strncasecmp(msg, "WEBCAMINVITE", strlen("WEBCAMINVITE"))) 957 970 { 958 971 if (!strcmp(ind, " ")) { 959 YAHOO_CALLBACK(ext_yahoo_webcam_invite)(yd->client_id, from);972 YAHOO_CALLBACK(ext_yahoo_webcam_invite)(yd->client_id, to, from); 960 973 } else { 961 974 accept = atoi(ind); … … 963 976 if (accept < 0) 964 977 accept = 0; 965 YAHOO_CALLBACK(ext_yahoo_webcam_invite_reply)(yd->client_id, from, accept);978 YAHOO_CALLBACK(ext_yahoo_webcam_invite_reply)(yd->client_id, to, from, accept); 966 979 } 967 980 } … … 1022 1035 } 1023 1036 if(url && from) 1024 YAHOO_CALLBACK(ext_yahoo_got_file)(yd->client_id, from, url, expires, msg, filename, filesize);1037 YAHOO_CALLBACK(ext_yahoo_got_file)(yd->client_id, to, from, url, expires, msg, filename, filesize); 1025 1038 1026 1039 } … … 1096 1109 ; 1097 1110 else if(members) 1098 YAHOO_CALLBACK(ext_yahoo_got_conf_invite)(yd->client_id, host, room, msg, members);1111 YAHOO_CALLBACK(ext_yahoo_got_conf_invite)(yd->client_id, id, host, room, msg, members); 1099 1112 else if(msg) 1100 YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, msg, 0 );1113 YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, msg, 0, E_CONFNOTAVAIL); 1101 1114 break; 1102 1115 case YAHOO_SERVICE_CONFADDINVITE: … … 1104 1117 ; 1105 1118 else 1106 YAHOO_CALLBACK(ext_yahoo_got_conf_invite)(yd->client_id, host, room, msg, members);1119 YAHOO_CALLBACK(ext_yahoo_got_conf_invite)(yd->client_id, id, host, room, msg, members); 1107 1120 break; 1108 1121 case YAHOO_SERVICE_CONFDECLINE: 1109 1122 if(who) 1110 YAHOO_CALLBACK(ext_yahoo_conf_userdecline)(yd->client_id, who, room, msg);1123 YAHOO_CALLBACK(ext_yahoo_conf_userdecline)(yd->client_id, id, who, room, msg); 1111 1124 break; 1112 1125 case YAHOO_SERVICE_CONFLOGON: 1113 1126 if(who) 1114 YAHOO_CALLBACK(ext_yahoo_conf_userjoin)(yd->client_id, who, room);1127 YAHOO_CALLBACK(ext_yahoo_conf_userjoin)(yd->client_id, id, who, room); 1115 1128 break; 1116 1129 case YAHOO_SERVICE_CONFLOGOFF: 1117 1130 if(who) 1118 YAHOO_CALLBACK(ext_yahoo_conf_userleave)(yd->client_id, who, room);1131 YAHOO_CALLBACK(ext_yahoo_conf_userleave)(yd->client_id, id, who, room); 1119 1132 break; 1120 1133 case YAHOO_SERVICE_CONFMSG: 1121 1134 if(who) 1122 YAHOO_CALLBACK(ext_yahoo_conf_message)(yd->client_id, who, room, msg, utf8);1135 YAHOO_CALLBACK(ext_yahoo_conf_message)(yd->client_id, id, who, room, msg, utf8); 1123 1136 break; 1124 1137 } … … 1128 1141 { 1129 1142 char *msg = NULL; 1143 char *id = NULL; 1130 1144 char *who = NULL; 1131 1145 char *room = NULL; … … 1144 1158 struct yahoo_pair *pair = l->data; 1145 1159 1160 if (pair->key == 1) { 1161 /* My identity */ 1162 id = pair->value; 1163 } 1164 1146 1165 if (pair->key == 104) { 1147 1166 /* Room name */ … … 1218 1237 if(!room) { 1219 1238 if (pkt->service == YAHOO_SERVICE_CHATLOGOUT) { /* yahoo originated chat logout */ 1220 YAHOO_CALLBACK(ext_yahoo_chat_yahoologout)(yid->yd->client_id );1239 YAHOO_CALLBACK(ext_yahoo_chat_yahoologout)(yid->yd->client_id, id); 1221 1240 return ; 1222 1241 } 1223 1242 if (pkt->service == YAHOO_SERVICE_COMMENT && chaterr) { 1224 YAHOO_CALLBACK(ext_yahoo_chat_yahooerror)(yid->yd->client_id );1225 return 1243 YAHOO_CALLBACK(ext_yahoo_chat_yahooerror)(yid->yd->client_id, id); 1244 return; 1226 1245 } 1227 1246 … … 1236 1255 } 1237 1256 if(firstjoin && members) { 1238 YAHOO_CALLBACK(ext_yahoo_chat_join)(yid->yd->client_id, room, topic, members, yid->fd);1257 YAHOO_CALLBACK(ext_yahoo_chat_join)(yid->yd->client_id, id, room, topic, members, yid->fd); 1239 1258 } else if(who) { 1240 1259 if(y_list_length(members) != 1) { … … 1245 1264 YList *n = members->next; 1246 1265 currentmember = members->data; 1247 YAHOO_CALLBACK(ext_yahoo_chat_userjoin)(yid->yd->client_id, room, currentmember);1266 YAHOO_CALLBACK(ext_yahoo_chat_userjoin)(yid->yd->client_id, id, room, currentmember); 1248 1267 y_list_free_1(members); 1249 1268 members=n; … … 1253 1272 case YAHOO_SERVICE_CHATEXIT: 1254 1273 if(who) { 1255 YAHOO_CALLBACK(ext_yahoo_chat_userleave)(yid->yd->client_id, room, who);1274 YAHOO_CALLBACK(ext_yahoo_chat_userleave)(yid->yd->client_id, id, room, who); 1256 1275 } 1257 1276 break; 1258 1277 case YAHOO_SERVICE_COMMENT: 1259 1278 if(who) { 1260 YAHOO_CALLBACK(ext_yahoo_chat_message)(yid->yd->client_id, who, room, msg, msgtype, utf8);1279 YAHOO_CALLBACK(ext_yahoo_chat_message)(yid->yd->client_id, id, who, room, msg, msgtype, utf8); 1261 1280 } 1262 1281 break; … … 1317 1336 YAHOO_CALLBACK(ext_yahoo_system_message)(yd->client_id, message->msg); 1318 1337 } else if (pkt->status <= 2 || pkt->status == 5) { 1319 YAHOO_CALLBACK(ext_yahoo_got_im)(yd->client_id, message-> from, message->msg, message->tm, pkt->status, message->utf8);1338 YAHOO_CALLBACK(ext_yahoo_got_im)(yd->client_id, message->to, message->from, message->msg, message->tm, pkt->status, message->utf8); 1320 1339 } else if (pkt->status == 0xffffffff) { 1321 YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, message->msg, 0 );1340 YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, message->msg, 0, E_SYSTEM); 1322 1341 } 1323 1342 free(message); … … 1332 1351 YList *l; 1333 1352 struct yahoo_data *yd = yid->yd; 1334 char *name = NULL; 1335 int state = 0; 1336 int away = 0; 1337 int idle = 0; 1338 char *msg = NULL; 1353 1354 struct user 1355 { 1356 char *name; /* 7 name */ 1357 int state; /* 10 state */ 1358 int flags; /* 13 flags, bit 0 = pager, bit 1 = chat, bit 2 = game */ 1359 int mobile; /* 60 mobile */ 1360 char *msg; /* 19 custom status message */ 1361 int away; /* 47 away (or invisible)*/ 1362 int buddy_session; /* 11 state */ 1363 int f17; /* 17 in chat? then what about flags? */ 1364 int idle; /* 137 seconds idle */ 1365 int f138; /* 138 state */ 1366 char *f184; /* 184 state */ 1367 int f192; /* 192 state */ 1368 int f10001; /* 10001 state */ 1369 int f10002; /* 10002 state */ 1370 int f198; /* 198 state */ 1371 char *f197; /* 197 state */ 1372 char *f205; /* 205 state */ 1373 int f213; /* 213 state */ 1374 } *u; 1375 1376 YList *users = 0; 1339 1377 1340 if (pkt->service == YAHOO_SERVICE_LOGOFF && pkt->status == -1) {1378 if (pkt->service == YAHOO_SERVICE_LOGOFF && pkt->status == -1) { 1341 1379 YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, YAHOO_LOGIN_DUPL, NULL); 1342 1380 return; … … 1362 1400 break; 1363 1401 case 7: /* the current buddy */ 1364 name = pair->value; 1402 u = y_new0(struct user, 1); 1403 u->name = pair->value; 1404 users = y_list_prepend(users, u); 1365 1405 break; 1366 1406 case 10: /* state */ 1367 state = strtol(pair->value, NULL, 10);1407 ((struct user*)users->data)->state = strtol(pair->value, NULL, 10); 1368 1408 break; 1369 1409 case 19: /* custom status message */ 1370 msg = pair->value;1410 ((struct user*)users->data)->msg = pair->value; 1371 1411 break; 1372 1412 case 47: /* is it an away message or not */ 1373 away = atoi(pair->value);1413 ((struct user*)users->data)->away = atoi(pair->value); 1374 1414 break; 1375 1415 case 137: /* seconds idle */ 1376 idle = atoi(pair->value);1377 break; 1378 case 11: /* what is this?*/1379 NOTICE(("key %d:%s", pair->key, pair->value));1416 ((struct user*)users->data)->idle = atoi(pair->value); 1417 break; 1418 case 11: /* this is the buddy's session id */ 1419 ((struct user*)users->data)->buddy_session = atoi(pair->value); 1380 1420 break; 1381 1421 case 17: /* in chat? */ 1382 break; 1383 case 13: /* in pager? */ 1384 if (pkt->service == YAHOO_SERVICE_LOGOFF || strtol(pair->value, NULL, 10) == 0) { 1385 YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, name, YAHOO_STATUS_OFFLINE, NULL, 1); 1386 break; 1387 } 1388 if (state == YAHOO_STATUS_AVAILABLE) { 1389 YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, name, state, NULL, 0); 1390 } else if (state == YAHOO_STATUS_CUSTOM) { 1391 YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, name, state, msg, away); 1392 } else { 1393 YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, name, state, NULL, idle); 1394 } 1395 1396 break; 1397 case 60: 1422 ((struct user*)users->data)->f17 = atoi(pair->value); 1423 break; 1424 case 13: /* bitmask, bit 0 = pager, bit 1 = chat, bit 2 = game */ 1425 ((struct user*)users->data)->flags = atoi(pair->value); 1426 break; 1427 case 60: /* SMS -> 1 MOBILE USER */ 1398 1428 /* sometimes going offline makes this 2, but invisible never sends it */ 1399 NOTICE(("key %d:%s", pair->key, pair->value)); 1400 break; 1429 ((struct user*)users->data)->mobile = atoi(pair->value); 1430 break; 1431 case 138: 1432 ((struct user*)users->data)->f138 = atoi(pair->value); 1433 break; 1434 case 184: 1435 ((struct user*)users->data)->f184 = pair->value; 1436 break; 1437 case 192: 1438 ((struct user*)users->data)->f192 = atoi(pair->value); 1439 break; 1440 case 10001: 1441 ((struct user*)users->data)->f10001 = atoi(pair->value); 1442 break; 1443 case 10002: 1444 ((struct user*)users->data)->f10002 = atoi(pair->value); 1445 break; 1446 case 198: 1447 ((struct user*)users->data)->f198 = atoi(pair->value); 1448 break; 1449 case 197: 1450 ((struct user*)users->data)->f197 = pair->value; 1451 break; 1452 case 205: 1453 ((struct user*)users->data)->f205 = pair->value; 1454 break; 1455 case 213: 1456 ((struct user*)users->data)->f213 = atoi(pair->value); 1457 break; 1401 1458 case 16: /* Custom error message */ 1402 YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, pair->value, 0 );1459 YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, pair->value, 0, E_CUSTOM); 1403 1460 break; 1404 1461 default: … … 1406 1463 break; 1407 1464 } 1465 } 1466 1467 while (users) { 1468 YList *t = users; 1469 struct user *u = users->data; 1470 1471 if (u->name != NULL) { 1472 if (pkt->service == YAHOO_SERVICE_LOGOFF || u->flags == 0) { 1473 YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, u->name, YAHOO_STATUS_OFFLINE, NULL, 1, 0, 0); 1474 } else { 1475 YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, u->name, u->state, u->msg, u->away, u->idle, u->mobile); 1476 } 1477 } 1478 1479 users = y_list_remove_link(users, users); 1480 y_list_free_1(t); 1481 FREE(u); 1408 1482 } 1409 1483 } … … 1510 1584 yahoo_packet_free(pkt); 1511 1585 1586 } 1587 1588 static void yahoo_process_picture_checksum( struct yahoo_input_data *yid, struct yahoo_packet *pkt) 1589 { 1590 struct yahoo_data *yd = yid->yd; 1591 char *from = NULL; 1592 char *to = NULL; 1593 int checksum = 0; 1594 YList *l; 1595 1596 for(l = pkt->hash; l; l = l->next) 1597 { 1598 struct yahoo_pair *pair = l->data; 1599 1600 switch(pair->key) 1601 { 1602 case 1: 1603 case 4: 1604 from = pair->value; 1605 case 5: 1606 to = pair->value; 1607 break; 1608 case 212: 1609 break; 1610 case 192: 1611 checksum = atoi( pair->value ); 1612 break; 1613 } 1614 } 1615 1616 YAHOO_CALLBACK(ext_yahoo_got_buddyicon_checksum)(yd->client_id,to,from,checksum); 1617 } 1618 1619 static void yahoo_process_picture(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 1620 { 1621 struct yahoo_data *yd = yid->yd; 1622 char *url = NULL; 1623 char *from = NULL; 1624 char *to = NULL; 1625 int status = 0; 1626 int checksum = 0; 1627 YList *l; 1628 1629 for(l = pkt->hash; l; l = l->next) 1630 { 1631 struct yahoo_pair *pair = l->data; 1632 1633 switch(pair->key) 1634 { 1635 case 1: 1636 case 4: /* sender */ 1637 from = pair->value; 1638 break; 1639 case 5: /* we */ 1640 to = pair->value; 1641 break; 1642 case 13: /* request / sending */ 1643 status = atoi( pair->value ); 1644 break; 1645 case 20: /* url */ 1646 url = pair->value; 1647 break; 1648 case 192: /*checksum */ 1649 checksum = atoi( pair->value ); 1650 break; 1651 } 1652 } 1653 1654 switch( status ) 1655 { 1656 case 1: /* this is a request, ignore for now */ 1657 YAHOO_CALLBACK(ext_yahoo_got_buddyicon_request)(yd->client_id, to, from); 1658 break; 1659 case 2: /* this is cool - we get a picture :) */ 1660 YAHOO_CALLBACK(ext_yahoo_got_buddyicon)(yd->client_id,to, from, url, checksum); 1661 break; 1662 } 1663 } 1664 1665 static void yahoo_process_picture_upload(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 1666 { 1667 struct yahoo_data *yd = yid->yd; 1668 YList *l; 1669 char *url = NULL; 1670 1671 if ( pkt->status != 1 ) 1672 return; /* something went wrong */ 1673 1674 for(l = pkt->hash; l; l = l->next) 1675 { 1676 struct yahoo_pair *pair = l->data; 1677 1678 switch(pair->key) 1679 { 1680 case 5: /* we */ 1681 break; 1682 case 20: /* url */ 1683 url = pair->value; 1684 break; 1685 case 27: /* local filename */ 1686 break; 1687 case 38: /* time */ 1688 break; 1689 } 1690 } 1691 1692 YAHOO_CALLBACK(ext_yahoo_buddyicon_uploaded)(yd->client_id, url); 1512 1693 } 1513 1694 … … 2154 2335 int online = FALSE; 2155 2336 int away = 0; 2337 int idle = 0; 2338 int mobile = 0; 2156 2339 2157 2340 YList *l; … … 2175 2358 else if (pair->key == 47) 2176 2359 away = strtol(pair->value, NULL, 10); 2360 else if (pair->key == 137) 2361 idle = strtol(pair->value, NULL, 10); 2362 else if (pair->key == 60) 2363 mobile = strtol(pair->value, NULL, 10); 2364 2177 2365 } 2178 2366 … … 2180 2368 YAHOO_CALLBACK(ext_yahoo_contact_added)(yd->client_id, id, who, msg); 2181 2369 else if (name) 2182 YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, name, state, msg, away );2370 YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, name, state, msg, away, idle, mobile); 2183 2371 else if(pkt->status == 0x07) 2184 2372 YAHOO_CALLBACK(ext_yahoo_rejected)(yd->client_id, who, msg); … … 2308 2496 2309 2497 /* if(status) 2310 YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, status, who, 0);2498 YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, who, 0, status); 2311 2499 */ 2312 2500 } … … 2332 2520 } 2333 2521 2334 NOTICE(("got voice chat invite from %s in %s ", who, room));2522 NOTICE(("got voice chat invite from %s in %s to identity %s", who, room, me)); 2335 2523 /* 2336 2524 * send: s:0 1:me 5:who 57:room 13:1 … … 2342 2530 * rejr: s:4 5:who 10:99 19:-1617114599 2343 2531 */ 2532 } 2533 2534 static void yahoo_process_ping(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 2535 { 2536 char *errormsg = NULL; 2537 2538 YList *l; 2539 for (l = pkt->hash; l; l = l->next) { 2540 struct yahoo_pair *pair = l->data; 2541 if (pair->key == 16) 2542 errormsg = pair->value; 2543 } 2544 2545 NOTICE(("got ping packet")); 2546 YAHOO_CALLBACK(ext_yahoo_got_ping)(yid->yd->client_id, errormsg); 2344 2547 } 2345 2548 … … 2519 2722 yahoo_process_webcam_key(yid, pkt); 2520 2723 break; 2724 case YAHOO_SERVICE_PING: 2725 yahoo_process_ping(yid, pkt); 2726 break; 2521 2727 case YAHOO_SERVICE_IDLE: 2522 2728 case YAHOO_SERVICE_MAILSTAT: … … 2526 2732 case YAHOO_SERVICE_ADDIDENT: 2527 2733 case YAHOO_SERVICE_ADDIGNORE: 2528 case YAHOO_SERVICE_PING:2529 2734 case YAHOO_SERVICE_GOTGROUPRENAME: 2530 2735 case YAHOO_SERVICE_GROUPRENAME: … … 2538 2743 yahoo_dump_unhandled(pkt); 2539 2744 break; 2745 case YAHOO_SERVICE_PICTURE: 2746 yahoo_process_picture(yid, pkt); 2747 break; 2748 case YAHOO_SERVICE_PICTURE_CHECKSUM: 2749 yahoo_process_picture_checksum(yid, pkt); 2750 break; 2751 case YAHOO_SERVICE_PICTURE_UPLOAD: 2752 yahoo_process_picture_upload(yid, pkt); 2753 break; 2540 2754 default: 2541 2755 WARNING(("unknown service 0x%02x", pkt->service)); … … 3347 3561 3348 3562 if(yid->type == YAHOO_CONNECTION_PAGER) { 3349 YAHOO_CALLBACK(ext_yahoo_ login_response)(yid->yd->client_id, YAHOO_LOGIN_SOCK, NULL);3563 YAHOO_CALLBACK(ext_yahoo_error)(yid->yd->client_id, "Connection closed by server", 1, E_CONNECTION); 3350 3564 } 3351 3565 … … 3495 3709 } 3496 3710 3497 void yahoo_send_im(int id, const char *from, const char *who, const char *what, int utf8 )3711 void yahoo_send_im(int id, const char *from, const char *who, const char *what, int utf8, int picture) 3498 3712 { 3499 3713 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 3500 3714 struct yahoo_packet *pkt = NULL; 3501 3715 struct yahoo_data *yd; 3716 char pic_str[10]; 3502 3717 3503 3718 if(!yid) … … 3508 3723 pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE, yd->session_id); 3509 3724 3725 snprintf(pic_str, sizeof(pic_str), "%d", picture); 3726 3510 3727 if(from && strcmp(from, yd->user)) 3511 3728 yahoo_packet_hash(pkt, 0, yd->user); … … 3519 3736 yahoo_packet_hash(pkt, 63, ";0"); /* imvironment name; or ;0 */ 3520 3737 yahoo_packet_hash(pkt, 64, "0"); 3738 yahoo_packet_hash(pkt, 206, pic_str); 3521 3739 3522 3740 … … 3571 3789 else 3572 3790 service = YAHOO_SERVICE_ISAWAY; 3573 pkt = yahoo_packet_new(service, yd->current_status, yd->session_id); 3574 snprintf(s, sizeof(s), "%d", yd->current_status); 3575 yahoo_packet_hash(pkt, 10, s); 3576 if (yd->current_status == YAHOO_STATUS_CUSTOM) { 3577 yahoo_packet_hash(pkt, 19, msg); 3578 yahoo_packet_hash(pkt, 47, away?"1":"0"); 3791 3792 if ((away == 2) && (yd->current_status == YAHOO_STATUS_AVAILABLE)) { 3793 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_BRB, yd->session_id); 3794 yahoo_packet_hash(pkt, 10, "999"); 3795 yahoo_packet_hash(pkt, 47, "2"); 3796 }else { 3797 pkt = yahoo_packet_new(service, YAHOO_STATUS_AVAILABLE, yd->session_id); 3798 snprintf(s, sizeof(s), "%d", yd->current_status); 3799 yahoo_packet_hash(pkt, 10, s); 3800 if (yd->current_status == YAHOO_STATUS_CUSTOM) { 3801 yahoo_packet_hash(pkt, 19, msg); 3802 yahoo_packet_hash(pkt, 47, (away == 2)? "2": (away) ?"1":"0"); 3803 } else { 3804 yahoo_packet_hash(pkt, 47, (away == 2)? "2": (away) ?"1":"0"); 3805 } 3806 3807 3808 3579 3809 } 3580 3810 … … 3817 4047 } 3818 4048 3819 void yahoo_add_buddy(int id, const char *who, const char *group )4049 void yahoo_add_buddy(int id, const char *who, const char *group, const char *msg) 3820 4050 { 3821 4051 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); … … 3834 4064 yahoo_packet_hash(pkt, 7, who); 3835 4065 yahoo_packet_hash(pkt, 65, group); 4066 if (msg != NULL) /* add message/request "it's me add me" */ 4067 yahoo_packet_hash(pkt, 14, msg); 3836 4068 yahoo_send_packet(yid, pkt, 0); 3837 4069 yahoo_packet_free(pkt); … … 3895 4127 yahoo_packet_hash(pkt, 7, who); 3896 4128 yahoo_packet_hash(pkt, 13, unignore?"2":"1"); 4129 yahoo_send_packet(yid, pkt, 0); 4130 yahoo_packet_free(pkt); 4131 } 4132 4133 void yahoo_stealth_buddy(int id, const char *who, int unstealth) 4134 { 4135 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4136 struct yahoo_data *yd; 4137 struct yahoo_packet *pkt; 4138 4139 if(!yid) 4140 return; 4141 yd = yid->yd; 4142 4143 if (!yd->logged_in) 4144 return; 4145 4146 pkt = yahoo_packet_new(YAHOO_SERVICE_STEALTH, YAHOO_STATUS_AVAILABLE, yd->session_id); 4147 yahoo_packet_hash(pkt, 1, yd->user); 4148 yahoo_packet_hash(pkt, 7, who); 4149 yahoo_packet_hash(pkt, 31, unstealth?"2":"1"); 4150 yahoo_packet_hash(pkt, 13, "2"); 3897 4151 yahoo_send_packet(yid, pkt, 0); 3898 4152 yahoo_packet_free(pkt); … … 4202 4456 yahoo_packet_hash(pkt, 1, (from?from:yd->user)); 4203 4457 4458 yahoo_send_packet(yid, pkt, 0); 4459 4460 yahoo_packet_free(pkt); 4461 } 4462 4463 void yahoo_buddyicon_request(int id, const char *who) 4464 { 4465 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4466 struct yahoo_data *yd; 4467 struct yahoo_packet *pkt; 4468 4469 if( !yid ) 4470 return; 4471 4472 yd = yid->yd; 4473 4474 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YAHOO_STATUS_AVAILABLE, 0); 4475 yahoo_packet_hash(pkt, 4, yd->user); 4476 yahoo_packet_hash(pkt, 5, who); 4477 yahoo_packet_hash(pkt, 13, "1"); 4478 yahoo_send_packet(yid, pkt, 0); 4479 4480 yahoo_packet_free(pkt); 4481 } 4482 4483 void yahoo_send_picture_info(int id, const char *who, const char *url, int checksum) 4484 { 4485 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4486 struct yahoo_data *yd; 4487 struct yahoo_packet *pkt; 4488 char checksum_str[10]; 4489 4490 if( !yid ) 4491 return; 4492 4493 yd = yid->yd; 4494 4495 snprintf(checksum_str, sizeof(checksum_str), "%d", checksum); 4496 4497 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YAHOO_STATUS_AVAILABLE, 0); 4498 yahoo_packet_hash(pkt, 1, yd->user); 4499 yahoo_packet_hash(pkt, 4, yd->user); 4500 yahoo_packet_hash(pkt, 5, who); 4501 yahoo_packet_hash(pkt, 13, "2"); 4502 yahoo_packet_hash(pkt, 20, url); 4503 yahoo_packet_hash(pkt, 192, checksum_str); 4504 yahoo_send_packet(yid, pkt, 0); 4505 4506 yahoo_packet_free(pkt); 4507 } 4508 4509 void yahoo_send_picture_update(int id, const char *who, int type) 4510 { 4511 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4512 struct yahoo_data *yd; 4513 struct yahoo_packet *pkt; 4514 char type_str[10]; 4515 4516 if( !yid ) 4517 return; 4518 4519 yd = yid->yd; 4520 4521 snprintf(type_str, sizeof(type_str), "%d", type); 4522 4523 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_UPDATE, YAHOO_STATUS_AVAILABLE, 0); 4524 yahoo_packet_hash(pkt, 1, yd->user); 4525 yahoo_packet_hash(pkt, 5, who); 4526 yahoo_packet_hash(pkt, 206, type_str); 4527 yahoo_send_packet(yid, pkt, 0); 4528 4529 yahoo_packet_free(pkt); 4530 } 4531 4532 void yahoo_send_picture_checksum(int id, const char *who, int checksum) 4533 { 4534 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4535 struct yahoo_data *yd; 4536 struct yahoo_packet *pkt; 4537 char checksum_str[10]; 4538 4539 if( !yid ) 4540 return; 4541 4542 yd = yid->yd; 4543 4544 snprintf(checksum_str, sizeof(checksum_str), "%d", checksum); 4545 4546 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_CHECKSUM, YAHOO_STATUS_AVAILABLE, 0); 4547 yahoo_packet_hash(pkt, 1, yd->user); 4548 if( who != 0 ) 4549 yahoo_packet_hash(pkt, 5, who); 4550 yahoo_packet_hash(pkt, 192, checksum_str); 4551 yahoo_packet_hash(pkt, 212, "1"); 4204 4552 yahoo_send_packet(yid, pkt, 0); 4205 4553 … … 4410 4758 }; 4411 4759 4760 static void _yahoo_send_picture_connected(int id, int fd, int error, void *data) 4761 { 4762 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_FT); 4763 struct send_file_data *sfd = data; 4764 struct yahoo_packet *pkt = sfd->pkt; 4765 unsigned char buff[1024]; 4766 4767 if(fd <= 0) { 4768 sfd->callback(id, fd, error, sfd->user_data); 4769 FREE(sfd); 4770 yahoo_packet_free(pkt); 4771 inputs = y_list_remove(inputs, yid); 4772 FREE(yid); 4773 return; 4774 } 4775 4776 yid->fd = fd; 4777 yahoo_send_packet(yid, pkt, 8); 4778 yahoo_packet_free(pkt); 4779 4780 snprintf((char *)buff, sizeof(buff), "29"); 4781 buff[2] = 0xc0; 4782 buff[3] = 0x80; 4783 4784 write(yid->fd, buff, 4); 4785 4786 /* YAHOO_CALLBACK(ext_yahoo_add_handler)(nyd->fd, YAHOO_INPUT_READ); */ 4787 4788 sfd->callback(id, fd, error, sfd->user_data); 4789 FREE(sfd); 4790 inputs = y_list_remove(inputs, yid); 4791 /* 4792 while(yahoo_tcp_readline(buff, sizeof(buff), nyd->fd) > 0) { 4793 if(!strcmp(buff, "")) 4794 break; 4795 } 4796 4797 */ 4798 yahoo_input_close(yid); 4799 } 4800 4801 void yahoo_send_picture(int id, const char *name, unsigned long size, 4802 yahoo_get_fd_callback callback, void *data) 4803 { 4804 struct yahoo_data *yd = find_conn_by_id(id); 4805 struct yahoo_input_data *yid; 4806 struct yahoo_server_settings *yss; 4807 struct yahoo_packet *pkt = NULL; 4808 char size_str[10]; 4809 char expire_str[10]; 4810 long content_length=0; 4811 unsigned char buff[1024]; 4812 char url[255]; 4813 struct send_file_data *sfd; 4814 4815 if(!yd) 4816 return; 4817 4818 yss = yd->server_settings; 4819 4820 yid = y_new0(struct yahoo_input_data, 1); 4821 yid->yd = yd; 4822 yid->type = YAHOO_CONNECTION_FT; 4823 4824 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_UPLOAD, YAHOO_STATUS_AVAILABLE, yd->session_id); 4825 4826 snprintf(size_str, sizeof(size_str), "%ld", size); 4827 snprintf(expire_str, sizeof(expire_str), "%ld", (long)604800); 4828 4829 yahoo_packet_hash(pkt, 0, yd->user); 4830 yahoo_packet_hash(pkt, 1, yd->user); 4831 yahoo_packet_hash(pkt, 14, ""); 4832 yahoo_packet_hash(pkt, 27, name); 4833 yahoo_packet_hash(pkt, 28, size_str); 4834 yahoo_packet_hash(pkt, 38, expire_str); 4835 4836 4837 content_length = YAHOO_PACKET_HDRLEN + yahoo_packet_length(pkt); 4838 4839 snprintf(url, sizeof(url), "http://%s:%d/notifyft", 4840 yss->filetransfer_host, yss->filetransfer_port); 4841 snprintf((char *)buff, sizeof(buff), "Y=%s; T=%s", 4842 yd->cookie_y, yd->cookie_t); 4843 inputs = y_list_prepend(inputs, yid); 4844 4845 sfd = y_new0(struct send_file_data, 1); 4846 sfd->pkt = pkt; 4847 sfd->callback = callback; 4848 sfd->user_data = data; 4849 yahoo_http_post(yid->yd->client_id, url, (char *)buff, content_length+4+size, 4850 _yahoo_send_picture_connected, sfd); 4851 } 4852 4412 4853 static void _yahoo_send_file_connected(int id, int fd, int error, void *data) 4413 4854 {
Note: See TracChangeset
for help on using the changeset viewer.