mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Tidied cmd_otr, added check-unit target to Makefile
This commit is contained in:
parent
6097a5bade
commit
fb0e065902
@ -174,3 +174,6 @@ $(git_include): $(git_include).in
|
|||||||
clean-local:
|
clean-local:
|
||||||
rm -f $(git_include) $(git_include).in
|
rm -f $(git_include) $(git_include).in
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
check-unit: tests/unittests/unittests
|
||||||
|
tests/unittests/unittests
|
||||||
|
@ -4200,29 +4200,34 @@ cmd_otr(gchar **args, struct cmd_help_t help)
|
|||||||
} else if (strcmp(args[0], "myfp") == 0) {
|
} else if (strcmp(args[0], "myfp") == 0) {
|
||||||
if (!otr_key_loaded()) {
|
if (!otr_key_loaded()) {
|
||||||
ui_current_print_formatted_line('!', 0, "You have not generated or loaded a private key, use '/otr gen'");
|
ui_current_print_formatted_line('!', 0, "You have not generated or loaded a private key, use '/otr gen'");
|
||||||
} else {
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
char *fingerprint = otr_get_my_fingerprint();
|
char *fingerprint = otr_get_my_fingerprint();
|
||||||
ui_current_print_formatted_line('!', 0, "Your OTR fingerprint: %s", fingerprint);
|
ui_current_print_formatted_line('!', 0, "Your OTR fingerprint: %s", fingerprint);
|
||||||
free(fingerprint);
|
free(fingerprint);
|
||||||
}
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
} else if (strcmp(args[0], "theirfp") == 0) {
|
} else if (strcmp(args[0], "theirfp") == 0) {
|
||||||
win_type_t win_type = ui_current_win_type();
|
win_type_t win_type = ui_current_win_type();
|
||||||
|
|
||||||
if (win_type != WIN_CHAT) {
|
if (win_type != WIN_CHAT) {
|
||||||
ui_current_print_line("You must be in a regular chat window to view a recipient's fingerprint.");
|
ui_current_print_line("You must be in a regular chat window to view a recipient's fingerprint.");
|
||||||
} else if (!ui_current_win_is_otr()) {
|
return TRUE;
|
||||||
ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
|
}
|
||||||
} else {
|
|
||||||
ProfChatWin *chatwin = wins_get_current_chat();
|
ProfChatWin *chatwin = wins_get_current_chat();
|
||||||
|
if (chatwin->enc_mode != PROF_ENC_OTR) {
|
||||||
|
ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
char *fingerprint = otr_get_their_fingerprint(chatwin->barejid);
|
char *fingerprint = otr_get_their_fingerprint(chatwin->barejid);
|
||||||
ui_current_print_formatted_line('!', 0, "%s's OTR fingerprint: %s", chatwin->barejid, fingerprint);
|
ui_current_print_formatted_line('!', 0, "%s's OTR fingerprint: %s", chatwin->barejid, fingerprint);
|
||||||
free(fingerprint);
|
free(fingerprint);
|
||||||
}
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
} else if (strcmp(args[0], "start") == 0) {
|
} else if (strcmp(args[0], "start") == 0) {
|
||||||
|
// recipient supplied
|
||||||
if (args[1]) {
|
if (args[1]) {
|
||||||
char *contact = args[1];
|
char *contact = args[1];
|
||||||
char *barejid = roster_barejid_from_name(contact);
|
char *barejid = roster_barejid_from_name(contact);
|
||||||
@ -4236,131 +4241,165 @@ cmd_otr(gchar **args, struct cmd_help_t help)
|
|||||||
}
|
}
|
||||||
ui_ev_focus_win((ProfWin*)chatwin);
|
ui_ev_focus_win((ProfWin*)chatwin);
|
||||||
|
|
||||||
if (ui_current_win_is_otr()) {
|
if (chatwin->enc_mode == PROF_ENC_OTR) {
|
||||||
ui_current_print_formatted_line('!', 0, "You are already in an OTR session.");
|
ui_current_print_formatted_line('!', 0, "You are already in an OTR session.");
|
||||||
} else {
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
if (!otr_key_loaded()) {
|
if (!otr_key_loaded()) {
|
||||||
ui_current_print_formatted_line('!', 0, "You have not generated or loaded a private key, use '/otr gen'");
|
ui_current_print_formatted_line('!', 0, "You have not generated or loaded a private key, use '/otr gen'");
|
||||||
} else if (!otr_is_secure(barejid)) {
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!otr_is_secure(barejid)) {
|
||||||
char *otr_query_message = otr_start_query();
|
char *otr_query_message = otr_start_query();
|
||||||
message_send_chat_encrypted(barejid, otr_query_message);
|
message_send_chat_encrypted(barejid, otr_query_message);
|
||||||
} else {
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
ui_gone_secure(barejid, otr_is_trusted(barejid));
|
ui_gone_secure(barejid, otr_is_trusted(barejid));
|
||||||
}
|
return TRUE;
|
||||||
}
|
|
||||||
|
// no recipient, use current chat
|
||||||
} else {
|
} else {
|
||||||
win_type_t win_type = ui_current_win_type();
|
win_type_t win_type = ui_current_win_type();
|
||||||
|
|
||||||
if (win_type != WIN_CHAT) {
|
if (win_type != WIN_CHAT) {
|
||||||
ui_current_print_line("You must be in a regular chat window to start an OTR session.");
|
ui_current_print_line("You must be in a regular chat window to start an OTR session.");
|
||||||
} else if (ui_current_win_is_otr()) {
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ProfChatWin *chatwin = wins_get_current_chat();
|
||||||
|
if (chatwin->enc_mode == PROF_ENC_OTR) {
|
||||||
ui_current_print_formatted_line('!', 0, "You are already in an OTR session.");
|
ui_current_print_formatted_line('!', 0, "You are already in an OTR session.");
|
||||||
} else {
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
if (!otr_key_loaded()) {
|
if (!otr_key_loaded()) {
|
||||||
ui_current_print_formatted_line('!', 0, "You have not generated or loaded a private key, use '/otr gen'");
|
ui_current_print_formatted_line('!', 0, "You have not generated or loaded a private key, use '/otr gen'");
|
||||||
} else {
|
return TRUE;
|
||||||
ProfChatWin *chatwin = wins_get_current_chat();
|
}
|
||||||
|
|
||||||
char *otr_query_message = otr_start_query();
|
char *otr_query_message = otr_start_query();
|
||||||
message_send_chat_encrypted(chatwin->barejid, otr_query_message);
|
message_send_chat_encrypted(chatwin->barejid, otr_query_message);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
} else if (strcmp(args[0], "end") == 0) {
|
} else if (strcmp(args[0], "end") == 0) {
|
||||||
win_type_t win_type = ui_current_win_type();
|
win_type_t win_type = ui_current_win_type();
|
||||||
|
|
||||||
if (win_type != WIN_CHAT) {
|
if (win_type != WIN_CHAT) {
|
||||||
ui_current_print_line("You must be in a regular chat window to use OTR.");
|
ui_current_print_line("You must be in a regular chat window to use OTR.");
|
||||||
} else if (!ui_current_win_is_otr()) {
|
return TRUE;
|
||||||
ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
|
}
|
||||||
} else {
|
|
||||||
ProfChatWin *chatwin = wins_get_current_chat();
|
ProfChatWin *chatwin = wins_get_current_chat();
|
||||||
|
if (chatwin->enc_mode != PROF_ENC_OTR) {
|
||||||
|
ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
ui_gone_insecure(chatwin->barejid);
|
ui_gone_insecure(chatwin->barejid);
|
||||||
otr_end_session(chatwin->barejid);
|
otr_end_session(chatwin->barejid);
|
||||||
}
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
} else if (strcmp(args[0], "trust") == 0) {
|
} else if (strcmp(args[0], "trust") == 0) {
|
||||||
win_type_t win_type = ui_current_win_type();
|
win_type_t win_type = ui_current_win_type();
|
||||||
|
|
||||||
if (win_type != WIN_CHAT) {
|
if (win_type != WIN_CHAT) {
|
||||||
ui_current_print_line("You must be in an OTR session to trust a recipient.");
|
ui_current_print_line("You must be in an OTR session to trust a recipient.");
|
||||||
} else if (!ui_current_win_is_otr()) {
|
return TRUE;
|
||||||
ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
|
}
|
||||||
} else {
|
|
||||||
ProfChatWin *chatwin = wins_get_current_chat();
|
ProfChatWin *chatwin = wins_get_current_chat();
|
||||||
|
if (chatwin->enc_mode != PROF_ENC_OTR) {
|
||||||
|
ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
ui_trust(chatwin->barejid);
|
ui_trust(chatwin->barejid);
|
||||||
otr_trust(chatwin->barejid);
|
otr_trust(chatwin->barejid);
|
||||||
}
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
} else if (strcmp(args[0], "untrust") == 0) {
|
} else if (strcmp(args[0], "untrust") == 0) {
|
||||||
win_type_t win_type = ui_current_win_type();
|
win_type_t win_type = ui_current_win_type();
|
||||||
|
|
||||||
if (win_type != WIN_CHAT) {
|
if (win_type != WIN_CHAT) {
|
||||||
ui_current_print_line("You must be in an OTR session to untrust a recipient.");
|
ui_current_print_line("You must be in an OTR session to untrust a recipient.");
|
||||||
} else if (!ui_current_win_is_otr()) {
|
return TRUE;
|
||||||
ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
|
}
|
||||||
} else {
|
|
||||||
ProfChatWin *chatwin = wins_get_current_chat();
|
ProfChatWin *chatwin = wins_get_current_chat();
|
||||||
|
if (chatwin->enc_mode != PROF_ENC_OTR) {
|
||||||
|
ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
ui_untrust(chatwin->barejid);
|
ui_untrust(chatwin->barejid);
|
||||||
otr_untrust(chatwin->barejid);
|
otr_untrust(chatwin->barejid);
|
||||||
}
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
} else if (strcmp(args[0], "secret") == 0) {
|
} else if (strcmp(args[0], "secret") == 0) {
|
||||||
win_type_t win_type = ui_current_win_type();
|
win_type_t win_type = ui_current_win_type();
|
||||||
if (win_type != WIN_CHAT) {
|
if (win_type != WIN_CHAT) {
|
||||||
ui_current_print_line("You must be in an OTR session to trust a recipient.");
|
ui_current_print_line("You must be in an OTR session to trust a recipient.");
|
||||||
} else if (!ui_current_win_is_otr()) {
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ProfChatWin *chatwin = wins_get_current_chat();
|
||||||
|
if (chatwin->enc_mode != PROF_ENC_OTR) {
|
||||||
ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
|
ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
|
||||||
} else {
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
char *secret = args[1];
|
char *secret = args[1];
|
||||||
if (secret == NULL) {
|
if (secret == NULL) {
|
||||||
cons_show("Usage: %s", help.usage);
|
cons_show("Usage: %s", help.usage);
|
||||||
} else {
|
return TRUE;
|
||||||
ProfChatWin *chatwin = wins_get_current_chat();
|
}
|
||||||
|
|
||||||
otr_smp_secret(chatwin->barejid, secret);
|
otr_smp_secret(chatwin->barejid, secret);
|
||||||
}
|
|
||||||
}
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
} else if (strcmp(args[0], "question") == 0) {
|
} else if (strcmp(args[0], "question") == 0) {
|
||||||
char *question = args[1];
|
char *question = args[1];
|
||||||
char *answer = args[2];
|
char *answer = args[2];
|
||||||
|
|
||||||
if (question == NULL || answer == NULL) {
|
if (question == NULL || answer == NULL) {
|
||||||
cons_show("Usage: %s", help.usage);
|
cons_show("Usage: %s", help.usage);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
}
|
||||||
|
|
||||||
win_type_t win_type = ui_current_win_type();
|
win_type_t win_type = ui_current_win_type();
|
||||||
if (win_type != WIN_CHAT) {
|
if (win_type != WIN_CHAT) {
|
||||||
ui_current_print_line("You must be in an OTR session to trust a recipient.");
|
ui_current_print_line("You must be in an OTR session to trust a recipient.");
|
||||||
} else if (!ui_current_win_is_otr()) {
|
|
||||||
ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
|
|
||||||
} else {
|
|
||||||
ProfChatWin *chatwin = wins_get_current_chat();
|
|
||||||
otr_smp_question(chatwin->barejid, question, answer);
|
|
||||||
}
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ProfChatWin *chatwin = wins_get_current_chat();
|
||||||
|
if (chatwin->enc_mode != PROF_ENC_OTR) {
|
||||||
|
ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
otr_smp_question(chatwin->barejid, question, answer);
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
} else if (strcmp(args[0], "answer") == 0) {
|
} else if (strcmp(args[0], "answer") == 0) {
|
||||||
win_type_t win_type = ui_current_win_type();
|
win_type_t win_type = ui_current_win_type();
|
||||||
if (win_type != WIN_CHAT) {
|
if (win_type != WIN_CHAT) {
|
||||||
ui_current_print_line("You must be in an OTR session to trust a recipient.");
|
ui_current_print_line("You must be in an OTR session to trust a recipient.");
|
||||||
} else if (!ui_current_win_is_otr()) {
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ProfChatWin *chatwin = wins_get_current_chat();
|
||||||
|
if (chatwin->enc_mode != PROF_ENC_OTR) {
|
||||||
ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
|
ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
|
||||||
} else {
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
char *answer = args[1];
|
char *answer = args[1];
|
||||||
if (answer == NULL) {
|
if (answer == NULL) {
|
||||||
cons_show("Usage: %s", help.usage);
|
cons_show("Usage: %s", help.usage);
|
||||||
} else {
|
return TRUE;
|
||||||
ProfChatWin *chatwin = wins_get_current_chat();
|
}
|
||||||
|
|
||||||
otr_smp_answer(chatwin->barejid, answer);
|
otr_smp_answer(chatwin->barejid, answer);
|
||||||
}
|
|
||||||
}
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -1151,19 +1151,6 @@ ui_current_win_type(void)
|
|||||||
return current->type;
|
return current->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
|
||||||
ui_current_win_is_otr(void)
|
|
||||||
{
|
|
||||||
ProfWin *current = wins_get_current();
|
|
||||||
if (current->type == WIN_CHAT) {
|
|
||||||
ProfChatWin *chatwin = (ProfChatWin*)current;
|
|
||||||
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
|
|
||||||
return chatwin->enc_mode == PROF_ENC_OTR;
|
|
||||||
} else {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
win_type_t
|
win_type_t
|
||||||
ui_win_type(int index)
|
ui_win_type(int index)
|
||||||
{
|
{
|
||||||
|
@ -194,7 +194,6 @@ int ui_close_read_wins(void);
|
|||||||
|
|
||||||
// current window actions
|
// current window actions
|
||||||
win_type_t ui_current_win_type(void);
|
win_type_t ui_current_win_type(void);
|
||||||
gboolean ui_current_win_is_otr(void);
|
|
||||||
|
|
||||||
void ui_current_print_line(const char * const msg, ...);
|
void ui_current_print_line(const char * const msg, ...);
|
||||||
void ui_current_print_formatted_line(const char show_char, int attrs, const char * const msg, ...);
|
void ui_current_print_formatted_line(const char show_char, int attrs, const char * const msg, ...);
|
||||||
|
@ -422,12 +422,21 @@ 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)
|
||||||
{
|
{
|
||||||
|
char *recipient = "someuser@someserver.com";
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||||
gchar *args[] = { "theirfp", NULL };
|
gchar *args[] = { "theirfp", NULL };
|
||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
||||||
will_return(ui_current_win_type, WIN_CHAT);
|
will_return(ui_current_win_type, WIN_CHAT);
|
||||||
will_return(ui_current_win_is_otr, FALSE);
|
|
||||||
|
ProfChatWin *chatwin = malloc(sizeof(ProfChatWin));
|
||||||
|
chatwin->barejid = strdup(recipient);
|
||||||
|
chatwin->memcheck = PROFCHATWIN_MEMCHECK;
|
||||||
|
will_return(win_create_chat, &chatwin->window);
|
||||||
|
|
||||||
|
wins_init();
|
||||||
|
wins_new_chat(recipient);
|
||||||
|
wins_set_current_by_num(2);
|
||||||
|
|
||||||
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.");
|
||||||
|
|
||||||
@ -435,6 +444,7 @@ void cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void **state)
|
|||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
free(help);
|
||||||
|
wins_close_current();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_otr_theirfp_shows_fingerprint(void **state)
|
void cmd_otr_theirfp_shows_fingerprint(void **state)
|
||||||
@ -450,6 +460,7 @@ void cmd_otr_theirfp_shows_fingerprint(void **state)
|
|||||||
ProfChatWin *chatwin = malloc(sizeof(ProfChatWin));
|
ProfChatWin *chatwin = malloc(sizeof(ProfChatWin));
|
||||||
chatwin->barejid = strdup(recipient);
|
chatwin->barejid = strdup(recipient);
|
||||||
chatwin->memcheck = PROFCHATWIN_MEMCHECK;
|
chatwin->memcheck = PROFCHATWIN_MEMCHECK;
|
||||||
|
chatwin->enc_mode = PROF_ENC_OTR;
|
||||||
will_return(win_create_chat, &chatwin->window);
|
will_return(win_create_chat, &chatwin->window);
|
||||||
|
|
||||||
wins_init();
|
wins_init();
|
||||||
@ -458,7 +469,6 @@ void cmd_otr_theirfp_shows_fingerprint(void **state)
|
|||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
||||||
will_return(ui_current_win_type, WIN_CHAT);
|
will_return(ui_current_win_type, WIN_CHAT);
|
||||||
will_return(ui_current_win_is_otr, TRUE);
|
|
||||||
|
|
||||||
expect_string(otr_get_their_fingerprint, recipient, chatwin->barejid);
|
expect_string(otr_get_their_fingerprint, recipient, chatwin->barejid);
|
||||||
will_return(otr_get_their_fingerprint, strdup(fingerprint));
|
will_return(otr_get_their_fingerprint, strdup(fingerprint));
|
||||||
@ -507,12 +517,22 @@ 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";
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
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);
|
||||||
will_return(ui_current_win_type, WIN_CHAT);
|
will_return(ui_current_win_type, WIN_CHAT);
|
||||||
will_return(ui_current_win_is_otr, TRUE);
|
|
||||||
|
ProfChatWin *chatwin = malloc(sizeof(ProfChatWin));
|
||||||
|
chatwin->barejid = strdup(recipient);
|
||||||
|
chatwin->memcheck = PROFCHATWIN_MEMCHECK;
|
||||||
|
chatwin->enc_mode = PROF_ENC_OTR;
|
||||||
|
will_return(win_create_chat, &chatwin->window);
|
||||||
|
|
||||||
|
wins_init();
|
||||||
|
wins_new_chat(recipient);
|
||||||
|
wins_set_current_by_num(2);
|
||||||
|
|
||||||
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.");
|
||||||
|
|
||||||
@ -520,24 +540,36 @@ void cmd_otr_start_shows_message_when_already_started(void **state)
|
|||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
free(help);
|
||||||
|
wins_close_current();
|
||||||
}
|
}
|
||||||
|
|
||||||
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";
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
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);
|
||||||
will_return(ui_current_win_type, WIN_CHAT);
|
will_return(ui_current_win_type, WIN_CHAT);
|
||||||
will_return(ui_current_win_is_otr, FALSE);
|
|
||||||
will_return(otr_key_loaded, FALSE);
|
will_return(otr_key_loaded, FALSE);
|
||||||
|
|
||||||
|
ProfChatWin *chatwin = malloc(sizeof(ProfChatWin));
|
||||||
|
chatwin->barejid = strdup(recipient);
|
||||||
|
chatwin->memcheck = PROFCHATWIN_MEMCHECK;
|
||||||
|
chatwin->enc_mode = PROF_ENC_NONE;
|
||||||
|
will_return(win_create_chat, &chatwin->window);
|
||||||
|
|
||||||
|
wins_init();
|
||||||
|
wins_new_chat(recipient);
|
||||||
|
wins_set_current_by_num(2);
|
||||||
|
|
||||||
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(args, *help);
|
gboolean result = cmd_otr(args, *help);
|
||||||
assert_true(result);
|
assert_true(result);
|
||||||
|
|
||||||
free(help);
|
free(help);
|
||||||
|
wins_close_current();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -559,7 +591,6 @@ cmd_otr_start_sends_otr_query_message_to_current_recipeint(void **state)
|
|||||||
|
|
||||||
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
will_return(jabber_get_connection_status, JABBER_CONNECTED);
|
||||||
will_return(ui_current_win_type, WIN_CHAT);
|
will_return(ui_current_win_type, WIN_CHAT);
|
||||||
will_return(ui_current_win_is_otr, FALSE);
|
|
||||||
will_return(otr_key_loaded, TRUE);
|
will_return(otr_key_loaded, TRUE);
|
||||||
will_return(otr_start_query, query_message);
|
will_return(otr_start_query, query_message);
|
||||||
|
|
||||||
|
@ -126,11 +126,6 @@ win_type_t ui_current_win_type(void)
|
|||||||
return (win_type_t)mock();
|
return (win_type_t)mock();
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean ui_current_win_is_otr(void)
|
|
||||||
{
|
|
||||||
return (gboolean)mock();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ui_current_print_line(const char * const msg, ...)
|
void ui_current_print_line(const char * const msg, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
|
Loading…
Reference in New Issue
Block a user