1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-06-23 21:45:30 +00:00

Merge branch 'master' into openpgp

This commit is contained in:
James Booth 2015-06-15 22:03:25 +01:00
commit de47450594
5 changed files with 25 additions and 27 deletions

View File

@ -4286,7 +4286,7 @@ cmd_otr(gchar **args, struct cmd_help_t help)
} else if (!ui_current_win_is_otr()) {
ui_current_print_formatted_line('!', 0, "You are not currently in an OTR session.");
} else {
ProfChatWin *chatwin = ui_get_current_chat();
ProfChatWin *chatwin = wins_get_current_chat();
char *fingerprint = otr_get_their_fingerprint(chatwin->barejid);
ui_current_print_formatted_line('!', 0, "%s's OTR fingerprint: %s", chatwin->barejid, fingerprint);
free(fingerprint);
@ -4330,7 +4330,7 @@ cmd_otr(gchar **args, struct cmd_help_t help)
if (!otr_key_loaded()) {
ui_current_print_formatted_line('!', 0, "You have not generated or loaded a private key, use '/otr gen'");
} else {
ProfChatWin *chatwin = ui_get_current_chat();
ProfChatWin *chatwin = wins_get_current_chat();
char *otr_query_message = otr_start_query();
message_send_chat_encrypted(chatwin->barejid, otr_query_message);
}

View File

@ -405,12 +405,6 @@ ui_get_chat_recipients(void)
return recipients;
}
ProfChatWin *
ui_get_current_chat(void)
{
return wins_get_current_chat();
}
void
ui_message_receipt(const char * const barejid, const char * const id)
{

View File

@ -196,8 +196,6 @@ int ui_close_read_wins(void);
win_type_t ui_current_win_type(void);
gboolean ui_current_win_is_otr(void);
ProfChatWin *ui_get_current_chat(void);
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_error_line(const char * const msg);

View File

@ -17,6 +17,7 @@
#include "command/command.h"
#include "command/commands.h"
#include "window_list.h"
#include "ui/ui.h"
#include "ui/stub_ui.h"
@ -442,15 +443,21 @@ void cmd_otr_theirfp_shows_fingerprint(void **state)
char *fingerprint = "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD EEEEEEEE";
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "theirfp", NULL };
ProfChatWin *chatwin = malloc(sizeof(ProfChatWin));
chatwin->barejid = strdup(recipient);
GString *message = g_string_new(chatwin->barejid);
GString *message = g_string_new(recipient);
g_string_append(message, "'s OTR fingerprint: ");
g_string_append(message, fingerprint);
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);
will_return(jabber_get_connection_status, JABBER_CONNECTED);
will_return(ui_current_win_type, WIN_CHAT);
will_return(ui_get_current_chat, chatwin);
will_return(ui_current_win_is_otr, TRUE);
expect_string(otr_get_their_fingerprint, recipient, chatwin->barejid);
@ -463,8 +470,7 @@ void cmd_otr_theirfp_shows_fingerprint(void **state)
g_string_free(message, TRUE);
free(help);
free(chatwin->barejid);
free(chatwin);
wins_close_current();
}
static void
@ -538,15 +544,21 @@ void
cmd_otr_start_sends_otr_query_message_to_current_recipeint(void **state)
{
char *recipient = "buddy@chat.com";
ProfChatWin *chatwin = malloc(sizeof(ProfChatWin));
chatwin->barejid = strdup(recipient);
char *query_message = "?OTR?";
CommandHelp *help = malloc(sizeof(CommandHelp));
gchar *args[] = { "start", NULL };
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);
will_return(jabber_get_connection_status, JABBER_CONNECTED);
will_return(ui_current_win_type, WIN_CHAT);
will_return(ui_get_current_chat, chatwin);
will_return(ui_current_win_is_otr, FALSE);
will_return(otr_key_loaded, TRUE);
will_return(otr_start_query, query_message);
@ -558,8 +570,7 @@ cmd_otr_start_sends_otr_query_message_to_current_recipeint(void **state)
assert_true(result);
free(help);
free(chatwin->barejid);
free(chatwin);
wins_close_current();
}
#else

View File

@ -131,11 +131,6 @@ gboolean ui_current_win_is_otr(void)
return (gboolean)mock();
}
ProfChatWin *ui_get_current_chat(void)
{
return (ProfChatWin*)mock();
}
void ui_current_print_line(const char * const msg, ...)
{
va_list args;
@ -517,7 +512,7 @@ ProfWin* win_create_xmlconsole(void)
}
ProfWin* win_create_chat(const char * const barejid)
{
return NULL;
return (ProfWin*)mock();
}
ProfWin* win_create_muc(const char * const roomjid)
{