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