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