Пример #1
0
static void sig_layout_restore(void)
{
	WINDOW_REC *window;
	CONFIG_NODE *node;
	GSList *tmp;

	node = iconfig_node_traverse("windows", FALSE);
	if (node == NULL) return;

	tmp = config_node_first(node->value);
	for (; tmp != NULL; tmp = config_node_next(tmp)) {
		CONFIG_NODE *node = tmp->data;

		window = window_find_refnum(atoi(node->key));
		if (window == NULL)
			window = window_create(NULL, TRUE);

		window_set_refnum(window, atoi(node->key));
                window->sticky_refnum = config_node_get_bool(node, "sticky_refnum", FALSE);
                window->immortal = config_node_get_bool(node, "immortal", FALSE);
		window_set_name(window, config_node_get_str(node, "name", NULL));
		window_set_history(window, config_node_get_str(node, "history_name", NULL));
		window_set_level(window, level2bits(config_node_get_str(node, "level", "")));

		window->servertag = g_strdup(config_node_get_str(node, "servertag", NULL));
		window->theme_name = g_strdup(config_node_get_str(node, "theme", NULL));
		if (window->theme_name != NULL)
			window->theme = theme_load(window->theme_name);

		window_add_items(window, config_node_section(node, "items", -1));
		signal_emit("layout restore window", 2, window, node);
	}
}
Пример #2
0
static void read_ignores(void)
{
	IGNORE_REC *rec;
	CONFIG_NODE *node;
	GSList *tmp;

	while (ignores != NULL)
                ignore_destroy(ignores->data);

	node = iconfig_node_traverse("ignores", FALSE);
	if (node == NULL) return;

	for (tmp = node->value; tmp != NULL; tmp = tmp->next) {
		node = tmp->data;

		if (node->type != NODE_TYPE_BLOCK)
			continue;

		rec = g_new0(IGNORE_REC, 1);
		ignores = g_slist_append(ignores, rec);

		rec->mask = g_strdup(config_node_get_str(node, "mask", NULL));
		rec->pattern = g_strdup(config_node_get_str(node, "pattern", NULL));
		rec->level = level2bits(config_node_get_str(node, "level", ""));
		rec->except_level = level2bits(config_node_get_str(node, "except_level", ""));
		rec->regexp = config_node_get_bool(node, "regexp", FALSE);
		rec->fullword = config_node_get_bool(node, "fullword", FALSE);
		rec->replies = config_node_get_bool(node, "replies", FALSE);

		node = config_node_section(node, "channels", -1);
		if (node != NULL) rec->channels = config_node_get_list(node);
	}
}
Пример #3
0
static void read_hilight_config(void)
{
    CONFIG_NODE *node;
    HILIGHT_REC *rec;
    GSList *tmp;
    char *text, *color;

    hilights_destroy_all();

    node = iconfig_node_traverse("hilights", FALSE);
    if (node == NULL) {
        reset_cache();
        return;
    }

    tmp = config_node_first(node->value);
    for (; tmp != NULL; tmp = config_node_next(tmp)) {
        node = tmp->data;

        if (node->type != NODE_TYPE_BLOCK)
            continue;

        text = config_node_get_str(node, "text", NULL);
        if (text == NULL || *text == '\0')
            continue;

        rec = g_new0(HILIGHT_REC, 1);
        hilights = g_slist_append(hilights, rec);

        rec->text = g_strdup(text);

        color = config_node_get_str(node, "color", NULL);
        rec->color = color == NULL || *color == '\0' ? NULL :
                     g_strdup(color);

        color = config_node_get_str(node, "act_color", NULL);
        rec->act_color = color == NULL || *color == '\0' ? NULL :
                         g_strdup(color);

        rec->level = config_node_get_int(node, "level", 0);
        rec->priority = config_node_get_int(node, "priority", 0);
        rec->nick = config_node_get_bool(node, "nick", TRUE);
        rec->word = config_node_get_bool(node, "word", TRUE);

        rec->nickmask = config_node_get_bool(node, "mask", FALSE);
        rec->fullword = config_node_get_bool(node, "fullword", FALSE);
        rec->regexp = config_node_get_bool(node, "regexp", FALSE);
        rec->servertag = config_node_get_str(node, "servertag", NULL);
        hilight_init_rec(rec);

        node = config_node_section(node, "channels", -1);
        if (node != NULL) rec->channels = config_node_get_list(node);
    }

    reset_cache();
}
Пример #4
0
void windows_layout_restore(void)
{
	WINDOW_REC *window;
	CONFIG_NODE *node;
	GSList *tmp;

	node = iconfig_node_traverse("windows", FALSE);
	if (node == NULL) return;

	for (tmp = node->value; tmp != NULL; tmp = tmp->next) {
		CONFIG_NODE *node = tmp->data;

		window = window_create(NULL, TRUE);
		window_set_refnum(window, atoi(node->key));
                window->sticky_refnum = config_node_get_bool(node, "sticky_refnum", FALSE);
		window_set_name(window, config_node_get_str(node, "name", NULL));
		window_set_level(window, level2bits(config_node_get_str(node, "level", "")));

		window->servertag = g_strdup(config_node_get_str(node, "servertag", NULL));
		window->theme_name = g_strdup(config_node_get_str(node, "theme", NULL));
		if (window->theme_name != NULL)
			window->theme = theme_load(window->theme_name);

		window_add_items(window, config_node_section(node, "items", -1));
		signal_emit("window restore", 2, window, node);
	}

	signal_emit("windows restored", 0);
}
Пример #5
0
static SETUP_CHANNEL_REC *setupchannel_add(CONFIG_NODE *node)
{
	SETUP_CHANNEL_REC *rec;
	char *channel, *ircnet, *password, *botmasks, *autosendcmd, *background, *font;

	g_return_val_if_fail(node != NULL, NULL);

	channel = config_node_get_str(node, "name", NULL);
	ircnet = config_node_get_str(node, "ircnet", NULL);
	if (channel == NULL || ircnet == NULL) {
		/* missing information.. */
		return NULL;
	}

	password = config_node_get_str(node, "password", NULL);
	botmasks = config_node_get_str(node, "botmasks", NULL);
	autosendcmd = config_node_get_str(node, "autosendcmd", NULL);
	background = config_node_get_str(node, "background", NULL);
	font = config_node_get_str(node, "font", NULL);

	rec = g_new(SETUP_CHANNEL_REC, 1);
	rec->autojoin = config_node_get_bool(node, "autojoin", FALSE);
	rec->name = g_strdup(channel);
	rec->ircnet = g_strdup(ircnet);
	rec->password = (password == NULL || *password == '\0') ? NULL : g_strdup(password);
	rec->botmasks = (botmasks == NULL || *botmasks == '\0') ? NULL : g_strdup(botmasks);
	rec->autosendcmd = (autosendcmd == NULL || *autosendcmd == '\0') ? NULL : g_strdup(autosendcmd);
	rec->background = (background == NULL || *background == '\0') ? NULL : g_strdup(background);
	rec->font = (font == NULL || *font == '\0') ? NULL : g_strdup(font);

	setupchannels = g_slist_append(setupchannels, rec);
	return rec;
}
Пример #6
0
static SETUP_SERVER_REC *setupserver_add_node(CONFIG_NODE *node)
{
	SETUP_SERVER_REC *rec;
	char *server;
	int port;

	g_return_val_if_fail(node != NULL, NULL);

	server = config_node_get_str(node, "address", NULL);
	if (server == NULL) return NULL;

	port = config_node_get_int(node, "port", 6667);
	if (server_setup_find(server, port) != NULL) {
		/* already exists - don't let it get there twice or
		   server reconnects will screw up! */
		return NULL;
	}

	rec = g_new0(SETUP_SERVER_REC, 1);
	rec->ircnet = g_strdup(config_node_get_str(node, "ircnet", NULL));
	rec->address = g_strdup(server);
	rec->password = g_strdup(config_node_get_str(node, "password", NULL));
	rec->port = port;
	rec->autoconnect = config_node_get_bool(node, "autoconnect", FALSE);
	rec->max_cmds_at_once = config_node_get_int(node, "cmds_max_at_once", 0);
	rec->cmd_queue_speed = config_node_get_int(node, "cmd_queue_speed", 0);
	rec->own_host = g_strdup(config_node_get_str(node, "own_host", 0));

	setupservers = g_slist_append(setupservers, rec);
	return rec;
}
Пример #7
0
Файл: ignore.c Проект: ahf/irssi
static void read_ignores(void)
{
	IGNORE_REC *rec;
	CONFIG_NODE *node;
	GSList *tmp;

	while (ignores != NULL)
                ignore_destroy(ignores->data, FALSE);

	node = iconfig_node_traverse("ignores", FALSE);
	if (node == NULL) {
		nickmatch_rebuild(nickmatch);
		return;
	}

	tmp = config_node_first(node->value);
	for (; tmp != NULL; tmp = config_node_next(tmp)) {
		node = tmp->data;

		if (node->type != NODE_TYPE_BLOCK)
			continue;

		rec = g_new0(IGNORE_REC, 1);
		ignores = g_slist_append(ignores, rec);

		rec->mask = g_strdup(config_node_get_str(node, "mask", NULL));
		rec->pattern = g_strdup(config_node_get_str(node, "pattern", NULL));
		rec->level = level2bits(config_node_get_str(node, "level", ""), NULL);
                rec->exception = config_node_get_bool(node, "exception", FALSE);
		rec->regexp = config_node_get_bool(node, "regexp", FALSE);
		rec->fullword = config_node_get_bool(node, "fullword", FALSE);
		rec->replies = config_node_get_bool(node, "replies", FALSE);
		rec->unignore_time = config_node_get_int(node, "unignore_time", 0);
		rec->servertag = g_strdup(config_node_get_str(node, "servertag", 0));

		node = iconfig_node_section(node, "channels", -1);
		if (node != NULL) rec->channels = config_node_get_list(node);

		ignore_init_rec(rec);
	}

	nickmatch_rebuild(nickmatch);
}
Пример #8
0
static void log_read_config(void)
{
	CONFIG_NODE *node;
	LOG_REC *log;
	GSList *tmp, *next, *fnames;

	/* close old logs, save list of open logs */
	fnames = NULL;
	for (tmp = logs; tmp != NULL; tmp = next) {
		log = tmp->data;

		next = tmp->next;
		if (log->temp)
			continue;

		if (log->handle != -1)
			fnames = g_slist_append(fnames, g_strdup(log->fname));
		log_destroy(log);
	}

	node = iconfig_node_traverse("logs", FALSE);
	if (node == NULL) return;

	tmp = config_node_first(node->value);
	for (; tmp != NULL; tmp = config_node_next(tmp)) {
		node = tmp->data;

		if (node->type != NODE_TYPE_BLOCK)
			continue;

		log = g_new0(LOG_REC, 1);
		logs = g_slist_append(logs, log);

		log->handle = -1;
		log->fname = g_strdup(node->key);
		log->autoopen = config_node_get_bool(node, "auto_open", FALSE);
		log->level = level2bits(config_node_get_str(node, "level", 0));

		signal_emit("log config read", 2, log, node);

		node = config_node_section(node, "items", -1);
		if (node != NULL)
			log_items_read_config(node, log);

		if (log->autoopen || gslist_find_string(fnames, log->fname))
			log_start_logging(log);
	}

	g_slist_foreach(fnames, (GFunc) g_free, NULL);
	g_slist_free(fnames);
}
Пример #9
0
int settings_get_bool(const char *key)
{
	SETTINGS_REC *rec;
	CONFIG_NODE *node;

	rec = settings_get(key, SETTING_TYPE_BOOLEAN);
	if (rec == NULL) return FALSE;

	node = iconfig_node_traverse("settings", FALSE);
	node = node == NULL ? NULL : iconfig_node_section(node, rec->module, -1);

	return node == NULL ? rec->default_value.v_bool :
		config_node_get_bool(node, key, rec->default_value.v_bool);
}
Пример #10
0
static void statusbar_read(STATUSBAR_GROUP_REC *group, CONFIG_NODE *node)
{
	STATUSBAR_CONFIG_REC *bar;
        GSList *tmp;
        const char *visible_str;

	g_return_if_fail(is_node_list(node));
	g_return_if_fail(node->key != NULL);

	bar = statusbar_config_find(group, node->key);
	if (config_node_get_bool(node, "disabled", FALSE)) {
		/* disabled, destroy it if it already exists */
		if (bar != NULL)
			statusbar_config_destroy(group, bar);
                return;
	}

	if (bar == NULL) {
		bar = statusbar_config_create(group, node->key);
		bar->type = STATUSBAR_TYPE_ROOT;
		bar->placement = STATUSBAR_BOTTOM;
		bar->position = 0;
	}

        visible_str = config_node_get_str(node, "visible", "");
	if (g_ascii_strcasecmp(visible_str, "active") == 0)
                bar->visible = STATUSBAR_VISIBLE_ACTIVE;
	else if (g_ascii_strcasecmp(visible_str, "inactive") == 0)
		bar->visible = STATUSBAR_VISIBLE_INACTIVE;
	else
		bar->visible = STATUSBAR_VISIBLE_ALWAYS;

	if (g_ascii_strcasecmp(config_node_get_str(node, "type", ""), "window") == 0)
                bar->type = STATUSBAR_TYPE_WINDOW;
	if (g_ascii_strcasecmp(config_node_get_str(node, "placement", ""), "top") == 0)
                bar->placement = STATUSBAR_TOP;
	bar->position = config_node_get_int(node, "position", 0);

	node = iconfig_node_section(node, "items", -1);
	if (node != NULL) {
                /* we're overriding the items - destroy the old */
                while (bar->items != NULL)
			statusbar_config_item_destroy(bar, bar->items->data);

		tmp = config_node_first(node->value);
		for (; tmp != NULL; tmp = config_node_next(tmp))
			statusbar_read_item(bar, tmp->data);
	}
}
Пример #11
0
static const char *completion_find(const char *key, int automatic)
{
	CONFIG_NODE *node;

	node = iconfig_node_traverse("completions", FALSE);
	if (node == NULL || node->type != NODE_TYPE_BLOCK)
		return NULL;

	node = iconfig_node_section(node, key, -1);
	if (node == NULL)
		return NULL;

	if (automatic && !config_node_get_bool(node, "auto", FALSE))
		return NULL;

	return config_node_get_str(node, "value", NULL);
}
Пример #12
0
static void botnet_config_read_botnet(CONFIG_NODE *node)
{
	CONFIG_NODE *subnode;
	BOTNET_REC *botnet;
	GSList *tmp;

	g_return_if_fail(node != NULL);

	if (node->key == NULL || node->value == NULL)
		return;

	/* New botnet */
	botnet = g_new0(BOTNET_REC, 1);
	botnet->name = g_strdup(node->key);
	botnet->nick = g_strdup(config_node_get_str(node, "nick", "bot"));
	botnet->priority = config_node_get_int(node, "priority", DEFAULT_BOTNET_PRIORITY);
	botnet->autoconnect = config_node_get_bool(node, "autoconnect", FALSE);

	botnet->addr = g_strdup(config_node_get_str(node, "listen_addr", NULL));
	botnet->port = config_node_get_int(node, "listen_port", DEFAULT_BOTNET_PORT);

	botnet->listen_handle = -1;
	botnet->listen_tag = -1;

	/* read uplinks */
	subnode = config_node_section(node, "uplinks", -1);
	tmp = subnode == NULL ? NULL : subnode->value;
	for (; tmp != NULL; tmp = tmp->next)
		botnet_config_read_uplink(botnet, tmp->data);

	/* read downlinks */
	subnode = config_node_section(node, "downlinks", -1);
	tmp = subnode == NULL ? NULL : subnode->value;
	for (; tmp != NULL; tmp = tmp->next)
		botnet_config_read_downlink(botnet, tmp->data);

	botnets = g_slist_append(botnets, botnet);
}
Пример #13
0
static CHANNEL_SETUP_REC *channel_setup_read(CONFIG_NODE *node)
{
	CHANNEL_SETUP_REC *rec;
        CHATNET_REC *chatnetrec;
	char *channel, *chatnet;

	g_return_val_if_fail(node != NULL, NULL);

	channel = config_node_get_str(node, "name", NULL);
        chatnet = config_node_get_str(node, "chatnet", NULL);
	if (chatnet == NULL) /* FIXME: remove this after .98... */ {
		chatnet = g_strdup(config_node_get_str(node, "ircnet", NULL));
		if (chatnet != NULL) {
                        iconfig_node_set_str(node, "chatnet", chatnet);
                        iconfig_node_set_str(node, "ircnet", NULL);
		}
	}

	chatnetrec = chatnet == NULL ? NULL : chatnet_find(chatnet);
	if (channel == NULL || chatnetrec == NULL) {
		/* missing information.. */
		return NULL;
	}

	rec = CHAT_PROTOCOL(chatnetrec)->create_channel_setup();
	rec->type = module_get_uniq_id("CHANNEL SETUP", 0);
	rec->chat_type = CHAT_PROTOCOL(chatnetrec)->id;
	rec->autojoin = config_node_get_bool(node, "autojoin", FALSE);
	rec->name = g_strdup(channel);
	rec->chatnet = g_strdup(chatnetrec != NULL ? chatnetrec->name : chatnet);
	rec->password = g_strdup(config_node_get_str(node, "password", NULL));
	rec->botmasks = g_strdup(config_node_get_str(node, "botmasks", NULL));
	rec->autosendcmd = g_strdup(config_node_get_str(node, "autosendcmd", NULL));

	setupchannels = g_slist_append(setupchannels, rec);
	signal_emit("channel setup created", 2, rec, node);
	return rec;
}
Пример #14
0
static SERVER_SETUP_REC *server_setup_read(CONFIG_NODE *node)
{
	SERVER_SETUP_REC *rec;
        CHATNET_REC *chatnetrec;
	char *server, *chatnet, *family;
	int port;

	g_return_val_if_fail(node != NULL, NULL);

	server = config_node_get_str(node, "address", NULL);
	if (server == NULL)
		return NULL;

	port = config_node_get_int(node, "port", 0);
	chatnet = config_node_get_str(node, "chatnet", NULL);

	if (server_setup_find(server, port, chatnet) != NULL) {
		return NULL;
	}

	rec = NULL;

	chatnetrec = chatnet == NULL ? NULL : chatnet_find(chatnet);
	if (chatnetrec == NULL && chatnet != NULL) {
                /* chat network not found, create it. */
		chatnetrec = chat_protocol_get_default()->create_chatnet();
		chatnetrec->chat_type = chat_protocol_get_default()->id;
		chatnetrec->name = g_strdup(chatnet);
		chatnet_create(chatnetrec);
	}

        family = config_node_get_str(node, "family", "");

	rec = CHAT_PROTOCOL(chatnetrec)->create_server_setup();
	rec->type = module_get_uniq_id("SERVER SETUP", 0);
        rec->chat_type = CHAT_PROTOCOL(chatnetrec)->id;
	rec->chatnet = chatnetrec == NULL ? NULL : g_strdup(chatnetrec->name);
	rec->family = g_ascii_strcasecmp(family, "inet6") == 0 ? AF_INET6 :
		(g_ascii_strcasecmp(family, "inet") == 0 ? AF_INET : 0);
	rec->address = g_strdup(server);
	rec->password = g_strdup(config_node_get_str(node, "password", NULL));
	rec->use_ssl = config_node_get_bool(node, "use_ssl", FALSE);
	rec->ssl_cert = g_strdup(config_node_get_str(node, "ssl_cert", NULL));
	rec->ssl_pkey = g_strdup(config_node_get_str(node, "ssl_pkey", NULL));
	rec->ssl_verify = config_node_get_bool(node, "ssl_verify", FALSE);
	rec->ssl_cafile = g_strdup(config_node_get_str(node, "ssl_cafile", NULL));
	rec->ssl_capath = g_strdup(config_node_get_str(node, "ssl_capath", NULL));
	if (rec->ssl_cafile || rec->ssl_capath)
		rec->ssl_verify = TRUE;
	if (rec->ssl_cert != NULL || rec->ssl_verify)
		rec->use_ssl = TRUE;
	rec->port = port;
	rec->autoconnect = config_node_get_bool(node, "autoconnect", FALSE);
	rec->no_proxy = config_node_get_bool(node, "no_proxy", FALSE);
	rec->own_host = g_strdup(config_node_get_str(node, "own_host", NULL));

	signal_emit("server setup read", 2, rec, node);

	setupservers = g_slist_append(setupservers, rec);
	return rec;
}
Пример #15
0
static void sig_log_config_read(LOG_REC *log, CONFIG_NODE *node)
{
        if (!config_node_get_bool(node, "colors", FALSE))
		log->colorizer = log_colorizer_strip;
}
Пример #16
0
/* SYNTAX: COMPLETION [-auto] [-delete] <key> <value> */
static void cmd_completion(const char *data)
{
	GHashTable *optlist;
	CONFIG_NODE *node;
	GSList *tmp;
	char *key, *value;
	void *free_arg;
	int len;

	if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTIONS |
			    PARAM_FLAG_GETREST,
			    "completion", &optlist, &key, &value))
		return;

	node = iconfig_node_traverse("completions", *value != '\0');
	if (node != NULL && node->type != NODE_TYPE_BLOCK) {
		/* FIXME: remove after 0.8.5 */
		iconfig_node_remove(mainconfig->mainnode, node);
		node = iconfig_node_traverse("completions", *value != '\0');
	}

	if (node == NULL || (node->value == NULL && *value == '\0')) {
		printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
			    TXT_NO_COMPLETIONS);
		cmd_params_free(free_arg);
		return;
	}

	if (g_hash_table_lookup(optlist, "delete") != NULL && *key != '\0') {
		printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
			    TXT_COMPLETION_REMOVED, key);

		iconfig_set_str("completions", key, NULL);
		signal_emit("completion removed", 1, key);
	} else if (*key != '\0' && *value != '\0') {
		int automatic = g_hash_table_lookup(optlist, "auto") != NULL;

		node = iconfig_node_section(node, key, NODE_TYPE_BLOCK);
		iconfig_node_set_str(node, "value", value);
		if (automatic)
			iconfig_node_set_bool(node, "auto", TRUE);
		else
			iconfig_node_set_str(node, "auto", NULL);

		printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP,
			    TXT_COMPLETION_LINE,
			    key, value, automatic ? "yes" : "no");

		signal_emit("completion added", 1, key);
	} else {
		printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP,
			    TXT_COMPLETION_HEADER);

		len = strlen(key);
		for (tmp = node->value; tmp != NULL; tmp = tmp->next) {
			node = tmp->data;

			if (len == 0 ||
			    g_ascii_strncasecmp(node->key, key, len) == 0) {
				printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP,
					    TXT_COMPLETION_LINE, node->key,
					    config_node_get_str(node, "value", ""),
					    config_node_get_bool(node, "auto", FALSE) ? "yes" : "no");
			}
		}

		printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP,
			    TXT_COMPLETION_FOOTER);
	}

	cmd_params_free(free_arg);
}