From 9a9f5886431dff4938979641fc1b3c69ef76ce38 Mon Sep 17 00:00:00 2001 From: Aleteoryx Date: Sun, 27 Jul 2025 21:37:54 -0400 Subject: [PATCH] remove all references to fe_* from server.c, other than ctor/dtor --- src/common/dcc.c | 100 ++++++++++++++++++++--------------------- src/common/fe.h | 9 ---- src/common/hexchat.c | 21 ++++----- src/common/hexchat.h | 4 ++ src/common/ignore.c | 2 +- src/common/inbound.c | 8 ++-- src/common/network.c | 35 +++++++++++++++ src/common/network.h | 7 +++ src/common/outbound.c | 6 +-- src/common/plugin.c | 15 ++++--- src/common/proto-irc.c | 41 +++++++++++++++-- src/common/server.c | 60 +++++++++---------------- src/common/servlist.c | 2 +- src/fe-gtk/fe-gtk.c | 52 --------------------- src/fe-gtk/maingui.c | 6 +-- src/fe-text/fe-text.c | 52 --------------------- 16 files changed, 186 insertions(+), 234 deletions(-) diff --git a/src/common/dcc.c b/src/common/dcc.c index 28bc080751b5504644ae6bc3259ff85545603267..f3d2a7cdb9a8bb35306a874acb29d765606ef876 100644 --- a/src/common/dcc.c +++ b/src/common/dcc.c @@ -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; } diff --git a/src/common/fe.h b/src/common/fe.h index 4d4093c6114ed3ab506c7037969696e7c33e7325..2a41c358d4e2e3cf1e13c93f00f2571b5c3a494c 100644 --- a/src/common/fe.h +++ b/src/common/fe.h @@ -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 diff --git a/src/common/hexchat.c b/src/common/hexchat.c index 8089cdd102db3480e7636ab8442bcaa4c836ce06..a3c4435f446090b98d3d8b123742815c6efc6983 100644 --- a/src/common/hexchat.c +++ b/src/common/hexchat.c @@ -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); diff --git a/src/common/hexchat.h b/src/common/hexchat.h index 38c5bb796ac094becbf3216da7cc65f87ecbca01..75dfe22938358ff10d8cbb860b4847d4c95c1216 100644 --- a/src/common/hexchat.h +++ b/src/common/hexchat.h @@ -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); diff --git a/src/common/ignore.c b/src/common/ignore.c index 8bf0d57fc3c668fccd7b3f869bc71b2643f87a1e..0001b98fe56030a00711b70f999fbef70512072d 100644 --- a/src/common/ignore.c +++ b/src/common/ignore.c @@ -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; } diff --git a/src/common/inbound.c b/src/common/inbound.c index 3cb6b5e86eaa4fdd322b36c098a535aa74209f15..5118111adeb18e9e135ad6b79f3d5e2cc5c8817b 100644 --- a/src/common/inbound.c +++ b/src/common/inbound.c @@ -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); } diff --git a/src/common/network.c b/src/common/network.c index fcdaf54724438500e177a732a1dfddff0e057ded..c6b2b6483d5bb2adccce1e8216ac01c95987bbe9 100644 --- a/src/common/network.c +++ b/src/common/network.c @@ -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; +} + diff --git a/src/common/network.h b/src/common/network.h index 8c1c0c799df00f4310b3c788fab53470e42d73a5..c78720b07186aa6b150301ecb367a0066d82a8ba 100644 --- a/src/common/network.h +++ b/src/common/network.h @@ -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 diff --git a/src/common/outbound.c b/src/common/outbound.c index ee620c874418bd341126603691309bb5140cf497..eeb2620b028e4f66aea2f0170d63d2240ba87bbc 100644 --- a/src/common/outbound.c +++ b/src/common/outbound.c @@ -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; } diff --git a/src/common/plugin.c b/src/common/plugin.c index 5d9f16efb65d6d68aee4aaafbe0f03a6b7a44085..654842373e4baac4c2a9fc994df55adf36e5c7b4 100644 --- a/src/common/plugin.c +++ b/src/common/plugin.c @@ -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; } diff --git a/src/common/proto-irc.c b/src/common/proto-irc.c index 6ae03d186d1e68abd2d59820bfac99b9df16aa0d..7250eef5caf32112a57521fa974027d5377ba4af 100644 --- a/src/common/proto-irc.c +++ b/src/common/proto-irc.c @@ -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; diff --git a/src/common/server.c b/src/common/server.c index e276c149ab9fc759345f86876c9b40c7c0ecfd16..8d6d017039954067a6aa24dc8511e536afa3efa6 100644 --- a/src/common/server.c +++ b/src/common/server.c @@ -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 diff --git a/src/common/servlist.c b/src/common/servlist.c index 31cf50e889b9e75177842ebc57aecee8151d27ef..e9d6d3cbeff42c326f28be72a5c961044eda5036 100644 --- a/src/common/servlist.c +++ b/src/common/servlist.c @@ -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); diff --git a/src/fe-gtk/fe-gtk.c b/src/fe-gtk/fe-gtk.c index afe4b09c850946cd5914b00c76395e2ca7c0968b..b33ad8933a4b5f34d2d3876ddbea3d196992c53b 100644 --- a/src/fe-gtk/fe-gtk.c +++ b/src/fe-gtk/fe-gtk.c @@ -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 @@ -493,40 +475,6 @@ fe_idle_add (void *func, void *data) g_idle_add (func, 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) { diff --git a/src/fe-gtk/maingui.c b/src/fe-gtk/maingui.c index 1e76fa97c4410078393fc23b415dea509e8db80c..14ed07f6340663a0fbecffd0cde6ad0984906c22 100644 --- a/src/fe-gtk/maingui.c +++ b/src/fe-gtk/maingui.c @@ -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); diff --git a/src/fe-text/fe-text.c b/src/fe-text/fe-text.c index 3673a81f44e4918b27e64ffec4708eac97e344e2..52628bc89388646f1fdc59cb8bcac3adbda94cd5 100644 --- a/src/fe-text/fe-text.c +++ b/src/fe-text/fe-text.c @@ -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;