void PAPlayer::UpdateCrossfadeTime(const CFileItem& file) { // we explicitely disable crossfading for audio cds if(file.IsCDDA()) m_upcomingCrossfadeMS = 0; else m_upcomingCrossfadeMS = m_defaultCrossfadeMS = CSettings::GetInstance().GetInt(CSettings::SETTING_MUSICPLAYER_CROSSFADE) * 1000; if (m_upcomingCrossfadeMS) { if (m_streams.size() == 0 || ( file.HasMusicInfoTag() && !CSettings::GetInstance().GetBool(CSettings::SETTING_MUSICPLAYER_CROSSFADEALBUMTRACKS) && m_FileItem->HasMusicInfoTag() && (m_FileItem->GetMusicInfoTag()->GetAlbum() != "") && (m_FileItem->GetMusicInfoTag()->GetAlbum() == file.GetMusicInfoTag()->GetAlbum()) && (m_FileItem->GetMusicInfoTag()->GetDiscNumber() == file.GetMusicInfoTag()->GetDiscNumber()) && (m_FileItem->GetMusicInfoTag()->GetTrackNumber() == file.GetMusicInfoTag()->GetTrackNumber() - 1) ) ) { //do not crossfade when playing consecutive albumtracks m_upcomingCrossfadeMS = 0; } } }
std::string CFavouritesDirectory::GetExecutePath(const CFileItem &item, const std::string &contextWindow) { std::string execute; if (item.m_bIsFolder && (g_advancedSettings.m_playlistAsFolders || !(item.IsSmartPlayList() || item.IsPlayList()))) { if (!contextWindow.empty()) execute = StringUtils::Format("ActivateWindow(%s,%s,return)", contextWindow.c_str(), StringUtils::Paramify(item.GetPath()).c_str()); } /* TODO:STRING_CLEANUP */ else if (item.IsAndroidApp() && item.GetPath().size() > 26) // androidapp://sources/apps/<foo> execute = StringUtils::Format("StartAndroidActivity(%s)", StringUtils::Paramify(item.GetPath().substr(26)).c_str()); else // assume a media file { if (item.IsVideoDb() && item.HasVideoInfoTag()) execute = StringUtils::Format("PlayMedia(%s)", StringUtils::Paramify(item.GetVideoInfoTag()->m_strFileNameAndPath).c_str()); else if (item.IsMusicDb() && item.HasMusicInfoTag()) execute = StringUtils::Format("PlayMedia(%s)", StringUtils::Paramify(item.GetMusicInfoTag()->GetURL()).c_str()); else if (item.IsPicture()) execute = StringUtils::Format("ShowPicture(%s)", StringUtils::Paramify(item.GetPath()).c_str()); else execute = StringUtils::Format("PlayMedia(%s)", StringUtils::Paramify(item.GetPath()).c_str()); } return execute; }
CStdString CThumbnailCache::GetFanart(const CFileItem &item) { // get the locally cached thumb if (item.IsVideoDb()) { if (!item.HasVideoInfoTag()) return ""; if (!item.GetVideoInfoTag()->m_strArtist.IsEmpty()) return GetThumb(item.GetVideoInfoTag()->m_strArtist,g_settings.GetMusicFanartFolder()); if (!item.m_bIsFolder && !item.GetVideoInfoTag()->m_strShowTitle.IsEmpty()) { CVideoDatabase database; database.Open(); int iShowId = database.GetTvShowId(item.GetVideoInfoTag()->m_strPath); CStdString showPath; database.GetFilePathById(iShowId,showPath,VIDEODB_CONTENT_TVSHOWS); return GetThumb(showPath,g_settings.GetVideoFanartFolder()); } return GetThumb(item.m_bIsFolder ? item.GetVideoInfoTag()->m_strPath : item.GetVideoInfoTag()->m_strFileNameAndPath,g_settings.GetVideoFanartFolder()); } if (item.HasMusicInfoTag()) return GetThumb(item.GetMusicInfoTag()->GetArtist(),g_settings.GetMusicFanartFolder()); return GetThumb(item.m_strPath,g_settings.GetVideoFanartFolder()); }
std::string CMime::GetMimeType(const CFileItem &item) { std::string path = item.GetPath(); if (item.HasVideoInfoTag() && !item.GetVideoInfoTag()->GetPath().empty()) path = item.GetVideoInfoTag()->GetPath(); else if (item.HasMusicInfoTag() && !item.GetMusicInfoTag()->GetURL().empty()) path = item.GetMusicInfoTag()->GetURL(); return GetMimeType(URIUtils::GetExtension(path)); }
void CGUIDialogMusicInfo::AddItemPathToFileBrowserSources(VECSOURCES &sources, const CFileItem &item) { std::string itemDir; if (item.HasMusicInfoTag() && item.GetMusicInfoTag()->GetType() == MediaTypeSong) itemDir = URIUtils::GetParentPath(item.GetMusicInfoTag()->GetURL()); else itemDir = item.GetPath(); if (!itemDir.empty() && CDirectory::Exists(itemDir)) { CMediaSource itemSource; itemSource.strName = g_localizeStrings.Get(36041); itemSource.strPath = itemDir; sources.push_back(itemSource); } }
bool CAudioDecoder::Create(const CFileItem &file, __int64 seekOffset, unsigned int nBufferSize) { Destroy(); CSingleLock lock(m_critSection); // create our pcm buffer m_pcmBuffer.Create((int)std::max<unsigned int>(2, nBufferSize) * INTERNAL_BUFFER_LENGTH); // reset our playback timing variables m_eof = false; // get correct cache size unsigned int filecache = g_guiSettings.GetInt("cacheaudio.internet"); if ( file.IsHD() ) filecache = g_guiSettings.GetInt("cache.harddisk"); else if ( file.IsOnDVD() ) filecache = g_guiSettings.GetInt("cacheaudio.dvdrom"); else if ( file.IsOnLAN() ) filecache = g_guiSettings.GetInt("cacheaudio.lan"); // create our codec m_codec=CodecFactory::CreateCodecDemux(file.GetPath(), file.GetMimeType(), filecache * 1024); if (!m_codec || !m_codec->Init(file.GetPath(), filecache * 1024)) { CLog::Log(LOGERROR, "CAudioDecoder: Unable to Init Codec while loading file %s", file.GetPath().c_str()); Destroy(); return false; } m_blockSize = m_codec->m_Channels * m_codec->m_BitsPerSample / 8; // set total time from the given tag if (file.HasMusicInfoTag() && file.GetMusicInfoTag()->GetDuration()) m_codec->SetTotalTime(file.GetMusicInfoTag()->GetDuration()); if (seekOffset) m_codec->Seek(seekOffset); m_status = STATUS_QUEUING; return true; }
void PAPlayer::UpdateCrossfadeTime(const CFileItem& file) { m_upcomingCrossfadeMS = m_defaultCrossfadeMS = g_guiSettings.GetInt("musicplayer.crossfade") * 1000; if (m_upcomingCrossfadeMS) { if ( file.HasMusicInfoTag() && !g_guiSettings.GetBool("musicplayer.crossfadealbumtracks") && m_FileItem->HasMusicInfoTag() && (m_FileItem->GetMusicInfoTag()->GetAlbum() != "") && (m_FileItem->GetMusicInfoTag()->GetAlbum() == file.GetMusicInfoTag()->GetAlbum()) && (m_FileItem->GetMusicInfoTag()->GetDiscNumber() == file.GetMusicInfoTag()->GetDiscNumber()) && (m_FileItem->GetMusicInfoTag()->GetTrackNumber() == file.GetMusicInfoTag()->GetTrackNumber() - 1) ) { //do not crossfade when playing consecutive albumtracks m_upcomingCrossfadeMS = 0; } } }
void PAPlayer::UpdateCrossFadingTime(const CFileItem& file) { if ((m_crossFading = g_guiSettings.GetInt("mymusic.crossfade"))) { if ( m_crossFading && ( file.IsCDDA() || file.IsLastFM() || ( file.HasMusicInfoTag() && !g_guiSettings.GetBool("mymusic.crossfadealbumtracks") && (m_currentFile->GetMusicInfoTag()->GetAlbum() != "") && (m_currentFile->GetMusicInfoTag()->GetAlbum() == file.GetMusicInfoTag()->GetAlbum()) && (m_currentFile->GetMusicInfoTag()->GetDiscNumber() == file.GetMusicInfoTag()->GetDiscNumber()) && (m_currentFile->GetMusicInfoTag()->GetTrackNumber() == file.GetMusicInfoTag()->GetTrackNumber() - 1) ) ) ) { m_crossFading = 0; } } }
std::string CFavouritesService::GetExecutePath(const CFileItem &item, const std::string &contextWindow) const { std::string execute; if (URIUtils::IsProtocol(item.GetPath(), "favourites")) { const CURL url(item.GetPath()); execute = CURL::Decode(url.GetHostName()); } else if (item.m_bIsFolder && (g_advancedSettings.m_playlistAsFolders || !(item.IsSmartPlayList() || item.IsPlayList()))) { if (!contextWindow.empty()) execute = StringUtils::Format("ActivateWindow(%s,%s,return)", contextWindow.c_str(), StringUtils::Paramify(item.GetPath()).c_str()); } //! @todo STRING_CLEANUP else if (item.IsScript() && item.GetPath().size() > 9) // script://<foo> execute = StringUtils::Format("RunScript(%s)", StringUtils::Paramify(item.GetPath().substr(9)).c_str()); else if (item.IsAddonsPath() && item.GetPath().size() > 9) // addons://<foo> { CURL url(item.GetPath()); execute = StringUtils::Format("RunAddon(%s)", url.GetFileName().c_str()); } else if (item.IsAndroidApp() && item.GetPath().size() > 26) // androidapp://sources/apps/<foo> execute = StringUtils::Format("StartAndroidActivity(%s)", StringUtils::Paramify(item.GetPath().substr(26)).c_str()); else // assume a media file { if (item.IsVideoDb() && item.HasVideoInfoTag()) execute = StringUtils::Format("PlayMedia(%s)", StringUtils::Paramify(item.GetVideoInfoTag()->m_strFileNameAndPath).c_str()); else if (item.IsMusicDb() && item.HasMusicInfoTag()) execute = StringUtils::Format("PlayMedia(%s)", StringUtils::Paramify(item.GetMusicInfoTag()->GetURL()).c_str()); else if (item.IsPicture()) execute = StringUtils::Format("ShowPicture(%s)", StringUtils::Paramify(item.GetPath()).c_str()); else execute = StringUtils::Format("PlayMedia(%s)", StringUtils::Paramify(item.GetPath()).c_str()); } return execute; }
void CGUIDialogMusicInfo::AddItemPathToFileBrowserSources(VECSOURCES &sources, const CFileItem &item) { std::string itemDir; std::string artistFolder; itemDir = item.GetPath(); if (item.HasMusicInfoTag()) { if (item.GetMusicInfoTag()->GetType() == MediaTypeSong) itemDir = URIUtils::GetParentPath(item.GetMusicInfoTag()->GetURL()); // For artist add Artist Info Folder path to browser sources if (item.GetMusicInfoTag()->GetType() == MediaTypeArtist) { artistFolder = CServiceBroker::GetSettings().GetString(CSettings::SETTING_MUSICLIBRARY_ARTISTSFOLDER); if (!artistFolder.empty() && artistFolder.compare(itemDir) == 0) itemDir.clear(); // skip *item when artist not have a unique path } } // Add "*Item folder" path to file browser sources if (!itemDir.empty() && CDirectory::Exists(itemDir)) { CMediaSource itemSource; itemSource.strName = g_localizeStrings.Get(36041); itemSource.strPath = itemDir; sources.push_back(itemSource); } // For artist add Artist Info Folder path to browser sources if (!artistFolder.empty() && CDirectory::Exists(artistFolder)) { CMediaSource itemSource; itemSource.strName = "* " + g_localizeStrings.Get(20223); itemSource.strPath = artistFolder; sources.push_back(itemSource); } }
void PAPlayer::UpdateCrossFadingTime(const CFileItem& file) { if ((m_crossFading = g_guiSettings.GetInt("musicplayer.crossfade"))) { if ( m_crossFading && ( file.IsCDDA() || file.IsLastFM() || ( file.HasMusicInfoTag() && !g_guiSettings.GetBool("musicplayer.crossfadealbumtracks") && (m_currentFile->GetMusicInfoTag()->GetAlbum() != "") && (m_currentFile->GetMusicInfoTag()->GetAlbum() == file.GetMusicInfoTag()->GetAlbum()) && (m_currentFile->GetMusicInfoTag()->GetDiscNumber() == file.GetMusicInfoTag()->GetDiscNumber()) && (m_currentFile->GetMusicInfoTag()->GetTrackNumber() == file.GetMusicInfoTag()->GetTrackNumber() - 1) ) || g_guiSettings.GetString("audiooutput.audiodevice").find("wasapi:") != CStdString::npos ) ) { m_crossFading = 0; } } }
void CApplicationMessenger::ProcessMessage(ThreadMessage *pMsg) { switch (pMsg->dwMessage) { case TMSG_SHUTDOWN: { switch (CSettings::Get().GetInt("powermanagement.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; case TMSG_RENDERER_FLUSH: g_renderManager.Flush(); break; } } break; case TMSG_POWERDOWN: { g_application.Stop(EXITCODE_POWERDOWN); g_powerManager.Powerdown(); } break; case TMSG_QUIT: { g_application.Stop(EXITCODE_QUIT); } break; case TMSG_HIBERNATE: { g_powerManager.Hibernate(); } break; case TMSG_SUSPEND: { g_powerManager.Suspend(); } break; case TMSG_RESTART: case TMSG_RESET: { g_application.Stop(EXITCODE_REBOOT); g_powerManager.Reboot(); } break; case TMSG_RESTARTAPP: { #if defined(TARGET_WINDOWS) || defined(TARGET_LINUX) g_application.Stop(EXITCODE_RESTARTAPP); #endif } break; case TMSG_INHIBITIDLESHUTDOWN: { g_application.InhibitIdleShutdown(pMsg->param1 != 0); } break; case TMSG_ACTIVATESCREENSAVER: { g_application.ActivateScreenSaver(); } break; case TMSG_MEDIA_PLAY: { // first check if we were called from the PlayFile() function if (pMsg->lpVoid && pMsg->param2 == 0) { CFileItem *item = (CFileItem *)pMsg->lpVoid; g_application.PlayFile(*item, pMsg->param1 != 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 if(pMsg->lpVoid) { CFileItemList *list = (CFileItemList *)pMsg->lpVoid; if (list->Size() > 0) { int playlist = PLAYLIST_MUSIC; for (int i = 0; i < list->Size(); i++) { if ((*list)[i]->IsVideo()) { playlist = PLAYLIST_VIDEO; break; } } g_playlistPlayer.ClearPlaylist(playlist); g_playlistPlayer.SetCurrentPlaylist(playlist); //For single item lists try PlayMedia. This covers some more cases where a playlist is not appropriate //It will fall through to PlayFile if (list->Size() == 1 && !(*list)[0]->IsPlayList()) g_application.PlayMedia(*((*list)[0]), playlist); else { // Handle "shuffled" option if present if (list->HasProperty("shuffled") && list->GetProperty("shuffled").isBoolean()) g_playlistPlayer.SetShuffle(playlist, list->GetProperty("shuffled").asBoolean(), false); // Handle "repeat" option if present if (list->HasProperty("repeat") && list->GetProperty("repeat").isInteger()) g_playlistPlayer.SetRepeat(playlist, (PLAYLIST::REPEAT_STATE)list->GetProperty("repeat").asInteger(), false); g_playlistPlayer.Add(playlist, (*list)); g_playlistPlayer.Play(pMsg->param1); } } delete list; } else if (pMsg->param1 == PLAYLIST_MUSIC || pMsg->param1 == PLAYLIST_VIDEO) { if (g_playlistPlayer.GetCurrentPlaylist() != pMsg->param1) g_playlistPlayer.SetCurrentPlaylist(pMsg->param1); PlayListPlayerPlay(pMsg->param2); } } break; case TMSG_MEDIA_RESTART: g_application.Restart(true); break; case TMSG_PICTURE_SHOW: { CGUIWindowSlideShow *pSlideShow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW); if (!pSlideShow) return ; // stop playing file if (g_application.m_pPlayer->IsPlayingVideo()) g_application.StopPlaying(); if (g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO) g_windowManager.PreviousWindow(); g_application.ResetScreenSaver(); g_application.WakeUpScreenSaverAndDPMS(); g_graphicsContext.Lock(); if (g_windowManager.GetActiveWindow() != WINDOW_SLIDESHOW) g_windowManager.ActivateWindow(WINDOW_SLIDESHOW); if (URIUtils::IsZIP(pMsg->strParam) || URIUtils::IsRAR(pMsg->strParam)) // actually a cbz/cbr { CFileItemList items; CURL pathToUrl; if (URIUtils::IsZIP(pMsg->strParam)) pathToUrl = URIUtils::CreateArchivePath("zip", CURL(pMsg->strParam), ""); else pathToUrl = URIUtils::CreateArchivePath("rar", CURL(pMsg->strParam), ""); CUtil::GetRecursiveListing(pathToUrl.Get(), items, g_advancedSettings.m_pictureExtensions, XFILE::DIR_FLAG_NO_FILE_DIRS); if (items.Size() > 0) { pSlideShow->Reset(); for (int i=0;i<items.Size();++i) { pSlideShow->Add(items[i].get()); } pSlideShow->Select(items[0]->GetPath()); } } else { CFileItem item(pMsg->strParam, false); pSlideShow->Reset(); pSlideShow->Add(&item); pSlideShow->Select(pMsg->strParam); } g_graphicsContext.Unlock(); } break; case TMSG_PICTURE_SLIDESHOW: { CGUIWindowSlideShow *pSlideShow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW); if (!pSlideShow) return ; if (g_application.m_pPlayer->IsPlayingVideo()) g_application.StopPlaying(); g_graphicsContext.Lock(); pSlideShow->Reset(); CFileItemList items; std::string strPath = pMsg->strParam; std::string extensions = g_advancedSettings.m_pictureExtensions; if (pMsg->param1) extensions += "|.tbn"; CUtil::GetRecursiveListing(strPath, items, extensions); if (items.Size() > 0) { for (int i=0;i<items.Size();++i) pSlideShow->Add(items[i].get()); pSlideShow->StartSlideShow(); //Start the slideshow! } if (g_windowManager.GetActiveWindow() != WINDOW_SLIDESHOW) { if(items.Size() == 0) { CSettings::Get().SetString("screensaver.mode", "screensaver.xbmc.builtin.dim"); g_application.ActivateScreenSaver(); } else g_windowManager.ActivateWindow(WINDOW_SLIDESHOW); } g_graphicsContext.Unlock(); } break; case TMSG_SETLANGUAGE: g_application.SetLanguage(pMsg->strParam); break; case TMSG_MEDIA_STOP: { // restore to previous window if needed bool stopSlideshow = true; bool stopVideo = true; bool stopMusic = true; if (pMsg->param1 >= PLAYLIST_MUSIC && pMsg->param1 <= PLAYLIST_PICTURE) { stopSlideshow = (pMsg->param1 == PLAYLIST_PICTURE); stopVideo = (pMsg->param1 == PLAYLIST_VIDEO); stopMusic = (pMsg->param1 == PLAYLIST_MUSIC); } if ((stopSlideshow && g_windowManager.GetActiveWindow() == WINDOW_SLIDESHOW) || (stopVideo && g_windowManager.GetActiveWindow() == WINDOW_FULLSCREEN_VIDEO) || (stopMusic && g_windowManager.GetActiveWindow() == WINDOW_VISUALISATION)) g_windowManager.PreviousWindow(); g_application.ResetScreenSaver(); g_application.WakeUpScreenSaverAndDPMS(); // stop playing file if (g_application.m_pPlayer->IsPlaying()) g_application.StopPlaying(); } break; case TMSG_MEDIA_PAUSE: if (g_application.m_pPlayer->HasPlayer()) { g_application.ResetScreenSaver(); g_application.WakeUpScreenSaverAndDPMS(); g_application.m_pPlayer->Pause(); } break; case TMSG_MEDIA_UNPAUSE: if (g_application.m_pPlayer->IsPausedPlayback()) { g_application.ResetScreenSaver(); g_application.WakeUpScreenSaverAndDPMS(); g_application.m_pPlayer->Pause(); } break; case TMSG_MEDIA_PAUSE_IF_PLAYING: if (g_application.m_pPlayer->IsPlaying() && !g_application.m_pPlayer->IsPaused()) { g_application.ResetScreenSaver(); g_application.WakeUpScreenSaverAndDPMS(); g_application.m_pPlayer->Pause(); } break; case TMSG_SWITCHTOFULLSCREEN: if(g_windowManager.GetActiveWindow() != WINDOW_FULLSCREEN_VIDEO) g_application.SwitchToFullScreen(true); break; case TMSG_SETVIDEORESOLUTION: { RESOLUTION res = (RESOLUTION)pMsg->param1; bool forceUpdate = pMsg->param2 == 1 ? true : false; g_graphicsContext.SetVideoResolution(res, forceUpdate); } break; case TMSG_VIDEORESIZE: { XBMC_Event newEvent; memset(&newEvent, 0, sizeof(newEvent)); newEvent.type = XBMC_VIDEORESIZE; newEvent.resize.w = pMsg->param1; newEvent.resize.h = pMsg->param2; g_application.OnEvent(newEvent); g_windowManager.MarkDirty(); } break; case TMSG_TOGGLEFULLSCREEN: g_graphicsContext.Lock(); g_graphicsContext.ToggleFullScreenRoot(); g_graphicsContext.Unlock(); break; case TMSG_MINIMIZE: g_application.Minimize(); break; case TMSG_EXECUTE_OS: /* Suspend AE temporarily so exclusive or hog-mode sinks */ /* don't block external player's access to audio device */ if (!CAEFactory::Suspend()) { CLog::Log(LOGNOTICE, "%s: Failed to suspend AudioEngine before launching external program",__FUNCTION__); } #if defined( TARGET_POSIX) && !defined(TARGET_DARWIN) CUtil::RunCommandLine(pMsg->strParam.c_str(), (pMsg->param1 == 1)); #elif defined(TARGET_WINDOWS) CWIN32Util::XBMCShellExecute(pMsg->strParam.c_str(), (pMsg->param1 == 1)); #endif /* Resume AE processing of XBMC native audio */ if (!CAEFactory::Resume()) { CLog::Log(LOGFATAL, "%s: Failed to restart AudioEngine after return from external player",__FUNCTION__); } break; case TMSG_EXECUTE_SCRIPT: CScriptInvocationManager::Get().ExecuteAsync(pMsg->strParam); break; case TMSG_EXECUTE_BUILT_IN: CBuiltins::Execute(pMsg->strParam.c_str()); break; case TMSG_PLAYLISTPLAYER_PLAY: if (pMsg->param1 != -1) g_playlistPlayer.Play(pMsg->param1); else g_playlistPlayer.Play(); break; case TMSG_PLAYLISTPLAYER_PLAY_SONG_ID: if (pMsg->param1 != -1) { bool *result = (bool*)pMsg->lpVoid; *result = g_playlistPlayer.PlaySongId(pMsg->param1); } else g_playlistPlayer.Play(); break; case TMSG_PLAYLISTPLAYER_NEXT: g_playlistPlayer.PlayNext(); break; case TMSG_PLAYLISTPLAYER_PREV: g_playlistPlayer.PlayPrevious(); break; case TMSG_PLAYLISTPLAYER_ADD: if(pMsg->lpVoid) { CFileItemList *list = (CFileItemList *)pMsg->lpVoid; g_playlistPlayer.Add(pMsg->param1, (*list)); delete list; } break; case TMSG_PLAYLISTPLAYER_INSERT: if (pMsg->lpVoid) { CFileItemList *list = (CFileItemList *)pMsg->lpVoid; g_playlistPlayer.Insert(pMsg->param1, (*list), pMsg->param2); delete list; } break; case TMSG_PLAYLISTPLAYER_REMOVE: if (pMsg->param1 != -1) g_playlistPlayer.Remove(pMsg->param1,pMsg->param2); break; case TMSG_PLAYLISTPLAYER_CLEAR: g_playlistPlayer.ClearPlaylist(pMsg->param1); break; case TMSG_PLAYLISTPLAYER_SHUFFLE: g_playlistPlayer.SetShuffle(pMsg->param1, pMsg->param2 > 0); break; case TMSG_PLAYLISTPLAYER_REPEAT: g_playlistPlayer.SetRepeat(pMsg->param1, (PLAYLIST::REPEAT_STATE)pMsg->param2); break; case TMSG_PLAYLISTPLAYER_GET_ITEMS: if (pMsg->lpVoid) { PLAYLIST::CPlayList playlist = g_playlistPlayer.GetPlaylist(pMsg->param1); CFileItemList *list = (CFileItemList *)pMsg->lpVoid; for (int i = 0; i < playlist.size(); i++) list->Add(CFileItemPtr(new CFileItem(*playlist[i]))); } break; case TMSG_PLAYLISTPLAYER_SWAP: if (pMsg->lpVoid) { vector<int> *indexes = (vector<int> *)pMsg->lpVoid; if (indexes->size() == 2) g_playlistPlayer.Swap(pMsg->param1, indexes->at(0), indexes->at(1)); delete indexes; } break; // Window messages below here... case TMSG_DIALOG_DOMODAL: //doModel of window { CGUIDialog* pDialog = (CGUIDialog*)g_windowManager.GetWindow(pMsg->param1); if (!pDialog) return ; pDialog->DoModal(); } break; case TMSG_NETWORKMESSAGE: { g_application.getNetwork().NetworkMessage((CNetwork::EMESSAGE)pMsg->param1, pMsg->param2); } break; case TMSG_GUI_DO_MODAL: { CGUIDialog *pDialog = (CGUIDialog *)pMsg->lpVoid; if (pDialog) pDialog->DoModal(pMsg->param1, pMsg->strParam); } break; case TMSG_GUI_SHOW: { CGUIDialog *pDialog = (CGUIDialog *)pMsg->lpVoid; if (pDialog) pDialog->Show(); } break; case TMSG_GUI_WINDOW_CLOSE: { CGUIWindow *window = (CGUIWindow *)pMsg->lpVoid; if (window) window->Close(pMsg->param2 & 0x1 ? true : false, pMsg->param1, pMsg->param2 & 0x2 ? true : false); } break; case TMSG_GUI_ACTIVATE_WINDOW: { g_windowManager.ActivateWindow(pMsg->param1, pMsg->params, pMsg->param2 & 0x1 ? true : false, pMsg->param2 & 0x2 ? true : false); } break; case TMSG_GUI_ADDON_DIALOG: { if (pMsg->lpVoid) { // TODO: This is ugly - really these python dialogs should just be normal XBMC dialogs ((ADDON::CGUIAddonWindowDialog *) pMsg->lpVoid)->Show_Internal(pMsg->param2 > 0); } } break; #ifdef HAS_PYTHON case TMSG_GUI_PYTHON_DIALOG: { // This hack is not much better but at least I don't need to make ApplicationMessenger // know about Addon (Python) specific classes. CAction caction(pMsg->param1); ((CGUIWindow*)pMsg->lpVoid)->OnAction(caction); } break; #endif case TMSG_GUI_ACTION: { if (pMsg->lpVoid) { CAction *action = (CAction *)pMsg->lpVoid; if (pMsg->param1 == WINDOW_INVALID) g_application.OnAction(*action); else { CGUIWindow *pWindow = g_windowManager.GetWindow(pMsg->param1); if (pWindow) pWindow->OnAction(*action); else CLog::Log(LOGWARNING, "Failed to get window with ID %i to send an action to", pMsg->param1); } delete action; } } break; case TMSG_GUI_MESSAGE: { if (pMsg->lpVoid) { CGUIMessage *message = (CGUIMessage *)pMsg->lpVoid; g_windowManager.SendMessage(*message, pMsg->param1); delete message; } } break; case TMSG_GUI_INFOLABEL: { if (pMsg->lpVoid) { vector<string> *infoLabels = (vector<string> *)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.EvaluateBool(pMsg->params[i])); } } break; case TMSG_CALLBACK: { ThreadMessageCallback *callback = (ThreadMessageCallback*)pMsg->lpVoid; callback->callback(callback->userptr); } break; case TMSG_VOLUME_SHOW: { CAction action(pMsg->param1); g_application.ShowVolumeBar(&action); } break; case TMSG_DISPLAY_SETUP: { *((bool*)pMsg->lpVoid) = g_application.InitWindow(); g_application.SetRenderGUI(true); } break; case TMSG_DISPLAY_DESTROY: { *((bool*)pMsg->lpVoid) = g_application.DestroyWindow(); g_application.SetRenderGUI(false); } break; case TMSG_UPDATE_CURRENT_ITEM: { CFileItem* item = (CFileItem*)pMsg->lpVoid; if (!item) return; if (pMsg->param1 == 1 && item->HasMusicInfoTag()) // only grab music tag g_infoManager.SetCurrentSongTag(*item->GetMusicInfoTag()); else if (pMsg->param1 == 2 && item->HasVideoInfoTag()) // only grab video tag g_infoManager.SetCurrentVideoTag(*item->GetVideoInfoTag()); else g_infoManager.SetCurrentItem(*item); delete item; break; } case TMSG_LOADPROFILE: { CGUIWindowLoginScreen::LoadProfile(pMsg->param1); break; } case TMSG_CECTOGGLESTATE: { *((bool*)pMsg->lpVoid) = g_peripherals.ToggleDeviceState(STATE_SWITCH_TOGGLE); break; } case TMSG_CECACTIVATESOURCE: { g_peripherals.ToggleDeviceState(STATE_ACTIVATE_SOURCE); break; } case TMSG_CECSTANDBY: { g_peripherals.ToggleDeviceState(STATE_STANDBY); break; } case TMSG_START_ANDROID_ACTIVITY: { #if defined(TARGET_ANDROID) if (pMsg->params.size()) { CXBMCApp::StartActivity(pMsg->params[0], pMsg->params.size() > 1 ? pMsg->params[1] : "", pMsg->params.size() > 2 ? pMsg->params[2] : "", pMsg->params.size() > 3 ? pMsg->params[3] : ""); } #endif break; } case TMSG_SETPVRMANAGERSTATE: { if (pMsg->param1 != 0) g_application.StartPVRManager(); else g_application.StopPVRManager(); } } }
void CGUIWindowMusicNav::GetContextButtons(int itemNumber, CContextButtons &buttons) { CGUIWindowMusicBase::GetContextButtons(itemNumber, buttons); CGUIDialogMusicScan *musicScan = (CGUIDialogMusicScan *)m_gWindowManager.GetWindow(WINDOW_DIALOG_MUSIC_SCAN); CFileItem *item = (itemNumber >= 0 && itemNumber < m_vecItems->Size()) ? m_vecItems->Get(itemNumber) : NULL; if (item && (item->GetExtraInfo().Find("lastfm") < 0)) { // are we in the playlists location? bool inPlaylists = m_vecItems->m_strPath.Equals(CUtil::MusicPlaylistsLocation()) || m_vecItems->m_strPath.Equals("special://musicplaylists/"); CMusicDatabaseDirectory dir; SScraperInfo info; m_musicdatabase.GetScraperForPath(item->m_strPath,info); // enable music info button on an album or on a song. if (item->IsAudio() && !item->IsPlayList() && !item->IsSmartPlayList() && !item->IsLastFM() && !item->IsShoutCast()) { buttons.Add(CONTEXT_BUTTON_SONG_INFO, 658); } else if (item->IsVideoDb()) { if (!item->m_bIsFolder) // music video buttons.Add(CONTEXT_BUTTON_INFO, 20393); if (item->m_strPath.Left(14).Equals("videodb://3/4/") && item->m_strPath.size() > 14 && item->m_bIsFolder) { long idArtist = m_musicdatabase.GetArtistByName(m_vecItems->Get(itemNumber)->GetLabel()); if (idArtist > - 1) buttons.Add(CONTEXT_BUTTON_INFO,21891); } } else if (!inPlaylists && (dir.HasAlbumInfo(item->m_strPath)|| dir.IsArtistDir(item->m_strPath) ) && !dir.IsAllItem(item->m_strPath) && !item->IsParentFolder() && !item->IsLastFM() && !item->IsShoutCast() && !item->m_strPath.Left(14).Equals("musicsearch://")) { if (dir.IsArtistDir(item->m_strPath)) buttons.Add(CONTEXT_BUTTON_INFO, 21891); else buttons.Add(CONTEXT_BUTTON_INFO, 13351); } // enable query all albums button only in album view if (dir.HasAlbumInfo(item->m_strPath) && !dir.IsAllItem(item->m_strPath) && item->m_bIsFolder && !item->IsVideoDb() && !item->IsParentFolder() && !item->IsLastFM() && !item->IsShoutCast() && !item->m_strPath.Left(14).Equals("musicsearch://")) { buttons.Add(CONTEXT_BUTTON_INFO_ALL, 20059); } // enable query all artist button only in album view if (dir.IsArtistDir(item->m_strPath) && !dir.IsAllItem(item->m_strPath) && item->m_bIsFolder && !item->IsVideoDb() && !info.strContent.IsEmpty()) { buttons.Add(CONTEXT_BUTTON_INFO_ALL, 21884); } // turn off set artist image if not at artist listing. if (dir.IsArtistDir(item->m_strPath) && !dir.IsAllItem(item->m_strPath) || (item->m_strPath.Left(14).Equals("videodb://3/4/") && item->m_strPath.size() > 14 && item->m_bIsFolder)) { buttons.Add(CONTEXT_BUTTON_SET_ARTIST_THUMB, 13359); } if (m_vecItems->m_strPath.Equals("plugin://music/")) buttons.Add(CONTEXT_BUTTON_SET_PLUGIN_THUMB, 1044); //Set default or clear default NODE_TYPE nodetype = dir.GetDirectoryType(item->m_strPath); if (!item->IsParentFolder() && !inPlaylists && (nodetype == NODE_TYPE_ROOT || nodetype == NODE_TYPE_OVERVIEW || nodetype == NODE_TYPE_TOP100)) { if (!item->m_strPath.Equals(g_settings.m_defaultMusicLibSource)) buttons.Add(CONTEXT_BUTTON_SET_DEFAULT, 13335); // set default if (strcmp(g_settings.m_defaultMusicLibSource, "")) buttons.Add(CONTEXT_BUTTON_CLEAR_DEFAULT, 13403); // clear default } NODE_TYPE childtype = dir.GetDirectoryChildType(item->m_strPath); if (childtype == NODE_TYPE_ALBUM || childtype == NODE_TYPE_ARTIST || nodetype == NODE_TYPE_GENRE || nodetype == NODE_TYPE_ALBUM) { // we allow the user to set content for // 1. general artist and album nodes // 2. specific per genre // 3. specific per artist // 4. specific per album buttons.Add(CONTEXT_BUTTON_SET_CONTENT,20195); } if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetArtist().size() > 0) { CVideoDatabase database; database.Open(); if (database.GetMusicVideoArtistByName(item->GetMusicInfoTag()->GetArtist()) > -1) buttons.Add(CONTEXT_BUTTON_GO_TO_ARTIST, 20400); } if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetArtist().size() > 0 && item->GetMusicInfoTag()->GetAlbum().size() > 0 && item->GetMusicInfoTag()->GetTitle().size() > 0) { CVideoDatabase database; database.Open(); if (database.GetMusicVideoByArtistAndAlbumAndTitle(item->GetMusicInfoTag()->GetArtist(),item->GetMusicInfoTag()->GetAlbum(),item->GetMusicInfoTag()->GetTitle()) > -1) buttons.Add(CONTEXT_BUTTON_PLAY_OTHER, 20401); } if (item->HasVideoInfoTag() && !item->m_bIsFolder) { if (item->GetVideoInfoTag()->m_bWatched) buttons.Add(CONTEXT_BUTTON_MARK_UNWATCHED, 16104); //Mark as UnWatched else buttons.Add(CONTEXT_BUTTON_MARK_WATCHED, 16103); //Mark as Watched if (g_settings.m_vecProfiles[g_settings.m_iLastLoadedProfileIndex].canWriteDatabases() || g_passwordManager.bMasterUser) { buttons.Add(CONTEXT_BUTTON_RENAME, 16105); buttons.Add(CONTEXT_BUTTON_DELETE, 646); } } } // noncontextual buttons if (musicScan && musicScan->IsScanning()) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); // Stop Scanning else if (musicScan) buttons.Add(CONTEXT_BUTTON_UPDATE_LIBRARY, 653); CGUIWindowMusicBase::GetNonContextButtons(buttons); }
void CGUIWindowMusicBase::OnInfo(CFileItem *pItem, bool bShowInfo) { if (pItem->m_bIsFolder && pItem->IsParentFolder()) return; if (pItem->IsVideoDb()) { OnContextButton(m_viewControl.GetSelectedItem(), CONTEXT_BUTTON_INFO); // nasty but it is the same item i promise :) return; } CStdString strPath = pItem->m_strPath; // Try to find an album to lookup from the current item CAlbum album; CArtist artist; bool foundAlbum = false; album.idAlbum = -1; if (pItem->IsMusicDb()) { CQueryParams params; CDirectoryNode::GetDatabaseInfo(pItem->m_strPath, params); if (params.GetAlbumId() == -1) { artist.idArtist = params.GetArtistId(); artist.strArtist = pItem->GetMusicInfoTag()->GetArtist(); } else { // show dialog box indicating we're searching the album name if (m_dlgProgress && bShowInfo) { m_dlgProgress->SetHeading(185); m_dlgProgress->SetLine(0, 501); m_dlgProgress->SetLine(1, ""); m_dlgProgress->SetLine(2, ""); m_dlgProgress->StartModal(); m_dlgProgress->Progress(); if (m_dlgProgress->IsCanceled()) return; } album.idAlbum = params.GetAlbumId(); album.strAlbum = pItem->GetMusicInfoTag()->GetAlbum(); album.strArtist = pItem->GetMusicInfoTag()->GetArtist(); // we're going to need it's path as well (we assume that there's only one) - this is for // assigning thumbs to folders, and obtaining the local folder.jpg m_musicdatabase.GetAlbumPath(album.idAlbum, strPath); } } else { // lookup is done on a folder - find the albums in the folder CFileItemList items; GetDirectory(strPath, items); // check the first song we find in the folder, and grab it's album info for (int i = 0; i < items.Size() && !foundAlbum; i++) { CFileItem* pItem = items[i]; pItem->LoadMusicTag(); if (pItem->HasMusicInfoTag() && pItem->GetMusicInfoTag()->Loaded() && !pItem->GetMusicInfoTag()->GetAlbum().IsEmpty()) { // great, have a song - use it. CSong song(*pItem->GetMusicInfoTag()); // this function won't be needed if/when the tag has idSong information if (!m_musicdatabase.GetAlbumFromSong(song, album)) { // album isn't in the database - construct it from the tag info we have CMusicInfoTag *tag = pItem->GetMusicInfoTag(); album.strAlbum = tag->GetAlbum(); album.strArtist = tag->GetAlbumArtist().IsEmpty() ? tag->GetArtist() : tag->GetAlbumArtist(); album.idAlbum = -1; // the -1 indicates it's not in the database } foundAlbum = true; } } if (!foundAlbum) { CLog::Log(LOGINFO, "%s called on a folder containing no songs with tag info - nothing can be done", __FUNCTION__); if (m_dlgProgress && bShowInfo) m_dlgProgress->Close(); } } if (m_dlgProgress && bShowInfo) m_dlgProgress->Close(); if (album.idAlbum == -1 && foundAlbum == false) ShowArtistInfo(artist, pItem->m_strPath, false, bShowInfo); else ShowAlbumInfo(album, strPath, false, bShowInfo); }
void CGUIWindowMusicBase::UpdateThumb(const CAlbum &album, const CStdString &path) { // check user permissions bool saveDb = album.idAlbum != -1; bool saveDirThumb = true; if (!g_settings.m_vecProfiles[g_settings.m_iLastLoadedProfileIndex].canWriteDatabases() && !g_passwordManager.bMasterUser) { saveDb = false; saveDirThumb = false; } CStdString albumThumb(CUtil::GetCachedAlbumThumb(album.strAlbum, album.strArtist)); // Update the thumb in the music database (songs + albums) CStdString albumPath(path); if (saveDb && CFile::Exists(albumThumb)) m_musicdatabase.SaveAlbumThumb(album.idAlbum, albumThumb); // Update currently playing song if it's from the same album. This is necessary as when the album // first gets it's cover, the info manager's item doesn't have the updated information (so will be // sending a blank thumb to the skin.) if (g_application.IsPlayingAudio()) { CStdString strSongFolder; const CMusicInfoTag* tag=g_infoManager.GetCurrentSongTag(); if (tag) { // really, this may not be enough as it is to reliably update this item. eg think of various artists albums // that aren't tagged as such (and aren't yet scanned). But we probably can't do anything better than this // in that case if (album.strAlbum == tag->GetAlbum() && (album.strArtist == tag->GetAlbumArtist() || album.strArtist == tag->GetArtist())) { g_infoManager.SetCurrentAlbumThumb(albumThumb); } } } // Save this thumb as the directory thumb if it's the only album in the folder (files view nicety) // We do this by grabbing all the songs in the folder, and checking to see whether they come // from the same album. if (saveDirThumb && CFile::Exists(albumThumb) && !albumPath.IsEmpty() && !CUtil::IsCDDA(albumPath)) { CFileItemList items; GetDirectory(albumPath, items); OnRetrieveMusicInfo(items); VECSONGS songs; for (int i = 0; i < items.Size(); i++) { CFileItem *item = items[i]; if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->Loaded()) { CSong song(*item->GetMusicInfoTag()); songs.push_back(song); } } CMusicInfoScanner::CheckForVariousArtists(songs); CStdString album, artist; if (CMusicInfoScanner::HasSingleAlbum(songs, album, artist)) { // can cache as the folder thumb CStdString folderThumb(CUtil::GetCachedMusicThumb(albumPath)); ::CopyFile(albumThumb, folderThumb, false); } } // update the file listing int iSelectedItem = m_viewControl.GetSelectedItem(); if (iSelectedItem >= 0 && m_vecItems->Get(iSelectedItem)) { CFileItem* pSelectedItem=m_vecItems->Get(iSelectedItem); if (pSelectedItem->m_bIsFolder) { // refresh only the icon of // the current folder pSelectedItem->FreeMemory(); if (!pSelectedItem->HasThumbnail()) pSelectedItem->SetThumbnailImage(albumThumb); pSelectedItem->FillInDefaultIcon(); } else { // Refresh all items m_vecItems->RemoveDiscCache(); Update(m_vecItems->m_strPath); } // Do we have to autoswitch to the thumb control? m_guiState.reset(CGUIViewState::GetViewState(GetID(), *m_vecItems)); UpdateButtons(); } }
void CApplicationMessenger::ProcessMessage(ThreadMessage *pMsg) { switch (pMsg->dwMessage) { case TMSG_SHUTDOWN: { switch (g_guiSettings.GetInt("powermanagement.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; case TMSG_RENDERER_FLUSH: g_renderManager.Flush(); break; } } break; case TMSG_POWERDOWN: { g_application.Stop(EXITCODE_POWERDOWN); g_powerManager.Powerdown(); } break; case TMSG_QUIT: { g_application.Stop(EXITCODE_QUIT); } break; case TMSG_HIBERNATE: { g_PVRManager.SetWakeupCommand(); g_powerManager.Hibernate(); } break; case TMSG_SUSPEND: { g_PVRManager.SetWakeupCommand(); g_powerManager.Suspend(); } break; case TMSG_RESTART: case TMSG_RESET: { g_application.Stop(EXITCODE_REBOOT); g_powerManager.Reboot(); } break; case TMSG_RESTARTAPP: { #if defined(TARGET_WINDOWS) || defined(TARGET_LINUX) g_application.Stop(EXITCODE_RESTARTAPP); #endif } break; case TMSG_INHIBITIDLESHUTDOWN: { g_application.InhibitIdleShutdown((bool)pMsg->dwParam1); } 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 if(pMsg->lpVoid) { CFileItemList *list = (CFileItemList *)pMsg->lpVoid; if (list->Size() > 0) { int playlist = PLAYLIST_MUSIC; for (int i = 0; i < list->Size(); i++) { if ((*list)[i]->IsVideo()) { playlist = PLAYLIST_VIDEO; break; } } g_playlistPlayer.ClearPlaylist(playlist); g_playlistPlayer.SetCurrentPlaylist(playlist); //For single item lists try PlayMedia. This covers some more cases where a playlist is not appropriate //It will fall through to PlayFile if (list->Size() == 1 && !(*list)[0]->IsPlayList()) g_application.PlayMedia(*((*list)[0]), playlist); else { // Handle "shuffled" option if present if (list->HasProperty("shuffled") && list->GetProperty("shuffled").isBoolean()) g_playlistPlayer.SetShuffle(playlist, list->GetProperty("shuffled").asBoolean(), false); // Handle "repeat" option if present if (list->HasProperty("repeat") && list->GetProperty("repeat").isInteger()) g_playlistPlayer.SetRepeat(playlist, (PLAYLIST::REPEAT_STATE)list->GetProperty("repeat").asInteger(), false); g_playlistPlayer.Add(playlist, (*list)); g_playlistPlayer.Play(pMsg->dwParam1); } } delete list; } else if (pMsg->dwParam1 == PLAYLIST_MUSIC || pMsg->dwParam1 == PLAYLIST_VIDEO) { if (g_playlistPlayer.GetCurrentPlaylist() != (int)pMsg->dwParam1) g_playlistPlayer.SetCurrentPlaylist(pMsg->dwParam1); PlayListPlayerPlay(pMsg->dwParam2); } } break; case TMSG_MEDIA_RESTART: g_application.Restart(true); break; 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(); if (g_windowManager.GetActiveWindow() != WINDOW_SLIDESHOW) g_windowManager.ActivateWindow(WINDOW_SLIDESHOW); if (URIUtils::IsZIP(pMsg->strParam) || URIUtils::IsRAR(pMsg->strParam)) // actually a cbz/cbr { CFileItemList items; CStdString strPath; if (URIUtils::IsZIP(pMsg->strParam)) URIUtils::CreateArchivePath(strPath, "zip", pMsg->strParam.c_str(), ""); else URIUtils::CreateArchivePath(strPath, "rar", pMsg->strParam.c_str(), ""); CUtil::GetRecursiveListing(strPath, items, g_settings.m_pictureExtensions); if (items.Size() > 0) { pSlideShow->Reset(); for (int i=0;i<items.Size();++i) { pSlideShow->Add(items[i].get()); } pSlideShow->Select(items[0]->GetPath()); } } else { CFileItem item(pMsg->strParam, false); pSlideShow->Reset(); 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 ; if (g_application.IsPlayingVideo()) g_application.StopPlaying(); g_graphicsContext.Lock(); pSlideShow->Reset(); CFileItemList items; CStdString strPath = pMsg->strParam; CStdString extensions = g_settings.m_pictureExtensions; if (pMsg->dwParam1) extensions += "|.tbn"; CUtil::GetRecursiveListing(strPath, items, extensions); 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) { if(items.Size() == 0) { g_guiSettings.SetString("screensaver.mode", "screensaver.xbmc.builtin.dim"); g_application.ActivateScreenSaver(); } else g_windowManager.ActivateWindow(WINDOW_SLIDESHOW); } g_graphicsContext.Unlock(); } break; case TMSG_SETLANGUAGE: g_guiSettings.SetLanguage(pMsg->strParam); break; case TMSG_MEDIA_STOP: { // 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_MEDIA_UNPAUSE: if (g_application.IsPaused()) { g_application.ResetScreenSaver(); g_application.WakeUpScreenSaverAndDPMS(); g_application.m_pPlayer->Pause(); } break; case TMSG_SWITCHTOFULLSCREEN: if( g_windowManager.GetActiveWindow() != WINDOW_FULLSCREEN_VIDEO ) g_application.SwitchToFullScreen(); break; case TMSG_TOGGLEFULLSCREEN: g_graphicsContext.Lock(); g_graphicsContext.ToggleFullScreenRoot(); g_graphicsContext.Unlock(); break; case TMSG_MINIMIZE: g_application.Minimize(); break; case TMSG_EXECUTE_OS: #if defined( _LINUX) && !defined(TARGET_DARWIN) 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_HTTPAPI if (!m_pXbmcHttp) { m_pXbmcHttp = new CXbmcHttp(); } switch (m_pXbmcHttp->xbmcCommand(pMsg->strParam)) { case 1: Restart(); break; case 2: Shutdown(); break; case 3: Quit(); break; case 4: Reset(); break; case 5: RestartApp(); break; } #endif } break; case TMSG_EXECUTE_SCRIPT: #ifdef HAS_PYTHON g_pythonParser.evalFile(pMsg->strParam.c_str(),ADDON::AddonPtr()); #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_PLAY_SONG_ID: if (pMsg->dwParam1 != (DWORD) -1) { bool *result = (bool*)pMsg->lpVoid; *result = g_playlistPlayer.PlaySongId(pMsg->dwParam1); } else g_playlistPlayer.Play(); break; case TMSG_PLAYLISTPLAYER_NEXT: g_playlistPlayer.PlayNext(); break; case TMSG_PLAYLISTPLAYER_PREV: g_playlistPlayer.PlayPrevious(); break; case TMSG_PLAYLISTPLAYER_ADD: if(pMsg->lpVoid) { CFileItemList *list = (CFileItemList *)pMsg->lpVoid; g_playlistPlayer.Add(pMsg->dwParam1, (*list)); delete list; } break; case TMSG_PLAYLISTPLAYER_INSERT: if (pMsg->lpVoid) { CFileItemList *list = (CFileItemList *)pMsg->lpVoid; g_playlistPlayer.Insert(pMsg->dwParam1, (*list), pMsg->dwParam2); delete list; } break; case TMSG_PLAYLISTPLAYER_REMOVE: if (pMsg->dwParam1 != (DWORD) -1) g_playlistPlayer.Remove(pMsg->dwParam1,pMsg->dwParam2); break; case TMSG_PLAYLISTPLAYER_CLEAR: g_playlistPlayer.ClearPlaylist(pMsg->dwParam1); break; case TMSG_PLAYLISTPLAYER_SHUFFLE: g_playlistPlayer.SetShuffle(pMsg->dwParam1, pMsg->dwParam2 > 0); break; case TMSG_PLAYLISTPLAYER_REPEAT: g_playlistPlayer.SetRepeat(pMsg->dwParam1, (PLAYLIST::REPEAT_STATE)pMsg->dwParam2); break; case TMSG_PLAYLISTPLAYER_GET_ITEMS: if (pMsg->lpVoid) { PLAYLIST::CPlayList playlist = g_playlistPlayer.GetPlaylist(pMsg->dwParam1); CFileItemList *list = (CFileItemList *)pMsg->lpVoid; for (int i = 0; i < playlist.size(); i++) list->Add(CFileItemPtr(new CFileItem(*playlist[i]))); } break; case TMSG_PLAYLISTPLAYER_SWAP: if (pMsg->lpVoid) { vector<int> *indexes = (vector<int> *)pMsg->lpVoid; if (indexes->size() == 2) g_playlistPlayer.Swap(pMsg->dwParam1, indexes->at(0), indexes->at(1)); delete indexes; } 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_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((int)pMsg->dwParam1, pMsg->strParam); } break; case TMSG_GUI_SHOW: { CGUIDialog *pDialog = (CGUIDialog *)pMsg->lpVoid; if (pDialog) pDialog->Show(); } break; case TMSG_GUI_WINDOW_CLOSE: { CGUIWindow *window = (CGUIWindow *)pMsg->lpVoid; if (window) window->Close(pMsg->dwParam2 & 0x1 ? true : false, pMsg->dwParam1, pMsg->dwParam2 & 0x2 ? true : false); } break; case TMSG_GUI_ACTIVATE_WINDOW: { g_windowManager.ActivateWindow(pMsg->dwParam1, pMsg->params, pMsg->dwParam2 > 0); } break; case TMSG_GUI_ADDON_DIALOG: { if (pMsg->lpVoid) { // TODO: This is ugly - really these python dialogs should just be normal XBMC dialogs ((ADDON::CGUIAddonWindowDialog *) pMsg->lpVoid)->Show_Internal(pMsg->dwParam2 > 0); } } break; case TMSG_GUI_PYTHON_DIALOG: { if (pMsg->lpVoid) { // TODO: This is ugly - really these python dialogs should just be normal XBMC dialogs if (pMsg->dwParam1) ((CGUIPythonWindowXMLDialog *)pMsg->lpVoid)->Show_Internal(pMsg->dwParam2 > 0); else ((CGUIPythonWindowDialog *)pMsg->lpVoid)->Show_Internal(pMsg->dwParam2 > 0); } } break; case TMSG_GUI_ACTION: { if (pMsg->lpVoid) { CAction *action = (CAction *)pMsg->lpVoid; if (pMsg->dwParam1 == WINDOW_INVALID) g_application.OnAction(*action); else { CGUIWindow *pWindow = g_windowManager.GetWindow(pMsg->dwParam1); if (pWindow) pWindow->OnAction(*action); else CLog::Log(LOGWARNING, "Failed to get window with ID %i to send an action to", pMsg->dwParam1); } delete action; } } break; case TMSG_GUI_MESSAGE: { if (pMsg->lpVoid) { CGUIMessage *message = (CGUIMessage *)pMsg->lpVoid; g_windowManager.SendMessage(*message, pMsg->dwParam1); delete message; } } 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.EvaluateBool(pMsg->params[i])); } } break; case TMSG_CALLBACK: { ThreadMessageCallback *callback = (ThreadMessageCallback*)pMsg->lpVoid; callback->callback(callback->userptr); } break; case TMSG_VOLUME_SHOW: { CAction action((int)pMsg->dwParam1); g_application.ShowVolumeBar(&action); } break; case TMSG_SPLASH_MESSAGE: { if (g_application.GetSplash()) g_application.GetSplash()->Show(pMsg->strParam); } break; case TMSG_DISPLAY_SETUP: { *((bool*)pMsg->lpVoid) = g_application.InitWindow(); g_application.ReloadSkin(); } break; case TMSG_DISPLAY_DESTROY: { *((bool*)pMsg->lpVoid) = g_application.DestroyWindow(); } break; case TMSG_UPDATE_CURRENT_ITEM: { CFileItem* item = (CFileItem*)pMsg->lpVoid; if (!item) return; if (pMsg->dwParam1 == 1 && item->HasMusicInfoTag()) // only grab music tag g_infoManager.SetCurrentSongTag(*item->GetMusicInfoTag()); else if (pMsg->dwParam1 == 2 && item->HasVideoInfoTag()) // only grab video tag g_infoManager.SetCurrentVideoTag(*item->GetVideoInfoTag()); else g_infoManager.SetCurrentItem(*item); delete item; break; } } }