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