bool CGUIControl::SendWindowMessage(CGUIMessage &message) const { CGUIWindow *pWindow = g_windowManager.GetWindow(GetParentID()); if (pWindow) return pWindow->OnMessage(message); return g_windowManager.SendMessage(message); }
bool CGUIControl::SendWindowMessage(CGUIMessage &message) { CGUIWindow *pWindow = m_gWindowManager.GetWindow(GetParentID()); if (pWindow) return pWindow->OnMessage(message); return g_graphicsContext.SendMessage(message); }
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(); CGUIMessage msg(GUI_MSG_WINDOW_DEINIT, 0, 0); pWindow->OnMessage(msg); } 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; }
bool CGUIWindowManager::SendMessage(CGUIMessage& message, int window) { CGUIWindow* pWindow = GetWindow(window); if(pWindow) return pWindow->OnMessage(message); else return false; }
/*! \brief Show a picture. * \param params The parameters. * \details params[0] = URL of picture. */ static int Show(const std::vector<std::string>& params) { CGUIMessage msg(GUI_MSG_SHOW_PICTURE, 0, 0); msg.SetStringParam(params[0]); CGUIWindow *pWindow = CServiceBroker::GetGUI()->GetWindowManager().GetWindow(WINDOW_SLIDESHOW); if (pWindow) pWindow->OnMessage(msg); return 0; }
bool CGUIAction::Execute(int controlID, int parentID, int direction /*= 0*/) const { /* 参数: 1、 返回: 1、 说明: 1、此函数对m_actions 容器中的所有单元都进行处理了 */ if (m_actions.size() == 0) return false; bool retval = false; CGUIAction copy(*this); /* 对调用实例的一个复制,相当于哪个CGUIAction 实例调用此方法,copy 就是哪个实例*/ for (ciActions it = copy.m_actions.begin() ; it != copy.m_actions.end() ; it++)/* 遍历容器内的每个单元,每个单元都为一个条件与动作的匹配对*/ { if (it->condition.IsEmpty() || g_infoManager.EvaluateBool(it->condition)) { if (StringUtils::IsInteger(it->action))/* 是一个移动动作的消息,则向相应的窗口发送移动的消息*/ { CGUIMessage msg(GUI_MSG_MOVE, parentID, controlID, direction); if (parentID)/* 如果父窗口id 有效则向父窗口发送就行*/ { CGUIWindow *pWindow = g_windowManager.GetWindow(parentID); if (pWindow) { retval |= pWindow->OnMessage(msg); continue; } } retval |= g_windowManager.SendMessage(msg); } else /* 是一个执行动作的消息,则向相应的窗口发送执行的消息*/ { CGUIMessage msg(GUI_MSG_EXECUTE, controlID, parentID); msg.SetStringParam(it->action); if (m_sendThreadMessages) g_windowManager.SendThreadMessage(msg); else g_windowManager.SendMessage(msg); retval |= true; } } } return retval; }
bool CGUIWindowManager::SendMessage(CGUIMessage& message, int window) { if (window == 0) // send to no specified windows. return SendMessage(message); CGUIWindow* pWindow = GetWindow(window); if(pWindow) return pWindow->OnMessage(message); else return false; }
void CGUIDialogKeyboard::SendSearchMessage() { CStdString utf8Edit; g_charsetConverter.wToUTF8(m_strEdit, utf8Edit); // send our search message (only the active window needs it) CGUIMessage message(GUI_MSG_NOTIFY_ALL, GetID(), 0, GUI_MSG_SEARCH_UPDATE); message.SetStringParam(utf8Edit); CGUIWindow *window = g_windowManager.GetWindow(g_windowManager.GetActiveWindow()); if (window) window->OnMessage(message); }
bool CGUIWindowManager::SendMessage(CGUIMessage& message, int window) { /* 参数: 1、 返回: 1、 说明: 1、直接发送消息给指定的窗体,即直接调用此窗体 实例的OnMessage 方法 */ CGUIWindow* pWindow = GetWindow(window); if(pWindow) return pWindow->OnMessage(message); else return false; }
static int Slideshow(const std::vector<std::string>& params) { std::string beginSlidePath; // leave RecursiveSlideShow command as-is unsigned int flags = 0; if (Recursive) flags |= 1; // SlideShow(dir[,recursive][,[not]random][,pause][,beginslide="/path/to/start/slide.jpg"]) // the beginslide value need be escaped (for '"' or '\' in it, by backslash) // and then quoted, or not. See CUtil::SplitParams() else { for (unsigned int i = 1 ; i < params.size() ; i++) { if (StringUtils::EqualsNoCase(params[i], "recursive")) flags |= 1; else if (StringUtils::EqualsNoCase(params[i], "random")) // set fullscreen or windowed flags |= 2; else if (StringUtils::EqualsNoCase(params[i], "notrandom")) flags |= 4; else if (StringUtils::EqualsNoCase(params[i], "pause")) flags |= 8; else if (StringUtils::StartsWithNoCase(params[i], "beginslide=")) beginSlidePath = params[i].substr(11); } } CGUIMessage msg(GUI_MSG_START_SLIDESHOW, 0, 0, flags); std::vector<std::string> strParams; strParams.push_back(params[0]); strParams.push_back(beginSlidePath); msg.SetStringParams(strParams); CGUIWindow *pWindow = CServiceBroker::GetGUI()->GetWindowManager().GetWindow(WINDOW_SLIDESHOW); if (pWindow) pWindow->OnMessage(msg); return 0; }
void CGUIWindowManager::PreviousWindow() { // deactivate any window CSingleLock lock(g_graphicsContext); CLog::Log(LOGDEBUG,"CGUIWindowManager::PreviousWindow: Deactivate"); int currentWindow = GetActiveWindow(); CGUIWindow *pCurrentWindow = GetWindow(currentWindow); if (!pCurrentWindow) return; // no windows or window history yet // check to see whether our current window has a <previouswindow> tag if (pCurrentWindow->GetPreviousWindow() != WINDOW_INVALID) { // TODO: we may need to test here for the // whether our history should be changed // don't reactivate the previouswindow if it is ourselves. if (currentWindow != pCurrentWindow->GetPreviousWindow()) ActivateWindow(pCurrentWindow->GetPreviousWindow()); return; } // get the previous window in our stack if (m_windowHistory.size() < 2) { // no previous window history yet - check if we should just activate home if (GetActiveWindow() != WINDOW_INVALID && GetActiveWindow() != WINDOW_HOME) { ClearWindowHistory(); ActivateWindow(WINDOW_HOME); } return; } m_windowHistory.pop(); int previousWindow = GetActiveWindow(); m_windowHistory.push(currentWindow); CGUIWindow *pNewWindow = GetWindow(previousWindow); if (!pNewWindow) { CLog::Log(LOGERROR, "Unable to activate the previous window"); ClearWindowHistory(); ActivateWindow(WINDOW_HOME); return; } // ok to go to the previous window now // tell our info manager which window we are going to g_infoManager.SetNextWindow(previousWindow); // set our overlay state (enables out animations on window change) HideOverlay(pNewWindow->GetOverlayState()); // deinitialize our window CloseWindowSync(pCurrentWindow); g_infoManager.SetNextWindow(WINDOW_INVALID); g_infoManager.SetPreviousWindow(currentWindow); // remove the current window off our window stack m_windowHistory.pop(); // ok, initialize the new window CLog::Log(LOGDEBUG,"CGUIWindowManager::PreviousWindow: Activate new"); CGUIMessage msg2(GUI_MSG_WINDOW_INIT, 0, 0, WINDOW_INVALID, GetActiveWindow()); pNewWindow->OnMessage(msg2); g_infoManager.SetPreviousWindow(WINDOW_INVALID); return; }
void CGUIWindowManager::PreviousWindow() { /* 参数: 1、 返回: 1、 说明: 1、此函数实现激活上一个窗体的功能 2、函数执行的原理: 根据窗体操作栈(m_windowHistory) 来实现的 */ // deactivate any window CSingleLock lock(g_graphicsContext); CLog::Log(LOGDEBUG,"CGUIWindowManager::PreviousWindow: Deactivate"); int currentWindow = GetActiveWindow(); /* 获取当前激活窗体的id 号*/ CGUIWindow *pCurrentWindow = GetWindow(currentWindow); /* 获取当前激活窗体指针*/ if (!pCurrentWindow)/* 没有当前被激活的窗体*/ return; // no windows or window history yet // check to see whether our current window has a <previouswindow> tag if (pCurrentWindow->GetPreviousWindow() != WINDOW_INVALID)/* 获取当前窗体是否具有上一个窗体的标记*/ { // TODO: we may need to test here for the // whether our history should be changed // don't reactivate the previouswindow if it is ourselves. if (currentWindow != pCurrentWindow->GetPreviousWindow()) ActivateWindow(pCurrentWindow->GetPreviousWindow());/* 激活上一个窗体*/ return;/* 返回*/ } /* 执行到此处时只能是从窗体的历史记录中获取上一个窗体进行激活了 */ // get the previous window in our stack /* 窗体操作记录总数少于2 个,则激活home 窗体*/ if (m_windowHistory.size() < 2) { // no previous window history yet - check if we should just activate home if (GetActiveWindow() != WINDOW_INVALID && GetActiveWindow() != WINDOW_HOME)/* 当前窗体有效,并且不是home 窗体,则激活home 窗体,否则直接返回了*/ { ClearWindowHistory(); ActivateWindow(WINDOW_HOME); } return; /* 返回*/ } /* 执行到此处时窗体操作栈中的数量肯定是大于等于2 个,因此需要从窗体操作栈中获取前一个窗体 */ /* 如下三行代码就是从窗体的操作记录表( 窗体操作栈) 中取出当前窗体前一个窗体的id 号*/ m_windowHistory.pop(); /* 将当前激活的窗体出栈*/ int previousWindow = GetActiveWindow(); /* 取出当前窗体的前一个窗体,即当前窗体出栈后栈顶的那个窗体*/ m_windowHistory.push(currentWindow); /* 再将当前激活的窗体入栈*/ CGUIWindow *pNewWindow = GetWindow(previousWindow);/* 根据前一个窗体的id 号取出窗体的指针*/ if (!pNewWindow)/* 没得到前一个窗体的指针则清除窗体操作记录栈,将home 窗体激活*/ { CLog::Log(LOGERROR, "Unable to activate the previous window"); ClearWindowHistory(); ActivateWindow(WINDOW_HOME); return; } /* 执行到此处时获得到了前一个窗体的指针 */ // ok to go to the previous window now //-------------------------------------------------------->>> 调用SetNextWindow 开始 // tell our info manager which window we are going to g_infoManager.SetNextWindow(previousWindow); // set our overlay state (enables out animations on window change) HideOverlay(pNewWindow->GetOverlayState()); // deinitialize our window CloseWindowSync(pCurrentWindow); //-------------------------------------------------------->>> 调用SetNextWindow 结束 g_infoManager.SetNextWindow(WINDOW_INVALID); g_infoManager.SetPreviousWindow(currentWindow); // remove the current window off our window stack m_windowHistory.pop(); // ok, initialize the new window CLog::Log(LOGDEBUG,"CGUIWindowManager::PreviousWindow: Activate new"); CGUIMessage msg2(GUI_MSG_WINDOW_INIT, 0, 0, WINDOW_INVALID, GetActiveWindow()); pNewWindow->OnMessage(msg2); g_infoManager.SetPreviousWindow(WINDOW_INVALID); return; }
void CGUIWindowManager::ActivateWindow_Internal(int iWindowID, const std::vector<std::string>& params, bool swappingWindows, bool force /* = false */) { // translate virtual windows // virtual music window which returns the last open music window (aka the music start window) if (iWindowID == WINDOW_MUSIC || iWindowID == WINDOW_MUSIC_FILES) { // backward compatibility for pre-something iWindowID = WINDOW_MUSIC_NAV; } // virtual video window which returns the last open video window (aka the video start window) if (iWindowID == WINDOW_VIDEOS || iWindowID == WINDOW_VIDEO_FILES) { // backward compatibility for pre-Eden iWindowID = WINDOW_VIDEO_NAV; } if (iWindowID == WINDOW_SCRIPTS) { // backward compatibility for pre-Dharma iWindowID = WINDOW_PROGRAMS; } if (iWindowID == WINDOW_START) { // virtual start window iWindowID = g_SkinInfo->GetStartWindow(); } // debug CLog::Log(LOGDEBUG, "Activating window ID: %i", iWindowID); if (!g_passwordManager.CheckMenuLock(iWindowID)) { CLog::Log(LOGERROR, "MasterCode is Wrong: Window with id %d will not be loaded! Enter a correct MasterCode!", iWindowID); if (GetActiveWindow() == WINDOW_INVALID && iWindowID != WINDOW_HOME) ActivateWindow(WINDOW_HOME); return; } // first check existence of the window we wish to activate. CGUIWindow *pNewWindow = GetWindow(iWindowID); if (!pNewWindow) { // nothing to see here - move along CLog::Log(LOGERROR, "Unable to locate window with id %d. Check skin files", iWindowID - WINDOW_HOME); return ; } else if (!pNewWindow->CanBeActivated()) { return; } else if (pNewWindow->IsDialog()) { // if we have a dialog, we do a DoModal() rather than activate the window if (!pNewWindow->IsDialogRunning()) { CSingleExit exitit(g_graphicsContext); ((CGUIDialog *)pNewWindow)->Open(params.size() > 0 ? params[0] : ""); } return; } // don't activate a window if there are active modal dialogs of type NORMAL if (!force && HasModalDialog({ DialogModalityType::MODAL })) { CLog::Log(LOGINFO, "Activate of window '%i' refused because there are active modal dialogs", iWindowID); g_audioManager.PlayActionSound(CAction(ACTION_ERROR)); return; } g_infoManager.SetNextWindow(iWindowID); // deactivate any window int currentWindow = GetActiveWindow(); CGUIWindow *pWindow = GetWindow(currentWindow); if (pWindow) CloseWindowSync(pWindow, iWindowID); g_infoManager.SetNextWindow(WINDOW_INVALID); // Add window to the history list (we must do this before we activate it, // as all messages done in WINDOW_INIT will want to be sent to the new // topmost window). If we are swapping windows, we pop the old window // off the history stack if (swappingWindows && !m_windowHistory.empty()) m_windowHistory.pop(); AddToWindowHistory(iWindowID); g_infoManager.SetPreviousWindow(currentWindow); // Send the init message CGUIMessage msg(GUI_MSG_WINDOW_INIT, 0, 0, currentWindow, iWindowID); msg.SetStringParams(params); pNewWindow->OnMessage(msg); // g_infoManager.SetPreviousWindow(WINDOW_INVALID); }
void CGUIWindowManager::PreviousWindow() { // deactivate any window CSingleLock lock(g_graphicsContext); CLog::Log(LOGDEBUG,"CGUIWindowManager::PreviousWindow: Deactivate"); int currentWindow = GetActiveWindow(); CGUIWindow *pCurrentWindow = GetWindow(currentWindow); if (!pCurrentWindow) return; // no windows or window history yet // check to see whether our current window has a <previouswindow> tag if (pCurrentWindow->GetPreviousWindow() != WINDOW_INVALID) { //! @todo we may need to test here for the //! whether our history should be changed // don't reactivate the previouswindow if it is ourselves. if (currentWindow != pCurrentWindow->GetPreviousWindow()) ActivateWindow(pCurrentWindow->GetPreviousWindow()); return; } // get the previous window in our stack if (m_windowHistory.size() < 2) { // no previous window history yet - check if we should just activate home if (GetActiveWindow() != WINDOW_INVALID && GetActiveWindow() != WINDOW_HOME) { CloseWindowSync(pCurrentWindow); ClearWindowHistory(); ActivateWindow(WINDOW_HOME); } return; } m_windowHistory.pop(); int previousWindow = GetActiveWindow(); m_windowHistory.push(currentWindow); CGUIWindow *pNewWindow = GetWindow(previousWindow); if (!pNewWindow) { CLog::Log(LOGERROR, "Unable to activate the previous window"); CloseWindowSync(pCurrentWindow); ClearWindowHistory(); ActivateWindow(WINDOW_HOME); return; } // ok to go to the previous window now // pause game when leaving fullscreen or resume game when entering fullscreen if (g_application.m_pPlayer->IsPlayingGame()) { if (previousWindow == WINDOW_FULLSCREEN_VIDEO && g_application.m_pPlayer->IsPaused()) g_application.OnAction(ACTION_PAUSE); else if (currentWindow == WINDOW_FULLSCREEN_VIDEO && !g_application.m_pPlayer->IsPaused()) g_application.OnAction(ACTION_PAUSE); } // tell our info manager which window we are going to g_infoManager.SetNextWindow(previousWindow); // deinitialize our window CloseWindowSync(pCurrentWindow); g_infoManager.SetNextWindow(WINDOW_INVALID); g_infoManager.SetPreviousWindow(currentWindow); // remove the current window off our window stack m_windowHistory.pop(); // ok, initialize the new window CLog::Log(LOGDEBUG,"CGUIWindowManager::PreviousWindow: Activate new"); CGUIMessage msg2(GUI_MSG_WINDOW_INIT, 0, 0, WINDOW_INVALID, GetActiveWindow()); pNewWindow->OnMessage(msg2); g_infoManager.SetPreviousWindow(WINDOW_INVALID); return; }
void CGUIWindowManager::ActivateWindow_Internal(int iWindowID, const vector<CStdString>& params, bool swappingWindows) { bool passParams = true; // translate virtual windows // virtual music window which returns the last open music window (aka the music start window) if (iWindowID == WINDOW_MUSIC) { iWindowID = g_stSettings.m_iMyMusicStartWindow; // ensure the music virtual window only returns music files and music library windows if (iWindowID != WINDOW_MUSIC_NAV) iWindowID = WINDOW_MUSIC_FILES; // destination path cannot be used with virtual window passParams = false; } // virtual video window which returns the last open video window (aka the video start window) if (iWindowID == WINDOW_VIDEOS) { iWindowID = g_stSettings.m_iVideoStartWindow; // ensure the virtual video window only returns video windows if (iWindowID != WINDOW_VIDEO_NAV) iWindowID = WINDOW_VIDEO_FILES; // destination path cannot be used with virtual window passParams = false; } // stop video player when entering home screen if(iWindowID == WINDOW_HOME && g_application.IsPlayingVideo()) { CLog::Log(LOGDEBUG,"CGUIWindowManager::ActivateWindow_Internal - [iWindowID=%d=WINDOW_HOME][IsPlayingVideo=TRUE] - Going to stop the video (ev)",iWindowID); g_application.StopPlaying(); } // debug CLog::Log(LOGDEBUG, "Activating window ID: %i", iWindowID); if(!g_passwordManager.CheckMenuLock(iWindowID)) { CLog::Log(LOGERROR, "MasterCode is Wrong: Window with id %d will not be loaded! Enter a correct MasterCode!", iWindowID); return; } // first check existence of the window we wish to activate. CGUIWindow *pNewWindow = GetWindow(iWindowID); if (!pNewWindow) { // nothing to see here - move along CLog::Log(LOGERROR, "Unable to locate window with id %d. Check skin files", iWindowID - WINDOW_HOME); return ; } else if (pNewWindow->IsDialog()) { // if we have a dialog, we do a DoModal() rather than activate the window if (!pNewWindow->IsDialogRunning()) ((CGUIDialog *)pNewWindow)->DoModal(iWindowID, (passParams && params.size()) ? params[0] : ""); return; } g_infoManager.SetNextWindow(iWindowID); // set our overlay state HideOverlay(pNewWindow->GetOverlayState()); // deactivate any window int currentWindow = GetActiveWindow(); CGUIWindow *pWindow = GetWindow(currentWindow); if (pWindow) { // If we got here from the screen saver, don't close the dialogs as we want to see // them when we come back if (!g_application.GetInSlideshowScreensaver()) CloseDialogs(); // Play the window specific deinit sound g_audioManager.PlayWindowSound(pWindow->GetID(), SOUND_DEINIT); CGUIMessage msg(GUI_MSG_WINDOW_DEINIT, 0, 0, iWindowID); pWindow->OnMessage(msg); } g_infoManager.SetNextWindow(WINDOW_INVALID); // Add window to the history list (we must do this before we activate it, // as all messages done in WINDOW_INIT will want to be sent to the new // topmost window). If we are swapping windows, we pop the old window // off the history stack if (swappingWindows && m_windowHistory.size()) m_windowHistory.pop(); AddToWindowHistory(iWindowID); g_infoManager.SetPreviousWindow(currentWindow); g_audioManager.PlayWindowSound(pNewWindow->GetID(), SOUND_INIT); // Send the init message CGUIMessage msg(GUI_MSG_WINDOW_INIT, 0, 0, currentWindow, iWindowID); if (passParams) msg.SetStringParams(params); pNewWindow->OnMessage(msg); // g_infoManager.SetPreviousWindow(WINDOW_INVALID); }
void CGUIWindowManager::ActivateWindow_Internal(int iWindowID, const vector<CStdString>& params, bool swappingWindows) { // translate virtual windows // virtual music window which returns the last open music window (aka the music start window) if (iWindowID == WINDOW_MUSIC) { iWindowID = g_settings.m_iMyMusicStartWindow; // ensure the music virtual window only returns music files and music library windows if (iWindowID != WINDOW_MUSIC_NAV) iWindowID = WINDOW_MUSIC_FILES; } // virtual video window which returns the last open video window (aka the video start window) if (iWindowID == WINDOW_VIDEOS || iWindowID == WINDOW_VIDEO_FILES) { // backward compatibility for pre-Eden iWindowID = WINDOW_VIDEO_NAV; } if (iWindowID == WINDOW_SCRIPTS) { // backward compatibility for pre-Dharma iWindowID = WINDOW_PROGRAMS; } if (iWindowID == WINDOW_START) { // virtual start window iWindowID = g_SkinInfo->GetStartWindow(); } // debug CLog::Log(LOGDEBUG, "Activating window ID: %i", iWindowID); if (!g_passwordManager.CheckMenuLock(iWindowID)) { CLog::Log(LOGERROR, "MasterCode is Wrong: Window with id %d will not be loaded! Enter a correct MasterCode!", iWindowID); if (GetActiveWindow() == WINDOW_INVALID && iWindowID != WINDOW_HOME) ActivateWindow(WINDOW_HOME); return; } // first check existence of the window we wish to activate. CGUIWindow *pNewWindow = GetWindow(iWindowID); if (!pNewWindow) { // nothing to see here - move along CLog::Log(LOGERROR, "Unable to locate window with id %d. Check skin files", iWindowID - WINDOW_HOME); return ; } else if (pNewWindow->IsDialog()) { // if we have a dialog, we do a DoModal() rather than activate the window if (!pNewWindow->IsDialogRunning()) { CSingleExit exitit(g_graphicsContext); ((CGUIDialog *)pNewWindow)->DoModal(iWindowID, params.size() ? params[0] : ""); } return; } g_infoManager.SetNextWindow(iWindowID); // set our overlay state HideOverlay(pNewWindow->GetOverlayState()); // deactivate any window int currentWindow = GetActiveWindow(); CGUIWindow *pWindow = GetWindow(currentWindow); if (pWindow) CloseWindowSync(pWindow, iWindowID); g_infoManager.SetNextWindow(WINDOW_INVALID); // Add window to the history list (we must do this before we activate it, // as all messages done in WINDOW_INIT will want to be sent to the new // topmost window). If we are swapping windows, we pop the old window // off the history stack if (swappingWindows && m_windowHistory.size()) m_windowHistory.pop(); AddToWindowHistory(iWindowID); g_infoManager.SetPreviousWindow(currentWindow); // Send the init message CGUIMessage msg(GUI_MSG_WINDOW_INIT, 0, 0, currentWindow, iWindowID); msg.SetStringParams(params); pNewWindow->OnMessage(msg); // g_infoManager.SetPreviousWindow(WINDOW_INVALID); }
void CGUIWindowManager::ActivateWindow_Internal(int iWindowID, const vector<CStdString>& params, bool swappingWindows) { /* 参数: 1、iWindowID : 要激活的窗体id 号 2、params : 传递给窗体的参数 3、swappingWindows : 是否交换激活窗体( 见下面对此参数的说明) 返回: 1、 说明: 1、激活窗体的原则: A、根据传入的窗体id 找到要激活的窗体指针 1) 没找到 a、直接出错返回 2) 找到了 a、如果是一个对话框,则调用对话框的DoModal 方法将对话框显示,然后返回 b、执行下面的B 步骤 B、 C、 2、参数swappingWindows 的作用: 假设: AAA : 原来激活的窗体,即当前激活窗体 BBB : 要激活的窗体 true : 将BBB 窗体激活,将AAA 窗体从窗体操作栈出栈,将BBB 窗体添加到窗体操作栈 false : 将BBB 窗体激活,不将AAA 窗体从窗体操作栈出栈,将BBB 窗体添加到窗体操作栈 */ // translate virtual windows // virtual music window which returns the last open music window (aka the music start window) if (iWindowID == WINDOW_MUSIC) { iWindowID = g_settings.m_iMyMusicStartWindow; // ensure the music virtual window only returns music files and music library windows if (iWindowID != WINDOW_MUSIC_NAV) iWindowID = WINDOW_MUSIC_FILES; } // virtual video window which returns the last open video window (aka the video start window) if (iWindowID == WINDOW_VIDEOS || iWindowID == WINDOW_VIDEO_FILES) { // backward compatibility for pre-Eden iWindowID = WINDOW_VIDEO_NAV; } if (iWindowID == WINDOW_SCRIPTS) { // backward compatibility for pre-Dharma iWindowID = WINDOW_PROGRAMS; } if (iWindowID == WINDOW_START) { // virtual start window iWindowID = g_SkinInfo->GetStartWindow(); } // debug CLog::Log(LOGDEBUG, "Activating window ID: %i", iWindowID); if (!g_passwordManager.CheckMenuLock(iWindowID)) { CLog::Log(LOGERROR, "MasterCode is Wrong: Window with id %d will not be loaded! Enter a correct MasterCode!", iWindowID); if (GetActiveWindow() == WINDOW_INVALID && iWindowID != WINDOW_HOME) ActivateWindow(WINDOW_HOME); return; } // first check existence of the window we wish to activate. CGUIWindow *pNewWindow = GetWindow(iWindowID);/* 获取要激活的窗体*/ if (!pNewWindow)/* 没得到*/ { // nothing to see here - move along CLog::Log(LOGERROR, "Unable to locate window with id %d. Check skin files", iWindowID - WINDOW_HOME); return ; } else if (pNewWindow->IsDialog()) /* 如果要激活的窗体是个对话框*/ { // if we have a dialog, we do a DoModal() rather than activate the window if (!pNewWindow->IsDialogRunning())/* 对话框没有在运行状态,则将其模态显示出来*/ { CSingleExit exitit(g_graphicsContext); ((CGUIDialog *)pNewWindow)->DoModal(iWindowID, params.size() ? params[0] : ""); } return; } //-------------------------------------------------------->>> 调用SetNextWindow 开始 g_infoManager.SetNextWindow(iWindowID); /* 设定要激活的窗体的id 为下一个窗体id ,即相当于全局变量保存这个值*/ // set our overlay state HideOverlay(pNewWindow->GetOverlayState()); // deactivate any window int currentWindow = GetActiveWindow(); CGUIWindow *pWindow = GetWindow(currentWindow); if (pWindow) CloseWindowSync(pWindow, iWindowID); //-------------------------------------------------------->>> 调用SetNextWindow 结束 g_infoManager.SetNextWindow(WINDOW_INVALID); /* 设定下一个窗体id 为无效的*/ // Add window to the history list (we must do this before we activate it, // as all messages done in WINDOW_INIT will want to be sent to the new // topmost window). If we are swapping windows, we pop the old window // off the history stack if (swappingWindows && m_windowHistory.size()) m_windowHistory.pop(); /* 将当前激活的窗体从窗体操作栈中出栈*/ AddToWindowHistory(iWindowID); /* 将要激活的窗体id 号添加入窗体操作栈*/ g_infoManager.SetPreviousWindow(currentWindow); /* 向要激活的窗体发送init 消息,即直接调用要激活窗体的OnMessage 方法*/ // Send the init message CGUIMessage msg(GUI_MSG_WINDOW_INIT, 0, 0, currentWindow, iWindowID); msg.SetStringParams(params); pNewWindow->OnMessage(msg); // g_infoManager.SetPreviousWindow(WINDOW_INVALID); }
bool CGUIDialogBoxeeCtx::OnMessage(CGUIMessage &message) { switch (message.GetMessage()) { case GUI_MSG_ITEM_LOADED: { // New data received from the item loader, update existing item CFileItemPtr pItem ((CFileItem *)message.GetPointer()); message.SetPointer(NULL); if (pItem) { m_item = *pItem; CGUIMessage msg(GUI_MSG_LABEL_RESET, GetID(), INFO_HIDDEN_LIST, 0); OnMessage(msg); CGUIMessage winmsg(GUI_MSG_LABEL_ADD, GetID(), INFO_HIDDEN_LIST, 0, 0, pItem); OnMessage(winmsg); CGUIMessage ref1(GUI_MSG_REFRESH_THUMBS, GetID(), IMG1); OnMessage(ref1); CGUIMessage ref2(GUI_MSG_REFRESH_THUMBS, GetID(), IMG2); OnMessage(ref2); CGUIMessage ref3(GUI_MSG_REFRESH_THUMBS, GetID(), IMG3); OnMessage(ref3); CGUIMessage ref4(GUI_MSG_REFRESH_THUMBS, GetID(), IMG4); OnMessage(ref4); } return true; } case GUI_MSG_CLICKED: { unsigned int iControl = message.GetSenderId(); if (iControl == BTN_MORE_INFO) { OnMoreInfo(); return true; } else if (iControl == BTN_RATE) { bool bLike; if (CGUIDialogBoxeeRate::ShowAndGetInput(bLike)) { BoxeeUtils::Rate(&m_item, bLike); g_application.m_guiDialogKaiToast.QueueNotification(CGUIDialogKaiToast::ICON_STAR, "", g_localizeStrings.Get(51034), 5000 , KAI_YELLOW_COLOR, KAI_GREY_COLOR); } } else if (iControl == BTN_SHARE) { CGUIDialogBoxeeShare *pShare = (CGUIDialogBoxeeShare *)g_windowManager.GetWindow(WINDOW_DIALOG_BOXEE_SHARE); if (pShare) { pShare->SetItem(&m_item); pShare->DoModal(); } else { CLog::Log(LOGERROR,"CGUIDialogBoxeeCtx::OnMessage - GUI_MSG_CLICKED - BTN_SHARE - FAILED to get WINDOW_DIALOG_BOXEE_SHARE (share)"); } } else if (iControl == BTN_PRESET) { if (m_item.GetPropertyBOOL("IsPreset")) { CGUIDialogYesNo* dlgYesNo = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (dlgYesNo) { dlgYesNo->SetHeading(51020); dlgYesNo->SetLine(0, 51021); dlgYesNo->SetLine(1, m_item.GetLabel() + "?"); dlgYesNo->SetLine(2, ""); dlgYesNo->DoModal(); if (dlgYesNo->IsConfirmed()) { g_settings.DeleteSource(GetItemShareType(), m_item.GetProperty("ShareName"), m_item.m_strPath); CGUIWindow *pWindow = g_windowManager.GetWindow(g_windowManager.GetActiveWindow()); if (pWindow) { CGUIMessage msg(GUI_MSG_REFRESH_APPS, 0, 0); pWindow->OnMessage(msg); } } } } else { CMediaSource newShare; newShare.strPath = m_item.m_strPath; newShare.strName = m_item.GetLabel(); if (m_item.HasProperty("OriginalThumb") && !m_item.GetProperty("OriginalThumb").IsEmpty()) newShare.m_strThumbnailImage = m_item.GetProperty("OriginalThumb"); else newShare.m_strThumbnailImage = m_item.GetThumbnailImage(); newShare.vecPaths.push_back(m_item.m_strPath); g_settings.AddShare(GetItemShareType(), newShare); } Close(); return true; } else if (iControl == BTN_QUALITY) { return HandleQualityList(); } } break; case GUI_MSG_WINDOW_DEINIT: case GUI_MSG_VISUALISATION_UNLOADING: { } break; case GUI_MSG_VISUALISATION_LOADED: { } } return CGUIDialog::OnMessage(message); }
bool CGUIWindowManager::SendMessage(CGUIMessage& message) { bool handled = false; // CLog::Log(LOGDEBUG,"SendMessage: mess=%d send=%d control=%d param1=%d", message.GetMessage(), message.GetSenderId(), message.GetControlId(), message.GetParam1()); // Send the message to all none window targets for (int i = 0; i < (int) m_vecMsgTargets.size(); i++) { IMsgTargetCallback* pMsgTarget = m_vecMsgTargets[i]; if (pMsgTarget) { if (pMsgTarget->OnMessage( message )) handled = true; } } // A GUI_MSG_NOTIFY_ALL is send to any active modal dialog // and all windows whether they are active or not if (message.GetMessage()==GUI_MSG_NOTIFY_ALL) { CSingleLock lock(g_graphicsContext); for (rDialog it = m_activeDialogs.rbegin(); it != m_activeDialogs.rend(); ++it) { CGUIWindow *dialog = *it; dialog->OnMessage(message); } for (WindowMap::iterator it = m_mapWindows.begin(); it != m_mapWindows.end(); it++) { CGUIWindow *pWindow = (*it).second; pWindow->OnMessage(message); } return true; } // Normal messages are sent to: // 1. All active modeless dialogs // 2. The topmost dialog that accepts the message // 3. The underlying window (only if it is the sender or receiver if a modal dialog is active) bool hasModalDialog(false); bool modalAcceptedMessage(false); // don't use an iterator for this loop, as some messages mean that m_activeDialogs is altered, // which will invalidate any iterator CSingleLock lock(g_graphicsContext); unsigned int topWindow = m_activeDialogs.size(); while (topWindow) { CGUIWindow* dialog = m_activeDialogs[--topWindow]; lock.Leave(); if (!modalAcceptedMessage && dialog->IsModalDialog()) { // modal window hasModalDialog = true; if (!modalAcceptedMessage && dialog->OnMessage( message )) { modalAcceptedMessage = handled = true; } } else if (!dialog->IsModalDialog()) { // modeless if (dialog->OnMessage( message )) handled = true; } lock.Enter(); if (topWindow > m_activeDialogs.size()) topWindow = m_activeDialogs.size(); } lock.Leave(); // now send to the underlying window CGUIWindow* window = GetWindow(GetActiveWindow()); if (window) { if (hasModalDialog) { // only send the message to the underlying window if it's the recipient // or sender (or we have no sender) if (message.GetSenderId() == window->GetID() || message.GetControlId() == window->GetID() || message.GetSenderId() == 0 ) { if (window->OnMessage(message)) handled = true; } } else { if (window->OnMessage(message)) handled = true; } } return handled; }
void CApplicationMessenger::ProcessMessage(ThreadMessage *pMsg) { switch (pMsg->dwMessage) { case TMSG_SHUTDOWN: { switch (g_guiSettings.GetInt("system.shutdownstate")) { case POWERSTATE_SHUTDOWN: Powerdown(); break; case POWERSTATE_SUSPEND: Suspend(); break; case POWERSTATE_HIBERNATE: Hibernate(); break; case POWERSTATE_QUIT: Quit(); break; case POWERSTATE_MINIMIZE: Minimize(); break; } } break; case TMSG_POWERDOWN: { g_application.Stop(); Sleep(200); g_Windowing.DestroyWindow(); g_powerManager.Powerdown(); #ifdef HAS_EMBEDDED CHalServicesFactory::GetInstance().Shutdown(); #endif exit(64); } break; case TMSG_QUIT: { g_application.Stop(); Sleep(200); g_Windowing.DestroyWindow(); exit(0); } break; case TMSG_HIBERNATE: { g_powerManager.Hibernate(); } break; case TMSG_SUSPEND: { g_powerManager.Suspend(); MediaStop(); } break; case TMSG_LOGOUT: { CLog::Log(LOGDEBUG,"CApplicationMessenger::ProcessMessage - Enter TMSG_LOGOUT case. Going to call BoxeeLoginManager::Logout() (logout)"); g_application.GetBoxeeLoginManager().Logout(); } break; case TMSG_RESTART: { g_application.Stop(); Sleep(200); g_Windowing.DestroyWindow(); g_powerManager.Reboot(); exit(66); } break; case TMSG_RESET: { g_application.Stop(); Sleep(200); g_Windowing.DestroyWindow(); g_powerManager.Reboot(); exit(66); } break; case TMSG_RESTARTAPP: { #ifdef _WIN32 g_application.Stop(); Sleep(200); #endif exit(65); // TODO //char szXBEFileName[1024]; //CIoSupport::GetXbePath(szXBEFileName); //CUtil::RunXBE(szXBEFileName); } break; case TMSG_MEDIA_PLAY: { // first check if we were called from the PlayFile() function if (pMsg->lpVoid && pMsg->dwParam2 == 0) { CFileItem *item = (CFileItem *)pMsg->lpVoid; g_application.PlayFile(*item, pMsg->dwParam1 != 0); delete item; return; } // restore to previous window if needed if (g_windowManager.GetActiveWindow() == WINDOW_SLIDESHOW || g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO || g_windowManager.GetActiveWindow() == WINDOW_VISUALISATION) g_windowManager.PreviousWindow(); g_application.ResetScreenSaver(); g_application.WakeUpScreenSaverAndDPMS(); //g_application.StopPlaying(); // play file CFileItem *item; if (pMsg->lpVoid && pMsg->dwParam2 == 1) { item = (CFileItem *)pMsg->lpVoid; } else { item = new CFileItem(pMsg->strParam, false); } if (item->IsAudio()) item->SetMusicThumb(); else item->SetVideoThumb(); item->FillInDefaultIcon(); g_application.PlayMedia(*item, item->IsAudio() ? PLAYLIST_MUSIC : PLAYLIST_VIDEO); //Note: this will play playlists always in the temp music playlist (default 2nd parameter), maybe needs some tweaking. delete item; } break; case TMSG_MEDIA_RESTART: g_application.Restart(true); break; case TMSG_MEDIA_QUEUE_NEXT_ITEM: { CFileItem *item = (CFileItem *)pMsg->lpVoid; //g_application.QueueNextMedia(*item); delete item; return; } case TMSG_MEDIA_UPDATE_ITEM: { CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_UPDATE_ITEM, 0); msg.SetItem(CFileItemPtr((CFileItem*)pMsg->lpVoid)); g_windowManager.SendMessage(msg); return; } case TMSG_PICTURE_SHOW: { CGUIWindowSlideShow *pSlideShow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW); if (!pSlideShow) return ; // stop playing file if (g_application.IsPlayingVideo()) g_application.StopPlaying(); if (g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO) g_windowManager.PreviousWindow(); g_application.ResetScreenSaver(); g_application.WakeUpScreenSaverAndDPMS(); g_graphicsContext.Lock(); pSlideShow->Reset(); if (g_windowManager.GetActiveWindow() != WINDOW_SLIDESHOW) g_windowManager.ActivateWindow(WINDOW_SLIDESHOW); if (CUtil::IsZIP(pMsg->strParam) || CUtil::IsRAR(pMsg->strParam)) // actually a cbz/cbr { CFileItemList items; CStdString strPath; if (CUtil::IsZIP(pMsg->strParam)) CUtil::CreateArchivePath(strPath, "zip", pMsg->strParam.c_str(), ""); else CUtil::CreateArchivePath(strPath, "rar", pMsg->strParam.c_str(), ""); CUtil::GetRecursiveListing(strPath, items, g_stSettings.m_pictureExtensions); if (items.Size() > 0) { for (int i=0;i<items.Size();++i) { pSlideShow->Add(items[i].get()); } pSlideShow->Select(items[0]->m_strPath); } } else { CFileItem item(pMsg->strParam, false); pSlideShow->Add(&item); pSlideShow->Select(pMsg->strParam); } g_graphicsContext.Unlock(); } break; case TMSG_SLIDESHOW_SCREENSAVER: case TMSG_PICTURE_SLIDESHOW: { CGUIWindowSlideShow *pSlideShow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW); if (!pSlideShow) return ; g_graphicsContext.Lock(); pSlideShow->Reset(); CFileItemList items; CStdString strPath = pMsg->strParam; if (pMsg->dwMessage == TMSG_SLIDESHOW_SCREENSAVER && g_guiSettings.GetString("screensaver.mode").Equals("Fanart Slideshow")) { CUtil::GetRecursiveListing(g_settings.GetVideoFanartFolder(), items, ".tbn"); CUtil::GetRecursiveListing(g_settings.GetMusicFanartFolder(), items, ".tbn"); } else CUtil::GetRecursiveListing(strPath, items, g_stSettings.m_pictureExtensions); if (items.Size() > 0) { for (int i=0;i<items.Size();++i) pSlideShow->Add(items[i].get()); pSlideShow->StartSlideShow(pMsg->dwMessage == TMSG_SLIDESHOW_SCREENSAVER); //Start the slideshow! } if (pMsg->dwMessage == TMSG_SLIDESHOW_SCREENSAVER) pSlideShow->Shuffle(); if (g_windowManager.GetActiveWindow() != WINDOW_SLIDESHOW) g_windowManager.ActivateWindow(WINDOW_SLIDESHOW); g_graphicsContext.Unlock(); } break; case TMSG_MEDIA_STOP: { // This check ensures we actually need to switch to the previous window, set by FlashVideoPlayer if (pMsg->dwParam1 != 1) { // restore to previous window if needed if (g_windowManager.GetActiveWindow() == WINDOW_SLIDESHOW || g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO || g_windowManager.GetActiveWindow() == WINDOW_VISUALISATION) g_windowManager.PreviousWindow(); } g_application.ResetScreenSaver(); g_application.WakeUpScreenSaverAndDPMS(); // stop playing file if (g_application.IsPlaying()) g_application.StopPlaying(); } break; case TMSG_MEDIA_PAUSE: if (g_application.m_pPlayer) { g_application.ResetScreenSaver(); g_application.WakeUpScreenSaverAndDPMS(); g_application.m_pPlayer->Pause(); } break; case TMSG_SWITCHTOFULLSCREEN: if( g_windowManager.GetActiveWindow() != WINDOW_FULLSCREEN_VIDEO && g_windowManager.GetActiveWindow() != WINDOW_KARAOKELYRICS) g_application.SwitchToFullScreen(); break; case TMSG_MINIMIZE: g_application.Minimize(); break; case TMSG_EXECUTE_OS: #if defined( _LINUX) && !defined(__APPLE__) CUtil::RunCommandLine(pMsg->strParam.c_str(), (pMsg->dwParam1 == 1)); #elif defined(_WIN32) CWIN32Util::XBMCShellExecute(pMsg->strParam.c_str(), (pMsg->dwParam1 == 1)); #endif break; case TMSG_HTTPAPI: { #ifdef HAS_WEB_SERVER if (!m_pXbmcHttp) { CSectionLoader::Load("LIBHTTP"); m_pXbmcHttp = new CXbmcHttp(); } switch (m_pXbmcHttp->xbmcCommand(pMsg->strParam)) { case 1: g_application.getApplicationMessenger().Restart(); break; case 2: g_application.getApplicationMessenger().Shutdown(); break; case 3: g_application.getApplicationMessenger().RebootToDashBoard(); break; case 4: g_application.getApplicationMessenger().Reset(); break; case 5: g_application.getApplicationMessenger().RestartApp(); break; } #endif } break; case TMSG_EXECUTE_SCRIPT: #ifdef HAS_PYTHON g_pythonParser.evalFile(pMsg->strParam.c_str()); #endif break; case TMSG_EXECUTE_BUILT_IN: CBuiltins::Execute(pMsg->strParam.c_str()); break; case TMSG_PLAYLISTPLAYER_PLAY: if (pMsg->dwParam1 != (DWORD) -1) g_playlistPlayer.Play(pMsg->dwParam1); else g_playlistPlayer.Play(); break; case TMSG_PLAYLISTPLAYER_NEXT: g_playlistPlayer.PlayNext(); break; case TMSG_PLAYLISTPLAYER_PREV: g_playlistPlayer.PlayPrevious(); break; // Window messages below here... case TMSG_DIALOG_DOMODAL: //doModel of window { CGUIDialog* pDialog = (CGUIDialog*)g_windowManager.GetWindow(pMsg->dwParam1); if (!pDialog) return ; pDialog->DoModal(); } break; case TMSG_DIALOG_PROGRESS_SHOWMODAL: { CGUIDialogProgress* pDialog = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS); if (!pDialog) return ; pDialog->StartModal(); } break; case TMSG_WRITE_SCRIPT_OUTPUT: { //send message to window 2004 (CGUIWindowScriptsInfo) CGUIMessage msg(GUI_MSG_USER, 0, 0); msg.SetLabel(pMsg->strParam); CGUIWindow* pWindowScripts = g_windowManager.GetWindow(WINDOW_SCRIPTS_INFO); if (pWindowScripts) pWindowScripts->OnMessage(msg); } break; case TMSG_NETWORKMESSAGE: { g_application.getNetwork().NetworkMessage((CNetwork::EMESSAGE)pMsg->dwParam1, (int)pMsg->dwParam2); } break; case TMSG_GUI_DO_MODAL: { CGUIDialog *pDialog = (CGUIDialog *)pMsg->lpVoid; if (pDialog) pDialog->DoModal_Internal((int)pMsg->dwParam1, pMsg->strParam); } break; case TMSG_GUI_SHOW: { CGUIDialog *pDialog = (CGUIDialog *)pMsg->lpVoid; if (pDialog) pDialog->Show_Internal(); } break; case TMSG_GUI_ACTION: { if (pMsg->lpVoid) { if (pMsg->dwParam1 == WINDOW_INVALID) g_application.OnAction(*(CAction *)pMsg->lpVoid); else { CGUIWindow *pWindow = g_windowManager.GetWindow(pMsg->dwParam1); if (pWindow) pWindow->OnAction(*(CAction *)pMsg->lpVoid); else CLog::Log(LOGWARNING, "Failed to get window with ID %i to send an action to", pMsg->dwParam1); } } } break; case TMSG_GUI_INFOLABEL: { if (pMsg->lpVoid) { vector<CStdString> *infoLabels = (vector<CStdString> *)pMsg->lpVoid; for (unsigned int i = 0; i < pMsg->params.size(); i++) infoLabels->push_back(g_infoManager.GetLabel(g_infoManager.TranslateString(pMsg->params[i]))); } } break; case TMSG_GUI_INFOBOOL: { if (pMsg->lpVoid) { vector<bool> *infoLabels = (vector<bool> *)pMsg->lpVoid; for (unsigned int i = 0; i < pMsg->params.size(); i++) infoLabels->push_back(g_infoManager.GetBool(g_infoManager.TranslateString(pMsg->params[i]))); } } break; case TMSG_LOAD_STRINGS: g_localizeStrings.Load(pMsg->strParam, pMsg->strParam2); break; case TMSG_GUI_ACTIVATE_WINDOW: { g_windowManager.ActivateWindow(pMsg->dwParam1, pMsg->params, pMsg->dwParam2 > 0); } break; case TMSG_GUI_WIN_MANAGER_PROCESS: g_windowManager.Process_Internal(0 != pMsg->dwParam1); break; case TMSG_GUI_WIN_MANAGER_RENDER: g_windowManager.Render_Internal(); break; #ifdef HAS_DVD_DRIVE case TMSG_OPTICAL_MOUNT: { /* CMediaSource share; share.strStatus = g_mediaManager.GetDiskLabel(share.strPath); share.strPath = pMsg->strParam; if(g_mediaManager.IsAudio(share.strPath)) share.strStatus = "Audio-CD"; else if(share.strStatus == "") share.strStatus = g_localizeStrings.Get(446); share.strName = share.strPath; share.m_ignore = true; share.m_iDriveType = CMediaSource::SOURCE_TYPE_DVD; g_mediaManager.AddAutoSource(share, pMsg->dwParam1 != 0); */ if (pMsg->dwParam1 != 0) { MEDIA_DETECT::CAutorun::ExecuteAutorun(); } } break; case TMSG_OPTICAL_UNMOUNT: { /* CMediaSource share; share.strPath = pMsg->strParam; share.strName = share.strPath; g_mediaManager.RemoveAutoSource(share); */ g_mediaManager.RemoveCdInfo(g_mediaManager.TranslateDevicePath(pMsg->strParam, true)); } break; #endif //Boxee case TMSG_INIT_WINDOW: { CGUIWindow *pWindow = (CGUIWindow *)pMsg->lpVoid; if (pWindow) pMsg->dwParam1 = pWindow->Initialize(); } break; case TMSG_LOAD_LANG_INFO: { pMsg->dwParam1 = g_langInfo.Load(pMsg->strParam); break; } break; case TMSG_DELETE_BG_LOADER: { CBackgroundInfoLoader *pLoader = (CBackgroundInfoLoader *)pMsg->lpVoid; if (pLoader) delete pLoader; } break; case TMSG_GENERAL_MESSAGE: { CGUIMessage *msg = (CGUIMessage *)pMsg->lpVoid; if (msg) { CGUIWindow* pWindow = g_windowManager.GetWindow(pMsg->dwParam1); if (pWindow) pWindow->OnMessage(*msg); if (!pMsg->hWaitEvent) // no one waits for this message to return. delete msg; } } break; case TMSG_SET_CONTROL_LABEL: { CGUIWindow* pWindow = g_windowManager.GetWindow(pMsg->dwParam1); if (pWindow) { CGUIControl *control = (CGUIControl *)pWindow->GetControl(pMsg->dwParam2); if (control) { CGUIMessage msg(GUI_MSG_LABEL_SET, pMsg->dwParam1, pMsg->dwParam2); msg.SetLabel(pMsg->strParam); control->OnMessage(msg); } } } break; case TMSG_CLOSE_DIALOG: { CGUIDialog *dlg = (CGUIDialog *)pMsg->lpVoid; bool bForce = (bool)pMsg->dwParam1; if (dlg) dlg->Close(bForce); } break; case TMSG_PREVIOUS_WINDOW: { g_windowManager.PreviousWindow(); } break; case TMSG_TOGGLEFULLSCREEN: { CAction action; action.id = ACTION_TOGGLE_FULLSCREEN; g_application.OnAction(action); } break; case TMSG_FREE_WINDOW_RESOURCES: { CGUIWindow *win = (CGUIWindow *)pMsg->lpVoid; if (win) win->FreeResources(); } break; case TMSG_FREE_TEXTURE: { CGUITextureBase *t = (CGUITextureBase *)pMsg->lpVoid; if (t) t->FreeResources(!!pMsg->dwParam1); } break; case TMSG_VIDEO_RENDERER_PREINIT: { pMsg->dwParam1 = g_renderManager.PreInit(); break; } case TMSG_VIDEO_RENDERER_UNINIT: { g_renderManager.UnInit(); break; } case TMSG_CLOSE_SLIDESHOWPIC: { CSlideShowPic *t = (CSlideShowPic *)pMsg->lpVoid; if (t) t->Close(); break; } case TMSG_SHOW_POST_PLAY_DIALOG: { CFileItem *item = (CFileItem *)pMsg->lpVoid; CGUIDialogBoxeePostPlay *dlg = (CGUIDialogBoxeePostPlay *)g_windowManager.GetWindow(WINDOW_DIALOG_BOXEE_POST_PLAY); dlg->SetItem(item); dlg->DoModal(); dlg->Reset(); delete item; break; } case TMSG_SHOW_BOXEE_DEVICE_PAIR_DIALOG: { CBoxeeDeviceItem* deviceItem = (CBoxeeDeviceItem*)pMsg->lpVoid; CGUIDialogBoxeePair* dlg = (CGUIDialogBoxeePair*)g_windowManager.GetWindow(WINDOW_DIALOG_BOXEE_PAIR); dlg->SetDeviceItem(deviceItem); dlg->DoModal(); dlg->Reset(); delete deviceItem; } break; case TMSG_SEND_KEY: { CKey key(pMsg->dwParam1); g_application.OnKey(key); } break; case TMSG_SEND_MOVE: { CPoint p = g_Mouse.GetLocation(); XBMC_Event newEvent; newEvent.type = XBMC_MOUSEMOTION; RESOLUTION iRes = g_graphicsContext.GetVideoResolution(); int m_screenX1 = g_settings.m_ResInfo[iRes].Overscan.left; int m_screenY1 = g_settings.m_ResInfo[iRes].Overscan.top; int m_screenX2 = g_settings.m_ResInfo[iRes].Overscan.right; int m_screenY2 = g_settings.m_ResInfo[iRes].Overscan.bottom; newEvent.motion.x = std::max(m_screenX1, std::min(m_screenX2 - 10, (int)(p.x + (int)pMsg->dwParam1))); newEvent.motion.y = std::max(m_screenY1, std::min(m_screenY2 - 10, (int)(p.y + (int)pMsg->dwParam2))); g_Mouse.HandleEvent(newEvent); } break; case TMSG_SHOW_PLAY_ERROR: { CGUIDialogOK2::ShowAndGetInput(g_localizeStrings.Get(257), pMsg->strParam); break; } case TMSG_EXECUTE_ON_MAIN_THREAD: { IGUIThreadTask *t = (IGUIThreadTask *)(pMsg->lpVoid); if (t) { t->DoWork(); if (pMsg->dwParam1 == 1) delete t; } break; } case TMSG_DELETE_PLAYER: { IPlayer *player = (IPlayer *)pMsg->lpVoid; printf("deleting player %p\n", player); if (player) delete player; } break; case TMSG_APP_HANDLE: { std::vector<CStdString> vecParams = pMsg->params; CStdString strContext = vecParams[0]; CStdString strHandler = vecParams[1]; CStdString strParam = vecParams[2]; if(g_application.OnAppMessage(strHandler, strParam) == true) { break; } CLog::Log(LOGDEBUG, "TMSG_APP_HANDLE received for application %s, handler = %s, param = %s (apphandle)", strContext.c_str(), strHandler.c_str(), strParam.c_str()); CStdString targetPath = _P("special://home/apps/"); targetPath += strContext; CStdString partnerId = CAppManager::GetInstance().GetDescriptor(strContext).GetPartnerId(); CStdString globalHandler = CAppManager::GetInstance().GetDescriptor(strContext).GetGlobalHandler(); char* argv[2]; argv[0] = new char[strHandler.size() + 1]; strncpy(argv[0], strHandler.c_str(), strHandler.size()); argv[1] = new char[strParam.size() + 1]; strncpy(argv[1], strParam.c_str(), strParam.size()); std::vector<CStdString> params; params.push_back(strHandler); params.push_back(strParam); #ifdef HAS_PYTHON g_pythonParser.evalStringInContext(globalHandler, targetPath, strContext, partnerId, params); #endif delete argv[0]; delete argv[1]; } break; case TMSG_GUI_INVOKE_FROM_BROWSER: { IPlayer* player = static_cast<IPlayer*> (pMsg->lpVoid); player->ProcessExternalMessage(pMsg); } break; //end Boxee } }