diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/event/server_events.c | 54 | ||||
-rw-r--r-- | src/event/server_events.h | 4 | ||||
-rw-r--r-- | src/ui/chatwin.c | 9 | ||||
-rw-r--r-- | src/ui/ui.h | 2 | ||||
-rw-r--r-- | src/xmpp/message.c | 24 |
5 files changed, 61 insertions, 32 deletions
diff --git a/src/event/server_events.c b/src/event/server_events.c index 1dd0c004..3d91f297 100644 --- a/src/event/server_events.c +++ b/src/event/server_events.c @@ -349,7 +349,7 @@ sv_ev_delayed_private_message(const char *const fulljid, char *message, GDateTim } void -sv_ev_outgoing_carbon(char *barejid, char *message) +sv_ev_outgoing_carbon(char *barejid, char *message, char *pgp_message) { ProfChatWin *chatwin = wins_get_chat(barejid); if (!chatwin) { @@ -358,22 +358,20 @@ sv_ev_outgoing_carbon(char *barejid, char *message) chat_state_active(chatwin->state); - chatwin_outgoing_carbon(chatwin, message); -} - -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; +#ifdef PROF_HAVE_LIBGPGME + if (pgp_message) { + char *decrypted = p_gpg_decrypt(pgp_message); + if (decrypted) { + chatwin_outgoing_carbon(chatwin, decrypted, PROF_MSG_PGP); + } else { + chatwin_outgoing_carbon(chatwin, message, PROF_MSG_PLAIN); + } + } else { + chatwin_outgoing_carbon(chatwin, message, PROF_MSG_PLAIN); } - - chatwin_incoming_msg(chatwin, resource, message, NULL, new_win, PROF_MSG_PLAIN); - chat_log_msg_in(barejid, message, NULL); +#else + chatwin_outgoing_carbon(chatwin, message, PROF_MSG_PLAIN); +#endif } #ifdef PROF_HAVE_LIBGPGME @@ -414,7 +412,6 @@ _sv_ev_incoming_otr(ProfChatWin *chatwin, gboolean new_win, char *barejid, char } #endif -#ifndef PROF_HAVE_LIBOTR static void _sv_ev_incoming_plain(ProfChatWin *chatwin, gboolean new_win, char *barejid, char *resource, char *message, GDateTime *timestamp) { @@ -422,7 +419,6 @@ _sv_ev_incoming_plain(ProfChatWin *chatwin, gboolean new_win, char *barejid, cha chat_log_msg_in(barejid, message, timestamp); chatwin->pgp_recv = FALSE; } -#endif void sv_ev_incoming_message(char *barejid, char *resource, char *message, char *pgp_message, GDateTime *timestamp) @@ -485,6 +481,28 @@ sv_ev_incoming_message(char *barejid, char *resource, char *message, char *pgp_m } void +sv_ev_incoming_carbon(char *barejid, char *resource, char *message, char *pgp_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; + } + +#ifdef PROF_HAVE_LIBGPGME + 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); +#endif +} + +void sv_ev_message_receipt(char *barejid, char *id) { ProfChatWin *chatwin = wins_get_chat(barejid); diff --git a/src/event/server_events.h b/src/event/server_events.h index f7038beb..b16eddbc 100644 --- a/src/event/server_events.h +++ b/src/event/server_events.h @@ -73,8 +73,8 @@ void sv_ev_room_occupent_kicked(const char *const room, const char *const nick, void sv_ev_room_banned(const char *const room, const char *const actor, const char *const reason); void sv_ev_room_occupent_banned(const char *const room, const char *const nick, const char *const actor, const char *const reason); -void sv_ev_outgoing_carbon(char *barejid, char *message); -void sv_ev_incoming_carbon(char *barejid, char *resource, char *message); +void sv_ev_outgoing_carbon(char *barejid, char *message, char *pgp_message); +void sv_ev_incoming_carbon(char *barejid, char *resource, char *message, char *pgp_message); void sv_ev_xmpp_stanza(const char *const msg); void sv_ev_muc_self_online(const char *const room, const char *const nick, gboolean config_required, const char *const role, const char *const affiliation, const char *const actor, const char *const reason, diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c index cbf0c93a..179e8a06 100644 --- a/src/ui/chatwin.c +++ b/src/ui/chatwin.c @@ -312,11 +312,16 @@ chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, } void -chatwin_outgoing_carbon(ProfChatWin *chatwin, const char *const message) +chatwin_outgoing_carbon(ProfChatWin *chatwin, const char *const message, prof_enc_t enc_mode) { assert(chatwin != NULL); - win_print((ProfWin*)chatwin, '-', 0, NULL, 0, THEME_TEXT_ME, "me", message); + char enc_char = '-'; + if (enc_mode == PROF_MSG_PGP) { + enc_char = prefs_get_pgp_char(); + } + + win_print((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", message); int num = wins_get_num((ProfWin*)chatwin); status_bar_active(num); } diff --git a/src/ui/ui.h b/src/ui/ui.h index f8cb1de7..d5d741d6 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -131,7 +131,7 @@ void chatwin_incoming_msg(ProfChatWin *chatwin, const char *const resource, cons void chatwin_receipt_received(ProfChatWin *chatwin, const char *const id); void chatwin_recipient_gone(ProfChatWin *chatwin); void chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, prof_enc_t enc_mode); -void chatwin_outgoing_carbon(ProfChatWin *chatwin, const char *const message); +void chatwin_outgoing_carbon(ProfChatWin *chatwin, const char *const message, prof_enc_t enc_mode); void chatwin_contact_online(ProfChatWin *chatwin, Resource *resource, GDateTime *last_activity); void chatwin_contact_offline(ProfChatWin *chatwin, char *resource, char *status); char* chatwin_get_string(ProfChatWin *chatwin); diff --git a/src/xmpp/message.c b/src/xmpp/message.c index ccd4d624..6e3e7721 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -191,8 +191,6 @@ message_send_chat_pgp(const char *const barejid, const char *const msg) stanza_attach_state(ctx, message, state); } - stanza_attach_carbons_private(ctx, message); - if (prefs_get_boolean(PREF_RECEIPTS_REQUEST)) { stanza_attach_receipt_request(ctx, message); } @@ -714,17 +712,25 @@ _handle_carbons(xmpp_stanza_t *const stanza) // check for and deal with message xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(message, STANZA_NAME_BODY); if (body) { - char *message = xmpp_stanza_get_text(body); - if (message) { + char *message_txt = xmpp_stanza_get_text(body); + if (message_txt) { + // check for pgp encrypted message + char *enc_message = NULL; + xmpp_stanza_t *x = xmpp_stanza_get_child_by_ns(message, STANZA_NS_ENCRYPTED); + if (x) { + enc_message = xmpp_stanza_get_text(x); + } + // if we are the recipient, treat as standard incoming message if(g_strcmp0(my_jid->barejid, jid_to->barejid) == 0){ - sv_ev_incoming_carbon(jid_from->barejid, jid_from->resourcepart, message); - } + sv_ev_incoming_carbon(jid_from->barejid, jid_from->resourcepart, message_txt, enc_message); + // else treat as a sent message - else{ - sv_ev_outgoing_carbon(jid_to->barejid, message); + } else { + sv_ev_outgoing_carbon(jid_to->barejid, message_txt, enc_message); } - xmpp_free(ctx, message); + xmpp_free(ctx, message_txt); + xmpp_free(ctx, enc_message); } } |