static char * _otr_decrypt_message(const char * const from, const char * const message, gboolean *was_decrypted) { char *decrypted = NULL; OtrlTLV *tlvs = NULL; OtrlTLV *tlv = NULL; int result = otrlib_decrypt_message(user_state, &ops, jid, from, message, &decrypted, &tlvs); // internal libotr message if (result == 1) { tlv = otrl_tlv_find(tlvs, OTRL_TLV_DISCONNECTED); if (tlv) { ConnContext *context = otrlib_context_find(user_state, from, jid); if (context != NULL) { otrl_context_force_plaintext(context); ui_gone_insecure(from); } } return NULL; // message was decrypted, return to user } else if (decrypted != NULL) { *was_decrypted = TRUE; return decrypted; // normal non OTR message } else { *was_decrypted = FALSE; return strdup(message); } }
char* otr_decrypt_message(const char *const from, const char *const message, gboolean *decrypted) { char *newmessage = NULL; OtrlTLV *tlvs = NULL; int result = otrlib_decrypt_message(user_state, &ops, jid, from, message, &newmessage, &tlvs); // internal libotr message if (result == 1) { ConnContext *context = otrlib_context_find(user_state, from, jid); // common tlv handling OtrlTLV *tlv = otrl_tlv_find(tlvs, OTRL_TLV_DISCONNECTED); if (tlv) { if (context) { otrl_context_force_plaintext(context); ProfChatWin *chatwin = wins_get_chat(from); if (chatwin) { chatwin_otr_unsecured(chatwin); } } } // library version specific tlv handling otrlib_handle_tlvs(user_state, &ops, context, tlvs, smp_initiators); _otr_tlv_free(tlvs); return NULL; // message was processed, return to user } else if (newmessage) { _otr_tlv_free(tlvs); if (g_str_has_prefix(message, "?OTR:")) { *decrypted = TRUE; } return newmessage; // normal non OTR message } else { _otr_tlv_free(tlvs); *decrypted = FALSE; return strdup(message); } }
char * otr_decrypt_message(const char * const from, const char * const message, gboolean *was_decrypted) { char *decrypted = NULL; OtrlTLV *tlvs = NULL; int result = otrlib_decrypt_message(user_state, &ops, jid, from, message, &decrypted, &tlvs); // internal libotr message if (result == 1) { ConnContext *context = otrlib_context_find(user_state, from, jid); // common tlv handling OtrlTLV *tlv = otrl_tlv_find(tlvs, OTRL_TLV_DISCONNECTED); if (tlv) { if (context) { otrl_context_force_plaintext(context); ui_gone_insecure(from); } } // library version specific tlv handling otrlib_handle_tlvs(user_state, &ops, context, tlvs, smp_initiators); return NULL; // message was decrypted, return to user } else if (decrypted) { *was_decrypted = TRUE; return decrypted; // normal non OTR message } else { *was_decrypted = FALSE; return strdup(message); } }