Mercurial > pidgin
annotate src/protocols/msn/msn.c @ 5166:cab5cd204956
[gaim-migrate @ 5530]
This is that stuff that's supposed to make msn work gooder on OSX.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Fri, 18 Apr 2003 18:04:38 +0000 |
parents | b31ad163de3b |
children | 092b418b5012 |
rev | line source |
---|---|
4542
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
1 /** |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
2 * @file msn.c The MSN protocol plugin |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
3 * |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
4 * gaim |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
5 * |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
6 * Parts Copyright (C) 2003, Christian Hammond <chipx86@gnupdate.org> |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
7 * |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
8 * This program is free software; you can redistribute it and/or modify |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
11 * (at your option) any later version. |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
12 * |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
16 * GNU General Public License for more details. |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
17 * |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
19 * along with this program; if not, write to the Free Software |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
21 * |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
22 */ |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
23 #include "msn.h" |
3630 | 24 |
4546
a951bb590857
[gaim-migrate @ 4825]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4542
diff
changeset
|
25 #ifdef _WIN32 |
a951bb590857
[gaim-migrate @ 4825]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4542
diff
changeset
|
26 #include "win32dep.h" |
a951bb590857
[gaim-migrate @ 4825]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4542
diff
changeset
|
27 #endif |
a951bb590857
[gaim-migrate @ 4825]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4542
diff
changeset
|
28 |
4687 | 29 #define BUDDY_ALIAS_MAXLEN 388 |
4542
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
30 |
4249 | 31 static struct prpl *my_protocol = NULL; |
32 | |
3630 | 33 /* for win32 compatability */ |
34 G_MODULE_IMPORT GSList *connections; | |
35 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
36 static void msn_login_callback(gpointer, gint, GaimInputCondition); |
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
37 static void msn_login_xfr_connect(gpointer, gint, GaimInputCondition); |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
38 |
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
39 #if 0 |
4546
a951bb590857
[gaim-migrate @ 4825]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4542
diff
changeset
|
40 static struct msn_file_transfer *find_mft_by_cookie(struct gaim_connection *gc, unsigned long cookie); |
a951bb590857
[gaim-migrate @ 4825]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4542
diff
changeset
|
41 static struct msn_file_transfer *find_mft_by_xfer(struct gaim_connection *gc, struct file_transfer *xfer); |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
42 #endif |
2086 | 43 |
44 static char *msn_normalize(const char *s) | |
45 { | |
46 static char buf[BUF_LEN]; | |
47 | |
48 g_return_val_if_fail(s != NULL, NULL); | |
49 | |
3504 | 50 g_snprintf(buf, sizeof(buf), "%s%s", s, strchr(s, '@') ? "" : "@hotmail.com"); |
2086 | 51 |
52 return buf; | |
53 } | |
54 | |
4542
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
55 char * |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
56 handle_errcode(char *buf, gboolean show) |
2086 | 57 { |
58 int errcode; | |
59 static char msg[MSN_BUF_LEN]; | |
60 | |
61 buf[4] = 0; | |
62 errcode = atoi(buf); | |
63 | |
64 switch (errcode) { | |
65 case 200: | |
3263 | 66 g_snprintf(msg, sizeof(msg), _("Syntax Error (probably a Gaim bug)")); |
2086 | 67 break; |
68 case 201: | |
3263 | 69 g_snprintf(msg, sizeof(msg), _("Invalid Parameter (probably a Gaim bug)")); |
2086 | 70 break; |
71 case 205: | |
3263 | 72 g_snprintf(msg, sizeof(msg), _("Invalid User")); |
2086 | 73 break; |
74 case 206: | |
3263 | 75 g_snprintf(msg, sizeof(msg), _("Fully Qualified Domain Name missing")); |
2086 | 76 break; |
77 case 207: | |
3263 | 78 g_snprintf(msg, sizeof(msg), _("Already Login")); |
2086 | 79 break; |
80 case 208: | |
3263 | 81 g_snprintf(msg, sizeof(msg), _("Invalid Username")); |
2086 | 82 break; |
83 case 209: | |
3263 | 84 g_snprintf(msg, sizeof(msg), _("Invalid Friendly Name")); |
2086 | 85 break; |
86 case 210: | |
3263 | 87 g_snprintf(msg, sizeof(msg), _("List Full")); |
2086 | 88 break; |
89 case 215: | |
3263 | 90 g_snprintf(msg, sizeof(msg), _("Already there")); |
2086 | 91 break; |
92 case 216: | |
3263 | 93 g_snprintf(msg, sizeof(msg), _("Not on list")); |
2086 | 94 break; |
2842
cf0f0153e2da
[gaim-migrate @ 2855]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
95 case 217: |
3263 | 96 g_snprintf(msg, sizeof(msg), _("User is offline")); |
2842
cf0f0153e2da
[gaim-migrate @ 2855]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2820
diff
changeset
|
97 break; |
2086 | 98 case 218: |
3263 | 99 g_snprintf(msg, sizeof(msg), _("Already in the mode")); |
2086 | 100 break; |
101 case 219: | |
3263 | 102 g_snprintf(msg, sizeof(msg), _("Already in opposite list")); |
2086 | 103 break; |
104 case 280: | |
3263 | 105 g_snprintf(msg, sizeof(msg), _("Switchboard failed")); |
2086 | 106 break; |
107 case 281: | |
3263 | 108 g_snprintf(msg, sizeof(msg), _("Notify Transfer failed")); |
2086 | 109 break; |
110 | |
111 case 300: | |
3263 | 112 g_snprintf(msg, sizeof(msg), _("Required fields missing")); |
2086 | 113 break; |
114 case 302: | |
3263 | 115 g_snprintf(msg, sizeof(msg), _("Not logged in")); |
2086 | 116 break; |
117 | |
118 case 500: | |
3263 | 119 g_snprintf(msg, sizeof(msg), _("Internal server error")); |
2086 | 120 break; |
121 case 501: | |
3263 | 122 g_snprintf(msg, sizeof(msg), _("Database server error")); |
2086 | 123 break; |
124 case 510: | |
3263 | 125 g_snprintf(msg, sizeof(msg), _("File operation error")); |
2086 | 126 break; |
127 case 520: | |
3263 | 128 g_snprintf(msg, sizeof(msg), _("Memory allocation error")); |
2086 | 129 break; |
130 | |
131 case 600: | |
3263 | 132 g_snprintf(msg, sizeof(msg), _("Server busy")); |
2086 | 133 break; |
134 case 601: | |
3263 | 135 g_snprintf(msg, sizeof(msg), _("Server unavailable")); |
2086 | 136 break; |
137 case 602: | |
3263 | 138 g_snprintf(msg, sizeof(msg), _("Peer Notification server down")); |
2086 | 139 break; |
140 case 603: | |
3263 | 141 g_snprintf(msg, sizeof(msg), _("Database connect error")); |
2086 | 142 break; |
143 case 604: | |
3263 | 144 g_snprintf(msg, sizeof(msg), _("Server is going down (abandon ship)")); |
2086 | 145 break; |
146 | |
147 case 707: | |
3263 | 148 g_snprintf(msg, sizeof(msg), _("Error creating connection")); |
2086 | 149 break; |
150 case 711: | |
3263 | 151 g_snprintf(msg, sizeof(msg), _("Unable to write")); |
2086 | 152 break; |
153 case 712: | |
3263 | 154 g_snprintf(msg, sizeof(msg), _("Session overload")); |
2086 | 155 break; |
156 case 713: | |
3263 | 157 g_snprintf(msg, sizeof(msg), _("User is too active")); |
2086 | 158 break; |
159 case 714: | |
3263 | 160 g_snprintf(msg, sizeof(msg), _("Too many sessions")); |
2086 | 161 break; |
162 case 715: | |
3263 | 163 g_snprintf(msg, sizeof(msg), _("Not expected")); |
2086 | 164 break; |
165 case 717: | |
3263 | 166 g_snprintf(msg, sizeof(msg), _("Bad friend file")); |
2086 | 167 break; |
168 | |
169 case 911: | |
3263 | 170 g_snprintf(msg, sizeof(msg), _("Authentication failed")); |
2086 | 171 break; |
172 case 913: | |
3263 | 173 g_snprintf(msg, sizeof(msg), _("Not allowed when offline")); |
2086 | 174 break; |
3073 | 175 case 920: |
3263 | 176 g_snprintf(msg, sizeof(msg), _("Not accepting new users")); |
2086 | 177 break; |
3073 | 178 case 924: |
3263 | 179 g_snprintf(msg, sizeof(msg), _("User unverified")); |
3073 | 180 break; |
2086 | 181 default: |
3263 | 182 g_snprintf(msg, sizeof(msg), _("Unknown Error Code")); |
2086 | 183 break; |
184 } | |
185 | |
186 if (show) | |
3427 | 187 do_error_dialog(msg, NULL, GAIM_ERROR); |
2086 | 188 |
189 return msg; | |
190 } | |
191 | |
4542
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
192 |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
193 char *url_decode(const char *msg) |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
194 { |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
195 static char buf[MSN_BUF_LEN]; |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
196 int i, j = 0; |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
197 |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
198 bzero(buf, sizeof(buf)); |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
199 for (i = 0; i < strlen(msg); i++) { |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
200 char hex[3]; |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
201 if (msg[i] != '%') { |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
202 buf[j++] = msg[i]; |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
203 continue; |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
204 } |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
205 strncpy(hex, msg + ++i, 2); hex[2] = 0; |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
206 /* i is pointing to the start of the number */ |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
207 i++; /* now it's at the end and at the start of the for loop |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
208 will be at the next character */ |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
209 buf[j++] = strtol(hex, NULL, 16); |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
210 } |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
211 buf[j] = 0; |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
212 |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
213 return buf; |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
214 } |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
215 |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
216 static char *url_encode(const char *msg) |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
217 { |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
218 static char buf[MSN_BUF_LEN]; |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
219 int i, j = 0; |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
220 |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
221 bzero(buf, sizeof(buf)); |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
222 for (i = 0; i < strlen(msg); i++) { |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
223 if (isalnum(msg[i])) |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
224 buf[j++] = msg[i]; |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
225 else { |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
226 sprintf(buf + j, "%%%02x", (unsigned char)msg[i]); |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
227 j += 3; |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
228 } |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
229 } |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
230 buf[j] = 0; |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
231 |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
232 return buf; |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
233 } |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
234 |
2086 | 235 static void handle_hotmail(struct gaim_connection *gc, char *data) |
236 { | |
2932 | 237 char login_url[2048]; |
3171 | 238 char buf[MSN_BUF_LEN]; |
239 struct msn_data *md = gc->proto_data; | |
240 | |
3293 | 241 if (strchr(gc->username, '@') != strstr(gc->username, "@hotmail.com")) |
242 /* We can only get Hotmail notification from hotmail users */ | |
243 return; | |
244 | |
3195 | 245 if (!md->passport) { |
4270 | 246 g_snprintf(buf, sizeof(buf), "URL %u INBOX\r\n", ++md->trId); |
2932 | 247 |
3195 | 248 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
2153
0befa2d2e540
[gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2152
diff
changeset
|
249 return; |
0befa2d2e540
[gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2152
diff
changeset
|
250 } |
3195 | 251 } else { |
252 g_snprintf(login_url, sizeof(login_url), "%s", md->passport); | |
253 | |
254 if (strstr(data, "Content-Type: text/x-msmsgsinitialemailnotification;")) { | |
255 char *x = strstr(data, "Inbox-Unread:"); | |
256 if (!x) return; | |
257 x += strlen("Inbox-Unread: "); | |
258 connection_has_mail(gc, atoi(x), NULL, NULL, login_url); | |
259 } else if (strstr(data, "Content-Type: text/x-msmsgsemailnotification;")) { | |
260 char *from = strstr(data, "From:"); | |
261 char *subject = strstr(data, "Subject:"); | |
262 char *x; | |
263 if (!from || !subject) { | |
264 connection_has_mail(gc, 1, NULL, NULL, login_url); | |
265 return; | |
266 } | |
267 from += strlen("From: "); | |
268 x = strstr(from, "\r\n"); *x = 0; | |
269 subject += strlen("Subject: "); | |
270 x = strstr(subject, "\r\n"); *x = 0; | |
271 connection_has_mail(gc, -1, from, subject, login_url); | |
272 } | |
2086 | 273 } |
274 } | |
275 | |
276 struct msn_add_permit { | |
277 struct gaim_connection *gc; | |
278 char *user; | |
279 char *friend; | |
280 }; | |
281 | |
3730 | 282 static void msn_accept_add(struct msn_add_permit *map) |
2086 | 283 { |
4249 | 284 if(g_slist_find(connections, map->gc)) { |
285 struct msn_data *md = map->gc->proto_data; | |
286 char buf[MSN_BUF_LEN]; | |
287 | |
4270 | 288 g_snprintf(buf, sizeof(buf), "ADD %u AL %s %s\r\n", ++md->trId, map->user, url_encode(map->friend)); |
4249 | 289 |
290 if (msn_write(md->fd, buf, strlen(buf)) < 0) { | |
291 hide_login_progress(map->gc, _("Write error")); | |
292 signoff(map->gc); | |
293 return; | |
294 } | |
4491 | 295 gaim_privacy_permit_add(map->gc->account, map->user); |
4249 | 296 build_allow_list(); /* er. right. we'll need to have a thing for this in CUI too */ |
297 show_got_added(map->gc, NULL, map->user, map->friend, NULL); | |
2086 | 298 } |
4249 | 299 |
3730 | 300 g_free(map->user); |
301 g_free(map->friend); | |
302 g_free(map); | |
2086 | 303 } |
304 | |
3730 | 305 static void msn_cancel_add(struct msn_add_permit *map) |
2086 | 306 { |
4249 | 307 if(g_slist_find(connections, map->gc)) { |
308 struct msn_data *md = map->gc->proto_data; | |
309 char buf[MSN_BUF_LEN]; | |
310 | |
4270 | 311 g_snprintf(buf, sizeof(buf), "ADD %u BL %s %s\r\n", ++md->trId, map->user, url_encode(map->friend)); |
4249 | 312 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
313 hide_login_progress(map->gc, _("Write error")); | |
314 signoff(map->gc); | |
315 return; | |
316 } | |
4491 | 317 gaim_privacy_deny_add(map->gc->account, map->user); |
4249 | 318 build_block_list(); |
3118 | 319 } |
4249 | 320 |
2086 | 321 g_free(map->user); |
322 g_free(map->friend); | |
323 g_free(map); | |
324 } | |
325 | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
326 static int msn_process_main(struct gaim_connection *gc, char *buf) |
2086 | 327 { |
328 struct msn_data *md = gc->proto_data; | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
329 char sendbuf[MSN_BUF_LEN]; |
2086 | 330 |
4793 | 331 if (!g_ascii_strncasecmp(buf, "ADD", 3)) { |
2086 | 332 char *list, *user, *friend, *tmp = buf; |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
333 struct msn_add_permit *ap; |
4491 | 334 GSList *perm = gc->account->permit; |
2086 | 335 char msg[MSN_BUF_LEN]; |
336 | |
337 GET_NEXT(tmp); | |
338 GET_NEXT(tmp); | |
339 list = tmp; | |
340 | |
341 GET_NEXT(tmp); | |
342 GET_NEXT(tmp); | |
343 user = tmp; | |
344 | |
345 GET_NEXT(tmp); | |
3323 | 346 friend = url_decode(tmp); |
2086 | 347 |
4793 | 348 if (g_ascii_strcasecmp(list, "RL")) |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
349 return 1; |
2086 | 350 |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
351 while (perm) { |
4793 | 352 if (!gaim_utf8_strcasecmp(perm->data, user)) |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
353 return 1; |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
354 perm = perm->next; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
355 } |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
356 |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
357 ap = g_new0(struct msn_add_permit, 1); |
2086 | 358 ap->user = g_strdup(user); |
3642 | 359 ap->friend = g_strdup(friend); |
2086 | 360 ap->gc = gc; |
361 | |
3299 | 362 g_snprintf(msg, sizeof(msg), _("The user %s (%s) wants to add %s to his or her buddy list."), |
3323 | 363 ap->user, ap->friend, ap->gc->username); |
2086 | 364 |
4687 | 365 // do_ask_dialog(msg, NULL, ap, _("Authorize"), msn_accept_add, _("Deny"), msn_cancel_add, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); |
4793 | 366 } else if (!g_ascii_strncasecmp(buf, "BLP", 3)) { |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
367 char *type, *tmp = buf; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
368 |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
369 GET_NEXT(tmp); |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
370 GET_NEXT(tmp); |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
371 GET_NEXT(tmp); |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
372 type = tmp; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
373 |
4793 | 374 if (!g_ascii_strcasecmp(type, "AL")) { |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
375 /* If the current setting is AL, messages |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
376 * from users who are not in BL will be delivered |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
377 * |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
378 * In other words, deny some */ |
4491 | 379 gc->account->permdeny = DENY_SOME; |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
380 } else { |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
381 /* If the current |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
382 * 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
|
383 * delivered. |
4349 | 384 * |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
385 * In other words, permit some */ |
4491 | 386 gc->account->permdeny = PERMIT_SOME; |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
387 } |
4793 | 388 } else if (!g_ascii_strncasecmp(buf, "BPR", 3)) { |
389 } else if (!g_ascii_strncasecmp(buf, "CHG", 3)) { | |
390 } else if (!g_ascii_strncasecmp(buf, "CHL", 3)) { | |
2086 | 391 char *hash = buf; |
392 char buf2[MSN_BUF_LEN]; | |
393 md5_state_t st; | |
394 md5_byte_t di[16]; | |
395 int i; | |
396 | |
397 GET_NEXT(hash); | |
398 GET_NEXT(hash); | |
399 | |
400 md5_init(&st); | |
401 md5_append(&st, (const md5_byte_t *)hash, strlen(hash)); | |
402 md5_append(&st, (const md5_byte_t *)"Q1P7W2E4J9R8U3S5", strlen("Q1P7W2E4J9R8U3S5")); | |
403 md5_finish(&st, di); | |
404 | |
4270 | 405 g_snprintf(sendbuf, sizeof(sendbuf), "QRY %u msmsgs@msnmsgr.com 32\r\n", ++md->trId); |
2086 | 406 for (i = 0; i < 16; i++) { |
407 g_snprintf(buf2, sizeof(buf2), "%02x", di[i]); | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
408 strcat(sendbuf, buf2); |
2086 | 409 } |
410 | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
411 if (msn_write(md->fd, sendbuf, strlen(sendbuf)) < 0) { |
4056 | 412 hide_login_progress(gc, _("Unable to write to server")); |
2086 | 413 signoff(gc); |
414 } | |
415 | |
416 debug_printf("\n"); | |
4793 | 417 } else if (!g_ascii_strncasecmp(buf, "FLN", 3)) { |
2086 | 418 char *usr = buf; |
419 | |
420 GET_NEXT(usr); | |
4732 | 421 serv_got_update(gc, usr, 0, 0, 0, 0, 0); |
4793 | 422 } else if (!g_ascii_strncasecmp(buf, "GTC", 3)) { |
423 } else if (!g_ascii_strncasecmp(buf, "INF", 3)) { | |
424 } else if (!g_ascii_strncasecmp(buf, "ILN", 3)) { | |
2607
e0d4a23aac89
[gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2603
diff
changeset
|
425 char *state, *user, *friend, *tmp = buf; |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
426 int status = 0; |
2086 | 427 |
428 GET_NEXT(tmp); | |
429 | |
430 GET_NEXT(tmp); | |
431 state = tmp; | |
432 | |
433 GET_NEXT(tmp); | |
434 user = tmp; | |
435 | |
436 GET_NEXT(tmp); | |
2607
e0d4a23aac89
[gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2603
diff
changeset
|
437 friend = url_decode(tmp); |
e0d4a23aac89
[gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2603
diff
changeset
|
438 |
4227 | 439 serv_got_alias(gc, user, friend); |
2086 | 440 |
4793 | 441 if (!g_ascii_strcasecmp(state, "BSY")) { |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
442 status |= UC_UNAVAILABLE | (MSN_BUSY << 1); |
4793 | 443 } else if (!g_ascii_strcasecmp(state, "IDL")) { |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
444 status |= UC_UNAVAILABLE | (MSN_IDLE << 1); |
4793 | 445 } else if (!g_ascii_strcasecmp(state, "BRB")) { |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
446 status |= UC_UNAVAILABLE | (MSN_BRB << 1); |
4793 | 447 } else if (!g_ascii_strcasecmp(state, "AWY")) { |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
448 status |= UC_UNAVAILABLE | (MSN_AWAY << 1); |
4793 | 449 } else if (!g_ascii_strcasecmp(state, "PHN")) { |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
450 status |= UC_UNAVAILABLE | (MSN_PHONE << 1); |
4793 | 451 } else if (!g_ascii_strcasecmp(state, "LUN")) { |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
452 status |= UC_UNAVAILABLE | (MSN_LUNCH << 1); |
2086 | 453 } |
454 | |
4732 | 455 serv_got_update(gc, user, 1, 0, 0, 0, status); |
4793 | 456 } else if (!g_ascii_strncasecmp(buf, "LST", 3)) { |
2086 | 457 char *which, *who, *friend, *tmp = buf; |
3012 | 458 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! */ |
4491 | 459 GSList *perm = gc->account->permit; /* current permit list */ |
460 GSList *denyl = gc->account->deny; | |
3012 | 461 char msg[MSN_BUF_LEN]; |
462 int new = 1; | |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
463 int pos, tot; |
2086 | 464 |
465 GET_NEXT(tmp); | |
466 GET_NEXT(tmp); | |
467 which = tmp; | |
468 | |
469 GET_NEXT(tmp); | |
470 GET_NEXT(tmp); | |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
471 pos = strtol(tmp, NULL, 10); |
2086 | 472 GET_NEXT(tmp); |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
473 tot = strtol(tmp, NULL, 10); |
2086 | 474 GET_NEXT(tmp); |
475 who = tmp; | |
476 | |
477 GET_NEXT(tmp); | |
478 friend = url_decode(tmp); | |
479 | |
4793 | 480 if (!g_ascii_strcasecmp(which, "FL") && pos) { |
2086 | 481 struct msn_buddy *b = g_new0(struct msn_buddy, 1); |
482 b->user = g_strdup(who); | |
3642 | 483 b->friend = g_strdup(friend); |
2086 | 484 md->fl = g_slist_append(md->fl, b); |
4793 | 485 } else if (!g_ascii_strcasecmp(which, "AL") && pos) { |
4491 | 486 if (g_slist_find_custom(gc->account->deny, who, |
4349 | 487 (GCompareFunc)strcmp)) { |
3294 | 488 debug_printf("moving from deny to permit: %s", who); |
4491 | 489 gaim_privacy_deny_remove(gc->account, who); |
3294 | 490 } |
4491 | 491 gaim_privacy_permit_add(gc->account, who); |
4793 | 492 } else if (!g_ascii_strcasecmp(which, "BL") && pos) { |
4491 | 493 gaim_privacy_deny_add(gc->account, who); |
4793 | 494 } else if (!g_ascii_strcasecmp(which, "RL")) { |
3121 | 495 if (pos) { |
3012 | 496 while(perm) { |
4793 | 497 if(!g_ascii_strcasecmp(perm->data, who)) |
3012 | 498 new = 0; |
499 perm = perm->next; | |
500 } | |
3018 | 501 while(denyl) { |
4793 | 502 if(!g_ascii_strcasecmp(denyl->data, who)) |
3018 | 503 new = 0; |
504 denyl = denyl->next; | |
505 } | |
3012 | 506 if(new) { |
3013 | 507 debug_printf("Unresolved MSN RL entry\n"); |
3012 | 508 ap = g_new0(struct msn_add_permit, 1); |
509 ap->user = g_strdup(who); | |
3642 | 510 ap->friend = g_strdup(friend); |
3012 | 511 ap->gc = gc; |
512 | |
4249 | 513 g_snprintf(msg, sizeof(msg), _("The user %s (%s) wants to add you to their buddy list"),ap->user, ap->friend); |
514 do_ask_dialog(msg, NULL, ap, _("Authorize"), msn_accept_add, _("Deny"), msn_cancel_add, my_protocol->plug ? my_protocol->plug->handle : NULL, FALSE); | |
3012 | 515 } |
3121 | 516 } |
3012 | 517 |
518 if (pos != tot) | |
519 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
|
520 |
4270 | 521 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
|
522 if (msn_write(md->fd, sendbuf, strlen(sendbuf)) < 0) { |
4056 | 523 hide_login_progress(gc, _("Unable to write")); |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
524 signoff(gc); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
525 return 0; |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
526 } |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
527 |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
528 account_online(gc); |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
529 serv_finish_login(gc); |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
530 |
4491 | 531 md->permit = g_slist_copy(gc->account->permit); |
532 md->deny = g_slist_copy(gc->account->deny); | |
4349 | 533 |
2086 | 534 while (md->fl) { |
535 struct msn_buddy *mb = md->fl->data; | |
4687 | 536 struct buddy *b = gaim_find_buddy(gc->account, mb->user); |
2086 | 537 md->fl = g_slist_remove(md->fl, mb); |
4687 | 538 if(!b) { |
539 struct group *g; | |
540 printf("I'm adding %s now..\n", mb->user); | |
541 if (!(g = gaim_find_group(_("Buddies")))) { | |
4690 | 542 printf("How could I not exitst!?!\n"); |
4687 | 543 g = gaim_group_new(_("Buddies")); |
544 gaim_blist_add_group(g, NULL); | |
545 } | |
546 b = gaim_buddy_new(gc->account, mb->user, NULL); | |
547 gaim_blist_add_buddy(b,g,NULL); | |
548 } | |
4227 | 549 serv_got_alias(gc, mb->user, mb->friend); |
2086 | 550 g_free(mb->user); |
551 g_free(mb->friend); | |
552 g_free(mb); | |
553 } | |
554 } | |
4793 | 555 } else if (!g_ascii_strncasecmp(buf, "MSG", 3)) { |
2086 | 556 char *user, *tmp = buf; |
557 int length; | |
558 | |
559 GET_NEXT(tmp); | |
560 user = tmp; | |
561 | |
562 GET_NEXT(tmp); | |
563 | |
564 GET_NEXT(tmp); | |
565 length = atoi(tmp); | |
566 | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
567 md->msg = TRUE; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
568 md->msguser = g_strdup(user); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
569 md->msglen = length; |
4793 | 570 } else if (!g_ascii_strncasecmp(buf, "NLN", 3)) { |
2607
e0d4a23aac89
[gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2603
diff
changeset
|
571 char *state, *user, *friend, *tmp = buf; |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
572 int status = 0; |
2086 | 573 |
574 GET_NEXT(tmp); | |
575 state = tmp; | |
576 | |
577 GET_NEXT(tmp); | |
578 user = tmp; | |
579 | |
580 GET_NEXT(tmp); | |
2607
e0d4a23aac89
[gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2603
diff
changeset
|
581 friend = url_decode(tmp); |
e0d4a23aac89
[gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2603
diff
changeset
|
582 |
4227 | 583 serv_got_alias(gc, user, friend); |
2086 | 584 |
4793 | 585 if (!g_ascii_strcasecmp(state, "BSY")) { |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
586 status |= UC_UNAVAILABLE | (MSN_BUSY << 1); |
4793 | 587 } else if (!g_ascii_strcasecmp(state, "IDL")) { |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
588 status |= UC_UNAVAILABLE | (MSN_IDLE << 1); |
4793 | 589 } else if (!g_ascii_strcasecmp(state, "BRB")) { |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
590 status |= UC_UNAVAILABLE | (MSN_BRB << 1); |
4793 | 591 } else if (!g_ascii_strcasecmp(state, "AWY")) { |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
592 status |= UC_UNAVAILABLE | (MSN_AWAY << 1); |
4793 | 593 } else if (!g_ascii_strcasecmp(state, "PHN")) { |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
594 status |= UC_UNAVAILABLE | (MSN_PHONE << 1); |
4793 | 595 } else if (!g_ascii_strcasecmp(state, "LUN")) { |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
596 status |= UC_UNAVAILABLE | (MSN_LUNCH << 1); |
2086 | 597 } |
598 | |
4732 | 599 serv_got_update(gc, user, 1, 0, 0, 0, status); |
4793 | 600 } else if (!g_ascii_strncasecmp(buf, "OUT", 3)) { |
2887 | 601 char *tmp = buf; |
602 | |
603 GET_NEXT(tmp); | |
4793 | 604 if (!g_ascii_strncasecmp(tmp, "OTH", 3)) { |
2889
fccda160c078
[gaim-migrate @ 2902]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2888
diff
changeset
|
605 hide_login_progress(gc, _("You have been disconnected. You have " |
fccda160c078
[gaim-migrate @ 2902]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2888
diff
changeset
|
606 "signed on from another location.")); |
fccda160c078
[gaim-migrate @ 2902]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2888
diff
changeset
|
607 signoff(gc); |
fccda160c078
[gaim-migrate @ 2902]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2888
diff
changeset
|
608 return 0; |
2887 | 609 } |
4793 | 610 } else if (!g_ascii_strncasecmp(buf, "PRP", 3)) { |
611 } else if (!g_ascii_strncasecmp(buf, "QNG", 3)) { | |
612 } else if (!g_ascii_strncasecmp(buf, "QRY", 3)) { | |
613 } else if (!g_ascii_strncasecmp(buf, "REA", 3)) { | |
2213
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
614 char *friend, *tmp = buf; |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
615 |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
616 GET_NEXT(tmp); |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
617 GET_NEXT(tmp); |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
618 GET_NEXT(tmp); |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
619 GET_NEXT(tmp); |
3456 | 620 |
621 friend = url_decode(tmp); | |
2213
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
622 |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
623 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", friend); |
4793 | 624 } else if (!g_ascii_strncasecmp(buf, "REM", 3)) { |
625 } else if (!g_ascii_strncasecmp(buf, "RNG", 3)) { | |
2086 | 626 struct msn_switchboard *ms; |
627 char *sessid, *ssaddr, *auth, *user; | |
628 int port, i = 0; | |
629 char *tmp = buf; | |
630 | |
631 GET_NEXT(tmp); | |
632 sessid = tmp; | |
633 | |
634 GET_NEXT(tmp); | |
635 ssaddr = tmp; | |
636 | |
637 GET_NEXT(tmp); | |
638 | |
639 GET_NEXT(tmp); | |
640 auth = tmp; | |
641 | |
642 GET_NEXT(tmp); | |
643 user = tmp; | |
644 GET_NEXT(tmp); | |
645 | |
646 while (ssaddr[i] && ssaddr[i] != ':') i++; | |
647 if (ssaddr[i] == ':') { | |
648 char *x = &ssaddr[i + 1]; | |
649 ssaddr[i] = 0; | |
650 port = atoi(x); | |
651 } else | |
652 port = 1863; | |
653 | |
654 ms = g_new0(struct msn_switchboard, 1); | |
4634 | 655 if (proxy_connect(gc->account, ssaddr, port, msn_rng_connect, ms) != 0) { |
2688
98b1ac8ddea3
[gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
656 g_free(ms); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
657 return 1; |
2688
98b1ac8ddea3
[gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
658 } |
2086 | 659 ms->user = g_strdup(user); |
660 ms->sessid = g_strdup(sessid); | |
661 ms->auth = g_strdup(auth); | |
662 ms->gc = gc; | |
4793 | 663 } else if (!g_ascii_strncasecmp(buf, "URL", 3)) { |
3171 | 664 char *tmp = buf; |
665 FILE *fd; | |
666 md5_state_t st; | |
667 md5_byte_t di[16]; | |
668 int i; | |
669 char buf2[64]; | |
670 char sendbuf[64]; | |
671 char hippy[2048]; | |
672 char *rru; | |
673 char *passport; | |
674 | |
675 GET_NEXT(tmp); | |
676 GET_NEXT(tmp); | |
677 rru = tmp; | |
678 GET_NEXT(tmp); | |
679 passport = tmp; | |
680 | |
3630 | 681 g_snprintf(hippy, sizeof(hippy), "%s%lu%s", md->mspauth, time(NULL) - md->sl, gc->password); |
3171 | 682 |
683 md5_init(&st); | |
684 md5_append(&st, (const md5_byte_t *)hippy, strlen(hippy)); | |
685 md5_finish(&st, di); | |
686 | |
687 bzero(sendbuf, sizeof(sendbuf)); | |
688 for (i = 0; i < 16; i++) { | |
689 g_snprintf(buf2, sizeof(buf2), "%02x", di[i]); | |
690 strcat(sendbuf, buf2); | |
691 } | |
692 | |
3195 | 693 if (md->passport) { |
694 unlink(md->passport); | |
3231 | 695 g_free(md->passport); |
3195 | 696 } |
3171 | 697 |
3630 | 698 if( (fd = gaim_mkstemp(&(md->passport))) == NULL ) { |
4270 | 699 debug_printf("Error opening temp file: %s\n", strerror(errno)); |
3630 | 700 } |
701 else { | |
4270 | 702 fputs("<html>\n" |
703 "<head>\n" | |
704 "<noscript>\n" | |
705 "<meta http-equiv=Refresh content=\"0; url=http://www.hotmail.com\">\n" | |
706 "</noscript>\n" | |
707 "</head>\n\n", fd); | |
3171 | 708 |
3630 | 709 fprintf(fd, "<body onload=\"document.pform.submit(); \">\n"); |
710 fprintf(fd, "<form name=\"pform\" action=\"%s\" method=\"POST\">\n\n", passport); | |
711 fprintf(fd, "<input type=\"hidden\" name=\"mode\" value=\"ttl\">\n"); | |
712 fprintf(fd, "<input type=\"hidden\" name=\"login\" value=\"%s\">\n", gc->username); | |
713 fprintf(fd, "<input type=\"hidden\" name=\"username\" value=\"%s\">\n", gc->username); | |
714 fprintf(fd, "<input type=\"hidden\" name=\"sid\" value=\"%s\">\n", md->sid); | |
715 fprintf(fd, "<input type=\"hidden\" name=\"kv\" value=\"%s\">\n", md->kv); | |
716 fprintf(fd, "<input type=\"hidden\" name=\"id\" value=\"2\">\n"); | |
717 fprintf(fd, "<input type=\"hidden\" name=\"sl\" value=\"%ld\">\n", time(NULL) - md->sl); | |
718 fprintf(fd, "<input type=\"hidden\" name=\"rru\" value=\"%s\">\n", rru); | |
719 fprintf(fd, "<input type=\"hidden\" name=\"auth\" value=\"%s\">\n", md->mspauth); | |
720 fprintf(fd, "<input type=\"hidden\" name=\"creds\" value=\"%s\">\n", sendbuf); // Digest me | |
721 fprintf(fd, "<input type=\"hidden\" name=\"svc\" value=\"mail\">\n"); | |
722 fprintf(fd, "<input type=\"hidden\" name=\"js\" value=\"yes\">\n"); | |
723 fprintf(fd, "</form></body>\n"); | |
724 fprintf(fd, "</html>\n"); | |
4270 | 725 if (fclose(fd)) { |
726 debug_printf("Error closing temp file: %s\n", strerror(errno)); | |
727 unlink(md->passport); | |
728 g_free(md->passport); | |
729 } | |
4462
ff6c275a57d4
[gaim-migrate @ 4737]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4460
diff
changeset
|
730 else { |
4464
e926d3bdfd14
[gaim-migrate @ 4739]
Christian Hammond <chipx86@chipx86.com>
parents:
4463
diff
changeset
|
731 /* |
e926d3bdfd14
[gaim-migrate @ 4739]
Christian Hammond <chipx86@chipx86.com>
parents:
4463
diff
changeset
|
732 * Renaming file with .html extension, so that |
e926d3bdfd14
[gaim-migrate @ 4739]
Christian Hammond <chipx86@chipx86.com>
parents:
4463
diff
changeset
|
733 * win32 open_url will work. |
e926d3bdfd14
[gaim-migrate @ 4739]
Christian Hammond <chipx86@chipx86.com>
parents:
4463
diff
changeset
|
734 */ |
e926d3bdfd14
[gaim-migrate @ 4739]
Christian Hammond <chipx86@chipx86.com>
parents:
4463
diff
changeset
|
735 char *tmp; |
e926d3bdfd14
[gaim-migrate @ 4739]
Christian Hammond <chipx86@chipx86.com>
parents:
4463
diff
changeset
|
736 if ((tmp = g_strdup_printf("%s.html", md->passport)) != NULL) { |
e926d3bdfd14
[gaim-migrate @ 4739]
Christian Hammond <chipx86@chipx86.com>
parents:
4463
diff
changeset
|
737 if (rename(md->passport, tmp) == 0) { |
4462
ff6c275a57d4
[gaim-migrate @ 4737]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4460
diff
changeset
|
738 g_free(md->passport); |
ff6c275a57d4
[gaim-migrate @ 4737]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4460
diff
changeset
|
739 md->passport = tmp; |
ff6c275a57d4
[gaim-migrate @ 4737]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4460
diff
changeset
|
740 } else |
ff6c275a57d4
[gaim-migrate @ 4737]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4460
diff
changeset
|
741 g_free(tmp); |
ff6c275a57d4
[gaim-migrate @ 4737]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4460
diff
changeset
|
742 } |
ff6c275a57d4
[gaim-migrate @ 4737]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4460
diff
changeset
|
743 } |
3630 | 744 } |
4793 | 745 } else if (!g_ascii_strncasecmp(buf, "SYN", 3)) { |
746 } else if (!g_ascii_strncasecmp(buf, "USR", 3)) { | |
747 } else if (!g_ascii_strncasecmp(buf, "XFR", 3)) { | |
2086 | 748 char *host = strstr(buf, "SB"); |
749 int port; | |
750 int i = 0; | |
751 gboolean switchboard = TRUE; | |
752 char *tmp; | |
753 | |
754 if (!host) { | |
755 host = strstr(buf, "NS"); | |
756 if (!host) { | |
4056 | 757 hide_login_progress(gc, _("Got invalid XFR\n")); |
2086 | 758 signoff(gc); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
759 return 0; |
2086 | 760 } |
761 switchboard = FALSE; | |
762 } | |
763 | |
764 GET_NEXT(host); | |
765 while (host[i] && host[i] != ':') i++; | |
766 if (host[i] == ':') { | |
767 tmp = &host[i + 1]; | |
768 host[i] = 0; | |
769 while (isdigit(*tmp)) tmp++; | |
770 *tmp++ = 0; | |
771 port = atoi(&host[i + 1]); | |
772 } else { | |
773 port = 1863; | |
774 tmp = host; | |
775 GET_NEXT(tmp); | |
776 } | |
777 | |
778 if (switchboard) { | |
4542
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
779 struct msn_switchboard *ms; |
2086 | 780 |
781 GET_NEXT(tmp); | |
782 | |
4542
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
783 ms = msn_switchboard_connect(gc, host, port); |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
784 |
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
785 if (ms == NULL) |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
786 return 1; |
4542
86b0a0243be8
[gaim-migrate @ 4821]
Christian Hammond <chipx86@chipx86.com>
parents:
4508
diff
changeset
|
787 |
2086 | 788 ms->auth = g_strdup(tmp); |
789 } else { | |
790 close(md->fd); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
791 gaim_input_remove(md->inpa); |
2086 | 792 md->inpa = 0; |
4634 | 793 if (proxy_connect(gc->account, host, port, msn_login_xfr_connect, gc) != 0) { |
4599 | 794 hide_login_progress(gc, _("Error transferring")); |
2688
98b1ac8ddea3
[gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
795 signoff(gc); |
2740
68ad186943e0
[gaim-migrate @ 2753]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2739
diff
changeset
|
796 return 0; |
2688
98b1ac8ddea3
[gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
797 } |
2086 | 798 } |
799 } else if (isdigit(*buf)) { | |
800 handle_errcode(buf, TRUE); | |
801 } else { | |
802 debug_printf("Unhandled message!\n"); | |
803 } | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
804 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
805 return 1; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
806 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
807 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
808 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
|
809 { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
810 struct msn_data *md = gc->proto_data; |
3642 | 811 char *skiphead; |
3171 | 812 char *content; |
813 | |
814 content = strstr(msg, "Content-Type: "); | |
815 | |
4793 | 816 if ((content) && (!g_ascii_strncasecmp(content, "Content-Type: text/x-msmsgsprofile", |
3171 | 817 strlen("Content-Type: text/x-msmsgsprofile")))) { |
818 | |
819 char *kv,*sid,*mspauth; | |
820 | |
821 kv = strstr(msg, "kv: "); | |
822 sid = strstr(msg, "sid: "); | |
823 mspauth = strstr(msg, "MSPAuth: "); | |
824 | |
825 if (kv) { | |
826 char *tmp; | |
827 | |
828 kv += strlen("kv: "); | |
829 tmp = strstr(kv, "\r\n"); *tmp = 0; | |
830 md->kv = g_strdup(kv); | |
831 } | |
832 | |
833 if (sid) { | |
834 char *tmp; | |
835 | |
836 sid += strlen("sid: "); | |
837 tmp = strstr(sid, "\r\n"); *tmp = 0; | |
838 md->sid = g_strdup(sid); | |
839 } | |
840 | |
841 if (mspauth) { | |
842 char *tmp; | |
843 | |
844 mspauth += strlen("MSPAuth: "); | |
845 tmp = strstr(mspauth, "\r\n"); *tmp = 0; | |
846 md->mspauth = g_strdup(mspauth); | |
847 } | |
848 | |
849 } | |
850 | |
851 | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
852 |
4793 | 853 if (!g_ascii_strcasecmp(md->msguser, "hotmail")) { |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
854 handle_hotmail(gc, msg); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
855 return; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
856 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
857 |
3171 | 858 |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
859 skiphead = strstr(msg, "\r\n\r\n"); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
860 if (!skiphead || !skiphead[4]) |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
861 return; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
862 skiphead += 4; |
3642 | 863 strip_linefeed(skiphead); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
864 |
3642 | 865 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
|
866 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
867 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
868 static void msn_callback(gpointer data, gint source, GaimInputCondition cond) |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
869 { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
870 struct gaim_connection *gc = data; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
871 struct msn_data *md = gc->proto_data; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
872 char buf[MSN_BUF_LEN]; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
873 int cont = 1; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
874 int len; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
875 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
876 len = read(md->fd, buf, sizeof(buf)); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
877 if (len <= 0) { |
3263 | 878 hide_login_progress_error(gc, _("Error reading from server")); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
879 signoff(gc); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
880 return; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
881 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
882 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
883 md->rxqueue = g_realloc(md->rxqueue, len + md->rxlen); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
884 memcpy(md->rxqueue + md->rxlen, buf, len); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
885 md->rxlen += len; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
886 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
887 while (cont) { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
888 if (!md->rxlen) |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
889 return; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
890 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
891 if (md->msg) { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
892 char *msg; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
893 if (md->msglen > md->rxlen) |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
894 return; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
895 msg = md->rxqueue; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
896 md->rxlen -= md->msglen; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
897 if (md->rxlen) { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
898 md->rxqueue = g_memdup(msg + md->msglen, md->rxlen); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
899 } else { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
900 md->rxqueue = NULL; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
901 msg = g_realloc(msg, md->msglen + 1); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
902 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
903 msg[md->msglen] = 0; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
904 md->msglen = 0; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
905 md->msg = FALSE; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
906 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
907 msn_process_main_msg(gc, msg); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
908 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
909 g_free(md->msguser); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
910 g_free(msg); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
911 } else { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
912 char *end = md->rxqueue; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
913 int cmdlen; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
914 char *cmd; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
915 int i = 0; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
916 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
917 while (i + 1 < md->rxlen) { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
918 if (*end == '\r' && end[1] == '\n') |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
919 break; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
920 end++; i++; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
921 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
922 if (i + 1 == md->rxlen) |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
923 return; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
924 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
925 cmdlen = end - md->rxqueue + 2; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
926 cmd = md->rxqueue; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
927 md->rxlen -= cmdlen; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
928 if (md->rxlen) { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
929 md->rxqueue = g_memdup(cmd + cmdlen, md->rxlen); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
930 } else { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
931 md->rxqueue = NULL; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
932 cmd = g_realloc(cmd, cmdlen + 1); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
933 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
934 cmd[cmdlen] = 0; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
935 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
936 debug_printf("MSN S: %s", cmd); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
937 g_strchomp(cmd); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
938 cont = msn_process_main(gc, cmd); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
939 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
940 g_free(cmd); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
941 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
942 } |
2086 | 943 } |
944 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
945 static void msn_login_xfr_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 946 { |
947 struct gaim_connection *gc = data; | |
948 struct msn_data *md; | |
949 char buf[MSN_BUF_LEN]; | |
950 | |
2210
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
951 if (!g_slist_find(connections, gc)) { |
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
952 close(source); |
2086 | 953 return; |
2210
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
954 } |
2086 | 955 |
956 md = gc->proto_data; | |
957 | |
958 if (md->fd != source) | |
959 md->fd = source; | |
960 | |
961 if (md->fd == -1) { | |
4056 | 962 hide_login_progress(gc, _("Unable to connect to Notification Server")); |
2086 | 963 signoff(gc); |
964 return; | |
965 } | |
966 | |
4270 | 967 g_snprintf(buf, sizeof(buf), "VER %u MSNP5\r\n", ++md->trId); |
2086 | 968 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 969 hide_login_progress(gc, _("Unable to talk to Notification Server")); |
2086 | 970 signoff(gc); |
971 return; | |
972 } | |
973 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
974 md->inpa = gaim_input_add(md->fd, GAIM_INPUT_READ, msn_login_callback, gc); |
2086 | 975 } |
976 | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
977 static int msn_process_login(struct gaim_connection *gc, char *buf) |
2086 | 978 { |
979 struct msn_data *md = gc->proto_data; | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
980 char sendbuf[MSN_BUF_LEN]; |
2086 | 981 |
4793 | 982 if (!g_ascii_strncasecmp(buf, "VER", 3)) { |
2226
2a09a177ed5f
[gaim-migrate @ 2236]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2219
diff
changeset
|
983 /* 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
|
984 if (!strstr(buf, "MSNP5")) { |
4056 | 985 hide_login_progress(gc, _("Protocol not supported")); |
2086 | 986 signoff(gc); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
987 return 0; |
2086 | 988 } |
989 | |
4270 | 990 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
|
991 if (msn_write(md->fd, sendbuf, strlen(sendbuf)) < 0) { |
4056 | 992 hide_login_progress(gc, _("Unable to request INF\n")); |
2086 | 993 signoff(gc); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
994 return 0; |
2086 | 995 } |
4793 | 996 } else if (!g_ascii_strncasecmp(buf, "INF", 3)) { |
2086 | 997 /* check to make sure we can use md5 */ |
998 if (!strstr(buf, "MD5")) { | |
4056 | 999 hide_login_progress(gc, _("Unable to login using MD5")); |
2086 | 1000 signoff(gc); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1001 return 0; |
2086 | 1002 } |
1003 | |
4270 | 1004 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
|
1005 if (msn_write(md->fd, sendbuf, strlen(sendbuf)) < 0) { |
4056 | 1006 hide_login_progress(gc, _("Unable to send USR\n")); |
2086 | 1007 signoff(gc); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1008 return 0; |
2086 | 1009 } |
1010 | |
3263 | 1011 set_login_progress(gc, 3, _("Requesting to send password")); |
4793 | 1012 } else if (!g_ascii_strncasecmp(buf, "USR", 3)) { |
2210
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1013 char *resp, *friend, *tmp = buf; |
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1014 |
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1015 GET_NEXT(tmp); |
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1016 GET_NEXT(tmp); |
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1017 resp = tmp; |
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1018 GET_NEXT(tmp); |
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1019 GET_NEXT(tmp); |
3323 | 1020 friend = url_decode(tmp); |
2213
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1021 GET_NEXT(tmp); |
2210
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1022 |
2086 | 1023 /* so here, we're either getting the challenge or the OK */ |
4793 | 1024 if (!g_ascii_strcasecmp(resp, "OK")) { |
2210
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1025 g_snprintf(gc->displayname, sizeof(gc->displayname), "%s", friend); |
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1026 |
4270 | 1027 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
|
1028 if (msn_write(md->fd, sendbuf, strlen(sendbuf)) < 0) { |
4056 | 1029 hide_login_progress(gc, _("Unable to write")); |
2086 | 1030 signoff(gc); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1031 return 0; |
2086 | 1032 } |
1033 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1034 gaim_input_remove(md->inpa); |
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1035 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
|
1036 return 0; |
4793 | 1037 } else if (!g_ascii_strcasecmp(resp, "MD5")) { |
2086 | 1038 char buf2[MSN_BUF_LEN]; |
1039 md5_state_t st; | |
1040 md5_byte_t di[16]; | |
1041 int i; | |
1042 | |
2213
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1043 g_snprintf(buf2, sizeof(buf2), "%s%s", friend, gc->password); |
2086 | 1044 |
1045 md5_init(&st); | |
1046 md5_append(&st, (const md5_byte_t *)buf2, strlen(buf2)); | |
1047 md5_finish(&st, di); | |
1048 | |
4270 | 1049 g_snprintf(sendbuf, sizeof(sendbuf), "USR %u MD5 S ", ++md->trId); |
2086 | 1050 for (i = 0; i < 16; i++) { |
1051 g_snprintf(buf2, sizeof(buf2), "%02x", di[i]); | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1052 strcat(sendbuf, buf2); |
2086 | 1053 } |
3321 | 1054 strcat(sendbuf, "\r\n"); |
2086 | 1055 |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1056 if (msn_write(md->fd, sendbuf, strlen(sendbuf)) < 0) { |
3263 | 1057 hide_login_progress(gc, _("Unable to send password")); |
2086 | 1058 signoff(gc); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1059 return 0; |
2086 | 1060 } |
1061 | |
3263 | 1062 set_login_progress(gc, 4, _("Password sent")); |
2086 | 1063 } |
4793 | 1064 } else if (!g_ascii_strncasecmp(buf, "XFR", 3)) { |
2086 | 1065 char *host = strstr(buf, "NS"); |
1066 int port; | |
1067 int i = 0; | |
1068 | |
1069 if (!host) { | |
4056 | 1070 hide_login_progress(gc, _("Got invalid XFR\n")); |
2086 | 1071 signoff(gc); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1072 return 0; |
2086 | 1073 } |
1074 | |
1075 GET_NEXT(host); | |
1076 while (host[i] && host[i] != ':') i++; | |
1077 if (host[i] == ':') { | |
1078 char *x = &host[i + 1]; | |
1079 host[i] = 0; | |
1080 port = atoi(x); | |
1081 } else | |
1082 port = 1863; | |
1083 | |
1084 close(md->fd); | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1085 gaim_input_remove(md->inpa); |
2086 | 1086 md->inpa = 0; |
1087 md->fd = 0; | |
3171 | 1088 md->sl = time(NULL); |
4634 | 1089 if (proxy_connect(gc->account, host, port, msn_login_xfr_connect, gc) != 0) { |
4056 | 1090 hide_login_progress(gc, _("Unable to transfer")); |
2688
98b1ac8ddea3
[gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1091 signoff(gc); |
98b1ac8ddea3
[gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1092 } |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1093 return 0; |
2086 | 1094 } else { |
1095 if (isdigit(*buf)) | |
1096 hide_login_progress(gc, handle_errcode(buf, FALSE)); | |
1097 else | |
4056 | 1098 hide_login_progress(gc, _("Unable to parse message")); |
2086 | 1099 signoff(gc); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1100 return 0; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1101 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1102 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1103 return 1; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1104 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1105 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1106 static void msn_login_callback(gpointer data, gint source, GaimInputCondition cond) |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1107 { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1108 struct gaim_connection *gc = data; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1109 struct msn_data *md = gc->proto_data; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1110 char buf[MSN_BUF_LEN]; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1111 int cont = 1; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1112 int len; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1113 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1114 len = read(md->fd, buf, sizeof(buf)); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1115 if (len <= 0) { |
3263 | 1116 hide_login_progress(gc, _("Error reading from server")); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1117 signoff(gc); |
2086 | 1118 return; |
1119 } | |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1120 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1121 md->rxqueue = g_realloc(md->rxqueue, len + md->rxlen); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1122 memcpy(md->rxqueue + md->rxlen, buf, len); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1123 md->rxlen += len; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1124 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1125 while (cont) { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1126 char *end = md->rxqueue; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1127 int cmdlen; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1128 char *cmd; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1129 int i = 0; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1130 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1131 if (!md->rxlen) |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1132 return; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1133 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1134 while (i + 1 < md->rxlen) { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1135 if (*end == '\r' && end[1] == '\n') |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1136 break; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1137 end++; i++; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1138 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1139 if (i + 1 == md->rxlen) |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1140 return; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1141 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1142 cmdlen = end - md->rxqueue + 2; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1143 cmd = md->rxqueue; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1144 md->rxlen -= cmdlen; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1145 if (md->rxlen) { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1146 md->rxqueue = g_memdup(cmd + cmdlen, md->rxlen); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1147 } else { |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1148 md->rxqueue = NULL; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1149 cmd = g_realloc(cmd, cmdlen + 1); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1150 } |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1151 cmd[cmdlen] = 0; |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1152 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1153 debug_printf("MSN S: %s", cmd); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1154 g_strchomp(cmd); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1155 cont = msn_process_login(gc, cmd); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1156 |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1157 g_free(cmd); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1158 } |
2086 | 1159 } |
1160 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1161 static void msn_login_connect(gpointer data, gint source, GaimInputCondition cond) |
2086 | 1162 { |
1163 struct gaim_connection *gc = data; | |
1164 struct msn_data *md; | |
1165 char buf[1024]; | |
1166 | |
2210
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1167 if (!g_slist_find(connections, gc)) { |
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1168 close(source); |
2086 | 1169 return; |
2210
3a6fd1e8f00a
[gaim-migrate @ 2220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1170 } |
2086 | 1171 |
1172 md = gc->proto_data; | |
1173 | |
1174 if (md->fd != source) | |
1175 md->fd = source; | |
1176 | |
1177 if (md->fd == -1) { | |
3263 | 1178 hide_login_progress(gc, _("Unable to connect")); |
2086 | 1179 signoff(gc); |
1180 return; | |
1181 } | |
1182 | |
4270 | 1183 g_snprintf(buf, sizeof(buf), "VER %u MSNP5\r\n", ++md->trId); |
2086 | 1184 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
3263 | 1185 hide_login_progress(gc, _("Unable to write to server")); |
2086 | 1186 signoff(gc); |
1187 return; | |
1188 } | |
1189 | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1190 md->inpa = gaim_input_add(md->fd, GAIM_INPUT_READ, msn_login_callback, gc); |
3263 | 1191 set_login_progress(gc, 2,_("Synching with server")); |
2086 | 1192 } |
1193 | |
4491 | 1194 static void msn_login(struct gaim_account *account) |
2086 | 1195 { |
4491 | 1196 struct gaim_connection *gc = new_gaim_conn(account); |
4460 | 1197 gc->proto_data = g_new0(struct msn_data, 1); |
2086 | 1198 |
3263 | 1199 set_login_progress(gc, 1, _("Connecting")); |
2086 | 1200 |
1201 g_snprintf(gc->username, sizeof(gc->username), "%s", msn_normalize(gc->username)); | |
4455 | 1202 |
4634 | 1203 if (proxy_connect(account, account->proto_opt[USEROPT_MSNSERVER][0] ? |
4491 | 1204 account->proto_opt[USEROPT_MSNSERVER] : MSN_SERVER, |
1205 account->proto_opt[USEROPT_MSNPORT][0] ? | |
1206 atoi(account->proto_opt[USEROPT_MSNPORT]) : MSN_PORT, | |
1207 msn_login_connect, gc) != 0) { | |
3263 | 1208 hide_login_progress(gc, _("Unable to connect")); |
2688
98b1ac8ddea3
[gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1209 signoff(gc); |
98b1ac8ddea3
[gaim-migrate @ 2701]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2681
diff
changeset
|
1210 } |
2086 | 1211 } |
1212 | |
1213 static void msn_close(struct gaim_connection *gc) | |
1214 { | |
1215 struct msn_data *md = gc->proto_data; | |
1216 close(md->fd); | |
1217 if (md->inpa) | |
2090
b66aca8e8dce
[gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2086
diff
changeset
|
1218 gaim_input_remove(md->inpa); |
2738
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1219 g_free(md->rxqueue); |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1220 if (md->msg) |
01f0497fe6c8
[gaim-migrate @ 2751]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2688
diff
changeset
|
1221 g_free(md->msguser); |
3195 | 1222 if (md->passport) { |
1223 unlink(md->passport); | |
3231 | 1224 g_free(md->passport); |
3195 | 1225 } |
2086 | 1226 while (md->switches) |
1227 msn_kill_switch(md->switches->data); | |
1228 while (md->fl) { | |
1229 struct msn_buddy *tmp = md->fl->data; | |
1230 md->fl = g_slist_remove(md->fl, tmp); | |
1231 g_free(tmp->user); | |
1232 g_free(tmp->friend); | |
1233 g_free(tmp); | |
1234 } | |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1235 g_slist_free(md->permit); |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1236 g_slist_free(md->deny); |
2086 | 1237 g_free(md); |
1238 } | |
1239 | |
3001 | 1240 static int msn_send_typing(struct gaim_connection *gc, char *who, int typing) { |
2993 | 1241 struct msn_switchboard *ms = msn_find_switch(gc, who); |
1242 char header[MSN_BUF_LEN] = "MIME-Version: 1.0\r\n" | |
1243 "Content-Type: text/x-msmsgscontrol\r\n" | |
1244 "TypingUser: "; | |
1245 char buf [MSN_BUF_LEN]; | |
3001 | 1246 if (!ms || !typing) |
1247 return 0; | |
4270 | 1248 g_snprintf(buf, sizeof(buf), "MSG %u N %d\r\n%s%s\r\n\r\n\r\n", |
2993 | 1249 ++ms->trId, |
1250 strlen(header) + strlen("\r\n\r\n\r\n") + strlen(gc->username), | |
1251 header, gc->username); | |
1252 if (msn_write(ms->fd, buf, strlen(buf)) < 0) | |
1253 msn_kill_switch(ms); | |
1254 return MSN_TYPING_SEND_TIMEOUT; | |
1255 } | |
1256 | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
1257 #if 0 |
4150 | 1258 static void msn_file_transfer_cancel(struct gaim_connection *gc, |
1259 struct file_transfer *xfer) | |
1260 { | |
1261 struct msn_data *md = gc->proto_data; | |
1262 struct msn_file_transfer *mft = find_mft_by_xfer(gc, xfer); | |
1263 struct msn_switchboard *ms = msn_find_switch(gc, mft->sn); | |
1264 char header[MSN_BUF_LEN]; | |
1265 char buf[MSN_BUF_LEN]; | |
1266 | |
1267 if (!ms || !mft) | |
1268 { | |
1269 debug_printf("Eep! Returning from msn_file_transfer_cancel early"); | |
1270 return; | |
1271 } | |
1272 | |
1273 g_snprintf(header, sizeof(header), | |
1274 "MIME-Version: 1.0\r\n" | |
1275 "Content-Type: text/x-msmsgsinvite; charset=UTF-8\r\n\r\n" | |
1276 "Invitation-Command: CANCEL\r\n" | |
4270 | 1277 "Invitation-Cookie: %lu\r\n" |
4150 | 1278 "Cancel-Code: REJECT\r\n", |
4270 | 1279 (unsigned long)mft->cookie); |
1280 | |
1281 g_snprintf(buf, sizeof(buf), "MSG %u N %d\r\n%s\r\n\r\n", | |
4150 | 1282 ++ms->trId, strlen(header) + strlen("\r\n\r\n"), |
1283 header); | |
1284 | |
1285 md->file_transfers = g_slist_remove(md->file_transfers, mft); | |
1286 | |
1287 if (msn_write(ms->fd, buf, strlen(buf)) < 0) | |
1288 { | |
1289 debug_printf("Uh oh! Killing switch.\n"); | |
1290 msn_kill_switch(ms); | |
1291 } | |
1292 } | |
1293 | |
1294 static void msn_file_transfer_in(struct gaim_connection *gc, | |
1295 struct file_transfer *xfer, int offset) | |
1296 { | |
1297 struct msn_file_transfer *mft = find_mft_by_xfer(gc, xfer); | |
1298 struct msn_switchboard *ms = msn_find_switch(gc, mft->sn); | |
1299 char header[MSN_BUF_LEN]; | |
1300 char buf[MSN_BUF_LEN]; | |
1301 | |
1302 if (!ms || !mft) | |
1303 { | |
1304 debug_printf("Eep! Returning from msn_file_transfer_in early"); | |
1305 return; | |
1306 } | |
1307 | |
1308 g_snprintf(header, sizeof(header), | |
1309 "MIME-Version: 1.0\r\n" | |
1310 "Content-Type: text/x-msmsgsinvite; charset=UTF-8\r\n\r\n" | |
1311 "Invitation-Command: ACCEPT\r\n" | |
4270 | 1312 "Invitation-Cookie: %lu\r\n" |
4150 | 1313 "Launch-Application: FALSE\r\n" |
1314 "Request-Data: IP-Address:\r\n", | |
4270 | 1315 (unsigned long)mft->cookie); |
1316 | |
1317 g_snprintf(buf, sizeof(buf), "MSG %u N %d\r\n%s\r\n\r\n", | |
4150 | 1318 ++ms->trId, strlen(header) + strlen("\r\n\r\n"), |
1319 header); | |
1320 | |
1321 if (msn_write(ms->fd, buf, strlen(buf)) < 0) { | |
1322 msn_kill_switch(ms); | |
1323 return; | |
1324 } | |
1325 | |
1326 mft->xfer = xfer; | |
1327 } | |
1328 | |
1329 static void msn_file_transfer_out(struct gaim_connection *gc, | |
1330 struct file_transfer *xfer, | |
1331 const char *name, int totfiles, int totsize) | |
1332 { | |
1333 struct msn_file_transfer *mft = find_mft_by_xfer(gc, xfer); | |
1334 struct msn_switchboard *ms = msn_find_switch(gc, mft->sn); | |
1335 char header[MSN_BUF_LEN]; | |
1336 char buf[MSN_BUF_LEN]; | |
1337 struct stat sb; | |
1338 | |
1339 if (!ms) | |
1340 return; | |
1341 | |
1342 if (totfiles > 1) | |
1343 return; | |
1344 | |
1345 if (stat(name, &sb) == -1) | |
1346 return; | |
1347 | |
5166 | 1348 mft->cookie = 1 + (guint32)(4294967295.0 * rand() / (RAND_MAX + 1.0)); |
4150 | 1349 |
1350 g_snprintf(header, sizeof(header), | |
1351 "MIME-Version: 1.0\r\n" | |
1352 "Content-Type: text/x-msmsgsinvite; charset=UTF-8\r\n" | |
1353 "Application-Name: File Transfer\r\n" | |
1354 "Application-GUID: {5D3E02AB-6190-11d3-BBBB-00C04F795683}\r\n" | |
1355 "Invitation-Command: INVITE\r\n" | |
4270 | 1356 "Invitation-Cookie: %lu\r\n" |
4150 | 1357 "Application-File: %s\r\n" |
1358 "Application-FileSize: %ld\r\n", | |
4270 | 1359 (unsigned long)mft->cookie, name, sb.st_size); |
1360 | |
1361 g_snprintf(buf, sizeof(buf), "MSG %u A %d\r\n%s\r\n\r\n", | |
4150 | 1362 ++ms->trId, |
1363 strlen(header) + strlen("\r\n\r\n"), | |
1364 header); | |
1365 | |
1366 if (msn_write(ms->fd, buf, strlen(buf)) < 0) | |
1367 msn_kill_switch(ms); | |
1368 | |
1369 debug_printf("\n"); | |
1370 } | |
1371 | |
1372 static void msn_file_transfer_done(struct gaim_connection *gc, | |
1373 struct file_transfer *xfer) | |
1374 { | |
1375 struct msn_data *md = (struct msn_data *)gc->proto_data; | |
1376 struct msn_file_transfer *mft = find_mft_by_xfer(gc, xfer); | |
1377 char buf[MSN_BUF_LEN]; | |
1378 | |
1379 g_snprintf(buf, sizeof(buf), "BYE 16777989\r\n"); | |
1380 | |
1381 msn_write(mft->fd, buf, strlen(buf)); | |
1382 | |
1383 md->file_transfers = g_slist_remove(md->file_transfers, mft); | |
1384 | |
1385 gaim_input_remove(mft->inpa); | |
1386 | |
1387 close(mft->fd); | |
1388 | |
1389 g_free(mft->filename); | |
1390 g_free(mft->sn); | |
1391 g_free(mft); | |
1392 } | |
1393 | |
1394 static size_t msn_file_transfer_read(struct gaim_connection *gc, | |
1395 struct file_transfer *xfer, int fd, | |
1396 char **buf) | |
1397 { | |
1398 unsigned char header[3]; | |
1399 size_t len, size; | |
1400 | |
1401 if (read(fd, header, sizeof(header)) < 3) | |
1402 return 0; | |
1403 | |
1404 if (header[0] != 0) { | |
1405 debug_printf("Invalid header[0]: %d. Aborting.\n", header[0]); | |
1406 return 0; | |
1407 } | |
1408 | |
1409 size = header[1] | (header[2] << 8); | |
1410 | |
1411 *buf = g_new0(char, size); | |
1412 | |
1413 for (len = 0; len < size; len += read(fd, *buf + len, size - len)); | |
1414 | |
1415 return len; | |
1416 } | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
1417 #endif |
4150 | 1418 |
5136 | 1419 static int msn_send_im(struct gaim_connection *gc, const char *who, const char *message, int len, int flags) |
2086 | 1420 { |
1421 struct msn_data *md = gc->proto_data; | |
1422 struct msn_switchboard *ms = msn_find_switch(gc, who); | |
1423 char buf[MSN_BUF_LEN]; | |
1424 | |
1425 if (ms) { | |
3642 | 1426 char *send; |
2591
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
1427 |
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
1428 if (ms->txqueue) { |
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
1429 debug_printf("appending to queue\n"); |
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
1430 ms->txqueue = g_slist_append(ms->txqueue, g_strdup(message)); |
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
1431 return 1; |
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
1432 } |
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
1433 |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2600
diff
changeset
|
1434 send = add_cr(message); |
4270 | 1435 g_snprintf(buf, sizeof(buf), "MSG %u N %d\r\n%s%s", ++ms->trId, |
3642 | 1436 strlen(MIME_HEADER) + strlen(send), |
1437 MIME_HEADER, send); | |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2600
diff
changeset
|
1438 g_free(send); |
2086 | 1439 if (msn_write(ms->fd, buf, strlen(buf)) < 0) |
1440 msn_kill_switch(ms); | |
1441 debug_printf("\n"); | |
1442 } else if (strcmp(who, gc->username)) { | |
4270 | 1443 g_snprintf(buf, MSN_BUF_LEN, "XFR %u SB\r\n", ++md->trId); |
2086 | 1444 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 1445 hide_login_progress(gc, _("Write error")); |
2086 | 1446 signoff(gc); |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
1447 return 1; |
2086 | 1448 } |
1449 | |
1450 ms = g_new0(struct msn_switchboard, 1); | |
1451 md->switches = g_slist_append(md->switches, ms); | |
1452 ms->user = g_strdup(who); | |
2591
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
1453 ms->txqueue = g_slist_append(ms->txqueue, g_strdup(message)); |
2086 | 1454 ms->gc = gc; |
1455 ms->fd = -1; | |
1456 } else | |
1457 /* 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
|
1458 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
|
1459 return 1; |
2086 | 1460 } |
1461 | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1462 static int msn_chat_send(struct gaim_connection *gc, int id, char *message) |
2086 | 1463 { |
1464 struct msn_switchboard *ms = msn_find_switch_by_id(gc, id); | |
1465 char buf[MSN_BUF_LEN]; | |
3642 | 1466 char *send; |
2086 | 1467 |
1468 if (!ms) | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1469 return -EINVAL; |
2086 | 1470 |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2600
diff
changeset
|
1471 send = add_cr(message); |
4270 | 1472 g_snprintf(buf, sizeof(buf), "MSG %u N %d\r\n%s%s", ++ms->trId, |
3642 | 1473 strlen(MIME_HEADER) + strlen(send), |
1474 MIME_HEADER, send); | |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2600
diff
changeset
|
1475 g_free(send); |
2591
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
1476 if (msn_write(ms->fd, buf, strlen(buf)) < 0) { |
2086 | 1477 msn_kill_switch(ms); |
2591
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
1478 return 0; |
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
1479 } |
2086 | 1480 debug_printf("\n"); |
1481 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
|
1482 return 0; |
2086 | 1483 } |
1484 | |
3466 | 1485 static void msn_chat_invite(struct gaim_connection *gc, int id, const char *msg, const char *who) |
2086 | 1486 { |
1487 struct msn_switchboard *ms = msn_find_switch_by_id(gc, id); | |
1488 char buf[MSN_BUF_LEN]; | |
1489 | |
1490 if (!ms) | |
1491 return; | |
1492 | |
4270 | 1493 g_snprintf(buf, sizeof(buf), "CAL %u %s\r\n", ++ms->trId, who); |
2086 | 1494 if (msn_write(ms->fd, buf, strlen(buf)) < 0) |
1495 msn_kill_switch(ms); | |
1496 } | |
1497 | |
1498 static void msn_chat_leave(struct gaim_connection *gc, int id) | |
1499 { | |
1500 struct msn_switchboard *ms = msn_find_switch_by_id(gc, id); | |
1501 char buf[MSN_BUF_LEN]; | |
1502 | |
1503 if (!ms) | |
1504 return; | |
1505 | |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2600
diff
changeset
|
1506 g_snprintf(buf, sizeof(buf), "OUT\r\n"); |
2086 | 1507 if (msn_write(ms->fd, buf, strlen(buf)) < 0) |
1508 msn_kill_switch(ms); | |
1509 } | |
1510 | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
1511 static GList *msn_away_states(struct gaim_connection *gc) |
2086 | 1512 { |
1513 GList *m = NULL; | |
1514 | |
3263 | 1515 m = g_list_append(m, _("Available")); |
1516 m = g_list_append(m, _("Away From Computer")); | |
1517 m = g_list_append(m, _("Be Right Back")); | |
1518 m = g_list_append(m, _("Busy")); | |
1519 m = g_list_append(m, _("On The Phone")); | |
1520 m = g_list_append(m, _("Out To Lunch")); | |
1521 m = g_list_append(m, _("Hidden")); | |
2086 | 1522 |
1523 return m; | |
1524 } | |
1525 | |
1526 static void msn_set_away(struct gaim_connection *gc, char *state, char *msg) | |
1527 { | |
1528 struct msn_data *md = gc->proto_data; | |
1529 char buf[MSN_BUF_LEN]; | |
4270 | 1530 const char *away; |
2086 | 1531 |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4069
diff
changeset
|
1532 if (gc->away) { |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4069
diff
changeset
|
1533 g_free(gc->away); |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4069
diff
changeset
|
1534 gc->away = NULL; |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4069
diff
changeset
|
1535 } |
2086 | 1536 |
1537 if (msg) { | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4069
diff
changeset
|
1538 gc->away = g_strdup(""); |
2086 | 1539 away = "AWY"; |
1540 } else if (state) { | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4069
diff
changeset
|
1541 gc->away = g_strdup(""); |
2086 | 1542 |
3538 | 1543 if (!strcmp(state, _("Away From Computer"))) |
2086 | 1544 away = "AWY"; |
3538 | 1545 else if (!strcmp(state, _("Be Right Back"))) |
2086 | 1546 away = "BRB"; |
3538 | 1547 else if (!strcmp(state, _("Busy"))) |
2086 | 1548 away = "BSY"; |
3538 | 1549 else if (!strcmp(state, _("On The Phone"))) |
2086 | 1550 away = "PHN"; |
3538 | 1551 else if (!strcmp(state, _("Out To Lunch"))) |
2086 | 1552 away = "LUN"; |
3538 | 1553 else if (!strcmp(state, _("Hidden"))) |
2152
f631cfc8e824
[gaim-migrate @ 2162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2123
diff
changeset
|
1554 away = "HDN"; |
2086 | 1555 else { |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
4069
diff
changeset
|
1556 g_free(gc->away); |
2086 | 1557 gc->away = NULL; |
1558 away = "NLN"; | |
1559 } | |
1560 } else if (gc->is_idle) | |
1561 away = "IDL"; | |
1562 else | |
1563 away = "NLN"; | |
1564 | |
4270 | 1565 g_snprintf(buf, sizeof(buf), "CHG %u %s\r\n", ++md->trId, away); |
2086 | 1566 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 1567 hide_login_progress(gc, _("Write error")); |
2086 | 1568 signoff(gc); |
1569 return; | |
1570 } | |
1571 } | |
1572 | |
1573 static void msn_set_idle(struct gaim_connection *gc, int idle) | |
1574 { | |
1575 struct msn_data *md = gc->proto_data; | |
4270 | 1576 char buf[64]; |
2086 | 1577 |
1578 if (gc->away) | |
1579 return; | |
4270 | 1580 g_snprintf(buf, sizeof(buf), |
1581 idle ? "CHG %d IDL\r\n" : "CHG %u NLN\r\n", ++md->trId); | |
2086 | 1582 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 1583 hide_login_progress(gc, _("Write error")); |
2086 | 1584 signoff(gc); |
1585 return; | |
1586 } | |
1587 } | |
1588 | |
4687 | 1589 static const char *msn_list_icon(struct gaim_account *a, struct buddy *b) |
2086 | 1590 { |
4687 | 1591 return "msn"; |
1592 } | |
4916 | 1593 |
1594 static void msn_list_emblems(struct buddy *b, char **se, char **sw, char **nw, char **ne) | |
1595 { | |
5068 | 1596 if (b->present == GAIM_BUDDY_OFFLINE) |
4916 | 1597 *se = "offline"; |
1598 else if (b->uc >> 1 == 2 || b->uc >> 1 == 6) | |
1599 *se = "occupied"; | |
5022 | 1600 else if (b->uc) |
1601 *se = "away"; | |
2086 | 1602 } |
4916 | 1603 |
2086 | 1604 static char *msn_get_away_text(int s) |
1605 { | |
1606 switch (s) { | |
1607 case MSN_BUSY : | |
4056 | 1608 return _("Busy"); |
2086 | 1609 case MSN_BRB : |
4606 | 1610 return _("Be Right Back"); |
2086 | 1611 case MSN_AWAY : |
4606 | 1612 return _("Away From Computer"); |
2086 | 1613 case MSN_PHONE : |
4606 | 1614 return _("On The Phone"); |
2086 | 1615 case MSN_LUNCH : |
4606 | 1616 return _("Out To Lunch"); |
2086 | 1617 case MSN_IDLE : |
4056 | 1618 return _("Idle"); |
2086 | 1619 default: |
4056 | 1620 return _("Available"); |
2086 | 1621 } |
1622 } | |
1623 | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
1624 #if 0 |
4150 | 1625 static void msn_ask_send_file(struct gaim_connection *gc, char *destsn) |
1626 { | |
1627 struct msn_data *md = (struct msn_data *)gc->proto_data; | |
1628 struct msn_file_transfer *mft = g_new0(struct msn_file_transfer, 1); | |
1629 | |
1630 mft->type = MFT_SENDFILE_OUT; | |
1631 mft->sn = g_strdup(destsn); | |
1632 mft->gc = gc; | |
1633 | |
1634 md->file_transfers = g_slist_append(md->file_transfers, mft); | |
1635 | |
1636 mft->xfer = transfer_out_add(gc, mft->sn); | |
1637 } | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
1638 #endif |
4732 | 1639 static char *msn_status_text(struct buddy *b) { |
4723 | 1640 if (b->uc & UC_UNAVAILABLE) |
4745 | 1641 return g_strdup(msn_get_away_text(b->uc >> 1)); |
4723 | 1642 return NULL; |
1643 } | |
4150 | 1644 |
4732 | 1645 static char *msn_tooltip_text(struct buddy *b) { |
5068 | 1646 if (GAIM_BUDDY_IS_ONLINE(b)) |
4920 | 1647 return g_strdup_printf(_("<b>Status:</b> %s"), msn_get_away_text(b->uc >> 1)); |
4921 | 1648 |
1649 return NULL; | |
4724 | 1650 } |
1651 | |
5136 | 1652 static GList *msn_buddy_menu(struct gaim_connection *gc, const char *who) |
2086 | 1653 { |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2169
diff
changeset
|
1654 GList *m = NULL; |
4729 | 1655 #if 0 |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2169
diff
changeset
|
1656 struct proto_buddy_menu *pbm; |
4687 | 1657 struct buddy *b = gaim_find_buddy(gc->account, who); |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2169
diff
changeset
|
1658 static char buf[MSN_BUF_LEN]; |
2086 | 1659 |
2607
e0d4a23aac89
[gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2603
diff
changeset
|
1660 pbm = g_new0(struct proto_buddy_menu, 1); |
4150 | 1661 pbm->label = _("Send File"); |
1662 pbm->callback = msn_ask_send_file; | |
1663 pbm->gc = gc; | |
1664 m = g_list_append(m, pbm); | |
1665 | |
2501
227cc42ffa6e
[gaim-migrate @ 2514]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2494
diff
changeset
|
1666 if (!b || !(b->uc >> 1)) |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2169
diff
changeset
|
1667 return m; |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
1668 #endif |
2086 | 1669 |
4723 | 1670 |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2169
diff
changeset
|
1671 |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2169
diff
changeset
|
1672 return m; |
2086 | 1673 } |
1674 | |
3466 | 1675 static void msn_add_buddy(struct gaim_connection *gc, const char *name) |
2086 | 1676 { |
1677 struct msn_data *md = gc->proto_data; | |
2588
a3117e29317d
[gaim-migrate @ 2601]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2582
diff
changeset
|
1678 char *who = msn_normalize(name); |
2086 | 1679 char buf[MSN_BUF_LEN]; |
1680 GSList *l = md->fl; | |
1681 | |
2600
8aade06646b5
[gaim-migrate @ 2613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
1682 if (who[0] == '@') |
8aade06646b5
[gaim-migrate @ 2613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
1683 /* how did this happen? */ |
8aade06646b5
[gaim-migrate @ 2613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
1684 return; |
8aade06646b5
[gaim-migrate @ 2613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2597
diff
changeset
|
1685 |
2953 | 1686 if (strchr(who, ' ')) |
2952 | 1687 /* This is a broken blist entry. */ |
1688 return; | |
1689 | |
2086 | 1690 while (l) { |
1691 struct msn_buddy *b = l->data; | |
4793 | 1692 if (!gaim_utf8_strcasecmp(who, b->user)) |
2086 | 1693 break; |
1694 l = l->next; | |
1695 } | |
1696 if (l) | |
1697 return; | |
1698 | |
4270 | 1699 g_snprintf(buf, sizeof(buf), "ADD %u FL %s %s\r\n", ++md->trId, who, who); |
2086 | 1700 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 1701 hide_login_progress(gc, _("Write error")); |
2086 | 1702 signoff(gc); |
1703 return; | |
1704 } | |
1705 } | |
1706 | |
2681
37d80035e77f
[gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2665
diff
changeset
|
1707 static void msn_rem_buddy(struct gaim_connection *gc, char *who, char *group) |
2086 | 1708 { |
1709 struct msn_data *md = gc->proto_data; | |
1710 char buf[MSN_BUF_LEN]; | |
1711 | |
4270 | 1712 g_snprintf(buf, sizeof(buf), "REM %u FL %s\r\n", ++md->trId, who); |
2086 | 1713 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 1714 hide_login_progress(gc, _("Write error")); |
2086 | 1715 signoff(gc); |
1716 return; | |
1717 } | |
1718 } | |
1719 | |
2213
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1720 static void msn_act_id(gpointer data, char *entry) |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1721 { |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1722 struct gaim_connection *gc = data; |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1723 struct msn_data *md = gc->proto_data; |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1724 char buf[MSN_BUF_LEN]; |
3323 | 1725 char *alias; |
2213
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1726 |
3466 | 1727 if (!entry || *entry == '\0') |
3448 | 1728 alias = g_strdup(""); |
1729 else | |
3642 | 1730 alias = g_strdup(entry); |
3323 | 1731 |
1732 if (strlen(alias) >= BUDDY_ALIAS_MAXLEN) { | |
3427 | 1733 do_error_dialog(_("New MSN friendly name too long."), NULL, GAIM_ERROR); |
3020 | 1734 return; |
1735 } | |
1736 | |
4270 | 1737 g_snprintf(buf, sizeof(buf), "REA %u %s %s\r\n", ++md->trId, gc->username, url_encode(alias)); |
3323 | 1738 g_free(alias); |
2213
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1739 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 1740 hide_login_progress(gc, _("Write error")); |
2213
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1741 signoff(gc); |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1742 return; |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1743 } |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1744 } |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1745 |
4333 | 1746 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
|
1747 { |
4333 | 1748 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
|
1749 } |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1750 |
4333 | 1751 static GList *msn_actions(struct gaim_connection *gc) |
2213
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1752 { |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1753 GList *m = NULL; |
4333 | 1754 struct proto_actions_menu *pam; |
1755 | |
1756 pam = g_new0(struct proto_actions_menu, 1); | |
1757 pam->label = _("Set Friendly Name"); | |
1758 pam->callback = msn_show_set_friendly_name; | |
1759 pam->gc = gc; | |
1760 m = g_list_append(m, pam); | |
2213
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1761 |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1762 return m; |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1763 } |
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
1764 |
2591
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
1765 static void msn_convo_closed(struct gaim_connection *gc, char *who) |
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
1766 { |
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
1767 struct msn_switchboard *ms = msn_find_switch(gc, who); |
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
1768 |
4069
5b56c42c2717
[gaim-migrate @ 4281]
Christian Hammond <chipx86@chipx86.com>
parents:
4068
diff
changeset
|
1769 if (ms) { |
5b56c42c2717
[gaim-migrate @ 4281]
Christian Hammond <chipx86@chipx86.com>
parents:
4068
diff
changeset
|
1770 char sendbuf[256]; |
5b56c42c2717
[gaim-migrate @ 4281]
Christian Hammond <chipx86@chipx86.com>
parents:
4068
diff
changeset
|
1771 |
5b56c42c2717
[gaim-migrate @ 4281]
Christian Hammond <chipx86@chipx86.com>
parents:
4068
diff
changeset
|
1772 g_snprintf(sendbuf, sizeof(sendbuf), "BYE %s\r\n", gc->username); |
5b56c42c2717
[gaim-migrate @ 4281]
Christian Hammond <chipx86@chipx86.com>
parents:
4068
diff
changeset
|
1773 |
5b56c42c2717
[gaim-migrate @ 4281]
Christian Hammond <chipx86@chipx86.com>
parents:
4068
diff
changeset
|
1774 msn_write(ms->fd, sendbuf, strlen(sendbuf)); |
5b56c42c2717
[gaim-migrate @ 4281]
Christian Hammond <chipx86@chipx86.com>
parents:
4068
diff
changeset
|
1775 |
2591
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
1776 msn_kill_switch(ms); |
4069
5b56c42c2717
[gaim-migrate @ 4281]
Christian Hammond <chipx86@chipx86.com>
parents:
4068
diff
changeset
|
1777 } |
2591
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
1778 } |
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
1779 |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1780 static void msn_keepalive(struct gaim_connection *gc) |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1781 { |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1782 struct msn_data *md = gc->proto_data; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1783 char buf[MSN_BUF_LEN]; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1784 |
2603
24664768a739
[gaim-migrate @ 2616]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2600
diff
changeset
|
1785 g_snprintf(buf, sizeof(buf), "PNG\r\n"); |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1786 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 1787 hide_login_progress(gc, _("Write error")); |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1788 signoff(gc); |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1789 return; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1790 } |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1791 } |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1792 |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1793 static void msn_set_permit_deny(struct gaim_connection *gc) |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1794 { |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1795 struct msn_data *md = gc->proto_data; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1796 char buf[MSN_BUF_LEN]; |
2665
b0478af51be0
[gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2611
diff
changeset
|
1797 GSList *s, *t = NULL; |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1798 |
4491 | 1799 if (gc->account->permdeny == PERMIT_ALL || gc->account->permdeny == DENY_SOME) |
4270 | 1800 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
|
1801 else |
4270 | 1802 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
|
1803 |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1804 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 1805 hide_login_progress(gc, _("Write error")); |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1806 signoff(gc); |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1807 return; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1808 } |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1809 |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1810 /* 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
|
1811 * 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
|
1812 * and so there's no sense in going through them all. */ |
4491 | 1813 if (g_slist_length(gc->account->permit) == g_slist_length(md->permit)) { |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1814 g_slist_free(md->permit); |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1815 md->permit = NULL; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1816 } |
4491 | 1817 if (g_slist_length(gc->account->deny) == g_slist_length(md->deny)) { |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1818 g_slist_free(md->deny); |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1819 md->deny = NULL; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1820 } |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1821 if (!md->permit && !md->deny) |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1822 return; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1823 |
3200 | 1824 if (md->permit) { |
4491 | 1825 s = g_slist_nth(gc->account->permit, g_slist_length(md->permit)); |
3200 | 1826 while (s) { |
1827 char *who = s->data; | |
1828 s = s->next; | |
1829 if (!strchr(who, '@')) { | |
1830 t = g_slist_append(t, who); | |
1831 continue; | |
1832 } | |
4349 | 1833 if (g_slist_find(md->deny, who)) { |
3294 | 1834 t = g_slist_append(t, who); |
1835 continue; | |
1836 } | |
4270 | 1837 g_snprintf(buf, sizeof(buf), "ADD %u AL %s %s\r\n", ++md->trId, who, who); |
3200 | 1838 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 1839 hide_login_progress(gc, _("Write error")); |
3200 | 1840 signoff(gc); |
1841 return; | |
1842 } | |
2665
b0478af51be0
[gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2611
diff
changeset
|
1843 } |
3200 | 1844 while (t) { |
4491 | 1845 gaim_privacy_permit_remove(gc->account, t->data); |
3200 | 1846 t = t->next; |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1847 } |
3200 | 1848 if (t) |
1849 g_slist_free(t); | |
2665
b0478af51be0
[gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2611
diff
changeset
|
1850 t = NULL; |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1851 g_slist_free(md->permit); |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1852 md->permit = NULL; |
3200 | 1853 } |
1854 | |
1855 if (md->deny) { | |
4491 | 1856 s = g_slist_nth(gc->account->deny, g_slist_length(md->deny)); |
3200 | 1857 while (s) { |
1858 char *who = s->data; | |
1859 s = s->next; | |
1860 if (!strchr(who, '@')) { | |
1861 t = g_slist_append(t, who); | |
1862 continue; | |
1863 } | |
4349 | 1864 if (g_slist_find(md->deny, who)) { |
3294 | 1865 t = g_slist_append(t, who); |
1866 continue; | |
1867 } | |
4270 | 1868 g_snprintf(buf, sizeof(buf), "ADD %u BL %s %s\r\n", ++md->trId, who, who); |
3200 | 1869 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 1870 hide_login_progress(gc, _("Write error")); |
3200 | 1871 signoff(gc); |
1872 return; | |
1873 } | |
2665
b0478af51be0
[gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2611
diff
changeset
|
1874 } |
3200 | 1875 while (t) { |
4491 | 1876 gaim_privacy_deny_remove(gc->account, t->data); |
3200 | 1877 t = t->next; |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1878 } |
3200 | 1879 if (t) |
1880 g_slist_free(t); | |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1881 g_slist_free(md->deny); |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1882 md->deny = NULL; |
3200 | 1883 } |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1884 } |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1885 |
4349 | 1886 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
|
1887 { |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1888 struct msn_data *md = gc->proto_data; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1889 char buf[MSN_BUF_LEN]; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1890 |
2665
b0478af51be0
[gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2611
diff
changeset
|
1891 if (!strchr(who, '@')) { |
3427 | 1892 g_snprintf(buf, sizeof(buf), |
1893 _("An MSN screenname must be in the form \"user@server.com\". " | |
1894 "Perhaps you meant %s@hotmail.com. No changes were made to your " | |
1895 "allow list."), who); | |
1896 do_error_dialog(_("Invalid MSN screenname"), buf, GAIM_ERROR); | |
4491 | 1897 gaim_privacy_permit_remove(gc->account, who); |
2665
b0478af51be0
[gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2611
diff
changeset
|
1898 return; |
b0478af51be0
[gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2611
diff
changeset
|
1899 } |
b0478af51be0
[gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2611
diff
changeset
|
1900 |
4491 | 1901 if (g_slist_find_custom(gc->account->deny, who, (GCompareFunc)strcmp)) { |
3294 | 1902 debug_printf("MSN: Moving %s from BL to AL\n", who); |
4491 | 1903 gaim_privacy_deny_remove(gc->account, who); |
4270 | 1904 g_snprintf(buf, sizeof(buf), "REM %u BL %s\r\n", ++md->trId, who); |
3294 | 1905 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 1906 hide_login_progress(gc, _("Write error")); |
3294 | 1907 signoff(gc); |
1908 return; | |
1909 } | |
1910 } | |
4270 | 1911 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
|
1912 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 1913 hide_login_progress(gc, _("Write error")); |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1914 signoff(gc); |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1915 return; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1916 } |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1917 } |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1918 |
4349 | 1919 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
|
1920 { |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1921 struct msn_data *md = gc->proto_data; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1922 char buf[MSN_BUF_LEN]; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1923 |
4270 | 1924 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
|
1925 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 1926 hide_login_progress(gc, _("Write error")); |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1927 signoff(gc); |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1928 return; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1929 } |
4349 | 1930 |
4491 | 1931 gaim_privacy_deny_add(gc->account, who); |
4270 | 1932 g_snprintf(buf, sizeof(buf), "ADD %u BL %s %s\r\n", ++md->trId, who, who); |
3294 | 1933 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 1934 hide_login_progress(gc, _("Write error")); |
3294 | 1935 signoff(gc); |
1936 return; | |
1937 } | |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1938 } |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1939 |
4349 | 1940 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
|
1941 { |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1942 struct msn_data *md = gc->proto_data; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1943 char buf[MSN_BUF_LEN]; |
4349 | 1944 |
2665
b0478af51be0
[gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2611
diff
changeset
|
1945 if (!strchr(who, '@')) { |
3427 | 1946 g_snprintf(buf, sizeof(buf), |
1947 _("An MSN screenname must be in the form \"user@server.com\". " | |
1948 "Perhaps you meant %s@hotmail.com. No changes were made to your " | |
1949 "block list."), who); | |
1950 do_error_dialog(_("Invalid MSN screenname"), buf, GAIM_ERROR); | |
4491 | 1951 gaim_privacy_deny_remove(gc->account, who); |
2665
b0478af51be0
[gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2611
diff
changeset
|
1952 return; |
b0478af51be0
[gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2611
diff
changeset
|
1953 } |
b0478af51be0
[gaim-migrate @ 2678]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2611
diff
changeset
|
1954 |
4491 | 1955 if (g_slist_find_custom(gc->account->permit, who, (GCompareFunc)strcmp)) { |
3294 | 1956 debug_printf("MSN: Moving %s from AL to BL\n", who); |
4491 | 1957 gaim_privacy_permit_remove(gc->account, who); |
4270 | 1958 g_snprintf(buf, sizeof(buf), "REM %u AL %s\r\n", ++md->trId, who); |
3294 | 1959 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 1960 hide_login_progress(gc, _("Write error")); |
3294 | 1961 signoff(gc); |
1962 return; | |
1963 } | |
1964 } | |
4349 | 1965 |
3294 | 1966 |
4270 | 1967 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
|
1968 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 1969 hide_login_progress(gc, _("Write error")); |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1970 signoff(gc); |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1971 return; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1972 } |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1973 } |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1974 |
4349 | 1975 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
|
1976 { |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1977 struct msn_data *md = gc->proto_data; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1978 char buf[MSN_BUF_LEN]; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1979 |
4270 | 1980 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
|
1981 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 1982 hide_login_progress(gc, _("Write error")); |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1983 signoff(gc); |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1984 return; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1985 } |
4349 | 1986 |
4491 | 1987 gaim_privacy_permit_add(gc->account, who); |
4270 | 1988 g_snprintf(buf, sizeof(buf), "ADD %u AL %s %s\r\n", ++md->trId, who, who); |
3294 | 1989 if (msn_write(md->fd, buf, strlen(buf)) < 0) { |
4056 | 1990 hide_login_progress(gc, _("Write error")); |
3294 | 1991 signoff(gc); |
1992 return; | |
1993 } | |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1994 } |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
1995 |
2607
e0d4a23aac89
[gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2603
diff
changeset
|
1996 static void msn_buddy_free(struct buddy *b) |
e0d4a23aac89
[gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2603
diff
changeset
|
1997 { |
e0d4a23aac89
[gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2603
diff
changeset
|
1998 if (b->proto_data) |
e0d4a23aac89
[gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2603
diff
changeset
|
1999 g_free(b->proto_data); |
e0d4a23aac89
[gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2603
diff
changeset
|
2000 } |
e0d4a23aac89
[gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2603
diff
changeset
|
2001 |
3630 | 2002 G_MODULE_EXPORT void msn_init(struct prpl *ret) |
2086 | 2003 { |
3572 | 2004 struct proto_user_opt *puo; |
2086 | 2005 ret->protocol = PROTO_MSN; |
2153
0befa2d2e540
[gaim-migrate @ 2163]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2152
diff
changeset
|
2006 ret->options = OPT_PROTO_MAIL_CHECK; |
3572 | 2007 ret->name = g_strdup("MSN"); |
2086 | 2008 ret->list_icon = msn_list_icon; |
4916 | 2009 ret->list_emblems = msn_list_emblems; |
2086 | 2010 ret->buddy_menu = msn_buddy_menu; |
2011 ret->login = msn_login; | |
2012 ret->close = msn_close; | |
2013 ret->send_im = msn_send_im; | |
2993 | 2014 ret->send_typing = msn_send_typing; |
2086 | 2015 ret->away_states = msn_away_states; |
4723 | 2016 ret->status_text = msn_status_text; |
4724 | 2017 ret->tooltip_text = msn_tooltip_text; |
2086 | 2018 ret->set_away = msn_set_away; |
2019 ret->set_idle = msn_set_idle; | |
2020 ret->add_buddy = msn_add_buddy; | |
2021 ret->remove_buddy = msn_rem_buddy; | |
2022 ret->chat_send = msn_chat_send; | |
2023 ret->chat_invite = msn_chat_invite; | |
2024 ret->chat_leave = msn_chat_leave; | |
2025 ret->normalize = msn_normalize; | |
2213
a226ebf4be47
[gaim-migrate @ 2223]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2210
diff
changeset
|
2026 ret->actions = msn_actions; |
2591
b771cbe7e161
[gaim-migrate @ 2604]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2588
diff
changeset
|
2027 ret->convo_closed = msn_convo_closed; |
2597
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2028 ret->keepalive = msn_keepalive; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2029 ret->set_permit_deny = msn_set_permit_deny; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2030 ret->add_permit = msn_add_permit; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2031 ret->rem_permit = msn_rem_permit; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2032 ret->add_deny = msn_add_deny; |
2ced57c58653
[gaim-migrate @ 2610]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2591
diff
changeset
|
2033 ret->rem_deny = msn_rem_deny; |
2607
e0d4a23aac89
[gaim-migrate @ 2620]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2603
diff
changeset
|
2034 ret->buddy_free = msn_buddy_free; |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2035 |
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2036 #if 0 |
4150 | 2037 ret->file_transfer_cancel = msn_file_transfer_cancel; |
2038 ret->file_transfer_in = msn_file_transfer_in; | |
2039 ret->file_transfer_out = msn_file_transfer_out; | |
2040 ret->file_transfer_done = msn_file_transfer_done; | |
2041 ret->file_transfer_read = msn_file_transfer_read; | |
4508
4c40fccbd7c9
[gaim-migrate @ 4784]
Christian Hammond <chipx86@chipx86.com>
parents:
4491
diff
changeset
|
2042 #endif |
3572 | 2043 |
2044 puo = g_new0(struct proto_user_opt, 1); | |
4966 | 2045 puo->label = g_strdup(_("Login Server:")); |
3572 | 2046 puo->def = g_strdup(MSN_SERVER); |
2047 puo->pos = USEROPT_MSNSERVER; | |
2048 ret->user_opts = g_list_append(ret->user_opts, puo); | |
2049 | |
2050 puo = g_new0(struct proto_user_opt, 1); | |
4115 | 2051 puo->label = g_strdup(_("Port:")); |
3572 | 2052 puo->def = g_strdup("1863"); |
2053 puo->pos = USEROPT_MSNPORT; | |
2054 ret->user_opts = g_list_append(ret->user_opts, puo); | |
2086 | 2055 |
2056 my_protocol = ret; | |
2057 } | |
2058 | |
2059 #ifndef STATIC | |
2060 | |
3630 | 2061 G_MODULE_EXPORT void gaim_prpl_init(struct prpl *prpl) |
2086 | 2062 { |
3572 | 2063 msn_init(prpl); |
2064 prpl->plug->desc.api_version = PLUGIN_API_VERSION; | |
2086 | 2065 } |
2066 | |
3630 | 2067 G_MODULE_EXPORT void gaim_plugin_remove() |
2086 | 2068 { |
2069 struct prpl *p = find_prpl(PROTO_MSN); | |
2070 if (p == my_protocol) | |
2071 unload_protocol(p); | |
2072 } | |
2073 | |
3630 | 2074 G_MODULE_EXPORT char *name() |
2086 | 2075 { |
2076 return "MSN"; | |
2077 } | |
2078 | |
3630 | 2079 G_MODULE_EXPORT char *description() |
2086 | 2080 { |
2162
a464da684307
[gaim-migrate @ 2172]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2153
diff
changeset
|
2081 return PRPL_DESC("MSN"); |
2086 | 2082 } |
2083 | |
2084 #endif |