mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-06-14 18:50:19 +00:00
Compare commits
5 Commits
bede379021
...
tray-iconi
| Author | SHA1 | Date | |
|---|---|---|---|
| d1707d3c72 | |||
|
|
c9bed097ba | ||
| 5acb90025f | |||
|
|
2d12da79b0 | ||
| 38acde1b20 |
@@ -304,29 +304,24 @@ dcc_check_timeouts (void)
|
||||
static int
|
||||
dcc_lookup_proxy (char *host, struct sockaddr_in *addr)
|
||||
{
|
||||
struct hostent *h;
|
||||
static char *cache_host = NULL;
|
||||
static guint32 cache_addr;
|
||||
|
||||
/* too lazy to thread this, so we cache results */
|
||||
if (cache_host)
|
||||
{
|
||||
if (strcmp (host, cache_host) == 0)
|
||||
{
|
||||
memcpy (&addr->sin_addr, &cache_addr, 4);
|
||||
addr->sin_addr.s_addr = cache_addr;
|
||||
return TRUE;
|
||||
}
|
||||
g_free (cache_host);
|
||||
cache_host = NULL;
|
||||
}
|
||||
|
||||
h = gethostbyname (host);
|
||||
if (h != NULL && h->h_length == 4 && h->h_addr_list[0] != NULL)
|
||||
if (net_lookup_ipv4 (host, &addr->sin_addr.s_addr))
|
||||
{
|
||||
memcpy (&addr->sin_addr, h->h_addr_list[0], 4);
|
||||
memcpy (&cache_addr, h->h_addr_list[0], 4);
|
||||
cache_addr = addr->sin_addr.s_addr;
|
||||
cache_host = g_strdup (host);
|
||||
/* cppcheck-suppress memleak */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1614,25 +1609,14 @@ dcc_accept (GIOChannel *source, GIOCondition condition, struct DCC *dcc)
|
||||
}
|
||||
|
||||
guint32
|
||||
dcc_get_my_address (session *sess) /* the address we'll tell the other person */
|
||||
dcc_get_my_address (session *sess)
|
||||
{
|
||||
struct hostent *dns_query;
|
||||
guint32 addr = 0;
|
||||
|
||||
if (prefs.hex_dcc_ip_from_server && sess->server->dcc_ip)
|
||||
addr = sess->server->dcc_ip;
|
||||
else if (prefs.hex_dcc_ip[0])
|
||||
{
|
||||
dns_query = gethostbyname ((const char *) prefs.hex_dcc_ip);
|
||||
|
||||
if (dns_query != NULL &&
|
||||
dns_query->h_length == 4 &&
|
||||
dns_query->h_addr_list[0] != NULL)
|
||||
{
|
||||
/*we're offered at least one IPv4 address: we take the first*/
|
||||
addr = *((guint32*) dns_query->h_addr_list[0]);
|
||||
}
|
||||
}
|
||||
net_lookup_ipv4 ((const char *) prefs.hex_dcc_ip, &addr);
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "ignore.h"
|
||||
#include "fe.h"
|
||||
#include "modes.h"
|
||||
#include "network.h"
|
||||
#include "notify.h"
|
||||
#include "outbound.h"
|
||||
#include "inbound.h"
|
||||
@@ -1476,14 +1477,13 @@ inbound_uback (server *serv, const message_tags_data *tags_data)
|
||||
void
|
||||
inbound_foundip (session *sess, char *ip, const message_tags_data *tags_data)
|
||||
{
|
||||
struct hostent *HostAddr;
|
||||
struct in_addr addr;
|
||||
|
||||
HostAddr = gethostbyname (ip);
|
||||
if (HostAddr)
|
||||
if (net_lookup_ipv4 (ip, &addr.s_addr))
|
||||
{
|
||||
sess->server->dcc_ip = ((struct in_addr *) HostAddr->h_addr_list[0])->s_addr;
|
||||
sess->server->dcc_ip = addr.s_addr;
|
||||
EMIT_SIGNAL_TIMESTAMP (XP_TE_FOUNDIP, sess->server->server_session,
|
||||
inet_ntoa (*((struct in_addr *) HostAddr->h_addr_list[0])),
|
||||
inet_ntoa (addr),
|
||||
NULL, NULL, NULL, 0, tags_data->timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +96,30 @@ net_ip (uint32_t addr)
|
||||
return inet_ntoa (ia);
|
||||
}
|
||||
|
||||
int
|
||||
net_lookup_ipv4 (const char *hostname, uint32_t *addr)
|
||||
{
|
||||
struct addrinfo hints;
|
||||
struct addrinfo *res;
|
||||
struct sockaddr_in *sin;
|
||||
int ret;
|
||||
|
||||
memset (&hints, 0, sizeof (hints));
|
||||
hints.ai_family = AF_INET;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_flags = AI_ADDRCONFIG;
|
||||
|
||||
ret = getaddrinfo (hostname, NULL, &hints, &res);
|
||||
if (ret != 0)
|
||||
return FALSE;
|
||||
|
||||
sin = (struct sockaddr_in *) res->ai_addr;
|
||||
*addr = sin->sin_addr.s_addr;
|
||||
freeaddrinfo (res);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
net_store_destroy (netstore * ns)
|
||||
{
|
||||
|
||||
@@ -39,6 +39,7 @@ int net_connect (netstore *ns, int sok4, int sok6, int *sok_return);
|
||||
char *net_resolve (netstore *ns, char *hostname, int port, char **real_host);
|
||||
void net_bind (netstore *tobindto, int sok4, int sok6);
|
||||
char *net_ip (uint32_t addr);
|
||||
int net_lookup_ipv4 (const char *hostname, uint32_t *addr);
|
||||
void net_sockets (int *sok4, int *sok6);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -881,7 +881,7 @@ server_read_child (GIOChannel *source, GIOCondition condition, server *serv)
|
||||
if (prefs.hex_net_auto_reconnectonfail)
|
||||
auto_reconnect (serv, FALSE, -1);
|
||||
break;
|
||||
case '3': /* gethostbyname finished */
|
||||
case '3': /* resolver finished */
|
||||
waitline2 (source, host, sizeof host);
|
||||
waitline2 (source, ip, sizeof ip);
|
||||
waitline2 (source, outbuf, sizeof outbuf);
|
||||
@@ -932,7 +932,7 @@ server_read_child (GIOChannel *source, GIOCondition condition, server *serv)
|
||||
waitline2 (source, tbuf, sizeof tbuf);
|
||||
prefs.local_ip = inet_addr (tbuf);
|
||||
break;
|
||||
case '7': /* gethostbyname (prefs.hex_net_bind_host) failed */
|
||||
case '7': /* prefs.hex_net_bind_host resolve failed */
|
||||
sprintf (outbuf,
|
||||
_("Cannot resolve hostname %s\nCheck your IP Settings!\n"),
|
||||
prefs.hex_net_bind_host);
|
||||
|
||||
@@ -855,6 +855,7 @@ tray_toggle_visibility (gboolean force_hide)
|
||||
static int maximized;
|
||||
static int fullscreen;
|
||||
GtkWindow *win;
|
||||
WinStatus status;
|
||||
|
||||
if (!tray_backend_active)
|
||||
return FALSE;
|
||||
@@ -870,7 +871,9 @@ tray_toggle_visibility (gboolean force_hide)
|
||||
if (!win)
|
||||
return FALSE;
|
||||
|
||||
if (force_hide || gtk_widget_get_visible (GTK_WIDGET (win)))
|
||||
status = tray_get_window_status ();
|
||||
|
||||
if (force_hide || status != WS_HIDDEN)
|
||||
{
|
||||
if (prefs.hex_gui_tray_away)
|
||||
zoitechat_command (ph, "ALLSERV AWAY");
|
||||
@@ -890,8 +893,8 @@ tray_toggle_visibility (gboolean force_hide)
|
||||
gtk_window_maximize (win);
|
||||
if (fullscreen)
|
||||
gtk_window_fullscreen (win);
|
||||
gtk_widget_show (GTK_WIDGET (win));
|
||||
gtk_window_deiconify (win);
|
||||
gtk_widget_show (GTK_WIDGET (win));
|
||||
gtk_window_present (win);
|
||||
}
|
||||
|
||||
|
||||
@@ -107,12 +107,23 @@ theme_manager_reset_mode_colors (unsigned int mode, gboolean *palette_changed)
|
||||
*palette_changed = FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
theme_runtime_clear_gtk_mapped_custom_tokens (void)
|
||||
{
|
||||
}
|
||||
|
||||
gboolean
|
||||
theme_manager_save_preferences (void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
theme_manager_apply_to_window (GtkWidget *window)
|
||||
{
|
||||
(void)window;
|
||||
}
|
||||
|
||||
void
|
||||
theme_manager_dispatch_changed (ThemeChangedReason reasons)
|
||||
{
|
||||
|
||||
@@ -88,9 +88,15 @@ theme_application_apply_toplevel_theme (gboolean dark)
|
||||
gboolean
|
||||
theme_application_apply_mode (unsigned int mode, gboolean *palette_changed)
|
||||
{
|
||||
static gboolean runtime_loaded = FALSE;
|
||||
gboolean dark;
|
||||
|
||||
theme_runtime_load ();
|
||||
if (!runtime_loaded)
|
||||
{
|
||||
theme_runtime_load ();
|
||||
runtime_loaded = TRUE;
|
||||
}
|
||||
|
||||
dark = theme_runtime_apply_mode (mode, palette_changed);
|
||||
theme_application_apply_toplevel_theme (dark);
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "theme-gtk3.h"
|
||||
#include "theme-manager.h"
|
||||
#include "theme-preferences.h"
|
||||
#include "theme-runtime.h"
|
||||
|
||||
extern void load_text_events (void);
|
||||
|
||||
@@ -1417,17 +1418,56 @@ theme_preferences_gtk3_sync_remove_state (theme_preferences_ui *ui)
|
||||
gtk_widget_set_sensitive (ui->gtk3_remove, source == ZOITECHAT_GTK3_THEME_SOURCE_USER);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
theme_preferences_gtk3_apply_and_refresh (GError **error)
|
||||
static void
|
||||
theme_preferences_gtk3_sync_runtime_palette (theme_preferences_ui *ui)
|
||||
{
|
||||
if (!theme_gtk3_apply_current (error))
|
||||
return FALSE;
|
||||
theme_manager_dispatch_changed (THEME_CHANGED_REASON_THEME_PACK |
|
||||
THEME_CHANGED_REASON_PALETTE |
|
||||
THEME_CHANGED_REASON_WIDGET_STYLE |
|
||||
THEME_CHANGED_REASON_USERLIST |
|
||||
THEME_CHANGED_REASON_MODE);
|
||||
return TRUE;
|
||||
ThemeWidgetStyleValues style_values;
|
||||
GtkWidget *style_source = NULL;
|
||||
|
||||
if (ui && ui->parent)
|
||||
style_source = GTK_WIDGET (ui->parent);
|
||||
else if (ui && ui->gtk3_combo)
|
||||
style_source = ui->gtk3_combo;
|
||||
|
||||
theme_runtime_clear_gtk_mapped_custom_tokens ();
|
||||
|
||||
theme_get_widget_style_values_for_widget (style_source, &style_values);
|
||||
|
||||
theme_preferences_staged_set_color (THEME_TOKEN_TEXT_FOREGROUND,
|
||||
&style_values.foreground,
|
||||
NULL,
|
||||
TRUE);
|
||||
theme_preferences_staged_set_color (THEME_TOKEN_TEXT_BACKGROUND,
|
||||
&style_values.background,
|
||||
NULL,
|
||||
TRUE);
|
||||
theme_preferences_staged_set_color (THEME_TOKEN_SELECTION_FOREGROUND,
|
||||
&style_values.selection_foreground,
|
||||
NULL,
|
||||
TRUE);
|
||||
theme_preferences_staged_set_color (THEME_TOKEN_SELECTION_BACKGROUND,
|
||||
&style_values.selection_background,
|
||||
NULL,
|
||||
TRUE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
theme_preferences_gtk3_apply_and_refresh (theme_preferences_ui *ui, GError **error)
|
||||
{
|
||||
if (!theme_gtk3_apply_current (error))
|
||||
return FALSE;
|
||||
|
||||
if (ui && ui->parent)
|
||||
theme_manager_apply_to_window (GTK_WIDGET (ui->parent));
|
||||
|
||||
theme_preferences_gtk3_sync_runtime_palette (ui);
|
||||
|
||||
theme_manager_dispatch_changed (THEME_CHANGED_REASON_THEME_PACK |
|
||||
THEME_CHANGED_REASON_PALETTE |
|
||||
THEME_CHANGED_REASON_WIDGET_STYLE |
|
||||
THEME_CHANGED_REASON_USERLIST |
|
||||
THEME_CHANGED_REASON_MODE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1463,7 +1503,7 @@ theme_preferences_gtk3_changed_cb (GtkComboBox *combo, gpointer user_data)
|
||||
ui->setup_prefs->hex_gui_gtk3_variant = prefs.hex_gui_gtk3_variant;
|
||||
}
|
||||
|
||||
if (selection_changed && !theme_preferences_gtk3_apply_and_refresh (&error))
|
||||
if (selection_changed && !theme_preferences_gtk3_apply_and_refresh (ui, &error))
|
||||
{
|
||||
theme_preferences_show_message (ui, GTK_MESSAGE_ERROR,
|
||||
error ? error->message : _("Failed to apply GTK3 theme."));
|
||||
@@ -1552,7 +1592,7 @@ theme_preferences_populate_gtk3 (theme_preferences_ui *ui)
|
||||
g_free (final_id);
|
||||
}
|
||||
|
||||
if (should_apply && !theme_preferences_gtk3_apply_and_refresh (&error))
|
||||
if (should_apply && !theme_preferences_gtk3_apply_and_refresh (ui, &error))
|
||||
{
|
||||
theme_preferences_show_message (ui, GTK_MESSAGE_ERROR,
|
||||
error ? error->message : _("Failed to apply GTK3 theme."));
|
||||
|
||||
@@ -410,6 +410,20 @@ theme_runtime_reset_mode_colors (gboolean dark_mode)
|
||||
dark_mode_active = FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
theme_runtime_clear_gtk_mapped_custom_tokens (void)
|
||||
{
|
||||
light_custom_tokens[THEME_TOKEN_TEXT_FOREGROUND] = FALSE;
|
||||
light_custom_tokens[THEME_TOKEN_TEXT_BACKGROUND] = FALSE;
|
||||
light_custom_tokens[THEME_TOKEN_SELECTION_FOREGROUND] = FALSE;
|
||||
light_custom_tokens[THEME_TOKEN_SELECTION_BACKGROUND] = FALSE;
|
||||
|
||||
dark_custom_tokens[THEME_TOKEN_TEXT_FOREGROUND] = FALSE;
|
||||
dark_custom_tokens[THEME_TOKEN_TEXT_BACKGROUND] = FALSE;
|
||||
dark_custom_tokens[THEME_TOKEN_SELECTION_FOREGROUND] = FALSE;
|
||||
dark_custom_tokens[THEME_TOKEN_SELECTION_BACKGROUND] = FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
theme_runtime_load (void)
|
||||
{
|
||||
|
||||
@@ -47,6 +47,7 @@ gboolean theme_runtime_apply_dark_mode (gboolean enable);
|
||||
void theme_runtime_user_set_color (ThemeSemanticToken token, const GdkRGBA *col);
|
||||
void theme_runtime_dark_set_color (ThemeSemanticToken token, const GdkRGBA *col);
|
||||
void theme_runtime_reset_mode_colors (gboolean dark_mode);
|
||||
void theme_runtime_clear_gtk_mapped_custom_tokens (void);
|
||||
gboolean theme_runtime_get_color (ThemeSemanticToken token, GdkRGBA *out_rgba);
|
||||
gboolean theme_runtime_mode_has_user_colors (gboolean dark_mode);
|
||||
void theme_runtime_get_widget_style_values (ThemeWidgetStyleValues *out_values);
|
||||
|
||||
Reference in New Issue
Block a user