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