Пример #1
0
void
relay_raw_print (struct t_relay_client *client, int flags,
                 const char *format, ...)
{
    struct t_relay_raw_message *new_raw_message;

    weechat_va_format (format);
    if (!vbuffer)
        return;

    /* auto-open Relay raw buffer if debug for irc plugin is >= 1 */
    if (!relay_raw_buffer && (weechat_relay_plugin->debug >= 1))
        relay_raw_open (0);

    new_raw_message = relay_raw_message_add (client, flags, vbuffer);
    if (new_raw_message)
    {
        if (relay_raw_buffer)
            relay_raw_message_print (new_raw_message);
        if (weechat_config_integer (relay_config_look_raw_messages) == 0)
            relay_raw_message_free (new_raw_message);
    }

    free (vbuffer);
}
Пример #2
0
void
relay_raw_print (struct t_relay_client *client, int flags,
                 const char *data, int data_size)
{
    /* auto-open Relay raw buffer if debug for irc plugin is >= 1 */
    if (!relay_raw_buffer && (weechat_relay_plugin->debug >= 1))
        relay_raw_open (0);

    relay_raw_message_add (client, flags, data, data_size);
}
Пример #3
0
int
relay_command_relay (void *data, struct t_gui_buffer *buffer, int argc,
                     char **argv, char **argv_eol)
{
    struct t_relay_server *ptr_server;
    struct t_config_option *ptr_option;
    int port;

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

    if (argc > 1)
    {
        if (weechat_strcasecmp (argv[1], "list") == 0)
        {
            relay_command_client_list (0);
            return WEECHAT_RC_OK;
        }

        if (weechat_strcasecmp (argv[1], "listfull") == 0)
        {
            relay_command_client_list (1);
            return WEECHAT_RC_OK;
        }

        if (weechat_strcasecmp (argv[1], "listrelay") == 0)
        {
            relay_command_server_list ();
            return WEECHAT_RC_OK;
        }
        if (weechat_strcasecmp (argv[1], "add") == 0)
        {
            if (argc >= 4)
            {
                if (relay_config_create_option_port (NULL,
                                                     relay_config_file,
                                                     relay_config_section_port,
                                                     argv[2],
                                                     argv_eol[3]) != WEECHAT_CONFIG_OPTION_SET_ERROR)
                {
                    weechat_printf (NULL,
                                    _("%s: relay \"%s\" (port %s) added"),
                                    RELAY_PLUGIN_NAME,
                                    argv[2], argv_eol[3]);
                }
            }
            else
            {
                weechat_printf (NULL,
                                _("%s%s: missing arguments for \"%s\" "
                                  "command"),
                                weechat_prefix ("error"), RELAY_PLUGIN_NAME,
                                "relay add");
            }
            return WEECHAT_RC_OK;
        }
        if (weechat_strcasecmp (argv[1], "del") == 0)
        {
            if (argc >= 3)
            {
                ptr_server = relay_server_search (argv_eol[2]);
                if (ptr_server)
                {
                    port = ptr_server->port;
                    relay_server_free (ptr_server);
                    ptr_option = weechat_config_search_option (relay_config_file,
                                                               relay_config_section_port,
                                                               argv_eol[2]);
                    if (ptr_option)
                        weechat_config_option_free (ptr_option);
                    weechat_printf (NULL,
                                    _("%s: relay \"%s\" (port %d) removed"),
                                    RELAY_PLUGIN_NAME,
                                    argv[2], port);
                }
                else
                {
                    weechat_printf (NULL,
                                    _("%s%s: relay \"%s\" not found"),
                                    weechat_prefix ("error"),
                                    RELAY_PLUGIN_NAME,
                                    argv_eol[2]);
                }
            }
            else
            {
                weechat_printf (NULL,
                                _("%s%s: missing arguments for \"%s\" "
                                  "command"),
                                weechat_prefix ("error"), RELAY_PLUGIN_NAME,
                                "relay del");
            }
            return WEECHAT_RC_OK;
        }
        if (weechat_strcasecmp (argv[1], "raw") == 0)
        {
            relay_raw_open (1);
            return WEECHAT_RC_OK;
        }
        if (weechat_strcasecmp (argv[1], "sslcertkey") == 0)
        {
            relay_network_set_ssl_cert_key (1);
            return WEECHAT_RC_OK;
        }
    }

    if (!relay_buffer)
        relay_buffer_open ();

    if (relay_buffer)
    {
        weechat_buffer_set (relay_buffer, "display", "1");

        if (argc > 1)
        {
            if (strcmp (argv[1], "up") == 0)
            {
                if (relay_buffer_selected_line > 0)
                    relay_buffer_selected_line--;
            }
            else if (strcmp (argv[1], "down") == 0)
            {
                if (relay_buffer_selected_line < relay_client_count - 1)
                    relay_buffer_selected_line++;
            }
        }
    }

    relay_buffer_refresh (NULL);

    return WEECHAT_RC_OK;
}