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