void CPowerManager::SettingOptionsShutdownStatesFiller(const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int ¤t, void *data) { if (g_powerManager.CanPowerdown()) list.push_back(make_pair(g_localizeStrings.Get(13005), POWERSTATE_SHUTDOWN)); if (g_powerManager.CanHibernate()) list.push_back(make_pair(g_localizeStrings.Get(13010), POWERSTATE_HIBERNATE)); if (g_powerManager.CanSuspend()) list.push_back(make_pair(g_localizeStrings.Get(13011), POWERSTATE_SUSPEND)); if (!g_application.IsStandAlone()) { list.push_back(make_pair(g_localizeStrings.Get(13009), POWERSTATE_QUIT)); #if !defined(TARGET_DARWIN_IOS) list.push_back(make_pair(g_localizeStrings.Get(13014), POWERSTATE_MINIMIZE)); #endif } }
void CPowerManager::SetDefaults() { int defaultShutdown = g_guiSettings.GetInt("powermanagement.shutdownstate"); switch (defaultShutdown) { case POWERSTATE_QUIT: case POWERSTATE_MINIMIZE: // assume we can shutdown if --standalone is passed if (g_application.IsStandAlone()) defaultShutdown = POWERSTATE_SHUTDOWN; break; case POWERSTATE_HIBERNATE: if (!g_powerManager.CanHibernate()) { if (g_powerManager.CanSuspend()) defaultShutdown = POWERSTATE_SUSPEND; else defaultShutdown = g_powerManager.CanPowerdown() ? POWERSTATE_SHUTDOWN : POWERSTATE_QUIT; } break; case POWERSTATE_SUSPEND: if (!g_powerManager.CanSuspend()) { if (g_powerManager.CanHibernate()) defaultShutdown = POWERSTATE_HIBERNATE; else defaultShutdown = g_powerManager.CanPowerdown() ? POWERSTATE_SHUTDOWN : POWERSTATE_QUIT; } break; case POWERSTATE_SHUTDOWN: if (!g_powerManager.CanPowerdown()) { if (g_powerManager.CanSuspend()) defaultShutdown = POWERSTATE_SUSPEND; else defaultShutdown = g_powerManager.CanHibernate() ? POWERSTATE_HIBERNATE : POWERSTATE_QUIT; } break; } g_guiSettings.SetInt("powermanagement.shutdownstate", defaultShutdown); }
void CPowerManager::SetDefaults() { int defaultShutdown = CServiceBroker::GetSettings().GetInt(CSettings::SETTING_POWERMANAGEMENT_SHUTDOWNSTATE); switch (defaultShutdown) { case POWERSTATE_QUIT: case POWERSTATE_MINIMIZE: // assume we can shutdown if --standalone is passed if (g_application.IsStandAlone()) defaultShutdown = POWERSTATE_SHUTDOWN; break; case POWERSTATE_HIBERNATE: if (!g_powerManager.CanHibernate()) { if (g_powerManager.CanSuspend()) defaultShutdown = POWERSTATE_SUSPEND; else defaultShutdown = g_powerManager.CanPowerdown() ? POWERSTATE_SHUTDOWN : POWERSTATE_QUIT; } break; case POWERSTATE_SUSPEND: if (!g_powerManager.CanSuspend()) { if (g_powerManager.CanHibernate()) defaultShutdown = POWERSTATE_HIBERNATE; else defaultShutdown = g_powerManager.CanPowerdown() ? POWERSTATE_SHUTDOWN : POWERSTATE_QUIT; } break; case POWERSTATE_SHUTDOWN: if (!g_powerManager.CanPowerdown()) { if (g_powerManager.CanSuspend()) defaultShutdown = POWERSTATE_SUSPEND; else defaultShutdown = g_powerManager.CanHibernate() ? POWERSTATE_HIBERNATE : POWERSTATE_QUIT; } break; } ((CSettingInt*)CServiceBroker::GetSettings().GetSetting(CSettings::SETTING_POWERMANAGEMENT_SHUTDOWNSTATE))->SetDefault(defaultShutdown); }