예제 #1
0
static void cmd_network_list(void)
{
	GString *str;
	GSList *tmp;

	str = g_string_new(NULL);
	printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_NETWORK_HEADER);
	for (tmp = chatnets; tmp != NULL; tmp = tmp->next) {
		IRC_CHATNET_REC *rec = tmp->data;

		if (!IS_IRCNET(rec))
                        continue;

		g_string_truncate(str, 0);
		if (rec->nick != NULL)
			g_string_sprintfa(str, "nick: %s, ", rec->nick);
		if (rec->username != NULL)
			g_string_sprintfa(str, "username: %s, ", rec->username);
		if (rec->realname != NULL)
			g_string_sprintfa(str, "realname: %s, ", rec->realname);
		if (rec->own_host != NULL)
			g_string_sprintfa(str, "host: %s, ", rec->own_host);
		if (rec->autosendcmd != NULL)
			g_string_sprintfa(str, "autosendcmd: %s, ", rec->autosendcmd);
		if (rec->usermode != NULL)
			g_string_sprintfa(str, "usermode: %s, ", rec->usermode);

		if (rec->cmd_queue_speed > 0)
			g_string_sprintfa(str, "cmdspeed: %d, ", rec->cmd_queue_speed);
		if (rec->max_cmds_at_once > 0)
			g_string_sprintfa(str, "cmdmax: %d, ", rec->max_cmds_at_once);
		if (rec->max_query_chans > 0)
			g_string_sprintfa(str, "querychans: %d, ", rec->max_query_chans);

		if (rec->max_kicks > 0)
			g_string_sprintfa(str, "max_kicks: %d, ", rec->max_kicks);
		if (rec->max_msgs > 0)
			g_string_sprintfa(str, "max_msgs: %d, ", rec->max_msgs);
		if (rec->max_modes > 0)
			g_string_sprintfa(str, "max_modes: %d, ", rec->max_modes);
		if (rec->max_whois > 0)
			g_string_sprintfa(str, "max_whois: %d, ", rec->max_whois);

		if (str->len > 1) g_string_truncate(str, str->len-2);
		printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP,
			    IRCTXT_NETWORK_LINE, rec->name, str->str);
	}
	g_string_free(str, TRUE);
	printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_NETWORK_FOOTER);
}
예제 #2
0
static void sig_server_setup_fill_chatnet(IRC_SERVER_CONNECT_REC *conn,
					  IRC_CHATNET_REC *ircnet)
{
	if (!IS_IRC_SERVER_CONNECT(conn))
		return;
	g_return_if_fail(IS_IRCNET(ircnet));

	if (ircnet->nick != NULL) g_free_and_null(conn->alternate_nick);
	if (ircnet->usermode != NULL) {
		g_free_and_null(conn->usermode);
		conn->usermode = g_strdup(ircnet->usermode);
	}

	if (ircnet->max_kicks > 0) conn->max_kicks = ircnet->max_kicks;
	if (ircnet->max_msgs > 0) conn->max_msgs = ircnet->max_msgs;
	if (ircnet->max_modes > 0) conn->max_modes = ircnet->max_modes;
	if (ircnet->max_whois > 0) conn->max_whois = ircnet->max_whois;

	if (ircnet->max_cmds_at_once > 0)
		conn->max_cmds_at_once = ircnet->max_cmds_at_once;
	if (ircnet->cmd_queue_speed > 0)
		conn->cmd_queue_speed = ircnet->cmd_queue_speed;
	if (ircnet->max_query_chans > 0)
		conn->max_query_chans = ircnet->max_query_chans;

	/* Validate the SASL parameters filled by sig_chatnet_read() or cmd_network_add */
	conn->sasl_mechanism = SASL_MECHANISM_NONE;

	if (ircnet->sasl_mechanism != NULL) {
		if (!g_ascii_strcasecmp(ircnet->sasl_mechanism, "plain")) {
			/* The PLAIN method needs both the username and the password */
			if (ircnet->sasl_username != NULL && *ircnet->sasl_username &&
			    ircnet->sasl_password != NULL && *ircnet->sasl_password) {
				conn->sasl_mechanism = SASL_MECHANISM_PLAIN;
				conn->sasl_username = ircnet->sasl_username;
				conn->sasl_password = ircnet->sasl_password;
			} else
				g_warning("The fields sasl_username and sasl_password are either missing or empty");
		}
		else if (!g_ascii_strcasecmp(ircnet->sasl_mechanism, "external")) {
				conn->sasl_mechanism = SASL_MECHANISM_EXTERNAL;
				conn->sasl_username = NULL;
				conn->sasl_password = NULL;
		}
		else
			g_warning("Unsupported SASL mechanism \"%s\" selected", ircnet->sasl_mechanism);
	}
}
예제 #3
0
static void read_ircnets(void)
{
	CONFIG_NODE *node;
	GSList *tmp, *next;

	for (tmp = chatnets; tmp != NULL; tmp = next) {
		CHATNET_REC *rec = tmp->data;

		next = tmp->next;
		if (IS_IRCNET(rec))
			chatnet_destroy(rec);
	}

	/* read ircnets */
	node = iconfig_node_traverse("ircnets", FALSE);
	if (node != NULL) {
		for (tmp = node->value; tmp != NULL; tmp = tmp->next)
			ircnet_read(tmp->data);
	}
}