Exemplo n.º 1
0
bool CGUIPassword::IsDatabasePathUnlocked(const std::string& strPath, VECSOURCES& vecSources)
{
  if (g_passwordManager.bMasterUser || CProfilesManager::GetInstance().GetMasterProfile().getLockMode() == LOCK_MODE_EVERYONE)
    return true;

  // try to find the best matching source
  bool bName = false;
  int iIndex = CUtil::GetMatchingSource(strPath, vecSources, bName);

  if (iIndex > -1 && iIndex < (int)vecSources.size())
    if (vecSources[iIndex].m_iHasLock < 2)
      return true;

  return false;
}
Exemplo n.º 2
0
bool CGUIDialogMediaSource::ShowAndEditMediaSource(const std::string &type, const CMediaSource &share)
{
  std::string strOldName = share.strName;
  CGUIDialogMediaSource *dialog = (CGUIDialogMediaSource *)g_windowManager.GetWindow(WINDOW_DIALOG_MEDIA_SOURCE);
  if (!dialog) return false;
  dialog->Initialize();
  dialog->SetShare(share);
  dialog->SetTypeOfMedia(type, true);
  dialog->Open();
  bool confirmed(dialog->IsConfirmed());
  if (confirmed)
  { // yay, add this share
    unsigned int i, j = 2;
    bool bConfirmed = false;
    VECSOURCES* pShares = CMediaSourceSettings::GetInstance().GetSources(type);
    std::string strName = dialog->m_name;
    while (!bConfirmed)
    {
      for (i = 0;i<pShares->size();++i)
      {
        if (StringUtils::EqualsNoCase((*pShares)[i].strName, strName))
          break;
      }
      if (i < pShares->size() && (*pShares)[i].strName != strOldName) // found a match -  try next
        strName = StringUtils::Format("%s (%i)", dialog->m_name.c_str(), j++);
      else
        bConfirmed = true;
    }

    CMediaSource newShare;
    newShare.FromNameAndPaths(type, strName, dialog->GetPaths());
    CMediaSourceSettings::GetInstance().UpdateShare(type, strOldName, newShare);
  }
  dialog->m_paths->Clear();
  return confirmed;
}
Exemplo n.º 3
0
bool CGUIDialogFileBrowser::ShowAndGetDirectory(const VECSOURCES &shares, const std::string &heading, std::string &path, bool bWriteOnly)
{
  // an extension mask of "/" ensures that no files are shown
  if (bWriteOnly)
  {
    VECSOURCES shareWritable;
    for (unsigned int i=0;i<shares.size();++i)
    {
      if (shares[i].IsWritable())
        shareWritable.push_back(shares[i]);
    }

    return ShowAndGetFile(shareWritable, "/w", heading, path);
  }

  return ShowAndGetFile(shares, "/", heading, path);
}
Exemplo n.º 4
0
CStdString CGUIWindowJukeboxSongs::GetStartFolder(const CStdString &dir) {
  SetupShares();
  VECSOURCES shares;
  m_rootDir.GetSources(shares);
  bool bIsSourceName = false;
  int iIndex = CUtil::GetMatchingSource(dir, shares, bIsSourceName);
  if (iIndex > -1) {
    if (iIndex < (int) shares.size() && shares[iIndex].m_iHasLock == 2) {
      CFileItem item(shares[iIndex]);
      if (!g_passwordManager.IsItemUnlocked(&item, "music"))
        return "";
    }
    // set current directory to matching share
    if (bIsSourceName)
      return shares[iIndex].strPath;
    return dir;
  }
  return CGUIWindowJukeboxBase::GetStartFolder(dir);
}
Exemplo n.º 5
0
bool CFileUtils::RemoteAccessAllowed(const CStdString &strPath)
{
    const unsigned int SourcesSize = 5;
    CStdString SourceNames[] = { "programs", "files", "video", "music", "pictures" };

    string realPath = URIUtils::GetRealPath(strPath);
    // for rar:// and zip:// paths we need to extract the path to the archive
    // instead of using the VFS path
    while (URIUtils::IsInArchive(realPath))
        realPath = CURL(realPath).GetHostName();

    if (StringUtils::StartsWithNoCase(realPath, "virtualpath://upnproot/"))
        return true;
    else if (StringUtils::StartsWithNoCase(realPath, "musicdb://"))
        return true;
    else if (StringUtils::StartsWithNoCase(realPath, "videodb://"))
        return true;
    else if (StringUtils::StartsWithNoCase(realPath, "library://video"))
        return true;
    else if (StringUtils::StartsWithNoCase(realPath, "sources://video"))
        return true;
    else if (StringUtils::StartsWithNoCase(realPath, "special://musicplaylists"))
        return true;
    else if (StringUtils::StartsWithNoCase(realPath, "special://profile/playlists"))
        return true;
    else if (StringUtils::StartsWithNoCase(realPath, "special://videoplaylists"))
        return true;
    else if (StringUtils::StartsWithNoCase(realPath, "addons://sources"))
        return true;
    else if (StringUtils::StartsWithNoCase(realPath, "upnp://"))
        return true;
    else if (StringUtils::StartsWithNoCase(realPath, "plugin://"))
        return true;
    bool isSource;
    for (unsigned int index = 0; index < SourcesSize; index++)
    {
        VECSOURCES* sources = CMediaSourceSettings::Get().GetSources(SourceNames[index]);
        int sourceIndex = CUtil::GetMatchingSource(realPath, *sources, isSource);
        if (sourceIndex >= 0 && sourceIndex < (int)sources->size() && sources->at(sourceIndex).m_iHasLock != 2 && sources->at(sourceIndex).m_allowSharing)
            return true;
    }
    return false;
}
Exemplo n.º 6
0
std::string CMediaManager::GetDiscPath()
{
#ifdef TARGET_WINDOWS
  return g_mediaManager.TranslateDevicePath("");
#else

  CSingleLock lock(m_CritSecStorageProvider);
  VECSOURCES drives;
  m_platformStorage->GetRemovableDrives(drives);
  for(unsigned i = 0; i < drives.size(); ++i)
  {
    if(drives[i].m_iDriveType == CMediaSource::SOURCE_TYPE_DVD && !drives[i].strPath.empty())
      return drives[i].strPath;
  }

  // iso9660://, cdda://local/ or D:\ depending on disc type
  return MEDIA_DETECT::CDetectDVDMedia::GetDVDPath();
#endif
}
Exemplo n.º 7
0
void CGUIWindowBoxeeBrowseLocal::UpdateEjectButtonState()
{
#ifndef HAS_EMBEDDED
  SET_CONTROL_HIDDEN(BUTTON_EJECT);
  SET_CONTROL_HIDDEN(BUTTON_EJECT_USER);
#else
  CStdString strPath =  ((CLocalBrowseWindowState*)m_windowState)->GetCurrentPath();

  if (CUtil::HasSlashAtEnd(strPath))
  {
    // remove slash at the end
    strPath.Delete(strPath.size() - 1);
  }

  if(!strPath.Equals("afp://") && !strPath.Equals("afp://all") && strPath.Find("afp://") != -1)
  {
    SET_CONTROL_VISIBLE(BUTTON_EJECT_USER);
    SET_CONTROL_HIDDEN(BUTTON_EJECT);
    return;
  }

  if (strPath != "network://protocols" && strPath != "")
  {
    SET_CONTROL_HIDDEN(BUTTON_EJECT);
    SET_CONTROL_HIDDEN(BUTTON_EJECT_USER);
    return;
  }


  VECSOURCES removableDrives;
  g_mediaManager.GetRemovableDrives(removableDrives);
  if (removableDrives.size() == 0)
  {
    SET_CONTROL_HIDDEN(BUTTON_EJECT);
    SET_CONTROL_HIDDEN(BUTTON_EJECT_USER);
    return;
  }

  SET_CONTROL_HIDDEN(BUTTON_EJECT_USER);
  SET_CONTROL_VISIBLE(BUTTON_EJECT);
#endif
}
Exemplo n.º 8
0
/*!
 \brief Is the share \e path in the virtual directory.
 \param path Share to test
 \return Returns \e true, if share is in the virtual directory.
 \note The parameter \e path CAN be a share with directory. Eg. "iso9660://dir" will
       return the same as "iso9660://".
 */
bool CVirtualDirectory::IsInSource(const CStdString &path) const
{
  bool isSourceName;
  VECSOURCES shares;
  GetSources(shares);
  int iShare = CUtil::GetMatchingSource(path, shares, isSourceName);
  if (URIUtils::IsOnDVD(path))
  { // check to see if our share path is still available and of the same type, as it changes during autodetect
    // and GetMatchingSource() is too naive at it's matching
    for (unsigned int i = 0; i < shares.size(); i++)
    {
      CMediaSource &share = shares[i];
      if (URIUtils::IsOnDVD(share.strPath) && share.strPath.Equals(path.Left(share.strPath.GetLength())))
        return true;
    }
    return false;
  }
  // TODO: May need to handle other special cases that GetMatchingSource() fails on
  return (iShare > -1);
}
Exemplo n.º 9
0
void CVirtualDirectory::GetSources(VECSOURCES &shares) const
{
  shares = m_vecSources;
  // add our plug n play shares

#ifndef IS_PROFESSIONAL // Laureon: Added: Jukebox: Professional mode shouldn't list removable sources
  if (m_allowNonLocalSources)
    g_mediaManager.GetRemovableDrives(shares);
#endif

#ifdef HAS_DVD_DRIVE
  // and update our dvd share
  for (unsigned int i = 0; i < shares.size(); ++i)
  {
    CMediaSource& share = shares[i];
    if (share.m_iDriveType == CMediaSource::SOURCE_TYPE_DVD)
    {
      if(g_mediaManager.IsAudio(share.strPath))
      {
        share.strStatus = "Audio-CD";
        share.strPath = "cdda://local/";
        share.strDiskUniqueId = "";
      }
      else
      {
        share.strStatus = g_mediaManager.GetDiskLabel(share.strPath);
        share.strDiskUniqueId = g_mediaManager.GetDiskUniqueId(share.strPath);
        if (!share.strPath.length()) // unmounted CD
        {
          if (g_mediaManager.GetDiscPath() == "iso9660://")
            share.strPath = "iso9660://";
          else
            // share is unmounted and not iso9660, discard it
            shares.erase(shares.begin() + i--);
        }
      }
    }
  }
#endif
}
bool CVirtualPathDirectory::GetMatchingSource(const CStdString &strPath, CMediaSource& share)
{
  CStdString strType, strSource;
  if (!GetTypeAndSource(strPath, strType, strSource))
    return false;

  // no support for "files" operation
  if (strType == "files")
    return false;
  VECSOURCES *VECSOURCES = g_settings.GetSourcesFromType(strType);
  if (!VECSOURCES)
    return false;

  bool bIsSourceName = false;
  int iIndex = CUtil::GetMatchingSource(strSource, *VECSOURCES, bIsSourceName);
  if (!bIsSourceName)
    return false;
  if (iIndex < 0 || iIndex >= (int)VECSOURCES->size())
    return false;

  share = (*VECSOURCES)[iIndex];
  return true;
}
Exemplo n.º 11
0
CStdString CGUIWindowPictures::GetStartFolder(const CStdString &dir)
{
  if (dir.Equals("Plugins") || dir.Equals("Addons"))
    return "addons://sources/image/";

  SetupShares();
  VECSOURCES shares;
  m_rootDir.GetSources(shares);
  bool bIsSourceName = false;
  int iIndex = CUtil::GetMatchingSource(dir, shares, bIsSourceName);
  if (iIndex > -1)
  {
    if (iIndex < (int)shares.size() && shares[iIndex].m_iHasLock == 2)
    {
      CFileItem item(shares[iIndex]);
      if (!g_passwordManager.IsItemUnlocked(&item,"pictures"))
        return "";
    }
    if (bIsSourceName)
      return shares[iIndex].strPath;
    return dir;
  }
  return CGUIMediaWindow::GetStartFolder(dir);
}
Exemplo n.º 12
0
JSONRPC_STATUS CFileOperations::GetRootDirectory(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
{
  CStdString media = parameterObject["media"].asString();
  media = media.ToLower();

  VECSOURCES *sources = g_settings.GetSourcesFromType(media);
  if (sources)
  {
    CFileItemList items;
    for (unsigned int i = 0; i < (unsigned int)sources->size(); i++)
    {
      // Do not show sources which are locked
      if (sources->at(i).m_iHasLock == 2)
        continue;

      items.Add(CFileItemPtr(new CFileItem(sources->at(i))));
    }

    for (unsigned int i = 0; i < (unsigned int)items.Size(); i++)
    {
      if (items[i]->IsSmb())
      {
        CURL url(items[i]->GetPath());
        items[i]->SetPath(url.GetWithoutUserDetails());
      }
    }

    CVariant param = parameterObject;
    param["properties"] = CVariant(CVariant::VariantTypeArray);
    param["properties"].append("file");

    HandleFileItemList(NULL, true, "sources", items, param, result);
  }

  return OK;
}
Exemplo n.º 13
0
bool CGUIWindowPrograms::OnMessage(CGUIMessage& message)
{
  switch ( message.GetMessage() )
  {
  case GUI_MSG_WINDOW_DEINIT:
    {
      if (m_thumbLoader.IsLoading())
        m_thumbLoader.StopThread();
      m_database.Close();
    }
    break;

  case GUI_MSG_WINDOW_INIT:
    {
      m_iRegionSet = 0;
      m_dlgProgress = (CGUIDialogProgress*)m_gWindowManager.GetWindow(WINDOW_DIALOG_PROGRESS);

      // check for a passed destination path

      CStdString strDestination = message.GetStringParam();
      if (!strDestination.IsEmpty())
      {
        message.SetStringParam("");
        CLog::Log(LOGINFO, "Attempting to quickpath to: %s", strDestination.c_str());
        // reset directory path, as we have effectively cleared it here
        m_history.ClearPathHistory();
      }
      // is this the first time accessing this window?
      // a quickpath overrides the a default parameter
      if (m_vecItems->m_strPath == "?" && strDestination.IsEmpty())
      {
        m_vecItems->m_strPath = strDestination = g_settings.m_defaultProgramSource;
        CLog::Log(LOGINFO, "Attempting to default to: %s", strDestination.c_str());
      }

      m_database.Open();
      // try to open the destination path
      if (!strDestination.IsEmpty())
      {
        // open root
        if (strDestination.Equals("$ROOT"))
        {
          m_vecItems->m_strPath = "";
          CLog::Log(LOGINFO, "  Success! Opening root listing.");
        }
        else
        {
          // default parameters if the jump fails
          m_vecItems->m_strPath = "";

          bool bIsSourceName = false;
          SetupShares();
          VECSOURCES shares;
          m_rootDir.GetSources(shares);
          int iIndex = CUtil::GetMatchingSource(strDestination, shares, bIsSourceName);
          if (iIndex > -1)
          {
            bool bDoStuff = true;
            if (iIndex < (int)shares.size() && shares[iIndex].m_iHasLock == 2)
            {
              CFileItem item(shares[iIndex]);
              if (!g_passwordManager.IsItemUnlocked(&item,"programs"))
              {
                m_vecItems->m_strPath = ""; // no u don't
                bDoStuff = false;
                CLog::Log(LOGINFO, "  Failure! Failed to unlock destination path: %s", strDestination.c_str());
              }
            }
            // set current directory to matching share
            if (bDoStuff)
            {
              if (bIsSourceName)
                m_vecItems->m_strPath=shares[iIndex].strPath;
              else
                m_vecItems->m_strPath=strDestination;
              CLog::Log(LOGINFO, "  Success! Opened destination path: %s", strDestination.c_str());
            }
          }
          else
          {
            CLog::Log(LOGERROR, "  Failed! Destination parameter (%s) does not match a valid source!", strDestination.c_str());
          }
        }
        SetHistoryForPath(m_vecItems->m_strPath);
      }

      return CGUIMediaWindow::OnMessage(message);
    }
  break;

  case GUI_MSG_CLICKED:
    {
      if (message.GetSenderId() == CONTROL_BTNSORTBY)
      {
        // need to update shortcuts manually
        if (CGUIMediaWindow::OnMessage(message))
        {
          LABEL_MASKS labelMasks;
          m_guiState->GetSortMethodLabelMasks(labelMasks);
          CLabelFormatter formatter("", labelMasks.m_strLabel2File);
          for (int i=0;i<m_vecItems->Size();++i)
          {
            CFileItemPtr item = m_vecItems->Get(i);
            if (item->IsShortCut())
              formatter.FormatLabel2(item.get());
          }
          return true;
        }
        else
          return false;
      }
      if (m_viewControl.HasControl(message.GetSenderId()))  // list/thumb control
      {
        if (message.GetParam1() == ACTION_PLAYER_PLAY)
        {
          OnPlayMedia(m_viewControl.GetSelectedItem());
          return true;
        }
      }
    }
    break;
  }

  return CGUIMediaWindow::OnMessage(message);
}
Exemplo n.º 14
0
void CGUIDialogMediaSource::OnPathBrowse(int item)
{
    if (item < 0 || item > m_paths->Size()) return;
    // Browse is called.  Open the filebrowser dialog.
    // Ignore current path is best at this stage??
    CStdString path;
    bool allowNetworkShares(m_type != "programs");
    VECSOURCES extraShares;

    if (m_name != CUtil::GetTitleFromPath(m_paths->Get(item)->GetPath()))
        m_bNameChanged=true;

    if (m_type == "music")
    {   // add the music playlist location
        CMediaSource share1;
        share1.strPath = "special://musicplaylists/";
        share1.strName = g_localizeStrings.Get(20011);
        share1.m_ignore = true;
        extraShares.push_back(share1);

#ifdef HAS_FILESYSTEM_SMB
        share1.strPath = "smb://";
        share1.strName = g_localizeStrings.Get(20171);
        extraShares.push_back(share1);
#endif

#ifdef HAS_FILESYSTEM_NFS
        share1.strPath = "nfs://";
        share1.strName = g_localizeStrings.Get(20259);
        extraShares.push_back(share1);
#endif// HAS_FILESYSTEM_NFS

        share1.strPath = "upnp://";
        share1.strName = "UPnP Devices";
        extraShares.push_back(share1);

        share1.strPath = "sap://";
        share1.strName = "SAP Streams";
        extraShares.push_back(share1);

        share1.strPath = "zeroconf://";
        share1.strName = "Zeroconf Browser";
        extraShares.push_back(share1);

        if (g_guiSettings.GetString("audiocds.recordingpath",false) != "")
        {
            share1.strPath = "special://recordings/";
            share1.strName = g_localizeStrings.Get(21883);
            extraShares.push_back(share1);
        }

        if (g_guiSettings.GetString("scrobbler.lastfmusername") != "")
        {
            share1.strName = "Last.FM";
            share1.strPath = "lastfm://";
            extraShares.push_back(share1);
        }
    }
    else if (m_type == "video")
    {   // add the music playlist location
        CMediaSource share1;
        share1.m_ignore = true;
        share1.strPath = "special://videoplaylists/";
        share1.strName = g_localizeStrings.Get(20012);
        extraShares.push_back(share1);

        share1.strPath = "rtv://*/";
        share1.strName = "ReplayTV Devices";
        extraShares.push_back(share1);

#ifdef HAS_FILESYSTEM_SMB
        share1.strPath = "smb://";
        share1.strName = g_localizeStrings.Get(20171);
        extraShares.push_back(share1);
#endif

#ifdef HAS_FILESYSTEM_NFS
        share1.strPath = "nfs://";
        share1.strName = g_localizeStrings.Get(20259);
        extraShares.push_back(share1);
#endif// HAS_FILESYSTEM_NFS

        share1.strPath = "hdhomerun://";
        share1.strName = "HDHomerun Devices";
        extraShares.push_back(share1);

        share1.strPath = "sap://";
        share1.strName = "SAP Streams";
        extraShares.push_back(share1);

        share1.strPath = "upnp://";
        share1.strName = "UPnP Devices";
        extraShares.push_back(share1);

        share1.strPath = "zeroconf://";
        share1.strName = "Zeroconf Browser";
        extraShares.push_back(share1);
    }
    else if (m_type == "pictures")
    {
        CMediaSource share1;
        share1.m_ignore = true;
        if (g_guiSettings.GetString("debug.screenshotpath",false)!= "")
        {
            share1.strPath = "special://screenshots/";
            share1.strName = g_localizeStrings.Get(20008);
            extraShares.push_back(share1);
        }

#ifdef HAS_FILESYSTEM_SMB
        share1.strPath = "smb://";
        share1.strName = g_localizeStrings.Get(20171);
        extraShares.push_back(share1);
#endif

#ifdef HAS_FILESYSTEM_NFS
        share1.strPath = "nfs://";
        share1.strName = g_localizeStrings.Get(20259);
        extraShares.push_back(share1);
#endif// HAS_FILESYSTEM_NFS

        share1.strPath = "upnp://";
        share1.strName = "UPnP Devices";
        extraShares.push_back(share1);

        share1.strPath = "zeroconf://";
        share1.strName = "Zeroconf Browser";
        extraShares.push_back(share1);
    }
    else if (m_type == "programs")
    {
        // nothing to add
    }
    if (CGUIDialogFileBrowser::ShowAndGetSource(path, allowNetworkShares, extraShares.size()==0?NULL:&extraShares))
    {
        if (item < m_paths->Size()) // if the skin does funky things, m_paths may have been cleared
            m_paths->Get(item)->SetPath(path);
        if (!m_bNameChanged || m_name.IsEmpty())
        {
            CURL url(path);
            m_name = url.GetWithoutUserDetails();
            URIUtils::RemoveSlashAtEnd(m_name);
            m_name = CUtil::GetTitleFromPath(m_name);
        }
        UpdateButtons();
    }
}
Exemplo n.º 15
0
bool CGUIWindowVideoFiles::OnMessage(CGUIMessage& message)
{
  switch ( message.GetMessage() )
  {
  case GUI_MSG_WINDOW_INIT:
    {
      // check for a passed destination path
      CStdString strDestination = message.GetStringParam();
      if (!strDestination.IsEmpty())
      {
        message.SetStringParam("");
        g_stSettings.m_iVideoStartWindow = GetID();
        CLog::Log(LOGINFO, "Attempting to quickpath to: %s", strDestination.c_str());
        // reset directory path, as we have effectively cleared it here
        m_history.ClearPathHistory();
      }

      // is this the first time accessing this window?
      // a quickpath overrides the a default parameter
      if ((m_vecItems->m_strPath == "?" || m_vecItems->m_strPath == "") && strDestination.IsEmpty())
      {
        m_vecItems->m_strPath = strDestination = g_settings.m_defaultVideoSource;
        CLog::Log(LOGINFO, "Attempting to default to: %s", strDestination.c_str());
      }

      // try to open the destination path
      if (!strDestination.IsEmpty())
      {
        // open root
        if (strDestination.Equals("$ROOT"))
        {
          m_vecItems->m_strPath = "";
          CLog::Log(LOGINFO, "  Success! Opening root listing.");
        }
        // open playlists location
        else if (strDestination.Equals("$PLAYLISTS"))
        {
          m_vecItems->m_strPath = "special://videoplaylists/";
          CLog::Log(LOGINFO, "  Success! Opening destination path: %s", m_vecItems->m_strPath.c_str());
        }
        else
        {
          // default parameters if the jump fails
          m_vecItems->m_strPath = "";

          bool bIsSourceName = false;

          SetupShares();
          VECSOURCES shares;
          m_rootDir.GetSources(shares);
          int iIndex = CUtil::GetMatchingSource(strDestination, shares, bIsSourceName);
          if (iIndex > -1)
          {
            bool bDoStuff = true;
            if (iIndex < shares.size() && shares[iIndex].m_iHasLock == 2)
            {
              CFileItem item(shares[iIndex]);
              if (!g_passwordManager.IsItemUnlocked(&item,"video"))
              {
                m_vecItems->m_strPath = ""; // no u don't
                bDoStuff = false;
                CLog::Log(LOGINFO, "  Failure! Failed to unlock destination path: %s", strDestination.c_str());
              }
            }
            // set current directory to matching share
            if (bDoStuff)
            {
              if (bIsSourceName)
                m_vecItems->m_strPath=shares[iIndex].strPath;
              else
                m_vecItems->m_strPath=strDestination;
              CLog::Log(LOGINFO, "  Success! Opened destination path: %s", strDestination.c_str());
            }
          }
          else
          {
            CLog::Log(LOGERROR, "  Failed! Destination parameter (%s) does not match a valid source!", strDestination.c_str());
          }
        }

        // check for network up
        if (CUtil::IsRemote(m_vecItems->m_strPath) && !WaitForNetwork())
          m_vecItems->m_strPath.Empty();

        SetHistoryForPath(m_vecItems->m_strPath);
      }

      return CGUIWindowVideoBase::OnMessage(message);
    }
    break;

  case GUI_MSG_CLICKED:
    {
      int iControl = message.GetSenderId();
      //if (iControl == CONTROL_BTNSCAN)
      //{
      //  OnScan();
     // }
      /*else*/ if (iControl == CONTROL_STACK)
      {
        // toggle between the following states:
        //   0 : no stacking
        //   1 : stacking
        g_stSettings.m_iMyVideoStack++;

        if (g_stSettings.m_iMyVideoStack > STACK_SIMPLE)
          g_stSettings.m_iMyVideoStack = STACK_NONE;

        g_settings.Save();
        UpdateButtons();
        Update( m_vecItems->m_strPath );
      }
      else if (iControl == CONTROL_BTNPLAYLISTS)
      {
        if (!m_vecItems->m_strPath.Equals("special://videoplaylists/"))
        {
          CStdString strParent = m_vecItems->m_strPath;
          UpdateButtons();
          Update("special://videoplaylists/");
        }
      }
      // list/thumb panel
      else if (m_viewControl.HasControl(iControl))
      {
        int iItem = m_viewControl.GetSelectedItem();
        int iAction = message.GetParam1();

        const CFileItemPtr pItem = m_vecItems->Get(iItem);

        // use play button to add folders of items to temp playlist
        if (iAction == ACTION_PLAYER_PLAY && pItem->m_bIsFolder && !pItem->IsParentFolder())
        {
          if (pItem->IsDVD())
            return CAutorun::PlayDisc();

          if (pItem->m_bIsShareOrDrive)
            return false;
          // if playback is paused or playback speed != 1, return
          if (g_application.IsPlayingVideo())
          {
            if (g_application.m_pPlayer->IsPaused()) return false;
            if (g_application.GetPlaySpeed() != 1) return false;
          }
          // not playing, or playback speed == 1
          // queue folder or playlist into temp playlist and play
          if ((pItem->m_bIsFolder && !pItem->IsParentFolder()) || pItem->IsPlayList())
            PlayItem(iItem);
          return true;
        }
      }
    }
  }
  return CGUIWindowVideoBase::OnMessage(message);
}
Exemplo n.º 16
0
JSONRPC_STATUS CFileOperations::GetDirectory(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
{
  CStdString media = parameterObject["media"].asString();
  media = media.ToLower();

  CFileItemList items;
  CStdString strPath = parameterObject["directory"].asString();

  // Check if this directory is part of a source and whether it's locked
  VECSOURCES *sources;
  bool isSource;
  for (unsigned int index = 0; index < SourcesSize; index++)
  {
    sources = g_settings.GetSourcesFromType(SourceNames[index]);
    int sourceIndex = CUtil::GetMatchingSource(strPath, *sources, isSource);
    if (sourceIndex >= 0 && sourceIndex < (int)sources->size() && sources->at(sourceIndex).m_iHasLock == 2)
      return InvalidParams;
  }

  CStdStringArray regexps;
  CStdString extensions = "";
  if (media.Equals("video"))
  {
    regexps = g_advancedSettings.m_videoExcludeFromListingRegExps;
    extensions = g_settings.m_videoExtensions;
  }
  else if (media.Equals("music"))
  {
    regexps = g_advancedSettings.m_audioExcludeFromListingRegExps;
    extensions = g_settings.m_musicExtensions;
  }
  else if (media.Equals("pictures"))
  {
    regexps = g_advancedSettings.m_pictureExcludeFromListingRegExps;
    extensions = g_settings.m_pictureExtensions;
  }

  if (CDirectory::GetDirectory(strPath, items, extensions))
  {
    CFileItemList filteredDirectories, filteredFiles;
    for (unsigned int i = 0; i < (unsigned int)items.Size(); i++)
    {
      if (CUtil::ExcludeFileOrFolder(items[i]->GetPath(), regexps))
        continue;

      if (items[i]->IsSmb())
      {
        CURL url(items[i]->GetPath());
        items[i]->SetPath(url.GetWithoutUserDetails());
      }

      if ((media == "video" && items[i]->HasVideoInfoTag()) ||
          (media == "music" && items[i]->HasMusicInfoTag()) ||
          (media == "picture" && items[i]->HasPictureInfoTag()) ||
           media == "files")
      {
        if (items[i]->m_bIsFolder)
          filteredDirectories.Add(items[i]);
        else 
          filteredFiles.Add(items[i]);
      }
      else
      {
        CFileItem fileItem;
        if (FillFileItem(items[i], fileItem, media))
        {
          if (items[i]->m_bIsFolder)
            filteredDirectories.Add(CFileItemPtr(new CFileItem(fileItem)));
          else
            filteredFiles.Add(CFileItemPtr(new CFileItem(fileItem)));
        }
        else
        {
          if (items[i]->m_bIsFolder)
            filteredDirectories.Add(items[i]);
          else
            filteredFiles.Add(items[i]);
        }
      }
    }

    // Check if the "properties" list exists
    // and make sure it contains the "file"
    // field
    CVariant param = parameterObject;
    if (!param.isMember("properties"))
      param["properties"] = CVariant(CVariant::VariantTypeArray);

    bool hasFileField = false;
    for (CVariant::const_iterator_array itr = param["properties"].begin_array(); itr != param["properties"].end_array(); itr++)
    {
      if (itr->asString().compare("file") == 0)
      {
        hasFileField = true;
        break;
      }
    }

    if (!hasFileField)
      param["properties"].append("file");

    HandleFileItemList("id", true, "files", filteredDirectories, param, result);
    for (unsigned int index = 0; index < result["files"].size(); index++)
    {
      result["files"][index]["filetype"] = "directory";
    }
    int count = (int)result["limits"]["total"].asInteger();

    HandleFileItemList("id", true, "files", filteredFiles, param, result);
    for (unsigned int index = count; index < result["files"].size(); index++)
    {
      result["files"][index]["filetype"] = "file";
    }
    count += (int)result["limits"]["total"].asInteger();

    result["limits"]["end"] = count;
    result["limits"]["total"] = count;

    return OK;
  }

  return InvalidParams;
}
Exemplo n.º 17
0
void CGUIDialogMediaSource::OnPathBrowse(int item)
{
  if (item < 0 || item > m_paths->Size()) return;
  // Browse is called.  Open the filebrowser dialog.
  // Ignore current path is best at this stage??
  CStdString path;
  bool allowNetworkShares(m_type != "programs");
  VECSOURCES extraShares;

  if (m_name != CUtil::GetTitleFromPath(m_paths->Get(item)->GetPath()))
    m_bNameChanged=true;

  if (m_type == "music")
  {
    CMediaSource share1;
#if defined(TARGET_ANDROID)
    // add the default android music directory
    std::string path;
    if (CXBMCApp::GetExternalStorage(path, "music") && !path.empty() && CFile::Exists(path))
    {
      share1.strPath = path;
      share1.strName = g_localizeStrings.Get(20240);
      share1.m_ignore = true;
      extraShares.push_back(share1);
    }
#endif

    // add the music playlist location
    share1.strPath = "special://musicplaylists/";
    share1.strName = g_localizeStrings.Get(20011);
    share1.m_ignore = true;
    extraShares.push_back(share1);

    share1.strPath = "sap://";
    share1.strName = "SAP Streams";
    extraShares.push_back(share1);

    if (CSettings::Get().GetString("audiocds.recordingpath") != "")
    {
      share1.strPath = "special://recordings/";
      share1.strName = g_localizeStrings.Get(21883);
      extraShares.push_back(share1);
    }
 }
  else if (m_type == "video")
  {
    CMediaSource share1;
#if defined(TARGET_ANDROID)
    // add the default android video directory
    std::string path;
    if (CXBMCApp::GetExternalStorage(path, "videos") && !path.empty() && CFile::Exists(path))
    {
      share1.strPath = path;
      share1.strName = g_localizeStrings.Get(20241);
      share1.m_ignore = true;
      extraShares.push_back(share1);
    }
#endif

    // add the video playlist location
    share1.m_ignore = true;
    share1.strPath = "special://videoplaylists/";
    share1.strName = g_localizeStrings.Get(20012);
    extraShares.push_back(share1);

    share1.strPath = "rtv://*/";
    share1.strName = "ReplayTV Devices";
    extraShares.push_back(share1);

    share1.strPath = "hdhomerun://";
    share1.strName = "HDHomerun Devices";
    extraShares.push_back(share1);

    share1.strPath = "sap://";
    share1.strName = "SAP Streams";
    extraShares.push_back(share1);

    // add the recordings dir as needed
    if (CPVRDirectory::HasRecordings())
    {
      share1.strPath = "pvr://recordings/";
      share1.strName = g_localizeStrings.Get(19017); // TV Recordings
      extraShares.push_back(share1);
    }
  }
  else if (m_type == "pictures")
  {
    CMediaSource share1;
#if defined(TARGET_ANDROID)
    // add the default android music directory
    std::string path;
    if (CXBMCApp::GetExternalStorage(path, "pictures") && !path.empty() &&  CFile::Exists(path))
    {
      share1.strPath = path;
      share1.strName = g_localizeStrings.Get(20242);
      share1.m_ignore = true;
      extraShares.push_back(share1);
    }

    path.clear();
    if (CXBMCApp::GetExternalStorage(path, "photos") && !path.empty() &&  CFile::Exists(path))
    {
      share1.strPath = path;
      share1.strName = g_localizeStrings.Get(20243);
      share1.m_ignore = true;
      extraShares.push_back(share1);
    }
#endif

    share1.m_ignore = true;
    if (CSettings::Get().GetString("debug.screenshotpath") != "")
    {
      share1.strPath = "special://screenshots/";
      share1.strName = g_localizeStrings.Get(20008);
      extraShares.push_back(share1);
    }
  }
  else if (m_type == "programs")
  {
    // nothing to add
  }
  if (CGUIDialogFileBrowser::ShowAndGetSource(path, allowNetworkShares, extraShares.size()==0?NULL:&extraShares))
  {
    if (item < m_paths->Size()) // if the skin does funky things, m_paths may have been cleared
      m_paths->Get(item)->SetPath(path);
    if (!m_bNameChanged || m_name.empty())
    {
      CURL url(path);
      m_name = url.GetWithoutUserDetails();
      URIUtils::RemoveSlashAtEnd(m_name);
      m_name = CUtil::GetTitleFromPath(m_name);
    }
    UpdateButtons();
  }
}
Exemplo n.º 18
0
void CGUIDialogMediaSource::OnPathBrowse(int item)
{
  if (item < 0 || item > m_paths->Size()) return;
  // Browse is called.  Open the filebrowser dialog.
  // Ignore current path is best at this stage??
  std::string path;
  bool allowNetworkShares(m_type != "programs");
  VECSOURCES extraShares;

  if (m_name != CUtil::GetTitleFromPath(m_paths->Get(item)->GetPath()))
    m_bNameChanged = true;

  std::string strDevices = g_localizeStrings.Get(33040); //"% Devices"

  if (m_type == "music")
  {
    CMediaSource share1;
#if defined(TARGET_ANDROID)
    // add the default android music directory
    std::string path;
    if (CXBMCApp::GetExternalStorage(path, "music") && !path.empty() && CDirectory::Exists(path))
    {
      share1.strPath = path;
      share1.strName = g_localizeStrings.Get(20240);
      share1.m_ignore = true;
      extraShares.push_back(share1);
    }
#endif

    // add the music playlist location
    share1.strPath = "special://musicplaylists/";
    share1.strName = g_localizeStrings.Get(20011);
    share1.m_ignore = true;
    extraShares.push_back(share1);

    // add the recordings dir as needed
    if (CPVRDirectory::HasRadioRecordings())
    {
      share1.strPath = PVR::CPVRRecordingsPath::PATH_ACTIVE_RADIO_RECORDINGS;
      share1.strName = g_localizeStrings.Get(19017); // Recordings
      extraShares.push_back(share1);
    }
    if (CPVRDirectory::HasDeletedRadioRecordings())
    {
      share1.strPath = PVR::CPVRRecordingsPath::PATH_DELETED_RADIO_RECORDINGS;
      share1.strName = g_localizeStrings.Get(19184); // Deleted recordings
      extraShares.push_back(share1);
    }

    if (CSettings::GetInstance().GetString(CSettings::SETTING_AUDIOCDS_RECORDINGPATH) != "")
    {
      share1.strPath = "special://recordings/";
      share1.strName = g_localizeStrings.Get(21883);
      extraShares.push_back(share1);
    }
  }
  else if (m_type == "video")
  {
    CMediaSource share1;
#if defined(TARGET_ANDROID)
    // add the default android video directory
    std::string path;
    if (CXBMCApp::GetExternalStorage(path, "videos") && !path.empty() && CFile::Exists(path))
    {
      share1.strPath = path;
      share1.strName = g_localizeStrings.Get(20241);
      share1.m_ignore = true;
      extraShares.push_back(share1);
    }
#endif

    // add the video playlist location
    share1.m_ignore = true;
    share1.strPath = "special://videoplaylists/";
    share1.strName = g_localizeStrings.Get(20012);
    extraShares.push_back(share1);

    // add the recordings dir as needed
    if (CPVRDirectory::HasTVRecordings())
    {
      share1.strPath = PVR::CPVRRecordingsPath::PATH_ACTIVE_TV_RECORDINGS;
      share1.strName = g_localizeStrings.Get(19017); // Recordings
      extraShares.push_back(share1);
    }
    if (CPVRDirectory::HasDeletedTVRecordings())
    {
      share1.strPath = PVR::CPVRRecordingsPath::PATH_DELETED_TV_RECORDINGS;
      share1.strName = g_localizeStrings.Get(19184); // Deleted recordings
      extraShares.push_back(share1);
    }
  }
  else if (m_type == "pictures")
  {
    CMediaSource share1;
#if defined(TARGET_ANDROID)
    // add the default android music directory
    std::string path;
    if (CXBMCApp::GetExternalStorage(path, "pictures") && !path.empty() && CFile::Exists(path))
    {
      share1.strPath = path;
      share1.strName = g_localizeStrings.Get(20242);
      share1.m_ignore = true;
      extraShares.push_back(share1);
    }

    path.clear();
    if (CXBMCApp::GetExternalStorage(path, "photos") && !path.empty() && CFile::Exists(path))
    {
      share1.strPath = path;
      share1.strName = g_localizeStrings.Get(20243);
      share1.m_ignore = true;
      extraShares.push_back(share1);
    }
#endif

    share1.m_ignore = true;
    if (CSettings::GetInstance().GetString(CSettings::SETTING_DEBUG_SCREENSHOTPATH) != "")
    {
      share1.strPath = "special://screenshots/";
      share1.strName = g_localizeStrings.Get(20008);
      extraShares.push_back(share1);
    }
  }
  else if (m_type == "programs")
  {
    // nothing to add
  }
  if (CGUIDialogFileBrowser::ShowAndGetSource(path, allowNetworkShares, extraShares.size() == 0 ? NULL : &extraShares))
  {
    if (item < m_paths->Size()) // if the skin does funky things, m_paths may have been cleared
      m_paths->Get(item)->SetPath(path);
    if (!m_bNameChanged || m_name.empty())
    {
      CURL url(path);
      m_name = url.GetWithoutUserDetails();
      URIUtils::RemoveSlashAtEnd(m_name);
      m_name = CUtil::GetTitleFromPath(m_name);
    }
    UpdateButtons();
  }
}
Exemplo n.º 19
0
/*----------------------------------------------------------------------
|   CUPnPVirtualPathDirectory::GetDirectory
+---------------------------------------------------------------------*/
bool
CUPnPVirtualPathDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
{
    NPT_String path = strPath.c_str();
    CMediaSource     share;
    CFileItemPtr item;
    vector<CStdString> paths;
    path.TrimRight("/");

    if (path == "virtualpath://upnproot") {
        // music
        item.reset(new CFileItem("virtualpath://upnpmusic/", true));
        item->SetLabel("Music Files");
        item->SetLabelPreformated(true);
        items.Add(item);

        // video
        item.reset(new CFileItem("virtualpath://upnpvideo/", true));
        item->SetLabel("Video Files");
        item->SetLabelPreformated(true);
        items.Add(item);

        // pictures
        item.reset(new CFileItem("virtualpath://upnppictures/", true));
        item->SetLabel("Picture Files");
        item->SetLabelPreformated(true);
        items.Add(item);

        // music library
        item.reset(new CFileItem("musicdb://", true));
        item->SetLabel("Music Library");
        item->SetLabelPreformated(true);
        items.Add(item);

        // video library
        item.reset(new CFileItem("videodb://", true));
        item->SetLabel("Video Library");
        item->SetLabelPreformated(true);
        items.Add(item);

        return true;
    } else if (path == "virtualpath://upnpmusic" ||
               path == "virtualpath://upnpvideo" ||
               path == "virtualpath://upnppictures") {
        // look for all shares given a container
        VECSOURCES *shares = NULL;
        if (path == "virtualpath://upnpmusic") {
            shares = g_settings.GetSourcesFromType("upnpmusic");
        } else if (path == "virtualpath://upnpvideo") {
            shares = g_settings.GetSourcesFromType("upnpvideo");
        } else if (path == "virtualpath://upnppictures") {
            shares = g_settings.GetSourcesFromType("upnppictures");
        }
        if (shares) {
            for (unsigned int i = 0; i < shares->size(); i++) {
                // Does this share contains any local paths?
                CMediaSource &share = shares->at(i);
                // reconstruct share name as it could have been replaced by
                // a path if there was just one entry
                NPT_String share_name = path + "/";
                share_name += share.strName + "/";
                if (GetMatchingSource((const char*)share_name, share, paths) && paths.size()) {
                    item.reset(new CFileItem((const char*)share_name, true));
                    item->SetLabel(share.strName);
                    item->SetLabelPreformated(true);
                    items.Add(item);
                }
            }
        }

        return true;
    } else if (!GetMatchingSource((const char*)path, share, paths)) {
        // split to remove share name from path
        NPT_String share_name;
        NPT_String file_path;
        bool bret = SplitPath(path, share_name, file_path);
        if (!bret || share_name.GetLength() == 0 || file_path.GetLength() == 0) {
            return false;
        }

        // make sure the file_path is the beginning of a share paths
        if (!FindSourcePath(share_name, file_path, true)) return false;

        // use the share name to figure out what extensions to use
        if (share_name.StartsWith("virtualpath://upnpmusic")) {
            CDirectory::GetDirectory(
                (const char*)file_path,
                items,
                g_stSettings.m_musicExtensions);
        } else if (share_name.StartsWith("virtualpath://upnpvideo")) {
            CDirectory::GetDirectory(
                (const char*)file_path,
                items,
                g_stSettings.m_videoExtensions);
        } else if (share_name.StartsWith("virtualpath://upnppictures")) {
            CDirectory::GetDirectory(
                (const char*)file_path,
                items,
                g_stSettings.m_pictureExtensions);
        }

        // paths should be prefixed
        for (int i=0; i < (int) items.Size(); ++i) {
            items[i]->m_strPath = share_name + "/" + items[i]->m_strPath.c_str();
        }

    } else {

        // use the path to figure out what extensions to use
        if (path.StartsWith("virtualpath://upnpmusic")) {
            SetMask(g_stSettings.m_musicExtensions);
        } else if (path.StartsWith("virtualpath://upnpvideo")) {
            SetMask(g_stSettings.m_videoExtensions);
        } else if (path.StartsWith("virtualpath://upnppictures")) {
            SetMask(g_stSettings.m_pictureExtensions);
        }

        // dont allow prompting, this is a background task
        // although I don't think it matters here
        SetAllowPrompting(false);

        // it's a virtual path, get all items
        CVirtualPathDirectory::GetDirectory(strPath, items);

        // paths should be prefixed
        for (int i=0; i < (int) items.Size(); ++i) {
            items[i]->m_strPath = strPath + "/" + items[i]->m_strPath.c_str();
        }

    }

    // always return true
    // this will make sure that even if nothing is found in a share
    // it doesn't fail upnp
    return true;
}
Exemplo n.º 20
0
void CGUIWindowFileManager::SetInitialPath(const CStdString &path)
{
/*
	歌方:
		1、
		
	卦指:
		1、
		
	傍苧:
		1、
*/
	// check for a passed destination path
	CStdString strDestination = path;
	m_rootDir.SetSources(*g_settings.GetSourcesFromType("files"));
	if (!strDestination.IsEmpty())
	{
		CLog::Log(LOGINFO, "Attempting to quickpath to: %s", strDestination.c_str());
	}
	// otherwise, is this the first time accessing this window?
	else if (m_Directory[0]->GetPath() == "?")
	{
		m_Directory[0]->SetPath(strDestination = g_settings.m_defaultFileSource);
		CLog::Log(LOGINFO, "Attempting to default to: %s", strDestination.c_str());
	}
	// try to open the destination path
	if (!strDestination.IsEmpty())
	{
		// open root
		if (strDestination.Equals("$ROOT"))
		{
			m_Directory[0]->SetPath("");
			CLog::Log(LOGINFO, "  Success! Opening root listing.");
		}
		else
		{
			// default parameters if the jump fails
			m_Directory[0]->SetPath("");

			bool bIsSourceName = false;
			VECSOURCES shares;
			m_rootDir.GetSources(shares);
			int iIndex = CUtil::GetMatchingSource(strDestination, shares, bIsSourceName);
			if (iIndex > -1)
			{
				// set current directory to matching share
				CStdString path;
				if (bIsSourceName && iIndex < (int)shares.size())
					path = shares[iIndex].strPath;
				else
					path = strDestination;
				
				URIUtils::RemoveSlashAtEnd(path);
				m_Directory[0]->SetPath(path);
				CLog::Log(LOGINFO, "  Success! Opened destination path: %s", strDestination.c_str());

				// outside call: check the share for connectivity
				bCheckShareConnectivity = Update(0, m_Directory[0]->GetPath());
				if(!bCheckShareConnectivity)
					strCheckSharePath = m_Directory[0]->GetPath();
			}
			else
			{
				CLog::Log(LOGERROR, "  Failed! Destination parameter (%s) does not match a valid share!", strDestination.c_str());
			}
		}
	}

	if (m_Directory[1]->GetPath() == "?") 
		m_Directory[1]->SetPath("");
}
Exemplo n.º 21
0
bool CGUIWindowBoxeeBrowseLocal::OnMessage(CGUIMessage& message)
{
  switch ( message.GetMessage() )
  {
    case GUI_MSG_NOTIFY_ALL:
    {
      if (message.GetParam1() == GUI_MSG_FILE_SCANNER_UPDATE)
      {
        CStdString strPath = message.GetStringParam();
        if (strPath == ((CLocalBrowseWindowState*)m_windowState)->GetCurrentPath())
        {
          SET_CONTROL_VISIBLE(BUTTON_SCAN);
          SET_CONTROL_HIDDEN(BUTTON_ADD_SOURCE);
          SET_CONTROL_HIDDEN(BUTTON_EJECT);
          CONTROL_ENABLE(BUTTON_SCAN);
        }
      }
      else if (message.GetParam1() == GUI_MSG_REMOVED_MEDIA)
      {
        Refresh();
      }
    }
    break;
    case GUI_MSG_MANAGE_ITEM:
    {
      if (message.GetParam1() == GUI_MSG_ADD_ITEM)
      {
        if (((CLocalBrowseWindowState*) m_windowState)->GetCurrentPath() == "upnp://all")
        {
          CStdString strPath = message.GetStringParam(0);
          CStdString strFriendlyName = message.GetStringParam(1);
          CStdString strIconURL = message.GetStringParam(2);

          CLog::Log(LOGDEBUG,"CGUIWindowBoxeeBrowseLocal::OnMessage - adding new UPnP source. [strPath=%s][strFriendlyName=%s][strIconURL=%s] (browse)",strPath.c_str(), strFriendlyName.c_str(), strIconURL.c_str());

          CFileItemPtr pItem(new CFileItem(strFriendlyName));
          pItem->m_strPath = strPath;
          pItem->m_bIsFolder = true;
          pItem->SetThumbnailImage(strIconURL);

          CFileItemList pList;
          pList.Add(pItem);
          ShowItems(pList, true);
        }
      }
    }
    break;
    case GUI_MSG_CLICKED:
    {
      int iControl = message.GetSenderId();

      CLog::Log(LOGDEBUG,"CGUIWindowBoxeeBrowseLocal::OnMessage - GUI_MSG_CLICKED - [controlId=%d] (browse)", iControl);

      if (iControl == BUTTON_ADD_SOURCE)
      {
        CGUIWindowBoxeeMediaSourceInfo *pDlgSourceInfo = (CGUIWindowBoxeeMediaSourceInfo*)g_windowManager.GetWindow(WINDOW_BOXEE_MEDIA_SOURCE_INFO);
        if (pDlgSourceInfo)
        {
          CStdString path = CGUIWindowBoxeeMediaSourceAddFolder::GetSelectedEncodedPath(((CLocalBrowseWindowState*)m_windowState)->GetCurrentPath());
          pDlgSourceInfo->SetAddSource(path);
        }

        g_windowManager.ActivateWindow(WINDOW_BOXEE_MEDIA_SOURCE_INFO);

        Refresh();
        return true;
      }
      else if (iControl == BUTTON_SCAN)
      {
        CStdString strPath =  ((CLocalBrowseWindowState*)m_windowState)->GetCurrentPath();

        if (BoxeeUtils::DoYouWantToScan(strPath))
        {
          CLog::Log(LOGDEBUG,"CGUIWindowBoxeeBrowseLocal::OnMessage - GUI_MSG_CLICKED - BUTTON_SCAN - [path=%s] (checkpath)", strPath.c_str());
          g_application.GetBoxeeFileScanner().AddUserPath(_P(strPath));
          //BOXEE::Boxee::GetInstance().GetMetadataEngine().MarkFolderTreeNew(_P(strPath));

          UpdateScanningButtonState();
        }
      }
      else if(iControl == BUTTON_EJECT_USER)
      {
        CStdString strPath =  ((CLocalBrowseWindowState*)m_windowState)->GetCurrentPath();
        CLog::Log(LOGDEBUG,"CGUIWindowBoxeeBrowseLocal::OnMessage - GUI_MSG_CLICKED - BUTTON_EJECT_USER - [strPath=%s] (ejc)",strPath.c_str());
        EjectUserButtonPressed();
      }
      else if (iControl == BUTTON_EJECT)
      {
        // Get the list of available USB devices
        CFileItemList devices;
        VECSOURCES removableDrives;
        g_mediaManager.GetLocalDrives(removableDrives);

        CGUIDialogBoxeeEject *dialog = (CGUIDialogBoxeeEject *)g_windowManager.GetWindow(WINDOW_DIALOG_BOXEE_EJECT);

        dialog->Reset();
        for (size_t i = 0; i < removableDrives.size(); i++)
        {
          CMediaSource removableDrive = removableDrives[i];
          CFileItemPtr share ( new CFileItem(removableDrive.strName)  );
          share->SetProperty("IsShare","1");
          share->m_strPath = removableDrive.strPath;
          share->SetProperty("value", removableDrive.strPath);
          share->m_bIsFolder = true;
          share->SetProperty("IsRemovable",true);

          if (removableDrive.m_localSourceType == CMediaSource::LOCAL_SOURCE_TYPE_USB)
            share->SetProperty("IsUSB",true);
          else if (removableDrive.m_localSourceType == CMediaSource::LOCAL_SOURCE_TYPE_SD)
            share->SetProperty("IsSD",true);
          else if (removableDrive.m_localSourceType == CMediaSource::LOCAL_SOURCE_TYPE_INTERNAL_HD)
            share->SetProperty("IsInternalHD",true);
          else
            share->SetProperty("IsUSB",true);

          devices.Add(share);
        }

        if(devices.Size() > 0)
        {
          dialog->Add(devices);
          dialog->DoModal();

          if(dialog->GetWasItemSelected())
          {
            CStdString value = dialog->GetSelectedItem().m_strPath;
#ifdef HAS_BOXEE_HAL
            CHalServicesFactory::GetInstance().EjectStorage(value);
#endif
          }
        }
      }
    } // case GUI_MSG_CLICKED
    break;
  }

  return CGUIWindowBoxeeBrowse::OnMessage(message);
}
bool CGUIWindowMusicSongs::OnMessage(CGUIMessage& message)
{
  switch ( message.GetMessage() )
  {
  case GUI_MSG_WINDOW_DEINIT:
    if (m_thumbLoader.IsLoading())
      m_thumbLoader.StopThread();
    break;
  case GUI_MSG_WINDOW_INIT:
    {
      // removed the start window check from files view
      // the window translator does it by using a virtual window id (5)

      // check for a passed destination path
      CStdString strDestination = message.GetStringParam();
      if (!strDestination.IsEmpty())
      {
        message.SetStringParam("");
        CLog::Log(LOGINFO, "Attempting to quickpath to: %s", strDestination.c_str());
        m_history.ClearPathHistory();
      }

      // is this the first time the window is opened?
      if (m_vecItems->m_strPath == "?" && strDestination.IsEmpty())
      {
        strDestination = g_settings.m_defaultMusicSource;
        m_vecItems->m_strPath=strDestination;
        CLog::Log(LOGINFO, "Attempting to default to: %s", strDestination.c_str());
      }

      // try to open the destination path
      if (!strDestination.IsEmpty())
      {
        // open root
        if (strDestination.Equals("$ROOT"))
        {
          m_vecItems->m_strPath = "";
          CLog::Log(LOGINFO, "  Success! Opening root listing.");
        }
        // open playlists location
        else if (strDestination.Equals("$PLAYLISTS"))
        {
          m_vecItems->m_strPath = "special://musicplaylists/";
          CLog::Log(LOGINFO, "  Success! Opening destination path: %s", m_vecItems->m_strPath.c_str());
        }
        else
        {
          // default parameters if the jump fails
          m_vecItems->m_strPath.Empty();

          bool bIsSourceName = false;

          SetupShares();
          VECSOURCES shares;
          m_rootDir.GetSources(shares);
          int iIndex = CUtil::GetMatchingSource(strDestination, shares, bIsSourceName);
          if (iIndex > -1)
          {
            bool unlocked = true;
            if (iIndex < (int)shares.size() && shares[iIndex].m_iHasLock == 2)
            {
              CFileItem item(shares[iIndex]);
              if (!g_passwordManager.IsItemUnlocked(&item,"music"))
              {
                m_vecItems->m_strPath = ""; // no u don't
                unlocked = false;
                CLog::Log(LOGINFO, "  Failure! Failed to unlock destination path: %s", strDestination.c_str());
              }
            }
            // set current directory to matching share
            if (unlocked)
            {
              if (bIsSourceName)
                m_vecItems->m_strPath=shares[iIndex].strPath;
              else
                m_vecItems->m_strPath=strDestination;
              CLog::Log(LOGINFO, "  Success! Opened destination path: %s (%s)", strDestination.c_str(), m_vecItems->m_strPath.c_str());
            }
          }
          else
          {
            CLog::Log(LOGERROR, "  Failed! Destination parameter (%s) does not match a valid source!", strDestination.c_str());
          }
        }

        // check for network up
        if (CUtil::IsRemote(m_vecItems->m_strPath) && !WaitForNetwork())
          m_vecItems->m_strPath.Empty();

        // need file filters or GetDirectory in SetHistoryPath fails
        SetHistoryForPath(m_vecItems->m_strPath);
      }

      return CGUIWindowMusicBase::OnMessage(message);
    }
    break;

  case GUI_MSG_DIRECTORY_SCANNED:
    {
      CFileItem directory(message.GetStringParam(), true);

      // Only update thumb on a local drive
      if (directory.IsHD())
      {
        CStdString strParent;
        CUtil::GetParentPath(directory.m_strPath, strParent);
        if (directory.m_strPath == m_vecItems->m_strPath || strParent == m_vecItems->m_strPath)
        {
          Update(m_vecItems->m_strPath);
        }
      }
    }
    break;

  case GUI_MSG_NOTIFY_ALL:
    {
      if (message.GetParam1()==GUI_MSG_REMOVED_MEDIA)
        DeleteRemoveableMediaDirectoryCache();
    }
    break;

  case GUI_MSG_CLICKED:
    {
      int iControl = message.GetSenderId();

      if (iControl == CONTROL_BTNPLAYLISTS)
      {
        if (!m_vecItems->m_strPath.Equals("special://musicplaylists/"))
          Update("special://musicplaylists/");
      }
      else if (iControl == CONTROL_BTNSCAN)
      {
        OnScan(-1);
      }
      else if (iControl == CONTROL_BTNREC)
      {
        if (g_application.IsPlayingAudio() )
        {
          if (g_application.m_pPlayer->CanRecord() )
          {
            bool bIsRecording = g_application.m_pPlayer->IsRecording();
            g_application.m_pPlayer->Record(!bIsRecording);
            UpdateButtons();
          }
        }
      }
      else if (iControl == CONTROL_BTNRIP)
      {
        OnRipCD();
      }
    }
    break;
  }

  return CGUIWindowMusicBase::OnMessage(message);
}