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

Merge branch 'master' into osx-functional

This commit is contained in:
James Booth 2016-10-15 22:22:06 +01:00
commit a45c50b013
19 changed files with 784 additions and 580 deletions

View File

@ -1479,9 +1479,9 @@ _cmd_help_cmd_list(const char *const tag)
cons_show(""); cons_show("");
ProfWin *console = wins_get_console(); ProfWin *console = wins_get_console();
if (tag) { if (tag) {
win_vprint(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "%s commands", tag); win_println(console, THEME_WHITE_BOLD, '-', "%s commands", tag);
} else { } else {
win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "All commands"); win_println(console, THEME_WHITE_BOLD, '-', "All commands");
} }
GList *ordered_commands = NULL; GList *ordered_commands = NULL;
@ -3108,7 +3108,7 @@ cmd_status(ProfWin *window, const char *const command, gchar **args)
if (occupant) { if (occupant) {
win_show_occupant(window, occupant); win_show_occupant(window, occupant);
} else { } else {
win_vprint(window, '-', 0, NULL, 0, 0, "", "No such participant \"%s\" in room.", usr); win_println(window, THEME_DEFAULT, '-', "No such participant \"%s\" in room.", usr);
} }
} else { } else {
ui_current_print_line("You must specify a nickname."); ui_current_print_line("You must specify a nickname.");
@ -3124,7 +3124,7 @@ cmd_status(ProfWin *window, const char *const command, gchar **args)
if (pcontact) { if (pcontact) {
win_show_contact(window, pcontact); win_show_contact(window, pcontact);
} else { } else {
win_println(window, 0, "Error getting contact info."); win_println(window, THEME_DEFAULT, '-', "Error getting contact info.");
} }
} }
break; break;
@ -3139,7 +3139,7 @@ cmd_status(ProfWin *window, const char *const command, gchar **args)
if (occupant) { if (occupant) {
win_show_occupant(window, occupant); win_show_occupant(window, occupant);
} else { } else {
win_println(window, 0, "Error getting contact info."); win_println(window, THEME_DEFAULT, '-', "Error getting contact info.");
} }
jid_destroy(jid); jid_destroy(jid);
} }
@ -3204,7 +3204,7 @@ cmd_info(ProfWin *window, const char *const command, gchar **args)
if (pcontact) { if (pcontact) {
win_show_info(window, pcontact); win_show_info(window, pcontact);
} else { } else {
win_println(window, 0, "Error getting contact info."); win_println(window, THEME_DEFAULT, '-', "Error getting contact info.");
} }
} }
break; break;
@ -3219,7 +3219,7 @@ cmd_info(ProfWin *window, const char *const command, gchar **args)
if (occupant) { if (occupant) {
win_show_occupant_info(window, jid->barejid, occupant); win_show_occupant_info(window, jid->barejid, occupant);
} else { } else {
win_println(window, 0, "Error getting contact info."); win_println(window, THEME_DEFAULT, '-', "Error getting contact info.");
} }
jid_destroy(jid); jid_destroy(jid);
} }
@ -3372,7 +3372,7 @@ cmd_software(ProfWin *window, const char *const command, gchar **args)
iq_send_software_version(fulljid->str); iq_send_software_version(fulljid->str);
g_string_free(fulljid, TRUE); g_string_free(fulljid, TRUE);
} else { } else {
win_println(window, 0, "Unknown resource for /software command."); win_println(window, THEME_DEFAULT, '-', "Unknown resource for /software command.");
} }
} }
break; break;
@ -3881,7 +3881,7 @@ cmd_kick(ProfWin *window, const char *const command, gchar **args)
char *reason = args[1]; char *reason = args[1];
iq_room_kick_occupant(mucwin->roomjid, nick, reason); iq_room_kick_occupant(mucwin->roomjid, nick, reason);
} else { } else {
win_vprint((ProfWin*) mucwin, '!', 0, NULL, 0, 0, "", "Occupant does not exist: %s", nick); win_println(window, THEME_DEFAULT, '!', "Occupant does not exist: %s", nick);
} }
} else { } else {
cons_bad_cmd_usage(command); cons_bad_cmd_usage(command);
@ -3939,10 +3939,10 @@ cmd_subject(ProfWin *window, const char *const command, gchar **args)
if (args[0] == NULL) { if (args[0] == NULL) {
char *subject = muc_subject(mucwin->roomjid); char *subject = muc_subject(mucwin->roomjid);
if (subject) { if (subject) {
win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Room subject: "); win_print(window, THEME_ROOMINFO, '!', "Room subject: ");
win_vprint(window, '!', 0, NULL, NO_DATE, 0, "", "%s", subject); win_appendln(window, THEME_DEFAULT, "%s", subject);
} else { } else {
win_print(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room has no subject"); win_println(window, THEME_ROOMINFO, '!', "Room has no subject");
} }
return TRUE; return TRUE;
} }
@ -3974,7 +3974,7 @@ cmd_subject(ProfWin *window, const char *const command, gchar **args)
message_send_groupchat_subject(mucwin->roomjid, new_subject->str); message_send_groupchat_subject(mucwin->roomjid, new_subject->str);
g_string_free(new_subject, TRUE); g_string_free(new_subject, TRUE);
} else { } else {
win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Room does not have a subject, use /subject set <subject>"); win_print(window, THEME_ROOMINFO, '!', "Room does not have a subject, use /subject set <subject>");
} }
} else { } else {
cons_bad_cmd_usage(command); cons_bad_cmd_usage(command);
@ -3991,7 +3991,7 @@ cmd_subject(ProfWin *window, const char *const command, gchar **args)
message_send_groupchat_subject(mucwin->roomjid, new_subject->str); message_send_groupchat_subject(mucwin->roomjid, new_subject->str);
g_string_free(new_subject, TRUE); g_string_free(new_subject, TRUE);
} else { } else {
win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Room does not have a subject, use /subject set <subject>"); win_print(window, THEME_ROOMINFO, '!', "Room does not have a subject, use /subject set <subject>");
} }
} else { } else {
cons_bad_cmd_usage(command); cons_bad_cmd_usage(command);
@ -4050,7 +4050,7 @@ cmd_affiliation(ProfWin *window, const char *const command, gchar **args)
iq_room_affiliation_list(mucwin->roomjid, "member"); iq_room_affiliation_list(mucwin->roomjid, "member");
iq_room_affiliation_list(mucwin->roomjid, "outcast"); iq_room_affiliation_list(mucwin->roomjid, "outcast");
} else if (g_strcmp0(affiliation, "none") == 0) { } else if (g_strcmp0(affiliation, "none") == 0) {
win_print((ProfWin*) mucwin, '!', 0, NULL, 0, 0, "", "Cannot list users with no affiliation."); win_println(window, THEME_DEFAULT, '!', "Cannot list users with no affiliation.");
} else { } else {
iq_room_affiliation_list(mucwin->roomjid, affiliation); iq_room_affiliation_list(mucwin->roomjid, affiliation);
} }
@ -4118,7 +4118,7 @@ cmd_role(ProfWin *window, const char *const command, gchar **args)
iq_room_role_list(mucwin->roomjid, "participant"); iq_room_role_list(mucwin->roomjid, "participant");
iq_room_role_list(mucwin->roomjid, "visitor"); iq_room_role_list(mucwin->roomjid, "visitor");
} else if (g_strcmp0(role, "none") == 0) { } else if (g_strcmp0(role, "none") == 0) {
win_print((ProfWin*) mucwin, '!', 0, NULL, 0, 0, "", "Cannot list users with no role."); win_println(window, THEME_DEFAULT, '!', "Cannot list users with no role.");
} else { } else {
iq_room_role_list(mucwin->roomjid, role); iq_room_role_list(mucwin->roomjid, role);
} }
@ -4180,12 +4180,12 @@ cmd_room(ProfWin *window, const char *const command, gchar **args)
if (g_strcmp0(args[0], "accept") == 0) { if (g_strcmp0(args[0], "accept") == 0) {
gboolean requires_config = muc_requires_config(mucwin->roomjid); gboolean requires_config = muc_requires_config(mucwin->roomjid);
if (!requires_config) { if (!requires_config) {
win_print(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Current room does not require configuration."); win_println(window, THEME_ROOMINFO, '!', "Current room does not require configuration.");
return TRUE; return TRUE;
} else { } else {
iq_confirm_instant_room(mucwin->roomjid); iq_confirm_instant_room(mucwin->roomjid);
muc_set_requires_config(mucwin->roomjid, FALSE); muc_set_requires_config(mucwin->roomjid, FALSE);
win_print(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room unlocked."); win_println(window, THEME_ROOMINFO, '!', "Room unlocked.");
return TRUE; return TRUE;
} }
} }
@ -4681,13 +4681,13 @@ cmd_tiny(ProfWin *window, const char *const command, gchar **args)
} }
if (!tinyurl_valid(url)) { if (!tinyurl_valid(url)) {
win_vprint(window, '-', 0, NULL, 0, THEME_ERROR, "", "/tiny, badly formed URL: %s", url); win_println(window, THEME_ERROR, '-', "/tiny, badly formed URL: %s", url);
return TRUE; return TRUE;
} }
char *tiny = tinyurl_get(url); char *tiny = tinyurl_get(url);
if (!tiny) { if (!tiny) {
win_print(window, '-', 0, NULL, 0, THEME_ERROR, "", "Couldn't create tinyurl."); win_println(window, THEME_ERROR, '-', "Couldn't create tinyurl.");
return TRUE; return TRUE;
} }
@ -5137,50 +5137,50 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args)
if (!args[0]) { if (!args[0]) {
ProfWin *current = wins_get_current(); ProfWin *current = wins_get_current();
if (current->type == WIN_MUC) { if (current->type == WIN_MUC) {
win_println(current, 0, ""); win_println(current, THEME_DEFAULT, '-', "");
ProfMucWin *mucwin = (ProfMucWin *)current; ProfMucWin *mucwin = (ProfMucWin *)current;
win_vprintln_ch(window, '!', "Notification settings for %s:", mucwin->roomjid); win_println(window, THEME_DEFAULT, '!', "Notification settings for %s:", mucwin->roomjid);
if (prefs_has_room_notify(mucwin->roomjid)) { if (prefs_has_room_notify(mucwin->roomjid)) {
if (prefs_get_room_notify(mucwin->roomjid)) { if (prefs_get_room_notify(mucwin->roomjid)) {
win_vprintln_ch(window, '!', " Message : ON"); win_println(window, THEME_DEFAULT, '!', " Message : ON");
} else { } else {
win_vprintln_ch(window, '!', " Message : OFF"); win_println(window, THEME_DEFAULT, '!', " Message : OFF");
} }
} else { } else {
if (prefs_get_boolean(PREF_NOTIFY_ROOM)) { if (prefs_get_boolean(PREF_NOTIFY_ROOM)) {
win_vprintln_ch(window, '!', " Message : ON (global setting)"); win_println(window, THEME_DEFAULT, '!', " Message : ON (global setting)");
} else { } else {
win_vprintln_ch(window, '!', " Message : OFF (global setting)"); win_println(window, THEME_DEFAULT, '!', " Message : OFF (global setting)");
} }
} }
if (prefs_has_room_notify_mention(mucwin->roomjid)) { if (prefs_has_room_notify_mention(mucwin->roomjid)) {
if (prefs_get_room_notify_mention(mucwin->roomjid)) { if (prefs_get_room_notify_mention(mucwin->roomjid)) {
win_vprintln_ch(window, '!', " Mention : ON"); win_println(window, THEME_DEFAULT, '!', " Mention : ON");
} else { } else {
win_vprintln_ch(window, '!', " Mention : OFF"); win_println(window, THEME_DEFAULT, '!', " Mention : OFF");
} }
} else { } else {
if (prefs_get_boolean(PREF_NOTIFY_ROOM_MENTION)) { if (prefs_get_boolean(PREF_NOTIFY_ROOM_MENTION)) {
win_vprintln_ch(window, '!', " Mention : ON (global setting)"); win_println(window, THEME_DEFAULT, '!', " Mention : ON (global setting)");
} else { } else {
win_vprintln_ch(window, '!', " Mention : OFF (global setting)"); win_println(window, THEME_DEFAULT, '!', " Mention : OFF (global setting)");
} }
} }
if (prefs_has_room_notify_trigger(mucwin->roomjid)) { if (prefs_has_room_notify_trigger(mucwin->roomjid)) {
if (prefs_get_room_notify_trigger(mucwin->roomjid)) { if (prefs_get_room_notify_trigger(mucwin->roomjid)) {
win_vprintln_ch(window, '!', " Triggers : ON"); win_println(window, THEME_DEFAULT, '!', " Triggers : ON");
} else { } else {
win_vprintln_ch(window, '!', " Triggers : OFF"); win_println(window, THEME_DEFAULT, '!', " Triggers : OFF");
} }
} else { } else {
if (prefs_get_boolean(PREF_NOTIFY_ROOM_TRIGGER)) { if (prefs_get_boolean(PREF_NOTIFY_ROOM_TRIGGER)) {
win_vprintln_ch(window, '!', " Triggers : ON (global setting)"); win_println(window, THEME_DEFAULT, '!', " Triggers : ON (global setting)");
} else { } else {
win_vprintln_ch(window, '!', " Triggers : OFF (global setting)"); win_println(window, THEME_DEFAULT, '!', " Triggers : OFF (global setting)");
} }
} }
win_println(current, 0, ""); win_println(current, THEME_DEFAULT, '-', "");
} else { } else {
cons_show(""); cons_show("");
cons_notify_setting(); cons_notify_setting();
@ -5394,7 +5394,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args)
} else { } else {
ProfMucWin *mucwin = (ProfMucWin*)window; ProfMucWin *mucwin = (ProfMucWin*)window;
prefs_set_room_notify(mucwin->roomjid, TRUE); prefs_set_room_notify(mucwin->roomjid, TRUE);
win_vprintln_ch(window, '!', "Notifications enabled for %s", mucwin->roomjid); win_println(window, THEME_DEFAULT, '!', "Notifications enabled for %s", mucwin->roomjid);
} }
} }
} else if (g_strcmp0(args[0], "off") == 0) { } else if (g_strcmp0(args[0], "off") == 0) {
@ -5409,7 +5409,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args)
} else { } else {
ProfMucWin *mucwin = (ProfMucWin*)window; ProfMucWin *mucwin = (ProfMucWin*)window;
prefs_set_room_notify(mucwin->roomjid, FALSE); prefs_set_room_notify(mucwin->roomjid, FALSE);
win_vprintln_ch(window, '!', "Notifications disabled for %s", mucwin->roomjid); win_println(window, THEME_DEFAULT, '!', "Notifications disabled for %s", mucwin->roomjid);
} }
} }
} else if (g_strcmp0(args[0], "mention") == 0) { } else if (g_strcmp0(args[0], "mention") == 0) {
@ -5425,7 +5425,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args)
} else { } else {
ProfMucWin *mucwin = (ProfMucWin*)window; ProfMucWin *mucwin = (ProfMucWin*)window;
prefs_set_room_notify_mention(mucwin->roomjid, TRUE); prefs_set_room_notify_mention(mucwin->roomjid, TRUE);
win_vprintln_ch(window, '!', "Mention notifications enabled for %s", mucwin->roomjid); win_println(window, THEME_DEFAULT, '!', "Mention notifications enabled for %s", mucwin->roomjid);
} }
} else if (g_strcmp0(args[1], "off") == 0) { } else if (g_strcmp0(args[1], "off") == 0) {
ProfWin *window = wins_get_current(); ProfWin *window = wins_get_current();
@ -5434,7 +5434,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args)
} else { } else {
ProfMucWin *mucwin = (ProfMucWin*)window; ProfMucWin *mucwin = (ProfMucWin*)window;
prefs_set_room_notify_mention(mucwin->roomjid, FALSE); prefs_set_room_notify_mention(mucwin->roomjid, FALSE);
win_vprintln_ch(window, '!', "Mention notifications disabled for %s", mucwin->roomjid); win_println(window, THEME_DEFAULT, '!', "Mention notifications disabled for %s", mucwin->roomjid);
} }
} else { } else {
cons_bad_cmd_usage(command); cons_bad_cmd_usage(command);
@ -5453,7 +5453,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args)
} else { } else {
ProfMucWin *mucwin = (ProfMucWin*)window; ProfMucWin *mucwin = (ProfMucWin*)window;
prefs_set_room_notify_trigger(mucwin->roomjid, TRUE); prefs_set_room_notify_trigger(mucwin->roomjid, TRUE);
win_vprintln_ch(window, '!', "Custom trigger notifications enabled for %s", mucwin->roomjid); win_println(window, THEME_DEFAULT, '!', "Custom trigger notifications enabled for %s", mucwin->roomjid);
} }
} else if (g_strcmp0(args[1], "off") == 0) { } else if (g_strcmp0(args[1], "off") == 0) {
ProfWin *window = wins_get_current(); ProfWin *window = wins_get_current();
@ -5462,7 +5462,7 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args)
} else { } else {
ProfMucWin *mucwin = (ProfMucWin*)window; ProfMucWin *mucwin = (ProfMucWin*)window;
prefs_set_room_notify_trigger(mucwin->roomjid, FALSE); prefs_set_room_notify_trigger(mucwin->roomjid, FALSE);
win_vprintln_ch(window, '!', "Custom trigger notifications disabled for %s", mucwin->roomjid); win_println(window, THEME_DEFAULT, '!', "Custom trigger notifications disabled for %s", mucwin->roomjid);
} }
} else { } else {
cons_bad_cmd_usage(command); cons_bad_cmd_usage(command);
@ -5481,9 +5481,9 @@ cmd_notify(ProfWin *window, const char *const command, gchar **args)
ProfMucWin *mucwin = (ProfMucWin*)window; ProfMucWin *mucwin = (ProfMucWin*)window;
gboolean res = prefs_reset_room_notify(mucwin->roomjid); gboolean res = prefs_reset_room_notify(mucwin->roomjid);
if (res) { if (res) {
win_vprintln_ch(window, '!', "Notification settings set to global defaults for %s", mucwin->roomjid); win_println(window, THEME_DEFAULT, '!', "Notification settings set to global defaults for %s", mucwin->roomjid);
} else { } else {
win_vprintln_ch(window, '!', "No custom notification settings for %s", mucwin->roomjid); win_println(window, THEME_DEFAULT, '!', "No custom notification settings for %s", mucwin->roomjid);
} }
} }
} }

View File

@ -39,6 +39,8 @@
#include <glib.h> #include <glib.h>
#define THEME_DEFAULT 0
typedef enum { typedef enum {
THEME_TEXT, THEME_TEXT,
THEME_TEXT_ME, THEME_TEXT_ME,

View File

@ -442,7 +442,7 @@ sv_ev_incoming_message(char *barejid, char *resource, char *message, char *pgp_m
#ifdef HAVE_LIBGPGME #ifdef HAVE_LIBGPGME
if (pgp_message) { if (pgp_message) {
if (chatwin->is_otr) { if (chatwin->is_otr) {
win_println((ProfWin*)chatwin, 0, "PGP encrypted message received whilst in OTR session."); win_println((ProfWin*)chatwin, THEME_DEFAULT, '-', "PGP encrypted message received whilst in OTR session.");
} else { // PROF_ENC_NONE, PROF_ENC_PGP } else { // PROF_ENC_NONE, PROF_ENC_PGP
_sv_ev_incoming_pgp(chatwin, new_win, barejid, resource, message, pgp_message, timestamp); _sv_ev_incoming_pgp(chatwin, new_win, barejid, resource, message, pgp_message, timestamp);
} }

View File

@ -352,14 +352,14 @@ otr_on_message_send(ProfChatWin *chatwin, const char *const message, gboolean re
free(id); free(id);
return TRUE; return TRUE;
} else { } else {
ui_win_error_line((ProfWin*)chatwin, "Failed to encrypt and send message."); win_println((ProfWin*)chatwin, THEME_ERROR, '-', "%s", "Failed to encrypt and send message.");
return TRUE; return TRUE;
} }
} }
// show error if not secure and policy always // show error if not secure and policy always
if (policy == PROF_OTRPOLICY_ALWAYS) { if (policy == PROF_OTRPOLICY_ALWAYS) {
ui_win_error_line((ProfWin*)chatwin, "Failed to send message. OTR policy set to: always"); win_println((ProfWin*)chatwin, THEME_ERROR, '-', "%s", "Failed to send message. OTR policy set to: always");
return TRUE; return TRUE;
} }

View File

@ -85,7 +85,7 @@ api_cons_show_themed(const char *const group, const char *const key, const char
char *parsed = str_replace(message, "\r\n", "\n"); char *parsed = str_replace(message, "\r\n", "\n");
theme_item_t themeitem = plugin_themes_get(group, key, def); theme_item_t themeitem = plugin_themes_get(group, key, def);
ProfWin *console = wins_get_console(); ProfWin *console = wins_get_console();
win_print(console, '-', 0, NULL, 0, themeitem, "", parsed); win_println(console, themeitem, '-', "%s", parsed);
free(parsed); free(parsed);
@ -368,7 +368,7 @@ api_win_show(const char *tag, const char *line)
} }
ProfWin *window = (ProfWin*)pluginwin; ProfWin *window = (ProfWin*)pluginwin;
win_print(window, '!', 0, NULL, 0, 0, "", line); win_println(window, THEME_DEFAULT, '!', "%s", line);
return 1; return 1;
} }
@ -393,7 +393,7 @@ api_win_show_themed(const char *tag, const char *const group, const char *const
theme_item_t themeitem = plugin_themes_get(group, key, def); theme_item_t themeitem = plugin_themes_get(group, key, def);
ProfWin *window = (ProfWin*)pluginwin; ProfWin *window = (ProfWin*)pluginwin;
win_print(window, '!', 0, NULL, 0, themeitem, "", line); win_println(window, themeitem, '!', "%s", line);
return 1; return 1;
} }

View File

@ -146,7 +146,7 @@ http_file_put(void *userdata)
if (asprintf(&msg, "Uploading '%s': 0%%", upload->filename) == -1) { if (asprintf(&msg, "Uploading '%s': 0%%", upload->filename) == -1) {
msg = strdup(FALLBACK_MSG); msg = strdup(FALLBACK_MSG);
} }
win_print_with_receipt(upload->window, '!', 0, NULL, 0, THEME_TEXT_ME, NULL, msg, upload->put_url); win_print_http_upload(upload->window, msg, upload->put_url);
free(msg); free(msg);
char *cert_path = prefs_get_string(PREF_TLS_CERTPATH); char *cert_path = prefs_get_string(PREF_TLS_CERTPATH);

View File

@ -96,9 +96,9 @@ chatwin_otr_secured(ProfChatWin *chatwin, gboolean trusted)
ProfWin *window = (ProfWin*) chatwin; ProfWin *window = (ProfWin*) chatwin;
if (trusted) { if (trusted) {
win_print(window, '!', 0, NULL, 0, THEME_OTR_STARTED_TRUSTED, "", "OTR session started (trusted)."); win_println(window, THEME_OTR_STARTED_TRUSTED, '!', "OTR session started (trusted).");
} else { } else {
win_print(window, '!', 0, NULL, 0, THEME_OTR_STARTED_UNTRUSTED, "", "OTR session started (untrusted)."); win_println(window, THEME_OTR_STARTED_UNTRUSTED, '!', "OTR session started (untrusted).");
} }
if (wins_is_current(window)) { if (wins_is_current(window)) {
@ -125,7 +125,7 @@ chatwin_otr_unsecured(ProfChatWin *chatwin)
chatwin->otr_is_trusted = FALSE; chatwin->otr_is_trusted = FALSE;
ProfWin *window = (ProfWin*)chatwin; ProfWin *window = (ProfWin*)chatwin;
win_print(window, '!', 0, NULL, 0, THEME_OTR_ENDED, "", "OTR session ended."); win_println(window, THEME_OTR_ENDED, '!', "OTR session ended.");
if (wins_is_current(window)) { if (wins_is_current(window)) {
title_bar_switch(); title_bar_switch();
} }
@ -138,41 +138,41 @@ chatwin_otr_smp_event(ProfChatWin *chatwin, prof_otr_smp_event_t event, void *da
switch (event) { switch (event) {
case PROF_OTR_SMP_INIT: case PROF_OTR_SMP_INIT:
win_vprintln_ch((ProfWin*)chatwin, '!', win_println((ProfWin*)chatwin, THEME_DEFAULT, '!',
"%s wants to authenticate your identity, use '/otr secret <secret>'.", chatwin->barejid); "%s wants to authenticate your identity, use '/otr secret <secret>'.", chatwin->barejid);
break; break;
case PROF_OTR_SMP_INIT_Q: case PROF_OTR_SMP_INIT_Q:
win_vprintln_ch((ProfWin*)chatwin, '!', win_println((ProfWin*)chatwin, THEME_DEFAULT, '!',
"%s wants to authenticate your identity with the following question:", chatwin->barejid); "%s wants to authenticate your identity with the following question:", chatwin->barejid);
win_vprintln_ch((ProfWin*)chatwin, '!', " %s", (char*)data); win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', " %s", (char*)data);
win_vprintln_ch((ProfWin*)chatwin, '!', "use '/otr answer <answer>'."); win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', "use '/otr answer <answer>'.");
break; break;
case PROF_OTR_SMP_SENDER_FAIL: case PROF_OTR_SMP_SENDER_FAIL:
win_vprintln_ch((ProfWin*)chatwin, '!', win_println((ProfWin*)chatwin, THEME_DEFAULT, '!',
"Authentication failed, the secret you entered does not match the secret entered by %s.", "Authentication failed, the secret you entered does not match the secret entered by %s.",
chatwin->barejid); chatwin->barejid);
break; break;
case PROF_OTR_SMP_RECEIVER_FAIL: case PROF_OTR_SMP_RECEIVER_FAIL:
win_vprintln_ch((ProfWin*)chatwin, '!', win_println((ProfWin*)chatwin, THEME_DEFAULT, '!',
"Authentication failed, the secret entered by %s does not match yours.", chatwin->barejid); "Authentication failed, the secret entered by %s does not match yours.", chatwin->barejid);
break; break;
case PROF_OTR_SMP_ABORT: case PROF_OTR_SMP_ABORT:
win_vprintln_ch((ProfWin*)chatwin, '!', "SMP session aborted."); win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', "SMP session aborted.");
break; break;
case PROF_OTR_SMP_SUCCESS: case PROF_OTR_SMP_SUCCESS:
win_vprintln_ch((ProfWin*)chatwin, '!', "Authentication successful."); win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', "Authentication successful.");
break; break;
case PROF_OTR_SMP_SUCCESS_Q: case PROF_OTR_SMP_SUCCESS_Q:
win_vprintln_ch((ProfWin*)chatwin, '!', "%s successfully authenticated you.", chatwin->barejid); win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', "%s successfully authenticated you.", chatwin->barejid);
break; break;
case PROF_OTR_SMP_FAIL_Q: case PROF_OTR_SMP_FAIL_Q:
win_vprintln_ch((ProfWin*)chatwin, '!', "%s failed to authenticate you.", chatwin->barejid); win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', "%s failed to authenticate you.", chatwin->barejid);
break; break;
case PROF_OTR_SMP_AUTH: case PROF_OTR_SMP_AUTH:
win_vprintln_ch((ProfWin*)chatwin, '!', "Authenticating %s...", chatwin->barejid); win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', "Authenticating %s...", chatwin->barejid);
break; break;
case PROF_OTR_SMP_AUTH_WAIT: case PROF_OTR_SMP_AUTH_WAIT:
win_vprintln_ch((ProfWin*)chatwin, '!', "Awaiting authentication from %s...", chatwin->barejid); win_println((ProfWin*)chatwin, THEME_DEFAULT, '!', "Awaiting authentication from %s...", chatwin->barejid);
break; break;
default: default:
break; break;
@ -188,7 +188,7 @@ chatwin_otr_trust(ProfChatWin *chatwin)
chatwin->otr_is_trusted = TRUE; chatwin->otr_is_trusted = TRUE;
ProfWin *window = (ProfWin*)chatwin; ProfWin *window = (ProfWin*)chatwin;
win_print(window, '!', 0, NULL, 0, THEME_OTR_TRUSTED, "", "OTR session trusted."); win_println(window, THEME_OTR_TRUSTED, '!', "OTR session trusted.");
if (wins_is_current(window)) { if (wins_is_current(window)) {
title_bar_switch(); title_bar_switch();
} }
@ -203,7 +203,7 @@ chatwin_otr_untrust(ProfChatWin *chatwin)
chatwin->otr_is_trusted = FALSE; chatwin->otr_is_trusted = FALSE;
ProfWin *window = (ProfWin*)chatwin; ProfWin *window = (ProfWin*)chatwin;
win_print(window, '!', 0, NULL, 0, THEME_OTR_UNTRUSTED, "", "OTR session untrusted."); win_println(window, THEME_OTR_UNTRUSTED, '!', "OTR session untrusted.");
if (wins_is_current(window)) { if (wins_is_current(window)) {
title_bar_switch(); title_bar_switch();
} }
@ -227,7 +227,7 @@ chatwin_recipient_gone(ProfChatWin *chatwin)
display_usr = chatwin->barejid; display_usr = chatwin->barejid;
} }
win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, THEME_GONE, "", "<- %s has left the conversation.", display_usr); win_println((ProfWin*)chatwin, THEME_GONE, '!', "<- %s has left the conversation.", display_usr);
} }
void void
@ -247,7 +247,7 @@ chatwin_incoming_msg(ProfChatWin *chatwin, const char *const resource, const cha
// currently viewing chat window with sender // currently viewing chat window with sender
if (wins_is_current(window)) { if (wins_is_current(window)) {
win_print_incoming_message(window, timestamp, display_name, plugin_message, enc_mode); win_print_incoming(window, timestamp, display_name, plugin_message, enc_mode);
title_bar_set_typing(FALSE); title_bar_set_typing(FALSE);
status_bar_active(num); status_bar_active(num);
@ -274,7 +274,7 @@ chatwin_incoming_msg(ProfChatWin *chatwin, const char *const resource, const cha
} }
} }
win_print_incoming_message(window, timestamp, display_name, plugin_message, enc_mode); win_print_incoming(window, timestamp, display_name, plugin_message, enc_mode);
} }
if (prefs_get_boolean(PREF_BEEP)) { if (prefs_get_boolean(PREF_BEEP)) {
@ -306,9 +306,9 @@ chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id,
} }
if (request_receipt && id) { if (request_receipt && id) {
win_print_with_receipt((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", message, id); win_print_with_receipt((ProfWin*)chatwin, enc_char, "me", message, id);
} else { } else {
win_print((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", message); win_print_outgoing((ProfWin*)chatwin, enc_char, "%s", message);
} }
} }
@ -322,7 +322,7 @@ chatwin_outgoing_carbon(ProfChatWin *chatwin, const char *const message, prof_en
enc_char = prefs_get_pgp_char(); enc_char = prefs_get_pgp_char();
} }
win_print((ProfWin*)chatwin, enc_char, 0, NULL, 0, THEME_TEXT_ME, "me", message); win_print_outgoing((ProfWin*)chatwin, enc_char, "%s", message);
int num = wins_get_num((ProfWin*)chatwin); int num = wins_get_num((ProfWin*)chatwin);
status_bar_active(num); status_bar_active(num);
} }
@ -401,11 +401,11 @@ _chatwin_history(ProfChatWin *chatwin, const char *const contact)
char mm[3]; memcpy(mm, &line[3], 2); mm[2] = '\0'; int imm = atoi(mm); 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); char ss[3]; memcpy(ss, &line[6], 2); ss[2] = '\0'; int iss = atoi(ss);
GDateTime *timestamp = g_date_time_new_local(2000, 1, 1, ihh, imm, iss); GDateTime *timestamp = g_date_time_new_local(2000, 1, 1, ihh, imm, iss);
win_print((ProfWin*)chatwin, '-', 0, timestamp, NO_COLOUR_DATE, 0, "", curr->data+11); win_print_history((ProfWin*)chatwin, timestamp, "%s", curr->data+11);
g_date_time_unref(timestamp); g_date_time_unref(timestamp);
// header // header
} else { } else {
win_print((ProfWin*)chatwin, '-', 0, NULL, 0, 0, "", curr->data); win_println((ProfWin*)chatwin, THEME_DEFAULT, '-', "%s", curr->data);
} }
curr = g_slist_next(curr); curr = g_slist_next(curr);
} }

View File

@ -67,14 +67,14 @@ void
cons_show_time(void) cons_show_time(void)
{ {
ProfWin *console = wins_get_console(); ProfWin *console = wins_get_console();
win_print(console, '-', 0, NULL, NO_EOL, 0, "", ""); win_print(console, THEME_DEFAULT, '-', "");
} }
void void
cons_show_word(const char *const word) cons_show_word(const char *const word)
{ {
ProfWin *console = wins_get_console(); ProfWin *console = wins_get_console();
win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", word); win_append(console, THEME_DEFAULT, "%s", word);
} }
void void
@ -86,7 +86,7 @@ cons_debug(const char *const msg, ...)
va_start(arg, msg); va_start(arg, msg);
GString *fmt_msg = g_string_new(NULL); GString *fmt_msg = g_string_new(NULL);
g_string_vprintf(fmt_msg, msg, arg); g_string_vprintf(fmt_msg, msg, arg);
win_println(console, 0, fmt_msg->str); win_println(console, THEME_DEFAULT, '-', "%s", fmt_msg->str);
g_string_free(fmt_msg, TRUE); g_string_free(fmt_msg, TRUE);
va_end(arg); va_end(arg);
} }
@ -100,7 +100,7 @@ cons_show(const char *const msg, ...)
va_start(arg, msg); va_start(arg, msg);
GString *fmt_msg = g_string_new(NULL); GString *fmt_msg = g_string_new(NULL);
g_string_vprintf(fmt_msg, msg, arg); g_string_vprintf(fmt_msg, msg, arg);
win_println(console, 0, fmt_msg->str); win_println(console, THEME_DEFAULT, '-', "%s", fmt_msg->str);
g_string_free(fmt_msg, TRUE); g_string_free(fmt_msg, TRUE);
va_end(arg); va_end(arg);
} }
@ -113,7 +113,7 @@ cons_show_padded(int pad, const char *const msg, ...)
va_start(arg, msg); va_start(arg, msg);
GString *fmt_msg = g_string_new(NULL); GString *fmt_msg = g_string_new(NULL);
g_string_vprintf(fmt_msg, msg, arg); g_string_vprintf(fmt_msg, msg, arg);
win_println(console, pad, fmt_msg->str); win_println_indent(console, pad, "%s", fmt_msg->str);
g_string_free(fmt_msg, TRUE); g_string_free(fmt_msg, TRUE);
va_end(arg); va_end(arg);
} }
@ -124,21 +124,21 @@ cons_show_help(const char *const cmd, CommandHelp *help)
ProfWin *console = wins_get_console(); ProfWin *console = wins_get_console();
cons_show(""); cons_show("");
win_vprint(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "%s", &cmd[1]); win_println(console, THEME_WHITE_BOLD, '-', "%s", &cmd[1]);
win_print(console, '-', 0, NULL, NO_EOL, THEME_WHITE_BOLD, "", ""); win_print(console, THEME_WHITE_BOLD, '-', "");
int i; int i;
for (i = 0; i < strlen(cmd) - 1 ; i++) { for (i = 0; i < strlen(cmd) - 1 ; i++) {
win_print(console, '-', 0, NULL, NO_EOL | NO_DATE, THEME_WHITE_BOLD, "", "-"); win_append(console, THEME_WHITE_BOLD, "-");
} }
win_print(console, '-', 0, NULL, NO_DATE, THEME_WHITE_BOLD, "", ""); win_appendln(console, THEME_WHITE_BOLD, "");
cons_show(""); cons_show("");
win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Synopsis"); win_println(console, THEME_WHITE_BOLD, '-', "Synopsis");
ui_show_lines(console, help->synopsis); ui_show_lines(console, help->synopsis);
cons_show(""); cons_show("");
win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Description"); win_println(console, THEME_WHITE_BOLD, '-', "Description");
win_println(console, 0, help->desc); win_println(console, THEME_DEFAULT, '-', "%s", help->desc);
int maxlen = 0; int maxlen = 0;
for (i = 0; help->args[i][0] != NULL; i++) { for (i = 0; help->args[i][0] != NULL; i++) {
@ -148,15 +148,15 @@ cons_show_help(const char *const cmd, CommandHelp *help)
if (i > 0) { if (i > 0) {
cons_show(""); cons_show("");
win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Arguments"); win_println(console, THEME_WHITE_BOLD, '-', "Arguments");
for (i = 0; help->args[i][0] != NULL; i++) { for (i = 0; help->args[i][0] != NULL; i++) {
win_vprint(console, '-', maxlen + 3, NULL, 0, 0, "", "%-*s: %s", maxlen + 1, help->args[i][0], help->args[i][1]); win_println_indent(console, maxlen + 3, "%-*s: %s", maxlen + 1, help->args[i][0], help->args[i][1]);
} }
} }
if (g_strv_length((gchar**)help->examples) > 0) { if (g_strv_length((gchar**)help->examples) > 0) {
cons_show(""); cons_show("");
win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Examples"); win_println(console, THEME_WHITE_BOLD, '-', "Arguments");
ui_show_lines(console, help->examples); ui_show_lines(console, help->examples);
} }
} }
@ -181,7 +181,7 @@ cons_show_error(const char *const msg, ...)
va_start(arg, msg); va_start(arg, msg);
GString *fmt_msg = g_string_new(NULL); GString *fmt_msg = g_string_new(NULL);
g_string_vprintf(fmt_msg, msg, arg); g_string_vprintf(fmt_msg, msg, arg);
win_print(console, '-', 0, NULL, 0, THEME_ERROR, "", fmt_msg->str); win_println(console, THEME_ERROR, '-', "%s", fmt_msg->str);
g_string_free(fmt_msg, TRUE); g_string_free(fmt_msg, TRUE);
va_end(arg); va_end(arg);
@ -296,7 +296,7 @@ cons_show_typing(const char *const barejid)
display_usr = barejid; display_usr = barejid;
} }
win_vprint(console, '-', 0, NULL, 0, THEME_TYPING, "", "!! %s is typing a message...", display_usr); win_println(console, THEME_TYPING, '-', "!! %s is typing a message...", display_usr);
cons_alert(); cons_alert();
} }
@ -333,27 +333,27 @@ cons_show_incoming_room_message(const char *const nick, const char *const room,
if (g_strcmp0(muc_show, "all") == 0) { if (g_strcmp0(muc_show, "all") == 0) {
if (mention) { if (mention) {
win_vprint(console, '-', 0, NULL, 0, THEME_MENTION, "", "<< room mention: %s in %s (win %d)", nick, room, ui_index); win_println(console, THEME_MENTION, '-', "<< room mention: %s in %s (win %d)", nick, room, ui_index);
} else if (triggers) { } else if (triggers) {
char *triggers_str = _room_triggers_to_string(triggers); char *triggers_str = _room_triggers_to_string(triggers);
win_vprint(console, '-', 0, NULL, 0, THEME_TRIGGER, "", "<< room trigger %s: %s in %s (win %d)", triggers_str, nick, room, ui_index); win_println(console, THEME_TRIGGER, '-', "<< room trigger %s: %s in %s (win %d)", triggers_str, nick, room, ui_index);
free(triggers_str); free(triggers_str);
} else { } else {
win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< room message: %s in %s (win %d)", nick, room, ui_index); win_println(console, THEME_INCOMING, '-', "<< room message: %s in %s (win %d)", nick, room, ui_index);
} }
cons_alert(); cons_alert();
} else if (g_strcmp0(muc_show, "first") == 0) { } else if (g_strcmp0(muc_show, "first") == 0) {
if (mention) { if (mention) {
win_vprint(console, '-', 0, NULL, 0, THEME_MENTION, "", "<< room mention: %s in %s (win %d)", nick, room, ui_index); win_println(console, THEME_MENTION, '-', "<< room mention: %s in %s (win %d)", nick, room, ui_index);
cons_alert(); cons_alert();
} else if (triggers) { } else if (triggers) {
char *triggers_str = _room_triggers_to_string(triggers); char *triggers_str = _room_triggers_to_string(triggers);
win_vprint(console, '-', 0, NULL, 0, THEME_TRIGGER, "", "<< room trigger %s: %s in %s (win %d)", triggers_str, nick, room, ui_index); win_println(console, THEME_TRIGGER, '-', "<< room trigger %s: %s in %s (win %d)", triggers_str, nick, room, ui_index);
free(triggers_str); free(triggers_str);
cons_alert(); cons_alert();
} else if (unread == 0) { } else if (unread == 0) {
win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< room message: %s (win %d)", room, ui_index); win_println(console, THEME_INCOMING, '-', "<< room message: %s (win %d)", room, ui_index);
cons_alert(); cons_alert();
} }
} }
@ -372,10 +372,10 @@ cons_show_incoming_message(const char *const short_from, const int win_index, in
char *chat_show = prefs_get_string(PREF_CONSOLE_CHAT); char *chat_show = prefs_get_string(PREF_CONSOLE_CHAT);
if (g_strcmp0(chat_show, "all") == 0) { if (g_strcmp0(chat_show, "all") == 0) {
win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< chat message: %s (win %d)", short_from, ui_index); win_println(console, THEME_INCOMING, '-', "<< chat message: %s (win %d)", short_from, ui_index);
cons_alert(); cons_alert();
} else if ((g_strcmp0(chat_show, "first") == 0) && unread == 0) { } else if ((g_strcmp0(chat_show, "first") == 0) && unread == 0) {
win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< chat message: %s (win %d)", short_from, ui_index); win_println(console, THEME_INCOMING, '-', "<< chat message: %s (win %d)", short_from, ui_index);
cons_alert(); cons_alert();
} }
@ -394,10 +394,10 @@ cons_show_incoming_private_message(const char *const nick, const char *const roo
char *priv_show = prefs_get_string(PREF_CONSOLE_PRIVATE); char *priv_show = prefs_get_string(PREF_CONSOLE_PRIVATE);
if (g_strcmp0(priv_show, "all") == 0) { if (g_strcmp0(priv_show, "all") == 0) {
win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< private message: %s in %s (win %d)", nick, room, ui_index); win_println(console, THEME_INCOMING, '-', "<< private message: %s in %s (win %d)", nick, room, ui_index);
cons_alert(); cons_alert();
} else if ((g_strcmp0(priv_show, "first") == 0) && unread == 0) { } else if ((g_strcmp0(priv_show, "first") == 0) && unread == 0) {
win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< private message: %s in %s (win %d)", nick, room, ui_index); win_println(console, THEME_INCOMING, '-', "<< private message: %s in %s (win %d)", nick, room, ui_index);
cons_alert(); cons_alert();
} }
@ -417,23 +417,23 @@ cons_about(void)
if (strcmp(PACKAGE_STATUS, "development") == 0) { if (strcmp(PACKAGE_STATUS, "development") == 0) {
#ifdef HAVE_GIT_VERSION #ifdef HAVE_GIT_VERSION
win_vprint(console, '-', 0, NULL, 0, 0, "", "Welcome to Profanity, version %sdev.%s.%s", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION); win_println(console, THEME_DEFAULT, '-', "Welcome to Profanity, version %sdev.%s.%s", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION);
#else #else
win_vprint(console, '-', 0, NULL, 0, 0, "", "Welcome to Profanity, version %sdev", PACKAGE_VERSION); win_println(console, THEME_DEFAULT, "Welcome to Profanity, version %sdev", PACKAGE_VERSION);
#endif #endif
} else { } else {
win_vprint(console, '-', 0, NULL, 0, 0, "", "Welcome to Profanity, version %s", PACKAGE_VERSION); win_println(console, THEME_DEFAULT, '-', "Welcome to Profanity, version %s", PACKAGE_VERSION);
} }
} }
win_vprint(console, '-', 0, NULL, 0, 0, "", "Copyright (C) 2012 - 2016 James Booth <%s>.", PACKAGE_BUGREPORT); win_println(console, THEME_DEFAULT, '-', "Copyright (C) 2012 - 2016 James Booth <%s>.", PACKAGE_BUGREPORT);
win_println(console, 0, "License GPLv3+: GNU GPL version 3 or later <https://www.gnu.org/licenses/gpl.html>"); win_println(console, THEME_DEFAULT, '-', "License GPLv3+: GNU GPL version 3 or later <https://www.gnu.org/licenses/gpl.html>");
win_println(console, 0, ""); win_println(console, THEME_DEFAULT, '-', "");
win_println(console, 0, "This is free software; you are free to change and redistribute it."); win_println(console, THEME_DEFAULT, '-', "This is free software; you are free to change and redistribute it.");
win_println(console, 0, "There is NO WARRANTY, to the extent permitted by law."); win_println(console, THEME_DEFAULT, '-', "There is NO WARRANTY, to the extent permitted by law.");
win_println(console, 0, ""); win_println(console, THEME_DEFAULT, '-', "");
win_println(console, 0, "Type '/help' to show complete help."); win_println(console, THEME_DEFAULT, '-', "Type '/help' to show complete help.");
win_println(console, 0, ""); win_println(console, THEME_DEFAULT, '-', "");
if (prefs_get_boolean(PREF_VERCHECK)) { if (prefs_get_boolean(PREF_VERCHECK)) {
cons_check_version(FALSE); cons_check_version(FALSE);
@ -455,13 +455,13 @@ cons_check_version(gboolean not_available_msg)
if (relase_valid) { if (relase_valid) {
if (release_is_new(latest_release)) { if (release_is_new(latest_release)) {
win_vprint(console, '-', 0, NULL, 0, 0, "", "A new version of Profanity is available: %s", latest_release); win_println(console, THEME_DEFAULT, '-', "A new version of Profanity is available: %s", latest_release);
win_println(console, 0, "Check <http://www.profanity.im> for details."); win_println(console, THEME_DEFAULT, '-', "Check <http://www.profanity.im> for details.");
win_println(console, 0, ""); win_println(console, THEME_DEFAULT, '-', "");
} else { } else {
if (not_available_msg) { if (not_available_msg) {
win_println(console, 0, "No new version available."); win_println(console, THEME_DEFAULT, '-', "No new version available.");
win_println(console, 0, ""); win_println(console, THEME_DEFAULT, '-', "");
} }
} }
@ -475,16 +475,15 @@ void
cons_show_login_success(ProfAccount *account, gboolean secured) cons_show_login_success(ProfAccount *account, gboolean secured)
{ {
ProfWin *console = wins_get_console(); ProfWin *console = wins_get_console();
win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", "%s logged in successfully, ", account->jid); win_print(console, THEME_DEFAULT, '-', "%s logged in successfully, ", account->jid);
resource_presence_t presence = accounts_get_login_presence(account->name); resource_presence_t presence = accounts_get_login_presence(account->name);
const char *presence_str = string_from_resource_presence(presence); const char *presence_str = string_from_resource_presence(presence);
theme_item_t presence_colour = theme_main_presence_attrs(presence_str); theme_item_t presence_colour = theme_main_presence_attrs(presence_str);
win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", presence_str); win_append(console, presence_colour, "%s", presence_str);
win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " (priority %d)", win_append(console, THEME_DEFAULT, " (priority %d)", accounts_get_priority_for_presence_type(account->name, presence));
accounts_get_priority_for_presence_type(account->name, presence)); win_appendln(console, THEME_DEFAULT, ".");
win_print(console, '-', 0, NULL, NO_DATE, 0, "", ".");
if (!secured) { if (!secured) {
cons_show_error("TLS connection not established"); cons_show_error("TLS connection not established");
} }
@ -509,7 +508,7 @@ cons_show_wins(gboolean unread)
GSList *curr = window_strings; GSList *curr = window_strings;
while (curr) { while (curr) {
win_println(console, 0, curr->data); win_println(console, THEME_DEFAULT, '-', "%s", curr->data);
curr = g_slist_next(curr); curr = g_slist_next(curr);
} }
g_slist_free_full(window_strings, free); g_slist_free_full(window_strings, free);
@ -554,27 +553,27 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence)
const char *resource_presence = string_from_resource_presence(presence); const char *resource_presence = string_from_resource_presence(presence);
theme_item_t presence_colour = theme_main_presence_attrs(resource_presence); theme_item_t presence_colour = theme_main_presence_attrs(resource_presence);
win_vprint(console, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", fulljid); win_print(console, presence_colour, '-', "%s", fulljid);
win_print(console, '-', 0, NULL, NO_DATE, 0, "", ":"); win_appendln(console, THEME_DEFAULT, ":");
// show identity // show identity
if (caps->identity) { if (caps->identity) {
DiscoIdentity *identity = caps->identity; DiscoIdentity *identity = caps->identity;
win_print(console, '-', 0, NULL, NO_EOL, 0, "", "Identity: "); win_print(console, THEME_DEFAULT, '-', "Identity: ");
if (identity->name) { if (identity->name) {
win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->name); win_append(console, THEME_DEFAULT, "%s", identity->name);
if (identity->category || identity->type) { if (identity->category || identity->type) {
win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); win_append(console, THEME_DEFAULT, " ");
} }
} }
if (identity->type) { if (identity->type) {
win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->type); win_append(console, THEME_DEFAULT, "%s", identity->type);
if (identity->category) { if (identity->category) {
win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); win_append(console, THEME_DEFAULT, " ");
} }
} }
if (identity->category) { if (identity->category) {
win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->category); win_append(console, THEME_DEFAULT, "%s", identity->category);
} }
win_newline(console); win_newline(console);
} }
@ -582,19 +581,19 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence)
if (caps->software_version) { if (caps->software_version) {
SoftwareVersion *software_version = caps->software_version; SoftwareVersion *software_version = caps->software_version;
if (software_version->software) { if (software_version->software) {
win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", "Software: %s", software_version->software); win_print(console, THEME_DEFAULT, '-', "Software: %s", software_version->software);
} }
if (software_version->software_version) { if (software_version->software_version) {
win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->software_version); win_append(console, THEME_DEFAULT, ", %s", software_version->software_version);
} }
if (software_version->software || software_version->software_version) { if (software_version->software || software_version->software_version) {
win_newline(console); win_newline(console);
} }
if (software_version->os) { if (software_version->os) {
win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", "OS: %s", software_version->os); win_print(console, THEME_DEFAULT, '-', "OS: %s", software_version->os);
} }
if (software_version->os_version) { if (software_version->os_version) {
win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->os_version); win_append(console, THEME_DEFAULT, ", %s", software_version->os_version);
} }
if (software_version->os || software_version->os_version) { if (software_version->os || software_version->os_version) {
win_newline(console); win_newline(console);
@ -602,10 +601,10 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence)
} }
if (caps->features) { if (caps->features) {
win_println(console, 0, "Features:"); win_println(console, THEME_DEFAULT, '-', "Features:");
GSList *feature = caps->features; GSList *feature = caps->features;
while (feature) { while (feature) {
win_vprint(console, '-', 0, NULL, 0, 0, "", " %s", feature->data); win_println(console, THEME_DEFAULT, '-', " %s", feature->data);
feature = g_slist_next(feature); feature = g_slist_next(feature);
} }
} }
@ -667,9 +666,9 @@ cons_show_room_list(GSList *rooms, const char *const conference_node)
cons_show("Chat rooms at %s:", conference_node); cons_show("Chat rooms at %s:", conference_node);
while (rooms) { while (rooms) {
DiscoItem *room = rooms->data; DiscoItem *room = rooms->data;
win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", " %s", room->jid); win_print(console, THEME_DEFAULT, '-', " %s", room->jid);
if (room->name) { if (room->name) {
win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", (%s)", room->name); win_append(console, THEME_DEFAULT, ", (%s)", room->name);
} }
win_newline(console); win_newline(console);
rooms = g_slist_next(rooms); rooms = g_slist_next(rooms);
@ -701,21 +700,21 @@ cons_show_bookmarks(const GList *list)
if (muc_active(item->barejid)) { if (muc_active(item->barejid)) {
presence_colour = THEME_ONLINE; presence_colour = THEME_ONLINE;
} }
win_vprint(console, '-', 0, NULL, NO_EOL, presence_colour, "", " %s", item->barejid); win_print(console, presence_colour, '-', " %s", item->barejid);
if (item->nick) { if (item->nick) {
win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "/%s", item->nick); win_append(console, presence_colour, "/%s", item->nick);
} }
if (item->autojoin) { if (item->autojoin) {
win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (autojoin)"); win_append(console, presence_colour, " (autojoin)");
} }
if (item->password) { if (item->password) {
win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (private)"); win_append(console, presence_colour, " (private)");
} }
if (muc_active(item->barejid)) { if (muc_active(item->barejid)) {
ProfWin *roomwin = (ProfWin*)wins_get_muc(item->barejid); ProfWin *roomwin = (ProfWin*)wins_get_muc(item->barejid);
if (roomwin) { if (roomwin) {
int num = wins_get_num(roomwin); int num = wins_get_num(roomwin);
win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (win %d)", num); win_append(console, presence_colour, " (win %d)", num);
} }
} }
win_newline(console); win_newline(console);
@ -784,11 +783,11 @@ cons_show_disco_items(GSList *items, const char *const jid)
cons_show("Service discovery items for %s:", jid); cons_show("Service discovery items for %s:", jid);
while (items) { while (items) {
DiscoItem *item = items->data; DiscoItem *item = items->data;
win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", " %s", item->jid); win_print(console, THEME_DEFAULT, '-', " %s", item->jid);
if (item->name) { if (item->name) {
win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", (%s)", item->name); win_append(console, THEME_DEFAULT, ", (%s)", item->name);
} }
win_vprint(console, '-', 0, NULL, NO_DATE, 0, "", ""); win_appendln(console, THEME_DEFAULT, "");
items = g_slist_next(items); items = g_slist_next(items);
} }
} else { } else {
@ -863,7 +862,7 @@ cons_show_account_list(gchar **accounts)
(g_strcmp0(session_get_account_name(), accounts[i]) == 0)) { (g_strcmp0(session_get_account_name(), accounts[i]) == 0)) {
resource_presence_t presence = accounts_get_last_presence(accounts[i]); resource_presence_t presence = accounts_get_last_presence(accounts[i]);
theme_item_t presence_colour = theme_main_presence_attrs(string_from_resource_presence(presence)); theme_item_t presence_colour = theme_main_presence_attrs(string_from_resource_presence(presence));
win_vprint(console, '-', 0, NULL, 0, presence_colour, "", "%s", accounts[i]); win_println(console, presence_colour, '-', "%s", accounts[i]);
} else { } else {
cons_show(accounts[i]); cons_show(accounts[i]);
} }
@ -982,7 +981,7 @@ cons_show_account(ProfAccount *account)
GList *curr = resources; GList *curr = resources;
if (curr) { if (curr) {
win_println(console, 0, "Resources:"); win_println(console, THEME_DEFAULT, '-', "Resources:");
// sort in order of availability // sort in order of availability
while (curr) { while (curr) {
@ -1000,12 +999,12 @@ cons_show_account(ProfAccount *account)
Resource *resource = curr->data; Resource *resource = curr->data;
const char *resource_presence = string_from_resource_presence(resource->presence); const char *resource_presence = string_from_resource_presence(resource->presence);
theme_item_t presence_colour = theme_main_presence_attrs(resource_presence); theme_item_t presence_colour = theme_main_presence_attrs(resource_presence);
win_vprint(console, '-', 0, NULL, NO_EOL, presence_colour, "", " %s (%d), %s", resource->name, resource->priority, resource_presence); win_print(console, presence_colour, '-', " %s (%d), %s", resource->name, resource->priority, resource_presence);
if (resource->status) { if (resource->status) {
win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", resource->status); win_append(console, presence_colour, ", \"%s\"", resource->status);
} }
win_vprint(console, '-', 0, NULL, NO_DATE, 0, "", ""); win_appendln(console, THEME_DEFAULT, "");
Jid *jidp = jid_create_from_bare_and_resource(account->jid, resource->name); Jid *jidp = jid_create_from_bare_and_resource(account->jid, resource->name);
EntityCapabilities *caps = caps_lookup(jidp->fulljid); EntityCapabilities *caps = caps_lookup(jidp->fulljid);
jid_destroy(jidp); jid_destroy(jidp);
@ -1014,21 +1013,21 @@ cons_show_account(ProfAccount *account)
// show identity // show identity
if (caps->identity) { if (caps->identity) {
DiscoIdentity *identity = caps->identity; DiscoIdentity *identity = caps->identity;
win_print(console, '-', 0, NULL, NO_EOL, 0, "", " Identity: "); win_print(console, THEME_DEFAULT, '-', " Identity: ");
if (identity->name) { if (identity->name) {
win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->name); win_append(console, THEME_DEFAULT, "%s", identity->name);
if (identity->category || identity->type) { if (identity->category || identity->type) {
win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); win_append(console, THEME_DEFAULT, " ");
} }
} }
if (identity->type) { if (identity->type) {
win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->type); win_append(console, THEME_DEFAULT, "%s", identity->type);
if (identity->category) { if (identity->category) {
win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); win_append(console, THEME_DEFAULT, " ");
} }
} }
if (identity->category) { if (identity->category) {
win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->category); win_append(console, THEME_DEFAULT, "%s", identity->category);
} }
win_newline(console); win_newline(console);
} }
@ -1036,19 +1035,19 @@ cons_show_account(ProfAccount *account)
if (caps->software_version) { if (caps->software_version) {
SoftwareVersion *software_version = caps->software_version; SoftwareVersion *software_version = caps->software_version;
if (software_version->software) { if (software_version->software) {
win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", " Software: %s", software_version->software); win_print(console, THEME_DEFAULT, '-', " Software: %s", software_version->software);
} }
if (software_version->software_version) { if (software_version->software_version) {
win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->software_version); win_append(console, THEME_DEFAULT, ", %s", software_version->software_version);
} }
if (software_version->software || software_version->software_version) { if (software_version->software || software_version->software_version) {
win_newline(console); win_newline(console);
} }
if (software_version->os) { if (software_version->os) {
win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", " OS: %s", software_version->os); win_print(console, THEME_DEFAULT, '-', " OS: %s", software_version->os);
} }
if (software_version->os_version) { if (software_version->os_version) {
win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->os_version); win_append(console, THEME_DEFAULT, ", %s", software_version->os_version);
} }
if (software_version->os || software_version->os_version) { if (software_version->os || software_version->os_version) {
win_newline(console); win_newline(console);
@ -2078,7 +2077,7 @@ cons_navigation_help(void)
{ {
ProfWin *console = wins_get_console(); ProfWin *console = wins_get_console();
cons_show(""); cons_show("");
win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Navigation"); win_println(console, THEME_WHITE_BOLD, '-', "Navigation");
cons_show("Alt-1..Alt-0, F1..F10 : Choose window."); cons_show("Alt-1..Alt-0, F1..F10 : Choose window.");
cons_show("Alt-LEFT, Alt-RIGHT : Previous/next chat window."); cons_show("Alt-LEFT, Alt-RIGHT : Previous/next chat window.");
cons_show("PAGEUP, PAGEDOWN : Page the main window."); cons_show("PAGEUP, PAGEDOWN : Page the main window.");
@ -2184,15 +2183,15 @@ _cons_theme_bar_prop(theme_item_t theme, char *prop)
GString *propstr = g_string_new(" "); GString *propstr = g_string_new(" ");
g_string_append_printf(propstr, "%-24s", prop); g_string_append_printf(propstr, "%-24s", prop);
win_print(console, '-', 0, NULL, NO_EOL, THEME_TEXT, "", propstr->str); win_print(console, THEME_TEXT, '-', "%s", propstr->str);
g_string_free(propstr, TRUE); g_string_free(propstr, TRUE);
GString *valstr = g_string_new(" "); GString *valstr = g_string_new(" ");
char *setting = theme_get_string(prop); char *setting = theme_get_string(prop);
g_string_append_printf(valstr, "%s ", setting); g_string_append_printf(valstr, "%s ", setting);
theme_free_string(setting); theme_free_string(setting);
win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, theme, "", valstr->str); win_append(console, theme, "%s", valstr->str);
win_print(console, '-', 0, NULL, NO_DATE, THEME_TEXT, "", ""); win_appendln(console, THEME_TEXT, "");
g_string_free(valstr, TRUE); g_string_free(valstr, TRUE);
} }
@ -2203,22 +2202,15 @@ _cons_theme_prop(theme_item_t theme, char *prop)
GString *propstr = g_string_new(" "); GString *propstr = g_string_new(" ");
g_string_append_printf(propstr, "%-24s", prop); g_string_append_printf(propstr, "%-24s", prop);
win_print(console, '-', 0, NULL, NO_EOL, THEME_TEXT, "", propstr->str); win_print(console, THEME_TEXT, '-', "%s", propstr->str);
g_string_free(propstr, TRUE); g_string_free(propstr, TRUE);
GString *valstr = g_string_new(""); GString *valstr = g_string_new("");
char *setting = theme_get_string(prop); char *setting = theme_get_string(prop);
g_string_append_printf(valstr, "%s", setting); g_string_append_printf(valstr, "%s", setting);
theme_free_string(setting); theme_free_string(setting);
win_print(console, '-', 0, NULL, NO_DATE, theme, "", valstr->str); win_appendln(console, theme, "%s", valstr->str);
g_string_free(valstr, TRUE); g_string_free(valstr, TRUE);
// GString *str = g_string_new(" ");
// char *setting = theme_get_string(prop);
// g_string_append_printf(str, "%-24s%s", prop, setting);
// theme_free_string(setting);
// win_print(console, '-', 0, NULL, 0, theme, "", str->str);
// g_string_free(str, TRUE);
} }
void void
@ -2332,22 +2324,31 @@ cons_theme_colours(void)
ProfWin *console = wins_get_console(); ProfWin *console = wins_get_console();
cons_show("Available colours:"); cons_show("Available colours:");
win_print(console, '-', 0, NULL, NO_EOL, THEME_WHITE, "", " white ");
win_print(console, '-', 0, NULL, NO_DATE, THEME_WHITE_BOLD, "", " bold_white"); win_print(console, THEME_WHITE, '-', " white ");
win_print(console, '-', 0, NULL, NO_EOL, THEME_GREEN, "", " green "); win_appendln(console, THEME_WHITE_BOLD, " bold_white");
win_print(console, '-', 0, NULL, NO_DATE, THEME_GREEN_BOLD, "", " bold_green");
win_print(console, '-', 0, NULL, NO_EOL, THEME_RED, "", " red "); win_print(console, THEME_GREEN, '-', " green ");
win_print(console, '-', 0, NULL, NO_DATE, THEME_RED_BOLD, "", " bold_red"); win_appendln(console, THEME_GREEN_BOLD, " bold_green");
win_print(console, '-', 0, NULL, NO_EOL, THEME_YELLOW, "", " yellow ");
win_print(console, '-', 0, NULL, NO_DATE, THEME_YELLOW_BOLD, "", " bold_yellow"); win_print(console, THEME_RED, '-', " red ");
win_print(console, '-', 0, NULL, NO_EOL, THEME_BLUE, "", " blue "); win_appendln(console, THEME_RED_BOLD, " bold_red");
win_print(console, '-', 0, NULL, NO_DATE, THEME_BLUE_BOLD, "", " bold_blue");
win_print(console, '-', 0, NULL, NO_EOL, THEME_CYAN, "", " cyan "); win_print(console, THEME_YELLOW, '-', " yellow ");
win_print(console, '-', 0, NULL, NO_DATE, THEME_CYAN_BOLD, "", " bold_cyan"); win_appendln(console, THEME_YELLOW_BOLD, " bold_yellow");
win_print(console, '-', 0, NULL, NO_EOL, THEME_MAGENTA, "", " magenta ");
win_print(console, '-', 0, NULL, NO_DATE, THEME_MAGENTA_BOLD, "", " bold_magenta"); win_print(console, THEME_BLUE, '-', " blue ");
win_print(console, '-', 0, NULL, NO_EOL, THEME_BLACK, "", " black "); win_appendln(console, THEME_BLUE_BOLD, " bold_blue");
win_print(console, '-', 0, NULL, NO_DATE, THEME_BLACK_BOLD, "", " bold_black");
win_print(console, THEME_CYAN, '-', " cyan ");
win_appendln(console, THEME_CYAN_BOLD, " bold_cyan");
win_print(console, THEME_MAGENTA, '-', " magenta ");
win_appendln(console, THEME_MAGENTA_BOLD, " bold_magenta");
win_print(console, THEME_BLACK, '-', " black ");
win_appendln(console, THEME_BLACK_BOLD, " bold_black");
cons_show(""); cons_show("");
} }
@ -2355,25 +2356,25 @@ static void
_cons_splash_logo(void) _cons_splash_logo(void)
{ {
ProfWin *console = wins_get_console(); ProfWin *console = wins_get_console();
win_println(console, 0, "Welcome to"); win_println(console, THEME_DEFAULT, '-', "Welcome to");
win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", " ___ _ "); win_println(console, THEME_SPLASH, '-', " ___ _ ");
win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", " / __) (_)_ "); win_println(console, THEME_SPLASH, '-', " / __) (_)_ ");
win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", " ____ ____ ___ | |__ ____ ____ _| |_ _ _ "); win_println(console, THEME_SPLASH, '-', " ____ ____ ___ | |__ ____ ____ _| |_ _ _ ");
win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", "| _ \\ / ___) _ \\| __) _ | _ \\| | _) | | |"); win_println(console, THEME_SPLASH, '-', "| _ \\ / ___) _ \\| __) _ | _ \\| | _) | | |");
win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", "| | | | | | |_| | | ( ( | | | | | | |_| |_| |"); win_println(console, THEME_SPLASH, '-', "| | | | | | |_| | | ( ( | | | | | | |_| |_| |");
win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", "| ||_/|_| \\___/|_| \\_||_|_| |_|_|\\___)__ |"); win_println(console, THEME_SPLASH, '-', "| ||_/|_| \\___/|_| \\_||_|_| |_|_|\\___)__ |");
win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", "|_| (____/ "); win_println(console, THEME_SPLASH, '-', "|_| (____/ ");
win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", ""); win_println(console, THEME_SPLASH, '-', "");
if (strcmp(PACKAGE_STATUS, "development") == 0) { if (strcmp(PACKAGE_STATUS, "development") == 0) {
#ifdef HAVE_GIT_VERSION #ifdef HAVE_GIT_VERSION
win_vprint(console, '-', 0, NULL, 0, 0, "", "Version %sdev.%s.%s", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION); win_println(console, THEME_DEFAULT, '-', "Version %sdev.%s.%s", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION);
#else #else
win_vprint(console, '-', 0, NULL, 0, 0, "", "Version %sdev", PACKAGE_VERSION); win_println(console, THEME_DEFAULT, "Version %sdev", PACKAGE_VERSION);
#endif #endif
} else { } else {
win_vprint(console, '-', 0, NULL, 0, 0, "", "Version %s", PACKAGE_VERSION); win_println(console, THEME_DEFAULT, '-', "Version %s", PACKAGE_VERSION);
} }
} }
@ -2400,11 +2401,11 @@ _show_roster_contacts(GSList *list, gboolean show_groups)
} else { } else {
presence_colour = theme_main_presence_attrs("offline"); presence_colour = theme_main_presence_attrs("offline");
} }
win_vprint(console, '-', 0, NULL, NO_EOL, presence_colour, "", title->str); win_print(console, presence_colour, '-', "%s", title->str);
g_string_free(title, TRUE); g_string_free(title, TRUE);
win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " - "); win_append(console, THEME_DEFAULT, " - ");
GString *sub = g_string_new(""); GString *sub = g_string_new("");
sub = g_string_append(sub, p_contact_subscription(contact)); sub = g_string_append(sub, p_contact_subscription(contact));
if (p_contact_pending_out(contact)) { if (p_contact_pending_out(contact)) {
@ -2420,9 +2421,9 @@ _show_roster_contacts(GSList *list, gboolean show_groups)
} }
if (show_groups) { if (show_groups) {
win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", sub->str); win_append(console, presence_colour, "%s", sub->str);
} else { } else {
win_vprint(console, '-', 0, NULL, NO_DATE, presence_colour, "", "%s", sub->str); win_appendln(console, presence_colour, "%s", sub->str);
} }
g_string_free(sub, TRUE); g_string_free(sub, TRUE);
@ -2438,10 +2439,10 @@ _show_roster_contacts(GSList *list, gboolean show_groups)
} }
groups = g_slist_next(groups); groups = g_slist_next(groups);
} }
win_vprint(console, '-', 0, NULL, NO_DATE, 0, "", "%s", groups_str->str); win_appendln(console, THEME_DEFAULT, "%s", groups_str->str);
g_string_free(groups_str, TRUE); g_string_free(groups_str, TRUE);
} else { } else {
win_print(console, '-', 0, NULL, NO_DATE, 0, "", " "); win_appendln(console, THEME_DEFAULT, " ");
} }
} }

View File

@ -413,19 +413,19 @@ ui_handle_recipient_error(const char *const recipient, const char *const err_msg
ProfChatWin *chatwin = wins_get_chat(recipient); ProfChatWin *chatwin = wins_get_chat(recipient);
if (chatwin) { if (chatwin) {
win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, THEME_ERROR, "", "Error from %s: %s", recipient, err_msg); win_println((ProfWin*)chatwin, THEME_ERROR, '!', "Error from %s: %s", recipient, err_msg);
return; return;
} }
ProfMucWin *mucwin = wins_get_muc(recipient); ProfMucWin *mucwin = wins_get_muc(recipient);
if (mucwin) { if (mucwin) {
win_vprint((ProfWin*)mucwin, '!', 0, NULL, 0, THEME_ERROR, "", "Error from %s: %s", recipient, err_msg); win_println((ProfWin*)mucwin, THEME_ERROR, '!', "Error from %s: %s", recipient, err_msg);
return; return;
} }
ProfPrivateWin *privatewin = wins_get_private(recipient); ProfPrivateWin *privatewin = wins_get_private(recipient);
if (privatewin) { if (privatewin) {
win_vprint((ProfWin*)privatewin, '!', 0, NULL, 0, THEME_ERROR, "", "Error from %s: %s", recipient, err_msg); win_println((ProfWin*)privatewin, THEME_ERROR, '!', "Error from %s: %s", recipient, err_msg);
return; return;
} }
} }
@ -435,7 +435,7 @@ ui_handle_otr_error(const char *const barejid, const char *const message)
{ {
ProfChatWin *chatwin = wins_get_chat(barejid); ProfChatWin *chatwin = wins_get_chat(barejid);
if (chatwin) { if (chatwin) {
win_print((ProfWin*)chatwin, '!', 0, NULL, 0, THEME_ERROR, "", message); win_println((ProfWin*)chatwin, THEME_ERROR, '!', "%s", message);
} else { } else {
cons_show_error("%s - %s", barejid, message); cons_show_error("%s - %s", barejid, message);
} }
@ -739,7 +739,7 @@ ui_current_print_line(const char *const msg, ...)
va_start(arg, msg); va_start(arg, msg);
GString *fmt_msg = g_string_new(NULL); GString *fmt_msg = g_string_new(NULL);
g_string_vprintf(fmt_msg, msg, arg); g_string_vprintf(fmt_msg, msg, arg);
win_println(window, 0, fmt_msg->str); win_println(window, THEME_DEFAULT, '-', "%s", fmt_msg->str);
va_end(arg); va_end(arg);
g_string_free(fmt_msg, TRUE); g_string_free(fmt_msg, TRUE);
} }
@ -752,24 +752,11 @@ ui_current_print_formatted_line(const char show_char, int attrs, const char *con
va_start(arg, msg); va_start(arg, msg);
GString *fmt_msg = g_string_new(NULL); GString *fmt_msg = g_string_new(NULL);
g_string_vprintf(fmt_msg, msg, arg); g_string_vprintf(fmt_msg, msg, arg);
win_print(current, show_char, 0, NULL, 0, attrs, "", fmt_msg->str); win_println(current, attrs, show_char, "%s", fmt_msg->str);
va_end(arg); va_end(arg);
g_string_free(fmt_msg, TRUE); g_string_free(fmt_msg, TRUE);
} }
void
ui_win_error_line(ProfWin *window, const char *const msg)
{
win_print(window, '-', 0, NULL, 0, THEME_ERROR, "", msg);
}
void
ui_current_error_line(const char *const msg)
{
ProfWin *current = wins_get_current();
win_print(current, '-', 0, NULL, 0, THEME_ERROR, "", msg);
}
void void
ui_print_system_msg_from_recipient(const char *const barejid, const char *message) ui_print_system_msg_from_recipient(const char *const barejid, const char *message)
{ {
@ -790,7 +777,7 @@ ui_print_system_msg_from_recipient(const char *const barejid, const char *messag
} }
} }
win_vprint(window, '-', 0, NULL, 0, 0, "", "*%s %s", barejid, message); win_println(window, THEME_DEFAULT, '-', "*%s %s", barejid, message);
} }
void void
@ -802,19 +789,18 @@ ui_room_join(const char *const roomjid, gboolean focus)
} }
char *nick = muc_nick(roomjid); char *nick = muc_nick(roomjid);
win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "-> You have joined the room as %s", nick); win_print(window, THEME_ROOMINFO, '!', "-> You have joined the room as %s", nick);
if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) { if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) {
char *role = muc_role_str(roomjid); char *role = muc_role_str(roomjid);
char *affiliation = muc_affiliation_str(roomjid); char *affiliation = muc_affiliation_str(roomjid);
if (role) { if (role) {
win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", role: %s", role); win_append(window, THEME_ROOMINFO, ", role: %s", role);
} }
if (affiliation) { if (affiliation) {
win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", affiliation: %s", affiliation); win_append(window, THEME_ROOMINFO, ", affiliation: %s", affiliation);
} }
} }
win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); win_appendln(window, THEME_ROOMINFO, "");
if (focus) { if (focus) {
ui_focus_win(window); ui_focus_win(window);
@ -823,7 +809,7 @@ ui_room_join(const char *const roomjid, gboolean focus)
status_bar_active(num); status_bar_active(num);
ProfWin *console = wins_get_console(); ProfWin *console = wins_get_console();
char *nick = muc_nick(roomjid); char *nick = muc_nick(roomjid);
win_vprint(console, '!', 0, NULL, 0, THEME_TYPING, "", "-> Autojoined %s as %s (%d).", roomjid, nick, num); win_println(console, THEME_TYPING, '!', "-> Autojoined %s as %s (%d).", roomjid, nick, num);
} }
GList *privwins = wins_get_private_chats(roomjid); GList *privwins = wins_get_private_chats(roomjid);
@ -898,16 +884,16 @@ ui_room_destroyed(const char *const roomjid, const char *const reason, const cha
ProfWin *console = wins_get_console(); ProfWin *console = wins_get_console();
if (reason) { if (reason) {
win_vprint(console, '!', 0, NULL, 0, THEME_TYPING, "", "<- Room destroyed: %s, reason: %s", roomjid, reason); win_println(console, THEME_TYPING, '!', "<- Room destroyed: %s, reason: %s", roomjid, reason);
} else { } else {
win_vprint(console, '!', 0, NULL, 0, THEME_TYPING, "", "<- Room destroyed: %s", roomjid); win_println(console, THEME_TYPING, '!', "<- Room destroyed: %s", roomjid);
} }
if (new_jid) { if (new_jid) {
if (password) { if (password) {
win_vprint(console, '!', 0, NULL, 0, THEME_TYPING, "", "Replacement room: %s, password: %s", new_jid, password); win_println(console, THEME_TYPING, '!', "Replacement room: %s, password: %s", new_jid, password);
} else { } else {
win_vprint(console, '!', 0, NULL, 0, THEME_TYPING, "", "Replacement room: %s", new_jid); win_println(console, THEME_TYPING, '!', "Replacement room: %s", new_jid);
} }
} }
} }
@ -944,7 +930,7 @@ ui_room_kicked(const char *const roomjid, const char *const actor, const char *c
} }
ProfWin *console = wins_get_console(); ProfWin *console = wins_get_console();
win_vprint(console, '!', 0, NULL, 0, THEME_TYPING, "", "<- %s", message->str); win_println(console, THEME_TYPING, '!', "<- %s", message->str);
g_string_free(message, TRUE); g_string_free(message, TRUE);
} }
@ -980,7 +966,7 @@ ui_room_banned(const char *const roomjid, const char *const actor, const char *c
} }
ProfWin *console = wins_get_console(); ProfWin *console = wins_get_console();
win_vprint(console, '!', 0, NULL, 0, THEME_TYPING, "", "<- %s", message->str); win_println(console, THEME_TYPING, '!', "<- %s", message->str);
g_string_free(message, TRUE); g_string_free(message, TRUE);
} }
@ -1025,16 +1011,16 @@ ui_ask_pgp_passphrase(const char *hint, int prev_fail)
{ {
ProfWin *current = wins_get_current(); ProfWin *current = wins_get_current();
win_println(current, 0, ""); win_println(current, THEME_DEFAULT, '-', "");
if (prev_fail) { if (prev_fail) {
win_print(current, '!', 0, NULL, 0, 0, "", "Incorrect passphrase"); win_println(current, THEME_DEFAULT, '!', "Incorrect passphrase");
} }
if (hint) { if (hint) {
win_vprint(current, '!', 0, NULL, 0, 0, "", "Enter PGP key passphrase for %s", hint); win_println(current, THEME_DEFAULT, '!', "Enter PGP key passphrase for %s", hint);
} else { } else {
win_print(current, '!', 0, NULL, 0, 0, "", "Enter PGP key passphrase"); win_println(current, THEME_DEFAULT, '!', "Enter PGP key passphrase");
} }
ui_update(); ui_update();
@ -1158,7 +1144,7 @@ ui_handle_room_configuration_form_error(const char *const roomjid, const char *c
g_string_append(message_str, message); g_string_append(message_str, message);
} }
win_print(window, '-', 0, NULL, 0, THEME_ERROR, "", message_str->str); win_println(window, THEME_ERROR, '-', "%s", message_str->str);
g_string_free(message_str, TRUE); g_string_free(message_str, TRUE);
} }
@ -1182,7 +1168,7 @@ ui_handle_room_config_submit_result(const char *const roomjid)
if (muc_window) { if (muc_window) {
ui_focus_win((ProfWin*)muc_window); ui_focus_win((ProfWin*)muc_window);
win_print(muc_window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room configuration successful"); win_println(muc_window, THEME_ROOMINFO, '!', "Room configuration successful");
} else { } else {
ProfWin *console = wins_get_console(); ProfWin *console = wins_get_console();
ui_focus_win(console); ui_focus_win(console);
@ -1209,25 +1195,25 @@ ui_handle_room_config_submit_result_error(const char *const roomjid, const char
if (form_window) { if (form_window) {
if (message) { if (message) {
win_vprint(form_window, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error: %s", message); win_println(form_window, THEME_ERROR, '!', "Configuration error: %s", message);
} else { } else {
win_print(form_window, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error"); win_println(form_window, THEME_ERROR, '!', "Configuration error");
} }
} else if (muc_window) { } else if (muc_window) {
if (message) { if (message) {
win_vprint(muc_window, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error: %s", message); win_println(muc_window, THEME_ERROR, '!', "Configuration error: %s", message);
} else { } else {
win_print(muc_window, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error"); win_println(muc_window, THEME_ERROR, '!', "Configuration error");
} }
} else { } else {
if (message) { if (message) {
win_vprint(console, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error for %s: %s", roomjid, message); win_println(console, THEME_ERROR, '!', "Configuration error for %s: %s", roomjid, message);
} else { } else {
win_vprint(console, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error for %s", roomjid); win_println(console, THEME_ERROR, '!', "Configuration error for %s", roomjid);
} }
} }
} else { } else {
win_print(console, '!', 0, NULL, 0, THEME_ERROR, "", "Configuration error"); win_println(console, THEME_ERROR, '!', "Configuration error");
} }
} }
@ -1237,7 +1223,7 @@ ui_show_lines(ProfWin *window, gchar** lines)
if (lines) { if (lines) {
int i; int i;
for (i = 0; lines[i] != NULL; i++) { for (i = 0; lines[i] != NULL; i++) {
win_print(window, '-', 0, NULL, 0, 0, "", lines[i]); win_println(window, THEME_DEFAULT, '-', "%s", lines[i]);
} }
} }
} }
@ -1274,7 +1260,7 @@ ui_handle_software_version_error(const char *const roomjid, const char *const me
g_string_append(message_str, message); g_string_append(message_str, message);
} }
win_print(window, '-', 0, NULL, 0, THEME_ERROR, "", message_str->str); win_println(window, THEME_ERROR, '-', "%s", message_str->str);
g_string_free(message_str, TRUE); g_string_free(message_str, TRUE);
} }
@ -1314,19 +1300,19 @@ ui_show_software_version(const char *const jid, const char *const presence,
} }
if (name || version || os) { if (name || version || os) {
win_println(window, 0, ""); win_println(window, THEME_DEFAULT, '-', "");
theme_item_t presence_colour = theme_main_presence_attrs(presence); theme_item_t presence_colour = theme_main_presence_attrs(presence);
win_vprint(window, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", jid); win_print(window, presence_colour, '-', "%s", jid);
win_print(window, '-', 0, NULL, NO_DATE, 0, "", ":"); win_appendln(window, THEME_DEFAULT, ":");
} }
if (name) { if (name) {
win_vprint(window, '-', 0, NULL, 0, 0, "", "Name : %s", name); win_println(window, THEME_DEFAULT, '-', "Name : %s", name);
} }
if (version) { if (version) {
win_vprint(window, '-', 0, NULL, 0, 0, "", "Version : %s", version); win_println(window, THEME_DEFAULT, '-', "Version : %s", version);
} }
if (os) { if (os) {
win_vprint(window, '-', 0, NULL, 0, 0, "", "OS : %s", os); win_println(window, THEME_DEFAULT, '-', "OS : %s", os);
} }
} }

View File

@ -47,12 +47,12 @@ mucconfwin_show_form(ProfMucConfWin *confwin)
{ {
ProfWin *window = (ProfWin*) confwin; ProfWin *window = (ProfWin*) confwin;
if (confwin->form->title) { if (confwin->form->title) {
win_print(window, '-', 0, NULL, NO_EOL, 0, "", "Form title: "); win_print(window, THEME_DEFAULT, '-', "Form title: ");
win_print(window, '-', 0, NULL, NO_DATE, 0, "", confwin->form->title); win_appendln(window, THEME_DEFAULT, "%s", confwin->form->title);
} else { } else {
win_vprint(window, '-', 0, NULL, 0, 0, "", "Configuration for room %s.", confwin->roomjid); win_println(window, THEME_DEFAULT, '-', "Configuration for room %s.", confwin->roomjid);
} }
win_print(window, '-', 0, NULL, 0, 0, "", ""); win_println(window, THEME_DEFAULT, '-', "");
mucconfwin_form_help(confwin); mucconfwin_form_help(confwin);
@ -64,7 +64,7 @@ mucconfwin_show_form(ProfMucConfWin *confwin)
if ((g_strcmp0(field->type, "fixed") == 0) && field->values) { if ((g_strcmp0(field->type, "fixed") == 0) && field->values) {
if (field->values) { if (field->values) {
char *value = field->values->data; char *value = field->values->data;
win_print(window, '-', 0, NULL, 0, 0, "", value); win_println(window, THEME_DEFAULT, '-', "%s", value);
} }
} else if (g_strcmp0(field->type, "hidden") != 0 && field->var) { } else if (g_strcmp0(field->type, "hidden") != 0 && field->var) {
char *tag = g_hash_table_lookup(confwin->form->var_to_tag, field->var); char *tag = g_hash_table_lookup(confwin->form->var_to_tag, field->var);
@ -83,7 +83,7 @@ mucconfwin_show_form_field(ProfMucConfWin *confwin, DataForm *form, char *tag)
FormField *field = form_get_field_by_tag(form, tag); FormField *field = form_get_field_by_tag(form, tag);
ProfWin *window = (ProfWin*)confwin; ProfWin *window = (ProfWin*)confwin;
_mucconfwin_form_field(window, tag, field); _mucconfwin_form_field(window, tag, field);
win_println(window, 0, ""); win_println(window, THEME_DEFAULT, '-', "");
} }
void void
@ -96,11 +96,11 @@ mucconfwin_handle_configuration(ProfMucConfWin *confwin, DataForm *form)
mucconfwin_show_form(confwin); mucconfwin_show_form(confwin);
win_print(window, '-', 0, NULL, 0, 0, "", ""); win_println(window, THEME_DEFAULT, '-', "");
win_print(window, '-', 0, NULL, 0, 0, "", "Use '/form submit' to save changes."); win_println(window, THEME_DEFAULT, '-', "Use '/form submit' to save changes.");
win_print(window, '-', 0, NULL, 0, 0, "", "Use '/form cancel' to cancel changes."); win_println(window, THEME_DEFAULT, '-', "Use '/form cancel' to cancel changes.");
win_print(window, '-', 0, NULL, 0, 0, "", "See '/form help' for more information."); win_println(window, THEME_DEFAULT, '-', "See '/form help' for more information.");
win_print(window, '-', 0, NULL, 0, 0, "", ""); win_println(window, THEME_DEFAULT, '-', "");
} }
void void
@ -111,16 +111,16 @@ mucconfwin_field_help(ProfMucConfWin *confwin, char *tag)
ProfWin *window = (ProfWin*) confwin; ProfWin *window = (ProfWin*) confwin;
FormField *field = form_get_field_by_tag(confwin->form, tag); FormField *field = form_get_field_by_tag(confwin->form, tag);
if (field) { if (field) {
win_print(window, '-', 0, NULL, NO_EOL, 0, "", field->label); win_print(window, THEME_DEFAULT, '-', "%s", field->label);
if (field->required) { if (field->required) {
win_print(window, '-', 0, NULL, NO_DATE, 0, "", " (Required):"); win_appendln(window, THEME_DEFAULT, " (Required):");
} else { } else {
win_print(window, '-', 0, NULL, NO_DATE, 0, "", ":"); win_appendln(window, THEME_DEFAULT, ":");
} }
if (field->description) { if (field->description) {
win_vprint(window, '-', 0, NULL, 0, 0, "", " Description : %s", field->description); win_println(window, THEME_DEFAULT, '-', " Description : %s", field->description);
} }
win_vprint(window, '-', 0, NULL, 0, 0, "", " Type : %s", field->type); win_println(window, THEME_DEFAULT, '-', " Type : %s", field->type);
int num_values = 0; int num_values = 0;
GSList *curr_option = NULL; GSList *curr_option = NULL;
@ -129,51 +129,51 @@ mucconfwin_field_help(ProfMucConfWin *confwin, char *tag)
switch (field->type_t) { switch (field->type_t) {
case FIELD_TEXT_SINGLE: case FIELD_TEXT_SINGLE:
case FIELD_TEXT_PRIVATE: case FIELD_TEXT_PRIVATE:
win_vprint(window, '-', 0, NULL, 0, 0, "", " Set : /%s <value>", tag); win_println(window, THEME_DEFAULT, '-', " Set : /%s <value>", tag);
win_print(window, '-', 0, NULL, 0, 0, "", " Where : <value> is any text"); win_println(window, THEME_DEFAULT, '-', " Where : <value> is any text");
break; break;
case FIELD_TEXT_MULTI: case FIELD_TEXT_MULTI:
num_values = form_get_value_count(confwin->form, tag); num_values = form_get_value_count(confwin->form, tag);
win_vprint(window, '-', 0, NULL, 0, 0, "", " Add : /%s add <value>", tag); win_println(window, THEME_DEFAULT, '-', " Add : /%s add <value>", tag);
win_print(window, '-', 0, NULL, 0, 0, "", " Where : <value> is any text"); win_println(window, THEME_DEFAULT, '-', " Where : <value> is any text");
if (num_values > 0) { if (num_values > 0) {
win_vprint(window, '-', 0, NULL, 0, 0, "", " Remove : /%s remove <value>", tag); win_println(window, THEME_DEFAULT, '-', " Remove : /%s remove <value>", tag);
win_vprint(window, '-', 0, NULL, 0, 0, "", " Where : <value> between 'val1' and 'val%d'", num_values); win_println(window, THEME_DEFAULT, '-', " Where : <value> between 'val1' and 'val%d'", num_values);
} }
break; break;
case FIELD_BOOLEAN: case FIELD_BOOLEAN:
win_vprint(window, '-', 0, NULL, 0, 0, "", " Set : /%s <value>", tag); win_println(window, THEME_DEFAULT, '-', " Set : /%s <value>", tag);
win_print(window, '-', 0, NULL, 0, 0, "", " Where : <value> is either 'on' or 'off'"); win_println(window, THEME_DEFAULT, '-', " Where : <value> is either 'on' or 'off'");
break; break;
case FIELD_LIST_SINGLE: case FIELD_LIST_SINGLE:
win_vprint(window, '-', 0, NULL, 0, 0, "", " Set : /%s <value>", tag); win_println(window, THEME_DEFAULT, '-', " Set : /%s <value>", tag);
win_print(window, '-', 0, NULL, 0, 0, "", " Where : <value> is one of"); win_println(window, THEME_DEFAULT, '-', " Where : <value> is one of");
curr_option = field->options; curr_option = field->options;
while (curr_option) { while (curr_option) {
option = curr_option->data; option = curr_option->data;
win_vprint(window, '-', 0, NULL, 0, 0, "", " %s", option->value); win_println(window, THEME_DEFAULT, '-', " %s", option->value);
curr_option = g_slist_next(curr_option); curr_option = g_slist_next(curr_option);
} }
break; break;
case FIELD_LIST_MULTI: case FIELD_LIST_MULTI:
win_vprint(window, '-', 0, NULL, 0, 0, "", " Add : /%s add <value>", tag); win_println(window, THEME_DEFAULT, '-', " Add : /%s add <value>", tag);
win_vprint(window, '-', 0, NULL, 0, 0, "", " Remove : /%s remove <value>", tag); win_println(window, THEME_DEFAULT, '-', " Remove : /%s remove <value>", tag);
win_print(window, '-', 0, NULL, 0, 0, "", " Where : <value> is one of"); win_println(window, THEME_DEFAULT, '-', " Where : <value> is one of");
curr_option = field->options; curr_option = field->options;
while (curr_option) { while (curr_option) {
option = curr_option->data; option = curr_option->data;
win_vprint(window, '-', 0, NULL, 0, 0, "", " %s", option->value); win_println(window, THEME_DEFAULT, '-', " %s", option->value);
curr_option = g_slist_next(curr_option); curr_option = g_slist_next(curr_option);
} }
break; break;
case FIELD_JID_SINGLE: case FIELD_JID_SINGLE:
win_vprint(window, '-', 0, NULL, 0, 0, "", " Set : /%s <value>", tag); win_println(window, THEME_DEFAULT, '-', " Set : /%s <value>", tag);
win_print(window, '-', 0, NULL, 0, 0, "", " Where : <value> is a valid Jabber ID"); win_println(window, THEME_DEFAULT, '-', " Where : <value> is a valid Jabber ID");
break; break;
case FIELD_JID_MULTI: case FIELD_JID_MULTI:
win_vprint(window, '-', 0, NULL, 0, 0, "", " Add : /%s add <value>", tag); win_println(window, THEME_DEFAULT, '-', " Add : /%s add <value>", tag);
win_vprint(window, '-', 0, NULL, 0, 0, "", " Remove : /%s remove <value>", tag); win_println(window, THEME_DEFAULT, '-', " Remove : /%s remove <value>", tag);
win_print(window, '-', 0, NULL, 0, 0, "", " Where : <value> is a valid Jabber ID"); win_println(window, THEME_DEFAULT, '-', " Where : <value> is a valid Jabber ID");
break; break;
case FIELD_FIXED: case FIELD_FIXED:
case FIELD_UNKNOWN: case FIELD_UNKNOWN:
@ -182,7 +182,7 @@ mucconfwin_field_help(ProfMucConfWin *confwin, char *tag)
break; break;
} }
} else { } else {
win_vprint(window, '-', 0, NULL, 0, 0, "", "No such field %s", tag); win_println(window, THEME_DEFAULT, '-', "No such field %s", tag);
} }
} }
@ -193,21 +193,21 @@ mucconfwin_form_help(ProfMucConfWin *confwin)
if (confwin->form->instructions) { if (confwin->form->instructions) {
ProfWin *window = (ProfWin*) confwin; ProfWin *window = (ProfWin*) confwin;
win_print(window, '-', 0, NULL, 0, 0, "", "Supplied instructions:"); win_println(window, THEME_DEFAULT, '-', "Supplied instructions:");
win_print(window, '-', 0, NULL, 0, 0, "", confwin->form->instructions); win_println(window, THEME_DEFAULT, '-', "%s", confwin->form->instructions);
win_print(window, '-', 0, NULL, 0, 0, "", ""); win_println(window, THEME_DEFAULT, '-', "");
} }
} }
static void static void
_mucconfwin_form_field(ProfWin *window, char *tag, FormField *field) _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field)
{ {
win_vprint(window, '-', 0, NULL, NO_EOL, THEME_AWAY, "", "[%s] ", tag); win_print(window, THEME_AWAY, '-', "[%s] ", tag);
win_vprint(window, '-', 0, NULL, NO_EOL | NO_DATE, 0, "", "%s", field->label); win_append(window, THEME_DEFAULT, "%s", field->label);
if (field->required) { if (field->required) {
win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " (required): "); win_append(window, THEME_DEFAULT, " (required): ");
} else { } else {
win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ": "); win_append(window, THEME_DEFAULT, ": ");
} }
GSList *values = field->values; GSList *values = field->values;
@ -221,9 +221,9 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field)
char *value = curr_value->data; char *value = curr_value->data;
if (value) { if (value) {
if (g_strcmp0(field->var, "muc#roomconfig_roomsecret") == 0) { if (g_strcmp0(field->var, "muc#roomconfig_roomsecret") == 0) {
win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", "[hidden]"); win_append(window, THEME_ONLINE, "[hidden]");
} else { } else {
win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", value); win_append(window, THEME_ONLINE, "%s", value);
} }
} }
} }
@ -233,7 +233,7 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field)
if (curr_value) { if (curr_value) {
char *value = curr_value->data; char *value = curr_value->data;
if (value) { if (value) {
win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", "[hidden]"); win_append(window, THEME_ONLINE, "[hidden]");
} }
} }
win_newline(window); win_newline(window);
@ -245,23 +245,23 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field)
char *value = curr_value->data; char *value = curr_value->data;
GString *val_tag = g_string_new(""); GString *val_tag = g_string_new("");
g_string_printf(val_tag, "val%d", index++); g_string_printf(val_tag, "val%d", index++);
win_vprint(window, '-', 0, NULL, 0, THEME_ONLINE, "", " [%s] %s", val_tag->str, value); win_println(window, THEME_ONLINE, '-', " [%s] %s", val_tag->str, value);
g_string_free(val_tag, TRUE); g_string_free(val_tag, TRUE);
curr_value = g_slist_next(curr_value); curr_value = g_slist_next(curr_value);
} }
break; break;
case FIELD_BOOLEAN: case FIELD_BOOLEAN:
if (curr_value == NULL) { if (curr_value == NULL) {
win_print(window, '-', 0, NULL, NO_DATE, THEME_OFFLINE, "", "FALSE"); win_appendln(window, THEME_OFFLINE, "FALSE");
} else { } else {
char *value = curr_value->data; char *value = curr_value->data;
if (value == NULL) { if (value == NULL) {
win_print(window, '-', 0, NULL, NO_DATE, THEME_OFFLINE, "", "FALSE"); win_appendln(window, THEME_OFFLINE, "FALSE");
} else { } else {
if (g_strcmp0(value, "0") == 0) { if (g_strcmp0(value, "0") == 0) {
win_print(window, '-', 0, NULL, NO_DATE, THEME_OFFLINE, "", "FALSE"); win_appendln(window, THEME_OFFLINE, "FALSE");
} else { } else {
win_print(window, '-', 0, NULL, NO_DATE, THEME_ONLINE, "", "TRUE"); win_appendln(window, THEME_ONLINE, "TRUE");
} }
} }
} }
@ -275,9 +275,9 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field)
while (curr_option) { while (curr_option) {
FormOption *option = curr_option->data; FormOption *option = curr_option->data;
if (g_strcmp0(option->value, value) == 0) { if (g_strcmp0(option->value, value) == 0) {
win_vprint(window, '-', 0, NULL, 0, THEME_ONLINE, "", " [%s] %s", option->value, option->label); win_println(window, THEME_ONLINE, '-', " [%s] %s", option->value, option->label);
} else { } else {
win_vprint(window, '-', 0, NULL, 0, THEME_OFFLINE, "", " [%s] %s", option->value, option->label); win_println(window, THEME_OFFLINE, '-', " [%s] %s", option->value, option->label);
} }
curr_option = g_slist_next(curr_option); curr_option = g_slist_next(curr_option);
} }
@ -291,9 +291,9 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field)
while (curr_option) { while (curr_option) {
FormOption *option = curr_option->data; FormOption *option = curr_option->data;
if (g_slist_find_custom(curr_value, option->value, (GCompareFunc)g_strcmp0)) { if (g_slist_find_custom(curr_value, option->value, (GCompareFunc)g_strcmp0)) {
win_vprint(window, '-', 0, NULL, 0, THEME_ONLINE, "", " [%s] %s", option->value, option->label); win_println(window, THEME_ONLINE, '-', " [%s] %s", option->value, option->label);
} else { } else {
win_vprint(window, '-', 0, NULL, 0, THEME_OFFLINE, "", " [%s] %s", option->value, option->label); win_println(window, THEME_OFFLINE, '-', " [%s] %s", option->value, option->label);
} }
curr_option = g_slist_next(curr_option); curr_option = g_slist_next(curr_option);
} }
@ -303,7 +303,7 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field)
if (curr_value) { if (curr_value) {
char *value = curr_value->data; char *value = curr_value->data;
if (value) { if (value) {
win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", value); win_append(window, THEME_ONLINE, "%s", value);
} }
} }
win_newline(window); win_newline(window);
@ -312,7 +312,7 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field)
win_newline(window); win_newline(window);
while (curr_value) { while (curr_value) {
char *value = curr_value->data; char *value = curr_value->data;
win_vprint(window, '-', 0, NULL, 0, THEME_ONLINE, "", " %s", value); win_println(window, THEME_ONLINE, '-', " %s", value);
curr_value = g_slist_next(curr_value); curr_value = g_slist_next(curr_value);
} }
break; break;
@ -320,7 +320,7 @@ _mucconfwin_form_field(ProfWin *window, char *tag, FormField *field)
if (curr_value) { if (curr_value) {
char *value = curr_value->data; char *value = curr_value->data;
if (value) { if (value) {
win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", value); win_append(window, THEME_DEFAULT, "%s", value);
} }
} }
win_newline(window); win_newline(window);

View File

@ -51,14 +51,14 @@ mucwin_role_change(ProfMucWin *mucwin, const char *const role, const char *const
assert(mucwin != NULL); assert(mucwin != NULL);
ProfWin *window = (ProfWin*)mucwin; ProfWin *window = (ProfWin*)mucwin;
win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Your role has been changed to: %s", role); win_print(window, THEME_ROOMINFO, '!', "Your role has been changed to: %s", role);
if (actor) { if (actor) {
win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor); win_append(window, THEME_ROOMINFO, ", by: %s", actor);
} }
if (reason) { if (reason) {
win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); win_append(window, THEME_ROOMINFO, ", reason: %s", reason);
} }
win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); win_appendln(window, THEME_ROOMINFO, "");
} }
void void
@ -68,14 +68,14 @@ mucwin_affiliation_change(ProfMucWin *mucwin, const char *const affiliation, con
assert(mucwin != NULL); assert(mucwin != NULL);
ProfWin *window = (ProfWin*)mucwin; ProfWin *window = (ProfWin*)mucwin;
win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Your affiliation has been changed to: %s", affiliation); win_print(window, THEME_ROOMINFO, '!', "Your affiliation has been changed to: %s", affiliation);
if (actor) { if (actor) {
win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor); win_append(window, THEME_ROOMINFO, ", by: %s", actor);
} }
if (reason) { if (reason) {
win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); win_append(window, THEME_ROOMINFO, ", reason: %s", reason);
} }
win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); win_appendln(window, THEME_ROOMINFO, "");
} }
void void
@ -85,14 +85,14 @@ mucwin_role_and_affiliation_change(ProfMucWin *mucwin, const char *const role, c
assert(mucwin != NULL); assert(mucwin != NULL);
ProfWin *window = (ProfWin*)mucwin; ProfWin *window = (ProfWin*)mucwin;
win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Your role and affiliation have been changed, role: %s, affiliation: %s", role, affiliation); win_print(window, THEME_ROOMINFO, '!', "Your role and affiliation have been changed, role: %s, affiliation: %s", role, affiliation);
if (actor) { if (actor) {
win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor); win_append(window, THEME_ROOMINFO, ", by: %s", actor);
} }
if (reason) { if (reason) {
win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); win_append(window, THEME_ROOMINFO, ", reason: %s", reason);
} }
win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); win_appendln(window, THEME_ROOMINFO, "");
} }
@ -103,14 +103,14 @@ mucwin_occupant_role_change(ProfMucWin *mucwin, const char *const nick, const ch
assert(mucwin != NULL); assert(mucwin != NULL);
ProfWin *window = (ProfWin*)mucwin; ProfWin *window = (ProfWin*)mucwin;
win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "%s's role has been changed to: %s", nick, role); win_print(window, THEME_ROOMINFO, '!', "%s's role has been changed to: %s", nick, role);
if (actor) { if (actor) {
win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor); win_append(window, THEME_ROOMINFO, ", by: %s", actor);
} }
if (reason) { if (reason) {
win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); win_append(window, THEME_ROOMINFO, ", reason: %s", reason);
} }
win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); win_appendln(window, THEME_ROOMINFO, "");
} }
void void
@ -120,14 +120,14 @@ mucwin_occupant_affiliation_change(ProfMucWin *mucwin, const char *const nick, c
assert(mucwin != NULL); assert(mucwin != NULL);
ProfWin *window = (ProfWin*)mucwin; ProfWin *window = (ProfWin*)mucwin;
win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "%s's affiliation has been changed to: %s", nick, affiliation); win_print(window, THEME_ROOMINFO, '!', "%s's affiliation has been changed to: %s", nick, affiliation);
if (actor) { if (actor) {
win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor); win_append(window, THEME_ROOMINFO, ", by: %s", actor);
} }
if (reason) { if (reason) {
win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); win_append(window, THEME_ROOMINFO, ", reason: %s", reason);
} }
win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); win_appendln(window, THEME_ROOMINFO, "");
} }
void void
@ -137,14 +137,14 @@ mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char *cons
assert(mucwin != NULL); assert(mucwin != NULL);
ProfWin *window = (ProfWin*)mucwin; ProfWin *window = (ProfWin*)mucwin;
win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "%s's role and affiliation have been changed, role: %s, affiliation: %s", nick, role, affiliation); win_print(window, THEME_ROOMINFO, '!', "%s's role and affiliation have been changed, role: %s, affiliation: %s", nick, role, affiliation);
if (actor) { if (actor) {
win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", by: %s", actor); win_append(window, THEME_ROOMINFO, ", by: %s", actor);
} }
if (reason) { if (reason) {
win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", reason: %s", reason); win_append(window, THEME_ROOMINFO, ", reason: %s", reason);
} }
win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); win_appendln(window, THEME_ROOMINFO, "");
} }
void void
@ -153,8 +153,8 @@ mucwin_room_info_error(ProfMucWin *mucwin, const char *const error)
assert(mucwin != NULL); assert(mucwin != NULL);
ProfWin *window = (ProfWin*)mucwin; ProfWin *window = (ProfWin*)mucwin;
win_vprint(window, '!', 0, NULL, 0, 0, "", "Room info request failed: %s", error); win_println(window, THEME_DEFAULT, '!', "Room info request failed: %s", error);
win_print(window, '-', 0, NULL, 0, 0, "", ""); win_println(window, THEME_DEFAULT, '-', "");
} }
void void
@ -166,7 +166,7 @@ mucwin_room_disco_info(ProfMucWin *mucwin, GSList *identities, GSList *features)
if ((identities && (g_slist_length(identities) > 0)) || if ((identities && (g_slist_length(identities) > 0)) ||
(features && (g_slist_length(features) > 0))) { (features && (g_slist_length(features) > 0))) {
if (identities) { if (identities) {
win_print(window, '!', 0, NULL, 0, 0, "", "Identities:"); win_println(window, THEME_DEFAULT, '!', "Identities:");
} }
while (identities) { while (identities) {
DiscoIdentity *identity = identities->data; // anme trpe, cat DiscoIdentity *identity = identities->data; // anme trpe, cat
@ -182,19 +182,19 @@ mucwin_room_disco_info(ProfMucWin *mucwin, GSList *identities, GSList *features)
if (identity->category) { if (identity->category) {
identity_str = g_string_append(identity_str, identity->category); identity_str = g_string_append(identity_str, identity->category);
} }
win_print(window, '!', 0, NULL, 0, 0, "", identity_str->str); win_println(window, THEME_DEFAULT, '!', "%s", identity_str->str);
g_string_free(identity_str, TRUE); g_string_free(identity_str, TRUE);
identities = g_slist_next(identities); identities = g_slist_next(identities);
} }
if (features) { if (features) {
win_print(window, '!', 0, NULL, 0, 0, "", "Features:"); win_println(window, THEME_DEFAULT, '!', "Features:");
} }
while (features) { while (features) {
win_vprint(window, '!', 0, NULL, 0, 0, "", " %s", features->data); win_println(window, THEME_DEFAULT, '!', " %s", features->data);
features = g_slist_next(features); features = g_slist_next(features);
} }
win_print(window, '-', 0, NULL, 0, 0, "", ""); win_println(window, THEME_DEFAULT, '-', "");
} }
} }
@ -206,16 +206,16 @@ mucwin_roster(ProfMucWin *mucwin, GList *roster, const char *const presence)
ProfWin *window = (ProfWin*)mucwin; ProfWin *window = (ProfWin*)mucwin;
if ((roster == NULL) || (g_list_length(roster) == 0)) { if ((roster == NULL) || (g_list_length(roster) == 0)) {
if (presence == NULL) { if (presence == NULL) {
win_print(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room is empty."); win_println(window, THEME_ROOMINFO, '!', "Room is empty.");
} else { } else {
win_vprint(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "No occupants %s.", presence); win_println(window, THEME_ROOMINFO, '!', "No occupants %s.", presence);
} }
} else { } else {
int length = g_list_length(roster); int length = g_list_length(roster);
if (presence == NULL) { if (presence == NULL) {
win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "%d occupants: ", length); win_print(window, THEME_ROOMINFO, '!', "%d occupants: ", length);
} else { } else {
win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "%d %s: ", length, presence); win_print(window, THEME_ROOMINFO, '!', "%d %s: ", length, presence);
} }
while (roster) { while (roster) {
@ -223,16 +223,15 @@ mucwin_roster(ProfMucWin *mucwin, GList *roster, const char *const presence)
const char *presence_str = string_from_resource_presence(occupant->presence); const char *presence_str = string_from_resource_presence(occupant->presence);
theme_item_t presence_colour = theme_main_presence_attrs(presence_str); theme_item_t presence_colour = theme_main_presence_attrs(presence_str);
win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", occupant->nick); win_append(window, presence_colour, "%s", occupant->nick);
if (roster->next) { if (roster->next) {
win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", ", "); win_append(window, THEME_DEFAULT, ", ");
} }
roster = g_list_next(roster); roster = g_list_next(roster);
} }
win_print(window, '!', 0, NULL, NO_DATE, THEME_ONLINE, "", ""); win_appendln(window, THEME_ONLINE, "");
} }
} }
@ -242,7 +241,7 @@ mucwin_occupant_offline(ProfMucWin *mucwin, const char *const nick)
assert(mucwin != NULL); assert(mucwin != NULL);
ProfWin *window = (ProfWin*)mucwin; ProfWin *window = (ProfWin*)mucwin;
win_vprint(window, '!', 0, NULL, 0, THEME_OFFLINE, "", "<- %s has left the room.", nick); win_println(window, THEME_OFFLINE, '!', "<- %s has left the room.", nick);
} }
void void
@ -263,7 +262,7 @@ mucwin_occupant_kicked(ProfMucWin *mucwin, const char *const nick, const char *c
g_string_append(message, reason); g_string_append(message, reason);
} }
win_vprint(window, '!', 0, NULL, 0, THEME_OFFLINE, "", "<- %s", message->str); win_println(window, THEME_OFFLINE, '!', "<- %s", message->str);
g_string_free(message, TRUE); g_string_free(message, TRUE);
} }
@ -285,7 +284,7 @@ mucwin_occupant_banned(ProfMucWin *mucwin, const char *const nick, const char *c
g_string_append(message, reason); g_string_append(message, reason);
} }
win_vprint(window, '!', 0, NULL, 0, THEME_OFFLINE, "", "<- %s", message->str); win_println(window, THEME_OFFLINE, '!', "<- %s", message->str);
g_string_free(message, TRUE); g_string_free(message, TRUE);
} }
@ -296,16 +295,16 @@ mucwin_occupant_online(ProfMucWin *mucwin, const char *const nick, const char *c
assert(mucwin != NULL); assert(mucwin != NULL);
ProfWin *window = (ProfWin*)mucwin; ProfWin *window = (ProfWin*)mucwin;
win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ONLINE, "", "-> %s has joined the room", nick); win_print(window, THEME_ONLINE, '!', "-> %s has joined the room", nick);
if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) { if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) {
if (role) { if (role) {
win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", ", role: %s", role); win_append(window, THEME_ONLINE, ", role: %s", role);
} }
if (affiliation) { if (affiliation) {
win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ONLINE, "", ", affiliation: %s", affiliation); win_append(window, THEME_ONLINE, ", affiliation: %s", affiliation);
} }
} }
win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", ""); win_appendln(window, THEME_ROOMINFO, "");
} }
void void
@ -324,7 +323,7 @@ mucwin_occupant_nick_change(ProfMucWin *mucwin, const char *const old_nick, cons
assert(mucwin != NULL); assert(mucwin != NULL);
ProfWin *window = (ProfWin*)mucwin; ProfWin *window = (ProfWin*)mucwin;
win_vprint(window, '!', 0, NULL, 0, THEME_THEM, "", "** %s is now known as %s", old_nick, nick); win_println(window, THEME_THEM, '!', "** %s is now known as %s", old_nick, nick);
} }
void void
@ -333,7 +332,7 @@ mucwin_nick_change(ProfMucWin *mucwin, const char *const nick)
assert(mucwin != NULL); assert(mucwin != NULL);
ProfWin *window = (ProfWin*)mucwin; ProfWin *window = (ProfWin*)mucwin;
win_vprint(window, '!', 0, NULL, 0, THEME_ME, "", "** You are now known as %s", nick); win_println(window, THEME_ME, '!', "** You are now known as %s", nick);
} }
void void
@ -355,7 +354,7 @@ mucwin_history(ProfMucWin *mucwin, const char *const nick, GDateTime *timestamp,
g_string_append(line, message); g_string_append(line, message);
} }
win_print(window, '-', 0, timestamp, NO_COLOUR_DATE, 0, "", line->str); win_print_history(window, timestamp, "%s", line->str);
g_string_free(line, TRUE); g_string_free(line, TRUE);
plugins_on_room_history_message(mucwin->roomjid, nick, message, timestamp); plugins_on_room_history_message(mucwin->roomjid, nick, message, timestamp);
@ -371,10 +370,10 @@ _mucwin_print_mention(ProfWin *window, const char *const message, const char *co
pos = GPOINTER_TO_INT(curr->data); pos = GPOINTER_TO_INT(curr->data);
char *before_str = g_strndup(message + last_pos, pos - last_pos); char *before_str = g_strndup(message + last_pos, pos - last_pos);
win_print(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMMENTION, "", before_str); win_append_highlight(window, THEME_ROOMMENTION, "%s", before_str);
g_free(before_str); g_free(before_str);
char *nick_str = g_strndup(message + pos, strlen(nick)); char *nick_str = g_strndup(message + pos, strlen(nick));
win_print(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMMENTION_TERM, "", nick_str); win_append_highlight(window, THEME_ROOMMENTION_TERM, "%s", nick_str);
g_free(nick_str); g_free(nick_str);
last_pos = pos + strlen(nick); last_pos = pos + strlen(nick);
@ -382,9 +381,9 @@ _mucwin_print_mention(ProfWin *window, const char *const message, const char *co
curr = g_slist_next(curr); curr = g_slist_next(curr);
} }
if (last_pos < strlen(message)) { if (last_pos < strlen(message)) {
win_print(window, '-', 0, NULL, NO_DATE | NO_ME, THEME_ROOMMENTION, "", &message[last_pos]); win_appendln_highlight(window, THEME_ROOMMENTION, "%s", &message[last_pos]);
} else { } else {
win_print(window, '-', 0, NULL, NO_DATE | NO_ME, THEME_ROOMMENTION, "", ""); win_appendln_highlight(window, THEME_ROOMMENTION, "");
} }
} }
@ -442,7 +441,7 @@ _mucwin_print_triggers(ProfWin *window, const char *const message, GList *trigge
// no triggers found // no triggers found
if (first_trigger_pos == -1) { if (first_trigger_pos == -1) {
win_print(window, '-', 0, NULL, NO_DATE | NO_ME, THEME_ROOMTRIGGER, "", message); win_appendln_highlight(window, THEME_ROOMTRIGGER, "%s", message);
} else { } else {
if (first_trigger_pos > 0) { if (first_trigger_pos > 0) {
char message_section[strlen(message) + 1]; char message_section[strlen(message) + 1];
@ -452,7 +451,7 @@ _mucwin_print_triggers(ProfWin *window, const char *const message, GList *trigge
i++; i++;
} }
message_section[i] = '\0'; message_section[i] = '\0';
win_print(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMTRIGGER, "", message_section); win_append_highlight(window, THEME_ROOMTRIGGER, "%s", message_section);
} }
char trigger_section[first_trigger_len + 1]; char trigger_section[first_trigger_len + 1];
int i = 0; int i = 0;
@ -463,10 +462,10 @@ _mucwin_print_triggers(ProfWin *window, const char *const message, GList *trigge
trigger_section[i] = '\0'; trigger_section[i] = '\0';
if (first_trigger_pos + first_trigger_len < strlen(message)) { if (first_trigger_pos + first_trigger_len < strlen(message)) {
win_print(window, '-', 0, NULL, NO_DATE | NO_ME | NO_EOL, THEME_ROOMTRIGGER_TERM, "", trigger_section); win_append_highlight(window, THEME_ROOMTRIGGER_TERM, "%s", trigger_section);
_mucwin_print_triggers(window, &message[first_trigger_pos + first_trigger_len], triggers); _mucwin_print_triggers(window, &message[first_trigger_pos + first_trigger_len], triggers);
} else { } else {
win_print(window, '-', 0, NULL, NO_DATE | NO_ME, THEME_ROOMTRIGGER_TERM, "", trigger_section); win_appendln_highlight(window, THEME_ROOMTRIGGER_TERM, "%s", trigger_section);
} }
} }
} }
@ -481,16 +480,16 @@ mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const mes
if (g_strcmp0(nick, mynick) != 0) { if (g_strcmp0(nick, mynick) != 0) {
if (g_slist_length(mentions) > 0) { if (g_slist_length(mentions) > 0) {
win_print(window, '-', 0, NULL, NO_ME | NO_EOL, THEME_ROOMMENTION, nick, ""); win_print_them(window, THEME_ROOMMENTION, nick);
_mucwin_print_mention(window, message, mynick, mentions); _mucwin_print_mention(window, message, mynick, mentions);
} else if (triggers) { } else if (triggers) {
win_print(window, '-', 0, NULL, NO_ME | NO_EOL, THEME_ROOMTRIGGER, nick, ""); win_print_them(window, THEME_ROOMTRIGGER, nick);
_mucwin_print_triggers(window, message, triggers); _mucwin_print_triggers(window, message, triggers);
} else { } else {
win_print(window, '-', 0, NULL, NO_ME, THEME_TEXT_THEM, nick, message); win_println_them_message(window, nick, "%s", message);
} }
} else { } else {
win_print(window, '-', 0, NULL, 0, THEME_TEXT_ME, nick, message); win_println_me_message(window, mynick, "%s", message);
} }
} }
@ -506,12 +505,12 @@ mucwin_requires_config(ProfMucWin *mucwin)
ui_index = 0; ui_index = 0;
} }
win_print(window, '-', 0, NULL, 0, 0, "", ""); win_println(window, THEME_DEFAULT, '-', "");
win_vprint(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room locked, requires configuration."); win_println(window, THEME_ROOMINFO, '!', "Room locked, requires configuration.");
win_vprint(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Use '/room accept' to accept the defaults"); win_println(window, THEME_ROOMINFO, '!', "Use '/room accept' to accept the defaults");
win_vprint(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Use '/room destroy' to cancel and destroy the room"); win_println(window, THEME_ROOMINFO, '!', "Use '/room destroy' to cancel and destroy the room");
win_vprint(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Use '/room config' to edit the room configuration"); win_println(window, THEME_ROOMINFO, '!', "Use '/room config' to edit the room configuration");
win_print(window, '-', 0, NULL, 0, 0, "", ""); win_println(window, THEME_DEFAULT, '-', "");
// currently in groupchat window // currently in groupchat window
if (wins_is_current(window)) { if (wins_is_current(window)) {
@ -533,17 +532,17 @@ mucwin_subject(ProfMucWin *mucwin, const char *const nick, const char *const sub
if (subject) { if (subject) {
if (nick) { if (nick) {
win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "*%s has set the room subject: ", nick); win_print(window, THEME_ROOMINFO, '!', "*%s has set the room subject: ", nick);
win_vprint(window, '!', 0, NULL, NO_DATE, 0, "", "%s", subject); win_appendln(window, THEME_DEFAULT, "%s", subject);
} else { } else {
win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Room subject: "); win_print(window, THEME_ROOMINFO, '!', "Room subject: ");
win_vprint(window, '!', 0, NULL, NO_DATE, 0, "", "%s", subject); win_appendln(window, THEME_DEFAULT, "%s", subject);
} }
} else { } else {
if (nick) { if (nick) {
win_vprint(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "*%s has cleared the room subject.", nick); win_println(window, THEME_ROOMINFO, '!', "*%s has cleared the room subject.", nick);
} else { } else {
win_vprint(window, '!', 0, NULL, 0, THEME_ROOMINFO, "", "Room subject cleared"); win_println(window, THEME_ROOMINFO, '!', "Room subject cleared");
} }
} }
@ -563,7 +562,7 @@ mucwin_kick_error(ProfMucWin *mucwin, const char *const nick, const char *const
assert(mucwin != NULL); assert(mucwin != NULL);
ProfWin *window = (ProfWin*)mucwin; ProfWin *window = (ProfWin*)mucwin;
win_vprint(window, '!', 0, NULL, 0, THEME_ERROR, "", "Error kicking %s: %s", nick, error); win_println(window, THEME_ERROR, '!', "Error kicking %s: %s", nick, error);
} }
void void
@ -574,8 +573,8 @@ mucwin_broadcast(ProfMucWin *mucwin, const char *const message)
ProfWin *window = (ProfWin*)mucwin; ProfWin *window = (ProfWin*)mucwin;
int num = wins_get_num(window); int num = wins_get_num(window);
win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "Room message: "); win_print(window, THEME_ROOMINFO, '!', "Room message: ");
win_vprint(window, '!', 0, NULL, NO_DATE, 0, "", "%s", message); win_appendln(window, THEME_DEFAULT, "%s", message);
// currently in groupchat window // currently in groupchat window
if (wins_is_current(window)) { if (wins_is_current(window)) {
@ -594,7 +593,7 @@ mucwin_affiliation_list_error(ProfMucWin *mucwin, const char *const affiliation,
assert(mucwin != NULL); assert(mucwin != NULL);
ProfWin *window = (ProfWin*)mucwin; ProfWin *window = (ProfWin*)mucwin;
win_vprint(window, '!', 0, NULL, 0, THEME_ERROR, "", "Error retrieving %s list: %s", affiliation, error); win_println(window, THEME_ERROR, '!', "Error retrieving %s list: %s", affiliation, error);
} }
void void
@ -604,17 +603,17 @@ mucwin_handle_affiliation_list(ProfMucWin *mucwin, const char *const affiliation
ProfWin *window = (ProfWin*)mucwin; ProfWin *window = (ProfWin*)mucwin;
if (jids) { if (jids) {
win_vprint(window, '!', 0, NULL, 0, 0, "", "Affiliation: %s", affiliation); win_println(window, THEME_DEFAULT, '!', "Affiliation: %s", affiliation);
GSList *curr_jid = jids; GSList *curr_jid = jids;
while (curr_jid) { while (curr_jid) {
const char *jid = curr_jid->data; const char *jid = curr_jid->data;
win_vprint(window, '!', 0, NULL, 0, 0, "", " %s", jid); win_println(window, THEME_DEFAULT, '!', " %s", jid);
curr_jid = g_slist_next(curr_jid); curr_jid = g_slist_next(curr_jid);
} }
win_print(window, '!', 0, NULL, 0, 0, "", ""); win_println(window, THEME_DEFAULT, '!', "");
} else { } else {
win_vprint(window, '!', 0, NULL, 0, 0, "", "No users found with affiliation: %s", affiliation); win_println(window, THEME_DEFAULT, '!', "No users found with affiliation: %s", affiliation);
win_print(window, '!', 0, NULL, 0, 0, "", ""); win_println(window, THEME_DEFAULT, '!', "");
} }
} }
@ -629,34 +628,34 @@ mucwin_show_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation)
if (!occupants) { if (!occupants) {
switch (affiliation) { switch (affiliation) {
case MUC_AFFILIATION_OWNER: case MUC_AFFILIATION_OWNER:
win_print(window, '!', 0, NULL, 0, 0, "", "No owners found."); win_println(window, THEME_DEFAULT, '!', "No owners found.");
break; break;
case MUC_AFFILIATION_ADMIN: case MUC_AFFILIATION_ADMIN:
win_print(window, '!', 0, NULL, 0, 0, "", "No admins found."); win_println(window, THEME_DEFAULT, '!', "No admins found.");
break; break;
case MUC_AFFILIATION_MEMBER: case MUC_AFFILIATION_MEMBER:
win_print(window, '!', 0, NULL, 0, 0, "", "No members found."); win_println(window, THEME_DEFAULT, '!', "No members found.");
break; break;
case MUC_AFFILIATION_OUTCAST: case MUC_AFFILIATION_OUTCAST:
win_print(window, '!', 0, NULL, 0, 0, "", "No outcasts found."); win_println(window, THEME_DEFAULT, '!', "No outcasts found.");
break; break;
default: default:
break; break;
} }
win_print(window, '-', 0, NULL, 0, 0, "", ""); win_println(window, THEME_DEFAULT, '-', "");
} else { } else {
switch (affiliation) { switch (affiliation) {
case MUC_AFFILIATION_OWNER: case MUC_AFFILIATION_OWNER:
win_print(window, '!', 0, NULL, 0, 0, "", "Owners:"); win_println(window, THEME_DEFAULT, '!', "Owners:");
break; break;
case MUC_AFFILIATION_ADMIN: case MUC_AFFILIATION_ADMIN:
win_print(window, '!', 0, NULL, 0, 0, "", "Admins:"); win_println(window, THEME_DEFAULT, '!', "Admins:");
break; break;
case MUC_AFFILIATION_MEMBER: case MUC_AFFILIATION_MEMBER:
win_print(window, '!', 0, NULL, 0, 0, "", "Members:"); win_println(window, THEME_DEFAULT, '!', "Members:");
break; break;
case MUC_AFFILIATION_OUTCAST: case MUC_AFFILIATION_OUTCAST:
win_print(window, '!', 0, NULL, 0, 0, "", "Outcasts:"); win_println(window, THEME_DEFAULT, '!', "Outcasts:");
break; break;
default: default:
break; break;
@ -667,16 +666,16 @@ mucwin_show_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation)
Occupant *occupant = curr_occupant->data; Occupant *occupant = curr_occupant->data;
if (occupant->affiliation == affiliation) { if (occupant->affiliation == affiliation) {
if (occupant->jid) { if (occupant->jid) {
win_vprint(window, '!', 0, NULL, 0, 0, "", " %s (%s)", occupant->nick, occupant->jid); win_println(window, THEME_DEFAULT, '!', " %s (%s)", occupant->nick, occupant->jid);
} else { } else {
win_vprint(window, '!', 0, NULL, 0, 0, "", " %s", occupant->nick); win_println(window, THEME_DEFAULT, '!', " %s", occupant->nick);
} }
} }
curr_occupant = g_slist_next(curr_occupant); curr_occupant = g_slist_next(curr_occupant);
} }
win_print(window, '-', 0, NULL, 0, 0, "", ""); win_println(window, THEME_DEFAULT, '-', "");
} }
} }
@ -686,7 +685,7 @@ mucwin_role_list_error(ProfMucWin *mucwin, const char *const role, const char *c
assert(mucwin != NULL); assert(mucwin != NULL);
ProfWin *window = (ProfWin*)mucwin; ProfWin *window = (ProfWin*)mucwin;
win_vprint(window, '!', 0, NULL, 0, THEME_ERROR, "", "Error retrieving %s list: %s", role, error); win_println(window, THEME_ERROR, '!', "Error retrieving %s list: %s", role, error);
} }
void void
@ -696,26 +695,26 @@ mucwin_handle_role_list(ProfMucWin *mucwin, const char *const role, GSList *nick
ProfWin *window = (ProfWin*)mucwin; ProfWin *window = (ProfWin*)mucwin;
if (nicks) { if (nicks) {
win_vprint(window, '!', 0, NULL, 0, 0, "", "Role: %s", role); win_println(window, THEME_DEFAULT, '!', "Role: %s", role);
GSList *curr_nick = nicks; GSList *curr_nick = nicks;
while (curr_nick) { while (curr_nick) {
const char *nick = curr_nick->data; const char *nick = curr_nick->data;
Occupant *occupant = muc_roster_item(mucwin->roomjid, nick); Occupant *occupant = muc_roster_item(mucwin->roomjid, nick);
if (occupant) { if (occupant) {
if (occupant->jid) { if (occupant->jid) {
win_vprint(window, '!', 0, NULL, 0, 0, "", " %s (%s)", nick, occupant->jid); win_println(window, THEME_DEFAULT, '!', " %s (%s)", nick, occupant->jid);
} else { } else {
win_vprint(window, '!', 0, NULL, 0, 0, "", " %s", nick); win_println(window, THEME_DEFAULT, '!', " %s", nick);
} }
} else { } else {
win_vprint(window, '!', 0, NULL, 0, 0, "", " %s", nick); win_println(window, THEME_DEFAULT, '!', " %s", nick);
} }
curr_nick = g_slist_next(curr_nick); curr_nick = g_slist_next(curr_nick);
} }
win_print(window, '!', 0, NULL, 0, 0, "", ""); win_println(window, THEME_DEFAULT, '!', "");
} else { } else {
win_vprint(window, '!', 0, NULL, 0, 0, "", "No occupants found with role: %s", role); win_println(window, THEME_DEFAULT, '!', "No occupants found with role: %s", role);
win_print(window, '!', 0, NULL, 0, 0, "", ""); win_println(window, THEME_DEFAULT, '!', "");
} }
} }
@ -730,28 +729,28 @@ mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role)
if (!occupants) { if (!occupants) {
switch (role) { switch (role) {
case MUC_ROLE_MODERATOR: case MUC_ROLE_MODERATOR:
win_print(window, '!', 0, NULL, 0, 0, "", "No moderators found."); win_println(window, THEME_DEFAULT, '!', "No moderators found.");
break; break;
case MUC_ROLE_PARTICIPANT: case MUC_ROLE_PARTICIPANT:
win_print(window, '!', 0, NULL, 0, 0, "", "No participants found."); win_println(window, THEME_DEFAULT, '!', "No participants found.");
break; break;
case MUC_ROLE_VISITOR: case MUC_ROLE_VISITOR:
win_print(window, '!', 0, NULL, 0, 0, "", "No visitors found."); win_println(window, THEME_DEFAULT, '!', "No visitors found.");
break; break;
default: default:
break; break;
} }
win_print(window, '-', 0, NULL, 0, 0, "", ""); win_println(window, THEME_DEFAULT, '-', "");
} else { } else {
switch (role) { switch (role) {
case MUC_ROLE_MODERATOR: case MUC_ROLE_MODERATOR:
win_print(window, '!', 0, NULL, 0, 0, "", "Moderators:"); win_println(window, THEME_DEFAULT, '!', "Moderators:");
break; break;
case MUC_ROLE_PARTICIPANT: case MUC_ROLE_PARTICIPANT:
win_print(window, '!', 0, NULL, 0, 0, "", "Participants:"); win_println(window, THEME_DEFAULT, '!', "Participants:");
break; break;
case MUC_ROLE_VISITOR: case MUC_ROLE_VISITOR:
win_print(window, '!', 0, NULL, 0, 0, "", "Visitors:"); win_println(window, THEME_DEFAULT, '!', "Visitors:");
break; break;
default: default:
break; break;
@ -762,16 +761,16 @@ mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role)
Occupant *occupant = curr_occupant->data; Occupant *occupant = curr_occupant->data;
if (occupant->role == role) { if (occupant->role == role) {
if (occupant->jid) { if (occupant->jid) {
win_vprint(window, '!', 0, NULL, 0, 0, "", " %s (%s)", occupant->nick, occupant->jid); win_println(window, THEME_DEFAULT, '!', " %s (%s)", occupant->nick, occupant->jid);
} else { } else {
win_vprint(window, '!', 0, NULL, 0, 0, "", " %s", occupant->nick); win_println(window, THEME_DEFAULT, '!', " %s", occupant->nick);
} }
} }
curr_occupant = g_slist_next(curr_occupant); curr_occupant = g_slist_next(curr_occupant);
} }
win_print(window, '-', 0, NULL, 0, 0, "", ""); win_println(window, THEME_DEFAULT, '-', "");
} }
} }
@ -782,7 +781,7 @@ mucwin_affiliation_set_error(ProfMucWin *mucwin, const char *const jid, const ch
assert(mucwin != NULL); assert(mucwin != NULL);
ProfWin *window = (ProfWin*)mucwin; ProfWin *window = (ProfWin*)mucwin;
win_vprint(window, '!', 0, NULL, 0, THEME_ERROR, "", "Error setting %s affiliation for %s: %s", affiliation, jid, error); win_println(window, THEME_ERROR, '!', "Error setting %s affiliation for %s: %s", affiliation, jid, error);
} }
void void
@ -792,7 +791,7 @@ mucwin_role_set_error(ProfMucWin *mucwin, const char *const nick, const char *co
assert(mucwin != NULL); assert(mucwin != NULL);
ProfWin *window = (ProfWin*)mucwin; ProfWin *window = (ProfWin*)mucwin;
win_vprint(window, '!', 0, NULL, 0, THEME_ERROR, "", "Error setting %s role for %s: %s", role, nick, error); win_println(window, THEME_ERROR, '!', "Error setting %s role for %s: %s", role, nick, error);
} }
void void
@ -804,10 +803,10 @@ mucwin_info(ProfMucWin *mucwin)
char *affiliation = muc_affiliation_str(mucwin->roomjid); char *affiliation = muc_affiliation_str(mucwin->roomjid);
ProfWin *window = (ProfWin*) mucwin; ProfWin *window = (ProfWin*) mucwin;
win_vprint(window, '!', 0, NULL, 0, 0, "", "Room: %s", mucwin->roomjid); win_println(window, THEME_DEFAULT, '!', "Room: %s", mucwin->roomjid);
win_vprint(window, '!', 0, NULL, 0, 0, "", "Affiliation: %s", affiliation); win_println(window, THEME_DEFAULT, '!', "Affiliation: %s", affiliation);
win_vprint(window, '!', 0, NULL, 0, 0, "", "Role: %s", role); win_println(window, THEME_DEFAULT, '!', "Role: %s", role);
win_print(window, '-', 0, NULL, 0, 0, "", ""); win_println(window, THEME_DEFAULT, '-', "");
} }
void void

View File

@ -60,7 +60,7 @@ privwin_incoming_msg(ProfPrivateWin *privatewin, const char *const message, GDat
// currently viewing chat window with sender // currently viewing chat window with sender
if (wins_is_current(window)) { if (wins_is_current(window)) {
win_print_incoming_message(window, timestamp, jidp->resourcepart, message, PROF_MSG_PLAIN); win_print_incoming(window, timestamp, jidp->resourcepart, message, PROF_MSG_PLAIN);
title_bar_set_typing(FALSE); title_bar_set_typing(FALSE);
status_bar_active(num); status_bar_active(num);
@ -68,7 +68,7 @@ privwin_incoming_msg(ProfPrivateWin *privatewin, const char *const message, GDat
} else { } else {
status_bar_new(num); status_bar_new(num);
cons_show_incoming_private_message(jidp->resourcepart, jidp->barejid, num, privatewin->unread); cons_show_incoming_private_message(jidp->resourcepart, jidp->barejid, num, privatewin->unread);
win_print_incoming_message(window, timestamp, jidp->resourcepart, message, PROF_MSG_PLAIN); win_print_incoming(window, timestamp, jidp->resourcepart, message, PROF_MSG_PLAIN);
privatewin->unread++; privatewin->unread++;
@ -93,7 +93,7 @@ privwin_outgoing_msg(ProfPrivateWin *privwin, const char *const message)
{ {
assert(privwin != NULL); assert(privwin != NULL);
win_print((ProfWin*)privwin, '-', 0, NULL, 0, THEME_TEXT_ME, "me", message); win_print_outgoing((ProfWin*)privwin, '-', "%s", message);
} }
void void
@ -101,7 +101,7 @@ privwin_message_occupant_offline(ProfPrivateWin *privwin)
{ {
assert(privwin != NULL); assert(privwin != NULL);
win_print((ProfWin*)privwin, '-', 0, NULL, 0, THEME_ERROR, NULL, "Unable to send message, occupant no longer present in room."); win_println((ProfWin*)privwin, THEME_ERROR, '-', "Unable to send message, occupant no longer present in room.");
} }
void void
@ -109,7 +109,7 @@ privwin_message_left_room(ProfPrivateWin *privwin)
{ {
assert(privwin != NULL); assert(privwin != NULL);
win_print((ProfWin*)privwin, '-', 0, NULL, 0, THEME_ERROR, NULL, "Unable to send message, you are no longer present in room."); win_println((ProfWin*)privwin, THEME_ERROR, '-', "Unable to send message, you are no longer present in room.");
} }
void void
@ -119,7 +119,7 @@ privwin_occupant_offline(ProfPrivateWin *privwin)
privwin->occupant_offline = TRUE; privwin->occupant_offline = TRUE;
Jid *jidp = jid_create(privwin->fulljid); Jid *jidp = jid_create(privwin->fulljid);
win_vprint((ProfWin*)privwin, '-', 0, NULL, 0, THEME_OFFLINE, NULL, "<- %s has left the room.", jidp->resourcepart); win_println((ProfWin*)privwin, THEME_OFFLINE, '-', "<- %s has left the room.", jidp->resourcepart);
jid_destroy(jidp); jid_destroy(jidp);
} }
@ -142,7 +142,7 @@ privwin_occupant_kicked(ProfPrivateWin *privwin, const char *const actor, const
g_string_append(message, reason); g_string_append(message, reason);
} }
win_vprint((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, NULL, "<- %s", message->str); win_println((ProfWin*)privwin, THEME_OFFLINE, '!', "<- %s", message->str);
g_string_free(message, TRUE); g_string_free(message, TRUE);
} }
@ -165,7 +165,7 @@ privwin_occupant_banned(ProfPrivateWin *privwin, const char *const actor, const
g_string_append(message, reason); g_string_append(message, reason);
} }
win_vprint((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, NULL, "<- %s", message->str); win_println((ProfWin*)privwin, THEME_OFFLINE, '!', "<- %s", message->str);
g_string_free(message, TRUE); g_string_free(message, TRUE);
} }
@ -176,7 +176,7 @@ privwin_occupant_online(ProfPrivateWin *privwin)
privwin->occupant_offline = FALSE; privwin->occupant_offline = FALSE;
Jid *jidp = jid_create(privwin->fulljid); Jid *jidp = jid_create(privwin->fulljid);
win_vprint((ProfWin*)privwin, '-', 0, NULL, 0, THEME_ONLINE, NULL, "-- %s has joined the room.", jidp->resourcepart); win_println((ProfWin*)privwin, THEME_ONLINE, '-', "-- %s has joined the room.", jidp->resourcepart);
jid_destroy(jidp); jid_destroy(jidp);
} }
@ -187,7 +187,7 @@ privwin_room_destroyed(ProfPrivateWin *privwin)
privwin->room_left = TRUE; privwin->room_left = TRUE;
Jid *jidp = jid_create(privwin->fulljid); Jid *jidp = jid_create(privwin->fulljid);
win_vprint((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, NULL, "-- %s has been destroyed.", jidp->barejid); win_println((ProfWin*)privwin, THEME_OFFLINE, '!', "-- %s has been destroyed.", jidp->barejid);
jid_destroy(jidp); jid_destroy(jidp);
} }
@ -198,7 +198,7 @@ privwin_room_joined(ProfPrivateWin *privwin)
privwin->room_left = FALSE; privwin->room_left = FALSE;
Jid *jidp = jid_create(privwin->fulljid); Jid *jidp = jid_create(privwin->fulljid);
win_vprint((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, NULL, "-- You have joined %s.", jidp->barejid); win_println((ProfWin*)privwin, THEME_OFFLINE, '!', "-- You have joined %s.", jidp->barejid);
jid_destroy(jidp); jid_destroy(jidp);
} }
@ -209,7 +209,7 @@ privwin_room_left(ProfPrivateWin *privwin)
privwin->room_left = TRUE; privwin->room_left = TRUE;
Jid *jidp = jid_create(privwin->fulljid); Jid *jidp = jid_create(privwin->fulljid);
win_vprint((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, NULL, "-- You have left %s.", jidp->barejid); win_println((ProfWin*)privwin, THEME_OFFLINE, '!', "-- You have left %s.", jidp->barejid);
jid_destroy(jidp); jid_destroy(jidp);
} }
@ -232,7 +232,7 @@ privwin_room_kicked(ProfPrivateWin *privwin, const char *const actor, const char
g_string_append(message, reason); g_string_append(message, reason);
} }
win_vprint((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, "", "<- %s", message->str); win_println((ProfWin*)privwin, THEME_OFFLINE, '!', "<- %s", message->str);
g_string_free(message, TRUE); g_string_free(message, TRUE);
} }
@ -255,7 +255,7 @@ privwin_room_banned(ProfPrivateWin *privwin, const char *const actor, const char
g_string_append(message, reason); g_string_append(message, reason);
} }
win_vprint((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, "", "<- %s", message->str); win_println((ProfWin*)privwin, THEME_OFFLINE, '!', "<- %s", message->str);
g_string_free(message, TRUE); g_string_free(message, TRUE);
} }

View File

@ -77,8 +77,6 @@ int ui_close_all_wins(void);
int ui_close_read_wins(void); int ui_close_read_wins(void);
void ui_current_print_line(const char *const msg, ...); void ui_current_print_line(const char *const msg, ...);
void ui_current_print_formatted_line(const char show_char, int attrs, const char *const msg, ...); void ui_current_print_formatted_line(const char show_char, int attrs, const char *const msg, ...);
void ui_current_error_line(const char *const msg);
void ui_win_error_line(ProfWin *window, const char *const msg);
void ui_close_win(int index); void ui_close_win(int index);
int ui_win_unread(int index); int ui_win_unread(int index);
char* ui_ask_password(void); char* ui_ask_password(void);
@ -357,17 +355,24 @@ void win_hide_subwin(ProfWin *window);
void win_show_subwin(ProfWin *window); void win_show_subwin(ProfWin *window);
void win_refresh_without_subwin(ProfWin *window); void win_refresh_without_subwin(ProfWin *window);
void win_refresh_with_subwin(ProfWin *window); void win_refresh_with_subwin(ProfWin *window);
void win_print(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_vprint(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_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, ...);
void win_append_highlight(ProfWin *window, theme_item_t theme_item, const char *const message, ...);
void win_appendln_highlight(ProfWin *window, theme_item_t theme_item, const char *const message, ...);
char* win_get_title(ProfWin *window); char* win_get_title(ProfWin *window);
void win_show_occupant(ProfWin *window, Occupant *occupant); void win_show_occupant(ProfWin *window, Occupant *occupant);
void win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupant); void win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupant);
void win_show_contact(ProfWin *window, PContact contact); void win_show_contact(ProfWin *window, PContact contact);
void win_show_info(ProfWin *window, PContact contact); void win_show_info(ProfWin *window, PContact contact);
void win_println(ProfWin *window, int pad, const char *const message);
void win_vprintln_ch(ProfWin *window, char ch, const char *const message, ...);
void win_clear(ProfWin *window); void win_clear(ProfWin *window);
char* win_get_string(ProfWin *window); char* win_to_string(ProfWin *window);
// desktop notifications // desktop notifications
void notifier_initialise(void); void notifier_initialise(void);

View File

@ -61,6 +61,8 @@
#define CEILING(X) (X-(int)(X) > 0 ? (int)(X+1) : (int)(X)) #define CEILING(X) (X-(int)(X) > 0 ? (int)(X+1) : (int)(X))
static 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, ...);
static void _win_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *time, static void _win_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *time,
int flags, theme_item_t theme_item, const char *const from, const char *const message, DeliveryReceipt *receipt); int flags, theme_item_t theme_item, const char *const from, const char *const message, DeliveryReceipt *receipt);
static void _win_print_wrapped(WINDOW *win, const char *const message, size_t indent, int pad_indent); static void _win_print_wrapped(WINDOW *win, const char *const message, size_t indent, int pad_indent);
@ -314,7 +316,7 @@ win_get_title(ProfWin *window)
} }
char* char*
win_get_string(ProfWin *window) win_to_string(ProfWin *window)
{ {
assert(window != NULL); assert(window != NULL);
@ -517,7 +519,6 @@ win_page_down(ProfWin *window)
void void
win_sub_page_down(ProfWin *window) win_sub_page_down(ProfWin *window)
{ {
if (window->layout->type == LAYOUT_SPLIT) { if (window->layout->type == LAYOUT_SPLIT) {
int rows = getmaxy(stdscr); int rows = getmaxy(stdscr);
int page_space = rows - 4; int page_space = rows - 4;
@ -683,14 +684,14 @@ win_show_occupant(ProfWin *window, Occupant *occupant)
theme_item_t presence_colour = theme_main_presence_attrs(presence_str); theme_item_t presence_colour = theme_main_presence_attrs(presence_str);
win_print(window, '-', 0, NULL, NO_EOL, presence_colour, "", occupant->nick); win_print(window, presence_colour, '-', "%s", occupant->nick);
win_vprint(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) { if (occupant->status) {
win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", occupant->status); win_append(window, presence_colour, ", \"%s\"", occupant->status);
} }
win_print(window, '-', 0, NULL, NO_DATE, presence_colour, "", ""); win_appendln(window, presence_colour, "");
} }
void void
@ -705,12 +706,12 @@ win_show_contact(ProfWin *window, PContact contact)
theme_item_t presence_colour = theme_main_presence_attrs(presence); theme_item_t presence_colour = theme_main_presence_attrs(presence);
if (name) { if (name) {
win_print(window, '-', 0, NULL, NO_EOL, presence_colour, "", name); win_print(window, presence_colour, '-', "%s", name);
} else { } else {
win_print(window, '-', 0, NULL, NO_EOL, presence_colour, "", barejid); win_print(window, presence_colour, '-', "%s", barejid);
} }
win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence); win_append(window, presence_colour, " is %s", presence);
if (last_activity) { if (last_activity) {
GDateTime *now = g_date_time_new_now_local(); GDateTime *now = g_date_time_new_now_local();
@ -724,18 +725,17 @@ win_show_contact(ProfWin *window, PContact contact)
int seconds = span / G_TIME_SPAN_SECOND; int seconds = span / G_TIME_SPAN_SECOND;
if (hours > 0) { if (hours > 0) {
win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", idle %dh%dm%ds", hours, minutes, seconds); win_append(window, presence_colour, ", idle %dh%dm%ds", hours, minutes, seconds);
} } else {
else { win_append(window, presence_colour, ", idle %dm%ds", minutes, seconds);
win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", idle %dm%ds", minutes, seconds);
} }
} }
if (status) { if (status) {
win_vprint(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_print(window, '-', 0, NULL, NO_DATE, presence_colour, "", ""); win_appendln(window, presence_colour, "");
} }
void void
@ -747,21 +747,21 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa
theme_item_t presence_colour = theme_main_presence_attrs(presence_str); theme_item_t presence_colour = theme_main_presence_attrs(presence_str);
win_print(window, '!', 0, NULL, NO_EOL, presence_colour, "", occupant->nick); win_print(window, presence_colour, '!', "%s", occupant->nick);
win_vprint(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) { if (occupant->status) {
win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", occupant->status); win_append(window, presence_colour, ", \"%s\"", occupant->status);
} }
win_newline(window); win_newline(window);
if (occupant->jid) { if (occupant->jid) {
win_vprint(window, '!', 0, NULL, 0, 0, "", " Jid: %s", occupant->jid); win_println(window, THEME_DEFAULT, '!', " Jid: %s", occupant->jid);
} }
win_vprint(window, '!', 0, NULL, 0, 0, "", " Affiliation: %s", occupant_affiliation); win_println(window, THEME_DEFAULT, '!', " Affiliation: %s", occupant_affiliation);
win_vprint(window, '!', 0, NULL, 0, 0, "", " Role: %s", occupant_role); win_println(window, THEME_DEFAULT, '!', " Role: %s", occupant_role);
Jid *jidp = jid_create_from_bare_and_resource(room, occupant->nick); Jid *jidp = jid_create_from_bare_and_resource(room, occupant->nick);
EntityCapabilities *caps = caps_lookup(jidp->fulljid); EntityCapabilities *caps = caps_lookup(jidp->fulljid);
@ -771,21 +771,21 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa
// show identity // show identity
if (caps->identity) { if (caps->identity) {
DiscoIdentity *identity = caps->identity; DiscoIdentity *identity = caps->identity;
win_print(window, '!', 0, NULL, NO_EOL, 0, "", " Identity: "); win_print(window, THEME_DEFAULT, '!', " Identity: ");
if (identity->name) { if (identity->name) {
win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->name); win_append(window, THEME_DEFAULT, "%s", identity->name);
if (identity->category || identity->type) { if (identity->category || identity->type) {
win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); win_append(window, THEME_DEFAULT, " ");
} }
} }
if (identity->type) { if (identity->type) {
win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->type); win_append(window, THEME_DEFAULT, "%s", identity->type);
if (identity->category) { if (identity->category) {
win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); win_append(window, THEME_DEFAULT, " ");
} }
} }
if (identity->category) { if (identity->category) {
win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->category); win_append(window, THEME_DEFAULT, "%s", identity->category);
} }
win_newline(window); win_newline(window);
} }
@ -793,19 +793,19 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa
if (caps->software_version) { if (caps->software_version) {
SoftwareVersion *software_version = caps->software_version; SoftwareVersion *software_version = caps->software_version;
if (software_version->software) { if (software_version->software) {
win_vprint(window, '!', 0, NULL, NO_EOL, 0, "", " Software: %s", software_version->software); win_print(window, THEME_DEFAULT, '!', " Software: %s", software_version->software);
} }
if (software_version->software_version) { if (software_version->software_version) {
win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->software_version); win_append(window, THEME_DEFAULT, ", %s", software_version->software_version);
} }
if (software_version->software || software_version->software_version) { if (software_version->software || software_version->software_version) {
win_newline(window); win_newline(window);
} }
if (software_version->os) { if (software_version->os) {
win_vprint(window, '!', 0, NULL, NO_EOL, 0, "", " OS: %s", software_version->os); win_print(window, THEME_DEFAULT, '!', " OS: %s", software_version->os);
} }
if (software_version->os_version) { if (software_version->os_version) {
win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->os_version); win_append(window, THEME_DEFAULT, ", %s", software_version->os_version);
} }
if (software_version->os || software_version->os_version) { if (software_version->os || software_version->os_version) {
win_newline(window); win_newline(window);
@ -815,7 +815,7 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa
caps_destroy(caps); caps_destroy(caps);
} }
win_print(window, '-', 0, NULL, 0, 0, "", ""); win_println(window, THEME_DEFAULT, '-', "");
} }
void void
@ -829,15 +829,15 @@ win_show_info(ProfWin *window, PContact contact)
theme_item_t presence_colour = theme_main_presence_attrs(presence); theme_item_t presence_colour = theme_main_presence_attrs(presence);
win_print(window, '-', 0, NULL, 0, 0, "", ""); win_println(window, THEME_DEFAULT, '-', "");
win_print(window, '-', 0, NULL, NO_EOL, presence_colour, "", barejid); win_print(window, presence_colour, '-', "%s", barejid);
if (name) { if (name) {
win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (%s)", name); win_append(window, presence_colour, " (%s)", name);
} }
win_print(window, '-', 0, NULL, NO_DATE, 0, "", ":"); win_appendln(window, THEME_DEFAULT, ":");
if (sub) { if (sub) {
win_vprint(window, '-', 0, NULL, 0, 0, "", "Subscription: %s", sub); win_println(window, THEME_DEFAULT, '-', "Subscription: %s", sub);
} }
if (last_activity) { if (last_activity) {
@ -851,10 +851,10 @@ win_show_info(ProfWin *window, PContact contact)
int seconds = span / G_TIME_SPAN_SECOND; int seconds = span / G_TIME_SPAN_SECOND;
if (hours > 0) { if (hours > 0) {
win_vprint(window, '-', 0, NULL, 0, 0, "", "Last activity: %dh%dm%ds", hours, minutes, seconds); win_println(window, THEME_DEFAULT, '-', "Last activity: %dh%dm%ds", hours, minutes, seconds);
} }
else { else {
win_vprint(window, '-', 0, NULL, 0, 0, "", "Last activity: %dm%ds", minutes, seconds); win_println(window, THEME_DEFAULT, '-', "Last activity: %dm%ds", minutes, seconds);
} }
g_date_time_unref(now); g_date_time_unref(now);
@ -863,7 +863,7 @@ win_show_info(ProfWin *window, PContact contact)
GList *resources = p_contact_get_available_resources(contact); GList *resources = p_contact_get_available_resources(contact);
GList *ordered_resources = NULL; GList *ordered_resources = NULL;
if (resources) { if (resources) {
win_print(window, '-', 0, NULL, 0, 0, "", "Resources:"); win_println(window, THEME_DEFAULT, '-', "Resources:");
// sort in order of availability // sort in order of availability
GList *curr = resources; GList *curr = resources;
@ -881,9 +881,9 @@ win_show_info(ProfWin *window, PContact contact)
Resource *resource = curr->data; Resource *resource = curr->data;
const char *resource_presence = string_from_resource_presence(resource->presence); const char *resource_presence = string_from_resource_presence(resource->presence);
theme_item_t presence_colour = theme_main_presence_attrs(resource_presence); theme_item_t presence_colour = theme_main_presence_attrs(resource_presence);
win_vprint(window, '-', 0, NULL, NO_EOL, presence_colour, "", " %s (%d), %s", resource->name, resource->priority, resource_presence); win_print(window, presence_colour, '-', " %s (%d), %s", resource->name, resource->priority, resource_presence);
if (resource->status) { if (resource->status) {
win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", resource->status); win_append(window, presence_colour, ", \"%s\"", resource->status);
} }
win_newline(window); win_newline(window);
@ -895,21 +895,21 @@ win_show_info(ProfWin *window, PContact contact)
// show identity // show identity
if (caps->identity) { if (caps->identity) {
DiscoIdentity *identity = caps->identity; DiscoIdentity *identity = caps->identity;
win_print(window, '-', 0, NULL, NO_EOL, 0, "", " Identity: "); win_print(window, THEME_DEFAULT, '-', " Identity: ");
if (identity->name) { if (identity->name) {
win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->name); win_append(window, THEME_DEFAULT, "%s", identity->name);
if (identity->category || identity->type) { if (identity->category || identity->type) {
win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); win_append(window, THEME_DEFAULT, " ");
} }
} }
if (identity->type) { if (identity->type) {
win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->type); win_append(window, THEME_DEFAULT, "%s", identity->type);
if (identity->category) { if (identity->category) {
win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); win_append(window, THEME_DEFAULT, " ");
} }
} }
if (identity->category) { if (identity->category) {
win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->category); win_append(window, THEME_DEFAULT, "%s", identity->category);
} }
win_newline(window); win_newline(window);
} }
@ -917,19 +917,19 @@ win_show_info(ProfWin *window, PContact contact)
if (caps->software_version) { if (caps->software_version) {
SoftwareVersion *software_version = caps->software_version; SoftwareVersion *software_version = caps->software_version;
if (software_version->software) { if (software_version->software) {
win_vprint(window, '-', 0, NULL, NO_EOL, 0, "", " Software: %s", software_version->software); win_print(window, THEME_DEFAULT, '-', " Software: %s", software_version->software);
} }
if (software_version->software_version) { if (software_version->software_version) {
win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->software_version); win_append(window, THEME_DEFAULT, ", %s", software_version->software_version);
} }
if (software_version->software || software_version->software_version) { if (software_version->software || software_version->software_version) {
win_newline(window); win_newline(window);
} }
if (software_version->os) { if (software_version->os) {
win_vprint(window, '-', 0, NULL, NO_EOL, 0, "", " OS: %s", software_version->os); win_print(window, THEME_DEFAULT, '-', " OS: %s", software_version->os);
} }
if (software_version->os_version) { if (software_version->os_version) {
win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->os_version); win_append(window, THEME_DEFAULT, ", %s", software_version->os_version);
} }
if (software_version->os || software_version->os_version) { if (software_version->os || software_version->os_version) {
win_newline(window); win_newline(window);
@ -960,13 +960,12 @@ win_show_status_string(ProfWin *window, const char *const from,
presence_colour = THEME_OFFLINE; presence_colour = THEME_OFFLINE;
} }
win_print(window, presence_colour, '-', "%s %s", pre, from);
win_vprint(window, '-', 0, NULL, NO_EOL, presence_colour, "", "%s %s", pre, from);
if (show) if (show)
win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", show); win_append(window, presence_colour, " is %s", show);
else else
win_vprint(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) { if (last_activity) {
gchar *date_fmt = NULL; gchar *date_fmt = NULL;
@ -975,20 +974,19 @@ win_show_status_string(ProfWin *window, const char *const from,
prefs_free_string(time_pref); prefs_free_string(time_pref);
assert(date_fmt != NULL); assert(date_fmt != NULL);
win_vprint(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); g_free(date_fmt);
} }
if (status) if (status)
win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", status); win_append(window, presence_colour, ", \"%s\"", status);
win_print(window, '-', 0, NULL, NO_DATE, presence_colour, "", "");
win_appendln(window, presence_colour, "");
} }
void void
win_print_incoming_message(ProfWin *window, GDateTime *timestamp, win_print_incoming(ProfWin *window, GDateTime *timestamp,
const char *const from, const char *const message, prof_enc_t enc_mode) const char *const from, const char *const message, prof_enc_t enc_mode)
{ {
char enc_char = '-'; char enc_char = '-';
@ -1001,10 +999,10 @@ win_print_incoming_message(ProfWin *window, GDateTime *timestamp,
} else if (enc_mode == PROF_MSG_PGP) { } else if (enc_mode == PROF_MSG_PGP) {
enc_char = prefs_get_pgp_char(); enc_char = prefs_get_pgp_char();
} }
win_print(window, enc_char, 0, timestamp, NO_ME, THEME_TEXT_THEM, from, message); _win_printf(window, enc_char, 0, timestamp, NO_ME, THEME_TEXT_THEM, from, "%s", message);
break; break;
case WIN_PRIVATE: case WIN_PRIVATE:
win_print(window, '-', 0, timestamp, NO_ME, THEME_TEXT_THEM, from, message); _win_printf(window, '-', 0, timestamp, NO_ME, THEME_TEXT_THEM, from, "%s", message);
break; break;
default: default:
assert(FALSE); assert(FALSE);
@ -1013,53 +1011,249 @@ win_print_incoming_message(ProfWin *window, GDateTime *timestamp,
} }
void void
win_vprint(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, win_print_them(ProfWin *window, theme_item_t theme_item, const char *const them)
int flags, theme_item_t theme_item, const char *const from, const char *const message, ...)
{ {
_win_printf(window, '-', 0, NULL, NO_ME | NO_EOL, theme_item, them, "");
}
void
win_println_them_message(ProfWin *window, const char *const them, const char *const message, ...)
{
GDateTime *timestamp = g_date_time_new_now_local();
va_list arg; va_list arg;
va_start(arg, message); va_start(arg, message);
GString *fmt_msg = g_string_new(NULL); GString *fmt_msg = g_string_new(NULL);
g_string_vprintf(fmt_msg, message, arg); g_string_vprintf(fmt_msg, message, arg);
win_print(window, show_char, pad_indent, timestamp, flags, theme_item, from, fmt_msg->str);
buffer_push(window->layout->buffer, '-', 0, timestamp, NO_ME, THEME_TEXT_THEM, them, fmt_msg->str, NULL);
_win_print(window, '-', 0, timestamp, NO_ME, THEME_TEXT_THEM, them, fmt_msg->str, NULL);
inp_nonblocking(TRUE);
g_date_time_unref(timestamp);
g_string_free(fmt_msg, TRUE); g_string_free(fmt_msg, TRUE);
va_end(arg); va_end(arg);
} }
void void
win_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *timestamp, win_println_me_message(ProfWin *window, const char *const me, const char *const message, ...)
int flags, theme_item_t theme_item, const char *const from, const char *const message)
{ {
if (timestamp == NULL) { GDateTime *timestamp = g_date_time_new_now_local();
timestamp = g_date_time_new_now_local();
} else {
g_date_time_ref(timestamp);
}
buffer_push(window->layout->buffer, show_char, pad_indent, timestamp, flags, theme_item, from, message, NULL); va_list arg;
_win_print(window, show_char, pad_indent, timestamp, flags, theme_item, from, message, NULL); va_start(arg, message);
// TODO: cross-reference.. this should be replaced by a real event-based system GString *fmt_msg = g_string_new(NULL);
g_string_vprintf(fmt_msg, message, arg);
buffer_push(window->layout->buffer, '-', 0, timestamp, 0, THEME_TEXT_ME, me, fmt_msg->str, NULL);
_win_print(window, '-', 0, timestamp, 0, THEME_TEXT_ME, me, fmt_msg->str, NULL);
inp_nonblocking(TRUE); inp_nonblocking(TRUE);
g_date_time_unref(timestamp); g_date_time_unref(timestamp);
g_string_free(fmt_msg, TRUE);
va_end(arg);
} }
void void
win_print_with_receipt(ProfWin *window, const char show_char, int pad_indent, GTimeVal *tstamp, win_print_outgoing(ProfWin *window, const char ch, const char *const message, ...)
int flags, theme_item_t theme_item, const char *const from, const char *const message, char *id)
{ {
GDateTime *time; GDateTime *timestamp = g_date_time_new_now_local();
if (tstamp == NULL) { va_list arg;
time = g_date_time_new_now_local(); va_start(arg, message);
} else { GString *fmt_msg = g_string_new(NULL);
time = g_date_time_new_from_timeval_utc(tstamp); g_string_vprintf(fmt_msg, message, arg);
buffer_push(window->layout->buffer, ch, 0, timestamp, 0, THEME_TEXT_ME, "me", fmt_msg->str, NULL);
_win_print(window, ch, 0, timestamp, 0, THEME_TEXT_ME, "me", fmt_msg->str, NULL);
inp_nonblocking(TRUE);
g_date_time_unref(timestamp);
g_string_free(fmt_msg, TRUE);
va_end(arg);
} }
void
win_print_history(ProfWin *window, GDateTime *timestamp, const char *const message, ...)
{
g_date_time_ref(timestamp);
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_COLOUR_DATE, THEME_DEFAULT, "", fmt_msg->str, NULL);
_win_print(window, '-', 0, timestamp, NO_COLOUR_DATE, THEME_DEFAULT, "", fmt_msg->str, NULL);
inp_nonblocking(TRUE);
g_date_time_unref(timestamp);
g_string_free(fmt_msg, TRUE);
va_end(arg);
}
void
win_print(ProfWin *window, theme_item_t theme_item, const char ch, 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, ch, 0, timestamp, NO_EOL, theme_item, "", fmt_msg->str, NULL);
_win_print(window, ch, 0, timestamp, 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_println(ProfWin *window, theme_item_t theme_item, const char ch, 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, ch, 0, timestamp, 0, theme_item, "", fmt_msg->str, NULL);
_win_print(window, ch, 0, timestamp, 0, 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_println_indent(ProfWin *window, int pad, 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, '-', pad, timestamp, 0, THEME_DEFAULT, "", fmt_msg->str, NULL);
_win_print(window, '-', pad, timestamp, 0, THEME_DEFAULT, "", fmt_msg->str, NULL);
inp_nonblocking(TRUE);
g_date_time_unref(timestamp);
g_string_free(fmt_msg, TRUE);
va_end(arg);
}
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_DATE | 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();
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_DATE, theme_item, "", fmt_msg->str, NULL);
_win_print(window, '-', 0, timestamp, NO_DATE, 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_append_highlight(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_DATE | NO_ME | NO_EOL, theme_item, "", fmt_msg->str, NULL);
_win_print(window, '-', 0, timestamp, NO_DATE | NO_ME | 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_highlight(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_DATE | NO_ME, theme_item, "", fmt_msg->str, NULL);
_win_print(window, '-', 0, timestamp, NO_DATE | NO_ME, 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_print_http_upload(ProfWin *window, const char *const message, char *url)
{
win_print_with_receipt(window, '!', NULL, message, url);
}
void
win_print_with_receipt(ProfWin *window, const char show_char, const char *const from, const char *const message,
char *id)
{
GDateTime *time = g_date_time_new_now_local();
DeliveryReceipt *receipt = malloc(sizeof(struct delivery_receipt_t)); DeliveryReceipt *receipt = malloc(sizeof(struct delivery_receipt_t));
receipt->id = strdup(id); receipt->id = strdup(id);
receipt->received = FALSE; receipt->received = FALSE;
buffer_push(window->layout->buffer, show_char, pad_indent, time, flags, theme_item, from, message, receipt); buffer_push(window->layout->buffer, show_char, 0, time, 0, THEME_TEXT_ME, from, message, receipt);
_win_print(window, show_char, pad_indent, time, flags, theme_item, from, message, receipt); _win_print(window, show_char, 0, time, 0, THEME_TEXT_ME, from, message, receipt);
// TODO: cross-reference.. this should be replaced by a real event-based system // TODO: cross-reference.. this should be replaced by a real event-based system
inp_nonblocking(TRUE); inp_nonblocking(TRUE);
g_date_time_unref(time); g_date_time_unref(time);
@ -1096,29 +1290,36 @@ win_update_entry_theme(ProfWin *window, const char *const id, theme_item_t theme
} }
void void
win_println(ProfWin *window, int pad, const char *const message) win_newline(ProfWin *window)
{ {
win_print(window, '-', pad, NULL, 0, 0, "", message); win_appendln(window, THEME_DEFAULT, "");
} }
void static void
win_vprintln_ch(ProfWin *window, char ch, const char *const message, ...) _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, ...)
{ {
if (timestamp == NULL) {
timestamp = g_date_time_new_now_local();
} else {
g_date_time_ref(timestamp);
}
va_list arg; va_list arg;
va_start(arg, message); va_start(arg, message);
GString *fmt_msg = g_string_new(NULL); GString *fmt_msg = g_string_new(NULL);
g_string_vprintf(fmt_msg, message, arg); g_string_vprintf(fmt_msg, message, arg);
win_print(window, ch, 0, NULL, 0, 0, "", fmt_msg->str);
buffer_push(window->layout->buffer, show_char, pad_indent, timestamp, flags, theme_item, from, fmt_msg->str, NULL);
_win_print(window, show_char, pad_indent, timestamp, flags, theme_item, from, fmt_msg->str, NULL);
inp_nonblocking(TRUE);
g_date_time_unref(timestamp);
g_string_free(fmt_msg, TRUE); g_string_free(fmt_msg, TRUE);
va_end(arg); va_end(arg);
} }
void
win_newline(ProfWin *window)
{
win_print(window, '-', 0, NULL, NO_DATE, 0, "", "");
}
static void static void
_win_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *time, _win_print(ProfWin *window, const char show_char, int pad_indent, GDateTime *time,
int flags, theme_item_t theme_item, const char *const from, const char *const message, DeliveryReceipt *receipt) int flags, theme_item_t theme_item, const char *const from, const char *const message, DeliveryReceipt *receipt)

View File

@ -59,10 +59,21 @@ void win_show_status_string(ProfWin *window, const char *const from,
const char *const show, const char *const status, const char *const show, const char *const status,
GDateTime *last_activity, const char *const pre, GDateTime *last_activity, const char *const pre,
const char *const default_show); const char *const default_show);
void win_print_incoming_message(ProfWin *window, GDateTime *timestamp,
void win_print_them(ProfWin *window, theme_item_t theme_item, const char *const them);
void win_println_them_message(ProfWin *window, const char *const them, const char *const message, ...);
void win_println_me_message(ProfWin *window, const char *const me, const char *const message, ...);
void win_print_outgoing(ProfWin *window, const char ch, const char *const message, ...);
void win_print_incoming(ProfWin *window, GDateTime *timestamp,
const char *const from, const char *const message, prof_enc_t enc_mode); const char *const from, const char *const message, prof_enc_t enc_mode);
void win_print_with_receipt(ProfWin *window, const char show_char, int pad_indent, GTimeVal *tstamp, int flags, void win_print_history(ProfWin *window, GDateTime *timestamp, const char *const message, ...);
theme_item_t theme_item, const char *const from, const char *const message, char *id);
void win_print_http_upload(ProfWin *window, const char *const message, char *url);
void win_print_with_receipt(ProfWin *window, const char show_char, const char *const from, const char *const message,
char *id);
void win_newline(ProfWin *window); void win_newline(ProfWin *window);
void win_redraw(ProfWin *window); void win_redraw(ProfWin *window);
int win_roster_cols(void); int win_roster_cols(void);

View File

@ -280,7 +280,7 @@ wins_private_nick_change(const char *const roomjid, const char *const oldnick, c
Jid *newjid = jid_create_from_bare_and_resource(roomjid, newnick); Jid *newjid = jid_create_from_bare_and_resource(roomjid, newnick);
privwin->fulljid = strdup(newjid->fulljid); privwin->fulljid = strdup(newjid->fulljid);
win_vprint((ProfWin*)privwin, '!', 0, NULL, 0, THEME_THEM, NULL, "** %s is now known as %s.", oldjid->resourcepart, newjid->resourcepart); win_println((ProfWin*)privwin, THEME_THEM, '!', "** %s is now known as %s.", oldjid->resourcepart, newjid->resourcepart);
autocomplete_remove(wins_ac, oldjid->fulljid); autocomplete_remove(wins_ac, oldjid->fulljid);
autocomplete_remove(wins_close_ac, oldjid->fulljid); autocomplete_remove(wins_close_ac, oldjid->fulljid);
@ -835,7 +835,7 @@ wins_lost_connection(void)
while (curr) { while (curr) {
ProfWin *window = curr->data; ProfWin *window = curr->data;
if (window->type != WIN_CONSOLE) { if (window->type != WIN_CONSOLE) {
win_print(window, '-', 0, NULL, 0, THEME_ERROR, "", "Lost connection."); win_println(window, THEME_ERROR, '-', "Lost connection.");
// if current win, set current_win_dirty // if current win, set current_win_dirty
if (wins_is_current(window)) { if (wins_is_current(window)) {
@ -1051,7 +1051,7 @@ wins_create_summary(gboolean unread)
GString *line = g_string_new(""); GString *line = g_string_new("");
int ui_index = GPOINTER_TO_INT(curr->data); int ui_index = GPOINTER_TO_INT(curr->data);
char *winstring = win_get_string(window); char *winstring = win_to_string(window);
if (!winstring) { if (!winstring) {
g_string_free(line, TRUE); g_string_free(line, TRUE);
continue; continue;

View File

@ -45,13 +45,13 @@ xmlwin_show(ProfXMLWin *xmlwin, const char *const msg)
ProfWin *window = (ProfWin*)xmlwin; ProfWin *window = (ProfWin*)xmlwin;
if (g_str_has_prefix(msg, "SENT:")) { if (g_str_has_prefix(msg, "SENT:")) {
win_print(window, '-', 0, NULL, 0, 0, "", "SENT:"); win_println(window, THEME_DEFAULT, '-', "SENT:");
win_print(window, '-', 0, NULL, 0, THEME_ONLINE, "", &msg[6]); win_println(window, THEME_ONLINE, '-', "%s", &msg[6]);
win_print(window, '-', 0, NULL, 0, THEME_ONLINE, "", ""); win_println(window, THEME_ONLINE, '-', "");
} else if (g_str_has_prefix(msg, "RECV:")) { } else if (g_str_has_prefix(msg, "RECV:")) {
win_print(window, '-', 0, NULL, 0, 0, "", "RECV:"); win_println(window, THEME_DEFAULT, '-', "RECV:");
win_print(window, '-', 0, NULL, 0, THEME_AWAY, "", &msg[6]); win_println(window, THEME_AWAY, '-', "%s", &msg[6]);
win_print(window, '-', 0, NULL, 0, THEME_AWAY, "", ""); win_println(window, THEME_AWAY, '-', "");
} }
} }

View File

@ -125,9 +125,6 @@ void ui_current_print_formatted_line(const char show_char, int attrs, const char
va_end(args); va_end(args);
} }
void ui_current_error_line(const char * const msg) {}
void ui_win_error_line(ProfWin *window, const char * const msg) {}
void ui_close_win(int index) {} void ui_close_win(int index) {}
int ui_win_unread(int index) int ui_win_unread(int index)
@ -520,8 +517,11 @@ void win_hide_subwin(ProfWin *window) {}
void win_show_subwin(ProfWin *window) {} void win_show_subwin(ProfWin *window) {}
void win_refresh_without_subwin(ProfWin *window) {} void win_refresh_without_subwin(ProfWin *window) {}
void win_refresh_with_subwin(ProfWin *window) {} void win_refresh_with_subwin(ProfWin *window) {}
void win_print(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_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_vprint(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, ...) {}
char* win_get_title(ProfWin *window) char* win_get_title(ProfWin *window)
{ {
return NULL; return NULL;
@ -530,10 +530,9 @@ void win_show_occupant(ProfWin *window, Occupant *occupant) {}
void win_show_occupant_info(ProfWin *window, const char * const room, Occupant *occupant) {} void win_show_occupant_info(ProfWin *window, const char * const room, Occupant *occupant) {}
void win_show_contact(ProfWin *window, PContact contact) {} void win_show_contact(ProfWin *window, PContact contact) {}
void win_show_info(ProfWin *window, PContact contact) {} void win_show_info(ProfWin *window, PContact contact) {}
void win_println(ProfWin *window, int pad, const char * const message) {} void win_println_indent(ProfWin *window, int pad, const char * const message, ...) {}
void win_vprintln_ch(ProfWin *window, char ch, const char *const message, ...) {}
void win_clear(ProfWin *window) {} void win_clear(ProfWin *window) {}
char* win_get_string(ProfWin *window) char* win_to_string(ProfWin *window)
{ {
return NULL; return NULL;
} }

View File

@ -95,11 +95,11 @@ intype=true
enc.warn=true enc.warn=true
resource.title=true resource.title=true
resource.message=true resource.message=true
statuses.console=all statuses.console=none
statuses.chat=none statuses.chat=none
statuses.muc=none statuses.muc=none
roster=true roster=true
roster.offline=true roster.offline=false
roster.empty=false roster.empty=false
roster.by=group roster.by=group
roster.order=presence roster.order=presence