Exemple #1
0
SERVER_REC *server_connect(SERVER_CONNECT_REC *conn)
{
	CHAT_PROTOCOL_REC *proto;
	SERVER_REC *server;

	proto = CHAT_PROTOCOL(conn);
	server = proto->server_init_connect(conn);
	proto->server_connect(server);

	return server;
}
Exemple #2
0
static void test_server_destroy_flood(ServerDestroyFloodData *fixture, const void *data)
{
	SERVER_REC *server; /* = g_new0(IRC_SERVER_REC, 1); */
	CHAT_PROTOCOL_REC *proto;
	SERVER_CONNECT_REC *conn;
	GLogLevelFlags loglev;

	g_test_bug("796");

	/* for the purpose of this exercise, we are ignoring the
	   errors of g_hash_table_lookup failure */
	loglev = g_log_set_always_fatal(G_LOG_FATAL_MASK);

	proto = chat_protocol_find("IRC");
	conn = server_create_conn(proto->id, "localhost", 0, "", "", "user");
	server = proto->server_init_connect(conn);
	server->session_reconnect = TRUE;
	server->tag = g_strdup("testserver");

	g_test_message("created server: %p", server);

	/* we skip some initialisations that would try to send data */
	/* irc_servers_deinit(); */
	irc_session_deinit();
	irc_irc_deinit();


	server_connect_finished(server);

	/* make up for the skipped session init */
	irc_server_init_bare_minimum(IRC_SERVER(server));

	irc_irc_init();
	irc_session_init();
	/* irc_servers_init(); */

	/* simulate failing irc_server_send_data() */
	server->connection_lost = TRUE;

	/*
	chat_completion_deinit();
	fe_messages_deinit();
	irc_notifylist_deinit();
	*/

	server_ref(server);
	signal_emit("event privmsg", 4, server, "#someroom :test message", "nick", "user@host");
	server_unref(server);

	g_log_set_always_fatal(loglev);
}
Exemple #3
0
static void session_restore_server(CONFIG_NODE *node)
{
	CHAT_PROTOCOL_REC *proto;
	SERVER_CONNECT_REC *conn;
	SERVER_REC *server;
	const char *chat_type, *address, *chatnet, *password, *nick;
        int port, handle;

        chat_type = config_node_get_str(node, "chat_type", NULL);
	address = config_node_get_str(node, "address", NULL);
	port = config_node_get_int(node, "port", 0);
	chatnet = config_node_get_str(node, "chatnet", NULL);
	password = config_node_get_str(node, "password", NULL);
	nick = config_node_get_str(node, "nick", NULL);
	handle = config_node_get_int(node, "handle", -1);

	if (chat_type == NULL || address == NULL || nick == NULL || handle < 0)
		return;

	proto = chat_protocol_find(chat_type);
	if (proto == NULL || proto->not_initialized) {
		if (handle < 0) close(handle);
		return;
	}

	conn = server_create_conn(proto->id, address, port,
				  chatnet, password, nick);
	if (conn != NULL) {
		conn->reconnection = TRUE;
		conn->connect_handle = g_io_channel_new(handle);

		server = proto->server_init_connect(conn);
		server->version = g_strdup(config_node_get_str(node, "version", NULL));
		server->session_reconnect = TRUE;
		signal_emit("session restore server", 2, server, node);

		proto->server_connect(server);
	}
}