Adjust all users of BUrl to new API

The old BUrl constructor with just a string is now private. The new one
has a default value for the second parameter, but C++ doesn't exclude
the private constructor from the candidate functions search. So, the
default argument for the new constructor needs to be explicitly
specified now.

Change-Id: Idb1915649ea3d2c59e344801a9d4fe201f8040e9
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9236
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: nephele nephele <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
PulkoMandy
2025-05-27 10:43:12 +00:00
committed by Adrien Destugues
parent 1d242620b4
commit 0ec1d4526c
20 changed files with 33 additions and 33 deletions
@@ -287,7 +287,7 @@ void HttpURLConnection::getResponse()
{ {
const char *p = getHeaderField("Location"); const char *p = getHeaderField("Location");
if (p) { if (p) {
BUrl trueUrl(p); BUrl trueUrl(p, true);
url = trueUrl; url = trueUrl;
delete __response; delete __response;
__response = NULL; __response = NULL;
@@ -114,7 +114,7 @@ bool IppSetupView::UpdateViewData()
request->setURI("printer-uri", url->Text()); request->setURI("printer-uri", url->Text());
request->setDelimiter(IPP_END_OF_ATTRIBUTES_TAG); request->setDelimiter(IPP_END_OF_ATTRIBUTES_TAG);
IppURLConnection conn(BUrl(url->Text())); IppURLConnection conn(BUrl(url->Text(), true));
conn.setIppRequest(request); conn.setIppRequest(request);
conn.setRequestProperty("Connection", "close"); conn.setRequestProperty("Connection", "close");
@@ -97,7 +97,7 @@ IppTransport::~IppTransport()
__fs.seekg(0, ios::beg); __fs.seekg(0, ios::beg);
request->setRawData(__fs, fssize); request->setRawData(__fs, fssize);
BUrl url(__url); BUrl url(__url, true);
IppURLConnection conn(url); IppURLConnection conn(url);
conn.setIppRequest(request); conn.setIppRequest(request);
conn.setRequestProperty("Connection", "close"); conn.setRequestProperty("Connection", "close");
@@ -23,7 +23,7 @@
#define USERAGENT_FALLBACK_VERSION "0.0.0" #define USERAGENT_FALLBACK_VERSION "0.0.0"
BUrl ServerSettings::sBaseUrl = BUrl(BASEURL_DEFAULT); BUrl ServerSettings::sBaseUrl = BUrl(BASEURL_DEFAULT, true);
BString ServerSettings::sUserAgent = BString(); BString ServerSettings::sUserAgent = BString();
pthread_once_t ServerSettings::sUserAgentInitOnce = PTHREAD_ONCE_INIT; pthread_once_t ServerSettings::sUserAgentInitOnce = PTHREAD_ONCE_INIT;
bool ServerSettings::sPreferCache = false; bool ServerSettings::sPreferCache = false;
+1 -1
View File
@@ -277,7 +277,7 @@ App::ArgvReceived(int32 argc, char* argv[])
break; break;
case WEB_APP_BASE_URL_SWITCH: case WEB_APP_BASE_URL_SWITCH:
if (ServerSettings::SetBaseUrl(BUrl(argv[i + 1])) != B_OK) { if (ServerSettings::SetBaseUrl(BUrl(argv[i + 1], true)) != B_OK) {
HDERROR("malformed web app base url; %s", argv[i + 1]); HDERROR("malformed web app base url; %s", argv[i + 1]);
Quit(); Quit();
} else { } else {
+1 -1
View File
@@ -777,7 +777,7 @@ public:
case MSG_VISIT_PUBLISHER_WEBSITE: case MSG_VISIT_PUBLISHER_WEBSITE:
{ {
BUrl url(fWebsiteLinkView->Text()); BUrl url(fWebsiteLinkView->Text(), true);
url.OpenWithPreferredApplication(); url.OpenWithPreferredApplication();
break; break;
} }
+1 -1
View File
@@ -218,7 +218,7 @@ MainApp::ArgvReceived(int32 argc, char** argv)
getcwd(cwd, sizeof(cwd)); getcwd(cwd, sizeof(cwd));
for (int i = 1; i < argc; i++) { for (int i = 1; i < argc; i++) {
BUrl url(argv[i]); BUrl url(argv[i], true);
if (url.IsValid()) { if (url.IsValid()) {
BMessage archivedUrl; BMessage archivedUrl;
url.Archive(&archivedUrl); url.Archive(&archivedUrl);
+1 -1
View File
@@ -654,7 +654,7 @@ MainWin::MessageReceived(BMessage* msg)
BString urlString; BString urlString;
entry_ref fileRef; entry_ref fileRef;
for (int32 j = 0; msg->FindString("data", j, &urlString) == B_OK; j++) { for (int32 j = 0; msg->FindString("data", j, &urlString) == B_OK; j++) {
BUrl url(urlString); BUrl url(urlString, true);
if (url.IsValid() && url.Protocol() != "file") { if (url.IsValid() && url.Protocol() != "file") {
UrlPlaylistItem* item = new UrlPlaylistItem(url); UrlPlaylistItem* item = new UrlPlaylistItem(url);
if (!fPlaylist->AddItem(item, i + j)) { if (!fPlaylist->AddItem(item, i + j)) {
+2 -2
View File
@@ -62,7 +62,7 @@ NetworkStreamWin::MessageReceived(BMessage* message)
switch(message->what) { switch(message->what) {
case M_OPEN_URL: case M_OPEN_URL:
{ {
BUrl url(fTextControl->Text()); BUrl url(fTextControl->Text(), true);
if (!url.IsValid()) { if (!url.IsValid()) {
BAlert* alert = new BAlert(B_TRANSLATE("Bad URL"), BAlert* alert = new BAlert(B_TRANSLATE("Bad URL"),
B_TRANSLATE("Invalid URL inserted!"), B_TRANSLATE("Invalid URL inserted!"),
@@ -137,7 +137,7 @@ NetworkStreamWin::_LookIntoClipboardForUrl()
// Before to set the text let's see if it's really // Before to set the text let's see if it's really
// a valid URL. // a valid URL.
BUrl url(text); BUrl url(text, true);
if (url.IsValid()) if (url.IsValid())
fTextControl->SetText(text); fTextControl->SetText(text);
} }
@@ -52,7 +52,7 @@ PlaylistFileReader::_AppendItemToPlaylist(const BString& entry, Playlist* playli
if (err == B_OK) if (err == B_OK)
item = new (nothrow) FilePlaylistItem(refPath); item = new (nothrow) FilePlaylistItem(refPath);
else { else {
BUrl url(entry); BUrl url(entry, true);
if (url.IsValid()) if (url.IsValid())
item = new (nothrow) UrlPlaylistItem(url); item = new (nothrow) UrlPlaylistItem(url);
else { else {
@@ -30,7 +30,7 @@ UrlPlaylistItem::UrlPlaylistItem(const BMessage* archive)
{ {
const char* url = NULL; const char* url = NULL;
if (archive->FindString("mediaplayer:url", &url) == B_OK) if (archive->FindString("mediaplayer:url", &url) == B_OK)
fUrl = BUrl(url); fUrl = BUrl(url, true);
} }
+2 -2
View File
@@ -119,7 +119,7 @@ CheckItOut::ArgvReceived(int32 argc, char** argv)
return; return;
} }
BUrl url(argv[1]); BUrl url(argv[1], true);
fUrlString = url; fUrlString = url;
BString full = BUrl(url).SetProtocol(BString()).UrlString(); BString full = BUrl(url).SetProtocol(BString()).UrlString();
@@ -158,7 +158,7 @@ CheckItOut::_DoCheckItOut(entry_ref *ref, const char *name)
const char* pausec = " ; read -p 'Press any key'"; const char* pausec = " ; read -p 'Press any key'";
char* args[] = { (char *)"/bin/sh", (char *)"-c", NULL, NULL}; char* args[] = { (char *)"/bin/sh", (char *)"-c", NULL, NULL};
BUrl url(fUrlString); BUrl url(fUrlString, true);
BString full = BUrl(url).SetProtocol(BString()).UrlString(); BString full = BUrl(url).SetProtocol(BString()).UrlString();
BString proto = url.Protocol(); BString proto = url.Protocol();
BString host = url.Host(); BString host = url.Host();
+1 -1
View File
@@ -58,7 +58,7 @@ int media_play(const char* uri)
BMediaFile* playFile; BMediaFile* playFile;
if (get_ref_for_path(uri, &ref) != B_OK) { if (get_ref_for_path(uri, &ref) != B_OK) {
url.SetUrlString(uri); url.SetUrlString(uri, true);
if (url.IsValid()) { if (url.IsValid()) {
playFile = new BMediaFile(url); playFile = new BMediaFile(url);
} else } else
+1 -1
View File
@@ -96,7 +96,7 @@ main(int argc, char** argv)
result = B_OK; result = B_OK;
} else if (strchr(*argv, ':')) { } else if (strchr(*argv, ':')) {
// try to open it as an URI // try to open it as an URI
BUrl url(*argv); BUrl url(*argv, true);
result = url.OpenWithPreferredApplication(); result = url.OpenWithPreferredApplication();
if (result == B_OK || result == B_ALREADY_RUNNING) if (result == B_OK || result == B_ALREADY_RUNNING)
continue; continue;
+1 -1
View File
@@ -89,7 +89,7 @@ AddRepoCommand::Execute(int argc, const char* const* argv)
status_t result; status_t result;
for (int i = 0; i < urlCount; ++i) { for (int i = 0; i < urlCount; ++i) {
// Test if a valid URL has been supplied before attempting to add // Test if a valid URL has been supplied before attempting to add
BUrl repoURL(repoURLs[i]); BUrl repoURL(repoURLs[i], true);
if (!repoURL.IsValid()) { if (!repoURL.IsValid()) {
result = B_BAD_VALUE; result = B_BAD_VALUE;
DIE(result, "request for adding repository \"%s\" failed", DIE(result, "request for adding repository \"%s\" failed",
+5 -5
View File
@@ -117,7 +117,7 @@ UrlWrapper::RefsReceived(BMessage* msg)
} }
} }
if (url.Length()) { if (url.Length()) {
BUrl u(url.String()); BUrl u(url.String(), true);
args[1] = (char*)u.UrlString().String(); args[1] = (char*)u.UrlString().String();
mimetype = kURLHandlerSigBase; mimetype = kURLHandlerSigBase;
mimetype += u.Protocol(); mimetype += u.Protocol();
@@ -196,7 +196,7 @@ UrlWrapper::RefsReceived(BMessage* msg)
} }
} }
if (url.Length()) { if (url.Length()) {
BUrl u(url.String()); BUrl u(url.String(), true);
args[1] = (char*)u.UrlString().String(); args[1] = (char*)u.UrlString().String();
mimetype = kURLHandlerSigBase; mimetype = kURLHandlerSigBase;
mimetype += u.Protocol(); mimetype += u.Protocol();
@@ -210,7 +210,7 @@ UrlWrapper::RefsReceived(BMessage* msg)
// NetPositive Bookmark or any file with a META:url attribute // NetPositive Bookmark or any file with a META:url attribute
if (f.ReadAttr("META:url", B_STRING_TYPE, 0LL, buff, if (f.ReadAttr("META:url", B_STRING_TYPE, 0LL, buff,
B_PATH_NAME_LENGTH) > 0) { B_PATH_NAME_LENGTH) > 0) {
BUrl u(buff); BUrl u(buff, true);
args[1] = (char*)u.UrlString().String(); args[1] = (char*)u.UrlString().String();
mimetype = kURLHandlerSigBase; mimetype = kURLHandlerSigBase;
mimetype += u.Protocol(); mimetype += u.Protocol();
@@ -235,7 +235,7 @@ UrlWrapper::ArgvReceived(int32 argc, char** argv)
char* args[] = { (char *)"/bin/sh", (char *)"-c", NULL, NULL}; char* args[] = { (char *)"/bin/sh", (char *)"-c", NULL, NULL};
status_t err; status_t err;
BUrl url(argv[1]); BUrl url(argv[1], true);
BString full = BUrl(url).SetProtocol(BString()).UrlString(); BString full = BUrl(url).SetProtocol(BString()).UrlString();
BString proto = url.Protocol(); BString proto = url.Protocol();
@@ -520,7 +520,7 @@ UrlWrapper::ArgvReceived(int32 argc, char** argv)
BString mimetype; BString mimetype;
url << full; url << full;
BUrl u(url.String()); BUrl u(url.String(), true);
args[0] = const_cast<char*>("urlwrapper"); //XXX args[0] = const_cast<char*>("urlwrapper"); //XXX
args[1] = (char*)u.UrlString().String(); args[1] = (char*)u.UrlString().String();
args[2] = NULL; args[2] = NULL;
@@ -51,8 +51,8 @@ class GeolocationListener: public BUrlProtocolListener
BGeolocation::BGeolocation() BGeolocation::BGeolocation()
: fGeolocationService(kDefaultGeolocationService), : fGeolocationService(kDefaultGeolocationService, true),
fGeocodingService(kDefaultGeocodingService) fGeocodingService(kDefaultGeocodingService, true)
{ {
} }
@@ -63,9 +63,9 @@ BGeolocation::BGeolocation(const BUrl& geolocationService,
fGeocodingService(geocodingService) fGeocodingService(geocodingService)
{ {
if (!fGeolocationService.IsValid()) if (!fGeolocationService.IsValid())
fGeolocationService.SetUrlString(kDefaultGeolocationService); fGeolocationService.SetUrlString(kDefaultGeolocationService, true);
if (!fGeocodingService.IsValid()) if (!fGeocodingService.IsValid())
fGeocodingService.SetUrlString(kDefaultGeocodingService); fGeocodingService.SetUrlString(kDefaultGeocodingService, true);
} }
+1 -1
View File
@@ -1204,7 +1204,7 @@ void
BPackageInfo::Parser::UrlStringValidator::Validate(const BString& urlString, BPackageInfo::Parser::UrlStringValidator::Validate(const BString& urlString,
const char* pos) const char* pos)
{ {
BUrl url(urlString); BUrl url(urlString, true);
if (!url.IsValid()) if (!url.IsValid())
throw ParseError("invalid url", pos); throw ParseError("invalid url", pos);
@@ -82,7 +82,7 @@ AddRepoWindow::MessageReceived(BMessage* message)
BString url(fText->Text()); BString url(fText->Text());
if (url != "") { if (url != "") {
// URL must have a protocol // URL must have a protocol
BUrl newRepoUrl(url); BUrl newRepoUrl(url, true);
if (!newRepoUrl.IsValid()) { if (!newRepoUrl.IsValid()) {
BAlert* alert = new BAlert("error", BAlert* alert = new BAlert("error",
B_TRANSLATE_COMMENT("This is not a valid URL.", B_TRANSLATE_COMMENT("This is not a valid URL.",
@@ -129,7 +129,7 @@ AddRepoWindow::_GetClipboardData()
// The string must be a valid url // The string must be a valid url
BString clipString(string, stringLen); BString clipString(string, stringLen);
BUrl testUrl(clipString.String()); BUrl testUrl(clipString.String(), true);
if (!testUrl.IsValid()) if (!testUrl.IsValid())
return B_ERROR; return B_ERROR;
else else
@@ -505,7 +505,7 @@ RepositoriesView::_UpdateFromRepoConfig(RepoRow* rowItem)
void void
RepositoriesView::AddManualRepository(BString url) RepositoriesView::AddManualRepository(BString url)
{ {
BUrl newRepoUrl(url); BUrl newRepoUrl(url, true);
if (!newRepoUrl.IsValid()) if (!newRepoUrl.IsValid())
return; return;
@@ -514,7 +514,7 @@ RepositoriesView::AddManualRepository(BString url)
int32 listCount = fListView->CountRows(); int32 listCount = fListView->CountRows();
for (index = 0; index < listCount; index++) { for (index = 0; index < listCount; index++) {
RepoRow* repoItem = dynamic_cast<RepoRow*>(fListView->RowAt(index)); RepoRow* repoItem = dynamic_cast<RepoRow*>(fListView->RowAt(index));
BUrl rowRepoUrl(repoItem->Url()); BUrl rowRepoUrl(repoItem->Url(), true);
// Find an already existing URL // Find an already existing URL
if (newRepoUrl == rowRepoUrl) { if (newRepoUrl == rowRepoUrl) {
(new BAlert("duplicate", (new BAlert("duplicate",
@@ -637,7 +637,7 @@ RepoRow*
RepositoriesView::_AddRepo(BString name, BString url, bool enabled) RepositoriesView::_AddRepo(BString name, BString url, bool enabled)
{ {
// URL must be valid // URL must be valid
BUrl repoUrl(url); BUrl repoUrl(url, true);
if (!repoUrl.IsValid()) if (!repoUrl.IsValid())
return NULL; return NULL;
int32 index; int32 index;
@@ -645,7 +645,7 @@ RepositoriesView::_AddRepo(BString name, BString url, bool enabled)
// Find if the repo already exists in list // Find if the repo already exists in list
for (index = 0; index < listCount; index++) { for (index = 0; index < listCount; index++) {
RepoRow* repoItem = dynamic_cast<RepoRow*>(fListView->RowAt(index)); RepoRow* repoItem = dynamic_cast<RepoRow*>(fListView->RowAt(index));
BUrl itemUrl(repoItem->Url()); BUrl itemUrl(repoItem->Url(), true);
if (repoUrl == itemUrl) { if (repoUrl == itemUrl) {
// update name and enabled values // update name and enabled values
if (name != repoItem->Name()) if (name != repoItem->Name())