M src/common/dcc.c => src/common/dcc.c +50 -50
@@ 373,13 373,13 @@ dcc_close (struct DCC *dcc, enum dcc_state dccstat, int destroy)
{
if (dcc->wiotag)
{
- fe_input_remove (dcc->wiotag);
+ net_input_remove (dcc->wiotag);
dcc->wiotag = 0;
}
if (dcc->iotag)
{
- fe_input_remove (dcc->iotag);
+ net_input_remove (dcc->iotag);
dcc->iotag = 0;
}
@@ 428,7 428,7 @@ dcc_close (struct DCC *dcc, enum dcc_state dccstat, int destroy)
g_free (dcc);
if (dcc_list == NULL && timeout_timer != 0)
{
- fe_timeout_remove (timeout_timer);
+ g_source_remove (timeout_timer);
timeout_timer = 0;
}
return;
@@ 581,13 581,13 @@ dcc_read_chat (GIOChannel *source, GIOCondition condition, struct DCC *dcc)
{
if (dcc->throttled)
{
- fe_input_remove (dcc->iotag);
+ net_input_remove (dcc->iotag);
dcc->iotag = 0;
return FALSE;
}
if (!dcc->iotag)
- dcc->iotag = fe_input_add (dcc->sok, FIA_READ|FIA_EX, dcc_read_chat, dcc);
+ dcc->iotag = net_input_add (dcc->sok, NIA_READ|NIA_EX, dcc_read_chat, dcc);
len = recv (dcc->sok, lbuf, sizeof (lbuf) - 2, 0);
if (len < 1)
@@ 720,13 720,13 @@ dcc_read (GIOChannel *source, GIOCondition condition, struct DCC *dcc)
if (need_ack)
dcc_send_ack (dcc);
- fe_input_remove (dcc->iotag);
+ net_input_remove (dcc->iotag);
dcc->iotag = 0;
return FALSE;
}
if (!dcc->iotag)
- dcc->iotag = fe_input_add (dcc->sok, FIA_READ|FIA_EX, dcc_read, dcc);
+ dcc->iotag = net_input_add (dcc->sok, NIA_READ|NIA_EX, dcc_read, dcc);
n = recv (dcc->sok, buf, sizeof (buf), 0);
if (n < 1)
@@ 840,7 840,7 @@ dcc_connect_finished (GIOChannel *source, GIOCondition condition, struct DCC *dc
if (dcc->iotag)
{
- fe_input_remove (dcc->iotag);
+ net_input_remove (dcc->iotag);
dcc->iotag = 0;
}
@@ 853,7 853,7 @@ dcc_connect_finished (GIOChannel *source, GIOCondition condition, struct DCC *dc
switch (dcc->type)
{
case TYPE_RECV:
- dcc->iotag = fe_input_add (dcc->sok, FIA_READ|FIA_EX, dcc_read, dcc);
+ dcc->iotag = net_input_add (dcc->sok, NIA_READ|NIA_EX, dcc_read, dcc);
EMIT_SIGNAL (XP_TE_DCCCONRECV, dcc->serv->front_session,
dcc->nick, host, dcc->file, NULL, 0);
break;
@@ 861,8 861,8 @@ dcc_connect_finished (GIOChannel *source, GIOCondition condition, struct DCC *dc
/* passive send */
dcc->fastsend = prefs.hex_dcc_fast_send;
if (dcc->fastsend)
- dcc->wiotag = fe_input_add (dcc->sok, FIA_WRITE, dcc_send_data, dcc);
- dcc->iotag = fe_input_add (dcc->sok, FIA_READ|FIA_EX, dcc_read_ack, dcc);
+ dcc->wiotag = net_input_add (dcc->sok, NIA_WRITE, dcc_send_data, dcc);
+ dcc->iotag = net_input_add (dcc->sok, NIA_READ|NIA_EX, dcc_read_ack, dcc);
dcc_send_data (NULL, 0, (gpointer)dcc);
EMIT_SIGNAL (XP_TE_DCCCONSEND, dcc->serv->front_session,
dcc->nick, host, dcc->file, NULL, 0);
@@ 870,7 870,7 @@ dcc_connect_finished (GIOChannel *source, GIOCondition condition, struct DCC *dc
case TYPE_CHATSEND: /* pchat */
dcc_open_query (dcc->serv, dcc->nick);
case TYPE_CHATRECV: /* normal chat */
- dcc->iotag = fe_input_add (dcc->sok, FIA_READ|FIA_EX, dcc_read_chat, dcc);
+ dcc->iotag = net_input_add (dcc->sok, NIA_READ|NIA_EX, dcc_read_chat, dcc);
dcc->dccchat = g_new0 (struct dcc_chat, 1);
EMIT_SIGNAL (XP_TE_DCCCONCHAT, dcc->serv->front_session,
dcc->nick, host, NULL, NULL, 0);
@@ 903,7 903,7 @@ read_proxy (struct DCC *dcc)
fe_dcc_update (dcc);
if (dcc->iotag)
{
- fe_input_remove (dcc->iotag);
+ net_input_remove (dcc->iotag);
dcc->iotag = 0;
}
return FALSE;
@@ 933,7 933,7 @@ write_proxy (struct DCC *dcc)
fe_dcc_update (dcc);
if (dcc->wiotag)
{
- fe_input_remove (dcc->wiotag);
+ net_input_remove (dcc->wiotag);
dcc->wiotag = 0;
}
return FALSE;
@@ 971,7 971,7 @@ dcc_wingate_proxy_traverse (GIOChannel *source, GIOCondition condition, struct D
"%s %d\r\n", net_ip(dcc->addr),
dcc->port);
proxy->bufferused = 0;
- dcc->wiotag = fe_input_add (dcc->sok, FIA_WRITE|FIA_EX,
+ dcc->wiotag = net_input_add (dcc->sok, NIA_WRITE|NIA_EX,
dcc_wingate_proxy_traverse, dcc);
++proxy->phase;
}
@@ 979,7 979,7 @@ dcc_wingate_proxy_traverse (GIOChannel *source, GIOCondition condition, struct D
{
if (!read_proxy (dcc))
return TRUE;
- fe_input_remove (dcc->wiotag);
+ net_input_remove (dcc->wiotag);
dcc->wiotag = 0;
dcc_connect_finished (source, 0, dcc);
}
@@ 1010,7 1010,7 @@ dcc_socks_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DCC
memcpy (proxy->buffer, &sc, sizeof (sc));
proxy->buffersize = 8 + strlen (sc.username) + 1;
proxy->bufferused = 0;
- dcc->wiotag = fe_input_add (dcc->sok, FIA_WRITE|FIA_EX,
+ dcc->wiotag = net_input_add (dcc->sok, NIA_WRITE|NIA_EX,
dcc_socks_proxy_traverse, dcc);
++proxy->phase;
}
@@ 1019,11 1019,11 @@ dcc_socks_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DCC
{
if (!write_proxy (dcc))
return TRUE;
- fe_input_remove (dcc->wiotag);
+ net_input_remove (dcc->wiotag);
dcc->wiotag = 0;
proxy->bufferused = 0;
proxy->buffersize = 8;
- dcc->iotag = fe_input_add (dcc->sok, FIA_READ|FIA_EX,
+ dcc->iotag = net_input_add (dcc->sok, NIA_READ|NIA_EX,
dcc_socks_proxy_traverse, dcc);
++proxy->phase;
}
@@ 1032,7 1032,7 @@ dcc_socks_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DCC
{
if (!read_proxy (dcc))
return TRUE;
- fe_input_remove (dcc->iotag);
+ net_input_remove (dcc->iotag);
dcc->iotag = 0;
if (proxy->buffer[1] == 90)
dcc_connect_finished (source, 0, dcc);
@@ 1070,7 1070,7 @@ dcc_socks5_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DC
memcpy (proxy->buffer, &sc1, 3);
proxy->buffersize = 3;
proxy->bufferused = 0;
- dcc->wiotag = fe_input_add (dcc->sok, FIA_WRITE|FIA_EX,
+ dcc->wiotag = net_input_add (dcc->sok, NIA_WRITE|NIA_EX,
dcc_socks5_proxy_traverse, dcc);
++proxy->phase;
}
@@ 1079,11 1079,11 @@ dcc_socks5_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DC
{
if (!write_proxy (dcc))
return TRUE;
- fe_input_remove (dcc->wiotag);
+ net_input_remove (dcc->wiotag);
dcc->wiotag = 0;
proxy->bufferused = 0;
proxy->buffersize = 2;
- dcc->iotag = fe_input_add (dcc->sok, FIA_READ|FIA_EX,
+ dcc->iotag = net_input_add (dcc->sok, NIA_READ|NIA_EX,
dcc_socks5_proxy_traverse, dcc);
++proxy->phase;
}
@@ 1092,7 1092,7 @@ dcc_socks5_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DC
{
if (!read_proxy (dcc))
return TRUE;
- fe_input_remove (dcc->iotag);
+ net_input_remove (dcc->iotag);
dcc->iotag = 0;
/* did the server say no auth required? */
@@ 1126,7 1126,7 @@ dcc_socks5_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DC
proxy->buffersize = 3 + len_u + len_p;
proxy->bufferused = 0;
- dcc->wiotag = fe_input_add (dcc->sok, FIA_WRITE|FIA_EX,
+ dcc->wiotag = net_input_add (dcc->sok, NIA_WRITE|NIA_EX,
dcc_socks5_proxy_traverse, dcc);
++proxy->phase;
}
@@ 1147,11 1147,11 @@ dcc_socks5_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DC
{
if (!write_proxy (dcc))
return TRUE;
- fe_input_remove (dcc->wiotag);
+ net_input_remove (dcc->wiotag);
dcc->wiotag = 0;
proxy->buffersize = 2;
proxy->bufferused = 0;
- dcc->iotag = fe_input_add (dcc->sok, FIA_READ|FIA_EX,
+ dcc->iotag = net_input_add (dcc->sok, NIA_READ|NIA_EX,
dcc_socks5_proxy_traverse, dcc);
++proxy->phase;
}
@@ 1162,7 1162,7 @@ dcc_socks5_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DC
return TRUE;
if (dcc->iotag)
{
- fe_input_remove (dcc->iotag);
+ net_input_remove (dcc->iotag);
dcc->iotag = 0;
}
if (proxy->buffer[1] != 0)
@@ 1190,7 1190,7 @@ dcc_socks5_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DC
proxy->buffer[9] = (dcc->port & 0xFF);
proxy->buffersize = 10;
proxy->bufferused = 0;
- dcc->wiotag = fe_input_add (dcc->sok, FIA_WRITE|FIA_EX,
+ dcc->wiotag = net_input_add (dcc->sok, NIA_WRITE|NIA_EX,
dcc_socks5_proxy_traverse, dcc);
++proxy->phase;
}
@@ 1199,11 1199,11 @@ dcc_socks5_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DC
{
if (!write_proxy (dcc))
return TRUE;
- fe_input_remove (dcc->wiotag);
+ net_input_remove (dcc->wiotag);
dcc->wiotag = 0;
proxy->buffersize = 4;
proxy->bufferused = 0;
- dcc->iotag = fe_input_add (dcc->sok, FIA_READ|FIA_EX,
+ dcc->iotag = net_input_add (dcc->sok, NIA_READ|NIA_EX,
dcc_socks5_proxy_traverse, dcc);
++proxy->phase;
}
@@ 1214,7 1214,7 @@ dcc_socks5_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DC
return TRUE;
if (proxy->buffer[0] != 5 || proxy->buffer[1] != 0)
{
- fe_input_remove (dcc->iotag);
+ net_input_remove (dcc->iotag);
dcc->iotag = 0;
if (proxy->buffer[1] == 2)
PrintText (dcc->serv->front_session, "SOCKS\tProxy refused to connect to host (not allowed).\n");
@@ 1245,7 1245,7 @@ dcc_socks5_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DC
/* everything done? */
if (proxy->bufferused == proxy->buffersize)
{
- fe_input_remove (dcc->iotag);
+ net_input_remove (dcc->iotag);
dcc->iotag = 0;
dcc_connect_finished (source, 0, dcc);
}
@@ 1278,7 1278,7 @@ dcc_http_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DCC
proxy->buffersize = n;
proxy->bufferused = 0;
memcpy (proxy->buffer, buf, proxy->buffersize);
- dcc->wiotag = fe_input_add (dcc->sok, FIA_WRITE|FIA_EX,
+ dcc->wiotag = net_input_add (dcc->sok, NIA_WRITE|NIA_EX,
dcc_http_proxy_traverse, dcc);
++proxy->phase;
}
@@ 1287,10 1287,10 @@ dcc_http_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DCC
{
if (!write_proxy (dcc))
return TRUE;
- fe_input_remove (dcc->wiotag);
+ net_input_remove (dcc->wiotag);
dcc->wiotag = 0;
proxy->bufferused = 0;
- dcc->iotag = fe_input_add (dcc->sok, FIA_READ|FIA_EX,
+ dcc->iotag = net_input_add (dcc->sok, NIA_READ|NIA_EX,
dcc_http_proxy_traverse, dcc);
++proxy->phase;
}
@@ 1303,7 1303,7 @@ dcc_http_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DCC
if (proxy->bufferused < 12 ||
memcmp (proxy->buffer, "HTTP/", 5) || memcmp (proxy->buffer + 9, "200", 3))
{
- fe_input_remove (dcc->iotag);
+ net_input_remove (dcc->iotag);
dcc->iotag = 0;
PrintText (dcc->serv->front_session, proxy->buffer);
dcc->dccstat = STAT_FAILED;
@@ 1333,7 1333,7 @@ dcc_http_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DCC
else
return TRUE;
}
- fe_input_remove (dcc->iotag);
+ net_input_remove (dcc->iotag);
dcc->iotag = 0;
dcc_connect_finished (source, 0, dcc);
}
@@ 1344,7 1344,7 @@ dcc_http_proxy_traverse (GIOChannel *source, GIOCondition condition, struct DCC
static gboolean
dcc_proxy_connect (GIOChannel *source, GIOCondition condition, struct DCC *dcc)
{
- fe_input_remove (dcc->iotag);
+ net_input_remove (dcc->iotag);
dcc->iotag = 0;
if (!dcc_did_connect (source, condition, dcc))
@@ 1404,9 1404,9 @@ dcc_connect (struct DCC *dcc)
return;
}
if (DCC_USE_PROXY ())
- dcc->iotag = fe_input_add (dcc->sok, FIA_WRITE|FIA_EX, dcc_proxy_connect, dcc);
+ dcc->iotag = net_input_add (dcc->sok, NIA_WRITE|NIA_EX, dcc_proxy_connect, dcc);
else
- dcc->iotag = fe_input_add (dcc->sok, FIA_WRITE|FIA_EX, dcc_connect_finished, dcc);
+ dcc->iotag = net_input_add (dcc->sok, NIA_WRITE|NIA_EX, dcc_connect_finished, dcc);
}
fe_dcc_update (dcc);
@@ 1426,7 1426,7 @@ dcc_send_data (GIOChannel *source, GIOCondition condition, struct DCC *dcc)
if (dcc->throttled)
{
- fe_input_remove (dcc->wiotag);
+ net_input_remove (dcc->wiotag);
dcc->wiotag = 0;
return FALSE;
}
@@ 1437,7 1437,7 @@ dcc_send_data (GIOChannel *source, GIOCondition condition, struct DCC *dcc)
return TRUE;
}
else if (!dcc->wiotag)
- dcc->wiotag = fe_input_add (sok, FIA_WRITE, dcc_send_data, dcc);
+ dcc->wiotag = net_input_add (sok, NIA_WRITE, dcc_send_data, dcc);
buf = g_malloc (prefs.hex_dcc_blocksize);
@@ 1469,7 1469,7 @@ abortit:
/* it's all sent now, so remove the WRITE/SEND handler */
if (dcc->wiotag)
{
- fe_input_remove (dcc->wiotag);
+ net_input_remove (dcc->wiotag);
dcc->wiotag = 0;
}
}
@@ 1568,7 1568,7 @@ dcc_accept (GIOChannel *source, GIOCondition condition, struct DCC *dcc)
len = sizeof (CAddr);
sok = accept (dcc->sok, (struct sockaddr *) &CAddr, &len);
- fe_input_remove (dcc->iotag);
+ net_input_remove (dcc->iotag);
dcc->iotag = 0;
closesocket (dcc->sok);
if (sok < 0)
@@ 1594,8 1594,8 @@ dcc_accept (GIOChannel *source, GIOCondition condition, struct DCC *dcc)
{
case TYPE_SEND:
if (dcc->fastsend)
- dcc->wiotag = fe_input_add (sok, FIA_WRITE, dcc_send_data, dcc);
- dcc->iotag = fe_input_add (sok, FIA_READ|FIA_EX, dcc_read_ack, dcc);
+ dcc->wiotag = net_input_add (sok, NIA_WRITE, dcc_send_data, dcc);
+ dcc->iotag = net_input_add (sok, NIA_READ|NIA_EX, dcc_read_ack, dcc);
dcc_send_data (NULL, 0, (gpointer)dcc);
EMIT_SIGNAL (XP_TE_DCCCONSEND, dcc->serv->front_session,
dcc->nick, host, dcc->file, NULL, 0);
@@ 1603,7 1603,7 @@ dcc_accept (GIOChannel *source, GIOCondition condition, struct DCC *dcc)
case TYPE_CHATSEND:
dcc_open_query (dcc->serv, dcc->nick);
- dcc->iotag = fe_input_add (dcc->sok, FIA_READ|FIA_EX, dcc_read_chat, dcc);
+ dcc->iotag = net_input_add (dcc->sok, NIA_READ|NIA_EX, dcc_read_chat, dcc);
dcc->dccchat = g_new0 (struct dcc_chat, 1);
EMIT_SIGNAL (XP_TE_DCCCONCHAT, dcc->serv->front_session,
dcc->nick, host, NULL, NULL, 0);
@@ 1722,7 1722,7 @@ dcc_listen_init (struct DCC *dcc, session *sess)
listen (dcc->sok, 1);
set_blocking (dcc->sok);
- dcc->iotag = fe_input_add (dcc->sok, FIA_READ|FIA_EX, dcc_accept, dcc);
+ dcc->iotag = net_input_add (dcc->sok, NIA_READ|NIA_EX, dcc_accept, dcc);
return TRUE;
}
@@ 2248,7 2248,7 @@ new_dcc (void)
dcc_list = g_slist_prepend (dcc_list, dcc);
if (timeout_timer == 0)
{
- timeout_timer = fe_timeout_add_seconds (1, dcc_check_timeouts, NULL);
+ timeout_timer = g_timeout_add_seconds (1, (GSourceFunc)dcc_check_timeouts, NULL);
}
return dcc;
}
M src/common/fe.h => src/common/fe.h +0 -9
@@ 49,9 49,6 @@ void fe_init (void);
void fe_main (void);
void fe_cleanup (void);
void fe_exit (void);
-int fe_timeout_add (int interval, void *callback, void *userdata);
-int fe_timeout_add_seconds (int interval, void *callback, void *userdata);
-void fe_timeout_remove (int tag);
void fe_new_window (struct session *sess, int focus);
void fe_new_server (struct server *serv);
void fe_add_rawlog (struct server *serv, char *text, int len, int outbound);
@@ 61,12 58,6 @@ void fe_add_rawlog (struct server *serv, char *text, int len, int outbound);
#define FE_MSG_ERROR 8
#define FE_MSG_MARKUP 16
void fe_message (char *msg, int flags);
-#define FIA_READ 1
-#define FIA_WRITE 2
-#define FIA_EX 4
-#define FIA_FD 8
-int fe_input_add (int sok, int flags, void *func, void *data);
-void fe_input_remove (int tag);
void fe_idle_add (void *func, void *data);
void fe_set_topic (struct session *sess, char *topic, char *stripped_topic);
typedef enum
M src/common/hexchat.c => src/common/hexchat.c +11 -10
@@ 36,6 36,7 @@
#include "hexchat.h"
#include "fe.h"
+#include "network.h"
#include "util.h"
#include "cfgfiles.h"
#include "chanopt.h"
@@ 371,34 372,34 @@ hexchat_reinit_timers (void)
/* notify timeout */
if (prefs.hex_notify_timeout && notify_tag == 0)
{
- notify_tag = fe_timeout_add_seconds (prefs.hex_notify_timeout,
- notify_checklist, NULL);
+ notify_tag = g_timeout_add_seconds (prefs.hex_notify_timeout,
+ (GSourceFunc)notify_checklist, NULL);
}
else if (!prefs.hex_notify_timeout && notify_tag != 0)
{
- fe_timeout_remove (notify_tag);
+ g_source_remove (notify_tag);
notify_tag = 0;
}
/* away status tracking */
if (prefs.hex_away_track && away_tag == 0)
{
- away_tag = fe_timeout_add_seconds (prefs.hex_away_timeout, away_check, NULL);
+ away_tag = g_timeout_add_seconds (prefs.hex_away_timeout, (GSourceFunc)away_check, NULL);
}
else if (!prefs.hex_away_track && away_tag != 0)
{
- fe_timeout_remove (away_tag);
+ g_source_remove (away_tag);
away_tag = 0;
}
/* lag-o-meter */
if (prefs.hex_gui_lagometer && lag_check_update_tag == 0)
{
- lag_check_update_tag = fe_timeout_add (500, hexchat_lag_check_update, NULL);
+ lag_check_update_tag = g_timeout_add (500, (GSourceFunc)hexchat_lag_check_update, NULL);
}
else if (!prefs.hex_gui_lagometer && lag_check_update_tag != 0)
{
- fe_timeout_remove (lag_check_update_tag);
+ g_source_remove (lag_check_update_tag);
lag_check_update_tag = 0;
}
@@ 406,12 407,12 @@ hexchat_reinit_timers (void)
if ((prefs.hex_net_ping_timeout != 0 || prefs.hex_gui_lagometer)
&& lag_check_tag == 0)
{
- lag_check_tag = fe_timeout_add_seconds (30, hexchat_lag_check, NULL);
+ lag_check_tag = g_timeout_add_seconds (30, (GSourceFunc)hexchat_lag_check, NULL);
}
else if ((!prefs.hex_net_ping_timeout && !prefs.hex_gui_lagometer)
&& lag_check_tag != 0)
{
- fe_timeout_remove (lag_check_tag);
+ g_source_remove (lag_check_tag);
lag_check_tag = 0;
}
}
@@ 567,7 568,7 @@ exec_notify_kill (session * sess)
sess->running_exec = NULL;
kill (re->childpid, SIGKILL);
waitpid (re->childpid, NULL, WNOHANG);
- fe_input_remove (re->iotag);
+ net_input_remove (re->iotag);
close (re->myfd);
g_free (re->linebuf);
g_free (re);
M src/common/hexchat.h => src/common/hexchat.h +4 -0
@@ 451,6 451,10 @@ typedef struct server
void (*p_readerr)(struct server *, int);
void (*p_log)(struct server *, const char *);
char *(*p_get_network)(struct server *, gboolean);
+ void (*p_rawlog)(struct server *, char *, int, int);
+ void (*p_throttle_update)(struct server *);
+ void (*p_cleanup)(struct server *);
+ void (*p_stopconnect)(struct server *);
/* irc protocol functions (in proto*.c) */
void (*p_inline)(struct server *, char *buf, int len);
M src/common/ignore.c => src/common/ignore.c +1 -1
@@ 404,7 404,7 @@ flood_check (char *nick, char *ip, server *serv, session *sess, int what) /*0=ct
{
prefs.hex_gui_autoopen_dialog = 0;
/* turn it back on in 30 secs */
- fe_timeout_add_seconds (30, flood_autodialog_timeout, NULL);
+ g_timeout_add_seconds (30, flood_autodialog_timeout, NULL);
}
return 0;
}
M src/common/inbound.c => src/common/inbound.c +4 -4
@@ 68,7 68,7 @@ clear_channel (session *sess)
if (sess->mode_timeout_tag)
{
- fe_timeout_remove (sess->mode_timeout_tag);
+ g_source_remove (sess->mode_timeout_tag);
sess->mode_timeout_tag = 0;
}
@@ 862,7 862,7 @@ inbound_account (server *serv, char *nick, char *account,
void
inbound_ping_reply (session *sess, char *timestring, char *from,
- const message_tags_data *tags_data)
+ const message_tags_data *tags_data)
{
unsigned long tim, nowtim, dif;
int lag = 0;
@@ 1575,7 1575,7 @@ inbound_login_end (session *sess, char *text, const message_tags_data *tags_data
&& ((net->pass && inbound_nickserv_login (serv))
|| net->commandlist))
{
- serv->joindelay_tag = fe_timeout_add_seconds (prefs.hex_irc_join_delay, check_autojoin_channels, serv);
+ serv->joindelay_tag = g_timeout_add_seconds (prefs.hex_irc_join_delay, (GSourceFunc)check_autojoin_channels, serv);
}
else
{
@@ 1606,7 1606,7 @@ inbound_identified (server *serv) /* 'MODE +e MYSELF' on freenode */
if (serv->joindelay_tag)
{
/* stop waiting, just auto JOIN now */
- fe_timeout_remove (serv->joindelay_tag);
+ g_source_remove (serv->joindelay_tag);
serv->joindelay_tag = 0;
check_autojoin_channels (serv);
}
M src/common/network.c => src/common/network.c +35 -0
@@ 188,3 188,38 @@ udp_sockets (int *sok4, int *sok6)
*sok4 = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
*sok6 = socket (AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
}
+
+void
+net_input_remove (int tag)
+{
+ g_source_remove (tag);
+}
+
+int
+net_input_add (int sok, int flags, void *func, void *data)
+{
+ int tag, type = 0;
+ GIOChannel *channel;
+
+#ifdef WIN32
+ if (flags & NIA_FD)
+ channel = g_io_channel_win32_new_fd (sok);
+ else
+ channel = g_io_channel_win32_new_socket (sok);
+#else
+ channel = g_io_channel_unix_new (sok);
+#endif
+
+ if (flags & NIA_READ)
+ type |= G_IO_IN | G_IO_HUP | G_IO_ERR;
+ if (flags & NIA_WRITE)
+ type |= G_IO_OUT | G_IO_ERR;
+ if (flags & NIA_EX)
+ type |= G_IO_PRI;
+
+ tag = g_io_add_watch (channel, type, (GIOFunc) func, data);
+ g_io_channel_unref (channel);
+
+ return tag;
+}
+
M src/common/network.h => src/common/network.h +7 -0
@@ 39,4 39,11 @@ void net_bind (netstore *tobindto, int sok4, int sok6);
char *net_ip (guint32 addr);
void net_sockets (int *sok4, int *sok6);
+#define NIA_READ 1
+#define NIA_WRITE 2
+#define NIA_EX 4
+#define NIA_FD 8
+int net_input_add (int sok, int flags, void *func, void *data);
+void net_input_remove (int tag);
+
#endif
M src/common/outbound.c => src/common/outbound.c +3 -3
@@ 1444,7 1444,7 @@ exec_check_process (struct session *sess)
if (val == -1 || val > 0)
{
close (sess->running_exec->myfd);
- fe_input_remove (sess->running_exec->iotag);
+ net_input_remove (sess->running_exec->iotag);
g_free (sess->running_exec);
sess->running_exec = NULL;
}
@@ 1726,7 1726,7 @@ exec_data (GIOChannel *source, GIOCondition condition, struct nbexec *s)
g_free(buf);
waitpid (s->childpid, NULL, 0);
s->sess->running_exec = NULL;
- fe_input_remove (s->iotag);
+ net_input_remove (s->iotag);
close (sok);
g_free (s);
return TRUE;
@@ 1869,7 1869,7 @@ cmd_exec (struct session *sess, char *tbuf, char *word[], char *word_eol[])
/* Parent path */
close(fds[1]);
s->childpid = pid;
- s->iotag = fe_input_add (s->myfd, FIA_READ|FIA_EX, exec_data, s);
+ s->iotag = net_input_add (s->myfd, NIA_READ|NIA_EX, exec_data, s);
sess->running_exec = s;
return TRUE;
}
M src/common/plugin.c => src/common/plugin.c +8 -7
@@ 31,6 31,7 @@
#include "hexchat.h"
#include "fe.h"
+#include "network.h"
#include "util.h"
#include "outbound.h"
#include "cfgfiles.h"
@@ 749,7 750,7 @@ plugin_timeout_cb (hexchat_hook *hook)
if (ret == 0)
{
- hook->tag = 0; /* avoid fe_timeout_remove, returning 0 is enough! */
+ hook->tag = 0; /* avoid g_source_remove, returning 0 is enough! */
hexchat_unhook (hook->pl, hook);
}
@@ 815,7 816,7 @@ plugin_fd_cb (GIOChannel *source, GIOCondition condition, hexchat_hook *hook)
if (ret == 0)
{
- hook->tag = 0; /* avoid fe_input_remove, returning 0 is enough! */
+ hook->tag = 0; /* avoid net_input_remove, returning 0 is enough! */
hexchat_unhook (hook->pl, hook);
}
@@ 843,7 844,7 @@ plugin_add_hook (hexchat_plugin *pl, int type, int pri, const char *name,
plugin_insert_hook (hook);
if (type == HOOK_TIMER)
- hook->tag = fe_timeout_add (timeout, plugin_timeout_cb, hook);
+ hook->tag = g_timeout_add (timeout, (GSourceFunc)plugin_timeout_cb, hook);
return hook;
}
@@ 976,10 977,10 @@ hexchat_unhook (hexchat_plugin *ph, hexchat_hook *hook)
return NULL;
if (hook->type == HOOK_TIMER && hook->tag != 0)
- fe_timeout_remove (hook->tag);
+ g_source_remove (hook->tag);
if (hook->type == HOOK_FD && hook->tag != 0)
- fe_input_remove (hook->tag);
+ net_input_remove (hook->tag);
hook->type = HOOK_DELETED; /* expunge later */
@@ 1042,8 1043,8 @@ hexchat_hook_fd (hexchat_plugin *ph, int fd, int flags,
hook = plugin_add_hook (ph, HOOK_FD, 0, 0, 0, callb, 0, userdata);
hook->pri = fd;
- /* plugin hook_fd flags correspond exactly to FIA_* flags (fe.h) */
- hook->tag = fe_input_add (fd, flags, plugin_fd_cb, hook);
+ /* plugin hook_fd flags correspond exactly to NIA_* flags (fe.h) */
+ hook->tag = net_input_add (fd, flags, plugin_fd_cb, hook);
return hook;
}
M src/common/proto-irc.c => src/common/proto-irc.c +38 -3
@@ 1792,6 1792,8 @@ irc_connected (server *serv)
}
ircserver_set_name (serv, serv->servername);
+
+ fe_server_event (serv, FE_SE_CONNECT, 0);
}
static void
@@ 1889,11 1891,11 @@ auto_reconnect (server *serv, int send_quit, int err)
/* is this server in a reconnect delay? remove it! */
if (serv->recondelay_tag)
{
- fe_timeout_remove (serv->recondelay_tag);
+ g_source_remove (serv->recondelay_tag);
serv->recondelay_tag = 0;
}
- serv->recondelay_tag = fe_timeout_add (del, timeout_auto_reconnect, serv);
+ serv->recondelay_tag = g_timeout_add (del, (GSourceFunc)timeout_auto_reconnect, serv);
fe_server_event (serv, FE_SE_RECONDELAY, del);
}
@@ 1916,10 1918,12 @@ irc_connstop (server *serv, const char *msg)
static void
irc_connecting (server *serv, const char *host, const char *ip, const char *port)
{
- serv->end_of_motd = FALSE;
EMIT_SIGNAL (XP_TE_CONNECT, serv->server_session,
(char *)host, (char *)ip, (char *)port, NULL, 0);
+
+ fe_server_event (serv, FE_SE_CONNECTING, 0);
+ fe_set_away (serv);
}
static void
@@ 1958,6 1962,32 @@ irc_serverlog (server *serv, const char *msg)
PrintText (serv->server_session, (char *)msg);
}
+static void
+irc_cleanup (server *serv)
+{
+ if (serv->joindelay_tag)
+ {
+ g_source_remove (serv->joindelay_tag);
+ serv->joindelay_tag = 0;
+ }
+
+ serv->end_of_motd = FALSE;
+ fe_set_lag (serv, 0);
+}
+
+static void
+irc_stopconnect (server *serv)
+{
+ if (serv->joindelay_tag)
+ {
+ g_source_remove (serv->joindelay_tag);
+ serv->joindelay_tag = 0;
+ }
+
+ fe_progressbar_end (serv);
+ fe_server_event (serv, FE_SE_DISCONNECT, 0);
+}
+
void
proto_fill_her_up (server *serv)
{
@@ 1973,6 2003,11 @@ proto_fill_her_up (server *serv)
serv->p_unknhost = irc_unknhost;
serv->p_readerr = irc_readerr;
serv->p_log = irc_serverlog;
+ serv->p_cleanup = irc_cleanup;
+ serv->p_stopconnect = irc_stopconnect;
+
+ serv->p_rawlog = fe_add_rawlog;
+ serv->p_throttle_update = fe_set_throttle;
serv->p_get_network = ircserver_get_network;
M src/common/server.c => src/common/server.c +21 -39
@@ 107,7 107,7 @@ tcp_send_real (void *ssl, int sok, GIConv write_converter, char *buf, int len)
static int
server_send_real (server *serv, char *buf, int len)
{
- fe_add_rawlog (serv, buf, len, TRUE);
+ serv->p_rawlog (serv, buf, len, TRUE);
url_check_line (buf);
@@ 149,7 149,7 @@ tcp_send_queue (server *serv)
{
/* check for clock skew */
if (now >= serv->prev_now)
- return 1; /* don't remove the timeout handler */
+ return 1; /* don't remove the timeout handler */
/* it is skewed, reset to something sane */
serv->next_send = now;
}
@@ 158,7 158,7 @@ tcp_send_queue (server *serv)
serv->next_send += (2 + i / 120);
serv->sendq_len -= len;
serv->prev_now = now;
- fe_set_throttle (serv);
+ serv->p_throttle_update (serv);
server_send_real (serv, buf, len);
@@ 234,7 234,7 @@ keep_priority:
serv->sendq_len += len; /* tcp_send_queue uses strlen */
if (tcp_send_queue (serv) && noqueue)
- fe_timeout_add (500, tcp_send_queue, serv);
+ g_timeout_add (500, (GSourceFunc)tcp_send_queue, serv);
return 1;
}
@@ 270,7 270,7 @@ static void
close_socket (int sok)
{
/* close the socket in 5 seconds so the QUIT message is not lost */
- fe_timeout_add_seconds (5, close_socket_cb, GINT_TO_POINTER (sok));
+ g_timeout_add_seconds (5, close_socket_cb, GINT_TO_POINTER (sok));
}
/* handle 1 line of text received from the server */
@@ 284,7 284,7 @@ server_inline (server *serv, char *line, gssize len)
else
line = text_convert_invalid (line, len, serv->read_converter, unicode_fallback_string, &len_utf8);
- fe_add_rawlog (serv, line, len_utf8, FALSE);
+ serv->p_rawlog (serv, line, len_utf8, FALSE);
/* let proto-irc.c handle it */
serv->p_inline (serv, line, len_utf8);
@@ 362,11 362,9 @@ server_connected (server *serv)
serv->lag_sent = 0;
serv->connected = TRUE;
set_nonblocking (serv->sok);
- serv->iotag = fe_input_add (serv->sok, FIA_READ|FIA_EX, server_read, serv);
+ serv->iotag = net_input_add (serv->sok, NIA_READ|NIA_EX, server_read, serv);
serv->p_connected(serv);
-
- fe_server_event (serv, FE_SE_CONNECT, 0);
}
#ifdef WIN32
@@ 387,16 385,10 @@ server_stopconnecting (server * serv)
{
if (serv->iotag)
{
- fe_input_remove (serv->iotag);
+ net_input_remove (serv->iotag);
serv->iotag = 0;
}
- if (serv->joindelay_tag)
- {
- fe_timeout_remove (serv->joindelay_tag);
- serv->joindelay_tag = 0;
- }
-
#ifndef WIN32
/* kill the child process trying to connect */
kill (serv->childpid, SIGKILL);
@@ 419,15 411,13 @@ server_stopconnecting (server * serv)
#ifdef USE_OPENSSL
if (serv->ssl_do_connect_tag)
{
- fe_timeout_remove (serv->ssl_do_connect_tag);
+ g_source_remove (serv->ssl_do_connect_tag);
serv->ssl_do_connect_tag = 0;
}
#endif
- fe_progressbar_end (serv);
-
serv->connecting = FALSE;
- fe_server_event (serv, FE_SE_DISCONNECT, 0);
+ serv->p_stopconnect (serv);
}
#ifdef USE_OPENSSL
@@ 438,7 428,7 @@ ssl_cb_info (SSL *s, int where, int ret)
/* char buf[128];*/
- return; /* FIXME: make debug level adjustable in serverlist or settings */
+ return; /* FIXME: make debug level adjustable in serverlist or settings */
/* g_snprintf (buf, sizeof (buf), "%s (%d)", SSL_state_string_long (s), where);
if (g_serv)
@@ 631,7 621,7 @@ server_flush_queue (server *serv)
{
list_free (&serv->outbound_queue);
serv->sendq_len = 0;
- fe_set_throttle (serv);
+ serv->p_throttle_update (serv);
}
/* connect() successed */
@@ 657,8 647,8 @@ server_connect_success (server *serv)
/* FIXME: it'll be needed by new servers */
/* send(serv->sok, "STLS\r\n", 6, 0); sleep(1); */
set_nonblocking (serv->sok);
- serv->ssl_do_connect_tag = fe_timeout_add (SSLDOCONNTMOUT,
- ssl_do_connect, serv);
+ serv->ssl_do_connect_tag = g_timeout_add (SSLDOCONNTMOUT,
+ (GSourceFunc)ssl_do_connect, serv);
return;
}
@@ 763,20 753,14 @@ server_read_child (GIOChannel *source, GIOCondition condition, server *serv)
static int
server_cleanup (server * serv)
{
- fe_set_lag (serv, 0);
+ serv->p_cleanup (serv);
if (serv->iotag)
{
- fe_input_remove (serv->iotag);
+ net_input_remove (serv->iotag);
serv->iotag = 0;
}
- if (serv->joindelay_tag)
- {
- fe_timeout_remove (serv->joindelay_tag);
- serv->joindelay_tag = 0;
- }
-
#ifdef USE_OPENSSL
if (serv->ssl)
{
@@ 811,11 795,11 @@ server_cleanup (server * serv)
/* is this server in a reconnect delay? remove it! */
if (serv->recondelay_tag)
{
- fe_timeout_remove (serv->recondelay_tag);
+ g_source_remove (serv->recondelay_tag);
serv->recondelay_tag = 0;
return 3;
}
-
+
return 0;
}
@@ 1437,8 1421,6 @@ server_connect (server *serv, char *hostname, int port, int no_login)
serv->port = port;
serv->no_login = no_login;
- fe_server_event (serv, FE_SE_CONNECTING, 0);
- fe_set_away (serv);
server_flush_queue (serv);
#ifdef WIN32
@@ 1485,11 1467,11 @@ server_connect (server *serv, char *hostname, int port, int no_login)
#endif
serv->childpid = pid;
#ifdef WIN32
- serv->iotag = fe_input_add (serv->childread, FIA_READ|FIA_FD, server_read_child,
+ serv->iotag = net_input_add (serv->childread, NIA_READ|NIA_FD, server_read_child,
#else
- serv->iotag = fe_input_add (serv->childread, FIA_READ, server_read_child,
+ serv->iotag = net_input_add (serv->childread, NIA_READ, server_read_child,
#endif
- serv);
+ serv);
}
void
M src/common/servlist.c => src/common/servlist.c +1 -1
@@ 548,7 548,7 @@ servlist_cycle (server *serv)
del = 500; /* so it doesn't block the gui */
if (del)
- serv->recondelay_tag = fe_timeout_add (del, servlist_cycle_cb, serv);
+ serv->recondelay_tag = g_timeout_add (del, (GSourceFunc)servlist_cycle_cb, serv);
else
servlist_connect (serv->server_session, net, TRUE);
M src/fe-gtk/fe-gtk.c => src/fe-gtk/fe-gtk.c +0 -52
@@ 365,24 365,6 @@ fe_exit (void)
gtk_main_quit ();
}
-int
-fe_timeout_add (int interval, void *callback, void *userdata)
-{
- return g_timeout_add (interval, (GSourceFunc) callback, userdata);
-}
-
-int
-fe_timeout_add_seconds (int interval, void *callback, void *userdata)
-{
- return g_timeout_add_seconds (interval, (GSourceFunc) callback, userdata);
-}
-
-void
-fe_timeout_remove (int tag)
-{
- g_source_remove (tag);
-}
-
#ifdef WIN32
static void
@@ 494,40 476,6 @@ fe_idle_add (void *func, void *data)
}
void
-fe_input_remove (int tag)
-{
- g_source_remove (tag);
-}
-
-int
-fe_input_add (int sok, int flags, void *func, void *data)
-{
- int tag, type = 0;
- GIOChannel *channel;
-
-#ifdef WIN32
- if (flags & FIA_FD)
- channel = g_io_channel_win32_new_fd (sok);
- else
- channel = g_io_channel_win32_new_socket (sok);
-#else
- channel = g_io_channel_unix_new (sok);
-#endif
-
- if (flags & FIA_READ)
- type |= G_IO_IN | G_IO_HUP | G_IO_ERR;
- if (flags & FIA_WRITE)
- type |= G_IO_OUT | G_IO_ERR;
- if (flags & FIA_EX)
- type |= G_IO_PRI;
-
- tag = g_io_add_watch (channel, type, (GIOFunc) func, data);
- g_io_channel_unref (channel);
-
- return tag;
-}
-
-void
fe_set_topic (session *sess, char *topic, char *stripped_topic)
{
if (!sess->gui->is_tab || sess == current_tab)
M src/fe-gtk/maingui.c => src/fe-gtk/maingui.c +3 -3
@@ 579,13 579,13 @@ mg_progressbar_create (session_gui *gui)
gui->bar = gtk_progress_bar_new ();
gtk_box_pack_start (GTK_BOX (gui->nick_box), gui->bar, 0, 0, 0);
gtk_widget_show (gui->bar);
- gui->bartag = fe_timeout_add (50, mg_progressbar_update, gui->bar);
+ gui->bartag = g_timeout_add (50, (GSourceFunc)mg_progressbar_update, gui->bar);
}
void
mg_progressbar_destroy (session_gui *gui)
{
- fe_timeout_remove (gui->bartag);
+ g_source_remove (gui->bartag);
gtk_widget_destroy (gui->bar);
gui->bar = 0;
gui->bartag = 0;
@@ 3680,7 3680,7 @@ fe_session_callback (session *sess)
g_free (sess->res->lag_tip);
if (sess->gui->bartag)
- fe_timeout_remove (sess->gui->bartag);
+ g_source_remove (sess->gui->bartag);
if (sess->gui != &static_mg_gui)
g_free (sess->gui);
M src/fe-text/fe-text.c => src/fe-text/fe-text.c +0 -52
@@ 403,58 403,6 @@ fe_print_text (struct session *sess, char *text, time_t stamp,
}
#endif
-void
-fe_timeout_remove (int tag)
-{
- g_source_remove (tag);
-}
-
-int
-fe_timeout_add (int interval, void *callback, void *userdata)
-{
- return g_timeout_add (interval, (GSourceFunc) callback, userdata);
-}
-
-int
-fe_timeout_add_seconds (int interval, void *callback, void *userdata)
-{
- return g_timeout_add_seconds (interval, (GSourceFunc) callback, userdata);
-}
-
-void
-fe_input_remove (int tag)
-{
- g_source_remove (tag);
-}
-
-int
-fe_input_add (int sok, int flags, void *func, void *data)
-{
- int tag, type = 0;
- GIOChannel *channel;
-
-#ifdef G_OS_WIN32
- if (flags & FIA_FD)
- channel = g_io_channel_win32_new_fd (sok);
- else
- channel = g_io_channel_win32_new_socket (sok);
-#else
- channel = g_io_channel_unix_new (sok);
-#endif
-
- if (flags & FIA_READ)
- type |= G_IO_IN | G_IO_HUP | G_IO_ERR;
- if (flags & FIA_WRITE)
- type |= G_IO_OUT | G_IO_ERR;
- if (flags & FIA_EX)
- type |= G_IO_PRI;
-
- tag = g_io_add_watch (channel, type, (GIOFunc) func, data);
- g_io_channel_unref (channel);
-
- return tag;
-}
-
/* === command-line parameter parsing : requires glib 2.6 === */
static char *arg_cfgdir = NULL;