mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-09-03 21:43:10 +00:00
Compare commits
2 Commits
sysinfo-up
...
implement-
| Author | SHA1 | Date | |
|---|---|---|---|
| 424cf9d706 | |||
| db32e3f38d |
2
.github/workflows/appimage-build.yml
vendored
2
.github/workflows/appimage-build.yml
vendored
@@ -35,7 +35,7 @@ jobs:
|
||||
libxkbcommon0 \
|
||||
libgtk-3-bin libglib2.0-bin shared-mime-info gsettings-desktop-schemas \
|
||||
liblua5.4-dev libpci-dev libperl-dev libssl-dev libayatana-appindicator3-dev \
|
||||
perl python3 python3-minimal python3-dev python3-cffi mono-devel desktop-file-utils \
|
||||
perl python3 python3-minimal python3-dev python3-cffi python3-sphinx mono-devel desktop-file-utils \
|
||||
fonts-noto-color-emoji breeze-gtk-theme \
|
||||
patchelf file curl
|
||||
|
||||
|
||||
1
.github/workflows/windows-build.yml
vendored
1
.github/workflows/windows-build.yml
vendored
@@ -40,6 +40,7 @@ jobs:
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install cffi
|
||||
python -m pip install zstandard
|
||||
python -m pip install sphinx
|
||||
|
||||
$ProgressPreference = 'SilentlyContinue'
|
||||
function Download-WithRetry {
|
||||
|
||||
42
docs/build-docs.py
Normal file
42
docs/build-docs.py
Normal file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 4:
|
||||
raise SystemExit("usage: build-docs.py SOURCE_DIR OUTPUT_DIR STAMP_FILE")
|
||||
|
||||
source_dir = os.path.abspath(sys.argv[1])
|
||||
output_dir = os.path.abspath(sys.argv[2])
|
||||
stamp_file = os.path.abspath(sys.argv[3])
|
||||
doctree_dir = output_dir + ".doctrees"
|
||||
|
||||
shutil.rmtree(output_dir, ignore_errors=True)
|
||||
shutil.rmtree(doctree_dir, ignore_errors=True)
|
||||
os.makedirs(output_dir, exist_ok=True)
|
||||
|
||||
subprocess.run(
|
||||
[
|
||||
sys.executable,
|
||||
"-m",
|
||||
"sphinx",
|
||||
"-b",
|
||||
"html",
|
||||
"-d",
|
||||
doctree_dir,
|
||||
source_dir,
|
||||
output_dir,
|
||||
],
|
||||
check=True,
|
||||
)
|
||||
|
||||
with open(stamp_file, "w", encoding="utf-8") as stamp:
|
||||
stamp.write("built\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
36
docs/install-docs.py
Normal file
36
docs/install-docs.py
Normal file
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 4:
|
||||
raise SystemExit("usage: install-docs.py STAMP_FILE SOURCE_DIR DATADIR")
|
||||
|
||||
_, source_dir, datadir = sys.argv[1:]
|
||||
source_dir = os.path.abspath(source_dir)
|
||||
|
||||
if not os.path.isfile(sys.argv[1]):
|
||||
raise SystemExit("documentation build did not produce its stamp file")
|
||||
if not os.path.isfile(os.path.join(source_dir, "index.html")):
|
||||
raise SystemExit("documentation build did not produce index.html")
|
||||
|
||||
if os.path.isabs(datadir):
|
||||
destdir = os.environ.get("DESTDIR", "")
|
||||
if destdir:
|
||||
data_root = os.path.join(destdir, datadir.lstrip("/\\"))
|
||||
else:
|
||||
data_root = datadir
|
||||
else:
|
||||
data_root = os.path.join(os.environ["MESON_INSTALL_DESTDIR_PREFIX"], datadir)
|
||||
|
||||
destination = os.path.join(data_root, "doc", "zoitechat", "html")
|
||||
shutil.rmtree(destination, ignore_errors=True)
|
||||
os.makedirs(os.path.dirname(destination), exist_ok=True)
|
||||
shutil.copytree(source_dir, destination)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -54,6 +54,7 @@
|
||||
"buildsystem": "meson",
|
||||
"config-opts": [
|
||||
"-Ddbus-service-use-appid=true",
|
||||
"-Dinstall-docs=false",
|
||||
"-Dwith-perl=perl",
|
||||
"-Dwith-python=python3",
|
||||
"-Dwith-lua=lua"
|
||||
|
||||
38
meson.build
38
meson.build
@@ -35,6 +35,9 @@ config_h.set_quoted('PACKAGE_NAME', meson.project_name())
|
||||
config_h.set_quoted('GETTEXT_PACKAGE', 'zoitechat')
|
||||
config_h.set_quoted('LOCALEDIR', join_paths(get_option('prefix'),
|
||||
get_option('datadir'), 'locale'))
|
||||
config_h.set_quoted('ZOITECHAT_DOCDIR',
|
||||
join_paths(get_option('prefix'), get_option('datadir'), 'doc', 'zoitechat', 'html')
|
||||
)
|
||||
config_h.set10('ENABLE_NLS', true)
|
||||
|
||||
# Optional features
|
||||
@@ -160,6 +163,41 @@ foreach ldflag : test_ldflags
|
||||
endforeach
|
||||
add_project_link_arguments(global_ldflags, language: 'c')
|
||||
|
||||
if get_option('install-docs')
|
||||
docs_python = find_program('python3', 'python')
|
||||
docs_sphinx = run_command(docs_python, '-c', 'import sphinx', check: false)
|
||||
if docs_sphinx.returncode() != 0
|
||||
error('Sphinx is required to build the local HTML documentation. Install Sphinx or configure with -Dinstall-docs=false.')
|
||||
endif
|
||||
|
||||
docs_source_dir = join_paths(meson.source_root(), 'docs')
|
||||
docs_output_dir = join_paths(meson.build_root(), 'docs-html')
|
||||
docs_build_script = join_paths(docs_source_dir, 'build-docs.py')
|
||||
docs_install_script = join_paths(docs_source_dir, 'install-docs.py')
|
||||
|
||||
docs_target = custom_target(
|
||||
'html-documentation',
|
||||
output: 'html-documentation.stamp',
|
||||
command: [
|
||||
docs_python,
|
||||
docs_build_script,
|
||||
docs_source_dir,
|
||||
docs_output_dir,
|
||||
'@OUTPUT@',
|
||||
],
|
||||
build_by_default: true,
|
||||
build_always_stale: true,
|
||||
)
|
||||
|
||||
meson.add_install_script(
|
||||
docs_python,
|
||||
docs_install_script,
|
||||
docs_target,
|
||||
docs_output_dir,
|
||||
get_option('datadir'),
|
||||
)
|
||||
endif
|
||||
|
||||
subdir('src')
|
||||
if get_option('plugin')
|
||||
subdir('plugins')
|
||||
|
||||
@@ -33,6 +33,9 @@ option('install-appdata', type: 'boolean',
|
||||
option('install-plugin-metainfo', type: 'boolean', value: false,
|
||||
description: 'Installs metainfo files for enabled plugins, useful when distros create split packages'
|
||||
)
|
||||
option('install-docs', type: 'boolean', value: true,
|
||||
description: 'Build and install the local HTML documentation'
|
||||
)
|
||||
|
||||
# Plugins
|
||||
option('with-checksum', type: 'boolean',
|
||||
|
||||
@@ -15,6 +15,7 @@ BuildRequires: perl
|
||||
BuildRequires: perl-devel
|
||||
BuildRequires: python3
|
||||
BuildRequires: python3-cffi
|
||||
BuildRequires: python3-sphinx
|
||||
BuildRequires: publicsuffix-list
|
||||
BuildRequires: xwayland-run
|
||||
BuildRequires: weston
|
||||
@@ -87,6 +88,7 @@ xwfb-run -- /usr/bin/meson test -C %{_vpath_builddir} --num-processes %{_smp_bui
|
||||
%{_datadir}/icons/hicolor/scalable/apps/net.zoite.Zoitechat.svg
|
||||
%{_datadir}/metainfo/net.zoite.Zoitechat.appdata.xml
|
||||
%{_datadir}/metainfo/net.zoite.Zoitechat*.metainfo.xml
|
||||
%{_datadir}/doc/zoitechat/html/
|
||||
%dir %{_libdir}/zoitechat
|
||||
%dir %{_libdir}/zoitechat/plugins
|
||||
%dir %{_libdir}/zoitechat/python
|
||||
|
||||
@@ -6,66 +6,50 @@ sysinfo_sources = [
|
||||
sysinfo_deps = [
|
||||
libgio_dep,
|
||||
zoitechat_plugin_dep,
|
||||
common_sysinfo_deps,
|
||||
]
|
||||
|
||||
sysinfo_includes = []
|
||||
sysinfo_cargs = ['-DHAVE_CONFIG_H']
|
||||
|
||||
system = host_machine.system()
|
||||
if system == 'linux' or system == 'gnu' or system.startswith('gnu/')
|
||||
if get_option('gtk-frontend')
|
||||
sysinfo_deps += dependency('gtk+-3.0', version: '>= 3.22')
|
||||
endif
|
||||
|
||||
libpci = dependency('libpci', required: false, method: 'pkg-config')
|
||||
if libpci.found()
|
||||
sysinfo_deps += libpci
|
||||
sysinfo_cargs += '-DHAVE_LIBPCI'
|
||||
endif
|
||||
|
||||
sysinfo_includes += 'unix'
|
||||
sysinfo_sources += 'unix/modern-backend.c'
|
||||
|
||||
elif system == 'freebsd'
|
||||
sysinfo_includes += ['shared', 'unix']
|
||||
if system == 'linux' or system == 'gnu' or system.startswith('gnu/') or system == 'darwin' or system == 'freebsd'
|
||||
sysinfo_includes += 'shared'
|
||||
sysinfo_sources += [
|
||||
'shared/df.c',
|
||||
'unix/backend.c',
|
||||
'unix/match.c',
|
||||
'unix/parse.c',
|
||||
'shared/df.c'
|
||||
]
|
||||
|
||||
libpci = dependency('libpci', required: false, method: 'pkg-config')
|
||||
if libpci.found()
|
||||
sysinfo_deps += libpci
|
||||
sysinfo_cargs += '-DHAVE_LIBPCI'
|
||||
sysinfo_sources += 'unix/pci.c'
|
||||
if system == 'linux' or system == 'gnu' or system.startswith('gnu/') or system == 'freebsd'
|
||||
libpci = dependency('libpci', required: false, method: 'pkg-config')
|
||||
if libpci.found()
|
||||
sysinfo_deps += libpci
|
||||
sysinfo_cargs += '-DHAVE_LIBPCI'
|
||||
sysinfo_sources += 'unix/pci.c'
|
||||
|
||||
picidsdir = libpci.get_pkgconfig_variable('idsdir')
|
||||
pciids = join_paths(picidsdir, 'pci.ids')
|
||||
sysinfo_cargs += '-DPCIIDS_FILE="@0@"'.format(pciids)
|
||||
picidsdir = libpci.get_pkgconfig_variable('idsdir')
|
||||
pciids = join_paths(picidsdir, 'pci.ids')
|
||||
sysinfo_cargs += '-DPCIIDS_FILE="@0@"'.format(pciids)
|
||||
endif
|
||||
if get_option('gtk-frontend')
|
||||
sysinfo_deps += dependency('gtk+-3.0', version: '>= 3.22')
|
||||
endif
|
||||
|
||||
sysinfo_includes += 'unix'
|
||||
sysinfo_sources += [
|
||||
'unix/backend.c',
|
||||
'unix/match.c',
|
||||
'unix/parse.c',
|
||||
]
|
||||
elif system == 'darwin'
|
||||
add_languages('objc')
|
||||
sysinfo_sources += 'osx/backend.m'
|
||||
endif
|
||||
|
||||
if get_option('gtk-frontend')
|
||||
sysinfo_deps += dependency('gtk+-3.0', version: '>= 3.22')
|
||||
endif
|
||||
|
||||
elif system == 'darwin'
|
||||
sysinfo_includes += 'shared'
|
||||
sysinfo_sources += 'shared/df.c'
|
||||
add_languages('objc')
|
||||
sysinfo_sources += 'osx/backend.m'
|
||||
|
||||
elif system == 'windows'
|
||||
cc = meson.get_compiler('c')
|
||||
sysinfo_deps += [
|
||||
cc.find_library('advapi32', required: true),
|
||||
cc.find_library('dxgi', required: true),
|
||||
cc.find_library('dxguid', required: true),
|
||||
cc.find_library('iphlpapi', required: true),
|
||||
cc.find_library('winmm', required: true),
|
||||
sysinfo_sources += [
|
||||
'win32/backend.c',
|
||||
'../../src/common/sysinfo/win32/backend.c'
|
||||
]
|
||||
sysinfo_sources += 'win32/backend.c'
|
||||
else
|
||||
error('sysinfo: Unknown system?')
|
||||
endif
|
||||
|
||||
@@ -40,8 +40,8 @@ static zoitechat_plugin *ph;
|
||||
|
||||
static char name[] = "Sysinfo";
|
||||
static char desc[] = "Display info about your hardware and OS";
|
||||
static char version[] = "2.0";
|
||||
static char sysinfo_help[] = "SysInfo Usage:\n /SYSINFO [-e|-o] [CLIENT|UI|OS|CPU|RAM|MEMORY|STORAGE|DISK|GPU|VGA|CHIPSET|SOUND|NETWORK|ETHERNET|UPTIME], print various details about your system or print a summary without arguments\n /SYSINFO SET <variable>\n";
|
||||
static char version[] = "1.0";
|
||||
static char sysinfo_help[] = "SysInfo Usage:\n /SYSINFO [-e|-o] [CLIENT|UI|OS|CPU|RAM|STORAGE|GPU|CHIPSET|SOUND|ETHERNET|UPTIME], print various details about your system or print a summary without arguments\n /SYSINFO SET <variable>\n";
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -68,15 +68,11 @@ static hwinfo hwinfos[] = {
|
||||
{"os", "OS", sysinfo_backend_get_os},
|
||||
{"cpu", "CPU", sysinfo_backend_get_cpu},
|
||||
{"memory", "Memory", sysinfo_backend_get_memory},
|
||||
#if defined(__linux__)
|
||||
{"storage", "Storage", sysinfo_backend_get_disk, FALSE},
|
||||
#else
|
||||
{"storage", "Storage", sysinfo_backend_get_disk, TRUE},
|
||||
#endif
|
||||
{"gpu", "GPU", sysinfo_backend_get_gpu},
|
||||
{"chipset", "Chipset", sysinfo_backend_get_chipset, TRUE},
|
||||
{"chipset", "CHIPSET", sysinfo_backend_get_chipset, TRUE},
|
||||
{"sound", "Sound", sysinfo_backend_get_sound, TRUE},
|
||||
{"ethernet", "Network", sysinfo_backend_get_network, TRUE},
|
||||
{"ethernet", "Ethernet", sysinfo_backend_get_network, TRUE},
|
||||
{"uptime", "Uptime", sysinfo_backend_get_uptime},
|
||||
{NULL, NULL},
|
||||
};
|
||||
@@ -119,30 +115,14 @@ print_summary (gboolean announce)
|
||||
g_free (output);
|
||||
}
|
||||
|
||||
static const char *
|
||||
normalize_info_name (const char *info)
|
||||
{
|
||||
if (!g_ascii_strcasecmp (info, "ram"))
|
||||
return "memory";
|
||||
if (!g_ascii_strcasecmp (info, "disk"))
|
||||
return "storage";
|
||||
if (!g_ascii_strcasecmp (info, "vga"))
|
||||
return "gpu";
|
||||
if (!g_ascii_strcasecmp (info, "network"))
|
||||
return "ethernet";
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
static void
|
||||
print_info (char *info, gboolean announce)
|
||||
{
|
||||
const char *normalized = normalize_info_name (info);
|
||||
int i;
|
||||
|
||||
for (i = 0; hwinfos[i].name != NULL; i++)
|
||||
{
|
||||
if (!g_ascii_strcasecmp (normalized, hwinfos[i].name))
|
||||
if (!g_ascii_strcasecmp (info, hwinfos[i].name))
|
||||
{
|
||||
char *str = hwinfos[i].callback();
|
||||
if (str)
|
||||
@@ -203,17 +183,12 @@ sysinfo_set_pref (char *key, char *value)
|
||||
}
|
||||
else if (g_str_has_prefix (key, "hide_"))
|
||||
{
|
||||
const char *normalized = normalize_info_name (key + 5);
|
||||
int i;
|
||||
|
||||
for (i = 0; hwinfos[i].name != NULL; i++)
|
||||
{
|
||||
if (!strcmp (normalized, hwinfos[i].name))
|
||||
if (!strcmp (key + 5, hwinfos[i].name))
|
||||
{
|
||||
char canonical[32];
|
||||
|
||||
g_snprintf (canonical, sizeof (canonical), "hide_%s", hwinfos[i].name);
|
||||
sysinfo_set_pref_real (canonical, value, hwinfos[i].def);
|
||||
sysinfo_set_pref_real (key, value, hwinfos[i].def);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,33 +1,28 @@
|
||||
/*
|
||||
* Modern Windows SysInfo backend for ZoiteChat.
|
||||
/* ZoiteChat
|
||||
* Copyright (c) 2011-2012 Berke Viktor.
|
||||
*
|
||||
* Avoids WMI in the plugin hot path and uses native Win32/DXGI APIs.
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _WIN32_WINNT
|
||||
#define _WIN32_WINNT 0x0601
|
||||
#elif _WIN32_WINNT < 0x0601
|
||||
#undef _WIN32_WINNT
|
||||
#define _WIN32_WINNT 0x0601
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
#include <winternl.h>
|
||||
#include <dxgi.h>
|
||||
#include <iphlpapi.h>
|
||||
#include <ipifcons.h>
|
||||
#include <mmsystem.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "advapi32.lib")
|
||||
#pragma comment(lib, "dxgi.lib")
|
||||
#pragma comment(lib, "dxguid.lib")
|
||||
#pragma comment(lib, "iphlpapi.lib")
|
||||
#pragma comment(lib, "winmm.lib")
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <windows.h>
|
||||
#include <wbemidl.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
@@ -35,543 +30,63 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "../../../src/common/sysinfo/sysinfo.h"
|
||||
|
||||
#include "../format.h"
|
||||
#include "../sysinfo-backend.h"
|
||||
|
||||
#define SYSINFO_SEP " \xC2\xB7 "
|
||||
static char *get_memory_info (void);
|
||||
|
||||
typedef struct
|
||||
char *
|
||||
sysinfo_backend_get_sound (void)
|
||||
{
|
||||
char *os;
|
||||
char *cpu;
|
||||
char *gpu;
|
||||
char *sound;
|
||||
} WinStaticSnapshot;
|
||||
|
||||
static WinStaticSnapshot snapshot;
|
||||
static gsize os_initialized = 0;
|
||||
static gsize cpu_initialized = 0;
|
||||
static gsize gpu_initialized = 0;
|
||||
static gsize sound_initialized = 0;
|
||||
|
||||
static char *wide_to_utf8 (const WCHAR *value);
|
||||
static char *read_registry_string (HKEY root, const WCHAR *subkey, const WCHAR *value_name);
|
||||
static gboolean read_registry_dword (HKEY root, const WCHAR *subkey, const WCHAR *value_name, DWORD *value);
|
||||
static const char *get_native_arch (void);
|
||||
static DWORD get_windows_build_number (void);
|
||||
static char *build_os_string (void);
|
||||
static DWORD count_physical_cores (void);
|
||||
static char *build_cpu_string (void);
|
||||
static char *build_gpu_string (void);
|
||||
static char *build_sound_string (void);
|
||||
static void ensure_os_snapshot (void);
|
||||
static void ensure_cpu_snapshot (void);
|
||||
static void ensure_gpu_snapshot (void);
|
||||
static void ensure_sound_snapshot (void);
|
||||
static char *format_usage (guint64 total, guint64 available);
|
||||
static char *join_ptr_array (GPtrArray *items, const char *separator);
|
||||
static void ptr_array_add_unique (GPtrArray *items, const char *value);
|
||||
static gboolean adapter_looks_virtual (const char *name);
|
||||
|
||||
static char *
|
||||
wide_to_utf8 (const WCHAR *value)
|
||||
{
|
||||
if (!value || value[0] == L'\0')
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return g_utf16_to_utf8 ((const gunichar2 *) value, -1, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
static char *
|
||||
read_registry_string (HKEY root, const WCHAR *subkey, const WCHAR *value_name)
|
||||
{
|
||||
HKEY key;
|
||||
DWORD type = 0;
|
||||
DWORD size = 0;
|
||||
WCHAR *buffer;
|
||||
char *result = NULL;
|
||||
LONG status;
|
||||
|
||||
status = RegOpenKeyExW (root, subkey, 0, KEY_READ | KEY_WOW64_64KEY, &key);
|
||||
if (status != ERROR_SUCCESS)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
status = RegQueryValueExW (key, value_name, NULL, &type, NULL, &size);
|
||||
if (status != ERROR_SUCCESS || (type != REG_SZ && type != REG_EXPAND_SZ) || size < sizeof (WCHAR))
|
||||
{
|
||||
RegCloseKey (key);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
buffer = g_malloc0 ((gsize) size + sizeof (WCHAR));
|
||||
status = RegQueryValueExW (key, value_name, NULL, &type, (LPBYTE) buffer, &size);
|
||||
if (status == ERROR_SUCCESS)
|
||||
{
|
||||
result = wide_to_utf8 (buffer);
|
||||
if (result)
|
||||
{
|
||||
g_strstrip (result);
|
||||
}
|
||||
}
|
||||
|
||||
g_free (buffer);
|
||||
RegCloseKey (key);
|
||||
return result;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
read_registry_dword (HKEY root, const WCHAR *subkey, const WCHAR *value_name, DWORD *value)
|
||||
{
|
||||
HKEY key;
|
||||
DWORD type = 0;
|
||||
DWORD size = sizeof (*value);
|
||||
LONG status;
|
||||
|
||||
status = RegOpenKeyExW (root, subkey, 0, KEY_READ | KEY_WOW64_64KEY, &key);
|
||||
if (status != ERROR_SUCCESS)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
status = RegQueryValueExW (key, value_name, NULL, &type, (LPBYTE) value, &size);
|
||||
RegCloseKey (key);
|
||||
return status == ERROR_SUCCESS && type == REG_DWORD;
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_native_arch (void)
|
||||
{
|
||||
SYSTEM_INFO info;
|
||||
|
||||
GetNativeSystemInfo (&info);
|
||||
switch (info.wProcessorArchitecture)
|
||||
{
|
||||
case PROCESSOR_ARCHITECTURE_AMD64:
|
||||
return "x64";
|
||||
case PROCESSOR_ARCHITECTURE_ARM64:
|
||||
return "ARM64";
|
||||
case PROCESSOR_ARCHITECTURE_INTEL:
|
||||
return "x86";
|
||||
default:
|
||||
return "unknown-arch";
|
||||
}
|
||||
}
|
||||
|
||||
static DWORD
|
||||
get_windows_build_number (void)
|
||||
{
|
||||
typedef LONG (WINAPI *RtlGetVersionFn) (PRTL_OSVERSIONINFOW);
|
||||
HMODULE ntdll;
|
||||
RtlGetVersionFn rtl_get_version;
|
||||
RTL_OSVERSIONINFOW version;
|
||||
DWORD build = 0;
|
||||
|
||||
ntdll = GetModuleHandleW (L"ntdll.dll");
|
||||
if (ntdll)
|
||||
{
|
||||
rtl_get_version = (RtlGetVersionFn) GetProcAddress (ntdll, "RtlGetVersion");
|
||||
if (rtl_get_version)
|
||||
{
|
||||
ZeroMemory (&version, sizeof (version));
|
||||
version.dwOSVersionInfoSize = sizeof (version);
|
||||
if (rtl_get_version (&version) == 0)
|
||||
{
|
||||
build = version.dwBuildNumber;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return build;
|
||||
}
|
||||
|
||||
static char *
|
||||
build_os_string (void)
|
||||
{
|
||||
static const WCHAR current_version_key[] = L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion";
|
||||
char *product;
|
||||
char *display_version;
|
||||
char *registry_build;
|
||||
char *fixed_product = NULL;
|
||||
char *result;
|
||||
DWORD ubr = 0;
|
||||
DWORD build;
|
||||
guint64 parsed_build = 0;
|
||||
|
||||
product = read_registry_string (HKEY_LOCAL_MACHINE, current_version_key, L"ProductName");
|
||||
display_version = read_registry_string (HKEY_LOCAL_MACHINE, current_version_key, L"DisplayVersion");
|
||||
registry_build = read_registry_string (HKEY_LOCAL_MACHINE, current_version_key, L"CurrentBuildNumber");
|
||||
read_registry_dword (HKEY_LOCAL_MACHINE, current_version_key, L"UBR", &ubr);
|
||||
|
||||
build = get_windows_build_number ();
|
||||
if (registry_build)
|
||||
{
|
||||
parsed_build = g_ascii_strtoull (registry_build, NULL, 10);
|
||||
if (parsed_build != 0)
|
||||
{
|
||||
build = (DWORD) parsed_build;
|
||||
}
|
||||
}
|
||||
|
||||
if (!product)
|
||||
{
|
||||
product = g_strdup (build >= 22000 ? "Windows 11" : "Windows");
|
||||
}
|
||||
else if (build >= 22000 && g_str_has_prefix (product, "Windows 10"))
|
||||
{
|
||||
fixed_product = g_strdup_printf ("Windows 11%s", product + strlen ("Windows 10"));
|
||||
g_free (product);
|
||||
product = fixed_product;
|
||||
}
|
||||
|
||||
if (display_version && build != 0)
|
||||
{
|
||||
result = g_strdup_printf ("%s %s" SYSINFO_SEP "build %lu.%lu" SYSINFO_SEP "%s",
|
||||
product, display_version, (unsigned long) build, (unsigned long) ubr, get_native_arch ());
|
||||
}
|
||||
else if (build != 0)
|
||||
{
|
||||
result = g_strdup_printf ("%s" SYSINFO_SEP "build %lu.%lu" SYSINFO_SEP "%s",
|
||||
product, (unsigned long) build, (unsigned long) ubr, get_native_arch ());
|
||||
}
|
||||
else
|
||||
{
|
||||
result = g_strdup_printf ("%s" SYSINFO_SEP "%s", product, get_native_arch ());
|
||||
}
|
||||
|
||||
g_free (product);
|
||||
g_free (display_version);
|
||||
g_free (registry_build);
|
||||
return result;
|
||||
}
|
||||
|
||||
static DWORD
|
||||
count_physical_cores (void)
|
||||
{
|
||||
DWORD length = 0;
|
||||
PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX buffer;
|
||||
BYTE *cursor;
|
||||
BYTE *end;
|
||||
DWORD cores = 0;
|
||||
|
||||
GetLogicalProcessorInformationEx (RelationProcessorCore, NULL, &length);
|
||||
if (GetLastError () != ERROR_INSUFFICIENT_BUFFER || length == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
buffer = g_malloc0 (length);
|
||||
if (!GetLogicalProcessorInformationEx (RelationProcessorCore, buffer, &length))
|
||||
{
|
||||
g_free (buffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
cursor = (BYTE *) buffer;
|
||||
end = cursor + length;
|
||||
while (cursor < end)
|
||||
{
|
||||
PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX info = (PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX) cursor;
|
||||
|
||||
if (info->Size == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (info->Relationship == RelationProcessorCore)
|
||||
{
|
||||
cores++;
|
||||
}
|
||||
cursor += info->Size;
|
||||
}
|
||||
|
||||
g_free (buffer);
|
||||
return cores;
|
||||
}
|
||||
|
||||
static char *
|
||||
build_cpu_string (void)
|
||||
{
|
||||
static const WCHAR cpu_key[] = L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0";
|
||||
char *name;
|
||||
DWORD cores;
|
||||
DWORD threads;
|
||||
SYSTEM_INFO info;
|
||||
char *result;
|
||||
|
||||
name = read_registry_string (HKEY_LOCAL_MACHINE, cpu_key, L"ProcessorNameString");
|
||||
if (!name)
|
||||
{
|
||||
name = g_strdup ("Unknown CPU");
|
||||
}
|
||||
|
||||
cores = count_physical_cores ();
|
||||
threads = GetActiveProcessorCount (ALL_PROCESSOR_GROUPS);
|
||||
if (threads == 0)
|
||||
{
|
||||
GetNativeSystemInfo (&info);
|
||||
threads = info.dwNumberOfProcessors;
|
||||
}
|
||||
if (cores == 0)
|
||||
{
|
||||
cores = threads;
|
||||
}
|
||||
|
||||
result = g_strdup_printf ("%s" SYSINFO_SEP "%luC/%luT",
|
||||
name, (unsigned long) cores, (unsigned long) threads);
|
||||
g_free (name);
|
||||
return result;
|
||||
}
|
||||
|
||||
static char *
|
||||
join_ptr_array (GPtrArray *items, const char *separator)
|
||||
{
|
||||
GString *joined;
|
||||
guint i;
|
||||
|
||||
if (!items || items->len == 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
joined = g_string_new (NULL);
|
||||
for (i = 0; i < items->len; i++)
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
g_string_append (joined, separator);
|
||||
}
|
||||
g_string_append (joined, g_ptr_array_index (items, i));
|
||||
}
|
||||
return g_string_free (joined, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
ptr_array_add_unique (GPtrArray *items, const char *value)
|
||||
{
|
||||
guint i;
|
||||
|
||||
if (!value || value[0] == '\0')
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < items->len; i++)
|
||||
{
|
||||
if (g_ascii_strcasecmp (g_ptr_array_index (items, i), value) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
g_ptr_array_add (items, g_strdup (value));
|
||||
}
|
||||
|
||||
static char *
|
||||
build_gpu_string (void)
|
||||
{
|
||||
IDXGIFactory1 *factory = NULL;
|
||||
GPtrArray *adapters;
|
||||
UINT index;
|
||||
HRESULT hr;
|
||||
char *result;
|
||||
|
||||
hr = CreateDXGIFactory1 (&IID_IDXGIFactory1, (void **) &factory);
|
||||
if (FAILED (hr) || !factory)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
adapters = g_ptr_array_new_with_free_func (g_free);
|
||||
for (index = 0; ; index++)
|
||||
{
|
||||
IDXGIAdapter1 *adapter = NULL;
|
||||
DXGI_ADAPTER_DESC1 desc;
|
||||
char *name;
|
||||
char *label;
|
||||
|
||||
hr = factory->lpVtbl->EnumAdapters1 (factory, index, &adapter);
|
||||
if (hr == DXGI_ERROR_NOT_FOUND)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (FAILED (hr) || !adapter)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ZeroMemory (&desc, sizeof (desc));
|
||||
hr = adapter->lpVtbl->GetDesc1 (adapter, &desc);
|
||||
adapter->lpVtbl->Release (adapter);
|
||||
if (FAILED (hr) || (desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
name = wide_to_utf8 (desc.Description);
|
||||
if (!name)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
g_strstrip (name);
|
||||
|
||||
if ((guint64) desc.DedicatedVideoMemory >= (512ULL * 1024ULL * 1024ULL))
|
||||
{
|
||||
char *vram = g_format_size_full ((guint64) desc.DedicatedVideoMemory, G_FORMAT_SIZE_IEC_UNITS);
|
||||
label = g_strdup_printf ("%s (%s VRAM)", name, vram);
|
||||
g_free (vram);
|
||||
}
|
||||
else
|
||||
{
|
||||
label = g_strdup (name);
|
||||
}
|
||||
|
||||
ptr_array_add_unique (adapters, label);
|
||||
g_free (label);
|
||||
g_free (name);
|
||||
}
|
||||
|
||||
factory->lpVtbl->Release (factory);
|
||||
result = join_ptr_array (adapters, ", ");
|
||||
g_ptr_array_free (adapters, TRUE);
|
||||
return result;
|
||||
}
|
||||
|
||||
static char *
|
||||
build_sound_string (void)
|
||||
{
|
||||
UINT count;
|
||||
UINT i;
|
||||
GPtrArray *devices;
|
||||
char *result;
|
||||
|
||||
count = waveOutGetNumDevs ();
|
||||
if (count == 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
devices = g_ptr_array_new_with_free_func (g_free);
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
WAVEOUTCAPSW caps;
|
||||
char *name;
|
||||
|
||||
ZeroMemory (&caps, sizeof (caps));
|
||||
if (waveOutGetDevCapsW ((UINT_PTR) i, &caps, sizeof (caps)) != MMSYSERR_NOERROR)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
name = wide_to_utf8 (caps.szPname);
|
||||
if (name)
|
||||
{
|
||||
g_strstrip (name);
|
||||
ptr_array_add_unique (devices, name);
|
||||
g_free (name);
|
||||
}
|
||||
}
|
||||
|
||||
result = join_ptr_array (devices, ", ");
|
||||
g_ptr_array_free (devices, TRUE);
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
ensure_os_snapshot (void)
|
||||
{
|
||||
if (g_once_init_enter (&os_initialized))
|
||||
{
|
||||
snapshot.os = build_os_string ();
|
||||
g_once_init_leave (&os_initialized, 1);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ensure_cpu_snapshot (void)
|
||||
{
|
||||
if (g_once_init_enter (&cpu_initialized))
|
||||
{
|
||||
snapshot.cpu = build_cpu_string ();
|
||||
g_once_init_leave (&cpu_initialized, 1);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ensure_gpu_snapshot (void)
|
||||
{
|
||||
if (g_once_init_enter (&gpu_initialized))
|
||||
{
|
||||
snapshot.gpu = build_gpu_string ();
|
||||
g_once_init_leave (&gpu_initialized, 1);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ensure_sound_snapshot (void)
|
||||
{
|
||||
if (g_once_init_enter (&sound_initialized))
|
||||
{
|
||||
snapshot.sound = build_sound_string ();
|
||||
g_once_init_leave (&sound_initialized, 1);
|
||||
}
|
||||
}
|
||||
|
||||
static char *
|
||||
format_usage (guint64 total, guint64 available)
|
||||
{
|
||||
guint64 used;
|
||||
char *used_fmt;
|
||||
char *total_fmt;
|
||||
char *result;
|
||||
double percent;
|
||||
|
||||
if (total == 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (available > total)
|
||||
{
|
||||
available = total;
|
||||
}
|
||||
used = total - available;
|
||||
percent = ((double) used / (double) total) * 100.0;
|
||||
used_fmt = g_format_size_full (used, G_FORMAT_SIZE_IEC_UNITS);
|
||||
total_fmt = g_format_size_full (total, G_FORMAT_SIZE_IEC_UNITS);
|
||||
result = g_strdup_printf ("%s / %s used (%.0f%%)", used_fmt, total_fmt, percent);
|
||||
g_free (used_fmt);
|
||||
g_free (total_fmt);
|
||||
return result;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
sysinfo_backend_get_os (void)
|
||||
sysinfo_backend_get_network (void)
|
||||
{
|
||||
ensure_os_snapshot ();
|
||||
return g_strdup (snapshot.os);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
sysinfo_backend_get_uptime (void)
|
||||
{
|
||||
return sysinfo_format_uptime (GetTickCount64 () / 1000);
|
||||
}
|
||||
|
||||
char *
|
||||
sysinfo_backend_get_disk (void)
|
||||
{
|
||||
guint64 hdd_capacity;
|
||||
guint64 hdd_free_space;
|
||||
|
||||
sysinfo_get_hdd_info (&hdd_capacity, &hdd_free_space);
|
||||
|
||||
if (hdd_capacity != 0)
|
||||
{
|
||||
return sysinfo_format_disk(hdd_capacity, hdd_free_space);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *
|
||||
sysinfo_backend_get_cpu (void)
|
||||
{
|
||||
ensure_cpu_snapshot ();
|
||||
return g_strdup (snapshot.cpu);
|
||||
return sysinfo_get_cpu ();
|
||||
}
|
||||
|
||||
char *
|
||||
sysinfo_backend_get_memory (void)
|
||||
{
|
||||
/* Memory information is always loaded dynamically since it includes the current amount of free memory */
|
||||
return get_memory_info ();
|
||||
}
|
||||
|
||||
char *
|
||||
sysinfo_backend_get_gpu (void)
|
||||
{
|
||||
ensure_gpu_snapshot ();
|
||||
return g_strdup (snapshot.gpu);
|
||||
}
|
||||
|
||||
char *
|
||||
sysinfo_backend_get_sound (void)
|
||||
{
|
||||
ensure_sound_snapshot ();
|
||||
return g_strdup (snapshot.sound);
|
||||
return sysinfo_get_gpu ();
|
||||
}
|
||||
|
||||
char *
|
||||
@@ -581,178 +96,43 @@ sysinfo_backend_get_chipset (void)
|
||||
}
|
||||
|
||||
char *
|
||||
sysinfo_backend_get_memory (void)
|
||||
sysinfo_backend_get_os (void)
|
||||
{
|
||||
MEMORYSTATUSEX memory;
|
||||
|
||||
ZeroMemory (&memory, sizeof (memory));
|
||||
memory.dwLength = sizeof (memory);
|
||||
if (!GlobalMemoryStatusEx (&memory))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return format_usage ((guint64) memory.ullTotalPhys, (guint64) memory.ullAvailPhys);
|
||||
return sysinfo_get_os ();
|
||||
}
|
||||
|
||||
char *
|
||||
sysinfo_backend_get_disk (void)
|
||||
static char *get_memory_info (void)
|
||||
{
|
||||
WCHAR windows_dir[MAX_PATH];
|
||||
WCHAR volume_path[MAX_PATH];
|
||||
ULARGE_INTEGER available;
|
||||
ULARGE_INTEGER total;
|
||||
ULARGE_INTEGER total_free;
|
||||
char *usage;
|
||||
char *volume_utf8;
|
||||
char *result;
|
||||
MEMORYSTATUSEX meminfo = { 0 };
|
||||
meminfo.dwLength = sizeof (meminfo);
|
||||
|
||||
if (GetWindowsDirectoryW (windows_dir, G_N_ELEMENTS (windows_dir)) == 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
if (!GetVolumePathNameW (windows_dir, volume_path, G_N_ELEMENTS (volume_path)))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
if (!GetDiskFreeSpaceExW (volume_path, &available, &total, &total_free))
|
||||
if (!GlobalMemoryStatusEx (&meminfo))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
usage = format_usage ((guint64) total.QuadPart, (guint64) available.QuadPart);
|
||||
if (!usage)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
volume_utf8 = wide_to_utf8 (volume_path);
|
||||
if (!volume_utf8)
|
||||
{
|
||||
return usage;
|
||||
}
|
||||
g_strchomp (volume_utf8);
|
||||
result = g_strdup_printf ("%s" SYSINFO_SEP "%s", usage, volume_utf8);
|
||||
g_free (volume_utf8);
|
||||
g_free (usage);
|
||||
return result;
|
||||
return sysinfo_format_memory (meminfo.ullTotalPhys, meminfo.ullAvailPhys);
|
||||
}
|
||||
|
||||
char *
|
||||
sysinfo_backend_get_uptime (void)
|
||||
static const char *sysinfo_detect_toolkit(void)
|
||||
{
|
||||
return sysinfo_format_uptime ((gint64) (GetTickCount64 () / 1000ULL));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
adapter_looks_virtual (const char *name)
|
||||
{
|
||||
char *lower;
|
||||
gboolean result;
|
||||
|
||||
if (!name)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
lower = g_ascii_strdown (name, -1);
|
||||
result = strstr (lower, "virtual") != NULL ||
|
||||
strstr (lower, "hyper-v") != NULL ||
|
||||
strstr (lower, "vmware") != NULL ||
|
||||
strstr (lower, "virtualbox") != NULL ||
|
||||
strstr (lower, "tap-windows") != NULL ||
|
||||
strstr (lower, "wireguard") != NULL ||
|
||||
strstr (lower, "vpn") != NULL;
|
||||
g_free (lower);
|
||||
return result;
|
||||
}
|
||||
|
||||
char *
|
||||
sysinfo_backend_get_network (void)
|
||||
{
|
||||
ULONG size = 16 * 1024;
|
||||
ULONG status;
|
||||
IP_ADAPTER_ADDRESSES *addresses;
|
||||
IP_ADAPTER_ADDRESSES *adapter;
|
||||
GPtrArray *physical;
|
||||
GPtrArray *fallback;
|
||||
GPtrArray *selected;
|
||||
char *result;
|
||||
|
||||
addresses = g_malloc0 (size);
|
||||
status = GetAdaptersAddresses (AF_UNSPEC,
|
||||
GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER,
|
||||
NULL, addresses, &size);
|
||||
if (status == ERROR_BUFFER_OVERFLOW)
|
||||
{
|
||||
g_free (addresses);
|
||||
addresses = g_malloc0 (size);
|
||||
status = GetAdaptersAddresses (AF_UNSPEC,
|
||||
GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER,
|
||||
NULL, addresses, &size);
|
||||
}
|
||||
if (status != NO_ERROR)
|
||||
{
|
||||
g_free (addresses);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
physical = g_ptr_array_new_with_free_func (g_free);
|
||||
fallback = g_ptr_array_new_with_free_func (g_free);
|
||||
for (adapter = addresses; adapter != NULL; adapter = adapter->Next)
|
||||
{
|
||||
char *description;
|
||||
char *friendly;
|
||||
const char *name;
|
||||
const char *type;
|
||||
char *label;
|
||||
|
||||
if (adapter->OperStatus != IfOperStatusUp || adapter->PhysicalAddressLength == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (adapter->IfType != IF_TYPE_ETHERNET_CSMACD && adapter->IfType != IF_TYPE_IEEE80211)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
description = wide_to_utf8 (adapter->Description);
|
||||
friendly = wide_to_utf8 (adapter->FriendlyName);
|
||||
name = description && description[0] ? description : friendly;
|
||||
if (!name)
|
||||
{
|
||||
g_free (description);
|
||||
g_free (friendly);
|
||||
continue;
|
||||
}
|
||||
|
||||
type = adapter->IfType == IF_TYPE_IEEE80211 ? "Wi-Fi" : "Ethernet";
|
||||
label = g_strdup_printf ("%s: %s", type, name);
|
||||
ptr_array_add_unique (fallback, label);
|
||||
if (!adapter_looks_virtual (name))
|
||||
{
|
||||
ptr_array_add_unique (physical, label);
|
||||
}
|
||||
|
||||
g_free (label);
|
||||
g_free (description);
|
||||
g_free (friendly);
|
||||
}
|
||||
g_free (addresses);
|
||||
|
||||
selected = physical->len != 0 ? physical : fallback;
|
||||
result = join_ptr_array (selected, ", ");
|
||||
g_ptr_array_free (physical, TRUE);
|
||||
g_ptr_array_free (fallback, TRUE);
|
||||
return result;
|
||||
#if defined(USE_GTK_FRONTEND)
|
||||
return "GTK3";
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
char *
|
||||
sysinfo_backend_get_ui (void)
|
||||
{
|
||||
#if defined(USE_GTK_FRONTEND)
|
||||
return g_strdup ("Windows / GTK3");
|
||||
#else
|
||||
const char *toolkit = sysinfo_detect_toolkit();
|
||||
|
||||
/* On Windows we don't have X11/Wayland. Keep it simple. */
|
||||
if (toolkit)
|
||||
{
|
||||
return g_strdup_printf ("Windows / %s", toolkit);
|
||||
}
|
||||
|
||||
return g_strdup ("Windows");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -126,21 +126,7 @@ ctcp_handle (session *sess, char *to, char *nick, char *ip,
|
||||
if (ctcp_check (sess, nick, word, word_eol, word[4] + ctcp_offset))
|
||||
goto generic;
|
||||
|
||||
{
|
||||
gboolean private_fromme = !serv->p_cmp (nick, serv->nick) && !is_channel (serv, to);
|
||||
|
||||
if (private_fromme)
|
||||
{
|
||||
session *target = find_dialog (serv, to);
|
||||
|
||||
if (target)
|
||||
sess = target;
|
||||
else if (serv->front_session)
|
||||
sess = serv->front_session;
|
||||
}
|
||||
|
||||
inbound_action (sess, to, nick, ip, msg + 7, private_fromme, tags_data->identified, tags_data);
|
||||
}
|
||||
inbound_action (sess, to, nick, ip, msg + 7, FALSE, tags_data->identified, tags_data);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1368,7 +1368,7 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[],
|
||||
{
|
||||
if (ignore_check (word[1], IG_PRIV))
|
||||
return;
|
||||
if (!serv->p_cmp (nick, serv->nick))
|
||||
if (serv->have_echo_message && !serv->p_cmp (nick, serv->nick))
|
||||
{
|
||||
session *target_sess = find_dialog (serv, to);
|
||||
|
||||
|
||||
@@ -1740,9 +1740,50 @@ menu_ctcpguiopen (void)
|
||||
editlist_gui_open (NULL, NULL, ctcp_list, buf, "ctcpreply", "ctcpreply.conf", ctcp_help);
|
||||
}
|
||||
|
||||
static char *
|
||||
menu_find_local_docs (void)
|
||||
{
|
||||
char *path;
|
||||
|
||||
#ifdef WIN32
|
||||
char *base_path;
|
||||
|
||||
base_path = g_win32_get_package_installation_directory_of_module (NULL);
|
||||
if (!base_path)
|
||||
return NULL;
|
||||
|
||||
path = g_build_filename (base_path, "share", "doc", "zoitechat", "html", "index.html", NULL);
|
||||
g_free (base_path);
|
||||
#else
|
||||
const char *appdir;
|
||||
|
||||
appdir = g_getenv ("APPDIR");
|
||||
if (appdir && *appdir)
|
||||
path = g_build_filename (appdir, "usr", "share", "doc", "zoitechat", "html", "index.html", NULL);
|
||||
else
|
||||
path = g_build_filename (ZOITECHAT_DOCDIR, "index.html", NULL);
|
||||
#endif
|
||||
|
||||
if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
|
||||
return path;
|
||||
|
||||
g_free (path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
menu_docs (GtkWidget *wid, gpointer none)
|
||||
{
|
||||
char *path;
|
||||
|
||||
path = menu_find_local_docs ();
|
||||
if (path)
|
||||
{
|
||||
fe_open_url (path);
|
||||
g_free (path);
|
||||
return;
|
||||
}
|
||||
|
||||
fe_open_url ("https://docs.zoitechat.org/en/latest/");
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<Target Name="Build">
|
||||
<Exec Command=""$(Python3Path)\python.exe" "$(SolutionDir)..\docs\build-docs.py" "$(SolutionDir)..\docs" "$(ZoiteChatBuild)\$(ZoiteChatPlatform)\docs-html" "$(ZoiteChatBuild)\$(ZoiteChatPlatform)\html-documentation.stamp"" />
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="$(DepsRoot)\bin\*atk-1.0-0.dll" />
|
||||
<None Include="$(DepsRoot)\bin\*cairo*.dll" />
|
||||
@@ -82,6 +84,7 @@
|
||||
<GdkPixbufLoaderCache Include="$(DepsRoot)\lib\gdk-pixbuf-2.0\**\loaders.cache" />
|
||||
|
||||
<FontConfig Include="$(DepsRoot)\etc\fonts\*" />
|
||||
<Docs Include="$(ZoiteChatBuild)\$(ZoiteChatPlatform)\docs-html\**\*" />
|
||||
<Share Include="share\**\*" />
|
||||
<Locale Include="$(ZoiteChatBin)locale\**\*;$(DepsRoot)\share\locale\**\*" />
|
||||
<MSWindowsTheme Include="$(DepsRoot)\share\themes\MS-Windows\**\*" />
|
||||
@@ -97,6 +100,7 @@
|
||||
<Copy SourceFiles="@(GdkPixbufLoaderCache)" DestinationFiles="@(GdkPixbufLoaderCache->'$(ZoiteChatRel)\lib\gdk-pixbuf-2.0\%(RecursiveDir)%(Filename)%(Extension)')" />
|
||||
<Copy SourceFiles="@(GSettingsSchemas)" DestinationFiles="@(GSettingsSchemas->'$(ZoiteChatRel)\share\glib-2.0\schemas\%(Filename)%(Extension)')" />
|
||||
<Copy SourceFiles="@(Share)" DestinationFiles="@(Share->'$(ZoiteChatRel)\share\%(RecursiveDir)%(Filename)%(Extension)')" />
|
||||
<Copy SourceFiles="@(Docs)" DestinationFiles="@(Docs->'$(ZoiteChatRel)\share\doc\zoitechat\html\%(RecursiveDir)%(Filename)%(Extension)')" />
|
||||
<Copy SourceFiles="..\..\COPYING" DestinationFolder="$(ZoiteChatRel)\share\doc\zoitechat" />
|
||||
<Copy SourceFiles="$(WinSparklePath)\COPYING" DestinationFolder="$(ZoiteChatRel)\share\doc\WinSparkle" />
|
||||
<Copy SourceFiles="@(EnchantProviders)" DestinationFolder="$(ZoiteChatRel)\lib\enchant-2" />
|
||||
|
||||
Reference in New Issue
Block a user