Пример #1
0
int
dogechat_plugin_init (struct t_dogechat_plugin *plugin, int argc, char *argv[])
{
    int i, upgrading;

    dogechat_plugin = plugin;

    exec_command_init ();

    if (!exec_config_init ())
        return DOGECHAT_RC_ERROR;

    exec_config_read ();

    /* hook some signals */
    dogechat_hook_signal ("debug_dump", &exec_debug_dump_cb, NULL);

    /* hook completions */
    exec_completion_init ();

    /* look at arguments */
    upgrading = 0;
    for (i = 0; i < argc; i++)
    {
        if (dogechat_strcasecmp (argv[i], "--upgrade") == 0)
        {
            upgrading = 1;
        }
    }

    if (upgrading)
        exec_buffer_set_callbacks ();

    return DOGECHAT_RC_OK;
}
Пример #2
0
int
dogechat_plugin_init (struct t_dogechat_plugin *plugin, int argc, char *argv[])
{
    int i, auto_connect, upgrading;

    dogechat_plugin = plugin;

    if (!irc_config_init ())
        return DOGECHAT_RC_ERROR;

    irc_config_read ();

    irc_command_init ();

    irc_info_init ();

    irc_redirect_init ();

    irc_notify_init ();

    /* hook some signals */
    irc_debug_init ();
    dogechat_hook_signal ("quit", &irc_signal_quit_cb, NULL);
    dogechat_hook_signal ("upgrade", &irc_signal_upgrade_cb, NULL);
    dogechat_hook_signal ("xfer_send_ready", &irc_server_xfer_send_ready_cb, NULL);
    dogechat_hook_signal ("xfer_resume_ready", &irc_server_xfer_resume_ready_cb, NULL);
    dogechat_hook_signal ("xfer_send_accept_resume", &irc_server_xfer_send_accept_resume_cb, NULL);
    dogechat_hook_signal ("irc_input_send", &irc_input_send_cb, NULL);

    /* hook hsignals for redirection */
    dogechat_hook_hsignal ("irc_redirect_pattern", &irc_redirect_pattern_hsignal_cb, NULL);
    dogechat_hook_hsignal ("irc_redirect_command", &irc_redirect_command_hsignal_cb, NULL);

    /* modifiers */
    dogechat_hook_modifier ("irc_color_decode", &irc_color_modifier_cb, NULL);
    dogechat_hook_modifier ("irc_color_encode", &irc_color_modifier_cb, NULL);
    dogechat_hook_modifier ("irc_color_decode_ansi", &irc_color_modifier_cb, NULL);

    /* hook completions */
    irc_completion_init ();

    irc_bar_item_init ();

    /* look at arguments */
    auto_connect = 1;
    upgrading = 0;
    for (i = 0; i < argc; i++)
    {
        if ((dogechat_strcasecmp (argv[i], "-a") == 0)
            || (dogechat_strcasecmp (argv[i], "--no-connect") == 0))
        {
            auto_connect = 0;
        }
        else if ((dogechat_strncasecmp (argv[i], IRC_PLUGIN_NAME, 3) == 0))
        {
            if (!irc_server_alloc_with_url (argv[i]))
            {
                dogechat_printf (
                    NULL,
                    _("%s%s: unable to add temporary server \"%s\" (check "
                      "if there is already a server with this name)"),
                    dogechat_prefix ("error"), IRC_PLUGIN_NAME, argv[i]);
            }
        }
        else if (dogechat_strcasecmp (argv[i], "--upgrade") == 0)
        {
            upgrading = 1;
        }
    }

    if (upgrading)
    {
        if (!irc_upgrade_load ())
        {
            dogechat_printf (
                NULL,
                _("%s%s: WARNING: some network connections may still be "
                  "opened and not visible, you should restart DogeChat now "
                  "(with /quit)."),
                dogechat_prefix ("error"), IRC_PLUGIN_NAME);
        }
    }
    else
    {
        irc_server_auto_connect (auto_connect);
    }

    irc_hook_timer = dogechat_hook_timer (1 * 1000, 0, 0,
                                         &irc_server_timer_cb, NULL);

    return DOGECHAT_RC_OK;
}