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