Example #1
0
bool CGUIMediaWindow::WaitForNetwork() const
{
  if (g_application.getNetwork().IsAvailable())
    return true;

  CGUIDialogProgress *progress = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
  if (!progress)
    return true;

  CURL url(m_vecItems->GetPath());
  progress->SetHeading(1040); // Loading Directory
  progress->SetLine(1, url.GetWithoutUserDetails());
  progress->ShowProgressBar(false);
  progress->StartModal();
  while (!g_application.getNetwork().IsAvailable())
  {
    progress->Progress();
    if (progress->IsCanceled())
    {
      progress->Close();
      return false;
    }
  }
  progress->Close();
  return true;
}
Example #2
0
void CGUIWindowPVRBase::OnInitWindow(void)
{
  if (!g_PVRManager.IsStarted() || !g_PVRClients->HasConnectedClients())
  {
    // wait until the PVR manager has been started
    CGUIDialogProgress* dialog = static_cast<CGUIDialogProgress*>(g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS));
    if (dialog)
    {
      dialog->SetHeading(CVariant{19235});
      dialog->SetText(CVariant{19045});
      dialog->ShowProgressBar(false);
      dialog->Open();

      // do not block the gfx context while waiting
      CSingleExit exit(g_graphicsContext);

      CEvent event(true);
      while(!event.WaitMSec(1))
      {
        if (g_PVRManager.IsStarted() && g_PVRClients->HasConnectedClients())
          event.Set();

        if (dialog->IsCanceled())
        {
          // return to previous window if canceled
          dialog->Close();
          g_windowManager.PreviousWindow();
          return;
        }

        g_windowManager.ProcessRenderLoop(false);
      }

      dialog->Close();
    }
  }

  {
    // set window group to playing group
    CPVRChannelGroupPtr group = g_PVRManager.GetPlayingGroup(m_bRadio);
    CSingleLock lock(m_critSection);
    if (m_group != group)
      m_viewControl.SetSelectedItem(0);
    m_group = group;
  }
  SetProperty("IsRadio", m_bRadio ? "true" : "");

  m_vecItems->SetPath(GetDirectoryPath());

  CGUIMediaWindow::OnInitWindow();

  // mark item as selected by channel path
  m_viewControl.SetSelectedItem(GetSelectedItemPath(m_bRadio));
}
Example #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;
    }
  }
}
Example #4
0
bool CGUIWindowSettings::ShowLegal()
{
  if (m_legalString.IsEmpty())
  {
    CGUIDialogProgress* progress = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
    if (progress)
    {
      progress->StartModal();
      progress->Progress();
    }

    // verify the username is available
    CStdString strUrl = BOXEE::BXConfiguration::GetInstance().GetStringParam("Boxee.Legal","http://app.boxee.tv/api/getlegal?page=legal");
    BOXEE::BXCurl curl;

    m_legalString = curl.HttpGetString(strUrl, false);

    if (progress)
    {
      progress->Close();
    }

    if (m_legalString.IsEmpty())
    {
      CGUIDialogOK2::ShowAndGetInput(g_localizeStrings.Get(53701), g_localizeStrings.Get(53431));
      return true;
    }
  }

  CGUIDialogBoxeeMessageScroll::ShowAndGetInput(g_localizeStrings.Get(53441), m_legalString);
  return true;
}
void CGUIDialogPVRChannelManager::SaveList(void)
{
  if (!m_bContainsChanges)
   return;

  /* display the progress dialog */
  CGUIDialogProgress* pDlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
  pDlgProgress->SetHeading(190);
  pDlgProgress->SetLine(0, "");
  pDlgProgress->SetLine(1, 328);
  pDlgProgress->SetLine(2, "");
  pDlgProgress->StartModal();
  pDlgProgress->Progress();
  pDlgProgress->SetPercentage(0);

  /* persist all channels */
  unsigned int iNextChannelNumber(0);
  CPVRChannelGroupPtr group = g_PVRChannelGroups->GetGroupAll(m_bIsRadio);
  if (!group)
    return;
  for (int iListPtr = 0; iListPtr < m_channelItems->Size(); iListPtr++)
  {
    CFileItemPtr pItem = m_channelItems->Get(iListPtr);
    PersistChannel(pItem, group, &iNextChannelNumber);

    pDlgProgress->SetPercentage(iListPtr * 100 / m_channelItems->Size());
  }

  group->SortAndRenumber();
  group->Persist();
  m_bContainsChanges = false;
  SetItemsUnchanged();
  pDlgProgress->Close();
}
Example #6
0
void CGUIWindowPVRSearch::UpdateData(bool bUpdateSelectedFile /* = true */)
{
  CLog::Log(LOGDEBUG, "CGUIWindowPVRSearch - %s - update window '%s'. set view to %d", __FUNCTION__, GetName(), m_iControlList);
  m_bUpdateRequired = false;

  /* lock the graphics context while updating */
  CSingleLock graphicsLock(g_graphicsContext);

  m_iSelected = m_parent->m_viewControl.GetSelectedItem();
  m_parent->m_viewControl.Clear();
  m_parent->m_vecItems->Clear();
  m_parent->m_viewControl.SetCurrentView(m_iControlList);

  if (m_bSearchConfirmed)
  {
    CGUIDialogProgress* dlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
    if (dlgProgress)
    {
      dlgProgress->SetHeading(194);
      dlgProgress->SetLine(0, m_searchfilter.m_strSearchTerm);
      dlgProgress->SetLine(1, "");
      dlgProgress->SetLine(2, "");
      dlgProgress->StartModal();
      dlgProgress->Progress();
    }

    // TODO get this from the selected channel group
    g_EpgContainer.GetEPGSearch(*m_parent->m_vecItems, m_searchfilter);
    if (dlgProgress)
      dlgProgress->Close();

    if (m_parent->m_vecItems->Size() == 0)
    {
      CGUIDialogOK::ShowAndGetInput(194, 284, 0, 0);
      m_bSearchConfirmed = false;
    }
  }

  if (m_parent->m_vecItems->Size() == 0)
  {
    CFileItemPtr item;
    item.reset(new CFileItem("pvr://guide/searchresults/empty.epg", false));
    item->SetLabel(g_localizeStrings.Get(19027));
    item->SetLabelPreformated(true);
    m_parent->m_vecItems->Add(item);
  }
  else
  {
    m_parent->m_vecItems->Sort(m_iSortMethod, m_iSortOrder, m_iSortAttributes);
  }

  m_parent->m_viewControl.SetItems(*m_parent->m_vecItems);

  if (bUpdateSelectedFile)
    m_parent->m_viewControl.SetSelectedItem(m_iSelected);

  m_parent->SetLabel(CONTROL_LABELHEADER, g_localizeStrings.Get(283));
  m_parent->SetLabel(CONTROL_LABELGROUP, "");
}
Example #7
0
bool CUPnPAvDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
{
  CURI url(strPath);

  m_cacheDirectory = DIR_CACHE_ALWAYS;

  if(url.GetProtocol() != "upnp")
  {
     CLog::Log(LOGERROR, "CUPnPAvDirectory::%s - invalid protocol [%s]", __func__, url.GetProtocol().c_str());
     return false;
  }

  CBrowserService* pBrowser = g_application.GetBrowserService();

  if( strPath == "upnp://" && pBrowser )
  {
    pBrowser->GetShare( CBrowserService::UPNP_SHARE, items );
    return true;
  }

  // If we have the items in the cache, return them
  if (g_directoryCache.GetDirectory(strPath, items))
  {
    return true;
  }

  if(strPath == "upnp://all")
  {
     bool bSuccess = ScanUPnPShares(items);
     if(!bSuccess)
     {
       IHalServices& client = CHalServicesFactory::GetInstance();
       client.DjmountRestart();

       CLog::Log(LOGWARNING, "CUPnPAvDirectory::%s - failed to scan UPnP shares, retrying...", __func__);

       CGUIDialogProgress* progress = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
       if (progress)
       {
         CStdString strId;
         strId.Format("%d-upnp-scan-retry", CThread::GetCurrentThreadId());
         progress->StartModal(strId);
         progress->Progress();
       }

       // hopefully djmount will be able to find all shares
       Sleep(5000);

       bSuccess = ScanUPnPShares(items);

       progress->Close();
     }

     return bSuccess;
  }

  return ReadDir(url, items);
}
Example #8
0
void CGUIWindowPVRSearch::UpdateData(void)
{
  if (m_bIsFocusing)
    return;

  CLog::Log(LOGDEBUG, "CGUIWindowPVRSearch - %s - update window '%s'. set view to %d", __FUNCTION__, GetName(), m_iControlList);
  m_bIsFocusing = true;
  m_bUpdateRequired = false;
  m_parent->m_viewControl.Clear();
  m_parent->m_vecItems->Clear();
  m_parent->m_viewControl.SetCurrentView(m_iControlList);

  if (m_bSearchConfirmed)
  {
    CGUIDialogProgress* dlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
    if (dlgProgress)
    {
      dlgProgress->SetHeading(194);
      dlgProgress->SetLine(0, m_searchfilter.m_strSearchTerm);
      dlgProgress->SetLine(1, "");
      dlgProgress->SetLine(2, "");
      dlgProgress->StartModal();
      dlgProgress->Progress();
    }

    CPVRManager::GetEpg()->GetEPGSearch(m_parent->m_vecItems, m_searchfilter);
    if (dlgProgress)
      dlgProgress->Close();

    if (m_parent->m_vecItems->Size() == 0)
    {
      CGUIDialogOK::ShowAndGetInput(194, 284, 0, 0);
      m_bSearchConfirmed = false;
    }
  }

  if (m_parent->m_vecItems->Size() == 0)
  {
    CFileItemPtr item;
    item.reset(new CFileItem("pvr://guide/searchresults/empty.epg", false));
    item->SetLabel(g_localizeStrings.Get(19027));
    item->SetLabelPreformated(true);
    m_parent->m_vecItems->Add(item);
  }
  else
  {
    m_parent->m_vecItems->Sort(m_iSortMethod, m_iSortOrder);
  }

  m_parent->m_viewControl.SetItems(*m_parent->m_vecItems);
  m_parent->m_viewControl.SetSelectedItem(m_iSelected);

  m_parent->SetLabel(CONTROL_LABELHEADER, g_localizeStrings.Get(283));
  m_parent->SetLabel(CONTROL_LABELGROUP, "");
  m_bIsFocusing = false;
}
Example #9
0
 ~progress_info()
 {
   if (shown && g_application.IsCurrentThread())
   {
     // close progress dialog
     CGUIDialogProgress* dlg = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
     if (dlg)
       dlg->Close();
   }
 }
Example #10
0
 ~progress_info()
 {
   if (shown)
   {
     // close progress dialog
     CGUIDialogProgress* dlg = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
     if (dlg)
       dlg->Close();
   }
 }
bool CGUIWindowBoxeeWizardNetwork::SaveConfiguration()
{
   if (!NetworkConfigurationChanged())
      return true;
      
   bool result = false;
   CStdString currentEssId;
   CStdString currentKey;
   EncMode    currentEnc;
   CStdString currentInterfaceName;
   
   GetUserConfiguration(currentInterfaceName, currentEssId, currentKey, currentEnc);
   
   CGUIDialogProgress* pDlgProgress = (CGUIDialogProgress*)m_gWindowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
   pDlgProgress->SetHeading("");
   pDlgProgress->SetLine(0, "Applying network configuration...");
   pDlgProgress->SetLine(1, "");
   pDlgProgress->SetLine(2, "");
   pDlgProgress->StartModal();
   pDlgProgress->Progress();
        
   CStdString empty;
   NetworkAssignment assignment;
   CNetworkInterface* interface; 
   for (unsigned int i = 0; i < m_interfaces.size(); i++)
   {
      interface = m_interfaces[i];
      if (interface->GetName() == currentInterfaceName)
      {
         assignment = NETWORK_DHCP;
         interface->SetSettings(assignment, empty, empty, empty, currentEssId, currentKey, currentEnc);
      }
      else
      { 
         // if we have a different interfaces, we need to take them down
         assignment = NETWORK_DISABLED;
         EncMode enc = ENC_NONE;
         interface->SetSettings(assignment, empty, empty, empty, empty, empty, enc);
      }
   }
   
   pDlgProgress->Close();
     
   if (!interface->IsConnected())
      CGUIDialogOK::ShowAndGetInput(0, 50001, 50002, 0);
   else if (!g_application.IsConnectedToNet())
      CGUIDialogOK::ShowAndGetInput(0, 50003, 50004, 50002);
   else
      result = true;
          
   ResetCurrentNetworkState();
   
   return result;
}
Example #12
0
bool CAsyncFileCopy::Copy(const CStdString &from, const CStdString &to, const CStdString &heading)
{
  // reset the variables to their appropriate states
  m_from = from;
  m_to = to;
  m_cancelled = false;
  m_succeeded = false;
  m_percent = 0;
  m_speed = 0;
  m_running = true;
  CStdString fromStripped, toStripped;
  CURL url1(from);
  url1.GetURLWithoutUserDetails(fromStripped);
  CURL url2(to);
  url2.GetURLWithoutUserDetails(toStripped);

  // create our thread, which starts the file copy operation
  Create();
  CGUIDialogProgress *dlg = (CGUIDialogProgress *)m_gWindowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
  DWORD time = timeGetTime();
  while (m_running)
  {
    m_event.WaitMSec(1000 / 30);
    if (!m_running)
      break;
    // start the dialog up as needed
    if (dlg && !dlg->IsDialogRunning() && timeGetTime() > time + 500) // wait 0.5 seconds before starting dialog
    {
      dlg->SetHeading(heading);
      dlg->SetLine(0, fromStripped);
      dlg->SetLine(1, toStripped);
      dlg->SetPercentage(0);
      dlg->StartModal();
    }
    // and update the dialog as we go
    if (dlg && dlg->IsDialogRunning())
    {
      CStdString speedString;
      speedString.Format("%2.2f KB/s", m_speed / 1024);
      dlg->SetHeading(heading);
      dlg->SetLine(0, fromStripped);
      dlg->SetLine(1, toStripped);
      dlg->SetLine(2, speedString);
      dlg->SetPercentage(m_percent);
      dlg->Progress();
      m_cancelled = dlg->IsCanceled();
    }
  }
  if (dlg)
    dlg->Close();
  return !m_cancelled && m_succeeded;
}
Example #13
0
bool CAddonInstaller::PromptForInstall(const std::string &addonID, AddonPtr &addon)
{
  if (!g_passwordManager.CheckMenuLock(WINDOW_ADDON_BROWSER))
    return false;

  // we assume that addons that are enabled don't get to this routine (i.e. that GetAddon() has been called)
  if (CAddonMgr::Get().GetAddon(addonID, addon, ADDON_UNKNOWN, false))
    return false; // addon is installed but disabled, and the user has specifically activated something that needs
                  // the addon - should we enable it?

  // check we have it available
  CAddonDatabase database;
  database.Open();
  if (database.GetAddon(addonID, addon))
  { // yes - ask user if they want it installed
    if (!CGUIDialogYesNo::ShowAndGetInput(g_localizeStrings.Get(24076), g_localizeStrings.Get(24100),
                                          addon->Name().c_str(), g_localizeStrings.Get(24101)))
      return false;
    if (Install(addonID, true))
    {
      CGUIDialogProgress *progress = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
      if (progress)
      {
        progress->SetHeading(13413); // Downloading
        progress->SetLine(0, "");
        progress->SetLine(1, addon->Name());
        progress->SetLine(2, "");
        progress->SetPercentage(0);
        progress->StartModal();
        while (true)
        {
          progress->Progress();
          unsigned int percent;
          if (progress->IsCanceled())
          {
            Cancel(addonID);
            break;
          }
          if (!GetProgress(addonID, percent))
            break;
          progress->SetPercentage(percent);
        }
        progress->Close();
      }
      return CAddonMgr::Get().GetAddon(addonID, addon);
    }
  }
  return false;
}
/// \brief Search the current directory for a string got from the virtual keyboard
void CGUIDialogVideoInfo::OnSearch(CStdString& strSearch)
{
  CGUIDialogProgress *progress = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
  if (progress)
  {
    progress->SetHeading(194);
    progress->SetLine(0, strSearch);
    progress->SetLine(1, "");
    progress->SetLine(2, "");
    progress->StartModal();
    progress->Progress();
  }
  CFileItemList items;
  DoSearch(strSearch, items);

  if (progress)
    progress->Close();

  if (items.Size())
  {
    CGUIDialogSelect* pDlgSelect = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
    pDlgSelect->Reset();
    pDlgSelect->SetHeading(283);

    for (int i = 0; i < (int)items.Size(); i++)
    {
      CFileItemPtr pItem = items[i];
      pDlgSelect->Add(pItem->GetLabel());
    }

    pDlgSelect->DoModal();

    int iItem = pDlgSelect->GetSelectedLabel();
    if (iItem < 0)
      return;

    CFileItem* pSelItem = new CFileItem(*items[iItem]);

    OnSearchItemFound(pSelItem);

    delete pSelItem;
  }
  else
  {
    CGUIDialogOK::ShowAndGetInput(194, 284, 0, 0);
  }
}
Example #15
0
bool CAsyncFileCopy::Copy(const std::string &from, const std::string &to, const std::string &heading)
{
  // reset the variables to their appropriate states
  m_from = from;
  m_to = to;
  m_cancelled = false;
  m_succeeded = false;
  m_percent = 0;
  m_speed = 0;
  m_running = true;
  CURL url1(from);
  CURL url2(to);

  // create our thread, which starts the file copy operation
  Create();
  CGUIDialogProgress *dlg = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
  unsigned int time = XbmcThreads::SystemClockMillis();
  while (m_running)
  {
    m_event.WaitMSec(1000 / 30);
    if (!m_running)
      break;
    // start the dialog up as needed
    if (dlg && !dlg->IsDialogRunning() && (XbmcThreads::SystemClockMillis() - time) > 500) // wait 0.5 seconds before starting dialog
    {
      dlg->SetHeading(CVariant{heading});
      dlg->SetLine(0, CVariant{url1.GetWithoutUserDetails()});
      dlg->SetLine(1, CVariant{url2.GetWithoutUserDetails()});
      dlg->SetPercentage(0);
      dlg->StartModal();
    }
    // and update the dialog as we go
    if (dlg && dlg->IsDialogRunning())
    {
      dlg->SetHeading(CVariant{heading});
      dlg->SetLine(0, CVariant{url1.Get()});
      dlg->SetLine(1, CVariant{url2.Get()});
      dlg->SetLine(2, CVariant{ StringUtils::Format("%2.2f KB/s", m_speed / 1024) });
      dlg->SetPercentage(m_percent);
      dlg->Progress();
      m_cancelled = dlg->IsCanceled();
    }
  }
  if (dlg)
    dlg->Close();
  return !m_cancelled && m_succeeded;
}
void CGUIDialogPVRChannelManager::SaveList(void)
{
    if (!m_bContainsChanges)
        return;

    /* display the progress dialog */
    CGUIDialogProgress* pDlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
    pDlgProgress->SetHeading(CVariant{190});
    pDlgProgress->SetLine(0, CVariant{""});
    pDlgProgress->SetLine(1, CVariant{328});
    pDlgProgress->SetLine(2, CVariant{""});
    pDlgProgress->StartModal();
    pDlgProgress->Progress();
    pDlgProgress->SetPercentage(0);

    /* persist all channels */
    unsigned int iNextChannelNumber(0);
    CPVRChannelGroupPtr group = g_PVRChannelGroups->GetGroupAll(m_bIsRadio);
    if (!group)
        return;

    for (int iListPtr = 0; iListPtr < m_channelItems->Size(); iListPtr++)
    {
        CFileItemPtr pItem = m_channelItems->Get(iListPtr);

        if (!pItem->HasPVRChannelInfoTag())
            continue;

        if (pItem->GetProperty("SupportsSettings").asBoolean())
            RenameChannel(pItem);

        PersistChannel(pItem, group, &iNextChannelNumber);

        pDlgProgress->SetPercentage(iListPtr * 100 / m_channelItems->Size());
    }

    group->SortAndRenumber();
    group->Persist();
    m_bContainsChanges = false;
    SetItemsUnchanged();
    pDlgProgress->Close();
}
Example #17
0
void CGUIWindowPVRSearch::OnPrepareFileItems(CFileItemList &items)
{
  bool bAddSpecialSearchItem = items.IsEmpty();

  if (m_bSearchConfirmed)
  {
    m_bSearchConfirmed = false;

    bAddSpecialSearchItem = true;

    CGUIDialogProgress* dlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
    if (dlgProgress)
    {
      dlgProgress->SetHeading(CVariant{194}); // "Searching..."
      dlgProgress->SetText(CVariant{m_searchfilter.m_strSearchTerm});
      dlgProgress->Open();
      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(CVariant{194},  // "Searching..."
                                    CVariant{284}); // "No results found"
  }

  if (bAddSpecialSearchItem)
  {
    CFileItemPtr item(new CFileItem("pvr://guide/searchresults/search/", true));
    item->SetLabel(g_localizeStrings.Get(19140)); // "Search..."
    item->SetLabelPreformated(true);
    item->SetSpecialSort(SortSpecialOnTop);
    items.Add(item);
  }
}
Example #18
0
void CPVRManager::ResetDatabase(bool bShowProgress /* = true */)
{
  CLog::Log(LOGNOTICE,"PVRManager - %s - clearing the PVR database", __FUNCTION__);

  g_EpgContainer.Stop();

  CGUIDialogProgress* pDlgProgress = NULL;
  if (bShowProgress)
  {
    pDlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
    pDlgProgress->SetLine(0, StringUtils::EmptyString);
    pDlgProgress->SetLine(1, g_localizeStrings.Get(19186));
    pDlgProgress->SetLine(2, StringUtils::EmptyString);
    pDlgProgress->StartModal();
    pDlgProgress->Progress();
  }

  if (m_addons && m_addons->IsPlaying())
  {
    CLog::Log(LOGNOTICE,"PVRManager - %s - stopping playback", __FUNCTION__);
    g_application.getApplicationMessenger().MediaStop();
  }

  if (bShowProgress)
  {
    pDlgProgress->SetPercentage(10);
    pDlgProgress->Progress();
  }

  /* stop the thread */
  if (g_guiSettings.GetBool("pvrmanager.enabled"))
    Stop();

  if (bShowProgress)
  {
    pDlgProgress->SetPercentage(20);
    pDlgProgress->Progress();
  }

  if (m_database && m_database->Open())
  {
    /* clean the EPG database */
    g_EpgContainer.Clear(true);
    if (bShowProgress)
    {
      pDlgProgress->SetPercentage(30);
      pDlgProgress->Progress();
    }

    m_database->DeleteChannelGroups();
    if (bShowProgress)
    {
      pDlgProgress->SetPercentage(50);
      pDlgProgress->Progress();
    }

    /* delete all channels */
    m_database->DeleteChannels();
    if (bShowProgress)
    {
      pDlgProgress->SetPercentage(70);
      pDlgProgress->Progress();
    }

    /* delete all channel settings */
    m_database->DeleteChannelSettings();
    if (bShowProgress)
    {
      pDlgProgress->SetPercentage(80);
      pDlgProgress->Progress();
    }

    /* delete all client information */
    m_database->DeleteClients();
    if (bShowProgress)
    {
      pDlgProgress->SetPercentage(90);
      pDlgProgress->Progress();
    }

    m_database->Close();
  }

  CLog::Log(LOGNOTICE,"PVRManager - %s - PVR database cleared", __FUNCTION__);

  g_EpgContainer.Start();

  if (g_guiSettings.GetBool("pvrmanager.enabled"))
  {
    CLog::Log(LOGNOTICE,"PVRManager - %s - restarting the PVRManager", __FUNCTION__);
    m_database->Open();
    Cleanup();
    Start();
  }

  if (bShowProgress)
  {
    pDlgProgress->SetPercentage(100);
    pDlgProgress->Close();
  }
}
Example #19
0
bool CPartyModeManager::Enable(PartyModeContext context /*= PARTYMODECONTEXT_MUSIC*/, const CStdString& strXspPath /*= ""*/)
{
  // Filter using our PartyMode xml file
  CSmartPlaylist playlist;
  CStdString partyModePath;
  bool playlistLoaded;

  m_bIsVideo = context == PARTYMODECONTEXT_VIDEO;
  if (!strXspPath.IsEmpty()) //if a path to a smartplaylist is supplied use it
    partyModePath = strXspPath;
  else if (m_bIsVideo)
    partyModePath = g_settings.GetUserDataItem("PartyMode-Video.xsp");
  else
    partyModePath = g_settings.GetUserDataItem("PartyMode.xsp");

  playlistLoaded=playlist.Load(partyModePath);

  if ( playlistLoaded )
  {
    m_type = playlist.GetType();
    if (context == PARTYMODECONTEXT_UNKNOWN)
    {
      //get it from the xsp file
      m_bIsVideo = (m_type.Equals("video") || m_type.Equals("musicvideos") || m_type.Equals("mixed"));
    }

    if (m_type.Equals("mixed"))
      playlist.SetType("songs");

    if (m_type.Equals("mixed"))
      playlist.SetType("video");

    playlist.SetType(m_type);
  }
  else
  {
    m_strCurrentFilterMusic.Empty();
    m_strCurrentFilterVideo.Empty();
    m_type = m_bIsVideo ? "musicvideos" : "songs";
  }

  CGUIDialogProgress* pDialog = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
  int iHeading = (m_bIsVideo ? 20250 : 20121);
  int iLine0 = (m_bIsVideo ? 20251 : 20123);
  pDialog->SetHeading(iHeading);
  pDialog->SetLine(0, iLine0);
  pDialog->SetLine(1, "");
  pDialog->SetLine(2, "");
  pDialog->StartModal();

  ClearState();
  unsigned int time = XbmcThreads::SystemClockMillis();
  vector< pair<int,int> > songIDs;
  if (m_type.Equals("songs") || m_type.Equals("mixed"))
  {
    CMusicDatabase db;
    if (db.Open())
    {
      set<CStdString> playlists;
      if ( playlistLoaded )
        m_strCurrentFilterMusic = playlist.GetWhereClause(db, playlists);

      CLog::Log(LOGINFO, "PARTY MODE MANAGER: Registering filter:[%s]", m_strCurrentFilterMusic.c_str());
      m_iMatchingSongs = (int)db.GetSongIDs(m_strCurrentFilterMusic, songIDs);
      if (m_iMatchingSongs < 1 && m_type.Equals("songs"))
      {
        pDialog->Close();
        db.Close();
        OnError(16031, (CStdString)"Party mode found no matching songs. Aborting.");
        return false;
      }
    }
    else
    {
      pDialog->Close();
      OnError(16033, (CStdString)"Party mode could not open database. Aborting.");
      return false;
    }
    db.Close();
  }

  if (m_type.Equals("musicvideos") || m_type.Equals("mixed"))
  {
    vector< pair<int,int> > songIDs2;
    CVideoDatabase db;
    if (db.Open())
    {
      set<CStdString> playlists;
      if ( playlistLoaded )
        m_strCurrentFilterVideo = playlist.GetWhereClause(db, playlists);

      CLog::Log(LOGINFO, "PARTY MODE MANAGER: Registering filter:[%s]", m_strCurrentFilterVideo.c_str());
      m_iMatchingSongs += (int)db.GetMusicVideoIDs(m_strCurrentFilterVideo, songIDs2);
      if (m_iMatchingSongs < 1)
      {
        pDialog->Close();
        db.Close();
        OnError(16031, (CStdString)"Party mode found no matching songs. Aborting.");
        return false;
      }
    }
    else
    {
      pDialog->Close();
      OnError(16033, (CStdString)"Party mode could not open database. Aborting.");
      return false;
    }
    db.Close();
    songIDs.insert(songIDs.end(),songIDs2.begin(),songIDs2.end());
  }

  // calculate history size
  if (m_iMatchingSongs < 50)
    m_songsInHistory = 0;
  else
    m_songsInHistory = (int)(m_iMatchingSongs/2);
  if (m_songsInHistory > 200)
    m_songsInHistory = 200;

  CLog::Log(LOGINFO,"PARTY MODE MANAGER: Matching songs = %i, History size = %i", m_iMatchingSongs, m_songsInHistory);
  CLog::Log(LOGINFO,"PARTY MODE MANAGER: Party mode enabled!");

  int iPlaylist = m_bIsVideo ? PLAYLIST_VIDEO : PLAYLIST_MUSIC;

  g_playlistPlayer.ClearPlaylist(iPlaylist);
  g_playlistPlayer.SetShuffle(iPlaylist, false);
  g_playlistPlayer.SetRepeat(iPlaylist, PLAYLIST::REPEAT_NONE);

  pDialog->SetLine(0, (m_bIsVideo ? 20252 : 20124));
  pDialog->Progress();
  // add initial songs
  if (!AddInitialSongs(songIDs))
  {
    pDialog->Close();
    return false;
  }
  CLog::Log(LOGDEBUG, "%s time for song fetch: %u",
            __FUNCTION__, XbmcThreads::SystemClockMillis() - time);

  // start playing
  g_playlistPlayer.SetCurrentPlaylist(iPlaylist);
  Play(0);

  pDialog->Close();
  // open now playing window
  if (m_type.Equals("songs"))
  {
    if (g_windowManager.GetActiveWindow() != WINDOW_MUSIC_PLAYLIST)
      g_windowManager.ActivateWindow(WINDOW_MUSIC_PLAYLIST);
  }

  // done
  m_bEnabled = true;
  Announce();
  return true;
}
Example #20
0
void CGUIDialogPVRChannelManager::SaveList() // XXX investigate: renumbering doesn't work
{
  if (!m_bContainsChanges)
   return;

  CPVRDatabase *database = CPVRManager::Get()->GetTVDatabase();
  if (!database || !database->Open())
    return;

  CGUIDialogProgress* pDlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
  pDlgProgress->SetHeading(190);
  pDlgProgress->SetLine(0, "");
  pDlgProgress->SetLine(1, 328);
  pDlgProgress->SetLine(2, "");
  pDlgProgress->StartModal();
  pDlgProgress->Progress();
  pDlgProgress->SetPercentage(0);

  int iActiveChannels = 0;
  for (int iListPtr = 0; iListPtr < m_channelItems->Size(); iListPtr++)
  {
    if (m_channelItems->Get(iListPtr)->GetPropertyBOOL("ActiveChannel"))
      ++iActiveChannels;
  }

//  int iNextChannelNumber = 1;
//  int iNextHiddenChannelNumber = iActiveChannels + 1;
  bool bHasChangedItems = false;

  for (int iListPtr = 0; iListPtr < m_channelItems->Size(); iListPtr++)
  {
    bool bChanged = false;
    CFileItemPtr pItem = m_channelItems->Get(iListPtr);
    if (!pItem)
      continue;
    CPVRChannel *channel = pItem->GetPVRChannelInfoTag();

    if (!channel)
    {
      //TODO add new channel
      continue;
    }

    /* get values from the form */
    bool bHidden              = !pItem->GetPropertyBOOL("ActiveChannel");
    bool bVirtual             = pItem->GetPropertyBOOL("Virtual");
    bool bEPGEnabled          = pItem->GetPropertyBOOL("UseEPG");
    int iEPGSource            = pItem->GetPropertyInt("EPGSource");
    CStdString strChannelName = pItem->GetProperty("Name");
    CStdString strIconPath    = pItem->GetProperty("Icon");
    CStdString strStreamURL   = pItem->GetProperty("StreamURL");

    /* set new values in the channel tag */
// TODO
//    if (bHidden)
//      bChanged = channel->SetChannelNumber(iNextHiddenChannelNumber++) || bChanged;
//    else
//      bChanged = channel->SetChannelNumber(iNextChannelNumber++) || bChanged;
    bChanged = channel->SetChannelName(strChannelName) || bChanged;
    bChanged = channel->SetHidden(bHidden) || bChanged;
    bChanged = channel->SetIconPath(strIconPath) || bChanged;
    if (bVirtual)
      bChanged = channel->SetStreamURL(strStreamURL) || bChanged;

    if (iEPGSource == 0)
      bChanged = channel->SetEPGScraper("client") || bChanged;
    // TODO add other scrapers
    bChanged = channel->SetEPGEnabled(bEPGEnabled) || bChanged;

    if (bChanged)
    {
      bHasChangedItems = true;
      channel->Persist(true);
    }

    pItem->SetProperty("Changed", false);
    pDlgProgress->SetPercentage(iListPtr * 100 / m_channelItems->Size());
  }

  if (bHasChangedItems)
  {
    database->CommitInsertQueries();
    CPVRManager::Get()->Start(); // XXX not a nice way to refresh the channels, but works for now
  }

  database->Close();

  m_bContainsChanges = false;
  pDlgProgress->Close();
}
Example #21
0
bool CMultiPathDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
{
  CLog::Log(LOGDEBUG,"CMultiPathDirectory::GetDirectory(%s)", strPath.c_str());

  vector<CStdString> vecPaths;
  if (!GetPaths(strPath, vecPaths))
    return false;

  unsigned int progressTime = CTimeUtils::GetTimeMS() + 3000L;   // 3 seconds before showing progress bar
  CGUIDialogProgress* dlgProgress = NULL;

  unsigned int iFailures = 0;
  for (unsigned int i = 0; i < vecPaths.size(); ++i)
  {
    // show the progress dialog if we have passed our time limit
    if (CTimeUtils::GetTimeMS() > progressTime && !dlgProgress)
    {
      dlgProgress = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
      if (dlgProgress)
      {
        dlgProgress->SetHeading(15310);
        dlgProgress->SetLine(0, 15311);
        dlgProgress->SetLine(1, "");
        dlgProgress->SetLine(2, "");
        dlgProgress->StartModal();
        dlgProgress->ShowProgressBar(true);
        dlgProgress->SetProgressMax((int)vecPaths.size()*2);
        dlgProgress->Progress();
      }
    }
    if (dlgProgress)
    {
      CURL url(vecPaths[i]);
      dlgProgress->SetLine(1, url.GetWithoutUserDetails());
      dlgProgress->SetProgressAdvance();
      dlgProgress->Progress();
    }

    CFileItemList tempItems;
    CLog::Log(LOGDEBUG,"Getting Directory (%s)", vecPaths[i].c_str());
    if (CDirectory::GetDirectory(vecPaths[i], tempItems, m_strFileMask, m_useFileDirectories, m_allowPrompting, m_cacheDirectory, m_extFileInfo))
      items.Append(tempItems);
    else
    {
      CLog::Log(LOGERROR,"Error Getting Directory (%s)", vecPaths[i].c_str());
      iFailures++;
    }

    if (dlgProgress)
    {
      dlgProgress->SetProgressAdvance();
      dlgProgress->Progress();
    }
  }

  if (dlgProgress)
    dlgProgress->Close();

  if (iFailures == vecPaths.size())
    return false;

  // merge like-named folders into a sub multipath:// style url
  MergeItems(items);

  return true;
}
void CGUIWindowFileManager::OnPopupMenu(int list, int item, bool bContextDriven /* = true */)
{
  if (list < 0 || list > 2) return ;
  bool bDeselect = SelectItem(list, item);
  // calculate the position for our menu
  float posX = 200;
  float posY = 100;
  const CGUIControl *pList = GetControl(CONTROL_LEFT_LIST + list);
  if (pList)
  {
    posX = pList->GetXPosition() + pList->GetWidth() / 2;
    posY = pList->GetYPosition() + pList->GetHeight() / 2;
  }

  CFileItemPtr pItem = m_vecItems[list]->Get(item);
  if (!pItem.get())
    return;

  if (m_Directory[list]->IsVirtualDirectoryRoot())
  {
    if (item < 0)
    { // TODO: We should add the option here for shares to be added if there aren't any
      return ;
    }

    // and do the popup menu
    if (CGUIDialogContextMenu::SourcesMenu("files", pItem, posX, posY))
    {
      m_rootDir.SetSources(g_settings.m_fileSources);
      if (m_Directory[1 - list]->IsVirtualDirectoryRoot())
        Refresh();
      else
        Refresh(list);
      return ;
    }
    pItem->Select(false);
    return ;
  }
  // popup the context menu
  CGUIDialogContextMenu *pMenu = (CGUIDialogContextMenu *)m_gWindowManager.GetWindow(WINDOW_DIALOG_CONTEXT_MENU);
  if (pMenu)
  {
    bool showEntry = false;
    if (item >= m_vecItems[list]->Size()) item = -1;
    if (item >= 0)
      showEntry=(!pItem->IsParentFolder() || (pItem->IsParentFolder() && m_vecItems[list]->GetSelectedCount()>0));

    // determine available players
    VECPLAYERCORES vecCores;
    CPlayerCoreFactory::GetPlayers(*pItem, vecCores);

    // load our menu
    pMenu->Initialize();
    // add the needed buttons
    int btn_SelectAll = pMenu->AddButton(188); // SelectAll

    int btn_HandleFavourite;  // Add/Remove Favourite
    if (CFavourites::IsFavourite(pItem.get(), GetID()))
      btn_HandleFavourite = pMenu->AddButton(14077);
    else
      btn_HandleFavourite = pMenu->AddButton(14076);

    int btn_PlayUsing = pMenu->AddButton(15213); // Play Using ..
    int btn_Rename = pMenu->AddButton(118); // Rename
    int btn_Delete = pMenu->AddButton(117); // Delete
    int btn_Copy = pMenu->AddButton(115); // Copy
    int btn_Move = pMenu->AddButton(116); // Move
    int btn_NewFolder = pMenu->AddButton(20309); // New Folder
    int btn_Size = pMenu->AddButton(13393); // Calculate Size
    int btn_Settings = pMenu->AddButton(5);     // Settings
    int btn_GoToRoot = pMenu->AddButton(20128); // Go To Root
    int btn_Switch = pMenu->AddButton(523);     // switch media

    pMenu->EnableButton(btn_SelectAll, item >= 0);
    pMenu->EnableButton(btn_HandleFavourite, item >=0 && !pItem->IsParentFolder());
    pMenu->EnableButton(btn_PlayUsing, item >= 0 && vecCores.size() > 1);
    pMenu->EnableButton(btn_Rename, item >= 0 && CanRename(list) && !pItem->IsParentFolder());
    pMenu->EnableButton(btn_Delete, item >= 0 && CanDelete(list) && showEntry);
    pMenu->EnableButton(btn_Copy, item >= 0 && CanCopy(list) && showEntry);
    pMenu->EnableButton(btn_Move, item >= 0 && CanMove(list) && showEntry);
    pMenu->EnableButton(btn_NewFolder, CanNewFolder(list));
    pMenu->EnableButton(btn_Size, item >=0 && pItem->m_bIsFolder && !pItem->IsParentFolder());

    // position it correctly
    pMenu->OffsetPosition(posX, posY);
    pMenu->DoModal();
    int btnid = pMenu->GetButton();
    if (btnid == btn_SelectAll)
    {
      OnSelectAll(list);
      bDeselect=false;
    }
    if (btnid == btn_HandleFavourite)
    {
      CFavourites::AddOrRemove(pItem.get(), GetID());
      return;
    }
    if (btnid == btn_PlayUsing)
    {
      VECPLAYERCORES vecCores;
      CPlayerCoreFactory::GetPlayers(*pItem, vecCores);
      g_application.m_eForcedNextPlayer = CPlayerCoreFactory::SelectPlayerDialog(vecCores);
      if (g_application.m_eForcedNextPlayer != EPC_NONE)
        OnStart(pItem.get());
    }
    if (btnid == btn_Rename)
      OnRename(list);
    if (btnid == btn_Delete)
      OnDelete(list);
    if (btnid == btn_Copy)
      OnCopy(list);
    if (btnid == btn_Move)
      OnMove(list);
    if (btnid == btn_NewFolder)
      OnNewFolder(list);
    if (btnid == btn_Size)
    {
      // setup the progress dialog, and show it
      CGUIDialogProgress *progress = (CGUIDialogProgress *)m_gWindowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
      if (progress)
      {
        progress->SetHeading(13394);
        for (int i=0; i < 3; i++)
          progress->SetLine(i, "");
        progress->StartModal();
      }

      //  Calculate folder size for each selected item
      for (int i=0; i<m_vecItems[list]->Size(); ++i)
      {
        CFileItemPtr pItem2=m_vecItems[list]->Get(i);
        if (pItem2->m_bIsFolder && pItem2->IsSelected())
        {
          __int64 folderSize = CalculateFolderSize(pItem2->m_strPath, progress);
          if (folderSize >= 0)
          {
            pItem2->m_dwSize = folderSize;
            if (folderSize == 0)
              pItem2->SetLabel2(StringUtils::SizeToString(folderSize));
            else
              pItem2->SetFileSizeLabel();
          }
        }
      }
      if (progress)
        progress->Close();
    }
    if (btnid == btn_Settings)
    {
      m_gWindowManager.ActivateWindow(WINDOW_SETTINGS_MENU);
      return;
    }
    if (btnid == btn_GoToRoot)
    {
      Update(list,"");
      return;
    }
    if (btnid == btn_Switch)
    {
      CGUIDialogContextMenu::SwitchMedia("files", m_vecItems[list]->m_strPath);
      return;
    }

    if (bDeselect && item >= 0 && item < m_vecItems[list]->Size())
    { // deselect item as we didn't do anything
      pItem->Select(false);
    }
  }
}
Example #23
0
bool CMultiPathDirectory::GetDirectory(const CURL& url, CFileItemList &items)
{
  CLog::Log(LOGDEBUG,"CMultiPathDirectory::GetDirectory(%s)", url.GetRedacted().c_str());

  std::vector<std::string> vecPaths;
  if (!GetPaths(url, vecPaths))
    return false;

  XbmcThreads::EndTime progressTime(3000); // 3 seconds before showing progress bar
  CGUIDialogProgress* dlgProgress = NULL;

  unsigned int iFailures = 0;
  for (unsigned int i = 0; i < vecPaths.size(); ++i)
  {
    // show the progress dialog if we have passed our time limit
    if (progressTime.IsTimePast() && !dlgProgress)
    {
      dlgProgress = g_windowManager.GetWindow<CGUIDialogProgress>(WINDOW_DIALOG_PROGRESS);
      if (dlgProgress)
      {
        dlgProgress->SetHeading(CVariant{15310});
        dlgProgress->SetLine(0, CVariant{15311});
        dlgProgress->SetLine(1, CVariant{""});
        dlgProgress->SetLine(2, CVariant{""});
        dlgProgress->Open();
        dlgProgress->ShowProgressBar(true);
        dlgProgress->SetProgressMax((int)vecPaths.size()*2);
        dlgProgress->Progress();
      }
    }
    if (dlgProgress)
    {
      CURL url(vecPaths[i]);
      dlgProgress->SetLine(1, CVariant{url.GetWithoutUserDetails()});
      dlgProgress->SetProgressAdvance();
      dlgProgress->Progress();
    }

    CFileItemList tempItems;
    CLog::Log(LOGDEBUG,"Getting Directory (%s)", vecPaths[i].c_str());
    if (CDirectory::GetDirectory(vecPaths[i], tempItems, m_strFileMask, m_flags))
      items.Append(tempItems);
    else
    {
      CLog::Log(LOGERROR,"Error Getting Directory (%s)", vecPaths[i].c_str());
      iFailures++;
    }

    if (dlgProgress)
    {
      dlgProgress->SetProgressAdvance();
      dlgProgress->Progress();
    }
  }

  if (dlgProgress)
    dlgProgress->Close();

  if (iFailures == vecPaths.size())
    return false;

  // merge like-named folders into a sub multipath:// style url
  MergeItems(items);

  return true;
}
bool CVirtualPathDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
{
  CLog::Log(LOGDEBUG,"CVirtualPathDirectory::GetDirectory(%s)", strPath.c_str());

  CMediaSource share;
  if (!GetMatchingSource(strPath, share))
    return false;

  DWORD progressTime = timeGetTime() + 3000L;   // 3 seconds before showing progress bar
  CGUIDialogProgress* dlgProgress = NULL;

  unsigned int iFailures = 0;
  for (int i = 0; i < (int)share.vecPaths.size(); ++i)
  {
    // show the progress dialog if we have passed our time limit
    if (timeGetTime() > progressTime && !dlgProgress)
    {
      dlgProgress = (CGUIDialogProgress *)m_gWindowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
      if (dlgProgress)
      {
        dlgProgress->SetHeading(15310);
        dlgProgress->SetLine(0, 15311);
        dlgProgress->SetLine(1, "");
        dlgProgress->SetLine(2, "");
        dlgProgress->StartModal();
        dlgProgress->ShowProgressBar(true);
        dlgProgress->SetProgressMax((int)share.vecPaths.size()*2);
        dlgProgress->Progress();
      }
    }
    if (dlgProgress)
    {
      CURL url(share.vecPaths[i]);
      CStdString strStripped;
      url.GetURLWithoutUserDetails(strStripped);
      dlgProgress->SetLine(1, strStripped);
      dlgProgress->SetProgressAdvance();
      dlgProgress->Progress();
    }

    CFileItemList tempItems;
    CLog::Log(LOGDEBUG,"Getting Directory (%s)", share.vecPaths[i].c_str());
    if (CDirectory::GetDirectory(share.vecPaths[i], tempItems, m_strFileMask, m_useFileDirectories, m_allowPrompting, m_cacheDirectory, m_extFileInfo))
      items.Append(tempItems);
    else
    {
      CLog::Log(LOGERROR,"Error Getting Directory (%s)", share.vecPaths[i].c_str());
      iFailures++;
    }

    if (dlgProgress)
    {
      dlgProgress->SetProgressAdvance();
      dlgProgress->Progress();
    }
  }

  if (dlgProgress)
    dlgProgress->Close();

  if (iFailures == share.vecPaths.size())
    return false;

  return true;
}
Example #25
0
void CGUIWindowFileManager::OnPopupMenu(int list, int item, bool bContextDriven /* = true */)
{
/*
	歌方:
		1、
		
	卦指:
		1、
		
	傍苧:
		1、
*/
	if (list < 0 || list > 2) 
		return ;
	
	bool bDeselect = SelectItem(list, item);
	// calculate the position for our menu
	float posX = 200;
	float posY = 100;
	const CGUIControl *pList = GetControl(CONTROL_LEFT_LIST + list);
	if (pList)
	{
		posX = pList->GetXPosition() + pList->GetWidth() / 2;
		posY = pList->GetYPosition() + pList->GetHeight() / 2;
	}

	CFileItemPtr pItem = m_vecItems[list]->Get(item);
	if (!pItem.get())
		return;

	if (m_Directory[list]->IsVirtualDirectoryRoot())
	{
		if (item < 0)
		{ // TODO: We should add the option here for shares to be added if there aren't any
			return ;
		}

		// and do the popup menu
		if (CGUIDialogContextMenu::SourcesMenu("files", pItem, posX, posY))
		{
			m_rootDir.SetSources(g_settings.m_fileSources);
			if (m_Directory[1 - list]->IsVirtualDirectoryRoot())
				Refresh();
			else
				Refresh(list);
			
			return ;
		}
		pItem->Select(false);
		return ;
	}
	// popup the context menu

	bool showEntry = false;
	if (item >= m_vecItems[list]->Size()) 
		item = -1;
	if (item >= 0)
		showEntry=(!pItem->IsParentFolder() || (pItem->IsParentFolder() && m_vecItems[list]->GetSelectedCount()>0));

	// determine available players
	VECPLAYERCORES vecCores;
	CPlayerCoreFactory::GetPlayers(*pItem, vecCores);

	// add the needed buttons
	CContextButtons choices;
	if (item >= 0)
	{
		choices.Add(1, 188); // SelectAll
		if (!pItem->IsParentFolder())
			choices.Add(2, CFavourites::IsFavourite(pItem.get(), GetID()) ? 14077 : 14076); // Add/Remove Favourite
		if (vecCores.size() > 1)
			choices.Add(3, 15213); // Play Using...
		if (CanRename(list) && !pItem->IsParentFolder())
			choices.Add(4, 118); // Rename
		if (CanDelete(list) && showEntry)
			choices.Add(5, 117); // Delete
		if (CanCopy(list) && showEntry)
			choices.Add(6, 115); // Copy
		if (CanMove(list) && showEntry)
			choices.Add(7, 116); // Move
	}
	
	if (CanNewFolder(list))
		choices.Add(8, 20309); // New Folder
		
	if (item >= 0 && pItem->m_bIsFolder && !pItem->IsParentFolder())
		choices.Add(9, 13393); // Calculate Size
		
	choices.Add(10, 5);     // Settings
	choices.Add(11, 20128); // Go To Root
	choices.Add(12, 523);     // switch media

	int btnid = CGUIDialogContextMenu::ShowAndGetChoice(choices);
	if (btnid == 1)
	{
		OnSelectAll(list);
		bDeselect=false;
	}
	
	if (btnid == 2)
	{
		CFavourites::AddOrRemove(pItem.get(), GetID());
		return;
	}
	
	if (btnid == 3)
	{
		VECPLAYERCORES vecCores;
		CPlayerCoreFactory::GetPlayers(*pItem, vecCores);
		g_application.m_eForcedNextPlayer = CPlayerCoreFactory::SelectPlayerDialog(vecCores);
		if (g_application.m_eForcedNextPlayer != EPC_NONE)
			OnStart(pItem.get());
	}
	
	if (btnid == 4)
		OnRename(list);
	
	if (btnid == 5)
		OnDelete(list);
	
	if (btnid == 6)
		OnCopy(list);
	
	if (btnid == 7)
		OnMove(list);
	
	if (btnid == 8)
		OnNewFolder(list);
	
	if (btnid == 9)
	{
		// setup the progress dialog, and show it
		CGUIDialogProgress *progress = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
		if (progress)
		{
			progress->SetHeading(13394);
			for (int i=0; i < 3; i++)
				progress->SetLine(i, "");
			progress->StartModal();
		}

		//  Calculate folder size for each selected item
		for (int i=0; i<m_vecItems[list]->Size(); ++i)
		{
			CFileItemPtr pItem2=m_vecItems[list]->Get(i);
			if (pItem2->m_bIsFolder && pItem2->IsSelected())
			{
				int64_t folderSize = CalculateFolderSize(pItem2->GetPath(), progress);
				if (folderSize >= 0)
				{
					pItem2->m_dwSize = folderSize;
					if (folderSize == 0)
						pItem2->SetLabel2(StringUtils::SizeToString(folderSize));
					else
						pItem2->SetFileSizeLabel();
				}
			}
		}
		
		if (progress)
			progress->Close();
	}
	
	if (btnid == 10)
	{
		g_windowManager.ActivateWindow(WINDOW_SETTINGS_MENU);
		return;
	}
	
	if (btnid == 11)
	{
		Update(list,"");
		return;
	}
	
	if (btnid == 12)
	{
		CGUIDialogContextMenu::SwitchMedia("files", m_vecItems[list]->GetPath());
		return;
	}

	if (bDeselect && item >= 0 && item < m_vecItems[list]->Size())
	{ // deselect item as we didn't do anything
		pItem->Select(false);
	}
}
Example #26
0
bool CPlexDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
{
  CStdString strRoot = strPath;
  if (CUtil::HasSlashAtEnd(strRoot) && strRoot != "plex://")
    strRoot.Delete(strRoot.size() - 1);
  
  strRoot.Replace(" ", "%20");

  // Start the download thread running.
  printf("PlexDirectory::GetDirectory(%s)\n", strRoot.c_str());
  m_url = strRoot;
  CThread::Create(false, 0);

  // Now display progress, look for cancel.
  CGUIDialogProgress* dlgProgress = 0;
  
  int time = GetTickCount();
  
  while (m_downloadEvent.WaitMSec(100) == false)
  {
    // If enough time has passed, display the dialog.
    if (GetTickCount() - time > 1000 && m_allowPrompting == true)
    {
      dlgProgress = (CGUIDialogProgress*)m_gWindowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
      if (dlgProgress)
      {
        dlgProgress->ShowProgressBar(false);
        dlgProgress->SetHeading(40203);
        dlgProgress->SetLine(0, 40204);
        dlgProgress->SetLine(1, "");
        dlgProgress->SetLine(2, "");
        dlgProgress->StartModal();
      }
    }

    if (dlgProgress)
    {
      dlgProgress->Progress();
      if (dlgProgress->IsCanceled())
      {
        items.m_wasListingCancelled = true;
        m_http.Cancel();
        StopThread();
      }
    }
  }
  
  if (dlgProgress) 
    dlgProgress->Close();
  
  // Wait for the thread to exit.
  WaitForThreadExit(INFINITE);
  
  // See if we suceeded.
  if (m_bSuccess == false)
    return false;
  
  // See if we're supposed to parse the results or not.
  if (m_bParseResults == false)
    return true;
  
  // Parse returned xml.
  TiXmlDocument doc;
  doc.Parse(m_data.c_str());

  TiXmlElement* root = doc.RootElement();
  if (root == 0)
  {
    CLog::Log(LOGERROR, "%s - Unable to parse XML\n%s", __FUNCTION__, m_data.c_str());
    return false;
  }
  
  // Get the fanart.
  const char* fanart = root->Attribute("art");
  string strFanart;
  if (fanart && strlen(fanart) > 0)
    strFanart = ProcessUrl(strPath, fanart, false);

  // Walk the parsed tree.
  string strFileLabel = "%N - %T"; 
  string strDirLabel = "%B";
  string strSecondDirLabel = "%Y";
  
  Parse(m_url, root, items, strFileLabel, strDirLabel, strSecondDirLabel);
  
  // Set the window titles
  const char* title1 = root->Attribute("title1");
  const char* title2 = root->Attribute("title2");

  if (title1 && strlen(title1) > 0)
    items.SetFirstTitle(title1);
  if (title2 && strlen(title2) > 0)
    items.SetSecondTitle(title2);

  // Set fanart on items if they don't have their own.
  for (int i=0; i<items.Size(); i++)
  {
    CFileItemPtr pItem = items[i];
    
    if (strFanart.size() > 0 && pItem->GetQuickFanart().size() == 0)
      pItem->SetQuickFanart(strFanart);
      
    // Make sure sort label is lower case.
    string sortLabel = pItem->GetLabel();
    boost::to_lower(sortLabel);
    pItem->SetSortLabel(sortLabel);
  }
  
  // Set fanart on directory.
  if (strFanart.size() > 0)
    items.SetQuickFanart(strFanart);
    
  // Set the view mode.
  const char* viewmode = root->Attribute("viewmode");
  if (viewmode && strlen(viewmode) > 0)
  {
    CGUIViewState* viewState = CGUIViewState::GetViewState(0, items);
    viewState->SaveViewAsControl(atoi(viewmode));
  }
  
  // Override labels.
  const char* fileLabel = root->Attribute("filelabel");
  if (fileLabel && strlen(fileLabel) > 0)
    strFileLabel = fileLabel;

  const char* dirLabel = root->Attribute("dirlabel");
  if (dirLabel && strlen(dirLabel) > 0)
    strDirLabel = dirLabel;

  // Add the sort method.
  items.AddSortMethod(SORT_METHOD_NONE, 552, LABEL_MASKS(strFileLabel, "%D", strDirLabel, strSecondDirLabel));
  
  // Set the content label.
  const char* content = root->Attribute("content");
  if (content && strlen(content) > 0)
  {
    items.SetContent(content);
  }
  
  // Check for dialog message attributes
  CStdString strMessage = "";
  const char* header = root->Attribute("header");
  if (header && strlen(header) > 0)
  {
    const char* message = root->Attribute("message");
    if (message && strlen(message) > 0) 
      strMessage = message;
    
    items.m_displayMessage = true; 
    items.m_displayMessageTitle = header; 
    items.m_displayMessageContents = root->Attribute("message");
    
    // Don't cache these.
    m_dirCacheType = DIR_CACHE_NEVER;
  }
  
  // See if this directory replaces the parent.
  const char* replace = root->Attribute("replaceParent");
  if (replace && strcmp(replace, "1") == 0)
    items.SetReplaceListing(true);
  
  // See if we're saving this into the history or not.
  const char* noHistory = root->Attribute("noHistory");
    if (noHistory && strcmp(noHistory, "1") == 0)
      items.SetSaveInHistory(false);
  
  // See if we're not supposed to cache this directory.
  const char* noCache = root->Attribute("nocache");
  if (noCache && strcmp(noCache, "1") == 0)
    m_dirCacheType = DIR_CACHE_NEVER;
    
  return true;
}
bool CWeather::GetSearchResults(const CStdString &strSearch, CStdString &strResult)
{
  // Check to see if the user entered a weather.com code
  if (strSearch.size() == 8)
  {
    strResult = "";
    int i = 0;
    for (i = 0; i < 4; ++i)
    {
      strResult += toupper(strSearch[i]);
      if (!isalpha(strSearch[i]))
        break;
    }
    if (i == 4)
    {
      for ( ; i < 8; ++i)
      {
        strResult += strSearch[i];
        if (!isdigit(strSearch[i]))
          break;
      }
      if (i == 8)
      {
        return true; // match
      }
    }
    // no match, wipe string
    strResult = "";
  }

  CGUIDialogSelect *pDlgSelect = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT);
  CGUIDialogProgress *pDlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);

  //do the download
  CStdString strURL;
  CStdString strXML;
  XFILE::CFileCurl httpUtil;

  if (pDlgProgress)
  {
    pDlgProgress->SetHeading(410);       //"Accessing Weather.com"
    pDlgProgress->SetLine(0, 194);       //"Searching"
    pDlgProgress->SetLine(1, strSearch);
    pDlgProgress->SetLine(2, "");
    pDlgProgress->StartModal();
    pDlgProgress->Progress();
  }

  strURL.Format("http://xoap.weather.com/search/search?where=%s", strSearch);

  if (!httpUtil.Get(strURL, strXML))
  {
    if (pDlgProgress)
      pDlgProgress->Close();
    return false;
  }

  //some select dialog init stuff
  if (!pDlgSelect)
  {
    if (pDlgProgress)
      pDlgProgress->Close();
    return false;
  }

  pDlgSelect->SetHeading(396); //"Select Location"
  pDlgSelect->Reset();

  ///////////////////////////////
  // load the xml file
  ///////////////////////////////
  TiXmlDocument xmlDoc;
  xmlDoc.Parse(strXML.c_str());
  if (xmlDoc.Error())
    return false;

  TiXmlElement *pRootElement = xmlDoc.RootElement();
  if (pRootElement)
  {
    CStdString strItemTmp;
    TiXmlElement *pElement = pRootElement->FirstChildElement("loc");
    while (pElement)
    {
      if (!pElement->NoChildren())
      {
        strItemTmp.Format("%s - %s", pElement->Attribute("id"), pElement->FirstChild()->Value());
        pDlgSelect->Add(strItemTmp);
      }
      pElement = pElement->NextSiblingElement("loc");
    }
  }

  if (pDlgProgress)
    pDlgProgress->Close();

  pDlgSelect->EnableButton(true, 222); //'Cancel' button returns to weather settings
  pDlgSelect->DoModal();

  if (pDlgSelect->GetSelectedLabel() < 0)
  {
    if (pDlgSelect->IsButtonPressed())
    {
      pDlgSelect->Close(); //close the select dialog and return to weather settings
      return true;
    }
  }

  //copy the selected code into the settings
  if (pDlgSelect->GetSelectedLabel() >= 0)
    strResult = pDlgSelect->GetSelectedLabelText();

  if (pDlgProgress)
    pDlgProgress->Close();

  return true;
}
void CPVRManager::ResetDatabase(bool bResetEPGOnly /* = false */)
{
  CLog::Log(LOGNOTICE,"PVRManager - %s - clearing the PVR database", __FUNCTION__);

  g_EpgContainer.Stop();

  CGUIDialogProgress* pDlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
  pDlgProgress->SetLine(0, StringUtils::EmptyString);
  pDlgProgress->SetLine(1, g_localizeStrings.Get(19186)); // All data in the PVR database is being erased
  pDlgProgress->SetLine(2, StringUtils::EmptyString);
  pDlgProgress->StartModal();
  pDlgProgress->Progress();

  if (m_addons && m_addons->IsPlaying())
  {
    CLog::Log(LOGNOTICE,"PVRManager - %s - stopping playback", __FUNCTION__);
    CApplicationMessenger::Get().MediaStop();
  }

  pDlgProgress->SetPercentage(10);
  pDlgProgress->Progress();

  /* reset the EPG pointers */
  m_database->ResetEPG();

  /* stop the thread */
  Stop();

  pDlgProgress->SetPercentage(20);
  pDlgProgress->Progress();

  if (!m_database)
    m_database = new CPVRDatabase;

  if (m_database && m_database->Open())
  {
    /* clean the EPG database */
    g_EpgContainer.Reset();
    pDlgProgress->SetPercentage(30);
    pDlgProgress->Progress();

    if (!bResetEPGOnly)
    {
      m_database->DeleteChannelGroups();
      pDlgProgress->SetPercentage(50);
      pDlgProgress->Progress();

      /* delete all channels */
      m_database->DeleteChannels();
      pDlgProgress->SetPercentage(70);
      pDlgProgress->Progress();

      /* delete all channel settings */
      m_database->DeleteChannelSettings();
      pDlgProgress->SetPercentage(80);
      pDlgProgress->Progress();

      /* delete all client information */
      m_database->DeleteClients();
      pDlgProgress->SetPercentage(90);
      pDlgProgress->Progress();
    }

    m_database->Close();
  }

  CLog::Log(LOGNOTICE,"PVRManager - %s - %s database cleared", __FUNCTION__, bResetEPGOnly ? "EPG" : "PVR and EPG");

  if (g_guiSettings.GetBool("pvrmanager.enabled"))
  {
    CLog::Log(LOGNOTICE,"PVRManager - %s - restarting the PVRManager", __FUNCTION__);
    m_database->Open();
    Cleanup();
    Start();
  }

  pDlgProgress->SetPercentage(100);
  pDlgProgress->Close();
}
void CGUIWindowFileManager::OnPopupMenu(int list, int item, bool bContextDriven /* = true */)
{
  if (list < 0 || list >= 2) return ;
  bool bDeselect = SelectItem(list, item);
  // calculate the position for our menu
  float posX = 200;
  float posY = 100;
  const CGUIControl *pList = GetControl(CONTROL_LEFT_LIST + list);
  if (pList)
  {
    posX = pList->GetXPosition() + pList->GetWidth() / 2;
    posY = pList->GetYPosition() + pList->GetHeight() / 2;
  }

  CFileItemPtr pItem = m_vecItems[list]->Get(item);
  if (!pItem.get())
    return;

  if (m_Directory[list]->IsVirtualDirectoryRoot())
  {
    if (item < 0)
    { // TODO: We should add the option here for shares to be added if there aren't any
      return ;
    }

    // and do the popup menu
    if (CGUIDialogContextMenu::SourcesMenu("files", pItem, posX, posY))
    {
      m_rootDir.SetSources(*CMediaSourceSettings::GetInstance().GetSources("files"));
      if (m_Directory[1 - list]->IsVirtualDirectoryRoot())
        Refresh();
      else
        Refresh(list);
      return ;
    }
    pItem->Select(false);
    return ;
  }
  // popup the context menu

  bool showEntry = false;
  if (item >= m_vecItems[list]->Size()) item = -1;
  if (item >= 0)
    showEntry=(!pItem->IsParentFolder() || (pItem->IsParentFolder() && m_vecItems[list]->GetSelectedCount()>0));

  // determine available players
  std::vector<std::string>players;
  CPlayerCoreFactory::GetInstance().GetPlayers(*pItem, players);

  // add the needed buttons
  CContextButtons choices;
  if (item >= 0)
  {
    //The ".." item is not selectable. Take that into account when figuring out if all items are selected
    int notSelectable = CSettings::GetInstance().GetBool(CSettings::SETTING_FILELISTS_SHOWPARENTDIRITEMS) ? 1 : 0;
    if (NumSelected(list) <  m_vecItems[list]->Size() - notSelectable)
      choices.Add(CONTROL_BTNSELECTALL, 188); // SelectAll
    if (!pItem->IsParentFolder())
      choices.Add(CONTROL_BTNFAVOURITES,  XFILE::CFavouritesDirectory::IsFavourite(pItem.get(), GetID()) ? 14077 : 14076); // Add/Remove Favourite
    if (players.size() > 1)
      choices.Add(CONTROL_BTNPLAYWITH, 15213);
    if (CanRename(list) && !pItem->IsParentFolder())
      choices.Add(CONTROL_BTNRENAME, 118);
    if (CanDelete(list) && showEntry)
      choices.Add(CONTROL_BTNDELETE, 117);
    if (CanCopy(list) && showEntry)
      choices.Add(CONTROL_BTNCOPY, 115);
    if (CanMove(list) && showEntry)
      choices.Add(CONTROL_BTNMOVE, 116);
  }
  if (CanNewFolder(list))
    choices.Add(CONTROL_BTNNEWFOLDER, 20309);
  if (item >= 0 && pItem->m_bIsFolder && !pItem->IsParentFolder())
    choices.Add(CONTROL_BTNCALCSIZE, 13393);
  choices.Add(CONTROL_BTNGOTOROOT, 20128);
  choices.Add(CONTROL_BTNSWITCHMEDIA, 523);
  if (CJobManager::GetInstance().IsProcessing("filemanager"))
    choices.Add(CONTROL_BTNCANCELJOB, 167);

  int btnid = CGUIDialogContextMenu::ShowAndGetChoice(choices);
  if (btnid == CONTROL_BTNSELECTALL)
  {
    OnSelectAll(list);
    bDeselect=false;
  }
  if (btnid == CONTROL_BTNFAVOURITES)
  {
    XFILE::CFavouritesDirectory::AddOrRemove(pItem.get(), GetID());
    return;
  }
  if (btnid == CONTROL_BTNPLAYWITH)
  {
    std::vector<std::string>players;
    CPlayerCoreFactory::GetInstance().GetPlayers(*pItem, players);
    std::string player = CPlayerCoreFactory::GetInstance().SelectPlayerDialog(players);
    if (!player.empty())
      OnStart(pItem.get(), player);
  }
  if (btnid == CONTROL_BTNRENAME)
    OnRename(list);
  if (btnid == CONTROL_BTNDELETE)
    OnDelete(list);
  if (btnid == CONTROL_BTNCOPY)
    OnCopy(list);
  if (btnid == CONTROL_BTNMOVE)
    OnMove(list);
  if (btnid == CONTROL_BTNNEWFOLDER)
    OnNewFolder(list);
  if (btnid == CONTROL_BTNCALCSIZE)
  {
    // setup the progress dialog, and show it
    CGUIDialogProgress *progress = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
    if (progress)
    {
      progress->SetHeading(CVariant{13394});
      for (int i=0; i < 3; i++)
        progress->SetLine(i, CVariant{""});
      progress->Open();
    }

    //  Calculate folder size for each selected item
    for (int i=0; i<m_vecItems[list]->Size(); ++i)
    {
      CFileItemPtr pItem2=m_vecItems[list]->Get(i);
      if (pItem2->m_bIsFolder && pItem2->IsSelected())
      {
        int64_t folderSize = CalculateFolderSize(pItem2->GetPath(), progress);
        if (folderSize >= 0)
        {
          pItem2->m_dwSize = folderSize;
          if (folderSize == 0)
            pItem2->SetLabel2(StringUtils::SizeToString(folderSize));
          else
            pItem2->SetFileSizeLabel();
        }
      }
    }
    if (progress)
      progress->Close();
  }
  if (btnid == CONTROL_BTNGOTOROOT)
  {
    Update(list,"");
    return;
  }
  if (btnid == CONTROL_BTNSWITCHMEDIA)
  {
    CGUIDialogContextMenu::SwitchMedia("files", m_vecItems[list]->GetPath());
    return;
  }
  if (btnid == CONTROL_BTNCANCELJOB)
    CancelJobs();

  if (bDeselect && item >= 0 && item < m_vecItems[list]->Size())
  { // deselect item as we didn't do anything
    pItem->Select(false);
  }
}
Example #30
0
bool CShoutcastDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
{

  CStdString strRoot = strPath;
  if (CUtil::HasSlashAtEnd(strRoot))
    strRoot.Delete(strRoot.size() - 1);

  /* for old users wich doesn't have the full url */
  if( strRoot.Equals("shout://www.shoutcast.com") )
    strRoot = "shout://www.shoutcast.com/sbin/newxml.phtml";

  if (g_directoryCache.GetDirectory(strRoot, items))
    return true;

  CGUIDialogProgress* dlgProgress = (CGUIDialogProgress*)m_gWindowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
  if (dlgProgress)
  {
    dlgProgress->ShowProgressBar(false);
    dlgProgress->SetHeading(260);
    dlgProgress->SetLine(0, 14003);
    dlgProgress->SetLine(1, "");
    dlgProgress->SetLine(2, "");
    dlgProgress->StartModal();
  }

  CURL url(strRoot);
  CStdString protocol = url.GetProtocol();
  url.SetProtocol("http");

  CFileCurl http;

  //CURL doesn't seem to understand that data is encoded.. odd
  // opening as text for now
  //http.SetContentEncoding("deflate");

  if( !http.Open(url, false) ) 
  {
    CLog::Log(LOGERROR, "%s - Unable to get shoutcast dir", __FUNCTION__);
    if (dlgProgress) dlgProgress->Close();
    return false;
  }

  /* restore protocol */
  url.SetProtocol(protocol);

  CStdString content = http.GetContent();
  if( !(content.Equals("text/html") || content.Equals("text/xml") 
	  || content.Equals("text/html;charset=utf-8") || content.Equals("text/xml;charset=utf-8") ))
  {
    CLog::Log(LOGERROR, "%s - Invalid content type %s", __FUNCTION__, content.c_str());
    if (dlgProgress) dlgProgress->Close();
    return false;
  }
  
  
  int size_read = 0;  
  int size_total = (int)http.GetLength();
  int data_size = 0;

  CStdString data;
  data.reserve(size_total);
  
  /* read response from server into string buffer */
  char buffer[16384];
  while( (size_read = http.Read(buffer, sizeof(buffer)-1)) > 0 )
  {
    buffer[size_read] = 0;
    data += buffer;
    data_size += size_read;

    dlgProgress->Progress();

    if (dlgProgress->IsCanceled())
    {
      dlgProgress->Close();
      return false;
    }
  }

  /* parse returned xml */
  TiXmlDocument doc;
  doc.Parse(data.c_str());

  TiXmlElement *root = doc.RootElement();
  if(root == NULL)
  {
    CLog::Log(LOGERROR, "%s - Unable to parse xml", __FUNCTION__);
    CLog::Log(LOGDEBUG, "%s - Sample follows...\n%s", __FUNCTION__, data.c_str());

    dlgProgress->Close();
    return false;
  }

  /* clear data to keep memusage down, not needed anymore */
  data.Empty();

  bool result = false;
  if( strcmp(root->Value(), "genrelist") == 0 )
    result = ParseGenres(root, items, url);
  else if( strcmp(root->Value(), "stationlist") == 0 )
    result = ParseStations(root, items, url);
  else
  {
    CLog::Log(LOGERROR, "%s - Invalid root xml element for shoutcast",__FUNCTION__);
    CLog::Log(LOGDEBUG, "%s - Sample follows...\n%s", __FUNCTION__, data.c_str());
  }

  CFileItemList vecCacheItems;  
  g_directoryCache.ClearDirectory(strRoot);
  for( int i = 0; i <items.Size(); i++ )
  {
    CFileItem* pItem=items[i];
    if (!pItem->IsParentFolder())
      vecCacheItems.Add(new CFileItem( *pItem ));
  }
  g_directoryCache.SetDirectory(strRoot, vecCacheItems);
  if (dlgProgress) dlgProgress->Close();
  return result;
}