Ejemplo n.º 1
0
//==============================================================================
juce::var OAuth2Client::getJSON (const OAuthSource& source)
{
    if (accessToken.id.isEmpty())
        return juce::var::null;

    juce::URL url (source.getWebsiteAddress().trim());

    if (! url.isWellFormed())
    {
        jassertfalse;
        return juce::var::null;
    }

    url = url.withParameter ("client_id", accessToken.id)
             .withParameter ("client_secret", accessToken.secret);

    if (accessToken.username.isNotEmpty()
        && accessToken.password.isNotEmpty())
    {
        url = url.withParameter ("username", accessToken.username)
                 .withParameter ("password", accessToken.password);
    }

    if (! url.isWellFormed())
    {
        jassertfalse;
        return juce::var::null;
    }

    const juce::String textStream (url.readEntireTextStream().trim());

    if (textStream.isEmpty()
        || (textStream.containsIgnoreCase ("errors")
            && textStream.containsIgnoreCase ("error_message")))
    {
        jassertfalse;
        return juce::var::null;
    }

    juce::var result (juce::JSON::parse (textStream));

    jassert (result != juce::var::null);
    jassert (! result.isUndefined() && ! result.isVoid());

    return result;
}
Ejemplo n.º 2
0
juce::String Track::extractInstrumentNameFromTrackName(const juce::String& trackName)
{
  //On regarde les noms des fichiers .fxp dans le répertoire fxp
  //Si la trackName contient un de ces noms, c'est l'instrument qu'on cherche !
  juce::Array<juce::File> fxpFiles;
  juce::File fxpDirectory = juce::File::getCurrentWorkingDirectory().getChildFile("../fxp").getFullPathName();
  fxpDirectory.findChildFiles(fxpFiles, juce::File::findFiles, true, "*.fxp");
  for(int i = 0; i < fxpFiles.size(); ++i)
  {
    if (trackName.containsIgnoreCase(fxpFiles[i].getFileNameWithoutExtension()))
      return fxpFiles[i].getFileNameWithoutExtension();
  }
  return juce::String::empty;
}