[5ebff60] | 1 | /********************************************************************\ |
---|
[b7d3cc34] | 2 | * BitlBee -- An IRC to other IM-networks gateway * |
---|
| 3 | * * |
---|
[f9258ae] | 4 | * Copyright 2002-2012 Wilmer van der Gaast and others * |
---|
[b7d3cc34] | 5 | \********************************************************************/ |
---|
| 6 | |
---|
| 7 | /* MSN module - Notification server callbacks */ |
---|
| 8 | |
---|
| 9 | /* |
---|
| 10 | This program is free software; you can redistribute it and/or modify |
---|
| 11 | it under the terms of the GNU General Public License as published by |
---|
| 12 | the Free Software Foundation; either version 2 of the License, or |
---|
| 13 | (at your option) any later version. |
---|
| 14 | |
---|
| 15 | This program is distributed in the hope that it will be useful, |
---|
| 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 18 | GNU General Public License for more details. |
---|
| 19 | |
---|
| 20 | You should have received a copy of the GNU General Public License with |
---|
| 21 | the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL; |
---|
[6f10697] | 22 | if not, write to the Free Software Foundation, Inc., 51 Franklin St., |
---|
| 23 | Fifth Floor, Boston, MA 02110-1301 USA |
---|
[b7d3cc34] | 24 | */ |
---|
| 25 | |
---|
| 26 | #include <ctype.h> |
---|
[f9258ae] | 27 | #include <sys/utsname.h> |
---|
[b7d3cc34] | 28 | #include "nogaim.h" |
---|
| 29 | #include "msn.h" |
---|
| 30 | #include "md5.h" |
---|
[f9258ae] | 31 | #include "sha1.h" |
---|
[7db65b7] | 32 | #include "soap.h" |
---|
[ca7de3a] | 33 | #include "xmltree.h" |
---|
[b7d3cc34] | 34 | |
---|
[5ebff60] | 35 | static gboolean msn_ns_connected(gpointer data, gint source, b_input_condition cond); |
---|
| 36 | static gboolean msn_ns_callback(gpointer data, gint source, b_input_condition cond); |
---|
[b7d3cc34] | 37 | |
---|
[5ebff60] | 38 | static void msn_ns_send_adl_start(struct im_connection *ic); |
---|
| 39 | static void msn_ns_send_adl(struct im_connection *ic); |
---|
[b7d3cc34] | 40 | |
---|
[5ebff60] | 41 | int msn_ns_write(struct im_connection *ic, int fd, const char *fmt, ...) |
---|
[64768d4] | 42 | { |
---|
| 43 | struct msn_data *md = ic->proto_data; |
---|
| 44 | va_list params; |
---|
| 45 | char *out; |
---|
| 46 | size_t len; |
---|
| 47 | int st; |
---|
[5ebff60] | 48 | |
---|
| 49 | va_start(params, fmt); |
---|
| 50 | out = g_strdup_vprintf(fmt, params); |
---|
| 51 | va_end(params); |
---|
| 52 | |
---|
| 53 | if (fd < 0) { |
---|
[ffa5b70] | 54 | fd = md->fd; |
---|
[5ebff60] | 55 | } |
---|
| 56 | |
---|
| 57 | if (getenv("BITLBEE_DEBUG")) { |
---|
[fa8c775] | 58 | fprintf(stderr, "\x1b[91m>>>[NS%d] %s\n\x1b[97m", fd, out); |
---|
[5ebff60] | 59 | } |
---|
| 60 | |
---|
| 61 | len = strlen(out); |
---|
| 62 | st = write(fd, out, len); |
---|
| 63 | g_free(out); |
---|
| 64 | if (st != len) { |
---|
| 65 | imcb_error(ic, "Short write() to main server"); |
---|
| 66 | imc_logout(ic, TRUE); |
---|
[64768d4] | 67 | return 0; |
---|
| 68 | } |
---|
[5ebff60] | 69 | |
---|
[64768d4] | 70 | return 1; |
---|
| 71 | } |
---|
| 72 | |
---|
[ffa5b70] | 73 | gboolean msn_ns_connect(struct im_connection *ic, const char *host, int port) |
---|
[b7d3cc34] | 74 | { |
---|
[ffa5b70] | 75 | struct msn_data *handler = ic->proto_data; |
---|
| 76 | |
---|
[5ebff60] | 77 | if (handler->fd >= 0) { |
---|
| 78 | closesocket(handler->fd); |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | handler->fd = proxy_connect(host, port, msn_ns_connected, handler); |
---|
| 82 | if (handler->fd < 0) { |
---|
| 83 | imcb_error(ic, "Could not connect to server"); |
---|
| 84 | imc_logout(ic, TRUE); |
---|
[ba9edaa] | 85 | return FALSE; |
---|
[b7d3cc34] | 86 | } |
---|
[5ebff60] | 87 | |
---|
[bae0617] | 88 | return TRUE; |
---|
| 89 | } |
---|
| 90 | |
---|
[5ebff60] | 91 | static gboolean msn_ns_connected(gpointer data, gint source, b_input_condition cond) |
---|
[bae0617] | 92 | { |
---|
[ffa5b70] | 93 | struct msn_data *md = data; |
---|
| 94 | struct msn_data *handler = md; |
---|
| 95 | struct im_connection *ic = md->ic; |
---|
[5ebff60] | 96 | |
---|
| 97 | if (source == -1) { |
---|
| 98 | imcb_error(ic, "Could not connect to server"); |
---|
| 99 | imc_logout(ic, TRUE); |
---|
[bae0617] | 100 | return FALSE; |
---|
[b7d3cc34] | 101 | } |
---|
[5ebff60] | 102 | |
---|
| 103 | g_free(handler->rxq); |
---|
[bae0617] | 104 | handler->rxlen = 0; |
---|
[5ebff60] | 105 | handler->rxq = g_new0(char, 1); |
---|
| 106 | |
---|
| 107 | if (md->uuid == NULL) { |
---|
[f9258ae] | 108 | struct utsname name; |
---|
| 109 | sha1_state_t sha[1]; |
---|
[5ebff60] | 110 | |
---|
[f9258ae] | 111 | /* UUID == SHA1("BitlBee" + my hostname + MSN username) */ |
---|
[5ebff60] | 112 | sha1_init(sha); |
---|
| 113 | sha1_append(sha, (void *) "BitlBee", 7); |
---|
| 114 | if (uname(&name) == 0) { |
---|
| 115 | sha1_append(sha, (void *) name.nodename, strlen(name.nodename)); |
---|
[f9258ae] | 116 | } |
---|
[5ebff60] | 117 | sha1_append(sha, (void *) ic->acc->user, strlen(ic->acc->user)); |
---|
| 118 | md->uuid = sha1_random_uuid(sha); |
---|
| 119 | memcpy(md->uuid, "b171be3e", 8); /* :-P */ |
---|
[f9258ae] | 120 | } |
---|
[5ebff60] | 121 | |
---|
| 122 | if (msn_ns_write(ic, source, "VER %d %s CVR0\r\n", ++md->trId, MSNP_VER)) { |
---|
| 123 | handler->inpa = b_input_add(handler->fd, B_EV_IO_READ, msn_ns_callback, handler); |
---|
| 124 | imcb_log(ic, "Connected to server, waiting for reply"); |
---|
[b7d3cc34] | 125 | } |
---|
[5ebff60] | 126 | |
---|
[ba9edaa] | 127 | return FALSE; |
---|
[b7d3cc34] | 128 | } |
---|
| 129 | |
---|
[ffa5b70] | 130 | void msn_ns_close(struct msn_data *handler) |
---|
[bae0617] | 131 | { |
---|
[5ebff60] | 132 | if (handler->fd >= 0) { |
---|
| 133 | closesocket(handler->fd); |
---|
| 134 | b_event_remove(handler->inpa); |
---|
[bae0617] | 135 | } |
---|
[5ebff60] | 136 | |
---|
[bae0617] | 137 | handler->fd = handler->inpa = -1; |
---|
[5ebff60] | 138 | g_free(handler->rxq); |
---|
| 139 | g_free(handler->cmd_text); |
---|
| 140 | |
---|
[bae0617] | 141 | handler->rxlen = 0; |
---|
| 142 | handler->rxq = NULL; |
---|
| 143 | handler->cmd_text = NULL; |
---|
| 144 | } |
---|
| 145 | |
---|
[5ebff60] | 146 | static gboolean msn_ns_callback(gpointer data, gint source, b_input_condition cond) |
---|
[b7d3cc34] | 147 | { |
---|
[ffa5b70] | 148 | struct msn_data *handler = data; |
---|
| 149 | struct im_connection *ic = handler->ic; |
---|
[5ebff60] | 150 | |
---|
| 151 | if (msn_handler(handler) == -1) { /* Don't do this on ret == 0, it's already done then. */ |
---|
| 152 | imcb_error(ic, "Error while reading from server"); |
---|
| 153 | imc_logout(ic, TRUE); |
---|
| 154 | |
---|
[ba9edaa] | 155 | return FALSE; |
---|
[5ebff60] | 156 | } else { |
---|
[ba9edaa] | 157 | return TRUE; |
---|
[5ebff60] | 158 | } |
---|
[b7d3cc34] | 159 | } |
---|
| 160 | |
---|
[ffa5b70] | 161 | int msn_ns_command(struct msn_data *handler, char **cmd, int num_parts) |
---|
[b7d3cc34] | 162 | { |
---|
[ffa5b70] | 163 | struct im_connection *ic = handler->ic; |
---|
| 164 | struct msn_data *md = handler; |
---|
[5ebff60] | 165 | |
---|
| 166 | if (num_parts == 0) { |
---|
[b7d3cc34] | 167 | /* Hrrm... Empty command...? Ignore? */ |
---|
[5ebff60] | 168 | return(1); |
---|
[b7d3cc34] | 169 | } |
---|
[5ebff60] | 170 | |
---|
| 171 | if (strcmp(cmd[0], "VER") == 0) { |
---|
| 172 | if (cmd[2] && strncmp(cmd[2], MSNP_VER, 5) != 0) { |
---|
| 173 | imcb_error(ic, "Unsupported protocol"); |
---|
| 174 | imc_logout(ic, FALSE); |
---|
| 175 | return(0); |
---|
[b7d3cc34] | 176 | } |
---|
[5ebff60] | 177 | |
---|
[3752019] | 178 | return(msn_ns_write(ic, handler->fd, "CVR %d 0x0409 mac 10.2.0 ppc macmsgs 3.5.1 macmsgs %s VmVyc2lvbjogMQ0KWGZyQ291bnQ6IDINClhmclNlbnRVVENUaW1lOiA2MzU2MTQ3OTU5NzgzOTAwMDANCklzR2VvWGZyOiB0cnVlDQo=\r\n", |
---|
[5ebff60] | 179 | ++md->trId, ic->acc->user)); |
---|
| 180 | } else if (strcmp(cmd[0], "CVR") == 0) { |
---|
[b7d3cc34] | 181 | /* We don't give a damn about the information we just received */ |
---|
[5ebff60] | 182 | return msn_ns_write(ic, handler->fd, "USR %d SSO I %s\r\n", ++md->trId, ic->acc->user); |
---|
| 183 | } else if (strcmp(cmd[0], "XFR") == 0) { |
---|
[b7d3cc34] | 184 | char *server; |
---|
| 185 | int port; |
---|
[5ebff60] | 186 | |
---|
| 187 | if (num_parts >= 6 && strcmp(cmd[2], "NS") == 0) { |
---|
| 188 | b_event_remove(handler->inpa); |
---|
[bae0617] | 189 | handler->inpa = -1; |
---|
[5ebff60] | 190 | |
---|
| 191 | server = strchr(cmd[3], ':'); |
---|
| 192 | if (!server) { |
---|
| 193 | imcb_error(ic, "Syntax error"); |
---|
| 194 | imc_logout(ic, TRUE); |
---|
| 195 | return(0); |
---|
[b7d3cc34] | 196 | } |
---|
| 197 | *server = 0; |
---|
[5ebff60] | 198 | port = atoi(server + 1); |
---|
[b7d3cc34] | 199 | server = cmd[3]; |
---|
[5ebff60] | 200 | |
---|
| 201 | imcb_log(ic, "Transferring to other server"); |
---|
[ffa5b70] | 202 | return msn_ns_connect(ic, server, port); |
---|
[5ebff60] | 203 | } else { |
---|
| 204 | imcb_error(ic, "Syntax error"); |
---|
| 205 | imc_logout(ic, TRUE); |
---|
| 206 | return(0); |
---|
| 207 | } |
---|
| 208 | } else if (strcmp(cmd[0], "USR") == 0) { |
---|
| 209 | if (num_parts >= 6 && strcmp(cmd[2], "SSO") == 0 && |
---|
| 210 | strcmp(cmd[3], "S") == 0) { |
---|
| 211 | g_free(md->pp_policy); |
---|
| 212 | md->pp_policy = g_strdup(cmd[4]); |
---|
| 213 | msn_soap_passport_sso_request(ic, cmd[5]); |
---|
| 214 | } else if (strcmp(cmd[2], "OK") == 0) { |
---|
[ed0589c] | 215 | /* If the number after the handle is 0, the e-mail |
---|
| 216 | address is unverified, which means we can't change |
---|
| 217 | the display name. */ |
---|
[5ebff60] | 218 | if (cmd[4][0] == '0') { |
---|
[ed0589c] | 219 | md->flags |= MSN_EMAIL_UNVERIFIED; |
---|
[5ebff60] | 220 | } |
---|
| 221 | |
---|
| 222 | imcb_log(ic, "Authenticated, getting buddy list"); |
---|
| 223 | msn_soap_memlist_request(ic); |
---|
| 224 | } else { |
---|
| 225 | imcb_error(ic, "Unknown authentication type"); |
---|
| 226 | imc_logout(ic, FALSE); |
---|
| 227 | return(0); |
---|
| 228 | } |
---|
| 229 | } else if (strcmp(cmd[0], "MSG") == 0) { |
---|
| 230 | if (num_parts < 4) { |
---|
| 231 | imcb_error(ic, "Syntax error"); |
---|
| 232 | imc_logout(ic, TRUE); |
---|
| 233 | return(0); |
---|
[e5854a8] | 234 | } |
---|
[5ebff60] | 235 | |
---|
| 236 | handler->msglen = atoi(cmd[3]); |
---|
| 237 | |
---|
| 238 | if (handler->msglen <= 0) { |
---|
| 239 | imcb_error(ic, "Syntax error"); |
---|
| 240 | imc_logout(ic, TRUE); |
---|
| 241 | return(0); |
---|
| 242 | } |
---|
| 243 | } else if (strcmp(cmd[0], "ADL") == 0) { |
---|
| 244 | if (num_parts >= 3 && strcmp(cmd[2], "OK") == 0) { |
---|
| 245 | msn_ns_send_adl(ic); |
---|
| 246 | return msn_ns_finish_login(ic); |
---|
| 247 | } else if (num_parts >= 3) { |
---|
| 248 | handler->msglen = atoi(cmd[2]); |
---|
| 249 | } |
---|
| 250 | } else if (strcmp(cmd[0], "PRP") == 0) { |
---|
| 251 | imcb_connected(ic); |
---|
| 252 | } else if (strcmp(cmd[0], "CHL") == 0) { |
---|
[be7a180] | 253 | char *resp; |
---|
[64768d4] | 254 | int st; |
---|
[5ebff60] | 255 | |
---|
| 256 | if (num_parts < 3) { |
---|
| 257 | imcb_error(ic, "Syntax error"); |
---|
| 258 | imc_logout(ic, TRUE); |
---|
| 259 | return(0); |
---|
[b7d3cc34] | 260 | } |
---|
[5ebff60] | 261 | |
---|
| 262 | resp = msn_p11_challenge(cmd[2]); |
---|
| 263 | |
---|
| 264 | st = msn_ns_write(ic, -1, "QRY %d %s %zd\r\n%s", |
---|
| 265 | ++md->trId, MSNP11_PROD_ID, |
---|
| 266 | strlen(resp), resp); |
---|
| 267 | g_free(resp); |
---|
[64768d4] | 268 | return st; |
---|
[5ebff60] | 269 | } else if (strcmp(cmd[0], "ILN") == 0 || strcmp(cmd[0], "NLN") == 0) { |
---|
[08995b0] | 270 | const struct msn_away_state *st; |
---|
[79bb7e4] | 271 | const char *handle; |
---|
| 272 | int cap = 0; |
---|
[5ebff60] | 273 | |
---|
| 274 | if (num_parts < 6) { |
---|
| 275 | imcb_error(ic, "Syntax error"); |
---|
| 276 | imc_logout(ic, TRUE); |
---|
| 277 | return(0); |
---|
[b7d3cc34] | 278 | } |
---|
[79bb7e4] | 279 | /* ILN and NLN are more or less the same, except ILN has a trId |
---|
[5ebff60] | 280 | at the start, and NLN has a capability field at the end. |
---|
[79bb7e4] | 281 | Does ILN still exist BTW? */ |
---|
[5ebff60] | 282 | if (cmd[0][1] == 'I') { |
---|
| 283 | cmd++; |
---|
| 284 | } else { |
---|
| 285 | cap = atoi(cmd[4]); |
---|
| 286 | } |
---|
[79bb7e4] | 287 | |
---|
[5ebff60] | 288 | handle = msn_normalize_handle(cmd[2]); |
---|
| 289 | if (strcmp(handle, ic->acc->user) == 0) { |
---|
[79bb7e4] | 290 | return 1; /* That's me! */ |
---|
[5ebff60] | 291 | |
---|
| 292 | } |
---|
| 293 | http_decode(cmd[3]); |
---|
| 294 | imcb_rename_buddy(ic, handle, cmd[3]); |
---|
| 295 | |
---|
| 296 | st = msn_away_state_by_code(cmd[1]); |
---|
| 297 | if (!st) { |
---|
[b7d3cc34] | 298 | /* FIXME: Warn/Bomb about unknown away state? */ |
---|
[b051d39] | 299 | st = msn_away_state_list + 1; |
---|
[b7d3cc34] | 300 | } |
---|
[5ebff60] | 301 | |
---|
| 302 | imcb_buddy_status(ic, handle, OPT_LOGGED_IN | |
---|
| 303 | (st != msn_away_state_list ? OPT_AWAY : 0) | |
---|
| 304 | (cap & 1 ? OPT_MOBILE : 0), |
---|
| 305 | st->name, NULL); |
---|
| 306 | |
---|
| 307 | } else if (strcmp(cmd[0], "FLN") == 0) { |
---|
[79bb7e4] | 308 | const char *handle; |
---|
[5ebff60] | 309 | |
---|
| 310 | if (cmd[1] == NULL) { |
---|
[9bf2481] | 311 | return 1; |
---|
[5ebff60] | 312 | } |
---|
| 313 | |
---|
| 314 | handle = msn_normalize_handle(cmd[1]); |
---|
| 315 | imcb_buddy_status(ic, handle, 0, NULL, NULL); |
---|
| 316 | } else if (strcmp(cmd[0], "OUT") == 0) { |
---|
[c2fb3809] | 317 | int allow_reconnect = TRUE; |
---|
[5ebff60] | 318 | |
---|
| 319 | if (cmd[1] && strcmp(cmd[1], "OTH") == 0) { |
---|
| 320 | imcb_error(ic, "Someone else logged in with your account"); |
---|
[c2fb3809] | 321 | allow_reconnect = FALSE; |
---|
[5ebff60] | 322 | } else if (cmd[1] && strcmp(cmd[1], "SSD") == 0) { |
---|
| 323 | imcb_error(ic, "Terminating session because of server shutdown"); |
---|
| 324 | } else { |
---|
| 325 | imcb_error(ic, "Session terminated by remote server (%s)", |
---|
| 326 | cmd[1] ? cmd[1] : "reason unknown)"); |
---|
[b7d3cc34] | 327 | } |
---|
[5ebff60] | 328 | |
---|
| 329 | imc_logout(ic, allow_reconnect); |
---|
| 330 | return(0); |
---|
| 331 | } else if (strcmp(cmd[0], "IPG") == 0) { |
---|
| 332 | imcb_error(ic, "Received IPG command, we don't handle them yet."); |
---|
| 333 | |
---|
| 334 | handler->msglen = atoi(cmd[1]); |
---|
| 335 | |
---|
| 336 | if (handler->msglen <= 0) { |
---|
| 337 | imcb_error(ic, "Syntax error"); |
---|
| 338 | imc_logout(ic, TRUE); |
---|
| 339 | return(0); |
---|
[b7d3cc34] | 340 | } |
---|
| 341 | } |
---|
[e5854a8] | 342 | #if 0 |
---|
[5ebff60] | 343 | else if (strcmp(cmd[0], "ADG") == 0) { |
---|
| 344 | char *group = g_strdup(cmd[3]); |
---|
[70ac477] | 345 | int groupnum, i; |
---|
| 346 | GSList *l, *next; |
---|
[5ebff60] | 347 | |
---|
| 348 | http_decode(group); |
---|
| 349 | if (sscanf(cmd[4], "%d", &groupnum) == 1) { |
---|
| 350 | if (groupnum >= md->groupcount) { |
---|
| 351 | md->grouplist = g_renew(char *, md->grouplist, groupnum + 1); |
---|
| 352 | for (i = md->groupcount; i <= groupnum; i++) { |
---|
[70ac477] | 353 | md->grouplist[i] = NULL; |
---|
[5ebff60] | 354 | } |
---|
[70ac477] | 355 | md->groupcount = groupnum + 1; |
---|
| 356 | } |
---|
[5ebff60] | 357 | g_free(md->grouplist[groupnum]); |
---|
[70ac477] | 358 | md->grouplist[groupnum] = group; |
---|
[5ebff60] | 359 | } else { |
---|
[70ac477] | 360 | /* Shouldn't happen, but if it does, give up on the group. */ |
---|
[5ebff60] | 361 | g_free(group); |
---|
| 362 | imcb_error(ic, "Syntax error"); |
---|
| 363 | imc_logout(ic, TRUE); |
---|
[70ac477] | 364 | return 0; |
---|
| 365 | } |
---|
[5ebff60] | 366 | |
---|
| 367 | for (l = md->grpq; l; l = next) { |
---|
[70ac477] | 368 | struct msn_groupadd *ga = l->data; |
---|
| 369 | next = l->next; |
---|
[5ebff60] | 370 | if (g_strcasecmp(ga->group, group) == 0) { |
---|
| 371 | if (!msn_buddy_list_add(ic, "FL", ga->who, ga->who, group)) { |
---|
[70ac477] | 372 | return 0; |
---|
[5ebff60] | 373 | } |
---|
| 374 | |
---|
| 375 | g_free(ga->group); |
---|
| 376 | g_free(ga->who); |
---|
| 377 | g_free(ga); |
---|
| 378 | md->grpq = g_slist_remove(md->grpq, ga); |
---|
[70ac477] | 379 | } |
---|
| 380 | } |
---|
| 381 | } |
---|
[e5854a8] | 382 | #endif |
---|
[5ebff60] | 383 | else if (strcmp(cmd[0], "GCF") == 0) { |
---|
[5fecede] | 384 | /* Coming up is cmd[2] bytes of stuff we're supposed to |
---|
| 385 | censore. Meh. */ |
---|
[5ebff60] | 386 | handler->msglen = atoi(cmd[2]); |
---|
| 387 | } else if (strcmp(cmd[0], "UBX") == 0) { |
---|
[e5854a8] | 388 | /* Status message. */ |
---|
[5ebff60] | 389 | if (num_parts >= 3) { |
---|
| 390 | handler->msglen = atoi(cmd[2]); |
---|
| 391 | } |
---|
| 392 | } else if (strcmp(cmd[0], "NOT") == 0) { |
---|
[e5854a8] | 393 | /* Some kind of notification, poorly documented but |
---|
| 394 | apparently used to announce address book changes. */ |
---|
[5ebff60] | 395 | if (num_parts >= 2) { |
---|
| 396 | handler->msglen = atoi(cmd[1]); |
---|
| 397 | } |
---|
[ffa5b70] | 398 | } else if ((strcmp(cmd[0], "NFY") == 0) || (strcmp(cmd[0], "SDG") == 0)) { |
---|
[3752019] | 399 | if (num_parts >= 3) { |
---|
| 400 | handler->msglen = atoi(cmd[2]); |
---|
| 401 | } |
---|
[5ebff60] | 402 | } else if (strcmp(cmd[0], "UBM") == 0) { |
---|
| 403 | if (num_parts >= 7) { |
---|
| 404 | handler->msglen = atoi(cmd[6]); |
---|
| 405 | } |
---|
| 406 | } else if (strcmp(cmd[0], "QNG") == 0) { |
---|
[e132b60] | 407 | ic->flags |= OPT_PONGED; |
---|
[5ebff60] | 408 | } else if (g_ascii_isdigit(cmd[0][0])) { |
---|
| 409 | int num = atoi(cmd[0]); |
---|
| 410 | const struct msn_status_code *err = msn_status_by_number(num); |
---|
| 411 | |
---|
| 412 | imcb_error(ic, "Error reported by MSN server: %s", err->text); |
---|
| 413 | |
---|
| 414 | if (err->flags & STATUS_FATAL) { |
---|
| 415 | imc_logout(ic, TRUE); |
---|
| 416 | return(0); |
---|
[b7d3cc34] | 417 | } |
---|
[5ebff60] | 418 | |
---|
[02bb9db] | 419 | /* Oh yes, errors can have payloads too now. Discard them for now. */ |
---|
[5ebff60] | 420 | if (num_parts >= 3) { |
---|
| 421 | handler->msglen = atoi(cmd[2]); |
---|
| 422 | } |
---|
| 423 | } else { |
---|
[8ff0a61] | 424 | /* debug( "Received unknown command from main server: %s", cmd[0] ); */ |
---|
[b7d3cc34] | 425 | } |
---|
[5ebff60] | 426 | |
---|
| 427 | return(1); |
---|
[b7d3cc34] | 428 | } |
---|
| 429 | |
---|
[ffa5b70] | 430 | int msn_ns_message(struct msn_data *handler, char *msg, int msglen, char **cmd, int num_parts) |
---|
[b7d3cc34] | 431 | { |
---|
[ffa5b70] | 432 | struct im_connection *ic = handler->ic; |
---|
[b7d3cc34] | 433 | char *body; |
---|
| 434 | int blen = 0; |
---|
[5ebff60] | 435 | |
---|
| 436 | if (!num_parts) { |
---|
| 437 | return(1); |
---|
| 438 | } |
---|
| 439 | |
---|
| 440 | if ((body = strstr(msg, "\r\n\r\n"))) { |
---|
[b7d3cc34] | 441 | body += 4; |
---|
[5ebff60] | 442 | blen = msglen - (body - msg); |
---|
[b7d3cc34] | 443 | } |
---|
[5ebff60] | 444 | |
---|
| 445 | if (strcmp(cmd[0], "MSG") == 0) { |
---|
| 446 | if (g_strcasecmp(cmd[1], "Hotmail") == 0) { |
---|
| 447 | char *ct = get_rfc822_header(msg, "Content-Type:", msglen); |
---|
| 448 | |
---|
| 449 | if (!ct) { |
---|
| 450 | return(1); |
---|
| 451 | } |
---|
| 452 | |
---|
| 453 | if (g_strncasecmp(ct, "application/x-msmsgssystemmessage", 33) == 0) { |
---|
[b7d3cc34] | 454 | char *mtype; |
---|
| 455 | char *arg1; |
---|
[5ebff60] | 456 | |
---|
| 457 | if (!body) { |
---|
| 458 | return(1); |
---|
[b7d3cc34] | 459 | } |
---|
[5ebff60] | 460 | |
---|
| 461 | mtype = get_rfc822_header(body, "Type:", blen); |
---|
| 462 | arg1 = get_rfc822_header(body, "Arg1:", blen); |
---|
| 463 | |
---|
| 464 | if (mtype && strcmp(mtype, "1") == 0) { |
---|
| 465 | if (arg1) { |
---|
| 466 | imcb_log(ic, "The server is going down for maintenance in %s minutes.", |
---|
| 467 | arg1); |
---|
| 468 | } |
---|
| 469 | } |
---|
| 470 | |
---|
| 471 | g_free(arg1); |
---|
| 472 | g_free(mtype); |
---|
| 473 | } else if (g_strncasecmp(ct, "text/x-msmsgsprofile", 20) == 0) { |
---|
[b7d3cc34] | 474 | /* We don't care about this profile for now... */ |
---|
[5ebff60] | 475 | } else if (g_strncasecmp(ct, "text/x-msmsgsinitialemailnotification", 37) == 0) { |
---|
| 476 | if (set_getbool(&ic->acc->set, "mail_notifications")) { |
---|
| 477 | char *inbox = get_rfc822_header(body, "Inbox-Unread:", blen); |
---|
| 478 | char *folders = get_rfc822_header(body, "Folders-Unread:", blen); |
---|
| 479 | |
---|
| 480 | if (inbox && folders) { |
---|
| 481 | imcb_log(ic, |
---|
| 482 | "INBOX contains %s new messages, plus %s messages in other folders.", inbox, |
---|
| 483 | folders); |
---|
| 484 | } |
---|
| 485 | |
---|
| 486 | g_free(inbox); |
---|
| 487 | g_free(folders); |
---|
[b7d3cc34] | 488 | } |
---|
[5ebff60] | 489 | } else if (g_strncasecmp(ct, "text/x-msmsgsemailnotification", 30) == 0) { |
---|
| 490 | if (set_getbool(&ic->acc->set, "mail_notifications")) { |
---|
| 491 | char *from = get_rfc822_header(body, "From-Addr:", blen); |
---|
| 492 | char *fromname = get_rfc822_header(body, "From:", blen); |
---|
| 493 | |
---|
| 494 | if (from && fromname) { |
---|
| 495 | imcb_log(ic, "Received an e-mail message from %s <%s>.", fromname, |
---|
| 496 | from); |
---|
| 497 | } |
---|
| 498 | |
---|
| 499 | g_free(from); |
---|
| 500 | g_free(fromname); |
---|
[b7d3cc34] | 501 | } |
---|
[5ebff60] | 502 | } else if (g_strncasecmp(ct, "text/x-msmsgsactivemailnotification", 35) == 0) { |
---|
| 503 | } else if (g_strncasecmp(ct, "text/x-msmsgsinitialmdatanotification", 37) == 0 || |
---|
| 504 | g_strncasecmp(ct, "text/x-msmsgsoimnotification", 28) == 0) { |
---|
[a325ebd] | 505 | /* We received an offline message. Or at least notification |
---|
| 506 | that there is one waiting for us. Fetching the message(s) |
---|
| 507 | and purging them from the server is a lot of SOAPy work |
---|
| 508 | not worth doing IMHO. Also I thought it was possible to |
---|
| 509 | have the notification server send them directly, I was |
---|
| 510 | pretty sure I saw Pidgin do it.. |
---|
[5ebff60] | 511 | |
---|
[a325ebd] | 512 | At least give a notification for now, seems like a |
---|
| 513 | reasonable thing to do. Only problem is, they'll keep |
---|
| 514 | coming back at login time until you read them using a |
---|
| 515 | different client. :-( */ |
---|
[5ebff60] | 516 | |
---|
| 517 | char *xml = get_rfc822_header(body, "Mail-Data:", blen); |
---|
[a325ebd] | 518 | struct xt_node *md, *m; |
---|
[5ebff60] | 519 | |
---|
| 520 | if (!xml) { |
---|
[a325ebd] | 521 | return 1; |
---|
[5ebff60] | 522 | } |
---|
| 523 | md = xt_from_string(xml, 0); |
---|
| 524 | if (!md) { |
---|
[a325ebd] | 525 | return 1; |
---|
[5ebff60] | 526 | } |
---|
| 527 | |
---|
| 528 | for (m = md->children; (m = xt_find_node(m, "M")); m = m->next) { |
---|
| 529 | struct xt_node *e = xt_find_node(m->children, "E"); |
---|
| 530 | struct xt_node *rt = xt_find_node(m->children, "RT"); |
---|
[a325ebd] | 531 | struct tm tp; |
---|
| 532 | time_t msgtime = 0; |
---|
[5ebff60] | 533 | |
---|
| 534 | if (!e || !e->text) { |
---|
[a325ebd] | 535 | continue; |
---|
[5ebff60] | 536 | } |
---|
| 537 | |
---|
| 538 | memset(&tp, 0, sizeof(tp)); |
---|
| 539 | if (rt && rt->text && |
---|
| 540 | sscanf(rt->text, "%4d-%2d-%2dT%2d:%2d:%2d.", |
---|
| 541 | &tp.tm_year, &tp.tm_mon, &tp.tm_mday, |
---|
| 542 | &tp.tm_hour, &tp.tm_min, &tp.tm_sec) == 6) { |
---|
[a325ebd] | 543 | tp.tm_year -= 1900; |
---|
[5ebff60] | 544 | tp.tm_mon--; |
---|
| 545 | msgtime = mktime_utc(&tp); |
---|
| 546 | |
---|
[a325ebd] | 547 | } |
---|
[5ebff60] | 548 | imcb_buddy_msg(ic, e->text, |
---|
| 549 | "<< \002BitlBee\002 - Received offline message. BitlBee can't show these. >>", 0, |
---|
| 550 | msgtime); |
---|
[a325ebd] | 551 | } |
---|
[5ebff60] | 552 | |
---|
| 553 | g_free(xml); |
---|
| 554 | xt_free_node(md); |
---|
| 555 | } else { |
---|
| 556 | debug("Can't handle %s packet from notification server", ct); |
---|
[b7d3cc34] | 557 | } |
---|
[5ebff60] | 558 | |
---|
| 559 | g_free(ct); |
---|
[b7d3cc34] | 560 | } |
---|
[5ebff60] | 561 | } else if (strcmp(cmd[0], "UBX") == 0) { |
---|
[9066974] | 562 | struct xt_node *ubx, *psm; |
---|
[d93c0eb9] | 563 | char *psm_text = NULL; |
---|
[5ebff60] | 564 | |
---|
| 565 | ubx = xt_from_string(msg, msglen); |
---|
| 566 | if (ubx && strcmp(ubx->name, "Data") == 0 && |
---|
| 567 | (psm = xt_find_node(ubx->children, "PSM"))) { |
---|
[d93c0eb9] | 568 | psm_text = psm->text; |
---|
[5ebff60] | 569 | } |
---|
| 570 | |
---|
| 571 | imcb_buddy_status_msg(ic, msn_normalize_handle(cmd[1]), psm_text); |
---|
| 572 | xt_free_node(ubx); |
---|
| 573 | } else if (strcmp(cmd[0], "ADL") == 0) { |
---|
[e5854a8] | 574 | struct xt_node *adl, *d, *c; |
---|
[5ebff60] | 575 | |
---|
| 576 | if (!(adl = xt_from_string(msg, msglen))) { |
---|
[e5854a8] | 577 | return 1; |
---|
[5ebff60] | 578 | } |
---|
| 579 | |
---|
| 580 | for (d = adl->children; d; d = d->next) { |
---|
[e5854a8] | 581 | char *dn; |
---|
[5ebff60] | 582 | if (strcmp(d->name, "d") != 0 || |
---|
| 583 | (dn = xt_find_attr(d, "n")) == NULL) { |
---|
[e5854a8] | 584 | continue; |
---|
[5ebff60] | 585 | } |
---|
| 586 | for (c = d->children; c; c = c->next) { |
---|
[e5854a8] | 587 | bee_user_t *bu; |
---|
| 588 | struct msn_buddy_data *bd; |
---|
| 589 | char *cn, *handle, *f, *l; |
---|
| 590 | int flags; |
---|
[5ebff60] | 591 | |
---|
| 592 | if (strcmp(c->name, "c") != 0 || |
---|
| 593 | (l = xt_find_attr(c, "l")) == NULL || |
---|
| 594 | (cn = xt_find_attr(c, "n")) == NULL) { |
---|
[e5854a8] | 595 | continue; |
---|
[5ebff60] | 596 | } |
---|
| 597 | |
---|
[3901b5d] | 598 | /* FIXME: Use "t" here, guess I should just add it |
---|
| 599 | as a prefix like elsewhere in the protocol. */ |
---|
[5ebff60] | 600 | handle = g_strdup_printf("%s@%s", cn, dn); |
---|
| 601 | if (!((bu = bee_user_by_handle(ic->bee, ic, handle)) || |
---|
| 602 | (bu = bee_user_new(ic->bee, ic, handle, 0)))) { |
---|
| 603 | g_free(handle); |
---|
[e5854a8] | 604 | continue; |
---|
| 605 | } |
---|
[5ebff60] | 606 | g_free(handle); |
---|
[e5854a8] | 607 | bd = bu->data; |
---|
[5ebff60] | 608 | |
---|
| 609 | if ((f = xt_find_attr(c, "f"))) { |
---|
| 610 | http_decode(f); |
---|
| 611 | imcb_rename_buddy(ic, bu->handle, f); |
---|
[e5854a8] | 612 | } |
---|
[5ebff60] | 613 | |
---|
| 614 | flags = atoi(l) & 15; |
---|
| 615 | if (bd->flags != flags) { |
---|
[e5854a8] | 616 | bd->flags = flags; |
---|
[5ebff60] | 617 | msn_buddy_ask(bu); |
---|
[e5854a8] | 618 | } |
---|
| 619 | } |
---|
| 620 | } |
---|
[ffa5b70] | 621 | } else if (strcmp(cmd[0], "SDG") == 0) { |
---|
| 622 | char **parts = g_strsplit(msg, "\r\n\r\n", 4); |
---|
| 623 | char *from = NULL; |
---|
| 624 | char *mt = NULL; |
---|
| 625 | char *who = NULL; |
---|
| 626 | char *s = NULL; |
---|
[5ebff60] | 627 | |
---|
[ffa5b70] | 628 | if ((from = get_rfc822_header(parts[0], "From", 0)) && |
---|
| 629 | (mt = get_rfc822_header(parts[2], "Message-Type", 0)) && |
---|
| 630 | (s = strchr(from, ';'))) { |
---|
[5ebff60] | 631 | |
---|
[ffa5b70] | 632 | who = g_strndup(from + 2, s - from - 2); |
---|
| 633 | |
---|
| 634 | if (strcmp(mt, "Control/Typing") == 0) { |
---|
| 635 | imcb_buddy_typing(ic, who, OPT_TYPING); |
---|
| 636 | } else if (strcmp(mt, "Text") == 0) { |
---|
| 637 | imcb_buddy_msg(ic, who, parts[3], 0, 0); |
---|
| 638 | } |
---|
| 639 | } |
---|
| 640 | g_free(from); |
---|
| 641 | g_free(mt); |
---|
| 642 | g_free(who); |
---|
| 643 | return 1; |
---|
[3901b5d] | 644 | } |
---|
[5ebff60] | 645 | |
---|
[3901b5d] | 646 | return 1; |
---|
[b7d3cc34] | 647 | } |
---|
| 648 | |
---|
[5ebff60] | 649 | void msn_auth_got_passport_token(struct im_connection *ic, const char *token, const char *error) |
---|
[b7d3cc34] | 650 | { |
---|
[d84e2a9] | 651 | struct msn_data *md; |
---|
[5ebff60] | 652 | |
---|
[d84e2a9] | 653 | /* Dead connection? */ |
---|
[5ebff60] | 654 | if (g_slist_find(msn_connections, ic) == NULL) { |
---|
[d84e2a9] | 655 | return; |
---|
[b7d3cc34] | 656 | } |
---|
[5ebff60] | 657 | |
---|
| 658 | md = ic->proto_data; |
---|
| 659 | |
---|
| 660 | if (token) { |
---|
| 661 | msn_ns_write(ic, -1, "USR %d SSO S %s %s {%s}\r\n", ++md->trId, md->tokens[0], token, md->uuid); |
---|
| 662 | } else { |
---|
| 663 | imcb_error(ic, "Error during Passport authentication: %s", error); |
---|
| 664 | imc_logout(ic, TRUE); |
---|
[660cb00] | 665 | } |
---|
[b7d3cc34] | 666 | } |
---|
[e3413cc] | 667 | |
---|
[5ebff60] | 668 | void msn_auth_got_contact_list(struct im_connection *ic) |
---|
[ca7de3a] | 669 | { |
---|
| 670 | /* Dead connection? */ |
---|
[5ebff60] | 671 | if (g_slist_find(msn_connections, ic) == NULL) { |
---|
[ca7de3a] | 672 | return; |
---|
[5ebff60] | 673 | } |
---|
| 674 | |
---|
[3752019] | 675 | msn_ns_send_adl_start(ic); |
---|
| 676 | msn_ns_finish_login(ic); |
---|
[ca7de3a] | 677 | } |
---|
| 678 | |
---|
[5ebff60] | 679 | static gboolean msn_ns_send_adl_1(gpointer key, gpointer value, gpointer data) |
---|
[ca7de3a] | 680 | { |
---|
[3752019] | 681 | struct xt_node *adl = data, *d, *c, *s; |
---|
[ca7de3a] | 682 | struct bee_user *bu = value; |
---|
| 683 | struct msn_buddy_data *bd = bu->data; |
---|
[5a7af1b] | 684 | struct msn_data *md = bu->ic->proto_data; |
---|
[4f161e3] | 685 | char handle[strlen(bu->handle) + 1]; |
---|
[ca7de3a] | 686 | char *domain; |
---|
| 687 | char l[4]; |
---|
[5ebff60] | 688 | |
---|
| 689 | if ((bd->flags & 7) == 0 || (bd->flags & MSN_BUDDY_ADL_SYNCED)) { |
---|
| 690 | return FALSE; |
---|
| 691 | } |
---|
| 692 | |
---|
| 693 | strcpy(handle, bu->handle); |
---|
| 694 | if ((domain = strchr(handle, '@')) == NULL) { /* WTF */ |
---|
[e5854a8] | 695 | return FALSE; |
---|
[5ebff60] | 696 | } |
---|
[ca7de3a] | 697 | *domain = '\0'; |
---|
[5ebff60] | 698 | domain++; |
---|
| 699 | |
---|
| 700 | if ((d = adl->children) == NULL || |
---|
| 701 | g_strcasecmp(xt_find_attr(d, "n"), domain) != 0) { |
---|
| 702 | d = xt_new_node("d", NULL, NULL); |
---|
| 703 | xt_add_attr(d, "n", domain); |
---|
| 704 | xt_insert_child(adl, d); |
---|
[ca7de3a] | 705 | } |
---|
[5ebff60] | 706 | |
---|
| 707 | g_snprintf(l, sizeof(l), "%d", bd->flags & 7); |
---|
| 708 | c = xt_new_node("c", NULL, NULL); |
---|
| 709 | xt_add_attr(c, "n", handle); |
---|
| 710 | xt_add_attr(c, "t", "1"); /* FIXME: Network type, i.e. 32 for Y!MSG */ |
---|
[3752019] | 711 | s = xt_new_node("s", NULL, NULL); |
---|
| 712 | xt_add_attr(s, "n", "IM"); |
---|
| 713 | xt_add_attr(s, "l", l); |
---|
| 714 | xt_insert_child(c, s); |
---|
[5ebff60] | 715 | xt_insert_child(d, c); |
---|
| 716 | |
---|
[5a7af1b] | 717 | /* Do this in batches of 100. */ |
---|
| 718 | bd->flags |= MSN_BUDDY_ADL_SYNCED; |
---|
| 719 | return (--md->adl_todo % 140) == 0; |
---|
[ca7de3a] | 720 | } |
---|
| 721 | |
---|
[5ebff60] | 722 | static void msn_ns_send_adl(struct im_connection *ic) |
---|
[ca7de3a] | 723 | { |
---|
| 724 | struct xt_node *adl; |
---|
[5a7af1b] | 725 | struct msn_data *md = ic->proto_data; |
---|
[64768d4] | 726 | char *adls; |
---|
[5ebff60] | 727 | |
---|
| 728 | adl = xt_new_node("ml", NULL, NULL); |
---|
| 729 | xt_add_attr(adl, "l", "1"); |
---|
| 730 | g_tree_foreach(md->domaintree, msn_ns_send_adl_1, adl); |
---|
| 731 | if (adl->children == NULL) { |
---|
[5a7af1b] | 732 | /* This tells the caller that we're done now. */ |
---|
| 733 | md->adl_todo = -1; |
---|
[5ebff60] | 734 | xt_free_node(adl); |
---|
[5a7af1b] | 735 | return; |
---|
| 736 | } |
---|
[5ebff60] | 737 | |
---|
| 738 | adls = xt_to_string(adl); |
---|
| 739 | xt_free_node(adl); |
---|
| 740 | msn_ns_write(ic, -1, "ADL %d %zd\r\n%s", ++md->trId, strlen(adls), adls); |
---|
| 741 | g_free(adls); |
---|
[5a7af1b] | 742 | } |
---|
| 743 | |
---|
[5ebff60] | 744 | static void msn_ns_send_adl_start(struct im_connection *ic) |
---|
[5a7af1b] | 745 | { |
---|
| 746 | struct msn_data *md; |
---|
| 747 | GSList *l; |
---|
[5ebff60] | 748 | |
---|
[5a7af1b] | 749 | /* Dead connection? */ |
---|
[5ebff60] | 750 | if (g_slist_find(msn_connections, ic) == NULL) { |
---|
[5a7af1b] | 751 | return; |
---|
[5ebff60] | 752 | } |
---|
| 753 | |
---|
[5a7af1b] | 754 | md = ic->proto_data; |
---|
| 755 | md->adl_todo = 0; |
---|
[5ebff60] | 756 | for (l = ic->bee->users; l; l = l->next) { |
---|
[5a7af1b] | 757 | bee_user_t *bu = l->data; |
---|
| 758 | struct msn_buddy_data *bd = bu->data; |
---|
[5ebff60] | 759 | |
---|
| 760 | if (bu->ic != ic || (bd->flags & 7) == 0) { |
---|
[5a7af1b] | 761 | continue; |
---|
[5ebff60] | 762 | } |
---|
| 763 | |
---|
[5a7af1b] | 764 | bd->flags &= ~MSN_BUDDY_ADL_SYNCED; |
---|
| 765 | md->adl_todo++; |
---|
| 766 | } |
---|
[5ebff60] | 767 | |
---|
| 768 | msn_ns_send_adl(ic); |
---|
[ca7de3a] | 769 | } |
---|
[80175a1] | 770 | |
---|
[5ebff60] | 771 | int msn_ns_finish_login(struct im_connection *ic) |
---|
[80175a1] | 772 | { |
---|
| 773 | struct msn_data *md = ic->proto_data; |
---|
[5ebff60] | 774 | |
---|
| 775 | if (ic->flags & OPT_LOGGED_IN) { |
---|
[80175a1] | 776 | return 1; |
---|
[5ebff60] | 777 | } |
---|
| 778 | |
---|
| 779 | if (md->adl_todo < 0) { |
---|
[80175a1] | 780 | md->flags |= MSN_DONE_ADL; |
---|
[ed0589c] | 781 | } |
---|
[5ebff60] | 782 | |
---|
| 783 | if ((md->flags & MSN_DONE_ADL) && (md->flags & MSN_GOT_PROFILE)) { |
---|
| 784 | if (md->flags & MSN_EMAIL_UNVERIFIED) { |
---|
| 785 | imcb_connected(ic); |
---|
| 786 | } else { |
---|
| 787 | return msn_ns_set_display_name(ic, set_getstr(&ic->acc->set, "display_name")); |
---|
| 788 | } |
---|
| 789 | } |
---|
| 790 | |
---|
[ed0589c] | 791 | return 1; |
---|
[80175a1] | 792 | } |
---|
[bc676ac] | 793 | |
---|
[ffa5b70] | 794 | // TODO: typing notifications, nudges lol, etc |
---|
[5ebff60] | 795 | int msn_ns_sendmessage(struct im_connection *ic, bee_user_t *bu, const char *text) |
---|
[bc676ac] | 796 | { |
---|
| 797 | struct msn_data *md = ic->proto_data; |
---|
[ffa5b70] | 798 | int retval = 0; |
---|
| 799 | char *buf; |
---|
[5ebff60] | 800 | |
---|
| 801 | if (strncmp(text, "\r\r\r", 3) == 0) { |
---|
[bc676ac] | 802 | /* Err. Shouldn't happen but I guess it can. Don't send others |
---|
| 803 | any of the "SHAKE THAT THING" messages. :-D */ |
---|
| 804 | return 1; |
---|
[5ebff60] | 805 | } |
---|
| 806 | |
---|
[ffa5b70] | 807 | buf = g_strdup_printf(MSN_MESSAGE_HEADERS, bu->handle, ic->acc->user, md->uuid, strlen(text), text); |
---|
| 808 | retval = msn_ns_write(ic, -1, "SDG %d %zd\r\n%s", ++md->trId, strlen(buf), buf); |
---|
| 809 | g_free(buf); |
---|
| 810 | return retval; |
---|
[bc676ac] | 811 | } |
---|
| 812 | |
---|
[5ebff60] | 813 | void msn_ns_oim_send_queue(struct im_connection *ic, GSList **msgq) |
---|
[bc676ac] | 814 | { |
---|
| 815 | GSList *l; |
---|
[5ebff60] | 816 | |
---|
| 817 | for (l = *msgq; l; l = l->next) { |
---|
[bc676ac] | 818 | struct msn_message *m = l->data; |
---|
[5ebff60] | 819 | bee_user_t *bu = bee_user_by_handle(ic->bee, ic, m->who); |
---|
| 820 | |
---|
| 821 | if (bu) { |
---|
| 822 | if (!msn_ns_sendmessage(ic, bu, m->text)) { |
---|
[bc676ac] | 823 | return; |
---|
[5ebff60] | 824 | } |
---|
| 825 | } |
---|
[bc676ac] | 826 | } |
---|
[5ebff60] | 827 | |
---|
| 828 | while (*msgq != NULL) { |
---|
[bc676ac] | 829 | struct msn_message *m = (*msgq)->data; |
---|
[5ebff60] | 830 | |
---|
[05816dd] | 831 | *msgq = g_slist_remove(*msgq, m); |
---|
[5ebff60] | 832 | g_free(m->who); |
---|
| 833 | g_free(m->text); |
---|
| 834 | g_free(m); |
---|
[bc676ac] | 835 | } |
---|
| 836 | } |
---|