diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/core.c | 26 | ||||
-rw-r--r-- | src/ui/ui.h | 10 | ||||
-rw-r--r-- | src/ui/window.c | 22 | ||||
-rw-r--r-- | src/ui/window.h | 2 |
4 files changed, 26 insertions, 34 deletions
diff --git a/src/ui/core.c b/src/ui/core.c index a7e46437..fa419e45 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -416,7 +416,7 @@ ui_message_receipt(const char * const barejid, const char * const id) } void -ui_incoming_msg(ProfChatWin *chatwin, const char * const resource, const char * const message, GTimeVal *tv_stamp, gboolean win_created) +ui_incoming_msg(ProfChatWin *chatwin, const char * const resource, const char * const message, GDateTime *timestamp, gboolean win_created) { ProfWin *window = (ProfWin*)chatwin; int num = wins_get_num(window); @@ -425,7 +425,7 @@ ui_incoming_msg(ProfChatWin *chatwin, const char * const resource, const char * // currently viewing chat window with sender if (wins_is_current(window)) { - win_print_incoming_message(window, tv_stamp, display_name, message); + win_print_incoming_message(window, timestamp, display_name, message); title_bar_set_typing(FALSE); status_bar_active(num); @@ -444,14 +444,14 @@ ui_incoming_msg(ProfChatWin *chatwin, const char * const resource, const char * } // show users status first, when receiving message via delayed delivery - if (tv_stamp && win_created) { + if (timestamp && win_created) { PContact pcontact = roster_get_contact(chatwin->barejid); if (pcontact) { win_show_contact(window, pcontact); } } - win_print_incoming_message(window, tv_stamp, display_name, message); + win_print_incoming_message(window, timestamp, display_name, message); } if (prefs_get_boolean(PREF_BEEP)) { @@ -466,7 +466,7 @@ ui_incoming_msg(ProfChatWin *chatwin, const char * const resource, const char * } void -ui_incoming_private_msg(const char * const fulljid, const char * const message, GTimeVal *tv_stamp) +ui_incoming_private_msg(const char * const fulljid, const char * const message, GDateTime *timestamp) { char *display_from = NULL; display_from = get_nick_from_full_jid(fulljid); @@ -482,7 +482,7 @@ ui_incoming_private_msg(const char * const fulljid, const char * const message, // currently viewing chat window with sender if (wins_is_current(window)) { - win_print_incoming_message(window, tv_stamp, display_from, message); + win_print_incoming_message(window, timestamp, display_from, message); title_bar_set_typing(FALSE); status_bar_active(num); @@ -491,7 +491,7 @@ ui_incoming_private_msg(const char * const fulljid, const char * const message, privatewin->unread++; status_bar_new(num); cons_show_incoming_message(display_from, num); - win_print_incoming_message(window, tv_stamp, display_from, message); + win_print_incoming_message(window, timestamp, display_from, message); if (prefs_get_boolean(PREF_FLASH)) { flash(); @@ -1665,7 +1665,7 @@ ui_room_nick_change(const char * const roomjid, const char * const nick) void ui_room_history(const char * const roomjid, const char * const nick, - GTimeVal tv_stamp, const char * const message) + GDateTime *timestamp, const char * const message) { ProfWin *window = (ProfWin*)wins_get_muc(roomjid); if (window == NULL) { @@ -1684,7 +1684,7 @@ ui_room_history(const char * const roomjid, const char * const nick, g_string_append(line, message); } - win_print(window, '-', &tv_stamp, NO_COLOUR_DATE, 0, "", line->str); + win_print(window, '-', timestamp, NO_COLOUR_DATE, 0, "", line->str); g_string_free(line, TRUE); } } @@ -2808,11 +2808,9 @@ _win_show_history(ProfChatWin *chatwin, const char * const contact) char hh[3]; memcpy(hh, &line[0], 2); hh[2] = '\0'; int ihh = atoi(hh); char mm[3]; memcpy(mm, &line[3], 2); mm[2] = '\0'; int imm = atoi(mm); char ss[3]; memcpy(ss, &line[6], 2); ss[2] = '\0'; int iss = atoi(ss); - GDateTime *time = g_date_time_new_local(2000, 1, 1, ihh, imm, iss); - GTimeVal tv; - g_date_time_to_timeval(time, &tv); - win_print((ProfWin*)chatwin, '-', &tv, NO_COLOUR_DATE, 0, "", curr->data+11); - g_date_time_unref(time); + GDateTime *timestamp = g_date_time_new_local(2000, 1, 1, ihh, imm, iss); + win_print((ProfWin*)chatwin, '-', timestamp, NO_COLOUR_DATE, 0, "", curr->data+11); + g_date_time_unref(timestamp); // header } else { win_print((ProfWin*)chatwin, '-', NULL, 0, 0, "", curr->data); diff --git a/src/ui/ui.h b/src/ui/ui.h index 80fc6997..7682f57b 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -101,8 +101,8 @@ void ui_handle_stanza(const char * const msg); // ui events void ui_contact_online(char *barejid, Resource *resource, GDateTime *last_activity); void ui_contact_typing(const char * const barejid, const char * const resource); -void ui_incoming_msg(ProfChatWin *chatwin, const char * const resource, const char * const message, GTimeVal *tv_stamp, gboolean win_created); -void ui_incoming_private_msg(const char * const fulljid, const char * const message, GTimeVal *tv_stamp); +void ui_incoming_msg(ProfChatWin *chatwin, const char * const resource, const char * const message, GDateTime *timestamp, gboolean win_created); +void ui_incoming_private_msg(const char * const fulljid, const char * const message, GDateTime *timestamp); void ui_message_receipt(const char * const barejid, const char * const id); void ui_disconnected(void); @@ -129,7 +129,7 @@ void ui_room_occupant_role_and_affiliation_change(const char * const roomjid, co const char * const affiliation, const char * const actor, const char * const reason); void ui_room_roster(const char * const roomjid, GList *occupants, const char * const presence); void ui_room_history(const char * const roomjid, const char * const nick, - GTimeVal tv_stamp, const char * const message); + GDateTime *timestamp, const char * const message); void ui_room_message(const char * const roomjid, const char * const nick, const char * const message); void ui_room_subject(const char * const roomjid, const char * const nick, const char * const subject); @@ -350,8 +350,8 @@ void win_hide_subwin(ProfWin *window); void win_show_subwin(ProfWin *window); void win_refresh_without_subwin(ProfWin *window); void win_refresh_with_subwin(ProfWin *window); -void win_print(ProfWin *window, const char show_char, GTimeVal *tstamp, int flags, theme_item_t theme_item, const char * const from, const char * const message); -void win_vprint(ProfWin *window, const char show_char, GTimeVal *tstamp, int flags, theme_item_t theme_item, const char * const from, const char * const message, ...); +void win_print(ProfWin *window, const char show_char, GDateTime *timestamp, int flags, theme_item_t theme_item, const char * const from, const char * const message); +void win_vprint(ProfWin *window, const char show_char, GDateTime *timestamp, int flags, theme_item_t theme_item, const char * const from, const char * const message, ...); char* win_get_title(ProfWin *window); void win_show_occupant(ProfWin *window, Occupant *occupant); void win_show_occupant_info(ProfWin *window, const char * const room, Occupant *occupant); diff --git a/src/ui/window.c b/src/ui/window.c index 92db25fa..9db4f854 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -922,14 +922,14 @@ win_show_status_string(ProfWin *window, const char * const from, } void -win_print_incoming_message(ProfWin *window, GTimeVal *tv_stamp, +win_print_incoming_message(ProfWin *window, GDateTime *timestamp, const char * const from, const char * const message) { switch (window->type) { case WIN_CHAT: case WIN_PRIVATE: - win_print(window, '-', tv_stamp, NO_ME, THEME_TEXT_THEM, from, message); + win_print(window, '-', timestamp, NO_ME, THEME_TEXT_THEM, from, message); break; default: assert(FALSE); @@ -938,31 +938,25 @@ win_print_incoming_message(ProfWin *window, GTimeVal *tv_stamp, } void -win_vprint(ProfWin *window, const char show_char, GTimeVal *tstamp, +win_vprint(ProfWin *window, const char show_char, GDateTime *timestamp, int flags, theme_item_t theme_item, const char * const from, const char * const message, ...) { va_list arg; va_start(arg, message); GString *fmt_msg = g_string_new(NULL); g_string_vprintf(fmt_msg, message, arg); - win_print(window, show_char, tstamp, flags, theme_item, from, fmt_msg->str); + win_print(window, show_char, timestamp, flags, theme_item, from, fmt_msg->str); g_string_free(fmt_msg, TRUE); } void -win_print(ProfWin *window, const char show_char, GTimeVal *tstamp, +win_print(ProfWin *window, const char show_char, GDateTime *timestamp, int flags, theme_item_t theme_item, const char * const from, const char * const message) { - GDateTime *time; - - if (tstamp == NULL) { - time = g_date_time_new_now_local(); - } else { - time = g_date_time_new_from_timeval_utc(tstamp); - } + if (timestamp == NULL) timestamp = g_date_time_new_now_local(); - buffer_push(window->layout->buffer, show_char, time, flags, theme_item, from, message, NULL); - _win_print(window, show_char, time, flags, theme_item, from, message, NULL); + buffer_push(window->layout->buffer, show_char, timestamp, flags, theme_item, from, message, NULL); + _win_print(window, show_char, timestamp, flags, theme_item, from, message, NULL); // TODO: cross-reference.. this should be replaced by a real event-based system ui_input_nonblocking(TRUE); } diff --git a/src/ui/window.h b/src/ui/window.h index 4b11ade0..2728c66c 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -59,7 +59,7 @@ void win_show_status_string(ProfWin *window, const char * const from, const char * const show, const char * const status, GDateTime *last_activity, const char * const pre, const char * const default_show); -void win_print_incoming_message(ProfWin *window, GTimeVal *tv_stamp, +void win_print_incoming_message(ProfWin *window, GDateTime *timestamp, const char * const from, const char * const message); void win_print_with_receipt(ProfWin *window, const char show_char, GTimeVal *tstamp, int flags, theme_item_t theme_item, const char * const from, const char * const message, char *id); |