예제 #1
0
static void window_save(WINDOW_REC *window, CONFIG_NODE *node)
{
	char refnum[MAX_INT_STRLEN];

        ltoa(refnum, window->refnum);
	node = config_node_section(node, refnum, NODE_TYPE_BLOCK);

	if (window->sticky_refnum)
		iconfig_node_set_bool(node, "sticky_refnum", TRUE);

	if (window->immortal)
		iconfig_node_set_bool(node, "immortal", TRUE);

	if (window->name != NULL)
		iconfig_node_set_str(node, "name", window->name);

	if (window->history_name != NULL)
		iconfig_node_set_str(node, "history_name", window->history_name);

	if (window->servertag != NULL)
		iconfig_node_set_str(node, "servertag", window->servertag);
	if (window->level != 0) {
                char *level = bits2level(window->level);
		iconfig_node_set_str(node, "level", level);
		g_free(level);
	}
	if (window->theme_name != NULL)
		iconfig_node_set_str(node, "theme", window->theme_name);

	if (window->items != NULL)
		window_save_items(window, node);

	signal_emit("layout save window", 2, window, node);
}
예제 #2
0
파일: ignore.c 프로젝트: ahf/irssi
static void ignore_set_config(IGNORE_REC *rec)
{
	CONFIG_NODE *node;
	char *levelstr;

	if (rec->level == 0)
		return;

	node = iconfig_node_traverse("(ignores", TRUE);
	node = iconfig_node_section(node, NULL, NODE_TYPE_BLOCK);

	if (rec->mask != NULL) iconfig_node_set_str(node, "mask", rec->mask);
	if (rec->level) {
		levelstr = bits2level(rec->level);
		iconfig_node_set_str(node, "level", levelstr);
		g_free(levelstr);
	}
	iconfig_node_set_str(node, "pattern", rec->pattern);
	if (rec->exception) iconfig_node_set_bool(node, "exception", TRUE);
	if (rec->regexp) iconfig_node_set_bool(node, "regexp", TRUE);
	if (rec->fullword) iconfig_node_set_bool(node, "fullword", TRUE);
	if (rec->replies) iconfig_node_set_bool(node, "replies", TRUE);
	if (rec->unignore_time != 0)
		iconfig_node_set_int(node, "unignore_time", rec->unignore_time);
	iconfig_node_set_str(node, "servertag", rec->servertag);

	if (rec->channels != NULL && *rec->channels != NULL) {
		node = iconfig_node_section(node, "channels", NODE_TYPE_LIST);
		iconfig_node_add_list(node, rec->channels);
	}
}
예제 #3
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->act_color) iconfig_node_set_str(node, "act_color", rec->act_color);
    if (rec->priority > 0) iconfig_node_set_int(node, "priority", rec->priority);
    iconfig_node_set_bool(node, "nick", rec->nick);
    iconfig_node_set_bool(node, "word", rec->word);
    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->servertag) iconfig_node_set_str(node, "servertag", rec->servertag);

    if (rec->channels != NULL && *rec->channels != NULL) {
        node = config_node_section(node, "channels", NODE_TYPE_LIST);
        iconfig_node_add_list(node, rec->channels);
    }
}
예제 #4
0
파일: log.c 프로젝트: FabrizioFabbe/silc
static void log_update_config(LOG_REC *log)
{
	CONFIG_NODE *node;
	char *levelstr;

	if (log->temp)
		return;

	node = iconfig_node_traverse("logs", TRUE);
	node = config_node_section(node, log->fname, NODE_TYPE_BLOCK);

	if (log->autoopen)
		iconfig_node_set_bool(node, "auto_open", TRUE);
	else
		iconfig_node_set_str(node, "auto_open", NULL);

	levelstr = bits2level(log->level);
	iconfig_node_set_str(node, "level", levelstr);
	g_free(levelstr);

	iconfig_node_set_str(node, "items", NULL);

	if (log->items != NULL)
		log_items_update_config(log, node);

	signal_emit("log config save", 2, log, node);
}
예제 #5
0
파일: fe-log.c 프로젝트: ailin-nemui/irssi
static void sig_log_config_save(LOG_REC *log, CONFIG_NODE *node)
{
        if (log->colorizer == NULL)
		iconfig_node_set_bool(node, "colors", TRUE);
        else
		iconfig_node_set_str(node, "colors", NULL);
}
예제 #6
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);
}
예제 #7
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);
}
예제 #8
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);
}
예제 #9
0
void settings_set_bool(const char *key, int value)
{
        iconfig_node_set_bool(settings_get_node(key), key, value);
}
예제 #10
0
/* SYNTAX: STATUSBAR <name> DISABLE */
static void cmd_statusbar_disable(const char *data, void *server,
				  void *item, CONFIG_NODE *node)
{
        iconfig_node_set_bool(node, "disabled", TRUE);
}
예제 #11
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);
}
예제 #12
0
/* SYNTAX: STATUSBAR ADD|MODIFY [-disable | -nodisable] [-type window|root]
           [-placement top|bottom] [-position #] [-visible always|active|inactive] <statusbar> */
static void cmd_statusbar_add_modify(const char *data, void *server, void *witem)
{
	GHashTable *optlist;
	CONFIG_NODE *node;
	char *name, *type, *placement, *visible;
	void *free_arg;
	int error;
	int add = GPOINTER_TO_INT(signal_get_user_data());

	if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS | PARAM_FLAG_STRIP_TRAILING_WS,
	                    "statusbar add", &optlist, &name))
		return;

	if (*name == '\0') {
		cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
	}

	error = 0;

	type = NULL;
	data = g_hash_table_lookup(optlist, "type");
	if (data != NULL) {
		if (g_ascii_strcasecmp(data, "window") == 0)
			type = "window";
		else if (g_ascii_strcasecmp(data, "root") == 0)
			type = "root";
		else {
			printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_STATUSBAR_UNKNOWN_TYPE,
			            data);
			error++;
		}
	}

	placement = NULL;
	data = g_hash_table_lookup(optlist, "placement");
	if (data != NULL) {
		if (g_ascii_strcasecmp(data, "top") == 0)
			placement = "top";
		else if (g_ascii_strcasecmp(data, "bottom") == 0)
			placement = "bottom";
		else {
			printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
			            TXT_STATUSBAR_UNKNOWN_PLACEMENT, data);
			error++;
		}
	}

	visible = NULL;
	data = g_hash_table_lookup(optlist, "visible");
	if (data != NULL) {
		if (g_ascii_strcasecmp(data, "always") == 0)
			visible = "always";
		else if (g_ascii_strcasecmp(data, "active") == 0)
			visible = "active";
		else if (g_ascii_strcasecmp(data, "inactive") == 0)
			visible = "inactive";
		else {
			printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
			            TXT_STATUSBAR_UNKNOWN_VISIBILITY, data);
			error++;
		}
	}

	if (!error) {
		node = sbar_node(name, add);
		if (node == NULL && !add && sbar_node_isdefault(name)) {
			/* If this node is a default status bar, we need to create it in the config
			 * to configure it */
			node = sbar_node(name, TRUE);
		}

		if (node == NULL) {
			printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_STATUSBAR_NOT_FOUND, name);
			error++;
		}
	}

	if (error) {
		cmd_params_free(free_arg);
		return;
	}

	if (g_hash_table_lookup(optlist, "nodisable"))
		iconfig_node_set_str(node, "disabled", NULL);
	if (g_hash_table_lookup(optlist, "disable"))
		iconfig_node_set_bool(node, "disabled", TRUE);
	if (type != NULL)
		iconfig_node_set_str(node, "type", type);
	if (placement != NULL)
		iconfig_node_set_str(node, "placement", placement);
	data = g_hash_table_lookup(optlist, "position");
	if (data != NULL)
		iconfig_node_set_int(node, "position", atoi(data));
	if (visible != NULL)
		iconfig_node_set_str(node, "visible", visible);

	read_statusbar_config();
	cmd_params_free(free_arg);
}