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