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