mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-12-05 06:22:18 +00:00
fix release+refresh hardware caches
This commit is contained in:
6 files changed
+82
-30
No files matched your search
@@ -99,10 +99,19 @@ get_os_fallback (void)
|
|||||||
return g_strdup_printf ("OS X %ld.%ld.%ld", version.majorVersion, version.minorVersion, version.patchVersion);
|
return g_strdup_printf ("OS X %ld.%ld.%ld", version.majorVersion, version.minorVersion, version.patchVersion);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
static char *os_str;
|
||||||
|
static char *gpu_str;
|
||||||
|
|
||||||
|
void
|
||||||
|
sysinfo_backend_reset_cache (void)
|
||||||
|
{
|
||||||
|
g_clear_pointer (&os_str, g_free);
|
||||||
|
g_clear_pointer (&gpu_str, g_free);
|
||||||
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
sysinfo_backend_get_os(void)
|
sysinfo_backend_get_os(void)
|
||||||
{
|
{
|
||||||
static char *os_str = NULL;
|
|
||||||
if (!os_str)
|
if (!os_str)
|
||||||
{
|
{
|
||||||
os_str = get_os();
|
os_str = get_os();
|
||||||
@@ -250,7 +259,6 @@ get_gpu(void)
|
|||||||
char *
|
char *
|
||||||
sysinfo_backend_get_gpu(void)
|
sysinfo_backend_get_gpu(void)
|
||||||
{
|
{
|
||||||
static char *gpu_str = NULL;
|
|
||||||
if (!gpu_str)
|
if (!gpu_str)
|
||||||
gpu_str = get_gpu();
|
gpu_str = get_gpu();
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,8 @@
|
|||||||
#ifndef SYSINFO_BACKEND_H
|
#ifndef SYSINFO_BACKEND_H
|
||||||
#define SYSINFO_BACKEND_H
|
#define SYSINFO_BACKEND_H
|
||||||
|
|
||||||
|
/* Called on the same client thread as the getters. Safe to call repeatedly. */
|
||||||
|
void sysinfo_backend_reset_cache (void);
|
||||||
char *sysinfo_backend_get_os(void);
|
char *sysinfo_backend_get_os(void);
|
||||||
char *sysinfo_backend_get_disk(void);
|
char *sysinfo_backend_get_disk(void);
|
||||||
char *sysinfo_backend_get_memory(void);
|
char *sysinfo_backend_get_memory(void);
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ static zoitechat_plugin *ph;
|
|||||||
static char name[] = "Sysinfo";
|
static char name[] = "Sysinfo";
|
||||||
static char desc[] = "Display info about your hardware and OS";
|
static char desc[] = "Display info about your hardware and OS";
|
||||||
static char version[] = "2.0";
|
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 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 /SYSINFO REFRESH - clear cached hardware information\n";
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@@ -241,10 +241,15 @@ sysinfo_cb (char *word[], char *word_eol[], void *userdata)
|
|||||||
announce = FALSE;
|
announce = FALSE;
|
||||||
|
|
||||||
cmd = word[2+offset];
|
cmd = word[2+offset];
|
||||||
if (!g_ascii_strcasecmp ("SET", cmd))
|
if (!cmd || !cmd[0])
|
||||||
sysinfo_set_pref (word[3+offset], word_eol[4+offset]);
|
|
||||||
else if (!cmd || !cmd[0])
|
|
||||||
print_summary (announce);
|
print_summary (announce);
|
||||||
|
else if (!g_ascii_strcasecmp ("REFRESH", cmd))
|
||||||
|
{
|
||||||
|
sysinfo_backend_reset_cache ();
|
||||||
|
zoitechat_print (ph, _("Sysinfo: Hardware cache cleared."));
|
||||||
|
}
|
||||||
|
else if (!g_ascii_strcasecmp ("SET", cmd))
|
||||||
|
sysinfo_set_pref (word[3+offset], word_eol[4+offset]);
|
||||||
else
|
else
|
||||||
print_info (cmd, announce);
|
print_info (cmd, announce);
|
||||||
|
|
||||||
@@ -269,6 +274,7 @@ zoitechat_plugin_init (zoitechat_plugin *plugin_handle, char **plugin_name, char
|
|||||||
int
|
int
|
||||||
zoitechat_plugin_deinit (void)
|
zoitechat_plugin_deinit (void)
|
||||||
{
|
{
|
||||||
|
sysinfo_backend_reset_cache ();
|
||||||
zoitechat_command (ph, "MENU DEL \"Window/Send System Info\"");
|
zoitechat_command (ph, "MENU DEL \"Window/Send System Info\"");
|
||||||
zoitechat_command (ph, "MENU DEL \"Window/Display System Info\"");
|
zoitechat_command (ph, "MENU DEL \"Window/Display System Info\"");
|
||||||
zoitechat_printf (ph, _("%s plugin unloaded\n"), name);
|
zoitechat_printf (ph, _("%s plugin unloaded\n"), name);
|
||||||
|
|||||||
@@ -175,6 +175,12 @@ char *sysinfo_backend_get_uptime(void)
|
|||||||
return sysinfo_format_uptime (uptime);
|
return sysinfo_format_uptime (uptime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The legacy Unix backend does not cache hardware snapshots. */
|
||||||
|
void
|
||||||
|
sysinfo_backend_reset_cache (void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
char *sysinfo_backend_get_network(void)
|
char *sysinfo_backend_get_network(void)
|
||||||
{
|
{
|
||||||
char ethernet_card[bsize];
|
char ethernet_card[bsize];
|
||||||
|
|||||||
@@ -40,11 +40,27 @@ typedef struct
|
|||||||
GHashTable *pci_names;
|
GHashTable *pci_names;
|
||||||
} LinuxStaticSnapshot;
|
} LinuxStaticSnapshot;
|
||||||
|
|
||||||
|
/* Sysinfo callbacks and plugin teardown run on the client thread. */
|
||||||
static LinuxStaticSnapshot snapshot;
|
static LinuxStaticSnapshot snapshot;
|
||||||
static gsize os_initialized = 0;
|
static gboolean os_initialized;
|
||||||
static gsize cpu_initialized = 0;
|
static gboolean cpu_initialized;
|
||||||
static gsize pci_initialized = 0;
|
static gboolean pci_initialized;
|
||||||
static gsize sound_initialized = 0;
|
static gboolean sound_initialized;
|
||||||
|
|
||||||
|
void
|
||||||
|
sysinfo_backend_reset_cache (void)
|
||||||
|
{
|
||||||
|
g_clear_pointer (&snapshot.os, g_free);
|
||||||
|
g_clear_pointer (&snapshot.cpu, g_free);
|
||||||
|
g_clear_pointer (&snapshot.gpu, g_free);
|
||||||
|
g_clear_pointer (&snapshot.chipset, g_free);
|
||||||
|
g_clear_pointer (&snapshot.sound, g_free);
|
||||||
|
g_clear_pointer (&snapshot.pci_names, g_hash_table_unref);
|
||||||
|
os_initialized = FALSE;
|
||||||
|
cpu_initialized = FALSE;
|
||||||
|
pci_initialized = FALSE;
|
||||||
|
sound_initialized = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static char *read_trimmed_file (const char *path);
|
static char *read_trimmed_file (const char *path);
|
||||||
static gboolean read_hex_file (const char *path, guint *value);
|
static gboolean read_hex_file (const char *path, guint *value);
|
||||||
@@ -642,40 +658,40 @@ build_os_string (void)
|
|||||||
static void
|
static void
|
||||||
ensure_os_snapshot (void)
|
ensure_os_snapshot (void)
|
||||||
{
|
{
|
||||||
if (g_once_init_enter (&os_initialized))
|
if (!os_initialized)
|
||||||
{
|
{
|
||||||
snapshot.os = build_os_string ();
|
snapshot.os = build_os_string ();
|
||||||
g_once_init_leave (&os_initialized, 1);
|
os_initialized = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ensure_cpu_snapshot (void)
|
ensure_cpu_snapshot (void)
|
||||||
{
|
{
|
||||||
if (g_once_init_enter (&cpu_initialized))
|
if (!cpu_initialized)
|
||||||
{
|
{
|
||||||
snapshot.cpu = build_cpu_string ();
|
snapshot.cpu = build_cpu_string ();
|
||||||
g_once_init_leave (&cpu_initialized, 1);
|
cpu_initialized = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ensure_pci_snapshot (void)
|
ensure_pci_snapshot (void)
|
||||||
{
|
{
|
||||||
if (g_once_init_enter (&pci_initialized))
|
if (!pci_initialized)
|
||||||
{
|
{
|
||||||
scan_pci_devices ();
|
scan_pci_devices ();
|
||||||
g_once_init_leave (&pci_initialized, 1);
|
pci_initialized = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ensure_sound_snapshot (void)
|
ensure_sound_snapshot (void)
|
||||||
{
|
{
|
||||||
if (g_once_init_enter (&sound_initialized))
|
if (!sound_initialized)
|
||||||
{
|
{
|
||||||
snapshot.sound = build_sound_string ();
|
snapshot.sound = build_sound_string ();
|
||||||
g_once_init_leave (&sound_initialized, 1);
|
sound_initialized = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,11 +49,25 @@ typedef struct
|
|||||||
char *sound;
|
char *sound;
|
||||||
} WinStaticSnapshot;
|
} WinStaticSnapshot;
|
||||||
|
|
||||||
|
/* Sysinfo callbacks and plugin teardown run on the client thread. */
|
||||||
static WinStaticSnapshot snapshot;
|
static WinStaticSnapshot snapshot;
|
||||||
static gsize os_initialized = 0;
|
static gboolean os_initialized;
|
||||||
static gsize cpu_initialized = 0;
|
static gboolean cpu_initialized;
|
||||||
static gsize gpu_initialized = 0;
|
static gboolean gpu_initialized;
|
||||||
static gsize sound_initialized = 0;
|
static gboolean sound_initialized;
|
||||||
|
|
||||||
|
void
|
||||||
|
sysinfo_backend_reset_cache (void)
|
||||||
|
{
|
||||||
|
g_clear_pointer (&snapshot.os, g_free);
|
||||||
|
g_clear_pointer (&snapshot.cpu, g_free);
|
||||||
|
g_clear_pointer (&snapshot.gpu, g_free);
|
||||||
|
g_clear_pointer (&snapshot.sound, g_free);
|
||||||
|
os_initialized = FALSE;
|
||||||
|
cpu_initialized = FALSE;
|
||||||
|
gpu_initialized = FALSE;
|
||||||
|
sound_initialized = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static char *wide_to_utf8 (const WCHAR *value);
|
static char *wide_to_utf8 (const WCHAR *value);
|
||||||
static char *read_registry_string (HKEY root, const WCHAR *subkey, const WCHAR *value_name);
|
static char *read_registry_string (HKEY root, const WCHAR *subkey, const WCHAR *value_name);
|
||||||
@@ -444,40 +458,40 @@ build_sound_string (void)
|
|||||||
static void
|
static void
|
||||||
ensure_os_snapshot (void)
|
ensure_os_snapshot (void)
|
||||||
{
|
{
|
||||||
if (g_once_init_enter (&os_initialized))
|
if (!os_initialized)
|
||||||
{
|
{
|
||||||
snapshot.os = build_os_string ();
|
snapshot.os = build_os_string ();
|
||||||
g_once_init_leave (&os_initialized, 1);
|
os_initialized = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ensure_cpu_snapshot (void)
|
ensure_cpu_snapshot (void)
|
||||||
{
|
{
|
||||||
if (g_once_init_enter (&cpu_initialized))
|
if (!cpu_initialized)
|
||||||
{
|
{
|
||||||
snapshot.cpu = build_cpu_string ();
|
snapshot.cpu = build_cpu_string ();
|
||||||
g_once_init_leave (&cpu_initialized, 1);
|
cpu_initialized = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ensure_gpu_snapshot (void)
|
ensure_gpu_snapshot (void)
|
||||||
{
|
{
|
||||||
if (g_once_init_enter (&gpu_initialized))
|
if (!gpu_initialized)
|
||||||
{
|
{
|
||||||
snapshot.gpu = build_gpu_string ();
|
snapshot.gpu = build_gpu_string ();
|
||||||
g_once_init_leave (&gpu_initialized, 1);
|
gpu_initialized = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ensure_sound_snapshot (void)
|
ensure_sound_snapshot (void)
|
||||||
{
|
{
|
||||||
if (g_once_init_enter (&sound_initialized))
|
if (!sound_initialized)
|
||||||
{
|
{
|
||||||
snapshot.sound = build_sound_string ();
|
snapshot.sound = build_sound_string ();
|
||||||
g_once_init_leave (&sound_initialized, 1);
|
sound_initialized = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user