Пример #1
0
/**
 * Initialize Tox-WeeChat config. Creates file and section objects.
 */
void
twc_config_init()
{
    twc_config_file = weechat_config_new("tox", NULL, NULL);

    twc_config_section_profile =
        weechat_config_new_section(twc_config_file, "profile",
                                   0, 0,
                                   twc_config_profile_read_callback, NULL,
                                   NULL, NULL,
                                   NULL, NULL,
                                   NULL, NULL,
                                   NULL, NULL);

    twc_config_section_profile_default =
        weechat_config_new_section(twc_config_file, "profile_default",
                                   0, 0,
                                   NULL, NULL,
                                   NULL, NULL,
                                   NULL, NULL,
                                   NULL, NULL,
                                   NULL, NULL);

    for (int i = 0; i < TWC_PROFILE_NUM_OPTIONS; ++i)
    {
        twc_config_profile_default[i] =
            twc_config_init_option(twc_config_section_profile_default,
                                   i, twc_profile_option_names[i], true);
    }

    twc_config_section_look =
        weechat_config_new_section(twc_config_file, "look",
                                   0, 0,
                                   NULL, NULL,
                                   NULL, NULL,
                                   NULL, NULL,
                                   NULL, NULL,
                                   NULL, NULL);

    twc_config_friend_request_message = weechat_config_new_option(
        twc_config_file, twc_config_section_look,
        "friend_request_message", "string",
        "message sent with friend requests if no other message is specified",
        NULL, 0, 0,
        "Hi! Please add me on Tox!", NULL, 0,
        twc_config_check_value_callback, NULL,
        NULL, NULL, NULL, NULL);
    twc_config_short_id_size = weechat_config_new_option(
        twc_config_file, twc_config_section_look,
        "short_id_size", "integer",
        "length of Tox IDs shown in short format; must be a multiple of two",
        NULL, 2, TOX_PUBLIC_KEY_SIZE * 2,
        "8", NULL, 0,
        twc_config_check_value_callback, NULL,
        NULL, NULL, NULL, NULL);
}
Пример #2
0
void
rmodifier_config_modifier_new_option (const char *name, const char *modifiers,
                                      const char *regex, const char *groups)
{
    int length;
    char *value;

    length = strlen (modifiers) + 1 + strlen (regex) + 1 +
        ((groups) ? strlen (groups) : 0) + 1;
    value = malloc (length);
    if (value)
    {
        snprintf (value, length, "%s;%s;%s",
                  modifiers, regex,
                  (groups) ? groups : "");
        weechat_config_new_option (rmodifier_config_file,
                                   rmodifier_config_section_modifier,
                                   name, "string", NULL,
                                   NULL, 0, 0, "", value, 0,
                                   NULL, NULL,
                                   &rmodifier_config_modifier_change_cb, NULL,
                                   &rmodifier_config_modifier_delete_cb, NULL);
        free (value);
    }
}
Пример #3
0
int
fifo_config_init ()
{
    struct t_config_section *ptr_section;

    fifo_config_file = weechat_config_new (FIFO_CONFIG_NAME,
                                           NULL, NULL, NULL);
    if (!fifo_config_file)
        return 0;

    /* file */
    ptr_section = weechat_config_new_section (fifo_config_file, "file",
                                              0, 0,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (fifo_config_file);
        fifo_config_file = NULL;
        return 0;
    }

    fifo_config_file_enabled = weechat_config_new_option (
        fifo_config_file, ptr_section,
        "enabled", "boolean",
        N_("enable FIFO pipe"),
        NULL, 0, 0, "on", NULL, 0,
        NULL, NULL, NULL,
        &fifo_config_change_file_enabled, NULL, NULL,
        NULL, NULL, NULL);
    fifo_config_file_path = weechat_config_new_option (
        fifo_config_file, ptr_section,
        "path", "string",
        N_("path for FIFO file; \"%h\" at beginning of string is "
           "replaced by WeeChat home (\"~/.weechat\" by default); "
           "WeeChat PID can be used in path with ${info:pid} "
           "(note: content is evaluated, see /help eval)"),
        NULL, 0, 0, "%h/weechat_fifo", NULL, 0,
        NULL, NULL, NULL,
        fifo_config_change_file_path, NULL, NULL,
        NULL, NULL, NULL);

    return 1;
}
Пример #4
0
int
plugin_script_config_init (struct t_weechat_plugin *weechat_plugin,
                           struct t_plugin_script_data *plugin_data)
{
    struct t_config_section *ptr_section;

    *(plugin_data->config_file) = weechat_config_new (weechat_plugin->name,
                                                      NULL, NULL, NULL);
    if (!(*plugin_data->config_file))
        return 0;

    /* look */
    ptr_section = weechat_config_new_section (*(plugin_data->config_file),
                                              "look",
                                              0, 0,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (*(plugin_data->config_file));
        *(plugin_data->config_file) = NULL;
        return 0;
    }

    *(plugin_data->config_look_check_license) = weechat_config_new_option (
        *(plugin_data->config_file), ptr_section,
        "check_license", "boolean",
        N_("check the license of scripts when they are loaded: if the license "
           "is different from the plugin license, a warning is displayed"),
        NULL, 0, 0, "off", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
    *(plugin_data->config_look_eval_keep_context) = weechat_config_new_option (
        *(plugin_data->config_file), ptr_section,
        "eval_keep_context", "boolean",
        N_("keep context between two calls to the source code evaluation "
           "(option \"eval\" of script command or info \"%s_eval\"); "
           "a hidden script is used to eval script code; "
           "if this option is disabled, this hidden script is unloaded after "
           "each eval: this uses less memory, but is slower"),
        NULL, 0, 0, "on", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

    return 1;
}
Пример #5
0
int
logger_config_mask_create_option (void *data,
                                  struct t_config_file *config_file,
                                  struct t_config_section *section,
                                  const char *option_name,
                                  const char *value)
{
    struct t_config_option *ptr_option;
    int rc;
    
    /* make C compiler happy */
    (void) data;
    
    rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
    
    if (option_name)
    {
        ptr_option = weechat_config_search_option (config_file, section,
                                                   option_name);
        if (ptr_option)
        {
            if (value && value[0])
                rc = weechat_config_option_set (ptr_option, value, 1);
            else
            {
                weechat_config_option_free (ptr_option);
                rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
            }
        }
        else
        {
            if (value && value[0])
            {
                ptr_option = weechat_config_new_option (
                    config_file, section,
                    option_name, "string",
                    _("file mask for log file; local buffer variables are "
                      "permitted"),
                    NULL, 0, 0, "", value, 0, NULL, NULL,
                    &logger_config_mask_change, NULL,
                    NULL, NULL);
                rc = (ptr_option) ?
                    WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
            }
            else
                rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
        }
    }

    if (!logger_config_loading)
    {
        logger_stop_all ();
        logger_start_buffer_all ();
    }
    
    return rc;
}
Пример #6
0
int
logger_config_level_create_option (const void *pointer, void *data,
                                   struct t_config_file *config_file,
                                   struct t_config_section *section,
                                   const char *option_name,
                                   const char *value)
{
    struct t_config_option *ptr_option;
    int rc;

    /* make C compiler happy */
    (void) pointer;
    (void) data;

    rc = WEECHAT_CONFIG_OPTION_SET_ERROR;

    if (option_name)
    {
        ptr_option = weechat_config_search_option (config_file, section,
                                                   option_name);
        if (ptr_option)
        {
            if (value && value[0])
                rc = weechat_config_option_set (ptr_option, value, 1);
            else
            {
                weechat_config_option_free (ptr_option);
                rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
            }
        }
        else
        {
            if (value && value[0])
            {
                ptr_option = weechat_config_new_option (
                    config_file, section,
                    option_name, "integer",
                    _("logging level for this buffer (0 = logging disabled, "
                      "1 = a few messages (most important) .. 9 = all messages)"),
                      NULL, 0, 9, "9", value, 0,
                    NULL, NULL, NULL,
                    &logger_config_level_change, NULL,  NULL,
                    NULL, NULL, NULL);
                rc = (ptr_option) ?
                    WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
            }
            else
                rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
        }
    }

    if (!logger_config_loading)
        logger_start_buffer_all (1);

    return rc;
}
Пример #7
0
void
alias_config_cmd_new_option (const char *name, const char *command)
{
    weechat_config_new_option (alias_config_file, alias_config_section_cmd,
                               name, "string", NULL,
                               NULL, 0, 0, NULL, command, 0,
                               NULL, NULL,
                               &alias_config_cmd_change_cb, NULL,
                               &alias_config_cmd_delete_cb, NULL);
}
Пример #8
0
int
charset_config_create_option (void *data, struct t_config_file *config_file,
                              struct t_config_section *section,
                              const char *option_name, const char *value)
{
    struct t_config_option *ptr_option;
    int rc;

    /* make C compiler happy */
    (void) data;

    rc = WEECHAT_CONFIG_OPTION_SET_ERROR;

    if (option_name)
    {
        ptr_option = weechat_config_search_option (config_file, section,
                                                   option_name);
        if (ptr_option)
        {
            if (value && value[0])
                rc = weechat_config_option_set (ptr_option, value, 1);
            else
            {
                weechat_config_option_free (ptr_option);
                rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
            }
        }
        else
        {
            if (value && value[0])
            {
                ptr_option = weechat_config_new_option (
                    config_file, section,
                    option_name, "string", NULL,
                    NULL, 0, 0, "", value, 0,
                    NULL, NULL, NULL, NULL, NULL, NULL);
                rc = (ptr_option) ?
                    WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
            }
            else
                rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
        }
    }

    if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR)
    {
        weechat_printf (NULL,
                        _("%s%s: error creating charset \"%s\" => \"%s\""),
                        weechat_prefix ("error"), CHARSET_PLUGIN_NAME,
                        option_name, value);
    }

    return rc;
}
Пример #9
0
int
rmodifier_config_init ()
{
    struct t_config_section *ptr_section;

    rmodifier_config_file = weechat_config_new (RMODIFIER_CONFIG_NAME,
                                                &rmodifier_config_reload, NULL);
    if (!rmodifier_config_file)
        return 0;

    /* look */
    ptr_section = weechat_config_new_section (rmodifier_config_file, "look",
                                              0, 0,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (rmodifier_config_file);
        return 0;
    }

    rmodifier_config_look_hide_char = weechat_config_new_option (
        rmodifier_config_file, ptr_section,
        "hide_char", "string",
        N_("char used to hide part of a string"),
        NULL, 0, 0, "*", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);

    /* modifier */
    ptr_section = weechat_config_new_section (rmodifier_config_file, "modifier",
                                              0, 0,
                                              NULL, NULL,
                                              NULL, NULL,
                                              &rmodifier_config_modifier_write_default_cb, NULL,
                                              &rmodifier_config_modifier_create_option_cb, NULL,
                                              NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (rmodifier_config_file);
        return 0;
    }
    rmodifier_config_section_modifier = ptr_section;

    return 1;
}
Пример #10
0
int
relay_config_create_option_port (void *data,
                                 struct t_config_file *config_file,
                                 struct t_config_section *section,
                                 const char *option_name,
                                 const char *value)
{
    int rc, protocol_number, ipv4, ipv6, ssl;
    char *error, *protocol, *protocol_args;
    long port;
    struct t_relay_server *ptr_server;

    /* make C compiler happy */
    (void) data;

    rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;

    protocol_number = -1;
    port = -1;

    relay_server_get_protocol_args (option_name, &ipv4, &ipv6, &ssl,
                                    &protocol, &protocol_args);

#ifndef HAVE_GNUTLS
    if (ssl)
    {
        weechat_printf (NULL,
                        _("%s%s: cannot use SSL because WeeChat was not built "
                          "with GnuTLS support"),
                        weechat_prefix ("error"), RELAY_PLUGIN_NAME);
        rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
    }
#endif

    if (rc != WEECHAT_CONFIG_OPTION_SET_ERROR)
    {
        if (protocol)
            protocol_number = relay_protocol_search (protocol);

        if (protocol_number < 0)
        {
            weechat_printf (NULL, _("%s%s: error: unknown protocol \"%s\""),
                            weechat_prefix ("error"),
                            RELAY_PLUGIN_NAME, protocol);
            rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
        }

        if ((protocol_number == RELAY_PROTOCOL_WEECHAT) && protocol_args)
        {
            weechat_printf (NULL, _("%s%s: error: name is not allowed for "
                                    "protocol \"%s\""),
                            weechat_prefix ("error"),
                            RELAY_PLUGIN_NAME, protocol);
            rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
        }
    }

    if (rc != WEECHAT_CONFIG_OPTION_SET_ERROR)
    {
        if (weechat_config_search_option (config_file, section, option_name))
        {
            weechat_printf (NULL, _("%s%s: error: relay for \"%s\" already exists"),
                            weechat_prefix ("error"),
                            RELAY_PLUGIN_NAME, option_name);
            rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
        }
    }

    if (rc != WEECHAT_CONFIG_OPTION_SET_ERROR)
    {
        error = NULL;
        port = strtol (value, &error, 10);
        ptr_server = relay_server_search_port ((int)port);
        if (ptr_server)
        {
            weechat_printf (NULL, _("%s%s: error: port \"%d\" is already used"),
                            weechat_prefix ("error"),
                            RELAY_PLUGIN_NAME, (int)port);
            rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
        }
    }

    if (rc != WEECHAT_CONFIG_OPTION_SET_ERROR)
    {
        if (relay_server_new (option_name, protocol_number, protocol_args,
                              port, ipv4, ipv6, ssl))
        {
            /* create configuration option */
            weechat_config_new_option (
                config_file, section,
                option_name, "integer", NULL,
                NULL, 0, 65535, "", value, 0,
                &relay_config_check_port_cb, NULL,
                &relay_config_change_port_cb, NULL,
                &relay_config_delete_port_cb, NULL);
            rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
        }
        else
            rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
    }

    if (protocol)
        free (protocol);
    if (protocol_args)
        free (protocol_args);

    return rc;
}
Пример #11
0
/**
 * Create a new option for a profile.
 */
struct t_config_option *
twc_config_init_option(struct t_config_section *section,
                       int option_index, const char *option_name,
                       bool is_default_profile)
{
    char *type;
    char *description;
    char *string_values = NULL;
    int min = 0, max = 0;
    char *value;
    char *default_value = NULL;
    bool null_allowed = false;


    switch (option_index)
    {
        case TWC_PROFILE_OPTION_AUTOLOAD:
            type = "boolean";
            description = "automatically load profile and connect to the Tox "
                          "network when WeeChat starts";
            default_value = "off";
            break;
        case TWC_PROFILE_OPTION_IPV6:
            type = "boolean";
            description = "use IPv6 as well as IPv4 to connect to the Tox "
                          "network";
            default_value = "on";
            break;
        case TWC_PROFILE_OPTION_MAX_FRIEND_REQUESTS:
            type = "integer";
            description = "maximum amount of friend requests to retain before "
                          "ignoring new ones";
            min = 0; max = INT_MAX;
            default_value = "100";
            break;
        case TWC_PROFILE_OPTION_PASSPHRASE:
            type = "string";
            description = "passphrase for encrypted profile";
            null_allowed = true;
            break;
        case TWC_PROFILE_OPTION_PROXY_ADDRESS:
            type = "string";
            description = "proxy address";
            null_allowed = true;
            break;
        case TWC_PROFILE_OPTION_PROXY_PORT:
            type = "integer";
            description = "proxy port";
            min = 0; max = UINT16_MAX;
            null_allowed = true;
            break;
        case TWC_PROFILE_OPTION_PROXY_TYPE:
            type = "integer";
            description = "proxy type; requires profile reload to take effect";
            string_values = "none|socks5|http";
            min = 0; max = 0;
            default_value = "none";
            break;
        case TWC_PROFILE_OPTION_SAVEFILE:
            type = "string";
            description = "path to Tox data file (\"%h\" will be replaced by "
                          "WeeChat home folder and \"%p\" by profile name";
            default_value = "%h/tox/%p";
            break;
        case TWC_PROFILE_OPTION_UDP:
            type = "boolean";
            description = "use UDP when communicating with the Tox network";
            default_value = "on";
            break;
        default:
            return NULL;
    }

    null_allowed = null_allowed || !is_default_profile;
    value = is_default_profile ? default_value : NULL;

    return weechat_config_new_option(
        twc_config_file, section,
        option_name, type, description, string_values, min, max,
        default_value, value, null_allowed,
        twc_config_profile_check_value_callback, (void *)(intptr_t)option_index,
        twc_config_profile_change_callback, (void *)(intptr_t)option_index,
        NULL, NULL);
}
Пример #12
0
int
xfer_config_init ()
{
    struct t_config_section *ptr_section;

    xfer_config_file = weechat_config_new (XFER_CONFIG_NAME,
                                           &xfer_config_reload, NULL);
    if (!xfer_config_file)
        return 0;

    ptr_section = weechat_config_new_section (xfer_config_file, "look",
                                              0, 0,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (xfer_config_file);
        return 0;
    }

    xfer_config_look_auto_open_buffer = weechat_config_new_option (
        xfer_config_file, ptr_section,
        "auto_open_buffer", "boolean",
        N_("auto open xfer buffer when a new xfer is added "
           "to list"),
        NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
    xfer_config_look_progress_bar_size = weechat_config_new_option (
        xfer_config_file, ptr_section,
        "progress_bar_size", "integer",
        N_("size of progress bar, in chars (if 0, progress bar is disabled)"),
        NULL, 0, XFER_CONFIG_PROGRESS_BAR_MAX_SIZE, "20", NULL, 0,
        NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
    xfer_config_look_pv_tags = weechat_config_new_option (
        xfer_config_file, ptr_section,
        "pv_tags", "string",
        N_("comma separated list of tags used in private messages, for example: "
           "\"notify_message\", \"notify_private\" or \"notify_highlight\""),
        NULL, 0, 0, "notify_private", NULL, 0, NULL, NULL,
        NULL, NULL, NULL, NULL);

    ptr_section = weechat_config_new_section (xfer_config_file, "color",
                                              0, 0,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (xfer_config_file);
        return 0;
    }

    xfer_config_color_status[XFER_STATUS_WAITING] = weechat_config_new_option (
        xfer_config_file, ptr_section,
        "status_waiting", "color",
        N_("text color for \"waiting\" status"),
        NULL, 0, 0, "lightcyan", NULL, 0,
        NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
    xfer_config_color_status[XFER_STATUS_CONNECTING] = weechat_config_new_option (
        xfer_config_file, ptr_section,
        "status_connecting", "color",
        N_("text color for \"connecting\" status"),
        NULL, 0, 0, "yellow", NULL, 0,
        NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
    xfer_config_color_status[XFER_STATUS_ACTIVE] = weechat_config_new_option (
        xfer_config_file, ptr_section,
        "status_active", "color",
        N_("text color for \"active\" status"),
        NULL, 0, 0, "lightblue", NULL, 0,
        NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
    xfer_config_color_status[XFER_STATUS_DONE] = weechat_config_new_option (
        xfer_config_file, ptr_section,
        "status_done", "color",
        N_("text color for \"done\" status"),
        NULL, 0, 0, "lightgreen", NULL, 0,
        NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
    xfer_config_color_status[XFER_STATUS_FAILED] = weechat_config_new_option (
        xfer_config_file, ptr_section,
        "status_failed", "color",
        N_("text color for \"failed\" status"),
        NULL, 0, 0, "lightred", NULL, 0,
        NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
    xfer_config_color_status[XFER_STATUS_ABORTED] = weechat_config_new_option (
        xfer_config_file, ptr_section,
        "status_aborted", "color",
        N_("text color for \"aborted\" status"),
        NULL, 0, 0, "lightred", NULL, 0,
        NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
    xfer_config_color_text = weechat_config_new_option (
        xfer_config_file, ptr_section,
        "text", "color",
        N_("text color in xfer buffer"),
        NULL, 0, 0, "default", NULL, 0,
        NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
    xfer_config_color_text_bg = weechat_config_new_option (
        xfer_config_file, ptr_section,
        "text_bg", "color",
        N_("background color in xfer buffer"),
        NULL, 0, 0, "default", NULL, 0,
        NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);
    xfer_config_color_text_selected = weechat_config_new_option (
        xfer_config_file, ptr_section,
        "text_selected", "color",
        N_("text color of selected line in xfer buffer"),
        NULL, 0, 0, "white", NULL, 0,
        NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL);

    ptr_section = weechat_config_new_section (xfer_config_file, "network",
                                              0, 0,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (xfer_config_file);
        return 0;
    }

    xfer_config_network_blocksize = weechat_config_new_option (
        xfer_config_file, ptr_section,
        "blocksize", "integer",
        N_("block size for sending packets, in bytes"),
        NULL, XFER_BLOCKSIZE_MIN, XFER_BLOCKSIZE_MAX, "65536", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL);
    xfer_config_network_fast_send = weechat_config_new_option (
        xfer_config_file, ptr_section,
        "fast_send", "boolean",
        N_("does not wait for ACK when sending file"),
        NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
    xfer_config_network_own_ip = weechat_config_new_option (
        xfer_config_file, ptr_section,
        "own_ip", "string",
        N_("IP or DNS address used for sending files/chats "
           "(if empty, local interface IP is used)"),
        NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
    xfer_config_network_port_range = weechat_config_new_option (
        xfer_config_file, ptr_section,
        "port_range", "string",
        N_("restricts outgoing files/chats to use only ports in the given "
           "range (useful for NAT) (syntax: a single port, ie. 5000 or a port "
           "range, ie. 5000-5015, empty value means any port, it's recommended "
           "to use ports greater than 1024, because only root can use ports "
           "below 1024)"),
        NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
    xfer_config_network_speed_limit = weechat_config_new_option (
        xfer_config_file, ptr_section,
        "speed_limit", "integer",
        N_("speed limit for sending files, in kilo-bytes by second (0 means "
           "no limit)"),
        NULL, 0, INT_MAX, "0", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
    xfer_config_network_timeout = weechat_config_new_option (
        xfer_config_file, ptr_section,
        "timeout", "integer",
        N_("timeout for xfer request (in seconds)"),
        NULL, 5, INT_MAX, "300", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);

    ptr_section = weechat_config_new_section (xfer_config_file, "file",
                                              0, 0,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (xfer_config_file);
        return 0;
    }

    xfer_config_file_auto_accept_chats = weechat_config_new_option (
        xfer_config_file, ptr_section,
        "auto_accept_chats", "boolean",
        N_("automatically accept chat requests (use carefully!)"),
        NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
    xfer_config_file_auto_accept_files = weechat_config_new_option (
        xfer_config_file, ptr_section,
        "auto_accept_files", "boolean",
        N_("automatically accept incoming files (use carefully!)"),
        NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
    xfer_config_file_auto_accept_nicks = weechat_config_new_option (
        xfer_config_file, ptr_section,
        "auto_accept_nicks", "string",
        N_("comma-separated list of nicks for which the incoming files and "
           "chats are automatically accepted; format is \"server.nick\" (for a "
           "specific server) or \"nick\" (for all servers); example: "
           "\"freenode.FlashCode,andrew\""),
        NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
    xfer_config_file_auto_rename = weechat_config_new_option (
        xfer_config_file, ptr_section,
        "auto_rename", "boolean",
        N_("rename incoming files if already exists (add \".1\", \".2\", ...)"),
        NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
    xfer_config_file_auto_resume = weechat_config_new_option (
        xfer_config_file, ptr_section,
        "auto_resume", "boolean",
        N_("automatically resume file transfer if connection with remote host "
           "is lost"),
        NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
    xfer_config_file_convert_spaces = weechat_config_new_option (
        xfer_config_file, ptr_section,
        "convert_spaces", "boolean",
        N_("convert spaces to underscores when sending files"),
        NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
    xfer_config_file_download_path = weechat_config_new_option (
        xfer_config_file, ptr_section,
        "download_path", "string",
        N_("path for writing incoming files (\"%h\" will be replaced by "
           "WeeChat home, \"~/.weechat\" by default)"),
        NULL, 0, 0, "%h/xfer", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
    xfer_config_file_upload_path = weechat_config_new_option (
        xfer_config_file, ptr_section,
        "upload_path", "string",
        N_("path for reading files when sending (when no path is "
           "specified by user) (\"%h\" will be replaced by "
           "WeeChat home, \"~/.weechat\" by default)"),
        NULL, 0, 0, "~", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
    xfer_config_file_use_nick_in_filename = weechat_config_new_option (
        xfer_config_file, ptr_section,
        "use_nick_in_filename", "boolean",
        N_("use remote nick as prefix in local filename when receiving a file"),
        NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);

    return 1;
}
Пример #13
0
int
weechat_aspell_config_dict_create_option (void *data,
                                          struct t_config_file *config_file,
                                          struct t_config_section *section,
                                          const char *option_name,
                                          const char *value)
{
    struct t_config_option *ptr_option;
    int rc;
    
    /* make C compiler happy */
    (void) data;
    
    rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
    
    if (value && value[0])
        weechat_aspell_speller_check_dictionaries (value);
    
    if (option_name)
    {
        ptr_option = weechat_config_search_option (config_file, section,
                                                   option_name);
        if (ptr_option)
        {
            if (value && value[0])
                rc = weechat_config_option_set (ptr_option, value, 1);
            else
            {
                weechat_config_option_free (ptr_option);
                rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
            }
        }
        else
        {
            if (value && value[0])
            {
                ptr_option = weechat_config_new_option (
                    config_file, section,
                    option_name, "string",
                    _("comma separated list of dictionaries to use on this buffer"),
                    NULL, 0, 0, "", value, 0,
                    NULL, NULL,
                    &weechat_aspell_config_dict_change, NULL,
                    NULL, NULL);
                rc = (ptr_option) ?
                    WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
            }
            else
                rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
        }
    }
    
    if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR)
    {
        weechat_printf (NULL,
                        _("%s%s: error creating aspell dictionary \"%s\" => \"%s\""),
                        weechat_prefix ("error"), ASPELL_PLUGIN_NAME,
                        option_name, value);
    }
    else
        weechat_aspell_create_spellers (weechat_current_buffer ());
    
    return rc;
}
Пример #14
0
int
weechat_aspell_config_option_create_option (const void *pointer, void *data,
                                            struct t_config_file *config_file,
                                            struct t_config_section *section,
                                            const char *option_name,
                                            const char *value)
{
    struct t_config_option *ptr_option;
    int rc;

    /* make C compiler happy */
    (void) pointer;
    (void) data;

    rc = WEECHAT_CONFIG_OPTION_SET_ERROR;

    if (option_name)
    {
        ptr_option = weechat_config_search_option (config_file, section,
                                                   option_name);
        if (ptr_option)
        {
            if (value && value[0])
                rc = weechat_config_option_set (ptr_option, value, 1);
            else
            {
                weechat_config_option_free (ptr_option);
                rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
            }
        }
        else
        {
            if (value && value[0])
            {
                ptr_option = weechat_config_new_option (
                    config_file, section,
                    option_name, "string",
                    _("option for aspell (for list of available options and "
                      "format, run command \"aspell config\" in a shell)"),
                    NULL, 0, 0, "", value, 0,
                    NULL, NULL, NULL,
                    &weechat_aspell_config_option_change, NULL, NULL,
                    NULL, NULL, NULL);
                rc = (ptr_option) ?
                    WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
            }
            else
                rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
        }
    }

    if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR)
    {
        weechat_printf (NULL,
                        _("%s%s: error creating aspell option \"%s\" => \"%s\""),
                        weechat_prefix ("error"), ASPELL_PLUGIN_NAME,
                        option_name, value);
    }
    else
    {
        weechat_hashtable_remove_all (weechat_aspell_speller_buffer);
        if (!weechat_aspell_config_loading)
            weechat_aspell_speller_remove_unused ();
    }

    return rc;
}
Пример #15
0
int
script_config_init ()
{
    struct t_config_section *ptr_section;

    script_config_file = weechat_config_new (SCRIPT_CONFIG_NAME,
                                             &script_config_reload, NULL);
    if (!script_config_file)
        return 0;

    /* look */
    ptr_section = weechat_config_new_section (script_config_file, "look",
                                              0, 0,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (script_config_file);
        return 0;
    }

    script_config_look_columns = weechat_config_new_option (
        script_config_file, ptr_section,
        "columns", "string",
        N_("format of columns displayed in script buffer: following column "
           "identifiers are replaced by their value: %a=author, %d=description, "
           "%D=date added, %e=extension, %l=language, %L=license, %n=name with "
           "extension, %N=name, %r=requirements, %s=status, %t=tags, "
           "%u=date updated, %v=version, %V=version loaded, %w=min_weechat, "
           "%W=max_weechat)"),
        NULL, 0, 0, "%s %n %V %v %u | %d | %t", NULL, 0,
        NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
    script_config_look_diff_color = weechat_config_new_option (
        script_config_file, ptr_section,
        "diff_color", "boolean",
        N_("colorize output of diff"),
        NULL, 0, 0, "on", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL);
    script_config_look_diff_command = weechat_config_new_option (
        script_config_file, ptr_section,
        "diff_command", "string",
        N_("command used to show differences between script installed and the "
           "new version in repository (\"auto\" = auto detect diff command (git "
           "or diff), empty value = disable diff, other string = name of "
           "command, for example \"diff\")"),
        NULL, 0, 0, "auto", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL);
    script_config_look_display_source = weechat_config_new_option (
        script_config_file, ptr_section,
        "display_source", "boolean",
        N_("display source code of script on buffer with detail on a script "
           "(script is downloaded in a temporary file when detail on script "
           "is displayed)"),
        NULL, 0, 0, "on", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL);
    script_config_look_quiet_actions = weechat_config_new_option (
        script_config_file, ptr_section,
        "quiet_actions", "boolean",
        N_("quiet actions on script buffer: do not display messages on core "
           "buffer when scripts are installed/removed/loaded/unloaded (only "
           "errors are displayed)"),
        NULL, 0, 0, "on", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL);
    script_config_look_sort = weechat_config_new_option (
        script_config_file, ptr_section,
        "sort", "string",
        N_("default sort keys for scripts: comma-separated list of identifiers: "
           "a=author, A=autoloaded, d=date added, e=extension, i=installed, "
           "l=language, n=name, o=obsolete, p=popularity, r=running, "
           "u=date updated; char \"-\" can be used before identifier to reverse "
           "order; example: \"i,u\": installed scripts first, sorted by update "
           "date"),
        NULL, 0, 0, "p,n", NULL, 0,
        NULL, NULL, &script_config_reload_scripts_cb, NULL, NULL, NULL);
    script_config_look_translate_description = weechat_config_new_option (
        script_config_file, ptr_section,
        "translate_description", "boolean",
        N_("translate description of scripts (if translation is available in "
           "your language, otherwise english version is used)"),
        NULL, 0, 0, "on", NULL, 0,
        NULL, NULL, &script_config_reload_scripts_cb, NULL, NULL, NULL);
    script_config_look_use_keys = weechat_config_new_option (
        script_config_file, ptr_section,
        "use_keys", "boolean",
        N_("use keys alt+X in script buffer to do actions on scripts (alt+i = "
           "install, alt+r = remove, ...); if disabled, only the input is "
           "allowed: i, r, ..."),
        NULL, 0, 0, "on", NULL, 0,
        NULL, NULL, &script_config_change_use_keys_cb, NULL, NULL, NULL);

    /* color */
    ptr_section = weechat_config_new_section (script_config_file, "color",
                                              0, 0,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (script_config_file);
        return 0;
    }

    script_config_color_status_autoloaded = weechat_config_new_option (
        script_config_file, ptr_section,
        "status_autoloaded", "color",
        N_("color for status \"autoloaded\" (\"a\")"),
        NULL, 0, 0, "cyan", NULL, 0,
        NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
    script_config_color_status_held = weechat_config_new_option (
        script_config_file, ptr_section,
        "status_held", "color",
        N_("color for status \"held\" (\"H\")"),
        NULL, 0, 0, "white", NULL, 0,
        NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
    script_config_color_status_installed = weechat_config_new_option (
        script_config_file, ptr_section,
        "status_installed", "color",
        N_("color for status \"installed\" (\"i\")"),
        NULL, 0, 0, "lightcyan", NULL, 0,
        NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
    script_config_color_status_obsolete = weechat_config_new_option (
        script_config_file, ptr_section,
        "status_obsolete", "color",
        N_("color for status \"obsolete\" (\"N\")"),
        NULL, 0, 0, "lightmagenta", NULL, 0,
        NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
    script_config_color_status_popular = weechat_config_new_option (
        script_config_file, ptr_section,
        "status_popular", "color",
        N_("color for status \"popular\" (\"*\")"),
        NULL, 0, 0, "yellow", NULL, 0,
        NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
    script_config_color_status_running = weechat_config_new_option (
        script_config_file, ptr_section,
        "status_running", "color",
        N_("color for status \"running\" (\"r\")"),
        NULL, 0, 0, "lightgreen", NULL, 0,
        NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
    script_config_color_status_unknown = weechat_config_new_option (
        script_config_file, ptr_section,
        "status_unknown", "color",
        N_("color for status \"unknown\" (\"?\")"),
        NULL, 0, 0, "lightred", NULL, 0,
        NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
    script_config_color_text = weechat_config_new_option (
        script_config_file, ptr_section,
        "text", "color",
        N_("text color in script buffer"),
        NULL, 0, 0, "default", NULL, 0,
        NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
    script_config_color_text_bg = weechat_config_new_option (
        script_config_file, ptr_section,
        "text_bg", "color",
        N_("background color in script buffer"),
        NULL, 0, 0, "default", NULL, 0,
        NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
    script_config_color_text_bg_selected = weechat_config_new_option (
        script_config_file, ptr_section,
        "text_bg_selected", "color",
        N_("background color for selected line in script buffer"),
        NULL, 0, 0, "red", NULL, 0,
        NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
    script_config_color_text_date = weechat_config_new_option (
        script_config_file, ptr_section,
        "text_date", "color",
        N_("text color of dates in script buffer"),
        NULL, 0, 0, "default", NULL, 0,
        NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
    script_config_color_text_date_selected = weechat_config_new_option (
        script_config_file, ptr_section,
        "text_date_selected", "color",
        N_("text color of dates for selected line in script buffer"),
        NULL, 0, 0, "white", NULL, 0,
        NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
    script_config_color_text_delimiters = weechat_config_new_option (
        script_config_file, ptr_section,
        "text_delimiters", "color",
        N_("text color of delimiters in script buffer"),
        NULL, 0, 0, "darkgray", NULL, 0,
        NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
    script_config_color_text_description = weechat_config_new_option (
        script_config_file, ptr_section,
        "text_description", "color",
        N_("text color of description in script buffer"),
        NULL, 0, 0, "default", NULL, 0,
        NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
    script_config_color_text_description_selected = weechat_config_new_option (
        script_config_file, ptr_section,
        "text_description_selected", "color",
        N_("text color of description for selected line in script buffer"),
        NULL, 0, 0, "white", NULL, 0,
        NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
    script_config_color_text_extension = weechat_config_new_option (
        script_config_file, ptr_section,
        "text_extension", "color",
        N_("text color of extension in script buffer"),
        NULL, 0, 0, "default", NULL, 0,
        NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
    script_config_color_text_extension_selected = weechat_config_new_option (
        script_config_file, ptr_section,
        "text_extension_selected", "color",
        N_("text color of extension for selected line in script buffer"),
        NULL, 0, 0, "white", NULL, 0,
        NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
    script_config_color_text_name = weechat_config_new_option (
        script_config_file, ptr_section,
        "text_name", "color",
        N_("text color of script name in script buffer"),
        NULL, 0, 0, "cyan", NULL, 0,
        NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
    script_config_color_text_name_selected = weechat_config_new_option (
        script_config_file, ptr_section,
        "text_name_selected", "color",
        N_("text color of script name for selected line in script buffer"),
        NULL, 0, 0, "lightcyan", NULL, 0,
        NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
    script_config_color_text_selected = weechat_config_new_option (
        script_config_file, ptr_section,
        "text_selected", "color",
        N_("text color for selected line in script buffer"),
        NULL, 0, 0, "white", NULL, 0,
        NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
    script_config_color_text_tags = weechat_config_new_option (
        script_config_file, ptr_section,
        "text_tags", "color",
        N_("text color of tags in script buffer"),
        NULL, 0, 0, "brown", NULL, 0,
        NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
    script_config_color_text_tags_selected = weechat_config_new_option (
        script_config_file, ptr_section,
        "text_tags_selected", "color",
        N_("text color of tags for selected line in script buffer"),
        NULL, 0, 0, "yellow", NULL, 0,
        NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
    script_config_color_text_version = weechat_config_new_option (
        script_config_file, ptr_section,
        "text_version", "color",
        N_("text color of version in script buffer"),
        NULL, 0, 0, "magenta", NULL, 0,
        NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
    script_config_color_text_version_loaded = weechat_config_new_option (
        script_config_file, ptr_section,
        "text_version_loaded", "color",
        N_("text color of version loaded in script buffer"),
        NULL, 0, 0, "default", NULL, 0,
        NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
    script_config_color_text_version_loaded_selected = weechat_config_new_option (
        script_config_file, ptr_section,
        "text_version_loaded_selected", "color",
        N_("text color of version loaded for selected line in script buffer"),
        NULL, 0, 0, "white", NULL, 0,
        NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);
    script_config_color_text_version_selected = weechat_config_new_option (
        script_config_file, ptr_section,
        "text_version_selected", "color",
        N_("text color of version for selected line in script buffer"),
        NULL, 0, 0, "lightmagenta", NULL, 0,
        NULL, NULL, &script_config_refresh_cb, NULL, NULL, NULL);

    /* scripts */
    ptr_section = weechat_config_new_section (script_config_file, "scripts",
                                              0, 0,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (script_config_file);
        return 0;
    }

    script_config_scripts_autoload = weechat_config_new_option (
        script_config_file, ptr_section,
        "autoload", "boolean",
        N_("autoload scripts installed (make a link in \"autoload\" directory "
           "to script in parent directory)"),
        NULL, 0, 0, "on", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL);
    script_config_scripts_cache_expire = weechat_config_new_option (
        script_config_file, ptr_section,
        "cache_expire", "integer",
        N_("local cache expiration time, in minutes (-1 = never expires, "
           "0 = always expire)"),
        NULL, -1, 525600, "60", NULL, 0, NULL, NULL,
        NULL, NULL, NULL, NULL);
    script_config_scripts_dir = weechat_config_new_option (
        script_config_file, ptr_section,
        "dir", "string",
        N_("local cache directory for scripts"),
        NULL, 0, 0, "%h/script", NULL, 0, NULL, NULL,
        NULL, NULL, NULL, NULL);
    script_config_scripts_hold = weechat_config_new_option (
        script_config_file, ptr_section,
        "hold", "string",
        N_("scripts to \"hold\": comma-separated list of scripts which will "
           "never been upgraded and can not be removed, for example: "
           "\"buffers.pl,iset.pl\""),
        NULL, 0, 0, "", NULL, 0, NULL, NULL,
        &script_config_change_hold_cb, NULL, NULL, NULL);
    script_config_scripts_url = weechat_config_new_option (
        script_config_file, ptr_section,
        "url", "string",
        N_("URL for file with list of scripts"),
        NULL, 0, 0, "http://www.weechat.org/files/plugins.xml.gz", NULL, 0, NULL, NULL,
        NULL, NULL, NULL, NULL);

    return 1;
}
Пример #16
0
int
logger_config_init ()
{
    struct t_config_section *ptr_section;
    
    logger_config_file = weechat_config_new (LOGGER_CONFIG_NAME,
                                             NULL, NULL);
    if (!logger_config_file)
        return 0;
    
    /* look */
    ptr_section = weechat_config_new_section (logger_config_file, "look",
                                              0, 0,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (logger_config_file);
        return 0;
    }
    
    logger_config_look_backlog = weechat_config_new_option (
        logger_config_file, ptr_section,
        "backlog", "integer",
        N_("maximum number of lines to display from log file when creating "
           "new buffer (0 = no backlog)"),
        NULL, 0, INT_MAX, "20", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
    
    /* file */
    ptr_section = weechat_config_new_section (logger_config_file, "file",
                                              0, 0,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (logger_config_file);
        return 0;
    }
    
    logger_config_file_auto_log = weechat_config_new_option (
        logger_config_file, ptr_section,
        "auto_log", "boolean",
        N_("automatically save content of buffers to files (unless a buffer "
           "disables log)"),
        NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
    logger_config_file_name_lower_case = weechat_config_new_option (
        logger_config_file, ptr_section,
        "name_lower_case", "boolean",
        N_("use only lower case for log filenames"),
        NULL, 0, 0, "on", NULL, 0, NULL, NULL,
        &logger_config_change_file_option_restart_log, NULL, NULL, NULL);
    logger_config_file_path = weechat_config_new_option (
        logger_config_file, ptr_section,
        "path", "string",
        N_("path for WeeChat log files (\"%h\" will be replaced by WeeChat "
           "home, \"~/.weechat\" by default)"),
        NULL, 0, 0, "%h/logs/", NULL, 0, NULL, NULL,
        &logger_config_change_file_option_restart_log, NULL, NULL, NULL);
    logger_config_file_mask = weechat_config_new_option (
        logger_config_file, ptr_section,
        "mask", "string",
        N_("default file name mask for log files (format is "
           "\"directory/to/file\" or \"file\", without first \"/\" because "
           "\"path\" option is used to build complete path to file); local "
           "buffer variables are permitted"),
        NULL, 0, 0, "$plugin.$name.weechatlog", NULL, 0, NULL, NULL,
        &logger_config_change_file_option_restart_log, NULL, NULL, NULL);
    logger_config_file_replacement_char = weechat_config_new_option (
        logger_config_file, ptr_section,
        "replacement_char", "string",
        N_("replacement char for special chars in filename built with mask "
           "(like directory delimiter)"),
        NULL, 0, 0, "_", NULL, 0, NULL, NULL,
        &logger_config_change_file_option_restart_log, NULL, NULL, NULL);
    logger_config_file_info_lines = weechat_config_new_option (
        logger_config_file, ptr_section,
        "info_lines", "boolean",
        N_("write information line in log file when log starts or ends for a "
           "buffer"),
        NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
    logger_config_file_time_format = weechat_config_new_option (
        logger_config_file, ptr_section,
        "time_format", "string",
        N_("timestamp used in log files (see man strftime for date/time "
           "specifiers)"),
        NULL, 0, 0, "%Y-%m-%d %H:%M:%S", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
    
    /* level */
    ptr_section = weechat_config_new_section (logger_config_file, "level",
                                              1, 1,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL,
                                              &logger_config_level_create_option, NULL,
                                              &logger_config_level_delete_option, NULL);
    if (!ptr_section)
    {
        weechat_config_free (logger_config_file);
        return 0;
    }
    
    logger_config_section_level = ptr_section;
    
    /* mask */
    ptr_section = weechat_config_new_section (logger_config_file, "mask",
                                              1, 1,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL,
                                              &logger_config_mask_create_option, NULL,
                                              &logger_config_mask_delete_option, NULL);
    if (!ptr_section)
    {
        weechat_config_free (logger_config_file);
        return 0;
    }
    
    logger_config_section_mask = ptr_section;
    
    return 1;
}
Пример #17
0
int
buflist_config_init ()
{
    struct t_config_section *ptr_section;

    buflist_config_file = weechat_config_new (BUFLIST_CONFIG_NAME,
                                              NULL, NULL, NULL);
    if (!buflist_config_file)
        return 0;

    /* look */
    ptr_section = weechat_config_new_section (buflist_config_file, "look",
                                              0, 0,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (buflist_config_file);
        buflist_config_file = NULL;
        return 0;
    }

    buflist_config_look_add_newline = weechat_config_new_option (
        buflist_config_file, ptr_section,
        "add_newline", "boolean",
        N_("add newline between the buffers displayed, so each buffer is "
           "displayed on a separate line (recommended); if disabled, newlines "
           "must be manually added in the formats with \"${\\n}\", "
           "and the mouse actions are not possible any more"),
        NULL, 0, 0, "on", NULL, 0,
        NULL, NULL, NULL,
        &buflist_config_change_buflist, NULL, NULL,
        NULL, NULL, NULL);
    buflist_config_look_auto_scroll = weechat_config_new_option (
        buflist_config_file, ptr_section,
        "auto_scroll", "integer",
        N_("automatically scroll the buflist bar to always see the current "
           "buffer (this works only with a bar on the left/right position "
           "with a \"vertical\" filling); this value is the percent number "
           "of lines displayed before the current buffer when scrolling "
           "(-1 = disable scroll); for example 50 means that after a scroll, "
           "the current buffer is at the middle of bar, 0 means on top of "
           "bar, 100 means at bottom of bar"),
        NULL, -1, 100, "50", NULL, 0,
        NULL, NULL, NULL,
        NULL, NULL, NULL,
        NULL, NULL, NULL);
    buflist_config_look_display_conditions = weechat_config_new_option (
        buflist_config_file, ptr_section,
        "display_conditions", "string",
        N_("conditions to display a buffer "
           "(note: content is evaluated, see /help buflist); for example "
           "to hide server buffers if they are merged with core buffer: "
           "\"${buffer.hidden}==0 && ((${type}!=server && "
           "${buffer.full_name}!=core.weechat) || ${buffer.active}==1)\""),
        NULL, 0, 0, "${buffer.hidden}==0", NULL, 0,
        NULL, NULL, NULL,
        &buflist_config_change_buflist, NULL, NULL,
        NULL, NULL, NULL);
    buflist_config_look_enabled = weechat_config_new_option (
        buflist_config_file, ptr_section,
        "enabled", "boolean",
        N_("enable buflist"),
        NULL, 0, 0, "on", NULL, 0,
        NULL, NULL, NULL,
        &buflist_config_change_enabled, NULL, NULL,
        NULL, NULL, NULL);
    buflist_config_look_mouse_jump_visited_buffer = weechat_config_new_option (
        buflist_config_file, ptr_section,
        "mouse_jump_visited_buffer", "boolean",
        N_("if enabled, clicks with left/right buttons on the line with "
           "current buffer jump to previous/next visited buffer"),
        NULL, 0, 0, "off", NULL, 0,
        NULL, NULL, NULL,
        NULL, NULL, NULL,
        NULL, NULL, NULL);
    buflist_config_look_mouse_move_buffer = weechat_config_new_option (
        buflist_config_file, ptr_section,
        "mouse_move_buffer", "boolean",
        N_("if enabled, mouse gestures (drag & drop) move buffers in list"),
        NULL, 0, 0, "on", NULL, 0,
        NULL, NULL, NULL,
        NULL, NULL, NULL,
        NULL, NULL, NULL);
    buflist_config_look_nick_prefix = weechat_config_new_option (
        buflist_config_file, ptr_section,
        "nick_prefix", "boolean",
        N_("get the nick prefix and its color from nicklist so that "
           "${nick_prefix} can be used in format; this can be slow on buffers "
           "with lot of nicks in nicklist, so this option is disabled "
           "by default"),
        NULL, 0, 0, "off", NULL, 0,
        NULL, NULL, NULL,
        &buflist_config_change_nick_prefix, NULL, NULL,
        NULL, NULL, NULL);
    buflist_config_look_nick_prefix_empty = weechat_config_new_option (
        buflist_config_file, ptr_section,
        "nick_prefix_empty", "boolean",
        N_("when the nick prefix is enabled, display a space instead if there "
           "is no nick prefix on the buffer"),
        NULL, 0, 0, "on", NULL, 0,
        NULL, NULL, NULL,
        &buflist_config_change_buflist, NULL, NULL,
        NULL, NULL, NULL);
    buflist_config_look_mouse_wheel = weechat_config_new_option (
        buflist_config_file, ptr_section,
        "mouse_wheel", "boolean",
        N_("if enabled, mouse wheel up/down actions jump to previous/next "
           "buffer in list"),
        NULL, 0, 0, "on", NULL, 0,
        NULL, NULL, NULL,
        NULL, NULL, NULL,
        NULL, NULL, NULL);
    buflist_config_look_signals_refresh = weechat_config_new_option (
        buflist_config_file, ptr_section,
        "signals_refresh", "string",
        N_("comma-separated list of extra signals that are hooked and trigger "
           "the refresh of buffers list; this can be useful if some custom "
           "variables are used in formats and need specific refresh"),
        NULL, 0, 0, "", NULL, 0,
        NULL, NULL, NULL,
        &buflist_config_change_signals_refresh, NULL, NULL,
        NULL, NULL, NULL);
    buflist_config_look_sort = weechat_config_new_option (
        buflist_config_file, ptr_section,
        "sort", "string",
        N_("comma-separated list of fields to sort buffers; each field is "
           "a hdata variable of buffer (\"var\"), a hdata variable of "
           "IRC server (\"irc_server.var\") or a hdata variable of "
           "IRC channel (\"irc_channel.var\"); "
           "char \"-\" can be used before field to reverse order, "
           "char \"~\" can be used to do a case insensitive comparison; "
           "example: \"-~short_name\" for case insensitive and reverse "
           "sort on buffer short name"),
        NULL, 0, 0, "number,-active", NULL, 0,
        NULL, NULL, NULL,
        &buflist_config_change_sort, NULL, NULL,
        NULL, NULL, NULL);

    /* format */
    ptr_section = weechat_config_new_section (buflist_config_file, "format",
                                              0, 0,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (buflist_config_file);
        buflist_config_file = NULL;
        return 0;
    }

    buflist_config_format_buffer = weechat_config_new_option (
        buflist_config_file, ptr_section,
        "buffer", "string",
        N_("format of each line with a buffer "
           "(note: content is evaluated, see /help buflist); "
           "example: standard format for bar item \"buflist\" and only the "
           "buffer number between square brackets for other bar items "
           "(\"buflist2\" and \"buflist3\"): "
           "\"${if:${bar_item.name}==buflist?${format_number}${indent}"
           "${format_nick_prefix}${color_hotlist}${format_name}:"
           "[${number}]}\""),
        NULL, 0, 0,
        "${format_number}${indent}${format_nick_prefix}${color_hotlist}"
        "${format_name}",
        NULL, 0,
        NULL, NULL, NULL,
        &buflist_config_change_format, NULL, NULL,
        NULL, NULL, NULL);
    buflist_config_format_buffer_current = weechat_config_new_option (
        buflist_config_file, ptr_section,
        "buffer_current", "string",
        N_("format for the line with current buffer "
           "(note: content is evaluated, see /help buflist)"),
        NULL, 0, 0, "${color:,blue}${format_buffer}", NULL, 0,
        NULL, NULL, NULL,
        &buflist_config_change_format, NULL, NULL,
        NULL, NULL, NULL);
    buflist_config_format_hotlist = weechat_config_new_option (
        buflist_config_file, ptr_section,
        "hotlist", "string",
        N_("format for hotlist "
           "(note: content is evaluated, see /help buflist)"),
        NULL, 0, 0,
        " ${color:green}(${hotlist}${color:green})",
        NULL, 0,
        NULL, NULL, NULL,
        &buflist_config_change_format, NULL, NULL,
        NULL, NULL, NULL);
    buflist_config_format_hotlist_level[0] = weechat_config_new_option (
        buflist_config_file, ptr_section,
        "hotlist_low", "string",
        N_("format for a buffer with hotlist level \"low\" "
           "(note: content is evaluated, see /help buflist)"),
        NULL, 0, 0, "${color:white}", NULL, 0,
        NULL, NULL, NULL,
        &buflist_config_change_buflist, NULL, NULL,
        NULL, NULL, NULL);
    buflist_config_format_hotlist_level[1] = weechat_config_new_option (
        buflist_config_file, ptr_section,
        "hotlist_message", "string",
        N_("format for a buffer with hotlist level \"message\" "
           "(note: content is evaluated, see /help buflist)"),
        NULL, 0, 0, "${color:brown}", NULL, 0,
        NULL, NULL, NULL,
        &buflist_config_change_buflist, NULL, NULL,
        NULL, NULL, NULL);
    buflist_config_format_hotlist_level[2] = weechat_config_new_option (
        buflist_config_file, ptr_section,
        "hotlist_private", "string",
        N_("format for a buffer with hotlist level \"private\" "
           "(note: content is evaluated, see /help buflist)"),
        NULL, 0, 0, "${color:green}", NULL, 0,
        NULL, NULL, NULL,
        &buflist_config_change_buflist, NULL, NULL,
        NULL, NULL, NULL);
    buflist_config_format_hotlist_level[3] = weechat_config_new_option (
        buflist_config_file, ptr_section,
        "hotlist_highlight", "string",
        N_("format for a buffer with hotlist level \"highlight\" "
           "(note: content is evaluated, see /help buflist)"),
        NULL, 0, 0, "${color:magenta}", NULL, 0,
        NULL, NULL, NULL,
        &buflist_config_change_buflist, NULL, NULL,
        NULL, NULL, NULL);
    buflist_config_format_hotlist_level_none = weechat_config_new_option (
        buflist_config_file, ptr_section,
        "hotlist_none", "string",
        N_("format for a buffer not in hotlist "
           "(note: content is evaluated, see /help buflist)"),
        NULL, 0, 0, "${color:default}", NULL, 0,
        NULL, NULL, NULL,
        &buflist_config_change_buflist, NULL, NULL,
        NULL, NULL, NULL);
    buflist_config_format_hotlist_separator = weechat_config_new_option (
        buflist_config_file, ptr_section,
        "hotlist_separator", "string",
        N_("separator for counts in hotlist "
           "(note: content is evaluated, see /help buflist)"),
        NULL, 0, 0, "${color:default},", NULL, 0,
        NULL, NULL, NULL,
        &buflist_config_change_buflist, NULL, NULL,
        NULL, NULL, NULL);
    buflist_config_format_indent = weechat_config_new_option (
        buflist_config_file, ptr_section,
        "indent", "string",
        N_("string displayed to indent channel and private buffers "
           "(note: content is evaluated, see /help buflist)"),
        NULL, 0, 0, "  ", NULL, 0,
        NULL, NULL, NULL,
        &buflist_config_change_buflist, NULL, NULL,
        NULL, NULL, NULL);
    buflist_config_format_lag = weechat_config_new_option (
        buflist_config_file, ptr_section,
        "lag", "string",
        N_("format for lag on an IRC server buffer "
           "(note: content is evaluated, see /help buflist)"),
        NULL, 0, 0,
        " ${color:green}[${color:brown}${lag}${color:green}]",
        NULL, 0,
        NULL, NULL, NULL,
        &buflist_config_change_buflist, NULL, NULL,
        NULL, NULL, NULL);
    buflist_config_format_name = weechat_config_new_option (
        buflist_config_file, ptr_section,
        "name", "string",
        N_("format for buffer name "
           "(note: content is evaluated, see /help buflist)"),
        NULL, 0, 0, "${name}", NULL, 0,
        NULL, NULL, NULL,
        &buflist_config_change_buflist, NULL, NULL,
        NULL, NULL, NULL);
    buflist_config_format_nick_prefix = weechat_config_new_option (
        buflist_config_file, ptr_section,
        "nick_prefix", "string",
        N_("format for nick prefix on a channel "
           "(note: content is evaluated, see /help buflist)"),
        NULL, 0, 0, "${color_nick_prefix}${nick_prefix}", NULL, 0,
        NULL, NULL, NULL,
        &buflist_config_change_buflist, NULL, NULL,
        NULL, NULL, NULL);
    buflist_config_format_number = weechat_config_new_option (
        buflist_config_file, ptr_section,
        "number", "string",
        N_("format for buffer number, ${number} is the indented number "
           "(note: content is evaluated, see /help buflist)"),
        NULL, 0, 0,
        "${color:green}${number}${if:${number_displayed}?.: }",
        NULL, 0,
        NULL, NULL, NULL,
        &buflist_config_change_buflist, NULL, NULL,
        NULL, NULL, NULL);

    return 1;
}
Пример #18
0
int
logger_config_init ()
{
    struct t_config_section *ptr_section;

    logger_config_file = weechat_config_new (LOGGER_CONFIG_NAME,
                                             NULL, NULL, NULL);
    if (!logger_config_file)
        return 0;

    /* look */
    ptr_section = weechat_config_new_section (logger_config_file, "look",
                                              0, 0,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (logger_config_file);
        return 0;
    }

    logger_config_look_backlog = weechat_config_new_option (
        logger_config_file, ptr_section,
        "backlog", "integer",
        N_("maximum number of lines to display from log file when creating "
           "new buffer (0 = no backlog)"),
        NULL, 0, INT_MAX, "20", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

    /* color */
    ptr_section = weechat_config_new_section (logger_config_file, "color",
                                              0, 0,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (logger_config_file);
        return 0;
    }

    logger_config_color_backlog_end = weechat_config_new_option (
        logger_config_file, ptr_section,
        "backlog_end", "color",
        N_("color for line ending the backlog"),
        NULL, -1, 0, "default", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
    logger_config_color_backlog_line = weechat_config_new_option (
        logger_config_file, ptr_section,
        "backlog_line", "color",
        N_("color for backlog lines"),
        NULL, -1, 0, "default", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

    /* file */
    ptr_section = weechat_config_new_section (logger_config_file, "file",
                                              0, 0,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (logger_config_file);
        return 0;
    }

    logger_config_file_auto_log = weechat_config_new_option (
        logger_config_file, ptr_section,
        "auto_log", "boolean",
        N_("automatically save content of buffers to files (unless a buffer "
           "disables log)"),
        NULL, 0, 0, "on", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
    logger_config_file_flush_delay = weechat_config_new_option (
        logger_config_file, ptr_section,
        "flush_delay", "integer",
        N_("number of seconds between flush of log files (0 = write in log "
           "files immediately for each line printed)"),
        NULL, 0, 3600, "120", NULL, 0,
        NULL, NULL, NULL,
        &logger_config_flush_delay_change, NULL, NULL,
        NULL, NULL, NULL);
    logger_config_file_info_lines = weechat_config_new_option (
        logger_config_file, ptr_section,
        "info_lines", "boolean",
        N_("write information line in log file when log starts or ends for a "
           "buffer"),
        NULL, 0, 0, "off", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
    logger_config_file_mask = weechat_config_new_option (
        logger_config_file, ptr_section,
        "mask", "string",
        N_("default file name mask for log files (format is "
           "\"directory/to/file\" or \"file\", without first \"/\" because "
           "\"path\" option is used to build complete path to file); local "
           "buffer variables are permitted (you should use only variables "
           "that are defined on all buffers, so for example you should NOT "
           "use $server nor $channel); date specifiers are permitted "
           "(see man strftime)"),
        NULL, 0, 0, "$plugin.$name.weechatlog", NULL, 0,
        NULL, NULL, NULL,
        &logger_config_change_file_option_restart_log, NULL, NULL,
        NULL, NULL, NULL);
    logger_config_file_name_lower_case = weechat_config_new_option (
        logger_config_file, ptr_section,
        "name_lower_case", "boolean",
        N_("use only lower case for log filenames"),
        NULL, 0, 0, "on", NULL, 0,
        NULL, NULL, NULL,
        &logger_config_change_file_option_restart_log, NULL, NULL,
        NULL, NULL, NULL);
    logger_config_file_nick_prefix = weechat_config_new_option (
        logger_config_file, ptr_section,
        "nick_prefix", "string",
        N_("text to write before nick in prefix of message, example: \"<\""),
        NULL, 0, 0, "", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
    logger_config_file_nick_suffix = weechat_config_new_option (
        logger_config_file, ptr_section,
        "nick_suffix", "string",
        N_("text to write after nick in prefix of message, example: \">\""),
        NULL, 0, 0, "", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
    logger_config_file_path = weechat_config_new_option (
        logger_config_file, ptr_section,
        "path", "string",
        N_("path for WeeChat log files; \"%h\" at beginning of string is "
           "replaced by WeeChat home (\"~/.weechat\" by default); date "
           "specifiers are permitted (see man strftime) "
           "(note: content is evaluated, see /help eval)"),
        NULL, 0, 0, "%h/logs/", NULL, 0,
        NULL, NULL, NULL,
        &logger_config_change_file_option_restart_log, NULL, NULL,
        NULL, NULL, NULL);
    logger_config_file_replacement_char = weechat_config_new_option (
        logger_config_file, ptr_section,
        "replacement_char", "string",
        N_("replacement char for special chars in filename built with mask "
           "(like directory delimiter)"),
        NULL, 0, 0, "_", NULL, 0,
        NULL, NULL, NULL,
        &logger_config_change_file_option_restart_log, NULL, NULL,
        NULL, NULL, NULL);
    logger_config_file_time_format = weechat_config_new_option (
        logger_config_file, ptr_section,
        "time_format", "string",
        N_("timestamp used in log files (see man strftime for date/time "
           "specifiers)"),
        NULL, 0, 0, "%Y-%m-%d %H:%M:%S", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

    /* level */
    ptr_section = weechat_config_new_section (
        logger_config_file, "level",
        1, 1,
        NULL, NULL, NULL,
        NULL, NULL, NULL,
        NULL, NULL, NULL,
        &logger_config_level_create_option, NULL, NULL,
        &logger_config_level_delete_option, NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (logger_config_file);
        return 0;
    }

    logger_config_section_level = ptr_section;

    /* mask */
    ptr_section = weechat_config_new_section (
        logger_config_file, "mask",
        1, 1,
        NULL, NULL, NULL,
        NULL, NULL, NULL,
        NULL, NULL, NULL,
        &logger_config_mask_create_option, NULL, NULL,
        &logger_config_mask_delete_option, NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (logger_config_file);
        return 0;
    }

    logger_config_section_mask = ptr_section;

    return 1;
}
Пример #19
0
int
relay_config_init ()
{
    struct t_config_section *ptr_section;

    relay_config_file = weechat_config_new (RELAY_CONFIG_NAME,
                                            &relay_config_reload, NULL);
    if (!relay_config_file)
        return 0;

    /* section look */
    ptr_section = weechat_config_new_section (relay_config_file, "look",
                                              0, 0,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (relay_config_file);
        return 0;
    }

    relay_config_look_auto_open_buffer = weechat_config_new_option (
        relay_config_file, ptr_section,
        "auto_open_buffer", "boolean",
        N_("auto open relay buffer when a new client is connecting"),
        NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
    relay_config_look_raw_messages = weechat_config_new_option (
        relay_config_file, ptr_section,
        "raw_messages", "integer",
        N_("number of raw messages to save in memory when raw data buffer is "
           "closed (messages will be displayed when opening raw data buffer)"),
        NULL, 0, 65535, "256", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);

    /* section color */
    ptr_section = weechat_config_new_section (relay_config_file, "color",
                                              0, 0,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (relay_config_file);
        return 0;
    }

    relay_config_color_client = weechat_config_new_option (
        relay_config_file, ptr_section,
        "client", "color",
        N_("text color for client description"),
        NULL, 0, 0, "cyan", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL);
    relay_config_color_status[RELAY_STATUS_CONNECTING] = weechat_config_new_option (
        relay_config_file, ptr_section,
        "status_connecting", "color",
        N_("text color for \"connecting\" status"),
        NULL, 0, 0, "yellow", NULL, 0,
        NULL, NULL, &relay_config_refresh_cb, NULL, NULL, NULL);
    relay_config_color_status[RELAY_STATUS_WAITING_AUTH] = weechat_config_new_option (
        relay_config_file, ptr_section,
        "status_waiting_auth", "color",
        N_("text color for \"waiting authentication\" status"),
        NULL, 0, 0, "brown", NULL, 0,
        NULL, NULL, &relay_config_refresh_cb, NULL, NULL, NULL);
    relay_config_color_status[RELAY_STATUS_CONNECTED] = weechat_config_new_option (
        relay_config_file, ptr_section,
        "status_active", "color",
        N_("text color for \"connected\" status"),
        NULL, 0, 0, "lightblue", NULL, 0,
        NULL, NULL, &relay_config_refresh_cb, NULL, NULL, NULL);
    relay_config_color_status[RELAY_STATUS_AUTH_FAILED] = weechat_config_new_option (
        relay_config_file, ptr_section,
        "status_auth_failed", "color",
        N_("text color for \"authentication failed\" status"),
        NULL, 0, 0, "lightred", NULL, 0,
        NULL, NULL, &relay_config_refresh_cb, NULL, NULL, NULL);
    relay_config_color_status[RELAY_STATUS_DISCONNECTED] = weechat_config_new_option (
        relay_config_file, ptr_section,
        "status_disconnected", "color",
        N_("text color for \"disconnected\" status"),
        NULL, 0, 0, "lightred", NULL, 0,
        NULL, NULL, &relay_config_refresh_cb, NULL, NULL, NULL);
    relay_config_color_text = weechat_config_new_option (
        relay_config_file, ptr_section,
        "text", "color",
        N_("text color in relay buffer"),
        NULL, 0, 0, "default", NULL, 0,
        NULL, NULL, &relay_config_refresh_cb, NULL, NULL, NULL);
    relay_config_color_text_bg = weechat_config_new_option (
        relay_config_file, ptr_section,
        "text_bg", "color",
        N_("background color in relay buffer"),
        NULL, 0, 0, "default", NULL, 0,
        NULL, NULL, &relay_config_refresh_cb, NULL, NULL, NULL);
    relay_config_color_text_selected = weechat_config_new_option (
        relay_config_file, ptr_section,
        "text_selected", "color",
        N_("text color of selected line in relay buffer"),
        NULL, 0, 0, "white", NULL, 0,
        NULL, NULL, &relay_config_refresh_cb, NULL, NULL, NULL);

    /* section network */
    ptr_section = weechat_config_new_section (relay_config_file, "network",
                                              0, 0,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (relay_config_file);
        return 0;
    }

    relay_config_network_allowed_ips = weechat_config_new_option (
        relay_config_file, ptr_section,
        "allowed_ips", "string",
        N_("regular expression with IPs allowed to use relay (case insensitive, "
           "use \"(?-i)\" at beginning to make it case sensitive); if IPv6 is "
           "enabled and that connection is made using IPv4, it will be "
           "IPv4-mapped IPv6 address (like: \"::ffff:127.0.0.1\"), example: "
           "\"^((::ffff:)?123.45.67.89|192.160.*)$\""),
        NULL, 0, 0, "", NULL, 0, NULL, NULL,
        &relay_config_change_network_allowed_ips, NULL, NULL, NULL);
    relay_config_network_bind_address = weechat_config_new_option (
        relay_config_file, ptr_section,
        "bind_address", "string",
        N_("address for bind (if empty, connection is possible on all "
           "interfaces, use \"127.0.0.1\" to allow connections from "
            "local machine only)"),
        NULL, 0, 0, "", NULL, 0, NULL, NULL,
        &relay_config_change_network_bind_address_cb, NULL, NULL, NULL);
    relay_config_network_compression_level = weechat_config_new_option (
        relay_config_file, ptr_section,
        "compression_level", "integer",
        N_("compression level for packets sent to client with WeeChat protocol "
           "(0 = disable compression, 1 = low compression ... 9 = best "
           "compression)"),
        NULL, 0, 9, "6", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL);
    relay_config_network_ipv6 = weechat_config_new_option (
        relay_config_file, ptr_section,
        "ipv6", "boolean",
        N_("listen on IPv6 socket by default (in addition to IPv4 which is "
            "default); protocols IPv4 and IPv6 can be forced (individually or "
           "together) in the protocol name (see /help relay)"),
        NULL, 0, 0, "on", NULL, 0, NULL, NULL,
        &relay_config_change_network_ipv6_cb, NULL, NULL, NULL);
    relay_config_network_max_clients = weechat_config_new_option (
        relay_config_file, ptr_section,
        "max_clients", "integer",
        N_("maximum number of clients connecting to a port"),
        NULL, 1, 1024, "5", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL);
    relay_config_network_password = weechat_config_new_option (
        relay_config_file, ptr_section,
        "password", "string",
        N_("password required by clients to access this relay (empty value "
            "means no password required) (note: content is evaluated, see "
           "/help eval)"),
        NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
    relay_config_network_ssl_cert_key = weechat_config_new_option (
        relay_config_file, ptr_section,
        "ssl_cert_key", "string",
        N_("file with SSL certificate and private key (for serving clients "
           "with SSL)"),
        NULL, 0, 0, "%h/ssl/relay.pem", NULL, 0, NULL, NULL,
        &relay_config_change_network_ssl_cert_key, NULL, NULL, NULL);
    relay_config_network_websocket_allowed_origins = weechat_config_new_option (
        relay_config_file, ptr_section,
        "websocket_allowed_origins", "string",
        N_("regular expression with origins allowed in websockets (case "
           "insensitive, use \"(?-i)\" at beginning to make it case sensitive), "
           "example: \"^http://(www\\.)?example\\.(com|org)\""),
        NULL, 0, 0, "", NULL, 0, NULL, NULL,
        &relay_config_change_network_websocket_allowed_origins, NULL, NULL, NULL);

    /* section irc */
    ptr_section = weechat_config_new_section (relay_config_file, "irc",
                                              0, 0,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (relay_config_file);
        return 0;
    }

    relay_config_irc_backlog_max_minutes = weechat_config_new_option (
        relay_config_file, ptr_section,
        "backlog_max_minutes", "integer",
        N_("maximum number of minutes in backlog per IRC channel "
           "(0 = unlimited, examples: 1440 = one day, 10080 = one week, "
           "43200 = one month, 525600 = one year)"),
        NULL, 0, INT_MAX, "1440", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL);
    relay_config_irc_backlog_max_number = weechat_config_new_option (
        relay_config_file, ptr_section,
        "backlog_max_number", "integer",
        N_("maximum number of lines in backlog per IRC channel "
           "(0 = unlimited)"),
        NULL, 0, INT_MAX, "256", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL);
    relay_config_irc_backlog_since_last_disconnect = weechat_config_new_option (
        relay_config_file, ptr_section,
        "backlog_since_last_disconnect", "boolean",
        N_("display backlog starting from last client disconnect"),
        NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
    relay_config_irc_backlog_tags = weechat_config_new_option (
        relay_config_file, ptr_section,
        "backlog_tags", "string",
        N_("tags of messages which are displayed in backlog per IRC channel "
           "(supported tags: \"irc_join\", \"irc_part\", \"irc_quit\", "
           "\"irc_nick\", \"irc_privmsg\"), \"*\" = all supported tags"),
        NULL, 0, 0, "irc_privmsg", NULL, 0, NULL, NULL,
        &relay_config_change_irc_backlog_tags, NULL, NULL, NULL);
    relay_config_irc_backlog_time_format = weechat_config_new_option (
        relay_config_file, ptr_section,
        "backlog_time_format", "string",
        N_("format for time in backlog messages (see man strftime for format) "
           "(not used if server capability \"server-time\" was enabled by "
           "client, because time is sent as irc tag); empty string = disable "
           "time in backlog messages"),
        NULL, 0, 0, "[%H:%M] ", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);

    /* section port */
    ptr_section = weechat_config_new_section (relay_config_file, "port",
                                              1, 1,
                                              NULL, NULL,
                                              NULL, NULL,
                                              NULL, NULL,
                                              &relay_config_create_option_port, NULL,
                                              NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (relay_config_file);
        return 0;
    }

    relay_config_section_port = ptr_section;

    return 1;
}
Пример #20
0
int
charset_config_init ()
{
    struct t_config_section *ptr_section;

    charset_config_file = weechat_config_new (CHARSET_CONFIG_NAME,
                                              &charset_config_reload, NULL, NULL);
    if (!charset_config_file)
        return 0;

    ptr_section = weechat_config_new_section (charset_config_file, "default",
                                              0, 0,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (charset_config_file);
        return 0;
    }

    charset_default_decode = weechat_config_new_option (
        charset_config_file, ptr_section,
        "decode", "string",
        N_("global decoding charset: charset used to decode incoming messages "
           "when they are not UTF-8 valid"),
        NULL, 0, 0,
        (charset_terminal && charset_internal
         && (weechat_strcasecmp (charset_terminal,
                                 charset_internal) != 0)) ?
        charset_terminal : "iso-8859-1", NULL, 0,
        &charset_check_charset_decode_cb, NULL, NULL,
        NULL, NULL, NULL,
        NULL, NULL, NULL);
    charset_default_encode = weechat_config_new_option (
        charset_config_file, ptr_section,
        "encode", "string",
        N_("global encoding charset: charset used to encode outgoing messages "
           "(if empty, default is UTF-8 because it is the WeeChat internal "
           "charset)"),
        NULL, 0, 0, "", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

    ptr_section = weechat_config_new_section (
        charset_config_file, "decode",
        1, 1,
        NULL, NULL, NULL,
        NULL, NULL, NULL,
        NULL, NULL, NULL,
        &charset_config_create_option, NULL, NULL,
        NULL, NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (charset_config_file);
        return 0;
    }

    charset_config_section_decode = ptr_section;

    ptr_section = weechat_config_new_section (
        charset_config_file, "encode",
        1, 1,
        NULL, NULL, NULL,
        NULL, NULL, NULL,
        NULL, NULL, NULL,
        &charset_config_create_option, NULL, NULL,
        NULL, NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (charset_config_file);
        return 0;
    }

    charset_config_section_encode = ptr_section;

    return 1;
}
Пример #21
0
struct t_config_option *
trigger_config_create_trigger_option (const char *trigger_name, int index_option,
                                      const char *value)
{
    struct t_config_option *ptr_option;
    int length;
    char *option_name;

    ptr_option = NULL;

    length = strlen (trigger_name) + 1 +
        strlen (trigger_option_string[index_option]) + 1;
    option_name = malloc (length);
    if (!option_name)
        return NULL;

    snprintf (option_name, length, "%s.%s",
              trigger_name, trigger_option_string[index_option]);

    switch (index_option)
    {
        case TRIGGER_OPTION_ENABLED:
            ptr_option = weechat_config_new_option (
                trigger_config_file, trigger_config_section_trigger,
                option_name, "boolean",
                N_("if disabled, the hooks are removed from trigger, so it is "
                   "not called any more"),
                NULL, 0, 0, value, NULL, 0,
                NULL, NULL, NULL,
                &trigger_config_change_trigger_enabled, NULL, NULL,
                NULL, NULL, NULL);
            break;
        case TRIGGER_OPTION_HOOK:
            ptr_option = weechat_config_new_option (
                trigger_config_file, trigger_config_section_trigger,
                option_name, "integer",
                N_("type of hook used"),
                trigger_hook_option_values,
                0, 0, value, NULL, 0,
                NULL, NULL, NULL,
                &trigger_config_change_trigger_hook, NULL, NULL,
                NULL, NULL, NULL);
            break;
        case TRIGGER_OPTION_ARGUMENTS:
            ptr_option = weechat_config_new_option (
                trigger_config_file, trigger_config_section_trigger,
                option_name, "string",
                N_("arguments for the hook (depend on the hook type, see /help "
                   "trigger)"),
                NULL, 0, 0, value, NULL, 0,
                NULL, NULL, NULL,
                &trigger_config_change_trigger_arguments, NULL, NULL,
                NULL, NULL, NULL);
            break;
        case TRIGGER_OPTION_CONDITIONS:
            ptr_option = weechat_config_new_option (
                trigger_config_file, trigger_config_section_trigger,
                option_name, "string",
                N_("condition(s) for running the command (it is checked in "
                   "hook callback) (note: content is evaluated when trigger is "
                   "run, see /help eval)"),
                NULL, 0, 0, value, NULL, 0,
                NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
            break;
        case TRIGGER_OPTION_REGEX:
            ptr_option = weechat_config_new_option (
                trigger_config_file, trigger_config_section_trigger,
                option_name, "string",
                N_("replace text with a POSIX extended regular expression (it "
                   "is done only if conditions are OK, and before running the "
                   "command) (note: content is evaluated when trigger is run, "
                   "see /help eval); format is: \"/regex/replace/var\" (var "
                   "is the hashtable variable to replace, it is optional), "
                   "many regex can be separated by a space, for example: "
                   "\"/regex1/replace1/var1 /regex2/replace2/var2\"; escaped "
                   "chars are interpreted in the regex (for example \"\\n\"); "
                   "the separator \"/\" can be replaced by any char (one or "
                   "more identical chars); matching groups can be used in "
                   "replace: ${re:0} to ${re:99}, ${re:+} for last match and "
                   "${hide:c,${re:N}} to replace all chars of group N by "
                   "char 'c'"),
                NULL, 0, 0, value, NULL, 0,
                NULL, NULL, NULL,
                &trigger_config_change_trigger_regex, NULL, NULL,
                NULL, NULL, NULL);
            break;
        case TRIGGER_OPTION_COMMAND:
            ptr_option = weechat_config_new_option (
                trigger_config_file, trigger_config_section_trigger,
                option_name, "string",
                N_("command(s) to run if conditions are OK, after regex "
                   "replacements (many commands can be separated by semicolons)"),
                NULL, 0, 0, value, NULL, 0,
                NULL, NULL, NULL,
                &trigger_config_change_trigger_command, NULL, NULL,
                NULL, NULL, NULL);
            break;
        case TRIGGER_OPTION_RETURN_CODE:
            ptr_option = weechat_config_new_option (
                trigger_config_file, trigger_config_section_trigger,
                option_name, "integer",
                N_("return code for hook callback (see plugin API reference to "
                   "know where ok_eat/error can be used efficiently)"),
                "ok|ok_eat|error", 0, 0, value, NULL, 0,
                NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
            break;
        case TRIGGER_OPTION_POST_ACTION:
            ptr_option = weechat_config_new_option (
                trigger_config_file, trigger_config_section_trigger,
                option_name, "integer",
                N_("action to take on the trigger after execution"),
                "none|disable|delete", 0, 0, value, NULL, 0,
                NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
            break;
        case TRIGGER_NUM_OPTIONS:
            break;
    }

    free (option_name);

    return ptr_option;
}
Пример #22
0
int
weechat_aspell_config_init ()
{
    struct t_config_section *ptr_section;

    weechat_aspell_config_file = weechat_config_new (ASPELL_CONFIG_NAME,
                                                     NULL, NULL, NULL);
    if (!weechat_aspell_config_file)
        return 0;

    /* color */
    ptr_section = weechat_config_new_section (
        weechat_aspell_config_file, "color",
        0, 0,
        NULL, NULL, NULL,
        NULL, NULL, NULL,
        NULL, NULL, NULL,
        NULL, NULL, NULL,
        NULL, NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (weechat_aspell_config_file);
        return 0;
    }

    weechat_aspell_config_color_misspelled = weechat_config_new_option (
        weechat_aspell_config_file, ptr_section,
        "misspelled", "color",
        N_("text color for misspelled words (input bar)"),
        NULL, 0, 0, "lightred", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
    weechat_aspell_config_color_suggestions = weechat_config_new_option (
        weechat_aspell_config_file, ptr_section,
        "suggestions", "color",
        N_("text color for suggestions on a misspelled word (status bar)"),
        NULL, 0, 0, "default", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

    /* check */
    ptr_section = weechat_config_new_section (
        weechat_aspell_config_file, "check",
        0, 0,
        NULL, NULL, NULL,
        NULL, NULL, NULL,
        NULL, NULL, NULL,
        NULL, NULL, NULL,
        NULL, NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (weechat_aspell_config_file);
        return 0;
    }

    weechat_aspell_config_check_commands = weechat_config_new_option (
        weechat_aspell_config_file, ptr_section,
        "commands", "string",
        N_("comma separated list of commands for which spell checking is "
           "enabled (spell checking is disabled for all other commands)"),
        NULL, 0, 0,
        "ame,amsg,away,command,cycle,kick,kickban,me,msg,notice,part,query,"
        "quit,topic", NULL, 0,
        NULL, NULL, NULL,
        &weechat_aspell_config_change_commands, NULL, NULL,
        NULL, NULL, NULL);
    weechat_aspell_config_check_default_dict = weechat_config_new_option (
        weechat_aspell_config_file, ptr_section,
        "default_dict", "string",
        N_("default dictionary (or comma separated list of dictionaries) to "
           "use when buffer has no dictionary defined (leave blank to disable "
           "aspell on buffers for which you didn't explicitly enabled it)"),
        NULL, 0, 0, "", NULL, 0,
        NULL, NULL, NULL,
        &weechat_aspell_config_change_default_dict, NULL, NULL,
        NULL, NULL, NULL);
    weechat_aspell_config_check_during_search = weechat_config_new_option (
        weechat_aspell_config_file, ptr_section,
        "during_search", "boolean",
        N_("check words during text search in buffer"),
        NULL, 0, 0, "off", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
    weechat_aspell_config_check_enabled = weechat_config_new_option (
        weechat_aspell_config_file, ptr_section,
        "enabled", "boolean",
        N_("enable aspell check for command line"),
        NULL, 0, 0, "off", NULL, 0,
        NULL, NULL, NULL,
        &weechat_aspell_config_change_enabled, NULL, NULL,
        NULL, NULL, NULL);
    weechat_aspell_config_check_real_time = weechat_config_new_option (
        weechat_aspell_config_file, ptr_section,
        "real_time", "boolean",
        N_("real-time spell checking of words (slower, disabled by default: "
           "words are checked only if there's delimiter after)"),
        NULL, 0, 0, "off", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
    weechat_aspell_config_check_suggestions = weechat_config_new_option (
        weechat_aspell_config_file, ptr_section,
        "suggestions", "integer",
        N_("number of suggestions to display in bar item \"aspell_suggest\" "
           "for each dictionary set in buffer (-1 = disable suggestions, "
           "0 = display all possible suggestions in all languages)"),
        NULL, -1, INT_MAX, "-1", NULL, 0,
        NULL, NULL, NULL,
        &weechat_aspell_config_change_suggestions, NULL, NULL,
        NULL, NULL, NULL);
    weechat_aspell_config_check_word_min_length = weechat_config_new_option (
        weechat_aspell_config_file, ptr_section,
        "word_min_length", "integer",
        N_("minimum length for a word to be spell checked (use 0 to check all "
           "words)"),
        NULL, 0, INT_MAX, "2", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

    /* dict */
    ptr_section = weechat_config_new_section (
        weechat_aspell_config_file, "dict",
        1, 1,
        NULL, NULL, NULL,
        NULL, NULL, NULL,
        NULL, NULL, NULL,
        &weechat_aspell_config_dict_create_option, NULL, NULL,
        &weechat_aspell_config_dict_delete_option, NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (weechat_aspell_config_file);
        return 0;
    }

    weechat_aspell_config_section_dict = ptr_section;

    /* option */
    ptr_section = weechat_config_new_section (
        weechat_aspell_config_file, "option",
        1, 1,
        NULL, NULL, NULL,
        NULL, NULL, NULL,
        NULL, NULL, NULL,
        &weechat_aspell_config_option_create_option, NULL, NULL,
        &weechat_aspell_config_option_delete_option, NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (weechat_aspell_config_file);
        return 0;
    }

    return 1;
}
Пример #23
0
int
trigger_config_init ()
{
    struct t_config_section *ptr_section;

    trigger_config_file = weechat_config_new (
        TRIGGER_CONFIG_NAME, &trigger_config_reload_cb, NULL, NULL);
    if (!trigger_config_file)
        return 0;

    /* look */
    ptr_section = weechat_config_new_section (trigger_config_file, "look",
                                              0, 0,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (trigger_config_file);
        trigger_config_file = NULL;
        return 0;
    }

    trigger_config_look_enabled = weechat_config_new_option (
        trigger_config_file, ptr_section,
        "enabled", "boolean",
        N_("enable trigger support"),
        NULL, 0, 0, "on", NULL, 0,
        NULL, NULL, NULL,
        &trigger_config_change_enabled, NULL, NULL,
        NULL, NULL, NULL);
    trigger_config_look_monitor_strip_colors = weechat_config_new_option (
        trigger_config_file, ptr_section,
        "monitor_strip_colors", "boolean",
        N_("strip colors in hashtable values displayed on monitor buffer"),
        NULL, 0, 0, "off", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

    /* color */
    ptr_section = weechat_config_new_section (trigger_config_file, "color",
                                              0, 0,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL,
                                              NULL, NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (trigger_config_file);
        trigger_config_file = NULL;
        return 0;
    }

    trigger_config_color_flag_command = weechat_config_new_option (
        trigger_config_file, ptr_section,
        "flag_command", "color",
        N_("text color for command flag (in /trigger list)"),
        NULL, 0, 0, "lightgreen", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
    trigger_config_color_flag_conditions = weechat_config_new_option (
        trigger_config_file, ptr_section,
        "flag_conditions", "color",
        N_("text color for conditions flag (in /trigger list)"),
        NULL, 0, 0, "yellow", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
    trigger_config_color_flag_regex = weechat_config_new_option (
        trigger_config_file, ptr_section,
        "flag_regex", "color",
        N_("text color for regex flag (in /trigger list)"),
        NULL, 0, 0, "lightcyan", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
    trigger_config_color_flag_return_code = weechat_config_new_option (
        trigger_config_file, ptr_section,
        "flag_return_code", "color",
        N_("text color for return code flag (in /trigger list)"),
        NULL, 0, 0, "lightmagenta", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
    trigger_config_color_flag_post_action = weechat_config_new_option (
        trigger_config_file, ptr_section,
        "flag_post_action", "color",
        N_("text color for post action flag (in /trigger list)"),
        NULL, 0, 0, "lightblue", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
    trigger_config_color_regex = weechat_config_new_option (
        trigger_config_file, ptr_section,
        "regex", "color",
        N_("text color for regular expressions"),
        NULL, 0, 0, "white", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
    trigger_config_color_replace = weechat_config_new_option (
        trigger_config_file, ptr_section,
        "replace", "color",
        N_("text color for replacement text (for regular expressions)"),
        NULL, 0, 0, "cyan", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
    trigger_config_color_trigger = weechat_config_new_option (
        trigger_config_file, ptr_section,
        "trigger", "color",
        N_("text color for trigger name"),
        NULL, 0, 0, "green", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
    trigger_config_color_trigger_disabled = weechat_config_new_option (
        trigger_config_file, ptr_section,
        "trigger_disabled", "color",
        N_("text color for disabled trigger name"),
        NULL, 0, 0, "red", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);

    /* trigger */
    ptr_section = weechat_config_new_section (
        trigger_config_file,
        TRIGGER_CONFIG_SECTION_TRIGGER,
        0, 0,
        &trigger_config_trigger_read_cb, NULL, NULL,
        NULL, NULL, NULL,
        &trigger_config_trigger_write_default_cb, NULL, NULL,
        NULL, NULL, NULL,
        NULL, NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (trigger_config_file);
        trigger_config_file = NULL;
        return 0;
    }

    trigger_config_section_trigger = ptr_section;

    return 1;
}
Пример #24
0
int
weechat_aspell_config_init ()
{
    struct t_config_section *ptr_section;
    
    weechat_aspell_config_file = weechat_config_new (ASPELL_CONFIG_NAME,
                                                     NULL, NULL);
    if (!weechat_aspell_config_file)
        return 0;
    
    /* look */
    ptr_section = weechat_config_new_section (weechat_aspell_config_file, "look",
                                              0, 0,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (weechat_aspell_config_file);
        return 0;
    }
    
    weechat_aspell_config_look_color = weechat_config_new_option (
        weechat_aspell_config_file, ptr_section,
        "color", "color",
        N_("color used for misspelled words"),
        NULL, 0, 0, "lightred", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
    
    /* check */
    ptr_section = weechat_config_new_section (weechat_aspell_config_file, "check",
                                              0, 0,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (weechat_aspell_config_file);
        return 0;
    }
    
    weechat_aspell_config_check_commands = weechat_config_new_option (
        weechat_aspell_config_file, ptr_section,
        "commands", "string",
        N_("comma separated list of commands for which spell checking is "
           "enabled (spell checking is disabled for all other commands)"),
        NULL, 0, 0,
        "ame,amsg,away,command,cycle,kick,kickban,me,msg,notice,part,query,"
        "quit,topic", NULL, 0,
        NULL, NULL, &weechat_aspell_config_change_commands, NULL, NULL, NULL);
    weechat_aspell_config_check_default_dict = weechat_config_new_option (
        weechat_aspell_config_file, ptr_section,
        "default_dict", "string",
        N_("default dictionary (or comma separated list of dictionaries) to "
           "use when buffer has no dictionary defined (leave blank to disable "
           "aspell on buffers for which you didn't explicitly enabled it)"),
        NULL, 0, 0, "", NULL, 0,
        NULL, NULL, &weechat_aspell_config_change_default_dict, NULL, NULL, NULL);
    weechat_aspell_config_check_during_search = weechat_config_new_option (
        weechat_aspell_config_file, ptr_section,
        "during_search", "boolean",
        N_("check words during text search in buffer"),
        NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
    weechat_aspell_config_check_real_time = weechat_config_new_option (
        weechat_aspell_config_file, ptr_section,
        "real_time", "boolean",
        N_("real-time spell checking of words (slower, disabled by default: "
           "words are checked only if there's delimiter after)"),
        NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
    weechat_aspell_config_check_word_min_length = weechat_config_new_option (
        weechat_aspell_config_file, ptr_section,
        "word_min_length", "integer",
        N_("minimum length for a word to be spell checked (use 0 to check all "
           "words)"),
        NULL, 0, INT_MAX, "2", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
    
    /* dict */
    ptr_section = weechat_config_new_section (weechat_aspell_config_file, "dict",
                                              1, 1,
                                              NULL, NULL,
                                              NULL, NULL,
                                              NULL, NULL,
                                              &weechat_aspell_config_dict_create_option, NULL,
                                              &weechat_aspell_config_dict_delete_option, NULL);
    if (!ptr_section)
    {
        weechat_config_free (weechat_aspell_config_file);
        return 0;
    }
    
    weechat_aspell_config_section_dict = ptr_section;
    
    return 1;
}
Пример #25
0
int
charset_config_init ()
{
    struct t_config_section *ptr_section;

    charset_config_file = weechat_config_new (CHARSET_CONFIG_NAME,
                                              &charset_config_reload, NULL);
    if (!charset_config_file)
        return 0;

    ptr_section = weechat_config_new_section (charset_config_file, "default",
                                              0, 0,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (charset_config_file);
        return 0;
    }

    charset_default_decode = weechat_config_new_option (
        charset_config_file, ptr_section,
        "decode", "string",
        N_("global decoding charset"),
        NULL, 0, 0,
        (charset_terminal && charset_internal
         && (strcasecmp (charset_terminal,
                         charset_internal) != 0)) ?
        charset_terminal : "iso-8859-1", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL);
    charset_default_encode = weechat_config_new_option (
        charset_config_file, ptr_section,
        "encode", "string",
        N_("global encoding charset"),
        NULL, 0, 0, "", NULL, 0,
        NULL, NULL, NULL, NULL, NULL, NULL);

    ptr_section = weechat_config_new_section (charset_config_file, "decode",
                                              1, 1,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL,
                                              &charset_config_create_option, NULL,
                                              NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (charset_config_file);
        return 0;
    }

    charset_config_section_decode = ptr_section;

    ptr_section = weechat_config_new_section (charset_config_file, "encode",
                                              1, 1,
                                              NULL, NULL, NULL, NULL,
                                              NULL, NULL,
                                              &charset_config_create_option, NULL,
                                              NULL, NULL);
    if (!ptr_section)
    {
        weechat_config_free (charset_config_file);
        return 0;
    }

    charset_config_section_encode = ptr_section;

    return 1;
}