void handle_incoming_message(char *from, char *message, gboolean priv) { #ifdef HAVE_LIBOTR gboolean was_decrypted = FALSE; char *newmessage; if (!priv) { newmessage = otr_decrypt_message(from, message, &was_decrypted); // internal OTR message if (newmessage == NULL) { return; } } else { newmessage = message; } ui_incoming_msg(from, newmessage, NULL, priv); ui_current_page_off(); if (prefs_get_boolean(PREF_CHLOG) && !priv) { Jid *from_jid = jid_create(from); const char *jid = jabber_get_fulljid(); Jid *jidp = jid_create(jid); if (!was_decrypted || (strcmp(prefs_get_string(PREF_OTR_LOG), "on") == 0)) { chat_log_chat(jidp->barejid, from_jid->barejid, newmessage, PROF_IN_LOG, NULL); } else if (strcmp(prefs_get_string(PREF_OTR_LOG), "redact") == 0) { chat_log_chat(jidp->barejid, from_jid->barejid, "[redacted]", PROF_IN_LOG, NULL); } jid_destroy(jidp); jid_destroy(from_jid); } if (!priv) otr_free_message(newmessage); #else ui_incoming_msg(from, message, NULL, priv); ui_current_page_off(); if (prefs_get_boolean(PREF_CHLOG) && !priv) { Jid *from_jid = jid_create(from); const char *jid = jabber_get_fulljid(); Jid *jidp = jid_create(jid); chat_log_chat(jidp->barejid, from_jid->barejid, message, PROF_IN_LOG, NULL); jid_destroy(jidp); jid_destroy(from_jid); } #endif }
void sv_ev_incoming_message(char *barejid, char *resource, char *message) { #ifdef HAVE_LIBOTR otr_on_message_recv(barejid, resource, message); #else ui_incoming_msg(barejid, resource, message, NULL); chat_log_msg_in(barejid, message); #endif }
void sv_ev_delayed_message(char *barejid, char *message, GDateTime *timestamp) { gboolean new_win = FALSE; ProfChatWin *chatwin = wins_get_chat(barejid); if (!chatwin) { ProfWin *window = wins_new_chat(barejid); chatwin = (ProfChatWin*)window; new_win = TRUE; } ui_incoming_msg(chatwin, NULL, message, timestamp, new_win); chat_log_msg_in_delayed(barejid, message, timestamp); }
void sv_ev_incoming_carbon(char *barejid, char *resource, char *message) { gboolean new_win = FALSE; ProfChatWin *chatwin = wins_get_chat(barejid); if (!chatwin) { ProfWin *window = wins_new_chat(barejid); chatwin = (ProfChatWin*)window; new_win = TRUE; } ui_incoming_msg(chatwin, resource, message, NULL, new_win); chat_log_msg_in(barejid, message); }
void handle_delayed_message(char *from, char *message, GTimeVal tv_stamp, gboolean priv) { ui_incoming_msg(from, message, &tv_stamp, priv); if (prefs_get_boolean(PREF_CHLOG) && !priv) { Jid *from_jid = jid_create(from); const char *jid = jabber_get_fulljid(); Jid *jidp = jid_create(jid); chat_log_chat(jidp->barejid, from_jid->barejid, message, PROF_IN_LOG, &tv_stamp); jid_destroy(jidp); jid_destroy(from_jid); } }
void sv_ev_delayed_message(char *barejid, char *message, GTimeVal tv_stamp) { ui_incoming_msg(barejid, NULL, message, &tv_stamp); chat_log_msg_in_delayed(barejid, message, &tv_stamp); }
void sv_ev_incoming_message(char *barejid, char *resource, char *message, char *enc_message) { gboolean new_win = FALSE; ProfChatWin *chatwin = wins_get_chat(barejid); if (!chatwin) { ProfWin *window = wins_new_chat(barejid); chatwin = (ProfChatWin*)window; new_win = TRUE; } // OTR suported, PGP supported #ifdef HAVE_LIBOTR #ifdef HAVE_LIBGPGME prof_enc_t enc_mode = chatwin->enc_mode; if (enc_message) { if (enc_mode == PROF_ENC_OTR) { win_println((ProfWin*)chatwin, "PGP encrypted message received whilst in OTR session."); } else { // PROF_ENC_NONE, PROF_ENC_PGP char *decrypted = p_gpg_decrypt(barejid, enc_message); if (decrypted) { if (enc_mode == PROF_ENC_NONE) { win_println((ProfWin*)chatwin, "PGP encryption enabled."); } ui_incoming_msg(chatwin, resource, decrypted, NULL, new_win); chat_log_pgp_msg_in(barejid, decrypted); chatwin->enc_mode = PROF_ENC_PGP; } else { ui_incoming_msg(chatwin, resource, message, NULL, new_win); chat_log_msg_in(barejid, message); chatwin->enc_mode = PROF_ENC_NONE; } } } else { if (enc_mode == PROF_ENC_PGP) { win_println((ProfWin*)chatwin, "PGP encryption disabled."); ui_incoming_msg(chatwin, resource, message, NULL, new_win); chat_log_msg_in(barejid, message); chatwin->enc_mode = PROF_ENC_NONE; } else { gboolean decrypted = FALSE; char *otr_res = otr_on_message_recv(barejid, resource, message, &decrypted); if (otr_res) { ui_incoming_msg(chatwin, resource, otr_res, NULL, new_win); chat_log_otr_msg_in(barejid, otr_res, decrypted); otr_free_message(otr_res); } } } return; #endif #endif // OTR supported, PGP unsupported #ifdef HAVE_LIBOTR #ifndef HAVE_LIBGPGME gboolean decrypted = FALSE; char *otr_res = otr_on_message_recv(barejid, resource, message, &decrypted); if (otr_res) { ui_incoming_msg(chatwin, resource, otr_res, NULL, new_win); chat_log_otr_msg_in(barejid, otr_res, decrypted); otr_free_message(otr_res); } return; #endif #endif // OTR unsupported, PGP supported #ifndef HAVE_LIBOTR #ifdef HAVE_LIBGPGME if (enc_message) { char *decrypted = p_gpg_decrypt(barejid, enc_message); if (decrypted) { ui_incoming_msg(chatwin, resource, decrypted, NULL, new_win); chat_log_pgp_msg_in(barejid, decrypted); chatwin->enc_mode = PROF_ENC_PGP; } else { ui_incoming_msg(chatwin, resource, message, NULL, new_win); chat_log_msg_in(barejid, message); chatwin->enc_mode = PROF_ENC_NONE; } } else { ui_incoming_msg(chatwin, resource, message, NULL, new_win); chat_log_msg_in(barejid, message); chatwin->enc_mode = PROF_ENC_NONE; } return; #endif #endif // OTR unsupported, PGP unsupported #ifndef HAVE_LIBOTR #ifndef HAVE_LIBGPGME ui_incoming_msg(chatwin, resource, message, NULL, new_win); chat_log_msg_in(barejid, message); chatwin->enc_mode = PROF_ENC_NONE; return; #endif #endif }
void handle_incoming_message(char *from, char *message, gboolean priv) { #ifdef HAVE_LIBOTR gboolean was_decrypted = FALSE; char *newmessage; prof_otrpolicy_t policy = otr_get_policy(from); char *whitespace_base = strstr(message,OTRL_MESSAGE_TAG_BASE); if (!priv) { //check for OTR whitespace (opportunistic or always) if (policy == PROF_OTRPOLICY_OPPORTUNISTIC || policy == PROF_OTRPOLICY_ALWAYS) { if (whitespace_base) { if (strstr(message, OTRL_MESSAGE_TAG_V2) || strstr(message, OTRL_MESSAGE_TAG_V1)) { // Remove whitespace pattern for proper display in UI // Handle both BASE+TAGV1/2(16+8) and BASE+TAGV1+TAGV2(16+8+8) int tag_length = 24; if (strstr(message, OTRL_MESSAGE_TAG_V2) && strstr(message, OTRL_MESSAGE_TAG_V1)) { tag_length = 32; } memmove(whitespace_base, whitespace_base+tag_length, tag_length); char *otr_query_message = otr_start_query(); cons_show("OTR Whitespace pattern detected. Attempting to start OTR session..."); message_send(otr_query_message, from); } } } newmessage = otr_decrypt_message(from, message, &was_decrypted); // internal OTR message if (newmessage == NULL) { return; } } else { newmessage = message; } if (policy == PROF_OTRPOLICY_ALWAYS && !was_decrypted && !whitespace_base) { char *otr_query_message = otr_start_query(); cons_show("Attempting to start OTR session..."); message_send(otr_query_message, from); } ui_incoming_msg(from, newmessage, NULL, priv); if (prefs_get_boolean(PREF_CHLOG) && !priv) { Jid *from_jid = jid_create(from); const char *jid = jabber_get_fulljid(); Jid *jidp = jid_create(jid); char *pref_otr_log = prefs_get_string(PREF_OTR_LOG); if (!was_decrypted || (strcmp(pref_otr_log, "on") == 0)) { chat_log_chat(jidp->barejid, from_jid->barejid, newmessage, PROF_IN_LOG, NULL); } else if (strcmp(pref_otr_log, "redact") == 0) { chat_log_chat(jidp->barejid, from_jid->barejid, "[redacted]", PROF_IN_LOG, NULL); } prefs_free_string(pref_otr_log); jid_destroy(jidp); jid_destroy(from_jid); } if (!priv) otr_free_message(newmessage); #else ui_incoming_msg(from, message, NULL, priv); if (prefs_get_boolean(PREF_CHLOG) && !priv) { Jid *from_jid = jid_create(from); const char *jid = jabber_get_fulljid(); Jid *jidp = jid_create(jid); chat_log_chat(jidp->barejid, from_jid->barejid, message, PROF_IN_LOG, NULL); jid_destroy(jidp); jid_destroy(from_jid); } #endif }