Ejemplo n.º 1
0
void CGUIDialogSubtitles::Process(unsigned int currentTime, CDirtyRegionList &dirtyregions)
{
  if (m_bInvalidated)
  {
    // take copies of our variables to ensure we don't hold the lock for long.
    std::string status;
    CFileItemList subs;
    {
      CSingleLock lock(m_section);
      status = m_status;
      subs.Assign(*m_subtitles);
    }
    SET_CONTROL_LABEL(CONTROL_SUBSTATUS, status);

    if (m_updateSubsList)
    {
      CGUIMessage message(GUI_MSG_LABEL_BIND, GetID(), CONTROL_SUBLIST, 0, 0, &subs);
      OnMessage(message);
      m_updateSubsList = false;
    }

    if (!m_subtitles->IsEmpty() && !GetFocusedControl())
    { // set focus to the list
      CGUIMessage msg(GUI_MSG_SETFOCUS, GetID(), CONTROL_SUBLIST);
      OnMessage(msg);
    }
  }
  CGUIDialog::Process(currentTime, dirtyregions);
}
Ejemplo n.º 2
0
bool CGUIWindowPVRGuideBase::GetDirectory(const std::string &strDirectory, CFileItemList &items)
{
  bool bRefreshTimelineItems = false;

  {
    CSingleLock lock(m_critSection);

    if (m_cachedChannelGroup && *m_cachedChannelGroup != *GetChannelGroup())
    {
      // channel group change and not very first open of this window. force immediate update.
      m_bRefreshTimelineItems = true;
      bRefreshTimelineItems = true;
    }
  }

  // never call DoRefresh with locked mutex!
  if (bRefreshTimelineItems)
    m_refreshTimelineItemsThread->DoRefresh();

  {
    CSingleLock lock(m_critSection);

    // Note: no need to do anything if no new data available. items always contains previous data.
    if (m_newTimeline)
    {
      items.RemoveDiscCache(GetID());
      items.Assign(*m_newTimeline, false);
      m_newTimeline.reset();
    }
  }

  return true;
}
Ejemplo n.º 3
0
bool CPluginDirectory::GetDirectory(const CURL& url, CFileItemList& items)
{
  const std::string pathToUrl(url.Get());
  bool success = StartScript(pathToUrl, true);

  // append the items to the list
  items.Assign(*m_listItems, true); // true to keep the current items
  m_listItems->Clear();
  return success;
}
Ejemplo n.º 4
0
bool CPluginDirectory::GetDirectory(const CStdString& strPath, CFileItemList& items)
{
  CURL url(strPath);

  bool success = StartScript(strPath, true);

  // append the items to the list
  items.Assign(*m_listItems, true); // true to keep the current items
  m_listItems->Clear();
  return success;
}
Ejemplo n.º 5
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);
}
Ejemplo n.º 6
0
bool CDirectoryCache::GetDirectory(const CStdString& strPath, CFileItemList &items) const
{
  CSingleLock lock (m_cs);

  CStdString storedPath = _P(strPath);
  CUtil::RemoveSlashAtEnd(storedPath);

  for (civecCache i = m_vecCache.begin(); i != m_vecCache.end(); i++)
  {
    const CDir* dir = *i;
    if (dir->m_strPath == storedPath && dir->m_cacheType == DIR_CACHE_ALWAYS)
    {
      items.Assign(*dir->m_Items);
      return true;
    }
  }
  return false;
}
Ejemplo n.º 7
0
void CGUIDialogSubtitles::Process(unsigned int currentTime, CDirtyRegionList &dirtyregions)
{
  if (m_bInvalidated)
  {
    // take copies of our variables to ensure we don't hold the lock for long.
    std::string status;
    CFileItemList subs;
    {
      CSingleLock lock(m_critsection);
      status = m_status;
      subs.Assign(*m_subtitles);
    }
    SET_CONTROL_LABEL(CONTROL_SUBSTATUS, status);

    if (m_updateSubsList)
    {
      CGUIMessage message(GUI_MSG_LABEL_BIND, GetID(), CONTROL_SUBLIST, 0, 0, &subs);
      OnMessage(message);
      if (!subs.IsEmpty())
      {
        // focus subtitles list
        CGUIMessage msg(GUI_MSG_SETFOCUS, GetID(), CONTROL_SUBLIST);
        OnMessage(msg);
      }
      m_updateSubsList = false;
    }
    
    int control = GetFocusedControlID();
    // nothing has focus
    if (!control)
    {
      CGUIMessage msg(GUI_MSG_SETFOCUS, GetID(), m_subtitles->IsEmpty() ?
                      CONTROL_SERVICELIST : CONTROL_SUBLIST);
      OnMessage(msg);
    }
    // subs list is focused but we have no subs
    else if (control == CONTROL_SUBLIST && m_subtitles->IsEmpty())
    {
      CGUIMessage msg(GUI_MSG_SETFOCUS, GetID(), CONTROL_SERVICELIST);
      OnMessage(msg);
    }
  }
  CGUIDialog::Process(currentTime, dirtyregions);
}
Ejemplo n.º 8
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));
}
Ejemplo n.º 9
0
void CGUIWindowPVRGuide::GetViewTimelineItems(CFileItemList &items)
{
  CGUIEPGGridContainer* epgGridContainer = (CGUIEPGGridContainer*) GetControl(m_viewControl.GetCurrentControl());
  if (!epgGridContainer)
    return;

  CPVRChannelGroupPtr group = GetGroup();

  // group change detected reset grid coordinate
  if (*m_cachedChannelGroup != *group)
    epgGridContainer->ResetCoordinates();

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

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

  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);
}
Ejemplo n.º 10
0
bool CGUIWindowPVRGuide::GetDirectory(const std::string &strDirectory, CFileItemList &items)
{
  bool bRefresh = false;

  {
    CSingleLock lock(m_critSection);

    // group change detected reset grid coordinates and refresh grid items
    if (!m_bRefreshTimelineItems && *m_cachedChannelGroup != *GetChannelGroup())
    {
      CGUIEPGGridContainer* epgGridContainer = GetGridControl();
      if (!epgGridContainer)
        return true;

      epgGridContainer->ResetCoordinates();
      m_bRefreshTimelineItems = true;
      bRefresh = true;
    }
  }

  // never call RefreshTimelineItems with locked mutex!
  if (bRefresh)
    RefreshTimelineItems();

  {
    CSingleLock lock(m_critSection);

    // Note: no need to do anything if no new data available. items always contains previous data.
    if (m_newTimeline)
    {
      items.RemoveDiscCache(GetID());
      items.Assign(*m_newTimeline, false);
      m_newTimeline.reset();
    }
  }

  return true;
}
Ejemplo n.º 11
0
void CGUIWindowPVRGuide::GetViewTimelineItems(CFileItemList &items)
{
  CSingleLock lock(m_critSection);

  // group change detected reset grid coordinates and refresh grid items
  if (!m_bRefreshTimelineItems && *m_cachedChannelGroup != *GetChannelGroup())
  {
    CGUIEPGGridContainer* epgGridContainer = GetGridControl();
    if (!epgGridContainer)
      return;

    epgGridContainer->ResetCoordinates();
    m_bRefreshTimelineItems = true;
    RefreshTimelineItems();
  }

  // Note: no need to do anything if no new data available. items always contains previous data.
  if (m_newTimeline)
  {
    items.RemoveDiscCache(GetID());
    items.Assign(*m_newTimeline, false);
    m_newTimeline.reset();
  }
}
Ejemplo n.º 12
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());

  // see if we can load a previously cached folder
  CFileItemList cachedItems(strDirectory);
  if (!strDirectory.IsEmpty() && cachedItems.Load(GetID()))
  {
    items.Assign(cachedItems);
  }
  else
  {
    unsigned int time = XbmcThreads::SystemClockMillis();

    if (strDirectory.IsEmpty())
      SetupShares();

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

    // took over a second, and not normally cached, so cache it
    if ((XbmcThreads::SystemClockMillis() - time) > 1000  && items.CacheToDiscIfSlow())
      items.Save(GetID());

    // if these items should replace the current listing, then pop it off the top
    if (items.GetReplaceListing())
      m_history.RemoveParentPath();
  }

  if (m_guiState.get() && !m_guiState->HideParentDirItems() && items.GetPath() != m_startDirectory)
  {
    CFileItemPtr pItem(new CFileItem(".."));
    pItem->SetPath(strParentPath);
    pItem->m_bIsFolder = true;
    pItem->m_bIsShareOrDrive = false;
    items.AddFront(pItem, 0);
  }

  CStdStringArray regexps;
  int iWindow = GetID();

  // TODO: Do we want to limit the directories we apply the video ones to?
  if (iWindow == WINDOW_VIDEO_NAV)
    regexps = g_advancedSettings.m_videoExcludeFromListingRegExps;
  if (iWindow == WINDOW_MUSIC_FILES)
    regexps = g_advancedSettings.m_audioExcludeFromListingRegExps;
  if (iWindow == WINDOW_PICTURES)
    regexps = g_advancedSettings.m_pictureExcludeFromListingRegExps;

  if (regexps.size())
  {
    for (int i=0; i < items.Size();)
    {
      if (CUtil::ExcludeFileOrFolder(items[i]->GetPath(), regexps))
        items.Remove(i);
      else
        i++;
    }
  }

  // clear the filter
  SetProperty("filter", "");
  return true;
}
Ejemplo n.º 13
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());

  // see if we can load a previously cached folder
  CFileItemList cachedItems(strDirectory);
  if (!strDirectory.IsEmpty() && cachedItems.Load())
  {
    items.Assign(cachedItems);
  }
  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.CacheToDiscIfSlow())
      items.Save();

    // if these items should replace the current listing, then pop it off the top
    if (items.GetReplaceListing())
      m_history.RemoveParentPath();
  }

  if (m_guiState.get() && !m_guiState->HideParentDirItems() && !items.m_strPath.IsEmpty())
  {
    CFileItemPtr pItem(new CFileItem(".."));
    pItem->m_strPath = strParentPath;
    pItem->m_bIsFolder = true;
    pItem->m_bIsShareOrDrive = false;
    items.AddFront(pItem, 0);
  }

  int iWindow = GetID();
  CStdStringArray regexps;

  if (iWindow == WINDOW_VIDEO_FILES)
    regexps = g_advancedSettings.m_videoExcludeFromListingRegExps;
  if (iWindow == WINDOW_MUSIC_FILES)
    regexps = g_advancedSettings.m_audioExcludeFromListingRegExps;
  if (iWindow == WINDOW_PICTURES)
    regexps = g_advancedSettings.m_pictureExcludeFromListingRegExps;

  if (regexps.size())
  {
    for (int i=0; i < items.Size();)
    {
      if (CUtil::ExcludeFileOrFolder(items[i]->m_strPath, regexps))
        items.Remove(i);
      else
        i++;
    }
  }

  // clear window properties at root or plugin root
  if (items.IsVirtualDirectoryRoot() || items.IsPluginRoot())
    ClearProperties();

  return true;
}
Ejemplo n.º 14
0
bool CPluginDirectory::GetDirectory(const CStdString& strPath, CFileItemList& items)
{
  CURL url(_P(strPath));
  if (url.GetFileName().IsEmpty())
  { // called with no script - should never happen
    return GetPluginsDirectory(url.GetHostName(), items);
  }

  CStdString fileName;
  CUtil::AddFileToFolder(url.GetFileName(), "default.py", fileName);

  // path is Q:\plugins\<path from here>
  CStdString pathToScript = _P("U:\\plugins\\");
  CUtil::AddFileToFolder(pathToScript, url.GetHostName(), pathToScript);
  CUtil::AddFileToFolder(pathToScript, fileName, pathToScript);
#ifdef _WIN32
  pathToScript.Replace("/", "\\");
#endif

  // base path
  CStdString basePath = "plugin://";
  CUtil::AddFileToFolder(basePath, url.GetHostName(), basePath);
  CUtil::AddFileToFolder(basePath, url.GetFileName(), basePath);

  // options
  CStdString options = url.GetOptions();
  CUtil::RemoveSlashAtEnd(options); // This MAY kill some scripts (eg though with a URL ending with a slash), but
                                    // is needed for all others, as XBMC adds slashes to "folders"

  // Load the plugin settings
  CLog::Log(LOGDEBUG, "%s - URL for plugin settings: %s", __FUNCTION__, url.GetFileName().c_str() );
  g_currentPluginSettings.Load(url);

  // Load language strings
  LoadPluginStrings(url);

  // reset our wait event, and grab a new handle
  ResetEvent(m_directoryFetched);
  int handle = getNewHandle(this);

  // clear out our status variables
  m_listItems->Clear();
  m_listItems->m_strPath = strPath;
  m_cancelled = false;
  m_success = false;
  m_totalItems = 0;

  // setup our parameters to send the script
  CStdString strHandle;
  strHandle.Format("%i", handle);
  const char *plugin_argv[] = {basePath.c_str(), strHandle.c_str(), options.c_str(), NULL };

  // run the script
  CLog::Log(LOGDEBUG, "%s - calling plugin %s('%s','%s','%s')", __FUNCTION__, pathToScript.c_str(), plugin_argv[0], plugin_argv[1], plugin_argv[2]);
  bool success = false;
  if (g_pythonParser.evalFile(pathToScript.c_str(), 3, (const char**)plugin_argv) >= 0)
  { // wait for our script to finish
    CStdString scriptName = url.GetFileName();
    CUtil::RemoveSlashAtEnd(scriptName);
    success = WaitOnScriptResult(_P(pathToScript), scriptName);
  }
  else
    CLog::Log(LOGERROR, "Unable to run plugin %s", pathToScript.c_str());

  // free our handle
  removeHandle(handle);

  // append the items to the list
  items.Assign(*m_listItems, true); // true to keep the current items
  m_listItems->Clear();
  return success;
}