示例#1
0
文件: completion.c 项目: Adam-/irssi
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 = config_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);
}
示例#2
0
static void keyconfig_save(const char *id, const char *key, const char *data)
{
	CONFIG_NODE *node;

	g_return_if_fail(id != NULL);
	g_return_if_fail(key != NULL);

	node = key_config_find(key);
	if (node == NULL) {
		node = iconfig_node_traverse("(keyboard", TRUE);
		node = config_node_section(node, NULL, NODE_TYPE_BLOCK);
	}

	iconfig_node_set_str(node, "key", key);
	iconfig_node_set_str(node, "id", id);
	iconfig_node_set_str(node, "data", data);
}
示例#3
0
static void chatnet_config_save(CHATNET_REC *chatnet)
{
	CONFIG_NODE *node;

	node = iconfig_node_traverse("chatnets", TRUE);
	node = config_node_section(node, chatnet->name, NODE_TYPE_BLOCK);
	iconfig_node_clear(node);

	iconfig_node_set_str(node, "type", chat_protocol_find_id(chatnet->chat_type)->name);
	iconfig_node_set_str(node, "nick", chatnet->nick);
	iconfig_node_set_str(node, "username", chatnet->username);
	iconfig_node_set_str(node, "realname", chatnet->realname);
	iconfig_node_set_str(node, "host", chatnet->own_host);
	iconfig_node_set_str(node, "autosendcmd", chatnet->autosendcmd);

        signal_emit("chatnet saved", 2, chatnet, node);
}
示例#4
0
static void channel_config_add(SETUP_CHANNEL_REC *channel)
{
	CONFIG_NODE *node;

	node = iconfig_node_traverse("(channels", TRUE);
	node = config_node_section(node, NULL, NODE_TYPE_BLOCK);

	iconfig_node_set_str(node, "name", channel->name);
	iconfig_node_set_str(node, "ircnet", channel->ircnet);
	if (channel->autojoin)
		config_node_set_bool(node, "autojoin", TRUE);
	iconfig_node_set_str(node, "password", channel->password);
	iconfig_node_set_str(node, "botmasks", channel->botmasks);
	iconfig_node_set_str(node, "autosendcmd", channel->autosendcmd);
	iconfig_node_set_str(node, "background", channel->background);
	iconfig_node_set_str(node, "font", channel->font);
}
示例#5
0
static void server_setup_remove_config(SERVER_SETUP_REC *rec)
{
	CONFIG_NODE *parent_node;
	GSList *config_node;

	parent_node = iconfig_node_traverse("servers", FALSE);

	if (parent_node == NULL)
		return;

	/* Try to find this server in the configuration */
	config_node = g_slist_find_custom(parent_node->value, rec,
					  (GCompareFunc)compare_server_setup);

	if (config_node != NULL)
		/* Delete the server from the configuration */
		iconfig_node_remove(parent_node, config_node->data);
}
示例#6
0
文件: keyboard.c 项目: ahf/irssi
static CONFIG_NODE *key_config_find(const char *key)
{
	CONFIG_NODE *node;
        GSList *tmp;

	/* remove old keyboard settings */
	node = iconfig_node_traverse("(keyboard", TRUE);

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

		if (g_strcmp0(config_node_get_str(node, "key", ""), key) == 0)
                        return node;
	}

        return NULL;
}
示例#7
0
static void server_setup_save(SERVER_SETUP_REC *rec)
{
	CONFIG_NODE *parent_node, *node;
	GSList *config_node;

	parent_node = iconfig_node_traverse("(servers", TRUE);

	/* Try to find this channel in the configuration */
	config_node = g_slist_find_custom(parent_node->value, rec,
					  (GCompareFunc)compare_server_setup);
	if (config_node != NULL)
		/* Let's update this server record */
		node = config_node->data;
	else
		/* Create a brand-new server record */
		node = iconfig_node_section(parent_node, NULL, NODE_TYPE_BLOCK);

        iconfig_node_clear(node);
	iconfig_node_set_str(node, "address", rec->address);
	iconfig_node_set_str(node, "chatnet", rec->chatnet);

	iconfig_node_set_int(node, "port", rec->port);
	iconfig_node_set_str(node, "password", rec->password);
	iconfig_node_set_bool(node, "use_ssl", rec->use_ssl);
	iconfig_node_set_str(node, "ssl_cert", rec->ssl_cert);
	iconfig_node_set_str(node, "ssl_pkey", rec->ssl_pkey);
	iconfig_node_set_str(node, "ssl_pass", rec->ssl_pass);
	iconfig_node_set_bool(node, "ssl_verify", rec->ssl_verify);
	iconfig_node_set_str(node, "ssl_cafile", rec->ssl_cafile);
	iconfig_node_set_str(node, "ssl_capath", rec->ssl_capath);
	iconfig_node_set_str(node, "ssl_ciphers", rec->ssl_ciphers);
	iconfig_node_set_str(node, "own_host", rec->own_host);

	iconfig_node_set_str(node, "family",
			     rec->family == AF_INET6 ? "inet6" :
			     rec->family == AF_INET ? "inet" : NULL);

	if (rec->autoconnect)
		iconfig_node_set_bool(node, "autoconnect", TRUE);
	if (rec->no_proxy)
		iconfig_node_set_bool(node, "no_proxy", TRUE);

	signal_emit("server setup saved", 2, rec, node);
}
示例#8
0
static void cmd_statusbar(const char *data)
{
        CONFIG_NODE *node;
	char *name, *cmd, *params, *signal;
	void *free_arg;

	if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST,
			    &name, &cmd, &params))
		return;

	if (*name == '\0') {
		/* list all statusbars */
                cmd_statusbar_list();
		cmd_params_free(free_arg);
                return;
	}

	if (*cmd == '\0') {
		/* print statusbar info */
                cmd_statusbar_print_info(name);
		cmd_params_free(free_arg);
                return;
	}

        /* lookup/create the statusbar node */
	node = iconfig_node_traverse("statusbar", TRUE);
	node = config_node_section(node, active_statusbar_group->name,
				   NODE_TYPE_BLOCK);
	node = config_node_section(node, name, NODE_TYPE_BLOCK);

	/* call the subcommand */
	signal = g_strconcat("command statusbar ", cmd, NULL);
        g_strdown(signal);
	if (!signal_emit(signal, 4, params, NULL, NULL, node)) {
		printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
			    TXT_STATUSBAR_UNKNOWN_COMMAND, cmd);
	} else {
                read_statusbar_config();
	}
	g_free(signal);

	cmd_params_free(free_arg);
}
示例#9
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);
}
示例#10
0
static void read_keyboard_config(void)
{
	KEYINFO_REC *info;
	CONFIG_NODE *node;
	GSList *tmp;

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

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

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

		info = key_info_find(node->key);
		if (info != NULL) read_keyinfo(info, node->value);
	}
}
示例#11
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);
	}
}
示例#12
0
int settings_get_choice(const char *key)
{
	SETTINGS_REC *rec;
	CONFIG_NODE *node;
	char *str;
	int index;

	rec = settings_get(key, SETTING_TYPE_CHOICE);
	if (rec == NULL) return -1;

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

	str = node == NULL ? rec->default_value.v_string :
		config_node_get_str(node, key, rec->default_value.v_string);

	if (str == NULL || (index = strarray_find(rec->choices, str)) < 0)
		return rec->default_value.v_int;

	return index;
}
示例#13
0
static void settings_clean_invalid_module(const char *module)
{
        CONFIG_NODE *node;
        SETTINGS_REC *set;
	GSList *tmp, *next;

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

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

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

		set = g_hash_table_lookup(settings, subnode->key);
		if (set == NULL || g_strcmp0(set->module, module) != 0)
                        iconfig_node_remove(node, subnode);
	}
}
示例#14
0
static void channel_setup_save(CHANNEL_SETUP_REC *channel)
{
	CONFIG_NODE *parentnode, *node;
	int index;

	index = g_slist_index(setupchannels, channel);

	parentnode = iconfig_node_traverse("(channels", TRUE);
	node = config_node_index(parentnode, index);
	if (node == NULL)
		node = config_node_section(parentnode, NULL, NODE_TYPE_BLOCK);

        iconfig_node_clear(node);
	iconfig_node_set_str(node, "name", channel->name);
	iconfig_node_set_str(node, "chatnet", channel->chatnet);
	if (channel->autojoin)
		iconfig_node_set_bool(node, "autojoin", TRUE);
	iconfig_node_set_str(node, "password", channel->password);
	iconfig_node_set_str(node, "botmasks", channel->botmasks);
	iconfig_node_set_str(node, "autosendcmd", channel->autosendcmd);
}
示例#15
0
static int backwards_compatibility(const char *module, CONFIG_NODE *node,
				   CONFIG_NODE *parent)
{
	const char *new_key, *new_module;
	CONFIG_NODE *new_node;
	char *new_value;

	new_value = NULL; new_key = NULL; new_module = NULL;

	/* fe-text term_type -> fe-common/core term_charset - for 0.8.10-> */
	if (g_strcmp0(module, "fe-text") == 0) {
		if (g_ascii_strcasecmp(node->key, "term_type") == 0 ||
		    /* kludge for cvs-version where term_charset was in fe-text */
		    g_ascii_strcasecmp(node->key, "term_charset") == 0) {
			new_module = "fe-common/core";
			new_key = "term_charset";
			new_value = !is_valid_charset(node->value) ? NULL :
				g_strdup(node->value);
			new_node = iconfig_node_traverse("settings", FALSE);
			new_node = new_node == NULL ? NULL :
				iconfig_node_section(new_node, new_module, -1);

			config_node_set_str(mainconfig, new_node,
					    new_key, new_value);
			/* remove old */
			config_node_set_str(mainconfig, parent,
					    node->key, NULL);
			g_free(new_value);
			config_changed = TRUE;
			return new_key != NULL;
		} else if (g_ascii_strcasecmp(node->key, "actlist_moves") == 0 &&
			   node->value != NULL && g_ascii_strcasecmp(node->value, "yes") == 0) {
			config_node_set_str(mainconfig, parent, "actlist_sort", "recent");
			config_node_set_str(mainconfig, parent, node->key, NULL);
			config_changed = TRUE;
			return TRUE;
		}
	}
	return new_key != NULL;
}
示例#16
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) return;

	for (tmp = node->value; tmp != NULL; tmp = tmp->next) {
		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);

		color = config_node_get_str(node, "color", NULL);

		rec->text = g_strdup(text);
		rec->color = color == NULL || *color == '\0' ? NULL :
			g_strdup(color);
		rec->level = config_node_get_int(node, "level", 0);
		rec->nick = config_node_get_bool(node, "nick", 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);

		node = config_node_section(node, "channels", -1);
		if (node != NULL) rec->channels = config_node_get_list(node);
	}
}
示例#17
0
static void hilight_add_config(HILIGHT_REC *rec)
{
	CONFIG_NODE *node;

	g_return_if_fail(rec != NULL);

	node = iconfig_node_traverse("(hilights", TRUE);
	node = config_node_section(node, NULL, NODE_TYPE_BLOCK);

        iconfig_node_set_str(node, "text", rec->text);
        if (rec->level > 0) iconfig_node_set_int(node, "level", rec->level);
        if (rec->color) iconfig_node_set_str(node, "color", rec->color);
        if (rec->nick) iconfig_node_set_bool(node, "nick", TRUE);
        if (rec->nickmask) iconfig_node_set_bool(node, "mask", TRUE);
        if (rec->fullword) iconfig_node_set_bool(node, "fullword", TRUE);
        if (rec->regexp) iconfig_node_set_bool(node, "regexp", TRUE);

	if (rec->channels != NULL && *rec->channels != NULL) {
		node = config_node_section(node, "channels", NODE_TYPE_LIST);
		iconfig_node_add_list(node, rec->channels);
	}
}
示例#18
0
void setupserver_config_add(SETUP_SERVER_REC *rec)
{
	CONFIG_NODE *node;

	node = iconfig_node_traverse("(servers", TRUE);
	node = config_node_section(node, NULL, NODE_TYPE_BLOCK);

	iconfig_node_set_str(node, "address", rec->address);
	iconfig_node_set_str(node, "ircnet", rec->ircnet);

	config_node_set_int(node, "port", rec->port);
	iconfig_node_set_str(node, "password", rec->password);
	iconfig_node_set_str(node, "own_host", rec->own_host);

	if (rec->autoconnect)
		config_node_set_bool(node, "autoconnect", TRUE);

	if (rec->max_cmds_at_once > 0)
		config_node_set_int(node, "cmds_max_at_once", rec->max_cmds_at_once);
	if (rec->cmd_queue_speed > 0)
		config_node_set_int(node, "cmd_queue_speed", rec->cmd_queue_speed);
}
示例#19
0
static void server_setup_save(SERVER_SETUP_REC *rec)
{
	CONFIG_NODE *parentnode, *node;
	int index;

	index = g_slist_index(setupservers, rec);

	parentnode = iconfig_node_traverse("(servers", TRUE);
	node = config_node_nth(parentnode, index);
	if (node == NULL)
		node = config_node_section(parentnode, NULL, NODE_TYPE_BLOCK);

        iconfig_node_clear(node);
	iconfig_node_set_str(node, "address", rec->address);
	iconfig_node_set_str(node, "chatnet", rec->chatnet);

	iconfig_node_set_int(node, "port", rec->port);
	iconfig_node_set_str(node, "password", rec->password);
	iconfig_node_set_bool(node, "use_ssl", rec->use_ssl);
	iconfig_node_set_str(node, "ssl_tpm", rec->ssl_tpm);
	iconfig_node_set_str(node, "ssl_cert", rec->ssl_cert);
	iconfig_node_set_str(node, "ssl_pkey", rec->ssl_pkey);
	iconfig_node_set_bool(node, "ssl_verify", rec->ssl_verify);
	iconfig_node_set_str(node, "ssl_cafile", rec->ssl_cafile);
	iconfig_node_set_str(node, "ssl_capath", rec->ssl_capath);
	iconfig_node_set_str(node, "own_host", rec->own_host);

	iconfig_node_set_str(node, "family",
			     rec->family == AF_INET6 ? "inet6" :
			     rec->family == AF_INET ? "inet" : NULL);

	if (rec->autoconnect)
		iconfig_node_set_bool(node, "autoconnect", TRUE);
	if (rec->no_proxy)
		iconfig_node_set_bool(node, "no_proxy", TRUE);

	signal_emit("server setup saved", 2, rec, node);
}
示例#20
0
void keyboard_save(void)
{
	CONFIG_NODE *keyboard, *node, *listnode;
	GSList *tmp, *tmp2;

	/* remove old keyboard settings */
	iconfig_node_set_str(NULL, "(keyboard", NULL);
	keyboard = iconfig_node_traverse("(keyboard", TRUE);

	for (tmp = keyinfos; tmp != NULL; tmp = tmp->next) {
		KEYINFO_REC *info = tmp->data;

                node = config_node_section(keyboard, info->id, TRUE);
		for (tmp2 = info->keys; tmp2 != NULL; tmp2 = tmp2->next) {
			KEY_REC *key = tmp2->data;

                        listnode = config_node_section(node, NULL, NODE_TYPE_BLOCK);
			if (key->data != NULL)
				iconfig_node_set_str(listnode, "data", key->data);
			iconfig_node_set_str(listnode, "key", key->key);
		}
	}
}
示例#21
0
static void ircnet_save(IRC_CHATNET_REC *rec)
{
	CONFIG_NODE *node;

	g_return_if_fail(rec != NULL);

	node = iconfig_node_traverse("ircnets", TRUE);
	node = chatnet_save((CHATNET_REC *) rec, node);

	if (rec->max_cmds_at_once > 0)
		iconfig_node_set_int(node, "cmdmax", rec->max_cmds_at_once);
	if (rec->cmd_queue_speed > 0)
		iconfig_node_set_int(node, "cmdspeed", rec->cmd_queue_speed);

	if (rec->max_kicks > 0)
		iconfig_node_set_int(node, "max_kicks", rec->max_kicks);
	if (rec->max_msgs > 0)
		iconfig_node_set_int(node, "max_msgs", rec->max_msgs);
	if (rec->max_modes > 0)
		iconfig_node_set_int(node, "max_modes", rec->max_modes);
	if (rec->max_whois > 0)
		iconfig_node_set_int(node, "max_whois", rec->max_whois);
}
示例#22
0
static void show_aliases(const char *alias)
{
	CONFIG_NODE *node;
	GSList *tmp, *list;
	int aliaslen;

	printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_ALIASLIST_HEADER);

	node = iconfig_node_traverse("aliases", FALSE);
	tmp = node == NULL ? NULL : config_node_first(node->value);

	/* first get the list of aliases sorted */
	list = NULL;
	aliaslen = strlen(alias);
	for (; tmp != NULL; tmp = config_node_next(tmp)) {
		CONFIG_NODE *node = tmp->data;

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

		if (aliaslen != 0 && g_strncasecmp(node->key, alias, aliaslen) != 0)
			continue;

		list = g_slist_insert_sorted(list, node, (GCompareFunc) config_key_compare);
	}

	/* print the aliases */
	for (tmp = list; tmp != NULL; tmp = tmp->next) {
		CONFIG_NODE *node = tmp->data;

		printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_ALIASLIST_LINE,
			    node->key, node->value);
	}
	g_slist_free(list);

	printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_ALIASLIST_FOOTER);
}
示例#23
0
文件: completion.c 项目: irssi/irssi
static GList *completion_get_aliases(const char *alias, char cmdchar)
{
	CONFIG_NODE *node;
	GList *complist;
	GSList *tmp;
	char *word;
	int len;

	g_return_val_if_fail(alias != NULL, NULL);

	/* get list of aliases from mainconfig */
	node = iconfig_node_traverse("aliases", FALSE);
	tmp = node == NULL ? NULL : config_node_first(node->value);

	len = strlen(alias);
	complist = NULL;
	for (; tmp != NULL; tmp = config_node_next(tmp)) {
		CONFIG_NODE *node = tmp->data;

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

		if (g_ascii_strncasecmp(node->key, alias, len) == 0) {
			word = cmdchar == '\0' ? g_strdup(node->key) :
				g_strdup_printf("%c%s", cmdchar, node->key);
			/* add matching alias to completion list, aliases will
			   be appended after command completions and kept in
			   uppercase to show it's an alias */
			if (glist_find_icase_string(complist, word) == NULL)
				complist = g_list_insert_sorted(complist, word, (GCompareFunc) g_istr_cmp);
			else
				g_free(word);
		}
	}
	return complist;
}
示例#24
0
文件: completion.c 项目: irssi/irssi
/* 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);
}
示例#25
0
static int backwards_compatibility(const char *module, CONFIG_NODE *node,
				   CONFIG_NODE *parent)
{
	const char *new_key, *new_module;
	CONFIG_NODE *new_node;
	char *new_value;
	int old_value;

	new_value = NULL; new_key = NULL; new_module = NULL;

	/* fe-text term_type -> fe-common/core term_charset - for 0.8.10-> */
	if (strcmp(module, "fe-text") == 0) {
		if (strcasecmp(node->key, "term_type") == 0 ||
		    /* kludge for cvs-version where term_charset was in fe-text */
		    strcasecmp(node->key, "term_charset") == 0) {
			new_module = "fe-common/core";
			new_key = "term_charset";
			new_value = !is_valid_charset(node->value) ? NULL :
				g_strdup(node->value);
			new_node = iconfig_node_traverse("settings", FALSE);
			new_node = new_node == NULL ? NULL :
				config_node_section(new_node, new_module, -1);

			config_node_set_str(mainconfig, new_node,
					    new_key, new_value);
			/* remove old */
			config_node_set_str(mainconfig, parent,
					    node->key, NULL);
			g_free(new_value);
			config_changed = TRUE;
			return new_key != NULL;
		}
	}
	new_value = NULL, new_key = NULL;
	/* FIXME: remove later - for 0.8.6 -> */
	if (node->value == NULL || !is_numeric(node->value, '\0'))
		return FALSE;

	old_value = atoi(node->value);

	if (strcmp(module, "fe-text") == 0) {
		if (strcasecmp(node->key, "lag_min_show") == 0)
			new_value = g_strdup_printf("%dms", old_value*10);
		else if (strcasecmp(node->key, "scrollback_hours") == 0) {
			new_value = g_strdup_printf("%dh", old_value);
			new_key = "scrollback_time";
		}
	} else if (strcmp(module, "irc/core") == 0) {
		if (strcasecmp(node->key, "cmd_queue_speed") == 0)
			new_value = g_strdup_printf("%dms", old_value);
	} else if (strcmp(module, "irc/dcc") == 0) {
		if (strcasecmp(node->key, "dcc_autoget_max_size") == 0)
			new_value = g_strdup_printf("%dk", old_value);
	} else if (strcmp(module, "irc/notify") == 0) {
		if (strcasecmp(node->key, "notify_idle_time") == 0)
			new_value = g_strdup_printf("%dmin", old_value);
	} else if (strcmp(module, "core") == 0) {
		if (strcasecmp(node->key, "write_buffer_mins") == 0) {
			new_value = g_strdup_printf("%dmin", old_value);
			new_key = "write_buffer_timeout";
		} else if (strcasecmp(node->key, "write_buffer_kb") == 0) {
			new_value = g_strdup_printf("%dk", old_value);
			new_key = "write_buffer_size";
		}
	}

	if (new_key != NULL || new_value != NULL) {
		config_node_set_str(mainconfig, parent,
				    new_key != NULL ? new_key : node->key,
				    new_value != NULL ?
				    new_value : node->value);
		if (new_key != NULL) {
			/* remove old */
			config_node_set_str(mainconfig, parent,
					    node->key, NULL);
		}
		config_changed = TRUE;
		g_free(new_value);
	}
	return new_key != NULL;
}