/// Return the url from a string that matched the regex std::string LLUrlEntrySecondlifeURL::getUrl(const std::string &string) const { if (string.find("://") == std::string::npos) { return "https://" + escapeUrl(string); } return escapeUrl(string); }
std::string LLUrlEntryHTTPNoProtocol::getUrl(const std::string &string) const { if (string.find("://") == std::string::npos) { return "http://" + escapeUrl(string); } return escapeUrl(string); }
optional<string> FileSharing::download(const string& filename, const string& dir, ProgressMeter& meter) { if (!options.getBoolValue(OptionId::ONLINE)) return string("Downloading not enabled!"); //progressFun = [&] (double p) { meter.setProgress(p);}; if (CURL *curl = curl_easy_init()) { string path = dir + "/" + filename; Debug() << "Downloading to " << path; if (FILE* fp = fopen(path.c_str(), "wb")) { curl_easy_setopt(curl, CURLOPT_URL, escapeUrl(uploadUrl + "/uploads/" + filename).c_str()); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeToFile); curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); // Internal CURL progressmeter must be disabled if we provide our own callback curl_easy_setopt(curl, CURLOPT_NOPROGRESS, false); // Install the callback function curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progressFunction); curl_easy_setopt(curl, CURLOPT_FAILONERROR, true); CURLcode res = curl_easy_perform(curl); string ret; if(res != CURLE_OK) ret = string("Upload failed: ") + curl_easy_strerror(res); curl_easy_cleanup(curl); fclose(fp); if (!ret.empty()) { remove(path.c_str()); return ret; } else return none; } else return string("Failed to open file: " + path); } else return string("Failed to initialize libcurl"); }
std::string LLUrlEntryBase::getUrlFromWikiLink(const std::string &string) const { // return the url part from [http://www.example.org Label] const char *text = string.c_str(); S32 end = 0; while (! isspace(text[end])) { end++; } return escapeUrl(string.substr(1, end-1)); }
string FileSharing::downloadHighscores() { string ret; if(CURL* curl = curl_easy_init()) { curl_easy_setopt(curl, CURLOPT_URL, escapeUrl(uploadUrl + "/highscores.php").c_str()); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, dataFun); curl_easy_setopt(curl, CURLOPT_TIMEOUT, 5); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ret); curl_easy_perform(curl); curl_easy_cleanup(curl); } return ret; }
vector<FileSharing::GameInfo> FileSharing::listGames() { if(CURL* curl = curl_easy_init()) { curl_easy_setopt(curl, CURLOPT_URL, escapeUrl(uploadUrl + "/get_games.php").c_str()); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, dataFun); curl_easy_setopt(curl, CURLOPT_TIMEOUT, 5); string ret; curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ret); curl_easy_perform(curl); curl_easy_cleanup(curl); return parseGames(ret); } return {}; }
void SpeedDial::addPage(const QUrl &url, const QString &title) { ENSURE_LOADED; if (url.isEmpty()) { return; } Page page; page.title = escapeTitle(title); page.url = escapeUrl(url.toString()); m_pages.append(page); m_regenerateScript = true; emit pagesChanged(); }
void SpeedDial::addPage(const QUrl &url, const QString &title) { ENSURE_LOADED; if (url.isEmpty()) { return; } Page page; page.title = escapeTitle(title); page.url = escapeUrl(url.toString()); m_webPages.append(page); m_regenerateScript = true; foreach (QWebFrame* frame, cleanFrames()) { frame->page()->triggerAction(QWebPage::Reload); }
static optional<string> curlUpload(const char* path, const char* url, void* progressCallback, int timeout) { struct curl_httppost *formpost=NULL; struct curl_httppost *lastptr=NULL; curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "fileToUpload", CURLFORM_FILE, path, CURLFORM_END); curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "submit", CURLFORM_COPYCONTENTS, "send", CURLFORM_END); if (CURL* curl = curl_easy_init()) { curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, dataFun); string ret; curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ret); /* what URL that receives this POST */ curl_easy_setopt(curl, CURLOPT_URL, escapeUrl(url).c_str()); curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost); if (timeout > 0) curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout); // Internal CURL progressmeter must be disabled if we provide our own callback curl_easy_setopt(curl, CURLOPT_NOPROGRESS, false); if (progressCallback) { curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, progressCallback); curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progressFunction); } CURLcode res = curl_easy_perform(curl); if (res != CURLE_OK) ret = string("Upload failed: ") + curl_easy_strerror(res); curl_easy_cleanup(curl); curl_formfree(formpost); if (!ret.empty()) return ret; else return none; } else return string("Failed to initialize libcurl"); }
optional<vector<FileSharing::SiteInfo>> FileSharing::listSites() { if (!options.getBoolValue(OptionId::ONLINE)) return {}; if (CURL* curl = curl_easy_init()) { curl_easy_setopt(curl, CURLOPT_URL, escapeUrl(uploadUrl + "/get_sites.php").c_str()); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, dataFun); curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10); // Internal CURL progressmeter must be disabled if we provide our own callback curl_easy_setopt(curl, CURLOPT_NOPROGRESS, false); // Install the callback function curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progressFunction); string ret; curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ret); CURLcode res = curl_easy_perform(curl); curl_easy_cleanup(curl); if (res != CURLE_OK) return none; return parseSites(ret); } return none; }
void FileSharing::uploadGameEventImpl(const GameEvent& data, int tries) { if (tries >= 0) uploadQueue.push([data, this, tries] { string params; for (auto& elem : data) { if (!params.empty()) params += "&"; params += elem.first + "=" + elem.second; } if (CURL* curl = curl_easy_init()) { string ret; curl_easy_setopt(curl, CURLOPT_URL, escapeUrl(uploadUrl + "/game_event2.php").c_str()); curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, params.c_str()); CURLcode res = curl_easy_perform(curl); curl_easy_cleanup(curl); if (res != CURLE_OK) uploadGameEventImpl(data, tries - 1); } }); }
std::string LLUrlEntryBase::getUrl(const std::string &string) const { return escapeUrl(string); }
std::string LLUrlEntryInvalidSLURL::getUrl(const std::string &string) const { return escapeUrl(string); }
std::string LLUrlEntryInvalidSLURL::getLabel(const std::string &url, const LLUrlLabelCallback &cb) { return escapeUrl(url); }