Changeset c5a1502 for protocols/msn/ns.c
- Timestamp:
- 2015-03-15T14:41:47Z (10 years ago)
- Children:
- e2bf725
- Parents:
- 6e74911
- git-author:
- dequis <dx@…> (09-03-15 08:26:16)
- git-committer:
- dequis <dx@…> (15-03-15 14:41:47)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/msn/ns.c
r6e74911 rc5a1502 248 248 handler->msglen = atoi(cmd[2]); 249 249 } 250 } else if (strcmp(cmd[0], "PRP") == 0) {251 imcb_connected(ic);252 250 } else if (strcmp(cmd[0], "CHL") == 0) { 253 251 char *resp; … … 267 265 g_free(resp); 268 266 return st; 269 } else if (strcmp(cmd[0], "ILN") == 0 || strcmp(cmd[0], "NLN") == 0) {270 const struct msn_away_state *st;271 const char *handle;272 int cap = 0;273 274 if (num_parts < 6) {275 imcb_error(ic, "Syntax error");276 imc_logout(ic, TRUE);277 return(0);278 }279 /* ILN and NLN are more or less the same, except ILN has a trId280 at the start, and NLN has a capability field at the end.281 Does ILN still exist BTW? */282 if (cmd[0][1] == 'I') {283 cmd++;284 } else {285 cap = atoi(cmd[4]);286 }287 288 handle = msn_normalize_handle(cmd[2]);289 if (strcmp(handle, ic->acc->user) == 0) {290 return 1; /* That's me! */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) {298 /* FIXME: Warn/Bomb about unknown away state? */299 st = msn_away_state_list + 1;300 }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) {308 const char *handle;309 310 if (cmd[1] == NULL) {311 return 1;312 }313 314 handle = msn_normalize_handle(cmd[1]);315 imcb_buddy_status(ic, handle, 0, NULL, NULL);316 267 } else if (strcmp(cmd[0], "OUT") == 0) { 317 268 int allow_reconnect = TRUE; … … 329 280 imc_logout(ic, allow_reconnect); 330 281 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); 340 } 341 } 342 #if 0 343 else if (strcmp(cmd[0], "ADG") == 0) { 344 char *group = g_strdup(cmd[3]); 345 int groupnum, i; 346 GSList *l, *next; 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++) { 353 md->grouplist[i] = NULL; 354 } 355 md->groupcount = groupnum + 1; 356 } 357 g_free(md->grouplist[groupnum]); 358 md->grouplist[groupnum] = group; 359 } else { 360 /* Shouldn't happen, but if it does, give up on the group. */ 361 g_free(group); 362 imcb_error(ic, "Syntax error"); 363 imc_logout(ic, TRUE); 364 return 0; 365 } 366 367 for (l = md->grpq; l; l = next) { 368 struct msn_groupadd *ga = l->data; 369 next = l->next; 370 if (g_strcasecmp(ga->group, group) == 0) { 371 if (!msn_buddy_list_add(ic, "FL", ga->who, ga->who, group)) { 372 return 0; 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); 379 } 380 } 381 } 382 #endif 383 else if (strcmp(cmd[0], "GCF") == 0) { 282 } else if (strcmp(cmd[0], "GCF") == 0) { 384 283 /* Coming up is cmd[2] bytes of stuff we're supposed to 385 284 censore. Meh. */ 386 285 handler->msglen = atoi(cmd[2]); 387 } else if (strcmp(cmd[0], "UBX") == 0) {388 /* Status message. */389 if (num_parts >= 3) {390 handler->msglen = atoi(cmd[2]);391 }392 } else if (strcmp(cmd[0], "NOT") == 0) {393 /* Some kind of notification, poorly documented but394 apparently used to announce address book changes. */395 if (num_parts >= 2) {396 handler->msglen = atoi(cmd[1]);397 }398 286 } else if ((strcmp(cmd[0], "NFY") == 0) || (strcmp(cmd[0], "SDG") == 0)) { 399 287 if (num_parts >= 3) { 400 288 handler->msglen = atoi(cmd[2]); 401 }402 } else if (strcmp(cmd[0], "UBM") == 0) {403 if (num_parts >= 7) {404 handler->msglen = atoi(cmd[6]);405 289 } 406 290 } else if (strcmp(cmd[0], "QNG") == 0) { … … 422 306 } 423 307 } else { 424 /* debug( "Received unknown command from main server: %s", cmd[0] ); */308 imcb_error(ic, "Received unknown command from main server: %s", cmd[0]); 425 309 } 426 310 … … 501 385 } 502 386 } 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) { 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.. 511 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. :-( */ 516 517 char *xml = get_rfc822_header(body, "Mail-Data:", blen); 518 struct xt_node *md, *m; 519 520 if (!xml) { 521 return 1; 522 } 523 md = xt_from_string(xml, 0); 524 if (!md) { 525 return 1; 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"); 531 struct tm tp; 532 time_t msgtime = 0; 533 534 if (!e || !e->text) { 535 continue; 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) { 543 tp.tm_year -= 1900; 544 tp.tm_mon--; 545 msgtime = mktime_utc(&tp); 546 547 } 548 imcb_buddy_msg(ic, e->text, 549 "<< \002BitlBee\002 - Received offline message. BitlBee can't show these. >>", 0, 550 msgtime); 551 } 552 553 g_free(xml); 554 xt_free_node(md); 387 /* Notification that a message has been read... Ignore it */ 555 388 } else { 556 389 debug("Can't handle %s packet from notification server", ct); … … 559 392 g_free(ct); 560 393 } 561 } else if (strcmp(cmd[0], "UBX") == 0) {562 struct xt_node *ubx, *psm;563 char *psm_text = NULL;564 565 ubx = xt_from_string(msg, msglen);566 if (ubx && strcmp(ubx->name, "Data") == 0 &&567 (psm = xt_find_node(ubx->children, "PSM"))) {568 psm_text = psm->text;569 }570 571 imcb_buddy_status_msg(ic, msn_normalize_handle(cmd[1]), psm_text);572 xt_free_node(ubx);573 394 } else if (strcmp(cmd[0], "ADL") == 0) { 574 395 struct xt_node *adl, *d, *c; … … 782 603 783 604 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 } 605 imcb_connected(ic); 789 606 } 790 607 … … 810 627 return retval; 811 628 } 812 813 void msn_ns_oim_send_queue(struct im_connection *ic, GSList **msgq)814 {815 GSList *l;816 817 for (l = *msgq; l; l = l->next) {818 struct msn_message *m = l->data;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)) {823 return;824 }825 }826 }827 828 while (*msgq != NULL) {829 struct msn_message *m = (*msgq)->data;830 831 *msgq = g_slist_remove(*msgq, m);832 g_free(m->who);833 g_free(m->text);834 g_free(m);835 }836 }
Note: See TracChangeset
for help on using the changeset viewer.