~ubuntu-branches/ubuntu/karmic/libyahoo2/karmic

« back to all changes in this revision

Viewing changes to src/libyahoo2.c

  • Committer: Bazaar Package Importer
  • Author(s): Kartik Mistry
  • Date: 2008-05-06 14:27:51 UTC
  • mfrom: (1.1.1 upstream) (2.1.2 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080506142751-vncfzy8640lllm4y
Tags: 0.7.6-1
* New upstream release
  + Dropped dpatch support, patch 01_sha_replacements.dpatch
    merged with upstream
* debian/README.Debian:
  + Removed as it is not required now
* Added debian/watch file
* debian/rules:
  + [Lintian] Fixed config.guess, config.sub presence in .diff.gz,
    Thanks to Kumar Appaiah for help
* debian/copyright:
  + Updated Authors list
  + Updated Debian package copyright year
* Uploaded for Kartik by Jaldhar H. Vyas <jaldhar@debian.org>

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
# include <config.h>
48
48
#endif
49
49
 
 
50
#if HAVE_UNISTD_H
50
51
#include <unistd.h>
 
52
#endif
51
53
#include <errno.h>
52
54
#include <stdio.h>
53
55
#include <stdarg.h>
77
79
#include <stdlib.h>
78
80
#include <ctype.h>
79
81
 
80
 
#include "sha.h"
 
82
#include "sha1.h"
81
83
#include "md5.h"
82
84
#include "yahoo2.h"
83
85
#include "yahoo_httplib.h"
104
106
#define YAHOO_CALLBACK(x)       x
105
107
#endif
106
108
 
 
109
static int yahoo_send_data(int fd, void *data, int len);
 
110
 
107
111
int yahoo_log_message(char * fmt, ...)
108
112
{
109
113
        char out[1024];
203
207
        YAHOO_SERVICE_CHATEXIT = 0x9b,
204
208
        YAHOO_SERVICE_CHATLOGOUT = 0xa0,
205
209
        YAHOO_SERVICE_CHATPING,
206
 
        YAHOO_SERVICE_COMMENT = 0xa8
 
210
        YAHOO_SERVICE_COMMENT = 0xa8,
 
211
        YAHOO_SERVICE_STEALTH = 0xb9,
 
212
        YAHOO_SERVICE_PICTURE_CHECKSUM = 0xbd,
 
213
        YAHOO_SERVICE_PICTURE = 0xbe,
 
214
        YAHOO_SERVICE_PICTURE_UPDATE = 0xc1,
 
215
        YAHOO_SERVICE_PICTURE_UPLOAD = 0xc2
207
216
};
208
217
 
209
218
struct yahoo_pair {
741
750
        data = y_new0(unsigned char, len + 1);
742
751
 
743
752
        memcpy(data + pos, "YMSG", 4); pos += 4;
744
 
        pos += yahoo_put16(data + pos, 0x0a00);
 
753
        pos += yahoo_put16(data + pos, 0x000c);
745
754
        pos += yahoo_put16(data + pos, 0x0000);
746
755
        pos += yahoo_put16(data + pos, pktlen + extra_pad);
747
756
        pos += yahoo_put16(data + pos, pkt->service);
752
761
 
753
762
        yahoo_packet_dump(data, len);
754
763
        
 
764
        if( yid->type == YAHOO_CONNECTION_FT )
 
765
                yahoo_send_data(yid->fd, data, len);
 
766
        else
755
767
        yahoo_add_to_send_queue(yid, data, len);
756
768
        FREE(data);
757
769
}
937
949
        struct yahoo_data *yd = yid->yd;
938
950
        char *msg = NULL;
939
951
        char *from = NULL;
 
952
        char *to = NULL;
940
953
        int stat = 0;
941
954
        int accept = 0;
942
955
        char *ind = NULL;
945
958
                struct yahoo_pair *pair = l->data;
946
959
                if (pair->key == 4)
947
960
                        from = pair->value;
 
961
                if (pair->key == 5)
 
962
                        to = pair->value;
948
963
                if (pair->key == 49)
949
964
                        msg = pair->value;
950
965
                if (pair->key == 13)
962
977
                return;
963
978
        
964
979
        if (!strncasecmp(msg, "TYPING", strlen("TYPING"))) 
965
 
                YAHOO_CALLBACK(ext_yahoo_typing_notify)(yd->client_id, from, stat);
 
980
                YAHOO_CALLBACK(ext_yahoo_typing_notify)(yd->client_id, to, from, stat);
966
981
        else if (!strncasecmp(msg, "GAME", strlen("GAME"))) 
967
 
                YAHOO_CALLBACK(ext_yahoo_game_notify)(yd->client_id, from, stat);
 
982
                YAHOO_CALLBACK(ext_yahoo_game_notify)(yd->client_id, to, from, stat);
968
983
        else if (!strncasecmp(msg, "WEBCAMINVITE", strlen("WEBCAMINVITE"))) 
969
984
        {
970
985
                if (!strcmp(ind, " ")) {
971
 
                        YAHOO_CALLBACK(ext_yahoo_webcam_invite)(yd->client_id, from);
 
986
                        YAHOO_CALLBACK(ext_yahoo_webcam_invite)(yd->client_id, to, from);
972
987
                } else {
973
988
                        accept = atoi(ind);
974
989
                        /* accept the invitation (-1 = deny 1 = accept) */
975
990
                        if (accept < 0)
976
991
                                accept = 0;
977
 
                        YAHOO_CALLBACK(ext_yahoo_webcam_invite_reply)(yd->client_id, from, accept);
 
992
                        YAHOO_CALLBACK(ext_yahoo_webcam_invite_reply)(yd->client_id, to, from, accept);
978
993
                }
979
994
        }
980
995
        else
1033
1048
                        *tmp = '\0';
1034
1049
        }
1035
1050
        if(url && from)
1036
 
                YAHOO_CALLBACK(ext_yahoo_got_file)(yd->client_id, from, url, expires, msg, filename, filesize);
 
1051
                YAHOO_CALLBACK(ext_yahoo_got_file)(yd->client_id, to, from, url, expires, msg, filename, filesize);
1037
1052
 
1038
1053
}
1039
1054
 
1107
1122
                if(pkt->status == 2)
1108
1123
                        ;
1109
1124
                else if(members)
1110
 
                        YAHOO_CALLBACK(ext_yahoo_got_conf_invite)(yd->client_id, host, room, msg, members);
 
1125
                        YAHOO_CALLBACK(ext_yahoo_got_conf_invite)(yd->client_id, id, host, room, msg, members);
1111
1126
                else if(msg)
1112
 
                        YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, msg, 0);
 
1127
                        YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, msg, 0, E_CONFNOTAVAIL);
1113
1128
                break;
1114
1129
        case YAHOO_SERVICE_CONFADDINVITE:
1115
1130
                if(pkt->status == 2)
1116
1131
                        ;
1117
1132
                else
1118
 
                        YAHOO_CALLBACK(ext_yahoo_got_conf_invite)(yd->client_id, host, room, msg, members);
 
1133
                        YAHOO_CALLBACK(ext_yahoo_got_conf_invite)(yd->client_id, id, host, room, msg, members);
1119
1134
                break;
1120
1135
        case YAHOO_SERVICE_CONFDECLINE:
1121
1136
                if(who)
1122
 
                        YAHOO_CALLBACK(ext_yahoo_conf_userdecline)(yd->client_id, who, room, msg);
 
1137
                        YAHOO_CALLBACK(ext_yahoo_conf_userdecline)(yd->client_id, id, who, room, msg);
1123
1138
                break;
1124
1139
        case YAHOO_SERVICE_CONFLOGON:
1125
1140
                if(who)
1126
 
                        YAHOO_CALLBACK(ext_yahoo_conf_userjoin)(yd->client_id, who, room);
 
1141
                        YAHOO_CALLBACK(ext_yahoo_conf_userjoin)(yd->client_id, id, who, room);
1127
1142
                break;
1128
1143
        case YAHOO_SERVICE_CONFLOGOFF:
1129
1144
                if(who)
1130
 
                        YAHOO_CALLBACK(ext_yahoo_conf_userleave)(yd->client_id, who, room);
 
1145
                        YAHOO_CALLBACK(ext_yahoo_conf_userleave)(yd->client_id, id, who, room);
1131
1146
                break;
1132
1147
        case YAHOO_SERVICE_CONFMSG:
1133
1148
                if(who)
1134
 
                        YAHOO_CALLBACK(ext_yahoo_conf_message)(yd->client_id, who, room, msg, utf8);
 
1149
                        YAHOO_CALLBACK(ext_yahoo_conf_message)(yd->client_id, id, who, room, msg, utf8);
1135
1150
                break;
1136
1151
        }
1137
1152
}
1139
1154
static void yahoo_process_chat(struct yahoo_input_data *yid, struct yahoo_packet *pkt)
1140
1155
{
1141
1156
        char *msg = NULL;
 
1157
        char *id = NULL;
1142
1158
        char *who = NULL;
1143
1159
        char *room = NULL;
1144
1160
        char *topic = NULL;
1155
1171
        for (l = pkt->hash; l; l = l->next) {
1156
1172
                struct yahoo_pair *pair = l->data;
1157
1173
 
 
1174
                if (pair->key == 1) {
 
1175
                        /* My identity */
 
1176
                        id = pair->value;
 
1177
                }
 
1178
 
1158
1179
                if (pair->key == 104) {
1159
1180
                        /* Room name */
1160
1181
                        room = pair->value;
1229
1250
 
1230
1251
        if(!room) {
1231
1252
                if (pkt->service == YAHOO_SERVICE_CHATLOGOUT) { /* yahoo originated chat logout */
1232
 
                        YAHOO_CALLBACK(ext_yahoo_chat_yahoologout)(yid->yd->client_id);
 
1253
                        YAHOO_CALLBACK(ext_yahoo_chat_yahoologout)(yid->yd->client_id, id);
1233
1254
                        return ;
1234
1255
                }
1235
1256
                if (pkt->service == YAHOO_SERVICE_COMMENT && chaterr)  {
1236
 
                        YAHOO_CALLBACK(ext_yahoo_chat_yahooerror)(yid->yd->client_id);
1237
 
                        return ;
 
1257
                        YAHOO_CALLBACK(ext_yahoo_chat_yahooerror)(yid->yd->client_id, id);
 
1258
                        return;
1238
1259
                }
1239
1260
 
1240
1261
                WARNING(("We didn't get a room name, ignoring packet"));
1247
1268
                        WARNING(("Count of members doesn't match No. of members we got"));
1248
1269
                }
1249
1270
                if(firstjoin && members) {
1250
 
                        YAHOO_CALLBACK(ext_yahoo_chat_join)(yid->yd->client_id, room, topic, members, yid->fd);
 
1271
                        YAHOO_CALLBACK(ext_yahoo_chat_join)(yid->yd->client_id, id, room, topic, members, yid->fd);
1251
1272
                } else if(who) {
1252
1273
                        if(y_list_length(members) != 1) {
1253
1274
                                WARNING(("Got more than 1 member on a normal join"));
1256
1277
                        while(members) {
1257
1278
                                YList *n = members->next;
1258
1279
                                currentmember = members->data;
1259
 
                                YAHOO_CALLBACK(ext_yahoo_chat_userjoin)(yid->yd->client_id, room, currentmember);
 
1280
                                YAHOO_CALLBACK(ext_yahoo_chat_userjoin)(yid->yd->client_id, id, room, currentmember);
1260
1281
                                y_list_free_1(members);
1261
1282
                                members=n;
1262
1283
                        }
1264
1285
                break;
1265
1286
        case YAHOO_SERVICE_CHATEXIT:
1266
1287
                if(who) {
1267
 
                        YAHOO_CALLBACK(ext_yahoo_chat_userleave)(yid->yd->client_id, room, who);
 
1288
                        YAHOO_CALLBACK(ext_yahoo_chat_userleave)(yid->yd->client_id, id, room, who);
1268
1289
                }
1269
1290
                break;
1270
1291
        case YAHOO_SERVICE_COMMENT:
1271
1292
                if(who) {
1272
 
                        YAHOO_CALLBACK(ext_yahoo_chat_message)(yid->yd->client_id, who, room, msg, msgtype, utf8);
 
1293
                        YAHOO_CALLBACK(ext_yahoo_chat_message)(yid->yd->client_id, id, who, room, msg, msgtype, utf8);
1273
1294
                }
1274
1295
                break;
1275
1296
        }
1328
1349
                if (pkt->service == YAHOO_SERVICE_SYSMESSAGE) {
1329
1350
                        YAHOO_CALLBACK(ext_yahoo_system_message)(yd->client_id, message->msg);
1330
1351
                } else if (pkt->status <= 2 || pkt->status == 5) {
1331
 
                        YAHOO_CALLBACK(ext_yahoo_got_im)(yd->client_id, message->from, message->msg, message->tm, pkt->status, message->utf8);
 
1352
                        YAHOO_CALLBACK(ext_yahoo_got_im)(yd->client_id, message->to, message->from, message->msg, message->tm, pkt->status, message->utf8);
1332
1353
                } else if (pkt->status == 0xffffffff) {
1333
 
                        YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, message->msg, 0);
 
1354
                        YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, message->msg, 0, E_SYSTEM);
1334
1355
                }
1335
1356
                free(message);
1336
1357
        }
1343
1364
{
1344
1365
        YList *l;
1345
1366
        struct yahoo_data *yd = yid->yd;
1346
 
        char *name = NULL;
1347
 
        int state = 0;
1348
 
        int away = 0;
1349
 
        int idle = 0;
1350
 
        char *msg = NULL;
 
1367
 
 
1368
        struct user
 
1369
        {
 
1370
                char *name;     /* 7    name */
 
1371
                int   state;    /* 10   state */
 
1372
                int   flags;    /* 13   flags, bit 0 = pager, bit 1 = chat, bit 2 = game */
 
1373
                int   mobile;   /* 60   mobile */
 
1374
                char *msg;      /* 19   custom status message */
 
1375
                int   away;     /* 47   away (or invisible)*/
 
1376
                int   buddy_session;    /* 11   state */
 
1377
                int   f17;      /* 17   in chat? then what about flags? */
 
1378
                int   idle;     /* 137  seconds idle */
 
1379
                int   f138;     /* 138  state */
 
1380
                char *f184;     /* 184  state */
 
1381
                int   f192;     /* 192  state */
 
1382
                int   f10001;   /* 10001        state */
 
1383
                int   f10002;   /* 10002        state */
 
1384
                int   f198;     /* 198  state */
 
1385
                char *f197;     /* 197  state */
 
1386
                char *f205;     /* 205  state */
 
1387
                int   f213;     /* 213  state */
 
1388
        } *u;
 
1389
 
 
1390
        YList *users = 0;
1351
1391
        
1352
 
        if(pkt->service == YAHOO_SERVICE_LOGOFF && pkt->status == -1) {
 
1392
        if (pkt->service == YAHOO_SERVICE_LOGOFF && pkt->status == -1) {
1353
1393
                YAHOO_CALLBACK(ext_yahoo_login_response)(yd->client_id, YAHOO_LOGIN_DUPL, NULL);
1354
1394
                return;
1355
1395
        }
1373
1413
                        NOTICE(("key %d:%s", pair->key, pair->value));
1374
1414
                        break;
1375
1415
                case 7: /* the current buddy */
1376
 
                        name = pair->value;
 
1416
                        u = y_new0(struct user, 1);
 
1417
                        u->name = pair->value;
 
1418
                        users = y_list_prepend(users, u);
1377
1419
                        break;
1378
1420
                case 10: /* state */
1379
 
                        state = strtol(pair->value, NULL, 10);
 
1421
                        ((struct user*)users->data)->state = strtol(pair->value, NULL, 10);
1380
1422
                        break;
1381
1423
                case 19: /* custom status message */
1382
 
                        msg = pair->value;
 
1424
                        ((struct user*)users->data)->msg = pair->value;
1383
1425
                        break;
1384
1426
                case 47: /* is it an away message or not */
1385
 
                        away = atoi(pair->value);
 
1427
                        ((struct user*)users->data)->away = atoi(pair->value);
1386
1428
                        break;
1387
1429
                case 137: /* seconds idle */
1388
 
                        idle = atoi(pair->value);
 
1430
                        ((struct user*)users->data)->idle = atoi(pair->value);
1389
1431
                        break;
1390
 
                case 11: /* what is this? */
1391
 
                        NOTICE(("key %d:%s", pair->key, pair->value));
 
1432
                case 11: /* this is the buddy's session id */
 
1433
                        ((struct user*)users->data)->buddy_session = atoi(pair->value);
1392
1434
                        break;
1393
1435
                case 17: /* in chat? */
1394
 
                        break;
1395
 
                case 13: /* in pager? */
1396
 
                        if (pkt->service == YAHOO_SERVICE_LOGOFF || strtol(pair->value, NULL, 10) == 0) {
1397
 
                                YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, name, YAHOO_STATUS_OFFLINE, NULL, 1);
1398
 
                                break;
1399
 
                        }
1400
 
                        if (state == YAHOO_STATUS_AVAILABLE) {
1401
 
                                YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, name, state, NULL, 0);
1402
 
                        } else if (state == YAHOO_STATUS_CUSTOM) {
1403
 
                                YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, name, state, msg, away);
1404
 
                        } else {
1405
 
                                YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, name, state, NULL, idle);
1406
 
                        }
1407
 
 
1408
 
                        break;
1409
 
                case 60: 
 
1436
                        ((struct user*)users->data)->f17 = atoi(pair->value);
 
1437
                        break;
 
1438
                case 13: /* bitmask, bit 0 = pager, bit 1 = chat, bit 2 = game */
 
1439
                        ((struct user*)users->data)->flags = atoi(pair->value);
 
1440
                        break;
 
1441
                case 60: /* SMS -> 1 MOBILE USER */
1410
1442
                        /* sometimes going offline makes this 2, but invisible never sends it */
1411
 
                        NOTICE(("key %d:%s", pair->key, pair->value));
1412
 
                         break;
 
1443
                        ((struct user*)users->data)->mobile = atoi(pair->value);
 
1444
                        break;
 
1445
                case 138:
 
1446
                        ((struct user*)users->data)->f138 = atoi(pair->value);
 
1447
                        break;
 
1448
                case 184:
 
1449
                        ((struct user*)users->data)->f184 = pair->value;
 
1450
                        break;
 
1451
                case 192:
 
1452
                        ((struct user*)users->data)->f192 = atoi(pair->value);
 
1453
                        break;
 
1454
                case 10001:
 
1455
                        ((struct user*)users->data)->f10001 = atoi(pair->value);
 
1456
                        break;
 
1457
                case 10002:
 
1458
                        ((struct user*)users->data)->f10002 = atoi(pair->value);
 
1459
                        break;
 
1460
                case 198:
 
1461
                        ((struct user*)users->data)->f198 = atoi(pair->value);
 
1462
                        break;
 
1463
                case 197:
 
1464
                        ((struct user*)users->data)->f197 = pair->value;
 
1465
                        break;
 
1466
                case 205:
 
1467
                        ((struct user*)users->data)->f205 = pair->value;
 
1468
                        break;
 
1469
                case 213:
 
1470
                        ((struct user*)users->data)->f213 = atoi(pair->value);
 
1471
                        break;
1413
1472
                case 16: /* Custom error message */
1414
 
                        YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, pair->value, 0);
 
1473
                        YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, pair->value, 0, E_CUSTOM);
1415
1474
                        break;
1416
1475
                default:
1417
1476
                        WARNING(("unknown status key %d:%s", pair->key, pair->value));
1418
1477
                        break;
1419
1478
                }
1420
1479
        }
 
1480
        
 
1481
        while (users) {
 
1482
                YList *t = users;
 
1483
                struct user *u = users->data;
 
1484
 
 
1485
                if (u->name != NULL) {
 
1486
                        if (pkt->service == YAHOO_SERVICE_LOGOFF || u->flags == 0) {
 
1487
                                YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, u->name, YAHOO_STATUS_OFFLINE, NULL, 1, 0, 0);
 
1488
                        } else {
 
1489
                                YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, u->name, u->state, u->msg, u->away, u->idle, u->mobile);
 
1490
                        }
 
1491
                }
 
1492
 
 
1493
                users = y_list_remove_link(users, users);
 
1494
                y_list_free_1(t);
 
1495
                FREE(u);
 
1496
        }
1421
1497
}
1422
1498
 
1423
1499
static void yahoo_process_list(struct yahoo_input_data *yid, struct yahoo_packet *pkt)
1523
1599
 
1524
1600
}
1525
1601
 
 
1602
static void yahoo_process_picture_checksum( struct yahoo_input_data *yid, struct yahoo_packet *pkt)
 
1603
{
 
1604
        struct yahoo_data *yd = yid->yd;
 
1605
        char *from;
 
1606
        char *to;
 
1607
        int checksum = 0;
 
1608
        YList *l;
 
1609
 
 
1610
        for(l = pkt->hash; l; l = l->next)
 
1611
        {
 
1612
                struct yahoo_pair *pair = l->data;
 
1613
 
 
1614
                switch(pair->key)
 
1615
                {
 
1616
                        case 1:
 
1617
                        case 4:
 
1618
                                from = pair->value;
 
1619
                        case 5:
 
1620
                                to = pair->value;
 
1621
                                break;
 
1622
                        case 212:
 
1623
                                break;
 
1624
                        case 192:
 
1625
                                checksum = atoi( pair->value );
 
1626
                                break;
 
1627
                }
 
1628
        }
 
1629
 
 
1630
        YAHOO_CALLBACK(ext_yahoo_got_buddyicon_checksum)(yd->client_id,to,from,checksum);
 
1631
}
 
1632
 
 
1633
static void yahoo_process_picture(struct yahoo_input_data *yid, struct yahoo_packet *pkt)
 
1634
{
 
1635
        struct yahoo_data *yd = yid->yd;
 
1636
        char *url;
 
1637
        char *from;
 
1638
        char *to;
 
1639
        int status = 0;
 
1640
        int checksum = 0;
 
1641
        YList *l;
 
1642
        
 
1643
        for(l = pkt->hash; l; l = l->next)
 
1644
        {
 
1645
                struct yahoo_pair *pair = l->data;
 
1646
 
 
1647
                switch(pair->key)
 
1648
                {
 
1649
                case 1:
 
1650
                case 4:         /* sender */
 
1651
                        from = pair->value;
 
1652
                        break;
 
1653
                case 5:         /* we */
 
1654
                        to = pair->value;
 
1655
                        break;
 
1656
                case 13:                /* request / sending */
 
1657
                        status = atoi( pair->value );
 
1658
                        break;
 
1659
                case 20:                /* url */
 
1660
                        url = pair->value;
 
1661
                        break;
 
1662
                case 192:       /*checksum */
 
1663
                        checksum = atoi( pair->value );
 
1664
                        break;
 
1665
                }
 
1666
        }
 
1667
 
 
1668
        switch( status )
 
1669
        {
 
1670
                case 1: /* this is a request, ignore for now */
 
1671
                        YAHOO_CALLBACK(ext_yahoo_got_buddyicon_request)(yd->client_id, to, from);
 
1672
                        break;
 
1673
                case 2: /* this is cool - we get a picture :) */
 
1674
                        YAHOO_CALLBACK(ext_yahoo_got_buddyicon)(yd->client_id,to, from, url, checksum);
 
1675
                        break;
 
1676
        }
 
1677
}
 
1678
 
 
1679
static void yahoo_process_picture_upload(struct yahoo_input_data *yid, struct yahoo_packet *pkt)
 
1680
{
 
1681
        struct yahoo_data *yd = yid->yd;
 
1682
        YList *l;
 
1683
        char *url;
 
1684
 
 
1685
        if ( pkt->status != 1 )
 
1686
                return;         /* something went wrong */
 
1687
        
 
1688
        for(l = pkt->hash; l; l = l->next)
 
1689
        {
 
1690
                struct yahoo_pair *pair = l->data;
 
1691
 
 
1692
                switch(pair->key)
 
1693
                {
 
1694
                        case 5:         /* we */
 
1695
                                break;
 
1696
                        case 20:                /* url */
 
1697
                                url = pair->value;
 
1698
                                break;
 
1699
                        case 27:                /* local filename */
 
1700
                                break;
 
1701
                        case 38:                /* time */
 
1702
                                break;
 
1703
                }
 
1704
        }
 
1705
 
 
1706
        YAHOO_CALLBACK(ext_yahoo_buddyicon_uploaded)(yd->client_id, url);
 
1707
}
 
1708
 
1526
1709
static void yahoo_process_auth_pre_0x0b(struct yahoo_input_data *yid, 
1527
1710
                const char *seed, const char *sn)
1528
1711
{
1650
1833
        md5_byte_t         result[16];
1651
1834
        md5_state_t        ctx;
1652
1835
 
1653
 
        SHA_CTX            ctx1;
1654
 
        SHA_CTX            ctx2;
 
1836
        SHA1Context        ctx1;
 
1837
        SHA1Context        ctx2;
1655
1838
 
1656
1839
        char *alphabet1 = "FBZDWAGHrJTLMNOPpRSKUVEXYChImkwQ";
1657
1840
        char *alphabet2 = "F0E1D2C3B4A59687abcdefghijklmnop";
1867
2050
        md5_append(&ctx, (md5_byte_t *)crypt_result, strlen(crypt_result));
1868
2051
        md5_finish(&ctx, result);
1869
2052
        to_y64(crypt_hash, result, 16);
 
2053
        free(crypt_result);
1870
2054
 
1871
2055
        /* Our first authentication response is based off 
1872
2056
         * of the password hash. */
1885
2069
        if (cnt < 64) 
1886
2070
                memset(&(pass_hash_xor2[cnt]), 0x5c, 64-cnt);
1887
2071
 
1888
 
        shaInit(&ctx1);
1889
 
        shaInit(&ctx2);
 
2072
        SHA1Init(&ctx1);
 
2073
        SHA1Init(&ctx2);
1890
2074
 
1891
2075
        /* The first context gets the password hash XORed 
1892
2076
         * with 0x36 plus a magic value
1893
2077
         * which we previously extrapolated from our 
1894
2078
         * challenge. */
1895
2079
 
1896
 
        shaUpdate(&ctx1, pass_hash_xor1, 64);
 
2080
        SHA1Update(&ctx1, pass_hash_xor1, 64);
1897
2081
        if (j >= 3)
1898
 
                ctx1.sizeLo = 0x1ff;
1899
 
        shaUpdate(&ctx1, magic_key_char, 4);
1900
 
        shaFinal(&ctx1, digest1);
 
2082
                ctx1.totalLength = 0x1ff;
 
2083
        SHA1Update(&ctx1, magic_key_char, 4);
 
2084
        SHA1Final(&ctx1, digest1);
1901
2085
 
1902
2086
         /* The second context gets the password hash XORed 
1903
2087
          * with 0x5c plus the SHA-1 digest
1904
2088
          * of the first context. */
1905
2089
 
1906
 
        shaUpdate(&ctx2, pass_hash_xor2, 64);
1907
 
        shaUpdate(&ctx2, digest1, 20);
1908
 
        shaFinal(&ctx2, digest2);
 
2090
        SHA1Update(&ctx2, pass_hash_xor2, 64);
 
2091
        SHA1Update(&ctx2, digest1, 20);
 
2092
        SHA1Final(&ctx2, digest2);
1909
2093
 
1910
2094
        /* Now that we have digest2, use it to fetch 
1911
2095
         * characters from an alphabet to construct
1976
2160
        if (cnt < 64) 
1977
2161
                memset(&(crypt_hash_xor2[cnt]), 0x5c, 64-cnt);
1978
2162
 
1979
 
        shaInit(&ctx1);
1980
 
        shaInit(&ctx2);
 
2163
        SHA1Init(&ctx1);
 
2164
        SHA1Init(&ctx2);
1981
2165
 
1982
2166
        /* The first context gets the password hash XORed 
1983
2167
         * with 0x36 plus a magic value
1984
2168
         * which we previously extrapolated from our 
1985
2169
         * challenge. */
1986
2170
 
1987
 
        shaUpdate(&ctx1, crypt_hash_xor1, 64);
 
2171
        SHA1Update(&ctx1, crypt_hash_xor1, 64);
1988
2172
        if (j >= 3)
1989
 
                ctx1.sizeLo = 0x1ff;
1990
 
        shaUpdate(&ctx1, magic_key_char, 4);
1991
 
        shaFinal(&ctx1, digest1);
 
2173
                ctx1.totalLength = 0x1ff;
 
2174
        SHA1Update(&ctx1, magic_key_char, 4);
 
2175
        SHA1Final(&ctx1, digest1);
1992
2176
 
1993
2177
        /* The second context gets the password hash XORed 
1994
2178
         * with 0x5c plus the SHA-1 digest
1995
2179
         * of the first context. */
1996
2180
 
1997
 
        shaUpdate(&ctx2, crypt_hash_xor2, 64);
1998
 
        shaUpdate(&ctx2, digest1, 20);
1999
 
        shaFinal(&ctx2, digest2);
 
2181
        SHA1Update(&ctx2, crypt_hash_xor2, 64);
 
2182
        SHA1Update(&ctx2, digest1, 20);
 
2183
        SHA1Final(&ctx2, digest2);
2000
2184
 
2001
2185
        /* Now that we have digest2, use it to fetch 
2002
2186
         * characters from an alphabet to construct
2164
2348
        int state = YAHOO_STATUS_AVAILABLE;
2165
2349
        int online = FALSE;
2166
2350
        int away = 0;
 
2351
        int idle = 0;
 
2352
        int mobile = 0;
2167
2353
 
2168
2354
        YList *l;
2169
2355
 
2185
2371
                        online = strtol(pair->value, NULL, 10);
2186
2372
                else if (pair->key == 47)
2187
2373
                        away = strtol(pair->value, NULL, 10);
 
2374
                else if (pair->key == 137)
 
2375
                        idle = strtol(pair->value, NULL, 10);
 
2376
                else if (pair->key == 60)
 
2377
                        mobile = strtol(pair->value, NULL, 10);
 
2378
                
2188
2379
        }
2189
2380
 
2190
2381
        if (id)
2191
2382
                YAHOO_CALLBACK(ext_yahoo_contact_added)(yd->client_id, id, who, msg);
2192
2383
        else if (name)
2193
 
                YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, name, state, msg, away);
 
2384
                YAHOO_CALLBACK(ext_yahoo_status_changed)(yd->client_id, name, state, msg, away, idle, mobile);
2194
2385
        else if(pkt->status == 0x07)
2195
2386
                YAHOO_CALLBACK(ext_yahoo_rejected)(yd->client_id, who, msg);
2196
2387
}
2318
2509
         */
2319
2510
 
2320
2511
/*      if(status)
2321
 
                YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, status, who, 0);
 
2512
                YAHOO_CALLBACK(ext_yahoo_error)(yd->client_id, who, 0, status);
2322
2513
*/      
2323
2514
}
2324
2515
 
2342
2533
                        room=pair->value;
2343
2534
        }
2344
2535
 
2345
 
        NOTICE(("got voice chat invite from %s in %s", who, room));
 
2536
        NOTICE(("got voice chat invite from %s in %s to identity %s", who, room, me));
2346
2537
        /* 
2347
2538
         * send: s:0 1:me 5:who 57:room 13:1
2348
2539
         * ????  s:4 5:who 10:99 19:-1615114531
2354
2545
         */
2355
2546
}
2356
2547
 
 
2548
static void yahoo_process_ping(struct yahoo_input_data *yid, struct yahoo_packet *pkt)
 
2549
{
 
2550
        char *errormsg = NULL;
 
2551
        
 
2552
        YList *l;
 
2553
        for (l = pkt->hash; l; l = l->next) {
 
2554
                struct yahoo_pair *pair = l->data;
 
2555
                if (pair->key == 16)
 
2556
                        errormsg = pair->value;
 
2557
        }
 
2558
        
 
2559
        NOTICE(("got ping packet"));
 
2560
        YAHOO_CALLBACK(ext_yahoo_got_ping)(yid->yd->client_id, errormsg);
 
2561
}
 
2562
 
2357
2563
static void _yahoo_webcam_get_server_connected(int fd, int error, void *d)
2358
2564
{
2359
2565
        struct yahoo_input_data *yid = d;
2529
2735
        case YAHOO_SERVICE_WEBCAM:
2530
2736
                yahoo_process_webcam_key(yid, pkt);
2531
2737
                break;
 
2738
        case YAHOO_SERVICE_PING:
 
2739
                yahoo_process_ping(yid, pkt);
 
2740
                break;
2532
2741
        case YAHOO_SERVICE_IDLE:
2533
2742
        case YAHOO_SERVICE_MAILSTAT:
2534
2743
        case YAHOO_SERVICE_CHATINVITE:
2536
2745
        case YAHOO_SERVICE_NEWPERSONALMAIL:
2537
2746
        case YAHOO_SERVICE_ADDIDENT:
2538
2747
        case YAHOO_SERVICE_ADDIGNORE:
2539
 
        case YAHOO_SERVICE_PING:
2540
2748
        case YAHOO_SERVICE_GOTGROUPRENAME:
2541
2749
        case YAHOO_SERVICE_GROUPRENAME:
2542
2750
        case YAHOO_SERVICE_PASSTHROUGH2:
2548
2756
                WARNING(("unhandled service 0x%02x", pkt->service));
2549
2757
                yahoo_dump_unhandled(pkt);
2550
2758
                break;
 
2759
        case YAHOO_SERVICE_PICTURE:
 
2760
                yahoo_process_picture(yid, pkt);
 
2761
                break;
 
2762
        case YAHOO_SERVICE_PICTURE_CHECKSUM:
 
2763
                yahoo_process_picture_checksum(yid, pkt);
 
2764
                break;
 
2765
        case YAHOO_SERVICE_PICTURE_UPLOAD:
 
2766
                yahoo_process_picture_upload(yid, pkt);
 
2767
                break;  
2551
2768
        default:
2552
2769
                WARNING(("unknown service 0x%02x", pkt->service));
2553
2770
                yahoo_dump_unhandled(pkt);
3357
3574
                DEBUG_MSG(("len == %d (<= 0)", len));
3358
3575
 
3359
3576
                if(yid->type == YAHOO_CONNECTION_PAGER) {
3360
 
                        YAHOO_CALLBACK(ext_yahoo_login_response)(yid->yd->client_id, YAHOO_LOGIN_SOCK, NULL);
 
3577
                        YAHOO_CALLBACK(ext_yahoo_error)(yid->yd->client_id, "Connection closed by server", 1, E_CONNECTION);
3361
3578
                }
3362
3579
 
3363
3580
                yahoo_process_connection[yid->type](yid, 1);
3505
3722
                return yid->fd;
3506
3723
}
3507
3724
 
3508
 
void yahoo_send_im(int id, const char *from, const char *who, const char *what, int utf8)
 
3725
void yahoo_send_im(int id, const char *from, const char *who, const char *what, int utf8, int picture)
3509
3726
{
3510
3727
        struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
3511
3728
        struct yahoo_packet *pkt = NULL;
3512
3729
        struct yahoo_data *yd;
 
3730
        char pic_str[10];
3513
3731
 
3514
3732
        if(!yid)
3515
3733
                return;
3518
3736
 
3519
3737
        pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE, yd->session_id);
3520
3738
 
 
3739
        snprintf(pic_str, sizeof(pic_str), "%d", picture);
 
3740
        
3521
3741
        if(from && strcmp(from, yd->user))
3522
3742
                yahoo_packet_hash(pkt, 0, yd->user);
3523
3743
        yahoo_packet_hash(pkt, 1, from?from:yd->user);
3529
3749
 
3530
3750
        yahoo_packet_hash(pkt, 63, ";0");       /* imvironment name; or ;0 */
3531
3751
        yahoo_packet_hash(pkt, 64, "0");
 
3752
        yahoo_packet_hash(pkt, 206, pic_str);
3532
3753
 
3533
3754
 
3534
3755
        yahoo_send_packet(yid, pkt, 0);
3581
3802
                service = YAHOO_SERVICE_ISBACK;
3582
3803
        else
3583
3804
                service = YAHOO_SERVICE_ISAWAY;
3584
 
        pkt = yahoo_packet_new(service, yd->current_status, yd->session_id);
3585
 
        snprintf(s, sizeof(s), "%d", yd->current_status);
3586
 
        yahoo_packet_hash(pkt, 10, s);
3587
 
        if (yd->current_status == YAHOO_STATUS_CUSTOM) {
3588
 
                yahoo_packet_hash(pkt, 19, msg);
3589
 
                yahoo_packet_hash(pkt, 47, away?"1":"0");
 
3805
         
 
3806
        if ((away == 2) && (yd->current_status == YAHOO_STATUS_AVAILABLE)) {
 
3807
                pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_BRB, yd->session_id);
 
3808
                yahoo_packet_hash(pkt, 10, "999");
 
3809
                yahoo_packet_hash(pkt, 47, "2");
 
3810
        }else {
 
3811
                pkt = yahoo_packet_new(service, YAHOO_STATUS_AVAILABLE, yd->session_id);
 
3812
                snprintf(s, sizeof(s), "%d", yd->current_status);
 
3813
                yahoo_packet_hash(pkt, 10, s);
 
3814
                if (yd->current_status == YAHOO_STATUS_CUSTOM) {
 
3815
                        yahoo_packet_hash(pkt, 19, msg);
 
3816
                        yahoo_packet_hash(pkt, 47, (away == 2)? "2": (away) ?"1":"0");
 
3817
                } else {
 
3818
                        yahoo_packet_hash(pkt, 47, (away == 2)? "2": (away) ?"1":"0");
 
3819
                }
 
3820
                
 
3821
                
 
3822
                
3590
3823
        }
3591
3824
 
3592
3825
        yahoo_send_packet(yid, pkt, 0);
3844
4077
        yahoo_packet_hash(pkt, 1, yd->user);
3845
4078
        yahoo_packet_hash(pkt, 7, who);
3846
4079
        yahoo_packet_hash(pkt, 65, group);
3847
 
        if(msg)
 
4080
        if (msg != NULL) /* add message/request "it's me add me" */
3848
4081
                yahoo_packet_hash(pkt, 14, msg);
3849
 
 
3850
4082
        yahoo_send_packet(yid, pkt, 0);
3851
4083
        yahoo_packet_free(pkt);
3852
4084
}
3912
4144
        yahoo_packet_free(pkt);
3913
4145
}
3914
4146
 
 
4147
void yahoo_stealth_buddy(int id, const char *who, int unstealth)
 
4148
{
 
4149
        struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
 
4150
        struct yahoo_data *yd;
 
4151
        struct yahoo_packet *pkt;
 
4152
 
 
4153
        if(!yid)
 
4154
                return;
 
4155
        yd = yid->yd;
 
4156
 
 
4157
        if (!yd->logged_in)
 
4158
                return;
 
4159
 
 
4160
        pkt = yahoo_packet_new(YAHOO_SERVICE_STEALTH, YAHOO_STATUS_AVAILABLE, yd->session_id);
 
4161
        yahoo_packet_hash(pkt, 1, yd->user);
 
4162
        yahoo_packet_hash(pkt, 7, who);
 
4163
        yahoo_packet_hash(pkt, 31, unstealth?"2":"1");
 
4164
        yahoo_packet_hash(pkt, 13, "2");
 
4165
        yahoo_send_packet(yid, pkt, 0);
 
4166
        yahoo_packet_free(pkt);
 
4167
}
 
4168
 
3915
4169
void yahoo_change_buddy_group(int id, const char *who, const char *old_group, const char *new_group)
3916
4170
{
3917
4171
        struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
4220
4474
        yahoo_packet_free(pkt);
4221
4475
}
4222
4476
 
 
4477
void yahoo_buddyicon_request(int id, const char *who)
 
4478
{
 
4479
        struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
 
4480
        struct yahoo_data *yd;
 
4481
        struct yahoo_packet *pkt;
 
4482
 
 
4483
        if( !yid )
 
4484
                return;
 
4485
 
 
4486
        yd = yid->yd;
 
4487
        
 
4488
        pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YAHOO_STATUS_AVAILABLE, 0);
 
4489
        yahoo_packet_hash(pkt, 4, yd->user);
 
4490
        yahoo_packet_hash(pkt, 5, who);
 
4491
        yahoo_packet_hash(pkt, 13, "1");
 
4492
        yahoo_send_packet(yid, pkt, 0);
 
4493
 
 
4494
        yahoo_packet_free(pkt);
 
4495
}
 
4496
 
 
4497
void yahoo_send_picture_info(int id, const char *who, const char *url, int checksum)
 
4498
{
 
4499
        struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
 
4500
        struct yahoo_data *yd;
 
4501
        struct yahoo_packet *pkt;
 
4502
        char checksum_str[10];
 
4503
 
 
4504
        if( !yid )
 
4505
                return;
 
4506
 
 
4507
        yd = yid->yd;
 
4508
 
 
4509
        snprintf(checksum_str, sizeof(checksum_str), "%d", checksum);
 
4510
 
 
4511
        pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE, YAHOO_STATUS_AVAILABLE, 0);
 
4512
        yahoo_packet_hash(pkt, 1, yd->user);
 
4513
        yahoo_packet_hash(pkt, 4, yd->user);
 
4514
        yahoo_packet_hash(pkt, 5, who);
 
4515
        yahoo_packet_hash(pkt, 13, "2");
 
4516
        yahoo_packet_hash(pkt, 20, url);
 
4517
        yahoo_packet_hash(pkt, 192, checksum_str);
 
4518
        yahoo_send_packet(yid, pkt, 0);
 
4519
 
 
4520
        yahoo_packet_free(pkt);
 
4521
}
 
4522
 
 
4523
void yahoo_send_picture_update(int id, const char *who, int type)
 
4524
{
 
4525
        struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
 
4526
        struct yahoo_data *yd;
 
4527
        struct yahoo_packet *pkt;
 
4528
        char type_str[10];
 
4529
 
 
4530
        if( !yid )
 
4531
                return;
 
4532
 
 
4533
        yd = yid->yd;
 
4534
 
 
4535
        snprintf(type_str, sizeof(type_str), "%d", type);
 
4536
 
 
4537
        pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_UPDATE, YAHOO_STATUS_AVAILABLE, 0);
 
4538
        yahoo_packet_hash(pkt, 1, yd->user);
 
4539
        yahoo_packet_hash(pkt, 5, who);
 
4540
        yahoo_packet_hash(pkt, 206, type_str);
 
4541
        yahoo_send_packet(yid, pkt, 0);
 
4542
 
 
4543
        yahoo_packet_free(pkt);
 
4544
}
 
4545
 
 
4546
void yahoo_send_picture_checksum(int id, const char *who, int checksum)
 
4547
{
 
4548
        struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_PAGER);
 
4549
        struct yahoo_data *yd;
 
4550
        struct yahoo_packet *pkt;
 
4551
        char checksum_str[10];
 
4552
 
 
4553
        if( !yid )
 
4554
                return;
 
4555
 
 
4556
        yd = yid->yd;
 
4557
        
 
4558
        snprintf(checksum_str, sizeof(checksum_str), "%d", checksum);
 
4559
 
 
4560
        pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_CHECKSUM, YAHOO_STATUS_AVAILABLE, 0);
 
4561
        yahoo_packet_hash(pkt, 1, yd->user);
 
4562
        if( who != 0 )
 
4563
                yahoo_packet_hash(pkt, 5, who);
 
4564
        yahoo_packet_hash(pkt, 192, checksum_str);
 
4565
        yahoo_packet_hash(pkt, 212, "1");
 
4566
        yahoo_send_packet(yid, pkt, 0);
 
4567
 
 
4568
        yahoo_packet_free(pkt);
 
4569
}
 
4570
 
4223
4571
void yahoo_webcam_close_feed(int id, const char *who)
4224
4572
{
4225
4573
        struct yahoo_input_data *yid = find_input_by_id_and_webcam_user(id, who);
4423
4771
        void *user_data;
4424
4772
};
4425
4773
 
 
4774
static void _yahoo_send_picture_connected(int id, int fd, int error, void *data)
 
4775
{
 
4776
        struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_FT);
 
4777
        struct send_file_data *sfd = data;
 
4778
        struct yahoo_packet *pkt = sfd->pkt;
 
4779
        unsigned char buff[1024];
 
4780
 
 
4781
        if(fd <= 0) {
 
4782
                sfd->callback(id, fd, error, sfd->user_data);
 
4783
                FREE(sfd);
 
4784
                yahoo_packet_free(pkt);
 
4785
                inputs = y_list_remove(inputs, yid);
 
4786
                FREE(yid);
 
4787
                return;
 
4788
        }
 
4789
 
 
4790
        yid->fd = fd;
 
4791
        yahoo_send_packet(yid, pkt, 8);
 
4792
        yahoo_packet_free(pkt);
 
4793
 
 
4794
        snprintf((char *)buff, sizeof(buff), "29");
 
4795
        buff[2] = 0xc0;
 
4796
        buff[3] = 0x80;
 
4797
        
 
4798
        write(yid->fd, buff, 4);
 
4799
 
 
4800
        /*      YAHOO_CALLBACK(ext_yahoo_add_handler)(nyd->fd, YAHOO_INPUT_READ); */
 
4801
 
 
4802
        sfd->callback(id, fd, error, sfd->user_data);
 
4803
        FREE(sfd);
 
4804
        inputs = y_list_remove(inputs, yid);
 
4805
        /*
 
4806
        while(yahoo_tcp_readline(buff, sizeof(buff), nyd->fd) > 0) {
 
4807
        if(!strcmp(buff, ""))
 
4808
        break;
 
4809
}
 
4810
 
 
4811
        */
 
4812
        yahoo_input_close(yid);
 
4813
}
 
4814
 
 
4815
void yahoo_send_picture(int id, const char *name, unsigned long size,
 
4816
                                                        yahoo_get_fd_callback callback, void *data)
 
4817
{
 
4818
        struct yahoo_data *yd = find_conn_by_id(id);
 
4819
        struct yahoo_input_data *yid;
 
4820
        struct yahoo_server_settings *yss;
 
4821
        struct yahoo_packet *pkt = NULL;
 
4822
        char size_str[10];
 
4823
        char expire_str[10];
 
4824
        long content_length=0;
 
4825
        unsigned char buff[1024];
 
4826
        char url[255];
 
4827
        struct send_file_data *sfd;
 
4828
 
 
4829
        if(!yd)
 
4830
                return;
 
4831
 
 
4832
        yss = yd->server_settings;
 
4833
 
 
4834
        yid = y_new0(struct yahoo_input_data, 1);
 
4835
        yid->yd = yd;
 
4836
        yid->type = YAHOO_CONNECTION_FT;
 
4837
 
 
4838
        pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_UPLOAD, YAHOO_STATUS_AVAILABLE, yd->session_id);
 
4839
 
 
4840
        snprintf(size_str, sizeof(size_str), "%ld", size);
 
4841
        snprintf(expire_str, sizeof(expire_str), "%ld", (long)604800);
 
4842
 
 
4843
        yahoo_packet_hash(pkt, 0, yd->user);
 
4844
        yahoo_packet_hash(pkt, 1, yd->user);
 
4845
        yahoo_packet_hash(pkt, 14, "");
 
4846
        yahoo_packet_hash(pkt, 27, name);
 
4847
        yahoo_packet_hash(pkt, 28, size_str);
 
4848
        yahoo_packet_hash(pkt, 38, expire_str);
 
4849
        
 
4850
 
 
4851
        content_length = YAHOO_PACKET_HDRLEN + yahoo_packet_length(pkt);
 
4852
 
 
4853
        snprintf(url, sizeof(url), "http://%s:%d/notifyft",
 
4854
                                yss->filetransfer_host, yss->filetransfer_port);
 
4855
        snprintf((char *)buff, sizeof(buff), "Y=%s; T=%s",
 
4856
                                 yd->cookie_y, yd->cookie_t);
 
4857
        inputs = y_list_prepend(inputs, yid);
 
4858
 
 
4859
        sfd = y_new0(struct send_file_data, 1);
 
4860
        sfd->pkt = pkt;
 
4861
        sfd->callback = callback;
 
4862
        sfd->user_data = data;
 
4863
        yahoo_http_post(yid->yd->client_id, url, (char *)buff, content_length+4+size,
 
4864
                                                _yahoo_send_picture_connected, sfd);
 
4865
}
 
4866
 
4426
4867
static void _yahoo_send_file_connected(int id, int fd, int error, void *data)
4427
4868
{
4428
4869
        struct yahoo_input_data *yid = find_input_by_id_and_type(id, YAHOO_CONNECTION_FT);