Changeset 85d7b85 for protocols/yahoo
- Timestamp:
- 2008-04-02T14:22:57Z (17 years ago)
- Branches:
- master
- Children:
- f9dbc99
- Parents:
- 875ad42 (diff), dd34575 (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:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/yahoo/Makefile
r875ad42 r85d7b85 17 17 # [SH] Phony targets 18 18 all: yahoo_mod.o 19 check: all 20 lcov: check 21 gcov: 22 gcov *.c 19 23 20 24 .PHONY: all clean distclean -
protocols/yahoo/libyahoo2.c
r875ad42 r85d7b85 74 74 #include <ctype.h> 75 75 76 #include "sha .h"76 #include "sha1.h" 77 77 #include "md5.h" 78 78 #include "yahoo2.h" … … 88 88 #endif 89 89 90 #include "base64.h" 91 90 92 #ifdef USE_STRUCT_CALLBACKS 91 93 struct yahoo_callbacks *yc=NULL; … … 100 102 #define YAHOO_CALLBACK(x) x 101 103 #endif 104 105 static int yahoo_send_data(int fd, void *data, int len); 102 106 103 107 int yahoo_log_message(char * fmt, ...) … … 200 204 YAHOO_SERVICE_CHATLOGOUT = 0xa0, 201 205 YAHOO_SERVICE_CHATPING, 202 YAHOO_SERVICE_COMMENT = 0xa8 206 YAHOO_SERVICE_COMMENT = 0xa8, 207 YAHOO_SERVICE_STEALTH = 0xb9, 208 YAHOO_SERVICE_PICTURE_CHECKSUM = 0xbd, 209 YAHOO_SERVICE_PICTURE = 0xbe, 210 YAHOO_SERVICE_PICTURE_UPDATE = 0xc1, 211 YAHOO_SERVICE_PICTURE_UPLOAD = 0xc2 203 212 }; 204 213 … … 693 702 } 694 703 695 static char base64digits[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 696 "abcdefghijklmnopqrstuvwxyz" 697 "0123456789._"; 704 /* raw bytes in quasi-big-endian order to base 64 string (NUL-terminated) */ 698 705 static void to_y64(unsigned char *out, const unsigned char *in, int inlen) 699 /* raw bytes in quasi-big-endian order to base 64 string (NUL-terminated) */ 700 { 701 for (; inlen >= 3; inlen -= 3) 702 { 703 *out++ = base64digits[in[0] >> 2]; 704 *out++ = base64digits[((in[0]<<4) & 0x30) | (in[1]>>4)]; 705 *out++ = base64digits[((in[1]<<2) & 0x3c) | (in[2]>>6)]; 706 *out++ = base64digits[in[2] & 0x3f]; 707 in += 3; 708 } 709 if (inlen > 0) 710 { 711 unsigned char fragment; 712 713 *out++ = base64digits[in[0] >> 2]; 714 fragment = (in[0] << 4) & 0x30; 715 if (inlen > 1) 716 fragment |= in[1] >> 4; 717 *out++ = base64digits[fragment]; 718 *out++ = (inlen < 2) ? '-' 719 : base64digits[(in[1] << 2) & 0x3c]; 720 *out++ = '-'; 721 } 722 *out = '\0'; 706 { 707 base64_encode_real(in, inlen, out, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-"); 723 708 } 724 709 … … 750 735 751 736 memcpy(data + pos, "YMSG", 4); pos += 4; 752 pos += yahoo_put16(data + pos, 0x0 a00);737 pos += yahoo_put16(data + pos, 0x000c); 753 738 pos += yahoo_put16(data + pos, 0x0000); 754 739 pos += yahoo_put16(data + pos, pktlen + extra_pad); … … 761 746 yahoo_packet_dump(data, len); 762 747 748 if( yid->type == YAHOO_CONNECTION_FT ) 749 yahoo_send_data(yid->fd, data, len); 750 else 763 751 yahoo_add_to_send_queue(yid, data, len); 764 752 FREE(data); … … 946 934 char *msg = NULL; 947 935 char *from = NULL; 936 char *to = NULL; 948 937 int stat = 0; 949 938 int accept = 0; … … 954 943 if (pair->key == 4) 955 944 from = pair->value; 945 if (pair->key == 5) 946 to = pair->value; 956 947 if (pair->key == 49) 957 948 msg = pair->value; … … 971 962 972 963 if (!strncasecmp(msg, "TYPING", strlen("TYPING"))) 973 YAHOO_CALLBACK(ext_yahoo_typing_notify)(yd->client_id, from, stat);964 YAHOO_CALLBACK(ext_yahoo_typing_notify)(yd->client_id, to, from, stat); 974 965 else if (!strncasecmp(msg, "GAME", strlen("GAME"))) 975 YAHOO_CALLBACK(ext_yahoo_game_notify)(yd->client_id, from, stat);966 YAHOO_CALLBACK(ext_yahoo_game_notify)(yd->client_id, to, from, stat); 976 967 else if (!strncasecmp(msg, "WEBCAMINVITE", strlen("WEBCAMINVITE"))) 977 968 { 978 969 if (!strcmp(ind, " ")) { 979 YAHOO_CALLBACK(ext_yahoo_webcam_invite)(yd->client_id, from);970 YAHOO_CALLBACK(ext_yahoo_webcam_invite)(yd->client_id, to, from); 980 971 } else { 981 972 accept = atoi(ind); … … 983 974 if (accept < 0) 984 975 accept = 0; 985 YAHOO_CALLBACK(ext_yahoo_webcam_invite_reply)(yd->client_id, from, accept);976 YAHOO_CALLBACK(ext_yahoo_webcam_invite_reply)(yd->client_id, to, from, accept); 986 977 } 987 978 } … … 1042 1033 } 1043 1034 if(url && from) 1044 YAHOO_CALLBACK(ext_yahoo_got_file)(yd->client_id, from, url, expires, msg, filename, filesize);1035 YAHOO_CALLBACK(ext_yahoo_got_file)(yd->client_id, to, from, url, expires, msg, filename, filesize); 1045 1036 1046 1037 } … … 1116 1107 ; 1117 1108 else if(members) 1118 YAHOO_CALLBACK(ext_yahoo_got_conf_invite)(yd->client_id, host, room, msg, members);1109 YAHOO_CALLBACK(ext_yahoo_got_conf_invite)(yd->client_id, id, host, room, msg, members); 1119 1110 else if(msg) 1120 YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, msg, 0 );1111 YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, msg, 0, E_CONFNOTAVAIL); 1121 1112 break; 1122 1113 case YAHOO_SERVICE_CONFADDINVITE: … … 1124 1115 ; 1125 1116 else 1126 YAHOO_CALLBACK(ext_yahoo_got_conf_invite)(yd->client_id, host, room, msg, members);1117 YAHOO_CALLBACK(ext_yahoo_got_conf_invite)(yd->client_id, id, host, room, msg, members); 1127 1118 break; 1128 1119 case YAHOO_SERVICE_CONFDECLINE: 1129 1120 if(who) 1130 YAHOO_CALLBACK(ext_yahoo_conf_userdecline)(yd->client_id, who, room, msg);1121 YAHOO_CALLBACK(ext_yahoo_conf_userdecline)(yd->client_id, id, who, room, msg); 1131 1122 break; 1132 1123 case YAHOO_SERVICE_CONFLOGON: 1133 1124 if(who) 1134 YAHOO_CALLBACK(ext_yahoo_conf_userjoin)(yd->client_id, who, room);1125 YAHOO_CALLBACK(ext_yahoo_conf_userjoin)(yd->client_id, id, who, room); 1135 1126 break; 1136 1127 case YAHOO_SERVICE_CONFLOGOFF: 1137 1128 if(who) 1138 YAHOO_CALLBACK(ext_yahoo_conf_userleave)(yd->client_id, who, room);1129 YAHOO_CALLBACK(ext_yahoo_conf_userleave)(yd->client_id, id, who, room); 1139 1130 break; 1140 1131 case YAHOO_SERVICE_CONFMSG: 1141 1132 if(who) 1142 YAHOO_CALLBACK(ext_yahoo_conf_message)(yd->client_id, who, room, msg, utf8);1133 YAHOO_CALLBACK(ext_yahoo_conf_message)(yd->client_id, id, who, room, msg, utf8); 1143 1134 break; 1144 1135 } … … 1148 1139 { 1149 1140 char *msg = NULL; 1141 char *id = NULL; 1150 1142 char *who = NULL; 1151 1143 char *room = NULL; … … 1164 1156 struct yahoo_pair *pair = l->data; 1165 1157 1158 if (pair->key == 1) { 1159 /* My identity */ 1160 id = pair->value; 1161 } 1162 1166 1163 if (pair->key == 104) { 1167 1164 /* Room name */ … … 1238 1235 if(!room) { 1239 1236 if (pkt->service == YAHOO_SERVICE_CHATLOGOUT) { /* yahoo originated chat logout */ 1240 YAHOO_CALLBACK(ext_yahoo_chat_yahoologout)(yid->yd->client_id );1237 YAHOO_CALLBACK(ext_yahoo_chat_yahoologout)(yid->yd->client_id, id); 1241 1238 return ; 1242 1239 } 1243 1240 if (pkt->service == YAHOO_SERVICE_COMMENT && chaterr) { 1244 YAHOO_CALLBACK(ext_yahoo_chat_yahooerror)(yid->yd->client_id );1245 return 1241 YAHOO_CALLBACK(ext_yahoo_chat_yahooerror)(yid->yd->client_id, id); 1242 return; 1246 1243 } 1247 1244 … … 1256 1253 } 1257 1254 if(firstjoin && members) { 1258 YAHOO_CALLBACK(ext_yahoo_chat_join)(yid->yd->client_id, room, topic, members, yid->fd);1255 YAHOO_CALLBACK(ext_yahoo_chat_join)(yid->yd->client_id, id, room, topic, members, yid->fd); 1259 1256 } else if(who) { 1260 1257 if(y_list_length(members) != 1) { … … 1265 1262 YList *n = members->next; 1266 1263 currentmember = members->data; 1267 YAHOO_CALLBACK(ext_yahoo_chat_userjoin)(yid->yd->client_id, room, currentmember);1264 YAHOO_CALLBACK(ext_yahoo_chat_userjoin)(yid->yd->client_id, id, room, currentmember); 1268 1265 y_list_free_1(members); 1269 1266 members=n; … … 1273 1270 case YAHOO_SERVICE_CHATEXIT: 1274 1271 if(who) { 1275 YAHOO_CALLBACK(ext_yahoo_chat_userleave)(yid->yd->client_id, room, who);1272 YAHOO_CALLBACK(ext_yahoo_chat_userleave)(yid->yd->client_id, id, room, who); 1276 1273 } 1277 1274 break; 1278 1275 case YAHOO_SERVICE_COMMENT: 1279 1276 if(who) { 1280 YAHOO_CALLBACK(ext_yahoo_chat_message)(yid->yd->client_id, who, room, msg, msgtype, utf8);1277 YAHOO_CALLBACK(ext_yahoo_chat_message)(yid->yd->client_id, id, who, room, msg, msgtype, utf8); 1281 1278 } 1282 1279 break; … … 1337 1334 YAHOO_CALLBACK(ext_yahoo_system_message)(yd->client_id, message->msg); 1338 1335 } else if (pkt->status <= 2 || pkt->status == 5) { 1339 YAHOO_CALLBACK(ext_yahoo_got_im)(yd->client_id, message-> from, message->msg, message->tm, pkt->status, message->utf8);1336 YAHOO_CALLBACK(ext_yahoo_got_im)(yd->client_id, message->to, message->from, message->msg, message->tm, pkt->status, message->utf8); 1340 1337 } else if (pkt->status == 0xffffffff) { 1341 YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, message->msg, 0 );1338 YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, message->msg, 0, E_SYSTEM); 1342 1339 } 1343 1340 free(message); … … 1352 1349 YList *l; 1353 1350 struct yahoo_data *yd = yid->yd; 1354 char *name = NULL; 1355 int state = 0; 1356 int away = 0; 1357 int idle = 0; 1358 char *msg = NULL; 1351 1352 struct user 1353 { 1354 char *name; /* 7 name */ 1355 int state; /* 10 state */ 1356 int flags; /* 13 flags, bit 0 = pager, bit 1 = chat, bit 2 = game */ 1357 int mobile; /* 60 mobile */ 1358 char *msg; /* 19 custom status message */ 1359 int away; /* 47 away (or invisible)*/ 1360 int buddy_session; /* 11 state */ 1361 int f17; /* 17 in chat? then what about flags? */ 1362 int idle; /* 137 seconds idle */ 1363 int f138; /* 138 state */ 1364 char *f184; /* 184 state */ 1365 int f192; /* 192 state */ 1366 int f10001; /* 10001 state */ 1367 int f10002; /* 10002 state */ 1368 int f198; /* 198 state */ 1369 char *f197; /* 197 state */ 1370 char *f205; /* 205 state */ 1371 int f213; /* 213 state */ 1372 } *u; 1373 1374 YList *users = 0; 1359 1375 1360 if (pkt->service == YAHOO_SERVICE_LOGOFF && pkt->status == -1) {1376 if (pkt->service == YAHOO_SERVICE_LOGOFF && pkt->status == -1) { 1361 1377 YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, YAHOO_LOGIN_DUPL, NULL); 1362 1378 return; … … 1382 1398 break; 1383 1399 case 7: /* the current buddy */ 1384 name = pair->value; 1400 u = y_new0(struct user, 1); 1401 u->name = pair->value; 1402 users = y_list_prepend(users, u); 1385 1403 break; 1386 1404 case 10: /* state */ 1387 state = strtol(pair->value, NULL, 10);1405 ((struct user*)users->data)->state = strtol(pair->value, NULL, 10); 1388 1406 break; 1389 1407 case 19: /* custom status message */ 1390 msg = pair->value;1408 ((struct user*)users->data)->msg = pair->value; 1391 1409 break; 1392 1410 case 47: /* is it an away message or not */ 1393 away = atoi(pair->value);1411 ((struct user*)users->data)->away = atoi(pair->value); 1394 1412 break; 1395 1413 case 137: /* seconds idle */ 1396 idle = atoi(pair->value);1397 break; 1398 case 11: /* what is this?*/1399 NOTICE(("key %d:%s", pair->key, pair->value));1414 ((struct user*)users->data)->idle = atoi(pair->value); 1415 break; 1416 case 11: /* this is the buddy's session id */ 1417 ((struct user*)users->data)->buddy_session = atoi(pair->value); 1400 1418 break; 1401 1419 case 17: /* in chat? */ 1402 break; 1403 case 13: /* in pager? */ 1404 if (pkt->service == YAHOO_SERVICE_LOGOFF || strtol(pair->value, NULL, 10) == 0) { 1405 YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, name, YAHOO_STATUS_OFFLINE, NULL, 1); 1406 break; 1407 } 1408 if (state == YAHOO_STATUS_AVAILABLE) { 1409 YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, name, state, NULL, 0); 1410 } else if (state == YAHOO_STATUS_CUSTOM) { 1411 YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, name, state, msg, away); 1412 } else { 1413 YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, name, state, NULL, idle); 1414 } 1415 1416 break; 1417 case 60: 1420 ((struct user*)users->data)->f17 = atoi(pair->value); 1421 break; 1422 case 13: /* bitmask, bit 0 = pager, bit 1 = chat, bit 2 = game */ 1423 ((struct user*)users->data)->flags = atoi(pair->value); 1424 break; 1425 case 60: /* SMS -> 1 MOBILE USER */ 1418 1426 /* sometimes going offline makes this 2, but invisible never sends it */ 1419 NOTICE(("key %d:%s", pair->key, pair->value)); 1420 break; 1427 ((struct user*)users->data)->mobile = atoi(pair->value); 1428 break; 1429 case 138: 1430 ((struct user*)users->data)->f138 = atoi(pair->value); 1431 break; 1432 case 184: 1433 ((struct user*)users->data)->f184 = pair->value; 1434 break; 1435 case 192: 1436 ((struct user*)users->data)->f192 = atoi(pair->value); 1437 break; 1438 case 10001: 1439 ((struct user*)users->data)->f10001 = atoi(pair->value); 1440 break; 1441 case 10002: 1442 ((struct user*)users->data)->f10002 = atoi(pair->value); 1443 break; 1444 case 198: 1445 ((struct user*)users->data)->f198 = atoi(pair->value); 1446 break; 1447 case 197: 1448 ((struct user*)users->data)->f197 = pair->value; 1449 break; 1450 case 205: 1451 ((struct user*)users->data)->f205 = pair->value; 1452 break; 1453 case 213: 1454 ((struct user*)users->data)->f213 = atoi(pair->value); 1455 break; 1421 1456 case 16: /* Custom error message */ 1422 YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, pair->value, 0 );1457 YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, pair->value, 0, E_CUSTOM); 1423 1458 break; 1424 1459 default: … … 1426 1461 break; 1427 1462 } 1463 } 1464 1465 while (users) { 1466 YList *t = users; 1467 struct user *u = users->data; 1468 1469 if (u->name != NULL) { 1470 if (pkt->service == YAHOO_SERVICE_LOGOFF || u->flags == 0) { 1471 YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, u->name, YAHOO_STATUS_OFFLINE, NULL, 1, 0, 0); 1472 } else { 1473 YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, u->name, u->state, u->msg, u->away, u->idle, u->mobile); 1474 } 1475 } 1476 1477 users = y_list_remove_link(users, users); 1478 y_list_free_1(t); 1479 FREE(u); 1428 1480 } 1429 1481 } … … 1530 1582 yahoo_packet_free(pkt); 1531 1583 1584 } 1585 1586 static void yahoo_process_picture_checksum( struct yahoo_input_data *yid, struct yahoo_packet *pkt) 1587 { 1588 struct yahoo_data *yd = yid->yd; 1589 char *from = NULL; 1590 char *to = NULL; 1591 int checksum = 0; 1592 YList *l; 1593 1594 for(l = pkt->hash; l; l = l->next) 1595 { 1596 struct yahoo_pair *pair = l->data; 1597 1598 switch(pair->key) 1599 { 1600 case 1: 1601 case 4: 1602 from = pair->value; 1603 case 5: 1604 to = pair->value; 1605 break; 1606 case 212: 1607 break; 1608 case 192: 1609 checksum = atoi( pair->value ); 1610 break; 1611 } 1612 } 1613 1614 YAHOO_CALLBACK(ext_yahoo_got_buddyicon_checksum)(yd->client_id,to,from,checksum); 1615 } 1616 1617 static void yahoo_process_picture(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 1618 { 1619 struct yahoo_data *yd = yid->yd; 1620 char *url = NULL; 1621 char *from = NULL; 1622 char *to = NULL; 1623 int status = 0; 1624 int checksum = 0; 1625 YList *l; 1626 1627 for(l = pkt->hash; l; l = l->next) 1628 { 1629 struct yahoo_pair *pair = l->data; 1630 1631 switch(pair->key) 1632 { 1633 case 1: 1634 case 4: /* sender */ 1635 from = pair->value; 1636 break; 1637 case 5: /* we */ 1638 to = pair->value; 1639 break; 1640 case 13: /* request / sending */ 1641 status = atoi( pair->value ); 1642 break; 1643 case 20: /* url */ 1644 url = pair->value; 1645 break; 1646 case 192: /*checksum */ 1647 checksum = atoi( pair->value ); 1648 break; 1649 } 1650 } 1651 1652 switch( status ) 1653 { 1654 case 1: /* this is a request, ignore for now */ 1655 YAHOO_CALLBACK(ext_yahoo_got_buddyicon_request)(yd->client_id, to, from); 1656 break; 1657 case 2: /* this is cool - we get a picture :) */ 1658 YAHOO_CALLBACK(ext_yahoo_got_buddyicon)(yd->client_id,to, from, url, checksum); 1659 break; 1660 } 1661 } 1662 1663 static void yahoo_process_picture_upload(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 1664 { 1665 struct yahoo_data *yd = yid->yd; 1666 YList *l; 1667 char *url = NULL; 1668 1669 if ( pkt->status != 1 ) 1670 return; /* something went wrong */ 1671 1672 for(l = pkt->hash; l; l = l->next) 1673 { 1674 struct yahoo_pair *pair = l->data; 1675 1676 switch(pair->key) 1677 { 1678 case 5: /* we */ 1679 break; 1680 case 20: /* url */ 1681 url = pair->value; 1682 break; 1683 case 27: /* local filename */ 1684 break; 1685 case 38: /* time */ 1686 break; 1687 } 1688 } 1689 1690 YAHOO_CALLBACK(ext_yahoo_buddyicon_uploaded)(yd->client_id, url); 1532 1691 } 1533 1692 … … 1659 1818 md5_state_t ctx; 1660 1819 1661 SHA_CTXctx1;1662 SHA_CTXctx2;1820 sha1_state_t ctx1; 1821 sha1_state_t ctx2; 1663 1822 1664 1823 char *alphabet1 = "FBZDWAGHrJTLMNOPpRSKUVEXYChImkwQ"; … … 1716 1875 magic_ptr = (unsigned char *)seed; 1717 1876 1718 while (*magic_ptr != (int)NULL) {1877 while (*magic_ptr != 0) { 1719 1878 char *loc; 1720 1879 … … 1895 2054 memset(&(pass_hash_xor2[cnt]), 0x5c, 64-cnt); 1896 2055 1897 sha Init(&ctx1);1898 sha Init(&ctx2);2056 sha1_init(&ctx1); 2057 sha1_init(&ctx2); 1899 2058 1900 2059 /* The first context gets the password hash XORed … … 1903 2062 * challenge. */ 1904 2063 1905 sha Update(&ctx1, pass_hash_xor1, 64);2064 sha1_append(&ctx1, pass_hash_xor1, 64); 1906 2065 if (j >= 3 ) 1907 ctx1. sizeLo= 0x1ff;1908 sha Update(&ctx1, magic_key_char, 4);1909 sha Final(&ctx1, digest1);2066 ctx1.Length_Low = 0x1ff; 2067 sha1_append(&ctx1, magic_key_char, 4); 2068 sha1_finish(&ctx1, digest1); 1910 2069 1911 2070 /* The second context gets the password hash XORed … … 1913 2072 * of the first context. */ 1914 2073 1915 sha Update(&ctx2, pass_hash_xor2, 64);1916 sha Update(&ctx2, digest1, 20);1917 sha Final(&ctx2, digest2);2074 sha1_append(&ctx2, pass_hash_xor2, 64); 2075 sha1_append(&ctx2, digest1, 20); 2076 sha1_finish(&ctx2, digest2); 1918 2077 1919 2078 /* Now that we have digest2, use it to fetch … … 1986 2145 memset(&(crypt_hash_xor2[cnt]), 0x5c, 64-cnt); 1987 2146 1988 sha Init(&ctx1);1989 sha Init(&ctx2);2147 sha1_init(&ctx1); 2148 sha1_init(&ctx2); 1990 2149 1991 2150 /* The first context gets the password hash XORed … … 1994 2153 * challenge. */ 1995 2154 1996 sha Update(&ctx1, crypt_hash_xor1, 64);2155 sha1_append(&ctx1, crypt_hash_xor1, 64); 1997 2156 if (j >= 3 ) 1998 ctx1. sizeLo= 0x1ff;1999 sha Update(&ctx1, magic_key_char, 4);2000 sha Final(&ctx1, digest1);2157 ctx1.Length_Low = 0x1ff; 2158 sha1_append(&ctx1, magic_key_char, 4); 2159 sha1_finish(&ctx1, digest1); 2001 2160 2002 2161 /* The second context gets the password hash XORed … … 2004 2163 * of the first context. */ 2005 2164 2006 sha Update(&ctx2, crypt_hash_xor2, 64);2007 sha Update(&ctx2, digest1, 20);2008 sha Final(&ctx2, digest2);2165 sha1_append(&ctx2, crypt_hash_xor2, 64); 2166 sha1_append(&ctx2, digest1, 20); 2167 sha1_finish(&ctx2, digest2); 2009 2168 2010 2169 /* Now that we have digest2, use it to fetch … … 2174 2333 int online = FALSE; 2175 2334 int away = 0; 2335 int idle = 0; 2336 int mobile = 0; 2176 2337 2177 2338 YList *l; … … 2195 2356 else if (pair->key == 47) 2196 2357 away = strtol(pair->value, NULL, 10); 2358 else if (pair->key == 137) 2359 idle = strtol(pair->value, NULL, 10); 2360 else if (pair->key == 60) 2361 mobile = strtol(pair->value, NULL, 10); 2362 2197 2363 } 2198 2364 … … 2200 2366 YAHOO_CALLBACK(ext_yahoo_contact_added)(yd->client_id, id, who, msg); 2201 2367 else if (name) 2202 YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, name, state, msg, away );2368 YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, name, state, msg, away, idle, mobile); 2203 2369 else if(pkt->status == 0x07) 2204 2370 YAHOO_CALLBACK(ext_yahoo_rejected)(yd->client_id, who, msg); … … 2235 2401 where = "Unknown"; 2236 2402 2237 bud = y_new0(struct yahoo_buddy, 1); 2238 bud->id = strdup(who); 2239 bud->group = strdup(where); 2240 bud->real_name = NULL; 2241 2242 yd->buddies = y_list_append(yd->buddies, bud); 2403 /* status: 0 == Successful, 1 == Error (does not exist), 2 == Already in list */ 2404 if( status == 0 ) { 2405 bud = y_new0(struct yahoo_buddy, 1); 2406 bud->id = strdup(who); 2407 bud->group = strdup(where); 2408 bud->real_name = NULL; 2409 2410 yd->buddies = y_list_append(yd->buddies, bud); 2411 2412 /* Possibly called already, but at least the call above doesn't 2413 seem to happen every time (not anytime I tried). */ 2414 YAHOO_CALLBACK(ext_yahoo_contact_added)(yd->client_id, me, who, NULL); 2415 } 2243 2416 2244 2417 /* YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, who, status, NULL, (status==YAHOO_STATUS_AVAILABLE?0:1)); */ … … 2328 2501 2329 2502 /* if(status) 2330 YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, status, who, 0);2503 YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, who, 0, status); 2331 2504 */ 2332 2505 } … … 2352 2525 } 2353 2526 2354 NOTICE(("got voice chat invite from %s in %s ", who, room));2527 NOTICE(("got voice chat invite from %s in %s to identity %s", who, room, me)); 2355 2528 /* 2356 2529 * send: s:0 1:me 5:who 57:room 13:1 … … 2362 2535 * rejr: s:4 5:who 10:99 19:-1617114599 2363 2536 */ 2537 } 2538 2539 static void yahoo_process_ping(struct yahoo_input_data *yid, struct yahoo_packet *pkt) 2540 { 2541 char *errormsg = NULL; 2542 2543 YList *l; 2544 for (l = pkt->hash; l; l = l->next) { 2545 struct yahoo_pair *pair = l->data; 2546 if (pair->key == 16) 2547 errormsg = pair->value; 2548 } 2549 2550 NOTICE(("got ping packet")); 2551 YAHOO_CALLBACK(ext_yahoo_got_ping)(yid->yd->client_id, errormsg); 2364 2552 } 2365 2553 … … 2539 2727 yahoo_process_webcam_key(yid, pkt); 2540 2728 break; 2729 case YAHOO_SERVICE_PING: 2730 yahoo_process_ping(yid, pkt); 2731 break; 2541 2732 case YAHOO_SERVICE_IDLE: 2542 2733 case YAHOO_SERVICE_MAILSTAT: … … 2546 2737 case YAHOO_SERVICE_ADDIDENT: 2547 2738 case YAHOO_SERVICE_ADDIGNORE: 2548 case YAHOO_SERVICE_PING:2549 2739 case YAHOO_SERVICE_GOTGROUPRENAME: 2550 2740 case YAHOO_SERVICE_GROUPRENAME: … … 2558 2748 yahoo_dump_unhandled(pkt); 2559 2749 break; 2750 case YAHOO_SERVICE_PICTURE: 2751 yahoo_process_picture(yid, pkt); 2752 break; 2753 case YAHOO_SERVICE_PICTURE_CHECKSUM: 2754 yahoo_process_picture_checksum(yid, pkt); 2755 break; 2756 case YAHOO_SERVICE_PICTURE_UPLOAD: 2757 yahoo_process_picture_upload(yid, pkt); 2758 break; 2560 2759 default: 2561 2760 WARNING(("unknown service 0x%02x", pkt->service)); … … 3150 3349 break; 3151 3350 case 5: 3152 if( cp != "\005")3351 if(strcmp(cp, "5") != 0) 3153 3352 yct->location = cp; 3154 3353 k = 0; … … 3367 3566 3368 3567 if(yid->type == YAHOO_CONNECTION_PAGER) { 3369 YAHOO_CALLBACK(ext_yahoo_ login_response)(yid->yd->client_id, YAHOO_LOGIN_SOCK, NULL);3568 YAHOO_CALLBACK(ext_yahoo_error)(yid->yd->client_id, "Connection closed by server", 1, E_CONNECTION); 3370 3569 } 3371 3570 … … 3515 3714 } 3516 3715 3517 void yahoo_send_im(int id, const char *from, const char *who, const char *what, int utf8 )3716 void yahoo_send_im(int id, const char *from, const char *who, const char *what, int utf8, int picture) 3518 3717 { 3519 3718 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 3520 3719 struct yahoo_packet *pkt = NULL; 3521 3720 struct yahoo_data *yd; 3721 char pic_str[10]; 3522 3722 3523 3723 if(!yid) … … 3528 3728 pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE, yd->session_id); 3529 3729 3730 snprintf(pic_str, sizeof(pic_str), "%d", picture); 3731 3530 3732 if(from && strcmp(from, yd->user)) 3531 3733 yahoo_packet_hash(pkt, 0, yd->user); … … 3539 3741 yahoo_packet_hash(pkt, 63, ";0"); /* imvironment name; or ;0 */ 3540 3742 yahoo_packet_hash(pkt, 64, "0"); 3743 yahoo_packet_hash(pkt, 206, pic_str); 3541 3744 3542 3745 … … 3591 3794 else 3592 3795 service = YAHOO_SERVICE_ISAWAY; 3593 pkt = yahoo_packet_new(service, yd->current_status, yd->session_id); 3594 snprintf(s, sizeof(s), "%d", yd->current_status); 3595 yahoo_packet_hash(pkt, 10, s); 3596 if (yd->current_status == YAHOO_STATUS_CUSTOM) { 3597 yahoo_packet_hash(pkt, 19, msg); 3598 yahoo_packet_hash(pkt, 47, away?"1":"0"); 3796 3797 if ((away == 2) && (yd->current_status == YAHOO_STATUS_AVAILABLE)) { 3798 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_BRB, yd->session_id); 3799 yahoo_packet_hash(pkt, 10, "999"); 3800 yahoo_packet_hash(pkt, 47, "2"); 3801 }else { 3802 pkt = yahoo_packet_new(service, YAHOO_STATUS_AVAILABLE, yd->session_id); 3803 snprintf(s, sizeof(s), "%d", yd->current_status); 3804 yahoo_packet_hash(pkt, 10, s); 3805 if (yd->current_status == YAHOO_STATUS_CUSTOM) { 3806 yahoo_packet_hash(pkt, 19, msg); 3807 yahoo_packet_hash(pkt, 47, (away == 2)? "2": (away) ?"1":"0"); 3808 } else { 3809 yahoo_packet_hash(pkt, 47, (away == 2)? "2": (away) ?"1":"0"); 3810 } 3811 3812 3813 3599 3814 } 3600 3815 … … 3837 4052 } 3838 4053 3839 void yahoo_add_buddy(int id, const char *who, const char *group )4054 void yahoo_add_buddy(int id, const char *who, const char *group, const char *msg) 3840 4055 { 3841 4056 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); … … 3854 4069 yahoo_packet_hash(pkt, 7, who); 3855 4070 yahoo_packet_hash(pkt, 65, group); 4071 if (msg != NULL) /* add message/request "it's me add me" */ 4072 yahoo_packet_hash(pkt, 14, msg); 3856 4073 yahoo_send_packet(yid, pkt, 0); 3857 4074 yahoo_packet_free(pkt); … … 3915 4132 yahoo_packet_hash(pkt, 7, who); 3916 4133 yahoo_packet_hash(pkt, 13, unignore?"2":"1"); 4134 yahoo_send_packet(yid, pkt, 0); 4135 yahoo_packet_free(pkt); 4136 } 4137 4138 void yahoo_stealth_buddy(int id, const char *who, int unstealth) 4139 { 4140 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4141 struct yahoo_data *yd; 4142 struct yahoo_packet *pkt; 4143 4144 if(!yid) 4145 return; 4146 yd = yid->yd; 4147 4148 if (!yd->logged_in) 4149 return; 4150 4151 pkt = yahoo_packet_new(YAHOO_SERVICE_STEALTH, YAHOO_STATUS_AVAILABLE, yd->session_id); 4152 yahoo_packet_hash(pkt, 1, yd->user); 4153 yahoo_packet_hash(pkt, 7, who); 4154 yahoo_packet_hash(pkt, 31, unstealth?"2":"1"); 4155 yahoo_packet_hash(pkt, 13, "2"); 3917 4156 yahoo_send_packet(yid, pkt, 0); 3918 4157 yahoo_packet_free(pkt); … … 4222 4461 yahoo_packet_hash(pkt, 1, (from?from:yd->user)); 4223 4462 4463 yahoo_send_packet(yid, pkt, 0); 4464 4465 yahoo_packet_free(pkt); 4466 } 4467 4468 void yahoo_buddyicon_request(int id, const char *who) 4469 { 4470 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4471 struct yahoo_data *yd; 4472 struct yahoo_packet *pkt; 4473 4474 if( !yid ) 4475 return; 4476 4477 yd = yid->yd; 4478 4479 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YAHOO_STATUS_AVAILABLE, 0); 4480 yahoo_packet_hash(pkt, 4, yd->user); 4481 yahoo_packet_hash(pkt, 5, who); 4482 yahoo_packet_hash(pkt, 13, "1"); 4483 yahoo_send_packet(yid, pkt, 0); 4484 4485 yahoo_packet_free(pkt); 4486 } 4487 4488 void yahoo_send_picture_info(int id, const char *who, const char *url, int checksum) 4489 { 4490 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4491 struct yahoo_data *yd; 4492 struct yahoo_packet *pkt; 4493 char checksum_str[10]; 4494 4495 if( !yid ) 4496 return; 4497 4498 yd = yid->yd; 4499 4500 snprintf(checksum_str, sizeof(checksum_str), "%d", checksum); 4501 4502 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YAHOO_STATUS_AVAILABLE, 0); 4503 yahoo_packet_hash(pkt, 1, yd->user); 4504 yahoo_packet_hash(pkt, 4, yd->user); 4505 yahoo_packet_hash(pkt, 5, who); 4506 yahoo_packet_hash(pkt, 13, "2"); 4507 yahoo_packet_hash(pkt, 20, url); 4508 yahoo_packet_hash(pkt, 192, checksum_str); 4509 yahoo_send_packet(yid, pkt, 0); 4510 4511 yahoo_packet_free(pkt); 4512 } 4513 4514 void yahoo_send_picture_update(int id, const char *who, int type) 4515 { 4516 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4517 struct yahoo_data *yd; 4518 struct yahoo_packet *pkt; 4519 char type_str[10]; 4520 4521 if( !yid ) 4522 return; 4523 4524 yd = yid->yd; 4525 4526 snprintf(type_str, sizeof(type_str), "%d", type); 4527 4528 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_UPDATE, YAHOO_STATUS_AVAILABLE, 0); 4529 yahoo_packet_hash(pkt, 1, yd->user); 4530 yahoo_packet_hash(pkt, 5, who); 4531 yahoo_packet_hash(pkt, 206, type_str); 4532 yahoo_send_packet(yid, pkt, 0); 4533 4534 yahoo_packet_free(pkt); 4535 } 4536 4537 void yahoo_send_picture_checksum(int id, const char *who, int checksum) 4538 { 4539 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER); 4540 struct yahoo_data *yd; 4541 struct yahoo_packet *pkt; 4542 char checksum_str[10]; 4543 4544 if( !yid ) 4545 return; 4546 4547 yd = yid->yd; 4548 4549 snprintf(checksum_str, sizeof(checksum_str), "%d", checksum); 4550 4551 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_CHECKSUM, YAHOO_STATUS_AVAILABLE, 0); 4552 yahoo_packet_hash(pkt, 1, yd->user); 4553 if( who != 0 ) 4554 yahoo_packet_hash(pkt, 5, who); 4555 yahoo_packet_hash(pkt, 192, checksum_str); 4556 yahoo_packet_hash(pkt, 212, "1"); 4224 4557 yahoo_send_packet(yid, pkt, 0); 4225 4558 … … 4430 4763 }; 4431 4764 4765 static void _yahoo_send_picture_connected(int id, int fd, int error, void *data) 4766 { 4767 struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_FT); 4768 struct send_file_data *sfd = data; 4769 struct yahoo_packet *pkt = sfd->pkt; 4770 unsigned char buff[1024]; 4771 4772 if(fd <= 0) { 4773 sfd->callback(id, fd, error, sfd->user_data); 4774 FREE(sfd); 4775 yahoo_packet_free(pkt); 4776 inputs = y_list_remove(inputs, yid); 4777 FREE(yid); 4778 return; 4779 } 4780 4781 yid->fd = fd; 4782 yahoo_send_packet(yid, pkt, 8); 4783 yahoo_packet_free(pkt); 4784 4785 snprintf((char *)buff, sizeof(buff), "29"); 4786 buff[2] = 0xc0; 4787 buff[3] = 0x80; 4788 4789 write(yid->fd, buff, 4); 4790 4791 /* YAHOO_CALLBACK(ext_yahoo_add_handler)(nyd->fd, YAHOO_INPUT_READ); */ 4792 4793 sfd->callback(id, fd, error, sfd->user_data); 4794 FREE(sfd); 4795 inputs = y_list_remove(inputs, yid); 4796 /* 4797 while(yahoo_tcp_readline(buff, sizeof(buff), nyd->fd) > 0) { 4798 if(!strcmp(buff, "")) 4799 break; 4800 } 4801 4802 */ 4803 yahoo_input_close(yid); 4804 } 4805 4806 void yahoo_send_picture(int id, const char *name, unsigned long size, 4807 yahoo_get_fd_callback callback, void *data) 4808 { 4809 struct yahoo_data *yd = find_conn_by_id(id); 4810 struct yahoo_input_data *yid; 4811 struct yahoo_server_settings *yss; 4812 struct yahoo_packet *pkt = NULL; 4813 char size_str[10]; 4814 char expire_str[10]; 4815 long content_length=0; 4816 unsigned char buff[1024]; 4817 char url[255]; 4818 struct send_file_data *sfd; 4819 4820 if(!yd) 4821 return; 4822 4823 yss = yd->server_settings; 4824 4825 yid = y_new0(struct yahoo_input_data, 1); 4826 yid->yd = yd; 4827 yid->type = YAHOO_CONNECTION_FT; 4828 4829 pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_UPLOAD, YAHOO_STATUS_AVAILABLE, yd->session_id); 4830 4831 snprintf(size_str, sizeof(size_str), "%ld", size); 4832 snprintf(expire_str, sizeof(expire_str), "%ld", (long)604800); 4833 4834 yahoo_packet_hash(pkt, 0, yd->user); 4835 yahoo_packet_hash(pkt, 1, yd->user); 4836 yahoo_packet_hash(pkt, 14, ""); 4837 yahoo_packet_hash(pkt, 27, name); 4838 yahoo_packet_hash(pkt, 28, size_str); 4839 yahoo_packet_hash(pkt, 38, expire_str); 4840 4841 4842 content_length = YAHOO_PACKET_HDRLEN + yahoo_packet_length(pkt); 4843 4844 snprintf(url, sizeof(url), "http://%s:%d/notifyft", 4845 yss->filetransfer_host, yss->filetransfer_port); 4846 snprintf((char *)buff, sizeof(buff), "Y=%s; T=%s", 4847 yd->cookie_y, yd->cookie_t); 4848 inputs = y_list_prepend(inputs, yid); 4849 4850 sfd = y_new0(struct send_file_data, 1); 4851 sfd->pkt = pkt; 4852 sfd->callback = callback; 4853 sfd->user_data = data; 4854 yahoo_http_post(yid->yd->client_id, url, (char *)buff, content_length+4+size, 4855 _yahoo_send_picture_connected, sfd); 4856 } 4857 4432 4858 static void _yahoo_send_file_connected(int id, int fd, int error, void *data) 4433 4859 { -
protocols/yahoo/yahoo.c
r875ad42 r85d7b85 58 58 { 59 59 char *name; 60 struct conversation*c;60 struct groupchat *c; 61 61 int yid; 62 62 YList *members; 63 struct gaim_connection *gc;63 struct im_connection *ic; 64 64 }; 65 65 … … 67 67 static int byahoo_chat_id = 0; 68 68 69 static char *byahoo_strip( c har *in )69 static char *byahoo_strip( const char *in ) 70 70 { 71 71 int len; 72 72 73 /* This should get rid of HTML tagsat the beginning of the string. */73 /* This should get rid of the markup noise at the beginning of the string. */ 74 74 while( *in ) 75 75 { … … 86 86 else if( strncmp( in, "\e[", 2 ) == 0 ) 87 87 { 88 c har *s;88 const char *s; 89 89 90 90 for( s = in + 2; *s && *s != 'm'; s ++ ); … … 101 101 } 102 102 103 /* This is supposed to get rid of the closing HTML tagsat the end of the line. */103 /* This is supposed to get rid of the noise at the end of the line. */ 104 104 len = strlen( in ); 105 while( len > 0 && in[len-1] == '>')105 while( len > 0 && ( in[len-1] == '>' || in[len-1] == 'm' ) ) 106 106 { 107 107 int blen = len; 108 109 len --; 110 while( len > 0 && ( in[len] != '<' || in[len+1] != '/' ) ) 108 const char *search; 109 110 if( in[len-1] == '>' ) 111 search = "</"; 112 else 113 search = "\e["; 114 115 len -= 3; 116 while( len > 0 && strncmp( in + len, search, 2 ) != 0 ) 111 117 len --; 112 118 113 if( len == 0 && ( in[len] != '<' || in[len+1] != '/' ))119 if( len <= 0 && strncmp( in, search, 2 ) != 0 ) 114 120 { 115 121 len = blen; … … 121 127 } 122 128 123 static void byahoo_login( struct aim_user *user ) 124 { 125 struct gaim_connection *gc = new_gaim_conn( user ); 126 struct byahoo_data *yd = gc->proto_data = g_new0( struct byahoo_data, 1 ); 129 static void byahoo_init( account_t *acc ) 130 { 131 set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc ); 132 } 133 134 static void byahoo_login( account_t *acc ) 135 { 136 struct im_connection *ic = imcb_new( acc ); 137 struct byahoo_data *yd = ic->proto_data = g_new0( struct byahoo_data, 1 ); 127 138 128 139 yd->logged_in = FALSE; 129 140 yd->current_status = YAHOO_STATUS_AVAILABLE; 130 141 131 set_login_progress( gc, 1, "Connecting" );132 yd->y2_id = yahoo_init( user->username, user->password);142 imcb_log( ic, "Connecting" ); 143 yd->y2_id = yahoo_init( acc->user, acc->pass ); 133 144 yahoo_login( yd->y2_id, yd->current_status ); 134 145 } 135 146 136 static void byahoo_ close( struct gaim_connection *gc )137 { 138 struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;147 static void byahoo_logout( struct im_connection *ic ) 148 { 149 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; 139 150 GSList *l; 140 151 141 while( gc->conversations )142 serv_got_chat_left( gc, gc->conversations->id);152 while( ic->groupchats ) 153 imcb_chat_free( ic->groupchats ); 143 154 144 155 for( l = yd->buddygroups; l; l = l->next ) … … 160 171 } 161 172 162 static void byahoo_get_info(struct gaim_connection *gc, char *who)173 static void byahoo_get_info(struct im_connection *ic, char *who) 163 174 { 164 175 /* Just make an URL and let the user fetch the info */ 165 serv_got_crap(gc, "%s\n%s: %s%s", _("User Info"),176 imcb_log(ic, "%s\n%s: %s%s", _("User Info"), 166 177 _("For now, fetch yourself"), yahoo_get_profile_url(), 167 178 who); 168 179 } 169 180 170 static int byahoo_ send_im( struct gaim_connection *gc, char *who, char *what, int len, int flags )171 { 172 struct byahoo_data *yd = gc->proto_data;173 174 yahoo_send_im( yd->y2_id, NULL, who, what, 1 );181 static int byahoo_buddy_msg( struct im_connection *ic, char *who, char *what, int flags ) 182 { 183 struct byahoo_data *yd = ic->proto_data; 184 185 yahoo_send_im( yd->y2_id, NULL, who, what, 1, 0 ); 175 186 176 187 return 1; 177 188 } 178 189 179 static int byahoo_send_typing( struct gaim_connection *gc, char *who, int typing )180 { 181 struct byahoo_data *yd = gc->proto_data;182 183 yahoo_send_typing( yd->y2_id, NULL, who, typing);190 static int byahoo_send_typing( struct im_connection *ic, char *who, int typing ) 191 { 192 struct byahoo_data *yd = ic->proto_data; 193 194 yahoo_send_typing( yd->y2_id, NULL, who, ( typing & OPT_TYPING ) != 0 ); 184 195 185 196 return 1; 186 197 } 187 198 188 static void byahoo_set_away( struct gaim_connection *gc, char *state, char *msg )189 { 190 struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;191 192 gc->away = NULL;193 194 if( msg)199 static void byahoo_set_away( struct im_connection *ic, char *state, char *msg ) 200 { 201 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; 202 203 ic->away = NULL; 204 205 if( state && msg && g_strcasecmp( state, msg ) != 0 ) 195 206 { 196 207 yd->current_status = YAHOO_STATUS_CUSTOM; 197 gc->away = ""; 198 } 199 if( state ) 200 { 201 gc->away = ""; 208 ic->away = ""; 209 } 210 else if( state ) 211 { 212 /* Set msg to NULL since (if it isn't NULL already) it's equal 213 to state. msg must be empty if we want to use an existing 214 away state. */ 215 msg = NULL; 216 217 ic->away = ""; 202 218 if( g_strcasecmp( state, "Available" ) == 0 ) 203 219 { 204 220 yd->current_status = YAHOO_STATUS_AVAILABLE; 205 gc->away = NULL;221 ic->away = NULL; 206 222 } 207 223 else if( g_strcasecmp( state, "Be Right Back" ) == 0 ) … … 229 245 yd->current_status = YAHOO_STATUS_AVAILABLE; 230 246 231 gc->away = NULL;247 ic->away = NULL; 232 248 } 233 249 } … … 235 251 yd->current_status = YAHOO_STATUS_AVAILABLE; 236 252 237 if( yd->current_status == YAHOO_STATUS_INVISIBLE ) 238 yahoo_set_away( yd->y2_id, yd->current_status, NULL, gc->away != NULL ); 239 else 240 yahoo_set_away( yd->y2_id, yd->current_status, msg, gc->away != NULL ); 241 } 242 243 static GList *byahoo_away_states( struct gaim_connection *gc ) 253 yahoo_set_away( yd->y2_id, yd->current_status, msg, ic->away != NULL ? 2 : 0 ); 254 } 255 256 static GList *byahoo_away_states( struct im_connection *ic ) 244 257 { 245 258 GList *m = NULL; … … 261 274 } 262 275 263 static void byahoo_keepalive( struct gaim_connection *gc )264 { 265 struct byahoo_data *yd = gc->proto_data;276 static void byahoo_keepalive( struct im_connection *ic ) 277 { 278 struct byahoo_data *yd = ic->proto_data; 266 279 267 280 yahoo_keepalive( yd->y2_id ); 268 281 } 269 282 270 static void byahoo_add_buddy( struct gaim_connection *gc, char *who)271 { 272 struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;273 274 yahoo_add_buddy( yd->y2_id, who, BYAHOO_DEFAULT_GROUP);275 } 276 277 static void byahoo_remove_buddy( struct gaim_connection *gc, char *who, char *group )278 { 279 struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;283 static void byahoo_add_buddy( struct im_connection *ic, char *who, char *group ) 284 { 285 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; 286 287 yahoo_add_buddy( yd->y2_id, who, group ? group : BYAHOO_DEFAULT_GROUP, NULL ); 288 } 289 290 static void byahoo_remove_buddy( struct im_connection *ic, char *who, char *group ) 291 { 292 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; 280 293 GSList *bgl; 281 294 … … 291 304 } 292 305 293 static char *byahoo_get_status_string( struct gaim_connection *gc, int stat ) 294 { 295 enum yahoo_status a = stat >> 1; 296 297 switch (a) 298 { 299 case YAHOO_STATUS_BRB: 300 return "Be Right Back"; 301 case YAHOO_STATUS_BUSY: 302 return "Busy"; 303 case YAHOO_STATUS_NOTATHOME: 304 return "Not At Home"; 305 case YAHOO_STATUS_NOTATDESK: 306 return "Not At Desk"; 307 case YAHOO_STATUS_NOTINOFFICE: 308 return "Not In Office"; 309 case YAHOO_STATUS_ONPHONE: 310 return "On Phone"; 311 case YAHOO_STATUS_ONVACATION: 312 return "On Vacation"; 313 case YAHOO_STATUS_OUTTOLUNCH: 314 return "Out To Lunch"; 315 case YAHOO_STATUS_STEPPEDOUT: 316 return "Stepped Out"; 317 case YAHOO_STATUS_INVISIBLE: 318 return "Invisible"; 319 case YAHOO_STATUS_CUSTOM: 320 return "Away"; 321 case YAHOO_STATUS_IDLE: 322 return "Idle"; 323 case YAHOO_STATUS_OFFLINE: 324 return "Offline"; 325 case YAHOO_STATUS_NOTIFY: 326 return "Notify"; 327 default: 328 return "Away"; 329 } 330 } 331 332 static int byahoo_chat_send( struct gaim_connection *gc, int id, char *message ) 333 { 334 struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data; 335 struct conversation *c; 336 337 for( c = gc->conversations; c && c->id != id; c = c->next ); 338 306 static void byahoo_chat_msg( struct groupchat *c, char *message, int flags ) 307 { 308 struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data; 309 339 310 yahoo_conference_message( yd->y2_id, NULL, c->data, c->title, message, 1 ); 340 341 return( 0 ); 342 } 343 344 static void byahoo_chat_invite( struct gaim_connection *gc, int id, char *msg, char *who ) 345 { 346 struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data; 347 struct conversation *c; 348 349 for( c = gc->conversations; c && c->id != id; c = c->next ); 350 351 yahoo_conference_invite( yd->y2_id, NULL, c->data, c->title, msg ); 352 } 353 354 static void byahoo_chat_leave( struct gaim_connection *gc, int id ) 355 { 356 struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data; 357 struct conversation *c; 358 359 for( c = gc->conversations; c && c->id != id; c = c->next ); 311 } 312 313 static void byahoo_chat_invite( struct groupchat *c, char *who, char *msg ) 314 { 315 struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data; 316 317 yahoo_conference_invite( yd->y2_id, NULL, c->data, c->title, msg ? msg : "" ); 318 } 319 320 static void byahoo_chat_leave( struct groupchat *c ) 321 { 322 struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data; 360 323 361 324 yahoo_conference_logoff( yd->y2_id, NULL, c->data, c->title ); 362 serv_got_chat_left( gc, c->id);363 } 364 365 static int byahoo_chat_open( struct gaim_connection *gc, char *who )366 { 367 struct byahoo_data *yd = (struct byahoo_data *) gc->proto_data;368 struct conversation*c;325 imcb_chat_free( c ); 326 } 327 328 static struct groupchat *byahoo_chat_with( struct im_connection *ic, char *who ) 329 { 330 struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data; 331 struct groupchat *c; 369 332 char *roomname; 370 333 YList *members; 371 334 372 roomname = g_new0( char, strlen( gc->username ) + 16 ); 373 g_snprintf( roomname, strlen( gc->username ) + 16, "%s-Bee-%d", gc->username, byahoo_chat_id ); 374 375 c = serv_got_joined_chat( gc, ++byahoo_chat_id, roomname ); 376 add_chat_buddy( c, gc->username ); 335 roomname = g_strdup_printf( "%s-Bee-%d", ic->acc->user, byahoo_chat_id ); 336 337 c = imcb_chat_new( ic, roomname ); 338 imcb_chat_add_buddy( c, ic->acc->user ); 377 339 378 340 /* FIXME: Free this thing when the chat's destroyed. We can't *always* … … 385 347 g_free( roomname ); 386 348 387 return ( 1 );388 } 389 390 void byahoo_init ( )349 return c; 350 } 351 352 void byahoo_initmodule( ) 391 353 { 392 354 struct prpl *ret = g_new0(struct prpl, 1); 393 355 ret->name = "yahoo"; 356 ret->init = byahoo_init; 394 357 395 358 ret->login = byahoo_login; 396 ret->close = byahoo_close; 397 ret->send_im = byahoo_send_im; 359 ret->keepalive = byahoo_keepalive; 360 ret->logout = byahoo_logout; 361 362 ret->buddy_msg = byahoo_buddy_msg; 398 363 ret->get_info = byahoo_get_info; 399 364 ret->away_states = byahoo_away_states; 400 365 ret->set_away = byahoo_set_away; 401 ret->keepalive = byahoo_keepalive;402 366 ret->add_buddy = byahoo_add_buddy; 403 367 ret->remove_buddy = byahoo_remove_buddy; 404 ret->get_status_string = byahoo_get_status_string;405 368 ret->send_typing = byahoo_send_typing; 406 369 407 ret->chat_ send = byahoo_chat_send;370 ret->chat_msg = byahoo_chat_msg; 408 371 ret->chat_invite = byahoo_chat_invite; 409 372 ret->chat_leave = byahoo_chat_leave; 410 ret->chat_open = byahoo_chat_open; 411 ret->cmp_buddynames = g_strcasecmp; 373 ret->chat_with = byahoo_chat_with; 374 375 ret->handle_cmp = g_strcasecmp; 412 376 413 377 register_protocol(ret); 414 378 } 415 379 416 static struct gaim_connection *byahoo_get_gc_by_id( int id )380 static struct im_connection *byahoo_get_ic_by_id( int id ) 417 381 { 418 382 GSList *l; 419 struct gaim_connection *gc;383 struct im_connection *ic; 420 384 struct byahoo_data *yd; 421 385 422 386 for( l = get_connections(); l; l = l->next ) 423 387 { 424 gc = l->data;425 yd = gc->proto_data;426 427 if( !strcmp(gc->prpl->name, "yahoo")&& yd->y2_id == id )428 return( gc );388 ic = l->data; 389 yd = ic->proto_data; 390 391 if( strcmp( ic->acc->prpl->name, "yahoo" ) == 0 && yd->y2_id == id ) 392 return( ic ); 429 393 } 430 394 … … 443 407 }; 444 408 445 void byahoo_connect_callback( gpointer data, gint source, GaimInputCondition cond )409 void byahoo_connect_callback( gpointer data, gint source, b_input_condition cond ) 446 410 { 447 411 struct byahoo_connect_callback_data *d = data; 448 412 449 if( !byahoo_get_ gc_by_id( d->id ) )413 if( !byahoo_get_ic_by_id( d->id ) ) 450 414 { 451 415 g_free( d ); … … 465 429 }; 466 430 467 void byahoo_read_ready_callback( gpointer data, gint source, GaimInputCondition cond )431 gboolean byahoo_read_ready_callback( gpointer data, gint source, b_input_condition cond ) 468 432 { 469 433 struct byahoo_read_ready_data *d = data; 470 434 471 if( !byahoo_get_gc_by_id( d->id ) ) 472 { 435 if( !byahoo_get_ic_by_id( d->id ) ) 473 436 /* WTF doesn't libyahoo clean this up? */ 474 ext_yahoo_remove_handler( d->id, d->tag ); 475 return; 476 } 437 return FALSE; 477 438 478 439 yahoo_read_ready( d->id, d->fd, d->data ); 440 441 return TRUE; 479 442 } 480 443 … … 487 450 }; 488 451 489 void byahoo_write_ready_callback( gpointer data, gint source, GaimInputCondition cond )452 gboolean byahoo_write_ready_callback( gpointer data, gint source, b_input_condition cond ) 490 453 { 491 454 struct byahoo_write_ready_data *d = data; 492 455 493 if( !byahoo_get_gc_by_id( d->id ) ) 494 { 456 if( !byahoo_get_ic_by_id( d->id ) ) 495 457 /* WTF doesn't libyahoo clean this up? */ 496 ext_yahoo_remove_handler( d->id, d->tag ); 497 return; 498 } 458 return FALSE; 499 459 500 460 yahoo_write_ready( d->id, d->fd, d->data ); 501 } 502 503 void ext_yahoo_login_response( int id, int succ, char *url ) 504 { 505 struct gaim_connection *gc = byahoo_get_gc_by_id( id ); 461 462 return FALSE; 463 } 464 465 void ext_yahoo_login_response( int id, int succ, const char *url ) 466 { 467 struct im_connection *ic = byahoo_get_ic_by_id( id ); 506 468 struct byahoo_data *yd = NULL; 507 469 508 if( gc == NULL )470 if( ic == NULL ) 509 471 { 510 472 /* libyahoo2 seems to call this one twice when something … … 516 478 } 517 479 518 yd = (struct byahoo_data *) gc->proto_data;480 yd = (struct byahoo_data *) ic->proto_data; 519 481 520 482 if( succ == YAHOO_LOGIN_OK ) 521 483 { 522 account_online( gc );484 imcb_connected( ic ); 523 485 524 486 yd->logged_in = TRUE; … … 527 489 { 528 490 char *errstr; 529 char *s;491 int allow_reconnect = TRUE; 530 492 531 493 yd->logged_in = FALSE; … … 540 502 { 541 503 errstr = "Logged in on a different machine or device"; 542 gc->wants_to_die = TRUE;504 allow_reconnect = FALSE; 543 505 } 544 506 else if( succ == YAHOO_LOGIN_SOCK ) … … 548 510 549 511 if( url && *url ) 550 { 551 s = g_malloc( strlen( "Error %d (%s). See %s for more information." ) + strlen( url ) + strlen( errstr ) + 16 ); 552 sprintf( s, "Error %d (%s). See %s for more information.", succ, errstr, url ); 553 } 512 imcb_error( ic, "Error %d (%s). See %s for more information.", succ, errstr, url ); 554 513 else 555 { 556 s = g_malloc( strlen( "Error %d (%s)" ) + strlen( errstr ) + 16 ); 557 sprintf( s, "Error %d (%s)", succ, errstr ); 558 } 559 560 if( yd->logged_in ) 561 hide_login_progress_error( gc, s ); 562 else 563 hide_login_progress( gc, s ); 564 565 g_free( s ); 566 567 signoff( gc ); 514 imcb_error( ic, "Error %d (%s)", succ, errstr ); 515 516 imc_logout( ic, allow_reconnect ); 568 517 } 569 518 } … … 571 520 void ext_yahoo_got_buddies( int id, YList *buds ) 572 521 { 573 struct gaim_connection *gc = byahoo_get_gc_by_id( id );574 struct byahoo_data *yd = gc->proto_data;522 struct im_connection *ic = byahoo_get_ic_by_id( id ); 523 struct byahoo_data *yd = ic->proto_data; 575 524 YList *bl = buds; 576 525 … … 589 538 } 590 539 591 add_buddy( gc, b->group, b->id, b->real_name ); 540 imcb_add_buddy( ic, b->id, b->group ); 541 imcb_rename_buddy( ic, b->id, b->real_name ); 542 592 543 bl = bl->next; 593 544 } … … 606 557 } 607 558 608 void ext_yahoo_status_changed( int id, char *who, int stat, char *msg, int away ) 609 { 610 struct gaim_connection *gc = byahoo_get_gc_by_id( id ); 611 612 serv_got_update( gc, who, stat != YAHOO_STATUS_OFFLINE, 0, 0, 613 ( stat == YAHOO_STATUS_IDLE ) ? away : 0, 614 ( stat != YAHOO_STATUS_AVAILABLE ) | ( stat << 1 ), 0 ); 615 } 616 617 void ext_yahoo_got_im( int id, char *who, char *msg, long tm, int stat, int utf8 ) 618 { 619 struct gaim_connection *gc = byahoo_get_gc_by_id( id ); 620 char *m = byahoo_strip( msg ); 621 622 serv_got_im( gc, who, m, 0, 0, strlen( m ) ); 623 g_free( m ); 624 } 625 626 void ext_yahoo_got_file( int id, char *who, char *url, long expires, char *msg, char *fname, unsigned long fesize ) 627 { 628 struct gaim_connection *gc = byahoo_get_gc_by_id( id ); 629 630 serv_got_crap( gc, "Got a file transfer (file = %s) from %s. Ignoring for now due to lack of support.", fname, who ); 631 } 632 633 void ext_yahoo_typing_notify( int id, char *who, int stat ) 634 { 635 struct gaim_connection *gc = byahoo_get_gc_by_id( id ); 636 if (stat == 1) { 637 /* User is typing */ 638 serv_got_typing( gc, who, 1, 1 ); 639 } 640 else { 641 /* User stopped typing */ 642 serv_got_typing( gc, who, 1, 0 ); 643 } 644 } 645 646 void ext_yahoo_system_message( int id, char *msg ) 647 { 648 struct gaim_connection *gc = byahoo_get_gc_by_id( id ); 649 650 serv_got_crap( gc, "Yahoo! system message: %s", msg ); 651 } 652 653 void ext_yahoo_webcam_invite( int id, char *from ) 654 { 655 struct gaim_connection *gc = byahoo_get_gc_by_id( id ); 656 657 serv_got_crap( gc, "Got a webcam invitation from %s. IRC+webcams is a no-no though...", from ); 658 } 659 660 void ext_yahoo_error( int id, char *err, int fatal ) 661 { 662 struct gaim_connection *gc = byahoo_get_gc_by_id( id ); 559 void ext_yahoo_status_changed( int id, const char *who, int stat, const char *msg, int away, int idle, int mobile ) 560 { 561 struct im_connection *ic = byahoo_get_ic_by_id( id ); 562 char *state_string = NULL; 563 int flags = OPT_LOGGED_IN; 564 565 if( away ) 566 flags |= OPT_AWAY; 567 568 switch (stat) 569 { 570 case YAHOO_STATUS_BRB: 571 state_string = "Be Right Back"; 572 break; 573 case YAHOO_STATUS_BUSY: 574 state_string = "Busy"; 575 break; 576 case YAHOO_STATUS_NOTATHOME: 577 state_string = "Not At Home"; 578 break; 579 case YAHOO_STATUS_NOTATDESK: 580 state_string = "Not At Desk"; 581 break; 582 case YAHOO_STATUS_NOTINOFFICE: 583 state_string = "Not In Office"; 584 break; 585 case YAHOO_STATUS_ONPHONE: 586 state_string = "On Phone"; 587 break; 588 case YAHOO_STATUS_ONVACATION: 589 state_string = "On Vacation"; 590 break; 591 case YAHOO_STATUS_OUTTOLUNCH: 592 state_string = "Out To Lunch"; 593 break; 594 case YAHOO_STATUS_STEPPEDOUT: 595 state_string = "Stepped Out"; 596 break; 597 case YAHOO_STATUS_INVISIBLE: 598 state_string = "Invisible"; 599 break; 600 case YAHOO_STATUS_CUSTOM: 601 state_string = "Away"; 602 break; 603 case YAHOO_STATUS_IDLE: 604 state_string = "Idle"; 605 break; 606 case YAHOO_STATUS_OFFLINE: 607 state_string = "Offline"; 608 flags = 0; 609 break; 610 case YAHOO_STATUS_NOTIFY: 611 state_string = "Notify"; 612 break; 613 } 614 615 imcb_buddy_status( ic, who, flags, state_string, msg ); 616 617 /* Not implemented yet... 618 if( stat == YAHOO_STATUS_IDLE ) 619 imcb_buddy_times( ic, who, 0, away ); 620 */ 621 } 622 623 void ext_yahoo_got_im( int id, const char *me, const char *who, const char *msg, long tm, int stat, int utf8 ) 624 { 625 struct im_connection *ic = byahoo_get_ic_by_id( id ); 626 char *m; 627 628 if( msg ) 629 { 630 m = byahoo_strip( msg ); 631 imcb_buddy_msg( ic, (char*) who, (char*) m, 0, 0 ); 632 g_free( m ); 633 } 634 } 635 636 void ext_yahoo_got_file( int id, 637 const char *ignored, 638 const char *who, const char *url, long expires, const char *msg, const char *fname, unsigned long fesize ) 639 { 640 struct im_connection *ic = byahoo_get_ic_by_id( id ); 641 642 imcb_log( ic, "Got a file transfer (file = %s) from %s. Ignoring for now due to lack of support.", fname, who ); 643 } 644 645 void ext_yahoo_typing_notify( int id, const char *ignored, const char *who, int stat ) 646 { 647 struct im_connection *ic = byahoo_get_ic_by_id( id ); 648 649 if( stat == 1 ) 650 imcb_buddy_typing( ic, (char*) who, OPT_TYPING ); 651 else 652 imcb_buddy_typing( ic, (char*) who, 0 ); 653 } 654 655 void ext_yahoo_system_message( int id, const char *msg ) 656 { 657 struct im_connection *ic = byahoo_get_ic_by_id( id ); 658 659 imcb_log( ic, "Yahoo! system message: %s", msg ); 660 } 661 662 void ext_yahoo_webcam_invite( int id, const char *ignored, const char *from ) 663 { 664 struct im_connection *ic = byahoo_get_ic_by_id( id ); 665 666 imcb_log( ic, "Got a webcam invitation from %s. IRC+webcams is a no-no though...", from ); 667 } 668 669 void ext_yahoo_error( int id, const char *err, int fatal, int num ) 670 { 671 struct im_connection *ic = byahoo_get_ic_by_id( id ); 672 673 imcb_error( ic, "%s", err ); 663 674 664 675 if( fatal ) 665 { 666 hide_login_progress_error( gc, err ); 667 signoff( gc ); 668 } 669 else 670 { 671 do_error_dialog( gc, err, "Yahoo! error" ); 672 } 676 imc_logout( ic, TRUE ); 673 677 } 674 678 … … 687 691 688 692 inp->d = d; 689 d->tag = inp->h = gaim_input_add( fd, GAIM_INPUT_READ, (GaimInputFunction) byahoo_read_ready_callback, (gpointer) d );693 d->tag = inp->h = b_input_add( fd, GAIM_INPUT_READ, (b_event_handler) byahoo_read_ready_callback, (gpointer) d ); 690 694 } 691 695 else if( cond == YAHOO_INPUT_WRITE ) … … 698 702 699 703 inp->d = d; 700 d->tag = inp->h = gaim_input_add( fd, GAIM_INPUT_WRITE, (GaimInputFunction) byahoo_write_ready_callback, (gpointer) d );704 d->tag = inp->h = b_input_add( fd, GAIM_INPUT_WRITE, (b_event_handler) byahoo_write_ready_callback, (gpointer) d ); 701 705 } 702 706 else … … 729 733 } 730 734 731 gaim_input_remove( tag );732 } 733 734 int ext_yahoo_connect_async( int id, c har *host, int port, yahoo_connect_callback callback, void *data )735 b_event_remove( tag ); 736 } 737 738 int ext_yahoo_connect_async( int id, const char *host, int port, yahoo_connect_callback callback, void *data ) 735 739 { 736 740 struct byahoo_connect_callback_data *d; … … 738 742 739 743 d = g_new0( struct byahoo_connect_callback_data, 1 ); 740 if( ( fd = proxy_connect( host, port, ( GaimInputFunction) byahoo_connect_callback, (gpointer) d ) ) < 0 )744 if( ( fd = proxy_connect( host, port, (b_event_handler) byahoo_connect_callback, (gpointer) d ) ) < 0 ) 741 745 { 742 746 g_free( d ); … … 753 757 /* Because we don't want asynchronous connects in BitlBee, and because 754 758 libyahoo doesn't seem to use this one anyway, this one is now defunct. */ 755 int ext_yahoo_connect(c har *host, int port)759 int ext_yahoo_connect(const char *host, int port) 756 760 { 757 761 #if 0 … … 796 800 { 797 801 yahoo_conference_logon( inv->yid, NULL, inv->members, inv->name ); 798 add_chat_buddy( inv->c, inv->gc->username);802 imcb_chat_add_buddy( inv->c, inv->ic->acc->user ); 799 803 g_free( inv->name ); 800 804 g_free( inv ); … … 804 808 { 805 809 yahoo_conference_decline( inv->yid, NULL, inv->members, inv->name, "User rejected groupchat" ); 806 serv_got_chat_left( inv->gc, inv->c->id);810 imcb_chat_free( inv->c ); 807 811 g_free( inv->name ); 808 812 g_free( inv ); 809 813 } 810 814 811 void ext_yahoo_got_conf_invite( int id, char *who, char *room, char *msg, YList *members ) 812 { 813 struct gaim_connection *gc = byahoo_get_gc_by_id( id ); 815 void ext_yahoo_got_conf_invite( int id, const char *ignored, 816 const char *who, const char *room, const char *msg, YList *members ) 817 { 818 struct im_connection *ic = byahoo_get_ic_by_id( id ); 814 819 struct byahoo_conf_invitation *inv; 815 820 char txt[1024]; … … 819 824 memset( inv, 0, sizeof( struct byahoo_conf_invitation ) ); 820 825 inv->name = g_strdup( room ); 821 inv->c = serv_got_joined_chat( gc, ++byahoo_chat_id,room );826 inv->c = imcb_chat_new( ic, (char*) room ); 822 827 inv->c->data = members; 823 828 inv->yid = id; 824 829 inv->members = members; 825 inv-> gc = gc;830 inv->ic = ic; 826 831 827 832 for( m = members; m; m = m->next ) 828 if( g_strcasecmp( m->data, gc->username) != 0 )829 add_chat_buddy( inv->c, m->data );833 if( g_strcasecmp( m->data, ic->acc->user ) != 0 ) 834 imcb_chat_add_buddy( inv->c, m->data ); 830 835 831 836 g_snprintf( txt, 1024, "Got an invitation to chatroom %s from %s: %s", room, who, msg ); 832 837 833 do_ask_dialog( gc, txt, inv, byahoo_accept_conf, byahoo_reject_conf );834 } 835 836 void ext_yahoo_conf_userdecline( int id, c har *who, char *room,char *msg )837 { 838 struct gaim_connection *gc = byahoo_get_gc_by_id( id );839 840 serv_got_crap( gc, "Invite to chatroom %s rejected by %s: %s", room, who, msg );841 } 842 843 void ext_yahoo_conf_userjoin( int id, c har *who,char *room )844 { 845 struct gaim_connection *gc = byahoo_get_gc_by_id( id );846 struct conversation*c;847 848 for( c = gc->conversations; c && strcmp( c->title, room ) != 0; c = c->next );838 imcb_ask( ic, txt, inv, byahoo_accept_conf, byahoo_reject_conf ); 839 } 840 841 void ext_yahoo_conf_userdecline( int id, const char *ignored, const char *who, const char *room, const char *msg ) 842 { 843 struct im_connection *ic = byahoo_get_ic_by_id( id ); 844 845 imcb_log( ic, "Invite to chatroom %s rejected by %s: %s", room, who, msg ); 846 } 847 848 void ext_yahoo_conf_userjoin( int id, const char *ignored, const char *who, const char *room ) 849 { 850 struct im_connection *ic = byahoo_get_ic_by_id( id ); 851 struct groupchat *c; 852 853 for( c = ic->groupchats; c && strcmp( c->title, room ) != 0; c = c->next ); 849 854 850 855 if( c ) 851 add_chat_buddy( c, who ); 852 } 853 854 void ext_yahoo_conf_userleave( int id, char *who, char *room ) 855 { 856 struct gaim_connection *gc = byahoo_get_gc_by_id( id ); 857 struct conversation *c; 858 859 for( c = gc->conversations; c && strcmp( c->title, room ) != 0; c = c->next ); 856 imcb_chat_add_buddy( c, (char*) who ); 857 } 858 859 void ext_yahoo_conf_userleave( int id, const char *ignored, const char *who, const char *room ) 860 861 { 862 struct im_connection *ic = byahoo_get_ic_by_id( id ); 863 struct groupchat *c; 864 865 for( c = ic->groupchats; c && strcmp( c->title, room ) != 0; c = c->next ); 860 866 861 867 if( c ) 862 remove_chat_buddy( c,who, "" );863 } 864 865 void ext_yahoo_conf_message( int id, c har *who, char *room,char *msg, int utf8 )866 { 867 struct gaim_connection *gc = byahoo_get_gc_by_id( id );868 imcb_chat_remove_buddy( c, (char*) who, "" ); 869 } 870 871 void ext_yahoo_conf_message( int id, const char *ignored, const char *who, const char *room, const char *msg, int utf8 ) 872 { 873 struct im_connection *ic = byahoo_get_ic_by_id( id ); 868 874 char *m = byahoo_strip( msg ); 869 struct conversation *c; 870 871 for( c = gc->conversations; c && strcmp( c->title, room ) != 0; c = c->next ); 872 873 serv_got_chat_in( gc, c ? c->id : 0, who, 0, m, 0 ); 875 struct groupchat *c; 876 877 for( c = ic->groupchats; c && strcmp( c->title, room ) != 0; c = c->next ); 878 879 if( c ) 880 imcb_chat_msg( c, (char*) who, (char*) m, 0, 0 ); 874 881 g_free( m ); 875 882 } 876 883 877 void ext_yahoo_chat_cat_xml( int id, char *xml ) 878 { 879 } 880 881 void ext_yahoo_chat_join( int id, char *room, char *topic, YList *members, int fd ) 882 { 883 } 884 885 void ext_yahoo_chat_userjoin( int id, char *room, struct yahoo_chat_member *who ) 886 { 887 } 888 889 void ext_yahoo_chat_userleave( int id, char *room, char *who ) 890 { 891 } 892 893 void ext_yahoo_chat_message( int id, char *who, char *room, char *msg, int msgtype, int utf8 ) 894 { 895 } 896 897 void ext_yahoo_chat_yahoologout( int id ) 898 { 899 } 900 901 void ext_yahoo_chat_yahooerror( int id ) 902 { 903 } 904 905 void ext_yahoo_contact_added( int id, char *myid, char *who, char *msg ) 906 { 907 } 908 909 void ext_yahoo_rejected( int id, char *who, char *msg ) 910 { 911 } 912 913 void ext_yahoo_game_notify( int id, char *who, int stat ) 914 { 915 } 916 917 void ext_yahoo_mail_notify( int id, char *from, char *subj, int cnt ) 918 { 919 struct gaim_connection *gc = byahoo_get_gc_by_id( id ); 920 921 if( from && subj ) 922 serv_got_crap( gc, "Received e-mail message from %s with subject `%s'", from, subj ); 884 void ext_yahoo_chat_cat_xml( int id, const char *xml ) 885 { 886 } 887 888 void ext_yahoo_chat_join( int id, const char *who, const char *room, const char *topic, YList *members, int fd ) 889 { 890 } 891 892 void ext_yahoo_chat_userjoin( int id, const char *me, const char *room, struct yahoo_chat_member *who ) 893 { 894 free(who->id); 895 free(who->alias); 896 free(who->location); 897 free(who); 898 } 899 900 void ext_yahoo_chat_userleave( int id, const char *me, const char *room, const char *who ) 901 { 902 } 903 904 void ext_yahoo_chat_message( int id, const char *me, const char *who, const char *room, const char *msg, int msgtype, int utf8 ) 905 { 906 } 907 908 void ext_yahoo_chat_yahoologout( int id, const char *me ) 909 { 910 } 911 912 void ext_yahoo_chat_yahooerror( int id, const char *me ) 913 { 914 } 915 916 void ext_yahoo_contact_added( int id, const char *myid, const char *who, const char *msg ) 917 { 918 /* Groups schmoups. If I want to handle groups properly I can get the 919 buddy data from some internal libyahoo2 structure. */ 920 imcb_add_buddy( byahoo_get_ic_by_id( id ), (char*) who, NULL ); 921 } 922 923 void ext_yahoo_rejected( int id, const char *who, const char *msg ) 924 { 925 } 926 927 void ext_yahoo_game_notify( int id, const char *me, const char *who, int stat ) 928 { 929 } 930 931 void ext_yahoo_mail_notify( int id, const char *from, const char *subj, int cnt ) 932 { 933 struct im_connection *ic = byahoo_get_ic_by_id( id ); 934 935 if( !set_getbool( &ic->acc->set, "mail_notifications" ) ) 936 ; /* The user doesn't care. */ 937 else if( from && subj ) 938 imcb_log( ic, "Received e-mail message from %s with subject `%s'", from, subj ); 923 939 else if( cnt > 0 ) 924 serv_got_crap( gc, "Received %d new e-mails", cnt );925 } 926 927 void ext_yahoo_webcam_invite_reply( int id, c har *from, int accept )928 { 929 } 930 931 void ext_yahoo_webcam_closed( int id, c har *who, int reason )940 imcb_log( ic, "Received %d new e-mails", cnt ); 941 } 942 943 void ext_yahoo_webcam_invite_reply( int id, const char *me, const char *from, int accept ) 944 { 945 } 946 947 void ext_yahoo_webcam_closed( int id, const char *who, int reason ) 932 948 { 933 949 } … … 937 953 } 938 954 939 void ext_yahoo_webcam_viewer( int id, c har *who, int connect )955 void ext_yahoo_webcam_viewer( int id, const char *who, int connect ) 940 956 { 941 957 } … … 945 961 } 946 962 947 int ext_yahoo_log( c har *fmt, ... )963 int ext_yahoo_log( const char *fmt, ... ) 948 964 { 949 965 return( 0 ); … … 953 969 { 954 970 } 971 972 void ext_yahoo_got_ping( int id, const char *msg) 973 { 974 } 975 976 void ext_yahoo_got_buddyicon (int id, const char *me, const char *who, const char *url, int checksum) {} 977 void ext_yahoo_got_buddyicon_checksum (int id, const char *me,const char *who, int checksum) {} 978 979 void ext_yahoo_got_buddyicon_request(int id, const char *me, const char *who){} 980 void ext_yahoo_buddyicon_uploaded(int id, const char *url){} -
protocols/yahoo/yahoo2.h
r875ad42 r85d7b85 120 120 /* from is the identity you're sending from. if NULL, the default is used */ 121 121 /* utf8 is whether msg is a utf8 string or not. */ 122 void yahoo_send_im(int id, const char *from, const char *who, const char *msg, int utf8 );122 void yahoo_send_im(int id, const char *from, const char *who, const char *msg, int utf8, int picture); 123 123 /* if type is true, send typing notice, else send stopped typing notice */ 124 124 void yahoo_send_typing(int id, const char *from, const char *who, int typ); … … 128 128 void yahoo_set_away(int id, enum yahoo_status state, const char *msg, int away); 129 129 130 void yahoo_add_buddy(int id, const char *who, const char *group );130 void yahoo_add_buddy(int id, const char *who, const char *group, const char *msg); 131 131 void yahoo_remove_buddy(int id, const char *who, const char *group); 132 132 void yahoo_reject_buddy(int id, const char *who, const char *msg); 133 void yahoo_stealth_buddy(int id, const char *who, int unstealth); 133 134 /* if unignore is true, unignore, else ignore */ 134 135 void yahoo_ignore_buddy(int id, const char *who, int unignore); … … 214 215 const char * yahoo_get_profile_url( void ); 215 216 217 void yahoo_buddyicon_request(int id, const char *who); 218 216 219 #include "yahoo_httplib.h" 217 220 -
protocols/yahoo/yahoo2_callbacks.h
r875ad42 r85d7b85 29 29 * declared in this file and defined in libyahoo2.c 30 30 */ 31 32 31 33 32 … … 67 66 68 67 69 70 68 /* 71 69 * The following functions need to be implemented in the client … … 96 94 * url - url to reactivate account if locked 97 95 */ 98 void YAHOO_CALLBACK_TYPE(ext_yahoo_login_response)(int id, int succ, char *url); 99 100 96 void YAHOO_CALLBACK_TYPE(ext_yahoo_login_response)(int id, int succ, const char *url); 101 97 102 98 … … 111 107 112 108 113 114 115 109 /* 116 110 * Name: ext_yahoo_got_ignore … … 123 117 124 118 125 126 127 128 119 /* 129 120 * Name: ext_yahoo_got_identities … … 136 127 137 128 138 139 140 141 129 /* 142 130 * Name: ext_yahoo_got_cookies … … 148 136 149 137 138 /* 139 * Name: ext_yahoo_got_ping 140 * Called when the ping packet is received from the server 141 * Params: 142 * id - the id that identifies the server connection 143 * errormsg - optional error message 144 */ 145 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_ping)(int id, const char *errormsg); 150 146 151 147 … … 159 155 * msg - the message if stat == YAHOO_STATUS_CUSTOM 160 156 * away - whether the contact is away or not (YAHOO_STATUS_CUSTOM) 161 * for YAHOO_STATUS_IDLE, this is the number of seconds he is idle162 * /163 void YAHOO_CALLBACK_TYPE(ext_yahoo_status_changed)(int id, char *who, int stat, char *msg, int away); 164 165 157 * idle - this is the number of seconds he is idle [if he is idle] 158 * mobile - this is set for mobile users/buddies 159 * TODO: add support for pager, chat, and game states 160 */ 161 void YAHOO_CALLBACK_TYPE(ext_yahoo_status_changed)(int id, const char *who, int stat, const char *msg, int away, int idle, int mobile); 166 162 167 163 … … 171 167 * Params: 172 168 * id - the id that identifies the server connection 169 * me - the identity the message was sent to 173 170 * who - the handle of the remote user 174 171 * msg - the message - NULL if stat == 2 … … 180 177 * utf8 - whether the message is encoded as utf8 or not 181 178 */ 182 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_im)(int id, char *who, char *msg, long tm, int stat, int utf8); 183 184 179 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_im)(int id, const char *me, const char *who, const char *msg, long tm, int stat, int utf8); 185 180 186 181 … … 190 185 * Params: 191 186 * id - the id that identifies the server connection 187 * me - the identity the invitation was sent to 192 188 * who - the user inviting you 193 189 * room - the room to join … … 195 191 * members - the initial members of the conference (null terminated list) 196 192 */ 197 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_conf_invite)(int id, char *who, char *room, char *msg, YList *members); 198 199 193 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_conf_invite)(int id, const char *me, const char *who, const char *room, const char *msg, YList *members); 200 194 201 195 … … 205 199 * Params: 206 200 * id - the id that identifies the server connection 201 * me - the identity in the conference 207 202 * who - the user who has declined 208 203 * room - the room 209 204 * msg - the declining message 210 205 */ 211 void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userdecline)(int id, char *who, char *room, char *msg); 212 213 206 void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userdecline)(int id, const char *me, const char *who, const char *room, const char *msg); 214 207 215 208 … … 219 212 * Params: 220 213 * id - the id that identifies the server connection 214 * me - the identity in the conference 221 215 * who - the user who has joined 222 216 * room - the room joined 223 217 */ 224 void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userjoin)(int id, char *who, char *room); 225 226 218 void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userjoin)(int id, const char *me, const char *who, const char *room); 227 219 228 220 … … 232 224 * Params: 233 225 * id - the id that identifies the server connection 226 * me - the identity in the conference 234 227 * who - the user who has left 235 228 * room - the room left 236 229 */ 237 void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userleave)(int id, char *who, char *room); 238 239 240 241 230 void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userleave)(int id, const char *me, const char *who, const char *room); 242 231 243 232 244 233 /* 245 234 * Name: ext_yahoo_chat_cat_xml 246 * Called when joining the chatroom.235 * Called when ? 247 236 * Params: 248 237 * id - the id that identifies the server connection 249 * room - the room joined, used in all other chat calls, freed by 250 * library after call 251 * topic - the topic of the room, freed by library after call 252 * members - the initial members of the chatroom (null terminated YList of 253 * yahoo_chat_member's) Must be freed by the client 254 */ 255 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_cat_xml)(int id, char *xml); 256 257 258 259 260 238 * xml - ? 239 */ 240 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_cat_xml)(int id, const char *xml); 261 241 262 242 … … 266 246 * Params: 267 247 * id - the id that identifies the server connection 248 * me - the identity in the chatroom 268 249 * room - the room joined, used in all other chat calls, freed by 269 250 * library after call … … 273 254 * fd - the socket where the connection is coming from (for tracking) 274 255 */ 275 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_join)(int id, char *room, char *topic, YList *members, int fd); 276 277 278 279 256 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_join)(int id, const char *me, const char *room, const char *topic, YList *members, int fd); 280 257 281 258 … … 285 262 * Params: 286 263 * id - the id that identifies the server connection 264 * me - the identity in the chatroom 287 265 * room - the room joined 288 266 * who - the user who has joined, Must be freed by the client 289 267 */ 290 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userjoin)(int id, char *room, struct yahoo_chat_member *who); 291 292 268 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userjoin)(int id, const char *me, const char *room, struct yahoo_chat_member *who); 293 269 294 270 … … 298 274 * Params: 299 275 * id - the id that identifies the server connection 276 * me - the identity in the chatroom 300 277 * room - the room left 301 278 * who - the user who has left (Just the User ID) 302 279 */ 303 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userleave)(int id, char *room, char *who); 304 305 280 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userleave)(int id, const char *me, const char *room, const char *who); 306 281 307 282 … … 311 286 * Params: 312 287 * id - the id that identifies the server connection 288 * me - the identity in the chatroom 313 289 * room - the room 314 290 * who - the user who messaged (Just the user id) … … 318 294 * utf8 - whether the message is utf8 encoded or not 319 295 */ 320 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_message)(int id, char *who, char *room, char *msg, int msgtype, int utf8); 296 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_message)(int id, const char *me, const char *who, const char *room, const char *msg, int msgtype, int utf8); 297 321 298 322 299 /* … … 329 306 * Params: 330 307 * id - the id that identifies this connection 308 * me - the identity in the chatroom 331 309 * Returns: 332 310 * nothing. 333 311 */ 334 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahoologout)(int id); 312 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahoologout)(int id, const char *me); 313 335 314 336 315 /* … … 344 323 * Params: 345 324 * id - the id that identifies this connection 325 * me - the identity in the chatroom 346 326 * Returns: 347 327 * nothing. 348 328 */ 349 350 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahooerror)(int id); 329 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahooerror)(int id, const char *me); 330 351 331 352 332 /* … … 355 335 * Params: 356 336 * id - the id that identifies the server connection 337 * me - the identity the conf message was sent to 357 338 * who - the user who messaged 358 339 * room - the room … … 360 341 * utf8 - whether the message is utf8 encoded or not 361 342 */ 362 void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_message)(int id, char *who, char *room, char *msg, int utf8); 363 364 343 void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_message)(int id, const char *me, const char *who, const char *room, const char *msg, int utf8); 365 344 366 345 … … 370 349 * Params: 371 350 * id - the id that identifies the server connection 351 * me - the identity the file was sent to 372 352 * who - the user who sent the file 373 353 * url - the file url … … 377 357 * fsize- the file size if direct transfer 378 358 */ 379 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_file)(int id, char *who, char *url, long expires, char *msg, char *fname, unsigned long fesize); 380 381 359 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_file)(int id, const char *me, const char *who, const char *url, long expires, const char *msg, const char *fname, unsigned long fesize); 382 360 383 361 … … 391 369 * msg - any message sent 392 370 */ 393 void YAHOO_CALLBACK_TYPE(ext_yahoo_contact_added)(int id, char *myid, char *who, char *msg); 394 395 371 void YAHOO_CALLBACK_TYPE(ext_yahoo_contact_added)(int id, const char *myid, const char *who, const char *msg); 396 372 397 373 … … 404 380 * msg - any message sent 405 381 */ 406 void YAHOO_CALLBACK_TYPE(ext_yahoo_rejected)(int id, char *who, char *msg); 407 408 382 void YAHOO_CALLBACK_TYPE(ext_yahoo_rejected)(int id, const char *who, const char *msg); 409 383 410 384 … … 414 388 * Params: 415 389 * id - the id that identifies the server connection 390 * me - the handle of the identity the notification is sent to 416 391 * who - the handle of the remote user 417 392 * stat - 1 if typing, 0 if stopped typing 418 393 */ 419 void YAHOO_CALLBACK_TYPE(ext_yahoo_typing_notify)(int id, char *who, int stat); 420 421 394 void YAHOO_CALLBACK_TYPE(ext_yahoo_typing_notify)(int id, const char *me, const char *who, int stat); 422 395 423 396 … … 427 400 * Params: 428 401 * id - the id that identifies the server connection 402 * me - the handle of the identity the notification is sent to 429 403 * who - the handle of the remote user 430 404 * stat - 1 if game, 0 if stopped gaming 431 405 */ 432 void YAHOO_CALLBACK_TYPE(ext_yahoo_game_notify)(int id, char *who, int stat); 433 434 406 void YAHOO_CALLBACK_TYPE(ext_yahoo_game_notify)(int id, const char *me, const char *who, int stat); 435 407 436 408 … … 444 416 * cnt - mail count - 0 if new mail notification 445 417 */ 446 void YAHOO_CALLBACK_TYPE(ext_yahoo_mail_notify)(int id, char *from, char *subj, int cnt); 447 448 418 void YAHOO_CALLBACK_TYPE(ext_yahoo_mail_notify)(int id, const char *from, const char *subj, int cnt); 449 419 450 420 … … 456 426 * msg - the message 457 427 */ 458 void YAHOO_CALLBACK_TYPE(ext_yahoo_system_message)(int id, char *msg); 459 460 461 462 463 464 465 466 467 468 428 void YAHOO_CALLBACK_TYPE(ext_yahoo_system_message)(int id, const char *msg); 429 430 /* 431 * Name: ext_yahoo_got_buddyicon 432 * Buddy icon received 433 * Params: 434 * id - the id that identifies the server connection 435 * me - the handle of the identity the notification is sent to 436 * who - the person the buddy icon is for 437 * url - the url to use to load the icon 438 * checksum - the checksum of the icon content 439 */ 440 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon)(int id, const char *me, const char *who, const char *url, int checksum); 441 442 /* 443 * Name: ext_yahoo_got_buddyicon_checksum 444 * Buddy icon checksum received 445 * Params: 446 * id - the id that identifies the server connection 447 * me - the handle of the identity the notification is sent to 448 * who - the yahoo id of the buddy icon checksum is for 449 * checksum - the checksum of the icon content 450 */ 451 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon_checksum)(int id, const char *me,const char *who, int checksum); 452 453 /* 454 * Name: ext_yahoo_got_buddyicon_request 455 * Buddy icon request received 456 * Params: 457 * id - the id that identifies the server connection 458 * me - the handle of the identity the notification is sent to 459 * who - the yahoo id of the buddy that requested the buddy icon 460 */ 461 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon_request)(int id, const char *me, const char *who); 462 463 /* 464 * Name: ext_yahoo_got_buddyicon_request 465 * Buddy icon request received 466 * Params: 467 * id - the id that identifies the server connection 468 * url - remote url, the uploaded buddy icon can be fetched from 469 */ 470 void YAHOO_CALLBACK_TYPE(ext_yahoo_buddyicon_uploaded)(int id, const char *url); 469 471 470 472 /* … … 496 498 497 499 498 499 500 500 /* 501 501 * Name: ext_yahoo_webcam_invite … … 503 503 * Params: 504 504 * id - the id that identifies the server connection 505 * me - identity the invitation is to 505 506 * from - who the invitation is from 506 507 */ 507 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite)(int id, char *from); 508 509 508 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite)(int id, const char *me, const char *from); 510 509 511 510 … … 515 514 * Params: 516 515 * id - the id that identifies the server connection 516 * me - identity the invitation response is to 517 517 * from - who the invitation response is from 518 518 * accept - 0 (decline), 1 (accept) 519 519 */ 520 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite_reply)(int id, char *from, int accept); 521 520 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite_reply)(int id, const char *me, const char *from, int accept); 522 521 523 522 … … 534 533 * 4 = user does not have webcam online 535 534 */ 536 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_closed)(int id, c har *who, int reason);535 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_closed)(int id, const char *who, int reason); 537 536 538 537 … … 552 551 553 552 554 555 553 /* 556 554 * Name: ext_yahoo_error … … 560 558 * err - the error message 561 559 * fatal- whether this error is fatal to the connection or not 562 */ 563 void YAHOO_CALLBACK_TYPE(ext_yahoo_error)(int id, char *err, int fatal); 564 565 560 * num - Which error is this 561 */ 562 void YAHOO_CALLBACK_TYPE(ext_yahoo_error)(int id, const char *err, int fatal, int num); 566 563 567 564 … … 574 571 * connect - 0=disconnect 1=connect 2=request 575 572 */ 576 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_viewer)(int id, char *who, int connect); 577 578 573 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_viewer)(int id, const char *who, int connect); 579 574 580 575 … … 587 582 */ 588 583 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_data_request)(int id, int send); 589 590 591 584 592 585 … … 599 592 * 0 600 593 */ 601 int YAHOO_CALLBACK_TYPE(ext_yahoo_log)(char *fmt, ...); 602 603 604 605 606 607 594 int YAHOO_CALLBACK_TYPE(ext_yahoo_log)(const char *fmt, ...); 608 595 609 596 … … 624 611 625 612 626 627 628 613 /* 629 614 * Name: ext_yahoo_remove_handler … … 634 619 */ 635 620 void YAHOO_CALLBACK_TYPE(ext_yahoo_remove_handler)(int id, int tag); 636 637 638 639 621 640 622 … … 648 630 * a unix file descriptor to the socket 649 631 */ 650 int YAHOO_CALLBACK_TYPE(ext_yahoo_connect)(char *host, int port); 651 652 653 654 655 656 632 int YAHOO_CALLBACK_TYPE(ext_yahoo_connect)(const char *host, int port); 657 633 658 634 … … 675 651 * a unix file descriptor to the socket 676 652 */ 677 int YAHOO_CALLBACK_TYPE(ext_yahoo_connect_async)(int id, c har *host, int port,653 int YAHOO_CALLBACK_TYPE(ext_yahoo_connect_async)(int id, const char *host, int port, 678 654 yahoo_connect_callback callback, void *callback_data); 679 655 … … 686 662 */ 687 663 void yahoo_register_callbacks(struct yahoo_callbacks * tyc); 688 664 689 665 #undef YAHOO_CALLBACK_TYPE 690 666 … … 696 672 697 673 #endif 674 -
protocols/yahoo/yahoo2_types.h
r875ad42 r85d7b85 30 30 31 31 enum yahoo_status { 32 YAHOO_STATUS_DISCONNECTED = -1, 32 33 YAHOO_STATUS_AVAILABLE = 0, 33 34 YAHOO_STATUS_BRB, … … 43 44 YAHOO_STATUS_CUSTOM = 99, 44 45 YAHOO_STATUS_IDLE = 999, 46 YAHOO_STATUS_WEBLOGIN = 0x5a55aa55, 45 47 YAHOO_STATUS_OFFLINE = 0x5a55aa56, /* don't ask */ 46 YAHOO_STATUS_NOTIFY = 0x16 48 YAHOO_STATUS_NOTIFY = 0x16 /* TYPING */ 47 49 }; 48 50 #define YAHOO_STATUS_GAME 0x2 /* Games don't fit into the regular status model */ … … 50 52 enum yahoo_login_status { 51 53 YAHOO_LOGIN_OK = 0, 54 YAHOO_LOGIN_LOGOFF = 2, 52 55 YAHOO_LOGIN_UNAME = 3, 53 56 YAHOO_LOGIN_PASSWD = 13, … … 58 61 59 62 enum yahoo_error { 63 E_UNKNOWN = -1, 64 E_CONNECTION = -2, 65 E_SYSTEM = -3, 60 66 E_CUSTOM = 0, 61 67 … … 79 85 }; 80 86 87 #define YAHOO_PROTO_VER 0x000b 81 88 82 89 /* Yahoo style/color directives */ … … 116 123 }; 117 124 125 enum yahoo_stealth_visibility_type { 126 YAHOO_STEALTH_DEFAULT = 0, 127 YAHOO_STEALTH_ONLINE, 128 YAHOO_STEALTH_PERM_OFFLINE 129 }; 130 118 131 /* chat member attribs */ 119 132 #define YAHOO_CHAT_MALE 0x8000 -
protocols/yahoo/yahoo_util.c
r875ad42 r85d7b85 69 69 int i=0; 70 70 int l = strlen(sep); 71 if(nelem < 0) {71 if(nelem <= 0) { 72 72 char * s; 73 73 nelem=0; 74 for(s=strstr(str, sep); s; s=strstr(s+l, sep),nelem++) 75 ; 76 if(strcmp(str+strlen(str)-l, sep)) 77 nelem++; 74 if (*str) { 75 for(s=strstr(str, sep); s; s=strstr(s+l, sep),nelem++) 76 ; 77 if(strcmp(str+strlen(str)-l, sep)) 78 nelem++; 79 } 78 80 } 79 81 … … 87 89 } 88 90 89 if(i<nelem ) /* str didn't end with sep*/91 if(i<nelem && *str) /* str didn't end with sep, and str isn't empty */ 90 92 vector[i++] = strdup(p); 91 93
Note: See TracChangeset
for help on using the changeset viewer.