diff options
author | Paul Fariello <paul@fariello.eu> | 2019-03-18 20:30:28 +0140 |
---|---|---|
committer | Paul Fariello <paul@fariello.eu> | 2019-04-10 17:12:31 +0200 |
commit | 4e1ffa6bdb89269fa5eff9e5ee2484106d52d149 (patch) | |
tree | cd5689a2b23a7e19aaf528842bc42aa52c9aa21d /src/event | |
parent | a9d55dec9275c472d7eea2ff79304eda1aefd3be (diff) | |
download | profani-tty-4e1ffa6bdb89269fa5eff9e5ee2484106d52d149.tar.gz |
Log and print outgoing encrypted message
Diffstat (limited to 'src/event')
-rw-r--r-- | src/event/client_events.c | 29 | ||||
-rw-r--r-- | src/event/server_events.c | 66 | ||||
-rw-r--r-- | src/event/server_events.h | 4 |
3 files changed, 81 insertions, 18 deletions
diff --git a/src/event/client_events.c b/src/event/client_events.c index 1488174a..d1cdc797 100644 --- a/src/event/client_events.c +++ b/src/event/client_events.c @@ -218,7 +218,10 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char *const msg, const char *const oo #ifndef HAVE_LIBGPGME #ifdef HAVE_OMEMO if (chatwin->is_omemo) { - omemo_on_message_send((ProfWin *)chatwin, plugin_msg, request_receipt, FALSE); + char *id = omemo_on_message_send((ProfWin *)chatwin, plugin_msg, request_receipt, FALSE); + chat_log_omemo_msg_out(chatwin->barejid, plugin_msg); + chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_OMEMO, request_receipt); + free(id); } else { char *id = message_send_chat(chatwin->barejid, plugin_msg, oob_url, request_receipt); chat_log_msg_out(chatwin->barejid, plugin_msg); @@ -238,7 +241,10 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char *const msg, const char *const oo #ifndef HAVE_LIBGPGME #ifdef HAVE_OMEMO if (chatwin->is_omemo) { - omemo_on_message_send((ProfWin *)chatwin, plugin_msg, request_receipt, FALSE); + char *id = omemo_on_message_send((ProfWin *)chatwin, plugin_msg, request_receipt, FALSE); + chat_log_omemo_msg_out(chatwin->barejid, plugin_msg); + chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_OMEMO, request_receipt); + free(id); } else { gboolean handled = otr_on_message_send(chatwin, plugin_msg, request_receipt); if (!handled) { @@ -261,7 +267,10 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char *const msg, const char *const oo #ifdef HAVE_LIBGPGME #ifdef HAVE_OMEMO if (chatwin->is_omemo) { - omemo_on_message_send((ProfWin *)chatwin, plugin_msg, request_receipt, FALSE); + char *id = omemo_on_message_send((ProfWin *)chatwin, plugin_msg, request_receipt, FALSE); + chat_log_omemo_msg_out(chatwin->barejid, plugin_msg); + chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_OMEMO, request_receipt); + free(id); } else if (chatwin->pgp_send) { char *id = message_send_chat_pgp(chatwin->barejid, plugin_msg, request_receipt); chat_log_pgp_msg_out(chatwin->barejid, plugin_msg); @@ -286,7 +295,10 @@ cl_ev_send_msg(ProfChatWin *chatwin, const char *const msg, const char *const oo #ifdef HAVE_LIBGPGME #ifdef HAVE_OMEMO if (chatwin->is_omemo) { - omemo_on_message_send((ProfWin *)chatwin, plugin_msg, request_receipt, FALSE); + char *id = omemo_on_message_send((ProfWin *)chatwin, plugin_msg, request_receipt, FALSE); + chat_log_omemo_msg_out(chatwin->barejid, plugin_msg); + chatwin_outgoing_msg(chatwin, plugin_msg, id, PROF_MSG_OMEMO, request_receipt); + free(id); } else if (chatwin->pgp_send) { char *id = message_send_chat_pgp(chatwin->barejid, plugin_msg, request_receipt); chat_log_pgp_msg_out(chatwin->barejid, plugin_msg); @@ -336,9 +348,14 @@ cl_ev_send_muc_msg(ProfMucWin *mucwin, const char *const msg, const char *const #ifdef HAVE_OMEMO if (mucwin->is_omemo) { - omemo_on_message_send((ProfWin *)mucwin, plugin_msg, FALSE, TRUE); + char *id = omemo_on_message_send((ProfWin *)mucwin, plugin_msg, FALSE, TRUE); + groupchat_log_omemo_msg_out(mucwin->roomjid, plugin_msg); + mucwin_outgoing_msg(mucwin, plugin_msg, PROF_MSG_OMEMO); + free(id); } else { message_send_groupchat(mucwin->roomjid, plugin_msg, oob_url); + groupchat_log_msg_out(mucwin->roomjid, plugin_msg); + mucwin_outgoing_msg(mucwin, plugin_msg, PROF_MSG_PLAIN); } plugins_post_room_message_send(mucwin->roomjid, plugin_msg); @@ -348,6 +365,8 @@ cl_ev_send_muc_msg(ProfMucWin *mucwin, const char *const msg, const char *const #ifndef HAVE_OMEMO message_send_groupchat(mucwin->roomjid, plugin_msg, oob_url); + groupchat_log_msg_out(mucwin->roomjid, plugin_msg); + mucwin_outgoing_msg(mucwin, plugin_msg, id, PROF_MSG_PLAIN, request_receipt); plugins_post_room_message_send(mucwin->roomjid, plugin_msg); free(plugin_msg); diff --git a/src/event/server_events.c b/src/event/server_events.c index 7f293198..fd719cc1 100644 --- a/src/event/server_events.c +++ b/src/event/server_events.c @@ -260,21 +260,26 @@ sv_ev_room_history(const char *const room_jid, const char *const nick, } void -sv_ev_room_message(const char *const room_jid, const char *const nick, const char *const message) +sv_ev_room_message(const char *const room_jid, const char *const nick, const char *const message, gboolean omemo) { - if (prefs_get_boolean(PREF_GRLOG)) { - Jid *jid = jid_create(connection_get_fulljid()); - groupchat_log_chat(jid->barejid, room_jid, nick, message); - jid_destroy(jid); - } - ProfMucWin *mucwin = wins_get_muc(room_jid); if (!mucwin) { return; } - char *new_message = plugins_pre_room_message_display(room_jid, nick, message); char *mynick = muc_nick(mucwin->roomjid); + if (g_strcmp0(mynick, nick) == 0) { + /* Ignore message reflection */ + return; + } + + if (omemo) { + groupchat_log_omemo_msg_in(room_jid, nick, message); + } else { + groupchat_log_msg_in(room_jid, nick, message); + } + + char *new_message = plugins_pre_room_message_display(room_jid, nick, message); gboolean whole_word = prefs_get_boolean(PREF_NOTIFY_MENTION_WHOLE_WORD); gboolean case_sensitive = prefs_get_boolean(PREF_NOTIFY_MENTION_CASE_SENSITIVE); @@ -289,7 +294,11 @@ sv_ev_room_message(const char *const room_jid, const char *const nick, const cha GList *triggers = prefs_message_get_triggers(new_message); - mucwin_message(mucwin, nick, new_message, mentions, triggers); + if (omemo) { + mucwin_incoming_msg(mucwin, nick, new_message, mentions, triggers, PROF_MSG_OMEMO); + } else { + mucwin_incoming_msg(mucwin, nick, new_message, mentions, triggers, PROF_MSG_PLAIN); + } g_slist_free(mentions); @@ -607,15 +616,50 @@ sv_ev_incoming_carbon(char *barejid, char *resource, char *message, char *pgp_me } #ifdef HAVE_LIBGPGME +#ifndef HAVE_OMEMO if (pgp_message) { _sv_ev_incoming_pgp(chatwin, new_win, barejid, resource, message, pgp_message, NULL); } else { _sv_ev_incoming_plain(chatwin, new_win, barejid, resource, message, NULL); } -#else - _sv_ev_incoming_plain(chatwin, new_win, barejid, resource, message, NULL); + rosterwin_roster(); + return; +#endif #endif + +#ifdef HAVE_LIBGPGME +#ifdef HAVE_OMEMO + if (pgp_message) { + _sv_ev_incoming_pgp(chatwin, new_win, barejid, resource, message, pgp_message, NULL); + } else if (omemo) { + _sv_ev_incoming_omemo(chatwin, new_win, barejid, resource, message, NULL); + } else { + _sv_ev_incoming_plain(chatwin, new_win, barejid, resource, message, NULL); + } rosterwin_roster(); + return; +#endif +#endif + +#ifndef HAVE_LIBGPGME +#ifdef HAVE_OMEMO + if (omemo) { + _sv_ev_incoming_omemo(chatwin, new_win, barejid, resource, message, NULL); + } else { + _sv_ev_incoming_plain(chatwin, new_win, barejid, resource, message, NULL); + } + rosterwin_roster(); + return; +#endif +#endif + +#ifndef HAVE_LIBGPGME +#ifndef HAVE_OMEMO + _sv_ev_incoming_plain(chatwin, new_win, barejid, resource, message, NULL); + rosterwin_roster(); + return; +#endif +#endif } void diff --git a/src/event/server_events.h b/src/event/server_events.h index 96fdb58c..0fa9989f 100644 --- a/src/event/server_events.h +++ b/src/event/server_events.h @@ -46,9 +46,9 @@ void sv_ev_room_invite(jabber_invite_t invite_type, void sv_ev_room_broadcast(const char *const room_jid, const char *const message); void sv_ev_room_subject(const char *const room, const char *const nick, const char *const subject); void sv_ev_room_history(const char *const room_jid, const char *const nick, - GDateTime *timestamp, const char *const message); + GDateTime *timestamp, const char *const message, gboolean omemo); void sv_ev_room_message(const char *const room_jid, const char *const nick, - const char *const message); + const char *const message, gboolean omemo); void sv_ev_incoming_message(char *barejid, char *resource, char *message, char *pgp_message, GDateTime *timestamp, gboolean omemo); void sv_ev_incoming_private_message(const char *const fulljid, char *message); void sv_ev_delayed_private_message(const char *const fulljid, char *message, GDateTime *timestamp); |