1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Refactor win_print_outgoing()

We never use the printf like behaviour anyways.
This commit is contained in:
Michael Vetter 2020-02-17 11:48:50 +01:00
parent 92f6930175
commit 69d474b3a7
4 changed files with 10 additions and 19 deletions

View File

@ -328,7 +328,7 @@ chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id,
if (request_receipt && id) {
win_print_outgoing_with_receipt((ProfWin*)chatwin, enc_char, "me", message, id, replace_id);
} else {
win_print_outgoing((ProfWin*)chatwin, enc_char, id, replace_id, "%s", message);
win_print_outgoing((ProfWin*)chatwin, enc_char, id, replace_id, message);
}
// save last id and message for LMC
@ -351,7 +351,7 @@ chatwin_outgoing_carbon(ProfChatWin *chatwin, ProfMessage *message)
ProfWin *window = (ProfWin*)chatwin;
win_print_outgoing(window, enc_char, message->id, message->replace_id, "%s", message->plain);
win_print_outgoing(window, enc_char, message->id, message->replace_id, message->plain);
int num = wins_get_num(window);
status_bar_active(num, WIN_CHAT, chatwin->barejid);
}

View File

@ -95,7 +95,7 @@ privwin_outgoing_msg(ProfPrivateWin *privwin, const char *const message)
{
assert(privwin != NULL);
win_print_outgoing((ProfWin*)privwin, '-', NULL, NULL ,"%s", message);
win_print_outgoing((ProfWin*)privwin, '-', NULL, NULL , message);
}
void

View File

@ -1196,26 +1196,19 @@ win_print_outgoing_muc_msg(ProfWin *window, char ch, const char *const me, const
}
void
win_print_outgoing(ProfWin *window, const char ch, const char *const id, const char *const replace_id, const char *const message, ...)
win_print_outgoing(ProfWin *window, const char ch, const char *const id, const char *const replace_id, const char *const message)
{
//TODO: we always use current timestamp here. instead of the message->timestamp one if available. i think somewhere else we check whether it exists first.
GDateTime *timestamp = g_date_time_new_now_local();
va_list arg;
va_start(arg, message);
GString *fmt_msg = g_string_new(NULL);
g_string_vprintf(fmt_msg, message, arg);
if (replace_id) {
_win_correct(window, fmt_msg->str, id, replace_id);
_win_correct(window, message, id, replace_id);
} else {
_win_printf(window, ch, 0, timestamp, 0, THEME_TEXT_THEM, "me", id, "%s", fmt_msg->str);
_win_printf(window, ch, 0, timestamp, 0, THEME_TEXT_THEM, "me", id, "%s", message);
}
inp_nonblocking(TRUE);
g_date_time_unref(timestamp);
g_string_free(fmt_msg, TRUE);
va_end(arg);
}
void

View File

@ -63,17 +63,15 @@ void win_show_status_string(ProfWin *window, const char *const from,
const char *const default_show);
void win_print_them(ProfWin *window, theme_item_t theme_item, char ch, int flags, const char *const them);
void win_print_incoming(ProfWin *window, const char *const from, ProfMessage *message);
void win_print_outgoing(ProfWin *window, const char ch, const char *const id, const char *const replace_id, const char *const message);
void win_print_outgoing_with_receipt(ProfWin *window, const char show_char, const char *const from, const char *const message, char *id, const char *const replace_id);
void win_println_incoming_muc_msg(ProfWin *window, char ch, int flags, const char *const them, const char *const id, const char *const replace_id, const char *const message, ...);
void win_print_outgoing_muc_msg(ProfWin *window, char ch, const char *const me, const char *const id, const char *const replace_id, const char *const message, ...);
void win_print_outgoing(ProfWin *window, const char ch, const char *const id, const char *const replace_id, const char *const message, ...);
void win_print_incoming(ProfWin *window, const char *const from, ProfMessage *message);
void win_print_history(ProfWin *window, GDateTime *timestamp, const char *const message, ...);
void win_print_http_upload(ProfWin *window, const char *const message, char *url);
void win_print_outgoing_with_receipt(ProfWin *window, const char show_char, const char *const from, const char *const message, char *id, const char *const replace_id);
void win_newline(ProfWin *window);
void win_redraw(ProfWin *window);
int win_roster_cols(void);