1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Added messaage when account resource changed whilst connected

This commit is contained in:
James Booth 2015-06-24 21:36:39 +01:00
parent 583bccf631
commit ae4c2781e1
4 changed files with 31 additions and 1 deletions

View File

@ -438,7 +438,11 @@ cmd_account(ProfWin *window, gchar **args, struct cmd_help_t help)
} }
} else if (strcmp(property, "resource") == 0) { } else if (strcmp(property, "resource") == 0) {
accounts_set_resource(account_name, value); accounts_set_resource(account_name, value);
if (jabber_get_connection_status() == JABBER_CONNECTED) {
cons_show("Updated resource for account %s: %s, you will need to reconnect to pick up the change.", account_name, value);
} else {
cons_show("Updated resource for account %s: %s", account_name, value); cons_show("Updated resource for account %s: %s", account_name, value);
}
cons_show(""); cons_show("");
} else if (strcmp(property, "password") == 0) { } else if (strcmp(property, "password") == 0) {
if(accounts_get_account(account_name)->eval_password) { if(accounts_get_account(account_name)->eval_password) {

View File

@ -458,6 +458,8 @@ void cmd_account_set_resource_sets_resource(void **state)
CommandHelp *help = malloc(sizeof(CommandHelp)); 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);
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);
@ -473,6 +475,28 @@ void cmd_account_set_resource_sets_resource(void **state)
free(help); free(help);
} }
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 };
will_return(jabber_get_connection_status, JABBER_CONNECTED);
expect_any(accounts_account_exists, account_name);
will_return(accounts_account_exists, TRUE);
expect_string(accounts_set_resource, account_name, "a_account");
expect_string(accounts_set_resource, value, "a_resource");
expect_cons_show("Updated resource for account a_account: a_resource, you will need to reconnect to pick up the change.");
expect_cons_show("");
gboolean result = cmd_account(NULL, args, *help);
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)); CommandHelp *help = malloc(sizeof(CommandHelp));

View File

@ -25,6 +25,7 @@ void cmd_account_set_jid_sets_barejid(void **state);
void cmd_account_set_jid_sets_resource(void **state); void cmd_account_set_jid_sets_resource(void **state);
void cmd_account_set_server_sets_server(void **state); void cmd_account_set_server_sets_server(void **state);
void cmd_account_set_resource_sets_resource(void **state); void cmd_account_set_resource_sets_resource(void **state);
void cmd_account_set_resource_sets_resource_with_online_message(void **state);
void cmd_account_set_password_sets_password(void **state); void cmd_account_set_password_sets_password(void **state);
void cmd_account_set_eval_password_sets_eval_password(void **state); void cmd_account_set_eval_password_sets_eval_password(void **state);
void cmd_account_set_password_when_eval_password_set(void **state); void cmd_account_set_password_when_eval_password_set(void **state);

View File

@ -325,6 +325,7 @@ int main(int argc, char* argv[]) {
unit_test(cmd_account_set_jid_sets_resource), unit_test(cmd_account_set_jid_sets_resource),
unit_test(cmd_account_set_server_sets_server), unit_test(cmd_account_set_server_sets_server),
unit_test(cmd_account_set_resource_sets_resource), unit_test(cmd_account_set_resource_sets_resource),
unit_test(cmd_account_set_resource_sets_resource_with_online_message),
unit_test(cmd_account_set_password_sets_password), unit_test(cmd_account_set_password_sets_password),
unit_test(cmd_account_set_eval_password_sets_eval_password), unit_test(cmd_account_set_eval_password_sets_eval_password),
unit_test(cmd_account_set_password_when_eval_password_set), unit_test(cmd_account_set_password_when_eval_password_set),