mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-03-14 09:40:20 +00:00
Merge pull request #104 from ZoiteChat/bug-fixes-pre3-prep
Merge color-changer: import colors.conf, fix userlist/GTK3 tabs, embed SVG icon, clean GTK/OpenSSL warnings.
This commit is contained in:
@@ -59,7 +59,9 @@ struct DCC
|
||||
int resume_error;
|
||||
int resume_errno;
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
GTimeVal lastcpstv, firstcpstv;
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
goffset lastcpspos;
|
||||
gint64 maxcps;
|
||||
|
||||
|
||||
@@ -22,8 +22,13 @@
|
||||
#include <glib/gstdio.h>
|
||||
#include <gio/gio.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef G_OS_WIN32
|
||||
extern char *realpath (const char *path, char *resolved_path);
|
||||
#endif
|
||||
|
||||
#include "util.h"
|
||||
#include "cfgfiles.h"
|
||||
|
||||
@@ -55,6 +60,7 @@ remove_tree (const char *path)
|
||||
g_rmdir (path);
|
||||
}
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
static gboolean
|
||||
path_tree_has_entries (const char *path)
|
||||
{
|
||||
@@ -86,6 +92,7 @@ path_tree_has_entries (const char *path)
|
||||
g_dir_close (dir);
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
static gboolean
|
||||
gtk3_css_dir_parse_minor (const char *name, gint *minor)
|
||||
@@ -492,6 +499,49 @@ discover_dir (GPtrArray *themes, GHashTable *seen_theme_roots, const char *base_
|
||||
}
|
||||
|
||||
|
||||
|
||||
static char *
|
||||
path_canonicalize_compat (const char *path)
|
||||
{
|
||||
char *absolute_path;
|
||||
char *cwd;
|
||||
char *resolved;
|
||||
|
||||
if (!path || path[0] == '\0')
|
||||
return NULL;
|
||||
|
||||
if (g_path_is_absolute (path))
|
||||
absolute_path = g_strdup (path);
|
||||
else
|
||||
{
|
||||
cwd = g_get_current_dir ();
|
||||
absolute_path = g_build_filename (cwd, path, NULL);
|
||||
g_free (cwd);
|
||||
}
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
resolved = _fullpath (NULL, absolute_path, 0);
|
||||
if (resolved)
|
||||
{
|
||||
char *copy = g_strdup (resolved);
|
||||
free (resolved);
|
||||
g_free (absolute_path);
|
||||
return copy;
|
||||
}
|
||||
#else
|
||||
resolved = realpath (absolute_path, NULL);
|
||||
if (resolved)
|
||||
{
|
||||
char *copy = g_strdup (resolved);
|
||||
free (resolved);
|
||||
g_free (absolute_path);
|
||||
return copy;
|
||||
}
|
||||
#endif
|
||||
|
||||
return absolute_path;
|
||||
}
|
||||
|
||||
static char *
|
||||
path_normalize_theme_root (const char *path)
|
||||
{
|
||||
@@ -501,7 +551,7 @@ path_normalize_theme_root (const char *path)
|
||||
if (!path || path[0] == '\0')
|
||||
return NULL;
|
||||
|
||||
canonical = g_canonicalize_filename (path, NULL);
|
||||
canonical = path_canonicalize_compat (path);
|
||||
target = g_file_read_link (canonical, NULL);
|
||||
if (target && target[0])
|
||||
{
|
||||
@@ -510,7 +560,7 @@ path_normalize_theme_root (const char *path)
|
||||
? g_strdup (target)
|
||||
: g_build_filename (base, target, NULL);
|
||||
g_free (canonical);
|
||||
canonical = g_canonicalize_filename (resolved, NULL);
|
||||
canonical = path_canonicalize_compat (resolved);
|
||||
g_free (resolved);
|
||||
g_free (base);
|
||||
}
|
||||
@@ -534,7 +584,7 @@ add_theme_root (GPtrArray *roots, GHashTable *seen, const char *path)
|
||||
if (!path || path[0] == '\0')
|
||||
return;
|
||||
|
||||
normalized = g_canonicalize_filename (path, NULL);
|
||||
normalized = path_canonicalize_compat (path);
|
||||
if (g_hash_table_contains (seen, normalized))
|
||||
{
|
||||
g_free (normalized);
|
||||
@@ -739,6 +789,51 @@ select_theme_root (GPtrArray *roots, const char *input_root)
|
||||
return selected;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
copy_css_file (const char *src, const char *dest, GError **error)
|
||||
{
|
||||
char *contents = NULL;
|
||||
char *normalized;
|
||||
gsize len = 0;
|
||||
GRegex *regex;
|
||||
|
||||
if (!g_file_get_contents (src, &contents, &len, error))
|
||||
return FALSE;
|
||||
|
||||
if (!g_strstr_len (contents, len, ":insensitive"))
|
||||
{
|
||||
gboolean ok = g_file_set_contents (dest, contents, len, error);
|
||||
g_free (contents);
|
||||
return ok;
|
||||
}
|
||||
|
||||
regex = g_regex_new (":insensitive", 0, 0, error);
|
||||
if (!regex)
|
||||
{
|
||||
g_free (contents);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
normalized = g_regex_replace_literal (regex, contents, -1, 0, ":disabled", 0, error);
|
||||
g_regex_unref (regex);
|
||||
if (!normalized)
|
||||
{
|
||||
g_free (contents);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!g_file_set_contents (dest, normalized, -1, error))
|
||||
{
|
||||
g_free (normalized);
|
||||
g_free (contents);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_free (normalized);
|
||||
g_free (contents);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
copy_tree (const char *src, const char *dest, GError **error)
|
||||
{
|
||||
@@ -768,19 +863,32 @@ copy_tree (const char *src, const char *dest, GError **error)
|
||||
}
|
||||
else
|
||||
{
|
||||
GFile *sf = g_file_new_for_path (s);
|
||||
GFile *df = g_file_new_for_path (d);
|
||||
if (!g_file_copy (sf, df, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, error))
|
||||
if (g_str_has_suffix (name, ".css"))
|
||||
{
|
||||
if (!copy_css_file (s, d, error))
|
||||
{
|
||||
g_free (s);
|
||||
g_free (d);
|
||||
g_dir_close (dir);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GFile *sf = g_file_new_for_path (s);
|
||||
GFile *df = g_file_new_for_path (d);
|
||||
if (!g_file_copy (sf, df, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, error))
|
||||
{
|
||||
g_object_unref (sf);
|
||||
g_object_unref (df);
|
||||
g_free (s);
|
||||
g_free (d);
|
||||
g_dir_close (dir);
|
||||
return FALSE;
|
||||
}
|
||||
g_object_unref (sf);
|
||||
g_object_unref (df);
|
||||
g_free (s);
|
||||
g_free (d);
|
||||
g_dir_close (dir);
|
||||
return FALSE;
|
||||
}
|
||||
g_object_unref (sf);
|
||||
g_object_unref (df);
|
||||
}
|
||||
g_free (s);
|
||||
g_free (d);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef ZOITECHAT_GTK3_THEME_SERVICE_H
|
||||
#define ZOITECHAT_GTK3_THEME_SERVICE_H
|
||||
|
||||
#include <glib.h>
|
||||
#include "zoitechat.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
||||
@@ -694,17 +694,29 @@ conn_fail:
|
||||
} else
|
||||
{
|
||||
SSL_SESSION *session = SSL_get_session (serv->ssl);
|
||||
if (session && SSL_SESSION_get_time (session) + SSLTMOUT < time (NULL))
|
||||
if (session)
|
||||
{
|
||||
g_snprintf (buf, sizeof (buf), "SSL handshake timed out");
|
||||
EMIT_SIGNAL (XP_TE_CONNFAIL, serv->server_session, buf, NULL,
|
||||
time_t session_time = 0;
|
||||
gboolean handshake_timed_out = FALSE;
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x30400000L
|
||||
session_time = (time_t) SSL_SESSION_get_time_ex (session);
|
||||
#else
|
||||
session_time = SSL_SESSION_get_time (session);
|
||||
#endif
|
||||
handshake_timed_out = session_time + SSLTMOUT < time (NULL);
|
||||
if (handshake_timed_out)
|
||||
{
|
||||
g_snprintf (buf, sizeof (buf), "SSL handshake timed out");
|
||||
EMIT_SIGNAL (XP_TE_CONNFAIL, serv->server_session, buf, NULL,
|
||||
NULL, NULL, 0);
|
||||
server_cleanup (serv); /* ->connecting = FALSE */
|
||||
server_cleanup (serv); /* ->connecting = FALSE */
|
||||
|
||||
if (prefs.hex_net_auto_reconnectonfail)
|
||||
auto_reconnect (serv, FALSE, -1);
|
||||
if (prefs.hex_net_auto_reconnectonfail)
|
||||
auto_reconnect (serv, FALSE, -1);
|
||||
|
||||
return (0); /* remove it (0) */
|
||||
return (0); /* remove it (0) */
|
||||
}
|
||||
}
|
||||
|
||||
return (1); /* call it more (1) */
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
#include "zoitechat.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
@@ -26,7 +27,6 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "zoitechat.h"
|
||||
#include "cfgfiles.h"
|
||||
#include "util.h"
|
||||
#include "text.h"
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include <glib.h>
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
#include "../zoitechat.h"
|
||||
#include "../gtk3-theme-service.h"
|
||||
#include "../cfgfiles.h"
|
||||
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
char *xdir = NULL;
|
||||
|
||||
char *
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include "zoitechat.h"
|
||||
|
||||
#include <gio/gio.h>
|
||||
#include <glib/gstdio.h>
|
||||
|
||||
#include "cfgfiles.h"
|
||||
#include "zoitechat.h"
|
||||
#include "theme-service.h"
|
||||
|
||||
static zoitechat_theme_post_apply_callback zoitechat_theme_post_apply_cb;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef ZOITECHAT_THEME_SERVICE_H
|
||||
#define ZOITECHAT_THEME_SERVICE_H
|
||||
|
||||
#include <glib.h>
|
||||
#include "zoitechat.h"
|
||||
|
||||
char *zoitechat_theme_service_get_themes_dir (void);
|
||||
GStrv zoitechat_theme_service_discover_themes (void);
|
||||
|
||||
@@ -317,6 +317,7 @@ userlist_change (struct session *sess, char *oldname, char *newname)
|
||||
|
||||
tree_insert (sess->usertree, user);
|
||||
fe_userlist_insert (sess, user, FALSE);
|
||||
fe_userlist_rehash (sess, user);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user