Esempio n. 1
0
void
sv_ev_lost_connection(void)
{
    cons_show_error("Lost connection.");

#ifdef HAVE_LIBOTR
    GSList *recipients = wins_get_chat_recipients();
    GSList *curr = recipients;
    while (curr) {
        char *barejid = curr->data;
        ProfChatWin *chatwin = wins_get_chat(barejid);
        if (chatwin && otr_is_secure(barejid)) {
            chatwin_otr_unsecured(chatwin);
            otr_end_session(barejid);
        }
        curr = g_slist_next(curr);
    }
    if (recipients) {
        g_slist_free(recipients);
    }
#endif

    muc_invites_clear();
    chat_sessions_clear();
    ui_disconnected();
    roster_destroy();
#ifdef HAVE_LIBGPGME
    p_gpg_on_disconnect();
#endif
}
Esempio n. 2
0
void
api_encryption_reset(const char *const barejid)
{
    if (barejid == NULL) {
        log_warning("%s", "api_encryption_reset failed, barejid is NULL");
        return;
    }

    ProfChatWin *chatwin = wins_get_chat(barejid);
    if (chatwin == NULL) {
        log_warning("%s", "api_encryption_reset failed, could not find chat window for %s", barejid);
        return;
    }

#ifdef HAVE_LIBGPGME
    if (chatwin->pgp_send) {
        chatwin->pgp_send = FALSE;
        win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', "PGP encryption disabled.");
    }
#endif

#ifdef HAVE_LIBOTR
    if (chatwin->is_otr) {
        chatwin_otr_unsecured(chatwin);
        otr_end_session(chatwin->barejid);
    }
#endif
}
Esempio n. 3
0
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);
    }
}
Esempio n. 4
0
void
sv_ev_contact_offline(char *barejid, char *resource, char *status)
{
    gboolean updated = roster_contact_offline(barejid, resource, status);

    if (resource && updated) {
        ui_contact_offline(barejid, resource, status);
    }

#ifdef PROF_HAVE_LIBOTR
    ProfChatWin *chatwin = wins_get_chat(barejid);
    if (chatwin && otr_is_secure(barejid)) {
        chatwin_otr_unsecured(chatwin);
        otr_end_session(chatwin->barejid);
    }
#endif

    rosterwin_roster();
    chat_session_remove(barejid);
}