Exemplo n.º 1
0
bool CAddonsDirectory::GetScriptsAndPlugins(const CStdString &content, CFileItemList &items)
{
  items.Clear();

  VECADDONS addons;
  if (!GetScriptsAndPlugins(content, addons))
    return false;

  for (unsigned i=0; i<addons.size(); i++)
  {
    CFileItemPtr item(FileItemFromAddon(addons[i], 
                      addons[i]->Type()==ADDON_PLUGIN?"plugin://":"script://",
                      addons[i]->Type() == ADDON_PLUGIN));
    PluginPtr plugin = boost::dynamic_pointer_cast<CPluginSource>(addons[i]);
    if (plugin->ProvidesSeveral())
    {
      CURL url = item->GetAsUrl();
      CStdString opt;
      opt.Format("?content_type=%s",content.c_str());
      url.SetOptions(opt);
      item->SetPath(url.Get());
    }
    items.Add(item);
  }

  items.Add(GetMoreItem(content));

  items.SetContent("addons");
  items.SetLabel(g_localizeStrings.Get(24001)); // Add-ons

  return items.Size() > 0;
}
Exemplo n.º 2
0
 bool CStackDirectory::GetDirectory(const CStdString& strPath, CFileItemList& items)
 {
   items.Clear();
   // format is:
   // stack://file1 , file2 , file3 , file4
   // filenames with commas are double escaped (ie replaced with ,,), thus the " , " separator used.
   //CStdString folder, file;
   //URIUtils::Split(strPath, folder, file);
   // split files on the single comma
   CStdStringArray files;
   StringUtils::SplitString(strPath, " , ", files);
   if (files.empty())
     return false;   // error in path
   // remove "stack://" from the folder
   for (unsigned int i = 0; i < files.size(); i++)
   {
     CStdString file = files[i];
     if (i == 0)
       file = file.Mid(8);
     // replace double comma's with single ones.
     file.Replace(",,", ",");
     CFileItemPtr item(new CFileItem(file));
     //URIUtils::AddFileToFolder(folder, file, item->m_strPath);
     item->m_strPath = file;
     item->m_bIsFolder = false;
     items.Add(item);
   }
   return true;
 }
Exemplo n.º 3
0
void CGUIWindowPVRSearch::OnPrepareFileItems(CFileItemList &items)
{
  items.Clear();

  CFileItemPtr item(new CFileItem("pvr://guide/searchresults/search/", true));
  item->SetLabel(g_localizeStrings.Get(19140));
  item->SetLabelPreformated(true);
  item->SetSpecialSort(SortSpecialOnTop);
  items.Add(item);

  if (m_bSearchConfirmed)
  {
    CGUIDialogProgress* dlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
    if (dlgProgress)
    {
      dlgProgress->SetHeading(194);
      dlgProgress->SetText(CVariant(m_searchfilter.m_strSearchTerm));
      dlgProgress->StartModal();
      dlgProgress->Progress();
    }

    // TODO should we limit the find similar search to the selected group?
    g_EpgContainer.GetEPGSearch(items, m_searchfilter);

    if (dlgProgress)
      dlgProgress->Close();

    if (items.IsEmpty())
    {
      CGUIDialogOK::ShowAndGetInput(194, 284, 0, 0);
      m_bSearchConfirmed = false;
    }
  }
}
Exemplo n.º 4
0
//  Get the child fileitems of this node
bool CDirectoryNode::GetChilds(CFileItemList& items)
{
  if (CanCache() && items.Load())
    return true;

  auto_ptr<CDirectoryNode> pNode(CDirectoryNode::CreateNode(GetChildType(), "", this));

  bool bSuccess=false;
  if (pNode.get())
  {
    pNode->m_options = m_options;
    bSuccess=pNode->GetContent(items);
    if (bSuccess)
    {
      AddQueuingFolder(items);
      if (CanCache())
        items.SetCacheToDisc(CFileItemList::CACHE_ALWAYS);
    }
    else
      items.Clear();

    pNode->RemoveParent();
  }

  return bSuccess;
}
bool CGUIWindowMusicPlaylistEditor::GetDirectory(const std::string &strDirectory, CFileItemList &items)
{
  items.Clear();
  if (strDirectory.empty())
  { // root listing - list files:// and musicdb://
    CFileItemPtr files(new CFileItem("files://", true));
    files->SetLabel(g_localizeStrings.Get(744));
    files->SetLabelPreformated(true);
    files->m_bIsShareOrDrive = true;
    items.Add(files);
    CFileItemPtr db(new CFileItem("musicdb://", true));
    db->SetLabel(g_localizeStrings.Get(14022));
    db->SetLabelPreformated(true);
    db->m_bIsShareOrDrive = true;
    items.SetPath("");
    items.Add(db);
    return true;
  }

  if (!CGUIWindowMusicBase::GetDirectory(strDirectory, items))
    return false;

  // check for .CUE files here.
  items.FilterCueItems();

  return true;
}
Exemplo n.º 6
0
bool CTextureCleanupJob::DoWork()
{
  CTextureDatabase db;
  if (db.Open())
  {
    std::string path;
    std::string fn;
    std::string prevPath = "";
    std::vector<std::string> pathContent;

    XFILE::CSpecialProtocolDirectory thumbDir;
    CFileItemList files;
    int fileIdx = 0;
    int totFileDel = 0;
    int totDbDel = 0;

    auto deleteFile = [&]()
    {
      std::string todel = files.Get(fileIdx)->GetPath();
      CLog::Log(LOGDEBUG, "CTextureCleanupJob: deleting %s", todel.c_str());
      XFILE::CFile::Delete(todel);
      totFileDel++;
      fileIdx++;
    };

    std::vector<std::pair<int, std::string>> urls = db.GetCachedTextureUrls();
    for (const auto &url : urls)
    {
      std::string cachedurl = url.second;
      URIUtils::Split(cachedurl, path, fn);
      std::string cmpurl = "special://thumbnails/" + cachedurl;
      if (path != prevPath)
      {
        while (fileIdx < files.Size())
          deleteFile();
        files.Clear();
        thumbDir.GetDirectory(CURL("special://thumbnails/" + path), files);
        files.Sort(SortByPath, SortOrderAscending);
        prevPath = path;
        fileIdx = 0;
      }
      while (fileIdx < files.Size() && files.Get(fileIdx)->GetPath() < cmpurl)
        deleteFile();
      if (fileIdx < files.Size() && files.Get(fileIdx)->GetPath() == cmpurl)
        fileIdx++;
      else
      {
        // No file for current entry; delete it
        CLog::Log(LOGDEBUG, "CTextureCleanupJob: deleting from Db: %d / %s", url.first, cachedurl.c_str());
        db.ClearCachedTexture(url.first, cachedurl);
        totDbDel++;
      }
    }
    while (fileIdx < files.Size())
      deleteFile();
    CLog::Log(LOGDEBUG, "CTextureCleanupJob: %d thumbnails deleted / %d db entries removed", totFileDel, totDbDel);
  }
  return true;
}
Exemplo n.º 7
0
bool CFavouritesDirectory::GetDirectory(const CURL& url, CFileItemList &items)
{
  items.Clear();
  if (url.IsProtocol("favourites"))
  {
    return Load(items); //load the default favourite files
  }
  return LoadFavourites(url.Get(), items); //directly load the given file
}
Exemplo n.º 8
0
void CDirectoryCache::InitCache(set<CStdString>& dirs)
{
  set<CStdString>::iterator it;
  for (it = dirs.begin(); it != dirs.end(); ++it)
  {
    const CStdString& strDir = *it;
    CFileItemList items;
    CDirectory::GetDirectory(strDir, items, "", DIR_FLAG_NO_FILE_DIRS);
    items.Clear();
  }
}
Exemplo n.º 9
0
bool CFavouritesDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
{
  items.Clear();
  CURL url(strPath);
  
  if (url.GetProtocol() == "favourites")
  {
    Load(items); //load the default favourite files
  }
  return LoadFavourites(strPath, items); //directly load the given file
}
Exemplo n.º 10
0
bool CWinLibraryDirectory::GetDirectory(const CURL &url, CFileItemList &items)
{
  items.Clear();

  auto folder = GetFolder(url);
  if (!folder)
    return false;

  // We accept win-lib://library/path[/]
  std::string path = url.Get();
  URIUtils::AddSlashAtEnd(path); //be sure the dir ends with a slash

  auto vectorView = Wait(folder->GetItemsAsync());
  for (unsigned i = 0; i < vectorView->Size; i++)
  {
    IStorageItem^ item = vectorView->GetAt(i);
    std::string itemName = FromW(std::wstring(item->Name->Data()));

    CFileItemPtr pItem(new CFileItem(itemName));
    pItem->m_bIsFolder = (item->Attributes & FileAttributes::Directory) == FileAttributes::Directory;
    IStorageItemProperties^ storageItemProperties = dynamic_cast<IStorageItemProperties^>(item);
    if (item != nullptr)
    {
      pItem->m_strTitle = FromW(storageItemProperties->DisplayName->Data());
    }

    if (pItem->m_bIsFolder)
      pItem->SetPath(path + itemName + "/");
    else
      pItem->SetPath(path + itemName);

    if (itemName.front() == '.')
      pItem->SetProperty("file:hidden", true);

    auto props = Wait(item->GetBasicPropertiesAsync());

    ULARGE_INTEGER ularge = { 0 };
    if (props->DateModified.UniversalTime > 0)
      ularge.QuadPart = static_cast<uint64_t>(props->DateModified.UniversalTime);

    FILETIME localTime = 
    { 
      ularge.LowPart, 
      ularge.HighPart 
    };
    pItem->m_dateTime = localTime;
    if (!pItem->m_bIsFolder)
      pItem->m_dwSize = static_cast<int64_t>(props->Size);

    items.Add(pItem);
  }

  return true;
}
Exemplo n.º 11
0
  bool GetDirectory(CFileItemList& list)
  {
    /* if it was not finished or failed, return failure */
    if(!m_result->m_event.WaitMSec(0) || !m_result->m_result)
    {
      list.Clear();
      return false;
    }

    list.Copy(m_result->m_list);
    return true;
  }
Exemplo n.º 12
0
void CAddonInstaller::PrunePackageCache()
{
  std::map<std::string,CFileItemList*> packs;
  int64_t size = EnumeratePackageFolder(packs);
  int64_t limit = (int64_t)g_advancedSettings.m_addonPackageFolderSize * 1024 * 1024;
  if (size < limit)
    return;

  // Prune packages
  // 1. Remove the largest packages, leaving at least 2 for each add-on
  CFileItemList items;
  CAddonDatabase db;
  db.Open();
  for (std::map<std::string,CFileItemList*>::const_iterator it = packs.begin(); it != packs.end(); ++it)
  {
    it->second->Sort(SortByLabel, SortOrderDescending);
    for (int j = 2; j < it->second->Size(); j++)
      items.Add(CFileItemPtr(new CFileItem(*it->second->Get(j))));
  }

  items.Sort(SortBySize, SortOrderDescending);
  int i = 0;
  while (size > limit && i < items.Size())
  {
    size -= items[i]->m_dwSize;
    db.RemovePackage(items[i]->GetPath());
    CFileUtils::DeleteItem(items[i++], true);
  }

  if (size > limit)
  {
    // 2. Remove the oldest packages (leaving least 1 for each add-on)
    items.Clear();
    for (std::map<std::string,CFileItemList*>::iterator it = packs.begin(); it != packs.end(); ++it)
    {
      if (it->second->Size() > 1)
        items.Add(CFileItemPtr(new CFileItem(*it->second->Get(1))));
    }

    items.Sort(SortByDate, SortOrderAscending);
    i = 0;
    while (size > limit && i < items.Size())
    {
      size -= items[i]->m_dwSize;
      db.RemovePackage(items[i]->GetPath());
      CFileUtils::DeleteItem(items[i++],true);
    }
  }

  // clean up our mess
  for (std::map<std::string,CFileItemList*>::iterator it = packs.begin(); it != packs.end(); ++it)
    delete it->second;
}
Exemplo n.º 13
0
bool CGUIDialogSimpleMenu::ShowPlaySelection(CFileItem& item, const std::string& directory)
{

  CFileItemList items;

  if (!XFILE::CDirectory::GetDirectory(directory, items, XFILE::CDirectory::CHints(), true))
  {
    CLog::Log(LOGERROR, "CGUIWindowVideoBase::ShowPlaySelection - Failed to get play directory for %s", directory.c_str());
    return true;
  }

  if (items.IsEmpty())
  {
    CLog::Log(LOGERROR, "CGUIWindowVideoBase::ShowPlaySelection - Failed to get any items %s", directory.c_str());
    return true;
  }

  CGUIDialogSelect* dialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
  while (true)
  {
    dialog->Reset();
    dialog->SetHeading(CVariant{25006}); // Select playback item
    dialog->SetItems(items);
    dialog->SetUseDetails(true);
    dialog->Open();

    CFileItemPtr item_new = dialog->GetSelectedItem();
    if (!item_new || dialog->GetSelectedLabel() < 0)
    {
      CLog::Log(LOGDEBUG, "CGUIWindowVideoBase::ShowPlaySelection - User aborted %s", directory.c_str());
      break;
    }

    if (item_new->m_bIsFolder == false)
    {
      std::string original_path = item.GetPath();
      item.Reset();
      item = *item_new;
      item.SetProperty("original_listitem_url", original_path);
      return true;
    }

    items.Clear();
    if (!XFILE::CDirectory::GetDirectory(item_new->GetPath(), items, XFILE::CDirectory::CHints(), true) || items.IsEmpty())
    {
      CLog::Log(LOGERROR, "CGUIWindowVideoBase::ShowPlaySelection - Failed to get any items %s", item_new->GetPath().c_str());
      break;
    }
  }

  return false;
}
Exemplo n.º 14
0
void CGUIWindowPVRGuide::GetViewChannelItems(CFileItemList &items)
{
  CPVRChannelPtr currentChannel(g_PVRManager.GetCurrentChannel());
  items.Clear();
  if (!currentChannel || g_PVRManager.GetCurrentEpg(items) == 0)
  {
    CFileItemPtr item;
    item.reset(new CFileItem("pvr://guide/channel/empty.epg", false));
    item->SetLabel(g_localizeStrings.Get(19028));
    item->SetLabelPreformated(true);
    items.Add(item);
  }
}
Exemplo n.º 15
0
void CGUIWindowPVRGuide::GetViewNextItems(CFileItemList &items)
{
  items.Clear();
  int iEpgItems = GetChannelGroup()->GetEPGNext(items);

  if (iEpgItems)
  {
    CFileItemPtr item;
    item.reset(new CFileItem("pvr://guide/next/empty.epg", false));
    item->SetLabel(g_localizeStrings.Get(19028));
    item->SetLabelPreformated(true);
    items.Add(item);
  }
}
Exemplo n.º 16
0
TEST(TestFileOperationJob, ActionDelete)
{
    XFILE::CFile *tmpfile;
    CStdString tmpfilepath, destpath, destfile;
    CFileItemList items;
    CFileOperationJob job;

    ASSERT_TRUE((tmpfile = XBMC_CREATETEMPFILE("")));
    tmpfilepath = XBMC_TEMPFILEPATH(tmpfile);
    tmpfile->Close();

    CFileItemPtr item(new CFileItem(tmpfilepath));
    item->SetPath(tmpfilepath);
    item->m_bIsFolder = false;
    item->Select(true);
    items.Add(item);

    URIUtils::GetDirectory(tmpfilepath, destpath);
    destpath = URIUtils::AddFileToFolder(destpath, "delete");
    destfile = URIUtils::AddFileToFolder(destpath, URIUtils::GetFileName(tmpfilepath));
    ASSERT_FALSE(XFILE::CFile::Exists(destfile));

    job.SetFileOperation(CFileOperationJob::ActionCopy, items, destpath);
    EXPECT_EQ(CFileOperationJob::ActionCopy, job.GetAction());

    EXPECT_TRUE(job.DoWork());
    EXPECT_TRUE(XFILE::CFile::Exists(tmpfilepath));
    EXPECT_TRUE(XFILE::CFile::Exists(destfile));

    job.SetFileOperation(CFileOperationJob::ActionDelete, items, "");
    EXPECT_EQ(CFileOperationJob::ActionDelete, job.GetAction());

    EXPECT_TRUE(job.DoWork());
    EXPECT_FALSE(XFILE::CFile::Exists(tmpfilepath));

    items.Clear();
    CFileItemPtr item2(new CFileItem(destfile));
    item2->SetPath(destfile);
    item2->m_bIsFolder = false;
    item2->Select(true);
    items.Add(item2);

    job.SetFileOperation(CFileOperationJob::ActionDelete, items, "");
    EXPECT_EQ(CFileOperationJob::ActionDelete, job.GetAction());

    EXPECT_TRUE(job.DoWork());
    EXPECT_FALSE(XFILE::CFile::Exists(destfile));
    EXPECT_TRUE(XFILE::CDirectory::Remove(destpath));
}
Exemplo n.º 17
0
void CGUIWindowPVRGuide::GetViewTimelineItems(CFileItemList &items)
{
  CGUIEPGGridContainer* epgGridContainer = dynamic_cast<CGUIEPGGridContainer*>(GetControl(m_viewControl.GetCurrentControl()));
  if (!epgGridContainer)
    return;

  CPVRChannelGroupPtr group;
  {
    CSingleLock lock(m_critSection);

    // group change detected reset grid coordinates and refresh grid items
    if (!m_bRefreshTimelineItems && *m_cachedChannelGroup != *GetGroup())
    {
      epgGridContainer->ResetCoordinates();
      m_bRefreshTimelineItems = true;
      RefreshTimelineItems();
    }

    if (m_newTimeline != nullptr)
    {
      m_cachedTimeline = m_newTimeline;
      m_newTimeline.reset();
    }

    items.Clear();
    items.RemoveDiscCache(GetID());
    items.Assign(*m_cachedTimeline, false);

    group = m_cachedChannelGroup;
  }

  CDateTime startDate(group->GetFirstEPGDate());
  CDateTime endDate(group->GetLastEPGDate());
  CDateTime currentDate = CDateTime::GetCurrentDateTime().GetAsUTCDateTime();

  if (!startDate.IsValid())
    startDate = currentDate;

  if (!endDate.IsValid() || endDate < startDate)
    endDate = startDate;

  // limit start to linger time
  CDateTime maxPastDate = currentDate - CDateTimeSpan(0, 0, g_advancedSettings.m_iEpgLingerTime, 0);
  if (startDate < maxPastDate)
    startDate = maxPastDate;

  epgGridContainer->SetStartEnd(startDate, endDate);
}
Exemplo n.º 18
0
  bool CStackDirectory::GetDirectory(const CURL& url, CFileItemList& items)
  {
    items.Clear();
    vector<std::string> files;
    const std::string pathToUrl(url.Get());
    if (!GetPaths(pathToUrl, files))
      return false;   // error in path

    for (vector<std::string>::const_iterator i = files.begin(); i != files.end(); ++i)
    {
      CFileItemPtr item(new CFileItem(*i));
      item->SetPath(*i);
      item->m_bIsFolder = false;
      items.Add(item);
    }
    return true;
  }
Exemplo n.º 19
0
TEST(TestFileOperationJob, ActionDelete)
{
  XFILE::CFile *tmpfile;
  CStdString tmpfilepath, destpath;
  CFileItemList items;
  CFileOperationJob job;

  ASSERT_TRUE((tmpfile = XBMC_CREATETEMPFILE("")));
  tmpfilepath = XBMC_TEMPFILEPATH(tmpfile);

  CFileItemPtr item(new CFileItem(tmpfilepath));
  item->SetPath(tmpfilepath);
  item->m_bIsFolder = false;
  item->Select(true);
  items.Add(item);

  destpath = tmpfilepath;
  destpath += ".delete";
  ASSERT_FALSE(XFILE::CFile::Exists(destpath));

  job.SetFileOperation(CFileOperationJob::ActionCopy, items, destpath);
  EXPECT_EQ(CFileOperationJob::ActionCopy, job.GetAction());

  EXPECT_TRUE(job.DoWork());
  EXPECT_TRUE(XFILE::CFile::Exists(tmpfilepath));
  EXPECT_TRUE(XFILE::CFile::Exists(destpath));

  job.SetFileOperation(CFileOperationJob::ActionDelete, items, "");
  EXPECT_EQ(CFileOperationJob::ActionDelete, job.GetAction());

  EXPECT_TRUE(job.DoWork());
  EXPECT_FALSE(XFILE::CFile::Exists(tmpfilepath));

  items.Clear();
  CFileItemPtr item2(new CFileItem(destpath));
  item->SetPath(destpath);
  item->m_bIsFolder = false;
  item->Select(true);
  items.Add(item2);

  job.SetFileOperation(CFileOperationJob::ActionDelete, items, "");
  EXPECT_EQ(CFileOperationJob::ActionDelete, job.GetAction());

  EXPECT_TRUE(job.DoWork());
  EXPECT_FALSE(XFILE::CFile::Exists(destpath));
}
Exemplo n.º 20
0
  bool CStackDirectory::GetDirectory(const CStdString& strPath, CFileItemList& items)
  {
    items.Clear();
    CStdStringArray files;
    if (!GetPaths(strPath, files))
      return false;   // error in path

    for (unsigned int i = 0; i < files.size(); i++)
    {
      CStdString file = files[i];
      CFileItemPtr item(new CFileItem(file));
      item->SetPath(file);
      item->m_bIsFolder = false;
      items.Add(item);
    }
    return true;
  }
Exemplo n.º 21
0
bool CWinLibraryDirectory::GetDirectory(const CURL& url, CFileItemList& items)
{
  items.Clear();

  auto folder = GetFolder(url);
  if (!folder)
    return false;

  // We accept win-lib://library/path[/]
  std::string path = url.Get();
  URIUtils::AddSlashAtEnd(path); //be sure the dir ends with a slash

  auto vectorView = Wait(folder.GetItemsAsync());
  for (unsigned i = 0; i < vectorView.Size(); i++)
  {
    IStorageItem item = vectorView.GetAt(i);
    std::string itemName = FromW(item.Name().c_str());

    CFileItemPtr pItem(new CFileItem(itemName));
    pItem->m_bIsFolder =
        (item.Attributes() & FileAttributes::Directory) == FileAttributes::Directory;
    IStorageItemProperties storageItemProperties = item.as<IStorageItemProperties>();
    if (item != nullptr)
    {
      pItem->m_strTitle = FromW(storageItemProperties.DisplayName().c_str());
    }

    if (pItem->m_bIsFolder)
      pItem->SetPath(path + itemName + "/");
    else
      pItem->SetPath(path + itemName);

    if (itemName.front() == '.')
      pItem->SetProperty("file:hidden", true);

    auto props = Wait(item.GetBasicPropertiesAsync());

    pItem->m_dateTime = winrt::clock::to_FILETIME(props.DateModified());
    if (!pItem->m_bIsFolder)
      pItem->m_dwSize = static_cast<int64_t>(props.Size());

    items.Add(pItem);
  }

  return true;
}
Exemplo n.º 22
0
void CGUIWindowPVRGuide::GetViewNextItems(CFileItemList &items)
{
    SET_CONTROL_LABEL(CONTROL_LABEL_HEADER1, g_localizeStrings.Get(19031));
    SET_CONTROL_LABEL(CONTROL_LABEL_HEADER2, GetGroup()->GroupName());

    items.Clear();
    int iEpgItems = GetGroup()->GetEPGNext(items);

    if (iEpgItems)
    {
        CFileItemPtr item;
        item.reset(new CFileItem("pvr://guide/next/empty.epg", false));
        item->SetLabel(g_localizeStrings.Get(19028));
        item->SetLabelPreformated(true);
        items.Add(item);
    }
}
Exemplo n.º 23
0
bool CFavouritesDirectory::Load(CFileItemList &items)
{
  items.Clear();
  std::string favourites;

  favourites = "special://xbmc/system/favourites.xml";
  if(XFILE::CFile::Exists(favourites))
    CFavouritesDirectory::LoadFavourites(favourites, items);
  else
    CLog::Log(LOGDEBUG, "CFavourites::Load - no system favourites found, skipping");
  favourites = URIUtils::AddFileToFolder(CProfilesManager::GetInstance().GetProfileUserDataFolder(), "favourites.xml");
  if(XFILE::CFile::Exists(favourites))
    CFavouritesDirectory::LoadFavourites(favourites, items);
  else
    CLog::Log(LOGDEBUG, "CFavourites::Load - no userdata favourites found, skipping");

  return true;
}
Exemplo n.º 24
0
void CGUIWindowPVRGuide::GetViewChannelItems(CFileItemList &items)
{
    CPVRChannelPtr currentChannel(g_PVRManager.GetCurrentChannel());

    if (currentChannel)
        SET_CONTROL_LABEL(CONTROL_LABEL_HEADER1, currentChannel->ChannelName().c_str());
    SET_CONTROL_LABEL(CONTROL_LABEL_HEADER2, GetGroup()->GroupName());

    items.Clear();
    if (!currentChannel || g_PVRManager.GetCurrentEpg(items) == 0)
    {
        CFileItemPtr item;
        item.reset(new CFileItem("pvr://guide/channel/empty.epg", false));
        item->SetLabel(g_localizeStrings.Get(19028));
        item->SetLabelPreformated(true);
        items.Add(item);
    }
}
Exemplo n.º 25
0
bool CFavourites::Load(CFileItemList &items)
{
  items.Clear();
  CStdString favourites;

  favourites = "special://xbmc/system/favourites.xml";
  if(XFILE::CFile::Exists(favourites))
    CFavourites::LoadFavourites(favourites, items);
  else
    CLog::Log(LOGDEBUG, "CFavourites::Load - no system favourites found, skipping");
  URIUtils::AddFileToFolder(g_settings.GetProfileUserDataFolder(), "favourites.xml", favourites);
  if(XFILE::CFile::Exists(favourites))
    CFavourites::LoadFavourites(favourites, items);
  else
    CLog::Log(LOGDEBUG, "CFavourites::Load - no userdata favourites found, skipping");

  return true;
}
Exemplo n.º 26
0
bool CVirtualDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items, bool bUseFileDirectories)
{
  if (!strPath.IsEmpty() && strPath != "files://")
    return CDirectory::GetDirectory(strPath, items, m_strFileMask, bUseFileDirectories, m_allowPrompting, m_cacheDirectory, m_extFileInfo, m_allowThreads);

  // if strPath is blank, clear the list (to avoid parent items showing up)
  if (strPath.IsEmpty())
    items.Clear();

  // return the root listing
  items.SetPath(strPath);

  // grab our shares
  VECSOURCES shares;
  GetSources(shares);
  CSourcesDirectory dir;
  return dir.GetDirectory(shares, items);
}
Exemplo n.º 27
0
bool CDirectoryNodeSeasons::GetContent(CFileItemList& items) const
{
  CVideoDatabase videodatabase;
  if (!videodatabase.Open())
    return false;

  CQueryParams params;
  CollectQueryParams(params);

  int iFlatten = CSettings::Get().GetInt("videolibrary.flattentvshows");
  bool bSuccess=videodatabase.GetSeasonsNav(BuildPath(), items, params.GetActorId(), params.GetDirectorId(), params.GetGenreId(), params.GetYear(), params.GetTvShowId());
  bool bFlatten = (items.GetObjectCount() == 1 && iFlatten == 1) || iFlatten == 2;
  if (items.GetObjectCount() == 2 && iFlatten == 1)
    if (items[0]->GetVideoInfoTag()->m_iSeason == 0 || items[1]->GetVideoInfoTag()->m_iSeason == 0)
      bFlatten = true; // flatten if one season + specials

  if (iFlatten > 0 && !bFlatten && CMediaSettings::Get().GetWatchedMode("tvshows") == WatchedModeUnwatched)
  {
    int count = 0;
    for(int i = 0; i < items.Size(); i++) 
    {
      if (items[i]->GetProperty("unwatchedepisodes").asInteger() != 0 && items[i]->GetVideoInfoTag()->m_iSeason != 0)
        count++;
    }
    bFlatten = (count < 2); // flatten if there is only 1 unwatched season (not counting specials)
  }

  if (bFlatten)
  { // flatten if one season or flatten always
    items.Clear();

    CVideoDbUrl videoUrl;
    if (!videoUrl.FromString(BuildPath()))
      return false;
  
    videoUrl.AppendPath("-2/");
    bSuccess=videodatabase.GetEpisodesNav(videoUrl.ToString(), items, params.GetGenreId(), params.GetYear(), params.GetActorId(), params.GetDirectorId(), params.GetTvShowId());
    items.SetPath(videoUrl.ToString());
  }

  videodatabase.Close();

  return bSuccess;
}
Exemplo n.º 28
0
/*!
  \brief Overwrite to fill fileitems from a source
  \param strDirectory Path to read
  \param items Fill with items specified in \e strDirectory
  */
bool CGUIMediaWindow::GetDirectory(const CStdString &strDirectory, CFileItemList &items)
{
  // cleanup items
  if (items.Size())
    items.Clear();

  CStdString strParentPath=m_history.GetParentPath();

  CLog::Log(LOGDEBUG,"CGUIMediaWindow::GetDirectory (%s)", strDirectory.c_str());
  CLog::Log(LOGDEBUG,"  ParentPath = [%s]", strParentPath.c_str());

  if (m_guiState.get() && !m_guiState->HideParentDirItems())
  {
    CFileItem *pItem = new CFileItem("..");
    pItem->m_strPath = strParentPath;
    pItem->m_bIsFolder = true;
    pItem->m_bIsShareOrDrive = false;
    items.Add(pItem);
  }

  // see if we can load a previously cached folder
  CFileItemList cachedItems(strDirectory);
  if (!strDirectory.IsEmpty() && cachedItems.Load())
  {
    items.AssignPointer(cachedItems, true); // true to keep any previous items (".." item)
    cachedItems.ClearKeepPointer();
  }
  else
  {
    DWORD time = timeGetTime();

    if (!m_rootDir.GetDirectory(strDirectory, items))
      return false;

    // took over a second, and not normally cached, so cache it
    if (time + 1000 < timeGetTime() && !items.GetCacheToDisc())
      items.Save();

    // if these items should replace the current listing, then pop it off the top
    if (items.GetReplaceListing())
      m_history.RemoveParentPath();
  }
  return true;
}
Exemplo n.º 29
0
void CGUIWindowPVRGuide::GetViewTimelineItems(CFileItemList &items)
{
    CGUIEPGGridContainer* epgGridContainer = (CGUIEPGGridContainer*) GetControl(m_viewControl.GetCurrentControl());
    if (!epgGridContainer)
        return;

    CPVRChannelGroupPtr group = GetGroup();

    if (m_bUpdateRequired || m_cachedTimeline->IsEmpty() || *m_cachedChannelGroup != *group)
    {
        m_bUpdateRequired = false;

        m_cachedTimeline->Clear();
        m_cachedChannelGroup = group;
        m_cachedChannelGroup->GetEPGAll(*m_cachedTimeline);
    }

    items.Clear();
    items.RemoveDiscCache(GetID());
    items.Assign(*m_cachedTimeline, false);

    CDateTime startDate(m_cachedChannelGroup->GetFirstEPGDate());
    CDateTime endDate(m_cachedChannelGroup->GetLastEPGDate());
    CDateTime currentDate = CDateTime::GetCurrentDateTime().GetAsUTCDateTime();

    if (!startDate.IsValid())
        startDate = currentDate;

    if (!endDate.IsValid() || endDate < startDate)
        endDate = startDate;

    // limit start to linger time
    CDateTime maxPastDate = currentDate - CDateTimeSpan(0, 0, g_advancedSettings.m_iEpgLingerTime, 0);
    if (startDate < maxPastDate)
        startDate = maxPastDate;

    epgGridContainer->SetStartEnd(startDate, endDate);

    SET_CONTROL_LABEL(CONTROL_LABEL_HEADER1, g_localizeStrings.Get(19032));
    SET_CONTROL_LABEL(CONTROL_LABEL_HEADER2, GetGroup()->GroupName());

    epgGridContainer->SetChannel(GetSelectedItemPath(m_bRadio));
}
Exemplo n.º 30
0
static bool
ScanUPnPShares(CFileItemList &items)
{
  bool bMounted = false;
  CStdString strDevicesFile = CStdString(UPNP_MNT) + "/devices";

  bMounted = CUtil::IsMountpoint(UPNP_MNT) && CFile::Exists(strDevicesFile);

  if(!bMounted)
  {
    CLog::Log(LOGERROR, "CUPnPAvDirectory:%s - UPnP mountpoint doesnt exist", __func__);
    return false;
  }

  CFile fDevices;
  char szDevice[1024] = {0};


  if (!fDevices.Open(strDevicesFile))
  {
    CLog::Log(LOGERROR, "CUPnPAvDirectory:%s - Failed to open [%s]", __func__, strDevicesFile.c_str());
    return false;
  }

  items.Clear();

  while(fDevices.ReadString(szDevice, sizeof(szDevice)))
  {
    CFileItemPtr pItem(new CFileItem(szDevice));
    CStdString strDevice = szDevice;

    CUtil::URLEncode(strDevice);

    pItem->m_bIsFolder = true;
    pItem->m_strPath.Format("upnp://%s", strDevice);

    items.Add(pItem);
  }

  fDevices.Close();

  return items.Size() != 0;
}