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