7 Commits

Author SHA1 Message Date
64833d7af8 fix dependencies in appimage 2026-05-25 22:41:28 -06:00
a98c30a679 Restore strict miniupnpc dep handling 2026-05-25 22:12:51 -06:00
92fe064e26 Add DCC passive-first + NAT mapping prefs 2026-05-25 21:37:10 -06:00
deepend-tildeclub
fb491a6bb2 Merge pull request #249 from ZoiteChat/lost-connection-fixes
Add configurable stale-link ping checks
2026-05-25 12:21:45 -06:00
3da7c89b66 Add configurable stale-link ping checks 2026-05-25 11:43:10 -06:00
deepend-tildeclub
e842cf3a57 Merge pull request #248 from ZoiteChat/scroll-speed-fix
Fix xtext wheel scroll speed handling + prefs slider
2026-05-25 10:29:40 -06:00
85b0e8f1a6 Fix xtext wheel scroll speed handling + prefs slider 2026-05-25 09:45:22 -06:00
20 changed files with 295 additions and 19 deletions

View File

@@ -29,6 +29,7 @@ jobs:
build-essential pkg-config meson ninja-build cmake \ build-essential pkg-config meson ninja-build cmake \
gettext \ gettext \
libcanberra-dev libglib2.0-dev \ libcanberra-dev libglib2.0-dev \
libminiupnpc-dev \
libarchive-dev \ libarchive-dev \
libgtk-3-dev \ libgtk-3-dev \
libwayland-client0 libwayland-cursor0 libwayland-egl1 \ libwayland-client0 libwayland-cursor0 libwayland-egl1 \
@@ -86,11 +87,21 @@ jobs:
cp -a /usr/lib/x86_64-linux-gnu/python3/dist-packages AppDir/usr/lib/x86_64-linux-gnu/python3/ cp -a /usr/lib/x86_64-linux-gnu/python3/dist-packages AppDir/usr/lib/x86_64-linux-gnu/python3/
fi fi
if [ -d "/usr/lib/x86_64-linux-gnu/perl-base" ]; then
install -d AppDir/usr/lib/x86_64-linux-gnu
cp -a /usr/lib/x86_64-linux-gnu/perl-base AppDir/usr/lib/x86_64-linux-gnu/
fi
if [ -d "/usr/lib/x86_64-linux-gnu/perl" ]; then if [ -d "/usr/lib/x86_64-linux-gnu/perl" ]; then
install -d AppDir/usr/lib/x86_64-linux-gnu install -d AppDir/usr/lib/x86_64-linux-gnu
cp -a /usr/lib/x86_64-linux-gnu/perl AppDir/usr/lib/x86_64-linux-gnu/ cp -a /usr/lib/x86_64-linux-gnu/perl AppDir/usr/lib/x86_64-linux-gnu/
fi fi
if [ -d "/usr/lib/x86_64-linux-gnu/perl5" ]; then
install -d AppDir/usr/lib/x86_64-linux-gnu
cp -a /usr/lib/x86_64-linux-gnu/perl5 AppDir/usr/lib/x86_64-linux-gnu/
fi
if [ -d "/usr/share/perl" ]; then if [ -d "/usr/share/perl" ]; then
install -d AppDir/usr/share install -d AppDir/usr/share
cp -a /usr/share/perl AppDir/usr/share/ cp -a /usr/share/perl AppDir/usr/share/
@@ -100,6 +111,10 @@ jobs:
install -d AppDir/usr/share install -d AppDir/usr/share
cp -a /usr/share/perl5 AppDir/usr/share/ cp -a /usr/share/perl5 AppDir/usr/share/
fi fi
perl -MFile::Spec -e 'print "Build host File::Spec: $INC{\"File/Spec.pm\"}\n"'
find AppDir/usr -path '*/File/Spec.pm' -print -quit | grep -q .
if compgen -G '/usr/lib/x86_64-linux-gnu/libpython3*.so*' > /dev/null; then if compgen -G '/usr/lib/x86_64-linux-gnu/libpython3*.so*' > /dev/null; then
install -d AppDir/usr/lib/x86_64-linux-gnu install -d AppDir/usr/lib/x86_64-linux-gnu
cp -a /usr/lib/x86_64-linux-gnu/libpython3*.so* AppDir/usr/lib/x86_64-linux-gnu/ cp -a /usr/lib/x86_64-linux-gnu/libpython3*.so* AppDir/usr/lib/x86_64-linux-gnu/
@@ -162,7 +177,7 @@ jobs:
APPDIR="${APPDIR:-$(dirname "$(readlink -f "$0")")}" APPDIR="${APPDIR:-$(dirname "$(readlink -f "$0")")}"
export PATH="${PATH:-/usr/bin:/bin}:$APPDIR/usr/bin" export PATH="$APPDIR/usr/bin:${PATH:-/usr/bin:/bin}"
export LD_LIBRARY_PATH="$APPDIR/usr/lib:$APPDIR/usr/lib/x86_64-linux-gnu:${LD_LIBRARY_PATH:-}" export LD_LIBRARY_PATH="$APPDIR/usr/lib:$APPDIR/usr/lib/x86_64-linux-gnu:${LD_LIBRARY_PATH:-}"
export XDG_DATA_DIRS="$APPDIR/usr/share:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" export XDG_DATA_DIRS="$APPDIR/usr/share:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"
export GTK_EXE_PREFIX="$APPDIR/usr" export GTK_EXE_PREFIX="$APPDIR/usr"
@@ -211,6 +226,23 @@ jobs:
unset GTK_MODULES unset GTK_MODULES
perl5lib_entries=""
for dir in \
"$APPDIR/usr/lib/x86_64-linux-gnu/perl-base" \
"$APPDIR/usr/lib/x86_64-linux-gnu/perl"/* \
"$APPDIR/usr/lib/x86_64-linux-gnu/perl5"/* \
"$APPDIR/usr/share/perl"/* \
"$APPDIR/usr/share/perl5"
do
if [ -d "$dir" ]; then
perl5lib_entries="${perl5lib_entries:+$perl5lib_entries:}$dir"
fi
done
if [ -n "$perl5lib_entries" ]; then
export PERL5LIB="$perl5lib_entries${PERL5LIB:+:$PERL5LIB}"
fi
export PYTHONHOME="$APPDIR/usr" export PYTHONHOME="$APPDIR/usr"
python_stdlib_dir="$(find "$APPDIR/usr/lib" -maxdepth 1 -type d -name 'python3.*' | head -n 1 || true)" python_stdlib_dir="$(find "$APPDIR/usr/lib" -maxdepth 1 -type d -name 'python3.*' | head -n 1 || true)"
pythonpath_entries="" pythonpath_entries=""
@@ -256,7 +288,6 @@ jobs:
EOF EOF
chmod +x AppRun chmod +x AppRun
VERSION="$(git describe --tags --always)" VERSION="$(git describe --tags --always)"
./linuxdeploy-x86_64.AppImage \ ./linuxdeploy-x86_64.AppImage \

View File

@@ -33,6 +33,7 @@ jobs:
gtk3 \ gtk3 \
openssl \ openssl \
libcanberra \ libcanberra \
miniupnpc \
libayatana-appindicator \ libayatana-appindicator \
iso-codes \ iso-codes \
lua \ lua \

View File

@@ -18,6 +18,8 @@ libgmodule_dep = dependency('gmodule-2.0')
libcanberra_dep = dependency('libcanberra', version: '>= 0.22', libcanberra_dep = dependency('libcanberra', version: '>= 0.22',
required: get_option('libcanberra')) required: get_option('libcanberra'))
miniupnpc_dep = dependency('miniupnpc', version: '>= 2.0.0',
required: get_option('miniupnpc'))
dbus_dep = dependency('gio-2.0', required: get_option('dbus')) dbus_dep = dependency('gio-2.0', required: get_option('dbus'))
global_deps = [] global_deps = []
@@ -40,6 +42,7 @@ config_h.set10('ENABLE_NLS', true)
config_h.set('USE_OPENSSL', libssl_dep.found()) config_h.set('USE_OPENSSL', libssl_dep.found())
config_h.set('USE_LIBCANBERRA', libcanberra_dep.found()) config_h.set('USE_LIBCANBERRA', libcanberra_dep.found())
config_h.set('USE_DBUS', dbus_dep.found()) config_h.set('USE_DBUS', dbus_dep.found())
config_h.set('USE_MINIUPNPC', miniupnpc_dep.found())
config_h.set('USE_PLUGIN', get_option('plugin')) config_h.set('USE_PLUGIN', get_option('plugin'))
config_h.set('USE_GTK_FRONTEND', get_option('gtk-frontend')) config_h.set('USE_GTK_FRONTEND', get_option('gtk-frontend'))
@@ -183,6 +186,7 @@ if meson.version().version_compare('>= 0.55.0')
'Plugin Support': get_option('plugin'), 'Plugin Support': get_option('plugin'),
'DBus Support': dbus_dep.found(), 'DBus Support': dbus_dep.found(),
'libcanberra': libcanberra_dep.found(), 'libcanberra': libcanberra_dep.found(),
'miniupnpc': miniupnpc_dep.found(),
}, section: 'Features') }, section: 'Features')
summary({ summary({

View File

@@ -19,6 +19,9 @@ option('dbus', type: 'feature', value: 'auto',
option('libcanberra', type: 'feature', value: 'auto', option('libcanberra', type: 'feature', value: 'auto',
description: 'Support for sound alerts, Unix only' description: 'Support for sound alerts, Unix only'
) )
option('miniupnpc', type: 'feature', value: 'auto',
description: 'Support for DCC Universal Plug & Play, Unix only'
)
option('appindicator', type: 'feature', value: 'auto', option('appindicator', type: 'feature', value: 'auto',
description: 'Use Ayatana/AppIndicator-based tray backend for GTK frontend (non-Windows only)' description: 'Use Ayatana/AppIndicator-based tray backend for GTK frontend (non-Windows only)'
) )

View File

@@ -13,6 +13,7 @@ depends=(
'iso-codes' 'iso-codes'
'libayatana-appindicator' 'libayatana-appindicator'
'libcanberra' 'libcanberra'
'miniupnpc'
'lua' 'lua'
'openssl' 'openssl'
'perl' 'perl'

View File

@@ -447,6 +447,7 @@ const struct prefs vars[] =
{"gui_tab_layout", P_OFFINT (hex_gui_tab_layout), TYPE_INT}, {"gui_tab_layout", P_OFFINT (hex_gui_tab_layout), TYPE_INT},
{"gui_tab_closebuttons", P_OFFINT (hex_gui_tab_closebuttons), TYPE_BOOL}, {"gui_tab_closebuttons", P_OFFINT (hex_gui_tab_closebuttons), TYPE_BOOL},
{"gui_tab_middleclose", P_OFFINT (hex_gui_tab_middleclose), TYPE_BOOL}, {"gui_tab_middleclose", P_OFFINT (hex_gui_tab_middleclose), TYPE_BOOL},
{"gui_mouse_scroll_speed", P_OFFINT (hex_gui_mouse_scroll_speed), TYPE_INT},
{"gui_tab_newtofront", P_OFFINT (hex_gui_tab_newtofront), TYPE_INT}, {"gui_tab_newtofront", P_OFFINT (hex_gui_tab_newtofront), TYPE_INT},
{"gui_tab_pos", P_OFFINT (hex_gui_tab_pos), TYPE_INT}, {"gui_tab_pos", P_OFFINT (hex_gui_tab_pos), TYPE_INT},
{"gui_tab_scrollchans", P_OFFINT (hex_gui_tab_scrollchans), TYPE_BOOL}, {"gui_tab_scrollchans", P_OFFINT (hex_gui_tab_scrollchans), TYPE_BOOL},
@@ -548,6 +549,10 @@ const struct prefs vars[] =
#endif #endif
{"net_bind_host", P_OFFSET (hex_net_bind_host), TYPE_STR}, {"net_bind_host", P_OFFSET (hex_net_bind_host), TYPE_STR},
{"net_ping_timeout", P_OFFINT (hex_net_ping_timeout), TYPE_INT, zoitechat_reinit_timers}, {"net_ping_timeout", P_OFFINT (hex_net_ping_timeout), TYPE_INT, zoitechat_reinit_timers},
{"net_lag_check", P_OFFINT (hex_net_lag_check), TYPE_INT, zoitechat_reinit_timers},
{"net_keepalive_idle", P_OFFINT (hex_net_keepalive_idle), TYPE_INT},
{"net_keepalive_interval", P_OFFINT (hex_net_keepalive_interval), TYPE_INT},
{"net_keepalive_count", P_OFFINT (hex_net_keepalive_count), TYPE_INT},
{"net_proxy_auth", P_OFFINT (hex_net_proxy_auth), TYPE_BOOL}, {"net_proxy_auth", P_OFFINT (hex_net_proxy_auth), TYPE_BOOL},
{"net_proxy_host", P_OFFSET (hex_net_proxy_host), TYPE_STR}, {"net_proxy_host", P_OFFSET (hex_net_proxy_host), TYPE_STR},
{"net_proxy_pass", P_OFFSET (hex_net_proxy_pass), TYPE_STR}, {"net_proxy_pass", P_OFFSET (hex_net_proxy_pass), TYPE_STR},
@@ -557,6 +562,7 @@ const struct prefs vars[] =
{"net_proxy_user", P_OFFSET (hex_net_proxy_user), TYPE_STR}, {"net_proxy_user", P_OFFSET (hex_net_proxy_user), TYPE_STR},
{"net_reconnect_delay", P_OFFINT (hex_net_reconnect_delay), TYPE_INT}, {"net_reconnect_delay", P_OFFINT (hex_net_reconnect_delay), TYPE_INT},
{"net_throttle", P_OFFINT (hex_net_throttle), TYPE_BOOL}, {"net_throttle", P_OFFINT (hex_net_throttle), TYPE_BOOL},
{"net_upnp", P_OFFINT (hex_net_upnp), TYPE_BOOL},
{"notify_timeout", P_OFFINT (hex_notify_timeout), TYPE_INT}, {"notify_timeout", P_OFFINT (hex_notify_timeout), TYPE_INT},
{"notify_whois_online", P_OFFINT (hex_notify_whois_online), TYPE_BOOL}, {"notify_whois_online", P_OFFINT (hex_notify_whois_online), TYPE_BOOL},
@@ -783,6 +789,7 @@ load_default_config(void)
prefs.hex_gui_tab_server = 1; prefs.hex_gui_tab_server = 1;
prefs.hex_gui_tab_sort = 1; prefs.hex_gui_tab_sort = 1;
prefs.hex_gui_tab_scrollchans = 1; prefs.hex_gui_tab_scrollchans = 1;
prefs.hex_gui_mouse_scroll_speed = 10;
prefs.hex_gui_topicbar = 1; prefs.hex_gui_topicbar = 1;
prefs.hex_gui_transparency = 255; prefs.hex_gui_transparency = 255;
prefs.hex_gui_tray = 1; prefs.hex_gui_tray = 1;
@@ -805,6 +812,7 @@ load_default_config(void)
prefs.hex_irc_whois_front = 1; prefs.hex_irc_whois_front = 1;
prefs.hex_net_auto_reconnect = 1; prefs.hex_net_auto_reconnect = 1;
prefs.hex_net_throttle = 1; prefs.hex_net_throttle = 1;
prefs.hex_net_upnp = 1;
prefs.hex_stamp_log = 1; prefs.hex_stamp_log = 1;
prefs.hex_stamp_text = 1; prefs.hex_stamp_text = 1;
prefs.hex_text_autocopy_text = 1; prefs.hex_text_autocopy_text = 1;
@@ -858,6 +866,10 @@ load_default_config(void)
prefs.hex_irc_ban_type = 1; prefs.hex_irc_ban_type = 1;
prefs.hex_irc_join_delay = 5; prefs.hex_irc_join_delay = 5;
prefs.hex_net_ping_timeout = 60; prefs.hex_net_ping_timeout = 60;
prefs.hex_net_lag_check = 60;
prefs.hex_net_keepalive_idle = 60;
prefs.hex_net_keepalive_interval = 20;
prefs.hex_net_keepalive_count = 3;
prefs.hex_net_reconnect_delay = 10; prefs.hex_net_reconnect_delay = 10;
prefs.hex_notify_timeout = 15; prefs.hex_notify_timeout = 15;
prefs.hex_text_max_indent = 256; prefs.hex_text_max_indent = 256;

View File

@@ -74,6 +74,7 @@
<ClCompile Include="sysinfo\win32\backend.c" /> <ClCompile Include="sysinfo\win32\backend.c" />
<ClCompile Include="text.c" /> <ClCompile Include="text.c" />
<ClCompile Include="tree.c" /> <ClCompile Include="tree.c" />
<ClCompile Include="upnp.c" />
<ClCompile Include="url.c" /> <ClCompile Include="url.c" />
<ClCompile Include="userlist.c" /> <ClCompile Include="userlist.c" />
<ClCompile Include="util.c" /> <ClCompile Include="util.c" />

View File

@@ -190,6 +190,9 @@
<ClCompile Include="tree.c"> <ClCompile Include="tree.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="upnp.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="url.c"> <ClCompile Include="url.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>

View File

@@ -57,6 +57,7 @@
#include "text.h" #include "text.h"
#include "url.h" #include "url.h"
#include "zoitechatc.h" #include "zoitechatc.h"
#include "upnp.h"
/* Setting _FILE_OFFSET_BITS to 64 doesn't change lseek to use off64_t on Windows, so override lseek to the version that does */ /* Setting _FILE_OFFSET_BITS to 64 doesn't change lseek to use off64_t on Windows, so override lseek to the version that does */
#if defined(WIN32) && (!defined(__MINGW32__) && !defined(__MINGW64__)) #if defined(WIN32) && (!defined(__MINGW32__) && !defined(__MINGW64__))
@@ -371,6 +372,12 @@ dcc_connect_sok (struct DCC *dcc)
static void static void
dcc_close (struct DCC *dcc, enum dcc_state dccstat, int destroy) dcc_close (struct DCC *dcc, enum dcc_state dccstat, int destroy)
{ {
if (dcc->port > 0)
{
if (prefs.hex_net_upnp)
upnp_rem_redir(dcc->port);
}
if (dcc->wiotag) if (dcc->wiotag)
{ {
fe_input_remove (dcc->wiotag); fe_input_remove (dcc->wiotag);
@@ -1711,6 +1718,8 @@ dcc_listen_init (struct DCC *dcc, session *sess)
set_blocking (dcc->sok); set_blocking (dcc->sok);
dcc->iotag = fe_input_add (dcc->sok, FIA_READ|FIA_EX, dcc_accept, dcc); dcc->iotag = fe_input_add (dcc->sok, FIA_READ|FIA_EX, dcc_accept, dcc);
if (prefs.hex_net_upnp)
upnp_add_redir(inet_ntoa(SAddr.sin_addr), dcc->port);
return TRUE; return TRUE;
} }

View File

@@ -24,7 +24,8 @@ common_sources = [
'tree.c', 'tree.c',
'url.c', 'url.c',
'userlist.c', 'userlist.c',
'util.c' 'util.c',
'upnp.c'
] ]
common_sysinfo_deps = [] common_sysinfo_deps = []
@@ -115,6 +116,10 @@ if libssl_dep.found()
common_deps += libssl_dep common_deps += libssl_dep
endif endif
if miniupnpc_dep.found()
common_deps += miniupnpc_dep
endif
if dbus_dep.found() if dbus_dep.found()
subdir('dbus') subdir('dbus')
common_deps += zoitechat_dbus_dep common_deps += zoitechat_dbus_dep

View File

@@ -34,6 +34,9 @@
#ifndef WIN32 #ifndef WIN32
#include <unistd.h> #include <unistd.h>
#ifdef HAVE_NETINET_TCP_H
#include <netinet/tcp.h>
#endif
#endif #endif
#define WANTSOCKET #define WANTSOCKET
@@ -43,6 +46,9 @@
#define NETWORK_PRIVATE #define NETWORK_PRIVATE
#include "network.h" #include "network.h"
#include "zoitechat.h"
extern struct zoitechatprefs prefs;
#define RAND_INT(n) ((int)(rand() / (RAND_MAX + 1.0) * (n))) #define RAND_INT(n) ((int)(rand() / (RAND_MAX + 1.0) * (n)))
@@ -58,6 +64,27 @@ net_set_socket_options (int sok)
setsockopt (sok, SOL_SOCKET, SO_REUSEADDR, (char *) &sw, sizeof (sw)); setsockopt (sok, SOL_SOCKET, SO_REUSEADDR, (char *) &sw, sizeof (sw));
sw = 1; sw = 1;
setsockopt (sok, SOL_SOCKET, SO_KEEPALIVE, (char *) &sw, sizeof (sw)); setsockopt (sok, SOL_SOCKET, SO_KEEPALIVE, (char *) &sw, sizeof (sw));
#ifdef TCP_KEEPIDLE
{
int keepidle = prefs.hex_net_keepalive_idle;
if (keepidle > 0)
setsockopt (sok, IPPROTO_TCP, TCP_KEEPIDLE, (char *) &keepidle, sizeof (keepidle));
}
#endif
#ifdef TCP_KEEPINTVL
{
int keepintvl = prefs.hex_net_keepalive_interval;
if (keepintvl > 0)
setsockopt (sok, IPPROTO_TCP, TCP_KEEPINTVL, (char *) &keepintvl, sizeof (keepintvl));
}
#endif
#ifdef TCP_KEEPCNT
{
int keepcnt = prefs.hex_net_keepalive_count;
if (keepcnt > 0)
setsockopt (sok, IPPROTO_TCP, TCP_KEEPCNT, (char *) &keepcnt, sizeof (keepcnt));
}
#endif
} }
char * char *

111
src/common/upnp.c Normal file
View File

@@ -0,0 +1,111 @@
/*
* Copyright (C) Thomas Bernard
* Copyright (C) HexChat contributors
* Copyright (C) ZoiteChat contributors
*/
#include <stdio.h>
#include <string.h>
#include "upnp.h"
#ifdef USE_MINIUPNPC
#include <miniupnpc/miniupnpc.h>
#include <miniupnpc/upnpcommands.h>
#include <miniupnpc/upnperrors.h>
static struct UPNPUrls urls;
static struct IGDdatas data;
static int ready;
static char upnp_lanaddr[64];
void
upnp_init(void)
{
int err = 0;
int igd = 0;
char lanaddr[64] = {0};
struct UPNPDev *devlist;
memset(&urls, 0, sizeof(urls));
memset(&data, 0, sizeof(data));
ready = 0;
upnp_lanaddr[0] = 0;
devlist = upnpDiscover(2000, NULL, NULL, 0, 0, 2, &err);
if (!devlist)
devlist = upnpDiscover(2000, NULL, NULL, 0, 1, 2, &err);
if (!devlist)
return;
igd = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr));
if (igd == 1 || igd == 2 || igd == 3)
{
ready = 1;
snprintf(upnp_lanaddr, sizeof(upnp_lanaddr), "%s", lanaddr);
}
freeUPNPDevlist(devlist);
}
void
upnp_add_redir(const char *addr, int port)
{
char port_str[16];
const char *map_addr;
int r;
if (!ready)
upnp_init();
if (!ready)
return;
map_addr = upnp_lanaddr[0] ? upnp_lanaddr : addr;
if (!map_addr || !map_addr[0])
return;
snprintf(port_str, sizeof(port_str), "%d", port);
r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,
port_str, port_str, NULL, "zoitechat", "TCP", NULL, NULL);
if (r != UPNPCOMMAND_SUCCESS)
r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,
port_str, port_str, map_addr, "zoitechat", "TCP", NULL, NULL);
if (r != UPNPCOMMAND_SUCCESS)
return;
}
void
upnp_rem_redir(int port)
{
char port_str[16];
if (!ready)
upnp_init();
if (!ready)
return;
snprintf(port_str, sizeof(port_str), "%d", port);
UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, port_str, "TCP", NULL);
}
#else
void
upnp_init(void)
{
}
void
upnp_add_redir(const char *addr, int port)
{
(void)addr;
(void)port;
}
void
upnp_rem_redir(int port)
{
(void)port;
}
#endif

14
src/common/upnp.h Normal file
View File

@@ -0,0 +1,14 @@
/*
* Copyright (C) Thomas Bernard
* Copyright (C) HexChat contributors
* Copyright (C) ZoiteChat contributors
*/
#ifndef ZOITECHAT_UPNP_H
#define ZOITECHAT_UPNP_H
void upnp_init(void);
void upnp_add_redir(const char *addr, int port);
void upnp_rem_redir(int port);
#endif

View File

@@ -54,6 +54,7 @@
#include "text.h" #include "text.h"
#include "url.h" #include "url.h"
#include "zoitechatc.h" #include "zoitechatc.h"
#include "upnp.h"
#if ! GLIB_CHECK_VERSION (2, 36, 0) #if ! GLIB_CHECK_VERSION (2, 36, 0)
#include <glib-object.h> /* for g_type_init() */ #include <glib-object.h> /* for g_type_init() */
@@ -379,6 +380,7 @@ lag_check (void)
char tbuf[128]; char tbuf[128];
time_t now = time (0); time_t now = time (0);
time_t lag; time_t lag;
time_t ping_age;
tim = make_ping_time (); tim = make_ping_time ();
@@ -388,7 +390,7 @@ lag_check (void)
if (serv->connected && serv->end_of_motd) if (serv->connected && serv->end_of_motd)
{ {
lag = now - serv->ping_recv; lag = now - serv->ping_recv;
if (prefs.hex_net_ping_timeout != 0 && lag > prefs.hex_net_ping_timeout && lag > 0) if (serv->lag_sent && prefs.hex_net_ping_timeout != 0 && lag > prefs.hex_net_ping_timeout && lag > 0)
{ {
sprintf (tbuf, "%" G_GINT64_FORMAT, (gint64) lag); sprintf (tbuf, "%" G_GINT64_FORMAT, (gint64) lag);
EMIT_SIGNAL (XP_TE_PINGTIMEOUT, serv->server_session, tbuf, NULL, EMIT_SIGNAL (XP_TE_PINGTIMEOUT, serv->server_session, tbuf, NULL,
@@ -398,11 +400,11 @@ lag_check (void)
} }
else else
{ {
g_snprintf (tbuf, sizeof (tbuf), "LAG%lu", tim); ping_age = now - serv->ping_recv;
serv->p_ping (serv, "", tbuf); if (!serv->lag_sent && prefs.hex_net_lag_check > 0 && ping_age >= prefs.hex_net_lag_check)
if (!serv->lag_sent)
{ {
g_snprintf (tbuf, sizeof (tbuf), "LAG%lu", tim);
serv->p_ping (serv, "", tbuf);
serv->lag_sent = tim; serv->lag_sent = tim;
fe_set_lag (serv, -1); fe_set_lag (serv, -1);
} }
@@ -525,7 +527,7 @@ zoitechat_reinit_timers (void)
if ((prefs.hex_net_ping_timeout != 0 || prefs.hex_gui_lagometer) if ((prefs.hex_net_ping_timeout != 0 || prefs.hex_gui_lagometer)
&& lag_check_tag == 0) && lag_check_tag == 0)
{ {
lag_check_tag = fe_timeout_add_seconds (30, zoitechat_lag_check, NULL); lag_check_tag = fe_timeout_add_seconds (1, zoitechat_lag_check, NULL);
} }
else if ((!prefs.hex_net_ping_timeout && !prefs.hex_gui_lagometer) else if ((!prefs.hex_net_ping_timeout && !prefs.hex_gui_lagometer)
&& lag_check_tag != 0) && lag_check_tag != 0)
@@ -960,6 +962,8 @@ xchat_init (void)
sound_load (); sound_load ();
notify_load (); notify_load ();
ignore_load (); ignore_load ();
if (prefs.hex_net_upnp)
upnp_init ();
sts_init (); sts_init ();
g_snprintf (buf, sizeof (buf), g_snprintf (buf, sizeof (buf),

View File

@@ -202,6 +202,7 @@ struct zoitechatprefs
unsigned int hex_net_auto_reconnectonfail; unsigned int hex_net_auto_reconnectonfail;
unsigned int hex_net_proxy_auth; unsigned int hex_net_proxy_auth;
unsigned int hex_net_throttle; unsigned int hex_net_throttle;
unsigned int hex_net_upnp;
unsigned int hex_notify_whois_online; unsigned int hex_notify_whois_online;
unsigned int hex_perl_warnings; unsigned int hex_perl_warnings;
unsigned int hex_stamp_log; unsigned int hex_stamp_log;
@@ -267,6 +268,7 @@ struct zoitechatprefs
int hex_gui_tab_layout; int hex_gui_tab_layout;
int hex_gui_tab_closebuttons; int hex_gui_tab_closebuttons;
int hex_gui_tab_middleclose; int hex_gui_tab_middleclose;
int hex_gui_mouse_scroll_speed;
int hex_gui_tab_newtofront; int hex_gui_tab_newtofront;
int hex_gui_tab_pos; int hex_gui_tab_pos;
int hex_gui_tab_small; int hex_gui_tab_small;
@@ -289,6 +291,10 @@ struct zoitechatprefs
int hex_irc_join_delay; int hex_irc_join_delay;
int hex_irc_notice_pos; int hex_irc_notice_pos;
int hex_net_ping_timeout; int hex_net_ping_timeout;
int hex_net_lag_check;
int hex_net_keepalive_idle;
int hex_net_keepalive_interval;
int hex_net_keepalive_count;
int hex_net_proxy_port; int hex_net_proxy_port;
int hex_net_proxy_type; /* 0=disabled, 1=wingate 2=socks4, 3=socks5, 4=http */ int hex_net_proxy_type; /* 0=disabled, 1=wingate 2=socks4, 3=socks5, 4=http */
int hex_net_proxy_use; /* 0=all 1=IRC_ONLY 2=DCC_ONLY */ int hex_net_proxy_use; /* 0=all 1=IRC_ONLY 2=DCC_ONLY */

View File

@@ -305,12 +305,14 @@ static gboolean
tab_scroll_cb (GtkWidget *widget, GdkEventScroll *event, gpointer cv) tab_scroll_cb (GtkWidget *widget, GdkEventScroll *event, gpointer cv)
{ {
int direction = cv_scroll_direction (event); int direction = cv_scroll_direction (event);
int i;
if (prefs.hex_gui_tab_scrollchans) if (prefs.hex_gui_tab_scrollchans)
{ {
if (direction != 0) if (direction != 0)
{ {
mg_switch_page (1, direction); for (i = 0; i < cv_scroll_step_count (); i++)
mg_switch_page (1, direction);
return TRUE; return TRUE;
} }
} }
@@ -318,12 +320,14 @@ tab_scroll_cb (GtkWidget *widget, GdkEventScroll *event, gpointer cv)
{ {
if (direction < 0) if (direction < 0)
{ {
tab_scroll_left_up_clicked (widget, cv); for (i = 0; i < cv_scroll_step_count (); i++)
tab_scroll_left_up_clicked (widget, cv);
return TRUE; return TRUE;
} }
else if (direction > 0) else if (direction > 0)
{ {
tab_scroll_right_down_clicked (widget, cv); for (i = 0; i < cv_scroll_step_count (); i++)
tab_scroll_right_down_clicked (widget, cv);
return TRUE; return TRUE;
} }
} }

View File

@@ -112,9 +112,11 @@ cv_tree_scroll_event_cb (GtkWidget *widget, GdkEventScroll *event, gpointer user
if (prefs.hex_gui_tab_scrollchans) if (prefs.hex_gui_tab_scrollchans)
{ {
int direction = cv_scroll_direction (event); int direction = cv_scroll_direction (event);
int i;
if (direction != 0) if (direction != 0)
mg_switch_page (1, direction); for (i = 0; i < cv_scroll_step_count (); i++)
mg_switch_page (1, direction);
return direction != 0; return direction != 0;
} }

View File

@@ -126,6 +126,15 @@ cv_scroll_direction (GdkEventScroll *event)
} }
} }
static int
cv_scroll_step_count (void)
{
int speed = prefs.hex_gui_mouse_scroll_speed;
if (speed < 1)
speed = 1;
return (speed + 9) / 10;
}
/* ======= TABS ======= */ /* ======= TABS ======= */

View File

@@ -193,6 +193,7 @@ static const setting appearance_advanced_settings[] =
{ST_HEADER, N_("Advanced"),0,0,0}, {ST_HEADER, N_("Advanced"),0,0,0},
{ST_EFILE, N_ ("Background image:"), P_OFFSETNL (hex_text_background), 0, 0, sizeof prefs.hex_text_background}, {ST_EFILE, N_ ("Background image:"), P_OFFSETNL (hex_text_background), 0, 0, sizeof prefs.hex_text_background},
{ST_HSCALE, N_("Window opacity:"), P_OFFINTNL(hex_gui_transparency),0,0,0}, {ST_HSCALE, N_("Window opacity:"), P_OFFINTNL(hex_gui_transparency),0,0,0},
{ST_HSCALE, N_("Mouse wheel scroll speed (Slower ← → Faster):"), P_OFFINTNL(hex_gui_mouse_scroll_speed), 0, 0, 100},
{ST_END, 0, 0, 0, 0, 0} {ST_END, 0, 0, 0, 0, 0}
}; };
@@ -582,6 +583,7 @@ static const setting advanced_settings[] =
{ST_TOGGLE, N_("Display lists in compact mode"), P_OFFINTNL(hex_gui_compact), N_("Use less spacing between user list/channel tree rows."), 0, 0}, {ST_TOGGLE, N_("Display lists in compact mode"), P_OFFINTNL(hex_gui_compact), N_("Use less spacing between user list/channel tree rows."), 0, 0},
{ST_TOGGLE, N_("Use server time if supported"), P_OFFINTNL(hex_irc_cap_server_time), N_("Display timestamps obtained from server if it supports the time-server extension."), 0, 0}, {ST_TOGGLE, N_("Use server time if supported"), P_OFFINTNL(hex_irc_cap_server_time), N_("Display timestamps obtained from server if it supports the time-server extension."), 0, 0},
{ST_TOGGLE, N_("Automatically reconnect to servers on disconnect"), P_OFFINTNL(hex_net_auto_reconnect), 0, 0, 1}, {ST_TOGGLE, N_("Automatically reconnect to servers on disconnect"), P_OFFINTNL(hex_net_auto_reconnect), 0, 0, 1},
{ST_NUMBER, N_("Lag check interval:"), P_OFFINTNL(hex_net_lag_check), 0, (const char **)N_("seconds."), 9999},
{ST_NUMBER, N_("Auto reconnect delay:"), P_OFFINTNL(hex_net_reconnect_delay), 0, 0, 9999}, {ST_NUMBER, N_("Auto reconnect delay:"), P_OFFINTNL(hex_net_reconnect_delay), 0, 0, 9999},
{ST_NUMBER, N_("Auto join delay:"), P_OFFINTNL(hex_irc_join_delay), 0, 0, 9999}, {ST_NUMBER, N_("Auto join delay:"), P_OFFINTNL(hex_irc_join_delay), 0, 0, 9999},
{ST_MENU, N_("Ban Type:"), P_OFFINTNL(hex_irc_ban_type), N_("Attempt to use this banmask when banning or quieting. (requires irc_who_join)"), bantypemenu, 0}, {ST_MENU, N_("Ban Type:"), P_OFFINTNL(hex_irc_ban_type), N_("Attempt to use this banmask when banning or quieting. (requires irc_who_join)"), bantypemenu, 0},
@@ -648,13 +650,18 @@ static const setting network_settings[] =
{ST_NUMBER, N_("First DCC listen port:"), P_OFFINTNL(hex_dcc_port_first), 0, 0, 65535}, {ST_NUMBER, N_("First DCC listen port:"), P_OFFINTNL(hex_dcc_port_first), 0, 0, 65535},
{ST_NUMBER, N_("Last DCC listen port:"), P_OFFINTNL(hex_dcc_port_last), 0, {ST_NUMBER, N_("Last DCC listen port:"), P_OFFINTNL(hex_dcc_port_last), 0,
(const char **)N_("!Leave ports at zero for full range."), 65535}, (const char **)N_("!Leave ports at zero for full range."), 65535},
{ST_TOGGLE, N_("Enable UPnP port mapping for DCC"), P_OFFINTNL(hex_net_upnp), 0, 0, 0},
{ST_HEADER, N_("Proxy Server"), 0, 0, 0, 0}, {ST_HEADER, N_("Proxy Server"), 0, 0, 0, 0},
{ST_ENTRY, N_("Hostname:"), P_OFFSETNL(hex_net_proxy_host), 0, 0, sizeof prefs.hex_net_proxy_host}, {ST_ENTRY, N_("Hostname:"), P_OFFSETNL(hex_net_proxy_host), 0, 0, sizeof prefs.hex_net_proxy_host},
{ST_NUMBER, N_("Port:"), P_OFFINTNL(hex_net_proxy_port), 0, 0, 65535}, {ST_NUMBER, N_("Port:"), P_OFFINTNL(hex_net_proxy_port), 0, 0, 65535},
{ST_MENU, N_("Type:"), P_OFFINTNL(hex_net_proxy_type), 0, proxytypes, 0}, {ST_MENU, N_("Type:"), P_OFFINTNL(hex_net_proxy_type), 0, proxytypes, 0},
{ST_MENU, N_("Use proxy for:"), P_OFFINTNL(hex_net_proxy_use), 0, proxyuse, 0}, {ST_MENU, N_("Use proxy for:"), P_OFFINTNL(hex_net_proxy_use), 0, proxyuse, 0},
{ST_HEADER, N_("Connection Health"), 0, 0, 0, 0},
{ST_NUMBER, N_("TCP keepalive idle:"), P_OFFINTNL(hex_net_keepalive_idle), 0, (const char **)N_("seconds."), 7200},
{ST_NUMBER, N_("TCP keepalive interval:"), P_OFFINTNL(hex_net_keepalive_interval), 0, (const char **)N_("seconds."), 600},
{ST_NUMBER, N_("TCP keepalive probes:"), P_OFFINTNL(hex_net_keepalive_count), 0, 0, 20},
{ST_HEADER, N_("Proxy Authentication"), 0, 0, 0, 0}, {ST_HEADER, N_("Proxy Authentication"), 0, 0, 0, 0},
{ST_TOGGLE, N_("Use authentication (HTTP or SOCKS5 only)"), P_OFFINTNL(hex_net_proxy_auth), 0, 0, 0}, {ST_TOGGLE, N_("Use authentication (HTTP or SOCKS5 only)"), P_OFFINTNL(hex_net_proxy_auth), 0, 0, 0},
{ST_ENTRY, N_("Username:"), P_OFFSETNL(hex_net_proxy_user), 0, 0, sizeof prefs.hex_net_proxy_user}, {ST_ENTRY, N_("Username:"), P_OFFSETNL(hex_net_proxy_user), 0, 0, sizeof prefs.hex_net_proxy_user},

View File

@@ -2938,19 +2938,41 @@ gtk_xtext_scroll (GtkWidget *widget, GdkEventScroll *event)
{ {
GtkXText *xtext = GTK_XTEXT (widget); GtkXText *xtext = GTK_XTEXT (widget);
gfloat new_value; gfloat new_value;
gfloat step;
gdouble dx;
gdouble dy;
int direction = 0;
int speed = prefs.hex_gui_mouse_scroll_speed;
if (event->direction == GDK_SCROLL_UP) /* mouse wheel pageUp */ if (speed < 1)
speed = 1;
step = (xtext_adj_get_page_increment (xtext->adj) * speed) / 100.0f;
if (event->direction == GDK_SCROLL_SMOOTH &&
gdk_event_get_scroll_deltas ((GdkEvent *)event, &dx, &dy))
{
if (dy > 0)
direction = 1;
else if (dy < 0)
direction = -1;
}
else if (event->direction == GDK_SCROLL_UP)
direction = -1;
else if (event->direction == GDK_SCROLL_DOWN)
direction = 1;
if (direction < 0)
{ {
new_value = xtext_adj_get_value (xtext->adj) - new_value = xtext_adj_get_value (xtext->adj) -
(xtext_adj_get_page_increment (xtext->adj) / 10); step;
if (new_value < xtext_adj_get_lower (xtext->adj)) if (new_value < xtext_adj_get_lower (xtext->adj))
new_value = xtext_adj_get_lower (xtext->adj); new_value = xtext_adj_get_lower (xtext->adj);
xtext_adj_set_value (xtext->adj, new_value); xtext_adj_set_value (xtext->adj, new_value);
} }
else if (event->direction == GDK_SCROLL_DOWN) /* mouse wheel pageDn */ else if (direction > 0)
{ {
new_value = xtext_adj_get_value (xtext->adj) + new_value = xtext_adj_get_value (xtext->adj) +
(xtext_adj_get_page_increment (xtext->adj) / 10); step;
if (new_value > (xtext_adj_get_upper (xtext->adj) - if (new_value > (xtext_adj_get_upper (xtext->adj) -
xtext_adj_get_page_size (xtext->adj))) xtext_adj_get_page_size (xtext->adj)))
new_value = xtext_adj_get_upper (xtext->adj) - new_value = xtext_adj_get_upper (xtext->adj) -
@@ -2958,7 +2980,7 @@ gtk_xtext_scroll (GtkWidget *widget, GdkEventScroll *event)
xtext_adj_set_value (xtext->adj, new_value); xtext_adj_set_value (xtext->adj, new_value);
} }
return FALSE; return direction != 0;
} }
static void static void