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 2015-08-02 00:25:48 +01:00
commit cf48b124a6
29 changed files with 2885 additions and 2750 deletions

View File

@ -68,29 +68,29 @@ unittest_sources = \
tests/unittests/log/stub_log.c \ tests/unittests/log/stub_log.c \
tests/unittests/config/stub_accounts.c \ tests/unittests/config/stub_accounts.c \
tests/unittests/helpers.c tests/unittests/helpers.h \ tests/unittests/helpers.c tests/unittests/helpers.h \
tests/unittests/test_cmd_account.c tests/unittests/test_cmd_account.h \ tests/unittests/test_form.c tests/unittests/test_form.h \
tests/unittests/test_common.c tests/unittests/test_common.h \
tests/unittests/test_autocomplete.c tests/unittests/test_autocomplete.h \
tests/unittests/test_jid.c tests/unittests/test_jid.h \
tests/unittests/test_parser.c tests/unittests/test_parser.h \
tests/unittests/test_roster_list.c tests/unittests/test_roster_list.h \
tests/unittests/test_chat_session.c tests/unittests/test_chat_session.h \
tests/unittests/test_contact.c tests/unittests/test_contact.h \
tests/unittests/test_preferences.c tests/unittests/test_preferences.h \
tests/unittests/test_server_events.c tests/unittests/test_server_events.h \
tests/unittests/test_muc.c tests/unittests/test_muc.h \
tests/unittests/test_cmd_statuses.c tests/unittests/test_cmd_statuses.h \
tests/unittests/test_cmd_alias.c tests/unittests/test_cmd_alias.h \ tests/unittests/test_cmd_alias.c tests/unittests/test_cmd_alias.h \
tests/unittests/test_cmd_bookmark.c tests/unittests/test_cmd_bookmark.h \
tests/unittests/test_cmd_connect.c tests/unittests/test_cmd_connect.h \ tests/unittests/test_cmd_connect.c tests/unittests/test_cmd_connect.h \
tests/unittests/test_cmd_join.c tests/unittests/test_cmd_join.h \ tests/unittests/test_cmd_rooms.c tests/unittests/test_cmd_rooms.h \
tests/unittests/test_cmd_account.c tests/unittests/test_cmd_account.h \
tests/unittests/test_cmd_sub.c tests/unittests/test_cmd_sub.h \
tests/unittests/test_cmd_bookmark.c tests/unittests/test_cmd_bookmark.h \
tests/unittests/test_cmd_otr.c tests/unittests/test_cmd_otr.h \ tests/unittests/test_cmd_otr.c tests/unittests/test_cmd_otr.h \
tests/unittests/test_cmd_pgp.c tests/unittests/test_cmd_pgp.h \ tests/unittests/test_cmd_pgp.c tests/unittests/test_cmd_pgp.h \
tests/unittests/test_cmd_rooms.c tests/unittests/test_cmd_rooms.h \ tests/unittests/test_cmd_join.c tests/unittests/test_cmd_join.h \
tests/unittests/test_cmd_roster.c tests/unittests/test_cmd_roster.h \ tests/unittests/test_cmd_roster.c tests/unittests/test_cmd_roster.h \
tests/unittests/test_cmd_statuses.c tests/unittests/test_cmd_statuses.h \
tests/unittests/test_cmd_sub.c tests/unittests/test_cmd_sub.h \
tests/unittests/test_cmd_disconnect.c tests/unittests/test_cmd_disconnect.h \ tests/unittests/test_cmd_disconnect.c tests/unittests/test_cmd_disconnect.h \
tests/unittests/test_common.c tests/unittests/test_common.h \
tests/unittests/test_contact.c tests/unittests/test_contact.h \
tests/unittests/test_form.c tests/unittests/test_form.h \
tests/unittests/test_jid.c tests/unittests/test_jid.h \
tests/unittests/test_muc.c tests/unittests/test_muc.h \
tests/unittests/test_parser.c tests/unittests/test_parser.h \
tests/unittests/test_preferences.c tests/unittests/test_preferences.h \
tests/unittests/test_roster_list.c tests/unittests/test_roster_list.h \
tests/unittests/test_server_events.c tests/unittests/test_server_events.h \
tests/unittests/test_autocomplete.c tests/unittests/test_autocomplete.h \
tests/unittests/test_chat_session.c tests/unittests/test_chat_session.h \
tests/unittests/unittests.c tests/unittests/unittests.c
functionaltest_sources = \ functionaltest_sources = \

File diff suppressed because it is too large Load Diff

View File

@ -54,6 +54,9 @@ void cmd_autocomplete_remove_form_fields(DataForm *form);
void cmd_alias_add(char *value); void cmd_alias_add(char *value);
void cmd_alias_remove(char *value); void cmd_alias_remove(char *value);
gboolean cmd_valid_tag(const char * const str);
gboolean cmd_has_tag(Command *pcmd, const char * const tag);
gboolean cmd_process_input(ProfWin *window, char *inp); gboolean cmd_process_input(ProfWin *window, char *inp);
void cmd_execute_connect(ProfWin *window, const char * const account); void cmd_execute_connect(ProfWin *window, const char * const account);

File diff suppressed because it is too large Load Diff

View File

@ -35,13 +35,15 @@
#ifndef COMMANDS_H #ifndef COMMANDS_H
#define COMMANDS_H #define COMMANDS_H
#include "ui/ui.h" #include "ui/win_types.h"
// Command help strings // Command help strings
typedef struct cmd_help_t { typedef struct cmd_help_t {
const gchar *usage; const gchar *tags[20];
const gchar *short_help; const gchar *synopsis[50];
const gchar *long_help[50]; const gchar *desc;
const gchar *args[50][2];
const gchar *examples[10];
} CommandHelp; } CommandHelp;
/* /*
@ -56,7 +58,7 @@ typedef struct cmd_help_t {
*/ */
typedef struct cmd_t { typedef struct cmd_t {
gchar *cmd; gchar *cmd;
gboolean (*func)(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean (*func)(ProfWin *window, const char * const command, gchar **args);
gchar** (*parser)(const char * const inp, int min, int max, gboolean *result); gchar** (*parser)(const char * const inp, int min, int max, gboolean *result);
int min_args; int min_args;
int max_args; int max_args;
@ -67,85 +69,85 @@ typedef struct cmd_t {
gboolean cmd_execute_alias(ProfWin *window, const char * const inp, gboolean *ran); gboolean cmd_execute_alias(ProfWin *window, const char * const inp, gboolean *ran);
gboolean cmd_execute_default(ProfWin *window, const char * inp); gboolean cmd_execute_default(ProfWin *window, const char * inp);
gboolean cmd_about(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_about(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_account(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_account(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_autoaway(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_autoaway(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_autoconnect(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_autoconnect(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_autoping(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_autoping(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_away(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_away(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_beep(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_beep(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_caps(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_caps(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_chat(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_chat(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_chlog(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_chlog(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_clear(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_clear(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_close(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_close(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_connect(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_connect(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_decline(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_decline(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_disco(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_disco(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_disconnect(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_disconnect(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_dnd(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_dnd(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_flash(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_flash(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_gone(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_gone(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_grlog(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_grlog(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_group(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_group(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_help(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_help(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_history(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_history(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_carbons(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_carbons(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_receipts(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_receipts(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_info(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_info(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_intype(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_intype(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_invite(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_invite(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_invites(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_invites(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_join(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_join(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_leave(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_leave(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_log(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_log(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_msg(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_msg(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_nick(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_nick(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_notify(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_notify(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_online(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_online(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_otr(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_otr(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_pgp(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_pgp(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_outtype(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_outtype(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_prefs(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_prefs(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_priority(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_priority(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_quit(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_quit(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_reconnect(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_reconnect(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_room(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_room(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_rooms(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_rooms(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_bookmark(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_bookmark(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_roster(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_roster(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_software(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_software(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_splash(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_splash(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_states(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_states(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_status(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_status(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_statuses(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_statuses(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_sub(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_sub(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_theme(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_theme(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_tiny(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_tiny(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_titlebar(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_titlebar(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_vercheck(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_vercheck(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_who(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_who(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_win(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_win(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_wins(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_wins(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_winstidy(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_winstidy(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_xa(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_xa(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_alias(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_alias(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_xmlconsole(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_xmlconsole(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_ping(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_ping(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_form(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_form(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_occupants(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_occupants(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_kick(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_kick(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_ban(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_ban(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_subject(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_subject(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_affiliation(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_affiliation(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_role(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_role(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_privileges(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_privileges(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_presence(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_presence(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_wrap(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_wrap(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_time(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_time(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_resource(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_resource(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_inpblock(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_inpblock(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_encwarn(ProfWin *window, gchar **args, struct cmd_help_t help); gboolean cmd_encwarn(ProfWin *window, const char * const command, gchar **args);
gboolean cmd_form_field(ProfWin *window, char *tag, gchar **args); gboolean cmd_form_field(ProfWin *window, char *tag, gchar **args);

View File

@ -208,12 +208,12 @@ sv_ev_incoming_message(char *barejid, char *resource, char *message, char *enc_m
prof_enc_t enc_mode = chatwin->enc_mode; prof_enc_t enc_mode = chatwin->enc_mode;
if (enc_message) { if (enc_message) {
if (enc_mode == PROF_ENC_OTR) { if (enc_mode == PROF_ENC_OTR) {
win_println((ProfWin*)chatwin, "PGP encrypted message received whilst in OTR session."); win_println((ProfWin*)chatwin, 0, "PGP encrypted message received whilst in OTR session.");
} else { // PROF_ENC_NONE, PROF_ENC_PGP } else { // PROF_ENC_NONE, PROF_ENC_PGP
char *decrypted = p_gpg_decrypt(barejid, enc_message); char *decrypted = p_gpg_decrypt(barejid, enc_message);
if (decrypted) { if (decrypted) {
if (enc_mode == PROF_ENC_NONE) { if (enc_mode == PROF_ENC_NONE) {
win_println((ProfWin*)chatwin, "PGP encryption enabled."); win_println((ProfWin*)chatwin, 0, "PGP encryption enabled.");
} }
ui_incoming_msg(chatwin, resource, decrypted, NULL, new_win); ui_incoming_msg(chatwin, resource, decrypted, NULL, new_win);
chat_log_pgp_msg_in(barejid, decrypted); chat_log_pgp_msg_in(barejid, decrypted);
@ -226,7 +226,7 @@ sv_ev_incoming_message(char *barejid, char *resource, char *message, char *enc_m
} }
} else { } else {
if (enc_mode == PROF_ENC_PGP) { if (enc_mode == PROF_ENC_PGP) {
win_println((ProfWin*)chatwin, "PGP encryption disabled."); win_println((ProfWin*)chatwin, 0, "PGP encryption disabled.");
ui_incoming_msg(chatwin, resource, message, NULL, new_win); ui_incoming_msg(chatwin, resource, message, NULL, new_win);
chat_log_msg_in(barejid, message); chat_log_msg_in(barejid, message);
chatwin->enc_mode = PROF_ENC_NONE; chatwin->enc_mode = PROF_ENC_NONE;

View File

@ -166,8 +166,10 @@ void
muc_invites_clear(void) muc_invites_clear(void)
{ {
autocomplete_clear(invite_ac); autocomplete_clear(invite_ac);
if (invite_passwords) {
g_hash_table_remove_all(invite_passwords); g_hash_table_remove_all(invite_passwords);
} }
}
void void
muc_join(const char * const room, const char * const nick, muc_join(const char * const room, const char * const nick,

View File

@ -80,11 +80,12 @@ buffer_free(ProfBuff buffer)
} }
void void
buffer_push(ProfBuff buffer, const char show_char, GDateTime *time, buffer_push(ProfBuff buffer, 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)
{ {
ProfBuffEntry *e = malloc(sizeof(struct prof_buff_entry_t)); ProfBuffEntry *e = malloc(sizeof(struct prof_buff_entry_t));
e->show_char = show_char; e->show_char = show_char;
e->pad_indent = pad_indent;
e->flags = flags; e->flags = flags;
e->theme_item = theme_item; e->theme_item = theme_item;
e->time = g_date_time_ref(time); e->time = g_date_time_ref(time);

View File

@ -47,6 +47,7 @@ typedef struct delivery_receipt_t {
typedef struct prof_buff_entry_t { typedef struct prof_buff_entry_t {
char show_char; char show_char;
int pad_indent;
GDateTime *time; GDateTime *time;
int flags; int flags;
theme_item_t theme_item; theme_item_t theme_item;
@ -59,7 +60,7 @@ typedef struct prof_buff_t *ProfBuff;
ProfBuff buffer_create(); ProfBuff buffer_create();
void buffer_free(ProfBuff buffer); void buffer_free(ProfBuff buffer);
void buffer_push(ProfBuff buffer, const char show_char, GDateTime *time, int flags, theme_item_t theme_item, void buffer_push(ProfBuff buffer, 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); const char * const from, const char * const message, DeliveryReceipt *receipt);
int buffer_size(ProfBuff buffer); int buffer_size(ProfBuff buffer);
ProfBuffEntry* buffer_yield_entry(ProfBuff buffer, int entry); ProfBuffEntry* buffer_yield_entry(ProfBuff buffer, int entry);

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, '-', NULL, NO_EOL, 0, "", ""); win_print(console, '-', 0, NULL, NO_EOL, 0, "", "");
} }
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, '-', NULL, NO_DATE | NO_EOL, 0, "", word); win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", 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, fmt_msg->str); win_println(console, 0, fmt_msg->str);
g_string_free(fmt_msg, TRUE); g_string_free(fmt_msg, TRUE);
va_end(arg); va_end(arg);
} }
@ -100,11 +100,79 @@ 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, fmt_msg->str); win_println(console, 0, fmt_msg->str);
g_string_free(fmt_msg, TRUE); g_string_free(fmt_msg, TRUE);
va_end(arg); va_end(arg);
} }
void
cons_show_padded(int pad, const char * const msg, ...)
{
ProfWin *console = wins_get_console();
va_list arg;
va_start(arg, msg);
GString *fmt_msg = g_string_new(NULL);
g_string_vprintf(fmt_msg, msg, arg);
win_println(console, pad, fmt_msg->str);
g_string_free(fmt_msg, TRUE);
va_end(arg);
}
void
cons_show_help(Command *command)
{
ProfWin *console = wins_get_console();
cons_show("");
win_vprint(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "%s", &command->cmd[1]);
win_print(console, '-', 0, NULL, NO_EOL, THEME_WHITE_BOLD, "", "");
int i;
for (i = 0; i < strlen(command->cmd) - 1 ; i++) {
win_print(console, '-', 0, NULL, NO_EOL | NO_DATE, THEME_WHITE_BOLD, "", "-");
}
win_print(console, '-', 0, NULL, NO_DATE, THEME_WHITE_BOLD, "", "");
cons_show("");
win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Synopsis");
ui_show_lines(console, command->help.synopsis);
cons_show("");
win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Description");
win_println(console, 0, command->help.desc);
int maxlen = 0;
for (i = 0; command->help.args[i][0] != NULL; i++) {
if (strlen(command->help.args[i][0]) > maxlen)
maxlen = strlen(command->help.args[i][0]);
}
if (i > 0) {
cons_show("");
win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Arguments");
for (i = 0; command->help.args[i][0] != NULL; i++) {
win_vprint(console, '-', maxlen + 3, NULL, 0, 0, "", "%-*s: %s", maxlen + 1, command->help.args[i][0], command->help.args[i][1]);
}
}
if (g_strv_length((gchar**)command->help.examples) > 0) {
cons_show("");
win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Examples");
ui_show_lines(console, command->help.examples);
}
}
void
cons_bad_cmd_usage(const char * const cmd)
{
GString *msg = g_string_new("");
g_string_printf(msg, "Invalid usage, see '/help %s' for details.", &cmd[1]);
cons_show("");
cons_show(msg->str);
g_string_free(msg, TRUE);
}
void void
cons_show_error(const char * const msg, ...) cons_show_error(const char * const msg, ...)
{ {
@ -113,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, '-', NULL, 0, THEME_ERROR, "", fmt_msg->str); win_print(console, '-', 0, NULL, 0, THEME_ERROR, "", fmt_msg->str);
g_string_free(fmt_msg, TRUE); g_string_free(fmt_msg, TRUE);
va_end(arg); va_end(arg);
@ -136,7 +204,7 @@ cons_show_typing(const char * const barejid)
display_usr = barejid; display_usr = barejid;
} }
win_vprint(console, '-', NULL, 0, THEME_TYPING, "", "!! %s is typing a message...", display_usr); win_vprint(console, '-', 0, NULL, 0, THEME_TYPING, "", "!! %s is typing a message...", display_usr);
cons_alert(); cons_alert();
} }
@ -149,7 +217,7 @@ cons_show_incoming_message(const char * const short_from, const int win_index)
if (ui_index == 10) { if (ui_index == 10) {
ui_index = 0; ui_index = 0;
} }
win_vprint(console, '-', NULL, 0, THEME_INCOMING, "", "<< incoming from %s (%d)", short_from, ui_index); win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< incoming from %s (%d)", short_from, ui_index);
cons_alert(); cons_alert();
} }
@ -167,23 +235,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, '-', NULL, 0, 0, "", "Welcome to Profanity, version %sdev.%s.%s", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION); win_vprint(console, '-', 0, NULL, 0, 0, "", "Welcome to Profanity, version %sdev.%s.%s", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION);
#else #else
win_vprint(console, '-', NULL, 0, 0, "", "Welcome to Profanity, version %sdev", PACKAGE_VERSION); win_vprint(console, '-', 0, NULL, 0, 0, "", "Welcome to Profanity, version %sdev", PACKAGE_VERSION);
#endif #endif
} else { } else {
win_vprint(console, '-', NULL, 0, 0, "", "Welcome to Profanity, version %s", PACKAGE_VERSION); win_vprint(console, '-', 0, NULL, 0, 0, "", "Welcome to Profanity, version %s", PACKAGE_VERSION);
} }
} }
win_vprint(console, '-', NULL, 0, 0, "", "Copyright (C) 2012 - 2015 James Booth <%s>.", PACKAGE_BUGREPORT); win_vprint(console, '-', 0, NULL, 0, 0, "", "Copyright (C) 2012 - 2015 James Booth <%s>.", PACKAGE_BUGREPORT);
win_println(console, "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>"); win_println(console, 0, "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>");
win_println(console, ""); win_println(console, 0, "");
win_println(console, "This is free software; you are free to change and redistribute it."); win_println(console, 0, "This is free software; you are free to change and redistribute it.");
win_println(console, "There is NO WARRANTY, to the extent permitted by law."); win_println(console, 0, "There is NO WARRANTY, to the extent permitted by law.");
win_println(console, ""); win_println(console, 0, "");
win_println(console, "Type '/help' to show complete help."); win_println(console, 0, "Type '/help' to show complete help.");
win_println(console, ""); win_println(console, 0, "");
if (prefs_get_boolean(PREF_VERCHECK)) { if (prefs_get_boolean(PREF_VERCHECK)) {
cons_check_version(FALSE); cons_check_version(FALSE);
@ -205,13 +273,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, '-', NULL, 0, 0, "", "A new version of Profanity is available: %s", latest_release); win_vprint(console, '-', 0, NULL, 0, 0, "", "A new version of Profanity is available: %s", latest_release);
win_println(console, "Check <http://www.profanity.im> for details."); win_println(console, 0, "Check <http://www.profanity.im> for details.");
win_println(console, ""); win_println(console, 0, "");
} else { } else {
if (not_available_msg) { if (not_available_msg) {
win_println(console, "No new version available."); win_println(console, 0, "No new version available.");
win_println(console, ""); win_println(console, 0, "");
} }
} }
@ -225,16 +293,16 @@ void
cons_show_login_success(ProfAccount *account) cons_show_login_success(ProfAccount *account)
{ {
ProfWin *console = wins_get_console(); ProfWin *console = wins_get_console();
win_vprint(console, '-', NULL, NO_EOL, 0, "", "%s logged in successfully, ", account->jid); win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", "%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, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", presence_str); win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", presence_str);
win_vprint(console, '-', NULL, NO_DATE | NO_EOL, 0, "", " (priority %d)", win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " (priority %d)",
accounts_get_priority_for_presence_type(account->name, presence)); accounts_get_priority_for_presence_type(account->name, presence));
win_print(console, '-', NULL, NO_DATE, 0, "", "."); win_print(console, '-', 0, NULL, NO_DATE, 0, "", ".");
cons_alert(); cons_alert();
} }
@ -248,7 +316,7 @@ cons_show_wins(void)
GSList *curr = window_strings; GSList *curr = window_strings;
while (curr) { while (curr) {
win_println(console, curr->data); win_println(console, 0, 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);
@ -294,53 +362,53 @@ 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, '-', NULL, NO_EOL, presence_colour, "", "%s", fulljid); win_vprint(console, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", fulljid);
win_print(console, '-', NULL, NO_DATE, 0, "", ":"); win_print(console, '-', 0, NULL, NO_DATE, 0, "", ":");
// show identity // show identity
if (caps->category || caps->type || caps->name) { if (caps->category || caps->type || caps->name) {
win_print(console, '-', NULL, NO_EOL, 0, "", "Identity: "); win_print(console, '-', 0, NULL, NO_EOL, 0, "", "Identity: ");
if (caps->name) { if (caps->name) {
win_print(console, '-', NULL, NO_DATE | NO_EOL, 0, "", caps->name); win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->name);
if (caps->category || caps->type) { if (caps->category || caps->type) {
win_print(console, '-', NULL, NO_DATE | NO_EOL, 0, "", " "); win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " ");
} }
} }
if (caps->type) { if (caps->type) {
win_print(console, '-', NULL, NO_DATE | NO_EOL, 0, "", caps->type); win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->type);
if (caps->category) { if (caps->category) {
win_print(console, '-', NULL, NO_DATE | NO_EOL, 0, "", " "); win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " ");
} }
} }
if (caps->category) { if (caps->category) {
win_print(console, '-', NULL, NO_DATE | NO_EOL, 0, "", caps->category); win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->category);
} }
win_newline(console); win_newline(console);
} }
if (caps->software) { if (caps->software) {
win_vprint(console, '-', NULL, NO_EOL, 0, "", "Software: %s", caps->software); win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", "Software: %s", caps->software);
} }
if (caps->software_version) { if (caps->software_version) {
win_vprint(console, '-', NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->software_version); win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->software_version);
} }
if (caps->software || caps->software_version) { if (caps->software || caps->software_version) {
win_newline(console); win_newline(console);
} }
if (caps->os) { if (caps->os) {
win_vprint(console, '-', NULL, NO_EOL, 0, "", "OS: %s", caps->os); win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", "OS: %s", caps->os);
} }
if (caps->os_version) { if (caps->os_version) {
win_vprint(console, '-', NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->os_version); win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->os_version);
} }
if (caps->os || caps->os_version) { if (caps->os || caps->os_version) {
win_newline(console); win_newline(console);
} }
if (caps->features) { if (caps->features) {
win_println(console, "Features:"); win_println(console, 0, "Features:");
GSList *feature = caps->features; GSList *feature = caps->features;
while (feature) { while (feature) {
win_vprint(console, '-', NULL, 0, 0, "", " %s", feature->data); win_vprint(console, '-', 0, NULL, 0, 0, "", " %s", feature->data);
feature = g_slist_next(feature); feature = g_slist_next(feature);
} }
} }
@ -361,8 +429,8 @@ cons_show_software_version(const char * const jid, const char * const presence,
if (name || version || os) { if (name || version || os) {
cons_show(""); cons_show("");
theme_item_t presence_colour = theme_main_presence_attrs(presence); theme_item_t presence_colour = theme_main_presence_attrs(presence);
win_vprint(console, '-', NULL, NO_EOL, presence_colour, "", "%s", jid); win_vprint(console, '-', 0, NULL, NO_EOL, presence_colour, "", "%s", jid);
win_print(console, '-', NULL, NO_DATE, 0, "", ":"); win_print(console, '-', 0, NULL, NO_DATE, 0, "", ":");
} }
if (name) { if (name) {
cons_show("Name : %s", name); cons_show("Name : %s", name);
@ -426,9 +494,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, '-', NULL, NO_EOL, 0, "", " %s", room->jid); win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", " %s", room->jid);
if (room->name) { if (room->name) {
win_vprint(console, '-', NULL, NO_DATE | NO_EOL, 0, "", ", (%s)", room->name); win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", (%s)", room->name);
} }
win_newline(console); win_newline(console);
rooms = g_slist_next(rooms); rooms = g_slist_next(rooms);
@ -460,21 +528,21 @@ cons_show_bookmarks(const GList *list)
if (muc_active(item->jid)) { if (muc_active(item->jid)) {
presence_colour = THEME_ONLINE; presence_colour = THEME_ONLINE;
} }
win_vprint(console, '-', NULL, NO_EOL, presence_colour, "", " %s", item->jid); win_vprint(console, '-', 0, NULL, NO_EOL, presence_colour, "", " %s", item->jid);
if (item->nick) { if (item->nick) {
win_vprint(console, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", "/%s", item->nick); win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "/%s", item->nick);
} }
if (item->autojoin) { if (item->autojoin) {
win_print(console, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", " (autojoin)"); win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (autojoin)");
} }
if (item->password) { if (item->password) {
win_print(console, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", " (private)"); win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (private)");
} }
if (muc_active(item->jid)) { if (muc_active(item->jid)) {
ProfWin *roomwin = (ProfWin*)wins_get_muc(item->jid); ProfWin *roomwin = (ProfWin*)wins_get_muc(item->jid);
if (roomwin) { if (roomwin) {
int num = wins_get_num(roomwin); int num = wins_get_num(roomwin);
win_vprint(console, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", " (%d)", num); win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (%d)", num);
} }
} }
win_newline(console); win_newline(console);
@ -535,11 +603,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, '-', NULL, NO_EOL, 0, "", " %s", item->jid); win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", " %s", item->jid);
if (item->name) { if (item->name) {
win_vprint(console, '-', NULL, NO_DATE | NO_EOL, 0, "", ", (%s)", item->name); win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", (%s)", item->name);
} }
win_vprint(console, '-', NULL, NO_DATE, 0, "", ""); win_vprint(console, '-', 0, NULL, NO_DATE, 0, "", "");
items = g_slist_next(items); items = g_slist_next(items);
} }
} else { } else {
@ -614,7 +682,7 @@ cons_show_account_list(gchar **accounts)
(g_strcmp0(jabber_get_account_name(), accounts[i]) == 0)) { (g_strcmp0(jabber_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, '-', NULL, 0, presence_colour, "", "%s", accounts[i]); win_vprint(console, '-', 0, NULL, 0, presence_colour, "", "%s", accounts[i]);
} else { } else {
cons_show(accounts[i]); cons_show(accounts[i]);
} }
@ -725,7 +793,7 @@ cons_show_account(ProfAccount *account)
GList *curr = resources; GList *curr = resources;
if (curr) { if (curr) {
win_println(console, "Resources:"); win_println(console, 0, "Resources:");
// sort in order of availability // sort in order of availability
while (curr) { while (curr) {
@ -743,12 +811,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, '-', NULL, NO_EOL, presence_colour, "", " %s (%d), %s", resource->name, resource->priority, resource_presence); win_vprint(console, '-', 0, NULL, NO_EOL, presence_colour, "", " %s (%d), %s", resource->name, resource->priority, resource_presence);
if (resource->status) { if (resource->status) {
win_vprint(console, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", resource->status); win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", resource->status);
} }
win_vprint(console, '-', NULL, NO_DATE, 0, "", ""); win_vprint(console, '-', 0, NULL, NO_DATE, 0, "", "");
Jid *jidp = jid_create_from_bare_and_resource(account->jid, resource->name); Jid *jidp = jid_create_from_bare_and_resource(account->jid, resource->name);
Capabilities *caps = caps_lookup(jidp->fulljid); Capabilities *caps = caps_lookup(jidp->fulljid);
jid_destroy(jidp); jid_destroy(jidp);
@ -756,38 +824,38 @@ cons_show_account(ProfAccount *account)
if (caps) { if (caps) {
// show identity // show identity
if (caps->category || caps->type || caps->name) { if (caps->category || caps->type || caps->name) {
win_print(console, '-', NULL, NO_EOL, 0, "", " Identity: "); win_print(console, '-', 0, NULL, NO_EOL, 0, "", " Identity: ");
if (caps->name) { if (caps->name) {
win_print(console, '-', NULL, NO_DATE | NO_EOL, 0, "", caps->name); win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->name);
if (caps->category || caps->type) { if (caps->category || caps->type) {
win_print(console, '-', NULL, NO_DATE | NO_EOL, 0, "", " "); win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " ");
} }
} }
if (caps->type) { if (caps->type) {
win_print(console, '-', NULL, NO_DATE | NO_EOL, 0, "", caps->type); win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->type);
if (caps->category) { if (caps->category) {
win_print(console, '-', NULL, NO_DATE | NO_EOL, 0, "", " "); win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " ");
} }
} }
if (caps->category) { if (caps->category) {
win_print(console, '-', NULL, NO_DATE | NO_EOL, 0, "", caps->category); win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->category);
} }
win_newline(console); win_newline(console);
} }
if (caps->software) { if (caps->software) {
win_vprint(console, '-', NULL, NO_EOL, 0, "", " Software: %s", caps->software); win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", " Software: %s", caps->software);
} }
if (caps->software_version) { if (caps->software_version) {
win_vprint(console, '-', NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->software_version); win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->software_version);
} }
if (caps->software || caps->software_version) { if (caps->software || caps->software_version) {
win_newline(console); win_newline(console);
} }
if (caps->os) { if (caps->os) {
win_vprint(console, '-', NULL, NO_EOL, 0, "", " OS: %s", caps->os); win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", " OS: %s", caps->os);
} }
if (caps->os_version) { if (caps->os_version) {
win_vprint(console, '-', NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->os_version); win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->os_version);
} }
if (caps->os || caps->os_version) { if (caps->os || caps->os_version) {
win_newline(console); win_newline(console);
@ -1476,19 +1544,21 @@ cons_prefs(void)
void void
cons_help(void) cons_help(void)
{ {
int pad = strlen("/help commands connection") + 3;
cons_show(""); cons_show("");
cons_show("Choose a help option:"); cons_show("Choose a help option:");
cons_show(""); cons_show("");
cons_show("/help commands - List all commands."); cons_show_padded(pad, "/help commands : List all commands.");
cons_show("/help basic - List basic commands for getting started."); cons_show_padded(pad, "/help commands chat : List chat commands.");
cons_show("/help chatting - List chat commands."); cons_show_padded(pad, "/help commands groupchat : List groupchat commands.");
cons_show("/help groupchat - List groupchat commands."); cons_show_padded(pad, "/help commands roster : List commands for manipulating your roster.");
cons_show("/help presences - List commands to change presence."); cons_show_padded(pad, "/help commands presence : List commands to change your presence.");
cons_show("/help contacts - List commands for manipulating your roster."); cons_show_padded(pad, "/help commands discovery : List service discovery commands.");
cons_show("/help service - List service discovery commands."); cons_show_padded(pad, "/help commands connection : List commands related to managing your connection.");
cons_show("/help settings - List commands for changing settings."); cons_show_padded(pad, "/help commands ui : List commands for manipulating the user interface.");
cons_show("/help navigation - How to navigate around Profanity."); cons_show_padded(pad, "/help [command] : Detailed help on a specific command.");
cons_show("/help [command] - Detailed help on a specific command."); cons_show_padded(pad, "/help navigation : How to navigate around Profanity.");
cons_show(""); cons_show("");
cons_alert(); cons_alert();
@ -1497,13 +1567,14 @@ cons_help(void)
void void
cons_navigation_help(void) cons_navigation_help(void)
{ {
int pad = strlen("Alt-PAGEUP, Alt-PAGEDOWN") + 3;
ProfWin *console = wins_get_console();
cons_show(""); cons_show("");
cons_show("Navigation:"); win_print(console, '-', 0, NULL, 0, THEME_WHITE_BOLD, "", "Navigation");
cons_show(""); cons_show_padded(pad, "Alt-1..Alt-0, F1..F10 : Choose window.");
cons_show("Alt-1..Alt-0, F1..F10 : Choose window."); cons_show_padded(pad, "Alt-LEFT, Alt-RIGHT : Previous/next chat window");
cons_show("Alt-LEFT, Alt-RIGHT : Previous/next chat window"); cons_show_padded(pad, "PAGEUP, PAGEDOWN : Page the main window.");
cons_show("PAGEUP, PAGEDOWN : Page the main window."); cons_show_padded(pad, "Alt-PAGEUP, Alt-PAGEDOWN : Page occupants/roster panel.");
cons_show("Alt-PAGEUP, Alt-PAGEDOWN : Page occupants/roster panel.");
cons_show(""); cons_show("");
cons_alert(); cons_alert();
@ -1604,22 +1675,22 @@ cons_theme_colours(void)
ProfWin *console = wins_get_console(); ProfWin *console = wins_get_console();
cons_show("Theme colours:"); cons_show("Theme colours:");
win_print(console, '-', NULL, NO_EOL, THEME_WHITE, "", " white "); win_print(console, '-', 0, NULL, NO_EOL, THEME_WHITE, "", " white ");
win_print(console, '-', NULL, NO_DATE, THEME_WHITE_BOLD, "", " bold_white"); win_print(console, '-', 0, NULL, NO_DATE, THEME_WHITE_BOLD, "", " bold_white");
win_print(console, '-', NULL, NO_EOL, THEME_GREEN, "", " green "); win_print(console, '-', 0, NULL, NO_EOL, THEME_GREEN, "", " green ");
win_print(console, '-', NULL, NO_DATE, THEME_GREEN_BOLD, "", " bold_green"); win_print(console, '-', 0, NULL, NO_DATE, THEME_GREEN_BOLD, "", " bold_green");
win_print(console, '-', NULL, NO_EOL, THEME_RED, "", " red "); win_print(console, '-', 0, NULL, NO_EOL, THEME_RED, "", " red ");
win_print(console, '-', NULL, NO_DATE, THEME_RED_BOLD, "", " bold_red"); win_print(console, '-', 0, NULL, NO_DATE, THEME_RED_BOLD, "", " bold_red");
win_print(console, '-', NULL, NO_EOL, THEME_YELLOW, "", " yellow "); win_print(console, '-', 0, NULL, NO_EOL, THEME_YELLOW, "", " yellow ");
win_print(console, '-', NULL, NO_DATE, THEME_YELLOW_BOLD, "", " bold_yellow"); win_print(console, '-', 0, NULL, NO_DATE, THEME_YELLOW_BOLD, "", " bold_yellow");
win_print(console, '-', NULL, NO_EOL, THEME_BLUE, "", " blue "); win_print(console, '-', 0, NULL, NO_EOL, THEME_BLUE, "", " blue ");
win_print(console, '-', NULL, NO_DATE, THEME_BLUE_BOLD, "", " bold_blue"); win_print(console, '-', 0, NULL, NO_DATE, THEME_BLUE_BOLD, "", " bold_blue");
win_print(console, '-', NULL, NO_EOL, THEME_CYAN, "", " cyan "); win_print(console, '-', 0, NULL, NO_EOL, THEME_CYAN, "", " cyan ");
win_print(console, '-', NULL, NO_DATE, THEME_CYAN_BOLD, "", " bold_cyan"); win_print(console, '-', 0, NULL, NO_DATE, THEME_CYAN_BOLD, "", " bold_cyan");
win_print(console, '-', NULL, NO_EOL, THEME_MAGENTA, "", " magenta "); win_print(console, '-', 0, NULL, NO_EOL, THEME_MAGENTA, "", " magenta ");
win_print(console, '-', NULL, NO_DATE, THEME_MAGENTA_BOLD, "", " bold_magenta"); win_print(console, '-', 0, NULL, NO_DATE, THEME_MAGENTA_BOLD, "", " bold_magenta");
win_print(console, '-', NULL, NO_EOL, THEME_BLACK, "", " black "); win_print(console, '-', 0, NULL, NO_EOL, THEME_BLACK, "", " black ");
win_print(console, '-', NULL, NO_DATE, THEME_BLACK_BOLD, "", " bold_black"); win_print(console, '-', 0, NULL, NO_DATE, THEME_BLACK_BOLD, "", " bold_black");
cons_show(""); cons_show("");
} }
@ -1627,25 +1698,25 @@ static void
_cons_splash_logo(void) _cons_splash_logo(void)
{ {
ProfWin *console = wins_get_console(); ProfWin *console = wins_get_console();
win_println(console, "Welcome to"); win_println(console, 0, "Welcome to");
win_print(console, '-', NULL, 0, THEME_SPLASH, "", " ___ _ "); win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", " ___ _ ");
win_print(console, '-', NULL, 0, THEME_SPLASH, "", " / __) (_)_ "); win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", " / __) (_)_ ");
win_print(console, '-', NULL, 0, THEME_SPLASH, "", " ____ ____ ___ | |__ ____ ____ _| |_ _ _ "); win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", " ____ ____ ___ | |__ ____ ____ _| |_ _ _ ");
win_print(console, '-', NULL, 0, THEME_SPLASH, "", "| _ \\ / ___) _ \\| __) _ | _ \\| | _) | | |"); win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", "| _ \\ / ___) _ \\| __) _ | _ \\| | _) | | |");
win_print(console, '-', NULL, 0, THEME_SPLASH, "", "| | | | | | |_| | | ( ( | | | | | | |_| |_| |"); win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", "| | | | | | |_| | | ( ( | | | | | | |_| |_| |");
win_print(console, '-', NULL, 0, THEME_SPLASH, "", "| ||_/|_| \\___/|_| \\_||_|_| |_|_|\\___)__ |"); win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", "| ||_/|_| \\___/|_| \\_||_|_| |_|_|\\___)__ |");
win_print(console, '-', NULL, 0, THEME_SPLASH, "", "|_| (____/ "); win_print(console, '-', 0, NULL, 0, THEME_SPLASH, "", "|_| (____/ ");
win_print(console, '-', NULL, 0, THEME_SPLASH, "", ""); win_print(console, '-', 0, NULL, 0, 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, '-', NULL, 0, 0, "", "Version %sdev.%s.%s", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION); win_vprint(console, '-', 0, NULL, 0, 0, "", "Version %sdev.%s.%s", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION);
#else #else
win_vprint(console, '-', NULL, 0, 0, "", "Version %sdev", PACKAGE_VERSION); win_vprint(console, '-', 0, NULL, 0, 0, "", "Version %sdev", PACKAGE_VERSION);
#endif #endif
} else { } else {
win_vprint(console, '-', NULL, 0, 0, "", "Version %s", PACKAGE_VERSION); win_vprint(console, '-', 0, NULL, 0, 0, "", "Version %s", PACKAGE_VERSION);
} }
} }
@ -1672,11 +1743,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, '-', NULL, NO_EOL, presence_colour, "", title->str); win_vprint(console, '-', 0, NULL, NO_EOL, presence_colour, "", title->str);
g_string_free(title, TRUE); g_string_free(title, TRUE);
win_print(console, '-', NULL, NO_DATE | NO_EOL, 0, "", " - "); win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " - ");
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)) {
@ -1692,9 +1763,9 @@ _show_roster_contacts(GSList *list, gboolean show_groups)
} }
if (show_groups) { if (show_groups) {
win_vprint(console, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", sub->str); win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", "%s", sub->str);
} else { } else {
win_vprint(console, '-', NULL, NO_DATE, presence_colour, "", "%s", sub->str); win_vprint(console, '-', 0, NULL, NO_DATE, presence_colour, "", "%s", sub->str);
} }
g_string_free(sub, TRUE); g_string_free(sub, TRUE);
@ -1710,10 +1781,10 @@ _show_roster_contacts(GSList *list, gboolean show_groups)
} }
groups = g_slist_next(groups); groups = g_slist_next(groups);
} }
win_vprint(console, '-', NULL, NO_DATE, 0, "", "%s", groups_str->str); win_vprint(console, '-', 0, NULL, NO_DATE, 0, "", "%s", groups_str->str);
g_string_free(groups_str, TRUE); g_string_free(groups_str, TRUE);
} else { } else {
win_print(console, '-', NULL, NO_DATE, 0, "", " "); win_print(console, '-', 0, NULL, NO_DATE, 0, "", " ");
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -35,6 +35,7 @@
#ifndef UI_UI_H #ifndef UI_UI_H
#define UI_UI_H #define UI_UI_H
#include "command/commands.h"
#include "ui/win_types.h" #include "ui/win_types.h"
#include "muc.h" #include "muc.h"
@ -227,7 +228,7 @@ void ui_input_clear(void);
void ui_input_nonblocking(gboolean); void ui_input_nonblocking(gboolean);
void ui_write(char *line, int offset); void ui_write(char *line, int offset);
void ui_invalid_command_usage(const char * const usage, void (*setting_func)(void)); void ui_invalid_command_usage(const char * const cmd, void (*setting_func)(void));
void ui_create_xmlconsole_win(void); void ui_create_xmlconsole_win(void);
gboolean ui_xmlconsole_exists(void); gboolean ui_xmlconsole_exists(void);
@ -239,8 +240,11 @@ void ui_inp_history_append(char *inp);
// console window actions // console window actions
void cons_show(const char * const msg, ...); void cons_show(const char * const msg, ...);
void cons_show_padded(int pad, const char * const msg, ...);
void cons_about(void); void cons_about(void);
void cons_help(void); void cons_help(void);
void cons_show_help(Command *command);
void cons_bad_cmd_usage(const char * const cmd);
void cons_navigation_help(void); void cons_navigation_help(void);
void cons_prefs(void); void cons_prefs(void);
void cons_show_ui_prefs(void); void cons_show_ui_prefs(void);
@ -349,14 +353,14 @@ 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, GDateTime *timestamp, int flags, theme_item_t theme_item, const char * const from, const char * const message); 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, 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, ...);
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, const char * const message); void win_println(ProfWin *window, int pad, const char * const message);
// desktop notifier actions // desktop notifier actions
void notifier_initialise(void); void notifier_initialise(void);

View File

@ -59,9 +59,9 @@
#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_print(ProfWin *window, const char show_char, 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); static void _win_print_wrapped(WINDOW *win, const char * const message, size_t indent, int pad_indent);
int int
win_roster_cols(void) win_roster_cols(void)
@ -577,14 +577,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, '-', NULL, NO_EOL, presence_colour, "", occupant->nick); win_print(window, '-', 0, NULL, NO_EOL, presence_colour, "", occupant->nick);
win_vprint(window, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str); win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str);
if (occupant->status) { if (occupant->status) {
win_vprint(window, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", occupant->status); win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", occupant->status);
} }
win_print(window, '-', NULL, NO_DATE, presence_colour, "", ""); win_print(window, '-', 0, NULL, NO_DATE, presence_colour, "", "");
} }
void void
@ -599,12 +599,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, '-', NULL, NO_EOL, presence_colour, "", name); win_print(window, '-', 0, NULL, NO_EOL, presence_colour, "", name);
} else { } else {
win_print(window, '-', NULL, NO_EOL, presence_colour, "", barejid); win_print(window, '-', 0, NULL, NO_EOL, presence_colour, "", barejid);
} }
win_vprint(window, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence); win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, 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();
@ -617,18 +617,18 @@ 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, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", ", idle %dh%dm%ds", hours, minutes, seconds); win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", idle %dh%dm%ds", hours, minutes, seconds);
} }
else { else {
win_vprint(window, '-', NULL, NO_DATE | NO_EOL, 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, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", p_contact_status(contact)); win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", p_contact_status(contact));
} }
win_print(window, '-', NULL, NO_DATE, presence_colour, "", ""); win_print(window, '-', 0, NULL, NO_DATE, presence_colour, "", "");
} }
void void
@ -640,21 +640,21 @@ win_show_occupant_info(ProfWin *window, const char * const room, Occupant *occup
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, '!', NULL, NO_EOL, presence_colour, "", occupant->nick); win_print(window, '!', 0, NULL, NO_EOL, presence_colour, "", occupant->nick);
win_vprint(window, '!', NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str); win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str);
if (occupant->status) { if (occupant->status) {
win_vprint(window, '!', NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", occupant->status); win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", occupant->status);
} }
win_newline(window); win_newline(window);
if (occupant->jid) { if (occupant->jid) {
win_vprint(window, '!', NULL, 0, 0, "", " Jid: %s", occupant->jid); win_vprint(window, '!', 0, NULL, 0, 0, "", " Jid: %s", occupant->jid);
} }
win_vprint(window, '!', NULL, 0, 0, "", " Affiliation: %s", occupant_affiliation); win_vprint(window, '!', 0, NULL, 0, 0, "", " Affiliation: %s", occupant_affiliation);
win_vprint(window, '!', NULL, 0, 0, "", " Role: %s", occupant_role); win_vprint(window, '!', 0, NULL, 0, 0, "", " 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);
Capabilities *caps = caps_lookup(jidp->fulljid); Capabilities *caps = caps_lookup(jidp->fulljid);
@ -663,38 +663,38 @@ win_show_occupant_info(ProfWin *window, const char * const room, Occupant *occup
if (caps) { if (caps) {
// show identity // show identity
if (caps->category || caps->type || caps->name) { if (caps->category || caps->type || caps->name) {
win_print(window, '!', NULL, NO_EOL, 0, "", " Identity: "); win_print(window, '!', 0, NULL, NO_EOL, 0, "", " Identity: ");
if (caps->name) { if (caps->name) {
win_print(window, '!', NULL, NO_DATE | NO_EOL, 0, "", caps->name); win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->name);
if (caps->category || caps->type) { if (caps->category || caps->type) {
win_print(window, '-', NULL, NO_DATE | NO_EOL, 0, "", " "); win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " ");
} }
} }
if (caps->type) { if (caps->type) {
win_print(window, '!', NULL, NO_DATE | NO_EOL, 0, "", caps->type); win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->type);
if (caps->category) { if (caps->category) {
win_print(window, '!', NULL, NO_DATE | NO_EOL, 0, "", " "); win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", " ");
} }
} }
if (caps->category) { if (caps->category) {
win_print(window, '!', NULL, NO_DATE | NO_EOL, 0, "", caps->category); win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->category);
} }
win_newline(window); win_newline(window);
} }
if (caps->software) { if (caps->software) {
win_vprint(window, '!', NULL, NO_EOL, 0, "", " Software: %s", caps->software); win_vprint(window, '!', 0, NULL, NO_EOL, 0, "", " Software: %s", caps->software);
} }
if (caps->software_version) { if (caps->software_version) {
win_vprint(window, '!', NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->software_version); win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->software_version);
} }
if (caps->software || caps->software_version) { if (caps->software || caps->software_version) {
win_newline(window); win_newline(window);
} }
if (caps->os) { if (caps->os) {
win_vprint(window, '!', NULL, NO_EOL, 0, "", " OS: %s", caps->os); win_vprint(window, '!', 0, NULL, NO_EOL, 0, "", " OS: %s", caps->os);
} }
if (caps->os_version) { if (caps->os_version) {
win_vprint(window, '!', NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->os_version); win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->os_version);
} }
if (caps->os || caps->os_version) { if (caps->os || caps->os_version) {
win_newline(window); win_newline(window);
@ -702,7 +702,7 @@ win_show_occupant_info(ProfWin *window, const char * const room, Occupant *occup
caps_destroy(caps); caps_destroy(caps);
} }
win_print(window, '-', NULL, 0, 0, "", ""); win_print(window, '-', 0, NULL, 0, 0, "", "");
} }
void void
@ -716,15 +716,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, '-', NULL, 0, 0, "", ""); win_print(window, '-', 0, NULL, 0, 0, "", "");
win_print(window, '-', NULL, NO_EOL, presence_colour, "", barejid); win_print(window, '-', 0, NULL, NO_EOL, presence_colour, "", barejid);
if (name) { if (name) {
win_vprint(window, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", " (%s)", name); win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " (%s)", name);
} }
win_print(window, '-', NULL, NO_DATE, 0, "", ":"); win_print(window, '-', 0, NULL, NO_DATE, 0, "", ":");
if (sub) { if (sub) {
win_vprint(window, '-', NULL, 0, 0, "", "Subscription: %s", sub); win_vprint(window, '-', 0, NULL, 0, 0, "", "Subscription: %s", sub);
} }
if (last_activity) { if (last_activity) {
@ -738,10 +738,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, '-', NULL, 0, 0, "", "Last activity: %dh%dm%ds", hours, minutes, seconds); win_vprint(window, '-', 0, NULL, 0, 0, "", "Last activity: %dh%dm%ds", hours, minutes, seconds);
} }
else { else {
win_vprint(window, '-', NULL, 0, 0, "", "Last activity: %dm%ds", minutes, seconds); win_vprint(window, '-', 0, NULL, 0, 0, "", "Last activity: %dm%ds", minutes, seconds);
} }
g_date_time_unref(now); g_date_time_unref(now);
@ -750,7 +750,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, '-', NULL, 0, 0, "", "Resources:"); win_print(window, '-', 0, NULL, 0, 0, "", "Resources:");
// sort in order of availability // sort in order of availability
GList *curr = resources; GList *curr = resources;
@ -768,9 +768,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, '-', NULL, NO_EOL, presence_colour, "", " %s (%d), %s", resource->name, resource->priority, resource_presence); win_vprint(window, '-', 0, NULL, NO_EOL, presence_colour, "", " %s (%d), %s", resource->name, resource->priority, resource_presence);
if (resource->status) { if (resource->status) {
win_vprint(window, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", resource->status); win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", resource->status);
} }
win_newline(window); win_newline(window);
@ -781,38 +781,38 @@ win_show_info(ProfWin *window, PContact contact)
if (caps) { if (caps) {
// show identity // show identity
if (caps->category || caps->type || caps->name) { if (caps->category || caps->type || caps->name) {
win_print(window, '-', NULL, NO_EOL, 0, "", " Identity: "); win_print(window, '-', 0, NULL, NO_EOL, 0, "", " Identity: ");
if (caps->name) { if (caps->name) {
win_print(window, '-', NULL, NO_DATE | NO_EOL, 0, "", caps->name); win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->name);
if (caps->category || caps->type) { if (caps->category || caps->type) {
win_print(window, '-', NULL, NO_DATE | NO_EOL, 0, "", " "); win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " ");
} }
} }
if (caps->type) { if (caps->type) {
win_print(window, '-', NULL, NO_DATE | NO_EOL, 0, "", caps->type); win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->type);
if (caps->category) { if (caps->category) {
win_print(window, '-', NULL, NO_DATE | NO_EOL, 0, "", " "); win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " ");
} }
} }
if (caps->category) { if (caps->category) {
win_print(window, '-', NULL, NO_DATE | NO_EOL, 0, "", caps->category); win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->category);
} }
win_newline(window); win_newline(window);
} }
if (caps->software) { if (caps->software) {
win_vprint(window, '-', NULL, NO_EOL, 0, "", " Software: %s", caps->software); win_vprint(window, '-', 0, NULL, NO_EOL, 0, "", " Software: %s", caps->software);
} }
if (caps->software_version) { if (caps->software_version) {
win_vprint(window, '-', NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->software_version); win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->software_version);
} }
if (caps->software || caps->software_version) { if (caps->software || caps->software_version) {
win_newline(window); win_newline(window);
} }
if (caps->os) { if (caps->os) {
win_vprint(window, '-', NULL, NO_EOL, 0, "", " OS: %s", caps->os); win_vprint(window, '-', 0, NULL, NO_EOL, 0, "", " OS: %s", caps->os);
} }
if (caps->os_version) { if (caps->os_version) {
win_vprint(window, '-', NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->os_version); win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->os_version);
} }
if (caps->os || caps->os_version) { if (caps->os || caps->os_version) {
win_newline(window); win_newline(window);
@ -842,12 +842,12 @@ win_show_status_string(ProfWin *window, const char * const from,
} }
win_vprint(window, '-', NULL, NO_EOL, 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, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", show); win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", show);
else else
win_vprint(window, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", default_show); win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", default_show);
if (last_activity) { if (last_activity) {
GDateTime *now = g_date_time_new_now_local(); GDateTime *now = g_date_time_new_now_local();
@ -861,17 +861,17 @@ win_show_status_string(ProfWin *window, const char * const from,
int seconds = span / G_TIME_SPAN_SECOND; int seconds = span / G_TIME_SPAN_SECOND;
if (hours > 0) { if (hours > 0) {
win_vprint(window, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", ", idle %dh%dm%ds", hours, minutes, seconds); win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", idle %dh%dm%ds", hours, minutes, seconds);
} }
else { else {
win_vprint(window, '-', NULL, NO_DATE | NO_EOL, 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, '-', NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", status); win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", status);
win_print(window, '-', NULL, NO_DATE, presence_colour, "", ""); win_print(window, '-', 0, NULL, NO_DATE, presence_colour, "", "");
} }
@ -883,7 +883,7 @@ win_print_incoming_message(ProfWin *window, GDateTime *timestamp,
{ {
case WIN_CHAT: case WIN_CHAT:
case WIN_PRIVATE: case WIN_PRIVATE:
win_print(window, '-', timestamp, NO_ME, THEME_TEXT_THEM, from, message); win_print(window, '-', 0, timestamp, NO_ME, THEME_TEXT_THEM, from, message);
break; break;
default: default:
assert(FALSE); assert(FALSE);
@ -892,31 +892,31 @@ win_print_incoming_message(ProfWin *window, GDateTime *timestamp,
} }
void void
win_vprint(ProfWin *window, const char show_char, GDateTime *timestamp, 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, ...) int flags, theme_item_t theme_item, const char * const from, const char * const message, ...)
{ {
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, timestamp, flags, theme_item, from, fmt_msg->str); win_print(window, show_char, pad_indent, timestamp, flags, theme_item, from, fmt_msg->str);
g_string_free(fmt_msg, TRUE); g_string_free(fmt_msg, TRUE);
} }
void void
win_print(ProfWin *window, const char show_char, GDateTime *timestamp, 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) 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(); if (timestamp == NULL) timestamp = g_date_time_new_now_local();
buffer_push(window->layout->buffer, show_char, timestamp, flags, theme_item, from, message, NULL); buffer_push(window->layout->buffer, show_char, pad_indent, timestamp, flags, theme_item, from, message, NULL);
_win_print(window, show_char, timestamp, flags, theme_item, from, message, NULL); _win_print(window, show_char, pad_indent, timestamp, flags, theme_item, from, message, NULL);
// 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
ui_input_nonblocking(TRUE); ui_input_nonblocking(TRUE);
} }
void void
win_print_with_receipt(ProfWin *window, const char show_char, GTimeVal *tstamp, win_print_with_receipt(ProfWin *window, const char show_char, int pad_indent, GTimeVal *tstamp,
int flags, theme_item_t theme_item, const char * const from, const char * const message, char *id) int flags, theme_item_t theme_item, const char * const from, const char * const message, char *id)
{ {
GDateTime *time; GDateTime *time;
@ -931,8 +931,8 @@ win_print_with_receipt(ProfWin *window, const char show_char, GTimeVal *tstamp,
receipt->id = strdup(id); receipt->id = strdup(id);
receipt->received = FALSE; receipt->received = FALSE;
buffer_push(window->layout->buffer, show_char, time, flags, theme_item, from, message, receipt); buffer_push(window->layout->buffer, show_char, pad_indent, time, flags, theme_item, from, message, receipt);
_win_print(window, show_char, time, flags, theme_item, from, message, receipt); _win_print(window, show_char, pad_indent, time, flags, theme_item, 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
ui_input_nonblocking(TRUE); ui_input_nonblocking(TRUE);
} }
@ -947,19 +947,19 @@ win_mark_received(ProfWin *window, const char * const id)
} }
void void
win_println(ProfWin *window, const char * const message) win_println(ProfWin *window, int pad, const char * const message)
{ {
win_print(window, '-', NULL, 0, 0, "", message); win_print(window, '-', pad, NULL, 0, 0, "", message);
} }
void void
win_newline(ProfWin *window) win_newline(ProfWin *window)
{ {
win_print(window, '-', NULL, NO_DATE, 0, "", ""); win_print(window, '-', 0, NULL, NO_DATE, 0, "", "");
} }
static void static void
_win_print(ProfWin *window, const char show_char, 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)
{ {
// flags : 1st bit = 0/1 - me/not me // flags : 1st bit = 0/1 - me/not me
@ -1028,14 +1028,17 @@ _win_print(ProfWin *window, const char show_char, GDateTime *time,
} }
if (prefs_get_boolean(PREF_WRAP)) { if (prefs_get_boolean(PREF_WRAP)) {
_win_print_wrapped(window->layout->win, message+offset, indent); _win_print_wrapped(window->layout->win, message+offset, indent, pad_indent);
} else { } else {
wprintw(window->layout->win, "%s", message+offset); wprintw(window->layout->win, "%s", message+offset);
} }
if ((flags & NO_EOL) == 0) { if ((flags & NO_EOL) == 0) {
int curx = getcurx(window->layout->win);
if (curx != 0) {
wprintw(window->layout->win, "\n"); wprintw(window->layout->win, "\n");
} }
}
if (me_message) { if (me_message) {
wattroff(window->layout->win, colour); wattroff(window->layout->win, colour);
@ -1058,24 +1061,31 @@ _win_indent(WINDOW *win, int size)
} }
static void static void
_win_print_wrapped(WINDOW *win, const char * const message, size_t indent) _win_print_wrapped(WINDOW *win, const char * const message, size_t indent, int pad_indent)
{ {
int starty = getcury(win);
int wordi = 0; int wordi = 0;
char *word = malloc(strlen(message) + 1); char *word = malloc(strlen(message) + 1);
gchar *curr_ch = g_utf8_offset_to_pointer(message, 0); gchar *curr_ch = g_utf8_offset_to_pointer(message, 0);
while (*curr_ch != '\0') { while (*curr_ch != '\0') {
// handle space
if (*curr_ch == ' ') { if (*curr_ch == ' ') {
waddch(win, ' '); waddch(win, ' ');
curr_ch = g_utf8_next_char(curr_ch); curr_ch = g_utf8_next_char(curr_ch);
// handle newline
} else if (*curr_ch == '\n') { } else if (*curr_ch == '\n') {
waddch(win, '\n'); waddch(win, '\n');
_win_indent(win, indent); _win_indent(win, indent + pad_indent);
curr_ch = g_utf8_next_char(curr_ch); curr_ch = g_utf8_next_char(curr_ch);
// handle word
} else { } else {
// get word
wordi = 0; wordi = 0;
int wordlen = 0;
while (*curr_ch != ' ' && *curr_ch != '\n' && *curr_ch != '\0') { while (*curr_ch != ' ' && *curr_ch != '\n' && *curr_ch != '\0') {
size_t ch_len = mbrlen(curr_ch, 4, NULL); size_t ch_len = mbrlen(curr_ch, 4, NULL);
int offset = 0; int offset = 0;
@ -1085,40 +1095,77 @@ _win_print_wrapped(WINDOW *win, const char * const message, size_t indent)
curr_ch = g_utf8_next_char(curr_ch); curr_ch = g_utf8_next_char(curr_ch);
} }
word[wordi] = '\0'; word[wordi] = '\0';
wordlen = utf8_display_len(word);
int curx = getcurx(win); int curx = getcurx(win);
int cury = getcury(win);
int maxx = getmaxx(win); int maxx = getmaxx(win);
// wrap required
if (curx + wordlen > maxx) {
int linelen = maxx - (indent + pad_indent);
// word larger than line // word larger than line
if (utf8_display_len(word) > (maxx - indent)) { if (wordlen > linelen) {
gchar *word_ch = g_utf8_offset_to_pointer(word, 0); gchar *word_ch = g_utf8_offset_to_pointer(word, 0);
while(*word_ch != '\0') { while(*word_ch != '\0') {
curx = getcurx(win); curx = getcurx(win);
if (curx < indent) { cury = getcury(win);
gboolean firstline = cury == starty;
if (firstline && curx < indent) {
_win_indent(win, indent); _win_indent(win, indent);
} }
if (!firstline && curx < (indent + pad_indent)) {
_win_indent(win, indent + pad_indent);
}
gchar copy[wordi++]; gchar copy[wordi+1];
g_utf8_strncpy(copy, word_ch, 1); g_utf8_strncpy(copy, word_ch, 1);
if (curx + utf8_display_len(copy) > maxx) {
waddch(win, '\n');
_win_indent(win, indent);
}
waddstr(win, copy); waddstr(win, copy);
word_ch = g_utf8_next_char(word_ch); word_ch = g_utf8_next_char(word_ch);
} }
// newline and print word
} else { } else {
if (curx + utf8_display_len(word) > maxx) {
waddch(win, '\n'); waddch(win, '\n');
curx = getcurx(win);
cury = getcury(win);
gboolean firstline = cury == starty;
if (firstline && curx < indent) {
_win_indent(win, indent); _win_indent(win, indent);
} }
if (curx < indent) { if (!firstline && curx < (indent + pad_indent)) {
_win_indent(win, indent + pad_indent);
}
waddstr(win, word);
}
// no wrap required
} else {
curx = getcurx(win);
cury = getcury(win);
gboolean firstline = cury == starty;
if (firstline && curx < indent) {
_win_indent(win, indent); _win_indent(win, indent);
} }
wprintw(win, "%s", word); if (!firstline && curx < (indent + pad_indent)) {
_win_indent(win, indent + pad_indent);
} }
waddstr(win, word);
}
}
// consume first space of next line
int curx = getcurx(win);
int cury = getcury(win);
gboolean firstline = (cury == starty);
if (!firstline && curx == 0 && *curr_ch == ' ') {
curr_ch = g_utf8_next_char(curr_ch);
} }
} }
@ -1134,7 +1181,7 @@ win_redraw(ProfWin *window)
for (i = 0; i < size; i++) { for (i = 0; i < size; i++) {
ProfBuffEntry *e = buffer_yield_entry(window->layout->buffer, i); ProfBuffEntry *e = buffer_yield_entry(window->layout->buffer, i);
_win_print(window, e->show_char, e->time, e->flags, e->theme_item, e->from, e->message, e->receipt); _win_print(window, e->show_char, e->pad_indent, e->time, e->flags, e->theme_item, e->from, e->message, e->receipt);
} }
} }

View File

@ -61,7 +61,7 @@ void win_show_status_string(ProfWin *window, const char * const from,
const char * const default_show); const char * const default_show);
void win_print_incoming_message(ProfWin *window, GDateTime *timestamp, void win_print_incoming_message(ProfWin *window, GDateTime *timestamp,
const char * const from, const char * const message); const char * const from, const char * const message);
void win_print_with_receipt(ProfWin *window, const char show_char, GTimeVal *tstamp, int flags, void win_print_with_receipt(ProfWin *window, const char show_char, int pad_indent, GTimeVal *tstamp, int flags,
theme_item_t theme_item, const char * const from, const char * const message, char *id); theme_item_t theme_item, 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);

View File

@ -497,7 +497,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, '-', NULL, 0, THEME_ERROR, "", "Lost connection."); win_print(window, '-', 0, NULL, 0, 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)) {

View File

@ -15,26 +15,23 @@
#include "command/commands.h" #include "command/commands.h"
#define CMD_ACCOUNT "/account"
void cmd_account_shows_usage_when_not_connected_and_no_args(void **state) void cmd_account_shows_usage_when_not_connected_and_no_args(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { NULL }; gchar *args[] = { NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED); will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_cons_show("Usage: some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_shows_account_when_connected_and_no_args(void **state) void cmd_account_shows_account_when_connected_and_no_args(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
ProfAccount *account = account_new("jabber_org", "me@jabber.org", NULL, NULL, ProfAccount *account = account_new("jabber_org", "me@jabber.org", NULL, NULL,
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL); TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
gchar *args[] = { NULL }; gchar *args[] = { NULL };
@ -46,15 +43,12 @@ void cmd_account_shows_account_when_connected_and_no_args(void **state)
expect_memory(cons_show_account, account, account, sizeof(ProfAccount)); expect_memory(cons_show_account, account, account, sizeof(ProfAccount));
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_list_shows_accounts(void **state) void cmd_account_list_shows_accounts(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "list", NULL }; gchar *args[] = { "list", NULL };
gchar **accounts = malloc(sizeof(gchar *) * 4); gchar **accounts = malloc(sizeof(gchar *) * 4);
@ -67,29 +61,22 @@ void cmd_account_list_shows_accounts(void **state)
expect_memory(cons_show_account_list, accounts, accounts, sizeof(accounts)); expect_memory(cons_show_account_list, accounts, accounts, sizeof(accounts));
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_show_shows_usage_when_no_arg(void **state) void cmd_account_show_shows_usage_when_no_arg(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "show", NULL }; gchar *args[] = { "show", NULL };
expect_cons_show("Usage: some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_show_shows_message_when_account_does_not_exist(void **state) void cmd_account_show_shows_message_when_account_does_not_exist(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "show", "account_name", NULL }; gchar *args[] = { "show", "account_name", NULL };
expect_any(accounts_get_account, name); expect_any(accounts_get_account, name);
@ -98,15 +85,12 @@ void cmd_account_show_shows_message_when_account_does_not_exist(void **state)
expect_cons_show("No such account."); expect_cons_show("No such account.");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_show_shows_account_when_exists(void **state) void cmd_account_show_shows_account_when_exists(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "show", "account_name", NULL }; gchar *args[] = { "show", "account_name", NULL };
ProfAccount *account = account_new("jabber_org", "me@jabber.org", NULL, NULL, ProfAccount *account = account_new("jabber_org", "me@jabber.org", NULL, NULL,
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL); TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
@ -116,29 +100,22 @@ void cmd_account_show_shows_account_when_exists(void **state)
expect_memory(cons_show_account, account, account, sizeof(account)); expect_memory(cons_show_account, account, account, sizeof(account));
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_add_shows_usage_when_no_arg(void **state) void cmd_account_add_shows_usage_when_no_arg(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "add", NULL }; gchar *args[] = { "add", NULL };
expect_cons_show("Usage: some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_add_adds_account(void **state) void cmd_account_add_adds_account(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "add", "new_account", NULL }; gchar *args[] = { "add", "new_account", NULL };
expect_string(accounts_add, jid, "new_account"); expect_string(accounts_add, jid, "new_account");
@ -147,29 +124,22 @@ void cmd_account_add_adds_account(void **state)
expect_cons_show("Account created."); expect_cons_show("Account created.");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_enable_shows_usage_when_no_arg(void **state) void cmd_account_enable_shows_usage_when_no_arg(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "enable", NULL }; gchar *args[] = { "enable", NULL };
expect_cons_show("Usage: some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_enable_enables_account(void **state) void cmd_account_enable_enables_account(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "enable", "account_name", NULL }; gchar *args[] = { "enable", "account_name", NULL };
expect_string(accounts_enable, name, "account_name"); expect_string(accounts_enable, name, "account_name");
@ -178,15 +148,12 @@ void cmd_account_enable_enables_account(void **state)
expect_cons_show("Account enabled."); expect_cons_show("Account enabled.");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_enable_shows_message_when_account_doesnt_exist(void **state) void cmd_account_enable_shows_message_when_account_doesnt_exist(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "enable", "account_name", NULL }; gchar *args[] = { "enable", "account_name", NULL };
expect_any(accounts_enable, name); expect_any(accounts_enable, name);
@ -195,29 +162,22 @@ void cmd_account_enable_shows_message_when_account_doesnt_exist(void **state)
expect_cons_show("No such account: account_name"); expect_cons_show("No such account: account_name");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_disable_shows_usage_when_no_arg(void **state) void cmd_account_disable_shows_usage_when_no_arg(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "disable", NULL }; gchar *args[] = { "disable", NULL };
expect_cons_show("Usage: some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_disable_disables_account(void **state) void cmd_account_disable_disables_account(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "disable", "account_name", NULL }; gchar *args[] = { "disable", "account_name", NULL };
expect_string(accounts_disable, name, "account_name"); expect_string(accounts_disable, name, "account_name");
@ -226,15 +186,12 @@ void cmd_account_disable_disables_account(void **state)
expect_cons_show("Account disabled."); expect_cons_show("Account disabled.");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_disable_shows_message_when_account_doesnt_exist(void **state) void cmd_account_disable_shows_message_when_account_doesnt_exist(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "disable", "account_name", NULL }; gchar *args[] = { "disable", "account_name", NULL };
expect_any(accounts_disable, name); expect_any(accounts_disable, name);
@ -243,43 +200,32 @@ void cmd_account_disable_shows_message_when_account_doesnt_exist(void **state)
expect_cons_show("No such account: account_name"); expect_cons_show("No such account: account_name");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_rename_shows_usage_when_no_args(void **state) void cmd_account_rename_shows_usage_when_no_args(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "rename", NULL }; gchar *args[] = { "rename", NULL };
expect_cons_show("Usage: some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_rename_shows_usage_when_one_arg(void **state) void cmd_account_rename_shows_usage_when_one_arg(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "rename", "original_name", NULL }; gchar *args[] = { "rename", "original_name", NULL };
expect_cons_show("Usage: some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_rename_renames_account(void **state) void cmd_account_rename_renames_account(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "rename", "original_name", "new_name", NULL }; gchar *args[] = { "rename", "original_name", "new_name", NULL };
expect_string(accounts_rename, account_name, "original_name"); expect_string(accounts_rename, account_name, "original_name");
@ -289,15 +235,12 @@ void cmd_account_rename_renames_account(void **state)
expect_cons_show("Account renamed."); expect_cons_show("Account renamed.");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_rename_shows_message_when_not_renamed(void **state) void cmd_account_rename_shows_message_when_not_renamed(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "rename", "original_name", "new_name", NULL }; gchar *args[] = { "rename", "original_name", "new_name", NULL };
expect_any(accounts_rename, account_name); expect_any(accounts_rename, account_name);
@ -307,57 +250,42 @@ void cmd_account_rename_shows_message_when_not_renamed(void **state)
expect_cons_show("Either account original_name doesn't exist, or account new_name already exists."); expect_cons_show("Either account original_name doesn't exist, or account new_name already exists.");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_set_shows_usage_when_no_args(void **state) void cmd_account_set_shows_usage_when_no_args(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "set", NULL }; gchar *args[] = { "set", NULL };
expect_cons_show("Usage: some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_set_shows_usage_when_one_arg(void **state) void cmd_account_set_shows_usage_when_one_arg(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "set", "a_account", NULL }; gchar *args[] = { "set", "a_account", NULL };
expect_cons_show("Usage: some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_set_shows_usage_when_two_args(void **state) void cmd_account_set_shows_usage_when_two_args(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "set", "a_account", "a_property", NULL }; gchar *args[] = { "set", "a_account", "a_property", NULL };
expect_cons_show("Usage: some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_set_shows_message_when_account_doesnt_exist(void **state) void cmd_account_set_shows_message_when_account_doesnt_exist(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "set", "a_account", "a_property", "a_value", NULL }; gchar *args[] = { "set", "a_account", "a_property", "a_value", NULL };
expect_string(accounts_account_exists, account_name, "a_account"); expect_string(accounts_account_exists, account_name, "a_account");
@ -366,15 +294,12 @@ void cmd_account_set_shows_message_when_account_doesnt_exist(void **state)
expect_cons_show("Account a_account doesn't exist"); expect_cons_show("Account a_account doesn't exist");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_set_jid_shows_message_for_malformed_jid(void **state) void cmd_account_set_jid_shows_message_for_malformed_jid(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "set", "a_account", "jid", "@malformed", NULL }; gchar *args[] = { "set", "a_account", "jid", "@malformed", NULL };
expect_any(accounts_account_exists, account_name); expect_any(accounts_account_exists, account_name);
@ -382,15 +307,12 @@ void cmd_account_set_jid_shows_message_for_malformed_jid(void **state)
expect_cons_show("Malformed jid: @malformed"); expect_cons_show("Malformed jid: @malformed");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_set_jid_sets_barejid(void **state) void cmd_account_set_jid_sets_barejid(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "set", "a_account", "jid", "a_local@a_domain", NULL }; gchar *args[] = { "set", "a_account", "jid", "a_local@a_domain", NULL };
expect_any(accounts_account_exists, account_name); expect_any(accounts_account_exists, account_name);
@ -402,15 +324,12 @@ void cmd_account_set_jid_sets_barejid(void **state)
expect_cons_show("Updated jid for account a_account: a_local@a_domain"); expect_cons_show("Updated jid for account a_account: a_local@a_domain");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_set_jid_sets_resource(void **state) void cmd_account_set_jid_sets_resource(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "set", "a_account", "jid", "a_local@a_domain/a_resource", NULL }; gchar *args[] = { "set", "a_account", "jid", "a_local@a_domain/a_resource", NULL };
expect_any(accounts_account_exists, account_name); expect_any(accounts_account_exists, account_name);
@ -427,15 +346,12 @@ void cmd_account_set_jid_sets_resource(void **state)
expect_cons_show("Updated resource for account a_account: a_resource"); expect_cons_show("Updated resource for account a_account: a_resource");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_set_server_sets_server(void **state) void cmd_account_set_server_sets_server(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "set", "a_account", "server", "a_server", NULL }; gchar *args[] = { "set", "a_account", "server", "a_server", NULL };
expect_any(accounts_account_exists, account_name); expect_any(accounts_account_exists, account_name);
@ -447,15 +363,12 @@ void cmd_account_set_server_sets_server(void **state)
expect_cons_show("Updated server for account a_account: a_server"); expect_cons_show("Updated server for account a_account: a_server");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_set_resource_sets_resource(void **state) void cmd_account_set_resource_sets_resource(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "set", "a_account", "resource", "a_resource", NULL }; gchar *args[] = { "set", "a_account", "resource", "a_resource", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED); will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
@ -469,15 +382,12 @@ void cmd_account_set_resource_sets_resource(void **state)
expect_cons_show("Updated resource for account a_account: a_resource"); expect_cons_show("Updated resource for account a_account: a_resource");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_set_resource_sets_resource_with_online_message(void **state) void cmd_account_set_resource_sets_resource_with_online_message(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "set", "a_account", "resource", "a_resource", NULL }; gchar *args[] = { "set", "a_account", "resource", "a_resource", NULL };
will_return(jabber_get_connection_status, JABBER_CONNECTED); will_return(jabber_get_connection_status, JABBER_CONNECTED);
@ -491,15 +401,12 @@ void cmd_account_set_resource_sets_resource_with_online_message(void **state)
expect_cons_show("Updated resource for account a_account: a_resource, you will need to reconnect to pick up the change."); expect_cons_show("Updated resource for account a_account: a_resource, you will need to reconnect to pick up the change.");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_set_password_sets_password(void **state) void cmd_account_set_password_sets_password(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "set", "a_account", "password", "a_password", NULL }; gchar *args[] = { "set", "a_account", "password", "a_password", NULL };
ProfAccount *account = account_new("a_account", NULL, NULL, NULL, ProfAccount *account = account_new("a_account", NULL, NULL, NULL,
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL); TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
@ -517,20 +424,16 @@ void cmd_account_set_password_sets_password(void **state)
expect_cons_show("Updated password for account a_account"); expect_cons_show("Updated password for account a_account");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_set_eval_password_sets_eval_password(void **state) void cmd_account_set_eval_password_sets_eval_password(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "set", "a_account", "eval_password", "a_password", NULL }; gchar *args[] = { "set", "a_account", "eval_password", "a_password", NULL };
ProfAccount *account = account_new("a_account", NULL, NULL, NULL, ProfAccount *account = account_new("a_account", NULL, NULL, NULL,
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL); TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
expect_any(accounts_account_exists, account_name); expect_any(accounts_account_exists, account_name);
will_return(accounts_account_exists, TRUE); will_return(accounts_account_exists, TRUE);
@ -543,19 +446,15 @@ void cmd_account_set_eval_password_sets_eval_password(void **state)
expect_cons_show("Updated eval_password for account a_account"); expect_cons_show("Updated eval_password for account a_account");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_set_password_when_eval_password_set(void **state) { void cmd_account_set_password_when_eval_password_set(void **state) {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "set", "a_account", "password", "a_password", NULL }; gchar *args[] = { "set", "a_account", "password", "a_password", NULL };
ProfAccount *account = account_new("a_account", NULL, NULL, "a_password", ProfAccount *account = account_new("a_account", NULL, NULL, "a_password",
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL); TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
expect_any(accounts_account_exists, account_name); expect_any(accounts_account_exists, account_name);
will_return(accounts_account_exists, TRUE); will_return(accounts_account_exists, TRUE);
@ -564,19 +463,15 @@ void cmd_account_set_password_when_eval_password_set(void **state) {
expect_cons_show("Cannot set password when eval_password is set."); expect_cons_show("Cannot set password when eval_password is set.");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_set_eval_password_when_password_set(void **state) { void cmd_account_set_eval_password_when_password_set(void **state) {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "set", "a_account", "eval_password", "a_password", NULL }; gchar *args[] = { "set", "a_account", "eval_password", "a_password", NULL };
ProfAccount *account = account_new("a_account", NULL, "a_password", NULL, ProfAccount *account = account_new("a_account", NULL, "a_password", NULL,
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL); TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
expect_any(accounts_account_exists, account_name); expect_any(accounts_account_exists, account_name);
will_return(accounts_account_exists, TRUE); will_return(accounts_account_exists, TRUE);
@ -585,15 +480,12 @@ void cmd_account_set_eval_password_when_password_set(void **state) {
expect_cons_show("Cannot set eval_password when password is set."); expect_cons_show("Cannot set eval_password when password is set.");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_set_muc_sets_muc(void **state) void cmd_account_set_muc_sets_muc(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "set", "a_account", "muc", "a_muc", NULL }; gchar *args[] = { "set", "a_account", "muc", "a_muc", NULL };
expect_any(accounts_account_exists, account_name); expect_any(accounts_account_exists, account_name);
@ -605,15 +497,12 @@ void cmd_account_set_muc_sets_muc(void **state)
expect_cons_show("Updated muc service for account a_account: a_muc"); expect_cons_show("Updated muc service for account a_account: a_muc");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_set_nick_sets_nick(void **state) void cmd_account_set_nick_sets_nick(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "set", "a_account", "nick", "a_nick", NULL }; gchar *args[] = { "set", "a_account", "nick", "a_nick", NULL };
expect_any(accounts_account_exists, account_name); expect_any(accounts_account_exists, account_name);
@ -625,29 +514,22 @@ void cmd_account_set_nick_sets_nick(void **state)
expect_cons_show("Updated muc nick for account a_account: a_nick"); expect_cons_show("Updated muc nick for account a_account: a_nick");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_show_message_for_missing_otr_policy(void **state) void cmd_account_show_message_for_missing_otr_policy(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "Some usage";
gchar *args[] = { "set", "a_account", "otr", NULL }; gchar *args[] = { "set", "a_account", "otr", NULL };
expect_cons_show("Usage: Some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_show_message_for_invalid_otr_policy(void **state) void cmd_account_show_message_for_invalid_otr_policy(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "set", "a_account", "otr", "bad_otr_policy", NULL }; gchar *args[] = { "set", "a_account", "otr", "bad_otr_policy", NULL };
expect_any(accounts_account_exists, account_name); expect_any(accounts_account_exists, account_name);
@ -655,15 +537,12 @@ void cmd_account_show_message_for_invalid_otr_policy(void **state)
expect_cons_show("OTR policy must be one of: manual, opportunistic or always."); expect_cons_show("OTR policy must be one of: manual, opportunistic or always.");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_set_otr_sets_otr(void **state) void cmd_account_set_otr_sets_otr(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "set", "a_account", "otr", "opportunistic", NULL }; gchar *args[] = { "set", "a_account", "otr", "opportunistic", NULL };
expect_any(accounts_account_exists, account_name); expect_any(accounts_account_exists, account_name);
@ -675,15 +554,12 @@ void cmd_account_set_otr_sets_otr(void **state)
expect_cons_show("Updated OTR policy for account a_account: opportunistic"); expect_cons_show("Updated OTR policy for account a_account: opportunistic");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_set_status_shows_message_when_invalid_status(void **state) void cmd_account_set_status_shows_message_when_invalid_status(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "set", "a_account", "status", "bad_status", NULL }; gchar *args[] = { "set", "a_account", "status", "bad_status", NULL };
expect_any(accounts_account_exists, account_name); expect_any(accounts_account_exists, account_name);
@ -692,15 +568,12 @@ void cmd_account_set_status_shows_message_when_invalid_status(void **state)
expect_cons_show("Invalid status: bad_status"); expect_cons_show("Invalid status: bad_status");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_set_status_sets_status_when_valid(void **state) void cmd_account_set_status_sets_status_when_valid(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "set", "a_account", "status", "away", NULL }; gchar *args[] = { "set", "a_account", "status", "away", NULL };
expect_any(accounts_account_exists, account_name); expect_any(accounts_account_exists, account_name);
@ -712,15 +585,12 @@ void cmd_account_set_status_sets_status_when_valid(void **state)
expect_cons_show("Updated login status for account a_account: away"); expect_cons_show("Updated login status for account a_account: away");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_set_status_sets_status_when_last(void **state) void cmd_account_set_status_sets_status_when_last(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "set", "a_account", "status", "last", NULL }; gchar *args[] = { "set", "a_account", "status", "last", NULL };
expect_any(accounts_account_exists, account_name); expect_any(accounts_account_exists, account_name);
@ -732,15 +602,12 @@ void cmd_account_set_status_sets_status_when_last(void **state)
expect_cons_show("Updated login status for account a_account: last"); expect_cons_show("Updated login status for account a_account: last");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_set_invalid_presence_string_priority_shows_message(void **state) void cmd_account_set_invalid_presence_string_priority_shows_message(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "set", "a_account", "blah", "10", NULL }; gchar *args[] = { "set", "a_account", "blah", "10", NULL };
expect_any(accounts_account_exists, account_name); expect_any(accounts_account_exists, account_name);
@ -749,15 +616,12 @@ void cmd_account_set_invalid_presence_string_priority_shows_message(void **state
expect_cons_show("Invalid property: blah"); expect_cons_show("Invalid property: blah");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_set_last_priority_shows_message(void **state) void cmd_account_set_last_priority_shows_message(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "set", "a_account", "last", "10", NULL }; gchar *args[] = { "set", "a_account", "last", "10", NULL };
expect_any(accounts_account_exists, account_name); expect_any(accounts_account_exists, account_name);
@ -766,15 +630,12 @@ void cmd_account_set_last_priority_shows_message(void **state)
expect_cons_show("Invalid property: last"); expect_cons_show("Invalid property: last");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_set_online_priority_sets_preference(void **state) void cmd_account_set_online_priority_sets_preference(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "set", "a_account", "online", "10", NULL }; gchar *args[] = { "set", "a_account", "online", "10", NULL };
expect_any(accounts_account_exists, account_name); expect_any(accounts_account_exists, account_name);
@ -788,15 +649,12 @@ void cmd_account_set_online_priority_sets_preference(void **state)
expect_cons_show("Updated online priority for account a_account: 10"); expect_cons_show("Updated online priority for account a_account: 10");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_set_chat_priority_sets_preference(void **state) void cmd_account_set_chat_priority_sets_preference(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "set", "a_account", "chat", "10", NULL }; gchar *args[] = { "set", "a_account", "chat", "10", NULL };
expect_any(accounts_account_exists, account_name); expect_any(accounts_account_exists, account_name);
@ -810,15 +668,12 @@ void cmd_account_set_chat_priority_sets_preference(void **state)
expect_cons_show("Updated chat priority for account a_account: 10"); expect_cons_show("Updated chat priority for account a_account: 10");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_set_away_priority_sets_preference(void **state) void cmd_account_set_away_priority_sets_preference(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "set", "a_account", "away", "10", NULL }; gchar *args[] = { "set", "a_account", "away", "10", NULL };
expect_any(accounts_account_exists, account_name); expect_any(accounts_account_exists, account_name);
@ -832,15 +687,12 @@ void cmd_account_set_away_priority_sets_preference(void **state)
expect_cons_show("Updated away priority for account a_account: 10"); expect_cons_show("Updated away priority for account a_account: 10");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_set_xa_priority_sets_preference(void **state) void cmd_account_set_xa_priority_sets_preference(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "set", "a_account", "xa", "10", NULL }; gchar *args[] = { "set", "a_account", "xa", "10", NULL };
expect_any(accounts_account_exists, account_name); expect_any(accounts_account_exists, account_name);
@ -854,15 +706,12 @@ void cmd_account_set_xa_priority_sets_preference(void **state)
expect_cons_show("Updated xa priority for account a_account: 10"); expect_cons_show("Updated xa priority for account a_account: 10");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_set_dnd_priority_sets_preference(void **state) void cmd_account_set_dnd_priority_sets_preference(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "set", "a_account", "dnd", "10", NULL }; gchar *args[] = { "set", "a_account", "dnd", "10", NULL };
expect_any(accounts_account_exists, account_name); expect_any(accounts_account_exists, account_name);
@ -876,15 +725,12 @@ void cmd_account_set_dnd_priority_sets_preference(void **state)
expect_cons_show("Updated dnd priority for account a_account: 10"); expect_cons_show("Updated dnd priority for account a_account: 10");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_set_priority_too_low_shows_message(void **state) void cmd_account_set_priority_too_low_shows_message(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "set", "a_account", "online", "-150", NULL }; gchar *args[] = { "set", "a_account", "online", "-150", NULL };
expect_any(accounts_account_exists, account_name); expect_any(accounts_account_exists, account_name);
@ -892,15 +738,12 @@ void cmd_account_set_priority_too_low_shows_message(void **state)
expect_cons_show("Value -150 out of range. Must be in -128..127."); expect_cons_show("Value -150 out of range. Must be in -128..127.");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_set_priority_too_high_shows_message(void **state) void cmd_account_set_priority_too_high_shows_message(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "set", "a_account", "online", "150", NULL }; gchar *args[] = { "set", "a_account", "online", "150", NULL };
expect_any(accounts_account_exists, account_name); expect_any(accounts_account_exists, account_name);
@ -908,15 +751,12 @@ void cmd_account_set_priority_too_high_shows_message(void **state)
expect_cons_show("Value 150 out of range. Must be in -128..127."); expect_cons_show("Value 150 out of range. Must be in -128..127.");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_set_priority_when_not_number_shows_message(void **state) void cmd_account_set_priority_when_not_number_shows_message(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "set", "a_account", "online", "abc", NULL }; gchar *args[] = { "set", "a_account", "online", "abc", NULL };
expect_any(accounts_account_exists, account_name); expect_any(accounts_account_exists, account_name);
@ -924,15 +764,12 @@ void cmd_account_set_priority_when_not_number_shows_message(void **state)
expect_cons_show("Could not convert \"abc\" to a number."); expect_cons_show("Could not convert \"abc\" to a number.");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_set_priority_when_empty_shows_message(void **state) void cmd_account_set_priority_when_empty_shows_message(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "set", "a_account", "online", "", NULL }; gchar *args[] = { "set", "a_account", "online", "", NULL };
expect_any(accounts_account_exists, account_name); expect_any(accounts_account_exists, account_name);
@ -940,18 +777,14 @@ void cmd_account_set_priority_when_empty_shows_message(void **state)
expect_cons_show("Could not convert \"\" to a number."); expect_cons_show("Could not convert \"\" to a number.");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_set_priority_updates_presence_when_account_connected_with_presence(void **state) void cmd_account_set_priority_updates_presence_when_account_connected_with_presence(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "set", "a_account", "online", "10", NULL }; gchar *args[] = { "set", "a_account", "online", "10", NULL };
expect_any(accounts_account_exists, account_name); expect_any(accounts_account_exists, account_name);
will_return(accounts_account_exists, TRUE); will_return(accounts_account_exists, TRUE);
@ -984,43 +817,32 @@ void cmd_account_set_priority_updates_presence_when_account_connected_with_prese
expect_cons_show("Updated online priority for account a_account: 10"); expect_cons_show("Updated online priority for account a_account: 10");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_clear_shows_usage_when_no_args(void **state) void cmd_account_clear_shows_usage_when_no_args(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "clear", NULL }; gchar *args[] = { "clear", NULL };
expect_cons_show("Usage: some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_clear_shows_usage_when_one_arg(void **state) void cmd_account_clear_shows_usage_when_one_arg(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "clear", "a_account", NULL }; gchar *args[] = { "clear", "a_account", NULL };
expect_cons_show("Usage: some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT);
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_clear_shows_message_when_account_doesnt_exist(void **state) void cmd_account_clear_shows_message_when_account_doesnt_exist(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "clear", "a_account", "a_property", NULL }; gchar *args[] = { "clear", "a_account", "a_property", NULL };
expect_string(accounts_account_exists, account_name, "a_account"); expect_string(accounts_account_exists, account_name, "a_account");
@ -1029,15 +851,12 @@ void cmd_account_clear_shows_message_when_account_doesnt_exist(void **state)
expect_cons_show("Account a_account doesn't exist"); expect_cons_show("Account a_account doesn't exist");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_account_clear_shows_message_when_invalid_property(void **state) void cmd_account_clear_shows_message_when_invalid_property(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "clear", "a_account", "badproperty", NULL }; gchar *args[] = { "clear", "a_account", "badproperty", NULL };
expect_any(accounts_account_exists, account_name); expect_any(accounts_account_exists, account_name);
@ -1046,8 +865,6 @@ void cmd_account_clear_shows_message_when_invalid_property(void **state)
expect_cons_show("Invalid property: badproperty"); expect_cons_show("Invalid property: badproperty");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help); gboolean result = cmd_account(NULL, CMD_ACCOUNT, args);
assert_true(result); assert_true(result);
free(help);
} }

View File

@ -16,82 +16,63 @@
#include "command/command.h" #include "command/command.h"
#include "command/commands.h" #include "command/commands.h"
#define CMD_ALIAS "/alias"
void cmd_alias_add_shows_usage_when_no_args(void **state) void cmd_alias_add_shows_usage_when_no_args(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "add", NULL }; gchar *args[] = { "add", NULL };
expect_cons_show("Usage: some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_ALIAS);
gboolean result = cmd_alias(NULL, args, *help); gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_alias_add_shows_usage_when_no_value(void **state) void cmd_alias_add_shows_usage_when_no_value(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "add", "alias", NULL }; gchar *args[] = { "add", "alias", NULL };
expect_cons_show("Usage: some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_ALIAS);
gboolean result = cmd_alias(NULL, args, *help); gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_alias_remove_shows_usage_when_no_args(void **state) void cmd_alias_remove_shows_usage_when_no_args(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "remove", NULL }; gchar *args[] = { "remove", NULL };
expect_cons_show("Usage: some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_ALIAS);
gboolean result = cmd_alias(NULL, args, *help); gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_alias_show_usage_when_invalid_subcmd(void **state) void cmd_alias_show_usage_when_invalid_subcmd(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "blah", NULL }; gchar *args[] = { "blah", NULL };
expect_cons_show("Usage: some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_ALIAS);
gboolean result = cmd_alias(NULL, args, *help); gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_alias_add_adds_alias(void **state) void cmd_alias_add_adds_alias(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "add", "hc", "/help commands", NULL }; gchar *args[] = { "add", "hc", "/help commands", NULL };
expect_cons_show("Command alias added /hc -> /help commands"); expect_cons_show("Command alias added /hc -> /help commands");
gboolean result = cmd_alias(NULL, args, *help); gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
assert_true(result);
char *returned_val = prefs_get_alias("hc"); char *returned_val = prefs_get_alias("hc");
assert_true(result);
assert_string_equal("/help commands", returned_val); assert_string_equal("/help commands", returned_val);
free(help);
} }
void cmd_alias_add_shows_message_when_exists(void **state) void cmd_alias_add_shows_message_when_exists(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "add", "hc", "/help commands", NULL }; gchar *args[] = { "add", "hc", "/help commands", NULL };
cmd_init(); cmd_init();
@ -100,47 +81,37 @@ void cmd_alias_add_shows_message_when_exists(void **state)
expect_cons_show("Command or alias '/hc' already exists."); expect_cons_show("Command or alias '/hc' already exists.");
gboolean result = cmd_alias(NULL, args, *help); gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_alias_remove_removes_alias(void **state) void cmd_alias_remove_removes_alias(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "remove", "hn", NULL }; gchar *args[] = { "remove", "hn", NULL };
prefs_add_alias("hn", "/help navigation"); prefs_add_alias("hn", "/help navigation");
expect_cons_show("Command alias removed -> /hn"); expect_cons_show("Command alias removed -> /hn");
gboolean result = cmd_alias(NULL, args, *help); gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
assert_true(result);
char *returned_val = prefs_get_alias("hn"); char *returned_val = prefs_get_alias("hn");
assert_true(result);
assert_null(returned_val); assert_null(returned_val);
free(help);
} }
void cmd_alias_remove_shows_message_when_no_alias(void **state) void cmd_alias_remove_shows_message_when_no_alias(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "remove", "hn", NULL }; gchar *args[] = { "remove", "hn", NULL };
expect_cons_show("No such command alias /hn"); expect_cons_show("No such command alias /hn");
gboolean result = cmd_alias(NULL, args, *help); gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_alias_list_shows_all_aliases(void **state) void cmd_alias_list_shows_all_aliases(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "list", NULL }; gchar *args[] = { "list", NULL };
prefs_add_alias("vy", "/vercheck on"); prefs_add_alias("vy", "/vercheck on");
@ -152,8 +123,6 @@ void cmd_alias_list_shows_all_aliases(void **state)
// write a custom checker to check the correct list is passed // write a custom checker to check the correct list is passed
expect_any(cons_show_aliases, aliases); expect_any(cons_show_aliases, aliases);
gboolean result = cmd_alias(NULL, args, *help); gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
assert_true(result); assert_true(result);
free(help);
} }

View File

@ -20,17 +20,15 @@
#include "helpers.h" #include "helpers.h"
#define CMD_BOOKMARK "/bookmark"
static void test_with_connection_status(jabber_conn_status_t status) static void test_with_connection_status(jabber_conn_status_t status)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
will_return(jabber_get_connection_status, status); will_return(jabber_get_connection_status, status);
expect_cons_show("You are not currently connected."); expect_cons_show("You are not currently connected.");
gboolean result = cmd_bookmark(NULL, NULL, *help); gboolean result = cmd_bookmark(NULL, CMD_BOOKMARK, NULL);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_bookmark_shows_message_when_disconnected(void **state) void cmd_bookmark_shows_message_when_disconnected(void **state)
@ -60,20 +58,16 @@ void cmd_bookmark_shows_message_when_undefined(void **state)
void cmd_bookmark_shows_usage_when_no_args(void **state) void cmd_bookmark_shows_usage_when_no_args(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { NULL }; gchar *args[] = { NULL };
ProfWin window; ProfWin window;
window.type = WIN_CONSOLE; window.type = WIN_CONSOLE;
will_return(jabber_get_connection_status, JABBER_CONNECTED); will_return(jabber_get_connection_status, JABBER_CONNECTED);
expect_cons_show("Usage: some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_BOOKMARK);
gboolean result = cmd_bookmark(&window, args, *help); gboolean result = cmd_bookmark(&window, CMD_BOOKMARK, args);
assert_true(result); assert_true(result);
free(help);
} }
static void _free_bookmark(Bookmark *bookmark) static void _free_bookmark(Bookmark *bookmark)
@ -101,7 +95,6 @@ _cmp_bookmark(Bookmark *bm1, Bookmark *bm2)
void cmd_bookmark_list_shows_bookmarks(void **state) void cmd_bookmark_list_shows_bookmarks(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "list", NULL }; gchar *args[] = { "list", NULL };
GList *bookmarks = NULL; GList *bookmarks = NULL;
ProfWin window; ProfWin window;
@ -141,17 +134,15 @@ void cmd_bookmark_list_shows_bookmarks(void **state)
glist_set_cmp((GCompareFunc)_cmp_bookmark); glist_set_cmp((GCompareFunc)_cmp_bookmark);
expect_any(cons_show_bookmarks, list); expect_any(cons_show_bookmarks, list);
gboolean result = cmd_bookmark(&window, args, *help); gboolean result = cmd_bookmark(&window, CMD_BOOKMARK, args);
assert_true(result); assert_true(result);
free(help);
g_list_free_full(bookmarks, (GDestroyNotify)_free_bookmark); g_list_free_full(bookmarks, (GDestroyNotify)_free_bookmark);
} }
void cmd_bookmark_add_shows_message_when_invalid_jid(void **state) void cmd_bookmark_add_shows_message_when_invalid_jid(void **state)
{ {
char *jid = "room"; char *jid = "room";
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "add", jid, NULL }; gchar *args[] = { "add", jid, NULL };
ProfWin window; ProfWin window;
window.type = WIN_CONSOLE; window.type = WIN_CONSOLE;
@ -160,16 +151,13 @@ void cmd_bookmark_add_shows_message_when_invalid_jid(void **state)
expect_cons_show("Can't add bookmark with JID 'room'; should be 'room@domain.tld'"); expect_cons_show("Can't add bookmark with JID 'room'; should be 'room@domain.tld'");
gboolean result = cmd_bookmark(&window, args, *help); gboolean result = cmd_bookmark(&window, CMD_BOOKMARK, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_bookmark_add_adds_bookmark_with_jid(void **state) void cmd_bookmark_add_adds_bookmark_with_jid(void **state)
{ {
char *jid = "room@conf.server"; char *jid = "room@conf.server";
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "add", jid, NULL }; gchar *args[] = { "add", jid, NULL };
ProfWin window; ProfWin window;
window.type = WIN_CONSOLE; window.type = WIN_CONSOLE;
@ -184,16 +172,14 @@ void cmd_bookmark_add_adds_bookmark_with_jid(void **state)
expect_cons_show("Bookmark added for room@conf.server."); expect_cons_show("Bookmark added for room@conf.server.");
gboolean result = cmd_bookmark(&window, args, *help); gboolean result = cmd_bookmark(&window, CMD_BOOKMARK, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_bookmark_add_adds_bookmark_with_jid_nick(void **state) void cmd_bookmark_add_adds_bookmark_with_jid_nick(void **state)
{ char *jid = "room@conf.server"; {
char *jid = "room@conf.server";
char *nick = "bob"; char *nick = "bob";
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "add", jid, "nick", nick, NULL }; gchar *args[] = { "add", jid, "nick", nick, NULL };
ProfWin window; ProfWin window;
window.type = WIN_CONSOLE; window.type = WIN_CONSOLE;
@ -208,16 +194,13 @@ void cmd_bookmark_add_adds_bookmark_with_jid_nick(void **state)
expect_cons_show("Bookmark added for room@conf.server."); expect_cons_show("Bookmark added for room@conf.server.");
gboolean result = cmd_bookmark(&window, args, *help); gboolean result = cmd_bookmark(&window, CMD_BOOKMARK, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_bookmark_add_adds_bookmark_with_jid_autojoin(void **state) void cmd_bookmark_add_adds_bookmark_with_jid_autojoin(void **state)
{ {
char *jid = "room@conf.server"; char *jid = "room@conf.server";
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "add", jid, "autojoin", "on", NULL }; gchar *args[] = { "add", jid, "autojoin", "on", NULL };
ProfWin window; ProfWin window;
window.type = WIN_CONSOLE; window.type = WIN_CONSOLE;
@ -232,17 +215,14 @@ void cmd_bookmark_add_adds_bookmark_with_jid_autojoin(void **state)
expect_cons_show("Bookmark added for room@conf.server."); expect_cons_show("Bookmark added for room@conf.server.");
gboolean result = cmd_bookmark(&window, args, *help); gboolean result = cmd_bookmark(&window, CMD_BOOKMARK, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_bookmark_add_adds_bookmark_with_jid_nick_autojoin(void **state) void cmd_bookmark_add_adds_bookmark_with_jid_nick_autojoin(void **state)
{ {
char *jid = "room@conf.server"; char *jid = "room@conf.server";
char *nick = "bob"; char *nick = "bob";
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "add", jid, "nick", nick, "autojoin", "on", NULL }; gchar *args[] = { "add", jid, "nick", nick, "autojoin", "on", NULL };
ProfWin window; ProfWin window;
window.type = WIN_CONSOLE; window.type = WIN_CONSOLE;
@ -257,16 +237,13 @@ void cmd_bookmark_add_adds_bookmark_with_jid_nick_autojoin(void **state)
expect_cons_show("Bookmark added for room@conf.server."); expect_cons_show("Bookmark added for room@conf.server.");
gboolean result = cmd_bookmark(&window, args, *help); gboolean result = cmd_bookmark(&window, CMD_BOOKMARK, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_bookmark_remove_removes_bookmark(void **state) void cmd_bookmark_remove_removes_bookmark(void **state)
{ {
char *jid = "room@conf.server"; char *jid = "room@conf.server";
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "remove", jid, NULL }; gchar *args[] = { "remove", jid, NULL };
ProfWin window; ProfWin window;
window.type = WIN_CONSOLE; window.type = WIN_CONSOLE;
@ -278,16 +255,13 @@ void cmd_bookmark_remove_removes_bookmark(void **state)
expect_cons_show("Bookmark removed for room@conf.server."); expect_cons_show("Bookmark removed for room@conf.server.");
gboolean result = cmd_bookmark(&window, args, *help); gboolean result = cmd_bookmark(&window, CMD_BOOKMARK, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_bookmark_remove_shows_message_when_no_bookmark(void **state) void cmd_bookmark_remove_shows_message_when_no_bookmark(void **state)
{ {
char *jid = "room@conf.server"; char *jid = "room@conf.server";
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "remove", jid, NULL }; gchar *args[] = { "remove", jid, NULL };
ProfWin window; ProfWin window;
window.type = WIN_CONSOLE; window.type = WIN_CONSOLE;
@ -299,8 +273,6 @@ void cmd_bookmark_remove_shows_message_when_no_bookmark(void **state)
expect_cons_show("No bookmark exists for room@conf.server."); expect_cons_show("No bookmark exists for room@conf.server.");
gboolean result = cmd_bookmark(&window, args, *help); gboolean result = cmd_bookmark(&window, CMD_BOOKMARK, args);
assert_true(result); assert_true(result);
free(help);
} }

View File

@ -14,18 +14,16 @@
#include "command/commands.h" #include "command/commands.h"
#include "config/accounts.h" #include "config/accounts.h"
#define CMD_CONNECT "/connect"
static void test_with_connection_status(jabber_conn_status_t status) static void test_with_connection_status(jabber_conn_status_t status)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
will_return(jabber_get_connection_status, status); will_return(jabber_get_connection_status, status);
expect_cons_show("You are either connected already, or a login is in process."); expect_cons_show("You are either connected already, or a login is in process.");
gboolean result = cmd_connect(NULL, NULL, *help); gboolean result = cmd_connect(NULL, CMD_CONNECT, NULL);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_connect_shows_message_when_disconnecting(void **state) void cmd_connect_shows_message_when_disconnecting(void **state)
@ -48,209 +46,8 @@ void cmd_connect_shows_message_when_undefined(void **state)
test_with_connection_status(JABBER_UNDEFINED); test_with_connection_status(JABBER_UNDEFINED);
} }
void cmd_connect_shows_usage_when_no_server_value(void **state)
{
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "user@server.org", "server", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_cons_show("Usage: some usage");
expect_cons_show("");
gboolean result = cmd_connect(NULL, args, *help);
assert_true(result);
free(help);
}
void cmd_connect_shows_usage_when_server_no_port_value(void **state)
{
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "user@server.org", "server", "aserver", "port", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_cons_show("Usage: some usage");
expect_cons_show("");
gboolean result = cmd_connect(NULL, args, *help);
assert_true(result);
free(help);
}
void cmd_connect_shows_usage_when_no_port_value(void **state)
{
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "user@server.org", "port", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_cons_show("Usage: some usage");
expect_cons_show("");
gboolean result = cmd_connect(NULL, args, *help);
assert_true(result);
free(help);
}
void cmd_connect_shows_usage_when_port_no_server_value(void **state)
{
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "user@server.org", "port", "5678", "server", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_cons_show("Usage: some usage");
expect_cons_show("");
gboolean result = cmd_connect(NULL, args, *help);
assert_true(result);
free(help);
}
void cmd_connect_shows_message_when_port_0(void **state)
{
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "user@server.org", "port", "0", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_cons_show("Value 0 out of range. Must be in 1..65535.");
expect_cons_show("");
gboolean result = cmd_connect(NULL, args, *help);
assert_true(result);
free(help);
}
void cmd_connect_shows_message_when_port_minus1(void **state)
{
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "user@server.org", "port", "-1", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_cons_show("Value -1 out of range. Must be in 1..65535.");
expect_cons_show("");
gboolean result = cmd_connect(NULL, args, *help);
assert_true(result);
free(help);
}
void cmd_connect_shows_message_when_port_65536(void **state)
{
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "user@server.org", "port", "65536", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_cons_show("Value 65536 out of range. Must be in 1..65535.");
expect_cons_show("");
gboolean result = cmd_connect(NULL, args, *help);
assert_true(result);
free(help);
}
void cmd_connect_shows_message_when_port_contains_chars(void **state)
{
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "user@server.org", "port", "52f66", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_cons_show("Could not convert \"52f66\" to a number.");
expect_cons_show("");
gboolean result = cmd_connect(NULL, args, *help);
assert_true(result);
free(help);
}
void cmd_connect_shows_usage_when_server_provided_twice(void **state)
{
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "user@server.org", "server", "server1", "server", "server2", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_cons_show("Usage: some usage");
expect_cons_show("");
gboolean result = cmd_connect(NULL, args, *help);
assert_true(result);
free(help);
}
void cmd_connect_shows_usage_when_port_provided_twice(void **state)
{
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "user@server.org", "port", "1111", "port", "1111", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_cons_show("Usage: some usage");
expect_cons_show("");
gboolean result = cmd_connect(NULL, args, *help);
assert_true(result);
free(help);
}
void cmd_connect_shows_usage_when_invalid_first_property(void **state)
{
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "user@server.org", "wrong", "server", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_cons_show("Usage: some usage");
expect_cons_show("");
gboolean result = cmd_connect(NULL, args, *help);
assert_true(result);
free(help);
}
void cmd_connect_shows_usage_when_invalid_second_property(void **state)
{
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "user@server.org", "server", "aserver", "wrong", "1234", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_cons_show("Usage: some usage");
expect_cons_show("");
gboolean result = cmd_connect(NULL, args, *help);
assert_true(result);
free(help);
}
void cmd_connect_when_no_account(void **state) void cmd_connect_when_no_account(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "user@server.org", NULL }; gchar *args[] = { "user@server.org", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED); will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
@ -268,93 +65,12 @@ void cmd_connect_when_no_account(void **state)
expect_value(jabber_connect_with_details, port, 0); expect_value(jabber_connect_with_details, port, 0);
will_return(jabber_connect_with_details, JABBER_CONNECTING); will_return(jabber_connect_with_details, JABBER_CONNECTING);
gboolean result = cmd_connect(NULL, args, *help); gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
assert_true(result); assert_true(result);
free(help);
}
void cmd_connect_with_server_when_provided(void **state)
{
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "user@server.org", "server", "aserver", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_string(accounts_get_account, name, "user@server.org");
will_return(accounts_get_account, NULL);
will_return(ui_ask_password, strdup("password"));
expect_cons_show("Connecting as user@server.org");
expect_string(jabber_connect_with_details, jid, "user@server.org");
expect_string(jabber_connect_with_details, passwd, "password");
expect_string(jabber_connect_with_details, altdomain, "aserver");
expect_value(jabber_connect_with_details, port, 0);
will_return(jabber_connect_with_details, JABBER_CONNECTING);
gboolean result = cmd_connect(NULL, args, *help);
assert_true(result);
free(help);
}
void cmd_connect_with_port_when_provided(void **state)
{
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "user@server.org", "port", "5432", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_string(accounts_get_account, name, "user@server.org");
will_return(accounts_get_account, NULL);
will_return(ui_ask_password, strdup("password"));
expect_cons_show("Connecting as user@server.org");
expect_string(jabber_connect_with_details, jid, "user@server.org");
expect_string(jabber_connect_with_details, passwd, "password");
expect_value(jabber_connect_with_details, altdomain, NULL);
expect_value(jabber_connect_with_details, port, 5432);
will_return(jabber_connect_with_details, JABBER_CONNECTING);
gboolean result = cmd_connect(NULL, args, *help);
assert_true(result);
free(help);
}
void cmd_connect_with_server_and_port_when_provided(void **state)
{
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "user@server.org", "port", "5432", "server", "aserver", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_string(accounts_get_account, name, "user@server.org");
will_return(accounts_get_account, NULL);
will_return(ui_ask_password, strdup("password"));
expect_cons_show("Connecting as user@server.org");
expect_string(jabber_connect_with_details, jid, "user@server.org");
expect_string(jabber_connect_with_details, passwd, "password");
expect_string(jabber_connect_with_details, altdomain, "aserver");
expect_value(jabber_connect_with_details, port, 5432);
will_return(jabber_connect_with_details, JABBER_CONNECTING);
gboolean result = cmd_connect(NULL, args, *help);
assert_true(result);
free(help);
} }
void cmd_connect_fail_message(void **state) void cmd_connect_fail_message(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "user@server.org", NULL }; gchar *args[] = { "user@server.org", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED); will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
@ -374,15 +90,12 @@ void cmd_connect_fail_message(void **state)
expect_cons_show_error("Connection attempt for user@server.org failed."); expect_cons_show_error("Connection attempt for user@server.org failed.");
gboolean result = cmd_connect(NULL, args, *help); gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_connect_lowercases_argument(void **state) void cmd_connect_lowercases_argument(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "USER@server.ORG", NULL }; gchar *args[] = { "USER@server.ORG", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED); will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
@ -400,15 +113,12 @@ void cmd_connect_lowercases_argument(void **state)
expect_any(jabber_connect_with_details, port); expect_any(jabber_connect_with_details, port);
will_return(jabber_connect_with_details, JABBER_CONNECTING); will_return(jabber_connect_with_details, JABBER_CONNECTING);
gboolean result = cmd_connect(NULL, args, *help); gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_connect_asks_password_when_not_in_account(void **state) void cmd_connect_asks_password_when_not_in_account(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "jabber_org", NULL }; gchar *args[] = { "jabber_org", NULL };
ProfAccount *account = account_new("jabber_org", "me@jabber.org", NULL, NULL, ProfAccount *account = account_new("jabber_org", "me@jabber.org", NULL, NULL,
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL); TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
@ -425,15 +135,237 @@ void cmd_connect_asks_password_when_not_in_account(void **state)
expect_any(jabber_connect_with_account, account); expect_any(jabber_connect_with_account, account);
will_return(jabber_connect_with_account, JABBER_CONNECTING); will_return(jabber_connect_with_account, JABBER_CONNECTING);
gboolean result = cmd_connect(NULL, args, *help); gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
assert_true(result); assert_true(result);
}
free(help); void cmd_connect_shows_usage_when_no_server_value(void **state)
{
gchar *args[] = { "user@server.org", "server", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_string(cons_bad_cmd_usage, cmd, CMD_CONNECT);
expect_cons_show("");
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
assert_true(result);
}
void cmd_connect_shows_usage_when_server_no_port_value(void **state)
{
gchar *args[] = { "user@server.org", "server", "aserver", "port", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_string(cons_bad_cmd_usage, cmd, CMD_CONNECT);
expect_cons_show("");
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
assert_true(result);
}
void cmd_connect_shows_usage_when_no_port_value(void **state)
{
gchar *args[] = { "user@server.org", "port", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_string(cons_bad_cmd_usage, cmd, CMD_CONNECT);
expect_cons_show("");
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
assert_true(result);
}
void cmd_connect_shows_usage_when_port_no_server_value(void **state)
{
gchar *args[] = { "user@server.org", "port", "5678", "server", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_string(cons_bad_cmd_usage, cmd, CMD_CONNECT);
expect_cons_show("");
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
assert_true(result);
}
void cmd_connect_shows_message_when_port_0(void **state)
{
gchar *args[] = { "user@server.org", "port", "0", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_cons_show("Value 0 out of range. Must be in 1..65535.");
expect_cons_show("");
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
assert_true(result);
}
void cmd_connect_shows_message_when_port_minus1(void **state)
{
gchar *args[] = { "user@server.org", "port", "-1", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_cons_show("Value -1 out of range. Must be in 1..65535.");
expect_cons_show("");
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
assert_true(result);
}
void cmd_connect_shows_message_when_port_65536(void **state)
{
gchar *args[] = { "user@server.org", "port", "65536", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_cons_show("Value 65536 out of range. Must be in 1..65535.");
expect_cons_show("");
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
assert_true(result);
}
void cmd_connect_shows_message_when_port_contains_chars(void **state)
{
gchar *args[] = { "user@server.org", "port", "52f66", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_cons_show("Could not convert \"52f66\" to a number.");
expect_cons_show("");
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
assert_true(result);
}
void cmd_connect_shows_usage_when_server_provided_twice(void **state)
{
gchar *args[] = { "user@server.org", "server", "server1", "server", "server2", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_string(cons_bad_cmd_usage, cmd, CMD_CONNECT);
expect_cons_show("");
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
assert_true(result);
}
void cmd_connect_shows_usage_when_port_provided_twice(void **state)
{
gchar *args[] = { "user@server.org", "port", "1111", "port", "1111", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_string(cons_bad_cmd_usage, cmd, CMD_CONNECT);
expect_cons_show("");
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
assert_true(result);
}
void cmd_connect_shows_usage_when_invalid_first_property(void **state)
{
gchar *args[] = { "user@server.org", "wrong", "server", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_string(cons_bad_cmd_usage, cmd, CMD_CONNECT);
expect_cons_show("");
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
assert_true(result);
}
void cmd_connect_shows_usage_when_invalid_second_property(void **state)
{
gchar *args[] = { "user@server.org", "server", "aserver", "wrong", "1234", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_string(cons_bad_cmd_usage, cmd, CMD_CONNECT);
expect_cons_show("");
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
assert_true(result);
}
void cmd_connect_with_server_when_provided(void **state)
{
gchar *args[] = { "user@server.org", "server", "aserver", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_string(accounts_get_account, name, "user@server.org");
will_return(accounts_get_account, NULL);
will_return(ui_ask_password, strdup("password"));
expect_cons_show("Connecting as user@server.org");
expect_string(jabber_connect_with_details, jid, "user@server.org");
expect_string(jabber_connect_with_details, passwd, "password");
expect_string(jabber_connect_with_details, altdomain, "aserver");
expect_value(jabber_connect_with_details, port, 0);
will_return(jabber_connect_with_details, JABBER_CONNECTING);
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
assert_true(result);
}
void cmd_connect_with_port_when_provided(void **state)
{
gchar *args[] = { "user@server.org", "port", "5432", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_string(accounts_get_account, name, "user@server.org");
will_return(accounts_get_account, NULL);
will_return(ui_ask_password, strdup("password"));
expect_cons_show("Connecting as user@server.org");
expect_string(jabber_connect_with_details, jid, "user@server.org");
expect_string(jabber_connect_with_details, passwd, "password");
expect_value(jabber_connect_with_details, altdomain, NULL);
expect_value(jabber_connect_with_details, port, 5432);
will_return(jabber_connect_with_details, JABBER_CONNECTING);
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
assert_true(result);
}
void cmd_connect_with_server_and_port_when_provided(void **state)
{
gchar *args[] = { "user@server.org", "port", "5432", "server", "aserver", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_string(accounts_get_account, name, "user@server.org");
will_return(accounts_get_account, NULL);
will_return(ui_ask_password, strdup("password"));
expect_cons_show("Connecting as user@server.org");
expect_string(jabber_connect_with_details, jid, "user@server.org");
expect_string(jabber_connect_with_details, passwd, "password");
expect_string(jabber_connect_with_details, altdomain, "aserver");
expect_value(jabber_connect_with_details, port, 5432);
will_return(jabber_connect_with_details, JABBER_CONNECTING);
gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
assert_true(result);
} }
void cmd_connect_shows_message_when_connecting_with_account(void **state) void cmd_connect_shows_message_when_connecting_with_account(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "jabber_org", NULL }; gchar *args[] = { "jabber_org", NULL };
ProfAccount *account = account_new("jabber_org", "user@jabber.org", "password", NULL, ProfAccount *account = account_new("jabber_org", "user@jabber.org", "password", NULL,
TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL); TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
@ -448,15 +380,12 @@ void cmd_connect_shows_message_when_connecting_with_account(void **state)
expect_any(jabber_connect_with_account, account); expect_any(jabber_connect_with_account, account);
will_return(jabber_connect_with_account, JABBER_CONNECTING); will_return(jabber_connect_with_account, JABBER_CONNECTING);
gboolean result = cmd_connect(NULL, args, *help); gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_connect_connects_with_account(void **state) void cmd_connect_connects_with_account(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "jabber_org", NULL }; gchar *args[] = { "jabber_org", NULL };
ProfAccount *account = account_new("jabber_org", "me@jabber.org", "password", NULL, ProfAccount *account = account_new("jabber_org", "me@jabber.org", "password", NULL,
TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL); TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
@ -471,8 +400,6 @@ void cmd_connect_connects_with_account(void **state)
expect_memory(jabber_connect_with_account, account, account, sizeof(account)); expect_memory(jabber_connect_with_account, account, account, sizeof(account));
will_return(jabber_connect_with_account, JABBER_CONNECTING); will_return(jabber_connect_with_account, JABBER_CONNECTING);
gboolean result = cmd_connect(NULL, args, *help); gboolean result = cmd_connect(NULL, CMD_CONNECT, args);
assert_true(result); assert_true(result);
free(help);
} }

View File

@ -12,10 +12,10 @@
#include "ui/stub_ui.h" #include "ui/stub_ui.h"
#define CMD_DISCONNECT "/disconnect"
void clears_chat_sessions(void **state) void clears_chat_sessions(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
chat_sessions_init(); chat_sessions_init();
roster_init(); roster_init();
chat_session_recipient_active("bob@server.org", "laptop", FALSE); chat_session_recipient_active("bob@server.org", "laptop", FALSE);
@ -25,7 +25,7 @@ void clears_chat_sessions(void **state)
will_return(jabber_get_fulljid, "myjid@myserver.com"); will_return(jabber_get_fulljid, "myjid@myserver.com");
expect_any_cons_show(); expect_any_cons_show();
gboolean result = cmd_disconnect(NULL, NULL, *help); gboolean result = cmd_disconnect(NULL, CMD_DISCONNECT, NULL);
assert_true(result); assert_true(result);
@ -33,5 +33,4 @@ void clears_chat_sessions(void **state)
ChatSession *session2 = chat_session_get("mike@server.org"); ChatSession *session2 = chat_session_get("mike@server.org");
assert_null(session1); assert_null(session1);
assert_null(session2); assert_null(session2);
free(help);
} }

View File

@ -16,18 +16,16 @@
#include "command/commands.h" #include "command/commands.h"
#include "muc.h" #include "muc.h"
#define CMD_JOIN "/join"
static void test_with_connection_status(jabber_conn_status_t status) static void test_with_connection_status(jabber_conn_status_t status)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
will_return(jabber_get_connection_status, status); will_return(jabber_get_connection_status, status);
expect_cons_show("You are not currently connected."); expect_cons_show("You are not currently connected.");
gboolean result = cmd_join(NULL, NULL, *help); gboolean result = cmd_join(NULL, CMD_JOIN, NULL);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_join_shows_message_when_disconnecting(void **state) void cmd_join_shows_message_when_disconnecting(void **state)
@ -52,7 +50,6 @@ void cmd_join_shows_message_when_undefined(void **state)
void cmd_join_shows_error_message_when_invalid_room_jid(void **state) void cmd_join_shows_error_message_when_invalid_room_jid(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "//@@/", NULL }; gchar *args[] = { "//@@/", NULL };
will_return(jabber_get_connection_status, JABBER_CONNECTED); will_return(jabber_get_connection_status, JABBER_CONNECTED);
@ -60,10 +57,8 @@ void cmd_join_shows_error_message_when_invalid_room_jid(void **state)
expect_cons_show_error("Specified room has incorrect format."); expect_cons_show_error("Specified room has incorrect format.");
expect_cons_show(""); expect_cons_show("");
gboolean result = cmd_join(NULL, args, *help); gboolean result = cmd_join(NULL, CMD_JOIN, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_join_uses_account_mucservice_when_no_service_specified(void **state) void cmd_join_uses_account_mucservice_when_no_service_specified(void **state)
@ -73,7 +68,6 @@ void cmd_join_uses_account_mucservice_when_no_service_specified(void **state)
char *nick = "bob"; char *nick = "bob";
char *account_service = "conference.server.org"; char *account_service = "conference.server.org";
char *expected_room = "room@conference.server.org"; char *expected_room = "room@conference.server.org";
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { room, "nick", nick, NULL }; gchar *args[] = { room, "nick", nick, NULL };
ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL, ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL,
TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, NULL, NULL, NULL, NULL, NULL, NULL); TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, NULL, NULL, NULL, NULL, NULL, NULL);
@ -90,10 +84,8 @@ void cmd_join_uses_account_mucservice_when_no_service_specified(void **state)
expect_string(presence_join_room, nick, nick); expect_string(presence_join_room, nick, nick);
expect_value(presence_join_room, passwd, NULL); expect_value(presence_join_room, passwd, NULL);
gboolean result = cmd_join(NULL, args, *help); gboolean result = cmd_join(NULL, CMD_JOIN, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_join_uses_supplied_nick(void **state) void cmd_join_uses_supplied_nick(void **state)
@ -101,7 +93,6 @@ void cmd_join_uses_supplied_nick(void **state)
char *account_name = "an_account"; char *account_name = "an_account";
char *room = "room@conf.server.org"; char *room = "room@conf.server.org";
char *nick = "bob"; char *nick = "bob";
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { room, "nick", nick, NULL }; gchar *args[] = { room, "nick", nick, NULL };
ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL, ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL,
TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL); TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
@ -118,10 +109,8 @@ void cmd_join_uses_supplied_nick(void **state)
expect_string(presence_join_room, nick, nick); expect_string(presence_join_room, nick, nick);
expect_value(presence_join_room, passwd, NULL); expect_value(presence_join_room, passwd, NULL);
gboolean result = cmd_join(NULL, args, *help); gboolean result = cmd_join(NULL, CMD_JOIN, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_join_uses_account_nick_when_not_supplied(void **state) void cmd_join_uses_account_nick_when_not_supplied(void **state)
@ -129,7 +118,6 @@ void cmd_join_uses_account_nick_when_not_supplied(void **state)
char *account_name = "an_account"; char *account_name = "an_account";
char *room = "room2@conf.server.org"; char *room = "room2@conf.server.org";
char *account_nick = "a_nick"; char *account_nick = "a_nick";
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { room, NULL }; gchar *args[] = { room, NULL };
ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL, ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL,
TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, account_nick, NULL, NULL, NULL, NULL, NULL); TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, account_nick, NULL, NULL, NULL, NULL, NULL);
@ -146,10 +134,8 @@ void cmd_join_uses_account_nick_when_not_supplied(void **state)
expect_string(presence_join_room, nick, account_nick); expect_string(presence_join_room, nick, account_nick);
expect_value(presence_join_room, passwd, NULL); expect_value(presence_join_room, passwd, NULL);
gboolean result = cmd_join(NULL, args, *help); gboolean result = cmd_join(NULL, CMD_JOIN, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_join_uses_password_when_supplied(void **state) void cmd_join_uses_password_when_supplied(void **state)
@ -160,7 +146,6 @@ void cmd_join_uses_password_when_supplied(void **state)
char *account_nick = "a_nick"; char *account_nick = "a_nick";
char *account_service = "a_service"; char *account_service = "a_service";
char *expected_room = "room@a_service"; char *expected_room = "room@a_service";
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { room, "password", password, NULL }; gchar *args[] = { room, "password", password, NULL };
ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL, ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL,
TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, account_nick, NULL, NULL, NULL, NULL, NULL); TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, account_nick, NULL, NULL, NULL, NULL, NULL);
@ -177,8 +162,6 @@ void cmd_join_uses_password_when_supplied(void **state)
expect_string(presence_join_room, nick, account_nick); expect_string(presence_join_room, nick, account_nick);
expect_value(presence_join_room, passwd, password); expect_value(presence_join_room, passwd, password);
gboolean result = cmd_join(NULL, args, *help); gboolean result = cmd_join(NULL, CMD_JOIN, args);
assert_true(result); assert_true(result);
free(help);
} }

View File

@ -22,86 +22,68 @@
#include "ui/ui.h" #include "ui/ui.h"
#include "ui/stub_ui.h" #include "ui/stub_ui.h"
#define CMD_OTR "/otr"
#ifdef HAVE_LIBOTR #ifdef HAVE_LIBOTR
void cmd_otr_shows_usage_when_no_args(void **state) void cmd_otr_shows_usage_when_no_args(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "Some usage";
gchar *args[] = { NULL }; gchar *args[] = { NULL };
expect_cons_show("Usage: Some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_OTR);
gboolean result = cmd_otr(NULL, args, *help); gboolean result = cmd_otr(NULL, CMD_OTR, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_otr_shows_usage_when_invalid_subcommand(void **state) void cmd_otr_shows_usage_when_invalid_subcommand(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "Some usage";
gchar *args[] = { "unknown", NULL }; gchar *args[] = { "unknown", NULL };
will_return(jabber_get_connection_status, JABBER_CONNECTED); will_return(jabber_get_connection_status, JABBER_CONNECTED);
expect_cons_show("Usage: Some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_OTR);
gboolean result = cmd_otr(NULL, args, *help); gboolean result = cmd_otr(NULL, CMD_OTR, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_otr_log_shows_usage_when_no_args(void **state) void cmd_otr_log_shows_usage_when_no_args(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "Some usage";
gchar *args[] = { "log", NULL }; gchar *args[] = { "log", NULL };
expect_cons_show("Usage: Some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_OTR);
gboolean result = cmd_otr(NULL, args, *help); gboolean result = cmd_otr(NULL, CMD_OTR, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_otr_log_shows_usage_when_invalid_subcommand(void **state) void cmd_otr_log_shows_usage_when_invalid_subcommand(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "Some usage";
gchar *args[] = { "log", "wrong", NULL }; gchar *args[] = { "log", "wrong", NULL };
expect_cons_show("Usage: Some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_OTR);
gboolean result = cmd_otr(NULL, args, *help); gboolean result = cmd_otr(NULL, CMD_OTR, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_otr_log_on_enables_logging(void **state) void cmd_otr_log_on_enables_logging(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "log", "on", NULL }; gchar *args[] = { "log", "on", NULL };
prefs_set_string(PREF_OTR_LOG, "off"); prefs_set_string(PREF_OTR_LOG, "off");
prefs_set_boolean(PREF_CHLOG, TRUE); prefs_set_boolean(PREF_CHLOG, TRUE);
expect_cons_show("OTR messages will be logged as plaintext."); expect_cons_show("OTR messages will be logged as plaintext.");
gboolean result = cmd_otr(NULL, args, *help); gboolean result = cmd_otr(NULL, CMD_OTR, args);
char *pref_otr_log = prefs_get_string(PREF_OTR_LOG); char *pref_otr_log = prefs_get_string(PREF_OTR_LOG);
assert_true(result); assert_true(result);
assert_string_equal("on", pref_otr_log); assert_string_equal("on", pref_otr_log);
free(help);
} }
void cmd_otr_log_on_shows_warning_when_chlog_disabled(void **state) void cmd_otr_log_on_shows_warning_when_chlog_disabled(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "log", "on", NULL }; gchar *args[] = { "log", "on", NULL };
prefs_set_string(PREF_OTR_LOG, "off"); prefs_set_string(PREF_OTR_LOG, "off");
prefs_set_boolean(PREF_CHLOG, FALSE); prefs_set_boolean(PREF_CHLOG, FALSE);
@ -109,51 +91,42 @@ void cmd_otr_log_on_shows_warning_when_chlog_disabled(void **state)
expect_cons_show("OTR messages will be logged as plaintext."); expect_cons_show("OTR messages will be logged as plaintext.");
expect_cons_show("Chat logging is currently disabled, use '/chlog on' to enable."); expect_cons_show("Chat logging is currently disabled, use '/chlog on' to enable.");
gboolean result = cmd_otr(NULL, args, *help); gboolean result = cmd_otr(NULL, CMD_OTR, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_otr_log_off_disables_logging(void **state) void cmd_otr_log_off_disables_logging(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "log", "off", NULL }; gchar *args[] = { "log", "off", NULL };
prefs_set_string(PREF_OTR_LOG, "on"); prefs_set_string(PREF_OTR_LOG, "on");
prefs_set_boolean(PREF_CHLOG, TRUE); prefs_set_boolean(PREF_CHLOG, TRUE);
expect_cons_show("OTR message logging disabled."); expect_cons_show("OTR message logging disabled.");
gboolean result = cmd_otr(NULL, args, *help); gboolean result = cmd_otr(NULL, CMD_OTR, args);
char *pref_otr_log = prefs_get_string(PREF_OTR_LOG); char *pref_otr_log = prefs_get_string(PREF_OTR_LOG);
assert_true(result); assert_true(result);
assert_string_equal("off", pref_otr_log); assert_string_equal("off", pref_otr_log);
free(help);
} }
void cmd_otr_redact_redacts_logging(void **state) void cmd_otr_redact_redacts_logging(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "log", "redact", NULL }; gchar *args[] = { "log", "redact", NULL };
prefs_set_string(PREF_OTR_LOG, "on"); prefs_set_string(PREF_OTR_LOG, "on");
prefs_set_boolean(PREF_CHLOG, TRUE); prefs_set_boolean(PREF_CHLOG, TRUE);
expect_cons_show("OTR messages will be logged as '[redacted]'."); expect_cons_show("OTR messages will be logged as '[redacted]'.");
gboolean result = cmd_otr(NULL, args, *help); gboolean result = cmd_otr(NULL, CMD_OTR, args);
char *pref_otr_log = prefs_get_string(PREF_OTR_LOG); char *pref_otr_log = prefs_get_string(PREF_OTR_LOG);
assert_true(result); assert_true(result);
assert_string_equal("redact", pref_otr_log); assert_string_equal("redact", pref_otr_log);
free(help);
} }
void cmd_otr_log_redact_shows_warning_when_chlog_disabled(void **state) void cmd_otr_log_redact_shows_warning_when_chlog_disabled(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "log", "redact", NULL }; gchar *args[] = { "log", "redact", NULL };
prefs_set_string(PREF_OTR_LOG, "off"); prefs_set_string(PREF_OTR_LOG, "off");
prefs_set_boolean(PREF_CHLOG, FALSE); prefs_set_boolean(PREF_CHLOG, FALSE);
@ -161,15 +134,12 @@ void cmd_otr_log_redact_shows_warning_when_chlog_disabled(void **state)
expect_cons_show("OTR messages will be logged as '[redacted]'."); expect_cons_show("OTR messages will be logged as '[redacted]'.");
expect_cons_show("Chat logging is currently disabled, use '/chlog on' to enable."); expect_cons_show("Chat logging is currently disabled, use '/chlog on' to enable.");
gboolean result = cmd_otr(NULL, args, *help); gboolean result = cmd_otr(NULL, CMD_OTR, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_otr_libver_shows_libotr_version(void **state) void cmd_otr_libver_shows_libotr_version(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "libver", NULL }; gchar *args[] = { "libver", NULL };
char *version = "9.9.9"; char *version = "9.9.9";
GString *message = g_string_new("Using libotr version "); GString *message = g_string_new("Using libotr version ");
@ -179,41 +149,34 @@ void cmd_otr_libver_shows_libotr_version(void **state)
expect_cons_show(message->str); expect_cons_show(message->str);
gboolean result = cmd_otr(NULL, args, *help); gboolean result = cmd_otr(NULL, CMD_OTR, args);
assert_true(result); assert_true(result);
g_string_free(message, TRUE); g_string_free(message, TRUE);
free(help);
} }
void cmd_otr_gen_shows_message_when_not_connected(void **state) void cmd_otr_gen_shows_message_when_not_connected(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "gen", NULL }; gchar *args[] = { "gen", NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED); will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_cons_show("You must be connected with an account to load OTR information."); expect_cons_show("You must be connected with an account to load OTR information.");
gboolean result = cmd_otr(NULL, args, *help); gboolean result = cmd_otr(NULL, CMD_OTR, args);
assert_true(result); assert_true(result);
free(help);
} }
static void test_with_command_and_connection_status(char *command, jabber_conn_status_t status) static void test_with_command_and_connection_status(char *command, jabber_conn_status_t status)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { command, NULL }; gchar *args[] = { command, NULL };
will_return(jabber_get_connection_status, status); will_return(jabber_get_connection_status, status);
expect_cons_show("You must be connected with an account to load OTR information."); expect_cons_show("You must be connected with an account to load OTR information.");
gboolean result = cmd_otr(NULL, args, *help); gboolean result = cmd_otr(NULL, CMD_OTR, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_otr_gen_shows_message_when_disconnected(void **state) void cmd_otr_gen_shows_message_when_disconnected(void **state)
@ -243,7 +206,6 @@ void cmd_otr_gen_shows_message_when_disconnecting(void **state)
void cmd_otr_gen_generates_key_for_connected_account(void **state) void cmd_otr_gen_generates_key_for_connected_account(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "gen", NULL }; gchar *args[] = { "gen", NULL };
char *account_name = "myaccount"; char *account_name = "myaccount";
ProfAccount *account = account_new(account_name, "me@jabber.org", NULL, NULL, ProfAccount *account = account_new(account_name, "me@jabber.org", NULL, NULL,
@ -258,10 +220,8 @@ void cmd_otr_gen_generates_key_for_connected_account(void **state)
expect_memory(otr_keygen, account, account, sizeof(ProfAccount)); expect_memory(otr_keygen, account, account, sizeof(ProfAccount));
gboolean result = cmd_otr(NULL, args, *help); gboolean result = cmd_otr(NULL, CMD_OTR, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_otr_myfp_shows_message_when_disconnected(void **state) void cmd_otr_myfp_shows_message_when_disconnected(void **state)
@ -291,7 +251,6 @@ void cmd_otr_myfp_shows_message_when_disconnecting(void **state)
void cmd_otr_myfp_shows_message_when_no_key(void **state) void cmd_otr_myfp_shows_message_when_no_key(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "myfp", NULL }; gchar *args[] = { "myfp", NULL };
will_return(jabber_get_connection_status, JABBER_CONNECTED); will_return(jabber_get_connection_status, JABBER_CONNECTED);
@ -299,16 +258,13 @@ void cmd_otr_myfp_shows_message_when_no_key(void **state)
expect_ui_current_print_formatted_line('!', 0, "You have not generated or loaded a private key, use '/otr gen'"); expect_ui_current_print_formatted_line('!', 0, "You have not generated or loaded a private key, use '/otr gen'");
gboolean result = cmd_otr(NULL, args, *help); gboolean result = cmd_otr(NULL, CMD_OTR, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_otr_myfp_shows_my_fingerprint(void **state) void cmd_otr_myfp_shows_my_fingerprint(void **state)
{ {
char *fingerprint = "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD EEEEEEEE"; char *fingerprint = "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD EEEEEEEE";
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "myfp", NULL }; gchar *args[] = { "myfp", NULL };
GString *message = g_string_new("Your OTR fingerprint: "); GString *message = g_string_new("Your OTR fingerprint: ");
g_string_append(message, fingerprint); g_string_append(message, fingerprint);
@ -319,17 +275,15 @@ void cmd_otr_myfp_shows_my_fingerprint(void **state)
expect_ui_current_print_formatted_line('!', 0, message->str); expect_ui_current_print_formatted_line('!', 0, message->str);
gboolean result = cmd_otr(NULL, args, *help); gboolean result = cmd_otr(NULL, CMD_OTR, args);
assert_true(result); assert_true(result);
g_string_free(message, TRUE); g_string_free(message, TRUE);
free(help);
} }
static void static void
test_cmd_otr_theirfp_from_wintype(win_type_t wintype) test_cmd_otr_theirfp_from_wintype(win_type_t wintype)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "theirfp", NULL }; gchar *args[] = { "theirfp", NULL };
ProfWin window; ProfWin window;
window.type = wintype; window.type = wintype;
@ -338,10 +292,9 @@ test_cmd_otr_theirfp_from_wintype(win_type_t wintype)
expect_ui_current_print_line("You must be in a regular chat window to view a recipient's fingerprint."); expect_ui_current_print_line("You must be in a regular chat window to view a recipient's fingerprint.");
gboolean result = cmd_otr(&window, args, *help); gboolean result = cmd_otr(&window, CMD_OTR, args);
assert_true(result);
free(help); assert_true(result);
} }
void cmd_otr_theirfp_shows_message_when_in_console(void **state) void cmd_otr_theirfp_shows_message_when_in_console(void **state)
@ -361,7 +314,6 @@ void cmd_otr_theirfp_shows_message_when_in_private(void **state)
void cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void **state) void cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "theirfp", NULL }; gchar *args[] = { "theirfp", NULL };
ProfWin window; ProfWin window;
@ -374,17 +326,15 @@ void cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void **state)
expect_ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session."); expect_ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
gboolean result = cmd_otr((ProfWin*)&chatwin, args, *help); gboolean result = cmd_otr((ProfWin*)&chatwin, CMD_OTR, args);
assert_true(result);
free(help); assert_true(result);
} }
void cmd_otr_theirfp_shows_fingerprint(void **state) void cmd_otr_theirfp_shows_fingerprint(void **state)
{ {
char *recipient = "someone@chat.com"; char *recipient = "someone@chat.com";
char *fingerprint = "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD EEEEEEEE"; char *fingerprint = "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD EEEEEEEE";
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "theirfp", NULL }; gchar *args[] = { "theirfp", NULL };
GString *message = g_string_new(recipient); GString *message = g_string_new(recipient);
g_string_append(message, "'s OTR fingerprint: "); g_string_append(message, "'s OTR fingerprint: ");
@ -405,17 +355,15 @@ void cmd_otr_theirfp_shows_fingerprint(void **state)
expect_ui_current_print_formatted_line('!', 0, message->str); expect_ui_current_print_formatted_line('!', 0, message->str);
gboolean result = cmd_otr((ProfWin*)&chatwin, args, *help); gboolean result = cmd_otr((ProfWin*)&chatwin, CMD_OTR, args);
assert_true(result); assert_true(result);
g_string_free(message, TRUE); g_string_free(message, TRUE);
free(help);
} }
static void static void
test_cmd_otr_start_from_wintype(win_type_t wintype) test_cmd_otr_start_from_wintype(win_type_t wintype)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "start", NULL }; gchar *args[] = { "start", NULL };
ProfWin window; ProfWin window;
window.type = wintype; window.type = wintype;
@ -424,10 +372,8 @@ test_cmd_otr_start_from_wintype(win_type_t wintype)
expect_ui_current_print_line("You must be in a regular chat window to start an OTR session."); expect_ui_current_print_line("You must be in a regular chat window to start an OTR session.");
gboolean result = cmd_otr(&window, args, *help); gboolean result = cmd_otr(&window, CMD_OTR, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_otr_start_shows_message_when_in_console(void **state) void cmd_otr_start_shows_message_when_in_console(void **state)
@ -448,7 +394,6 @@ void cmd_otr_start_shows_message_when_in_private(void **state)
void cmd_otr_start_shows_message_when_already_started(void **state) void cmd_otr_start_shows_message_when_already_started(void **state)
{ {
char *recipient = "someone@server.org"; char *recipient = "someone@server.org";
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "start", NULL }; gchar *args[] = { "start", NULL };
will_return(jabber_get_connection_status, JABBER_CONNECTED); will_return(jabber_get_connection_status, JABBER_CONNECTED);
@ -463,16 +408,13 @@ void cmd_otr_start_shows_message_when_already_started(void **state)
expect_ui_current_print_formatted_line('!', 0, "You are already in an OTR session."); expect_ui_current_print_formatted_line('!', 0, "You are already in an OTR session.");
gboolean result = cmd_otr((ProfWin*)&chatwin, args, *help); gboolean result = cmd_otr((ProfWin*)&chatwin, CMD_OTR, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_otr_start_shows_message_when_no_key(void **state) void cmd_otr_start_shows_message_when_no_key(void **state)
{ {
char *recipient = "someone@server.org"; char *recipient = "someone@server.org";
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "start", NULL }; gchar *args[] = { "start", NULL };
will_return(jabber_get_connection_status, JABBER_CONNECTED); will_return(jabber_get_connection_status, JABBER_CONNECTED);
@ -488,10 +430,8 @@ void cmd_otr_start_shows_message_when_no_key(void **state)
expect_ui_current_print_formatted_line('!', 0, "You have not generated or loaded a private key, use '/otr gen'"); expect_ui_current_print_formatted_line('!', 0, "You have not generated or loaded a private key, use '/otr gen'");
gboolean result = cmd_otr((ProfWin*)&chatwin, args, *help); gboolean result = cmd_otr((ProfWin*)&chatwin, CMD_OTR, args);
assert_true(result); assert_true(result);
free(help);
} }
void void
@ -499,7 +439,6 @@ cmd_otr_start_sends_otr_query_message_to_current_recipeint(void **state)
{ {
char *recipient = "buddy@chat.com"; char *recipient = "buddy@chat.com";
char *query_message = "?OTR?"; char *query_message = "?OTR?";
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "start", NULL }; gchar *args[] = { "start", NULL };
ProfWin window; ProfWin window;
@ -517,23 +456,18 @@ cmd_otr_start_sends_otr_query_message_to_current_recipeint(void **state)
expect_string(message_send_chat_otr, barejid, recipient); expect_string(message_send_chat_otr, barejid, recipient);
expect_string(message_send_chat_otr, msg, query_message); expect_string(message_send_chat_otr, msg, query_message);
gboolean result = cmd_otr((ProfWin*)&chatwin, args, *help); gboolean result = cmd_otr((ProfWin*)&chatwin, CMD_OTR, args);
assert_true(result); assert_true(result);
free(help);
} }
#else #else
void cmd_otr_shows_message_when_otr_unsupported(void **state) void cmd_otr_shows_message_when_otr_unsupported(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "gen", NULL }; gchar *args[] = { "gen", NULL };
expect_cons_show("This version of Profanity has not been built with OTR support enabled"); expect_cons_show("This version of Profanity has not been built with OTR support enabled");
gboolean result = cmd_otr(NULL, args, *help); gboolean result = cmd_otr(NULL, CMD_OTR, args);
assert_true(result); assert_true(result);
free(help);
} }
#endif #endif

View File

@ -12,25 +12,21 @@
#include "ui/stub_ui.h" #include "ui/stub_ui.h"
#define CMD_PGP "/pgp"
#ifdef HAVE_LIBGPGME #ifdef HAVE_LIBGPGME
void cmd_pgp_shows_usage_when_no_args(void **state) void cmd_pgp_shows_usage_when_no_args(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "Some usage";
gchar *args[] = { NULL }; gchar *args[] = { NULL };
expect_cons_show("Usage: Some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_PGP);
gboolean result = cmd_pgp(NULL, args, *help); gboolean result = cmd_pgp(NULL, CMD_PGP, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_pgp_start_shows_message_when_connection(jabber_conn_status_t conn_status) void cmd_pgp_start_shows_message_when_connection(jabber_conn_status_t conn_status)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "Some usage";
gchar *args[] = { "start", NULL }; gchar *args[] = { "start", NULL };
ProfWin window; ProfWin window;
window.type = WIN_CHAT; window.type = WIN_CHAT;
@ -39,10 +35,8 @@ void cmd_pgp_start_shows_message_when_connection(jabber_conn_status_t conn_statu
expect_cons_show("You must be connected to start PGP encrpytion."); expect_cons_show("You must be connected to start PGP encrpytion.");
gboolean result = cmd_pgp(&window, args, *help); gboolean result = cmd_pgp(&window, CMD_PGP, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_pgp_start_shows_message_when_disconnected(void **state) void cmd_pgp_start_shows_message_when_disconnected(void **state)
@ -72,8 +66,6 @@ void cmd_pgp_start_shows_message_when_started(void **state)
void cmd_pgp_start_shows_message_when_no_arg_in_wintype(win_type_t wintype) void cmd_pgp_start_shows_message_when_no_arg_in_wintype(win_type_t wintype)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "Some usage";
gchar *args[] = { "start", NULL }; gchar *args[] = { "start", NULL };
ProfWin window; ProfWin window;
window.type = wintype; window.type = wintype;
@ -82,10 +74,8 @@ void cmd_pgp_start_shows_message_when_no_arg_in_wintype(win_type_t wintype)
expect_cons_show("You must be in a regular chat window to start PGP encrpytion."); expect_cons_show("You must be in a regular chat window to start PGP encrpytion.");
gboolean result = cmd_pgp(&window, args, *help); gboolean result = cmd_pgp(&window, CMD_PGP, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_pgp_start_shows_message_when_no_arg_in_console(void **state) void cmd_pgp_start_shows_message_when_no_arg_in_console(void **state)
@ -116,14 +106,11 @@ void cmd_pgp_start_shows_message_when_no_arg_in_xmlconsole(void **state)
#else #else
void cmd_pgp_shows_message_when_pgp_unsupported(void **state) void cmd_pgp_shows_message_when_pgp_unsupported(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "gen", NULL }; gchar *args[] = { "gen", NULL };
expect_cons_show("This version of Profanity has not been built with PGP support enabled"); expect_cons_show("This version of Profanity has not been built with PGP support enabled");
gboolean result = cmd_pgp(NULL, args, *help); gboolean result = cmd_pgp(NULL, CMD_PGP, args);
assert_true(result); assert_true(result);
free(help);
} }
#endif #endif

View File

@ -14,18 +14,16 @@
#include "config/accounts.h" #include "config/accounts.h"
#include "command/commands.h" #include "command/commands.h"
#define CMD_ROOMS "/rooms"
static void test_with_connection_status(jabber_conn_status_t status) static void test_with_connection_status(jabber_conn_status_t status)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
will_return(jabber_get_connection_status, status); will_return(jabber_get_connection_status, status);
expect_cons_show("You are not currently connected."); expect_cons_show("You are not currently connected.");
gboolean result = cmd_rooms(NULL, NULL, *help); gboolean result = cmd_rooms(NULL, CMD_ROOMS, NULL);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_rooms_shows_message_when_disconnected(void **state) void cmd_rooms_shows_message_when_disconnected(void **state)
@ -55,7 +53,6 @@ void cmd_rooms_shows_message_when_undefined(void **state)
void cmd_rooms_uses_account_default_when_no_arg(void **state) void cmd_rooms_uses_account_default_when_no_arg(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { NULL }; gchar *args[] = { NULL };
ProfAccount *account = malloc(sizeof(ProfAccount)); ProfAccount *account = malloc(sizeof(ProfAccount));
account->name = NULL; account->name = NULL;
@ -81,25 +78,18 @@ void cmd_rooms_uses_account_default_when_no_arg(void **state)
expect_string(iq_room_list_request, conferencejid, "default_conf_server"); expect_string(iq_room_list_request, conferencejid, "default_conf_server");
gboolean result = cmd_rooms(NULL, args, *help); gboolean result = cmd_rooms(NULL, CMD_ROOMS, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_rooms_arg_used_when_passed(void **state) void cmd_rooms_arg_used_when_passed(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "conf_server_arg" }; gchar *args[] = { "conf_server_arg" };
will_return(jabber_get_connection_status, JABBER_CONNECTED); will_return(jabber_get_connection_status, JABBER_CONNECTED);
expect_string(iq_room_list_request, conferencejid, "conf_server_arg"); expect_string(iq_room_list_request, conferencejid, "conf_server_arg");
gboolean result = cmd_rooms(NULL, args, *help); gboolean result = cmd_rooms(NULL, CMD_ROOMS, args);
assert_true(result); assert_true(result);
free(help);
} }

View File

@ -13,19 +13,18 @@
#include "roster_list.h" #include "roster_list.h"
#include "command/commands.h" #include "command/commands.h"
#define CMD_ROSTER "/roster"
static void test_with_connection_status(jabber_conn_status_t status) static void test_with_connection_status(jabber_conn_status_t status)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { NULL }; gchar *args[] = { NULL };
will_return(jabber_get_connection_status, status); will_return(jabber_get_connection_status, status);
expect_cons_show("You are not currently connected."); expect_cons_show("You are not currently connected.");
gboolean result = cmd_roster(NULL, args, *help); gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_roster_shows_message_when_disconnecting(void **state) void cmd_roster_shows_message_when_disconnecting(void **state)
@ -50,7 +49,6 @@ void cmd_roster_shows_message_when_undefined(void **state)
void cmd_roster_shows_roster_when_no_args(void **state) void cmd_roster_shows_roster_when_no_args(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { NULL }; gchar *args[] = { NULL };
will_return(jabber_get_connection_status, JABBER_CONNECTED); will_return(jabber_get_connection_status, JABBER_CONNECTED);
@ -61,34 +59,28 @@ void cmd_roster_shows_roster_when_no_args(void **state)
expect_memory(cons_show_roster, list, roster, sizeof(roster)); expect_memory(cons_show_roster, list, roster, sizeof(roster));
gboolean result = cmd_roster(NULL, args, *help); gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
assert_true(result); assert_true(result);
free(help);
roster_free(); roster_free();
} }
void cmd_roster_add_shows_message_when_no_jid(void **state) void cmd_roster_add_shows_message_when_no_jid(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "add", NULL }; gchar *args[] = { "add", NULL };
will_return(jabber_get_connection_status, JABBER_CONNECTED); will_return(jabber_get_connection_status, JABBER_CONNECTED);
expect_cons_show("Usage: some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_ROSTER);
gboolean result = cmd_roster(NULL, args, *help); gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_roster_add_sends_roster_add_request(void **state) void cmd_roster_add_sends_roster_add_request(void **state)
{ {
char *jid = "bob@server.org"; char *jid = "bob@server.org";
char *nick = "bob"; char *nick = "bob";
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "add", jid, nick, NULL }; gchar *args[] = { "add", jid, nick, NULL };
will_return(jabber_get_connection_status, JABBER_CONNECTED); will_return(jabber_get_connection_status, JABBER_CONNECTED);
@ -96,80 +88,61 @@ void cmd_roster_add_sends_roster_add_request(void **state)
expect_string(roster_send_add_new, barejid, jid); expect_string(roster_send_add_new, barejid, jid);
expect_string(roster_send_add_new, name, nick); expect_string(roster_send_add_new, name, nick);
gboolean result = cmd_roster(NULL, args, *help); gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_roster_remove_shows_message_when_no_jid(void **state) void cmd_roster_remove_shows_message_when_no_jid(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "remove", NULL }; gchar *args[] = { "remove", NULL };
will_return(jabber_get_connection_status, JABBER_CONNECTED); will_return(jabber_get_connection_status, JABBER_CONNECTED);
expect_cons_show("Usage: some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_ROSTER);
gboolean result = cmd_roster(NULL, args, *help); gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_roster_remove_sends_roster_remove_request(void **state) void cmd_roster_remove_sends_roster_remove_request(void **state)
{ {
char *jid = "bob@server.org"; char *jid = "bob@server.org";
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "remove", jid, NULL }; gchar *args[] = { "remove", jid, NULL };
will_return(jabber_get_connection_status, JABBER_CONNECTED); will_return(jabber_get_connection_status, JABBER_CONNECTED);
expect_string(roster_send_remove, barejid, jid); expect_string(roster_send_remove, barejid, jid);
gboolean result = cmd_roster(NULL, args, *help); gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_roster_nick_shows_message_when_no_jid(void **state) void cmd_roster_nick_shows_message_when_no_jid(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "nick", NULL }; gchar *args[] = { "nick", NULL };
will_return(jabber_get_connection_status, JABBER_CONNECTED); will_return(jabber_get_connection_status, JABBER_CONNECTED);
expect_cons_show("Usage: some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_ROSTER);
gboolean result = cmd_roster(NULL, args, *help); gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_roster_nick_shows_message_when_no_nick(void **state) void cmd_roster_nick_shows_message_when_no_nick(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "nick", "bob@server.org", NULL }; gchar *args[] = { "nick", "bob@server.org", NULL };
will_return(jabber_get_connection_status, JABBER_CONNECTED); will_return(jabber_get_connection_status, JABBER_CONNECTED);
expect_cons_show("Usage: some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_ROSTER);
gboolean result = cmd_roster(NULL, args, *help); gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_roster_nick_shows_message_when_no_contact_exists(void **state) void cmd_roster_nick_shows_message_when_no_contact_exists(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "nick", "bob@server.org", "bobster", NULL }; gchar *args[] = { "nick", "bob@server.org", "bobster", NULL };
roster_init(); roster_init();
@ -178,10 +151,9 @@ void cmd_roster_nick_shows_message_when_no_contact_exists(void **state)
expect_cons_show("Contact not found in roster: bob@server.org"); expect_cons_show("Contact not found in roster: bob@server.org");
gboolean result = cmd_roster(NULL, args, *help); gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
assert_true(result); assert_true(result);
free(help);
roster_free(); roster_free();
} }
@ -189,7 +161,6 @@ void cmd_roster_nick_sends_name_change_request(void **state)
{ {
char *jid = "bob@server.org"; char *jid = "bob@server.org";
char *nick = "bobster"; char *nick = "bobster";
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "nick", jid, nick, NULL }; gchar *args[] = { "nick", jid, nick, NULL };
roster_init(); roster_init();
@ -205,36 +176,28 @@ void cmd_roster_nick_sends_name_change_request(void **state)
expect_cons_show("Nickname for bob@server.org set to: bobster."); expect_cons_show("Nickname for bob@server.org set to: bobster.");
gboolean result = cmd_roster(NULL, args, *help); gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
assert_true(result); assert_true(result);
PContact contact = roster_get_contact(jid); PContact contact = roster_get_contact(jid);
assert_string_equal(p_contact_name(contact), nick); assert_string_equal(p_contact_name(contact), nick);
free(help);
roster_free(); roster_free();
} }
void cmd_roster_clearnick_shows_message_when_no_jid(void **state) void cmd_roster_clearnick_shows_message_when_no_jid(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "clearnick", NULL }; gchar *args[] = { "clearnick", NULL };
will_return(jabber_get_connection_status, JABBER_CONNECTED); will_return(jabber_get_connection_status, JABBER_CONNECTED);
expect_cons_show("Usage: some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_ROSTER);
gboolean result = cmd_roster(NULL, args, *help); gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_roster_clearnick_shows_message_when_no_contact_exists(void **state) void cmd_roster_clearnick_shows_message_when_no_contact_exists(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "clearnick", "bob@server.org", NULL }; gchar *args[] = { "clearnick", "bob@server.org", NULL };
roster_init(); roster_init();
@ -243,17 +206,15 @@ void cmd_roster_clearnick_shows_message_when_no_contact_exists(void **state)
expect_cons_show("Contact not found in roster: bob@server.org"); expect_cons_show("Contact not found in roster: bob@server.org");
gboolean result = cmd_roster(NULL, args, *help); gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
assert_true(result); assert_true(result);
free(help);
roster_free(); roster_free();
} }
void cmd_roster_clearnick_sends_name_change_request_with_empty_nick(void **state) void cmd_roster_clearnick_sends_name_change_request_with_empty_nick(void **state)
{ {
char *jid = "bob@server.org"; char *jid = "bob@server.org";
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "clearnick", jid, NULL }; gchar *args[] = { "clearnick", jid, NULL };
roster_init(); roster_init();
@ -269,12 +230,11 @@ void cmd_roster_clearnick_sends_name_change_request_with_empty_nick(void **state
expect_cons_show("Nickname for bob@server.org removed."); expect_cons_show("Nickname for bob@server.org removed.");
gboolean result = cmd_roster(NULL, args, *help); gboolean result = cmd_roster(NULL, CMD_ROSTER, args);
assert_true(result); assert_true(result);
PContact contact = roster_get_contact(jid); PContact contact = roster_get_contact(jid);
assert_null(p_contact_name(contact)); assert_null(p_contact_name(contact));
free(help);
roster_free(); roster_free();
} }

View File

@ -13,211 +13,170 @@
#include "command/commands.h" #include "command/commands.h"
#define CMD_STATUSES "/statuses"
void cmd_statuses_shows_usage_when_bad_subcmd(void **state) void cmd_statuses_shows_usage_when_bad_subcmd(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "badcmd", NULL }; gchar *args[] = { "badcmd", NULL };
expect_cons_show("Usage: some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_STATUSES);
gboolean result = cmd_statuses(NULL, args, *help); gboolean result = cmd_statuses(NULL, CMD_STATUSES, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_statuses_shows_usage_when_bad_console_setting(void **state) void cmd_statuses_shows_usage_when_bad_console_setting(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "console", "badsetting", NULL }; gchar *args[] = { "console", "badsetting", NULL };
expect_cons_show("Usage: some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_STATUSES);
gboolean result = cmd_statuses(NULL, args, *help); gboolean result = cmd_statuses(NULL, CMD_STATUSES, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_statuses_shows_usage_when_bad_chat_setting(void **state) void cmd_statuses_shows_usage_when_bad_chat_setting(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "chat", "badsetting", NULL }; gchar *args[] = { "chat", "badsetting", NULL };
expect_cons_show("Usage: some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_STATUSES);
gboolean result = cmd_statuses(NULL, args, *help); gboolean result = cmd_statuses(NULL, CMD_STATUSES, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_statuses_shows_usage_when_bad_muc_setting(void **state) void cmd_statuses_shows_usage_when_bad_muc_setting(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "some usage";
gchar *args[] = { "muc", "badsetting", NULL }; gchar *args[] = { "muc", "badsetting", NULL };
expect_cons_show("Usage: some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_STATUSES);
gboolean result = cmd_statuses(NULL, args, *help); gboolean result = cmd_statuses(NULL, CMD_STATUSES, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_statuses_console_sets_all(void **state) void cmd_statuses_console_sets_all(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "console", "all", NULL }; gchar *args[] = { "console", "all", NULL };
expect_cons_show("All presence updates will appear in the console."); expect_cons_show("All presence updates will appear in the console.");
gboolean result = cmd_statuses(NULL, args, *help); gboolean result = cmd_statuses(NULL, CMD_STATUSES, args);
char *setting = prefs_get_string(PREF_STATUSES_CONSOLE); char *setting = prefs_get_string(PREF_STATUSES_CONSOLE);
assert_non_null(setting); assert_non_null(setting);
assert_string_equal("all", setting); assert_string_equal("all", setting);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_statuses_console_sets_online(void **state) void cmd_statuses_console_sets_online(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "console", "online", NULL }; gchar *args[] = { "console", "online", NULL };
expect_cons_show("Only online/offline presence updates will appear in the console."); expect_cons_show("Only online/offline presence updates will appear in the console.");
gboolean result = cmd_statuses(NULL, args, *help); gboolean result = cmd_statuses(NULL, CMD_STATUSES, args);
char *setting = prefs_get_string(PREF_STATUSES_CONSOLE); char *setting = prefs_get_string(PREF_STATUSES_CONSOLE);
assert_non_null(setting); assert_non_null(setting);
assert_string_equal("online", setting); assert_string_equal("online", setting);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_statuses_console_sets_none(void **state) void cmd_statuses_console_sets_none(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "console", "none", NULL }; gchar *args[] = { "console", "none", NULL };
expect_cons_show("Presence updates will not appear in the console."); expect_cons_show("Presence updates will not appear in the console.");
gboolean result = cmd_statuses(NULL, args, *help); gboolean result = cmd_statuses(NULL, CMD_STATUSES, args);
char *setting = prefs_get_string(PREF_STATUSES_CONSOLE); char *setting = prefs_get_string(PREF_STATUSES_CONSOLE);
assert_non_null(setting); assert_non_null(setting);
assert_string_equal("none", setting); assert_string_equal("none", setting);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_statuses_chat_sets_all(void **state) void cmd_statuses_chat_sets_all(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "chat", "all", NULL }; gchar *args[] = { "chat", "all", NULL };
expect_cons_show("All presence updates will appear in chat windows."); expect_cons_show("All presence updates will appear in chat windows.");
gboolean result = cmd_statuses(NULL, args, *help); gboolean result = cmd_statuses(NULL, CMD_STATUSES, args);
char *setting = prefs_get_string(PREF_STATUSES_CHAT); char *setting = prefs_get_string(PREF_STATUSES_CHAT);
assert_non_null(setting); assert_non_null(setting);
assert_string_equal("all", setting); assert_string_equal("all", setting);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_statuses_chat_sets_online(void **state) void cmd_statuses_chat_sets_online(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "chat", "online", NULL }; gchar *args[] = { "chat", "online", NULL };
expect_cons_show("Only online/offline presence updates will appear in chat windows."); expect_cons_show("Only online/offline presence updates will appear in chat windows.");
gboolean result = cmd_statuses(NULL, args, *help); gboolean result = cmd_statuses(NULL, CMD_STATUSES, args);
char *setting = prefs_get_string(PREF_STATUSES_CHAT); char *setting = prefs_get_string(PREF_STATUSES_CHAT);
assert_non_null(setting); assert_non_null(setting);
assert_string_equal("online", setting); assert_string_equal("online", setting);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_statuses_chat_sets_none(void **state) void cmd_statuses_chat_sets_none(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "chat", "none", NULL }; gchar *args[] = { "chat", "none", NULL };
expect_cons_show("Presence updates will not appear in chat windows."); expect_cons_show("Presence updates will not appear in chat windows.");
gboolean result = cmd_statuses(NULL, args, *help); gboolean result = cmd_statuses(NULL, CMD_STATUSES, args);
char *setting = prefs_get_string(PREF_STATUSES_CHAT); char *setting = prefs_get_string(PREF_STATUSES_CHAT);
assert_non_null(setting); assert_non_null(setting);
assert_string_equal("none", setting); assert_string_equal("none", setting);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_statuses_muc_sets_all(void **state) void cmd_statuses_muc_sets_all(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "muc", "all", NULL }; gchar *args[] = { "muc", "all", NULL };
expect_cons_show("All presence updates will appear in chat room windows."); expect_cons_show("All presence updates will appear in chat room windows.");
gboolean result = cmd_statuses(NULL, args, *help); gboolean result = cmd_statuses(NULL, CMD_STATUSES, args);
char *setting = prefs_get_string(PREF_STATUSES_MUC); char *setting = prefs_get_string(PREF_STATUSES_MUC);
assert_non_null(setting); assert_non_null(setting);
assert_string_equal("all", setting); assert_string_equal("all", setting);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_statuses_muc_sets_online(void **state) void cmd_statuses_muc_sets_online(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "muc", "online", NULL }; gchar *args[] = { "muc", "online", NULL };
expect_cons_show("Only join/leave presence updates will appear in chat room windows."); expect_cons_show("Only join/leave presence updates will appear in chat room windows.");
gboolean result = cmd_statuses(NULL, args, *help); gboolean result = cmd_statuses(NULL, CMD_STATUSES, args);
char *setting = prefs_get_string(PREF_STATUSES_MUC); char *setting = prefs_get_string(PREF_STATUSES_MUC);
assert_non_null(setting); assert_non_null(setting);
assert_string_equal("online", setting); assert_string_equal("online", setting);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_statuses_muc_sets_none(void **state) void cmd_statuses_muc_sets_none(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "muc", "none", NULL }; gchar *args[] = { "muc", "none", NULL };
expect_cons_show("Presence updates will not appear in chat room windows."); expect_cons_show("Presence updates will not appear in chat room windows.");
gboolean result = cmd_statuses(NULL, args, *help); gboolean result = cmd_statuses(NULL, CMD_STATUSES, args);
char *setting = prefs_get_string(PREF_STATUSES_MUC); char *setting = prefs_get_string(PREF_STATUSES_MUC);
assert_non_null(setting); assert_non_null(setting);
assert_string_equal("none", setting); assert_string_equal("none", setting);
assert_true(result); assert_true(result);
free(help);
} }

View File

@ -13,33 +13,28 @@
#include "command/commands.h" #include "command/commands.h"
#define CMD_SUB "/sub"
void cmd_sub_shows_message_when_not_connected(void **state) void cmd_sub_shows_message_when_not_connected(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { NULL }; gchar *args[] = { NULL };
will_return(jabber_get_connection_status, JABBER_DISCONNECTED); will_return(jabber_get_connection_status, JABBER_DISCONNECTED);
expect_cons_show("You are currently not connected."); expect_cons_show("You are currently not connected.");
gboolean result = cmd_sub(NULL, args, *help); gboolean result = cmd_sub(NULL, CMD_SUB, args);
assert_true(result); assert_true(result);
free(help);
} }
void cmd_sub_shows_usage_when_no_arg(void **state) void cmd_sub_shows_usage_when_no_arg(void **state)
{ {
CommandHelp *help = malloc(sizeof(CommandHelp));
help->usage = "Some usage";
gchar *args[] = { NULL }; gchar *args[] = { NULL };
will_return(jabber_get_connection_status, JABBER_CONNECTED); will_return(jabber_get_connection_status, JABBER_CONNECTED);
expect_cons_show("Usage: Some usage"); expect_string(cons_bad_cmd_usage, cmd, CMD_SUB);
gboolean result = cmd_sub(NULL, args, *help); gboolean result = cmd_sub(NULL, CMD_SUB, args);
assert_true(result); assert_true(result);
free(help);
} }

View File

@ -358,6 +358,10 @@ void cons_show(const char * const msg, ...)
va_end(args); va_end(args);
} }
void cons_show_padded(int pad, const char * const msg, ...) {}
void cons_show_help(Command *command) {}
void cons_about(void) {} void cons_about(void) {}
void cons_help(void) {} void cons_help(void) {}
void cons_navigation_help(void) {} void cons_navigation_help(void) {}
@ -396,6 +400,12 @@ void cons_show_roster(GSList * list)
check_expected(list); check_expected(list);
} }
void
cons_bad_cmd_usage(const char * const cmd)
{
check_expected(cmd);
}
void cons_show_roster_group(const char * const group, GSList * list) {} void cons_show_roster_group(const char * const group, GSList * list) {}
void cons_show_wins(void) {} void cons_show_wins(void) {}
void cons_show_status(const char * const barejid) {} void cons_show_status(const char * const barejid) {}
@ -531,8 +541,8 @@ 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, GDateTime *timestamp, int flags, theme_item_t theme_item, const char * const from, const char * const message) {} 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, 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, ...) {}
char* win_get_title(ProfWin *window) char* win_get_title(ProfWin *window)
{ {
return NULL; return NULL;
@ -541,7 +551,7 @@ 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, const char * const message) {} void win_println(ProfWin *window, int pad, const char * const message) {}
// desktop notifier actions // desktop notifier actions
void notifier_uninit(void) {} void notifier_uninit(void) {}

View File

@ -37,6 +37,7 @@
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
const UnitTest all_tests[] = { const UnitTest all_tests[] = {
unit_test(replace_one_substr), unit_test(replace_one_substr),
unit_test(replace_one_substr_beginning), unit_test(replace_one_substr_beginning),
unit_test(replace_one_substr_end), unit_test(replace_one_substr_end),
@ -214,6 +215,7 @@ int main(int argc, char* argv[]) {
unit_test_setup_teardown(removes_chat_session, unit_test_setup_teardown(removes_chat_session,
init_chat_sessions, init_chat_sessions,
close_chat_sessions), close_chat_sessions),
unit_test_setup_teardown(cmd_connect_shows_message_when_disconnecting, unit_test_setup_teardown(cmd_connect_shows_message_when_disconnecting,
load_preferences, load_preferences,
close_preferences), close_preferences),
@ -238,15 +240,15 @@ int main(int argc, char* argv[]) {
unit_test_setup_teardown(cmd_connect_asks_password_when_not_in_account, unit_test_setup_teardown(cmd_connect_asks_password_when_not_in_account,
load_preferences, load_preferences,
close_preferences), close_preferences),
unit_test_setup_teardown(cmd_connect_shows_usage_when_no_server_value,
load_preferences,
close_preferences),
unit_test_setup_teardown(cmd_connect_shows_message_when_connecting_with_account, unit_test_setup_teardown(cmd_connect_shows_message_when_connecting_with_account,
load_preferences, load_preferences,
close_preferences), close_preferences),
unit_test_setup_teardown(cmd_connect_connects_with_account, unit_test_setup_teardown(cmd_connect_connects_with_account,
load_preferences, load_preferences,
close_preferences), close_preferences),
unit_test_setup_teardown(cmd_connect_shows_usage_when_no_server_value,
load_preferences,
close_preferences),
unit_test_setup_teardown(cmd_connect_shows_usage_when_server_no_port_value, unit_test_setup_teardown(cmd_connect_shows_usage_when_server_no_port_value,
load_preferences, load_preferences,
close_preferences), close_preferences),