Changeset cfc8d58 for protocols/yahoo


Ignore:
Timestamp:
2007-04-16T04:31:52Z (18 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
b3cae44
Parents:
6bbb939
Message:

Updating the Yahoo! module. This seems to fix handling of incoming away
states/messages, should fix some issues with group chats, and unfortunately
also adds some crap which I don't want to clean up for now.

Location:
protocols/yahoo
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • protocols/yahoo/libyahoo2.c

    r6bbb939 rcfc8d58  
    104104#define YAHOO_CALLBACK(x)       x
    105105#endif
     106
     107static int yahoo_send_data(int fd, void *data, int len);
    106108
    107109int yahoo_log_message(char * fmt, ...)
     
    204206        YAHOO_SERVICE_CHATLOGOUT = 0xa0,
    205207        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
    207214};
    208215
     
    741748        yahoo_packet_dump(data, len);
    742749       
     750        if( yid->type == YAHOO_CONNECTION_FT )
     751                yahoo_send_data(yid->fd, data, len);
     752        else
    743753        yahoo_add_to_send_queue(yid, data, len);
    744754        FREE(data);
     
    926936        char *msg = NULL;
    927937        char *from = NULL;
     938        char *to = NULL;
    928939        int stat = 0;
    929940        int accept = 0;
     
    934945                if (pair->key == 4)
    935946                        from = pair->value;
     947                if (pair->key == 5)
     948                        to = pair->value;
    936949                if (pair->key == 49)
    937950                        msg = pair->value;
     
    951964       
    952965        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);
    954967        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);
    956969        else if (!strncasecmp(msg, "WEBCAMINVITE", strlen("WEBCAMINVITE")))
    957970        {
    958971                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);
    960973                } else {
    961974                        accept = atoi(ind);
     
    963976                        if (accept < 0)
    964977                                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);
    966979                }
    967980        }
     
    10221035        }
    10231036        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);
    10251038
    10261039}
     
    10961109                        ;
    10971110                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);
    10991112                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);
    11011114                break;
    11021115        case YAHOO_SERVICE_CONFADDINVITE:
     
    11041117                        ;
    11051118                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);
    11071120                break;
    11081121        case YAHOO_SERVICE_CONFDECLINE:
    11091122                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);
    11111124                break;
    11121125        case YAHOO_SERVICE_CONFLOGON:
    11131126                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);
    11151128                break;
    11161129        case YAHOO_SERVICE_CONFLOGOFF:
    11171130                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);
    11191132                break;
    11201133        case YAHOO_SERVICE_CONFMSG:
    11211134                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);
    11231136                break;
    11241137        }
     
    11281141{
    11291142        char *msg = NULL;
     1143        char *id = NULL;
    11301144        char *who = NULL;
    11311145        char *room = NULL;
     
    11441158                struct yahoo_pair *pair = l->data;
    11451159
     1160                if (pair->key == 1) {
     1161                        /* My identity */
     1162                        id = pair->value;
     1163                }
     1164
    11461165                if (pair->key == 104) {
    11471166                        /* Room name */
     
    12181237        if(!room) {
    12191238                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);
    12211240                        return ;
    12221241                }
    12231242                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;
    12261245                }
    12271246
     
    12361255                }
    12371256                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);
    12391258                } else if(who) {
    12401259                        if(y_list_length(members) != 1) {
     
    12451264                                YList *n = members->next;
    12461265                                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);
    12481267                                y_list_free_1(members);
    12491268                                members=n;
     
    12531272        case YAHOO_SERVICE_CHATEXIT:
    12541273                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);
    12561275                }
    12571276                break;
    12581277        case YAHOO_SERVICE_COMMENT:
    12591278                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);
    12611280                }
    12621281                break;
     
    13171336                        YAHOO_CALLBACK(ext_yahoo_system_message)(yd->client_id, message->msg);
    13181337                } 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);
    13201339                } 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);
    13221341                }
    13231342                free(message);
     
    13321351        YList *l;
    13331352        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;
    13391377       
    1340         if(pkt->service == YAHOO_SERVICE_LOGOFF && pkt->status == -1) {
     1378        if (pkt->service == YAHOO_SERVICE_LOGOFF && pkt->status == -1) {
    13411379                YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, YAHOO_LOGIN_DUPL, NULL);
    13421380                return;
     
    13621400                        break;
    13631401                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);
    13651405                        break;
    13661406                case 10: /* state */
    1367                         state = strtol(pair->value, NULL, 10);
     1407                        ((struct user*)users->data)->state = strtol(pair->value, NULL, 10);
    13681408                        break;
    13691409                case 19: /* custom status message */
    1370                         msg = pair->value;
     1410                        ((struct user*)users->data)->msg = pair->value;
    13711411                        break;
    13721412                case 47: /* is it an away message or not */
    1373                         away = atoi(pair->value);
     1413                        ((struct user*)users->data)->away = atoi(pair->value);
    13741414                        break;
    13751415                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);
    13801420                        break;
    13811421                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 */
    13981428                        /* 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;
    14011458                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);
    14031460                        break;
    14041461                default:
     
    14061463                        break;
    14071464                }
     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);
    14081482        }
    14091483}
     
    15101584        yahoo_packet_free(pkt);
    15111585
     1586}
     1587
     1588static 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
     1619static 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
     1665static 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);
    15121693}
    15131694
     
    21542335        int online = FALSE;
    21552336        int away = 0;
     2337        int idle = 0;
     2338        int mobile = 0;
    21562339
    21572340        YList *l;
     
    21752358                else if (pair->key == 47)
    21762359                        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               
    21772365        }
    21782366
     
    21802368                YAHOO_CALLBACK(ext_yahoo_contact_added)(yd->client_id, id, who, msg);
    21812369        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);
    21832371        else if(pkt->status == 0x07)
    21842372                YAHOO_CALLBACK(ext_yahoo_rejected)(yd->client_id, who, msg);
     
    23082496
    23092497/*      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);
    23112499*/     
    23122500}
     
    23322520        }
    23332521
    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));
    23352523        /*
    23362524         * send: s:0 1:me 5:who 57:room 13:1
     
    23422530         * rejr: s:4 5:who 10:99 19:-1617114599
    23432531         */
     2532}
     2533
     2534static 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);
    23442547}
    23452548
     
    25192722                yahoo_process_webcam_key(yid, pkt);
    25202723                break;
     2724        case YAHOO_SERVICE_PING:
     2725                yahoo_process_ping(yid, pkt);
     2726                break;
    25212727        case YAHOO_SERVICE_IDLE:
    25222728        case YAHOO_SERVICE_MAILSTAT:
     
    25262732        case YAHOO_SERVICE_ADDIDENT:
    25272733        case YAHOO_SERVICE_ADDIGNORE:
    2528         case YAHOO_SERVICE_PING:
    25292734        case YAHOO_SERVICE_GOTGROUPRENAME:
    25302735        case YAHOO_SERVICE_GROUPRENAME:
     
    25382743                yahoo_dump_unhandled(pkt);
    25392744                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; 
    25402754        default:
    25412755                WARNING(("unknown service 0x%02x", pkt->service));
     
    33473561
    33483562                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);
    33503564                }
    33513565
     
    34953709}
    34963710
    3497 void yahoo_send_im(int id, const char *from, const char *who, const char *what, int utf8)
     3711void yahoo_send_im(int id, const char *from, const char *who, const char *what, int utf8, int picture)
    34983712{
    34993713        struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
    35003714        struct yahoo_packet *pkt = NULL;
    35013715        struct yahoo_data *yd;
     3716        char pic_str[10];
    35023717
    35033718        if(!yid)
     
    35083723        pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE, yd->session_id);
    35093724
     3725        snprintf(pic_str, sizeof(pic_str), "%d", picture);
     3726       
    35103727        if(from && strcmp(from, yd->user))
    35113728                yahoo_packet_hash(pkt, 0, yd->user);
     
    35193736        yahoo_packet_hash(pkt, 63, ";0");       /* imvironment name; or ;0 */
    35203737        yahoo_packet_hash(pkt, 64, "0");
     3738        yahoo_packet_hash(pkt, 206, pic_str);
    35213739
    35223740
     
    35713789        else
    35723790                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               
    35793809        }
    35803810
     
    38174047}
    38184048
    3819 void yahoo_add_buddy(int id, const char *who, const char *group)
     4049void yahoo_add_buddy(int id, const char *who, const char *group, const char *msg)
    38204050{
    38214051        struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
     
    38344064        yahoo_packet_hash(pkt, 7, who);
    38354065        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);
    38364068        yahoo_send_packet(yid, pkt, 0);
    38374069        yahoo_packet_free(pkt);
     
    38954127        yahoo_packet_hash(pkt, 7, who);
    38964128        yahoo_packet_hash(pkt, 13, unignore?"2":"1");
     4129        yahoo_send_packet(yid, pkt, 0);
     4130        yahoo_packet_free(pkt);
     4131}
     4132
     4133void 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");
    38974151        yahoo_send_packet(yid, pkt, 0);
    38984152        yahoo_packet_free(pkt);
     
    42024456        yahoo_packet_hash(pkt, 1, (from?from:yd->user));
    42034457
     4458        yahoo_send_packet(yid, pkt, 0);
     4459
     4460        yahoo_packet_free(pkt);
     4461}
     4462
     4463void 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
     4483void 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
     4509void 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
     4532void 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");
    42044552        yahoo_send_packet(yid, pkt, 0);
    42054553
     
    44104758};
    44114759
     4760static 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
     4801void 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
    44124853static void _yahoo_send_file_connected(int id, int fd, int error, void *data)
    44134854{
  • protocols/yahoo/yahoo.c

    r6bbb939 rcfc8d58  
    6767static int byahoo_chat_id = 0;
    6868
    69 static char *byahoo_strip( char *in )
     69static char *byahoo_strip( const char *in )
    7070{
    7171        int len;
     
    8686                else if( strncmp( in, "\e[", 2 ) == 0 )
    8787                {
    88                         char *s;
     88                        const char *s;
    8989                       
    9090                        for( s = in + 2; *s && *s != 'm'; s ++ );
     
    172172        struct byahoo_data *yd = ic->proto_data;
    173173       
    174         yahoo_send_im( yd->y2_id, NULL, who, what, 1 );
     174        yahoo_send_im( yd->y2_id, NULL, who, what, 1, 0 );
    175175       
    176176        return 1;
     
    240240                yd->current_status = YAHOO_STATUS_AVAILABLE;
    241241       
    242         yahoo_set_away( yd->y2_id, yd->current_status, msg, ic->away != NULL );
     242        yahoo_set_away( yd->y2_id, yd->current_status, msg, ic->away != NULL ? 2 : 0 );
    243243}
    244244
     
    274274        struct byahoo_data *yd = (struct byahoo_data *) ic->proto_data;
    275275       
    276         yahoo_add_buddy( yd->y2_id, who, group ? group : BYAHOO_DEFAULT_GROUP );
     276        yahoo_add_buddy( yd->y2_id, who, group ? group : BYAHOO_DEFAULT_GROUP, NULL );
    277277}
    278278
     
    451451}
    452452
    453 void ext_yahoo_login_response( int id, int succ, char *url )
     453void ext_yahoo_login_response( int id, int succ, const char *url )
    454454{
    455455        struct im_connection *ic = byahoo_get_ic_by_id( id );
     
    543543}
    544544
    545 void ext_yahoo_status_changed( int id, char *who, int stat, char *msg, int away )
     545void ext_yahoo_status_changed( int id, const char *who, int stat, const char *msg, int away, int idle, int mobile )
    546546{
    547547        struct im_connection *ic = byahoo_get_ic_by_id( id );
     
    607607}
    608608
    609 void ext_yahoo_got_im( int id, char *who, char *msg, long tm, int stat, int utf8 )
     609void ext_yahoo_got_im( int id, const char *me, const char *who, const char *msg, long tm, int stat, int utf8 )
    610610{
    611611        struct im_connection *ic = byahoo_get_ic_by_id( id );
    612612        char *m = byahoo_strip( msg );
    613613       
    614         serv_got_im( ic, who, m, 0, 0, strlen( m ) );
     614        serv_got_im( ic, (char*) who, (char*) m, 0, 0, strlen( m ) );
    615615        g_free( m );
    616616}
    617617
    618 void ext_yahoo_got_file( int id, char *who, char *url, long expires, char *msg, char *fname, unsigned long fesize )
     618void ext_yahoo_got_file( int id,
     619                         const char *ignored,
     620                         const char *who, const char *url, long expires, const char *msg, const char *fname, unsigned long fesize )
    619621{
    620622        struct im_connection *ic = byahoo_get_ic_by_id( id );
     
    623625}
    624626
    625 void ext_yahoo_typing_notify( int id, char *who, int stat )
     627void ext_yahoo_typing_notify( int id, const char *ignored, const char *who, int stat )
    626628{
    627629        struct im_connection *ic = byahoo_get_ic_by_id( id );
    628630        if (stat == 1) {
    629631                /* User is typing */
    630                 serv_got_typing( ic, who, 1, 1 );
     632                serv_got_typing( ic, (char*) who, 1, 1 );
    631633        }
    632634        else {
    633635                /* User stopped typing */
    634                 serv_got_typing( ic, who, 1, 0 );
    635         }
    636 }
    637 
    638 void ext_yahoo_system_message( int id, char *msg )
     636                serv_got_typing( ic, (char*) who, 1, 0 );
     637        }
     638}
     639
     640void ext_yahoo_system_message( int id, const char *msg )
    639641{
    640642        struct im_connection *ic = byahoo_get_ic_by_id( id );
     
    643645}
    644646
    645 void ext_yahoo_webcam_invite( int id, char *from )
     647void ext_yahoo_webcam_invite( int id, const char *ignored, const char *from )
    646648{
    647649        struct im_connection *ic = byahoo_get_ic_by_id( id );
     
    650652}
    651653
    652 void ext_yahoo_error( int id, char *err, int fatal )
     654void ext_yahoo_error( int id, const char *err, int fatal, int num )
    653655{
    654656        struct im_connection *ic = byahoo_get_ic_by_id( id );
     
    719721}
    720722
    721 int ext_yahoo_connect_async( int id, char *host, int port, yahoo_connect_callback callback, void *data )
     723int ext_yahoo_connect_async( int id, const char *host, int port, yahoo_connect_callback callback, void *data )
    722724{
    723725        struct byahoo_connect_callback_data *d;
     
    740742/* Because we don't want asynchronous connects in BitlBee, and because
    741743   libyahoo doesn't seem to use this one anyway, this one is now defunct. */
    742 int ext_yahoo_connect(char *host, int port)
     744int ext_yahoo_connect(const char *host, int port)
    743745{
    744746#if 0
     
    796798}
    797799
    798 void ext_yahoo_got_conf_invite( int id, char *who, char *room, char *msg, YList *members )
     800void ext_yahoo_got_conf_invite( int id, const char *ignored,
     801                                const char *who, const char *room, const char *msg, YList *members )
    799802{
    800803        struct im_connection *ic = byahoo_get_ic_by_id( id );
     
    806809        memset( inv, 0, sizeof( struct byahoo_conf_invitation ) );
    807810        inv->name = g_strdup( room );
    808         inv->c = serv_got_joined_chat( ic, room );
     811        inv->c = serv_got_joined_chat( ic, (char*) room );
    809812        inv->c->data = members;
    810813        inv->yid = id;
     
    821824}
    822825
    823 void ext_yahoo_conf_userdecline( int id, char *who, char *room, char *msg )
     826void ext_yahoo_conf_userdecline( int id, const char *ignored, const char *who, const char *room, const char *msg )
    824827{
    825828        struct im_connection *ic = byahoo_get_ic_by_id( id );
     
    828831}
    829832
    830 void ext_yahoo_conf_userjoin( int id, char *who, char *room )
     833void ext_yahoo_conf_userjoin( int id, const char *ignored, const char *who, const char *room )
    831834{
    832835        struct im_connection *ic = byahoo_get_ic_by_id( id );
     
    836839       
    837840        if( c )
    838                 add_chat_buddy( c, who );
    839 }
    840 
    841 void ext_yahoo_conf_userleave( int id, char *who, char *room )
     841                add_chat_buddy( c, (char*) who );
     842}
     843
     844void ext_yahoo_conf_userleave( int id, const char *ignored, const char *who, const char *room )
     845
    842846{
    843847        struct im_connection *ic = byahoo_get_ic_by_id( id );
     
    847851       
    848852        if( c )
    849                 remove_chat_buddy( c, who, "" );
    850 }
    851 
    852 void ext_yahoo_conf_message( int id, char *who, char *room, char *msg, int utf8 )
     853                remove_chat_buddy( c, (char*) who, "" );
     854}
     855
     856void ext_yahoo_conf_message( int id, const char *ignored, const char *who, const char *room, const char *msg, int utf8 )
    853857{
    854858        struct im_connection *ic = byahoo_get_ic_by_id( id );
     
    859863       
    860864        if( c )
    861                 serv_got_chat_in( c, who, 0, m, 0 );
     865                serv_got_chat_in( c, (char*) who, 0, (char*) m, 0 );
    862866        g_free( m );
    863867}
    864868
    865 void ext_yahoo_chat_cat_xml( int id, char *xml )
    866 {
    867 }
    868 
    869 void ext_yahoo_chat_join( int id, char *room, char *topic, YList *members, int fd )
    870 {
    871 }
    872 
    873 void ext_yahoo_chat_userjoin( int id, char *room, struct yahoo_chat_member *who )
    874 {
    875 }
    876 
    877 void ext_yahoo_chat_userleave( int id, char *room, char *who )
    878 {
    879 }
    880 
    881 void ext_yahoo_chat_message( int id, char *who, char *room, char *msg, int msgtype, int utf8 )
    882 {
    883 }
    884 
    885 void ext_yahoo_chat_yahoologout( int id )
    886 {
    887 }
    888 
    889 void ext_yahoo_chat_yahooerror( int id )
    890 {
    891 }
    892 
    893 void ext_yahoo_contact_added( int id, char *myid, char *who, char *msg )
    894 {
    895 }
    896 
    897 void ext_yahoo_rejected( int id, char *who, char *msg )
    898 {
    899 }
    900 
    901 void ext_yahoo_game_notify( int id, char *who, int stat )
    902 {
    903 }
    904 
    905 void ext_yahoo_mail_notify( int id, char *from, char *subj, int cnt )
     869void ext_yahoo_chat_cat_xml( int id, const char *xml )
     870{
     871}
     872
     873void ext_yahoo_chat_join( int id, const char *who, const char *room, const char *topic, YList *members, int fd )
     874{
     875}
     876
     877void ext_yahoo_chat_userjoin( int id, const char *me, const char *room, struct yahoo_chat_member *who )
     878{
     879        free(who->id);
     880        free(who->alias);
     881        free(who->location);
     882        free(who);
     883}
     884
     885void ext_yahoo_chat_userleave( int id, const char *me, const char *room, const char *who )
     886{
     887}
     888
     889void ext_yahoo_chat_message( int id, const char *me, const char *who, const char *room, const char *msg, int msgtype, int utf8 )
     890{
     891}
     892
     893void ext_yahoo_chat_yahoologout( int id, const char *me )
     894{
     895}
     896
     897void ext_yahoo_chat_yahooerror( int id, const char *me )
     898{
     899}
     900
     901void ext_yahoo_contact_added( int id, const char *myid, const char *who, const char *msg )
     902{
     903}
     904
     905void ext_yahoo_rejected( int id, const char *who, const char *msg )
     906{
     907}
     908
     909void ext_yahoo_game_notify( int id, const char *me, const char *who, int stat )
     910{
     911}
     912
     913void ext_yahoo_mail_notify( int id, const char *from, const char *subj, int cnt )
    906914{
    907915        struct im_connection *ic = byahoo_get_ic_by_id( id );
     
    913921}
    914922
    915 void ext_yahoo_webcam_invite_reply( int id, char *from, int accept )
    916 {
    917 }
    918 
    919 void ext_yahoo_webcam_closed( int id, char *who, int reason )
     923void ext_yahoo_webcam_invite_reply( int id, const char *me, const char *from, int accept )
     924{
     925}
     926
     927void ext_yahoo_webcam_closed( int id, const char *who, int reason )
    920928{
    921929}
     
    925933}
    926934
    927 void ext_yahoo_webcam_viewer( int id, char *who, int connect )
     935void ext_yahoo_webcam_viewer( int id, const char *who, int connect )
    928936{
    929937}
     
    933941}
    934942
    935 int ext_yahoo_log( char *fmt, ... )
     943int ext_yahoo_log( const char *fmt, ... )
    936944{
    937945        return( 0 );
     
    941949{
    942950}
     951
     952void ext_yahoo_got_ping( int id, const char *msg)
     953{
     954}
     955
     956void ext_yahoo_got_buddyicon (int id, const char *me, const char *who, const char *url, int checksum) {}
     957void ext_yahoo_got_buddyicon_checksum (int id, const char *me,const char *who, int checksum) {}
     958
     959void ext_yahoo_got_buddyicon_request(int id, const char *me, const char *who){}
     960void ext_yahoo_buddyicon_uploaded(int id, const char *url){}
  • protocols/yahoo/yahoo2.h

    r6bbb939 rcfc8d58  
    120120/* from is the identity you're sending from.  if NULL, the default is used */
    121121/* 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);
     122void yahoo_send_im(int id, const char *from, const char *who, const char *msg, int utf8, int picture);
    123123/* if type is true, send typing notice, else send stopped typing notice */
    124124void yahoo_send_typing(int id, const char *from, const char *who, int typ);
     
    128128void yahoo_set_away(int id, enum yahoo_status state, const char *msg, int away);
    129129
    130 void yahoo_add_buddy(int id, const char *who, const char *group);
     130void yahoo_add_buddy(int id, const char *who, const char *group, const char *msg);
    131131void yahoo_remove_buddy(int id, const char *who, const char *group);
    132132void yahoo_reject_buddy(int id, const char *who, const char *msg);
     133void yahoo_stealth_buddy(int id, const char *who, int unstealth);
    133134/* if unignore is true, unignore, else ignore */
    134135void yahoo_ignore_buddy(int id, const char *who, int unignore);
     
    214215const char  * yahoo_get_profile_url( void );
    215216
     217void yahoo_buddyicon_request(int id, const char *who);
     218
    216219#include "yahoo_httplib.h"
    217220
  • protocols/yahoo/yahoo2_callbacks.h

    r6bbb939 rcfc8d58  
    2929 * declared in this file and defined in libyahoo2.c
    3030 */
    31 
    3231
    3332
     
    6766
    6867
    69 
    7068/*
    7169 * The following functions need to be implemented in the client
     
    9694 *      url  - url to reactivate account if locked
    9795 */
    98 void YAHOO_CALLBACK_TYPE(ext_yahoo_login_response)(int id, int succ, char *url);
    99 
    100 
     96void YAHOO_CALLBACK_TYPE(ext_yahoo_login_response)(int id, int succ, const char *url);
    10197
    10298
     
    111107
    112108
    113 
    114 
    115109/*
    116110 * Name: ext_yahoo_got_ignore
     
    123117
    124118
    125 
    126 
    127 
    128119/*
    129120 * Name: ext_yahoo_got_identities
     
    136127
    137128
    138 
    139 
    140 
    141129/*
    142130 * Name: ext_yahoo_got_cookies
     
    148136
    149137
     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 */
     145void YAHOO_CALLBACK_TYPE(ext_yahoo_got_ping)(int id, const char *errormsg);
    150146
    151147
     
    159155 *      msg  - the message if stat == YAHOO_STATUS_CUSTOM
    160156 *      away - whether the contact is away or not (YAHOO_STATUS_CUSTOM)
    161  *             for YAHOO_STATUS_IDLE, this is the number of seconds he is idle
    162  */
    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 */
     161void YAHOO_CALLBACK_TYPE(ext_yahoo_status_changed)(int id, const char *who, int stat, const char *msg, int away, int idle, int mobile);
    166162
    167163
     
    171167 * Params:
    172168 *      id   - the id that identifies the server connection
     169 *      me   - the identity the message was sent to
    173170 *      who  - the handle of the remote user
    174171 *      msg  - the message - NULL if stat == 2
     
    180177 *      utf8 - whether the message is encoded as utf8 or not
    181178 */
    182 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_im)(int id, char *who, char *msg, long tm, int stat, int utf8);
    183 
    184 
     179void YAHOO_CALLBACK_TYPE(ext_yahoo_got_im)(int id, const char *me, const char *who, const char *msg, long tm, int stat, int utf8);
    185180
    186181
     
    190185 * Params:
    191186 *      id   - the id that identifies the server connection
     187 *      me   - the identity the invitation was sent to
    192188 *      who  - the user inviting you
    193189 *      room - the room to join
     
    195191 *      members - the initial members of the conference (null terminated list)
    196192 */
    197 void YAHOO_CALLBACK_TYPE(ext_yahoo_got_conf_invite)(int id, char *who, char *room, char *msg, YList *members);
    198 
    199 
     193void YAHOO_CALLBACK_TYPE(ext_yahoo_got_conf_invite)(int id, const char *me, const char *who, const char *room, const char *msg, YList *members);
    200194
    201195
     
    205199 * Params:
    206200 *      id   - the id that identifies the server connection
     201 *      me   - the identity in the conference
    207202 *      who  - the user who has declined
    208203 *      room - the room
    209204 *      msg  - the declining message
    210205 */
    211 void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userdecline)(int id, char *who, char *room, char *msg);
    212 
    213 
     206void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userdecline)(int id, const char *me, const char *who, const char *room, const char *msg);
    214207
    215208
     
    219212 * Params:
    220213 *      id   - the id that identifies the server connection
     214 *      me   - the identity in the conference
    221215 *      who  - the user who has joined
    222216 *      room - the room joined
    223217 */
    224 void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userjoin)(int id, char *who, char *room);
    225 
    226 
     218void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userjoin)(int id, const char *me, const char *who, const char *room);
    227219
    228220
     
    232224 * Params:
    233225 *      id   - the id that identifies the server connection
     226 *      me   - the identity in the conference
    234227 *      who  - the user who has left
    235228 *      room - the room left
    236229 */
    237 void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userleave)(int id, char *who, char *room);
    238 
    239 
    240 
    241 
     230void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userleave)(int id, const char *me, const char *who, const char *room);
    242231
    243232
    244233/*
    245234 * Name: ext_yahoo_chat_cat_xml
    246  *      Called when joining the chatroom.
     235 *      Called when ?
    247236 * Params:
    248237 *      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 */
     240void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_cat_xml)(int id, const char *xml);
    261241
    262242
     
    266246 * Params:
    267247 *      id      - the id that identifies the server connection
     248 *      me   - the identity in the chatroom
    268249 *      room    - the room joined, used in all other chat calls, freed by
    269250 *                library after call
     
    273254 *      fd      - the socket where the connection is coming from (for tracking)
    274255 */
    275 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_join)(int id, char *room, char *topic, YList *members, int fd);
    276 
    277 
    278 
    279 
     256void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_join)(int id, const char *me, const char *room, const char *topic, YList *members, int fd);
    280257
    281258
     
    285262 * Params:
    286263 *      id   - the id that identifies the server connection
     264 *      me   - the identity in the chatroom
    287265 *      room - the room joined
    288266 *      who  - the user who has joined, Must be freed by the client
    289267 */
    290 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userjoin)(int id, char *room, struct yahoo_chat_member *who);
    291 
    292 
     268void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userjoin)(int id, const char *me, const char *room, struct yahoo_chat_member *who);
    293269
    294270
     
    298274 * Params:
    299275 *      id   - the id that identifies the server connection
     276 *      me   - the identity in the chatroom
    300277 *      room - the room left
    301278 *      who  - the user who has left (Just the User ID)
    302279 */
    303 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userleave)(int id, char *room, char *who);
    304 
    305 
     280void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userleave)(int id, const char *me, const char *room, const char *who);
    306281
    307282
     
    311286 * Params:
    312287 *      id   - the id that identifies the server connection
     288 *      me   - the identity in the chatroom
    313289 *      room - the room
    314290 *      who  - the user who messaged (Just the user id)
     
    318294 *      utf8 - whether the message is utf8 encoded or not
    319295 */
    320 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_message)(int id, char *who, char *room, char *msg, int msgtype, int utf8);
     296void 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
    321298
    322299/*
     
    329306 * Params:
    330307 *      id   - the id that identifies this connection
     308 *      me   - the identity in the chatroom
    331309 * Returns:
    332310 *      nothing.
    333311 */
    334 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahoologout)(int id);
     312void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahoologout)(int id, const char *me);
     313
    335314
    336315/*
     
    344323 * Params:
    345324 *      id   - the id that identifies this connection
     325 *      me   - the identity in the chatroom
    346326 * Returns:
    347327 *      nothing.
    348328 */
    349 
    350 void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahooerror)(int id);
     329void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahooerror)(int id, const char *me);
     330
    351331
    352332/*
     
    355335 * Params:
    356336 *      id   - the id that identifies the server connection
     337 *      me   - the identity the conf message was sent to
    357338 *      who  - the user who messaged
    358339 *      room - the room
     
    360341 *      utf8 - whether the message is utf8 encoded or not
    361342 */
    362 void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_message)(int id, char *who, char *room, char *msg, int utf8);
    363 
    364 
     343void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_message)(int id, const char *me, const char *who, const char *room, const char *msg, int utf8);
    365344
    366345
     
    370349 * Params:
    371350 *      id   - the id that identifies the server connection
     351 *      me   - the identity the file was sent to
    372352 *      who  - the user who sent the file
    373353 *      url  - the file url
     
    377357 *      fsize- the file size if direct transfer
    378358 */
    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 
     359void 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);
    382360
    383361
     
    391369 *      msg  - any message sent
    392370 */
    393 void YAHOO_CALLBACK_TYPE(ext_yahoo_contact_added)(int id, char *myid, char *who, char *msg);
    394 
    395 
     371void YAHOO_CALLBACK_TYPE(ext_yahoo_contact_added)(int id, const char *myid, const char *who, const char *msg);
    396372
    397373
     
    404380 *      msg  - any message sent
    405381 */
    406 void YAHOO_CALLBACK_TYPE(ext_yahoo_rejected)(int id, char *who, char *msg);
    407 
    408 
     382void YAHOO_CALLBACK_TYPE(ext_yahoo_rejected)(int id, const char *who, const char *msg);
    409383
    410384
     
    414388 * Params:
    415389 *      id   - the id that identifies the server connection
     390 *      me   - the handle of the identity the notification is sent to
    416391 *      who  - the handle of the remote user
    417392 *      stat - 1 if typing, 0 if stopped typing
    418393 */
    419 void YAHOO_CALLBACK_TYPE(ext_yahoo_typing_notify)(int id, char *who, int stat);
    420 
    421 
     394void YAHOO_CALLBACK_TYPE(ext_yahoo_typing_notify)(int id, const char *me, const char *who, int stat);
    422395
    423396
     
    427400 * Params:
    428401 *      id   - the id that identifies the server connection
     402 *      me   - the handle of the identity the notification is sent to
    429403 *      who  - the handle of the remote user
    430404 *      stat - 1 if game, 0 if stopped gaming
    431405 */
    432 void YAHOO_CALLBACK_TYPE(ext_yahoo_game_notify)(int id, char *who, int stat);
    433 
    434 
     406void YAHOO_CALLBACK_TYPE(ext_yahoo_game_notify)(int id, const char *me, const char *who, int stat);
    435407
    436408
     
    444416 *      cnt  - mail count - 0 if new mail notification
    445417 */
    446 void YAHOO_CALLBACK_TYPE(ext_yahoo_mail_notify)(int id, char *from, char *subj, int cnt);
    447 
    448 
     418void YAHOO_CALLBACK_TYPE(ext_yahoo_mail_notify)(int id, const char *from, const char *subj, int cnt);
    449419
    450420
     
    456426 *      msg  - the message
    457427 */
    458 void YAHOO_CALLBACK_TYPE(ext_yahoo_system_message)(int id, char *msg);
    459 
    460 
    461 
    462 
    463 
    464 
    465 
    466 
    467 
    468 
     428void 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 */
     440void 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 */
     451void 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 */
     461void 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 */
     470void YAHOO_CALLBACK_TYPE(ext_yahoo_buddyicon_uploaded)(int id, const char *url);
    469471
    470472/*
     
    496498
    497499
    498 
    499 
    500500/*
    501501 * Name: ext_yahoo_webcam_invite
     
    503503 * Params:
    504504 *      id   - the id that identifies the server connection
     505 *      me   - identity the invitation is to
    505506 *      from - who the invitation is from
    506507 */
    507 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite)(int id, char *from);
    508 
    509 
     508void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite)(int id, const char *me, const char *from);
    510509
    511510
     
    515514 * Params:
    516515 *      id   - the id that identifies the server connection
     516 *      me   - identity the invitation response is to
    517517 *      from - who the invitation response is from
    518518 *      accept - 0 (decline), 1 (accept)
    519519 */
    520 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite_reply)(int id, char *from, int accept);
    521 
     520void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite_reply)(int id, const char *me, const char *from, int accept);
    522521
    523522
     
    534533 *               4 = user does not have webcam online
    535534 */
    536 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_closed)(int id, char *who, int reason);
     535void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_closed)(int id, const char *who, int reason);
    537536
    538537
     
    552551
    553552
    554 
    555553/*
    556554 * Name: ext_yahoo_error
     
    560558 *      err  - the error message
    561559 *      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 */
     562void YAHOO_CALLBACK_TYPE(ext_yahoo_error)(int id, const char *err, int fatal, int num);
    566563
    567564
     
    574571 *      connect - 0=disconnect 1=connect 2=request
    575572 */
    576 void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_viewer)(int id, char *who, int connect);
    577 
    578 
     573void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_viewer)(int id, const char *who, int connect);
    579574
    580575
     
    587582 */
    588583void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_data_request)(int id, int send);
    589 
    590 
    591584
    592585
     
    599592 *      0
    600593 */
    601 int YAHOO_CALLBACK_TYPE(ext_yahoo_log)(char *fmt, ...);
    602 
    603 
    604 
    605 
    606 
    607 
     594int YAHOO_CALLBACK_TYPE(ext_yahoo_log)(const char *fmt, ...);
    608595
    609596
     
    624611
    625612
    626 
    627 
    628613/*
    629614 * Name: ext_yahoo_remove_handler
     
    634619 */
    635620void YAHOO_CALLBACK_TYPE(ext_yahoo_remove_handler)(int id, int tag);
    636 
    637 
    638 
    639621
    640622
     
    648630 *      a unix file descriptor to the socket
    649631 */
    650 int YAHOO_CALLBACK_TYPE(ext_yahoo_connect)(char *host, int port);
    651 
    652 
    653 
    654 
    655 
    656 
     632int YAHOO_CALLBACK_TYPE(ext_yahoo_connect)(const char *host, int port);
    657633
    658634
     
    675651 *      a unix file descriptor to the socket
    676652 */
    677 int YAHOO_CALLBACK_TYPE(ext_yahoo_connect_async)(int id, char *host, int port,
     653int YAHOO_CALLBACK_TYPE(ext_yahoo_connect_async)(int id, const char *host, int port,
    678654                yahoo_connect_callback callback, void *callback_data);
    679655
     
    686662 */
    687663void yahoo_register_callbacks(struct yahoo_callbacks * tyc);
    688        
     664
    689665#undef YAHOO_CALLBACK_TYPE
    690666
     
    696672
    697673#endif
     674
  • protocols/yahoo/yahoo2_types.h

    r6bbb939 rcfc8d58  
    3030
    3131enum yahoo_status {
     32        YAHOO_STATUS_DISCONNECTED = -1,
    3233        YAHOO_STATUS_AVAILABLE = 0,
    3334        YAHOO_STATUS_BRB,
     
    4344        YAHOO_STATUS_CUSTOM = 99,
    4445        YAHOO_STATUS_IDLE = 999,
     46        YAHOO_STATUS_WEBLOGIN = 0x5a55aa55,
    4547        YAHOO_STATUS_OFFLINE = 0x5a55aa56, /* don't ask */
    46         YAHOO_STATUS_NOTIFY = 0x16
     48        YAHOO_STATUS_NOTIFY = 0x16 /* TYPING */
    4749};
    4850#define YAHOO_STATUS_GAME       0x2             /* Games don't fit into the regular status model */
     
    5052enum yahoo_login_status {
    5153        YAHOO_LOGIN_OK = 0,
     54        YAHOO_LOGIN_LOGOFF = 2,
    5255        YAHOO_LOGIN_UNAME = 3,
    5356        YAHOO_LOGIN_PASSWD = 13,
     
    5861
    5962enum yahoo_error {
     63        E_UNKNOWN = -1,
     64        E_CONNECTION = -2,
     65        E_SYSTEM = -3,
    6066        E_CUSTOM = 0,
    6167
     
    7985};
    8086
     87#define YAHOO_PROTO_VER 0x000b
    8188
    8289/* Yahoo style/color directives */
     
    116123};
    117124
     125enum yahoo_stealth_visibility_type {
     126        YAHOO_STEALTH_DEFAULT = 0,
     127        YAHOO_STEALTH_ONLINE,
     128        YAHOO_STEALTH_PERM_OFFLINE
     129};
     130
    118131/* chat member attribs */
    119132#define YAHOO_CHAT_MALE 0x8000
  • protocols/yahoo/yahoo_util.c

    r6bbb939 rcfc8d58  
    6969        int i=0;
    7070        int l = strlen(sep);
    71         if(nelem < 0) {
     71        if(nelem <= 0) {
    7272                char * s;
    7373                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                }
    7880        }
    7981
     
    8789        }
    8890
    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 */
    9092                vector[i++] = strdup(p);
    9193                       
Note: See TracChangeset for help on using the changeset viewer.