29 #include <Cocoa/Cocoa.h> 31 #import <IOKit/ps/IOPowerSources.h> 32 #import <IOKit/ps/IOPSKeys.h> 40 static bool is_64 = (
sizeof(
void*) == 8);
43 Gestalt(gestaltSysArchitecture, &x);
44 if (x == gestaltPowerPC) {
46 }
else if (x == gestaltIntel) {
53 static bool init_power_sources_info(CFTypeRef *blobptr, CFArrayRef *sourcesptr)
55 *blobptr = IOPSCopyPowerSourcesInfo();
56 *sourcesptr = IOPSCopyPowerSourcesList(*blobptr);
57 if (CFArrayGetCount(*sourcesptr) == 0) {
58 klfDbg(
"Could not retrieve battery information. May be a system without battery.") ;
70 klfDbg(
"_klf_mac_battery_info()") ;
72 bool have_battery = init_power_sources_info(&blob, &sources);
77 klfDbg(
"_klf_mac_battery_info(): unable to get battery info. Probably don't have a battery.") ;
83 CFDictionaryRef pSource = IOPSGetPowerSourceDescription(blob, CFArrayGetValueAtIndex(sources, 0));
85 bool powerConnected = [(NSString*)[(NSDictionary*)pSource objectForKey:@kIOPSPowerSourceStateKey]
86 isEqualToString:@kIOPSACPowerValue];
87 klfDbg(
"power is connected?: "<<(
bool)powerConnected) ;
115 bool have_battery = init_power_sources_info(&blob, &sources);
KLF_EXPORT QString klf_defs_sysinfo_arch()
KLF_EXPORT bool _klf_mac_is_on_battery_power()
Base declarations for klatexformula and some utilities.
#define klfDbg(streamableItems)
print debug stream items
QString fromLatin1(const char *str, int size)
KLF_EXPORT KLFSysInfo::BatteryInfo _klf_mac_battery_info()
KLF_EXPORT bool _klf_mac_is_laptop()