コード例 #1
0
ファイル: client.c プロジェクト: ProfDrLuigi/zanka
void wr_client_init(void) {
	wr_server_string_encoding = wi_string_encoding_init_with_charset(
		wi_string_encoding_alloc(),
		WI_STR("UTF-8"),
		WI_STRING_ENCODING_IGNORE | WI_STRING_ENCODING_TRANSLITERATE);
	
	wr_client_set_charset(WI_STR("UTF-8"));
	
	wr_nick = wi_retain(wi_user_name());
	wr_icon = wi_data_init_with_base64(wi_data_alloc(), wi_string_with_cstring(wr_default_icon));
}
コード例 #2
0
ファイル: client.c プロジェクト: ProfDrLuigi/wirebot
void wr_client_apply_settings(wi_set_t *changes) {
    wi_string_t 		*command;
    wi_p7_message_t		*message;

    if(wi_set_contains_data(changes, WI_STR("nick"))) {
        wi_release(wr_nick);

        wr_nick 	= wi_retain(wi_config_string_for_name(wd_config, WI_STR("nick")));

        if(!wr_nick)
            wr_nick = wi_retain(wi_user_name());

        if(wr_connected) {
            message = wi_p7_message_with_name(WI_STR("wired.user.set_nick"), wr_p7_spec);
            wi_p7_message_set_string_for_name(message, wr_nick, WI_STR("wired.user.nick"));
            wr_client_send_message(message);
        }
    }

    if(wi_set_contains_data(changes, WI_STR("status"))) {
        wi_release(wr_status);

        wr_status 	= wi_retain(wi_config_string_for_name(wd_config, WI_STR("status")));

        if(wr_connected) {
            message = wi_p7_message_with_name(WI_STR("wired.user.set_status"), wr_p7_spec);
            wi_p7_message_set_string_for_name(message, wr_status, WI_STR("wired.user.status"));
            wr_client_send_message(message);
        }
    }

    if(wi_set_contains_data(changes, WI_STR("icon"))) {

        wr_client_reload_icon();

        // wi_fs_path_exists(wr_icon_path, false) {
        // 	wi_release(wr_icon);

        // 	wr_icon 	= wi_data_init_with_contents_of_file(wi_data_alloc(), wr_icon_path);

        // 	if(!wr_icon)
        // 		wr_icon = wi_data_init_with_base64(wi_data_alloc(), wi_string_with_cstring(wr_default_icon));

        if(wr_connected) {
            message = wi_p7_message_with_name(WI_STR("wired.user.set_icon"), wr_p7_spec);
            wi_p7_message_set_data_for_name(message, wr_icon, WI_STR("wired.user.icon"));
            wr_client_send_message(message);
        }
        //}
    }
}
コード例 #3
0
ファイル: client.c プロジェクト: ProfDrLuigi/zanka
void wr_client_init(void) {
	wr_socket_tls = wi_socket_tls_init_with_type(wi_socket_tls_alloc(), WI_SOCKET_TLS_CLIENT);
	
	if(!wr_socket_tls)
		wi_log_error(WI_STR("Could not create TLS context: %m"));
	
	if(!wi_socket_tls_set_ciphers(wr_socket_tls, WI_STR("ALL:NULL:!MD5:@STRENGTH")))
		wi_log_error(WI_STR("Could not set TLS ciphers: %m"));
	
	wr_server_string_encoding = wi_string_encoding_init_with_charset(
		wi_string_encoding_alloc(),
		WI_STR("UTF-8"),
		WI_STRING_ENCODING_IGNORE | WI_STRING_ENCODING_TRANSLITERATE);
	
	wr_set_charset(WI_STR("UTF-8"));
	
	wr_nick = wi_retain(wi_user_name());
	wr_icon = wi_string_init_with_cstring(wi_string_alloc(), wr_default_icon);
}
コード例 #4
0
void wi_test_system(void) {
    wi_array_t  *backtrace;
    
    WI_TEST_ASSERT_TRUE(wi_user_id() >= 0, "");
    WI_TEST_ASSERT_TRUE(wi_string_length(wi_user_name()) > 0, "");
    WI_TEST_ASSERT_TRUE(wi_string_length(wi_user_home()) > 0, "");
    WI_TEST_ASSERT_TRUE(wi_group_id() >= 0, "");
    WI_TEST_ASSERT_TRUE(wi_string_length(wi_group_name()) > 0, "");

    WI_TEST_ASSERT_TRUE(wi_page_size() > 0, "");
    
    backtrace = wi_backtrace();
    
    if(backtrace) {
        WI_TEST_ASSERT_TRUE(wi_array_count(backtrace) > 0, "");
        WI_TEST_ASSERT_NOT_EQUALS(wi_string_index_of_string(wi_array_components_joined_by_string(backtrace, WI_STR("\n")),
                                                            WI_STR("test"), 0),
                                  WI_NOT_FOUND, "");
    }
    
    WI_TEST_ASSERT_TRUE(wi_string_length(wi_getenv(WI_STR("HOME"))) > 0, "");
}
コード例 #5
0
ファイル: client.c プロジェクト: ProfDrLuigi/wirebot
void wr_client_init(void) {
    wr_server_string_encoding = wi_string_encoding_init_with_charset(
                                    wi_string_encoding_alloc(),
                                    WI_STR("UTF-8"),
                                    WI_STRING_ENCODING_IGNORE | WI_STRING_ENCODING_TRANSLITERATE);

    //wr_client_set_charset(WI_STR("UTF-8"));

    wr_nick 	= wi_retain(wi_config_string_for_name(wd_config, WI_STR("nick")));
    wr_status 	= wi_retain(wi_config_string_for_name(wd_config, WI_STR("status")));

    // if(wi_fs_path_exists(wr_icon_path, false)) {
    // 	wi_log_info(WI_STR("wr_icon_path: %@"), wr_icon_path);
    // 	wr_icon	= wi_data_init_with_contents_of_file(wi_data_alloc(), wr_icon_path);
    // }

    if(!wr_nick)
        wr_nick = wi_retain(wi_user_name());

    // if(!wr_icon)
    // 	wr_icon = wi_data_init_with_base64(wi_data_alloc(), wi_string_with_cstring(wr_default_icon));

    wr_client_reload_icon();
}
コード例 #6
0
ファイル: main.c プロジェクト: ProfDrLuigi/zanka
int main(int argc, const char **argv) {
	wi_pool_t			*pool;
	wi_string_t			*homepath, *wirepath, *path, *component;
	wi_file_t			*file;	
	int					ch;

	/* init libwired */
	wi_initialize();
	wi_load(argc, argv);
	
	pool				= wi_pool_init(wi_pool_alloc());
	wi_log_callback		= wr_wi_log_callback;
	
	/* init core systems */
	wr_version_init();
	wr_start_date		= wi_date_init(wi_date_alloc());
	
	/* set defaults */
	wr_nick				= wi_retain(wi_user_name());
	homepath			= wi_user_home();
	wr_timestamp_format	= wi_retain(WI_STR("%H:%M"));

	/* parse command line switches */
	while((ch = getopt(argc, (char * const *) argv, "DhVv")) != -1) {
		switch(ch) {
			case 'D':
				wr_debug = true;

				wi_log_level = WI_LOG_DEBUG;
				wi_log_file = true;
				wi_log_path = WI_STR("wire.out");
				wi_log_callback = NULL;
				break;

			case 'V':
			case 'v':
				wr_version();
				break;

			case '?':
			case 'h':
			default:
				wr_usage();
				break;
		}
	}

	argc -= optind;
	argv += optind;

	/* open log */
	wi_log_open();
	
	/* create ~/.wire */
	wirepath = wi_string_by_appending_path_component(homepath, WI_STR(WR_WIRE_PATH));
	wi_file_create_directory(wirepath, 0700);
	
	/* init subsystems */
	wr_signals_init();
	wr_terminal_init();
	wr_readline_init();
	wr_chats_init();
	wr_windows_init();
	wr_client_init();
	wr_runloop_init();
	wr_users_init();
	wr_ignores_init();
	wr_files_init();
	wr_transfers_init();
	wr_servers_init();
	
	/* open default settings */
	path = wi_string_by_appending_path_component(homepath, WI_STR(WR_WIRE_CONFIG_PATH));
	file = wi_file_for_reading(path);

	if(file)
		wr_parse_file(file);
	else
		wr_printf_prefix(WI_STR("%@: %m"), path);

	/* read specified bookmark */
	if(*argv) {
		component	= wi_string_with_cstring(*argv);
		path		= wi_string_by_appending_path_component(wirepath, component);
		file		= wi_file_for_reading(path);

		if(file)
			wr_parse_file(file);
		else
			wr_printf_prefix(WI_STR("%@: %m"), path);
	}
	
	/* clean up pool after startup */
	wi_pool_drain(pool);
	
	/* enter event loop */
	wr_runloop_run();

	/* clean up */
	wr_cleanup();
	wi_release(pool);
	
	return 0;
}