diff options
-rw-r--r-- | src/ui/console.c | 57 | ||||
-rw-r--r-- | src/ui/core.c | 4 | ||||
-rw-r--r-- | src/ui/mucconfwin.c | 16 | ||||
-rw-r--r-- | src/ui/mucwin.c | 32 | ||||
-rw-r--r-- | src/ui/ui.h | 7 | ||||
-rw-r--r-- | src/ui/window.c | 81 |
6 files changed, 110 insertions, 87 deletions
diff --git a/src/ui/console.c b/src/ui/console.c index df9a7b43..2efe85b5 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -74,7 +74,7 @@ void cons_show_word(const char *const word) { ProfWin *console = wins_get_console(); - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", word); + win_append(console, THEME_DEFAULT, "%s", word); } void @@ -128,7 +128,7 @@ cons_show_help(const char *const cmd, CommandHelp *help) win_print(console, THEME_WHITE_BOLD, '-', ""); int i; for (i = 0; i < strlen(cmd) - 1 ; i++) { - win_printf(console, '-', 0, NULL, NO_EOL | NO_DATE, THEME_WHITE_BOLD, "", "-"); + win_append(console, THEME_WHITE_BOLD, "-"); } win_appendln(console, THEME_WHITE_BOLD, ""); cons_show(""); @@ -481,9 +481,8 @@ cons_show_login_success(ProfAccount *account, gboolean secured) const char *presence_str = string_from_resource_presence(presence); theme_item_t presence_colour = theme_main_presence_attrs(presence_str); - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", presence_str); - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " (priority %d)", - accounts_get_priority_for_presence_type(account->name, presence)); + win_append(console, presence_colour, "%s", presence_str); + win_append(console, THEME_DEFAULT, " (priority %d)", accounts_get_priority_for_presence_type(account->name, presence)); win_appendln(console, THEME_DEFAULT, "."); if (!secured) { cons_show_error("TLS connection not established"); @@ -562,19 +561,19 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence) DiscoIdentity *identity = caps->identity; win_print(console, THEME_DEFAULT, '-', "Identity: "); if (identity->name) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->name); + win_append(console, THEME_DEFAULT, "%s", identity->name); if (identity->category || identity->type) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " "); + win_append(console, THEME_DEFAULT, " "); } } if (identity->type) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->type); + win_append(console, THEME_DEFAULT, "%s", identity->type); if (identity->category) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " "); + win_append(console, THEME_DEFAULT, " "); } } if (identity->category) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->category); + win_append(console, THEME_DEFAULT, "%s", identity->category); } win_newline(console); } @@ -585,7 +584,7 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence) win_print(console, THEME_DEFAULT, '-', "Software: %s", software_version->software); } if (software_version->software_version) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", %s", software_version->software_version); + win_append(console, THEME_DEFAULT, ", %s", software_version->software_version); } if (software_version->software || software_version->software_version) { win_newline(console); @@ -594,7 +593,7 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence) win_print(console, THEME_DEFAULT, '-', "OS: %s", software_version->os); } if (software_version->os_version) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", %s", software_version->os_version); + win_append(console, THEME_DEFAULT, ", %s", software_version->os_version); } if (software_version->os || software_version->os_version) { win_newline(console); @@ -669,7 +668,7 @@ cons_show_room_list(GSList *rooms, const char *const conference_node) DiscoItem *room = rooms->data; win_print(console, THEME_DEFAULT, '-', " %s", room->jid); if (room->name) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", (%s)", room->name); + win_append(console, THEME_DEFAULT, ", (%s)", room->name); } win_newline(console); rooms = g_slist_next(rooms); @@ -703,19 +702,19 @@ cons_show_bookmarks(const GList *list) } win_print(console, presence_colour, '-', " %s", item->barejid); if (item->nick) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "/%s", item->nick); + win_append(console, presence_colour, "/%s", item->nick); } if (item->autojoin) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (autojoin)"); + win_append(console, presence_colour, " (autojoin)"); } if (item->password) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (private)"); + win_append(console, presence_colour, " (private)"); } if (muc_active(item->barejid)) { ProfWin *roomwin = (ProfWin*)wins_get_muc(item->barejid); if (roomwin) { int num = wins_get_num(roomwin); - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (win %d)", num); + win_append(console, presence_colour, " (win %d)", num); } } win_newline(console); @@ -786,7 +785,7 @@ cons_show_disco_items(GSList *items, const char *const jid) DiscoItem *item = items->data; win_print(console, THEME_DEFAULT, '-', " %s", item->jid); if (item->name) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", (%s)", item->name); + win_append(console, THEME_DEFAULT, ", (%s)", item->name); } win_appendln(console, THEME_DEFAULT, ""); items = g_slist_next(items); @@ -1003,7 +1002,7 @@ cons_show_account(ProfAccount *account) win_print(console, presence_colour, '-', " %s (%d), %s", resource->name, resource->priority, resource_presence); if (resource->status) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", resource->status); + win_append(console, presence_colour, ", \"%s\"", resource->status); } win_appendln(console, THEME_DEFAULT, ""); Jid *jidp = jid_create_from_bare_and_resource(account->jid, resource->name); @@ -1016,19 +1015,19 @@ cons_show_account(ProfAccount *account) DiscoIdentity *identity = caps->identity; win_print(console, THEME_DEFAULT, '-', " Identity: "); if (identity->name) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->name); + win_append(console, THEME_DEFAULT, "%s", identity->name); if (identity->category || identity->type) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " "); + win_append(console, THEME_DEFAULT, " "); } } if (identity->type) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->type); + win_append(console, THEME_DEFAULT, "%s", identity->type); if (identity->category) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " "); + win_append(console, THEME_DEFAULT, " "); } } if (identity->category) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->category); + win_append(console, THEME_DEFAULT, "%s", identity->category); } win_newline(console); } @@ -1039,7 +1038,7 @@ cons_show_account(ProfAccount *account) win_print(console, THEME_DEFAULT, '-', " Software: %s", software_version->software); } if (software_version->software_version) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", %s", software_version->software_version); + win_append(console, THEME_DEFAULT, ", %s", software_version->software_version); } if (software_version->software || software_version->software_version) { win_newline(console); @@ -1048,7 +1047,7 @@ cons_show_account(ProfAccount *account) win_print(console, THEME_DEFAULT, '-', " OS: %s", software_version->os); } if (software_version->os_version) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", %s", software_version->os_version); + win_append(console, THEME_DEFAULT, ", %s", software_version->os_version); } if (software_version->os || software_version->os_version) { win_newline(console); @@ -2191,7 +2190,7 @@ _cons_theme_bar_prop(theme_item_t theme, char *prop) char *setting = theme_get_string(prop); g_string_append_printf(valstr, "%s ", setting); theme_free_string(setting); - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, theme, "", "%s", valstr->str); + win_append(console, theme, "%s", valstr->str); win_appendln(console, THEME_TEXT, ""); g_string_free(valstr, TRUE); } @@ -2406,7 +2405,7 @@ _show_roster_contacts(GSList *list, gboolean show_groups) g_string_free(title, TRUE); - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " - "); + win_append(console, THEME_DEFAULT, " - "); GString *sub = g_string_new(""); sub = g_string_append(sub, p_contact_subscription(contact)); if (p_contact_pending_out(contact)) { @@ -2422,7 +2421,7 @@ _show_roster_contacts(GSList *list, gboolean show_groups) } if (show_groups) { - win_printf(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", sub->str); + win_append(console, presence_colour, "%s", sub->str); } else { win_appendln(console, presence_colour, "%s", sub->str); } diff --git a/src/ui/core.c b/src/ui/core.c index 9866d93b..5b5d8d2a 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -794,10 +794,10 @@ ui_room_join(const char *const roomjid, gboolean focus) char *role = muc_role_str(roomjid); char *affiliation = muc_affiliation_str(roomjid); if (role) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", role: %s", role); + win_append(window, THEME_ROOMINFO, ", role: %s", role); } if (affiliation) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", affiliation: %s", affiliation); + win_append(window, THEME_ROOMINFO, ", affiliation: %s", affiliation); } } win_appendln(window, THEME_ROOMINFO, ""); diff --git a/src/ui/mucconfwin.c b/src/ui/mucconfwin.c index 65cc6b04..6bdf23fe 100644 --- a/src/ui/mucconfwin.c +++ b/src/ui/mucconfwin.c @@ -203,11 +203,11 @@ static void _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) { win_print(window, THEME_AWAY, '-', "[%s] ", tag); - win_printf(window, '-', 0, NULL, NO_EOL | NO_DATE, THEME_DEFAULT, "", "%s", field->label); + win_append(window, THEME_DEFAULT, "%s", field->label); if (field->required) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " (required): "); + win_append(window, THEME_DEFAULT, " (required): "); } else { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ": "); + win_append(window, THEME_DEFAULT, ": "); } GSList *values = field->values; @@ -221,9 +221,9 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) char *value = curr_value->data; if (value) { if (g_strcmp0(field->var, "muc#roomconfig_roomsecret") == 0) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", "[hidden]"); + win_append(window, THEME_ONLINE, "[hidden]"); } else { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", "%s", value); + win_append(window, THEME_ONLINE, "%s", value); } } } @@ -233,7 +233,7 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) if (curr_value) { char *value = curr_value->data; if (value) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", "[hidden]"); + win_append(window, THEME_ONLINE, "[hidden]"); } } win_newline(window); @@ -303,7 +303,7 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) if (curr_value) { char *value = curr_value->data; if (value) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", "%s", value); + win_append(window, THEME_ONLINE, "%s", value); } } win_newline(window); @@ -320,7 +320,7 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) if (curr_value) { char *value = curr_value->data; if (value) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", value); + win_append(window, THEME_DEFAULT, "%s", value); } } win_newline(window); diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c index 62e5b997..7ad9411d 100644 --- a/src/ui/mucwin.c +++ b/src/ui/mucwin.c @@ -53,10 +53,10 @@ mucwin_role_change(ProfMucWin *mucwin, const char *const role, const char *const ProfWin *window = (ProfWin*)mucwin; win_print(window, THEME_ROOMINFO, '!', "Your role has been changed to: %s", role); if (actor) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor); + win_append(window, THEME_ROOMINFO, ", by: %s", actor); } if (reason) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); + win_append(window, THEME_ROOMINFO, ", reason: %s", reason); } win_appendln(window, THEME_ROOMINFO, ""); } @@ -70,10 +70,10 @@ mucwin_affiliation_change(ProfMucWin *mucwin, const char *const affiliation, con ProfWin *window = (ProfWin*)mucwin; win_print(window, THEME_ROOMINFO, '!', "Your affiliation has been changed to: %s", affiliation); if (actor) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor); + win_append(window, THEME_ROOMINFO, ", by: %s", actor); } if (reason) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); + win_append(window, THEME_ROOMINFO, ", reason: %s", reason); } win_appendln(window, THEME_ROOMINFO, ""); } @@ -87,10 +87,10 @@ mucwin_role_and_affiliation_change(ProfMucWin *mucwin, const char *const role, c ProfWin *window = (ProfWin*)mucwin; win_print(window, THEME_ROOMINFO, '!', "Your role and affiliation have been changed, role: %s, affiliation: %s", role, affiliation); if (actor) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor); + win_append(window, THEME_ROOMINFO, ", by: %s", actor); } if (reason) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); + win_append(window, THEME_ROOMINFO, ", reason: %s", reason); } win_appendln(window, THEME_ROOMINFO, ""); } @@ -105,10 +105,10 @@ mucwin_occupant_role_change(ProfMucWin *mucwin, const char *const nick, const ch ProfWin *window = (ProfWin*)mucwin; win_print(window, THEME_ROOMINFO, '!', "%s's role has been changed to: %s", nick, role); if (actor) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor); + win_append(window, THEME_ROOMINFO, ", by: %s", actor); } if (reason) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); + win_append(window, THEME_ROOMINFO, ", reason: %s", reason); } win_appendln(window, THEME_ROOMINFO, ""); } @@ -122,10 +122,10 @@ mucwin_occupant_affiliation_change(ProfMucWin *mucwin, const char *const nick, c ProfWin *window = (ProfWin*)mucwin; win_print(window, THEME_ROOMINFO, '!', "%s's affiliation has been changed to: %s", nick, affiliation); if (actor) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor); + win_append(window, THEME_ROOMINFO, ", by: %s", actor); } if (reason) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); + win_append(window, THEME_ROOMINFO, ", reason: %s", reason); } win_appendln(window, THEME_ROOMINFO, ""); } @@ -139,10 +139,10 @@ mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char *cons ProfWin *window = (ProfWin*)mucwin; win_print(window, THEME_ROOMINFO, '!', "%s's role and affiliation have been changed, role: %s, affiliation: %s", nick, role, affiliation); if (actor) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor); + win_append(window, THEME_ROOMINFO, ", by: %s", actor); } if (reason) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); + win_append(window, THEME_ROOMINFO, ", reason: %s", reason); } win_appendln(window, THEME_ROOMINFO, ""); } @@ -223,10 +223,10 @@ mucwin_roster(ProfMucWin *mucwin, GList *roster, const char *const presence) const char *presence_str = string_from_resource_presence(occupant->presence); theme_item_t presence_colour = theme_main_presence_attrs(presence_str); - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", occupant->nick); + win_append(window, presence_colour, "%s", occupant->nick); if (roster->next) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", "); + win_append(window, THEME_DEFAULT, ", "); } roster = g_list_next(roster); @@ -298,10 +298,10 @@ mucwin_occupant_online(ProfMucWin *mucwin, const char *const nick, const char *c win_print(window, THEME_ONLINE, '!', "-> %s has joined the room", nick); if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) { if (role) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", ", role: %s", role); + win_append(window, THEME_ONLINE, ", role: %s", role); } if (affiliation) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", ", affiliation: %s", affiliation); + win_append(window, THEME_ONLINE, ", affiliation: %s", affiliation); } } win_appendln(window, THEME_ROOMINFO, ""); diff --git a/src/ui/ui.h b/src/ui/ui.h index 0830639a..386b3eb4 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -355,12 +355,17 @@ 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_printf(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, int flags, theme_item_t theme_item, const char *const from, const char *const message, ...); + void win_print(ProfWin *window, theme_item_t theme_item, const char ch, const char *const message, ...); void win_println(ProfWin *window, theme_item_t theme_item, const char ch, const char *const message, ...); -void win_appendln(ProfWin *window, theme_item_t theme_item, const char *const message, ...); void win_println_indent(ProfWin *window, int pad, const char *const message); + +void win_append(ProfWin *window, theme_item_t theme_item, const char *const message, ...); +void win_appendln(ProfWin *window, theme_item_t theme_item, 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 c7016b6f..f0243578 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -683,10 +683,10 @@ win_show_occupant(ProfWin *window, Occupant *occupant) theme_item_t presence_colour = theme_main_presence_attrs(presence_str); win_print(window, presence_colour, '-', "%s", occupant->nick); - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str); + win_append(window, presence_colour, " is %s", presence_str); if (occupant->status) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", occupant->status); + win_append(window, presence_colour, ", \"%s\"", occupant->status); } win_appendln(window, presence_colour, ""); @@ -709,7 +709,7 @@ win_show_contact(ProfWin *window, PContact contact) win_print(window, presence_colour, '-', "%s", barejid); } - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence); + win_append(window, presence_colour, " is %s", presence); if (last_activity) { GDateTime *now = g_date_time_new_now_local(); @@ -723,15 +723,14 @@ win_show_contact(ProfWin *window, PContact contact) int seconds = span / G_TIME_SPAN_SECOND; if (hours > 0) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", idle %dh%dm%ds", hours, minutes, seconds); - } - else { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", idle %dm%ds", minutes, seconds); + win_append(window, presence_colour, ", idle %dh%dm%ds", hours, minutes, seconds); + } else { + win_append(window, presence_colour, ", idle %dm%ds", minutes, seconds); } } if (status) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", p_contact_status(contact)); + win_append(window, presence_colour, ", \"%s\"", p_contact_status(contact)); } win_appendln(window, presence_colour, ""); @@ -747,10 +746,10 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa theme_item_t presence_colour = theme_main_presence_attrs(presence_str); win_print(window, presence_colour, '!', "%s", occupant->nick); - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str); + win_append(window, presence_colour, " is %s", presence_str); if (occupant->status) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", occupant->status); + win_append(window, presence_colour, ", \"%s\"", occupant->status); } win_newline(window); @@ -772,19 +771,19 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa DiscoIdentity *identity = caps->identity; win_print(window, THEME_DEFAULT, '!', " Identity: "); if (identity->name) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->name); + win_append(window, THEME_DEFAULT, "%s", identity->name); if (identity->category || identity->type) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " "); + win_append(window, THEME_DEFAULT, " "); } } if (identity->type) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->type); + win_append(window, THEME_DEFAULT, "%s", identity->type); if (identity->category) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " "); + win_append(window, THEME_DEFAULT, " "); } } if (identity->category) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->category); + win_append(window, THEME_DEFAULT, "%s", identity->category); } win_newline(window); } @@ -795,7 +794,7 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa win_print(window, THEME_DEFAULT, '!', " Software: %s", software_version->software); } if (software_version->software_version) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", %s", software_version->software_version); + win_append(window, THEME_DEFAULT, ", %s", software_version->software_version); } if (software_version->software || software_version->software_version) { win_newline(window); @@ -804,7 +803,7 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa win_print(window, THEME_DEFAULT, '!', " OS: %s", software_version->os); } if (software_version->os_version) { - win_printf(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", %s", software_version->os_version); + win_append(window, THEME_DEFAULT, ", %s", software_version->os_version); } if (software_version->os || software_version->os_version) { win_newline(window); @@ -831,7 +830,7 @@ win_show_info(ProfWin *window, PContact contact) win_println(window, THEME_DEFAULT, '-', ""); win_print(window, presence_colour, '-', "%s", barejid); if (name) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (%s)", name); + win_append(window, presence_colour, " (%s)", name); } win_appendln(window, THEME_DEFAULT, ":"); @@ -882,7 +881,7 @@ win_show_info(ProfWin *window, PContact contact) theme_item_t presence_colour = theme_main_presence_attrs(resource_presence); win_print(window, presence_colour, '-', " %s (%d), %s", resource->name, resource->priority, resource_presence); if (resource->status) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", resource->status); + win_append(window, presence_colour, ", \"%s\"", resource->status); } win_newline(window); @@ -896,19 +895,19 @@ win_show_info(ProfWin *window, PContact contact) DiscoIdentity *identity = caps->identity; win_print(window, THEME_DEFAULT, '-', " Identity: "); if (identity->name) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->name); + win_append(window, THEME_DEFAULT, "%s", identity->name); if (identity->category || identity->type) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " "); + win_append(window, THEME_DEFAULT, " "); } } if (identity->type) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->type); + win_append(window, THEME_DEFAULT, "%s", identity->type); if (identity->category) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", " "); + win_append(window, THEME_DEFAULT, " "); } } if (identity->category) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", "%s", identity->category); + win_append(window, THEME_DEFAULT, "%s", identity->category); } win_newline(window); } @@ -919,7 +918,7 @@ win_show_info(ProfWin *window, PContact contact) win_print(window, THEME_DEFAULT, '-', " Software: %s", software_version->software); } if (software_version->software_version) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", %s", software_version->software_version); + win_append(window, THEME_DEFAULT, ", %s", software_version->software_version); } if (software_version->software || software_version->software_version) { win_newline(window); @@ -928,7 +927,7 @@ win_show_info(ProfWin *window, PContact contact) win_print(window, THEME_DEFAULT, '-', " OS: %s", software_version->os); } if (software_version->os_version) { - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_DEFAULT, "", ", %s", software_version->os_version); + win_append(window, THEME_DEFAULT, ", %s", software_version->os_version); } if (software_version->os || software_version->os_version) { win_newline(window); @@ -962,9 +961,9 @@ win_show_status_string(ProfWin *window, const char *const from, win_print(window, presence_colour, '-', "%s %s", pre, from); if (show) - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", show); + win_append(window, presence_colour, " is %s", show); else - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", default_show); + win_append(window, presence_colour, " is %s", default_show); if (last_activity) { gchar *date_fmt = NULL; @@ -973,13 +972,13 @@ win_show_status_string(ProfWin *window, const char *const from, prefs_free_string(time_pref); assert(date_fmt != NULL); - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", last activity: %s", date_fmt); + win_append(window, presence_colour, ", last activity: %s", date_fmt); g_free(date_fmt); } if (status) - win_printf(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", status); + win_append(window, presence_colour, ", \"%s\"", status); win_appendln(window, presence_colour, ""); } @@ -1075,6 +1074,26 @@ win_println(ProfWin *window, theme_item_t theme_item, const char ch, const char } void +win_append(ProfWin *window, theme_item_t theme_item, const char *const message, ...) +{ + 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); + + buffer_push(window->layout->buffer, '-', 0, timestamp, NO_EOL, theme_item, "", fmt_msg->str, NULL); + + _win_print(window, '-', 0, timestamp, NO_DATE | NO_EOL, theme_item, "", fmt_msg->str, NULL); + inp_nonblocking(TRUE); + g_date_time_unref(timestamp); + + g_string_free(fmt_msg, TRUE); + va_end(arg); +} + +void win_appendln(ProfWin *window, theme_item_t theme_item, const char *const message, ...) { GDateTime *timestamp = g_date_time_new_now_local(); @@ -1092,8 +1111,8 @@ win_appendln(ProfWin *window, theme_item_t theme_item, const char *const message g_string_free(fmt_msg, TRUE); va_end(arg); - } + void win_print_http_upload(ProfWin *window, const char *const message, char *url) { |