comparison mcabber/mcabber/otr.c @ 2329:746d72c6e1b9

Fix otr disconnected message for otrv4
author franky
date Thu, 09 May 2019 23:18:15 +0200
parents f5402d705f67
children 0dc317b5599d
comparison
equal deleted inserted replaced
2328:1e24d93746d6 2329:746d72c6e1b9
550 */ 550 */
551 int otr_receive(char **otr_data, const char *buddy, int *free_msg) 551 int otr_receive(char **otr_data, const char *buddy, int *free_msg)
552 { 552 {
553 int ignore_message; 553 int ignore_message;
554 char *newmessage = NULL; 554 char *newmessage = NULL;
555 #ifdef HAVE_LIBOTR3
556 OtrlTLV *tlvs = NULL; 555 OtrlTLV *tlvs = NULL;
557 OtrlTLV *tlv = NULL; 556 OtrlTLV *tlv = NULL;
558 #endif
559 ConnContext *ctx; 557 ConnContext *ctx;
560 558
561 ctx = otr_get_context(buddy); 559 ctx = otr_get_context(buddy);
562 *free_msg = 0; 560 *free_msg = 0;
561
562 if (!ctx)
563 return 0;
564
563 ignore_message = otrl_message_receiving(userstate, &ops, NULL, 565 ignore_message = otrl_message_receiving(userstate, &ops, NULL,
564 ctx->accountname, ctx->protocol, 566 ctx->accountname, ctx->protocol,
565 ctx->username, *otr_data, 567 ctx->username, *otr_data,
566 #ifdef HAVE_LIBOTR3 568 #ifdef HAVE_LIBOTR3
567 &newmessage, &tlvs, NULL, NULL); 569 &newmessage, &tlvs, NULL, NULL);
570 otr_handle_smp_tlvs(tlvs, ctx);
571 #else
572 &newmessage, &tlvs, NULL, NULL, NULL);
573 #endif
568 574
569 tlv = otrl_tlv_find(tlvs, OTRL_TLV_DISCONNECTED); 575 tlv = otrl_tlv_find(tlvs, OTRL_TLV_DISCONNECTED);
570 if (tlv) { 576 if (tlv) {
571 /* Notify the user that the other side disconnected. */ 577 /* Notify the user that the other side disconnected. */
572 if (ctx) { 578 cb_gone_insecure(NULL, ctx);
573 cb_gone_insecure(NULL, ctx); 579 otr_disconnect(ctx->username);
574 otr_disconnect(ctx->username); 580 }
575 } 581
576 } 582 otrl_tlv_free(tlvs);
577
578 otr_handle_smp_tlvs(tlvs, ctx);
579
580 if (tlvs != NULL)
581 otrl_tlv_free(tlvs);
582 #else
583 &newmessage, NULL, NULL, NULL, NULL);
584 #endif
585 583
586 if (ignore_message) 584 if (ignore_message)
587 *otr_data = NULL; 585 *otr_data = NULL;
588 586
589 if (!ignore_message && newmessage) { 587 if (!ignore_message && newmessage) {