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