void CGUIWindowManager::DeInitialize() { CSingleLock lock(g_graphicsContext); for (WindowMap::iterator it = m_mapWindows.begin(); it != m_mapWindows.end(); it++) { CGUIWindow* pWindow = (*it).second; if (IsWindowActive(it->first)) { pWindow->DisableAnimations(); pWindow->Close(true); } pWindow->ResetControlStates(); pWindow->FreeResources(true); } UnloadNotOnDemandWindows(); m_vecMsgTargets.erase( m_vecMsgTargets.begin(), m_vecMsgTargets.end() ); // destroy our custom windows... for (int i = 0; i < (int)m_vecCustomWindows.size(); i++) { CGUIWindow *pWindow = m_vecCustomWindows[i]; Remove(pWindow->GetID()); delete pWindow; } // clear our vectors of windows m_vecCustomWindows.clear(); m_activeDialogs.clear(); m_initialized = false; }
void CGUIWindowLoginScreen::LoadProfile(unsigned int profile) { // stop service addons and give it some time before we start it again ADDON::CAddonMgr::Get().StopServices(true); // stop PVR related services g_application.StopPVRManager(); if (profile != 0 || !g_settings.IsMasterUser()) { g_application.getNetworkManager().NetworkMessage(CNetworkManager::SERVICES_DOWN,1); g_settings.LoadProfile(profile); } else { CGUIWindow* pWindow = g_windowManager.GetWindow(WINDOW_HOME); if (pWindow) pWindow->ResetControlStates(); } g_application.getNetworkManager().StartServices(); g_settings.UpdateCurrentProfileDate(); g_settings.SaveProfiles(PROFILES_FILE); if (g_settings.GetLastUsedProfileIndex() != profile) { g_playlistPlayer.ClearPlaylist(PLAYLIST_VIDEO); g_playlistPlayer.ClearPlaylist(PLAYLIST_MUSIC); g_playlistPlayer.SetCurrentPlaylist(PLAYLIST_NONE); } // reload the add-ons, or we will first load all add-ons from the master account without checking disabled status ADDON::CAddonMgr::Get().ReInit(); g_weatherManager.Refresh(); #ifdef HAS_PYTHON g_pythonParser.m_bLogin = true; #endif #ifdef HAS_JSONRPC JSONRPC::CJSONRPC::Initialize(); #endif // start services which should run on login ADDON::CAddonMgr::Get().StartServices(false); // start PVR related services g_application.StartPVRManager(); g_windowManager.ChangeActiveWindow(g_SkinInfo->GetFirstWindow()); g_application.UpdateLibraries(); }
bool CGUIWindowLoginScreen::OnMessage(CGUIMessage& message) { switch ( message.GetMessage() ) { case GUI_MSG_WINDOW_DEINIT: { m_viewControl.Reset(); } break; case GUI_MSG_CLICKED: { int iControl = message.GetSenderId(); if (iControl == CONTROL_BIG_LIST) { int iAction = message.GetParam1(); // iItem is checked for validity inside these routines if (iAction == ACTION_CONTEXT_MENU || iAction == ACTION_MOUSE_RIGHT_CLICK) { int iItem = m_viewControl.GetSelectedItem(); bool bResult = OnPopupMenu(m_viewControl.GetSelectedItem()); if (bResult) { Update(); CGUIMessage msg(GUI_MSG_ITEM_SELECT,GetID(),CONTROL_BIG_LIST,iItem); OnMessage(msg); } return bResult; } else if (iAction == ACTION_PREVIOUS_MENU) // oh no u don't return false; else if (iAction == ACTION_SELECT_ITEM || iAction == ACTION_MOUSE_LEFT_CLICK) { int iItem = m_viewControl.GetSelectedItem(); bool bOkay = !g_guiSettings.GetBool("masterlock.loginlock"); bool bCanceled; if (!bOkay) bOkay = g_passwordManager.IsProfileLockUnlocked(m_viewControl.GetSelectedItem(), bCanceled); if (bOkay) { if (CFile::Exists("q:\\scripts\\autoexec.py") && watch.GetElapsedMilliseconds() < 5000.f) while (watch.GetElapsedMilliseconds() < 5000) ; if (iItem != 0 || g_settings.m_iLastLoadedProfileIndex != 0) { g_application.getNetwork().NetworkMessage(CNetwork::SERVICES_DOWN,1); #ifdef HAS_XBOX_NETWORK g_application.getNetwork().Deinitialize(); #endif #ifdef HAS_XBOX_HARDWARE CLog::Log(LOGNOTICE, "stop fancontroller"); CFanController::Instance()->Stop(); #endif g_settings.LoadProfile(m_viewControl.GetSelectedItem()); #ifdef HAS_XBOX_NETWORK g_application.getNetwork().Initialize(g_guiSettings.GetInt("network.assignment"), g_guiSettings.GetString("network.ipaddress").c_str(), g_guiSettings.GetString("network.subnet").c_str(), g_guiSettings.GetString("network.gateway").c_str(), g_guiSettings.GetString("network.dns").c_str()); #endif } else { CGUIWindow* pWindow = m_gWindowManager.GetWindow(WINDOW_HOME); if (pWindow) pWindow->ResetControlStates(); } g_settings.m_vecProfiles[g_settings.m_iLastLoadedProfileIndex].setDate(); g_settings.SaveProfiles(PROFILES_FILE); g_weatherManager.Refresh(); #ifdef HAS_PYTHON g_pythonParser.bLogin = true; #endif RESOLUTION res=INVALID; CStdString startupPath = g_SkinInfo.GetSkinPath("startup.xml", &res); int startWindow = g_guiSettings.GetInt("lookandfeel.startupwindow"); // test for a startup window, and activate that instead of home if (CFile::Exists(startupPath) && (!g_SkinInfo.OnlyAnimateToHome() || startWindow == WINDOW_HOME)) { m_gWindowManager.ChangeActiveWindow(WINDOW_STARTUP); } else { m_gWindowManager.ChangeActiveWindow(WINDOW_HOME); m_gWindowManager.ActivateWindow(g_guiSettings.GetInt("lookandfeel.startupwindow")); } #ifdef HAS_KAI if (iItem == 0) g_application.StartKai(); #endif return true; } else { if (!bCanceled && iItem != 0) CGUIDialogOK::ShowAndGetInput(20068,20117,20022,20022); } } } } break; case GUI_MSG_SETFOCUS: { if (m_viewControl.HasControl(message.GetControlId()) && (DWORD) m_viewControl.GetCurrentControl() != message.GetControlId()) { m_viewControl.SetFocused(); return true; } } default: break; } return CGUIWindow::OnMessage(message); }
void CGUIWindowLoginScreen::LoadProfile(unsigned int profile) { // stop service addons and give it some time before we start it again ADDON::CAddonMgr::GetInstance().StopServices(true); // stop PVR related services g_application.StopPVRManager(); // stop audio DSP services with a blocking message CServiceBroker::GetADSP().Deactivate(); if (profile != 0 || !CProfilesManager::GetInstance().IsMasterProfile()) { g_application.getNetwork().NetworkMessage(CNetwork::SERVICES_DOWN,1); CProfilesManager::GetInstance().LoadProfile(profile); } else { CGUIWindow* pWindow = g_windowManager.GetWindow(WINDOW_HOME); if (pWindow) pWindow->ResetControlStates(); } g_application.getNetwork().NetworkMessage(CNetwork::SERVICES_UP,1); CProfilesManager::GetInstance().UpdateCurrentProfileDate(); CProfilesManager::GetInstance().Save(); if (CProfilesManager::GetInstance().GetLastUsedProfileIndex() != profile) { g_playlistPlayer.ClearPlaylist(PLAYLIST_VIDEO); g_playlistPlayer.ClearPlaylist(PLAYLIST_MUSIC); g_playlistPlayer.SetCurrentPlaylist(PLAYLIST_NONE); } // reload the add-ons, or we will first load all add-ons from the master account without checking disabled status ADDON::CAddonMgr::GetInstance().ReInit(); // let CApplication know that we are logging into a new profile g_application.SetLoggingIn(true); if (!g_application.LoadLanguage(true)) { CLog::Log(LOGFATAL, "CGUIWindowLoginScreen: unable to load language for profile \"%s\"", CProfilesManager::GetInstance().GetCurrentProfile().getName().c_str()); return; } g_weatherManager.Refresh(); #ifdef HAS_JSONRPC JSONRPC::CJSONRPC::Initialize(); #endif // restart PVR services g_application.ReinitPVRManager(); // start services which should run on login ADDON::CAddonMgr::GetInstance().StartServices(false); int firstWindow = g_SkinInfo->GetFirstWindow(); // the startup window is considered part of the initialization as it most likely switches to the final window bool uiInitializationFinished = firstWindow != WINDOW_STARTUP_ANIM; g_windowManager.ChangeActiveWindow(firstWindow); g_application.UpdateLibraries(); CStereoscopicsManager::GetInstance().Initialize(); // if the user interfaces has been fully initialized let everyone know if (uiInitializationFinished) { CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_UI_READY); g_windowManager.SendThreadMessage(msg); } }
bool CProfilesManager::LoadProfile(unsigned int index) { PrepareLoadProfile(index); if (index == 0 && IsMasterProfile()) { CGUIWindow* pWindow = CServiceBroker::GetGUI()->GetWindowManager().GetWindow(WINDOW_HOME); if (pWindow) pWindow->ResetControlStates(); UpdateCurrentProfileDate(); Save(); FinalizeLoadProfile(); return true; } CSingleLock lock(m_critical); // check if the index is valid or not if (index >= m_profiles.size()) return false; // check if the profile is already active if (m_currentProfile == index) return true; // save any settings of the currently used skin but only if the (master) // profile hasn't just been loaded as a temporary profile for login if (g_SkinInfo != nullptr && !m_profileLoadedForLogin) g_SkinInfo->SaveSettings(); // unload any old settings CServiceBroker::GetSettings()->Unload(); SetCurrentProfileId(index); m_profileLoadedForLogin = false; // load the new settings if (!CServiceBroker::GetSettings()->Load()) { CLog::Log(LOGFATAL, "CProfilesManager: unable to load settings for profile \"%s\"", m_profiles.at(index).getName().c_str()); return false; } CServiceBroker::GetSettings()->SetLoaded(); CreateProfileFolders(); CServiceBroker::GetDatabaseManager().Initialize(); CServiceBroker::GetInputManager().LoadKeymaps(); CServiceBroker::GetInputManager().SetMouseEnabled(CServiceBroker::GetSettings()->GetBool(CSettings::SETTING_INPUT_ENABLEMOUSE)); CGUIComponent* gui = CServiceBroker::GetGUI(); if (gui) { CGUIInfoManager& infoMgr = gui->GetInfoManager(); infoMgr.ResetCache(); infoMgr.GetInfoProviders().GetGUIControlsInfoProvider().ResetContainerMovingCache(); infoMgr.GetInfoProviders().GetLibraryInfoProvider().ResetLibraryBools(); } if (m_currentProfile != 0) { CXBMCTinyXML doc; if (doc.LoadFile(URIUtils::AddFileToFolder(GetUserDataFolder(), "guisettings.xml"))) { CServiceBroker::GetSettings()->LoadSetting(doc.RootElement(), CSettings::SETTING_MASTERLOCK_MAXRETRIES); CServiceBroker::GetSettings()->LoadSetting(doc.RootElement(), CSettings::SETTING_MASTERLOCK_STARTUPLOCK); } } CPasswordManager::GetInstance().Clear(); // to set labels - shares are reloaded #if !defined(TARGET_WINDOWS) && defined(HAS_DVD_DRIVE) MEDIA_DETECT::CDetectDVDMedia::UpdateState(); #endif // init windows CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_WINDOW_RESET); CServiceBroker::GetGUI()->GetWindowManager().SendMessage(msg); CUtil::DeleteDirectoryCache(); g_directoryCache.Clear(); lock.Leave(); UpdateCurrentProfileDate(); Save(); FinalizeLoadProfile(); return true; }