Mercurial > pidgin
comparison src/toc.c @ 1920:5bed3bc833b5
[gaim-migrate @ 1930]
in addition, frombase64 mods, needed for buddy icon in toc.
committer: Tailor Script <tailor@pidgin.im>
| author | Eric Warmenhoven <eric@warmenhoven.org> |
|---|---|
| date | Wed, 30 May 2001 18:26:52 +0000 |
| parents | a02584b98823 |
| children | a69396ce5bab |
comparison
equal
deleted
inserted
replaced
| 1919:4dcaa4afc6c0 | 1920:5bed3bc833b5 |
|---|---|
| 90 char *filename; | 90 char *filename; |
| 91 int files; | 91 int files; |
| 92 int size; | 92 int size; |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 struct buddy_icon { | |
| 96 guint32 hash; | |
| 97 guint32 len; | |
| 98 time_t time; | |
| 99 void *data; | |
| 100 }; | |
| 101 | |
| 95 struct toc_data { | 102 struct toc_data { |
| 96 int toc_fd; | 103 int toc_fd; |
| 97 int seqno; | 104 int seqno; |
| 98 int state; | 105 int state; |
| 99 }; | 106 }; |
| 379 /* Client sends TOC toc_init_done message */ | 386 /* Client sends TOC toc_init_done message */ |
| 380 debug_printf("* Client sends TOC toc_init_done message\n"); | 387 debug_printf("* Client sends TOC toc_init_done message\n"); |
| 381 g_snprintf(snd, sizeof snd, "toc_init_done"); | 388 g_snprintf(snd, sizeof snd, "toc_init_done"); |
| 382 sflap_send(gc, snd, -1, TYPE_DATA); | 389 sflap_send(gc, snd, -1, TYPE_DATA); |
| 383 | 390 |
| 391 /* | |
| 392 g_snprintf(snd, sizeof snd, "toc_set_caps %s %s %s", | |
| 393 FILE_SEND_UID, FILE_GET_UID, B_ICON_UID); | |
| 394 */ | |
| 384 g_snprintf(snd, sizeof snd, "toc_set_caps %s %s", FILE_SEND_UID, FILE_GET_UID); | 395 g_snprintf(snd, sizeof snd, "toc_set_caps %s %s", FILE_SEND_UID, FILE_GET_UID); |
| 385 sflap_send(gc, snd, -1, TYPE_DATA); | 396 sflap_send(gc, snd, -1, TYPE_DATA); |
| 386 | 397 |
| 387 return; | 398 return; |
| 388 } | 399 } |
| 614 | 625 |
| 615 for (i = 0; i < 4; i++) { | 626 for (i = 0; i < 4; i++) { |
| 616 sscanf(strtok(NULL, ":"), "%d", &unk[i]); | 627 sscanf(strtok(NULL, ":"), "%d", &unk[i]); |
| 617 if (unk[i] == 10001) | 628 if (unk[i] == 10001) |
| 618 break; | 629 break; |
| 619 messages[i] = frombase64(strtok(NULL, ":")); | 630 frombase64(strtok(NULL, ":"), &messages[i], NULL); |
| 620 } | 631 } |
| 621 tmp = frombase64(strtok(NULL, ":")); | 632 frombase64(strtok(NULL, ":"), &tmp, NULL); |
| 622 | 633 |
| 623 subtype = tmp[1]; | 634 subtype = tmp[1]; |
| 624 files = tmp[3]; | 635 files = tmp[3]; |
| 625 | 636 |
| 626 totalsize |= (tmp[4] << 24) & 0xff000000; | 637 totalsize |= (tmp[4] << 24) & 0xff000000; |
| 668 | 679 |
| 669 for (i = 0; i < 4; i++) { | 680 for (i = 0; i < 4; i++) { |
| 670 sscanf(strtok(NULL, ":"), "%d", unk + i); | 681 sscanf(strtok(NULL, ":"), "%d", unk + i); |
| 671 if (unk[i] == 10001) | 682 if (unk[i] == 10001) |
| 672 break; | 683 break; |
| 673 messages[i] = frombase64(strtok(NULL, ":")); | 684 frombase64(strtok(NULL, ":"), &messages[i], NULL); |
| 674 } | 685 } |
| 675 tmp = frombase64(strtok(NULL, ":")); | 686 frombase64(strtok(NULL, ":"), &tmp, NULL); |
| 676 | 687 |
| 677 ft = g_new0(struct ft_request, 1); | 688 ft = g_new0(struct ft_request, 1); |
| 678 ft->cookie = g_strdup(cookie); | 689 ft->cookie = g_strdup(cookie); |
| 679 ft->ip = g_strdup(pip); | 690 ft->ip = g_strdup(pip); |
| 680 ft->port = port; | 691 ft->port = port; |
| 692 | 703 |
| 693 accept_file_dialog(ft); | 704 accept_file_dialog(ft); |
| 694 } else if (!strcmp(uuid, VOICE_UID)) { | 705 } else if (!strcmp(uuid, VOICE_UID)) { |
| 695 /* oh goody. voice over ip. fun stuff. */ | 706 /* oh goody. voice over ip. fun stuff. */ |
| 696 } else if (!strcmp(uuid, B_ICON_UID)) { | 707 } else if (!strcmp(uuid, B_ICON_UID)) { |
| 697 /* buddy icon... */ | 708 /* |
| 709 int unk[4], i; | |
| 710 char *messages[4]; | |
| 711 struct buddy_icon *icon; | |
| 712 | |
| 713 for (i = 0; i < 4; i++) { | |
| 714 sscanf(strtok(NULL, ":"), "%d", unk + i); | |
| 715 if (unk[i] == 10001) | |
| 716 break; | |
| 717 frombase64(strtok(NULL, ":"), &messages[i], NULL); | |
| 718 } | |
| 719 frombase64(strtok(NULL, ":"), (char **)&icon, NULL); | |
| 720 | |
| 721 debug_printf("received icon of length %d\n", icon->len); | |
| 722 g_free(icon); | |
| 723 for (i--; i >= 0; i--) | |
| 724 g_free(messages[i]); | |
| 725 */ | |
| 698 } else if (!strcmp(uuid, IMAGE_UID)) { | 726 } else if (!strcmp(uuid, IMAGE_UID)) { |
| 699 /* aka Direct IM */ | 727 /* aka Direct IM */ |
| 700 } else { | 728 } else { |
| 701 debug_printf("Don't know what to do with RVOUS UUID %s\n", uuid); | 729 debug_printf("Don't know what to do with RVOUS UUID %s\n", uuid); |
| 702 /* do we have to do anything here? i think it just times out */ | 730 /* do we have to do anything here? i think it just times out */ |
| 1360 g_free(ft); | 1388 g_free(ft); |
| 1361 return; | 1389 return; |
| 1362 } | 1390 } |
| 1363 | 1391 |
| 1364 if (ft->hdr.hdrtype != 0x202) { | 1392 if (ft->hdr.hdrtype != 0x202) { |
| 1365 char *buf = frombase64(ft->cookie); | 1393 char *buf; |
| 1394 frombase64(ft->cookie, &buf, NULL); | |
| 1366 | 1395 |
| 1367 read(source, ft, 8); | 1396 read(source, ft, 8); |
| 1368 read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); | 1397 read(source, &ft->hdr.bcookie, MIN(256 - 8, ntohs(ft->hdr.hdrlen) - 8)); |
| 1369 debug_header(ft); | 1398 debug_header(ft); |
| 1370 | 1399 |
| 1644 | 1673 |
| 1645 hdr = (struct file_header *)ft; | 1674 hdr = (struct file_header *)ft; |
| 1646 hdr->magic[0] = 'O'; hdr->magic[1] = 'F'; hdr->magic[2] = 'T'; hdr->magic[3] = '2'; | 1675 hdr->magic[0] = 'O'; hdr->magic[1] = 'F'; hdr->magic[2] = 'T'; hdr->magic[3] = '2'; |
| 1647 hdr->hdrlen = htons(256); | 1676 hdr->hdrlen = htons(256); |
| 1648 hdr->hdrtype = htons(0x1108); | 1677 hdr->hdrtype = htons(0x1108); |
| 1649 buf = frombase64(ft->cookie); | 1678 frombase64(ft->cookie, &buf, NULL); |
| 1650 g_snprintf(hdr->bcookie, 8, "%s", buf); | 1679 g_snprintf(hdr->bcookie, 8, "%s", buf); |
| 1651 g_free(buf); | 1680 g_free(buf); |
| 1652 hdr->totfiles = htons(1); hdr->filesleft = htons(1); | 1681 hdr->totfiles = htons(1); hdr->filesleft = htons(1); |
| 1653 hdr->totparts = htons(1); hdr->partsleft = htons(1); | 1682 hdr->totparts = htons(1); hdr->partsleft = htons(1); |
| 1654 hdr->totsize = htonl((long)ft->st.st_size); /* combined size of all files */ | 1683 hdr->totsize = htonl((long)ft->st.st_size); /* combined size of all files */ |
