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