(Apple) Style nits

This commit is contained in:
twinaphex 2015-04-18 15:09:03 +02:00
parent 9b4d2769f3
commit ba69d2ba59

View File

@ -410,71 +410,71 @@ static int frontend_apple_get_rating(void)
static enum frontend_powerstate frontend_apple_get_powerstate(int *seconds, int *percent) static enum frontend_powerstate frontend_apple_get_powerstate(int *seconds, int *percent)
{ {
enum frontend_powerstate ret = FRONTEND_POWERSTATE_NONE; enum frontend_powerstate ret = FRONTEND_POWERSTATE_NONE;
#if defined(OSX) #if defined(OSX)
CFIndex i, total; CFIndex i, total;
CFArrayRef list; CFArrayRef list;
bool have_ac, have_battery, charging; bool have_ac, have_battery, charging;
CFTypeRef blob = IOPSCopyPowerSourcesInfo(); CFTypeRef blob = IOPSCopyPowerSourcesInfo();
*seconds = -1; *seconds = -1;
*percent = -1; *percent = -1;
if (!blob) if (!blob)
goto end; goto end;
list = IOPSCopyPowerSourcesList(blob); list = IOPSCopyPowerSourcesList(blob);
if (!list) if (!list)
goto end; goto end;
/* don't CFRelease() the list items, or dictionaries! */ /* don't CFRelease() the list items, or dictionaries! */
have_ac = false; have_ac = false;
have_battery = false; have_battery = false;
charging = false; charging = false;
total = CFArrayGetCount(list); total = CFArrayGetCount(list);
for (i = 0; i < total; i++)
{
CFTypeRef ps = (CFTypeRef)CFArrayGetValueAtIndex(list, i);
CFDictionaryRef dict = IOPSGetPowerSourceDescription(blob, ps);
if (dict)
checkps(dict, &have_ac, &have_battery, &charging,
seconds, percent);
}
if (!have_battery)
ret = FRONTEND_POWERSTATE_NO_SOURCE;
else if (charging)
ret = FRONTEND_POWERSTATE_CHARGING;
else if (have_ac)
ret = FRONTEND_POWERSTATE_CHARGED;
else
ret = FRONTEND_POWERSTATE_ON_POWER_SOURCE;
CFRelease(list);
end:
if (blob)
CFRelease(blob);
for (i = 0; i < total; i++)
{
CFTypeRef ps = (CFTypeRef)CFArrayGetValueAtIndex(list, i);
CFDictionaryRef dict = IOPSGetPowerSourceDescription(blob, ps);
if (dict)
checkps(dict, &have_ac, &have_battery, &charging,
seconds, percent);
}
if (!have_battery)
ret = FRONTEND_POWERSTATE_NO_SOURCE;
else if (charging)
ret = FRONTEND_POWERSTATE_CHARGING;
else if (have_ac)
ret = FRONTEND_POWERSTATE_CHARGED;
else
ret = FRONTEND_POWERSTATE_ON_POWER_SOURCE;
CFRelease(list);
end:
if (blob)
CFRelease(blob);
#endif #endif
return ret; return ret;
} }
const frontend_ctx_driver_t frontend_ctx_apple = { const frontend_ctx_driver_t frontend_ctx_apple = {
frontend_apple_get_environment_settings, /* environment_get */ frontend_apple_get_environment_settings,
NULL, /* init */ NULL, /* init */
NULL, /* deinit */ NULL, /* deinit */
NULL, /* exitspawn */ NULL, /* exitspawn */
NULL, /* process_args */ NULL, /* process_args */
NULL, /* exec */ NULL, /* exec */
NULL, /* set_fork */ NULL, /* set_fork */
frontend_apple_shutdown, /* shutdown */ frontend_apple_shutdown,
frontend_apple_get_name, /* get_name */ frontend_apple_get_name,
frontend_apple_get_os, /* get_os */ frontend_apple_get_os,
frontend_apple_get_rating, /* get_rating */ frontend_apple_get_rating,
frontend_apple_load_content, /* load_content */ frontend_apple_load_content,
frontend_apple_get_powerstate, frontend_apple_get_powerstate,
"apple", "apple",
}; };