JSONRPC_STATUS CVideoLibrary::GetAdditionalEpisodeDetails(const CVariant ¶meterObject, CFileItemList &items, CVariant &result, CVideoDatabase &videodatabase, bool limit /* = true */) { if (!videodatabase.Open()) return InternalError; bool additionalInfo = false; bool streamdetails = false; for (CVariant::const_iterator_array itr = parameterObject["properties"].begin_array(); itr != parameterObject["properties"].end_array(); itr++) { CStdString fieldValue = itr->asString(); if (fieldValue == "cast" || fieldValue == "resume") additionalInfo = true; else if (fieldValue == "streamdetails") streamdetails = true; } if (additionalInfo || streamdetails) { for (int index = 0; index < items.Size(); index++) { if (additionalInfo) videodatabase.GetEpisodeInfo("", *(items[index]->GetVideoInfoTag()), items[index]->GetVideoInfoTag()->m_iDbId); if (streamdetails) videodatabase.GetStreamDetails(*(items[index]->GetVideoInfoTag())); } } int size = items.Size(); if (!limit && items.HasProperty("total") && items.GetProperty("total").asInteger() > size) size = (int)items.GetProperty("total").asInteger(); HandleFileItemList("episodeid", true, "episodes", items, parameterObject, result, size, limit); return OK; }
JSONRPC_STATUS CVideoLibrary::GetAdditionalMusicVideoDetails(const CVariant ¶meterObject, CFileItemList &items, CVariant &result, CVideoDatabase &videodatabase, bool limit /* = true */) { if (!videodatabase.Open()) return InternalError; bool streamdetails = false; for (CVariant::const_iterator_array itr = parameterObject["properties"].begin_array(); itr != parameterObject["properties"].end_array(); itr++) { if (itr->asString() == "tag" || itr->asString() == "streamdetails") streamdetails = true; } if (streamdetails) { for (int index = 0; index < items.Size(); index++) videodatabase.GetMusicVideoInfo("", *(items[index]->GetVideoInfoTag()), items[index]->GetVideoInfoTag()->m_iDbId); } int size = items.Size(); if (!limit && items.HasProperty("total") && items.GetProperty("total").asInteger() > size) size = (int)items.GetProperty("total").asInteger(); HandleFileItemList("musicvideoid", true, "musicvideos", items, parameterObject, result, size, limit); return OK; }
JSONRPC_STATUS CAudioLibrary::GetAlbums(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { CMusicDatabase musicdatabase; if (!musicdatabase.Open()) return InternalError; CMusicDbUrl musicUrl; musicUrl.FromString("musicdb://3/"); int artistID = -1, genreID = -1; const CVariant &filter = parameterObject["filter"]; if (filter.isMember("artistid")) artistID = (int)filter["artistid"].asInteger(); if (filter.isMember("artist")) musicUrl.AddOption("artist", filter["artist"].asString()); if (filter.isMember("genreid")) genreID = (int)filter["genreid"].asInteger(); if (filter.isMember("genre")) musicUrl.AddOption("genre", filter["genre"].asString()); SortDescription sorting; ParseLimits(parameterObject, sorting.limitStart, sorting.limitEnd); if (!ParseSorting(parameterObject, sorting.sortBy, sorting.sortOrder, sorting.sortAttributes)) return InvalidParams; CFileItemList items; if (!musicdatabase.GetAlbumsNav(musicUrl.ToString(), items, genreID, artistID, sorting)) return InternalError; int size = items.Size(); if (items.HasProperty("total") && items.GetProperty("total").asInteger() > size) size = (int)items.GetProperty("total").asInteger(); HandleFileItemList("albumid", false, "albums", items, parameterObject, result, size, false); return OK; }
JSONRPC_STATUS CAudioLibrary::GetSongs(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { CMusicDatabase musicdatabase; if (!musicdatabase.Open()) return InternalError; CMusicDbUrl musicUrl; if (!musicUrl.FromString("musicdb://songs/")) return InternalError; if (!parameterObject["includesingles"].asBoolean()) musicUrl.AddOption("singles", false); int genreID = -1, albumID = -1, artistID = -1; const CVariant &filter = parameterObject["filter"]; if (filter.isMember("artistid")) artistID = (int)filter["artistid"].asInteger(); else if (filter.isMember("artist")) musicUrl.AddOption("artist", filter["artist"].asString()); else if (filter.isMember("genreid")) genreID = (int)filter["genreid"].asInteger(); else if (filter.isMember("genre")) musicUrl.AddOption("genre", filter["genre"].asString()); else if (filter.isMember("albumid")) albumID = (int)filter["albumid"].asInteger(); else if (filter.isMember("album")) musicUrl.AddOption("album", filter["album"].asString()); else if (filter.isObject()) { std::string xsp; if (!GetXspFiltering("songs", filter, xsp)) return InvalidParams; musicUrl.AddOption("xsp", xsp); } SortDescription sorting; ParseLimits(parameterObject, sorting.limitStart, sorting.limitEnd); if (!ParseSorting(parameterObject, sorting.sortBy, sorting.sortOrder, sorting.sortAttributes)) return InvalidParams; CFileItemList items; if (!musicdatabase.GetSongsNav(musicUrl.ToString(), items, genreID, artistID, albumID, sorting)) return InternalError; JSONRPC_STATUS ret = GetAdditionalSongDetails(parameterObject, items, musicdatabase); if (ret != OK) return ret; int size = items.Size(); if (items.HasProperty("total") && items.GetProperty("total").asInteger() > size) size = (int)items.GetProperty("total").asInteger(); HandleFileItemList("songid", true, "songs", items, parameterObject, result, size, false); return OK; }
JSONRPC_STATUS CVideoLibrary::HandleItems(const char *idProperty, const char *resultName, CFileItemList &items, const CVariant ¶meterObject, CVariant &result, bool limit /* = true */) { int size = items.Size(); if (!limit && items.HasProperty("total") && items.GetProperty("total").asInteger() > size) size = (int)items.GetProperty("total").asInteger(); HandleFileItemList(idProperty, true, resultName, items, parameterObject, result, size, limit); return OK; }
JSONRPC_STATUS CAudioLibrary::GetArtists(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { CMusicDatabase musicdatabase; if (!musicdatabase.Open()) return InternalError; CMusicDbUrl musicUrl; if (!musicUrl.FromString("musicdb://artists/")) return InternalError; int genreID = -1, albumID = -1, songID = -1; const CVariant &filter = parameterObject["filter"]; if (filter.isMember("genreid")) genreID = (int)filter["genreid"].asInteger(); else if (filter.isMember("genre")) musicUrl.AddOption("genre", filter["genre"].asString()); else if (filter.isMember("albumid")) albumID = (int)filter["albumid"].asInteger(); else if (filter.isMember("album")) musicUrl.AddOption("album", filter["album"].asString()); else if (filter.isMember("songid")) songID = (int)filter["songid"].asInteger(); else if (filter.isObject()) { std::string xsp; if (!GetXspFiltering("artists", filter, xsp)) return InvalidParams; musicUrl.AddOption("xsp", xsp); } bool albumArtistsOnly = !CSettings::GetInstance().GetBool(CSettings::SETTING_MUSICLIBRARY_SHOWCOMPILATIONARTISTS); if (parameterObject["albumartistsonly"].isBoolean()) albumArtistsOnly = parameterObject["albumartistsonly"].asBoolean(); SortDescription sorting; ParseLimits(parameterObject, sorting.limitStart, sorting.limitEnd); if (!ParseSorting(parameterObject, sorting.sortBy, sorting.sortOrder, sorting.sortAttributes)) return InvalidParams; CFileItemList items; if (!musicdatabase.GetArtistsNav(musicUrl.ToString(), items, albumArtistsOnly, genreID, albumID, songID, CDatabase::Filter(), sorting)) return InternalError; // Add "artist" to "properties" array by default CVariant param = parameterObject; if (!param.isMember("properties")) param["properties"] = CVariant(CVariant::VariantTypeArray); param["properties"].append("artist"); int size = items.Size(); if (items.HasProperty("total") && items.GetProperty("total").asInteger() > size) size = (int)items.GetProperty("total").asInteger(); HandleFileItemList("artistid", false, "artists", items, param, result, size, false); return OK; }
virtual bool DoWork() { CFileItemList items; if (CDirectory::GetDirectory(m_url, items, "")) { // sort the items if necessary if (m_sort.sortBy != SortByNone) items.Sort(m_sort); // limit must not exceed the number of items int limit = (m_limit == 0) ? items.Size() : std::min((int) m_limit, items.Size()); // convert to CGUIStaticItem's and set visibility and targets m_items.reserve(limit); for (int i = 0; i < limit; i++) { CGUIStaticItemPtr item(new CGUIStaticItem(*items[i])); if (item->HasProperty("node.visible")) item->SetVisibleCondition(item->GetProperty("node.visible").asString(), m_parentID); getThumbLoader(item)->LoadItem(item.get()); m_items.push_back(item); } m_target = items.GetProperty("node.target").asString(); } return true; }
CGUIViewStateVideoMusicVideos::CGUIViewStateVideoMusicVideos(const CFileItemList& items) : CGUIViewStateWindowVideo(items) { if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 556, LABEL_MASKS("%T", "%Y")); // Filename, Duration | Foldername, empty else AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%T", "%Y")); // Filename, Duration | Foldername, empty AddSortMethod(SORT_METHOD_YEAR,562, LABEL_MASKS("%T", "%Y")); if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) { AddSortMethod(SORT_METHOD_ARTIST_IGNORE_THE,557, LABEL_MASKS("%A - %T", "%Y")); AddSortMethod(SORT_METHOD_ALBUM_IGNORE_THE,558, LABEL_MASKS("%B - %T", "%Y")); } else { AddSortMethod(SORT_METHOD_ARTIST,557, LABEL_MASKS("%A - %T", "%Y")); AddSortMethod(SORT_METHOD_ALBUM,558, LABEL_MASKS("%B - %T", "%Y")); } if (items.IsSmartPlayList() || items.GetProperty("library.filter").asBoolean()) { AddSortMethod(SORT_METHOD_PLAYLIST_ORDER, 559, LABEL_MASKS("%A - %T", "%Y")); SetSortMethod(SORT_METHOD_PLAYLIST_ORDER); } else SetSortMethod(g_settings.m_viewStateVideoNavMusicVideos.m_sortMethod); SetViewAsControl(g_settings.m_viewStateVideoNavMusicVideos.m_viewMode); SetSortOrder(g_settings.m_viewStateVideoNavMusicVideos.m_sortOrder); LoadViewState(items.GetPath(), WINDOW_VIDEO_NAV); }
void CGUIViewState::AddPlaylistOrder(const CFileItemList &items, LABEL_MASKS label_masks) { SortBy sortBy = SortByPlaylistOrder; int sortLabel = 559; SortOrder sortOrder = SortOrderAscending; if (items.HasProperty(PROPERTY_SORT_ORDER)) { sortBy = (SortBy)items.GetProperty(PROPERTY_SORT_ORDER).asInteger(); if (sortBy != SortByNone) { sortLabel = SortUtils::GetSortLabel(sortBy); sortOrder = items.GetProperty(PROPERTY_SORT_ASCENDING).asBoolean() ? SortOrderAscending : SortOrderDescending; } } AddSortMethod(sortBy, sortLabel, label_masks, SortAttributeNone, sortOrder); SetSortMethod(sortBy, sortOrder); }
void CGUIViewState::AddPlaylistOrder(const CFileItemList &items, LABEL_MASKS label_masks) { SORT_METHOD sortMethod = SORT_METHOD_PLAYLIST_ORDER; int sortLabel = 559; SortOrder sortOrder = SortOrderAscending; if (items.HasProperty(PROPERTY_SORT_ORDER)) { SortBy sortBy = (SortBy)items.GetProperty(PROPERTY_SORT_ORDER).asInteger(); if (sortBy != SortByNone) { sortMethod = SortUtils::TranslateOldSortMethod(sortBy, g_guiSettings.GetBool("filelists.ignorethewhensorting")); if (sortMethod == SORT_METHOD_NONE) sortMethod = SORT_METHOD_PLAYLIST_ORDER; else { sortLabel = SortUtils::GetSortLabel(sortBy); sortOrder = items.GetProperty(PROPERTY_SORT_ASCENDING).asBoolean() ? SortOrderAscending : SortOrderDescending; } } } AddSortMethod(sortMethod, sortLabel, label_masks); SetSortMethod(sortMethod); SetSortOrder(sortOrder); }
virtual bool DoWork() { CFileItemList items; if (CDirectory::GetDirectory(m_url, items, "")) { // convert to CGUIStaticItem's and set visibility and targets m_items.reserve(items.Size()); for (int i = 0; i < items.Size(); i++) { CGUIStaticItemPtr item(new CGUIStaticItem(*items[i])); if (item->HasProperty("node.visible")) item->SetVisibleCondition(item->GetProperty("node.visible").asString(), m_parentID); m_items.push_back(item); } m_target = items.GetProperty("node.target").asString(); } return true; }
CGUIViewStateVideoMusicVideos::CGUIViewStateVideoMusicVideos(const CFileItemList& items) : CGUIViewStateWindowVideo(items) { if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 556, LABEL_MASKS("%T", "%Y")); // Title, Year | empty, empty else AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%T", "%Y")); // Title, Year | empty, empty AddSortMethod(SORT_METHOD_MPAA_RATING, 20074, LABEL_MASKS("%T", "%O")); AddSortMethod(SORT_METHOD_YEAR, 562, LABEL_MASKS("%T", "%Y")); // Title, Year | empty, empty if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) { AddSortMethod(SORT_METHOD_ARTIST_IGNORE_THE, 557, LABEL_MASKS("%A - %T", "%Y")); // Artist - Title, Year | empty, empty AddSortMethod(SORT_METHOD_ALBUM_IGNORE_THE, 558, LABEL_MASKS("%B - %T", "%Y")); // Album - Title, Year | empty, empty } else { AddSortMethod(SORT_METHOD_ARTIST, 557, LABEL_MASKS("%A - %T", "%Y")); // Artist - Title, Year | empty, empty AddSortMethod(SORT_METHOD_ALBUM, 558, LABEL_MASKS("%B - %T", "%Y")); // Album - Title, Year | empty, empty } AddSortMethod(SORT_METHOD_PLAYCOUNT, 576, LABEL_MASKS("%T", "%V")); // Title, Playcount | empty, empty CStdString strTrackLeft=g_guiSettings.GetString("musicfiles.trackformat"); CStdString strTrackRight=g_guiSettings.GetString("musicfiles.trackformatright"); AddSortMethod(SORT_METHOD_TRACKNUM, 554, LABEL_MASKS(strTrackLeft, strTrackRight)); // Userdefined, Userdefined | empty, empty if (items.IsSmartPlayList() || items.GetProperty("library.filter").asBoolean()) { AddSortMethod(SORT_METHOD_PLAYLIST_ORDER, 559, LABEL_MASKS("%A - %T", "%Y")); // Artist - Title, Year | empty, empty SetSortMethod(SORT_METHOD_PLAYLIST_ORDER); } else SetSortMethod(g_settings.m_viewStateVideoNavMusicVideos.m_sortMethod); SetViewAsControl(g_settings.m_viewStateVideoNavMusicVideos.m_viewMode); SetSortOrder(g_settings.m_viewStateVideoNavMusicVideos.m_sortOrder); LoadViewState(items.GetPath(), WINDOW_VIDEO_NAV); }
CGUIViewStateVideoTVShows::CGUIViewStateVideoTVShows(const CFileItemList& items) : CGUIViewStateWindowVideo(items) { if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%L", "%M", "%L", "%M")); // Label, #Episodes | Label, #Episodes else AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%L", "%M", "%L", "%M")); // Label, #Episodes | Label, #Episodes AddSortMethod(SORT_METHOD_YEAR, 562, LABEL_MASKS("%L","%Y","%L","%Y")); // Label, Year | Label, Year if (items.IsSmartPlayList() || items.GetProperty("library.filter").asBoolean()) { AddSortMethod(SORT_METHOD_PLAYLIST_ORDER, 559, LABEL_MASKS("%L", "%M", "%L", "%M")); // Label, #Episodes | Label, #Episodes SetSortMethod(SORT_METHOD_PLAYLIST_ORDER); } else SetSortMethod(g_settings.m_viewStateVideoNavTvShows.m_sortMethod); SetViewAsControl(g_settings.m_viewStateVideoNavTvShows.m_viewMode); SetSortOrder(g_settings.m_viewStateVideoNavTvShows.m_sortOrder); LoadViewState(items.GetPath(), WINDOW_VIDEO_NAV); }
CGUIViewStateVideoEpisodes::CGUIViewStateVideoEpisodes(const CFileItemList& items) : CGUIViewStateWindowVideo(items) { if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) AddSortMethod(SORT_METHOD_LABEL_IGNORE_THE, 551, LABEL_MASKS("%Z - %H. %T","%R")); // Filename, Duration | Foldername, empty else AddSortMethod(SORT_METHOD_LABEL, 551, LABEL_MASKS("%Z - %H. %T", "%R")); // Filename, Duration | Foldername, empty if (0)//params.GetSeason() > -1) { AddSortMethod(SORT_METHOD_VIDEO_RATING, 563, LABEL_MASKS("%E. %T", "%R")); // Filename, Duration | Foldername, empty AddSortMethod(SORT_METHOD_MPAA_RATING, 20074, LABEL_MASKS("%E. %T", "%O")); AddSortMethod(SORT_METHOD_EPISODE,20359,LABEL_MASKS("%E. %T","%R")); AddSortMethod(SORT_METHOD_PRODUCTIONCODE,20368,LABEL_MASKS("%E. %T","%P", "%E. %T","%P")); AddSortMethod(SORT_METHOD_DATE,552,LABEL_MASKS("%E. %T","%J","E. %T","%J")); } else { // format here is tvshowtitle - season/episode number. episode title AddSortMethod(SORT_METHOD_VIDEO_RATING, 563, LABEL_MASKS("%Z - %H. %T", "%R")); AddSortMethod(SORT_METHOD_MPAA_RATING, 20074, LABEL_MASKS("%Z - %H. %T", "%O")); AddSortMethod(SORT_METHOD_EPISODE,20359,LABEL_MASKS("%Z - %H. %T","%R")); AddSortMethod(SORT_METHOD_PRODUCTIONCODE,20368,LABEL_MASKS("%Z - %H. %T","%P")); AddSortMethod(SORT_METHOD_DATE,552,LABEL_MASKS("%Z - %H. %T","%J")); } if (items.IsSmartPlayList() || items.GetProperty("library.filter").asBoolean()) { AddSortMethod(SORT_METHOD_PLAYLIST_ORDER, 559, LABEL_MASKS("%Z - %H. %T", "%R")); SetSortMethod(SORT_METHOD_PLAYLIST_ORDER); } else SetSortMethod(g_settings.m_viewStateVideoNavEpisodes.m_sortMethod); SetViewAsControl(g_settings.m_viewStateVideoNavEpisodes.m_viewMode); SetSortOrder(g_settings.m_viewStateVideoNavEpisodes.m_sortOrder); LoadViewState(items.GetPath(), WINDOW_VIDEO_NAV); }
CGUIViewStateVideoMovies::CGUIViewStateVideoMovies(const CFileItemList& items) : CGUIViewStateWindowVideo(items) { if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE, 551, LABEL_MASKS("%T", "%R")); // Filename, Duration | Foldername, empty else AddSortMethod(SORT_METHOD_VIDEO_SORT_TITLE, 551, LABEL_MASKS("%T", "%R")); AddSortMethod(SORT_METHOD_VIDEO_RATING, 563, LABEL_MASKS("%T", "%R")); // Filename, Duration | Foldername, empty AddSortMethod(SORT_METHOD_MPAA_RATING, 20074, LABEL_MASKS("%T", "%O")); AddSortMethod(SORT_METHOD_YEAR,562, LABEL_MASKS("%T", "%Y")); if (items.IsSmartPlayList() || items.GetProperty("library.filter").asBoolean()) { AddSortMethod(SORT_METHOD_PLAYLIST_ORDER, 559, LABEL_MASKS("%T", "%R")); SetSortMethod(SORT_METHOD_PLAYLIST_ORDER); } else SetSortMethod(g_settings.m_viewStateVideoNavTitles.m_sortMethod); SetViewAsControl(g_settings.m_viewStateVideoNavTitles.m_viewMode); SetSortOrder(g_settings.m_viewStateVideoNavTitles.m_sortOrder); LoadViewState(items.GetPath(), WINDOW_VIDEO_NAV); }
bool CLibraryDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items) { std::string libNode = GetNode(strPath); if (libNode.empty()) return false; if (URIUtils::HasExtension(libNode, ".xml")) { // a filter or folder node TiXmlElement *node = LoadXML(libNode); if (node) { CStdString type = node->Attribute("type"); if (type == "filter") { CSmartPlaylist playlist; CStdString type, label; XMLUtils::GetString(node, "content", type); if (type.IsEmpty()) { CLog::Log(LOGERROR, "<content> tag must not be empty for type=\"filter\" node '%s'", libNode.c_str()); return false; } if (XMLUtils::GetString(node, "label", label)) label = CGUIControlFactory::FilterLabel(label); playlist.SetType(type); playlist.SetName(label); if (playlist.LoadFromXML(node) && CSmartPlaylistDirectory::GetDirectory(playlist, items)) { items.SetProperty("library.filter", "true"); items.SetPath(items.GetProperty("path.db").asString()); return true; } } else if (type == "folder") { CStdString path; XMLUtils::GetPath(node, "path", path); if (!path.IsEmpty()) { URIUtils::AddSlashAtEnd(path); return CDirectory::GetDirectory(path, items, m_strFileMask, m_flags); } } } return false; } // just a plain node - read the folder for XML nodes and other folders CFileItemList nodes; if (!CDirectory::GetDirectory(libNode, nodes, ".xml", DIR_FLAG_NO_FILE_DIRS)) return false; // iterate over our nodes for (int i = 0; i < nodes.Size(); i++) { const TiXmlElement *node = NULL; CStdString xml = nodes[i]->GetPath(); if (nodes[i]->m_bIsFolder) node = LoadXML(URIUtils::AddFileToFolder(xml, "index.xml")); else { node = LoadXML(xml); if (node && URIUtils::GetFileName(xml).Equals("index.xml")) { // set the label on our items CStdString label; if (XMLUtils::GetString(node, "label", label)) label = CGUIControlFactory::FilterLabel(label); items.SetLabel(label); continue; } } if (node) { CStdString label, icon; if (XMLUtils::GetString(node, "label", label)) label = CGUIControlFactory::FilterLabel(label); XMLUtils::GetString(node, "icon", icon); int order = 0; node->Attribute("order", &order); // create item URIUtils::RemoveSlashAtEnd(xml); CStdString folder = URIUtils::GetFileName(xml); CFileItemPtr item(new CFileItem(URIUtils::AddFileToFolder(strPath, folder), true)); item->SetLabel(label); if (!icon.IsEmpty() && g_TextureManager.HasTexture(icon)) item->SetIconImage(icon); item->m_iprogramCount = order; items.Add(item); } } items.Sort(SortByPlaylistOrder, SortOrderAscending); return true; }
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 CGUIWindowVideoNav::LoadVideoInfo(CFileItemList &items, CVideoDatabase &database, bool allowReplaceLabels) { //! @todo this could possibly be threaded as per the music info loading, //! we could also cache the info if (!items.GetContent().empty() && !items.IsPlugin()) return; // don't load for listings that have content set and weren't created from plugins std::string content = items.GetContent(); // determine content only if it isn't set if (content.empty()) { content = database.GetContentForPath(items.GetPath()); items.SetContent((content.empty() && !items.IsPlugin()) ? "files" : content); } /* If we have a matching item in the library, so we can assign the metadata to it. In addition, we can choose * whether the item is stacked down (eg in the case of folders representing a single item) * whether or not we assign the library's labels to the item, or leave the item as is. As certain users (read: certain developers) don't want either of these to occur, we compromise by stacking items down only if stacking is available and enabled. Similarly, we assign the "clean" library labels to the item only if the "Replace filenames with library titles" setting is enabled. */ const bool stackItems = items.GetProperty("isstacked").asBoolean() || (StackingAvailable(items) && CServiceBroker::GetSettings().GetBool(CSettings::SETTING_MYVIDEOS_STACKVIDEOS)); const bool replaceLabels = allowReplaceLabels && CServiceBroker::GetSettings().GetBool(CSettings::SETTING_MYVIDEOS_REPLACELABELS); CFileItemList dbItems; /* NOTE: In the future when GetItemsForPath returns all items regardless of whether they're "in the library" we won't need the fetchedPlayCounts code, and can "simply" do this directly on absence of content. */ bool fetchedPlayCounts = false; if (!content.empty()) { database.GetItemsForPath(content, items.GetPath(), dbItems); dbItems.SetFastLookup(true); } for (int i = 0; i < items.Size(); i++) { CFileItemPtr pItem = items[i]; CFileItemPtr match; if (!content.empty()) /* optical media will be stacked down, so it's path won't match the base path */ { std::string pathToMatch = pItem->IsOpticalMediaFile() ? pItem->GetLocalMetadataPath() : pItem->GetPath(); if (URIUtils::IsMultiPath(pathToMatch)) pathToMatch = CMultiPathDirectory::GetFirstPath(pathToMatch); match = dbItems.Get(pathToMatch); } if (match) { pItem->UpdateInfo(*match, replaceLabels); if (stackItems) { if (match->m_bIsFolder) pItem->SetPath(match->GetVideoInfoTag()->m_strPath); else pItem->SetPath(match->GetVideoInfoTag()->m_strFileNameAndPath); // if we switch from a file to a folder item it means we really shouldn't be sorting files and // folders separately if (pItem->m_bIsFolder != match->m_bIsFolder) { items.SetSortIgnoreFolders(true); pItem->m_bIsFolder = match->m_bIsFolder; } } } else { /* NOTE: Currently we GetPlayCounts on our items regardless of whether content is set as if content is set, GetItemsForPaths doesn't return anything not in the content tables. This code can be removed once the content tables are always filled */ if (!pItem->m_bIsFolder && !fetchedPlayCounts) { database.GetPlayCounts(items.GetPath(), items); fetchedPlayCounts = true; } // set the watched overlay if (pItem->IsVideo()) pItem->SetOverlayImage(CGUIListItem::ICON_OVERLAY_UNWATCHED, pItem->HasVideoInfoTag() && pItem->GetVideoInfoTag()->GetPlayCount() > 0); } } }
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_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: { #ifdef _WIN32 g_application.Stop(EXITCODE_RESTARTAPP); #endif // TODO } 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(__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_HTTPAPI if (!m_pXbmcHttp) { 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().Quit(); 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(),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_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.m_splash) g_application.m_splash->Show(pMsg->strParam); } break; } }
JSONRPC_STATUS CVideoLibrary::GetTVShows(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { CVideoDatabase videodatabase; if (!videodatabase.Open()) return InternalError; SortDescription sorting; ParseLimits(parameterObject, sorting.limitStart, sorting.limitEnd); if (!ParseSorting(parameterObject, sorting.sortBy, sorting.sortOrder, sorting.sortAttributes)) return InvalidParams; CVideoDbUrl videoUrl; videoUrl.FromString("videodb://tvshows/titles/"); int genreID = -1, year = -1; const CVariant &filter = parameterObject["filter"]; if (filter.isMember("genreid")) genreID = (int)filter["genreid"].asInteger(); else if (filter.isMember("genre")) videoUrl.AddOption("genre", filter["genre"].asString()); else if (filter.isMember("year")) year = (int)filter["year"].asInteger(); else if (filter.isMember("actor")) videoUrl.AddOption("actor", filter["actor"].asString()); else if (filter.isMember("studio")) videoUrl.AddOption("studio", filter["studio"].asString()); else if (filter.isMember("tag")) videoUrl.AddOption("tag", filter["tag"].asString()); else if (filter.isObject()) { std::string xsp; if (!GetXspFiltering("tvshows", filter, xsp)) return InvalidParams; videoUrl.AddOption("xsp", xsp); } CFileItemList items; if (!videodatabase.GetTvShowsNav(videoUrl.ToString(), items, genreID, year, -1, -1, -1, -1, sorting)) return InvalidParams; bool additionalInfo = false; for (CVariant::const_iterator_array itr = parameterObject["properties"].begin_array(); itr != parameterObject["properties"].end_array(); itr++) { std::string fieldValue = itr->asString(); if (fieldValue == "cast" || fieldValue == "tag") additionalInfo = true; } if (additionalInfo) { for (int index = 0; index < items.Size(); index++) videodatabase.GetTvShowInfo("", *(items[index]->GetVideoInfoTag()), items[index]->GetVideoInfoTag()->m_iDbId); } int size = items.Size(); if (items.HasProperty("total") && items.GetProperty("total").asInteger() > size) size = (int)items.GetProperty("total").asInteger(); HandleFileItemList("tvshowid", true, "tvshows", items, parameterObject, result, size, false); return OK; }
void PLAYLIST::CPlayListPlayer::OnApplicationMessage(KODI::MESSAGING::ThreadMessage* pMsg) { switch (pMsg->dwMessage) { case TMSG_PLAYLISTPLAYER_PLAY: if (pMsg->param1 != -1) Play(pMsg->param1, ""); else Play(); break; case TMSG_PLAYLISTPLAYER_PLAY_SONG_ID: if (pMsg->param1 != -1) { bool *result = (bool*)pMsg->lpVoid; *result = PlaySongId(pMsg->param1); } else Play(); break; case TMSG_PLAYLISTPLAYER_NEXT: PlayNext(); break; case TMSG_PLAYLISTPLAYER_PREV: PlayPrevious(); break; case TMSG_PLAYLISTPLAYER_ADD: if (pMsg->lpVoid) { CFileItemList *list = (CFileItemList *)pMsg->lpVoid; Add(pMsg->param1, (*list)); delete list; } break; case TMSG_PLAYLISTPLAYER_INSERT: if (pMsg->lpVoid) { CFileItemList *list = (CFileItemList *)pMsg->lpVoid; Insert(pMsg->param1, (*list), pMsg->param2); delete list; } break; case TMSG_PLAYLISTPLAYER_REMOVE: if (pMsg->param1 != -1) Remove(pMsg->param1, pMsg->param2); break; case TMSG_PLAYLISTPLAYER_CLEAR: ClearPlaylist(pMsg->param1); break; case TMSG_PLAYLISTPLAYER_SHUFFLE: SetShuffle(pMsg->param1, pMsg->param2 > 0); break; case TMSG_PLAYLISTPLAYER_REPEAT: SetRepeat(pMsg->param1, (PLAYLIST::REPEAT_STATE)pMsg->param2); break; case TMSG_PLAYLISTPLAYER_GET_ITEMS: if (pMsg->lpVoid) { PLAYLIST::CPlayList playlist = GetPlaylist(pMsg->param1); CFileItemList *list = static_cast<CFileItemList*>(pMsg->lpVoid); for (int i = 0; i < playlist.size(); i++) list->Add(std::make_shared<CFileItem>(*playlist[i])); } break; case TMSG_PLAYLISTPLAYER_SWAP: if (pMsg->lpVoid) { auto indexes = static_cast<std::vector<int>*>(pMsg->lpVoid); if (indexes->size() == 2) Swap(pMsg->param1, indexes->at(0), indexes->at(1)); delete indexes; } 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; } } ClearPlaylist(playlist); SetCurrentPlaylist(playlist); if (list->Size() == 1 && !(*list)[0]->IsPlayList()) { CFileItemPtr item = (*list)[0]; if (item->IsAudio() || item->IsVideo()) Play(item, pMsg->strParam); else g_application.PlayMedia(*item, pMsg->strParam, playlist); } else { // Handle "shuffled" option if present if (list->HasProperty("shuffled") && list->GetProperty("shuffled").isBoolean()) SetShuffle(playlist, list->GetProperty("shuffled").asBoolean(), false); // Handle "repeat" option if present if (list->HasProperty("repeat") && list->GetProperty("repeat").isInteger()) SetRepeat(playlist, (PLAYLIST::REPEAT_STATE)list->GetProperty("repeat").asInteger(), false); Add(playlist, (*list)); Play(pMsg->param1, pMsg->strParam); } } delete list; } else if (pMsg->param1 == PLAYLIST_MUSIC || pMsg->param1 == PLAYLIST_VIDEO) { if (GetCurrentPlaylist() != pMsg->param1) SetCurrentPlaylist(pMsg->param1); CApplicationMessenger::GetInstance().SendMsg(TMSG_PLAYLISTPLAYER_PLAY, pMsg->param2); } } break; case TMSG_MEDIA_RESTART: g_application.Restart(true); 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; default: break; } }