Mercurial > pidgin
annotate src/protocols/msn/msn.c @ 4452:2afc0f845e74
[gaim-migrate @ 4727]
I cleaned up the async dns stuff a bit. Now everything will work again.
Even TOC. You don't want to use TOC, though--but you already know that.
You're smart.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Tue, 28 Jan 2003 21:42:44 +0000 |
parents | 5a7fda352a8d |
children | c7aae8902e5e |
rev | line source |
---|---|
2086 | 1 #include "config.h" |
2 | |
3630 | 3 #ifndef _WIN32 |
4 #include <unistd.h> | |
5 #else | |
6 #include <winsock.h> | |
7 #include <io.h> | |
8 #endif | |
9 | |
10 | |
4150 | 11 #include <sys/stat.h> |
2086 | 12 #include <stdlib.h> |
13 #include <string.h> | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
14 #include <errno.h> |
2086 | 15 #include <stdio.h> |
16 #include <ctype.h> | |
4321
1cfad48b7d93
[gaim-migrate @ 4576]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4278
diff
changeset
|
17 #ifndef _WIN32 |
4278
fd33fa2bc9da
[gaim-migrate @ 4529]
Christian Hammond <chipx86@chipx86.com>
parents:
4270
diff
changeset
|
18 #include <netdb.h> |
4321
1cfad48b7d93
[gaim-migrate @ 4576]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4278
diff
changeset
|
19 #endif |
2086 | 20 #include "gaim.h" |
21 #include "prpl.h" | |
22 #include "proxy.h" | |
23 #include "md5.h" | |
24 | |
3630 | 25 #ifdef _WIN32 |
26 #include "win32dep.h" | |
4321
1cfad48b7d93
[gaim-migrate @ 4576]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4278
diff
changeset
|
27 #include "stdint.h" |
3630 | 28 #endif |
29 | |
3592 | 30 #include "pixmaps/protocols/msn/msn_online.xpm" |
31 #include "pixmaps/protocols/msn/msn_away.xpm" | |
32 #include "pixmaps/protocols/msn/msn_occ.xpm" | |
2086 | 33 |
4249 | 34 static struct prpl *my_protocol = NULL; |
35 | |
3630 | 36 /* for win32 compatability */ |
37 G_MODULE_IMPORT GSList *connections; | |
38 | |
2086 | 39 #define MSN_BUF_LEN 8192 |
40 #define MIME_HEADER "MIME-Version: 1.0\r\n" \ | |
41 "Content-Type: text/plain; charset=UTF-8\r\n" \ | |
2273
0b5c3338fa3d
[gaim-migrate @ 2283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2265
diff
changeset
|
42 "User-Agent: Gaim/" VERSION "\r\n" \ |
3263 | 43 "X-MMS-IM-Format: FN=Arial; EF=; CO=0; PF=0\r\n\r\n" |
2086 | 44 |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
45 #define HOTMAIL_URL "http://www.hotmail.com/cgi-bin/folders" |
2932 | 46 #define PASSPORT_URL "http://lc1.law13.hotmail.passport.com/cgi-bin/dologin?login=" |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
47 |
2086 | 48 #define MSN_ONLINE 1 |
49 #define MSN_BUSY 2 | |
50 #define MSN_IDLE 3 | |
51 #define MSN_BRB 4 | |
52 #define MSN_AWAY 5 | |
53 #define MSN_PHONE 6 | |
54 #define MSN_LUNCH 7 | |
55 #define MSN_OFFLINE 8 | |
56 #define MSN_HIDDEN 9 | |
57 | |
58 #define USEROPT_HOTMAIL 0 | |
59 | |
3322 | 60 #define USEROPT_MSNSERVER 3 |
61 #define MSN_SERVER "messenger.hotmail.com" | |
62 #define USEROPT_MSNPORT 4 | |
63 #define MSN_PORT 1863 | |
64 | |
2993 | 65 #define MSN_TYPING_RECV_TIMEOUT 6 |
66 #define MSN_TYPING_SEND_TIMEOUT 4 | |
67 | |
4150 | 68 struct msn_file_transfer { |
69 enum { MFT_SENDFILE_IN, MFT_SENDFILE_OUT } type; | |
70 struct file_transfer *xfer; | |
71 struct gaim_connection *gc; | |
72 | |
73 int fd; | |
74 int inpa; | |
75 | |
76 char *filename; | |
77 | |
78 char *sn; | |
79 char ip[16]; | |
80 int port; | |
81 | |
4270 | 82 uint32_t cookie; |
83 uint32_t authcookie; | |
4150 | 84 |
85 int len; | |
86 | |
87 char *rxqueue; | |
88 int rxlen; | |
89 gboolean msg; | |
90 char *msguser; | |
91 int msglen; | |
92 }; | |
3035 | 93 |
2086 | 94 struct msn_data { |
95 int fd; | |
4270 | 96 uint32_t trId; |
2086 | 97 int inpa; |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
98 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
99 char *rxqueue; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
100 int rxlen; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
101 gboolean msg; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
102 char *msguser; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
103 int msglen; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
104 |
2086 | 105 GSList *switches; |
106 GSList *fl; | |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
107 GSList *permit; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
108 GSList *deny; |
4150 | 109 GSList *file_transfers; |
3171 | 110 |
111 char *kv; | |
112 char *sid; | |
113 char *mspauth; | |
114 unsigned long sl; | |
115 char *passport; | |
116 | |
2086 | 117 }; |
118 | |
119 struct msn_switchboard { | |
120 struct gaim_connection *gc; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
121 struct gaim_conversation *chat; |
2086 | 122 int fd; |
123 int inpa; | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
124 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
125 char *rxqueue; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
126 int rxlen; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
127 gboolean msg; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
128 char *msguser; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
129 int msglen; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
130 |
2086 | 131 char *sessid; |
132 char *auth; | |
4270 | 133 uint32_t trId; |
2086 | 134 int total; |
135 char *user; | |
2591
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
136 GSList *txqueue; |
2086 | 137 }; |
138 | |
139 struct msn_buddy { | |
140 char *user; | |
141 char *friend; | |
142 }; | |
143 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
144 static void msn_login_callback(gpointer, gint, GaimInputCondition); |
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
145 static void msn_login_xfr_connect(gpointer, gint, GaimInputCondition); |
4150 | 146 static struct msn_file_transfer *find_mft_by_cookie(struct gaim_connection *gc, |
147 unsigned long cookie); | |
148 static struct msn_file_transfer *find_mft_by_xfer(struct gaim_connection *gc, | |
149 struct file_transfer *xfer); | |
2086 | 150 |
4039 | 151 #define GET_NEXT(tmp) while (*(tmp) && *(tmp) != ' ') \ |
2086 | 152 (tmp)++; \ |
153 *(tmp)++ = 0; \ | |
4039 | 154 while (*(tmp) && *(tmp) == ' ') \ |
2086 | 155 (tmp)++; |
156 | |
4186 | 157 #define GET_NEXT_LINE(tmp,s) strsep (&tmp, " "); s = strsep (&tmp, "\r"); |
2086 | 158 |
159 static char *msn_normalize(const char *s) | |
160 { | |
161 static char buf[BUF_LEN]; | |
162 | |
163 g_return_val_if_fail(s != NULL, NULL); | |
164 | |
3504 | 165 g_snprintf(buf, sizeof(buf), "%s%s", s, strchr(s, '@') ? "" : "@hotmail.com"); |
2086 | 166 |
167 return buf; | |
168 } | |
169 | |
170 static int msn_write(int fd, void *data, int len) | |
171 { | |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4186
diff
changeset
|
172 debug_printf("MSN C: %s", (char *)data); |
2086 | 173 return write(fd, data, len); |
174 } | |
175 | |
176 static char *url_decode(const char *msg) | |
177 { | |
178 static char buf[MSN_BUF_LEN]; | |
179 int i, j = 0; | |
180 | |
181 bzero(buf, sizeof(buf)); | |
182 for (i = 0; i < strlen(msg); i++) { | |
183 char hex[3]; | |
184 if (msg[i] != '%') { | |
185 buf[j++] = msg[i]; | |
186 continue; | |
187 } | |
2093
83d8a9b7e89b
[gaim-migrate @ 2103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
188 strncpy(hex, msg + ++i, 2); hex[2] = 0; |
83d8a9b7e89b
[gaim-migrate @ 2103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
189 /* i is pointing to the start of the number */ |
83d8a9b7e89b
[gaim-migrate @ 2103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
190 i++; /* now it's at the end and at the start of the for loop |
83d8a9b7e89b
[gaim-migrate @ 2103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
191 will be at the next character */ |
83d8a9b7e89b
[gaim-migrate @ 2103]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2090
diff
changeset
|
192 buf[j++] = strtol(hex, NULL, 16); |
2086 | 193 } |
194 buf[j] = 0; | |
195 | |
196 return buf; | |
197 } | |
198 | |
2219
20a4d5da0b95
[gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2213
diff
changeset
|
199 static char *url_encode(const char *msg) |
20a4d5da0b95
[gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2213
diff
changeset
|
200 { |
20a4d5da0b95
[gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2213
diff
changeset
|
201 static char buf[MSN_BUF_LEN]; |
20a4d5da0b95
[gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2213
diff
changeset
|
202 int i, j = 0; |
20a4d5da0b95
[gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2213
diff
changeset
|
203 |
20a4d5da0b95
[gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2213
diff
changeset
|
204 bzero(buf, sizeof(buf)); |
20a4d5da0b95
[gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2213
diff
changeset
|
205 for (i = 0; i < strlen(msg); i++) { |
20a4d5da0b95
[gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2213
diff
changeset
|
206 if (isalnum(msg[i])) |
20a4d5da0b95
[gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2213
diff
changeset
|
207 buf[j++] = msg[i]; |
20a4d5da0b95
[gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2213
diff
changeset
|
208 else { |
20a4d5da0b95
[gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2213
diff
changeset
|
209 sprintf(buf + j, "%%%02x", (unsigned char)msg[i]); |
20a4d5da0b95
[gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2213
diff
changeset
|
210 j += 3; |
20a4d5da0b95
[gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2213
diff
changeset
|
211 } |
20a4d5da0b95
[gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2213
diff
changeset
|
212 } |
20a4d5da0b95
[gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2213
diff
changeset
|
213 buf[j] = 0; |
20a4d5da0b95
[gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2213
diff
changeset
|
214 |
20a4d5da0b95
[gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2213
diff
changeset
|
215 return buf; |
20a4d5da0b95
[gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2213
diff
changeset
|
216 } |
20a4d5da0b95
[gaim-migrate @ 2229]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2213
diff
changeset
|
217 |
2086 | 218 static char *handle_errcode(char *buf, gboolean show) |
219 { | |
220 int errcode; | |
221 static char msg[MSN_BUF_LEN]; | |
222 | |
223 buf[4] = 0; | |
224 errcode = atoi(buf); | |
225 | |
226 switch (errcode) { | |
227 case 200: | |
3263 | 228 g_snprintf(msg, sizeof(msg), _("Syntax Error (probably a Gaim bug)")); |
2086 | 229 break; |
230 case 201: | |
3263 | 231 g_snprintf(msg, sizeof(msg), _("Invalid Parameter (probably a Gaim bug)")); |
2086 | 232 break; |
233 case 205: | |
3263 | 234 g_snprintf(msg, sizeof(msg), _("Invalid User")); |
2086 | 235 break; |
236 case 206: | |
3263 | 237 g_snprintf(msg, sizeof(msg), _("Fully Qualified Domain Name missing")); |
2086 | 238 break; |
239 case 207: | |
3263 | 240 g_snprintf(msg, sizeof(msg), _("Already Login")); |
2086 | 241 break; |
242 case 208: | |
3263 | 243 g_snprintf(msg, sizeof(msg), _("Invalid Username")); |
2086 | 244 break; |
245 case 209: | |
3263 | 246 g_snprintf(msg, sizeof(msg), _("Invalid Friendly Name")); |
2086 | 247 break; |
248 case 210: | |
3263 | 249 g_snprintf(msg, sizeof(msg), _("List Full")); |
2086 | 250 break; |
251 case 215: | |
3263 | 252 g_snprintf(msg, sizeof(msg), _("Already there")); |
2086 | 253 break; |
254 case 216: | |
3263 | 255 g_snprintf(msg, sizeof(msg), _("Not on list")); |
2086 | 256 break; |
2842
cf0f0153e2da
[gaim-migrate @ 2855]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
257 case 217: |
3263 | 258 g_snprintf(msg, sizeof(msg), _("User is offline")); |
2842
cf0f0153e2da
[gaim-migrate @ 2855]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
259 break; |
2086 | 260 case 218: |
3263 | 261 g_snprintf(msg, sizeof(msg), _("Already in the mode")); |
2086 | 262 break; |
263 case 219: | |
3263 | 264 g_snprintf(msg, sizeof(msg), _("Already in opposite list")); |
2086 | 265 break; |
266 case 280: | |
3263 | 267 g_snprintf(msg, sizeof(msg), _("Switchboard failed")); |
2086 | 268 break; |
269 case 281: | |
3263 | 270 g_snprintf(msg, sizeof(msg), _("Notify Transfer failed")); |
2086 | 271 break; |
272 | |
273 case 300: | |
3263 | 274 g_snprintf(msg, sizeof(msg), _("Required fields missing")); |
2086 | 275 break; |
276 case 302: | |
3263 | 277 g_snprintf(msg, sizeof(msg), _("Not logged in")); |
2086 | 278 break; |
279 | |
280 case 500: | |
3263 | 281 g_snprintf(msg, sizeof(msg), _("Internal server error")); |
2086 | 282 break; |
283 case 501: | |
3263 | 284 g_snprintf(msg, sizeof(msg), _("Database server error")); |
2086 | 285 break; |
286 case 510: | |
3263 | 287 g_snprintf(msg, sizeof(msg), _("File operation error")); |
2086 | 288 break; |
289 case 520: | |
3263 | 290 g_snprintf(msg, sizeof(msg), _("Memory allocation error")); |
2086 | 291 break; |
292 | |
293 case 600: | |
3263 | 294 g_snprintf(msg, sizeof(msg), _("Server busy")); |
2086 | 295 break; |
296 case 601: | |
3263 | 297 g_snprintf(msg, sizeof(msg), _("Server unavailable")); |
2086 | 298 break; |
299 case 602: | |
3263 | 300 g_snprintf(msg, sizeof(msg), _("Peer Notification server down")); |
2086 | 301 break; |
302 case 603: | |
3263 | 303 g_snprintf(msg, sizeof(msg), _("Database connect error")); |
2086 | 304 break; |
305 case 604: | |
3263 | 306 g_snprintf(msg, sizeof(msg), _("Server is going down (abandon ship)")); |
2086 | 307 break; |
308 | |
309 case 707: | |
3263 | 310 g_snprintf(msg, sizeof(msg), _("Error creating connection")); |
2086 | 311 break; |
312 case 711: | |
3263 | 313 g_snprintf(msg, sizeof(msg), _("Unable to write")); |
2086 | 314 break; |
315 case 712: | |
3263 | 316 g_snprintf(msg, sizeof(msg), _("Session overload")); |
2086 | 317 break; |
318 case 713: | |
3263 | 319 g_snprintf(msg, sizeof(msg), _("User is too active")); |
2086 | 320 break; |
321 case 714: | |
3263 | 322 g_snprintf(msg, sizeof(msg), _("Too many sessions")); |
2086 | 323 break; |
324 case 715: | |
3263 | 325 g_snprintf(msg, sizeof(msg), _("Not expected")); |
2086 | 326 break; |
327 case 717: | |
3263 | 328 g_snprintf(msg, sizeof(msg), _("Bad friend file")); |
2086 | 329 break; |
330 | |
331 case 911: | |
3263 | 332 g_snprintf(msg, sizeof(msg), _("Authentication failed")); |
2086 | 333 break; |
334 case 913: | |
3263 | 335 g_snprintf(msg, sizeof(msg), _("Not allowed when offline")); |
2086 | 336 break; |
3073 | 337 case 920: |
3263 | 338 g_snprintf(msg, sizeof(msg), _("Not accepting new users")); |
2086 | 339 break; |
3073 | 340 case 924: |
3263 | 341 g_snprintf(msg, sizeof(msg), _("User unverified")); |
3073 | 342 break; |
2086 | 343 default: |
3263 | 344 g_snprintf(msg, sizeof(msg), _("Unknown Error Code")); |
2086 | 345 break; |
346 } | |
347 | |
348 if (show) | |
3427 | 349 do_error_dialog(msg, NULL, GAIM_ERROR); |
2086 | 350 |
351 return msg; | |
352 } | |
353 | |
354 static void handle_hotmail(struct gaim_connection *gc, char *data) | |
355 { | |
2932 | 356 char login_url[2048]; |
3171 | 357 char buf[MSN_BUF_LEN]; |
358 struct msn_data *md = gc->proto_data; | |
359 | |
3293 | 360 if (strchr(gc->username, '@') != strstr(gc->username, "@hotmail.com")) |
361 /* We can only get Hotmail notification from hotmail users */ | |
362 return; | |
363 | |
3195 | 364 if (!md->passport) { |
4270 | 365 g_snprintf(buf, sizeof(buf), "URL %u INBOX\r\n", ++md->trId); |
2932 | 366 |
3195 | 367 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
2153
0befa2d2e540
[gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2152
diff
changeset
|
368 return; |
0befa2d2e540
[gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2152
diff
changeset
|
369 } |
3195 | 370 } else { |
371 g_snprintf(login_url, sizeof(login_url), "%s", md->passport); | |
372 | |
373 if (strstr(data, "Content-Type: text/x-msmsgsinitialemailnotification;")) { | |
374 char *x = strstr(data, "Inbox-Unread:"); | |
375 if (!x) return; | |
376 x += strlen("Inbox-Unread: "); | |
377 connection_has_mail(gc, atoi(x), NULL, NULL, login_url); | |
378 } else if (strstr(data, "Content-Type: text/x-msmsgsemailnotification;")) { | |
379 char *from = strstr(data, "From:"); | |
380 char *subject = strstr(data, "Subject:"); | |
381 char *x; | |
382 if (!from || !subject) { | |
383 connection_has_mail(gc, 1, NULL, NULL, login_url); | |
384 return; | |
385 } | |
386 from += strlen("From: "); | |
387 x = strstr(from, "\r\n"); *x = 0; | |
388 subject += strlen("Subject: "); | |
389 x = strstr(subject, "\r\n"); *x = 0; | |
390 connection_has_mail(gc, -1, from, subject, login_url); | |
391 } | |
2086 | 392 } |
393 } | |
394 | |
395 static struct msn_switchboard *msn_find_switch(struct gaim_connection *gc, char *id) | |
396 { | |
397 struct msn_data *md = gc->proto_data; | |
398 GSList *m = md->switches; | |
399 | |
400 while (m) { | |
401 struct msn_switchboard *ms = m->data; | |
402 m = m->next; | |
2591
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
403 if ((ms->total <= 1) && !g_strcasecmp(ms->user, id)) |
2086 | 404 return ms; |
405 } | |
406 | |
407 return NULL; | |
408 } | |
409 | |
410 static struct msn_switchboard *msn_find_switch_by_id(struct gaim_connection *gc, int id) | |
411 { | |
412 struct msn_data *md = gc->proto_data; | |
413 GSList *m = md->switches; | |
414 | |
415 while (m) { | |
416 struct msn_switchboard *ms = m->data; | |
417 m = m->next; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
418 if (ms->chat && gaim_chat_get_id(GAIM_CHAT(ms->chat)) == id) |
2086 | 419 return ms; |
420 } | |
421 | |
422 return NULL; | |
423 } | |
424 | |
425 static struct msn_switchboard *msn_find_writable_switch(struct gaim_connection *gc) | |
426 { | |
427 struct msn_data *md = gc->proto_data; | |
428 GSList *m = md->switches; | |
429 | |
430 while (m) { | |
431 struct msn_switchboard *ms = m->data; | |
432 m = m->next; | |
433 if (ms->txqueue) | |
434 return ms; | |
435 } | |
436 | |
437 return NULL; | |
438 } | |
439 | |
440 static void msn_kill_switch(struct msn_switchboard *ms) | |
441 { | |
442 struct gaim_connection *gc = ms->gc; | |
443 struct msn_data *md = gc->proto_data; | |
444 | |
445 if (ms->inpa) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
446 gaim_input_remove(ms->inpa); |
2086 | 447 close(ms->fd); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
448 g_free(ms->rxqueue); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
449 if (ms->msg) |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
450 g_free(ms->msguser); |
2086 | 451 if (ms->sessid) |
452 g_free(ms->sessid); | |
453 g_free(ms->auth); | |
454 if (ms->user) | |
455 g_free(ms->user); | |
2591
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
456 while (ms->txqueue) { |
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
457 g_free(ms->txqueue->data); |
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
458 ms->txqueue = g_slist_remove(ms->txqueue, ms->txqueue->data); |
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
459 } |
2086 | 460 if (ms->chat) |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
461 serv_got_chat_left(gc, gaim_chat_get_id(GAIM_CHAT(ms->chat))); |
2086 | 462 |
463 md->switches = g_slist_remove(md->switches, ms); | |
464 | |
465 g_free(ms); | |
466 } | |
467 | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
468 static int msn_process_switch(struct msn_switchboard *ms, char *buf) |
2086 | 469 { |
470 struct gaim_connection *gc = ms->gc; | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
471 char sendbuf[MSN_BUF_LEN]; |
2086 | 472 static int id = 0; |
473 | |
474 if (!g_strncasecmp(buf, "ACK", 3)) { | |
475 } else if (!g_strncasecmp(buf, "ANS", 3)) { | |
476 if (ms->chat) | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
477 gaim_chat_add_user(GAIM_CHAT(ms->chat), gc->username, NULL); |
2086 | 478 } else if (!g_strncasecmp(buf, "BYE", 3)) { |
4068
29401c9ccc2a
[gaim-migrate @ 4280]
Christian Hammond <chipx86@chipx86.com>
parents:
4056
diff
changeset
|
479 char *user, *tmp = buf; |
29401c9ccc2a
[gaim-migrate @ 4280]
Christian Hammond <chipx86@chipx86.com>
parents:
4056
diff
changeset
|
480 GET_NEXT(tmp); |
29401c9ccc2a
[gaim-migrate @ 4280]
Christian Hammond <chipx86@chipx86.com>
parents:
4056
diff
changeset
|
481 user = tmp; |
29401c9ccc2a
[gaim-migrate @ 4280]
Christian Hammond <chipx86@chipx86.com>
parents:
4056
diff
changeset
|
482 |
2086 | 483 if (ms->chat) { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
484 gaim_chat_remove_user(GAIM_CHAT(ms->chat), user, NULL); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
485 } else { |
4068
29401c9ccc2a
[gaim-migrate @ 4280]
Christian Hammond <chipx86@chipx86.com>
parents:
4056
diff
changeset
|
486 char msgbuf[256]; |
4112
12552607e88c
[gaim-migrate @ 4327]
Christian Hammond <chipx86@chipx86.com>
parents:
4111
diff
changeset
|
487 const char *username; |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
488 struct gaim_conversation *cnv; |
4112
12552607e88c
[gaim-migrate @ 4327]
Christian Hammond <chipx86@chipx86.com>
parents:
4111
diff
changeset
|
489 struct buddy *b; |
12552607e88c
[gaim-migrate @ 4327]
Christian Hammond <chipx86@chipx86.com>
parents:
4111
diff
changeset
|
490 |
4349 | 491 if ((b = find_buddy(gc->user, user)) != NULL) |
4227 | 492 username = get_buddy_alias(b); |
4112
12552607e88c
[gaim-migrate @ 4327]
Christian Hammond <chipx86@chipx86.com>
parents:
4111
diff
changeset
|
493 else |
12552607e88c
[gaim-migrate @ 4327]
Christian Hammond <chipx86@chipx86.com>
parents:
4111
diff
changeset
|
494 username = user; |
4068
29401c9ccc2a
[gaim-migrate @ 4280]
Christian Hammond <chipx86@chipx86.com>
parents:
4056
diff
changeset
|
495 |
29401c9ccc2a
[gaim-migrate @ 4280]
Christian Hammond <chipx86@chipx86.com>
parents:
4056
diff
changeset
|
496 g_snprintf(msgbuf, sizeof(msgbuf), |
4112
12552607e88c
[gaim-migrate @ 4327]
Christian Hammond <chipx86@chipx86.com>
parents:
4111
diff
changeset
|
497 _("%s has closed the conversation window"), username); |
4068
29401c9ccc2a
[gaim-migrate @ 4280]
Christian Hammond <chipx86@chipx86.com>
parents:
4056
diff
changeset
|
498 |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
499 if ((cnv = gaim_find_conversation(user))) |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
500 gaim_conversation_write(cnv, NULL, msgbuf, -1, |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
501 WFLAG_SYSTEM, time(NULL)); |
4068
29401c9ccc2a
[gaim-migrate @ 4280]
Christian Hammond <chipx86@chipx86.com>
parents:
4056
diff
changeset
|
502 |
2086 | 503 msn_kill_switch(ms); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
504 return 0; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
505 } |
2086 | 506 } else if (!g_strncasecmp(buf, "CAL", 3)) { |
507 } else if (!g_strncasecmp(buf, "IRO", 3)) { | |
508 char *tot, *user, *tmp = buf; | |
509 | |
510 GET_NEXT(tmp); | |
511 GET_NEXT(tmp); | |
512 GET_NEXT(tmp); | |
513 tot = tmp; | |
514 GET_NEXT(tmp); | |
515 ms->total = atoi(tot); | |
516 user = tmp; | |
517 GET_NEXT(tmp); | |
518 | |
519 if (ms->total > 1) { | |
520 if (!ms->chat) | |
521 ms->chat = serv_got_joined_chat(gc, ++id, "MSN Chat"); | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
522 |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
523 gaim_chat_add_user(GAIM_CHAT(ms->chat), user, NULL); |
2086 | 524 } |
525 } else if (!g_strncasecmp(buf, "JOI", 3)) { | |
526 char *user, *tmp = buf; | |
527 GET_NEXT(tmp); | |
528 user = tmp; | |
529 GET_NEXT(tmp); | |
530 | |
531 if (ms->total == 1) { | |
532 ms->chat = serv_got_joined_chat(gc, ++id, "MSN Chat"); | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
533 gaim_chat_add_user(GAIM_CHAT(ms->chat), ms->user, NULL); |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
534 gaim_chat_add_user(GAIM_CHAT(ms->chat), gc->username, NULL); |
2086 | 535 g_free(ms->user); |
536 ms->user = NULL; | |
537 } | |
538 if (ms->chat) | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
539 gaim_chat_add_user(GAIM_CHAT(ms->chat), user, NULL); |
2086 | 540 ms->total++; |
2591
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
541 while (ms->txqueue) { |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2600
diff
changeset
|
542 char *send = add_cr(ms->txqueue->data); |
4270 | 543 g_snprintf(sendbuf, sizeof(sendbuf), "MSG %u N %d\r\n%s%s", ++ms->trId, |
3642 | 544 strlen(MIME_HEADER) + strlen(send), |
545 MIME_HEADER, send); | |
2591
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
546 g_free(ms->txqueue->data); |
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
547 ms->txqueue = g_slist_remove(ms->txqueue, ms->txqueue->data); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
548 if (msn_write(ms->fd, sendbuf, strlen(sendbuf)) < 0) { |
2086 | 549 msn_kill_switch(ms); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
550 return 0; |
2591
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
551 } |
2086 | 552 debug_printf("\n"); |
553 } | |
554 } else if (!g_strncasecmp(buf, "MSG", 3)) { | |
555 char *user, *tmp = buf; | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
556 int length; |
2086 | 557 |
558 GET_NEXT(tmp); | |
559 user = tmp; | |
560 | |
561 GET_NEXT(tmp); | |
562 | |
563 GET_NEXT(tmp); | |
564 length = atoi(tmp); | |
565 | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
566 ms->msg = TRUE; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
567 ms->msguser = g_strdup(user); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
568 ms->msglen = length; |
2086 | 569 } else if (!g_strncasecmp(buf, "NAK", 3)) { |
3427 | 570 do_error_dialog(_("An MSN message may not have been received."), NULL, GAIM_ERROR); |
2086 | 571 } else if (!g_strncasecmp(buf, "NLN", 3)) { |
572 } else if (!g_strncasecmp(buf, "OUT", 3)) { | |
573 if (ms->chat) | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
574 serv_got_chat_left(gc, gaim_chat_get_id(GAIM_CHAT(ms->chat))); |
2086 | 575 msn_kill_switch(ms); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
576 return 0; |
2086 | 577 } else if (!g_strncasecmp(buf, "USR", 3)) { |
578 /* good, we got USR, now we need to find out who we want to talk to */ | |
579 struct msn_switchboard *ms = msn_find_writable_switch(gc); | |
580 | |
581 if (!ms) | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
582 return 0; |
2086 | 583 |
4270 | 584 g_snprintf(sendbuf, sizeof(sendbuf), "CAL %u %s\r\n", ++ms->trId, ms->user); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
585 if (msn_write(ms->fd, sendbuf, strlen(sendbuf)) < 0) { |
2086 | 586 msn_kill_switch(ms); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
587 return 0; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
588 } |
2086 | 589 } else if (isdigit(*buf)) { |
590 handle_errcode(buf, TRUE); | |
591 } else { | |
592 debug_printf("Unhandled message!\n"); | |
593 } | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
594 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
595 return 1; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
596 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
597 |
3195 | 598 static char *msn_parse_format(char *mime) |
599 { | |
600 char *cur; | |
601 GString *ret = g_string_new(NULL); | |
3375 | 602 guint colorbuf; |
603 char *colors = (char *)(&colorbuf); | |
604 | |
3195 | 605 |
606 cur = strstr(mime, "FN="); | |
607 if (cur && (*(cur = cur + 3) != ';')) { | |
608 ret = g_string_append(ret, "<FONT FACE=\""); | |
609 while (*cur && *cur != ';') { | |
610 ret = g_string_append_c(ret, *cur); | |
611 cur++; | |
612 } | |
613 ret = g_string_append(ret, "\">"); | |
614 } | |
615 | |
616 cur = strstr(mime, "EF="); | |
617 if (cur && (*(cur = cur + 3) != ';')) { | |
618 while (*cur && *cur != ';') { | |
619 ret = g_string_append_c(ret, '<'); | |
620 ret = g_string_append_c(ret, *cur); | |
621 ret = g_string_append_c(ret, '>'); | |
622 cur++; | |
623 } | |
624 } | |
625 | |
626 cur = strstr(mime, "CO="); | |
627 if (cur && (*(cur = cur + 3) != ';')) { | |
3375 | 628 if (sscanf (cur, "%x;", &colorbuf) == 1) { |
4270 | 629 char tag[64]; |
3195 | 630 g_snprintf(tag, sizeof(tag), "<FONT COLOR=\"#%02hhx%02hhx%02hhx\">", colors[0], colors[1], colors[2]); |
631 ret = g_string_append(ret, tag); | |
632 } | |
633 } | |
634 | |
3323 | 635 cur = url_decode(ret->str); |
3324 | 636 g_string_free(ret, TRUE); |
3195 | 637 return cur; |
638 } | |
4150 | 639 |
640 static int msn_process_msnftp(struct msn_file_transfer *mft, char *buf) | |
641 { | |
642 struct gaim_connection *gc = mft->gc; | |
643 char sendbuf[MSN_BUF_LEN]; | |
644 | |
645 if (!g_strncasecmp(buf, "VER MSNFTP", 10)) { | |
646 | |
647 /* Send the USR string. */ | |
4270 | 648 g_snprintf(sendbuf, sizeof(sendbuf), "USR %s %lu\r\n", |
649 gc->username, (unsigned long)mft->authcookie); | |
4150 | 650 |
651 if (msn_write(mft->fd, sendbuf, strlen(sendbuf)) < 0) { | |
652 /* TODO: Clean up */ | |
653 return 0; | |
654 } | |
655 } | |
656 else if (!g_strncasecmp(buf, "FIL", 3)) { | |
657 | |
658 char *tmp = buf; | |
659 | |
660 GET_NEXT(tmp); | |
661 | |
662 mft->len = atoi(tmp); | |
663 | |
664 /* Send the TFR string, to request a start of transfer. */ | |
665 g_snprintf(sendbuf, sizeof(sendbuf), "TFR\r\n"); | |
666 | |
667 gaim_input_remove(mft->inpa); | |
668 mft->inpa = 0; | |
669 | |
670 if (msn_write(mft->fd, sendbuf, strlen(sendbuf)) < 0) { | |
671 /* TODO: Clean up */ | |
672 return 0; | |
673 } | |
674 | |
675 if (transfer_in_do(mft->xfer, mft->fd, mft->filename, mft->len)) { | |
676 debug_printf("MSN: transfer_in_do failed\n"); | |
677 } | |
678 } | |
679 | |
680 return 1; | |
681 } | |
682 | |
683 static void msn_msnftp_callback(gpointer data, gint source, | |
684 GaimInputCondition cond) | |
685 { | |
686 struct msn_file_transfer *mft = (struct msn_file_transfer *)data; | |
687 char buf[MSN_BUF_LEN]; | |
688 int cont = 1; | |
689 int len; | |
690 | |
4452 | 691 mft->fd = source; |
4150 | 692 |
693 len = read(mft->fd, buf, sizeof(buf)); | |
694 | |
695 if (len <= 0) { | |
696 /* TODO: Kill mft. */ | |
697 return; | |
698 } | |
699 | |
700 mft->rxqueue = g_realloc(mft->rxqueue, len + mft->rxlen); | |
701 memcpy(mft->rxqueue + mft->rxlen, buf, len); | |
702 mft->rxlen += len; | |
703 | |
704 while (cont) { | |
705 char *end = mft->rxqueue; | |
706 int cmdlen; | |
707 char *cmd; | |
708 int i = 0; | |
709 | |
710 if (!mft->rxlen) | |
711 return; | |
712 | |
713 while (i + 1 < mft->rxlen) { | |
714 if (*end == '\r' && end[1] == '\n') | |
715 break; | |
716 end++; i++; | |
717 } | |
718 if (i + 1 == mft->rxlen) | |
719 return; | |
720 | |
721 cmdlen = end - mft->rxqueue + 2; | |
722 cmd = mft->rxqueue; | |
723 mft->rxlen -= cmdlen; | |
724 if (mft->rxlen) { | |
725 mft->rxqueue = g_memdup(cmd + cmdlen, mft->rxlen); | |
726 } else { | |
727 mft->rxqueue = NULL; | |
728 cmd = g_realloc(cmd, cmdlen + 1); | |
729 } | |
730 cmd[cmdlen] = 0; | |
731 | |
732 g_strchomp(cmd); | |
733 cont = msn_process_msnftp(mft, cmd); | |
734 | |
735 g_free(cmd); | |
736 } | |
737 } | |
738 | |
739 static void msn_msnftp_connect(gpointer data, gint source, | |
740 GaimInputCondition cond) | |
741 { | |
742 struct msn_file_transfer *mft = (struct msn_file_transfer *)data; | |
743 struct gaim_connection *gc = mft->gc; | |
744 char buf[MSN_BUF_LEN]; | |
745 | |
746 if (source == -1 || !g_slist_find(connections, gc)) { | |
747 debug_printf("Error establishing MSNFTP connection\n"); | |
748 close(source); | |
749 /* TODO: Clean up */ | |
750 return; | |
751 } | |
752 | |
753 if (mft->fd != source) | |
754 mft->fd = source; | |
755 | |
756 g_snprintf(buf, sizeof(buf), "VER MSNFTP\r\n"); | |
757 | |
758 if (msn_write(mft->fd, buf, strlen(buf)) < 0) { | |
759 /* TODO: Clean up */ | |
760 return; | |
761 } | |
762 | |
763 mft->inpa = gaim_input_add(mft->fd, GAIM_INPUT_READ, | |
764 msn_msnftp_callback, mft); | |
765 } | |
766 | |
767 static void msn_process_ft_msg(struct msn_switchboard *ms, char *msg) | |
768 { | |
769 struct msn_file_transfer *mft; | |
770 struct msn_data *md = ms->gc->proto_data; | |
771 char *tmp = msg; | |
772 | |
4186 | 773 if (strstr(msg, "Application-GUID: {5D3E02AB-6190-11d3-BBBB-00C04F795683}") && |
4150 | 774 strstr(msg, "Invitation-Command: INVITE")) { |
775 | |
776 /* | |
777 * First invitation message, requesting an ACCEPT or CANCEL from | |
778 * the recipient. Used in incoming file transfers. | |
779 */ | |
780 | |
781 char *filename; | |
782 char *cookie_s, *filesize_s; | |
783 size_t filesize; | |
784 | |
4186 | 785 tmp = strstr(msg, "Invitation-Cookie:"); |
786 GET_NEXT_LINE(tmp, cookie_s); | |
787 GET_NEXT_LINE(tmp, filename); | |
788 GET_NEXT_LINE(tmp, filesize_s); | |
4150 | 789 |
790 mft = g_new0(struct msn_file_transfer, 1); | |
791 mft->gc = ms->gc; | |
792 mft->type = MFT_SENDFILE_IN; | |
793 mft->sn = g_strdup(ms->msguser); | |
794 mft->cookie = atoi(cookie_s); | |
795 mft->filename = g_strdup(filename); | |
796 | |
797 filesize = atoi(filesize_s); | |
798 | |
799 md->file_transfers = g_slist_append(md->file_transfers, mft); | |
800 | |
801 mft->xfer = transfer_in_add(ms->gc, ms->msguser, | |
802 mft->filename, filesize, 1, NULL); | |
803 } | |
804 else if (strstr(msg, "Invitation-Command: ACCEPT")) { | |
805 | |
806 /* | |
807 * XXX I hope these checks don't return false positives, but they | |
808 * seem like they should work. The only issue is alternative | |
809 * protocols, *maybe*. | |
810 */ | |
811 | |
812 if (strstr(msg, "AuthCookie:")) { | |
813 | |
814 /* | |
815 * Second invitation request, sent after the recipient accepts | |
816 * the request. Used in incoming file transfers. | |
817 */ | |
818 | |
819 char *cookie_s, *ip, *port_s, *authcookie_s; | |
820 | |
4186 | 821 tmp = strstr(msg, "Invitation-Cookie:"); |
822 GET_NEXT_LINE(tmp, cookie_s); | |
823 GET_NEXT_LINE(tmp, ip); | |
824 GET_NEXT_LINE(tmp, port_s); | |
825 GET_NEXT_LINE(tmp, authcookie_s); | |
826 GET_NEXT_LINE(tmp, authcookie_s); | |
4150 | 827 |
828 mft = find_mft_by_cookie(ms->gc, atoi(cookie_s)); | |
829 | |
830 if (!mft) | |
831 { | |
832 debug_printf("MSN: Cookie not found. File transfer aborted.\n"); | |
833 return; | |
834 } | |
835 | |
836 strncpy(mft->ip, ip, 16); | |
837 mft->port = atoi(port_s); | |
4270 | 838 mft->authcookie = atol(authcookie_s); |
4150 | 839 |
4452 | 840 if (proxy_connect(mft->ip, mft->port, msn_msnftp_connect, mft) != 0) { |
4150 | 841 md->file_transfers = g_slist_remove(md->file_transfers, mft); |
842 return; | |
843 } | |
844 } | |
845 else | |
846 { | |
847 /* | |
848 * An accept message from the recipient. Used in outgoing | |
849 * file transfers. | |
850 */ | |
851 } | |
852 } | |
853 } | |
854 | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
855 static void msn_process_switch_msg(struct msn_switchboard *ms, char *msg) |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
856 { |
3642 | 857 char *content, *agent, *format; |
3195 | 858 char *message = NULL; |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
859 int flags = 0; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
860 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
861 agent = strstr(msg, "User-Agent: "); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
862 if (agent) { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
863 if (!g_strncasecmp(agent, "User-Agent: Gaim", strlen("User-Agent: Gaim"))) |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
864 flags |= IM_FLAG_GAIMUSER; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
865 } |
3195 | 866 |
867 format = strstr(msg, "X-MMS-IM-Format: "); | |
868 if (format) { | |
869 format = msn_parse_format(format); | |
870 } else { | |
871 format = NULL; | |
872 } | |
873 | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
874 content = strstr(msg, "Content-Type: "); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
875 if (!content) |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
876 return; |
2993 | 877 if (!g_strncasecmp(content, "Content-Type: text/x-msmsgscontrol\r\n", |
878 strlen( "Content-Type: text/x-msmsgscontrol\r\n"))) { | |
3323 | 879 if (strstr(content,"TypingUser: ") && !ms->chat) { |
3768 | 880 serv_got_typing(ms->gc, ms->msguser, MSN_TYPING_RECV_TIMEOUT, TYPING); |
2993 | 881 return; |
882 } | |
3171 | 883 |
4150 | 884 } else if (!g_strncasecmp(content, "Content-Type: text/x-msmsgsinvite;", |
885 strlen("Content-Type: text/x-msmsgsinvite;"))) { | |
886 | |
887 /* | |
888 * NOTE: Other things, such as voice communication, would go in | |
889 * here too (since they send the same Content-Type). However, | |
890 * this is the best check for file transfer messages, so I'm | |
891 * calling msn_process_ft_invite_msg(). If anybody adds support | |
892 * for anything else that sends a text/x-msmsgsinvite, perhaps | |
893 * this should be changed. For now, it stays. | |
894 */ | |
895 msn_process_ft_msg(ms, content); | |
896 | |
2993 | 897 } else if (!g_strncasecmp(content, "Content-Type: text/plain", |
898 strlen("Content-Type: text/plain"))) { | |
3195 | 899 |
900 | |
901 | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
902 char *skiphead; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
903 skiphead = strstr(msg, "\r\n\r\n"); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
904 if (!skiphead || !skiphead[4]) { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
905 return; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
906 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
907 skiphead += 4; |
3642 | 908 strip_linefeed(skiphead); |
2993 | 909 |
3195 | 910 if (format) { |
3642 | 911 message = g_strdup_printf("%s%s", format, skiphead); |
3195 | 912 } else { |
3642 | 913 message = g_strdup(skiphead); |
3195 | 914 } |
915 | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
916 if (ms->chat) |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
917 serv_got_chat_in(ms->gc, gaim_chat_get_id(GAIM_CHAT(ms->chat)), |
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4349
diff
changeset
|
918 ms->msguser, flags, message, time(NULL)); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
919 else |
3195 | 920 serv_got_im(ms->gc, ms->msguser, message, flags, time(NULL), -1); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
921 |
3195 | 922 g_free(message); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
923 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
924 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
925 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
926 static void msn_switchboard_callback(gpointer data, gint source, GaimInputCondition cond) |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
927 { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
928 struct msn_switchboard *ms = data; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
929 char buf[MSN_BUF_LEN]; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
930 int cont = 1; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
931 int len; |
3195 | 932 |
4452 | 933 ms->fd = source; |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
934 len = read(ms->fd, buf, sizeof(buf)); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
935 if (len <= 0) { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
936 msn_kill_switch(ms); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
937 return; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
938 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
939 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
940 ms->rxqueue = g_realloc(ms->rxqueue, len + ms->rxlen); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
941 memcpy(ms->rxqueue + ms->rxlen, buf, len); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
942 ms->rxlen += len; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
943 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
944 while (cont) { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
945 if (!ms->rxlen) |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
946 return; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
947 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
948 if (ms->msg) { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
949 char *msg; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
950 if (ms->msglen > ms->rxlen) |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
951 return; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
952 msg = ms->rxqueue; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
953 ms->rxlen -= ms->msglen; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
954 if (ms->rxlen) { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
955 ms->rxqueue = g_memdup(msg + ms->msglen, ms->rxlen); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
956 } else { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
957 ms->rxqueue = NULL; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
958 msg = g_realloc(msg, ms->msglen + 1); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
959 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
960 msg[ms->msglen] = 0; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
961 ms->msglen = 0; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
962 ms->msg = FALSE; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
963 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
964 msn_process_switch_msg(ms, msg); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
965 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
966 g_free(ms->msguser); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
967 g_free(msg); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
968 } else { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
969 char *end = ms->rxqueue; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
970 int cmdlen; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
971 char *cmd; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
972 int i = 0; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
973 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
974 while (i + 1 < ms->rxlen) { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
975 if (*end == '\r' && end[1] == '\n') |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
976 break; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
977 end++; i++; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
978 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
979 if (i + 1 == ms->rxlen) |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
980 return; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
981 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
982 cmdlen = end - ms->rxqueue + 2; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
983 cmd = ms->rxqueue; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
984 ms->rxlen -= cmdlen; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
985 if (ms->rxlen) { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
986 ms->rxqueue = g_memdup(cmd + cmdlen, ms->rxlen); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
987 } else { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
988 ms->rxqueue = NULL; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
989 cmd = g_realloc(cmd, cmdlen + 1); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
990 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
991 cmd[cmdlen] = 0; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
992 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
993 debug_printf("MSN S: %s", cmd); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
994 g_strchomp(cmd); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
995 cont = msn_process_switch(ms, cmd); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
996 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
997 g_free(cmd); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
998 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
999 } |
2086 | 1000 } |
1001 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1002 static void msn_rng_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1003 { |
1004 struct msn_switchboard *ms = data; | |
1005 struct gaim_connection *gc = ms->gc; | |
1006 struct msn_data *md; | |
1007 char buf[MSN_BUF_LEN]; | |
1008 | |
1009 if (source == -1 || !g_slist_find(connections, gc)) { | |
2210
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1010 close(source); |
2086 | 1011 g_free(ms->sessid); |
1012 g_free(ms->auth); | |
1013 g_free(ms); | |
1014 return; | |
1015 } | |
1016 | |
1017 md = gc->proto_data; | |
1018 | |
1019 if (ms->fd != source) | |
1020 ms->fd = source; | |
1021 | |
4270 | 1022 g_snprintf(buf, sizeof(buf), "ANS %u %s %s %s\r\n", ++ms->trId, gc->username, ms->auth, ms->sessid); |
2086 | 1023 if (msn_write(ms->fd, buf, strlen(buf)) < 0) { |
1024 close(ms->fd); | |
1025 g_free(ms->sessid); | |
1026 g_free(ms->auth); | |
1027 g_free(ms); | |
1028 return; | |
1029 } | |
1030 | |
1031 md->switches = g_slist_append(md->switches, ms); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1032 ms->inpa = gaim_input_add(ms->fd, GAIM_INPUT_READ, msn_switchboard_callback, ms); |
2086 | 1033 } |
1034 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1035 static void msn_ss_xfr_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1036 { |
1037 struct msn_switchboard *ms = data; | |
1038 struct gaim_connection *gc = ms->gc; | |
1039 char buf[MSN_BUF_LEN]; | |
1040 | |
1041 if (source == -1 || !g_slist_find(connections, gc)) { | |
2210
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1042 close(source); |
2265
2f03cfd21fc2
[gaim-migrate @ 2275]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
1043 if (g_slist_find(connections, gc)) { |
2f03cfd21fc2
[gaim-migrate @ 2275]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
1044 msn_kill_switch(ms); |
3427 | 1045 do_error_dialog(_("Gaim was unable to send an MSN message"), |
1046 _("Gaim encountered an error communicating with the " | |
1047 "MSN switchboard server. Please try again later."), GAIM_ERROR); | |
2265
2f03cfd21fc2
[gaim-migrate @ 2275]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
1048 } |
2086 | 1049 return; |
1050 } | |
1051 | |
1052 if (ms->fd != source) | |
1053 ms->fd = source; | |
1054 | |
4270 | 1055 g_snprintf(buf, sizeof(buf), "USR %u %s %s\r\n", ++ms->trId, gc->username, ms->auth); |
2086 | 1056 if (msn_write(ms->fd, buf, strlen(buf)) < 0) { |
1057 g_free(ms->auth); | |
1058 g_free(ms); | |
1059 return; | |
1060 } | |
1061 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1062 ms->inpa = gaim_input_add(ms->fd, GAIM_INPUT_READ, msn_switchboard_callback, ms); |
2086 | 1063 } |
1064 | |
1065 struct msn_add_permit { | |
1066 struct gaim_connection *gc; | |
1067 char *user; | |
1068 char *friend; | |
1069 }; | |
1070 | |
3730 | 1071 static void msn_accept_add(struct msn_add_permit *map) |
2086 | 1072 { |
4249 | 1073 if(g_slist_find(connections, map->gc)) { |
1074 struct msn_data *md = map->gc->proto_data; | |
1075 char buf[MSN_BUF_LEN]; | |
1076 | |
4270 | 1077 g_snprintf(buf, sizeof(buf), "ADD %u AL %s %s\r\n", ++md->trId, map->user, url_encode(map->friend)); |
4249 | 1078 |
1079 if (msn_write(md->fd, buf, strlen(buf)) < 0) { | |
1080 hide_login_progress(map->gc, _("Write error")); | |
1081 signoff(map->gc); | |
1082 return; | |
1083 } | |
4349 | 1084 gaim_privacy_permit_add(map->gc->user, map->user); |
4249 | 1085 build_allow_list(); /* er. right. we'll need to have a thing for this in CUI too */ |
1086 show_got_added(map->gc, NULL, map->user, map->friend, NULL); | |
2086 | 1087 } |
4249 | 1088 |
3730 | 1089 g_free(map->user); |
1090 g_free(map->friend); | |
1091 g_free(map); | |
2086 | 1092 } |
1093 | |
3730 | 1094 static void msn_cancel_add(struct msn_add_permit *map) |
2086 | 1095 { |
4249 | 1096 if(g_slist_find(connections, map->gc)) { |
1097 struct msn_data *md = map->gc->proto_data; | |
1098 char buf[MSN_BUF_LEN]; | |
1099 | |
4270 | 1100 g_snprintf(buf, sizeof(buf), "ADD %u BL %s %s\r\n", ++md->trId, map->user, url_encode(map->friend)); |
4249 | 1101 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
1102 hide_login_progress(map->gc, _("Write error")); | |
1103 signoff(map->gc); | |
1104 return; | |
1105 } | |
4349 | 1106 gaim_privacy_deny_add(map->gc->user, map->user); |
4249 | 1107 build_block_list(); |
3118 | 1108 } |
4249 | 1109 |
2086 | 1110 g_free(map->user); |
1111 g_free(map->friend); | |
1112 g_free(map); | |
1113 } | |
1114 | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1115 static int msn_process_main(struct gaim_connection *gc, char *buf) |
2086 | 1116 { |
1117 struct msn_data *md = gc->proto_data; | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1118 char sendbuf[MSN_BUF_LEN]; |
2086 | 1119 |
1120 if (!g_strncasecmp(buf, "ADD", 3)) { | |
1121 char *list, *user, *friend, *tmp = buf; | |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1122 struct msn_add_permit *ap; |
4349 | 1123 GSList *perm = gc->user->permit; |
2086 | 1124 char msg[MSN_BUF_LEN]; |
1125 | |
1126 GET_NEXT(tmp); | |
1127 GET_NEXT(tmp); | |
1128 list = tmp; | |
1129 | |
1130 GET_NEXT(tmp); | |
1131 GET_NEXT(tmp); | |
1132 user = tmp; | |
1133 | |
1134 GET_NEXT(tmp); | |
3323 | 1135 friend = url_decode(tmp); |
2086 | 1136 |
1137 if (g_strcasecmp(list, "RL")) | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1138 return 1; |
2086 | 1139 |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1140 while (perm) { |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1141 if (!g_strcasecmp(perm->data, user)) |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1142 return 1; |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1143 perm = perm->next; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1144 } |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1145 |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1146 ap = g_new0(struct msn_add_permit, 1); |
2086 | 1147 ap->user = g_strdup(user); |
3642 | 1148 ap->friend = g_strdup(friend); |
2086 | 1149 ap->gc = gc; |
1150 | |
3299 | 1151 g_snprintf(msg, sizeof(msg), _("The user %s (%s) wants to add %s to his or her buddy list."), |
3323 | 1152 ap->user, ap->friend, ap->gc->username); |
2086 | 1153 |
4249 | 1154 do_ask_dialog(msg, NULL, ap, _("Authorize"), msn_accept_add, _("Deny"), msn_cancel_add, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); |
2086 | 1155 } else if (!g_strncasecmp(buf, "BLP", 3)) { |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1156 char *type, *tmp = buf; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1157 |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1158 GET_NEXT(tmp); |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1159 GET_NEXT(tmp); |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1160 GET_NEXT(tmp); |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1161 type = tmp; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1162 |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1163 if (!g_strcasecmp(type, "AL")) { |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1164 /* If the current setting is AL, messages |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1165 * from users who are not in BL will be delivered |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1166 * |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1167 * In other words, deny some */ |
4349 | 1168 gc->user->permdeny = DENY_SOME; |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1169 } else { |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1170 /* If the current |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1171 * setting is BL, only messages from people who are in the AL will be |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1172 * delivered. |
4349 | 1173 * |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1174 * In other words, permit some */ |
4349 | 1175 gc->user->permdeny = PERMIT_SOME; |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1176 } |
2086 | 1177 } else if (!g_strncasecmp(buf, "BPR", 3)) { |
1178 } else if (!g_strncasecmp(buf, "CHG", 3)) { | |
1179 } else if (!g_strncasecmp(buf, "CHL", 3)) { | |
1180 char *hash = buf; | |
1181 char buf2[MSN_BUF_LEN]; | |
1182 md5_state_t st; | |
1183 md5_byte_t di[16]; | |
1184 int i; | |
1185 | |
1186 GET_NEXT(hash); | |
1187 GET_NEXT(hash); | |
1188 | |
1189 md5_init(&st); | |
1190 md5_append(&st, (const md5_byte_t *)hash, strlen(hash)); | |
1191 md5_append(&st, (const md5_byte_t *)"Q1P7W2E4J9R8U3S5", strlen("Q1P7W2E4J9R8U3S5")); | |
1192 md5_finish(&st, di); | |
1193 | |
4270 | 1194 g_snprintf(sendbuf, sizeof(sendbuf), "QRY %u msmsgs@msnmsgr.com 32\r\n", ++md->trId); |
2086 | 1195 for (i = 0; i < 16; i++) { |
1196 g_snprintf(buf2, sizeof(buf2), "%02x", di[i]); | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1197 strcat(sendbuf, buf2); |
2086 | 1198 } |
1199 | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1200 if (msn_write(md->fd, sendbuf, strlen(sendbuf)) < 0) { |
4056 | 1201 hide_login_progress(gc, _("Unable to write to server")); |
2086 | 1202 signoff(gc); |
1203 } | |
1204 | |
1205 debug_printf("\n"); | |
1206 } else if (!g_strncasecmp(buf, "FLN", 3)) { | |
1207 char *usr = buf; | |
1208 | |
1209 GET_NEXT(usr); | |
1210 serv_got_update(gc, usr, 0, 0, 0, 0, 0, 0); | |
1211 } else if (!g_strncasecmp(buf, "GTC", 3)) { | |
1212 } else if (!g_strncasecmp(buf, "INF", 3)) { | |
1213 } else if (!g_strncasecmp(buf, "ILN", 3)) { | |
2607
e0d4a23aac89
[gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2603
diff
changeset
|
1214 char *state, *user, *friend, *tmp = buf; |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
1215 int status = 0; |
2086 | 1216 |
1217 GET_NEXT(tmp); | |
1218 | |
1219 GET_NEXT(tmp); | |
1220 state = tmp; | |
1221 | |
1222 GET_NEXT(tmp); | |
1223 user = tmp; | |
1224 | |
1225 GET_NEXT(tmp); | |
2607
e0d4a23aac89
[gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2603
diff
changeset
|
1226 friend = url_decode(tmp); |
e0d4a23aac89
[gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2603
diff
changeset
|
1227 |
4227 | 1228 serv_got_alias(gc, user, friend); |
2086 | 1229 |
1230 if (!g_strcasecmp(state, "BSY")) { | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
1231 status |= UC_UNAVAILABLE | (MSN_BUSY << 1); |
2086 | 1232 } else if (!g_strcasecmp(state, "IDL")) { |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
1233 status |= UC_UNAVAILABLE | (MSN_IDLE << 1); |
2086 | 1234 } else if (!g_strcasecmp(state, "BRB")) { |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
1235 status |= UC_UNAVAILABLE | (MSN_BRB << 1); |
2086 | 1236 } else if (!g_strcasecmp(state, "AWY")) { |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
1237 status |= UC_UNAVAILABLE | (MSN_AWAY << 1); |
2086 | 1238 } else if (!g_strcasecmp(state, "PHN")) { |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
1239 status |= UC_UNAVAILABLE | (MSN_PHONE << 1); |
2086 | 1240 } else if (!g_strcasecmp(state, "LUN")) { |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
1241 status |= UC_UNAVAILABLE | (MSN_LUNCH << 1); |
2086 | 1242 } |
1243 | |
1244 serv_got_update(gc, user, 1, 0, 0, 0, status, 0); | |
1245 } else if (!g_strncasecmp(buf, "LST", 3)) { | |
1246 char *which, *who, *friend, *tmp = buf; | |
3012 | 1247 struct msn_add_permit *ap; /* for any as yet undealt with buddies who've added you to their buddy list when you were off-line. How dare they! */ |
4349 | 1248 GSList *perm = gc->user->permit; /* current permit list */ |
1249 GSList *denyl = gc->user->deny; | |
3012 | 1250 char msg[MSN_BUF_LEN]; |
1251 int new = 1; | |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1252 int pos, tot; |
2086 | 1253 |
1254 GET_NEXT(tmp); | |
1255 GET_NEXT(tmp); | |
1256 which = tmp; | |
1257 | |
1258 GET_NEXT(tmp); | |
1259 GET_NEXT(tmp); | |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1260 pos = strtol(tmp, NULL, 10); |
2086 | 1261 GET_NEXT(tmp); |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1262 tot = strtol(tmp, NULL, 10); |
2086 | 1263 GET_NEXT(tmp); |
1264 who = tmp; | |
1265 | |
1266 GET_NEXT(tmp); | |
1267 friend = url_decode(tmp); | |
1268 | |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1269 if (!g_strcasecmp(which, "FL") && pos) { |
2086 | 1270 struct msn_buddy *b = g_new0(struct msn_buddy, 1); |
1271 b->user = g_strdup(who); | |
3642 | 1272 b->friend = g_strdup(friend); |
2086 | 1273 md->fl = g_slist_append(md->fl, b); |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1274 } else if (!g_strcasecmp(which, "AL") && pos) { |
4349 | 1275 if (g_slist_find_custom(gc->user->deny, who, |
1276 (GCompareFunc)strcmp)) { | |
3294 | 1277 debug_printf("moving from deny to permit: %s", who); |
4349 | 1278 gaim_privacy_deny_remove(gc->user, who); |
3294 | 1279 } |
4349 | 1280 gaim_privacy_permit_add(gc->user, who); |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1281 } else if (!g_strcasecmp(which, "BL") && pos) { |
4403 | 1282 gaim_privacy_deny_add(gc->user, who); |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1283 } else if (!g_strcasecmp(which, "RL")) { |
3121 | 1284 if (pos) { |
3012 | 1285 while(perm) { |
1286 if(!g_strcasecmp(perm->data, who)) | |
1287 new = 0; | |
1288 perm = perm->next; | |
1289 } | |
3018 | 1290 while(denyl) { |
1291 if(!g_strcasecmp(denyl->data, who)) | |
1292 new = 0; | |
1293 denyl = denyl->next; | |
1294 } | |
3012 | 1295 if(new) { |
3013 | 1296 debug_printf("Unresolved MSN RL entry\n"); |
3012 | 1297 ap = g_new0(struct msn_add_permit, 1); |
1298 ap->user = g_strdup(who); | |
3642 | 1299 ap->friend = g_strdup(friend); |
3012 | 1300 ap->gc = gc; |
1301 | |
4249 | 1302 g_snprintf(msg, sizeof(msg), _("The user %s (%s) wants to add you to their buddy list"),ap->user, ap->friend); |
1303 do_ask_dialog(msg, NULL, ap, _("Authorize"), msn_accept_add, _("Deny"), msn_cancel_add, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); | |
3012 | 1304 } |
3121 | 1305 } |
3012 | 1306 |
1307 if (pos != tot) | |
1308 return 1; /* this isn't the last one in the RL, so return. */ | |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1309 |
4270 | 1310 g_snprintf(sendbuf, sizeof(sendbuf), "CHG %u NLN\r\n", ++md->trId); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1311 if (msn_write(md->fd, sendbuf, strlen(sendbuf)) < 0) { |
4056 | 1312 hide_login_progress(gc, _("Unable to write")); |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1313 signoff(gc); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1314 return 0; |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1315 } |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1316 |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1317 account_online(gc); |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1318 serv_finish_login(gc); |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1319 |
4349 | 1320 md->permit = g_slist_copy(gc->user->permit); |
1321 md->deny = g_slist_copy(gc->user->deny); | |
1322 | |
2086 | 1323 while (md->fl) { |
1324 struct msn_buddy *mb = md->fl->data; | |
4349 | 1325 struct buddy *b = find_buddy(gc->user, mb->user); |
2086 | 1326 md->fl = g_slist_remove(md->fl, mb); |
4227 | 1327 if(!b) |
4349 | 1328 b = add_buddy(gc->user, _("Buddies"), mb->user, NULL); |
4227 | 1329 serv_got_alias(gc, mb->user, mb->friend); |
2086 | 1330 g_free(mb->user); |
1331 g_free(mb->friend); | |
1332 g_free(mb); | |
1333 } | |
1334 } | |
1335 } else if (!g_strncasecmp(buf, "MSG", 3)) { | |
1336 char *user, *tmp = buf; | |
1337 int length; | |
1338 | |
1339 GET_NEXT(tmp); | |
1340 user = tmp; | |
1341 | |
1342 GET_NEXT(tmp); | |
1343 | |
1344 GET_NEXT(tmp); | |
1345 length = atoi(tmp); | |
1346 | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1347 md->msg = TRUE; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1348 md->msguser = g_strdup(user); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1349 md->msglen = length; |
2086 | 1350 } else if (!g_strncasecmp(buf, "NLN", 3)) { |
2607
e0d4a23aac89
[gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2603
diff
changeset
|
1351 char *state, *user, *friend, *tmp = buf; |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
1352 int status = 0; |
2086 | 1353 |
1354 GET_NEXT(tmp); | |
1355 state = tmp; | |
1356 | |
1357 GET_NEXT(tmp); | |
1358 user = tmp; | |
1359 | |
1360 GET_NEXT(tmp); | |
2607
e0d4a23aac89
[gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2603
diff
changeset
|
1361 friend = url_decode(tmp); |
e0d4a23aac89
[gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2603
diff
changeset
|
1362 |
4227 | 1363 serv_got_alias(gc, user, friend); |
2086 | 1364 |
1365 if (!g_strcasecmp(state, "BSY")) { | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
1366 status |= UC_UNAVAILABLE | (MSN_BUSY << 1); |
2086 | 1367 } else if (!g_strcasecmp(state, "IDL")) { |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
1368 status |= UC_UNAVAILABLE | (MSN_IDLE << 1); |
2086 | 1369 } else if (!g_strcasecmp(state, "BRB")) { |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
1370 status |= UC_UNAVAILABLE | (MSN_BRB << 1); |
2086 | 1371 } else if (!g_strcasecmp(state, "AWY")) { |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
1372 status |= UC_UNAVAILABLE | (MSN_AWAY << 1); |
2086 | 1373 } else if (!g_strcasecmp(state, "PHN")) { |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
1374 status |= UC_UNAVAILABLE | (MSN_PHONE << 1); |
2086 | 1375 } else if (!g_strcasecmp(state, "LUN")) { |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
1376 status |= UC_UNAVAILABLE | (MSN_LUNCH << 1); |
2086 | 1377 } |
1378 | |
1379 serv_got_update(gc, user, 1, 0, 0, 0, status, 0); | |
1380 } else if (!g_strncasecmp(buf, "OUT", 3)) { | |
2887 | 1381 char *tmp = buf; |
1382 | |
1383 GET_NEXT(tmp); | |
1384 if (!g_strncasecmp(tmp, "OTH", 3)) { | |
2889
fccda160c078
[gaim-migrate @ 2902]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2888
diff
changeset
|
1385 hide_login_progress(gc, _("You have been disconnected. You have " |
fccda160c078
[gaim-migrate @ 2902]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2888
diff
changeset
|
1386 "signed on from another location.")); |
fccda160c078
[gaim-migrate @ 2902]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2888
diff
changeset
|
1387 signoff(gc); |
fccda160c078
[gaim-migrate @ 2902]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2888
diff
changeset
|
1388 return 0; |
2887 | 1389 } |
2086 | 1390 } else if (!g_strncasecmp(buf, "PRP", 3)) { |
2541
8229710b343b
[gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2501
diff
changeset
|
1391 } else if (!g_strncasecmp(buf, "QNG", 3)) { |
2086 | 1392 } else if (!g_strncasecmp(buf, "QRY", 3)) { |
2213
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1393 } else if (!g_strncasecmp(buf, "REA", 3)) { |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1394 char *friend, *tmp = buf; |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1395 |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1396 GET_NEXT(tmp); |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1397 GET_NEXT(tmp); |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1398 GET_NEXT(tmp); |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1399 GET_NEXT(tmp); |
3456 | 1400 |
1401 friend = url_decode(tmp); | |
2213
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1402 |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1403 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", friend); |
2086 | 1404 } else if (!g_strncasecmp(buf, "REM", 3)) { |
1405 } else if (!g_strncasecmp(buf, "RNG", 3)) { | |
1406 struct msn_switchboard *ms; | |
1407 char *sessid, *ssaddr, *auth, *user; | |
1408 int port, i = 0; | |
1409 char *tmp = buf; | |
1410 | |
1411 GET_NEXT(tmp); | |
1412 sessid = tmp; | |
1413 | |
1414 GET_NEXT(tmp); | |
1415 ssaddr = tmp; | |
1416 | |
1417 GET_NEXT(tmp); | |
1418 | |
1419 GET_NEXT(tmp); | |
1420 auth = tmp; | |
1421 | |
1422 GET_NEXT(tmp); | |
1423 user = tmp; | |
1424 GET_NEXT(tmp); | |
1425 | |
1426 while (ssaddr[i] && ssaddr[i] != ':') i++; | |
1427 if (ssaddr[i] == ':') { | |
1428 char *x = &ssaddr[i + 1]; | |
1429 ssaddr[i] = 0; | |
1430 port = atoi(x); | |
1431 } else | |
1432 port = 1863; | |
1433 | |
1434 ms = g_new0(struct msn_switchboard, 1); | |
4452 | 1435 if (proxy_connect(ssaddr, port, msn_rng_connect, ms) != 0) { |
2688
98b1ac8ddea3
[gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1436 g_free(ms); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1437 return 1; |
2688
98b1ac8ddea3
[gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1438 } |
2086 | 1439 ms->user = g_strdup(user); |
1440 ms->sessid = g_strdup(sessid); | |
1441 ms->auth = g_strdup(auth); | |
1442 ms->gc = gc; | |
3171 | 1443 } else if (!g_strncasecmp(buf, "URL", 3)) { |
1444 char *tmp = buf; | |
1445 FILE *fd; | |
1446 md5_state_t st; | |
1447 md5_byte_t di[16]; | |
1448 int i; | |
1449 char buf2[64]; | |
1450 char sendbuf[64]; | |
1451 char hippy[2048]; | |
1452 char *rru; | |
1453 char *passport; | |
1454 | |
1455 GET_NEXT(tmp); | |
1456 GET_NEXT(tmp); | |
1457 rru = tmp; | |
1458 GET_NEXT(tmp); | |
1459 passport = tmp; | |
1460 | |
3630 | 1461 g_snprintf(hippy, sizeof(hippy), "%s%lu%s", md->mspauth, time(NULL) - md->sl, gc->password); |
3171 | 1462 |
1463 md5_init(&st); | |
1464 md5_append(&st, (const md5_byte_t *)hippy, strlen(hippy)); | |
1465 md5_finish(&st, di); | |
1466 | |
1467 bzero(sendbuf, sizeof(sendbuf)); | |
1468 for (i = 0; i < 16; i++) { | |
1469 g_snprintf(buf2, sizeof(buf2), "%02x", di[i]); | |
1470 strcat(sendbuf, buf2); | |
1471 } | |
1472 | |
3195 | 1473 if (md->passport) { |
1474 unlink(md->passport); | |
3231 | 1475 g_free(md->passport); |
3195 | 1476 } |
3171 | 1477 |
3630 | 1478 if( (fd = gaim_mkstemp(&(md->passport))) == NULL ) { |
4270 | 1479 debug_printf("Error opening temp file: %s\n", strerror(errno)); |
3630 | 1480 } |
1481 else { | |
4270 | 1482 fputs("<html>\n" |
1483 "<head>\n" | |
1484 "<noscript>\n" | |
1485 "<meta http-equiv=Refresh content=\"0; url=http://www.hotmail.com\">\n" | |
1486 "</noscript>\n" | |
1487 "</head>\n\n", fd); | |
3171 | 1488 |
3630 | 1489 fprintf(fd, "<body onload=\"document.pform.submit(); \">\n"); |
1490 fprintf(fd, "<form name=\"pform\" action=\"%s\" method=\"POST\">\n\n", passport); | |
1491 fprintf(fd, "<input type=\"hidden\" name=\"mode\" value=\"ttl\">\n"); | |
1492 fprintf(fd, "<input type=\"hidden\" name=\"login\" value=\"%s\">\n", gc->username); | |
1493 fprintf(fd, "<input type=\"hidden\" name=\"username\" value=\"%s\">\n", gc->username); | |
1494 fprintf(fd, "<input type=\"hidden\" name=\"sid\" value=\"%s\">\n", md->sid); | |
1495 fprintf(fd, "<input type=\"hidden\" name=\"kv\" value=\"%s\">\n", md->kv); | |
1496 fprintf(fd, "<input type=\"hidden\" name=\"id\" value=\"2\">\n"); | |
1497 fprintf(fd, "<input type=\"hidden\" name=\"sl\" value=\"%ld\">\n", time(NULL) - md->sl); | |
1498 fprintf(fd, "<input type=\"hidden\" name=\"rru\" value=\"%s\">\n", rru); | |
1499 fprintf(fd, "<input type=\"hidden\" name=\"auth\" value=\"%s\">\n", md->mspauth); | |
1500 fprintf(fd, "<input type=\"hidden\" name=\"creds\" value=\"%s\">\n", sendbuf); // Digest me | |
1501 fprintf(fd, "<input type=\"hidden\" name=\"svc\" value=\"mail\">\n"); | |
1502 fprintf(fd, "<input type=\"hidden\" name=\"js\" value=\"yes\">\n"); | |
1503 fprintf(fd, "</form></body>\n"); | |
1504 fprintf(fd, "</html>\n"); | |
4270 | 1505 if (fclose(fd)) { |
1506 debug_printf("Error closing temp file: %s\n", strerror(errno)); | |
1507 unlink(md->passport); | |
1508 g_free(md->passport); | |
1509 } | |
3630 | 1510 } |
2086 | 1511 } else if (!g_strncasecmp(buf, "SYN", 3)) { |
1512 } else if (!g_strncasecmp(buf, "USR", 3)) { | |
1513 } else if (!g_strncasecmp(buf, "XFR", 3)) { | |
1514 char *host = strstr(buf, "SB"); | |
1515 int port; | |
1516 int i = 0; | |
1517 gboolean switchboard = TRUE; | |
1518 char *tmp; | |
1519 | |
1520 if (!host) { | |
1521 host = strstr(buf, "NS"); | |
1522 if (!host) { | |
4056 | 1523 hide_login_progress(gc, _("Got invalid XFR\n")); |
2086 | 1524 signoff(gc); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1525 return 0; |
2086 | 1526 } |
1527 switchboard = FALSE; | |
1528 } | |
1529 | |
1530 GET_NEXT(host); | |
1531 while (host[i] && host[i] != ':') i++; | |
1532 if (host[i] == ':') { | |
1533 tmp = &host[i + 1]; | |
1534 host[i] = 0; | |
1535 while (isdigit(*tmp)) tmp++; | |
1536 *tmp++ = 0; | |
1537 port = atoi(&host[i + 1]); | |
1538 } else { | |
1539 port = 1863; | |
1540 tmp = host; | |
1541 GET_NEXT(tmp); | |
1542 } | |
1543 | |
1544 if (switchboard) { | |
1545 struct msn_switchboard *ms = msn_find_writable_switch(gc); | |
1546 if (!ms) | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1547 return 1; |
2086 | 1548 |
1549 GET_NEXT(tmp); | |
1550 | |
4452 | 1551 if (proxy_connect(host, port, msn_ss_xfr_connect, ms) != 0) { |
2688
98b1ac8ddea3
[gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1552 msn_kill_switch(ms); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1553 return 1; |
2688
98b1ac8ddea3
[gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1554 } |
2086 | 1555 ms->auth = g_strdup(tmp); |
1556 } else { | |
1557 close(md->fd); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1558 gaim_input_remove(md->inpa); |
2086 | 1559 md->inpa = 0; |
4452 | 1560 if (proxy_connect(host, port, msn_login_xfr_connect, gc) != 0) { |
4056 | 1561 hide_login_progress(gc, _("Error transfering")); |
2688
98b1ac8ddea3
[gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1562 signoff(gc); |
2740
68ad186943e0
[gaim-migrate @ 2753]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2739
diff
changeset
|
1563 return 0; |
2688
98b1ac8ddea3
[gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1564 } |
2086 | 1565 } |
1566 } else if (isdigit(*buf)) { | |
1567 handle_errcode(buf, TRUE); | |
1568 } else { | |
1569 debug_printf("Unhandled message!\n"); | |
1570 } | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1571 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1572 return 1; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1573 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1574 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1575 static void msn_process_main_msg(struct gaim_connection *gc, char *msg) |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1576 { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1577 struct msn_data *md = gc->proto_data; |
3642 | 1578 char *skiphead; |
3171 | 1579 char *content; |
1580 | |
1581 content = strstr(msg, "Content-Type: "); | |
1582 | |
1583 if ((content) && (!g_strncasecmp(content, "Content-Type: text/x-msmsgsprofile", | |
1584 strlen("Content-Type: text/x-msmsgsprofile")))) { | |
1585 | |
1586 char *kv,*sid,*mspauth; | |
1587 | |
1588 kv = strstr(msg, "kv: "); | |
1589 sid = strstr(msg, "sid: "); | |
1590 mspauth = strstr(msg, "MSPAuth: "); | |
1591 | |
1592 if (kv) { | |
1593 char *tmp; | |
1594 | |
1595 kv += strlen("kv: "); | |
1596 tmp = strstr(kv, "\r\n"); *tmp = 0; | |
1597 md->kv = g_strdup(kv); | |
1598 } | |
1599 | |
1600 if (sid) { | |
1601 char *tmp; | |
1602 | |
1603 sid += strlen("sid: "); | |
1604 tmp = strstr(sid, "\r\n"); *tmp = 0; | |
1605 md->sid = g_strdup(sid); | |
1606 } | |
1607 | |
1608 if (mspauth) { | |
1609 char *tmp; | |
1610 | |
1611 mspauth += strlen("MSPAuth: "); | |
1612 tmp = strstr(mspauth, "\r\n"); *tmp = 0; | |
1613 md->mspauth = g_strdup(mspauth); | |
1614 } | |
1615 | |
1616 } | |
1617 | |
1618 | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1619 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1620 if (!g_strcasecmp(md->msguser, "hotmail")) { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1621 handle_hotmail(gc, msg); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1622 return; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1623 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1624 |
3171 | 1625 |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1626 skiphead = strstr(msg, "\r\n\r\n"); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1627 if (!skiphead || !skiphead[4]) |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1628 return; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1629 skiphead += 4; |
3642 | 1630 strip_linefeed(skiphead); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1631 |
3642 | 1632 serv_got_im(gc, md->msguser, skiphead, 0, time(NULL), -1); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1633 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1634 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1635 static void msn_callback(gpointer data, gint source, GaimInputCondition cond) |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1636 { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1637 struct gaim_connection *gc = data; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1638 struct msn_data *md = gc->proto_data; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1639 char buf[MSN_BUF_LEN]; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1640 int cont = 1; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1641 int len; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1642 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1643 len = read(md->fd, buf, sizeof(buf)); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1644 if (len <= 0) { |
3263 | 1645 hide_login_progress_error(gc, _("Error reading from server")); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1646 signoff(gc); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1647 return; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1648 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1649 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1650 md->rxqueue = g_realloc(md->rxqueue, len + md->rxlen); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1651 memcpy(md->rxqueue + md->rxlen, buf, len); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1652 md->rxlen += len; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1653 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1654 while (cont) { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1655 if (!md->rxlen) |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1656 return; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1657 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1658 if (md->msg) { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1659 char *msg; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1660 if (md->msglen > md->rxlen) |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1661 return; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1662 msg = md->rxqueue; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1663 md->rxlen -= md->msglen; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1664 if (md->rxlen) { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1665 md->rxqueue = g_memdup(msg + md->msglen, md->rxlen); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1666 } else { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1667 md->rxqueue = NULL; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1668 msg = g_realloc(msg, md->msglen + 1); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1669 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1670 msg[md->msglen] = 0; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1671 md->msglen = 0; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1672 md->msg = FALSE; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1673 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1674 msn_process_main_msg(gc, msg); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1675 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1676 g_free(md->msguser); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1677 g_free(msg); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1678 } else { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1679 char *end = md->rxqueue; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1680 int cmdlen; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1681 char *cmd; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1682 int i = 0; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1683 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1684 while (i + 1 < md->rxlen) { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1685 if (*end == '\r' && end[1] == '\n') |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1686 break; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1687 end++; i++; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1688 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1689 if (i + 1 == md->rxlen) |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1690 return; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1691 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1692 cmdlen = end - md->rxqueue + 2; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1693 cmd = md->rxqueue; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1694 md->rxlen -= cmdlen; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1695 if (md->rxlen) { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1696 md->rxqueue = g_memdup(cmd + cmdlen, md->rxlen); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1697 } else { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1698 md->rxqueue = NULL; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1699 cmd = g_realloc(cmd, cmdlen + 1); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1700 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1701 cmd[cmdlen] = 0; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1702 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1703 debug_printf("MSN S: %s", cmd); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1704 g_strchomp(cmd); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1705 cont = msn_process_main(gc, cmd); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1706 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1707 g_free(cmd); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1708 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1709 } |
2086 | 1710 } |
1711 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1712 static void msn_login_xfr_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1713 { |
1714 struct gaim_connection *gc = data; | |
1715 struct msn_data *md; | |
1716 char buf[MSN_BUF_LEN]; | |
1717 | |
2210
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1718 if (!g_slist_find(connections, gc)) { |
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1719 close(source); |
2086 | 1720 return; |
2210
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1721 } |
2086 | 1722 |
1723 md = gc->proto_data; | |
1724 | |
1725 if (md->fd != source) | |
1726 md->fd = source; | |
1727 | |
1728 if (md->fd == -1) { | |
4056 | 1729 hide_login_progress(gc, _("Unable to connect to Notification Server")); |
2086 | 1730 signoff(gc); |
1731 return; | |
1732 } | |
1733 | |
4270 | 1734 g_snprintf(buf, sizeof(buf), "VER %u MSNP5\r\n", ++md->trId); |
2086 | 1735 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 1736 hide_login_progress(gc, _("Unable to talk to Notification Server")); |
2086 | 1737 signoff(gc); |
1738 return; | |
1739 } | |
1740 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1741 md->inpa = gaim_input_add(md->fd, GAIM_INPUT_READ, msn_login_callback, gc); |
2086 | 1742 } |
1743 | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1744 static int msn_process_login(struct gaim_connection *gc, char *buf) |
2086 | 1745 { |
1746 struct msn_data *md = gc->proto_data; | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1747 char sendbuf[MSN_BUF_LEN]; |
2086 | 1748 |
1749 if (!g_strncasecmp(buf, "VER", 3)) { | |
2226
2a09a177ed5f
[gaim-migrate @ 2236]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2219
diff
changeset
|
1750 /* we got VER, check to see that MSNP5 is in the list, then send INF */ |
2a09a177ed5f
[gaim-migrate @ 2236]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2219
diff
changeset
|
1751 if (!strstr(buf, "MSNP5")) { |
4056 | 1752 hide_login_progress(gc, _("Protocol not supported")); |
2086 | 1753 signoff(gc); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1754 return 0; |
2086 | 1755 } |
1756 | |
4270 | 1757 g_snprintf(sendbuf, sizeof(sendbuf), "INF %u\r\n", ++md->trId); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1758 if (msn_write(md->fd, sendbuf, strlen(sendbuf)) < 0) { |
4056 | 1759 hide_login_progress(gc, _("Unable to request INF\n")); |
2086 | 1760 signoff(gc); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1761 return 0; |
2086 | 1762 } |
1763 } else if (!g_strncasecmp(buf, "INF", 3)) { | |
1764 /* check to make sure we can use md5 */ | |
1765 if (!strstr(buf, "MD5")) { | |
4056 | 1766 hide_login_progress(gc, _("Unable to login using MD5")); |
2086 | 1767 signoff(gc); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1768 return 0; |
2086 | 1769 } |
1770 | |
4270 | 1771 g_snprintf(sendbuf, sizeof(sendbuf), "USR %u MD5 I %s\r\n", ++md->trId, gc->username); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1772 if (msn_write(md->fd, sendbuf, strlen(sendbuf)) < 0) { |
4056 | 1773 hide_login_progress(gc, _("Unable to send USR\n")); |
2086 | 1774 signoff(gc); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1775 return 0; |
2086 | 1776 } |
1777 | |
3263 | 1778 set_login_progress(gc, 3, _("Requesting to send password")); |
2086 | 1779 } else if (!g_strncasecmp(buf, "USR", 3)) { |
2210
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1780 char *resp, *friend, *tmp = buf; |
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1781 |
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1782 GET_NEXT(tmp); |
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1783 GET_NEXT(tmp); |
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1784 resp = tmp; |
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1785 GET_NEXT(tmp); |
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1786 GET_NEXT(tmp); |
3323 | 1787 friend = url_decode(tmp); |
2213
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1788 GET_NEXT(tmp); |
2210
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1789 |
2086 | 1790 /* so here, we're either getting the challenge or the OK */ |
2213
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1791 if (!g_strcasecmp(resp, "OK")) { |
2210
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1792 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", friend); |
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1793 |
4270 | 1794 g_snprintf(sendbuf, sizeof(sendbuf), "SYN %u 0\r\n", ++md->trId); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1795 if (msn_write(md->fd, sendbuf, strlen(sendbuf)) < 0) { |
4056 | 1796 hide_login_progress(gc, _("Unable to write")); |
2086 | 1797 signoff(gc); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1798 return 0; |
2086 | 1799 } |
1800 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1801 gaim_input_remove(md->inpa); |
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1802 md->inpa = gaim_input_add(md->fd, GAIM_INPUT_READ, msn_callback, gc); |
2739
7aeedbf29a96
[gaim-migrate @ 2752]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2738
diff
changeset
|
1803 return 0; |
2213
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1804 } else if (!g_strcasecmp(resp, "MD5")) { |
2086 | 1805 char buf2[MSN_BUF_LEN]; |
1806 md5_state_t st; | |
1807 md5_byte_t di[16]; | |
1808 int i; | |
1809 | |
2213
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1810 g_snprintf(buf2, sizeof(buf2), "%s%s", friend, gc->password); |
2086 | 1811 |
1812 md5_init(&st); | |
1813 md5_append(&st, (const md5_byte_t *)buf2, strlen(buf2)); | |
1814 md5_finish(&st, di); | |
1815 | |
4270 | 1816 g_snprintf(sendbuf, sizeof(sendbuf), "USR %u MD5 S ", ++md->trId); |
2086 | 1817 for (i = 0; i < 16; i++) { |
1818 g_snprintf(buf2, sizeof(buf2), "%02x", di[i]); | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1819 strcat(sendbuf, buf2); |
2086 | 1820 } |
3321 | 1821 strcat(sendbuf, "\r\n"); |
2086 | 1822 |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1823 if (msn_write(md->fd, sendbuf, strlen(sendbuf)) < 0) { |
3263 | 1824 hide_login_progress(gc, _("Unable to send password")); |
2086 | 1825 signoff(gc); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1826 return 0; |
2086 | 1827 } |
1828 | |
3263 | 1829 set_login_progress(gc, 4, _("Password sent")); |
2086 | 1830 } |
1831 } else if (!g_strncasecmp(buf, "XFR", 3)) { | |
1832 char *host = strstr(buf, "NS"); | |
1833 int port; | |
1834 int i = 0; | |
1835 | |
1836 if (!host) { | |
4056 | 1837 hide_login_progress(gc, _("Got invalid XFR\n")); |
2086 | 1838 signoff(gc); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1839 return 0; |
2086 | 1840 } |
1841 | |
1842 GET_NEXT(host); | |
1843 while (host[i] && host[i] != ':') i++; | |
1844 if (host[i] == ':') { | |
1845 char *x = &host[i + 1]; | |
1846 host[i] = 0; | |
1847 port = atoi(x); | |
1848 } else | |
1849 port = 1863; | |
1850 | |
1851 close(md->fd); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1852 gaim_input_remove(md->inpa); |
2086 | 1853 md->inpa = 0; |
1854 md->fd = 0; | |
3171 | 1855 md->sl = time(NULL); |
4452 | 1856 if (proxy_connect(host, port, msn_login_xfr_connect, gc) != 0) { |
4056 | 1857 hide_login_progress(gc, _("Unable to transfer")); |
2688
98b1ac8ddea3
[gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1858 signoff(gc); |
98b1ac8ddea3
[gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1859 } |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1860 return 0; |
2086 | 1861 } else { |
1862 if (isdigit(*buf)) | |
1863 hide_login_progress(gc, handle_errcode(buf, FALSE)); | |
1864 else | |
4056 | 1865 hide_login_progress(gc, _("Unable to parse message")); |
2086 | 1866 signoff(gc); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1867 return 0; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1868 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1869 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1870 return 1; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1871 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1872 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1873 static void msn_login_callback(gpointer data, gint source, GaimInputCondition cond) |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1874 { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1875 struct gaim_connection *gc = data; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1876 struct msn_data *md = gc->proto_data; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1877 char buf[MSN_BUF_LEN]; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1878 int cont = 1; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1879 int len; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1880 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1881 len = read(md->fd, buf, sizeof(buf)); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1882 if (len <= 0) { |
3263 | 1883 hide_login_progress(gc, _("Error reading from server")); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1884 signoff(gc); |
2086 | 1885 return; |
1886 } | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1887 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1888 md->rxqueue = g_realloc(md->rxqueue, len + md->rxlen); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1889 memcpy(md->rxqueue + md->rxlen, buf, len); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1890 md->rxlen += len; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1891 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1892 while (cont) { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1893 char *end = md->rxqueue; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1894 int cmdlen; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1895 char *cmd; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1896 int i = 0; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1897 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1898 if (!md->rxlen) |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1899 return; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1900 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1901 while (i + 1 < md->rxlen) { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1902 if (*end == '\r' && end[1] == '\n') |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1903 break; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1904 end++; i++; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1905 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1906 if (i + 1 == md->rxlen) |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1907 return; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1908 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1909 cmdlen = end - md->rxqueue + 2; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1910 cmd = md->rxqueue; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1911 md->rxlen -= cmdlen; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1912 if (md->rxlen) { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1913 md->rxqueue = g_memdup(cmd + cmdlen, md->rxlen); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1914 } else { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1915 md->rxqueue = NULL; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1916 cmd = g_realloc(cmd, cmdlen + 1); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1917 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1918 cmd[cmdlen] = 0; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1919 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1920 debug_printf("MSN S: %s", cmd); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1921 g_strchomp(cmd); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1922 cont = msn_process_login(gc, cmd); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1923 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1924 g_free(cmd); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1925 } |
2086 | 1926 } |
1927 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1928 static void msn_login_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1929 { |
1930 struct gaim_connection *gc = data; | |
1931 struct msn_data *md; | |
1932 char buf[1024]; | |
1933 | |
2210
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1934 if (!g_slist_find(connections, gc)) { |
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1935 close(source); |
2086 | 1936 return; |
2210
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1937 } |
2086 | 1938 |
1939 md = gc->proto_data; | |
1940 | |
1941 if (md->fd != source) | |
1942 md->fd = source; | |
1943 | |
1944 if (md->fd == -1) { | |
3263 | 1945 hide_login_progress(gc, _("Unable to connect")); |
2086 | 1946 signoff(gc); |
1947 return; | |
1948 } | |
1949 | |
4270 | 1950 g_snprintf(buf, sizeof(buf), "VER %u MSNP5\r\n", ++md->trId); |
2086 | 1951 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
3263 | 1952 hide_login_progress(gc, _("Unable to write to server")); |
2086 | 1953 signoff(gc); |
1954 return; | |
1955 } | |
1956 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1957 md->inpa = gaim_input_add(md->fd, GAIM_INPUT_READ, msn_login_callback, gc); |
3263 | 1958 set_login_progress(gc, 2,_("Synching with server")); |
2086 | 1959 } |
1960 | |
1961 static void msn_login(struct aim_user *user) | |
1962 { | |
1963 struct gaim_connection *gc = new_gaim_conn(user); | |
1964 struct msn_data *md = gc->proto_data = g_new0(struct msn_data, 1); | |
1965 | |
3263 | 1966 set_login_progress(gc, 1, _("Connecting")); |
2086 | 1967 |
1968 g_snprintf(gc->username, sizeof(gc->username), "%s", msn_normalize(gc->username)); | |
3322 | 1969 |
4452 | 1970 if (proxy_connect(user->proto_opt[USEROPT_MSNSERVER][0] ? user->proto_opt[USEROPT_MSNSERVER] : MSN_SERVER, |
3322 | 1971 user->proto_opt[USEROPT_MSNPORT][0] ? atoi(user->proto_opt[USEROPT_MSNPORT]) : MSN_PORT, |
4452 | 1972 msn_login_connect, gc) != 0) { |
3263 | 1973 hide_login_progress(gc, _("Unable to connect")); |
2688
98b1ac8ddea3
[gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1974 signoff(gc); |
98b1ac8ddea3
[gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1975 } |
2086 | 1976 } |
1977 | |
1978 static void msn_close(struct gaim_connection *gc) | |
1979 { | |
1980 struct msn_data *md = gc->proto_data; | |
1981 close(md->fd); | |
1982 if (md->inpa) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1983 gaim_input_remove(md->inpa); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1984 g_free(md->rxqueue); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1985 if (md->msg) |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1986 g_free(md->msguser); |
3195 | 1987 if (md->passport) { |
1988 unlink(md->passport); | |
3231 | 1989 g_free(md->passport); |
3195 | 1990 } |
2086 | 1991 while (md->switches) |
1992 msn_kill_switch(md->switches->data); | |
1993 while (md->fl) { | |
1994 struct msn_buddy *tmp = md->fl->data; | |
1995 md->fl = g_slist_remove(md->fl, tmp); | |
1996 g_free(tmp->user); | |
1997 g_free(tmp->friend); | |
1998 g_free(tmp); | |
1999 } | |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2000 g_slist_free(md->permit); |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2001 g_slist_free(md->deny); |
2086 | 2002 g_free(md); |
2003 } | |
2004 | |
3001 | 2005 static int msn_send_typing(struct gaim_connection *gc, char *who, int typing) { |
2993 | 2006 struct msn_switchboard *ms = msn_find_switch(gc, who); |
2007 char header[MSN_BUF_LEN] = "MIME-Version: 1.0\r\n" | |
2008 "Content-Type: text/x-msmsgscontrol\r\n" | |
2009 "TypingUser: "; | |
2010 char buf [MSN_BUF_LEN]; | |
3001 | 2011 if (!ms || !typing) |
2012 return 0; | |
4270 | 2013 g_snprintf(buf, sizeof(buf), "MSG %u N %d\r\n%s%s\r\n\r\n\r\n", |
2993 | 2014 ++ms->trId, |
2015 strlen(header) + strlen("\r\n\r\n\r\n") + strlen(gc->username), | |
2016 header, gc->username); | |
2017 if (msn_write(ms->fd, buf, strlen(buf)) < 0) | |
2018 msn_kill_switch(ms); | |
2019 return MSN_TYPING_SEND_TIMEOUT; | |
2020 } | |
2021 | |
4150 | 2022 /* XXX Don't blame me. I stole this from the oscar module! */ |
2023 static struct msn_file_transfer *find_mft_by_xfer(struct gaim_connection *gc, | |
2024 struct file_transfer *xfer) | |
2025 { | |
2026 GSList *g = ((struct msn_data *)gc->proto_data)->file_transfers; | |
2027 struct msn_file_transfer *f = NULL; | |
2028 | |
2029 while (g) { | |
2030 f = (struct msn_file_transfer *)g->data; | |
2031 if (f->xfer == xfer) | |
2032 break; | |
2033 | |
2034 g = g->next; | |
2035 f = NULL; | |
2036 } | |
2037 | |
2038 return f; | |
2039 } | |
2040 | |
2041 /* XXX Don't blame me. I stole this from the oscar module! */ | |
2042 static struct msn_file_transfer *find_mft_by_cookie(struct gaim_connection *gc, | |
2043 unsigned long cookie) | |
2044 { | |
2045 GSList *g = ((struct msn_data *)gc->proto_data)->file_transfers; | |
2046 struct msn_file_transfer *f = NULL; | |
2047 | |
2048 while (g) { | |
2049 f = (struct msn_file_transfer *)g->data; | |
2050 if (f->cookie == cookie) | |
2051 break; | |
2052 | |
2053 g = g->next; | |
2054 f = NULL; | |
2055 } | |
2056 | |
2057 return f; | |
2058 } | |
2059 | |
2060 static void msn_file_transfer_cancel(struct gaim_connection *gc, | |
2061 struct file_transfer *xfer) | |
2062 { | |
2063 struct msn_data *md = gc->proto_data; | |
2064 struct msn_file_transfer *mft = find_mft_by_xfer(gc, xfer); | |
2065 struct msn_switchboard *ms = msn_find_switch(gc, mft->sn); | |
2066 char header[MSN_BUF_LEN]; | |
2067 char buf[MSN_BUF_LEN]; | |
2068 | |
2069 if (!ms || !mft) | |
2070 { | |
2071 debug_printf("Eep! Returning from msn_file_transfer_cancel early"); | |
2072 return; | |
2073 } | |
2074 | |
2075 g_snprintf(header, sizeof(header), | |
2076 "MIME-Version: 1.0\r\n" | |
2077 "Content-Type: text/x-msmsgsinvite; charset=UTF-8\r\n\r\n" | |
2078 "Invitation-Command: CANCEL\r\n" | |
4270 | 2079 "Invitation-Cookie: %lu\r\n" |
4150 | 2080 "Cancel-Code: REJECT\r\n", |
4270 | 2081 (unsigned long)mft->cookie); |
2082 | |
2083 g_snprintf(buf, sizeof(buf), "MSG %u N %d\r\n%s\r\n\r\n", | |
4150 | 2084 ++ms->trId, strlen(header) + strlen("\r\n\r\n"), |
2085 header); | |
2086 | |
2087 md->file_transfers = g_slist_remove(md->file_transfers, mft); | |
2088 | |
2089 if (msn_write(ms->fd, buf, strlen(buf)) < 0) | |
2090 { | |
2091 debug_printf("Uh oh! Killing switch.\n"); | |
2092 msn_kill_switch(ms); | |
2093 } | |
2094 } | |
2095 | |
2096 static void msn_file_transfer_in(struct gaim_connection *gc, | |
2097 struct file_transfer *xfer, int offset) | |
2098 { | |
2099 struct msn_file_transfer *mft = find_mft_by_xfer(gc, xfer); | |
2100 struct msn_switchboard *ms = msn_find_switch(gc, mft->sn); | |
2101 char header[MSN_BUF_LEN]; | |
2102 char buf[MSN_BUF_LEN]; | |
2103 | |
2104 if (!ms || !mft) | |
2105 { | |
2106 debug_printf("Eep! Returning from msn_file_transfer_in early"); | |
2107 return; | |
2108 } | |
2109 | |
2110 g_snprintf(header, sizeof(header), | |
2111 "MIME-Version: 1.0\r\n" | |
2112 "Content-Type: text/x-msmsgsinvite; charset=UTF-8\r\n\r\n" | |
2113 "Invitation-Command: ACCEPT\r\n" | |
4270 | 2114 "Invitation-Cookie: %lu\r\n" |
4150 | 2115 "Launch-Application: FALSE\r\n" |
2116 "Request-Data: IP-Address:\r\n", | |
4270 | 2117 (unsigned long)mft->cookie); |
2118 | |
2119 g_snprintf(buf, sizeof(buf), "MSG %u N %d\r\n%s\r\n\r\n", | |
4150 | 2120 ++ms->trId, strlen(header) + strlen("\r\n\r\n"), |
2121 header); | |
2122 | |
2123 if (msn_write(ms->fd, buf, strlen(buf)) < 0) { | |
2124 msn_kill_switch(ms); | |
2125 return; | |
2126 } | |
2127 | |
2128 mft->xfer = xfer; | |
2129 } | |
2130 | |
2131 static void msn_file_transfer_out(struct gaim_connection *gc, | |
2132 struct file_transfer *xfer, | |
2133 const char *name, int totfiles, int totsize) | |
2134 { | |
2135 struct msn_file_transfer *mft = find_mft_by_xfer(gc, xfer); | |
2136 struct msn_switchboard *ms = msn_find_switch(gc, mft->sn); | |
2137 char header[MSN_BUF_LEN]; | |
2138 char buf[MSN_BUF_LEN]; | |
2139 struct stat sb; | |
2140 | |
2141 if (!ms) | |
2142 return; | |
2143 | |
2144 if (totfiles > 1) | |
2145 return; | |
2146 | |
2147 if (stat(name, &sb) == -1) | |
2148 return; | |
2149 | |
4270 | 2150 mft->cookie = 1 + (uint32_t)(4294967295.0 * rand() / (RAND_MAX + 1.0)); |
4150 | 2151 |
2152 g_snprintf(header, sizeof(header), | |
2153 "MIME-Version: 1.0\r\n" | |
2154 "Content-Type: text/x-msmsgsinvite; charset=UTF-8\r\n" | |
2155 "Application-Name: File Transfer\r\n" | |
2156 "Application-GUID: {5D3E02AB-6190-11d3-BBBB-00C04F795683}\r\n" | |
2157 "Invitation-Command: INVITE\r\n" | |
4270 | 2158 "Invitation-Cookie: %lu\r\n" |
4150 | 2159 "Application-File: %s\r\n" |
2160 "Application-FileSize: %ld\r\n", | |
4270 | 2161 (unsigned long)mft->cookie, name, sb.st_size); |
2162 | |
2163 g_snprintf(buf, sizeof(buf), "MSG %u A %d\r\n%s\r\n\r\n", | |
4150 | 2164 ++ms->trId, |
2165 strlen(header) + strlen("\r\n\r\n"), | |
2166 header); | |
2167 | |
2168 if (msn_write(ms->fd, buf, strlen(buf)) < 0) | |
2169 msn_kill_switch(ms); | |
2170 | |
2171 debug_printf("\n"); | |
2172 } | |
2173 | |
2174 static void msn_file_transfer_done(struct gaim_connection *gc, | |
2175 struct file_transfer *xfer) | |
2176 { | |
2177 struct msn_data *md = (struct msn_data *)gc->proto_data; | |
2178 struct msn_file_transfer *mft = find_mft_by_xfer(gc, xfer); | |
2179 char buf[MSN_BUF_LEN]; | |
2180 | |
2181 g_snprintf(buf, sizeof(buf), "BYE 16777989\r\n"); | |
2182 | |
2183 msn_write(mft->fd, buf, strlen(buf)); | |
2184 | |
2185 md->file_transfers = g_slist_remove(md->file_transfers, mft); | |
2186 | |
2187 gaim_input_remove(mft->inpa); | |
2188 | |
2189 close(mft->fd); | |
2190 | |
2191 g_free(mft->filename); | |
2192 g_free(mft->sn); | |
2193 g_free(mft); | |
2194 } | |
2195 | |
2196 static size_t msn_file_transfer_read(struct gaim_connection *gc, | |
2197 struct file_transfer *xfer, int fd, | |
2198 char **buf) | |
2199 { | |
2200 unsigned char header[3]; | |
2201 size_t len, size; | |
2202 | |
2203 if (read(fd, header, sizeof(header)) < 3) | |
2204 return 0; | |
2205 | |
2206 if (header[0] != 0) { | |
2207 debug_printf("Invalid header[0]: %d. Aborting.\n", header[0]); | |
2208 return 0; | |
2209 } | |
2210 | |
2211 size = header[1] | (header[2] << 8); | |
2212 | |
2213 *buf = g_new0(char, size); | |
2214 | |
2215 for (len = 0; len < size; len += read(fd, *buf + len, size - len)); | |
2216 | |
2217 return len; | |
2218 } | |
2219 | |
3033 | 2220 static int msn_send_im(struct gaim_connection *gc, char *who, char *message, int len, int flags) |
2086 | 2221 { |
2222 struct msn_data *md = gc->proto_data; | |
2223 struct msn_switchboard *ms = msn_find_switch(gc, who); | |
2224 char buf[MSN_BUF_LEN]; | |
2225 | |
2226 if (ms) { | |
3642 | 2227 char *send; |
2591
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
2228 |
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
2229 if (ms->txqueue) { |
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
2230 debug_printf("appending to queue\n"); |
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
2231 ms->txqueue = g_slist_append(ms->txqueue, g_strdup(message)); |
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
2232 return 1; |
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
2233 } |
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
2234 |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2600
diff
changeset
|
2235 send = add_cr(message); |
4270 | 2236 g_snprintf(buf, sizeof(buf), "MSG %u N %d\r\n%s%s", ++ms->trId, |
3642 | 2237 strlen(MIME_HEADER) + strlen(send), |
2238 MIME_HEADER, send); | |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2600
diff
changeset
|
2239 g_free(send); |
2086 | 2240 if (msn_write(ms->fd, buf, strlen(buf)) < 0) |
2241 msn_kill_switch(ms); | |
2242 debug_printf("\n"); | |
2243 } else if (strcmp(who, gc->username)) { | |
4270 | 2244 g_snprintf(buf, MSN_BUF_LEN, "XFR %u SB\r\n", ++md->trId); |
2086 | 2245 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 2246 hide_login_progress(gc, _("Write error")); |
2086 | 2247 signoff(gc); |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2248 return 1; |
2086 | 2249 } |
2250 | |
2251 ms = g_new0(struct msn_switchboard, 1); | |
2252 md->switches = g_slist_append(md->switches, ms); | |
2253 ms->user = g_strdup(who); | |
2591
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
2254 ms->txqueue = g_slist_append(ms->txqueue, g_strdup(message)); |
2086 | 2255 ms->gc = gc; |
2256 ms->fd = -1; | |
2257 } else | |
2258 /* in msn you can't send messages to yourself, so we'll fake like we received it ;) */ | |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2842
diff
changeset
|
2259 serv_got_im(gc, who, message, flags | IM_FLAG_GAIMUSER, time(NULL), -1); |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
2260 return 1; |
2086 | 2261 } |
2262 | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2263 static int msn_chat_send(struct gaim_connection *gc, int id, char *message) |
2086 | 2264 { |
2265 struct msn_switchboard *ms = msn_find_switch_by_id(gc, id); | |
2266 char buf[MSN_BUF_LEN]; | |
3642 | 2267 char *send; |
2086 | 2268 |
2269 if (!ms) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2270 return -EINVAL; |
2086 | 2271 |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2600
diff
changeset
|
2272 send = add_cr(message); |
4270 | 2273 g_snprintf(buf, sizeof(buf), "MSG %u N %d\r\n%s%s", ++ms->trId, |
3642 | 2274 strlen(MIME_HEADER) + strlen(send), |
2275 MIME_HEADER, send); | |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2600
diff
changeset
|
2276 g_free(send); |
2591
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
2277 if (msn_write(ms->fd, buf, strlen(buf)) < 0) { |
2086 | 2278 msn_kill_switch(ms); |
2591
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
2279 return 0; |
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
2280 } |
2086 | 2281 debug_printf("\n"); |
2282 serv_got_chat_in(gc, id, gc->username, 0, message, time(NULL)); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2283 return 0; |
2086 | 2284 } |
2285 | |
3466 | 2286 static void msn_chat_invite(struct gaim_connection *gc, int id, const char *msg, const char *who) |
2086 | 2287 { |
2288 struct msn_switchboard *ms = msn_find_switch_by_id(gc, id); | |
2289 char buf[MSN_BUF_LEN]; | |
2290 | |
2291 if (!ms) | |
2292 return; | |
2293 | |
4270 | 2294 g_snprintf(buf, sizeof(buf), "CAL %u %s\r\n", ++ms->trId, who); |
2086 | 2295 if (msn_write(ms->fd, buf, strlen(buf)) < 0) |
2296 msn_kill_switch(ms); | |
2297 } | |
2298 | |
2299 static void msn_chat_leave(struct gaim_connection *gc, int id) | |
2300 { | |
2301 struct msn_switchboard *ms = msn_find_switch_by_id(gc, id); | |
2302 char buf[MSN_BUF_LEN]; | |
2303 | |
2304 if (!ms) | |
2305 return; | |
2306 | |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2600
diff
changeset
|
2307 g_snprintf(buf, sizeof(buf), "OUT\r\n"); |
2086 | 2308 if (msn_write(ms->fd, buf, strlen(buf)) < 0) |
2309 msn_kill_switch(ms); | |
2310 } | |
2311 | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
2312 static GList *msn_away_states(struct gaim_connection *gc) |
2086 | 2313 { |
2314 GList *m = NULL; | |
2315 | |
3263 | 2316 m = g_list_append(m, _("Available")); |
2317 m = g_list_append(m, _("Away From Computer")); | |
2318 m = g_list_append(m, _("Be Right Back")); | |
2319 m = g_list_append(m, _("Busy")); | |
2320 m = g_list_append(m, _("On The Phone")); | |
2321 m = g_list_append(m, _("Out To Lunch")); | |
2322 m = g_list_append(m, _("Hidden")); | |
2086 | 2323 |
2324 return m; | |
2325 } | |
2326 | |
2327 static void msn_set_away(struct gaim_connection *gc, char *state, char *msg) | |
2328 { | |
2329 struct msn_data *md = gc->proto_data; | |
2330 char buf[MSN_BUF_LEN]; | |
4270 | 2331 const char *away; |
2086 | 2332 |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4069
diff
changeset
|
2333 if (gc->away) { |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4069
diff
changeset
|
2334 g_free(gc->away); |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4069
diff
changeset
|
2335 gc->away = NULL; |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4069
diff
changeset
|
2336 } |
2086 | 2337 |
2338 if (msg) { | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4069
diff
changeset
|
2339 gc->away = g_strdup(""); |
2086 | 2340 away = "AWY"; |
2341 } else if (state) { | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4069
diff
changeset
|
2342 gc->away = g_strdup(""); |
2086 | 2343 |
3538 | 2344 if (!strcmp(state, _("Away From Computer"))) |
2086 | 2345 away = "AWY"; |
3538 | 2346 else if (!strcmp(state, _("Be Right Back"))) |
2086 | 2347 away = "BRB"; |
3538 | 2348 else if (!strcmp(state, _("Busy"))) |
2086 | 2349 away = "BSY"; |
3538 | 2350 else if (!strcmp(state, _("On The Phone"))) |
2086 | 2351 away = "PHN"; |
3538 | 2352 else if (!strcmp(state, _("Out To Lunch"))) |
2086 | 2353 away = "LUN"; |
3538 | 2354 else if (!strcmp(state, _("Hidden"))) |
2152
f631cfc8e824
[gaim-migrate @ 2162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2123
diff
changeset
|
2355 away = "HDN"; |
2086 | 2356 else { |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4069
diff
changeset
|
2357 g_free(gc->away); |
2086 | 2358 gc->away = NULL; |
2359 away = "NLN"; | |
2360 } | |
2361 } else if (gc->is_idle) | |
2362 away = "IDL"; | |
2363 else | |
2364 away = "NLN"; | |
2365 | |
4270 | 2366 g_snprintf(buf, sizeof(buf), "CHG %u %s\r\n", ++md->trId, away); |
2086 | 2367 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 2368 hide_login_progress(gc, _("Write error")); |
2086 | 2369 signoff(gc); |
2370 return; | |
2371 } | |
2372 } | |
2373 | |
2374 static void msn_set_idle(struct gaim_connection *gc, int idle) | |
2375 { | |
2376 struct msn_data *md = gc->proto_data; | |
4270 | 2377 char buf[64]; |
2086 | 2378 |
2379 if (gc->away) | |
2380 return; | |
4270 | 2381 g_snprintf(buf, sizeof(buf), |
2382 idle ? "CHG %d IDL\r\n" : "CHG %u NLN\r\n", ++md->trId); | |
2086 | 2383 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 2384 hide_login_progress(gc, _("Write error")); |
2086 | 2385 signoff(gc); |
2386 return; | |
2387 } | |
2388 } | |
2389 | |
2390 static char **msn_list_icon(int uc) | |
2391 { | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
2392 if (uc == 0) |
2086 | 2393 return msn_online_xpm; |
3175 | 2394 |
2395 uc >>= 1; | |
2396 | |
2397 if (uc == 2 || uc == 6) | |
2398 return msn_occ_xpm; | |
2399 | |
2086 | 2400 return msn_away_xpm; |
2401 } | |
2402 | |
2403 static char *msn_get_away_text(int s) | |
2404 { | |
2405 switch (s) { | |
2406 case MSN_BUSY : | |
4056 | 2407 return _("Busy"); |
2086 | 2408 case MSN_BRB : |
4056 | 2409 return _("Be right back"); |
2086 | 2410 case MSN_AWAY : |
4056 | 2411 return _("Away from the computer"); |
2086 | 2412 case MSN_PHONE : |
4056 | 2413 return _("On the phone"); |
2086 | 2414 case MSN_LUNCH : |
4056 | 2415 return _("Out to lunch"); |
2086 | 2416 case MSN_IDLE : |
4056 | 2417 return _("Idle"); |
2086 | 2418 default: |
4056 | 2419 return _("Available"); |
2086 | 2420 } |
2421 } | |
2422 | |
4150 | 2423 static void msn_ask_send_file(struct gaim_connection *gc, char *destsn) |
2424 { | |
2425 struct msn_data *md = (struct msn_data *)gc->proto_data; | |
2426 struct msn_file_transfer *mft = g_new0(struct msn_file_transfer, 1); | |
2427 | |
2428 mft->type = MFT_SENDFILE_OUT; | |
2429 mft->sn = g_strdup(destsn); | |
2430 mft->gc = gc; | |
2431 | |
2432 md->file_transfers = g_slist_append(md->file_transfers, mft); | |
2433 | |
2434 mft->xfer = transfer_out_add(gc, mft->sn); | |
2435 } | |
2436 | |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2169
diff
changeset
|
2437 static GList *msn_buddy_menu(struct gaim_connection *gc, char *who) |
2086 | 2438 { |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2169
diff
changeset
|
2439 GList *m = NULL; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2169
diff
changeset
|
2440 struct proto_buddy_menu *pbm; |
4349 | 2441 struct buddy *b = find_buddy(gc->user, who); |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2169
diff
changeset
|
2442 static char buf[MSN_BUF_LEN]; |
2086 | 2443 |
2607
e0d4a23aac89
[gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2603
diff
changeset
|
2444 pbm = g_new0(struct proto_buddy_menu, 1); |
4150 | 2445 pbm->label = _("Send File"); |
2446 pbm->callback = msn_ask_send_file; | |
2447 pbm->gc = gc; | |
2448 m = g_list_append(m, pbm); | |
2449 | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
2450 if (!b || !(b->uc >> 1)) |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2169
diff
changeset
|
2451 return m; |
2086 | 2452 |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2169
diff
changeset
|
2453 pbm = g_new0(struct proto_buddy_menu, 1); |
3263 | 2454 g_snprintf(buf, sizeof(buf), _("Status: %s"), msn_get_away_text(b->uc >> 1)); |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2169
diff
changeset
|
2455 pbm->label = buf; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2169
diff
changeset
|
2456 pbm->callback = NULL; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2169
diff
changeset
|
2457 pbm->gc = gc; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2169
diff
changeset
|
2458 m = g_list_append(m, pbm); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2169
diff
changeset
|
2459 |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2169
diff
changeset
|
2460 return m; |
2086 | 2461 } |
2462 | |
3466 | 2463 static void msn_add_buddy(struct gaim_connection *gc, const char *name) |
2086 | 2464 { |
2465 struct msn_data *md = gc->proto_data; | |
2588
a3117e29317d
[gaim-migrate @ 2601]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2582
diff
changeset
|
2466 char *who = msn_normalize(name); |
2086 | 2467 char buf[MSN_BUF_LEN]; |
2468 GSList *l = md->fl; | |
2469 | |
2600
8aade06646b5
[gaim-migrate @ 2613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
2470 if (who[0] == '@') |
8aade06646b5
[gaim-migrate @ 2613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
2471 /* how did this happen? */ |
8aade06646b5
[gaim-migrate @ 2613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
2472 return; |
8aade06646b5
[gaim-migrate @ 2613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
2473 |
2953 | 2474 if (strchr(who, ' ')) |
2952 | 2475 /* This is a broken blist entry. */ |
2476 return; | |
2477 | |
2086 | 2478 while (l) { |
2479 struct msn_buddy *b = l->data; | |
2480 if (!g_strcasecmp(who, b->user)) | |
2481 break; | |
2482 l = l->next; | |
2483 } | |
2484 if (l) | |
2485 return; | |
2486 | |
4270 | 2487 g_snprintf(buf, sizeof(buf), "ADD %u FL %s %s\r\n", ++md->trId, who, who); |
2086 | 2488 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 2489 hide_login_progress(gc, _("Write error")); |
2086 | 2490 signoff(gc); |
2491 return; | |
2492 } | |
2493 } | |
2494 | |
2681
37d80035e77f
[gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2665
diff
changeset
|
2495 static void msn_rem_buddy(struct gaim_connection *gc, char *who, char *group) |
2086 | 2496 { |
2497 struct msn_data *md = gc->proto_data; | |
2498 char buf[MSN_BUF_LEN]; | |
2499 | |
4270 | 2500 g_snprintf(buf, sizeof(buf), "REM %u FL %s\r\n", ++md->trId, who); |
2086 | 2501 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 2502 hide_login_progress(gc, _("Write error")); |
2086 | 2503 signoff(gc); |
2504 return; | |
2505 } | |
2506 } | |
2507 | |
2213
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
2508 static void msn_act_id(gpointer data, char *entry) |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
2509 { |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
2510 struct gaim_connection *gc = data; |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
2511 struct msn_data *md = gc->proto_data; |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
2512 char buf[MSN_BUF_LEN]; |
3323 | 2513 char *alias; |
2213
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
2514 |
3466 | 2515 if (!entry || *entry == '\0') |
3448 | 2516 alias = g_strdup(""); |
2517 else | |
3642 | 2518 alias = g_strdup(entry); |
3323 | 2519 |
2520 if (strlen(alias) >= BUDDY_ALIAS_MAXLEN) { | |
3427 | 2521 do_error_dialog(_("New MSN friendly name too long."), NULL, GAIM_ERROR); |
3020 | 2522 return; |
2523 } | |
2524 | |
4270 | 2525 g_snprintf(buf, sizeof(buf), "REA %u %s %s\r\n", ++md->trId, gc->username, url_encode(alias)); |
3323 | 2526 g_free(alias); |
2213
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
2527 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 2528 hide_login_progress(gc, _("Write error")); |
2213
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
2529 signoff(gc); |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
2530 return; |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
2531 } |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
2532 } |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
2533 |
4333 | 2534 static void msn_show_set_friendly_name(struct gaim_connection *gc) |
2213
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
2535 { |
4333 | 2536 do_prompt_dialog(_("Set Friendly Name:"), gc->displayname, gc, msn_act_id, NULL); |
2213
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
2537 } |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
2538 |
4333 | 2539 static GList *msn_actions(struct gaim_connection *gc) |
2213
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
2540 { |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
2541 GList *m = NULL; |
4333 | 2542 struct proto_actions_menu *pam; |
2543 | |
2544 pam = g_new0(struct proto_actions_menu, 1); | |
2545 pam->label = _("Set Friendly Name"); | |
2546 pam->callback = msn_show_set_friendly_name; | |
2547 pam->gc = gc; | |
2548 m = g_list_append(m, pam); | |
2213
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
2549 |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
2550 return m; |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
2551 } |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
2552 |
2591
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
2553 static void msn_convo_closed(struct gaim_connection *gc, char *who) |
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
2554 { |
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
2555 struct msn_switchboard *ms = msn_find_switch(gc, who); |
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
2556 |
4069
5b56c42c2717
[gaim-migrate @ 4281]
Christian Hammond <chipx86@chipx86.com>
parents:
4068
diff
changeset
|
2557 if (ms) { |
5b56c42c2717
[gaim-migrate @ 4281]
Christian Hammond <chipx86@chipx86.com>
parents:
4068
diff
changeset
|
2558 char sendbuf[256]; |
5b56c42c2717
[gaim-migrate @ 4281]
Christian Hammond <chipx86@chipx86.com>
parents:
4068
diff
changeset
|
2559 |
5b56c42c2717
[gaim-migrate @ 4281]
Christian Hammond <chipx86@chipx86.com>
parents:
4068
diff
changeset
|
2560 g_snprintf(sendbuf, sizeof(sendbuf), "BYE %s\r\n", gc->username); |
5b56c42c2717
[gaim-migrate @ 4281]
Christian Hammond <chipx86@chipx86.com>
parents:
4068
diff
changeset
|
2561 |
5b56c42c2717
[gaim-migrate @ 4281]
Christian Hammond <chipx86@chipx86.com>
parents:
4068
diff
changeset
|
2562 msn_write(ms->fd, sendbuf, strlen(sendbuf)); |
5b56c42c2717
[gaim-migrate @ 4281]
Christian Hammond <chipx86@chipx86.com>
parents:
4068
diff
changeset
|
2563 |
2591
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
2564 msn_kill_switch(ms); |
4069
5b56c42c2717
[gaim-migrate @ 4281]
Christian Hammond <chipx86@chipx86.com>
parents:
4068
diff
changeset
|
2565 } |
2591
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
2566 } |
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
2567 |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2568 static void msn_keepalive(struct gaim_connection *gc) |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2569 { |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2570 struct msn_data *md = gc->proto_data; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2571 char buf[MSN_BUF_LEN]; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2572 |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2600
diff
changeset
|
2573 g_snprintf(buf, sizeof(buf), "PNG\r\n"); |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2574 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 2575 hide_login_progress(gc, _("Write error")); |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2576 signoff(gc); |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2577 return; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2578 } |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2579 } |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2580 |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2581 static void msn_set_permit_deny(struct gaim_connection *gc) |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2582 { |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2583 struct msn_data *md = gc->proto_data; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2584 char buf[MSN_BUF_LEN]; |
2665
b0478af51be0
[gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2611
diff
changeset
|
2585 GSList *s, *t = NULL; |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2586 |
4349 | 2587 if (gc->user->permdeny == PERMIT_ALL || gc->user->permdeny == DENY_SOME) |
4270 | 2588 g_snprintf(buf, sizeof(buf), "BLP %u AL\r\n", ++md->trId); |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2589 else |
4270 | 2590 g_snprintf(buf, sizeof(buf), "BLP %u BL\r\n", ++md->trId); |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2591 |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2592 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 2593 hide_login_progress(gc, _("Write error")); |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2594 signoff(gc); |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2595 return; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2596 } |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2597 |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2598 /* this is safe because we'll always come here after we've gotten the list off the server, |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2599 * and data is never removed. So if the lengths are equal we don't know about anyone locally |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2600 * and so there's no sense in going through them all. */ |
4349 | 2601 if (g_slist_length(gc->user->permit) == g_slist_length(md->permit)) { |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2602 g_slist_free(md->permit); |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2603 md->permit = NULL; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2604 } |
4349 | 2605 if (g_slist_length(gc->user->deny) == g_slist_length(md->deny)) { |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2606 g_slist_free(md->deny); |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2607 md->deny = NULL; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2608 } |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2609 if (!md->permit && !md->deny) |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2610 return; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2611 |
3200 | 2612 if (md->permit) { |
4349 | 2613 s = g_slist_nth(gc->user->permit, g_slist_length(md->permit)); |
3200 | 2614 while (s) { |
2615 char *who = s->data; | |
2616 s = s->next; | |
2617 if (!strchr(who, '@')) { | |
2618 t = g_slist_append(t, who); | |
2619 continue; | |
2620 } | |
4349 | 2621 if (g_slist_find(md->deny, who)) { |
3294 | 2622 t = g_slist_append(t, who); |
2623 continue; | |
2624 } | |
4270 | 2625 g_snprintf(buf, sizeof(buf), "ADD %u AL %s %s\r\n", ++md->trId, who, who); |
3200 | 2626 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 2627 hide_login_progress(gc, _("Write error")); |
3200 | 2628 signoff(gc); |
2629 return; | |
2630 } | |
2665
b0478af51be0
[gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2611
diff
changeset
|
2631 } |
3200 | 2632 while (t) { |
4349 | 2633 gaim_privacy_permit_remove(gc->user, t->data); |
3200 | 2634 t = t->next; |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2635 } |
3200 | 2636 if (t) |
2637 g_slist_free(t); | |
2665
b0478af51be0
[gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2611
diff
changeset
|
2638 t = NULL; |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2639 g_slist_free(md->permit); |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2640 md->permit = NULL; |
3200 | 2641 } |
2642 | |
2643 if (md->deny) { | |
4349 | 2644 s = g_slist_nth(gc->user->deny, g_slist_length(md->deny)); |
3200 | 2645 while (s) { |
2646 char *who = s->data; | |
2647 s = s->next; | |
2648 if (!strchr(who, '@')) { | |
2649 t = g_slist_append(t, who); | |
2650 continue; | |
2651 } | |
4349 | 2652 if (g_slist_find(md->deny, who)) { |
3294 | 2653 t = g_slist_append(t, who); |
2654 continue; | |
2655 } | |
4270 | 2656 g_snprintf(buf, sizeof(buf), "ADD %u BL %s %s\r\n", ++md->trId, who, who); |
3200 | 2657 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 2658 hide_login_progress(gc, _("Write error")); |
3200 | 2659 signoff(gc); |
2660 return; | |
2661 } | |
2665
b0478af51be0
[gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2611
diff
changeset
|
2662 } |
3200 | 2663 while (t) { |
4349 | 2664 gaim_privacy_deny_remove(gc->user, t->data); |
3200 | 2665 t = t->next; |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2666 } |
3200 | 2667 if (t) |
2668 g_slist_free(t); | |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2669 g_slist_free(md->deny); |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2670 md->deny = NULL; |
3200 | 2671 } |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2672 } |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2673 |
4349 | 2674 static void msn_add_permit(struct gaim_connection *gc, const char *who) |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2675 { |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2676 struct msn_data *md = gc->proto_data; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2677 char buf[MSN_BUF_LEN]; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2678 |
2665
b0478af51be0
[gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2611
diff
changeset
|
2679 if (!strchr(who, '@')) { |
3427 | 2680 g_snprintf(buf, sizeof(buf), |
2681 _("An MSN screenname must be in the form \"user@server.com\". " | |
2682 "Perhaps you meant %s@hotmail.com. No changes were made to your " | |
2683 "allow list."), who); | |
2684 do_error_dialog(_("Invalid MSN screenname"), buf, GAIM_ERROR); | |
4349 | 2685 gaim_privacy_permit_remove(gc->user, who); |
2665
b0478af51be0
[gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2611
diff
changeset
|
2686 return; |
b0478af51be0
[gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2611
diff
changeset
|
2687 } |
b0478af51be0
[gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2611
diff
changeset
|
2688 |
4349 | 2689 if (g_slist_find_custom(gc->user->deny, who, (GCompareFunc)strcmp)) { |
3294 | 2690 debug_printf("MSN: Moving %s from BL to AL\n", who); |
4349 | 2691 gaim_privacy_deny_remove(gc->user, who); |
4270 | 2692 g_snprintf(buf, sizeof(buf), "REM %u BL %s\r\n", ++md->trId, who); |
3294 | 2693 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 2694 hide_login_progress(gc, _("Write error")); |
3294 | 2695 signoff(gc); |
2696 return; | |
2697 } | |
2698 } | |
4270 | 2699 g_snprintf(buf, sizeof(buf), "ADD %u AL %s %s\r\n", ++md->trId, who, who); |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2700 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 2701 hide_login_progress(gc, _("Write error")); |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2702 signoff(gc); |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2703 return; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2704 } |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2705 } |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2706 |
4349 | 2707 static void msn_rem_permit(struct gaim_connection *gc, const char *who) |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2708 { |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2709 struct msn_data *md = gc->proto_data; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2710 char buf[MSN_BUF_LEN]; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2711 |
4270 | 2712 g_snprintf(buf, sizeof(buf), "REM %u AL %s\r\n", ++md->trId, who); |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2713 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 2714 hide_login_progress(gc, _("Write error")); |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2715 signoff(gc); |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2716 return; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2717 } |
4349 | 2718 |
2719 gaim_privacy_deny_add(gc->user, who); | |
4270 | 2720 g_snprintf(buf, sizeof(buf), "ADD %u BL %s %s\r\n", ++md->trId, who, who); |
3294 | 2721 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 2722 hide_login_progress(gc, _("Write error")); |
3294 | 2723 signoff(gc); |
2724 return; | |
2725 } | |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2726 } |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2727 |
4349 | 2728 static void msn_add_deny(struct gaim_connection *gc, const char *who) |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2729 { |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2730 struct msn_data *md = gc->proto_data; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2731 char buf[MSN_BUF_LEN]; |
4349 | 2732 |
2665
b0478af51be0
[gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2611
diff
changeset
|
2733 if (!strchr(who, '@')) { |
3427 | 2734 g_snprintf(buf, sizeof(buf), |
2735 _("An MSN screenname must be in the form \"user@server.com\". " | |
2736 "Perhaps you meant %s@hotmail.com. No changes were made to your " | |
2737 "block list."), who); | |
2738 do_error_dialog(_("Invalid MSN screenname"), buf, GAIM_ERROR); | |
4349 | 2739 gaim_privacy_deny_remove(gc->user, who); |
2665
b0478af51be0
[gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2611
diff
changeset
|
2740 return; |
b0478af51be0
[gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2611
diff
changeset
|
2741 } |
b0478af51be0
[gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2611
diff
changeset
|
2742 |
4349 | 2743 if (g_slist_find_custom(gc->user->permit, who, (GCompareFunc)strcmp)) { |
3294 | 2744 debug_printf("MSN: Moving %s from AL to BL\n", who); |
4349 | 2745 gaim_privacy_permit_remove(gc->user, who); |
4270 | 2746 g_snprintf(buf, sizeof(buf), "REM %u AL %s\r\n", ++md->trId, who); |
3294 | 2747 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 2748 hide_login_progress(gc, _("Write error")); |
3294 | 2749 signoff(gc); |
2750 return; | |
2751 } | |
2752 } | |
4349 | 2753 |
3294 | 2754 |
4270 | 2755 g_snprintf(buf, sizeof(buf), "ADD %u BL %s %s\r\n", ++md->trId, who, who); |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2756 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 2757 hide_login_progress(gc, _("Write error")); |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2758 signoff(gc); |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2759 return; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2760 } |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2761 } |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2762 |
4349 | 2763 static void msn_rem_deny(struct gaim_connection *gc, const char *who) |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2764 { |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2765 struct msn_data *md = gc->proto_data; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2766 char buf[MSN_BUF_LEN]; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2767 |
4270 | 2768 g_snprintf(buf, sizeof(buf), "REM %u BL %s\r\n", ++md->trId, who); |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2769 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 2770 hide_login_progress(gc, _("Write error")); |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2771 signoff(gc); |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2772 return; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2773 } |
4349 | 2774 |
2775 gaim_privacy_permit_add(gc->user, who); | |
4270 | 2776 g_snprintf(buf, sizeof(buf), "ADD %u AL %s %s\r\n", ++md->trId, who, who); |
3294 | 2777 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 2778 hide_login_progress(gc, _("Write error")); |
3294 | 2779 signoff(gc); |
2780 return; | |
2781 } | |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2782 } |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2783 |
2607
e0d4a23aac89
[gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2603
diff
changeset
|
2784 static void msn_buddy_free(struct buddy *b) |
e0d4a23aac89
[gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2603
diff
changeset
|
2785 { |
e0d4a23aac89
[gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2603
diff
changeset
|
2786 if (b->proto_data) |
e0d4a23aac89
[gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2603
diff
changeset
|
2787 g_free(b->proto_data); |
e0d4a23aac89
[gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2603
diff
changeset
|
2788 } |
e0d4a23aac89
[gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2603
diff
changeset
|
2789 |
3630 | 2790 G_MODULE_EXPORT void msn_init(struct prpl *ret) |
2086 | 2791 { |
3572 | 2792 struct proto_user_opt *puo; |
2086 | 2793 ret->protocol = PROTO_MSN; |
2153
0befa2d2e540
[gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2152
diff
changeset
|
2794 ret->options = OPT_PROTO_MAIL_CHECK; |
3572 | 2795 ret->name = g_strdup("MSN"); |
2086 | 2796 ret->list_icon = msn_list_icon; |
2797 ret->buddy_menu = msn_buddy_menu; | |
2798 ret->login = msn_login; | |
2799 ret->close = msn_close; | |
2800 ret->send_im = msn_send_im; | |
2993 | 2801 ret->send_typing = msn_send_typing; |
2086 | 2802 ret->away_states = msn_away_states; |
2803 ret->set_away = msn_set_away; | |
2804 ret->set_idle = msn_set_idle; | |
2805 ret->add_buddy = msn_add_buddy; | |
2806 ret->remove_buddy = msn_rem_buddy; | |
2807 ret->chat_send = msn_chat_send; | |
2808 ret->chat_invite = msn_chat_invite; | |
2809 ret->chat_leave = msn_chat_leave; | |
2810 ret->normalize = msn_normalize; | |
2213
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
2811 ret->actions = msn_actions; |
2591
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
2812 ret->convo_closed = msn_convo_closed; |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2813 ret->keepalive = msn_keepalive; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2814 ret->set_permit_deny = msn_set_permit_deny; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2815 ret->add_permit = msn_add_permit; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2816 ret->rem_permit = msn_rem_permit; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2817 ret->add_deny = msn_add_deny; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2818 ret->rem_deny = msn_rem_deny; |
2607
e0d4a23aac89
[gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2603
diff
changeset
|
2819 ret->buddy_free = msn_buddy_free; |
4150 | 2820 ret->file_transfer_cancel = msn_file_transfer_cancel; |
2821 ret->file_transfer_in = msn_file_transfer_in; | |
2822 ret->file_transfer_out = msn_file_transfer_out; | |
2823 ret->file_transfer_done = msn_file_transfer_done; | |
2824 ret->file_transfer_read = msn_file_transfer_read; | |
3572 | 2825 |
2826 puo = g_new0(struct proto_user_opt, 1); | |
4115 | 2827 puo->label = g_strdup(_("Server:")); |
3572 | 2828 puo->def = g_strdup(MSN_SERVER); |
2829 puo->pos = USEROPT_MSNSERVER; | |
2830 ret->user_opts = g_list_append(ret->user_opts, puo); | |
2831 | |
2832 puo = g_new0(struct proto_user_opt, 1); | |
4115 | 2833 puo->label = g_strdup(_("Port:")); |
3572 | 2834 puo->def = g_strdup("1863"); |
2835 puo->pos = USEROPT_MSNPORT; | |
2836 ret->user_opts = g_list_append(ret->user_opts, puo); | |
2086 | 2837 |
2838 my_protocol = ret; | |
2839 } | |
2840 | |
2841 #ifndef STATIC | |
2842 | |
3630 | 2843 G_MODULE_EXPORT void gaim_prpl_init(struct prpl *prpl) |
2086 | 2844 { |
3572 | 2845 msn_init(prpl); |
2846 prpl->plug->desc.api_version = PLUGIN_API_VERSION; | |
2086 | 2847 } |
2848 | |
3630 | 2849 G_MODULE_EXPORT void gaim_plugin_remove() |
2086 | 2850 { |
2851 struct prpl *p = find_prpl(PROTO_MSN); | |
2852 if (p == my_protocol) | |
2853 unload_protocol(p); | |
2854 } | |
2855 | |
3630 | 2856 G_MODULE_EXPORT char *name() |
2086 | 2857 { |
2858 return "MSN"; | |
2859 } | |
2860 | |
3630 | 2861 G_MODULE_EXPORT char *description() |
2086 | 2862 { |
2162
a464da684307
[gaim-migrate @ 2172]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2153
diff
changeset
|
2863 return PRPL_DESC("MSN"); |
2086 | 2864 } |
2865 | |
2866 #endif |