mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Merge branch 'master' into plugins
This commit is contained in:
commit
050d996c1c
@ -236,8 +236,10 @@ if test "x$enable_otr" = xyes; then
|
||||
elif test "x$enable_otr" = xno; then
|
||||
AM_CONDITIONAL([BUILD_OTR], [false])
|
||||
elif test "x$enable_otr" = x; then
|
||||
AC_CHECK_LIB([otr], [main], [],
|
||||
[AM_CONDITIONAL([BUILD_OTR], [false]) AC_MSG_NOTICE([libotr not found, otr entryption support not enabled])])
|
||||
AM_CONDITIONAL([BUILD_OTR], [false])
|
||||
### Add the following back in once libotr 4.0.0 support is enabled
|
||||
### AC_CHECK_LIB([otr], [main], [],
|
||||
### [AM_CONDITIONAL([BUILD_OTR], [false]) AC_MSG_NOTICE([libotr not found, otr entryption support not enabled])])
|
||||
fi
|
||||
|
||||
### cmocka is required only for tests, profanity shouldn't be linked with it
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "otr.h"
|
||||
#endif
|
||||
|
||||
// TODO - replace with stanza error handlers
|
||||
void
|
||||
handle_error_message(const char *from, const char *err_msg)
|
||||
{
|
||||
@ -53,27 +54,28 @@ handle_error_message(const char *from, const char *err_msg)
|
||||
}
|
||||
}
|
||||
|
||||
// handle message stanza errors
|
||||
void
|
||||
handle_recipient_not_found(const char * const recipient, const char * const err_msg)
|
||||
handle_message_error(const char * const from, const char * const type,
|
||||
const char * const err_msg)
|
||||
{
|
||||
ui_handle_recipient_not_found(recipient, err_msg);
|
||||
if (prefs_get_boolean(PREF_STATES) && chat_session_exists(recipient)) {
|
||||
chat_session_set_recipient_supports(recipient, FALSE);
|
||||
// handle recipient not found ('from' contains a value and type is 'cancel')
|
||||
if ((from != NULL) && ((type != NULL && (strcmp(type, "cancel") == 0)))) {
|
||||
ui_handle_recipient_not_found(from, err_msg);
|
||||
if (prefs_get_boolean(PREF_STATES) && chat_session_exists(from)) {
|
||||
chat_session_set_recipient_supports(from, FALSE);
|
||||
}
|
||||
|
||||
// handle any other error from recipient
|
||||
} else if (from != NULL) {
|
||||
ui_handle_recipient_error(from, err_msg);
|
||||
|
||||
// handle errors from no recipient
|
||||
} else {
|
||||
ui_handle_error(err_msg);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
handle_recipient_error(const char * const recipient, const char * const err_msg)
|
||||
{
|
||||
ui_handle_recipient_error(recipient, err_msg);
|
||||
}
|
||||
|
||||
void
|
||||
handle_error(const char * const err_msg)
|
||||
{
|
||||
ui_handle_error(err_msg);
|
||||
}
|
||||
|
||||
void
|
||||
handle_login_account_success(char *account_name)
|
||||
{
|
||||
|
@ -75,8 +75,7 @@ void handle_group_remove(const char * const contact,
|
||||
void handle_roster_remove(const char * const barejid);
|
||||
void handle_roster_add(const char * const barejid, const char * const name);
|
||||
void handle_autoping_cancel(void);
|
||||
void handle_recipient_not_found(const char * const recipient, const char * const err_msg);
|
||||
void handle_recipient_error(const char * const recipient, const char * const err_msg);
|
||||
void handle_error(const char * const err_msg);
|
||||
void handle_message_error(const char * const from, const char * const type,
|
||||
const char * const err_msg);
|
||||
|
||||
#endif
|
||||
|
@ -224,18 +224,7 @@ _message_error_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
|
||||
g_string_free(log_msg, TRUE);
|
||||
|
||||
// handle recipient not found ('from' contains a value and type is 'cancel')
|
||||
if ((from != NULL) && ((type != NULL && (strcmp(type, "cancel") == 0)))) {
|
||||
handle_recipient_not_found(from, err_msg);
|
||||
|
||||
// handle any other error from recipient
|
||||
} else if (from != NULL) {
|
||||
handle_recipient_error(from, err_msg);
|
||||
|
||||
// handle errors from no recipient
|
||||
} else {
|
||||
handle_error(err_msg);
|
||||
}
|
||||
handle_message_error(from, type, err_msg);
|
||||
|
||||
free(err_msg);
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "common.h"
|
||||
#include "config/preferences.h"
|
||||
|
||||
void create_config_file(void **state)
|
||||
void init_preferences(void **state)
|
||||
{
|
||||
setenv("XDG_CONFIG_HOME", "./tests/files/xdg_config_home", 1);
|
||||
gchar *xdg_config = xdg_get_config_home();
|
||||
@ -30,7 +30,7 @@ void create_config_file(void **state)
|
||||
}
|
||||
}
|
||||
|
||||
void delete_config_file(void **state)
|
||||
void close_preferences(void **state)
|
||||
{
|
||||
prefs_close();
|
||||
remove("./tests/files/xdg_config_home/profanity/profrc");
|
||||
|
@ -1,2 +1,2 @@
|
||||
void create_config_file(void **state);
|
||||
void delete_config_file(void **state);
|
||||
void init_preferences(void **state);
|
||||
void close_preferences(void **state);
|
||||
|
@ -105,7 +105,7 @@ void cmd_alias_add_shows_message_when_exists(void **state)
|
||||
prefs_add_alias("hc", "/help commands");
|
||||
cmd_autocomplete_add("/hc");
|
||||
|
||||
expect_cons_show("Command or alias /hc already exists.");
|
||||
expect_cons_show("Command or alias '/hc' already exists.");
|
||||
|
||||
gboolean result = cmd_alias(args, *help);
|
||||
assert_true(result);
|
||||
|
@ -20,7 +20,7 @@ void contact_in_group(void **state)
|
||||
assert_true(result);
|
||||
|
||||
p_contact_free(contact);
|
||||
g_slist_free(groups);
|
||||
// g_slist_free(groups);
|
||||
}
|
||||
|
||||
void contact_not_in_group(void **state)
|
||||
@ -35,7 +35,7 @@ void contact_not_in_group(void **state)
|
||||
assert_false(result);
|
||||
|
||||
p_contact_free(contact);
|
||||
g_slist_free(groups);
|
||||
// g_slist_free(groups);
|
||||
}
|
||||
|
||||
void contact_name_when_name_exists(void **state)
|
||||
|
@ -104,3 +104,12 @@ void console_shows_dnd_presence_when_set_all(void **state)
|
||||
|
||||
roster_clear();
|
||||
}
|
||||
|
||||
void handle_message_stanza_error_when_no_from(void **state)
|
||||
{
|
||||
char *err_msg = "Some error.";
|
||||
mock_ui_handle_error();
|
||||
expect_ui_handle_error(err_msg);
|
||||
|
||||
handle_message_error(NULL, "cancel", err_msg);
|
||||
}
|
||||
|
@ -4,3 +4,4 @@ void console_shows_online_presence_when_set_all(void **state);
|
||||
void console_doesnt_show_dnd_presence_when_set_none(void **state);
|
||||
void console_doesnt_show_dnd_presence_when_set_online(void **state);
|
||||
void console_shows_dnd_presence_when_set_all(void **state);
|
||||
void handle_message_stanza_error_when_no_from(void **state);
|
||||
|
@ -333,62 +333,63 @@ int main(int argc, char* argv[]) {
|
||||
unit_test(cmd_statuses_shows_usage_when_bad_chat_setting),
|
||||
unit_test(cmd_statuses_shows_usage_when_bad_muc_setting),
|
||||
unit_test_setup_teardown(cmd_statuses_console_sets_all,
|
||||
create_config_file,
|
||||
delete_config_file),
|
||||
init_preferences,
|
||||
close_preferences),
|
||||
unit_test_setup_teardown(cmd_statuses_console_sets_online,
|
||||
create_config_file,
|
||||
delete_config_file),
|
||||
init_preferences,
|
||||
close_preferences),
|
||||
unit_test_setup_teardown(cmd_statuses_console_sets_none,
|
||||
create_config_file,
|
||||
delete_config_file),
|
||||
init_preferences,
|
||||
close_preferences),
|
||||
unit_test_setup_teardown(cmd_statuses_chat_sets_all,
|
||||
create_config_file,
|
||||
delete_config_file),
|
||||
init_preferences,
|
||||
close_preferences),
|
||||
unit_test_setup_teardown(cmd_statuses_chat_sets_online,
|
||||
create_config_file,
|
||||
delete_config_file),
|
||||
init_preferences,
|
||||
close_preferences),
|
||||
unit_test_setup_teardown(cmd_statuses_chat_sets_none,
|
||||
create_config_file,
|
||||
delete_config_file),
|
||||
init_preferences,
|
||||
close_preferences),
|
||||
unit_test_setup_teardown(cmd_statuses_muc_sets_on,
|
||||
create_config_file,
|
||||
delete_config_file),
|
||||
init_preferences,
|
||||
close_preferences),
|
||||
unit_test_setup_teardown(cmd_statuses_muc_sets_off,
|
||||
create_config_file,
|
||||
delete_config_file),
|
||||
init_preferences,
|
||||
close_preferences),
|
||||
};
|
||||
|
||||
const UnitTest preferences_tests[] = {
|
||||
unit_test_setup_teardown(statuses_console_defaults_to_all,
|
||||
create_config_file,
|
||||
delete_config_file),
|
||||
init_preferences,
|
||||
close_preferences),
|
||||
unit_test_setup_teardown(statuses_chat_defaults_to_all,
|
||||
create_config_file,
|
||||
delete_config_file),
|
||||
init_preferences,
|
||||
close_preferences),
|
||||
unit_test_setup_teardown(statuses_muc_defaults_to_on,
|
||||
create_config_file,
|
||||
delete_config_file),
|
||||
init_preferences,
|
||||
close_preferences),
|
||||
};
|
||||
|
||||
const UnitTest server_events_tests[] = {
|
||||
unit_test_setup_teardown(console_doesnt_show_online_presence_when_set_none,
|
||||
create_config_file,
|
||||
delete_config_file),
|
||||
init_preferences,
|
||||
close_preferences),
|
||||
unit_test_setup_teardown(console_shows_online_presence_when_set_online,
|
||||
create_config_file,
|
||||
delete_config_file),
|
||||
init_preferences,
|
||||
close_preferences),
|
||||
unit_test_setup_teardown(console_shows_online_presence_when_set_all,
|
||||
create_config_file,
|
||||
delete_config_file),
|
||||
init_preferences,
|
||||
close_preferences),
|
||||
unit_test_setup_teardown(console_doesnt_show_dnd_presence_when_set_none,
|
||||
create_config_file,
|
||||
delete_config_file),
|
||||
init_preferences,
|
||||
close_preferences),
|
||||
unit_test_setup_teardown(console_doesnt_show_dnd_presence_when_set_online,
|
||||
create_config_file,
|
||||
delete_config_file),
|
||||
// unit_test_setup_teardown(console_shows_dnd_presence_when_set_all,
|
||||
// create_config_file,
|
||||
// delete_config_file),
|
||||
init_preferences,
|
||||
close_preferences),
|
||||
unit_test_setup_teardown(console_shows_dnd_presence_when_set_all,
|
||||
init_preferences,
|
||||
close_preferences),
|
||||
unit_test(handle_message_stanza_error_when_no_from)
|
||||
};
|
||||
|
||||
const UnitTest cmd_alias_tests[] = {
|
||||
@ -397,23 +398,22 @@ int main(int argc, char* argv[]) {
|
||||
unit_test(cmd_alias_remove_shows_usage_when_no_args),
|
||||
unit_test(cmd_alias_show_usage_when_invalid_subcmd),
|
||||
unit_test_setup_teardown(cmd_alias_add_adds_alias,
|
||||
create_config_file,
|
||||
delete_config_file),
|
||||
// unit_test_setup_teardown(cmd_alias_add_shows_message_when_exists,
|
||||
// create_config_file,
|
||||
// delete_config_file),
|
||||
init_preferences,
|
||||
close_preferences),
|
||||
unit_test_setup_teardown(cmd_alias_add_shows_message_when_exists,
|
||||
init_preferences,
|
||||
close_preferences),
|
||||
unit_test_setup_teardown(cmd_alias_remove_removes_alias,
|
||||
create_config_file,
|
||||
delete_config_file),
|
||||
init_preferences,
|
||||
close_preferences),
|
||||
unit_test_setup_teardown(cmd_alias_remove_shows_message_when_no_alias,
|
||||
create_config_file,
|
||||
delete_config_file),
|
||||
init_preferences,
|
||||
close_preferences),
|
||||
unit_test_setup_teardown(cmd_alias_list_shows_all_aliases,
|
||||
create_config_file,
|
||||
delete_config_file),
|
||||
init_preferences,
|
||||
close_preferences),
|
||||
};
|
||||
|
||||
|
||||
int bak, new;
|
||||
fflush(stdout);
|
||||
bak = dup(1);
|
||||
@ -442,6 +442,7 @@ int main(int argc, char* argv[]) {
|
||||
fflush(stdout);
|
||||
dup2(bak, 1);
|
||||
close(bak);
|
||||
|
||||
if (result > 0) {
|
||||
return 1;
|
||||
} else {
|
||||
|
@ -92,6 +92,12 @@ char * _stub_ui_ask_password(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static
|
||||
void _mock_ui_handle_error(const char * const err_msg)
|
||||
{
|
||||
check_expected(err_msg);
|
||||
}
|
||||
|
||||
static
|
||||
void _stub_ui_chat_win_contact_online(PContact contact, Resource *resource, GDateTime *last_activity)
|
||||
{
|
||||
@ -159,6 +165,12 @@ stub_cons_show(void)
|
||||
cons_show = _stub_cons_show;
|
||||
}
|
||||
|
||||
void
|
||||
mock_ui_handle_error(void)
|
||||
{
|
||||
ui_handle_error = _mock_ui_handle_error;
|
||||
}
|
||||
|
||||
void
|
||||
expect_cons_show(char *output)
|
||||
{
|
||||
@ -213,3 +225,9 @@ mock_ui_ask_password_returns(char *password)
|
||||
{
|
||||
will_return(_mock_ui_ask_password, strdup(password));
|
||||
}
|
||||
|
||||
void
|
||||
expect_ui_handle_error(char *err_msg)
|
||||
{
|
||||
expect_string(_mock_ui_handle_error, err_msg, err_msg);
|
||||
}
|
||||
|
@ -18,6 +18,9 @@ void stub_ui_chat_win_contact_online(void);
|
||||
void mock_cons_show_error(void);
|
||||
void expect_cons_show_error(char *output);
|
||||
|
||||
void mock_ui_handle_error(void);
|
||||
void expect_ui_handle_error(char *err_msg);
|
||||
|
||||
void mock_cons_show_account(void);
|
||||
void expect_cons_show_account(ProfAccount *account);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user