bool CGUIWindowMusicBase::GetDirectory(const CStdString &strDirectory, CFileItemList &items) { items.SetThumbnailImage(""); bool bResult = CGUIMediaWindow::GetDirectory(strDirectory,items); if (bResult) items.SetMusicThumb(); // add in the "New Playlist" item if we're in the playlists folder if (items.m_strPath == "special://musicplaylists/" && !items.Contains("newplaylist://")) { CFileItem* newPlaylist = new CFileItem(g_settings.GetUserDataItem("PartyMode.xsp"),false); newPlaylist->SetLabel(g_localizeStrings.Get(16035)); newPlaylist->SetLabelPreformated(true); newPlaylist->m_bIsFolder = true; items.Add(newPlaylist); newPlaylist = new CFileItem("newplaylist://", false); newPlaylist->SetLabel(g_localizeStrings.Get(525)); newPlaylist->SetLabelPreformated(true); newPlaylist->SetCanQueue(false); items.Add(newPlaylist); newPlaylist = new CFileItem("newsmartplaylist://music", false); newPlaylist->SetLabel(g_localizeStrings.Get(21437)); newPlaylist->SetLabelPreformated(true); newPlaylist->SetCanQueue(false); items.Add(newPlaylist); } return bResult; }
bool CCMythDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items) { CURL url(strPath); CStdString base(strPath); CUtil::RemoveSlashAtEnd(base); m_session = CCMythSession::AquireSession(strPath); if(!m_session) return false; m_dll = m_session->GetLibrary(); if(!m_dll) return false; if(url.GetFileName().IsEmpty()) { CFileItem *item; item = new CFileItem(base + "/channels/", true); item->SetLabel("Live Channels"); item->SetLabelPreformated(true); items.Add(item); item = new CFileItem(base + "/recordings/", true); item->SetLabel("Recordings"); item->SetLabelPreformated(true); items.Add(item); item = new CFileItem(base + "/guide/", true); item->SetLabel("Guide"); item->SetLabelPreformated(true); items.Add(item); return true; } else if(url.GetFileName() == "channels/") return GetChannels(base, items); else if(url.GetFileName() == "channelsdb/") return GetChannelsDb(base, items); else if(url.GetFileName() == "recordings/") return GetRecordings(base, items); else if(url.GetFileName().Left(5) == "guide") return GetGuide(base, items); return false; }
// \brief Set window to a specific directory // \param strDirectory The directory to be displayed in list/thumb control // This function calls OnPrepareFileItems() and OnFinalizeFileItems() bool CGUIMediaWindow::Update(const CStdString &strDirectory) { // get selected item int iItem = m_viewControl.GetSelectedItem(); CStdString strSelectedItem = ""; if (iItem >= 0 && iItem < m_vecItems->Size()) { CFileItem* pItem = m_vecItems->Get(iItem); if (!pItem->IsParentFolder()) { GetDirectoryHistoryString(pItem, strSelectedItem); } } CStdString strOldDirectory = m_vecItems->m_strPath; m_history.SetSelectedItem(strSelectedItem, strOldDirectory); ClearFileItems(); m_vecItems->ClearProperties(); m_vecItems->SetThumbnailImage(""); if (!GetDirectory(strDirectory, *m_vecItems)) { CLog::Log(LOGERROR,"CGUIMediaWindow::GetDirectory(%s) failed", strDirectory.c_str()); // if the directory is the same as the old directory, then we'll return // false. Else, we assume we can get the previous directory if (strDirectory.Equals(strOldDirectory)) return false; // We assume, we can get the parent // directory again, but we have to // return false to be able to eg. show // an error message. CStdString strParentPath = m_history.GetParentPath(); m_history.RemoveParentPath(); Update(strParentPath); return false; } // if we're getting the root source listing // make sure the path history is clean if (strDirectory.IsEmpty()) m_history.ClearPathHistory(); int iWindow = GetID(); bool bOkay = (iWindow == WINDOW_MUSIC_FILES || iWindow == WINDOW_VIDEO_FILES || iWindow == WINDOW_FILES || iWindow == WINDOW_PICTURES || iWindow == WINDOW_PROGRAMS); if (strDirectory.IsEmpty() && bOkay && (m_vecItems->Size() == 0 || !m_guiState->DisableAddSourceButtons())) // add 'add source button' { CStdString strLabel = g_localizeStrings.Get(1026); CFileItem *pItem = new CFileItem(strLabel); pItem->m_strPath = "add"; pItem->SetThumbnailImage("DefaultAddSource.png"); pItem->SetLabel(strLabel); pItem->SetLabelPreformated(true); m_vecItems->Add(pItem); } m_iLastControl = GetFocusedControlID(); // Ask the derived class if it wants to load additional info // for the fileitems like media info or additional // filtering on the items, setting thumbs. OnPrepareFileItems(*m_vecItems); m_vecItems->FillInDefaultIcons(); m_guiState.reset(CGUIViewState::GetViewState(GetID(), *m_vecItems)); FormatAndSort(*m_vecItems); // Ask the devived class if it wants to do custom list operations, // eg. changing the label OnFinalizeFileItems(*m_vecItems); UpdateButtons(); m_viewControl.SetItems(*m_vecItems); strSelectedItem = m_history.GetSelectedItem(m_vecItems->m_strPath); bool bSelectedFound = false; //int iSongInDirectory = -1; for (int i = 0; i < m_vecItems->Size(); ++i) { CFileItem* pItem = m_vecItems->Get(i); // Update selected item if (!bSelectedFound) { CStdString strHistory; GetDirectoryHistoryString(pItem, strHistory); if (strHistory == strSelectedItem) { m_viewControl.SetSelectedItem(i); bSelectedFound = true; } } } // if we haven't found the selected item, select the first item if (!bSelectedFound) m_viewControl.SetSelectedItem(0); m_history.AddPath(m_vecItems->m_strPath); //m_history.DumpPathHistory(); return true; }
bool CCMythDirectory::GetGuide(const CStdString& base, CFileItemList &items) { CURL url(base); CStdString strPath = url.GetFileName(); std::vector<CStdString> tokens; CStdString Delimiter = "/"; CUtil::Tokenize(strPath, tokens, "/"); if (tokens.size() > 1) return GetGuideForChannel(base, atoi(tokens[1].c_str()), items); else { cmyth_database_t db = m_session->GetDatabase(); if(!db) return false; cmyth_chanlist_t list = m_dll->mysql_get_chanlist(db); if(!list) { CLog::Log(LOGERROR, "%s - unable to get list of channels with url %s", __FUNCTION__, base.c_str()); return false; } CURL url(base); int count = m_dll->chanlist_get_count(list); for(int i = 0; i < count; i++) { cmyth_channel_t channel = m_dll->chanlist_get_item(list, i); if(channel) { CStdString name, path, icon; if(!m_dll->channel_visible(channel)) { m_dll->ref_release(channel); continue; } int num = m_dll->channel_channum(channel); char* str; if((str = m_dll->channel_name(channel))) { name.Format("%d - %s", num, str); m_dll->ref_release(str); } else name.Format("%d"); icon = GetValue(m_dll->channel_icon(channel)); if(num <= 0) { CLog::Log(LOGDEBUG, "%s - Channel '%s' Icon '%s' - Skipped", __FUNCTION__, name.c_str(), icon.c_str()); } else { CLog::Log(LOGDEBUG, "%s - Channel '%s' Icon '%s'", __FUNCTION__, name.c_str(), icon.c_str()); path.Format("guide/%d/", num); url.SetFileName(path); url.GetURL(path); CFileItem *item = new CFileItem(path, true); item->SetLabel(name); item->SetLabelPreformated(true); if(icon.length() > 0) { url.SetFileName("files/channels/" + CUtil::GetFileName(icon)); url.GetURL(icon); item->SetThumbnailImage(icon); } items.Add(item); } m_dll->ref_release(channel); } } m_dll->ref_release(list); return true; } }
bool CCMythDirectory::GetGuideForChannel(const CStdString& base, int ChanNum, CFileItemList &items) { cmyth_database_t db = m_session->GetDatabase(); if(!db) { CLog::Log(LOGERROR, "%s - Could not get database", __FUNCTION__); return false; } time_t now; time(&now); // this sets how many seconds of EPG from now we should grabb time_t end = now + (1 * 24 * 60 * 60); cmyth_program_t *prog = NULL; int count = m_dll->mysql_get_guide(db, &prog, now, end); CLog::Log(LOGDEBUG, "%s - %i entries of guide data", __FUNCTION__, count); if (count <= 0) return false; for (int i = 0; i < count; i++) { if (prog[i].channum == ChanNum) { CStdString path; path.Format("%s%s", base.c_str(), prog[i].title); CDateTime starttime(prog[i].starttime); CDateTime endtime(prog[i].endtime); CStdString title; title.Format("%s - \"%s\"", starttime.GetAsLocalizedDateTime(), prog[i].title); CFileItem *item = new CFileItem(title, false); item->SetLabel(title); item->m_dateTime = starttime; item->SetLabelPreformated(true); CVideoInfoTag* tag = item->GetVideoInfoTag(); tag->m_strAlbum = GetValue(prog[i].callsign); tag->m_strShowTitle = GetValue(prog[i].title); tag->m_strPlotOutline = GetValue(prog[i].subtitle); tag->m_strPlot = GetValue(prog[i].description); tag->m_strGenre = GetValue(prog[i].category); if(tag->m_strPlot.Left(tag->m_strPlotOutline.length()) != tag->m_strPlotOutline && !tag->m_strPlotOutline.IsEmpty()) tag->m_strPlot = tag->m_strPlotOutline + '\n' + tag->m_strPlot; tag->m_strOriginalTitle = tag->m_strShowTitle; tag->m_strTitle = tag->m_strAlbum; if(tag->m_strShowTitle.length() > 0) tag->m_strTitle += " : " + tag->m_strShowTitle; CDateTimeSpan span(endtime.GetDay() - starttime.GetDay(), endtime.GetHour() - starttime.GetHour(), endtime.GetMinute() - starttime.GetMinute(), endtime.GetSecond() - starttime.GetSecond()); StringUtils::SecondsToTimeString( span.GetSeconds() + span.GetMinutes() * 60 + span.GetHours() * 3600, tag->m_strRuntime, TIME_FORMAT_GUESS); tag->m_iSeason = 0; /* set this so xbmc knows it's a tv show */ tag->m_iEpisode = 0; tag->m_strStatus = prog[i].rec_status; items.Add(item); } } m_dll->ref_release(prog); return true; }