void cmd_join_uses_password_when_supplied(void **state) { char *account_name = "an_account"; char *room = "room"; char *password = "******"; char *account_nick = "a_nick"; char *account_service = "a_service"; char *expected_room = "room@a_service"; CommandHelp *help = malloc(sizeof(CommandHelp)); gchar *args[] = { room, "password", password, NULL }; ProfAccount *account = account_new(account_name, "*****@*****.**", NULL, TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, account_nick); muc_init(); mock_connection_status(JABBER_CONNECTED); mock_connection_account_name(account_name); mock_accounts_get_account(); accounts_get_account_expect_and_return(account_name, account); mock_presence_join_room(); presence_join_room_expect(expected_room, account_nick, password); ui_room_join_expect(expected_room, TRUE); gboolean result = cmd_join(args, *help); assert_true(result); free(help); }
void cmd_join_uses_account_mucservice_when_no_service_specified(void **state) { char *account_name = "an_account"; char *room = "room"; char *nick = "bob"; char *account_service = "conference.server.org"; char *expected_room = "*****@*****.**"; CommandHelp *help = malloc(sizeof(CommandHelp)); gchar *args[] = { room, "nick", nick, NULL }; ProfAccount *account = account_new(account_name, "*****@*****.**", NULL, TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, NULL); muc_init(); mock_connection_status(JABBER_CONNECTED); mock_connection_account_name(account_name); mock_accounts_get_account(); accounts_get_account_expect_and_return(account_name, account); mock_presence_join_room(); presence_join_room_expect(expected_room, nick, NULL); ui_room_join_expect(expected_room, TRUE); gboolean result = cmd_join(args, *help); assert_true(result); free(help); }
void cmd_join_uses_password_when_supplied(void **state) { char *account_name = "an_account"; char *room = "room"; char *password = "******"; char *account_nick = "a_nick"; char *account_service = "a_service"; char *expected_room = "room@a_service"; gchar *args[] = { room, "password", password, NULL }; ProfAccount *account = account_new(account_name, "*****@*****.**", NULL, NULL, TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, account_nick, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); muc_init(); will_return(jabber_get_connection_status, JABBER_CONNECTED); will_return(jabber_get_account_name, account_name); expect_string(accounts_get_account, name, account_name); will_return(accounts_get_account, account); expect_string(presence_join_room, room, expected_room); expect_string(presence_join_room, nick, account_nick); expect_value(presence_join_room, passwd, password); gboolean result = cmd_join(NULL, CMD_JOIN, args); assert_true(result); }
void cmd_join_uses_account_mucservice_when_no_service_specified(void **state) { char *account_name = "an_account"; char *room = "room"; char *nick = "bob"; char *account_service = "conference.server.org"; char *expected_room = "*****@*****.**"; gchar *args[] = { room, "nick", nick, NULL }; ProfAccount *account = account_new(account_name, "*****@*****.**", NULL, NULL, TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); muc_init(); will_return(connection_get_status, JABBER_CONNECTED); will_return(session_get_account_name, account_name); expect_string(accounts_get_account, name, account_name); will_return(accounts_get_account, account); expect_string(presence_join_room, room, expected_room); expect_string(presence_join_room, nick, nick); expect_value(presence_join_room, passwd, NULL); gboolean result = cmd_join(NULL, CMD_JOIN, args); assert_true(result); }
static void _init(char *log_level) { setlocale(LC_ALL, ""); // ignore SIGPIPE signal(SIGPIPE, SIG_IGN); signal(SIGINT, SIG_IGN); signal(SIGTSTP, SIG_IGN); signal(SIGWINCH, ui_sigwinch_handler); if (pthread_mutex_init(&lock, NULL) != 0) { log_error("Mutex init failed"); exit(1); } pthread_mutex_lock(&lock); files_create_directories(); log_level_t prof_log_level = log_level_from_string(log_level); prefs_load(); log_init(prof_log_level); log_stderr_init(PROF_LEVEL_ERROR); if (strcmp(PACKAGE_STATUS, "development") == 0) { #ifdef HAVE_GIT_VERSION log_info("Starting Profanity (%sdev.%s.%s)...", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION); #else log_info("Starting Profanity (%sdev)...", PACKAGE_VERSION); #endif } else { log_info("Starting Profanity (%s)...", PACKAGE_VERSION); } chat_log_init(); groupchat_log_init(); accounts_load(); char *theme = prefs_get_string(PREF_THEME); theme_init(theme); prefs_free_string(theme); ui_init(); session_init(); cmd_init(); log_info("Initialising contact list"); muc_init(); tlscerts_init(); scripts_init(); #ifdef HAVE_LIBOTR otr_init(); #endif #ifdef HAVE_LIBGPGME p_gpg_init(); #endif #ifdef HAVE_OMEMO omemo_init(); #endif atexit(_shutdown); plugins_init(); #ifdef HAVE_GTK tray_init(); #endif inp_nonblocking(TRUE); ui_resize(); }
static void _init(char *log_level) { setlocale(LC_ALL, ""); // ignore SIGPIPE signal(SIGPIPE, SIG_IGN); signal(SIGINT, SIG_IGN); signal(SIGTSTP, SIG_IGN); signal(SIGWINCH, ui_sigwinch_handler); _create_directories(); log_level_t prof_log_level = log_level_from_string(log_level); prefs_load(); log_init(prof_log_level); log_stderr_init(PROF_LEVEL_ERROR); if (strcmp(PROF_PACKAGE_STATUS, "development") == 0) { #ifdef PROF_HAVE_GIT_VERSION log_info("Starting Profanity (%sdev.%s.%s)...", PROF_PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION); #else log_info("Starting Profanity (%sdev)...", PROF_PACKAGE_VERSION); #endif } else { log_info("Starting Profanity (%s)...", PROF_PACKAGE_VERSION); } chat_log_init(); groupchat_log_init(); accounts_load(); char *theme = prefs_get_string(PREF_THEME); theme_init(theme); prefs_free_string(theme); ui_init(); jabber_init(); cmd_init(); log_info("Initialising contact list"); muc_init(); tlscerts_init(); scripts_init(); #ifdef PROF_HAVE_LIBOTR otr_init(); #endif #ifdef PROF_HAVE_LIBGPGME p_gpg_init(); #endif atexit(_shutdown); plugins_init(); #ifdef PROF_HAVE_GTK if (gtk_ready) { log_debug("Building GTK icon"); create_tray(); } #endif inp_nonblocking(TRUE); }
void xep_init(void) { disco_init(); /* init sevice discovery first */ chatstates_init(); composing_init(); delay_init(); muc_init(); oob_init(); ping_init(); registration_init(); vcard_init(); version_init(); }
static void _init(const int disable_tls, char *log_level) { setlocale(LC_ALL, ""); // ignore SIGPIPE signal(SIGPIPE, SIG_IGN); signal(SIGINT, SIG_IGN); signal(SIGTSTP, SIG_IGN); _create_directories(); log_level_t prof_log_level = log_level_from_string(log_level); prefs_load(); log_init(prof_log_level); if (strcmp(PACKAGE_STATUS, "development") == 0) { #ifdef HAVE_GIT_VERSION log_info("Starting Profanity (%sdev.%s.%s)...", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION); #else log_info("Starting Profanity (%sdev)...", PACKAGE_VERSION); #endif } else { log_info("Starting Profanity (%s)...", PACKAGE_VERSION); } chat_log_init(); groupchat_log_init(); accounts_load(); char *theme = prefs_get_string(PREF_THEME); theme_init(theme); prefs_free_string(theme); ui_init(); jabber_init(disable_tls); cmd_init(); log_info("Initialising contact list"); roster_init(); muc_init(); #ifdef HAVE_LIBOTR otr_init(); #endif atexit(_shutdown); ui_input_nonblocking(TRUE); }
void muc_before_test(void **state) { muc_init(); }