49 Commits

Author SHA1 Message Date
303d5cc581 preparation for upcoming release 2.17.4 2026-02-03 13:28:35 -07:00
deepend-tildeclub
cf2e44f3d5 Refactor Windows build workflow by removing MSYS2 setup
Removed MSYS2 setup and dependency installation steps for GTK build fallback. Updated Python version syntax and adjusted paths for dependencies.
2026-02-01 22:25:20 -07:00
deepend-tildeclub
049d3c19af Add MSYS2 setup and improve dependency installation
Added MSYS2 setup step for GTK build fallback and updated the installation process for dependencies. Enhanced error handling and ensured proper paths for GTK and Lua headers.
2026-02-01 22:24:25 -07:00
deepend-tildeclub
7be145b94a Clarify OpenSSL trust store override and clean up code
Added a comment to clarify the purpose of the OpenSSL trust store override and removed unnecessary code related to GDK_BACKEND configuration.
2026-02-01 16:39:38 -07:00
deepend-tildeclub
e365266b4a Update OpenSSL trust store and GDK_BACKEND settings 2026-02-01 16:37:34 -07:00
deepend-tildeclub
4ad5df0370 Update documentation links in README 2026-01-26 14:15:31 -07:00
deepend-tildeclub
887d891541 Merge pull request #44 from ZoiteChat/glib-dependency-cleanup
Glib dependency cleanup + Makefile
2026-01-26 01:36:54 -07:00
041288cdad Removed the GLib dependency from the Windows 8 spellcheck provider by swapping in Windows/stdlib UTF-8/UTF-16 conversions and standard allocation/free routines. 2026-01-25 23:52:52 -07:00
c8ee118f00 Replaced GLib allocation helpers in history management with standard free/strdup to reduce unnecessary GLib coupling.
Updated the network helper API to use uint32_t and standard allocation/duplication routines, dropping the GLib include from the implementation and adding <stdint.h> to the header.
2026-01-25 23:37:09 -07:00
d4134c94b3 Swapped glib integer types in the sysinfo interface for standard stdint types to remove glib coupling in the header.
Replaced glib string/util usage in the win32 sysinfo backend with local helpers, a small string builder, and Windows UTF-8 conversion, removing the glib dependency there.
2026-01-25 23:32:33 -07:00
5ca3e835a7 Replaced GLib allocation helpers in history management with standard free/strdup to reduce unnecessary GLib coupling.
Updated the network helper API to use uint32_t and standard allocation/duplication routines, dropping the GLib include from the implementation and adding <stdint.h> to the header.
2026-01-25 23:00:20 -07:00
6c85c796d3 Merge branch 'master' of https://github.com/ZoiteChat/zoitechat
sync with master
2026-01-25 19:09:54 -07:00
992215ee91 Fix invalid call to g_io_channel_set_buffered 2026-01-25 19:09:17 -07:00
deepend-tildeclub
4cf1b52982 Merge pull request #42 from ZoiteChat/zoite-sts
IRCv3 STS Specification Support.
2026-01-25 18:48:26 -07:00
bc1d2e5f7a Updated STS upgrade handling to fall back to the current connection port when servers omit a port in the STS capability, enabling TLS upgrades for non-TLS connections in that case. 2026-01-25 18:26:20 -07:00
a0f0c48bc5 Added STS profile persistence and policy parsing/enforcement (including load/save, upgrades, and expiry rescheduling) to the STS module.
Integrated STS capability handling and connection lifecycle hooks (ignore CAP DEL, trigger upgrades, reschedule on disconnect, new server fields).
Initialized and cleaned up STS state during startup/shutdown to persist policies across sessions.
2026-01-25 17:20:53 -07:00
4d6c77704c Added STS profile data structures plus serialize/deserialize helpers for storing profile state in a compact string form.
Registered the new STS source file in the Meson and Visual Studio build definitions.
2026-01-25 16:51:43 -07:00
2b98ebc544 HEXCHAT -> ZOITECHAT 2026-01-25 16:13:47 -07:00
deepend-tildeclub
4ed7032fd5 Update lua.c
Allowed Lua scripts to be located by basename (script name only) when resolving /lua unload and related operations, while keeping path-based matching for explicit paths.
Ensured /lua load reports failures when script creation fails and added explicit failure feedback to the user.
Added unload feedback that distinguishes immediate unloads from deferred unloads, so users see confirmation right away.
2026-01-25 16:02:58 -07:00
deepend-tildeclub
4e01192979 Add badge references to README
Added badge references for GitHub version, downloads, size, last commit, and contributors.
2026-01-25 14:52:49 -07:00
deepend-tildeclub
2127820ae0 Enhance README with build badges and links
Updated README to include build badges and documentation link.
2026-01-25 14:47:08 -07:00
deepend-tildeclub
a40f53a1f3 Add 'standard-replies' to inbound.c
Add support for the standard-replies capability.
2026-01-25 11:09:31 -07:00
deepend-tildeclub
0e661dec95 Delete win32/installer/zoitechat-arm64.iss 2026-01-19 14:43:40 -07:00
deepend-tildeclub
e503bec31a Fix command line argument formatting in installer script 2026-01-19 14:42:57 -07:00
deepend-tildeclub
628bb2e157 Update submodule URL for shared-modules 2026-01-19 13:06:09 -07:00
deepend-tildeclub
afeae7380d Update submodule URL for shared-modules 2026-01-18 21:01:04 -07:00
deepend-tildeclub
3530a5c191 Add options for Perl and Python in Meson setup 2026-01-18 19:16:40 -07:00
deepend-tildeclub
92b9577a19 Update .mailmap
undoing email change that shouldn't have changed.
2026-01-18 18:48:01 -07:00
deepend-tildeclub
56dc9b1b4a Merge pull request #30 from ZoiteChat/auto-dark-mode-on-windows-fix
fix auto dark/light mode on windows.
2026-01-18 15:53:02 -07:00
8c3986ffe0 fix auto dark/light mode on windows. 2026-01-18 10:46:41 -07:00
deepend-tildeclub
c2b67e647d Merge pull request #29 from ZoiteChat/gtk-ciaro
Gtk ciaro
2026-01-18 02:11:54 -07:00
6137fdbd91 Updated the channel list theme application to honor explicit light mode selection so it applies the light palette instead of staying dark. 2026-01-18 01:21:51 -07:00
35ecc2c643 Standardized non-numbered color selector button labels to use two figure spaces so their width matches the numbered palette buttons. 2026-01-18 01:14:49 -07:00
cb8b8bd4cc - Added a helper to apply the selected palette color across all GTK button states so color selector backgrounds stay consistent in preferences (GTK Ciara compatible).
- Reused the helper when initializing and updating color selector buttons to keep the UI in sync with chosen colors.
2026-01-17 23:50:44 -07:00
7279e3592f - Replaced the dark mode checkbox with an Auto/Dark/Light selector in Preferences → Colors and added the new mode labels/setting metadata to match the combo box UI.
- Updated palette handling to respect the effective dark mode (including auto) when saving colors, applying themes, and refreshing user list styling.
- Added auto dark-mode tracking that listens to system theme changes and reapplies palette/styles live when Auto is selected, so updates happen without restart (including channel list styling updates via setup_apply_real).
- Synced the stored auto dark-mode state when preferences are applied, keeping Auto mode consistent after manual changes.
- Exposed a helper for keeping the Auto state synchronized from the GTK layer to preferences handling.
2026-01-17 23:09:38 -07:00
8d275ddb31 - Added dark mode mode constants, config storage as an integer, and a helper to resolve Auto/Dark/Light using system preferences where available.
- Replaced the dark mode checkbox with an Auto/Dark/Light color mode selector and ensured palette edits use the resolved mode.
- Applied the resolved color mode consistently across palette saving and GTK styling in the user list and channel tree/theme application paths.
2026-01-17 22:52:32 -07:00
cf41615cb3 - Reworked GTK window snapshotting in the main GUI to capture into cairo surfaces and convert via gdk_pixbuf_get_from_surface.
- Added a Cairo surface → RGBA pixbuf conversion helper that unpremultiplies ARGB32 data for GTK2 compatibility while keeping window snapshots Cairo-based.
- Updated window snapshotting to use the new Cairo surface conversion instead of gdk_pixbuf_get_from_surface
2026-01-17 22:25:12 -07:00
c1f855c2ab - Updated main GUI color helpers and tab palette generation to use XTextColor, and simplified drag icon snapshotting to use gdk_pixbuf_get_from_window with a null guard.
- Added pixbuf-based cairo surface capture for xtext window scrolling with a fallback to full redraw when capture fails.
2026-01-17 21:56:00 -07:00
4ac836fc66 - Added a shared XTextColor definition and a palette conversion helper for Cairo-ready colors, decoupling renderer palettes from GdkColor usage in the API surface.
- Updated xtext palette APIs to accept internal color arrays directly for rendering setup.
- Wired xtext palette creation through UI entry points to use the new palette helper when constructing or refreshing text views.
2026-01-17 21:39:45 -07:00
5986e6a78b -Added the standard type attribute to the GTK file info query so file type checks no longer trigger GLib-GIO warnings.
-Replaced GtkStyle application in the channel tree view with explicit base/text/font modifications to avoid style attach/detach issues on teardown.

-Updated user list styling to apply the font directly instead of setting a shared GtkStyle instance.

-Switched color button updates to use background modifications instead of creating per-button styles, reducing detach warnings on shutdown.
2026-01-17 18:31:04 -07:00
0601be026c - Converted text background loading to build Cairo surfaces directly from pixbufs for renderer use.
- Updated the xtext renderer to accept Cairo background surfaces and dropped the GtkStyle attach during realize to keep rendering Cairo/Pango-focused.
- Switched background surface ownership and cleanup to use cairo_surface_t across the shared state and settings update path.
2026-01-17 18:19:00 -07:00
24b0a3d75f - Introduced the XTextColor struct and stored xtext palette/foreground/background colors in internal renderer state rather than GdkColor fields.
- Converted palette colors and background pixmaps into cairo-ready values/surfaces for rendering (including background tiling and separator colors).
2026-01-17 17:44:49 -07:00
2ac5234803 - Added Cairo-based window snapshot conversion (with unpremultiplication) for drag icons and updated drag rendering to use the new helper instead of drawable capture.
- Updated GtkXText to track the draw window and use a pixmap-to-surface helper for Cairo contexts, avoiding drawable references in the struct and rendering flow.
- Added a Cairo helper for capturing window-backed surfaces and used it when blitting during scrolling, fixing the build break from the removed drawable helper.
2026-01-17 17:34:38 -07:00
30e309853c Added the required gdk/gdk.h include before gdkcairo.h in maingui.c to satisfy GDK header include order requirements on Windows builds.
Added cairo surface tracking and context creation helpers for xtext rendering, including state initialization for the new draw surface field.

Replaced GdkPixmap-based offscreen text buffering with cairo surfaces and routed rendering/underline/strikethrough operations through the cairo context helper.
2026-01-17 16:56:35 -07:00
944ce69906 Added a Cairo color helper for drag highlight rendering and applied it to the drag motion drawing path.
Replaced GDK source helpers in the text rendering pipeline with Cairo surface/color helpers for lines, backgrounds, and blits.

Updated render sizing to use window dimensions and switched window copy paths to Cairo surfaces.
2026-01-17 16:46:21 -07:00
4bf5316cfa Replaced legacy GDK rectangle drawing in the drag highlight path with Cairo calls and ensured cleanup before early return 2026-01-17 16:34:38 -07:00
136e63a6cd ciaro fixes 2026-01-17 16:19:56 -07:00
5ea424d0e8 start of ciaro implementation. 2026-01-17 16:08:00 -07:00
deepend-tildeclub
d0e7e45a41 Revise changelog for ZoiteChat 2.17.3 release
Updated changelog for ZoiteChat version 2.17.3 with new features, fixes, and known issues.
2026-01-17 15:34:53 -07:00
123 changed files with 4910 additions and 2413 deletions

View File

@@ -42,6 +42,8 @@ jobs:
meson setup build \
--prefix=/usr \
-Dtext-frontend=true \
-Dwith-perl=perl \
-Dwith-python=python3 \
-Dauto_features=enabled
- name: Build

View File

@@ -1,5 +1,5 @@
Berke Viktor <github.bviktor@outlook.com> <berkeviktor@aol.com>
Berke Viktor <github.bviktor@outlook.com> <bviktor@zoitechat.org>
Berke Viktor <github.bviktor@outlook.com> <bviktor@hexchat.org>
Berke Viktor <github.bviktor@outlook.com> <bviktor@outlook.com>
Berke Viktor <github.bviktor@outlook.com> berkeviktor@aol.com
Patrick Griffis <tingping@tingping.se> TingPing <tingping@fedoraproject.org>

43
Makefile Normal file
View File

@@ -0,0 +1,43 @@
PREFIX ?= /usr/local
BUILD_DIR ?= build
MESON ?= meson
NINJA ?= ninja
MESON_SETUP_ARGS ?=
MESON_COMPILE_ARGS ?=
MESON_INSTALL_ARGS ?=
CONFIG_STAMP := $(BUILD_DIR)/build.ninja
.PHONY: all configure build reconfigure install uninstall clean distclean
all: build
# Only run initial meson setup if we don't have a configured build dir yet.
$(CONFIG_STAMP):
@mkdir -p $(BUILD_DIR)
@env NINJA=$(NINJA) $(MESON) setup $(BUILD_DIR) --prefix=$(PREFIX) $(MESON_SETUP_ARGS)
configure: $(CONFIG_STAMP)
build: configure
@env NINJA=$(NINJA) $(MESON) compile -C $(BUILD_DIR) $(MESON_COMPILE_ARGS)
reconfigure:
@mkdir -p $(BUILD_DIR)
@env NINJA=$(NINJA) $(MESON) setup --reconfigure $(BUILD_DIR) --prefix=$(PREFIX) $(MESON_SETUP_ARGS)
install: build
@env NINJA=$(NINJA) $(MESON) install -C $(BUILD_DIR) $(MESON_INSTALL_ARGS)
uninstall: configure
@$(NINJA) -C $(BUILD_DIR) uninstall
clean:
@if [ -f "$(CONFIG_STAMP)" ]; then \
env NINJA=$(NINJA) $(MESON) compile -C $(BUILD_DIR) --clean; \
else \
echo "Nothing to clean (no $(CONFIG_STAMP))."; \
fi
distclean:
rm -rf $(BUILD_DIR)

1113
changelog.rst Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -25,6 +25,16 @@
<id>zoitechat.desktop</id>
</provides>
<releases>
<release date="2026-02-03" version="2.17.4">
<description>
<p>Fixes and minor features:</p>
<ul>
<li>STS handling now persists server policies, enforces upgrades more consistently, and falls back to current ports when needed.</li>
<li>Windows build workflow updated (MSYS2 setup changes) and OpenSSL trust store handling tightened for safer TLS connections.</li>
<li>Reduced GLib coupling in multiple Windows subsystems (spellcheck, history, sysinfo) plus small stability fixes.</li>
</ul>
</description>
</release>
<release date="2026-01-17" version="2.17.3">
<description>
<p>Fixes and minor features:</p>

View File

@@ -1,5 +1,5 @@
project('zoitechat', 'c',
version: '2.17.3',
version: '2.17.4',
meson_version: '>= 0.47.0',
default_options: [
'c_std=gnu89',
@@ -54,7 +54,7 @@ config_h.set('GLIB_VERSION_MIN_REQUIRED', 'GLIB_VERSION_2_36')
config_h.set('HAVE_MEMRCHR', cc.has_function('memrchr'))
config_h.set('HAVE_STRINGS_H', cc.has_header('strings.h'))
config_h.set_quoted('HEXCHATLIBDIR',
config_h.set_quoted('ZOITECHATLIBDIR',
join_paths(get_option('prefix'), get_option('libdir'), 'zoitechat/plugins')
)

View File

@@ -38,7 +38,7 @@ export PANGO_SYSCONFDIR="$bundle_etc"
export OPENSSL_CONF="/System/Library/OpenSSL/openssl.cnf"
export HEXCHAT_LIBDIR="$bundle_lib/zoitechat/plugins"
export ZOITECHAT_LIBDIR="$bundle_lib/zoitechat/plugins"
APP=name
I18NDIR="$bundle_data/locale"

View File

@@ -135,7 +135,7 @@ dccrecv_cb (char *word[], void *userdata)
if (!filename_fs) {
zoitechat_printf (ph, "Checksum: Invalid filename (%s)\n", filename);
g_free (filename);
return HEXCHAT_EAT_NONE;
return ZOITECHAT_EAT_NONE;
}
ChecksumCallbackInfo *callback_data = g_new (ChecksumCallbackInfo, 1);
@@ -153,7 +153,7 @@ dccrecv_cb (char *word[], void *userdata)
g_object_unref (file);
g_object_unref (task);
return HEXCHAT_EAT_NONE;
return ZOITECHAT_EAT_NONE;
}
static int
@@ -177,7 +177,7 @@ dccoffer_cb (char *word[], void *userdata)
g_object_unref (file);
g_object_unref (task);
return HEXCHAT_EAT_NONE;
return ZOITECHAT_EAT_NONE;
}
int
@@ -189,8 +189,8 @@ zoitechat_plugin_init (zoitechat_plugin *plugin_handle, char **plugin_name, char
*plugin_desc = desc;
*plugin_version = version;
zoitechat_hook_print (ph, "DCC RECV Complete", HEXCHAT_PRI_NORM, dccrecv_cb, NULL);
zoitechat_hook_print (ph, "DCC Offer", HEXCHAT_PRI_NORM, dccoffer_cb, NULL);
zoitechat_hook_print (ph, "DCC RECV Complete", ZOITECHAT_PRI_NORM, dccrecv_cb, NULL);
zoitechat_hook_print (ph, "DCC Offer", ZOITECHAT_PRI_NORM, dccoffer_cb, NULL);
zoitechat_printf (ph, "%s plugin loaded\n", name);
return 1;

View File

@@ -134,7 +134,7 @@ run_command (char *word[], char *word_eol[], void *userdata)
zoitechat_command (ph, "help exec");
}
return HEXCHAT_EAT_HEXCHAT;
return ZOITECHAT_EAT_ZOITECHAT;
}
int
@@ -146,7 +146,7 @@ zoitechat_plugin_init (zoitechat_plugin *plugin_handle, char **plugin_name, char
*plugin_desc = desc;
*plugin_version = version;
zoitechat_hook_command (ph, "EXEC", HEXCHAT_PRI_NORM, run_command, "Usage: /EXEC [-O] - execute commands inside ZoiteChat", 0);
zoitechat_hook_command (ph, "EXEC", ZOITECHAT_PRI_NORM, run_command, "Usage: /EXEC [-O] - execute commands inside ZoiteChat", 0);
zoitechat_printf (ph, "%s plugin loaded\n", name);
return 1; /* return 1 for success */

View File

@@ -283,7 +283,7 @@ char *decrypt_raw_message(const char *message, const char *key) {
zoitechat_printf(ph, ">%s< ", word[i]);
}
zoitechat_printf(ph, "\n");
return HEXCHAT_EAT_NONE;
return ZOITECHAT_EAT_NONE;
}*/
/**
@@ -299,7 +299,7 @@ static int handle_outgoing(char *word[], char *word_eol[], void *userdata) {
const char *channel = zoitechat_get_info(ph, "channel");
/* Check if we can encrypt */
if (!fish_nick_has_key(channel)) return HEXCHAT_EAT_NONE;
if (!fish_nick_has_key(channel)) return ZOITECHAT_EAT_NONE;
command = g_string_new("");
g_string_printf(command, "PRIVMSG %s :+OK ", channel);
@@ -307,7 +307,7 @@ static int handle_outgoing(char *word[], char *word_eol[], void *userdata) {
encrypted_list = fish_encrypt_for_nick(channel, word_eol[1], &mode, get_prefix_length() + command->len);
if (!encrypted_list) {
g_string_free(command, TRUE);
return HEXCHAT_EAT_NONE;
return ZOITECHAT_EAT_NONE;
}
/* Get prefix for own nick if any */
@@ -333,7 +333,7 @@ static int handle_outgoing(char *word[], char *word_eol[], void *userdata) {
g_string_free(command, TRUE);
g_slist_free_full(encrypted_list, g_free);
return HEXCHAT_EAT_HEXCHAT;
return ZOITECHAT_EAT_ZOITECHAT;
}
/**
@@ -350,7 +350,7 @@ static int handle_incoming(char *word[], char *word_eol[], zoitechat_event_attrs
GString *message;
if (!irc_parse_message((const char **)word, &prefix, &command, &parameters_offset))
return HEXCHAT_EAT_NONE;
return ZOITECHAT_EAT_NONE;
/* Topic (command 332) has an extra parameter */
if (!strcmp(command, "332"))
@@ -367,7 +367,7 @@ static int handle_incoming(char *word[], char *word_eol[], zoitechat_event_attrs
/* Nothing to decrypt */
if (decrypted == NULL)
return HEXCHAT_EAT_NONE;
return ZOITECHAT_EAT_NONE;
/* Build decrypted message */
@@ -395,7 +395,7 @@ static int handle_incoming(char *word[], char *word_eol[], zoitechat_event_attrs
zoitechat_command(ph, message->str);
g_string_free (message, TRUE);
return HEXCHAT_EAT_HEXCHAT;
return ZOITECHAT_EAT_ZOITECHAT;
}
static int handle_keyx_notice(char *word[], char *word_eol[], void *userdata) {
@@ -407,10 +407,10 @@ static int handle_keyx_notice(char *word[], char *word_eol[], void *userdata) {
enum fish_mode mode = FISH_ECB_MODE;
if (!*dh_message || !*dh_pubkey || strlen(dh_pubkey) != 181)
return HEXCHAT_EAT_NONE;
return ZOITECHAT_EAT_NONE;
if (!irc_parse_message((const char**)word, &prefix, NULL, NULL) || !prefix)
return HEXCHAT_EAT_NONE;
return ZOITECHAT_EAT_NONE;
sender = irc_prefix_get_nick(prefix);
query_ctx = find_context_on_network(sender);
@@ -447,7 +447,7 @@ static int handle_keyx_notice(char *word[], char *word_eol[], void *userdata) {
} else {
/* Regular notice */
g_free(sender);
return HEXCHAT_EAT_NONE;
return ZOITECHAT_EAT_NONE;
}
if (dh1080_compute_key(priv_key, dh_pubkey, &secret_key)) {
@@ -461,7 +461,7 @@ static int handle_keyx_notice(char *word[], char *word_eol[], void *userdata) {
cleanup:
g_free(sender);
g_free(priv_key);
return HEXCHAT_EAT_ALL;
return ZOITECHAT_EAT_ALL;
}
/**
@@ -475,7 +475,7 @@ static int handle_setkey(char *word[], char *word_eol[], void *userdata) {
/* Check syntax */
if (*word[2] == '\0') {
zoitechat_printf(ph, "%s\n", usage_setkey);
return HEXCHAT_EAT_HEXCHAT;
return ZOITECHAT_EAT_ZOITECHAT;
}
if (*word[3] == '\0') {
@@ -503,7 +503,7 @@ static int handle_setkey(char *word[], char *word_eol[], void *userdata) {
zoitechat_printf(ph, "\00305Failed to store key in addon_fishlim.conf\n");
}
return HEXCHAT_EAT_HEXCHAT;
return ZOITECHAT_EAT_ZOITECHAT;
}
/**
@@ -523,7 +523,7 @@ static int handle_delkey(char *word[], char *word_eol[], void *userdata) {
/* Only allow channel or dialog */
if (ctx_type < 2 || ctx_type > 3) {
zoitechat_printf(ph, "%s\n", usage_delkey);
return HEXCHAT_EAT_HEXCHAT;
return ZOITECHAT_EAT_ZOITECHAT;
}
}
@@ -535,7 +535,7 @@ static int handle_delkey(char *word[], char *word_eol[], void *userdata) {
}
g_free(nick);
return HEXCHAT_EAT_HEXCHAT;
return ZOITECHAT_EAT_ZOITECHAT;
}
static int handle_keyx(char *word[], char *word_eol[], void *userdata) {
@@ -558,7 +558,7 @@ static int handle_keyx(char *word[], char *word_eol[], void *userdata) {
if ((query_ctx && ctx_type != 3) || (!query_ctx && !irc_is_query(target))) {
zoitechat_print(ph, "You can only exchange keys with individuals");
return HEXCHAT_EAT_ALL;
return ZOITECHAT_EAT_ALL;
}
if (dh1080_generate_key(&priv_key, &pub_key)) {
@@ -572,7 +572,7 @@ static int handle_keyx(char *word[], char *word_eol[], void *userdata) {
zoitechat_print(ph, "Failed to generate keys");
}
return HEXCHAT_EAT_ALL;
return ZOITECHAT_EAT_ALL;
}
/**
@@ -587,12 +587,12 @@ static int handle_crypt_topic(char *word[], char *word_eol[], void *userdata) {
if (!*topic) {
zoitechat_print(ph, usage_topic);
return HEXCHAT_EAT_ALL;
return ZOITECHAT_EAT_ALL;
}
if (zoitechat_list_int(ph, NULL, "type") != 2) {
zoitechat_printf(ph, "Please change to the channel window where you want to set the topic!");
return HEXCHAT_EAT_ALL;
return ZOITECHAT_EAT_ALL;
}
target = zoitechat_get_info(ph, "channel");
@@ -600,7 +600,7 @@ static int handle_crypt_topic(char *word[], char *word_eol[], void *userdata) {
/* Check if we can encrypt */
if (!fish_nick_has_key(target)) {
zoitechat_printf(ph, "/topic+ error, no key found for %s", target);
return HEXCHAT_EAT_ALL;
return ZOITECHAT_EAT_ALL;
}
command = g_string_new("");
@@ -610,7 +610,7 @@ static int handle_crypt_topic(char *word[], char *word_eol[], void *userdata) {
if (!encrypted_list) {
g_string_free(command, TRUE);
zoitechat_printf(ph, "/topic+ error, can't encrypt %s", target);
return HEXCHAT_EAT_ALL;
return ZOITECHAT_EAT_ALL;
}
zoitechat_commandf(ph, "%s%s", command->str, (char *) encrypted_list->data);
@@ -618,7 +618,7 @@ static int handle_crypt_topic(char *word[], char *word_eol[], void *userdata) {
g_string_free(command, TRUE);
g_slist_free_full(encrypted_list, g_free);
return HEXCHAT_EAT_ALL;
return ZOITECHAT_EAT_ALL;
}
/**
@@ -634,13 +634,13 @@ static int handle_crypt_notice(char *word[], char *word_eol[], void *userdata) {
if (!*target || !*notice) {
zoitechat_print(ph, usage_notice);
return HEXCHAT_EAT_ALL;
return ZOITECHAT_EAT_ALL;
}
/* Check if we can encrypt */
if (!fish_nick_has_key(target)) {
zoitechat_printf(ph, "/notice+ error, no key found for %s.", target);
return HEXCHAT_EAT_ALL;
return ZOITECHAT_EAT_ALL;
}
command = g_string_new("");
@@ -650,7 +650,7 @@ static int handle_crypt_notice(char *word[], char *word_eol[], void *userdata) {
if (!encrypted_list) {
g_string_free(command, TRUE);
zoitechat_printf(ph, "/notice+ error, can't encrypt %s", target);
return HEXCHAT_EAT_ALL;
return ZOITECHAT_EAT_ALL;
}
notice_flag = g_strconcat("[", fish_modes[mode], "] ", notice, NULL);
@@ -668,7 +668,7 @@ static int handle_crypt_notice(char *word[], char *word_eol[], void *userdata) {
g_string_free(command, TRUE);
g_slist_free_full(encrypted_list, g_free);
return HEXCHAT_EAT_ALL;
return ZOITECHAT_EAT_ALL;
}
/**
@@ -686,13 +686,13 @@ static int handle_crypt_msg(char *word[], char *word_eol[], void *userdata) {
if (!*target || !*message) {
zoitechat_print(ph, usage_msg);
return HEXCHAT_EAT_ALL;
return ZOITECHAT_EAT_ALL;
}
/* Check if we can encrypt */
if (!fish_nick_has_key(target)) {
zoitechat_printf(ph, "/msg+ error, no key found for %s", target);
return HEXCHAT_EAT_ALL;
return ZOITECHAT_EAT_ALL;
}
command = g_string_new("");
@@ -702,7 +702,7 @@ static int handle_crypt_msg(char *word[], char *word_eol[], void *userdata) {
if (!encrypted_list) {
g_string_free(command, TRUE);
zoitechat_printf(ph, "/msg+ error, can't encrypt %s", target);
return HEXCHAT_EAT_ALL;
return ZOITECHAT_EAT_ALL;
}
/* Send encrypted messages */
@@ -731,7 +731,7 @@ static int handle_crypt_msg(char *word[], char *word_eol[], void *userdata) {
zoitechat_emit_print(ph, "Message Send", target, message);
}
return HEXCHAT_EAT_ALL;
return ZOITECHAT_EAT_ALL;
}
static int handle_crypt_me(char *word[], char *word_eol[], void *userdata) {
@@ -742,7 +742,7 @@ static int handle_crypt_me(char *word[], char *word_eol[], void *userdata) {
/* Check if we can encrypt */
if (!fish_nick_has_key(channel)) {
return HEXCHAT_EAT_NONE;
return ZOITECHAT_EAT_NONE;
}
command = g_string_new("");
@@ -753,7 +753,7 @@ static int handle_crypt_me(char *word[], char *word_eol[], void *userdata) {
if (!encrypted_list) {
g_string_free(command, TRUE);
zoitechat_printf(ph, "/me error, can't encrypt %s", channel);
return HEXCHAT_EAT_ALL;
return ZOITECHAT_EAT_ALL;
}
zoitechat_emit_print(ph, "Your Action", zoitechat_get_info(ph, "nick"), word_eol[2], NULL);
@@ -769,7 +769,7 @@ static int handle_crypt_me(char *word[], char *word_eol[], void *userdata) {
g_string_free(command, TRUE);
g_slist_free_full(encrypted_list, g_free);
return HEXCHAT_EAT_ALL;
return ZOITECHAT_EAT_ALL;
}
/**
@@ -798,22 +798,22 @@ int zoitechat_plugin_init(zoitechat_plugin *plugin_handle,
*version = plugin_version;
/* Register commands */
zoitechat_hook_command(ph, "SETKEY", HEXCHAT_PRI_NORM, handle_setkey, usage_setkey, NULL);
zoitechat_hook_command(ph, "DELKEY", HEXCHAT_PRI_NORM, handle_delkey, usage_delkey, NULL);
zoitechat_hook_command(ph, "KEYX", HEXCHAT_PRI_NORM, handle_keyx, usage_keyx, NULL);
zoitechat_hook_command(ph, "TOPIC+", HEXCHAT_PRI_NORM, handle_crypt_topic, usage_topic, NULL);
zoitechat_hook_command(ph, "NOTICE+", HEXCHAT_PRI_NORM, handle_crypt_notice, usage_notice, NULL);
zoitechat_hook_command(ph, "MSG+", HEXCHAT_PRI_NORM, handle_crypt_msg, usage_msg, NULL);
zoitechat_hook_command(ph, "ME", HEXCHAT_PRI_NORM, handle_crypt_me, NULL, NULL);
zoitechat_hook_command(ph, "SETKEY", ZOITECHAT_PRI_NORM, handle_setkey, usage_setkey, NULL);
zoitechat_hook_command(ph, "DELKEY", ZOITECHAT_PRI_NORM, handle_delkey, usage_delkey, NULL);
zoitechat_hook_command(ph, "KEYX", ZOITECHAT_PRI_NORM, handle_keyx, usage_keyx, NULL);
zoitechat_hook_command(ph, "TOPIC+", ZOITECHAT_PRI_NORM, handle_crypt_topic, usage_topic, NULL);
zoitechat_hook_command(ph, "NOTICE+", ZOITECHAT_PRI_NORM, handle_crypt_notice, usage_notice, NULL);
zoitechat_hook_command(ph, "MSG+", ZOITECHAT_PRI_NORM, handle_crypt_msg, usage_msg, NULL);
zoitechat_hook_command(ph, "ME", ZOITECHAT_PRI_NORM, handle_crypt_me, NULL, NULL);
/* Add handlers */
zoitechat_hook_command(ph, "", HEXCHAT_PRI_NORM, handle_outgoing, NULL, NULL);
zoitechat_hook_server(ph, "NOTICE", HEXCHAT_PRI_HIGHEST, handle_keyx_notice, NULL);
zoitechat_hook_server_attrs(ph, "NOTICE", HEXCHAT_PRI_NORM, handle_incoming, NULL);
zoitechat_hook_server_attrs(ph, "PRIVMSG", HEXCHAT_PRI_NORM, handle_incoming, NULL);
/* zoitechat_hook_server(ph, "RAW LINE", HEXCHAT_PRI_NORM, handle_debug, NULL); */
zoitechat_hook_server_attrs(ph, "TOPIC", HEXCHAT_PRI_NORM, handle_incoming, NULL);
zoitechat_hook_server_attrs(ph, "332", HEXCHAT_PRI_NORM, handle_incoming, NULL);
zoitechat_hook_command(ph, "", ZOITECHAT_PRI_NORM, handle_outgoing, NULL, NULL);
zoitechat_hook_server(ph, "NOTICE", ZOITECHAT_PRI_HIGHEST, handle_keyx_notice, NULL);
zoitechat_hook_server_attrs(ph, "NOTICE", ZOITECHAT_PRI_NORM, handle_incoming, NULL);
zoitechat_hook_server_attrs(ph, "PRIVMSG", ZOITECHAT_PRI_NORM, handle_incoming, NULL);
/* zoitechat_hook_server(ph, "RAW LINE", ZOITECHAT_PRI_NORM, handle_debug, NULL); */
zoitechat_hook_server_attrs(ph, "TOPIC", ZOITECHAT_PRI_NORM, handle_incoming, NULL);
zoitechat_hook_server_attrs(ph, "332", ZOITECHAT_PRI_NORM, handle_incoming, NULL);
if (!fish_init())
return 0;

View File

@@ -22,8 +22,8 @@
*/
#ifndef PLUGIN_HEXCHAT_H
#define PLUGIN_HEXCHAT_H
#ifndef PLUGIN_ZOITECHAT_H
#define PLUGIN_ZOITECHAT_H
gchar *get_config_filename(void);
int irc_nick_cmp (const char *, const char *);

View File

@@ -22,8 +22,8 @@
*/
#ifndef PLUGIN_HEXCHAT_FISHLIM_UTILS_H
#define PLUGIN_HEXCHAT_FISHLIM_UTILS_H
#ifndef PLUGIN_ZOITECHAT_FISHLIM_UTILS_H
#define PLUGIN_ZOITECHAT_FISHLIM_UTILS_H
#include <stddef.h>
#include "fish.h"

File diff suppressed because it is too large Load Diff

View File

@@ -36,7 +36,7 @@ sub PRI_LOW ();
sub PRI_LOWEST ();
sub EAT_NONE ();
sub EAT_HEXCHAT ();
sub EAT_ZOITECHAT ();
sub EAT_PLUGIN ();
sub EAT_ALL ();
@@ -60,7 +60,7 @@ BEGIN {
our %EXPORT_TAGS = (
constants => [
qw(PRI_HIGHEST PRI_HIGH PRI_NORM PRI_LOW PRI_LOWEST), # priorities
qw(EAT_NONE EAT_HEXCHAT EAT_XCHAT EAT_PLUGIN EAT_ALL), # callback return values
qw(EAT_NONE EAT_ZOITECHAT EAT_XCHAT EAT_PLUGIN EAT_ALL), # callback return values
qw(FD_READ FD_WRITE FD_EXCEPTION FD_NOTSOCKET), # fd flags
qw(KEEP REMOVE), # timers
],

View File

@@ -247,7 +247,7 @@ sub evaluate {
ZoiteChat::print $results[0];
}
return ZoiteChat::EAT_HEXCHAT;
return ZoiteChat::EAT_ZOITECHAT;
};
sub expand_homedir {

View File

@@ -337,11 +337,11 @@ fd_cb (int fd, int flags, void *userdata)
if (SvTRUE (ERRSV)) {
zoitechat_printf (ph, "Error in fd callback %s", SvPV_nolen (ERRSV));
if (!SvOK (POPs)) {} /* remove undef from the top of the stack */
retVal = HEXCHAT_EAT_ALL;
retVal = ZOITECHAT_EAT_ALL;
} else {
if (count != 1) {
zoitechat_print (ph, "Fd handler should only return 1 value.");
retVal = HEXCHAT_EAT_NONE;
retVal = ZOITECHAT_EAT_NONE;
} else {
retVal = POPi;
if (retVal == 0) {
@@ -398,11 +398,11 @@ timer_cb (void *userdata)
if (SvTRUE (ERRSV)) {
zoitechat_printf (ph, "Error in timer callback %s", SvPV_nolen (ERRSV));
if (!SvOK (POPs)) {} /* remove undef from the top of the stack */
retVal = HEXCHAT_EAT_ALL;
retVal = ZOITECHAT_EAT_ALL;
} else {
if (count != 1) {
zoitechat_print (ph, "Timer handler should only return 1 value.");
retVal = HEXCHAT_EAT_NONE;
retVal = ZOITECHAT_EAT_NONE;
} else {
retVal = POPi;
if (retVal == 0) {
@@ -438,7 +438,7 @@ server_cb (char *word[], char *word_eol[], void *userdata)
SAVETMPS;
if (data->depth)
return HEXCHAT_EAT_NONE;
return ZOITECHAT_EAT_NONE;
/* zoitechat_printf (ph, */
/* "Received %d words in server callback", av_len (wd)); */
@@ -457,11 +457,11 @@ server_cb (char *word[], char *word_eol[], void *userdata)
if (SvTRUE (ERRSV)) {
zoitechat_printf (ph, "Error in server callback %s", SvPV_nolen (ERRSV));
if (!SvOK (POPs)) {} /* remove undef from the top of the stack */
retVal = HEXCHAT_EAT_NONE;
retVal = ZOITECHAT_EAT_NONE;
} else {
if (count != 1) {
zoitechat_print (ph, "Server handler should only return 1 value.");
retVal = HEXCHAT_EAT_NONE;
retVal = ZOITECHAT_EAT_NONE;
} else {
retVal = POPi;
}
@@ -487,7 +487,7 @@ command_cb (char *word[], char *word_eol[], void *userdata)
SAVETMPS;
if (data->depth)
return HEXCHAT_EAT_NONE;
return ZOITECHAT_EAT_NONE;
/* zoitechat_printf (ph, "Received %d words in command callback", */
/* av_len (wd)); */
@@ -506,11 +506,11 @@ command_cb (char *word[], char *word_eol[], void *userdata)
if (SvTRUE (ERRSV)) {
zoitechat_printf (ph, "Error in command callback %s", SvPV_nolen (ERRSV));
if (!SvOK (POPs)) {} /* remove undef from the top of the stack */
retVal = HEXCHAT_EAT_HEXCHAT;
retVal = ZOITECHAT_EAT_ZOITECHAT;
} else {
if (count != 1) {
zoitechat_print (ph, "Command handler should only return 1 value.");
retVal = HEXCHAT_EAT_NONE;
retVal = ZOITECHAT_EAT_NONE;
} else {
retVal = POPi;
}
@@ -541,7 +541,7 @@ print_cb (char *word[], void *userdata)
SAVETMPS;
if (data->depth)
return HEXCHAT_EAT_NONE;
return ZOITECHAT_EAT_NONE;
wd = newAV ();
sv_2mortal ((SV *) wd);
@@ -582,11 +582,11 @@ print_cb (char *word[], void *userdata)
if (SvTRUE (ERRSV)) {
zoitechat_printf (ph, "Error in print callback %s", SvPV_nolen (ERRSV));
if (!SvOK (POPs)) {} /* remove undef from the top of the stack */
retVal = HEXCHAT_EAT_NONE;
retVal = ZOITECHAT_EAT_NONE;
} else {
if (count != 1) {
zoitechat_print (ph, "Print handler should only return 1 value.");
retVal = HEXCHAT_EAT_NONE;
retVal = ZOITECHAT_EAT_NONE;
} else {
retVal = POPi;
}
@@ -1022,7 +1022,7 @@ XS (XS_ZoiteChat_hook_fd)
data = NULL;
#ifdef WIN32
if ((flags & HEXCHAT_FD_NOTSOCKET) == 0) {
if ((flags & ZOITECHAT_FD_NOTSOCKET) == 0) {
/* this _get_osfhandle if from win32iop.h in the perl distribution,
* not the one provided by Windows
*/
@@ -1356,21 +1356,21 @@ xs_init (pTHX)
exit (1);
}
newCONSTSUB (stash, "PRI_HIGHEST", newSViv (HEXCHAT_PRI_HIGHEST));
newCONSTSUB (stash, "PRI_HIGH", newSViv (HEXCHAT_PRI_HIGH));
newCONSTSUB (stash, "PRI_NORM", newSViv (HEXCHAT_PRI_NORM));
newCONSTSUB (stash, "PRI_LOW", newSViv (HEXCHAT_PRI_LOW));
newCONSTSUB (stash, "PRI_LOWEST", newSViv (HEXCHAT_PRI_LOWEST));
newCONSTSUB (stash, "PRI_HIGHEST", newSViv (ZOITECHAT_PRI_HIGHEST));
newCONSTSUB (stash, "PRI_HIGH", newSViv (ZOITECHAT_PRI_HIGH));
newCONSTSUB (stash, "PRI_NORM", newSViv (ZOITECHAT_PRI_NORM));
newCONSTSUB (stash, "PRI_LOW", newSViv (ZOITECHAT_PRI_LOW));
newCONSTSUB (stash, "PRI_LOWEST", newSViv (ZOITECHAT_PRI_LOWEST));
newCONSTSUB (stash, "EAT_NONE", newSViv (HEXCHAT_EAT_NONE));
newCONSTSUB (stash, "EAT_HEXCHAT", newSViv (HEXCHAT_EAT_HEXCHAT));
newCONSTSUB (stash, "EAT_XCHAT", newSViv (HEXCHAT_EAT_HEXCHAT)); /* for compatibility */
newCONSTSUB (stash, "EAT_PLUGIN", newSViv (HEXCHAT_EAT_PLUGIN));
newCONSTSUB (stash, "EAT_ALL", newSViv (HEXCHAT_EAT_ALL));
newCONSTSUB (stash, "FD_READ", newSViv (HEXCHAT_FD_READ));
newCONSTSUB (stash, "FD_WRITE", newSViv (HEXCHAT_FD_WRITE));
newCONSTSUB (stash, "FD_EXCEPTION", newSViv (HEXCHAT_FD_EXCEPTION));
newCONSTSUB (stash, "FD_NOTSOCKET", newSViv (HEXCHAT_FD_NOTSOCKET));
newCONSTSUB (stash, "EAT_NONE", newSViv (ZOITECHAT_EAT_NONE));
newCONSTSUB (stash, "EAT_ZOITECHAT", newSViv (ZOITECHAT_EAT_ZOITECHAT));
newCONSTSUB (stash, "EAT_XCHAT", newSViv (ZOITECHAT_EAT_ZOITECHAT)); /* for compatibility */
newCONSTSUB (stash, "EAT_PLUGIN", newSViv (ZOITECHAT_EAT_PLUGIN));
newCONSTSUB (stash, "EAT_ALL", newSViv (ZOITECHAT_EAT_ALL));
newCONSTSUB (stash, "FD_READ", newSViv (ZOITECHAT_FD_READ));
newCONSTSUB (stash, "FD_WRITE", newSViv (ZOITECHAT_FD_WRITE));
newCONSTSUB (stash, "FD_EXCEPTION", newSViv (ZOITECHAT_FD_EXCEPTION));
newCONSTSUB (stash, "FD_NOTSOCKET", newSViv (ZOITECHAT_FD_NOTSOCKET));
newCONSTSUB (stash, "KEEP", newSViv (1));
newCONSTSUB (stash, "REMOVE", newSViv (0));
@@ -1509,10 +1509,10 @@ perl_command_unloadall (char *word[], char *word_eol[], void *userdata)
{
if (my_perl != NULL) {
execute_perl (sv_2mortal (newSVpv ("ZoiteChat::Embed::unload_all", 0)), "");
return HEXCHAT_EAT_HEXCHAT;
return ZOITECHAT_EAT_ZOITECHAT;
}
return HEXCHAT_EAT_HEXCHAT;
return ZOITECHAT_EAT_ZOITECHAT;
}
static int
@@ -1521,11 +1521,11 @@ perl_command_reloadall (char *word[], char *word_eol[], void *userdata)
if (my_perl != NULL) {
execute_perl (sv_2mortal (newSVpv ("ZoiteChat::Embed::reload_all", 0)), "");
return HEXCHAT_EAT_HEXCHAT;
return ZOITECHAT_EAT_ZOITECHAT;
} else {
perl_auto_load( NULL );
}
return HEXCHAT_EAT_HEXCHAT;
return ZOITECHAT_EAT_ZOITECHAT;
}
static int
@@ -1536,10 +1536,10 @@ perl_command_load (char *word[], char *word_eol[], void *userdata)
if (file != NULL )
{
perl_load_file (file);
return HEXCHAT_EAT_HEXCHAT;
return ZOITECHAT_EAT_ZOITECHAT;
}
return HEXCHAT_EAT_NONE;
return ZOITECHAT_EAT_NONE;
}
static int
@@ -1549,10 +1549,10 @@ perl_command_unload (char *word[], char *word_eol[], void *userdata)
if (my_perl != NULL && file != NULL) {
execute_perl (sv_2mortal (newSVpv ("ZoiteChat::Embed::unload", 0)), file);
return HEXCHAT_EAT_HEXCHAT;
return ZOITECHAT_EAT_ZOITECHAT;
}
return HEXCHAT_EAT_NONE;
return ZOITECHAT_EAT_NONE;
}
static int
@@ -1562,13 +1562,13 @@ perl_command_reload (char *word[], char *word_eol[], void *eat)
if (my_perl != NULL && file != NULL) {
execute_perl (sv_2mortal (newSVpv ("ZoiteChat::Embed::reload", 0)), file);
return HEXCHAT_EAT_HEXCHAT;
return ZOITECHAT_EAT_ZOITECHAT;
}
if (eat)
return HEXCHAT_EAT_HEXCHAT;
return ZOITECHAT_EAT_ZOITECHAT;
else
return HEXCHAT_EAT_NONE;
return ZOITECHAT_EAT_NONE;
}
static int
@@ -1577,7 +1577,7 @@ perl_command_eval (char *word[], char *word_eol[], void *userdata)
if (my_perl != NULL)
execute_perl (sv_2mortal (newSVpv ("ZoiteChat::Embed::evaluate", 0)), word_eol[2]);
return HEXCHAT_EAT_HEXCHAT;
return ZOITECHAT_EAT_ZOITECHAT;
}
void
@@ -1612,19 +1612,19 @@ zoitechat_plugin_init (zoitechat_plugin * plugin_handle, char **plugin_name,
*plugin_desc = "Perl scripting interface";
*plugin_version = PACKAGE_VERSION;
zoitechat_hook_command (ph, "load", HEXCHAT_PRI_NORM, perl_command_load, 0, 0);
zoitechat_hook_command (ph, "unload", HEXCHAT_PRI_NORM, perl_command_unload, 0,
zoitechat_hook_command (ph, "load", ZOITECHAT_PRI_NORM, perl_command_load, 0, 0);
zoitechat_hook_command (ph, "unload", ZOITECHAT_PRI_NORM, perl_command_unload, 0,
0);
zoitechat_hook_command (ph, "reload", HEXCHAT_PRI_NORM, perl_command_reload, 0,
zoitechat_hook_command (ph, "reload", ZOITECHAT_PRI_NORM, perl_command_reload, 0,
0);
zoitechat_hook_command (ph, "pl_reload", HEXCHAT_PRI_NORM, perl_command_reload,
zoitechat_hook_command (ph, "pl_reload", ZOITECHAT_PRI_NORM, perl_command_reload,
"Reloads a Perl script. Syntax: /pl_reload <filename.pl>", (int*)1);
zoitechat_hook_command (ph, "unloadall", HEXCHAT_PRI_NORM,
zoitechat_hook_command (ph, "unloadall", ZOITECHAT_PRI_NORM,
perl_command_unloadall, "Unloads all loaded Perl scripts.", 0);
zoitechat_hook_command (ph, "reloadall", HEXCHAT_PRI_NORM,
zoitechat_hook_command (ph, "reloadall", ZOITECHAT_PRI_NORM,
perl_command_reloadall, "Realoads all loaded Perl scripts.", 0);
zoitechat_hook_command (ph, "pl", HEXCHAT_PRI_NORM,
zoitechat_hook_command (ph, "pl", ZOITECHAT_PRI_NORM,
perl_command_eval, "Evaluates Perl code. Syntax: /pl <perl code>", 0);
/*perl_init (); */

View File

@@ -5,7 +5,7 @@ from contextlib import contextmanager
from _zoitechat_embedded import ffi, lib
__all__ = [
'EAT_ALL', 'EAT_HEXCHAT', 'EAT_NONE', 'EAT_PLUGIN', 'EAT_XCHAT',
'EAT_ALL', 'EAT_ZOITECHAT', 'EAT_NONE', 'EAT_PLUGIN', 'EAT_XCHAT',
'PRI_HIGH', 'PRI_HIGHEST', 'PRI_LOW', 'PRI_LOWEST', 'PRI_NORM',
'__doc__', '__version__', 'command', 'del_pluginpref', 'emit_print',
'find_context', 'get_context', 'get_info',
@@ -20,10 +20,10 @@ __version__ = (2, 0)
__license__ = 'GPL-2.0+'
EAT_NONE = 0
EAT_HEXCHAT = 1
EAT_XCHAT = EAT_HEXCHAT
EAT_ZOITECHAT = 1
EAT_XCHAT = EAT_ZOITECHAT
EAT_PLUGIN = 2
EAT_ALL = EAT_HEXCHAT | EAT_PLUGIN
EAT_ALL = EAT_ZOITECHAT | EAT_PLUGIN
PRI_LOWEST = -128
PRI_LOW = -64

View File

@@ -13,7 +13,7 @@ with open(sys.argv[1]) as f:
for line in f:
if line.startswith('#define'):
continue
elif line.endswith('HEXCHAT_PLUGIN_H\n'):
elif line.endswith('ZOITECHAT_PLUGIN_H\n'):
continue
elif 'time.h' in line:
output.append('typedef int... time_t;')
@@ -70,7 +70,7 @@ int zoitechat_plugin_init(zoitechat_plugin *plugin_handle,
}
ph = plugin_handle;
return _on_plugin_init(name_out, description_out, version_out, arg, HEXCHATLIBDIR);
return _on_plugin_init(name_out, description_out, version_out, arg, ZOITECHATLIBDIR);
}
int zoitechat_plugin_deinit(void)

View File

@@ -40,7 +40,7 @@ def redirected_stdout():
sys.stderr = zoitechat_stdout
if os.getenv('HEXCHAT_LOG_PYTHON'):
if os.getenv('ZOITECHAT_LOG_PYTHON'):
def log(*args):
with redirected_stdout():
print(*args)

View File

@@ -222,7 +222,7 @@ sysinfo_cb (char *word[], char *word_eol[], void *userdata)
else
print_info (cmd, announce);
return HEXCHAT_EAT_ALL;
return ZOITECHAT_EAT_ALL;
}
int
@@ -233,7 +233,7 @@ zoitechat_plugin_init (zoitechat_plugin *plugin_handle, char **plugin_name, char
*plugin_desc = desc;
*plugin_version = version;
zoitechat_hook_command (ph, "SYSINFO", HEXCHAT_PRI_NORM, sysinfo_cb, sysinfo_help, NULL);
zoitechat_hook_command (ph, "SYSINFO", ZOITECHAT_PRI_NORM, sysinfo_cb, sysinfo_help, NULL);
zoitechat_command (ph, "MENU ADD \"Window/Send System Info\" \"SYSINFO\"");
zoitechat_printf (ph, _("%s plugin loaded\n"), name);

View File

@@ -37,7 +37,7 @@ check_cmd (char *word[], char *word_eol[], void *userdata)
{
win_sparkle_check_update_with_ui ();
return HEXCHAT_EAT_ALL;
return ZOITECHAT_EAT_ALL;
}
int
@@ -52,7 +52,7 @@ zoitechat_plugin_init (zoitechat_plugin *plugin_handle, char **plugin_name, char
win_sparkle_set_appcast_url (APPCAST_URL);
win_sparkle_init ();
zoitechat_hook_command (ph, "UPDCHK", HEXCHAT_PRI_NORM, check_cmd, upd_help, NULL);
zoitechat_hook_command (ph, "UPDCHK", ZOITECHAT_PRI_NORM, check_cmd, upd_help, NULL);
zoitechat_command (ph, "MENU -ishare\\download.png ADD \"Help/Check for Updates\" \"UPDCHK\"");
zoitechat_printf (ph, "%s plugin loaded\n", name);

View File

@@ -76,7 +76,7 @@ winamp(char *word[], char *word_eol[], void *userdata)
if (!current_play)
{
zoitechat_print (ph, "Winamp: Error getting song information.");
return HEXCHAT_EAT_ALL;
return ZOITECHAT_EAT_ALL;
}
if (strchr(current_play, '-'))
@@ -120,7 +120,7 @@ winamp(char *word[], char *word_eol[], void *userdata)
{
zoitechat_print(ph, "Winamp not found.\n");
}
return HEXCHAT_EAT_ALL;
return ZOITECHAT_EAT_ALL;
}
int
@@ -137,7 +137,7 @@ zoitechat_plugin_init(zoitechat_plugin *plugin_handle,
*plugin_desc = "Winamp plugin for ZoiteChat";
*plugin_version = "0.6";
zoitechat_hook_command (ph, "WINAMP", HEXCHAT_PRI_NORM, winamp, "Usage: /WINAMP [PAUSE|PLAY|STOP|NEXT|PREV|START] - control Winamp or show what's currently playing", 0);
zoitechat_hook_command (ph, "WINAMP", ZOITECHAT_PRI_NORM, winamp, "Usage: /WINAMP [PAUSE|PLAY|STOP|NEXT|PREV|START] - control Winamp or show what's currently playing", 0);
zoitechat_command (ph, "MENU -ishare\\music.png ADD \"Window/Display Current Song (Winamp)\" \"WINAMP\"");
zoitechat_print (ph, "Winamp plugin loaded\n");

View File

@@ -1,5 +1,6 @@
# ZoiteChat
<div align="center">
<img src="data/icons/zoitechat.svg" height="230">
[![Debian Build](https://github.com/ZoiteChat/zoitechat/actions/workflows/debian-build.yml/badge.svg)](https://github.com/ZoiteChat/zoitechat/actions/workflows/debian-build.yml)
[![Flatpak Build](https://github.com/ZoiteChat/zoitechat/actions/workflows/flatpak-build.yml/badge.svg)](https://github.com/ZoiteChat/zoitechat/actions/workflows/flatpak-build.yml)
[![AppImage Build](https://github.com/ZoiteChat/zoitechat/actions/workflows/appimage-build.yml/badge.svg)](https://github.com/ZoiteChat/zoitechat/actions/workflows/appimage-build.yml)
@@ -7,9 +8,34 @@
[![MSYS2 Build](https://github.com/ZoiteChat/zoitechat/actions/workflows/msys-build.yml/badge.svg)](https://github.com/ZoiteChat/zoitechat/actions/workflows/msys-build.yml)
[![OpenBSD Build](https://github.com/ZoiteChat/zoitechat/actions/workflows/openbsd-build.yml/badge.svg)](https://github.com/ZoiteChat/zoitechat/actions/workflows/openbsd-build.yml)
[![Version][github-version-img]][github-version-uri] [![Downloads][github-downloads-img]][github-downloads-uri] [![Size][github-size-img]][github-size-img] [![Last Commit][github-commit-img]][github-commit-img] [![Contributors][contribs-all-img]](#contributors-)
[![View Official Documentation](https://img.shields.io/badge/View_Official_Documentation-526CFE?style=for-the-badge&logo=MaterialForMkDocs&logoColor=white)](https://docs.zoitechat.zoite.net)
</div>
<!-- Badge reference definitions -->
[github-version-img]: https://img.shields.io/github/v/release/ZoiteChat/zoitechat?display_name=tag&sort=semver
[github-version-uri]: https://github.com/ZoiteChat/zoitechat/releases/latest
[github-downloads-img]: https://img.shields.io/github/downloads/ZoiteChat/zoitechat/total
[github-downloads-uri]: https://github.com/ZoiteChat/zoitechat/releases
[github-size-img]: https://img.shields.io/github/repo-size/ZoiteChat/zoitechat
[github-size-uri]: https://github.com/ZoiteChat/zoitechat
[github-commit-img]: https://img.shields.io/github/last-commit/ZoiteChat/zoitechat
[github-commit-uri]: https://github.com/ZoiteChat/zoitechat/commits
[contribs-all-img]: https://img.shields.io/github/contributors/ZoiteChat/zoitechat
<br />
<br />
ZoiteChat is an HexChat based IRC client for Windows and UNIX-like operating systems.
See [IRCHelp.org](http://irchelp.org) for information about IRC in general.
For more information on ZoiteChat please read our [documentation](https://zoitechat.zoite.net/docs/):
For more information on ZoiteChat please read our [documentation](https://docs.zoitechat.zoite.net/):
- [Downloads](https://zoitechat.zoite.net/download)
---

View File

@@ -35,7 +35,7 @@
#include <io.h>
#else
#include <unistd.h>
#define HEXCHAT_DIR "zoitechat"
#define ZOITECHAT_DIR "zoitechat"
#endif
#define DEF_FONT "Monospace 9"
@@ -305,7 +305,7 @@ get_xdir (void)
if (!xdir)
{
#ifndef WIN32
xdir = g_build_filename (g_get_user_config_dir (), HEXCHAT_DIR, NULL);
xdir = g_build_filename (g_get_user_config_dir (), ZOITECHAT_DIR, NULL);
#else
wchar_t* roaming_path_wide;
gchar* roaming_path;
@@ -437,7 +437,7 @@ const struct prefs vars[] =
{"gui_tab_dialogs", P_OFFINT (hex_gui_tab_dialogs), TYPE_BOOL},
{"gui_tab_dots", P_OFFINT (hex_gui_tab_dots), TYPE_BOOL},
{"gui_tab_icons", P_OFFINT (hex_gui_tab_icons), TYPE_BOOL},
{"gui_dark_mode", P_OFFINT (hex_gui_dark_mode), TYPE_BOOL},
{"gui_dark_mode", P_OFFINT (hex_gui_dark_mode), TYPE_INT},
{"gui_tab_layout", P_OFFINT (hex_gui_tab_layout), TYPE_INT},
{"gui_tab_middleclose", P_OFFINT (hex_gui_tab_middleclose), TYPE_BOOL},
{"gui_tab_newtofront", P_OFFINT (hex_gui_tab_newtofront), TYPE_INT},
@@ -936,7 +936,7 @@ make_config_dirs (void)
}
g_free (buf);
buf = g_build_filename (get_xdir (), HEXCHAT_SOUND_DIR, NULL);
buf = g_build_filename (get_xdir (), ZOITECHAT_SOUND_DIR, NULL);
if (g_mkdir (buf, 0700) != 0)
{
g_free (buf);

View File

@@ -19,8 +19,8 @@
/* cfgfiles.h */
#ifndef HEXCHAT_CFGFILES_H
#define HEXCHAT_CFGFILES_H
#ifndef ZOITECHAT_CFGFILES_H
#define ZOITECHAT_CFGFILES_H
#include "zoitechat.h"
@@ -82,6 +82,6 @@ struct prefs
#define TYPE_INT 1
#define TYPE_BOOL 2
#define HEXCHAT_SOUND_DIR "sounds"
#define ZOITECHAT_SOUND_DIR "sounds"
#endif

View File

@@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_CHANOPT_H
#define HEXCHAT_CHANOPT_H
#ifndef ZOITECHAT_CHANOPT_H
#define ZOITECHAT_CHANOPT_H
int chanopt_command (session *sess, char *tbuf, char *word[], char *word_eol[]);
gboolean chanopt_is_set (unsigned int global, guint8 per_chan_setting);

View File

@@ -71,6 +71,7 @@
<ClCompile Include="servlist.c" />
<ClCompile Include="ssl.c" />
<ClCompile Include="scram.c" />
<ClCompile Include="sts.c" />
<ClCompile Include="sysinfo\win32\backend.c" />
<ClCompile Include="text.c" />
<ClCompile Include="tree.c" />

View File

@@ -172,6 +172,9 @@
<ClCompile Include="ssl.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="sts.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="text.c">
<Filter>Source Files</Filter>
</ClCompile>

View File

@@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_CTCP_H
#define HEXCHAT_CTCP_H
#ifndef ZOITECHAT_CTCP_H
#define ZOITECHAT_CTCP_H
void ctcp_handle (session *sess, char *to, char *nick, char *ip, char *msg,
char *word[], char *word_eol[], int id,

View File

@@ -1002,7 +1002,7 @@ open_context_cb (char *word[],
info->context = zoitechat_get_context (ph);
contexts = g_list_prepend (contexts, info);
return HEXCHAT_EAT_NONE;
return ZOITECHAT_EAT_NONE;
}
static int
@@ -1020,7 +1020,7 @@ close_context_cb (char *word[],
}
}
return HEXCHAT_EAT_NONE;
return ZOITECHAT_EAT_NONE;
}
static gboolean
@@ -1044,10 +1044,10 @@ unload_plugin_cb (char *word[], char *word_eol[], void *userdata)
g_signal_emit (obj,
signals[UNLOAD_SIGNAL],
0);
return HEXCHAT_EAT_ALL;
return ZOITECHAT_EAT_ALL;
}
return HEXCHAT_EAT_NONE;
return ZOITECHAT_EAT_NONE;
}
int
@@ -1071,17 +1071,17 @@ dbus_plugin_init (zoitechat_plugin *plugin_handle,
g_object_unref);
zoitechat_hook_print (ph, "Open Context",
HEXCHAT_PRI_NORM,
ZOITECHAT_PRI_NORM,
open_context_cb,
NULL);
zoitechat_hook_print (ph, "Close Context",
HEXCHAT_PRI_NORM,
ZOITECHAT_PRI_NORM,
close_context_cb,
NULL);
zoitechat_hook_command (ph, "unload",
HEXCHAT_PRI_HIGHEST,
ZOITECHAT_PRI_HIGHEST,
unload_plugin_cb, NULL, NULL);
}

View File

@@ -19,8 +19,8 @@
* xclaesse@gmail.com
*/
#ifndef HEXCHAT_DBUS_PLUGIN_H
#define HEXCHAT_DBUS_PLUGIN_H
#ifndef ZOITECHAT_DBUS_PLUGIN_H
#define ZOITECHAT_DBUS_PLUGIN_H
int dbus_plugin_init (zoitechat_plugin *plugin_handle,
char **plugin_name,

View File

@@ -22,8 +22,8 @@
#include <time.h> /* for time_t */
#include "proto-irc.h"
#ifndef HEXCHAT_DCC_H
#define HEXCHAT_DCC_H
#ifndef ZOITECHAT_DCC_H
#define ZOITECHAT_DCC_H
enum dcc_state {
STAT_QUEUED = 0,

View File

@@ -20,8 +20,8 @@
#include "userlist.h"
#include "dcc.h"
#ifndef HEXCHAT_FE_H
#define HEXCHAT_FE_H
#ifndef ZOITECHAT_FE_H
#define ZOITECHAT_FE_H
/* for storage of /menu entries */
typedef struct

View File

@@ -18,14 +18,13 @@
#include <string.h>
#include <stdlib.h>
#include <glib.h>
#include "history.h"
void
history_add (struct history *his, char *text)
{
g_free (his->lines[his->realpos]);
his->lines[his->realpos] = g_strdup (text);
free (his->lines[his->realpos]);
his->lines[his->realpos] = strdup (text);
his->realpos++;
if (his->realpos == HISTORY_SIZE)
his->realpos = 0;
@@ -40,7 +39,7 @@ history_free (struct history *his)
{
if (his->lines[i])
{
g_free (his->lines[i]);
free (his->lines[i]);
his->lines[i] = 0;
}
}

View File

@@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_HISTORY_H
#define HEXCHAT_HISTORY_H
#ifndef ZOITECHAT_HISTORY_H
#define ZOITECHAT_HISTORY_H
#define HISTORY_SIZE 100

View File

@@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_IGNORE_H
#define HEXCHAT_IGNORE_H
#ifndef ZOITECHAT_IGNORE_H
#define ZOITECHAT_IGNORE_H
extern GSList *ignore_list;

View File

@@ -43,6 +43,7 @@
#include "inbound.h"
#include "server.h"
#include "servlist.h"
#include "sts.h"
#include "text.h"
#include "ctcp.h"
#include "zoitechatc.h"
@@ -1722,6 +1723,25 @@ void
inbound_cap_del (server *serv, char *nick, char *extensions,
const message_tags_data *tags_data)
{
if (extensions)
{
char **tokens = g_strsplit (extensions, " ", 0);
int i;
for (i = 0; tokens[i]; i++)
{
if (!g_strcmp0 (tokens[i], "sts") ||
g_str_has_prefix (tokens[i], "sts="))
{
/* STS cannot be disabled via CAP DEL. */
g_strfreev (tokens);
return;
}
}
g_strfreev (tokens);
}
EMIT_SIGNAL_TIMESTAMP (XP_TE_CAPDEL, serv->server_session, nick, extensions,
NULL, NULL, 0, tags_data->timestamp);
@@ -1745,6 +1765,7 @@ static const char * const supported_caps[] = {
"invite-notify",
"account-tag",
"extended-monitor",
"standard-replies",
/* ZNC */
"znc.in/server-time-iso",
@@ -1818,6 +1839,7 @@ inbound_cap_ls (server *serv, char *nick, char *extensions_str,
{
char buffer[500]; /* buffer for requesting capabilities and emitting the signal */
gboolean want_cap = FALSE; /* format the CAP REQ string based on previous capabilities being requested or not */
gboolean sts_upgrade_triggered = FALSE;
char **extensions;
int i;
@@ -1852,6 +1874,15 @@ inbound_cap_ls (server *serv, char *nick, char *extensions_str,
value++;
}
if (!g_strcmp0 (extension, "sts"))
{
if (value)
{
sts_upgrade_triggered |= sts_handle_capability (serv, value);
}
continue;
}
/* if the SASL password is set AND auth mode is set to SASL, request SASL auth */
if (!g_strcmp0 (extension, "sasl") &&
(((serv->loginmethod == LOGIN_SASL
@@ -1887,6 +1918,11 @@ inbound_cap_ls (server *serv, char *nick, char *extensions_str,
g_strfreev (extensions);
if (sts_upgrade_triggered)
{
return;
}
if (want_cap)
{
/* buffer + 9 = emit buffer without "CAP REQ :" */

View File

@@ -19,8 +19,8 @@
#include "proto-irc.h"
#ifndef HEXCHAT_INBOUND_H
#define HEXCHAT_INBOUND_H
#ifndef ZOITECHAT_INBOUND_H
#define ZOITECHAT_INBOUND_H
void inbound_next_nick (session *sess, char *nick, int error,
const message_tags_data *tags_data);

View File

@@ -19,8 +19,8 @@
/* include stuff for internet */
#ifndef HEXCHAT_INET_H
#define HEXCHAT_INET_H
#ifndef ZOITECHAT_INET_H
#define ZOITECHAT_INET_H
#ifndef WIN32

View File

@@ -18,6 +18,7 @@ common_sources = [
'scram.c',
'server.c',
'servlist.c',
'sts.c',
'text.c',
'tree.c',
'url.c',

View File

@@ -19,8 +19,8 @@
#include "proto-irc.h"
#ifndef HEXCHAT_MODES_H
#define HEXCHAT_MODES_H
#ifndef ZOITECHAT_MODES_H
#define ZOITECHAT_MODES_H
int is_channel (server *serv, char *chan);
char get_nick_prefix (server *serv, unsigned int access);

View File

@@ -23,7 +23,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <glib.h>
#include <stdint.h>
#ifndef WIN32
#include <unistd.h>
@@ -54,7 +54,7 @@ net_set_socket_options (int sok)
}
char *
net_ip (guint32 addr)
net_ip (uint32_t addr)
{
struct in_addr ia;
@@ -67,13 +67,13 @@ net_store_destroy (netstore * ns)
{
if (ns->ip6_hostent)
freeaddrinfo (ns->ip6_hostent);
g_free (ns);
free (ns);
}
netstore *
net_store_new (void)
{
return g_new0 (netstore, 1);
return calloc (1, sizeof (netstore));
}
/* =================== IPV6 ================== */
@@ -121,11 +121,11 @@ net_resolve (netstore * ns, char *hostname, int port, char **real_host)
ipstring, sizeof (ipstring), NULL, 0, NI_NUMERICHOST);
if (ns->ip6_hostent->ai_canonname)
*real_host = g_strdup (ns->ip6_hostent->ai_canonname);
*real_host = strdup (ns->ip6_hostent->ai_canonname);
else
*real_host = g_strdup (hostname);
*real_host = strdup (hostname);
return g_strdup (ipstring);
return strdup (ipstring);
}
/* the only thing making this interface unclean, this shitty sok4, sok6 business */

View File

@@ -17,8 +17,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_NETWORK_H
#define HEXCHAT_NETWORK_H
#ifndef ZOITECHAT_NETWORK_H
#define ZOITECHAT_NETWORK_H
#include <stdint.h>
typedef struct netstore_
{
@@ -36,7 +38,7 @@ void net_store_destroy (netstore *ns);
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 (guint32 addr);
char *net_ip (uint32_t addr);
void net_sockets (int *sok4, int *sok6);
#endif

View File

@@ -478,7 +478,7 @@ notify_markonline (server *serv, char *word[], const message_tags_data *tags_dat
about 27 people */
if (i > PDIWORDS - 5)
{
/*fprintf (stderr, _("*** HEXCHAT WARNING: notify list too large.\n"));*/
/*fprintf (stderr, _("*** ZOITECHAT WARNING: notify list too large.\n"));*/
break;
}
}
@@ -515,7 +515,7 @@ notify_checklist_for_server (server *serv)
/* LAME: we can't send more than 512 bytes to the server, but *
* if we split it in two packets, our offline detection wouldn't *
work */
/*fprintf (stderr, _("*** HEXCHAT WARNING: notify list too large.\n"));*/
/*fprintf (stderr, _("*** ZOITECHAT WARNING: notify list too large.\n"));*/
break;
}
}

View File

@@ -19,8 +19,8 @@
#include "proto-irc.h"
#ifndef HEXCHAT_NOTIFY_H
#define HEXCHAT_NOTIFY_H
#ifndef ZOITECHAT_NOTIFY_H
#define ZOITECHAT_NOTIFY_H
struct notify
{

View File

@@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_OUTBOUND_H
#define HEXCHAT_OUTBOUND_H
#ifndef ZOITECHAT_OUTBOUND_H
#define ZOITECHAT_OUTBOUND_H
#include "zoitechat.h"

View File

@@ -73,7 +73,7 @@ identd_cleanup_response_cb (gpointer userdata)
static int
identd_command_cb (char *word[], char *word_eol[], void *userdata)
{
g_return_val_if_fail (responses != NULL, HEXCHAT_EAT_ALL);
g_return_val_if_fail (responses != NULL, ZOITECHAT_EAT_ALL);
if (!g_strcmp0 (word[2], "reload"))
{
@@ -86,11 +86,11 @@ identd_command_cb (char *word[], char *word_eol[], void *userdata)
identd_start_server ();
if (service)
return HEXCHAT_EAT_ALL;
return ZOITECHAT_EAT_ALL;
}
if (service == NULL) /* If we are not running plugins can handle it */
return HEXCHAT_EAT_HEXCHAT;
return ZOITECHAT_EAT_ZOITECHAT;
if (word[2] && *word[2] && word[3] && *word[3])
{
@@ -108,7 +108,7 @@ identd_command_cb (char *word[], char *word_eol[], void *userdata)
zoitechat_command (ph, "HELP IDENTD");
}
return HEXCHAT_EAT_ALL;
return ZOITECHAT_EAT_ALL;
}
static void
@@ -258,7 +258,7 @@ identd_plugin_init (zoitechat_plugin *plugin_handle, char **plugin_name,
responses = g_hash_table_new_full (NULL, NULL, NULL, g_free);
zoitechat_hook_command (ph, "IDENTD", HEXCHAT_PRI_NORM, identd_command_cb,
zoitechat_hook_command (ph, "IDENTD", ZOITECHAT_PRI_NORM, identd_command_cb,
_("IDENTD <port> <username>"), NULL);
identd_start_server ();

View File

@@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_PLUGIN_IDENTD_H
#define HEXCHAT_PLUGIN_IDENTD_H
#ifndef ZOITECHAT_PLUGIN_IDENTD_H
#define ZOITECHAT_PLUGIN_IDENTD_H
int identd_plugin_init (zoitechat_plugin *plugin_handle, char **plugin_name,
char **plugin_desc, char **plugin_version, char *arg);

View File

@@ -171,7 +171,7 @@ timer_cb (char *word[], char *word_eol[], void *userdata)
if (!word[2][0])
{
timer_showlist ();
return HEXCHAT_EAT_HEXCHAT;
return ZOITECHAT_EAT_ZOITECHAT;
}
if (g_ascii_strcasecmp (word[2], "-quiet") == 0)
@@ -183,7 +183,7 @@ timer_cb (char *word[], char *word_eol[], void *userdata)
if (g_ascii_strcasecmp (word[2 + offset], "-delete") == 0)
{
timer_del_ref (atoi (word[3 + offset]), quiet);
return HEXCHAT_EAT_HEXCHAT;
return ZOITECHAT_EAT_ZOITECHAT;
}
if (g_ascii_strcasecmp (word[2 + offset], "-refnum") == 0)
@@ -206,7 +206,7 @@ timer_cb (char *word[], char *word_eol[], void *userdata)
else
timer_add (ref, (int) timeout * 1000, repeat, command);
return HEXCHAT_EAT_HEXCHAT;
return ZOITECHAT_EAT_ZOITECHAT;
}
int
@@ -225,7 +225,7 @@ zoitechat_plugin_init
*plugin_desc = "IrcII style /TIMER command";
*plugin_version = "";
zoitechat_hook_command (ph, "TIMER", HEXCHAT_PRI_NORM, timer_cb, _(HELP), 0);
zoitechat_hook_command (ph, "TIMER", ZOITECHAT_PRI_NORM, timer_cb, _(HELP), 0);
return 1; /* return 1 for success */
}

View File

@@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_PLUGIN_TIMER_H
#define HEXCHAT_PLUGIN_TIMER_H
#ifndef ZOITECHAT_PLUGIN_TIMER_H
#define ZOITECHAT_PLUGIN_TIMER_H
int timer_plugin_init (zoitechat_plugin *plugin_handle, char **plugin_name,
char **plugin_desc, char **plugin_version, char *arg);

View File

@@ -466,11 +466,11 @@ plugin_get_libdir (void)
{
const char *libdir;
libdir = g_getenv ("HEXCHAT_LIBDIR");
libdir = g_getenv ("ZOITECHAT_LIBDIR");
if (libdir && *libdir)
return libdir;
else
return HEXCHATLIBDIR;
return ZOITECHATLIBDIR;
}
void
@@ -608,14 +608,14 @@ plugin_hook_run (session *sess, char *name, char *word[], char *word_eol[],
break;
}
if ((ret & HEXCHAT_EAT_HEXCHAT) && (ret & HEXCHAT_EAT_PLUGIN))
if ((ret & ZOITECHAT_EAT_ZOITECHAT) && (ret & ZOITECHAT_EAT_PLUGIN))
{
eat = 1;
goto xit;
}
if (ret & HEXCHAT_EAT_PLUGIN)
if (ret & ZOITECHAT_EAT_PLUGIN)
goto xit; /* stop running plugins */
if (ret & HEXCHAT_EAT_HEXCHAT)
if (ret & ZOITECHAT_EAT_ZOITECHAT)
eat = 1; /* eventually we'll return 1, but continue running plugins */
list = next;
@@ -801,11 +801,11 @@ plugin_fd_cb (GIOChannel *source, GIOCondition condition, zoitechat_hook *hook)
typedef int (zoitechat_fd_cb2) (int fd, int flags, void *user_data, GIOChannel *);
if (condition & G_IO_IN)
flags |= HEXCHAT_FD_READ;
flags |= ZOITECHAT_FD_READ;
if (condition & G_IO_OUT)
flags |= HEXCHAT_FD_WRITE;
flags |= ZOITECHAT_FD_WRITE;
if (condition & G_IO_PRI)
flags |= HEXCHAT_FD_EXCEPTION;
flags |= ZOITECHAT_FD_EXCEPTION;
ret = ((zoitechat_fd_cb2 *)hook->callback) (hook->pri, flags, hook->userdata, source);

View File

@@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_COMMONPLUGIN_H
#define HEXCHAT_COMMONPLUGIN_H
#ifndef ZOITECHAT_COMMONPLUGIN_H
#define ZOITECHAT_COMMONPLUGIN_H
#ifdef PLUGIN_C
struct _zoitechat_plugin

View File

@@ -20,8 +20,8 @@
#include <time.h>
#include "zoitechat.h"
#ifndef HEXCHAT_PROTO_H
#define HEXCHAT_PROTO_H
#ifndef ZOITECHAT_PROTO_H
#define ZOITECHAT_PROTO_H
#define MESSAGE_TAGS_DATA_INIT \
{ \

View File

@@ -15,8 +15,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_SCRAM_H
#define HEXCHAT_SCRAM_H
#ifndef ZOITECHAT_SCRAM_H
#define ZOITECHAT_SCRAM_H
#include "config.h"
#ifdef USE_OPENSSL

View File

@@ -54,6 +54,7 @@
#include "proto-irc.h"
#include "servlist.h"
#include "server.h"
#include "sts.h"
#ifdef USE_OPENSSL
#include <openssl/ssl.h> /* SSL_() */
@@ -396,7 +397,7 @@ server_read (GIOChannel *source, GIOCondition condition, server *serv)
serv->linebuf[serv->pos] = lbuf[i];
if (serv->pos >= (sizeof (serv->linebuf) - 1))
fprintf (stderr,
"*** HEXCHAT WARNING: Buffer overflow - non-compliant server!\n");
"*** ZOITECHAT WARNING: Buffer overflow - non-compliant server!\n");
else
serv->pos++;
}
@@ -1034,6 +1035,8 @@ server_disconnect (session * sess, int sendquit, int err)
server_sendquit (sess);
}
sts_reschedule_on_disconnect (serv);
fe_server_event (serv, FE_SE_DISCONNECT, 0);
/* close all sockets & io tags */
@@ -1588,6 +1591,15 @@ server_connect (server *serv, char *hostname, int port, int no_login)
int pid, read_des[2];
session *sess = serv->server_session;
if (!hostname[0])
return;
safe_strcpy (serv->sts_host, hostname, sizeof (serv->sts_host));
if (!sts_apply_policy_for_connection (serv, hostname, &port))
{
return;
}
#ifdef USE_OPENSSL
if (!serv->ctx && serv->use_ssl)
{
@@ -1599,9 +1611,6 @@ server_connect (server *serv, char *hostname, int port, int no_login)
}
#endif
if (!hostname[0])
return;
if (port < 1 || port > 65535)
{
/* use default port for this server type */
@@ -1842,6 +1851,8 @@ server_set_defaults (server *serv)
serv->have_sasl = FALSE;
serv->have_except = FALSE;
serv->have_invite = FALSE;
serv->sts_duration_seen = FALSE;
serv->sts_upgrade_in_progress = FALSE;
}
char *

View File

@@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_SERVER_H
#define HEXCHAT_SERVER_H
#ifndef ZOITECHAT_SERVER_H
#define ZOITECHAT_SERVER_H
extern GSList *serv_list;

View File

@@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_SERVLIST_H
#define HEXCHAT_SERVLIST_H
#ifndef ZOITECHAT_SERVLIST_H
#define ZOITECHAT_SERVLIST_H
typedef struct ircserver
{

View File

@@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_SSL_H
#define HEXCHAT_SSL_H
#ifndef ZOITECHAT_SSL_H
#define ZOITECHAT_SSL_H
struct cert_info {
char subject[256];

641
src/common/sts.c Normal file
View File

@@ -0,0 +1,641 @@
/* ZoiteChat
* Copyright (C) 2024
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <glib.h>
#include <time.h>
#include <fcntl.h>
#ifdef WIN32
#include <io.h>
#else
#include <unistd.h>
#endif
#include "zoitechat.h"
#include "cfgfiles.h"
#include "util.h"
#include "text.h"
#include "sts.h"
static GHashTable *sts_profiles = NULL;
static gboolean sts_loaded = FALSE;
static gboolean
sts_parse_bool (const char *value)
{
if (!value || !*value)
{
return FALSE;
}
return g_ascii_strcasecmp (value, "1") == 0 ||
g_ascii_strcasecmp (value, "true") == 0 ||
g_ascii_strcasecmp (value, "yes") == 0;
}
sts_profile *
sts_profile_new (const char *host, guint16 port, time_t expires_at, guint64 duration, gboolean preload)
{
sts_profile *profile = g_new0 (sts_profile, 1);
profile->host = g_strdup (host);
profile->port = port;
profile->expires_at = expires_at;
profile->duration = duration;
profile->preload = preload;
return profile;
}
void
sts_profile_free (sts_profile *profile)
{
if (!profile)
{
return;
}
g_free (profile->host);
g_free (profile);
}
char *
sts_profile_serialize (const sts_profile *profile)
{
GString *serialized;
char *escaped_host;
char *result;
if (!profile || !profile->host || !*profile->host)
{
return NULL;
}
escaped_host = g_strdup (profile->host);
serialized = g_string_new (escaped_host);
g_free (escaped_host);
g_string_append_printf (serialized, " %u %" G_GINT64_FORMAT,
profile->port, (gint64) profile->expires_at);
if (profile->duration > 0)
{
g_string_append_printf (serialized, " %" G_GUINT64_FORMAT, profile->duration);
}
if (profile->preload)
{
g_string_append (serialized, " 1");
}
result = g_string_free (serialized, FALSE);
return result;
}
sts_profile *
sts_profile_deserialize (const char *serialized)
{
char *host = NULL;
guint16 port = 0;
gint64 expires_at = -1;
guint64 duration = 0;
gboolean preload = FALSE;
gboolean duration_seen = FALSE;
gchar **pairs = NULL;
int i = 0;
if (!serialized || !*serialized)
{
return NULL;
}
pairs = g_strsplit_set (serialized, " \t", -1);
{
const char *fields[5] = {0};
int field_count = 0;
for (i = 0; pairs[i]; i++)
{
if (!pairs[i][0])
{
continue;
}
if (field_count < 5)
{
fields[field_count++] = pairs[i];
}
}
if (field_count >= 3)
{
host = g_strdup (fields[0]);
gint64 port_value = g_ascii_strtoll (fields[1], NULL, 10);
if (port_value > 0 && port_value <= G_MAXUINT16)
{
port = (guint16) port_value;
}
expires_at = g_ascii_strtoll (fields[2], NULL, 10);
if (field_count >= 4)
{
if (field_count == 4 && sts_parse_bool (fields[3]))
{
preload = TRUE;
}
else
{
duration = g_ascii_strtoull (fields[3], NULL, 10);
duration_seen = TRUE;
}
}
if (field_count >= 5)
{
duration_seen = TRUE;
preload = sts_parse_bool (fields[4]);
}
}
}
if (!host || !*host || expires_at < 0)
{
g_free (host);
g_strfreev (pairs);
return NULL;
}
if (!duration_seen && duration == 0 && expires_at > 0)
{
time_t now = time (NULL);
if (expires_at > now)
{
duration = (guint64) (expires_at - now);
}
}
sts_profile *profile = sts_profile_new (host, port, (time_t) expires_at, duration, preload);
g_free (host);
g_strfreev (pairs);
return profile;
}
static char *
sts_normalize_host (const char *host)
{
char *normalized;
gsize len;
if (!host || !*host)
{
return NULL;
}
normalized = g_ascii_strdown (host, -1);
g_strstrip (normalized);
len = strlen (normalized);
if (len > 2 && normalized[0] == '[' && normalized[len - 1] == ']')
{
char *trimmed = g_strndup (normalized + 1, len - 2);
g_free (normalized);
normalized = trimmed;
}
return normalized;
}
static void
sts_profiles_ensure (void)
{
if (!sts_profiles)
{
sts_profiles = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
(GDestroyNotify) sts_profile_free);
}
}
static void
sts_profile_store (sts_profile *profile)
{
char *normalized;
if (!profile || !profile->host)
{
sts_profile_free (profile);
return;
}
sts_profiles_ensure ();
normalized = sts_normalize_host (profile->host);
if (!normalized)
{
sts_profile_free (profile);
return;
}
g_hash_table_replace (sts_profiles, normalized, profile);
}
static void
sts_profile_remove (const char *host)
{
char *normalized;
if (!host)
{
return;
}
sts_profiles_ensure ();
normalized = sts_normalize_host (host);
if (!normalized)
{
return;
}
g_hash_table_remove (sts_profiles, normalized);
g_free (normalized);
}
static sts_profile *
sts_profile_lookup (const char *host, time_t now)
{
char *normalized;
sts_profile *profile = NULL;
sts_profiles_ensure ();
normalized = sts_normalize_host (host);
if (!normalized)
{
return NULL;
}
profile = g_hash_table_lookup (sts_profiles, normalized);
if (profile && profile->expires_at > 0 && profile->expires_at <= now)
{
g_hash_table_remove (sts_profiles, normalized);
profile = NULL;
}
g_free (normalized);
return profile;
}
static gboolean
sts_parse_value (const char *value, guint16 *port, guint64 *duration, gboolean *preload,
gboolean *has_port, gboolean *has_duration, gboolean *has_preload)
{
char **tokens;
gsize i;
if (!value || !*value)
{
return FALSE;
}
*has_port = FALSE;
*has_duration = FALSE;
*has_preload = FALSE;
tokens = g_strsplit (value, ",", -1);
for (i = 0; tokens[i]; i++)
{
char *token = g_strstrip (tokens[i]);
char *equals = strchr (token, '=');
char *key = token;
char *val = NULL;
if (!*token)
{
continue;
}
if (equals)
{
*equals = '\0';
val = equals + 1;
}
if (!g_ascii_strcasecmp (key, "port"))
{
gint64 port_value;
if (*has_port || !val)
{
continue;
}
port_value = g_ascii_strtoll (val, NULL, 10);
if (port_value > 0 && port_value <= G_MAXUINT16)
{
*port = (guint16) port_value;
*has_port = TRUE;
}
}
else if (!g_ascii_strcasecmp (key, "duration"))
{
guint64 duration_value;
if (*has_duration || !val)
{
continue;
}
duration_value = g_ascii_strtoull (val, NULL, 10);
*duration = duration_value;
*has_duration = TRUE;
}
else if (!g_ascii_strcasecmp (key, "preload"))
{
if (*has_preload)
{
continue;
}
*preload = TRUE;
*has_preload = TRUE;
}
}
g_strfreev (tokens);
return TRUE;
}
void
sts_init (void)
{
sts_profiles_ensure ();
if (sts_loaded)
{
return;
}
sts_loaded = TRUE;
{
int fh;
char buf[512];
fh = zoitechat_open_file ("sts.conf", O_RDONLY, 0, 0);
if (fh != -1)
{
while (waitline (fh, buf, sizeof buf, FALSE) != -1)
{
if (buf[0] == '#' || buf[0] == '\0')
{
continue;
}
sts_profile *profile = sts_profile_deserialize (buf);
if (!profile)
{
continue;
}
if (profile->expires_at <= time (NULL))
{
sts_profile_free (profile);
continue;
}
if (profile->duration == 0)
{
sts_profile_free (profile);
continue;
}
sts_profile_store (profile);
}
close (fh);
}
}
}
void
sts_save (void)
{
GHashTableIter iter;
gpointer key;
gpointer value;
int fh;
sts_profiles_ensure ();
fh = zoitechat_open_file ("sts.conf", O_TRUNC | O_WRONLY | O_CREAT, 0600, XOF_DOMODE);
if (fh == -1)
{
return;
}
g_hash_table_iter_init (&iter, sts_profiles);
while (g_hash_table_iter_next (&iter, &key, &value))
{
sts_profile *profile = value;
char *serialized;
if (!profile || profile->expires_at <= time (NULL) || profile->duration == 0)
{
continue;
}
serialized = sts_profile_serialize (profile);
if (serialized)
{
write (fh, serialized, strlen (serialized));
write (fh, "\n", 1);
g_free (serialized);
}
}
close (fh);
}
void
sts_cleanup (void)
{
if (!sts_profiles)
{
return;
}
sts_save ();
g_hash_table_destroy (sts_profiles);
sts_profiles = NULL;
sts_loaded = FALSE;
}
gboolean
sts_apply_policy_for_connection (struct server *serv, const char *hostname, int *port)
{
sts_profile *profile;
time_t now;
if (!hostname || !*hostname || !port)
{
return TRUE;
}
sts_init ();
sts_profiles_ensure ();
now = time (NULL);
profile = sts_profile_lookup (hostname, now);
if (!profile)
{
return TRUE;
}
if (profile->port == 0)
{
sts_profile_remove (hostname);
return TRUE;
}
#ifdef USE_OPENSSL
serv->use_ssl = TRUE;
if (profile->port > 0)
{
*port = profile->port;
}
return TRUE;
#else
PrintTextf (serv->server_session,
_("STS policy requires TLS for %s, but TLS is not available.\n"),
hostname);
return FALSE;
#endif
}
gboolean
sts_handle_capability (struct server *serv, const char *value)
{
guint16 port = 0;
guint64 duration = 0;
gboolean preload = FALSE;
gboolean has_port = FALSE;
gboolean has_duration = FALSE;
gboolean has_preload = FALSE;
const char *hostname;
if (!serv || !value)
{
return FALSE;
}
sts_init ();
if (!sts_parse_value (value, &port, &duration, &preload,
&has_port, &has_duration, &has_preload))
{
return FALSE;
}
hostname = serv->sts_host[0] ? serv->sts_host : serv->servername;
if (!hostname || !*hostname)
{
return FALSE;
}
if (!serv->use_ssl)
{
if (!has_port)
{
if (serv->port > 0)
{
port = (guint16) serv->port;
has_port = TRUE;
}
else
{
return FALSE;
}
}
#ifdef USE_OPENSSL
if (serv->sts_upgrade_in_progress)
{
return TRUE;
}
serv->sts_upgrade_in_progress = TRUE;
serv->use_ssl = TRUE;
{
char host_copy[128];
safe_strcpy (host_copy, hostname, sizeof (host_copy));
serv->disconnect (serv->server_session, FALSE, -1);
serv->connect (serv, host_copy, (int) port, serv->no_login);
}
#else
PrintTextf (serv->server_session,
_("STS upgrade requested for %s, but TLS is not available.\n"),
hostname);
#endif
return TRUE;
}
if (!has_duration)
{
return FALSE;
}
if (duration == 0)
{
sts_profile_remove (hostname);
serv->sts_duration_seen = FALSE;
return FALSE;
}
{
time_t now = time (NULL);
time_t expires_at = now + (time_t) duration;
guint16 effective_port = serv->port > 0 ? (guint16) serv->port : port;
sts_profile *profile;
if (effective_port == 0)
{
return FALSE;
}
profile = sts_profile_new (hostname, effective_port, expires_at, duration,
has_preload ? preload : FALSE);
sts_profile_store (profile);
serv->sts_duration_seen = TRUE;
}
return FALSE;
}
void
sts_reschedule_on_disconnect (struct server *serv)
{
sts_profile *profile;
time_t now;
if (!serv || !serv->sts_duration_seen)
{
return;
}
sts_init ();
now = time (NULL);
profile = sts_profile_lookup (serv->sts_host[0] ? serv->sts_host : serv->servername, now);
if (!profile || profile->duration == 0)
{
return;
}
profile->expires_at = now + (time_t) profile->duration;
}

53
src/common/sts.h Normal file
View File

@@ -0,0 +1,53 @@
/* ZoiteChat
* Copyright (C) 2024
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_STS_H
#define HEXCHAT_STS_H
#include <glib.h>
#include <time.h>
G_BEGIN_DECLS
struct server;
typedef struct sts_profile
{
char *host;
guint16 port;
time_t expires_at;
guint64 duration;
gboolean preload;
} sts_profile;
sts_profile *sts_profile_new (const char *host, guint16 port, time_t expires_at, guint64 duration, gboolean preload);
void sts_profile_free (sts_profile *profile);
char *sts_profile_serialize (const sts_profile *profile);
sts_profile *sts_profile_deserialize (const char *serialized);
void sts_init (void);
void sts_save (void);
void sts_cleanup (void);
gboolean sts_apply_policy_for_connection (struct server *serv, const char *hostname, int *port);
gboolean sts_handle_capability (struct server *serv, const char *value);
void sts_reschedule_on_disconnect (struct server *serv);
G_END_DECLS
#endif

View File

@@ -1,13 +1,13 @@
#ifndef HEXCHAT_SYSINFO_H
#define HEXCHAT_SYSINFO_H
#ifndef ZOITECHAT_SYSINFO_H
#define ZOITECHAT_SYSINFO_H
#include <glib.h>
#include <stdint.h>
int sysinfo_get_cpu_arch (void);
int sysinfo_get_build_arch (void);
char *sysinfo_get_cpu (void);
char *sysinfo_get_os (void);
void sysinfo_get_hdd_info (guint64 *hdd_capacity_out, guint64 *hdd_free_space_out);
void sysinfo_get_hdd_info (uint64_t *hdd_capacity_out, uint64_t *hdd_free_space_out);
char *sysinfo_get_gpu (void);
#endif

View File

@@ -20,7 +20,14 @@
* THE SOFTWARE.
*/
#include <ctype.h>
#include <inttypes.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#include <windows.h>
#include <wbemidl.h>
@@ -47,12 +54,26 @@ static char *read_os_name (IWbemClassObject *object);
static char *read_cpu_info (IWbemClassObject *object);
static char *read_vga_name (IWbemClassObject *object);
static guint64 hdd_capacity;
static guint64 hdd_free_space;
static uint64_t hdd_capacity;
static uint64_t hdd_free_space;
static char *read_hdd_info (IWbemClassObject *object);
static char *bstr_to_utf8 (BSTR bstr);
static guint64 variant_to_uint64 (VARIANT *variant);
static uint64_t variant_to_uint64 (VARIANT *variant);
static char *zoitechat_strdup (const char *value);
static char *zoitechat_strdup_printf (const char *format, ...);
static char *zoitechat_strchomp (char *value);
typedef struct
{
char *data;
size_t len;
size_t cap;
} StringBuilder;
static bool string_builder_init (StringBuilder *builder);
static void string_builder_free (StringBuilder *builder);
static bool string_builder_append (StringBuilder *builder, const char *text);
char *
sysinfo_get_cpu (void)
@@ -60,7 +81,7 @@ sysinfo_get_cpu (void)
if (cpu_info == NULL)
cpu_info = query_wmi (QUERY_WMI_CPU);
return g_strdup (cpu_info);
return zoitechat_strdup (cpu_info);
}
char *
@@ -69,7 +90,12 @@ sysinfo_get_os (void)
if (os_name == NULL)
os_name = query_wmi (QUERY_WMI_OS);
return g_strdup_printf ("%s (x%d)", os_name, sysinfo_get_cpu_arch ());
if (os_name == NULL)
{
return NULL;
}
return zoitechat_strdup_printf ("%s (x%d)", os_name, sysinfo_get_cpu_arch ());
}
int
@@ -124,11 +150,11 @@ sysinfo_get_gpu (void)
if (vga_name == NULL)
vga_name = query_wmi (QUERY_WMI_VGA);
return g_strdup (vga_name);
return zoitechat_strdup (vga_name);
}
void
sysinfo_get_hdd_info (guint64 *hdd_capacity_out, guint64 *hdd_free_space_out)
sysinfo_get_hdd_info (uint64_t *hdd_capacity_out, uint64_t *hdd_free_space_out)
{
char *hdd_info;
@@ -149,7 +175,8 @@ sysinfo_get_hdd_info (guint64 *hdd_capacity_out, guint64 *hdd_free_space_out)
/* https://msdn.microsoft.com/en-us/library/aa390423 */
static char *query_wmi (QueryWmiType type)
{
GString *result = NULL;
StringBuilder result;
bool result_initialized = false;
HRESULT hr;
IWbemLocator *locator = NULL;
@@ -160,7 +187,7 @@ static char *query_wmi (QueryWmiType type)
IUnknown *namespaceUnknown = NULL;
IEnumWbemClassObject *enumerator = NULL;
int i;
gboolean atleast_one_appended = FALSE;
bool atleast_one_appended = false;
hr = CoCreateInstance (&CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER, &IID_IWbemLocator, (LPVOID *) &locator);
if (FAILED (hr))
@@ -214,7 +241,11 @@ static char *query_wmi (QueryWmiType type)
goto release_query;
}
result = g_string_new ("");
if (!string_builder_init (&result))
{
goto release_query;
}
result_initialized = true;
for (i = 0;; i++)
{
@@ -256,14 +287,22 @@ static char *query_wmi (QueryWmiType type)
{
if (atleast_one_appended)
{
g_string_append (result, ", ");
if (!string_builder_append (&result, ", "))
{
free (line);
goto release_query;
}
}
g_string_append (result, line);
if (!string_builder_append (&result, line))
{
free (line);
goto release_query;
}
g_free (line);
free (line);
atleast_one_appended = TRUE;
atleast_one_appended = true;
}
}
@@ -286,12 +325,12 @@ release_locator:
SysFreeString (namespaceName);
exit:
if (result == NULL)
if (!result_initialized || result.data == NULL)
{
return NULL;
}
return g_string_free (result, FALSE);
return result.data;
}
static char *read_os_name (IWbemClassObject *object)
@@ -315,7 +354,7 @@ static char *read_os_name (IWbemClassObject *object)
return NULL;
}
g_strchomp (caption_utf8);
zoitechat_strchomp (caption_utf8);
return caption_utf8;
}
@@ -326,7 +365,7 @@ static char *read_cpu_info (IWbemClassObject *object)
VARIANT name_variant;
char *name_utf8;
VARIANT max_clock_speed_variant;
guint cpu_freq_mhz;
uint32_t cpu_freq_mhz;
char *result;
hr = object->lpVtbl->Get (object, L"Name", 0, &name_variant, NULL, NULL);
@@ -347,7 +386,7 @@ static char *read_cpu_info (IWbemClassObject *object)
hr = object->lpVtbl->Get (object, L"MaxClockSpeed", 0, &max_clock_speed_variant, NULL, NULL);
if (FAILED (hr))
{
g_free (name_utf8);
free (name_utf8);
return NULL;
}
@@ -356,18 +395,18 @@ static char *read_cpu_info (IWbemClassObject *object)
VariantClear (&max_clock_speed_variant);
g_strchomp (name_utf8);
zoitechat_strchomp (name_utf8);
if (cpu_freq_mhz > 1000)
{
result = g_strdup_printf ("%s (%.2fGHz)", name_utf8, cpu_freq_mhz / 1000.f);
result = zoitechat_strdup_printf ("%s (%.2fGHz)", name_utf8, cpu_freq_mhz / 1000.f);
}
else
{
result = g_strdup_printf ("%s (%" G_GUINT32_FORMAT "MHz)", name_utf8, cpu_freq_mhz);
result = zoitechat_strdup_printf ("%s (%" PRIu32 "MHz)", name_utf8, cpu_freq_mhz);
}
g_free (name_utf8);
free (name_utf8);
return result;
}
@@ -393,7 +432,7 @@ static char *read_vga_name (IWbemClassObject *object)
return NULL;
}
return g_strchomp (name_utf8);
return zoitechat_strchomp (name_utf8);
}
static char *read_hdd_info (IWbemClassObject *object)
@@ -401,11 +440,11 @@ static char *read_hdd_info (IWbemClassObject *object)
HRESULT hr;
VARIANT name_variant;
BSTR name_bstr;
gsize name_len;
size_t name_len;
VARIANT capacity_variant;
guint64 capacity;
uint64_t capacity;
VARIANT free_space_variant;
guint64 free_space;
uint64_t free_space;
hr = object->lpVtbl->Get (object, L"Name", 0, &name_variant, NULL, NULL);
if (FAILED (hr))
@@ -464,10 +503,38 @@ static char *read_hdd_info (IWbemClassObject *object)
static char *bstr_to_utf8 (BSTR bstr)
{
return g_utf16_to_utf8 (bstr, SysStringLen (bstr), NULL, NULL, NULL);
int utf8_len;
char *utf8;
if (bstr == NULL)
{
return NULL;
}
utf8_len = WideCharToMultiByte (CP_UTF8, 0, bstr, SysStringLen (bstr), NULL, 0, NULL, NULL);
if (utf8_len <= 0)
{
return NULL;
}
utf8 = malloc ((size_t) utf8_len + 1);
if (utf8 == NULL)
{
return NULL;
}
if (WideCharToMultiByte (CP_UTF8, 0, bstr, SysStringLen (bstr), utf8, utf8_len, NULL, NULL) <= 0)
{
free (utf8);
return NULL;
}
utf8[utf8_len] = '\0';
return utf8;
}
static guint64 variant_to_uint64 (VARIANT *variant)
static uint64_t variant_to_uint64 (VARIANT *variant)
{
switch (V_VT (variant))
{
@@ -481,3 +548,139 @@ static guint64 variant_to_uint64 (VARIANT *variant)
return 0;
}
}
static char *zoitechat_strdup (const char *value)
{
size_t len;
char *copy;
if (value == NULL)
{
return NULL;
}
len = strlen (value);
copy = malloc (len + 1);
if (copy == NULL)
{
return NULL;
}
memcpy (copy, value, len + 1);
return copy;
}
static char *zoitechat_strdup_printf (const char *format, ...)
{
va_list args;
va_list args_copy;
int length;
char *buffer;
va_start (args, format);
va_copy (args_copy, args);
length = vsnprintf (NULL, 0, format, args_copy);
va_end (args_copy);
if (length < 0)
{
va_end (args);
return NULL;
}
buffer = malloc ((size_t) length + 1);
if (buffer == NULL)
{
va_end (args);
return NULL;
}
vsnprintf (buffer, (size_t) length + 1, format, args);
va_end (args);
return buffer;
}
static char *zoitechat_strchomp (char *value)
{
size_t len;
if (value == NULL)
{
return NULL;
}
len = strlen (value);
while (len > 0 && isspace ((unsigned char) value[len - 1]) != 0)
{
value[len - 1] = '\0';
len--;
}
return value;
}
static bool string_builder_init (StringBuilder *builder)
{
builder->cap = 64;
builder->len = 0;
builder->data = malloc (builder->cap);
if (builder->data == NULL)
{
return false;
}
builder->data[0] = '\0';
return true;
}
static void string_builder_free (StringBuilder *builder)
{
if (builder->data != NULL)
{
free (builder->data);
builder->data = NULL;
}
builder->len = 0;
builder->cap = 0;
}
static bool string_builder_append (StringBuilder *builder, const char *text)
{
size_t add_len;
size_t needed;
size_t new_cap;
char *new_data;
if (text == NULL)
{
return true;
}
add_len = strlen (text);
needed = builder->len + add_len + 1;
if (needed > builder->cap)
{
new_cap = builder->cap;
while (new_cap < needed)
{
new_cap *= 2;
}
new_data = realloc (builder->data, new_cap);
if (new_data == NULL)
{
string_builder_free (builder);
return false;
}
builder->data = new_data;
builder->cap = new_cap;
}
memcpy (builder->data + builder->len, text, add_len);
builder->len += add_len;
builder->data[builder->len] = '\0';
return true;
}

View File

@@ -2237,7 +2237,7 @@ sound_play (const char *file, gboolean quiet)
}
else
{
wavfile = g_build_filename (get_xdir (), HEXCHAT_SOUND_DIR, file, NULL);
wavfile = g_build_filename (get_xdir (), ZOITECHAT_SOUND_DIR, file, NULL);
}
if (g_access (wavfile, R_OK) == 0)

View File

@@ -20,8 +20,8 @@
#include <time.h>
#include "textenums.h"
#ifndef HEXCHAT_TEXT_H
#define HEXCHAT_TEXT_H
#ifndef ZOITECHAT_TEXT_H
#define ZOITECHAT_TEXT_H
/* timestamp is non-zero if we are using server-time */
#define EMIT_SIGNAL_TIMESTAMP(i, sess, a, b, c, d, e, timestamp) \

View File

@@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_TREE_H
#define HEXCHAT_TREE_H
#ifndef ZOITECHAT_TREE_H
#define ZOITECHAT_TREE_H
#include <glib.h>

View File

@@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_TYPEDEF_H
#define HEXCHAT_TYPEDEF_H
#ifndef ZOITECHAT_TYPEDEF_H
#define ZOITECHAT_TYPEDEF_H
#ifdef WIN32

View File

@@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_URL_H
#define HEXCHAT_URL_H
#ifndef ZOITECHAT_URL_H
#define ZOITECHAT_URL_H
extern void *url_tree;

View File

@@ -20,8 +20,8 @@
#include <time.h>
#include "proto-irc.h"
#ifndef HEXCHAT_USERLIST_H
#define HEXCHAT_USERLIST_H
#ifndef ZOITECHAT_USERLIST_H
#define ZOITECHAT_USERLIST_H
struct User
{

View File

@@ -214,11 +214,13 @@ waitline2 (GIOChannel *source, char *buf, int bufsize)
gsize len;
GError *error = NULL;
if (g_io_channel_get_buffered (source))
{
g_io_channel_set_encoding (source, NULL, &error);
g_io_channel_set_buffered (source, FALSE);
}
while (1)
{
g_io_channel_set_buffered (source, FALSE);
g_io_channel_set_encoding (source, NULL, &error);
if (g_io_channel_read_chars (source, &buf[i], 1, &len, &error) != G_IO_STATUS_NORMAL)
{
return -1;

View File

@@ -30,8 +30,8 @@
* --+ Dagmar d'Surreal
*/
#ifndef HEXCHAT_UTIL_H
#define HEXCHAT_UTIL_H
#ifndef ZOITECHAT_UTIL_H
#define ZOITECHAT_UTIL_H
#define rfc_tolower(c) (rfc_tolowertab[(unsigned char)(c)])

View File

@@ -18,26 +18,26 @@
*/
/* You can distribute this header with your plugins for easy compilation */
#ifndef HEXCHAT_PLUGIN_H
#define HEXCHAT_PLUGIN_H
#ifndef ZOITECHAT_PLUGIN_H
#define ZOITECHAT_PLUGIN_H
#include <time.h>
#define HEXCHAT_PRI_HIGHEST 127
#define HEXCHAT_PRI_HIGH 64
#define HEXCHAT_PRI_NORM 0
#define HEXCHAT_PRI_LOW (-64)
#define HEXCHAT_PRI_LOWEST (-128)
#define ZOITECHAT_PRI_HIGHEST 127
#define ZOITECHAT_PRI_HIGH 64
#define ZOITECHAT_PRI_NORM 0
#define ZOITECHAT_PRI_LOW (-64)
#define ZOITECHAT_PRI_LOWEST (-128)
#define HEXCHAT_FD_READ 1
#define HEXCHAT_FD_WRITE 2
#define HEXCHAT_FD_EXCEPTION 4
#define HEXCHAT_FD_NOTSOCKET 8
#define ZOITECHAT_FD_READ 1
#define ZOITECHAT_FD_WRITE 2
#define ZOITECHAT_FD_EXCEPTION 4
#define ZOITECHAT_FD_NOTSOCKET 8
#define HEXCHAT_EAT_NONE 0 /* pass it on through! */
#define HEXCHAT_EAT_HEXCHAT 1 /* don't let ZoiteChat see this event */
#define HEXCHAT_EAT_PLUGIN 2 /* don't let other plugins see this event */
#define HEXCHAT_EAT_ALL (HEXCHAT_EAT_HEXCHAT|HEXCHAT_EAT_PLUGIN) /* don't let anything see this event */
#define ZOITECHAT_EAT_NONE 0 /* pass it on through! */
#define ZOITECHAT_EAT_ZOITECHAT 1 /* don't let ZoiteChat see this event */
#define ZOITECHAT_EAT_PLUGIN 2 /* don't let other plugins see this event */
#define ZOITECHAT_EAT_ALL (ZOITECHAT_EAT_ZOITECHAT|ZOITECHAT_EAT_PLUGIN) /* don't let anything see this event */
#ifdef __cplusplus
extern "C" {
@@ -407,50 +407,50 @@ zoitechat_pluginpref_list (zoitechat_plugin *ph,
char *dest);
#if !defined(PLUGIN_C) && (defined(WIN32) || defined(__CYGWIN__))
#ifndef HEXCHAT_PLUGIN_HANDLE
#define HEXCHAT_PLUGIN_HANDLE (ph)
#ifndef ZOITECHAT_PLUGIN_HANDLE
#define ZOITECHAT_PLUGIN_HANDLE (ph)
#endif
#define zoitechat_hook_command ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_hook_command)
#define zoitechat_event_attrs_create ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_event_attrs_create)
#define zoitechat_event_attrs_free ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_event_attrs_free)
#define zoitechat_hook_server ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_hook_server)
#define zoitechat_hook_server_attrs ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_hook_server_attrs)
#define zoitechat_hook_print ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_hook_print)
#define zoitechat_hook_print_attrs ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_hook_print_attrs)
#define zoitechat_hook_timer ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_hook_timer)
#define zoitechat_hook_fd ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_hook_fd)
#define zoitechat_unhook ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_unhook)
#define zoitechat_print ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_print)
#define zoitechat_printf ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_printf)
#define zoitechat_command ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_command)
#define zoitechat_commandf ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_commandf)
#define zoitechat_nickcmp ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_nickcmp)
#define zoitechat_set_context ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_set_context)
#define zoitechat_find_context ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_find_context)
#define zoitechat_get_context ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_get_context)
#define zoitechat_get_info ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_get_info)
#define zoitechat_get_prefs ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_get_prefs)
#define zoitechat_list_get ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_list_get)
#define zoitechat_list_free ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_list_free)
#define zoitechat_list_fields ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_list_fields)
#define zoitechat_list_next ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_list_next)
#define zoitechat_list_str ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_list_str)
#define zoitechat_list_int ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_list_int)
#define zoitechat_plugingui_add ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_plugingui_add)
#define zoitechat_plugingui_remove ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_plugingui_remove)
#define zoitechat_emit_print ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_emit_print)
#define zoitechat_emit_print_attrs ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_emit_print_attrs)
#define zoitechat_list_time ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_list_time)
#define zoitechat_gettext ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_gettext)
#define zoitechat_send_modes ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_send_modes)
#define zoitechat_strip ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_strip)
#define zoitechat_free ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_free)
#define zoitechat_pluginpref_set_str ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_pluginpref_set_str)
#define zoitechat_pluginpref_get_str ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_pluginpref_get_str)
#define zoitechat_pluginpref_set_int ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_pluginpref_set_int)
#define zoitechat_pluginpref_get_int ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_pluginpref_get_int)
#define zoitechat_pluginpref_delete ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_pluginpref_delete)
#define zoitechat_pluginpref_list ((HEXCHAT_PLUGIN_HANDLE)->zoitechat_pluginpref_list)
#define zoitechat_hook_command ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_hook_command)
#define zoitechat_event_attrs_create ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_event_attrs_create)
#define zoitechat_event_attrs_free ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_event_attrs_free)
#define zoitechat_hook_server ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_hook_server)
#define zoitechat_hook_server_attrs ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_hook_server_attrs)
#define zoitechat_hook_print ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_hook_print)
#define zoitechat_hook_print_attrs ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_hook_print_attrs)
#define zoitechat_hook_timer ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_hook_timer)
#define zoitechat_hook_fd ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_hook_fd)
#define zoitechat_unhook ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_unhook)
#define zoitechat_print ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_print)
#define zoitechat_printf ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_printf)
#define zoitechat_command ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_command)
#define zoitechat_commandf ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_commandf)
#define zoitechat_nickcmp ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_nickcmp)
#define zoitechat_set_context ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_set_context)
#define zoitechat_find_context ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_find_context)
#define zoitechat_get_context ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_get_context)
#define zoitechat_get_info ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_get_info)
#define zoitechat_get_prefs ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_get_prefs)
#define zoitechat_list_get ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_list_get)
#define zoitechat_list_free ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_list_free)
#define zoitechat_list_fields ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_list_fields)
#define zoitechat_list_next ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_list_next)
#define zoitechat_list_str ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_list_str)
#define zoitechat_list_int ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_list_int)
#define zoitechat_plugingui_add ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_plugingui_add)
#define zoitechat_plugingui_remove ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_plugingui_remove)
#define zoitechat_emit_print ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_emit_print)
#define zoitechat_emit_print_attrs ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_emit_print_attrs)
#define zoitechat_list_time ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_list_time)
#define zoitechat_gettext ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_gettext)
#define zoitechat_send_modes ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_send_modes)
#define zoitechat_strip ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_strip)
#define zoitechat_free ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_free)
#define zoitechat_pluginpref_set_str ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_pluginpref_set_str)
#define zoitechat_pluginpref_get_str ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_pluginpref_get_str)
#define zoitechat_pluginpref_set_int ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_pluginpref_set_int)
#define zoitechat_pluginpref_get_int ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_pluginpref_get_int)
#define zoitechat_pluginpref_delete ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_pluginpref_delete)
#define zoitechat_pluginpref_list ((ZOITECHAT_PLUGIN_HANDLE)->zoitechat_pluginpref_list)
#endif
#ifdef __cplusplus

View File

@@ -49,6 +49,7 @@
#include "notify.h"
#include "server.h"
#include "servlist.h"
#include "sts.h"
#include "outbound.h"
#include "text.h"
#include "url.h"
@@ -1200,6 +1201,7 @@ xchat_init (void)
sound_load ();
notify_load ();
ignore_load ();
sts_init ();
g_snprintf (buf, sizeof (buf),
"NAME %s~%s~\n" "CMD query %%s\n\n"\
@@ -1352,6 +1354,7 @@ zoitechat_exit (void)
sound_save ();
notify_save ();
ignore_save ();
sts_cleanup ();
free_sessions ();
chanopt_save_all (TRUE);
servlist_cleanup ();

View File

@@ -26,8 +26,8 @@
#include <time.h> /* need time_t */
#ifndef HEXCHAT_H
#define HEXCHAT_H
#ifndef ZOITECHAT_H
#define ZOITECHAT_H
gboolean zoitechat_theme_path_from_arg (const char *arg, char **path_out);
gboolean zoitechat_import_theme (const char *path, GError **error);
@@ -83,6 +83,10 @@ gboolean zoitechat_import_theme (const char *path, GError **error);
#define USERNAMELEN 10
#define HIDDEN_CHAR 8 /* invisible character for xtext */
#define ZOITECHAT_DARK_MODE_AUTO 0
#define ZOITECHAT_DARK_MODE_DARK 1
#define ZOITECHAT_DARK_MODE_LIGHT 2
struct nbexec
{
int myfd;
@@ -510,6 +514,7 @@ typedef struct server
int joindelay_tag; /* waiting before we send JOIN */
char hostname[128]; /* real ip number */
char servername[128]; /* what the server says is its name */
char sts_host[128];
char password[1024];
char nick[NICKLEN];
char linebuf[8704]; /* RFC says 512 chars including \r\n, IRCv3 message tags add 8191, plus the NUL byte */
@@ -584,6 +589,8 @@ typedef struct server
unsigned int have_sasl:1; /* SASL capability */
unsigned int have_except:1; /* ban exemptions +e */
unsigned int have_invite:1; /* invite exemptions +I */
unsigned int sts_duration_seen:1;
unsigned int sts_upgrade_in_progress:1;
unsigned int have_cert:1; /* have loaded a cert */
unsigned int use_who:1; /* whether to use WHO command to get dcc_ip */
unsigned int sasl_mech; /* mechanism for sasl auth */

View File

@@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_C_H
#define HEXCHAT_C_H
#ifndef ZOITECHAT_C_H
#define ZOITECHAT_C_H
extern struct zoitechatprefs prefs;

View File

@@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_ASCII_H
#define HEXCHAT_ASCII_H
#ifndef ZOITECHAT_ASCII_H
#define ZOITECHAT_ASCII_H
void ascii_open (void);

View File

@@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_BANLIST_H
#define HEXCHAT_BANLIST_H
#ifndef ZOITECHAT_BANLIST_H
#define ZOITECHAT_BANLIST_H
#include "../common/zoitechat.h"
void banlist_opengui (session *sess);
@@ -72,4 +72,4 @@ typedef struct mode_info_s {
void (*tester)(banlist_info *, int); /* Function returns true to set bit into checkable */
} mode_info;
#endif /* HEXCHAT_BANLIST_H */
#endif /* ZOITECHAT_BANLIST_H */

View File

@@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_CHANLIST_H
#define HEXCHAT_CHANLIST_H
#ifndef ZOITECHAT_CHANLIST_H
#define ZOITECHAT_CHANLIST_H
void chanlist_opengui (server *serv, int do_refresh);

View File

@@ -98,11 +98,11 @@ cv_tree_init (chanview *cv)
int wid1, wid2;
static const GtkTargetEntry dnd_src_target[] =
{
{"HEXCHAT_CHANVIEW", GTK_TARGET_SAME_APP, 75 }
{"ZOITECHAT_CHANVIEW", GTK_TARGET_SAME_APP, 75 }
};
static const GtkTargetEntry dnd_dest_target[] =
{
{"HEXCHAT_USERLIST", GTK_TARGET_SAME_APP, 75 }
{"ZOITECHAT_USERLIST", GTK_TARGET_SAME_APP, 75 }
};
win = gtk_scrolled_window_new (0, 0);
@@ -117,7 +117,11 @@ cv_tree_init (chanview *cv)
view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (cv->store));
gtk_widget_set_name (view, "zoitechat-tree");
if (cv->style)
gtk_widget_set_style (view, cv->style);
{
gtk_widget_modify_base (view, GTK_STATE_NORMAL, &cv->style->base[GTK_STATE_NORMAL]);
gtk_widget_modify_text (view, GTK_STATE_NORMAL, &cv->style->text[GTK_STATE_NORMAL]);
gtk_widget_modify_font (view, cv->style->font_desc);
}
/*gtk_widget_modify_base (view, GTK_STATE_NORMAL, &colors[COL_BG]);*/
gtk_widget_set_can_focus (view, FALSE);
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (view), FALSE);

View File

@@ -122,7 +122,7 @@ chanview_apply_theme (chanview *cv)
return;
w = GTK_WIDGET (tv->tree);
if (prefs.hex_gui_dark_mode)
if (fe_dark_mode_is_enabled () || prefs.hex_gui_dark_mode == ZOITECHAT_DARK_MODE_LIGHT)
{
gtk_widget_modify_base (w, GTK_STATE_NORMAL, &colors[COL_BG]);
gtk_widget_modify_text (w, GTK_STATE_NORMAL, &colors[COL_FG]);

View File

@@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_CHANVIEW_H
#define HEXCHAT_CHANVIEW_H
#ifndef ZOITECHAT_CHANVIEW_H
#define ZOITECHAT_CHANVIEW_H
typedef struct _chanview chanview;
typedef struct _chan chan;

View File

@@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_CUSTOM_LIST_H
#define HEXCHAT_CUSTOM_LIST_H
#ifndef ZOITECHAT_CUSTOM_LIST_H
#define ZOITECHAT_CUSTOM_LIST_H
#include <gtk/gtk.h>
@@ -103,4 +103,4 @@ void custom_list_append (CustomList *, chanlistrow *);
void custom_list_resort (CustomList *);
void custom_list_clear (CustomList *);
#endif /* HEXCHAT_CUSTOM_LIST_H */
#endif /* ZOITECHAT_CUSTOM_LIST_H */

View File

@@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_EDITLIST_H
#define HEXCHAT_EDITLIST_H
#ifndef ZOITECHAT_EDITLIST_H
#define ZOITECHAT_EDITLIST_H
void editlist_gui_open (char *title1, char *title2, GSList * list, char *title, char *wmclass, char *file, char *help);

View File

@@ -58,7 +58,7 @@
#include <canberra.h>
#endif
GdkPixmap *channelwin_pix;
cairo_surface_t *channelwin_pix;
#ifdef USE_LIBCANBERRA
static ca_context *ca_con;
@@ -270,6 +270,130 @@ static const char adwaita_workaround_rc[] =
"}"
"widget \"*.zoitechat-inputbox\" style \"zoitechat-input-workaround\"";
static gboolean
fe_system_prefers_dark (void)
{
GtkSettings *settings = gtk_settings_get_default ();
gboolean prefer_dark = FALSE;
char *theme_name = NULL;
#ifdef G_OS_WIN32
gboolean have_win_pref = FALSE;
#endif
if (!settings)
return FALSE;
#ifdef G_OS_WIN32
{
DWORD value = 1;
DWORD value_size = sizeof (value);
LSTATUS status;
status = RegGetValueW (HKEY_CURRENT_USER,
L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize",
L"AppsUseLightTheme",
RRF_RT_REG_DWORD,
NULL,
&value,
&value_size);
if (status != ERROR_SUCCESS)
status = RegGetValueW (HKEY_CURRENT_USER,
L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize",
L"SystemUsesLightTheme",
RRF_RT_REG_DWORD,
NULL,
&value,
&value_size);
if (status == ERROR_SUCCESS)
{
prefer_dark = (value == 0);
have_win_pref = TRUE;
}
}
#endif
#ifdef G_OS_WIN32
if (!have_win_pref)
#endif
if (g_object_class_find_property (G_OBJECT_GET_CLASS (settings),
"gtk-application-prefer-dark-theme"))
{
g_object_get (settings, "gtk-application-prefer-dark-theme", &prefer_dark, NULL);
}
if (!prefer_dark)
{
g_object_get (settings, "gtk-theme-name", &theme_name, NULL);
if (theme_name)
{
char *lower = g_ascii_strdown (theme_name, -1);
if (g_str_has_suffix (lower, "-dark") || g_strrstr (lower, "dark"))
prefer_dark = TRUE;
g_free (lower);
g_free (theme_name);
}
}
return prefer_dark;
}
static gboolean auto_dark_mode_enabled = FALSE;
static void
fe_auto_dark_mode_changed (GtkSettings *settings, GParamSpec *pspec, gpointer data)
{
gboolean enabled;
(void) settings;
(void) pspec;
(void) data;
if (prefs.hex_gui_dark_mode != ZOITECHAT_DARK_MODE_AUTO)
return;
enabled = fe_system_prefers_dark ();
if (enabled == auto_dark_mode_enabled)
return;
auto_dark_mode_enabled = enabled;
palette_apply_dark_mode (enabled);
setup_apply_real (0, TRUE, FALSE, FALSE);
}
void
fe_set_auto_dark_mode_state (gboolean enabled)
{
auto_dark_mode_enabled = enabled;
}
void
fe_refresh_auto_dark_mode (void)
{
fe_auto_dark_mode_changed (NULL, NULL, NULL);
}
gboolean
fe_dark_mode_is_enabled_for (unsigned int mode)
{
switch (mode)
{
case ZOITECHAT_DARK_MODE_DARK:
return TRUE;
case ZOITECHAT_DARK_MODE_LIGHT:
return FALSE;
case ZOITECHAT_DARK_MODE_AUTO:
default:
return fe_system_prefers_dark ();
}
}
gboolean
fe_dark_mode_is_enabled (void)
{
return fe_dark_mode_is_enabled_for (prefs.hex_gui_dark_mode);
}
GtkStyle *
create_input_style (GtkStyle *style)
{
@@ -316,8 +440,10 @@ create_input_style (GtkStyle *style)
void
fe_init (void)
{
GtkSettings *settings;
palette_load ();
palette_apply_dark_mode (prefs.hex_gui_dark_mode);
palette_apply_dark_mode (fe_dark_mode_is_enabled ());
key_init ();
pixmaps_init ();
@@ -326,6 +452,16 @@ fe_init (void)
#endif
channelwin_pix = pixmap_load_from_file (prefs.hex_text_background);
input_style = create_input_style (gtk_style_new ());
settings = gtk_settings_get_default ();
if (settings)
{
auto_dark_mode_enabled = fe_system_prefers_dark ();
g_signal_connect (settings, "notify::gtk-application-prefer-dark-theme",
G_CALLBACK (fe_auto_dark_mode_changed), NULL);
g_signal_connect (settings, "notify::gtk-theme-name",
G_CALLBACK (fe_auto_dark_mode_changed), NULL);
}
}
#ifdef HAVE_GTK_MAC
@@ -394,7 +530,7 @@ log_handler (const gchar *log_domain,
{
session *sess;
/* if (getenv ("HEXCHAT_WARNING_IGNORE")) this gets ignored sometimes, so simply just disable all warnings */
/* if (getenv ("ZOITECHAT_WARNING_IGNORE")) this gets ignored sometimes, so simply just disable all warnings */
return;
sess = find_dialog (serv_list->data, "(warnings)");
@@ -402,7 +538,7 @@ log_handler (const gchar *log_domain,
sess = new_ircwindow (serv_list->data, "(warnings)", SESS_DIALOG, 0);
PrintTextf (sess, "%s\t%s\n", log_domain, message);
if (getenv ("HEXCHAT_WARNING_ABORT"))
if (getenv ("ZOITECHAT_WARNING_ABORT"))
abort ();
}

View File

@@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_FE_GTK_H
#define HEXCHAT_FE_GTK_H
#ifndef ZOITECHAT_FE_GTK_H
#define ZOITECHAT_FE_GTK_H
#include "config.h"
@@ -30,6 +30,7 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <cairo.h>
#ifdef HAVE_GTK_MAC
#include <gtkosxapplication.h>
@@ -178,8 +179,13 @@ typedef struct session_gui
} session_gui;
extern GdkPixmap *channelwin_pix;
extern GdkPixmap *dialogwin_pix;
extern cairo_surface_t *channelwin_pix;
extern cairo_surface_t *dialogwin_pix;
gboolean fe_dark_mode_is_enabled (void);
gboolean fe_dark_mode_is_enabled_for (unsigned int mode);
void fe_set_auto_dark_mode_state (gboolean enabled);
void fe_refresh_auto_dark_mode (void);
#define SPELL_ENTRY_GET_TEXT(e) ((char *)(gtk_entry_get_text (GTK_ENTRY(e))))
#define SPELL_ENTRY_SET_TEXT(e,txt) gtk_entry_set_text(GTK_ENTRY(e),txt)

View File

@@ -803,6 +803,7 @@ key_dialog_show ()
GtkWidget *vbox, *box;
GtkWidget *view, *xtext;
GtkListStore *store;
XTextColor xtext_palette[XTEXT_COLS];
char buf[128];
if (key_dialog)
@@ -816,7 +817,8 @@ key_dialog_show ()
NULL, 600, 360, &vbox, 0);
view = key_dialog_treeview_new (vbox);
xtext = gtk_xtext_new (colors, 0);
palette_get_xtext_colors (xtext_palette, XTEXT_COLS);
xtext = gtk_xtext_new (xtext_palette, 0);
gtk_box_pack_start (GTK_BOX (vbox), xtext, FALSE, TRUE, 2);
gtk_xtext_set_font (GTK_XTEXT (xtext), prefs.hex_text_font);

View File

@@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_FKEYS_H
#define HEXCHAT_FKEYS_H
#ifndef ZOITECHAT_FKEYS_H
#define ZOITECHAT_FKEYS_H
/* These are cp'ed from history.c --AGL */
#define STATE_SHIFT GDK_SHIFT_MASK

View File

@@ -95,7 +95,7 @@ gtkutil_check_file (char *filename, struct file_req *freq)
}
else
{
GFileInfo *fi = g_file_query_info (file, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE, G_FILE_QUERY_INFO_NONE, NULL, NULL);
GFileInfo *fi = g_file_query_info (file, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE "," G_FILE_ATTRIBUTE_STANDARD_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL);
if (fi != NULL)
{

View File

@@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_GTKUTIL_H
#define HEXCHAT_GTKUTIL_H
#ifndef ZOITECHAT_GTKUTIL_H
#define ZOITECHAT_GTKUTIL_H
#include <gtk/gtk.h>
#include "../common/fe.h"

View File

@@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_JOIND_H
#define HEXCHAT_JOIND_H
#ifndef ZOITECHAT_JOIND_H
#define ZOITECHAT_JOIND_H
void joind_open (server *serv);
void joind_close (server *serv);

View File

@@ -21,7 +21,10 @@
#include <stdio.h>
#include <ctype.h>
#include <gdk/gdk.h>
#include <gdk/gdkkeysyms.h>
#include <gdk/gdkcairo.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "../common/zoitechat.h"
#include "../common/fe.h"
@@ -82,6 +85,136 @@ static void mg_emoji_button_cb (GtkWidget *widget, session_gui *gui);
static GtkWidget *mg_create_emoji_menu (session_gui *gui);
static void mg_emoji_insert_cb (GtkMenuItem *item, session_gui *gui);
static inline void
mg_set_source_color (cairo_t *cr, const XTextColor *color)
{
cairo_set_source_rgba (cr, color->red, color->green, color->blue, color->alpha);
}
static inline guint16
mg_color_component_to_pango (double value)
{
if (value < 0.0)
value = 0.0;
if (value > 1.0)
value = 1.0;
return (guint16)(value * 65535.0 + 0.5);
}
static void
mg_pixbuf_destroy (guchar *pixels, gpointer data)
{
g_free (pixels);
}
static GdkPixbuf *
mg_pixbuf_from_surface (cairo_surface_t *surface, int width, int height)
{
const unsigned char *src;
int src_stride;
int rowstride;
guchar *pixels;
int x;
int y;
if (!surface || width <= 0 || height <= 0)
return NULL;
src = cairo_image_surface_get_data (surface);
src_stride = cairo_image_surface_get_stride (surface);
rowstride = width * 4;
pixels = g_malloc ((gsize)rowstride * height);
for (y = 0; y < height; y++)
{
const unsigned char *src_row = src + (y * src_stride);
guchar *dest_row = pixels + (y * rowstride);
for (x = 0; x < width; x++)
{
guint8 a;
guint8 r;
guint8 g;
guint8 b;
const unsigned char *src_px = src_row + (x * 4);
guchar *dest_px = dest_row + (x * 4);
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
b = src_px[0];
g = src_px[1];
r = src_px[2];
a = src_px[3];
#else
a = src_px[0];
r = src_px[1];
g = src_px[2];
b = src_px[3];
#endif
if (a)
{
r = (guint8)((r * 255 + (a / 2)) / a);
g = (guint8)((g * 255 + (a / 2)) / a);
b = (guint8)((b * 255 + (a / 2)) / a);
}
else
{
r = g = b = 0;
}
dest_px[0] = r;
dest_px[1] = g;
dest_px[2] = b;
dest_px[3] = a;
}
}
return gdk_pixbuf_new_from_data (pixels, GDK_COLORSPACE_RGB, TRUE, 8,
width, height, rowstride, mg_pixbuf_destroy, NULL);
}
static GdkPixbuf *
mg_pixbuf_from_window (GdkWindow *window, int width, int height)
{
int src_width;
int src_height;
cairo_surface_t *surface;
cairo_t *cr;
GdkPixbuf *pixbuf;
if (!window)
return NULL;
src_width = gdk_window_get_width (window);
src_height = gdk_window_get_height (window);
if (width <= 0 || height <= 0)
{
width = src_width;
height = src_height;
}
if (width <= 0 || height <= 0)
return NULL;
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
if (cairo_surface_status (surface) != CAIRO_STATUS_SUCCESS)
{
cairo_surface_destroy (surface);
return NULL;
}
cr = cairo_create (surface);
gdk_cairo_set_source_window (cr, window, 0.0, 0.0);
cairo_paint (cr);
cairo_destroy (cr);
pixbuf = mg_pixbuf_from_surface (surface, width, height);
cairo_surface_destroy (surface);
return pixbuf;
}
static void mg_create_entry (session *sess, GtkWidget *box);
static void mg_create_search (session *sess, GtkWidget *box);
#ifdef G_OS_WIN32
@@ -106,7 +239,7 @@ static PangoAttrList *newmsg_list;
static PangoAttrList *plain_list = NULL;
static PangoAttrList *
mg_attr_list_create (GdkColor *col, int size)
mg_attr_list_create (const XTextColor *col, int size)
{
PangoAttribute *attr;
PangoAttrList *list;
@@ -115,7 +248,10 @@ mg_attr_list_create (GdkColor *col, int size)
if (col)
{
attr = pango_attr_foreground_new (col->red, col->green, col->blue);
attr = pango_attr_foreground_new (
mg_color_component_to_pango (col->red),
mg_color_component_to_pango (col->green),
mg_color_component_to_pango (col->blue));
attr->start_index = 0;
attr->end_index = 0xffff;
pango_attr_list_insert (list, attr);
@@ -135,6 +271,8 @@ mg_attr_list_create (GdkColor *col, int size)
static void
mg_create_tab_colors (void)
{
XTextColor gui_palette[MAX_COL + 1];
if (plain_list)
{
pango_attr_list_unref (plain_list);
@@ -144,11 +282,12 @@ mg_create_tab_colors (void)
pango_attr_list_unref (away_list);
}
palette_get_xtext_colors (gui_palette, G_N_ELEMENTS (gui_palette));
plain_list = mg_attr_list_create (NULL, prefs.hex_gui_tab_small);
newdata_list = mg_attr_list_create (&colors[COL_NEW_DATA], prefs.hex_gui_tab_small);
nickseen_list = mg_attr_list_create (&colors[COL_HILIGHT], prefs.hex_gui_tab_small);
newmsg_list = mg_attr_list_create (&colors[COL_NEW_MSG], prefs.hex_gui_tab_small);
away_list = mg_attr_list_create (&colors[COL_AWAY], FALSE);
newdata_list = mg_attr_list_create (&gui_palette[COL_NEW_DATA], prefs.hex_gui_tab_small);
nickseen_list = mg_attr_list_create (&gui_palette[COL_HILIGHT], prefs.hex_gui_tab_small);
newmsg_list = mg_attr_list_create (&gui_palette[COL_NEW_MSG], prefs.hex_gui_tab_small);
away_list = mg_attr_list_create (&gui_palette[COL_AWAY], FALSE);
}
static void
@@ -2314,8 +2453,10 @@ mg_update_xtext (GtkWidget *wid)
{
GtkXText *xtext = GTK_XTEXT (wid);
const gchar *font_name;
XTextColor xtext_palette[XTEXT_COLS];
gtk_xtext_set_palette (xtext, colors);
palette_get_xtext_colors (xtext_palette, XTEXT_COLS);
gtk_xtext_set_palette (xtext, xtext_palette);
gtk_xtext_set_max_lines (xtext, prefs.hex_text_max_lines);
gtk_xtext_set_background (xtext, channelwin_pix);
gtk_xtext_set_wordwrap (xtext, prefs.hex_text_wordwrap);
@@ -2340,6 +2481,7 @@ mg_create_textarea (session *sess, GtkWidget *box)
{
GtkWidget *inbox, *vbox, *frame;
GtkXText *xtext;
XTextColor xtext_palette[XTEXT_COLS];
session_gui *gui = sess->gui;
static const GtkTargetEntry dnd_targets[] =
{
@@ -2347,8 +2489,8 @@ mg_create_textarea (session *sess, GtkWidget *box)
};
static const GtkTargetEntry dnd_dest_targets[] =
{
{"HEXCHAT_CHANVIEW", GTK_TARGET_SAME_APP, 75 },
{"HEXCHAT_USERLIST", GTK_TARGET_SAME_APP, 75 }
{"ZOITECHAT_CHANVIEW", GTK_TARGET_SAME_APP, 75 },
{"ZOITECHAT_USERLIST", GTK_TARGET_SAME_APP, 75 }
};
vbox = gtk_vbox_new (FALSE, 0);
@@ -2360,7 +2502,8 @@ mg_create_textarea (session *sess, GtkWidget *box)
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_container_add (GTK_CONTAINER (inbox), frame);
gui->xtext = gtk_xtext_new (colors, TRUE);
palette_get_xtext_colors (xtext_palette, XTEXT_COLS);
gui->xtext = gtk_xtext_new (xtext_palette, TRUE);
xtext = GTK_XTEXT (gui->xtext);
gtk_xtext_set_max_indent (xtext, prefs.hex_text_max_indent);
gtk_xtext_set_thin_separator (xtext, prefs.hex_text_thin_sep);
@@ -2496,7 +2639,7 @@ mg_create_userlist (session_gui *gui, GtkWidget *box)
if (prefs.hex_gui_ulist_style)
{
gtk_widget_set_style (ulist, input_style);
gtk_widget_modify_font (ulist, input_style->font_desc);
}
/*
@@ -2507,7 +2650,7 @@ mg_create_userlist (session_gui *gui, GtkWidget *box)
* - When "Dark mode" is enabled, we also force the user list to use the
* palette colors so it doesn't stay blindingly white on GTK2 themes.
*/
if (prefs.hex_gui_ulist_style || prefs.hex_gui_dark_mode)
if (prefs.hex_gui_ulist_style || fe_dark_mode_is_enabled ())
{
gtk_widget_modify_base (ulist, GTK_STATE_NORMAL, &colors[COL_BG]);
gtk_widget_modify_text (ulist, GTK_STATE_NORMAL, &colors[COL_FG]);
@@ -3491,6 +3634,12 @@ mg_win32_filter (GdkXEvent *xevent, GdkEvent *event, gpointer data)
return GDK_FILTER_CONTINUE;
}
if (msg->message == WM_SETTINGCHANGE || msg->message == WM_THEMECHANGED)
{
fe_refresh_auto_dark_mode ();
return GDK_FILTER_CONTINUE;
}
if (msg->message == WM_COPYDATA)
{
COPYDATASTRUCT *copy_data = (COPYDATASTRUCT *)msg->lParam;
@@ -4034,7 +4183,7 @@ mg_is_gui_target (GdkDragContext *context)
target_name = gdk_atom_name (gdk_drag_context_list_targets (context)->data);
if (target_name)
{
/* if it's not HEXCHAT_CHANVIEW or HEXCHAT_USERLIST */
/* if it's not ZOITECHAT_CHANVIEW or ZOITECHAT_USERLIST */
/* we should ignore it. */
if (target_name[0] != 'H')
{
@@ -4053,18 +4202,20 @@ gboolean
mg_drag_begin_cb (GtkWidget *widget, GdkDragContext *context, gpointer userdata)
{
int width, height;
GdkColormap *cmap;
GdkPixbuf *pix, *pix2;
GdkWindow *window;
/* ignore file drops */
if (!mg_is_gui_target (context))
return FALSE;
cmap = gtk_widget_get_colormap (widget);
width = gdk_window_get_width (gtk_widget_get_window (widget));
height = gdk_window_get_height (gtk_widget_get_window (widget));
window = gtk_widget_get_window (widget);
width = gdk_window_get_width (window);
height = gdk_window_get_height (window);
pix = gdk_pixbuf_get_from_drawable (NULL, gtk_widget_get_window (widget), cmap, 0, 0, 0, 0, width, height);
pix = mg_pixbuf_from_window (window, width, height);
if (!pix)
return FALSE;
pix2 = gdk_pixbuf_scale_simple (pix, width * 4 / 5, height / 2, GDK_INTERP_HYPER);
g_object_unref (pix);
@@ -4115,12 +4266,11 @@ mg_drag_drop_cb (GtkWidget *widget, GdkDragContext *context, int x, int y, guint
gboolean
mg_drag_motion_cb (GtkWidget *widget, GdkDragContext *context, int x, int y, guint time, gpointer scbar)
{
GdkGC *gc;
GdkColor col;
GdkGCValues val;
XTextColor col;
cairo_t *cr;
int half, width, height;
int ox, oy;
GdkDrawable *draw;
GdkWindow *window;
GtkAllocation allocation;
/* ignore file drops */
@@ -4134,55 +4284,57 @@ mg_drag_motion_cb (GtkWidget *widget, GdkDragContext *context, int x, int y, gui
oy = allocation.y;
width = allocation.width;
height = allocation.height;
draw = gtk_widget_get_window (widget);
window = gtk_widget_get_window (widget);
}
else
{
ox = oy = 0;
width = gdk_window_get_width (gtk_widget_get_window (widget));
height = gdk_window_get_height (gtk_widget_get_window (widget));
draw = gtk_widget_get_window (widget);
window = gtk_widget_get_window (widget);
width = gdk_window_get_width (window);
height = gdk_window_get_height (window);
}
val.subwindow_mode = GDK_INCLUDE_INFERIORS;
val.graphics_exposures = 0;
val.function = GDK_XOR;
gc = gdk_gc_new_with_values (gtk_widget_get_window (widget), &val, GDK_GC_EXPOSURES | GDK_GC_SUBWINDOW | GDK_GC_FUNCTION);
col.red = rand() % 0xffff;
col.green = rand() % 0xffff;
col.blue = rand() % 0xffff;
gdk_colormap_alloc_color (gtk_widget_get_colormap (widget), &col, FALSE, TRUE);
gdk_gc_set_foreground (gc, &col);
col.red = (double)rand () / (double)RAND_MAX;
col.green = (double)rand () / (double)RAND_MAX;
col.blue = (double)rand () / (double)RAND_MAX;
col.alpha = 1.0;
cr = gdk_cairo_create (window);
cairo_set_operator (cr, CAIRO_OPERATOR_XOR);
mg_set_source_color (cr, &col);
cairo_set_line_width (cr, 1.0);
half = height / 2;
#if 0
/* are both tree/userlist on the same side? */
GtkPaned *paned;
paned = (GtkPaned *)widget->parent->parent;
if (paned->child1 != NULL && paned->child2 != NULL)
{
gdk_draw_rectangle (draw, gc, 0, 1, 2, width - 3, height - 4);
gdk_draw_rectangle (draw, gc, 0, 0, 1, width - 1, height - 2);
g_object_unref (gc);
cairo_rectangle (cr, 1 + ox, 2 + oy, width - 3, height - 4);
cairo_rectangle (cr, 0 + ox, 1 + oy, width - 1, height - 2);
cairo_stroke (cr);
cairo_destroy (cr);
return TRUE;
}
#endif
if (y < half)
{
gdk_draw_rectangle (draw, gc, FALSE, 1 + ox, 2 + oy, width - 3, half - 4);
gdk_draw_rectangle (draw, gc, FALSE, 0 + ox, 1 + oy, width - 1, half - 2);
cairo_rectangle (cr, 1 + ox, 2 + oy, width - 3, half - 4);
cairo_rectangle (cr, 0 + ox, 1 + oy, width - 1, half - 2);
cairo_stroke (cr);
gtk_widget_queue_draw_area (widget, ox, half + oy, width, height - half);
}
else
{
gdk_draw_rectangle (draw, gc, FALSE, 0 + ox, half + 1 + oy, width - 1, half - 2);
gdk_draw_rectangle (draw, gc, FALSE, 1 + ox, half + 2 + oy, width - 3, half - 4);
cairo_rectangle (cr, 0 + ox, half + 1 + oy, width - 1, half - 2);
cairo_rectangle (cr, 1 + ox, half + 2 + oy, width - 3, half - 4);
cairo_stroke (cr);
gtk_widget_queue_draw_area (widget, ox, oy, width, half);
}
g_object_unref (gc);
cairo_destroy (cr);
return TRUE;
}

View File

@@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_MAINGUI_H
#define HEXCHAT_MAINGUI_H
#ifndef ZOITECHAT_MAINGUI_H
#define ZOITECHAT_MAINGUI_H
extern GtkStyle *input_style;
extern GtkWidget *parent_window;

View File

@@ -1772,7 +1772,7 @@ menu_about (GtkWidget *wid, gpointer sess)
}
static struct mymenu mymenu[] = {
{N_("_ZoiteChat"), 0, 0, M_NEWMENU, MENU_ID_HEXCHAT, 0, 1},
{N_("_ZoiteChat"), 0, 0, M_NEWMENU, MENU_ID_ZOITECHAT, 0, 1},
{N_("Network Li_st"), menu_open_server_list, (char *)&pix_book, M_MENUPIX, 0, 0, 1, GDK_KEY_s},
{0, 0, 0, M_SEP, 0, 0, 0},
@@ -2396,7 +2396,7 @@ menu_create_main (void *accel_group, int bar, int away, int toplevel,
/* record the English name for /menu */
g_object_set_data (G_OBJECT (menu_item), "name", mymenu[i].text);
#ifdef HAVE_GTK_MAC /* Added to app menu, see below */
if (!bar || mymenu[i].id != MENU_ID_HEXCHAT)
if (!bar || mymenu[i].id != MENU_ID_ZOITECHAT)
#endif
gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), menu_item);
gtk_widget_show (menu_item);
@@ -2502,7 +2502,7 @@ togitem:
#ifdef HAVE_GTK_MAC
/* We want ZoiteChat to be the app menu, not including Quit or ZoiteChat itself */
if (bar && item && i <= CLOSE_OFFSET + 1 && mymenu[i].id != MENU_ID_HEXCHAT)
if (bar && item && i <= CLOSE_OFFSET + 1 && mymenu[i].id != MENU_ID_ZOITECHAT)
{
if (!submenu || mymenu[i].type == M_MENUSUB)
gtkosx_application_insert_app_menu_item (osx_app, item, appmenu_offset++);

View File

@@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_MENU_H
#define HEXCHAT_MENU_H
#ifndef ZOITECHAT_MENU_H
#define ZOITECHAT_MENU_H
GtkWidget *menu_create_main (void *accel_group, int bar, int away, int toplevel, GtkWidget **menu_widgets);
void menu_urlmenu (GdkEventButton * event, char *url);
@@ -62,9 +62,9 @@ void menu_set_fullscreen (session_gui *gui, int fullscreen);
#define MENU_ID_JOIN 11
#define MENU_ID_USERMENU 12
#define MENU_ID_FULLSCREEN 13
#define MENU_ID_HEXCHAT 14
#define MENU_ID_ZOITECHAT 14
#if (MENU_ID_NUM < MENU_ID_HEXCHAT)
#if (MENU_ID_NUM < MENU_ID_ZOITECHAT)
#error MENU_ID_NUM is set wrong
#endif

View File

@@ -16,8 +16,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_PLUGIN_NOTIFICATION_BACKEND_H
#define HEXCHAT_PLUGIN_NOTIFICATION_BACKEND_H
#ifndef ZOITECHAT_PLUGIN_NOTIFICATION_BACKEND_H
#define ZOITECHAT_PLUGIN_NOTIFICATION_BACKEND_H
int notification_backend_supported (void);
void notification_backend_show (const char *title, const char *text);

View File

@@ -47,7 +47,7 @@ notification_backend_init (const char **error)
/* Temporarily suppress the "DLL could not be loaded" dialog box before trying to load hcnotifications-winrt.dll */
original_error_mode = GetErrorMode ();
SetErrorMode(SEM_FAILCRITICALERRORS);
module = module_load (HEXCHATLIBDIR "\\hcnotifications-winrt.dll");
module = module_load (ZOITECHATLIBDIR "\\hcnotifications-winrt.dll");
SetErrorMode (original_error_mode);
if (module == NULL)

View File

@@ -17,8 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_NOTIFYGUI_H
#define HEXCHAT_NOTIFYGUI_H
#ifndef ZOITECHAT_NOTIFYGUI_H
#define ZOITECHAT_NOTIFYGUI_H
void notify_gui_update (void);
void notify_opengui (void);

View File

@@ -38,6 +38,18 @@
#include "../common/cfgfiles.h"
#include "../common/typedef.h"
static XTextColor
palette_color_from_gdk (const GdkColor *color)
{
XTextColor result;
result.red = color->red / 65535.0;
result.green = color->green / 65535.0;
result.blue = color->blue / 65535.0;
result.alpha = 1.0;
return result;
}
GdkColor colors[] = {
/* colors for xtext */
@@ -143,6 +155,18 @@ static const GdkColor dark_colors[MAX_COL + 1] = {
{0, 0xf4f4, 0x4747, 0x4747}, /* 41 COL_SPELL (spellcheck underline) */
};
void
palette_get_xtext_colors (XTextColor *palette, size_t palette_len)
{
size_t i;
size_t count = palette_len < G_N_ELEMENTS (colors) ? palette_len : G_N_ELEMENTS (colors);
for (i = 0; i < count; i++)
{
palette[i] = palette_color_from_gdk (&colors[i]);
}
}
void
palette_user_set_color (int idx, const GdkColor *col)
{
@@ -287,20 +311,21 @@ palette_save (void)
char prefname[256];
const GdkColor *lightpal = colors;
const GdkColor *darkpal = NULL;
gboolean dark_mode_active = fe_dark_mode_is_enabled ();
/* If we're currently in dark mode, keep colors.conf's legacy keys as the user's light palette. */
if (prefs.hex_gui_dark_mode && user_colors_valid)
if (dark_mode_active && user_colors_valid)
lightpal = user_colors;
/* If we're currently in light mode, ensure the snapshot stays in sync. */
if (!prefs.hex_gui_dark_mode)
if (!dark_mode_active)
{
memcpy (user_colors, colors, sizeof (user_colors));
user_colors_valid = TRUE;
}
/* If dark mode is enabled but we haven't snapshotted a custom dark palette yet, capture it now. */
if (prefs.hex_gui_dark_mode && !dark_user_colors_valid)
if (dark_mode_active && !dark_user_colors_valid)
{
memcpy (dark_user_colors, colors, sizeof (dark_user_colors));
dark_user_colors_valid = TRUE;
@@ -308,7 +333,7 @@ palette_save (void)
if (dark_user_colors_valid)
darkpal = dark_user_colors;
else if (prefs.hex_gui_dark_mode)
else if (dark_mode_active)
darkpal = colors; /* current dark palette (likely defaults) */
fh = zoitechat_open_file ("colors.conf", O_TRUNC | O_WRONLY | O_CREAT, 0600, XOF_DOMODE);
@@ -399,4 +424,3 @@ palette_apply_dark_mode (gboolean enable)
return changed;
}

View File

@@ -17,8 +17,12 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_PALETTE_H
#define HEXCHAT_PALETTE_H
#ifndef ZOITECHAT_PALETTE_H
#define ZOITECHAT_PALETTE_H
#include <stddef.h>
#include "xtext-color.h"
extern GdkColor colors[];
@@ -59,4 +63,6 @@ void palette_dark_set_color (int idx, const GdkColor *col);
*/
gboolean palette_apply_dark_mode (gboolean enable);
void palette_get_xtext_colors (XTextColor *palette, size_t palette_len);
#endif

View File

@@ -28,6 +28,7 @@
#include <gio/gio.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <cairo.h>
GdkPixbuf *pix_ulist_voice;
GdkPixbuf *pix_ulist_halfop;
@@ -49,26 +50,89 @@ GdkPixbuf *pix_tree_util;
GdkPixbuf *pix_book;
GdkPixbuf *pix_zoitechat;
static GdkPixmap *
static cairo_surface_t *
pixbuf_to_cairo_surface (GdkPixbuf *pixbuf)
{
cairo_surface_t *surface;
gboolean has_alpha;
int width;
int height;
int src_stride;
int dest_stride;
int n_channels;
const guchar *src_pixels;
unsigned char *dest_pixels;
int x;
int y;
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
width = gdk_pixbuf_get_width (pixbuf);
height = gdk_pixbuf_get_height (pixbuf);
has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
n_channels = gdk_pixbuf_get_n_channels (pixbuf);
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
if (cairo_surface_status (surface) != CAIRO_STATUS_SUCCESS)
{
cairo_surface_destroy (surface);
return NULL;
}
src_stride = gdk_pixbuf_get_rowstride (pixbuf);
src_pixels = gdk_pixbuf_get_pixels (pixbuf);
dest_stride = cairo_image_surface_get_stride (surface);
dest_pixels = cairo_image_surface_get_data (surface);
for (y = 0; y < height; y++)
{
const guchar *src_row = src_pixels + (y * src_stride);
guint32 *dest_row = (guint32 *)(dest_pixels + (y * dest_stride));
for (x = 0; x < width; x++)
{
const guchar *src = src_row + (x * n_channels);
guchar alpha = has_alpha ? src[3] : 0xff;
guchar red = src[0];
guchar green = src[1];
guchar blue = src[2];
guchar premul_red = (guchar)((red * alpha + 127) / 255);
guchar premul_green = (guchar)((green * alpha + 127) / 255);
guchar premul_blue = (guchar)((blue * alpha + 127) / 255);
dest_row[x] = ((guint32)alpha << 24) |
((guint32)premul_red << 16) |
((guint32)premul_green << 8) |
((guint32)premul_blue);
}
}
cairo_surface_mark_dirty (surface);
return surface;
}
static cairo_surface_t *
pixmap_load_from_file_real (char *file)
{
GdkPixbuf *img;
GdkPixmap *pixmap;
cairo_surface_t *surface;
img = gdk_pixbuf_new_from_file (file, 0);
if (!img)
return NULL;
gdk_pixbuf_render_pixmap_and_mask (img, &pixmap, NULL, 128);
surface = pixbuf_to_cairo_surface (img);
g_object_unref (img);
return pixmap;
return surface;
}
GdkPixmap *
cairo_surface_t *
pixmap_load_from_file (char *filename)
{
char buf[256];
GdkPixmap *pix;
cairo_surface_t *pix;
if (filename[0] == '\0')
return NULL;

View File

@@ -17,8 +17,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef HEXCHAT_PIXMAPS_H
#define HEXCHAT_PIXMAPS_H
#ifndef ZOITECHAT_PIXMAPS_H
#define ZOITECHAT_PIXMAPS_H
#include <cairo.h>
extern GdkPixbuf *pix_ulist_voice;
extern GdkPixbuf *pix_ulist_halfop;
@@ -40,7 +42,7 @@ extern GdkPixbuf *pix_tree_util;
extern GdkPixbuf *pix_book;
extern GdkPixbuf *pix_zoitechat;
extern GdkPixmap *pixmap_load_from_file (char *file);
extern cairo_surface_t *pixmap_load_from_file (char *file);
extern void pixmaps_init (void);
#endif

Some files were not shown because too many files have changed in this diff Show More