xfer: fix code style
This commit is contained in:
parent
037bf70817
commit
2d48964463
@ -521,37 +521,44 @@ xfer_network_timer_cb (void *arg_xfer, int remaining_calls)
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
xfer_network_connect_chat_recv_cb (void *data,
|
||||
int status,
|
||||
int gnutls_rc,
|
||||
int sock,
|
||||
const char *error,
|
||||
/*
|
||||
* Callback called when connecting to remote host (DCC chat only).
|
||||
*/
|
||||
|
||||
int
|
||||
xfer_network_connect_chat_recv_cb (void *data, int status, int gnutls_rc,
|
||||
int sock, const char *error,
|
||||
const char *ip_address)
|
||||
{
|
||||
struct t_xfer *xfer;
|
||||
int flags;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) gnutls_rc;
|
||||
(void) ip_address;
|
||||
(void) error;
|
||||
struct t_xfer *xfer = (struct t_xfer*)data;
|
||||
|
||||
/* Unhook */
|
||||
xfer = (struct t_xfer*)data;
|
||||
|
||||
weechat_unhook (xfer->hook_connect);
|
||||
xfer->hook_connect = NULL;
|
||||
|
||||
/* handle success */
|
||||
if (WEECHAT_HOOK_CONNECT_OK == status)
|
||||
/* connection OK? */
|
||||
if (status == WEECHAT_HOOK_CONNECT_OK)
|
||||
{
|
||||
xfer->sock = sock;
|
||||
|
||||
int flags = fcntl (xfer->sock, F_GETFL);
|
||||
flags = fcntl (xfer->sock, F_GETFL);
|
||||
if (flags == -1)
|
||||
flags = 0;
|
||||
if (fcntl (xfer->sock, F_SETFL, flags | O_NONBLOCK) == -1)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: unable to connect set DCC chat nonblocking"),
|
||||
weechat_prefix ("error"), XFER_PLUGIN_NAME);
|
||||
close (sock);
|
||||
_("%s%s: unable to set option \"nonblock\" "
|
||||
"for socket: error %d %s"),
|
||||
weechat_prefix ("error"), XFER_PLUGIN_NAME,
|
||||
errno, strerror (errno));
|
||||
close (xfer->sock);
|
||||
xfer->sock = -1;
|
||||
xfer_close (xfer, XFER_STATUS_FAILED);
|
||||
xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE);
|
||||
return WEECHAT_RC_OK;
|
||||
@ -569,67 +576,72 @@ xfer_network_connect_chat_recv_cb (void *data,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/* Report the error and fail xfer */
|
||||
/* connection error */
|
||||
switch (status)
|
||||
{
|
||||
case WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND:
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: unable to connect to DCC chat: Address (%s) not found"),
|
||||
(xfer->proxy && xfer->proxy[0]) ?
|
||||
_("%s%s: proxy address \"%s\" not found") :
|
||||
_("%s%s: address \"%s\" not found"),
|
||||
weechat_prefix ("error"), XFER_PLUGIN_NAME,
|
||||
xfer->remote_address_str);
|
||||
break;
|
||||
case WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND:
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: unable to connect to DCC chat: IP address (%s) not found"),
|
||||
weechat_prefix ("error"), XFER_PLUGIN_NAME,
|
||||
xfer->remote_address_str);
|
||||
(xfer->proxy && xfer->proxy[0]) ?
|
||||
_("%s%s: proxy IP address not found") :
|
||||
_("%s%s: IP address not found"),
|
||||
weechat_prefix ("error"), XFER_PLUGIN_NAME);
|
||||
break;
|
||||
case WEECHAT_HOOK_CONNECT_CONNECTION_REFUSED:
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: unable to connect to DCC chat: Connection refused"),
|
||||
(xfer->proxy && xfer->proxy[0]) ?
|
||||
_("%s%s: proxy connection refused") :
|
||||
_("%s%s: connection refused"),
|
||||
weechat_prefix ("error"), XFER_PLUGIN_NAME);
|
||||
break;
|
||||
case WEECHAT_HOOK_CONNECT_PROXY_ERROR:
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: unable to connect to DCC chat: Proxy error"),
|
||||
_("%s%s: proxy fails to establish connection to "
|
||||
"server (check username/password if used and if "
|
||||
"server address/port is allowed by proxy)"),
|
||||
weechat_prefix ("error"), XFER_PLUGIN_NAME);
|
||||
break;
|
||||
case WEECHAT_HOOK_CONNECT_LOCAL_HOSTNAME_ERROR:
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: unable to connect to DCC chat: Local hostname error"),
|
||||
weechat_prefix ("error"), XFER_PLUGIN_NAME);
|
||||
break;
|
||||
case WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR:
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: unable to connect to DCC chat: GNUTLS initialization"),
|
||||
weechat_prefix ("error"), XFER_PLUGIN_NAME);
|
||||
break;
|
||||
case WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR:
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: unable to connect to DCC chat: GNUTLS handshake error"),
|
||||
_("%s%s: unable to set local hostname/IP"),
|
||||
weechat_prefix ("error"), XFER_PLUGIN_NAME);
|
||||
break;
|
||||
case WEECHAT_HOOK_CONNECT_MEMORY_ERROR:
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: unable to connect to DCC chat: Insufficient memory"),
|
||||
_("%s%s: not enough memory"),
|
||||
weechat_prefix ("error"), XFER_PLUGIN_NAME);
|
||||
break;
|
||||
case WEECHAT_HOOK_CONNECT_TIMEOUT:
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: unable to connect to DCC chat: Timed out"),
|
||||
_("%s%s: timeout"),
|
||||
weechat_prefix ("error"), XFER_PLUGIN_NAME);
|
||||
break;
|
||||
case WEECHAT_HOOK_CONNECT_SOCKET_ERROR:
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: unable to connect to DCC chat: Unable to create socket"),
|
||||
_("%s%s: unable to create socket"),
|
||||
weechat_prefix ("error"), XFER_PLUGIN_NAME);
|
||||
break;
|
||||
default:
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: unable to connect to DCC chat: Unexpected error"),
|
||||
weechat_prefix ("error"), XFER_PLUGIN_NAME);
|
||||
_("%s%s: unable to connect: unexpected error (%d)"),
|
||||
weechat_prefix ("error"), XFER_PLUGIN_NAME,
|
||||
status);
|
||||
break;
|
||||
}
|
||||
if (error && error[0])
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: error: %s"),
|
||||
weechat_prefix ("error"), XFER_PLUGIN_NAME, error);
|
||||
}
|
||||
|
||||
xfer_close (xfer, XFER_STATUS_FAILED);
|
||||
xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE);
|
||||
|
||||
@ -717,19 +729,16 @@ xfer_network_connect_init (struct t_xfer *xfer)
|
||||
if (!xfer_network_connect (xfer))
|
||||
{
|
||||
xfer_close (xfer, XFER_STATUS_FAILED);
|
||||
xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* for a file: launch child process */
|
||||
if (XFER_IS_FILE(xfer->type))
|
||||
{
|
||||
xfer_network_recv_file_fork (xfer);
|
||||
}
|
||||
|
||||
xfer->status = XFER_STATUS_CONNECTING;
|
||||
xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE);
|
||||
}
|
||||
xfer_buffer_refresh (WEECHAT_HOTLIST_MESSAGE);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user