Beispiel #1
0
/* SYNTAX: STATUSBAR ADDITEM|MODIFYITEM [-before | -after <item>]
           [-priority #] [-alignment left|right] <item> <statusbar> */
static void cmd_statusbar_additem_modifyitem(const char *data, void *server, void *witem)
{
	CONFIG_NODE *node;
	GHashTable *optlist;
	char *item, *statusbar, *value;
	void *free_arg;
	int index;
	int additem = GPOINTER_TO_INT(signal_get_user_data());

	if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTIONS | PARAM_FLAG_STRIP_TRAILING_WS,
	                    "statusbar additem", &optlist, &item, &statusbar))
		return;

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

	node = sbar_find_item_with_defaults(statusbar, item, additem);
	if (node == NULL) {
		cmd_params_free(free_arg);
		return;
	}

	/* get the index */
	index = -1;
	value = g_hash_table_lookup(optlist, "before");
	if (value != NULL)
		index = config_node_index(node, value);
	value = g_hash_table_lookup(optlist, "after");
	if (value != NULL)
		index = config_node_index(node, value) + 1;

	/* create/move item */
	node = iconfig_node_section_index(node, item, index, NODE_TYPE_BLOCK);

	/* set the options */
	value = g_hash_table_lookup(optlist, "priority");
	if (value != NULL) iconfig_node_set_int(node, "priority", atoi(value));

	value = g_hash_table_lookup(optlist, "alignment");
	if (value != NULL) {
		iconfig_node_set_str(node, "alignment",
				     g_ascii_strcasecmp(value, "right") == 0 ?
				     "right" : NULL);
	}

	read_statusbar_config();
	cmd_params_free(free_arg);
}
Beispiel #2
0
/* SYNTAX: STATUSBAR <name> ADD [-before | -after <item>]
           [-priority #] [-alignment left|right] <item> */
static void cmd_statusbar_add(const char *data, void *server,
			      void *item, CONFIG_NODE *node)
{
        GHashTable *optlist;
        char *name, *value;
	void *free_arg;
        int index;

	node = statusbar_items_section(node);
	if (node == NULL)
                return;

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

        /* get the index */
	index = -1;
	value = g_hash_table_lookup(optlist, "before");
	if (value != NULL) index = config_node_index(node, value);
	value = g_hash_table_lookup(optlist, "after");
	if (value != NULL) index = config_node_index(node, value)+1;

        /* create/move item */
	node = config_node_section_index(node, name, index, NODE_TYPE_BLOCK);

        /* set the options */
        value = g_hash_table_lookup(optlist, "priority");
        if (value != NULL) iconfig_node_set_int(node, "priority", atoi(value));

	value = g_hash_table_lookup(optlist, "alignment");
	if (value != NULL) {
		iconfig_node_set_str(node, "alignment",
				     g_strcasecmp(value, "right") == 0 ?
				     "right" : NULL);
	}

	cmd_params_free(free_arg);
}
Beispiel #3
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);
}