void TemplateActor::createStringOfSimilarArtists() { if (this->similarArtistsStringCreationInProgress == true) { return; } this->similarArtistsStringCreationInProgress = true; this->similarArtistsStringVector.clear(); this->theTemplateAction->removeImage(); this->similarArtistsCurrentTrackIdentifier = VisualDataStore::getIdentifierOfCurrentTrack(); VisualString* normalizedArtistNameForURLConstruction = VisualNetwork::createNormalizedURLString(VisualDataStore::getArtistOfCurrentTrack()); if (!normalizedArtistNameForURLConstruction) { return; } VisualString similarArtistsURL; similarArtistsURL.initWithUTF8String("http://ws.audioscrobbler.com/1.0/artist/"); similarArtistsURL = (similarArtistsURL + *normalizedArtistNameForURLConstruction); delete normalizedArtistNameForURLConstruction; similarArtistsURL = (similarArtistsURL + "/similar.txt"); if (this->stringOfSimilarArtists != NULL) { delete this->stringOfSimilarArtists; } this->stringOfSimilarArtists = VisualString::createWithContentsOfURL(similarArtistsURL.getUtf8Representation(), this->similarArtistsStringRequestId); this->similarArtistsStringCreationInProgress = false; }
bool VisualAppleScript::executeScriptFile(VisualFile& scriptFile) { bool success = false; VisualString scriptFilePath; scriptFile.getFilePath(scriptFilePath); const char* const scriptPathCStr = scriptFilePath.getUtf8Representation(); size_t scriptPathCStrLen = strlen(scriptPathCStr); if (scriptPathCStrLen > 0) { char* script = (char*)malloc(scriptPathCStrLen + strlen("osascript ") + 3); sprintf(script, "osascript \"%s\"", scriptPathCStr); system(script); free(script); success = true; } return success; }