Ejemplo n.º 1
0
void URIUtils::GetDirectory(const CStdString& strFilePath,
                            CStdString& strDirectoryPath)
{
  // Will from a full filename return the directory the file resides in.
  // Keeps the final slash at end

  int iPos1 = strFilePath.ReverseFind('/');
  int iPos2 = strFilePath.ReverseFind('\\');

  if (iPos2 > iPos1)
  {
    iPos1 = iPos2;
  }

  if (iPos1 > 0)
  {
    strDirectoryPath = strFilePath.Left(iPos1 + 1); // include the slash

    // Keep possible |option=foo options for certain paths
    iPos2 = strFilePath.ReverseFind('|');
    if (iPos2 > 0)
    {
      strDirectoryPath += strFilePath.Mid(iPos2);
    }

  }
}
Ejemplo n.º 2
0
CStdString CCDDARipper::GetTrackName(CFileItem *item)
{
  // get track number from "cdda://local/01.cdda"
  int trackNumber = atoi(item->GetPath().substr(13, item->GetPath().size() - 13 - 5).c_str());

  // Format up our ripped file label
  CFileItem destItem(*item);
  destItem.SetLabel("");

  // get track file name format from audiocds.trackpathformat setting,
  // use only format part starting from the last '/'
  CStdString strFormat = CSettings::Get().GetString("audiocds.trackpathformat");
  int pos = max(strFormat.ReverseFind('/'), strFormat.ReverseFind('\\'));
  if (pos != -1)
  {
    strFormat = strFormat.Right(strFormat.GetLength() - pos - 1);
  }

  CLabelFormatter formatter(strFormat, "");
  formatter.FormatLabel(&destItem);

  // grab the label to use it as our ripped filename
  CStdString track = destItem.GetLabel();
  if (track.IsEmpty())
    track.Format("%s%02i", "Track-", trackNumber);
  track += GetExtension(CSettings::Get().GetInt("audiocds.encoder"));

  return track;
}
Ejemplo n.º 3
0
int CDAAPDirectory::GetCurrLevel(CStdString strPath)
{
  int intSPos;
  int intEPos;
  int intLevel;
  int intCnt;
  CStdString strJustPath;

  intSPos = strPath.Find("://");
  if (intSPos > -1)
    strJustPath = strPath.Right(strPath.size() - (intSPos + 3));
  else
    strJustPath = strPath;

  URIUtils::RemoveSlashAtEnd(strJustPath);

  intLevel = -1;
  intSPos = strPath.length();
  while (intSPos > -1)
  {
    intSPos = strJustPath.ReverseFind("/", intSPos);
    if (intSPos > -1) intLevel ++;
    intSPos -= 2;
  }

  m_selectedPlaylist = "";
  m_selectedArtist = "";
  m_selectedAlbum = "";
  intCnt = intLevel;
  intEPos = (strJustPath.length() - 1);
  while (intCnt >= 0)
  {
    intSPos = strJustPath.ReverseFind("/", intEPos);
    if (intSPos > -1)
    {
      if (intCnt == 2)  // album
      {
        m_selectedAlbum = strJustPath.substr(intSPos + 1, (intEPos - intSPos));
      }
      else if (intCnt == 1) // artist
      {
        m_selectedArtist = strJustPath.substr(intSPos + 1, (intEPos - intSPos));
      }
      else if (intCnt == 0) // playlist
      {
        m_selectedPlaylist = strJustPath.substr(intSPos + 1, (intEPos - intSPos));
      }

      intEPos = (intSPos - 1);
      intCnt --;
    }
  }

  return intLevel;
}
Ejemplo n.º 4
0
CStdString FilePath(CStdString& path)
{
	CStdString result;
	int lastSeparatorPosition = path.ReverseFind('/');
	if(lastSeparatorPosition == -1)
	{
		lastSeparatorPosition = path.ReverseFind('\\');
	}
	if(lastSeparatorPosition != -1 && path.GetLength()>3)
	{
		result = path.Left(lastSeparatorPosition + 1);
	}
	return result;
}
Ejemplo n.º 5
0
void CPVRRecording::Update(const CPVRRecording &tag)
{
  m_strRecordingId = tag.m_strRecordingId;
  m_iClientId      = tag.m_iClientId;
  m_strTitle       = tag.m_strTitle;
  m_recordingTime  = tag.m_recordingTime;
  m_duration       = tag.m_duration;
  m_iPriority      = tag.m_iPriority;
  m_iLifetime      = tag.m_iLifetime;
  m_strDirectory   = tag.m_strDirectory;
  m_strPlot        = tag.m_strPlot;
  m_strPlotOutline = tag.m_strPlotOutline;
  m_strStreamURL   = tag.m_strStreamURL;
  m_strChannelName = tag.m_strChannelName;
  m_strGenre       = tag.m_strGenre;

  CStdString strShow;
  strShow.Format("%s - ", g_localizeStrings.Get(20364).c_str());
  if (m_strPlotOutline.Left(strShow.size()).Equals(strShow))
  {
    CStdString strEpisode = m_strPlotOutline;
    CStdString strTitle = m_strDirectory;
    
    int pos = strTitle.ReverseFind('/');
    strTitle.erase(0, pos + 1);
    strEpisode.erase(0, strShow.size());
    m_strTitle.Format("%s - %s", strTitle.c_str(), strEpisode);
    pos = strEpisode.Find('-');
    strEpisode.erase(0, pos + 2);
    m_strPlotOutline = strEpisode;
  }
  UpdatePath();
}
Ejemplo n.º 6
0
CStdString CTestUtils::GetTestPath(const CStdString& sModule)
{
	CStdString sModuleName = sModule;
	sModuleName.ToLower();

	if ((sModuleName.Find(ARCHDIR + _T( "\\debug\\")) != -1) ||
		(sModuleName.Find(ARCHDIR + _T( "\\release\\")) != -1))
	{
		return PathBefore(sModuleName, ARCHDIR ) + "\\Test Files\\";
	}

	if (sModuleName.Find(_T("\\common\\testingframework\\")) != -1)
	{
		return PathBefore(sModuleName, "\\common") + "\\Test Files\\";
	}

	int iFileName = sModuleName.Find(_T("\\testharness.exe")) ;

	if (iFileName != -1)
	{
		return sModuleName.Mid(0, sModuleName.Find(_T("testharness.exe"))) + _T("Test Files\\");
	}
	
	iFileName = sModuleName.ReverseFind('\\');

	if (iFileName != -1)
	{
		return sModuleName.Mid(0, iFileName) + _T("Tests\\Test Files\\");
	}

	return _T("");
}
Ejemplo n.º 7
0
bool ASAPCodec::Init(const CStdString &strFile, unsigned int filecache)
{
  if (!m_dll.Load())
    return false;

  CStdString strFileToLoad = strFile;
  int song = -1;
  CStdString strExtension;
  CUtil::GetExtension(strFile, strExtension);
  strExtension.MakeLower();
  if (strExtension == ".asapstream")
  {
    CStdString strFileName = CUtil::GetFileName(strFile);
    int iStart = strFileName.ReverseFind('-') + 1;
    song = atoi(strFileName.substr(iStart, strFileName.size() - iStart - 11).c_str()) - 1;
    CStdString strPath = strFile;
    CUtil::GetDirectory(strPath, strFileToLoad);
    CUtil::RemoveSlashAtEnd(strFileToLoad);
  }

  int duration;
  if (!m_dll.asapLoad(strFileToLoad.c_str(), song, &m_Channels, &duration))
    return false;
  m_TotalTime = duration;
  m_SampleRate = 44100;
  m_BitsPerSample = 16;
  return true;
}
Ejemplo n.º 8
0
void URIUtils::RemoveExtension(CStdString& strFileName)
{
  if(IsURL(strFileName))
  {
    CURL url(strFileName);
    strFileName = url.GetFileName();
    RemoveExtension(strFileName);
    url.SetFileName(strFileName);
    strFileName = url.Get();
    return;
  }

  int iPos = strFileName.ReverseFind(".");
  // Extension found
  if (iPos > 0)
  {
    CStdString strExtension = GetExtension(strFileName);
    strExtension.ToLower();
    strExtension += "|";

    CStdString strFileMask;
    strFileMask = g_advancedSettings.m_pictureExtensions;
    strFileMask += "|" + g_advancedSettings.m_musicExtensions;
    strFileMask += "|" + g_advancedSettings.m_videoExtensions;
#if defined(TARGET_DARWIN)
    strFileMask += "|.py|.xml|.milk|.xpr|.xbt|.cdg|.app|.applescript|.workflow";
#else
    strFileMask += "|.py|.xml|.milk|.xpr|.xbt|.cdg";
#endif
    strFileMask += "|";

    if (strFileMask.Find(strExtension) >= 0)
      strFileName = strFileName.Left(iPos);
  }
}
Ejemplo n.º 9
0
CStdString CVisualisation::GetCombinedName(const char* friendlyName)
{
  CStdString moduleName;
  CStdString fName  = friendlyName;

  // convert from "module name (vis name)" to "vis name.mvis:module name"
  int startPos = fName.ReverseFind(" (");

  if ( startPos > 0 )
  {
    int endPos = fName.ReverseFind(")");
    CStdString moduleName = fName.Left( startPos );
    CStdString visName    = fName.Mid( startPos+2, endPos-startPos-2 );
    return visName + ".mvis" + ":" + moduleName;
  }
  return fName + ".vis";
}
Ejemplo n.º 10
0
CStdString CTestUtils::GetBinaryInstalledPath(const CStdString& sBinaryName)
{
	CStdString sModuleName = GetLongModuleName();
	sModuleName.ToLower();

	if ((sModuleName.Find(ARCHDIR + _T( "\\debug\\")) != -1) ||
		(sModuleName.Find(_T("\\common\\testingframework\\debug\\")) != -1) ||
		(sModuleName.Find(_T("\\common\\testingframework\\debug unicode\\")) != -1))
	{
		CStdString sLikelyPath = StopStringAfter(sModuleName, ARCHDIR  + L"\\debug\\");
		if (_taccess(sLikelyPath + sBinaryName, 0) != -1)
		{
			return (sLikelyPath) + sBinaryName;
		}
	}
	
	if ((sModuleName.Find(ARCHDIR + _T( "\\release\\")) != -1) ||
		(sModuleName.Find(_T("\\common\\testingframework\\release\\")) != -1)  ||
		(sModuleName.Find(_T("\\common\\testingframework\\release unicode\\")) != -1))
	{
		CStdString sLikelyPath = StopStringAfter(sModuleName, ARCHDIR + L"\\release\\");
		if (_taccess(sLikelyPath + sBinaryName, 0) != -1)
		{
			return sLikelyPath + sBinaryName;
		}
	}

	int iFileName = sModuleName.Find(_T("\\testharness.exe")) ;

	if (iFileName != -1)
	{
		CStdString sDir = sModuleName.Mid(0, sModuleName.Find(_T("tests\\testharness.exe")));

		if (_taccess(sDir + sBinaryName, 0) != -1)
		{
			return sDir + sBinaryName;
		}

		if (_taccess(sDir + _T("Tests\\") + sBinaryName, 0) != -1)
		{
			return sDir + _T("Tests\\") + sBinaryName;
		}
	}
	
	iFileName = sModuleName.ReverseFind('\\');

	if (iFileName != -1)
	{
		CStdString sDir = sModuleName.Mid(0, iFileName+1);

		if (_taccess(sDir + sBinaryName, 0) != -1)
		{
			return sDir + sBinaryName;
		}
	}

	return _T("");
}
Ejemplo n.º 11
0
HRESULT CWmp_scrobbler::SetCore(IWMPCore *pCore)
{
    HRESULT hr = S_OK;

    // release any existing WMP core interfaces
    ReleaseCore();

    // If we get passed a NULL core, this  means
    // that the plugin is being shutdown.

    if (pCore == NULL)
    {
        return S_OK;
    }

    m_spCore = pCore;

    // connect up the event interface
    CComPtr<IConnectionPointContainer>  spConnectionContainer;

    hr = m_spCore->QueryInterface( &spConnectionContainer );

    if (SUCCEEDED(hr))
    {
        hr = spConnectionContainer->FindConnectionPoint( __uuidof(IWMPEvents), &m_spConnectionPoint );
    }

    if (SUCCEEDED(hr))
    {
        hr = m_spConnectionPoint->Advise( GetUnknown(), &m_dwAdviseCookie );

        if ((FAILED(hr)) || (0 == m_dwAdviseCookie))
        {
            m_spConnectionPoint = NULL;
        }
    }

    m_wmpBootStrap.setParentHwnd( FindWindow( "WMPlayerApp", "Windows Media Player" ) );
    char filename[512];

	// Get the DLL filename etc
	GetModuleFileName( _Module.GetModuleInstance(), filename, sizeof( filename ) );
	CStdString Temp = filename;
	int pos = Temp.ReverseFind('\\');
	
	StartScrobbling( Temp.Left( pos + 1 ), _Module.GetModuleInstance() );
    
    if( m_wmpBootStrap.bootStrapRequired() )
    {
        m_wmpBootStrap.setCore( m_spCore );
        m_wmpBootStrap.setScrobSub( &m_Submitter );
        m_wmpBootStrap.setModuleHandle( _Module.GetModuleInstance() );
        m_wmpBootStrap.startBootStrap();
    }

    return hr;
}
Ejemplo n.º 12
0
CStdString FileBaseName(CStdString& path)
{
	CStdString result;
	int lastSeparatorPosition = path.ReverseFind('/');
	if(lastSeparatorPosition == -1)
	{
		lastSeparatorPosition = path.ReverseFind('\\');
	}
	if(lastSeparatorPosition != -1 && path.GetLength()>3)
	{
		result = path.Right(path.GetLength() - lastSeparatorPosition - 1);
	}
	else
	{
		result = path;
	}
	return result;
}
Ejemplo n.º 13
0
  bool Codec::Init(const CStdString & strFile, unsigned int filecache) {
    m_bufferSize = 2048 * sizeof(int16_t) * 50;
    m_buffer = new char[m_bufferSize];
    CStdString uri = URIUtils::GetFileName(strFile);
    CStdString extension = uri.Right(uri.GetLength() - uri.Find('.') - 1);
    if (extension.Left(12) == "spotifyradio") {
      //if its a radiotrack the radionumber and tracknumber is secretly encoded at the end of the extension
      CStdString trackStr = extension.Right(
          extension.GetLength() - extension.ReverseFind('#') - 1);
      Logger::printOut(extension);
      CStdString radioNumber = extension.Left(uri.Find('#'));
      Logger::printOut(radioNumber);
      radioNumber = radioNumber.Right(
          radioNumber.GetLength() - radioNumber.Find('#') - 1);
      Logger::printOut("loading codec radio");
      RadioHandler::getInstance()->pushToTrack(atoi(radioNumber),
          atoi(trackStr));
    }
    //we have a non legit extension so remove it manually
    uri = uri.Left(uri.Find('.'));

    Logger::printOut("trying to load track:");
    Logger::printOut(uri);
    sp_link *spLink = sp_link_create_from_string(uri);
    m_currentTrack = sp_link_as_track(spLink);
    sp_track_add_ref(m_currentTrack);
    sp_link_release(spLink);
    m_endOfTrack = false;
    m_bufferPos = 0;
    m_startStream = false;
    m_isPlayerLoaded = false;
    m_TotalTime = sp_track_duration(m_currentTrack);

    //prefetch the next track!

	  CPlayList& playlist = g_playlistPlayer.GetPlaylist(PLAYLIST_MUSIC);
	  int nextSong = g_playlistPlayer.GetNextSong();

	  if (nextSong >= 0 && nextSong < playlist.size()){
	  	CFileItemPtr song = playlist[nextSong];
	  	if (song != NULL){
	  		CStdString uri = song->GetPath();
	  		if (uri.Left(7).Equals("spotify")){
	  			uri = uri.Left(uri.Find('.'));
	  	    Logger::printOut("prefetching track:");
	  	    Logger::printOut(uri);
	  	    sp_link *spLink = sp_link_create_from_string(uri);
	  	    sp_track* track = sp_link_as_track(spLink);
	  	    sp_session_player_prefetch(getSession(), track);
	  	    sp_link_release(spLink);
	  		}
	  	}
	  }

    return true;
  }
Ejemplo n.º 14
0
void CTestUtils::AddBackslashIfNecessary(CStdString& sTempPath)
{
	if(IsDirectory(sTempPath))
	{
		if (sTempPath.ReverseFind('\\') != (sTempPath.length() - 1))
		{
			sTempPath += _T("\\");
		}
	}
}
Ejemplo n.º 15
0
CStdString CDefragStorage::GetFilePath(CStdString sFullName)
{
	sFullName.Replace(_T('/'),'\\');
	int iLastDirPos = sFullName.ReverseFind('\\');

	if (iLastDirPos == -1)
		return _T("");

	return sFullName.Left(iLastDirPos+1);
}
Ejemplo n.º 16
0
void URIUtils::GetDirectory(const CStdString& strFilePath,
                            CStdString& strDirectoryPath)
{
  // Will from a full filename return the directory the file resides in.
  // Keeps the final slash at end

  int iPos1 = strFilePath.ReverseFind('/');
  int iPos2 = strFilePath.ReverseFind('\\');

  if (iPos2 > iPos1)
  {
    iPos1 = iPos2;
  }

  if (iPos1 > 0)
  {
    strDirectoryPath = strFilePath.Left(iPos1 + 1); // include the slash
  }
}
Ejemplo n.º 17
0
CStdString SystemFolderInfo::GetProfilesRoot()
{
	CStdString sPath;

	switch (GetWindowsVersion())
	{
	case WINDOWS_95:
	case WINDOWS_ME:
	case WINDOWS_98:
		{
			sPath = GetWindowsPath();

			if (HasWin98UserGotProfile())
				sPath += _T("\\Profiles");
		}
		break;

	case WINDOWS_NT:
		{
			sPath = GetLocalUserAppDataPath();

			int nPos = sPath.ReverseFind('\\');
			sPath = sPath.Left(nPos);

			nPos = sPath.ReverseFind('\\');
			sPath = sPath.Left(nPos);
		}
		break;

	case WINDOWS_2003SERVER:
	case WINDOWS_2K:
	case WINDOWS_XP:
	default:
		{
			sPath = GetProfilesDirectory();
		}
		break;

	}

	return sPath;
}
Ejemplo n.º 18
0
// \brief Override the function to change the default behavior on how
// a selected item history should look like
void CGUIMediaWindow::GetDirectoryHistoryString(const CFileItem* pItem, CStdString& strHistoryString)
{
  if (pItem->m_bIsShareOrDrive)
  {
    // We are in the virual directory

    // History string of the DVD drive
    // must be handel separately
    if (pItem->m_iDriveType == CMediaSource::SOURCE_TYPE_DVD)
    {
      // Remove disc label from item label
      // and use as history string, m_strPath
      // can change for new discs
      CStdString strLabel = pItem->GetLabel();
      int nPosOpen = strLabel.Find('(');
      int nPosClose = strLabel.ReverseFind(')');
      if (nPosOpen > -1 && nPosClose > -1 && nPosClose > nPosOpen)
      {
        strLabel.Delete(nPosOpen + 1, (nPosClose) - (nPosOpen + 1));
        strHistoryString = strLabel;
      }
      else
        strHistoryString = strLabel;
    }
    else
    {
      // Other items in virual directory
      CStdString strPath = pItem->m_strPath;
      while (CUtil::HasSlashAtEnd(strPath))
        strPath.Delete(strPath.size() - 1);

      strHistoryString = pItem->GetLabel() + strPath;
    }
  }
  else if (pItem->m_lEndOffset>pItem->m_lStartOffset && pItem->m_lStartOffset != -1)
  {
    // Could be a cue item, all items of a cue share the same filename
    // so add the offsets to build the history string
    strHistoryString.Format("%ld%ld", pItem->m_lStartOffset, pItem->m_lEndOffset);
    strHistoryString += pItem->m_strPath;

    if (CUtil::HasSlashAtEnd(strHistoryString))
      strHistoryString.Delete(strHistoryString.size() - 1);
  }
  else
  {
    // Normal directory items
    strHistoryString = pItem->m_strPath;

    while (CUtil::HasSlashAtEnd(strHistoryString)) // to match CDirectoryHistory::GetSelectedItem
      strHistoryString.Delete(strHistoryString.size() - 1);
  }
  strHistoryString.ToLower();
}
Ejemplo n.º 19
0
CStdString FileStripExtension(CStdString& filename)
{
	CStdString result;
	int extensionPosition = filename.ReverseFind('.');
	if (extensionPosition != -1)
	{
		result = filename.Left(extensionPosition);
	}
	else
	{
		result = filename;
	}
	return result;
}
Ejemplo n.º 20
0
void TestGlobalMethods::TestReplaceFileExtension()
{
	CStdString sFile = _T("NotPDF.doc");
	CStdString sExtension = _T("pdf");
	CStdString sResult = ReplaceFileExtension(sFile, sExtension.c_str());
	int iPosition = sResult.ReverseFind(_T('.'));
	CStdString sNewExtension = sResult.Right((int)sResult.length() - (iPosition + 1));
	assertMessage(0 != iPosition, _T("Failed to locate file extension separator '.'"));
	assertMessage(0 == (int)sExtension.CompareNoCase(sNewExtension), _T("Failed to match the expected extension 'pdf'"));

	sFile = _T("IsPDF.pdf");
	sExtension = _T("pdf");
	sResult = ReplaceFileExtension(sFile, sExtension.c_str());
	sNewExtension = sResult.Right((int)sResult.length() - (sResult.Find(_T("."), 0) + 1));
	assertMessage(sExtension.length() == sNewExtension.length(), _T("We expected the extension lengths to be equal"));

	sFile = _T("NoExtension");
	sExtension = _T("pdf");
	sResult = ReplaceFileExtension(sFile, sExtension.c_str());
	iPosition = sResult.ReverseFind(_T('.'));
	assertMessage(0 != iPosition, _T("Failed to locate file extension separator '.'"));
	assertMessage(0 == (int)sExtension.CompareNoCase(sResult.Right((int)sResult.length() - (iPosition + 1))), _T("Failed to match the expected extension 'pdf'"));
}
Ejemplo n.º 21
0
void ExcelControllerImpl08::WaitForWorkbookOpened(const CStdString& sFilePathName)
{
   CStdString sWorkbookName = sFilePathName;

   int iPos = sWorkbookName.ReverseFind('\\');
   if (-1 != iPos)
      sWorkbookName = sWorkbookName.Right((int)sWorkbookName.length() - iPos - 1);
   else
   {
      iPos = sWorkbookName.ReverseFind(_T('/'));
      if (-1 != iPos)
         sWorkbookName = sWorkbookName.Right((int)sWorkbookName.length() - iPos - 1);
   }

   int iTryCount = 0;
   while (200 >= iTryCount)  // about 20 seconds
   {
      try
      {
         Excel::_ApplicationPtr spApplication = GetApplication();
         Excel::_WorkbookPtr spWorkbook = spApplication->Workbooks->Item[sWorkbookName.c_str()];
         return;
      }
      catch(const Workshare::Exception&)
      {
         //ignore
      }
      catch(...)
      {
         unexpected();
      }
      ::Sleep(100);
      iTryCount++;
   }
   throw Workshare::Com::ComException(_T("Failed to open workbook [") + sFilePathName + _T("], wait time expired"), E_FAIL);
}
Ejemplo n.º 22
0
CStdString SmartTagParser::ParseName(const _bstr_t & Name)
{
    CStdString sLocalName = Name;

    int iPos = sLocalName.ReverseFind(_T('#'));

    if (iPos == -1)
    {
        CStdString msg;
        msg.Format(_T("SmartTagParser::GetTextForSmartTagName - Failed to find '#' in string '%s'"), sLocalName);
        throw Workshare::Exception(msg);        
    }

    return sLocalName.Right(sLocalName.GetLength() - (iPos+1));
}
Ejemplo n.º 23
0
void CGUIWindowWeather::UpdateLocations()
{
  if (!IsActive()) return;
  m_maxLocation = strtol(GetProperty("Locations").asString().c_str(),0,10);
  if (m_maxLocation < 1) return;
  CGUIMessage msg(GUI_MSG_LABEL_RESET,GetID(),CONTROL_SELECTLOCATION);
  g_windowManager.SendMessage(msg);
  CGUIMessage msg2(GUI_MSG_LABEL_ADD,GetID(),CONTROL_SELECTLOCATION);

  unsigned int iCurWeather = g_weatherManager.GetArea();

  if (iCurWeather > m_maxLocation)
  {  
    g_weatherManager.SetArea(m_maxLocation);
    iCurWeather = m_maxLocation;
    ClearProperties();
    g_weatherManager.Refresh();
  }
  
  for (unsigned int i = 1; i <= m_maxLocation; i++)
  {
    CStdString strLabel = g_weatherManager.GetLocation(i);
    if (strLabel.size() > 1) //got the location string yet?
    {
      int iPos = strLabel.ReverseFind(", ");
      if (iPos)
      {
        CStdString strLabel2(strLabel);
        strLabel = strLabel2.substr(0,iPos);
      }
      msg2.SetParam1(i);
      msg2.SetLabel(strLabel);
      g_windowManager.SendMessage(msg2);
    }
    else
    {
      strLabel.Format("AreaCode %i", i);

      msg2.SetLabel(strLabel);
      msg2.SetParam1(i);
      g_windowManager.SendMessage(msg2);
    }
    if (i == iCurWeather)
      SET_CONTROL_LABEL(CONTROL_SELECTLOCATION,strLabel);
  }

  CONTROL_SELECT_ITEM(CONTROL_SELECTLOCATION, iCurWeather);
}
Ejemplo n.º 24
0
/// \brief Build a directory history string
/// \param pItem Item to build the history string from
/// \param strHistoryString History string build as return value
void CGUIWindowFileManager::GetDirectoryHistoryString(const CFileItem* pItem, CStdString& strHistoryString)
{
/*
	歌方:
		1、
		
	卦指:
		1、
		
	傍苧:
		1、
*/
	if (pItem->m_bIsShareOrDrive)
	{
		// We are in the virtual directory

		// History string of the DVD drive
		// must be handel separately
		if (pItem->m_iDriveType == CMediaSource::SOURCE_TYPE_DVD)
		{
			// Remove disc label from item label
			// and use as history string, m_strPath
			// can change for new discs
			CStdString strLabel = pItem->GetLabel();
			int nPosOpen = strLabel.Find('(');
			int nPosClose = strLabel.ReverseFind(')');
			if (nPosOpen > -1 && nPosClose > -1 && nPosClose > nPosOpen)
			{
				strLabel.Delete(nPosOpen + 1, (nPosClose) - (nPosOpen + 1));
				strHistoryString = strLabel;
			}
			else
				strHistoryString = strLabel;
		}
		else
		{
			// Other items in virtual directory
			strHistoryString = pItem->GetLabel() + pItem->GetPath();
			URIUtils::RemoveSlashAtEnd(strHistoryString);
		}
	}
	else
	{
		// Normal directory items
		strHistoryString = pItem->GetPath();
		URIUtils::RemoveSlashAtEnd(strHistoryString);
	}
}
Ejemplo n.º 25
0
CStdString CVisualisation::GetFriendlyName(const char* combinedName)
{
  CStdString moduleName;
  CStdString visName  = combinedName;
  int        colonPos = visName.ReverseFind(":");

  if ( colonPos > 0 )
  {
    visName    = visName.Mid( colonPos + 1 );
    moduleName = visName.Mid( 0, colonPos - 5 );  // remove .mvis

    // should be of the format "moduleName (visName)"
    return moduleName + " (" + visName + ")";
  }
  return visName.Left( visName.size() - 4 );
}
Ejemplo n.º 26
0
/*!
 \brief Sets the location to the specified index and refreshes the weather
 \param loc the location index (in the range [1..MAXLOCATION])
 */
void CGUIWindowWeather::SetLocation(int loc)
{
  if (loc < 1 || loc > (int)m_maxLocation)
    return;
  // Avoid a settings write if old location == new location
  if (g_weatherManager.GetArea() != loc)
  {
    ClearProperties();
    g_weatherManager.SetArea(loc);
    CStdString strLabel = g_weatherManager.GetLocation(loc);
    int iPos = strLabel.ReverseFind(", ");
    if (iPos)
      strLabel = strLabel.substr(0, iPos);
    SET_CONTROL_LABEL(CONTROL_SELECTLOCATION, strLabel);
  }
  g_weatherManager.Refresh();
}
Ejemplo n.º 27
0
void CTestUtils::RecursiveCreateDirectoryIfNecessary(CStdString sTempPath)
{
	int iBackSlashPos = sTempPath.ReverseFind('\\');

	if (iBackSlashPos == -1)
	{
		return;
	}

	CStdString sPath = sTempPath.Mid(0, iBackSlashPos);

	if (_taccess(sPath, 0) == -1)
	{
		RecursiveCreateDirectoryIfNecessary(sPath);
		_tmkdir(sPath);
	}
}
Ejemplo n.º 28
0
bool CMusicInfoTagLoaderASAP::Load(const CStdString &strFile, CMusicInfoTag &tag, EmbeddedArt *art)
{
    tag.SetLoaded(false);

    if (!m_dll.Load())
        return false;

    CStdString strFileToLoad = strFile;
    int song = -1;
    CStdString strExtension;
    URIUtils::GetExtension(strFile, strExtension);
    strExtension.MakeLower();
    if (strExtension == ".asapstream")
    {
        CStdString strFileName = URIUtils::GetFileName(strFile);
        int iStart = strFileName.ReverseFind('-') + 1;
        song = atoi(strFileName.substr(iStart, strFileName.size() - iStart - 11).c_str()) - 1;
        CStdString strPath = strFile;
        URIUtils::GetDirectory(strPath, strFileToLoad);
        URIUtils::RemoveSlashAtEnd(strFileToLoad);
    }

    ASAP_SongInfo songInfo;
    if (!m_dll.asapGetInfo(strFileToLoad.c_str(), song, &songInfo))
        return false;

    tag.SetURL(strFileToLoad);
    if (songInfo.name[0] != '\0')
        tag.SetTitle(songInfo.name);
    if (songInfo.author[0] != '\0')
        tag.SetArtist(songInfo.author);
    if (song >= 0)
        tag.SetTrackNumber(song + 1);
    if (songInfo.duration >= 0)
        tag.SetDuration(songInfo.duration / 1000);
    if (songInfo.year > 0)
    {
        SYSTEMTIME dateTime = { (WORD)songInfo.year, (WORD)songInfo.month, 0,
                                (WORD)songInfo.day, 0, 0, 0, 0
                              };
        tag.SetReleaseDate(dateTime);
    }
    tag.SetLoaded(true);
    return true;
}
Ejemplo n.º 29
0
CVisualisation* CVisualisationFactory::LoadVisualisation(const CStdString& strVisz,
                                                         const CStdString& strSubModule) const
{
  // strip of the path & extension to get the name of the visualisation
  // like goom or spectrum
  CStdString strFileName = strVisz;
  CStdString strName = CUtil::GetFileName(strVisz);

  // if it's a relative path or just a name, convert to absolute path
  if ( strFileName[1] != ':' && strFileName[0] != '/' )
  {
    // first check home
    strFileName.Format("special://home/visualisations/%s", strName.c_str() );

    // if not found, use system
    if ( ! CFile::Exists( strFileName ) )
      strFileName.Format("special://xbmc/visualisations/%s", strName.c_str() );
  }
  strName = strName.Left(strName.ReverseFind('.'));

#ifdef HAS_VISUALISATION
  // load visualisation
  DllVisualisation* pDll = new DllVisualisation;
  pDll->SetFile(strFileName);
  //  FIXME: Some Visualisations do not work 
  //  when their dll is not unloaded immediatly
  pDll->EnableDelayedUnload(false);
  if (!pDll->Load())
  {
    delete pDll;
    return NULL;
  }

  struct Visualisation* pVisz = new Visualisation;
  ZeroMemory(pVisz, sizeof(struct Visualisation));
  pDll->GetModule(pVisz);

  // and pass it to a new instance of CVisualisation() which will hanle the visualisation
  return new CVisualisation(pVisz, pDll, strName, strSubModule);
#else
  return NULL;
#endif
}
Ejemplo n.º 30
0
CStdString ReplaceFileExtension(CStdString filePath, LPCTSTR newExtension)
{
	if(filePath.IsEmpty() && (0 ==_tcslen(newExtension)))
		return _T("");

	CStdString sFileWithNewExtension(_T(""));

	CStdString sExtensionToUse;
	if(_T('.') != newExtension[0])
		sExtensionToUse = _T(".");

	sExtensionToUse.append(newExtension);

	int iExtensionPosition = filePath.ReverseFind(_T('.'));
	if(0 < iExtensionPosition)
		sFileWithNewExtension = filePath.Left(iExtensionPosition);
	else
		sFileWithNewExtension = filePath;

	sFileWithNewExtension += sExtensionToUse;
	return sFileWithNewExtension;
}