Exemple #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
}
Exemple #2
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);
}
Exemple #3
0
gboolean
otr_on_message_send(ProfChatWin *chatwin, const char *const message)
{
    char *id = NULL;
    prof_otrpolicy_t policy = otr_get_policy(chatwin->barejid);

    // Send encrypted message
    if (otr_is_secure(chatwin->barejid)) {
        char *encrypted = otr_encrypt_message(chatwin->barejid, message);
        if (encrypted) {
            id = message_send_chat_otr(chatwin->barejid, encrypted);
            chat_log_otr_msg_out(chatwin->barejid, message);
            chatwin_outgoing_msg(chatwin, message, id, PROF_MSG_OTR);
            otr_free_message(encrypted);
            free(id);
            return TRUE;
        } else {
            ui_win_error_line((ProfWin*)chatwin, "Failed to encrypt and send message.");
            return TRUE;
        }
    }

    // show error if not secure and policy always
    if (policy == PROF_OTRPOLICY_ALWAYS) {
        ui_win_error_line((ProfWin*)chatwin, "Failed to send message. OTR policy set to: always");
        return TRUE;
    }

    // tag and send for policy opportunistic
    if (policy == PROF_OTRPOLICY_OPPORTUNISTIC) {
        char *otr_tagged_msg = otr_tag_message(message);
        id = message_send_chat_otr(chatwin->barejid, otr_tagged_msg);
        chatwin_outgoing_msg(chatwin, message, id, PROF_MSG_PLAIN);
        chat_log_msg_out(chatwin->barejid, message);
        free(otr_tagged_msg);
        free(id);
        return TRUE;
    }

    return FALSE;
}