annotate src/protocols/msn/buddyicon.c @ 6800:8f228a7d5076

[gaim-migrate @ 7340] Added what I have of MSNSLP in my tree. It's broken, and therefore disabled, but I need to get this out so I can do other stuff too, and have something to revert back to if I break something :) committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Wed, 10 Sep 2003 00:24:48 +0000
parents 8efafdc38718
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1 /**
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2 * @file buddyicon.c Buddy icon support
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
3 *
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
4 * gaim
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
5 *
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
6 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org>
6701
b7e113a59b51 [gaim-migrate @ 7227]
Christian Hammond <chipx86@chipx86.com>
parents: 6695
diff changeset
7 *
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 * (at your option) any later version.
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 *
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 * GNU General Public License for more details.
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 *
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 */
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22 #include "msn.h"
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
23 #include "buddyicon.h"
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
24
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
25 #define PACKET_LENGTH 1500
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
26
5355
6a57fd9b45e1 [gaim-migrate @ 5731]
Christian Hammond <chipx86@chipx86.com>
parents: 5351
diff changeset
27 #define MAX_BUDDY_ICON_FILE_SIZE 8192
6a57fd9b45e1 [gaim-migrate @ 5731]
Christian Hammond <chipx86@chipx86.com>
parents: 5351
diff changeset
28
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
29 static const char alphabet[] =
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
30 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
31 "0123456789+/";
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
32
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
33 static char *
5793
952710ac6635 [gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
34 base64_enc(const char *data, int len)
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
35 {
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
36 char *dest;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
37 char *buf;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
38
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
39 buf = dest = g_malloc(4 * len / 3 + 4);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
40
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
41 /* Encode 3 bytes at a time */
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
42 while (len >= 3) {
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
43 buf[0] = alphabet[(data[0] >> 2) & 0x3F];
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
44 buf[1] = alphabet[((data[0] << 4) & 0x30) | ((data[1] >> 4) & 0x0F)];
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
45 buf[2] = alphabet[((data[1] << 2) & 0x3C) | ((data[2] >> 6) & 0x03)];
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
46 buf[3] = alphabet[data[2] & 0x3F];
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
47 data += 3;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48 buf += 4;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
49 len -= 3;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
50 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
52 if (len > 0) {
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
53 buf[0] = alphabet[(data[0] >> 2) & 0x3F];
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
54 buf[1] = alphabet[(data[0] << 4) & 0x30];
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
55
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
56 if (len > 1) {
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
57 buf[1] += (data[1] >> 4) & 0x0F;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
58 buf[2] = alphabet[(data[1] << 2) & 0x3C];
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
59 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
60
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
61 else
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62 buf[2] = '=';
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
64 buf[3] = '=';
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
65 buf += 4;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
66 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
67
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
68 *buf = '\0';
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
70 return dest;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
71 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
72
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
73 static gboolean
5793
952710ac6635 [gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
74 get_buddy_icon_info(GaimAccount *account, char **base64,
6478
338147ea6896 [gaim-migrate @ 6991]
Christian Hammond <chipx86@chipx86.com>
parents: 5793
diff changeset
75 char **md5sum, size_t *file_size, size_t *base64_size)
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
76 {
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
77 FILE *fp;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
78 struct stat sb;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
79 md5_state_t st;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
80 md5_byte_t di[16];
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5506
diff changeset
81 const char *icon;
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83 if (base64 != NULL) *base64 = NULL;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
84 if (md5sum != NULL) *md5sum = NULL;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
85 if (file_size != NULL) *file_size = 0;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
86 if (base64_size != NULL) *base64_size = 0;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
87
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5506
diff changeset
88 icon = gaim_account_get_buddy_icon(account);
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5506
diff changeset
89
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5506
diff changeset
90 if (!stat(icon, &sb)) {
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
91 if (file_size != NULL)
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92 *file_size = sb.st_size;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
93
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5506
diff changeset
94 if ((fp = fopen(icon, "rb")) != NULL) {
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95 char *buf = g_malloc(sb.st_size + 1);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
96 char *temp;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
97
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
98 fread(buf, 1, sb.st_size, fp);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
99
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
100 buf[sb.st_size] = '\0';
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
101
5793
952710ac6635 [gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
102 temp = base64_enc(buf, sb.st_size);
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
103
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
104 if (base64_size != NULL)
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
105 *base64_size = strlen(temp);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
106
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
107 if (base64 != NULL)
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
108 *base64 = temp;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
109 else
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
110 g_free(temp);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
111
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112 if (md5sum != NULL) {
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
113 char buf2[3];
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
114 int i;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
115
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116 md5_init(&st);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
117 md5_append(&st, (const md5_byte_t *)buf, sb.st_size);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
118 md5_finish(&st, di);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
119
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
120 *md5sum = g_new0(char, 33);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
121
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
122 for (i = 0; i < 16; i++) {
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
123 g_snprintf(buf2, sizeof(buf2), "%02x", di[i]);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124 strcat(*md5sum, buf2);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
125 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
126 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
127
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
128 g_free(buf);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
129
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
130 fclose(fp);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
132 else {
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
133 gaim_debug(GAIM_DEBUG_ERROR, "msn",
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
134 "Cannot open buddy icon file!\n");
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
135
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
136 return FALSE;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
138 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
139
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
140 return TRUE;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
141 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
142
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
143 static gboolean
5793
952710ac6635 [gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
144 send_icon_data(MsnSwitchBoard *swboard, MsnBuddyIconXfer *buddyicon)
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
145 {
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5506
diff changeset
146 GaimConnection *gc = swboard->servconn->session->account->gc;
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
147 char buf[MSN_BUF_LEN];
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
148 MsnMessage *msg;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
149 int len;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
150
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
151 len = MIN(PACKET_LENGTH - 4,
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
152 buddyicon->total_size - buddyicon->bytes_xfer);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
153
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
154 strcpy(buf, "ICON");
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
155
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
156 strncat(buf, buddyicon->data + buddyicon->bytes_xfer, len);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
157
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
158 msg = msn_message_new();
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
159 msn_message_set_content_type(msg, "application/x-buddyicon");
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
160 msn_message_set_receiver(msg, buddyicon->user);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
161 msn_message_set_charset(msg, NULL);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
162 msn_message_set_attr(msg, "User-Agent", NULL);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
163
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
164 msn_message_set_body(msg, buf);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
165
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
166 if (!msn_switchboard_send_msg(swboard, msg)) {
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
167 msn_message_destroy(msg);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
168
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
169 msn_buddy_icon_xfer_destroy(swboard->buddy_icon_xfer);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
170 swboard->buddy_icon_xfer = NULL;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
171
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5506
diff changeset
172 gaim_connection_error(gc, _("Write error"));
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
173
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
174 return FALSE;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
175 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
176
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
177 msn_message_destroy(msg);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
178
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
179 buddyicon->bytes_xfer += len;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
180
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
181 if (buddyicon->bytes_xfer == buddyicon->total_size) {
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
182 msg = msn_message_new();
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
183 msn_message_set_content_type(msg, "application/x-buddyicon");
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
184 msn_message_set_receiver(msg, buddyicon->user);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
185 msn_message_set_charset(msg, NULL);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
186 msn_message_set_attr(msg, "User-Agent", NULL);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
187
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
188 msn_message_set_body(msg, "Command: COMPLETE\r\n");
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
189
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
190 msn_switchboard_send_msg(swboard, msg);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
191
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
192 msn_buddy_icon_xfer_destroy(swboard->buddy_icon_xfer);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
193 swboard->buddy_icon_xfer = NULL;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
194 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
195
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
196 return TRUE;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
197 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
198
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
199 static gboolean
5793
952710ac6635 [gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
200 process_invite(MsnServConn *servconn, const MsnMessage *msg)
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
201 {
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
202 MsnSession *session = servconn->session;
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5506
diff changeset
203 GaimConnection *gc = session->account->gc;
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
204 MsnMessage *new_msg;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
205 MsnSwitchBoard *swboard;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
206 MsnBuddyIconXfer *buddyicon;
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6478
diff changeset
207 GaimBuddy *b;
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
208 GHashTable *table;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
209 const char *command;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
210
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
211 table = msn_message_get_hashtable_from_body(msg);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
212
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
213 command = g_hash_table_lookup(table, "Command");
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
214
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
215 if (command == NULL) {
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
216 gaim_debug(GAIM_DEBUG_ERROR, "msn",
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
217 "Missing Command from buddy icon message.\n");
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
218 return TRUE;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
219 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
220
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
221 if (!strcmp(command, "INVITE")) {
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
222 MsnUser *user;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
223 const char *md5sum = g_hash_table_lookup(table, "MD5SUM");
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
224 const char *size_s = g_hash_table_lookup(table, "File-Size");
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
225 const char *base64_size_s = g_hash_table_lookup(table, "Base64-Size");
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
226 const char *passport;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
227
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
228 if (md5sum == NULL) {
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
229 gaim_debug(GAIM_DEBUG_ERROR, "msn",
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
230 "Missing MD5SUM from buddy icon message.\n");
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
231
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
232 return TRUE;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
233 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
234
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
235 if (size_s == NULL) {
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
236 gaim_debug(GAIM_DEBUG_ERROR, "msn",
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
237 "Missing File-Size from buddy icon message.\n");
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
238
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
239 return TRUE;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
240 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
241
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
242 if (base64_size_s == NULL) {
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
243 gaim_debug(GAIM_DEBUG_ERROR, "msn",
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
244 "Missing Bas64-Size from buddy icon message.\n");
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
245
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
246 return TRUE;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
247 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
248
5355
6a57fd9b45e1 [gaim-migrate @ 5731]
Christian Hammond <chipx86@chipx86.com>
parents: 5351
diff changeset
249 if (atoi(size_s) > MAX_BUDDY_ICON_FILE_SIZE) {
6a57fd9b45e1 [gaim-migrate @ 5731]
Christian Hammond <chipx86@chipx86.com>
parents: 5351
diff changeset
250 gaim_debug(GAIM_DEBUG_ERROR, "msn",
6a57fd9b45e1 [gaim-migrate @ 5731]
Christian Hammond <chipx86@chipx86.com>
parents: 5351
diff changeset
251 "User tried to send a buddy icon over 8KB! "
6a57fd9b45e1 [gaim-migrate @ 5731]
Christian Hammond <chipx86@chipx86.com>
parents: 5351
diff changeset
252 "Not accepting.");
6a57fd9b45e1 [gaim-migrate @ 5731]
Christian Hammond <chipx86@chipx86.com>
parents: 5351
diff changeset
253 return TRUE;
6a57fd9b45e1 [gaim-migrate @ 5731]
Christian Hammond <chipx86@chipx86.com>
parents: 5351
diff changeset
254 }
6a57fd9b45e1 [gaim-migrate @ 5731]
Christian Hammond <chipx86@chipx86.com>
parents: 5351
diff changeset
255
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
256 user = msn_message_get_sender(msg);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
257
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
258 passport = msn_user_get_passport(user);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
259
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
260 /* See if we actually need a new icon. */
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
261 if ((b = gaim_find_buddy(gc->account, passport)) != NULL) {
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
262 const char *cur_md5sum;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
263
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
264 cur_md5sum = gaim_buddy_get_setting(b, "icon_checksum");
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
265
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
266 if (cur_md5sum != NULL && !strcmp(cur_md5sum, md5sum))
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
267 return TRUE;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
268 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
269
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
270 /* Send a request for transfer. */
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
271 new_msg = msn_message_new();
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
272 msn_message_set_content_type(new_msg, "application/x-buddyicon");
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
273 msn_message_set_receiver(new_msg, user);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
274 msn_message_set_charset(new_msg, NULL);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
275 msn_message_set_attr(new_msg, "User-Agent", NULL);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
276
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
277 msn_message_set_body(new_msg, "Command: REQUEST\r\n");
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
278
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
279 if ((swboard = msn_session_open_switchboard(session)) == NULL) {
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
280 msn_message_destroy(new_msg);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
281
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5506
diff changeset
282 gaim_connection_error(gc, _("Write error"));
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
283
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
284 return FALSE;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
285 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
286
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
287 swboard->hidden = TRUE;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
288 msn_switchboard_set_user(swboard, user);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
289 msn_switchboard_send_msg(swboard, new_msg);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
290
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
291 msn_message_destroy(new_msg);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
292
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
293 buddyicon = swboard->buddy_icon_xfer = msn_buddy_icon_xfer_new();
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
294
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
295 buddyicon->user = user;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
296 msn_user_ref(buddyicon->user);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
297
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
298 buddyicon->md5sum = g_strdup(md5sum);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
299 buddyicon->total_size = atoi(base64_size_s);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
300 buddyicon->file_size = atoi(size_s);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
301
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
302 buddyicon->data = g_malloc(buddyicon->total_size + 1);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
303 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
304 else if (!strcmp(command, "REQUEST")) {
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
305 swboard = (MsnSwitchBoard *)servconn->data;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
306
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
307 swboard->hidden = TRUE;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
308
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
309 swboard->buddy_icon_xfer = buddyicon = msn_buddy_icon_xfer_new();
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
310
5793
952710ac6635 [gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
311 if (!get_buddy_icon_info(gc->account,
952710ac6635 [gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
312 &buddyicon->data,
952710ac6635 [gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
313 &buddyicon->md5sum,
952710ac6635 [gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
314 &buddyicon->file_size,
952710ac6635 [gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
315 &buddyicon->total_size)) {
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
316
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
317 msn_buddy_icon_xfer_destroy(buddyicon);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
318
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
319 new_msg = msn_message_new();
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
320 msn_message_set_content_type(new_msg, "application/x-buddyicon");
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
321 msn_message_set_receiver(new_msg, msn_message_get_sender(msg));
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
322 msn_message_set_charset(new_msg, NULL);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
323 msn_message_set_attr(new_msg, "User-Agent", NULL);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
324
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
325 msn_message_set_body(new_msg, "Command: CANCEL\r\n");
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
326
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
327 if ((swboard = msn_session_open_switchboard(session)) == NULL) {
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
328 msn_message_destroy(new_msg);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
329
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5506
diff changeset
330 gaim_connection_error(gc, _("Write error"));
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
331
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
332 return FALSE;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
333 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
334
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
335 swboard->hidden = TRUE;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
336
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
337 msn_switchboard_send_msg(swboard, new_msg);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
338
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
339 msn_message_destroy(new_msg);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
340
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
341 msn_switchboard_destroy(swboard);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
342 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
343
5793
952710ac6635 [gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
344 return send_icon_data(swboard, buddyicon);
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
345 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
346 else if (!strcmp(command, "ACK")) {
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
347 swboard = (MsnSwitchBoard *)servconn->data;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
348
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
349 buddyicon = swboard->buddy_icon_xfer;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
350
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
351 if (buddyicon != NULL)
5793
952710ac6635 [gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
352 return send_icon_data(swboard, buddyicon);
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
353 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
354 else if (!strcmp(command, "COMPLETE")) {
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
355 const char *passport;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
356 char *icon;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
357 int icon_len;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
358
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
359 swboard = (MsnSwitchBoard *)servconn->data;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
360
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
361 buddyicon = swboard->buddy_icon_xfer;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
362
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
363 passport = msn_user_get_passport(buddyicon->user);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
364 swboard->hidden = TRUE;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
365
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
366 frombase64(buddyicon->data, &icon, &icon_len);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
367
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
368 if ((b = gaim_find_buddy(gc->account, passport)) != NULL) {
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
369 gaim_buddy_set_setting(b, "icon_checksum", buddyicon->md5sum);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
370 gaim_blist_save();
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
371 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
372
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
373 set_icon_data(gc, passport, icon, icon_len);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
374
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
375 g_free(icon);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
376
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
377 msn_buddy_icon_xfer_destroy(swboard->buddy_icon_xfer);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
378 swboard->buddy_icon_xfer = NULL;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
379
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
380 msn_switchboard_destroy(swboard);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
381 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
382 else if (!strcmp(command, "CANCEL")) {
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
383 swboard = (MsnSwitchBoard *)servconn->data;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
384
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
385 msn_buddy_icon_xfer_destroy(swboard->buddy_icon_xfer);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
386 swboard->buddy_icon_xfer = NULL;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
387
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
388 msn_switchboard_destroy(swboard);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
389 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
390 else {
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
391 gaim_debug(GAIM_DEBUG_ERROR, "msn",
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
392 "Unknown buddy icon message command: %s\n", command);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
393 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
394
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
395 return TRUE;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
396 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
397
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
398 static gboolean
5793
952710ac6635 [gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
399 process_data(MsnServConn *servconn, const MsnMessage *msg)
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
400 {
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5506
diff changeset
401 GaimConnection *gc = servconn->session->account->gc;
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
402 MsnSwitchBoard *swboard;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
403 MsnBuddyIconXfer *buddyicon;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
404 MsnMessage *ack_msg;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
405 const char *data;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
406 int len;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
407
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
408 swboard = (MsnSwitchBoard *)servconn->data;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
409 buddyicon = swboard->buddy_icon_xfer;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
410
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
411 data = msn_message_get_body(msg) + 4;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
412
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
413 len = strlen(data);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
414
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
415 /* Copy the data into our buffer. */
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
416 strncpy(buddyicon->data + buddyicon->bytes_xfer, data,
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
417 buddyicon->total_size - buddyicon->bytes_xfer);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
418
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
419 buddyicon->bytes_xfer += len;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
420
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
421 /* Acknowledge this data. */
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
422 ack_msg = msn_message_new();
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
423 msn_message_set_content_type(ack_msg, "application/x-buddyicon");
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
424 msn_message_set_receiver(ack_msg, msn_message_get_sender(msg));
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
425 msn_message_set_charset(ack_msg, NULL);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
426 msn_message_set_attr(ack_msg, "User-Agent", NULL);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
427 msn_message_set_body(ack_msg, "Command: ACK\r\n");
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
428
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
429 if (!msn_switchboard_send_msg(swboard, ack_msg)) {
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
430 msn_message_destroy(ack_msg);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
431
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
432 msn_buddy_icon_xfer_destroy(swboard->buddy_icon_xfer);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
433 swboard->buddy_icon_xfer = NULL;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
434
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5506
diff changeset
435 gaim_connection_error(gc, _("Write error"));
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
436
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
437 return FALSE;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
438 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
439
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
440 msn_message_destroy(ack_msg);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
441
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
442 return TRUE;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
443 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
444
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
445 MsnBuddyIconXfer *
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
446 msn_buddy_icon_xfer_new(void)
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
447 {
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
448 return g_new0(MsnBuddyIconXfer, 1);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
449 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
450
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
451 void
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
452 msn_buddy_icon_xfer_destroy(MsnBuddyIconXfer *xfer)
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
453 {
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
454 g_return_if_fail(xfer != NULL);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
455
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
456 if (xfer->user != NULL)
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
457 msn_user_unref(xfer->user);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
458
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
459 if (xfer->data != NULL)
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
460 g_free(xfer->data);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
461
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
462 g_free(xfer);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
463 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
464
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
465 gboolean
5506
4f72b611f0ee [gaim-migrate @ 5905]
Christian Hammond <chipx86@chipx86.com>
parents: 5355
diff changeset
466 msn_buddy_icon_msg(MsnServConn *servconn, MsnMessage *msg)
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
467 {
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
468 if (!strncmp(msn_message_get_body(msg), "ICON", 4))
5793
952710ac6635 [gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
469 return process_data(servconn, msg);
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
470 else
5793
952710ac6635 [gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
471 return process_invite(servconn, msg);
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
472 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
473
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
474 void
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
475 msn_buddy_icon_invite(MsnSwitchBoard *swboard)
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
476 {
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5506
diff changeset
477 GaimAccount *account = swboard->servconn->session->account;
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5506
diff changeset
478 GaimConnection *gc = account->gc;
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
479 MsnMessage *msg;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
480 char buf[MSN_BUF_LEN];
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
481 char *md5sum;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
482 int file_size, base64_size;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
483
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
484 g_return_if_fail(swboard != NULL);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
485
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5506
diff changeset
486 if (gaim_account_get_buddy_icon(account) == NULL)
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
487 return; /* We don't have an icon to send. */
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
488
5793
952710ac6635 [gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents: 5564
diff changeset
489 if (!get_buddy_icon_info(account, NULL, &md5sum,
6786
8efafdc38718 [gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
490 &file_size, &base64_size))
8efafdc38718 [gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
491 {
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
492 return;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
493 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
494
6786
8efafdc38718 [gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
495 if (file_size > MAX_BUDDY_ICON_FILE_SIZE)
8efafdc38718 [gaim-migrate @ 7325]
Christian Hammond <chipx86@chipx86.com>
parents: 6701
diff changeset
496 {
5355
6a57fd9b45e1 [gaim-migrate @ 5731]
Christian Hammond <chipx86@chipx86.com>
parents: 5351
diff changeset
497 gaim_debug(GAIM_DEBUG_ERROR, "msn",
6a57fd9b45e1 [gaim-migrate @ 5731]
Christian Hammond <chipx86@chipx86.com>
parents: 5351
diff changeset
498 "The buddy icon is too large to send. Must be no more "
6a57fd9b45e1 [gaim-migrate @ 5731]
Christian Hammond <chipx86@chipx86.com>
parents: 5351
diff changeset
499 "than %d bytes!\n", MAX_BUDDY_ICON_FILE_SIZE);
6a57fd9b45e1 [gaim-migrate @ 5731]
Christian Hammond <chipx86@chipx86.com>
parents: 5351
diff changeset
500 return;
6a57fd9b45e1 [gaim-migrate @ 5731]
Christian Hammond <chipx86@chipx86.com>
parents: 5351
diff changeset
501 }
6a57fd9b45e1 [gaim-migrate @ 5731]
Christian Hammond <chipx86@chipx86.com>
parents: 5351
diff changeset
502
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
503 msg = msn_message_new();
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
504 msn_message_set_content_type(msg, "application/x-buddyicon");
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
505 msn_message_set_receiver(msg, msn_message_get_sender(msg));
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
506 msn_message_set_charset(msg, NULL);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
507 msn_message_set_attr(msg, "User-Agent", NULL);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
508
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
509 g_snprintf(buf, sizeof(buf),
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
510 "Command: INVITE\r\n"
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
511 "MD5SUM: %s\r\n"
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
512 "File-Size: %d\r\n"
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
513 "Base64-Size: %d\r\n",
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
514 md5sum, file_size, base64_size);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
515
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
516 g_free(md5sum);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
517
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
518 msn_message_set_body(msg, buf);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
519
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
520 if (!msn_switchboard_send_msg(swboard, msg)) {
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
521 msn_message_destroy(msg);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
522
5564
187c740f2a4e [gaim-migrate @ 5966]
Christian Hammond <chipx86@chipx86.com>
parents: 5506
diff changeset
523 gaim_connection_error(gc, _("Write error"));
5351
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
524
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
525 return;
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
526 }
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
527
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
528 msn_message_destroy(msg);
2aa7e4237142 [gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
529 }