diff --git a/meson_options.txt b/meson_options.txt index b175ad0f..82e9f268 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -67,7 +67,7 @@ option('with-python', type: 'string', value: 'python3', description: 'Python scripting plugin. value is pkg-config name to use or "false"' ) option('with-sysinfo', type: 'boolean', - description: 'System information plugin, requires libpci on Unix' + description: 'System information plugin (optional libpci for PCI names on Unix)' ) option('with-upd', type: 'boolean', description: 'Update plugin, Windows only' diff --git a/plugins/sysinfo/meson.build b/plugins/sysinfo/meson.build index 58ea89a4..6f9d0abb 100644 --- a/plugins/sysinfo/meson.build +++ b/plugins/sysinfo/meson.build @@ -54,6 +54,7 @@ elif system == 'darwin' sysinfo_includes += 'shared' sysinfo_sources += 'shared/df.c' add_languages('objc') + sysinfo_deps += dependency('appleframeworks', modules: ['Cocoa', 'IOKit']) sysinfo_sources += 'osx/backend.m' elif system == 'windows' diff --git a/plugins/sysinfo/osx/backend.m b/plugins/sysinfo/osx/backend.m index 7a64d16a..16041029 100644 --- a/plugins/sysinfo/osx/backend.m +++ b/plugins/sysinfo/osx/backend.m @@ -23,6 +23,8 @@ */ #import +#include +#include #include #include @@ -38,6 +40,7 @@ #include "format.h" #include "df.h" +#include "sysinfo-backend.h" static char * get_os (void) @@ -48,10 +51,7 @@ get_os (void) return NULL; NSString *version = [systemversion objectForKey:@"ProductUserVisibleVersion"]; if (!version) - { - [build release]; return NULL; - } NSDictionary *profiler = [NSDictionary dictionaryWithContentsOfFile:[@"~/Library/Preferences/com.apple.SystemProfiler.plist" stringByExpandingTildeInPath]]; NSDictionary *names = [profiler objectForKey:@"OS Names"]; @@ -65,18 +65,11 @@ get_os (void) break; } } - [build release]; - + /* Dictionary values are borrowed; releasing them would over-release. */ if (!os_name) - { - [version release]; return NULL; - } - char *ret = g_strdup_printf ("%s %s", [os_name UTF8String], [version UTF8String]); - [version release]; - - return ret; + return g_strdup_printf ("%s %s", [os_name UTF8String], [version UTF8String]); } static char * @@ -219,9 +212,14 @@ get_gpu(void) } const void *class = CFDictionaryGetValue(serviceDictionary, @"class-code"); - if (!class || *(guint32*)CFDataGetBytePtr(class) != 0x30000) /* DISPLAY_VGA */ + guint32 class_code = 0; + if (class && CFGetTypeID (class) == CFDataGetTypeID () && + CFDataGetLength (class) >= sizeof (class_code)) + memcpy (&class_code, CFDataGetBytePtr (class), sizeof (class_code)); + if (GUINT32_FROM_LE (class_code) != 0x30000) /* DISPLAY_VGA */ { CFRelease(serviceDictionary); + IOObjectRelease (serviceObject); continue; } @@ -237,7 +235,9 @@ get_gpu(void) } CFRelease(serviceDictionary); + IOObjectRelease (serviceObject); } + IOObjectRelease (entry_iterator); if (gpu_list->len == 0) { @@ -265,6 +265,13 @@ sysinfo_backend_get_gpu(void) return g_strdup (gpu_str); } +char * +sysinfo_backend_get_chipset (void) +{ + /* No chipset detector exists in the legacy macOS backend. */ + return NULL; +} + char * sysinfo_backend_get_sound(void) {