diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/command/command.c | 12 | ||||
-rw-r--r-- | src/command/commands.c | 19 | ||||
-rw-r--r-- | src/server_events.c | 2 | ||||
-rw-r--r-- | src/ui/core.c | 13 | ||||
-rw-r--r-- | src/ui/ui.h | 2 | ||||
-rw-r--r-- | src/xmpp/message.c | 22 | ||||
-rw-r--r-- | src/xmpp/stanza.c | 4 | ||||
-rw-r--r-- | src/xmpp/stanza.h | 2 | ||||
-rw-r--r-- | src/xmpp/xmpp.h | 4 |
9 files changed, 49 insertions, 31 deletions
diff --git a/src/command/command.c b/src/command/command.c index 2186d224..806a75f2 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -1945,7 +1945,7 @@ _cmd_execute_default(const char * inp) if (otr_is_secure(chatwin->barejid)) { char *encrypted = otr_encrypt_message(chatwin->barejid, inp); if (encrypted != NULL) { - message_send_chat_encrypted(chatwin->barejid, encrypted); + char *id = message_send_chat_encrypted(chatwin->barejid, encrypted); otr_free_message(encrypted); if (prefs_get_boolean(PREF_CHLOG)) { const char *jid = jabber_get_fulljid(); @@ -1960,12 +1960,12 @@ _cmd_execute_default(const char * inp) jid_destroy(jidp); } - ui_outgoing_chat_msg("me", chatwin->barejid, inp); + ui_outgoing_chat_msg("me", chatwin->barejid, inp, id); } else { cons_show_error("Failed to send message."); } } else { - message_send_chat(chatwin->barejid, inp); + char *id = message_send_chat(chatwin->barejid, inp); if (prefs_get_boolean(PREF_CHLOG)) { const char *jid = jabber_get_fulljid(); Jid *jidp = jid_create(jid); @@ -1973,10 +1973,10 @@ _cmd_execute_default(const char * inp) jid_destroy(jidp); } - ui_outgoing_chat_msg("me", chatwin->barejid, inp); + ui_outgoing_chat_msg("me", chatwin->barejid, inp, id); } #else - message_send_chat(chatwin->barejid, inp); + char *id = message_send_chat(chatwin->barejid, inp); if (prefs_get_boolean(PREF_CHLOG)) { const char *jid = jabber_get_fulljid(); Jid *jidp = jid_create(jid); @@ -1984,7 +1984,7 @@ _cmd_execute_default(const char * inp) jid_destroy(jidp); } - ui_outgoing_chat_msg("me", chatwin->barejid, inp); + ui_outgoing_chat_msg("me", chatwin->barejid, inp, id); #endif } break; diff --git a/src/command/commands.c b/src/command/commands.c index 1851a3f4..dd63b25f 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -1265,9 +1265,9 @@ cmd_msg(gchar **args, struct cmd_help_t help) if (otr_is_secure(barejid)) { char *encrypted = otr_encrypt_message(barejid, msg); if (encrypted != NULL) { - message_send_chat_encrypted(barejid, encrypted); + char *id = message_send_chat_encrypted(barejid, encrypted); otr_free_message(encrypted); - ui_outgoing_chat_msg("me", barejid, msg); + ui_outgoing_chat_msg("me", barejid, msg, id); if (((win_type == WIN_CHAT) || (win_type == WIN_CONSOLE)) && prefs_get_boolean(PREF_CHLOG)) { const char *jid = jabber_get_fulljid(); @@ -1286,6 +1286,7 @@ cmd_msg(gchar **args, struct cmd_help_t help) } } else { prof_otrpolicy_t policy = otr_get_policy(barejid); + char *id = NULL; if (policy == PROF_OTRPOLICY_ALWAYS) { cons_show_error("Failed to send message. Please check OTR policy"); @@ -1294,13 +1295,13 @@ cmd_msg(gchar **args, struct cmd_help_t help) GString *otr_message = g_string_new(msg); g_string_append(otr_message, OTRL_MESSAGE_TAG_BASE); g_string_append(otr_message, OTRL_MESSAGE_TAG_V2); - message_send_chat_encrypted(barejid, otr_message->str); + id = message_send_chat_encrypted(barejid, otr_message->str); g_string_free(otr_message, TRUE); } else { - message_send_chat(barejid, msg); + id = message_send_chat(barejid, msg); } - ui_outgoing_chat_msg("me", barejid, msg); + ui_outgoing_chat_msg("me", barejid, msg, id); if (((win_type == WIN_CHAT) || (win_type == WIN_CONSOLE)) && prefs_get_boolean(PREF_CHLOG)) { const char *jid = jabber_get_fulljid(); @@ -3073,7 +3074,7 @@ cmd_tiny(gchar **args, struct cmd_help_t help) if (otr_is_secure(chatwin->barejid)) { char *encrypted = otr_encrypt_message(chatwin->barejid, tiny); if (encrypted != NULL) { - message_send_chat_encrypted(chatwin->barejid, encrypted); + char *id = message_send_chat_encrypted(chatwin->barejid, encrypted); otr_free_message(encrypted); if (prefs_get_boolean(PREF_CHLOG)) { const char *jid = jabber_get_fulljid(); @@ -3088,12 +3089,12 @@ cmd_tiny(gchar **args, struct cmd_help_t help) jid_destroy(jidp); } - ui_outgoing_chat_msg("me", chatwin->barejid, tiny); + ui_outgoing_chat_msg("me", chatwin->barejid, tiny, id); } else { cons_show_error("Failed to send message."); } } else { - message_send_chat(chatwin->barejid, tiny); + char *id = message_send_chat(chatwin->barejid, tiny); if (prefs_get_boolean(PREF_CHLOG)) { const char *jid = jabber_get_fulljid(); Jid *jidp = jid_create(jid); @@ -3101,7 +3102,7 @@ cmd_tiny(gchar **args, struct cmd_help_t help) jid_destroy(jidp); } - ui_outgoing_chat_msg("me", chatwin->barejid, tiny); + ui_outgoing_chat_msg("me", chatwin->barejid, tiny, id); } #else message_send_chat(chatwin->barejid, tiny); diff --git a/src/server_events.c b/src/server_events.c index 2509dd43..3d14f0aa 100644 --- a/src/server_events.c +++ b/src/server_events.c @@ -310,7 +310,7 @@ handle_incoming_private_message(char *fulljid, char *message) void handle_carbon(char *barejid, char *message){ - ui_outgoing_chat_msg("me", barejid, message); + ui_outgoing_chat_msg("me", barejid, message, NULL); } void diff --git a/src/ui/core.c b/src/ui/core.c index 48143f48..f43fb2a4 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -1424,7 +1424,7 @@ ui_open_xmlconsole_win(void) void ui_outgoing_chat_msg(const char * const from, const char * const barejid, - const char * const message) + const char * const message, char *id) { PContact contact = roster_get_contact(barejid); ProfWin *window = (ProfWin*)wins_get_chat(barejid); @@ -1460,7 +1460,16 @@ ui_outgoing_chat_msg(const char * const from, const char * const barejid, ProfChatWin *chatwin = (ProfChatWin*)window; chat_state_active(chatwin->state); - win_save_print(window, '-', NULL, 0, THEME_TEXT_ME, from, message); + if (id) { + GString *message_with_id = g_string_new(id); + g_string_append(message_with_id, ": "); + g_string_append(message_with_id, message); + win_save_print(window, '-', NULL, 0, THEME_TEXT_ME, from, message_with_id->str); + g_string_free(message_with_id, TRUE); + free(id); + } else { + win_save_print(window, '-', NULL, 0, THEME_TEXT_ME, from, message); + } ui_switch_win(num); } diff --git a/src/ui/ui.h b/src/ui/ui.h index b621a539..a6428da3 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -122,7 +122,7 @@ void ui_disconnected(void); void ui_recipient_gone(const char * const barejid, const char * const resource); void ui_outgoing_chat_msg(const char * const from, const char * const barejid, - const char * const message); + const char * const message, char *id); void ui_outgoing_private_msg(const char * const from, const char * const fulljid, const char * const message); diff --git a/src/xmpp/message.c b/src/xmpp/message.c index 739a95e6..dea4f8d0 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -79,7 +79,7 @@ message_add_handlers(void) HANDLE(STANZA_NS_CAPTCHA, NULL, _captcha_handler); } -void +char * message_send_chat(const char * const barejid, const char * const msg) { xmpp_conn_t * const conn = connection_get_conn(); @@ -103,7 +103,8 @@ message_send_chat(const char * const barejid, const char * const msg) jid = strdup(barejid); } - xmpp_stanza_t *message = stanza_create_message(ctx, jid, STANZA_TYPE_CHAT, msg); + char *id = create_unique_id("msg"); + xmpp_stanza_t *message = stanza_create_message(ctx, id, jid, STANZA_TYPE_CHAT, msg); free(jid); if (state) { @@ -115,9 +116,11 @@ message_send_chat(const char * const barejid, const char * const msg) xmpp_send(conn, message); xmpp_stanza_release(message); + + return id; } -void +char * message_send_chat_encrypted(const char * const barejid, const char * const msg) { xmpp_conn_t * const conn = connection_get_conn(); @@ -140,7 +143,8 @@ message_send_chat_encrypted(const char * const barejid, const char * const msg) jid = strdup(barejid); } - xmpp_stanza_t *message = stanza_create_message(ctx, barejid, STANZA_TYPE_CHAT, msg); + char *id = create_unique_id("msg"); + xmpp_stanza_t *message = stanza_create_message(ctx, id, barejid, STANZA_TYPE_CHAT, msg); free(jid); if (state) { @@ -153,6 +157,8 @@ message_send_chat_encrypted(const char * const barejid, const char * const msg) xmpp_send(conn, message); xmpp_stanza_release(message); + + return id; } void @@ -160,7 +166,9 @@ message_send_private(const char * const fulljid, const char * const msg) { xmpp_conn_t * const conn = connection_get_conn(); xmpp_ctx_t * const ctx = connection_get_ctx(); - xmpp_stanza_t *message = stanza_create_message(ctx, fulljid, STANZA_TYPE_CHAT, msg); + char *id = create_unique_id("prv"); + xmpp_stanza_t *message = stanza_create_message(ctx, id, fulljid, STANZA_TYPE_CHAT, msg); + free(id); xmpp_send(conn, message); xmpp_stanza_release(message); @@ -171,7 +179,9 @@ message_send_groupchat(const char * const roomjid, const char * const msg) { xmpp_conn_t * const conn = connection_get_conn(); xmpp_ctx_t * const ctx = connection_get_ctx(); - xmpp_stanza_t *message = stanza_create_message(ctx, roomjid, STANZA_TYPE_GROUPCHAT, msg); + char *id = create_unique_id("muc"); + xmpp_stanza_t *message = stanza_create_message(ctx, id, roomjid, STANZA_TYPE_GROUPCHAT, msg); + free(id); xmpp_send(conn, message); xmpp_stanza_release(message); diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c index 635f5678..0b291d2e 100644 --- a/src/xmpp/stanza.c +++ b/src/xmpp/stanza.c @@ -318,7 +318,7 @@ stanza_attach_receipt_request(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza) } xmpp_stanza_t * -stanza_create_message(xmpp_ctx_t *ctx, const char * const recipient, +stanza_create_message(xmpp_ctx_t *ctx, char *id, const char * const recipient, const char * const type, const char * const message) { xmpp_stanza_t *msg, *body, *text; @@ -327,9 +327,7 @@ stanza_create_message(xmpp_ctx_t *ctx, const char * const recipient, xmpp_stanza_set_name(msg, STANZA_NAME_MESSAGE); xmpp_stanza_set_type(msg, type); xmpp_stanza_set_attribute(msg, STANZA_ATTR_TO, recipient); - char *id = create_unique_id(NULL); xmpp_stanza_set_id(msg, id); - free(id); body = xmpp_stanza_new(ctx); xmpp_stanza_set_name(body, STANZA_NAME_BODY); diff --git a/src/xmpp/stanza.h b/src/xmpp/stanza.h index eca3bf8a..50f3dbd0 100644 --- a/src/xmpp/stanza.h +++ b/src/xmpp/stanza.h @@ -194,7 +194,7 @@ xmpp_stanza_t * stanza_attach_state(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza, cons xmpp_stanza_t * stanza_attach_carbons_private(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza); xmpp_stanza_t * stanza_attach_receipt_request(xmpp_ctx_t *ctx, xmpp_stanza_t *stanza); -xmpp_stanza_t* stanza_create_message(xmpp_ctx_t *ctx, +xmpp_stanza_t* stanza_create_message(xmpp_ctx_t *ctx, char *id, const char * const recipient, const char * const type, const char * const message); xmpp_stanza_t* stanza_create_room_join_presence(xmpp_ctx_t * const ctx, diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h index e8e79ee9..7deb71db 100644 --- a/src/xmpp/xmpp.h +++ b/src/xmpp/xmpp.h @@ -145,8 +145,8 @@ char* jabber_get_account_name(void); GList * jabber_get_available_resources(void); // message functions -void message_send_chat(const char * const barejid, const char * const msg); -void message_send_chat_encrypted(const char * const barejid, const char * const msg); +char* message_send_chat(const char * const barejid, const char * const msg); +char* message_send_chat_encrypted(const char * const barejid, const char * const msg); void message_send_private(const char * const fulljid, const char * const msg); void message_send_groupchat(const char * const roomjid, const char * const msg); void message_send_groupchat_subject(const char * const roomjid, const char * const subject); |