about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-10-16 22:13:49 +0100
committerJames Booth <boothj5@gmail.com>2016-10-16 22:13:49 +0100
commit333403d2e5c54039d84578c94dfe777ebf7d08d0 (patch)
tree6b5318525af32142fbb1f727d4107b0ec25ad76e
parent769e71b17b32235b3efd0a05c94709f3f6e0a4d8 (diff)
downloadprofani-tty-333403d2e5c54039d84578c94dfe777ebf7d08d0.tar.gz
Remove ui_current_print_formatted_line
-rw-r--r--src/command/cmd_funcs.c56
-rw-r--r--src/ui/core.c13
-rw-r--r--src/ui/ui.h1
-rw-r--r--tests/unittests/test_cmd_otr.c12
-rw-r--r--tests/unittests/ui/stub_ui.c8
-rw-r--r--tests/unittests/ui/stub_ui.h1
6 files changed, 34 insertions, 57 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index 84cc7943..c045a627 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -4333,9 +4333,9 @@ cmd_bookmark(ProfWin *window, const char *const command, gchar **args)
         char *password = muc_password(mucwin->roomjid);
         gboolean added = bookmark_add(mucwin->roomjid, nick, password, "on");
         if (added) {
-            ui_current_print_formatted_line('!', 0, "Bookmark added for %s.", mucwin->roomjid);
+            win_println(window, THEME_DEFAULT, '!', "Bookmark added for %s.", mucwin->roomjid);
         } else {
-            ui_current_print_formatted_line('!', 0, "Bookmark already exists for %s.", mucwin->roomjid);
+            win_println(window, THEME_DEFAULT, '!', "Bookmark already exists for %s.", mucwin->roomjid);
         }
         return TRUE;
     }
@@ -4345,9 +4345,9 @@ cmd_bookmark(ProfWin *window, const char *const command, gchar **args)
         assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
         gboolean removed = bookmark_remove(mucwin->roomjid);
         if (removed) {
-            ui_current_print_formatted_line('!', 0, "Bookmark removed for %s.", mucwin->roomjid);
+            win_println(window, THEME_DEFAULT, '!', "Bookmark removed for %s.", mucwin->roomjid);
         } else {
-            ui_current_print_formatted_line('!', 0, "Bookmark does not exist for %s.", mucwin->roomjid);
+            win_println(window, THEME_DEFAULT, '!', "Bookmark does not exist for %s.", mucwin->roomjid);
         }
         return TRUE;
     }
@@ -6480,19 +6480,19 @@ cmd_pgp(ProfWin *window, const char *const command, gchar **args)
         }
 
         if (chatwin->is_otr) {
-            ui_current_print_formatted_line('!', 0, "You must end the OTR session to start PGP encryption.");
+            win_println(window, THEME_DEFAULT, '!', "You must end the OTR session to start PGP encryption.");
             return TRUE;
         }
 
         if (chatwin->pgp_send) {
-            ui_current_print_formatted_line('!', 0, "You have already started PGP encryption.");
+            win_println(window, THEME_DEFAULT, '!', "You have already started PGP encryption.");
             return TRUE;
         }
 
         ProfAccount *account = accounts_get_account(session_get_account_name());
         char *err_str = NULL;
         if (!p_gpg_valid_key(account->pgp_keyid, &err_str)) {
-            ui_current_print_formatted_line('!', 0, "Invalid PGP key ID %s: %s, cannot start PGP encryption.", account->pgp_keyid, err_str);
+            win_println(window, THEME_DEFAULT, '!', "Invalid PGP key ID %s: %s, cannot start PGP encryption.", account->pgp_keyid, err_str);
             free(err_str);
             account_free(account);
             return TRUE;
@@ -6501,12 +6501,12 @@ cmd_pgp(ProfWin *window, const char *const command, gchar **args)
         account_free(account);
 
         if (!p_gpg_available(chatwin->barejid)) {
-            ui_current_print_formatted_line('!', 0, "No PGP key found for %s.", chatwin->barejid);
+            win_println(window, THEME_DEFAULT, '!', "No PGP key found for %s.", chatwin->barejid);
             return TRUE;
         }
 
         chatwin->pgp_send = TRUE;
-        ui_current_print_formatted_line('!', 0, "PGP encryption enabled.");
+        win_println(window, THEME_DEFAULT, '!', "PGP encryption enabled.");
         return TRUE;
     }
 
@@ -6524,12 +6524,12 @@ cmd_pgp(ProfWin *window, const char *const command, gchar **args)
 
         ProfChatWin *chatwin = (ProfChatWin*)window;
         if (chatwin->pgp_send == FALSE) {
-            ui_current_print_formatted_line('!', 0, "PGP encryption is not currently enabled.");
+            win_println(window, THEME_DEFAULT, '!', "PGP encryption is not currently enabled.");
             return TRUE;
         }
 
         chatwin->pgp_send = FALSE;
-        ui_current_print_formatted_line('!', 0, "PGP encryption disabled.");
+        win_println(window, THEME_DEFAULT, '!', "PGP encryption disabled.");
         return TRUE;
     }
 
@@ -6676,12 +6676,12 @@ cmd_otr_myfp(ProfWin *window, const char *const command, gchar **args)
     }
 
     if (!otr_key_loaded()) {
-        ui_current_print_formatted_line('!', 0, "You have not generated or loaded a private key, use '/otr gen'");
+        win_println(window, THEME_DEFAULT, '!', "You have not generated or loaded a private key, use '/otr gen'");
         return TRUE;
     }
 
     char *fingerprint = otr_get_my_fingerprint();
-    ui_current_print_formatted_line('!', 0, "Your OTR fingerprint: %s", fingerprint);
+    win_println(window, THEME_DEFAULT, '!', "Your OTR fingerprint: %s", fingerprint);
     free(fingerprint);
     return TRUE;
 #else
@@ -6707,12 +6707,12 @@ cmd_otr_theirfp(ProfWin *window, const char *const command, gchar **args)
     ProfChatWin *chatwin = (ProfChatWin*)window;
     assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
     if (chatwin->is_otr == FALSE) {
-        ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
+        win_println(window, THEME_DEFAULT, '!', "You are not currently in an OTR session.");
         return TRUE;
     }
 
     char *fingerprint = otr_get_their_fingerprint(chatwin->barejid);
-    ui_current_print_formatted_line('!', 0, "%s's OTR fingerprint: %s", chatwin->barejid, fingerprint);
+    win_println(window, THEME_DEFAULT, '!', "%s's OTR fingerprint: %s", chatwin->barejid, fingerprint);
     free(fingerprint);
     return TRUE;
 #else
@@ -6745,17 +6745,17 @@ cmd_otr_start(ProfWin *window, const char *const command, gchar **args)
         ui_focus_win((ProfWin*)chatwin);
 
         if (chatwin->pgp_send) {
-            ui_current_print_formatted_line('!', 0, "You must disable PGP encryption before starting an OTR session.");
+            win_println(window, THEME_DEFAULT, '!', "You must disable PGP encryption before starting an OTR session.");
             return TRUE;
         }
 
         if (chatwin->is_otr) {
-            ui_current_print_formatted_line('!', 0, "You are already in an OTR session.");
+            win_println(window, THEME_DEFAULT, '!', "You are already in an OTR session.");
             return TRUE;
         }
 
         if (!otr_key_loaded()) {
-            ui_current_print_formatted_line('!', 0, "You have not generated or loaded a private key, use '/otr gen'");
+            win_println(window, THEME_DEFAULT, '!', "You have not generated or loaded a private key, use '/otr gen'");
             return TRUE;
         }
 
@@ -6779,17 +6779,17 @@ cmd_otr_start(ProfWin *window, const char *const command, gchar **args)
         ProfChatWin *chatwin = (ProfChatWin*)window;
         assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
         if (chatwin->pgp_send) {
-            ui_current_print_formatted_line('!', 0, "You must disable PGP encryption before starting an OTR session.");
+            win_println(window, THEME_DEFAULT, '!', "You must disable PGP encryption before starting an OTR session.");
             return TRUE;
         }
 
         if (chatwin->is_otr) {
-            ui_current_print_formatted_line('!', 0, "You are already in an OTR session.");
+            win_println(window, THEME_DEFAULT, '!', "You are already in an OTR session.");
             return TRUE;
         }
 
         if (!otr_key_loaded()) {
-            ui_current_print_formatted_line('!', 0, "You have not generated or loaded a private key, use '/otr gen'");
+            win_println(window, THEME_DEFAULT, '!', "You have not generated or loaded a private key, use '/otr gen'");
             return TRUE;
         }
 
@@ -6821,7 +6821,7 @@ cmd_otr_end(ProfWin *window, const char *const command, gchar **args)
     ProfChatWin *chatwin = (ProfChatWin*)window;
     assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
     if (chatwin->is_otr == FALSE) {
-        ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
+        win_println(window, THEME_DEFAULT, '!', "You are not currently in an OTR session.");
         return TRUE;
     }
 
@@ -6851,7 +6851,7 @@ cmd_otr_trust(ProfWin *window, const char *const command, gchar **args)
     ProfChatWin *chatwin = (ProfChatWin*)window;
     assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
     if (chatwin->is_otr == FALSE) {
-        ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
+        win_println(window, THEME_DEFAULT, '!', "You are not currently in an OTR session.");
         return TRUE;
     }
 
@@ -6881,7 +6881,7 @@ cmd_otr_untrust(ProfWin *window, const char *const command, gchar **args)
     ProfChatWin *chatwin = (ProfChatWin*)window;
     assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
     if (chatwin->is_otr == FALSE) {
-        ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
+        win_println(window, THEME_DEFAULT, '!', "You are not currently in an OTR session.");
         return TRUE;
     }
 
@@ -6911,7 +6911,7 @@ cmd_otr_secret(ProfWin *window, const char *const command, gchar **args)
     ProfChatWin *chatwin = (ProfChatWin*)window;
     assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
     if (chatwin->is_otr == FALSE) {
-        ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
+        win_println(window, THEME_DEFAULT, '!', "You are not currently in an OTR session.");
         return TRUE;
     }
 
@@ -6953,7 +6953,7 @@ cmd_otr_question(ProfWin *window, const char *const command, gchar **args)
     ProfChatWin *chatwin = (ProfChatWin*)window;
     assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
     if (chatwin->is_otr == FALSE) {
-        ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
+        win_println(window, THEME_DEFAULT, '!', "You are not currently in an OTR session.");
         return TRUE;
     }
 
@@ -6982,7 +6982,7 @@ cmd_otr_answer(ProfWin *window, const char *const command, gchar **args)
     ProfChatWin *chatwin = (ProfChatWin*)window;
     assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
     if (chatwin->is_otr == FALSE) {
-        ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
+        win_println(window, THEME_DEFAULT, '!', "You are not currently in an OTR session.");
         return TRUE;
     }
 
@@ -7014,7 +7014,7 @@ _cmd_execute(ProfWin *window, const char *const command, const char *const inp)
         gboolean result = FALSE;
         gchar **args = parse_args_with_freetext(inp, 1, 2, &result);
         if (!result) {
-            ui_current_print_formatted_line('!', 0, "Invalid command, see /form help");
+            win_println(window, THEME_DEFAULT, '!', "Invalid command, see /form help");
             result = TRUE;
         } else {
             gchar **tokens = g_strsplit(inp, " ", 2);
diff --git a/src/ui/core.c b/src/ui/core.c
index a72423e4..62cf3a02 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -732,19 +732,6 @@ ui_prune_wins(void)
 }
 
 void
-ui_current_print_formatted_line(const char show_char, int attrs, const char *const msg, ...)
-{
-    ProfWin *current = wins_get_current();
-    va_list arg;
-    va_start(arg, msg);
-    GString *fmt_msg = g_string_new(NULL);
-    g_string_vprintf(fmt_msg, msg, arg);
-    win_println(current, attrs, show_char, "%s", fmt_msg->str);
-    va_end(arg);
-    g_string_free(fmt_msg, TRUE);
-}
-
-void
 ui_print_system_msg_from_recipient(const char *const barejid, const char *message)
 {
     if (barejid == NULL || message == NULL)
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 5a8a09ae..44d87966 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -75,7 +75,6 @@ void ui_print_system_msg_from_recipient(const char *const barejid, const char *m
 void ui_close_connected_win(int index);
 int ui_close_all_wins(void);
 int ui_close_read_wins(void);
-void ui_current_print_formatted_line(const char show_char, int attrs, const char *const msg, ...);
 void ui_close_win(int index);
 int ui_win_unread(int index);
 char* ui_ask_password(void);
diff --git a/tests/unittests/test_cmd_otr.c b/tests/unittests/test_cmd_otr.c
index 088b8baa..314a64b2 100644
--- a/tests/unittests/test_cmd_otr.c
+++ b/tests/unittests/test_cmd_otr.c
@@ -216,7 +216,7 @@ void cmd_otr_myfp_shows_message_when_no_key(void **state)
     will_return(connection_get_status, JABBER_CONNECTED);
     will_return(otr_key_loaded, FALSE);
 
-    expect_ui_current_print_formatted_line('!', 0, "You have not generated or loaded a private key, use '/otr gen'");
+    expect_win_println("You have not generated or loaded a private key, use '/otr gen'");
 
     gboolean result = cmd_otr_myfp(NULL, CMD_OTR, args);
     assert_true(result);
@@ -233,7 +233,7 @@ void cmd_otr_myfp_shows_my_fingerprint(void **state)
     will_return(otr_key_loaded, TRUE);
     will_return(otr_get_my_fingerprint, strdup(fingerprint));
 
-    expect_ui_current_print_formatted_line('!', 0, message->str);
+    expect_win_println(message->str);
 
     gboolean result = cmd_otr_myfp(NULL, CMD_OTR, args);
     assert_true(result);
@@ -286,7 +286,7 @@ void cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void **state)
 
     will_return(connection_get_status, JABBER_CONNECTED);
 
-    expect_ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
+    expect_win_println("You are not currently in an OTR session.");
 
     gboolean result = cmd_otr_theirfp((ProfWin*)&chatwin, CMD_OTR, args);
 
@@ -316,7 +316,7 @@ void cmd_otr_theirfp_shows_fingerprint(void **state)
     expect_string(otr_get_their_fingerprint, recipient, recipient);
     will_return(otr_get_their_fingerprint, strdup(fingerprint));
 
-    expect_ui_current_print_formatted_line('!', 0, message->str);
+    expect_win_println(message->str);
 
     gboolean result = cmd_otr_theirfp((ProfWin*)&chatwin, CMD_OTR, args);
     assert_true(result);
@@ -370,7 +370,7 @@ void cmd_otr_start_shows_message_when_already_started(void **state)
     chatwin.pgp_send = FALSE;
     chatwin.is_otr = TRUE;
 
-    expect_ui_current_print_formatted_line('!', 0, "You are already in an OTR session.");
+    expect_win_println("You are already in an OTR session.");
 
     gboolean result = cmd_otr_start((ProfWin*)&chatwin, CMD_OTR, args);
     assert_true(result);
@@ -393,7 +393,7 @@ void cmd_otr_start_shows_message_when_no_key(void **state)
     chatwin.pgp_send = FALSE;
     chatwin.is_otr = FALSE;
 
-    expect_ui_current_print_formatted_line('!', 0, "You have not generated or loaded a private key, use '/otr gen'");
+    expect_win_println("You have not generated or loaded a private key, use '/otr gen'");
 
     gboolean result = cmd_otr_start((ProfWin*)&chatwin, CMD_OTR, args);
     assert_true(result);
diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c
index da253774..e4f56c85 100644
--- a/tests/unittests/ui/stub_ui.c
+++ b/tests/unittests/ui/stub_ui.c
@@ -48,14 +48,6 @@ expect_win_println(char *message)
     expect_string(win_println, output, message);
 }
 
-void
-expect_ui_current_print_formatted_line(char show_char, int attrs, char *message)
-{
-    expect_value(ui_current_print_formatted_line, show_char, show_char);
-    expect_value(ui_current_print_formatted_line, attrs, attrs);
-    expect_string(ui_current_print_formatted_line, output, message);
-}
-
 // stubs
 
 void ui_init(void) {}
diff --git a/tests/unittests/ui/stub_ui.h b/tests/unittests/ui/stub_ui.h
index a1b94478..635f719e 100644
--- a/tests/unittests/ui/stub_ui.h
+++ b/tests/unittests/ui/stub_ui.h
@@ -2,5 +2,4 @@ void expect_cons_show(char *expected);
 void expect_any_cons_show(void);
 void expect_cons_show_error(char *expected);
 void expect_any_cons_show_error(void);
-void expect_ui_current_print_formatted_line(char show_char, int attrs, char *message);
 void expect_win_println(char *message);