status_t BUrl::OpenWithPreferredApplication(bool onProblemAskUser) const { status_t status = InitCheck(); if (status != B_OK) return status; if (Length() > B_PATH_NAME_LENGTH) { // TODO: BAlert // if (onProblemAskUser) // BAlert ... Too long URL! fprintf(stderr, "URL too long"); return B_NAME_TOO_LONG; } char* argv[] = { const_cast<char*>("BUrlInvokedApplication"), const_cast<char*>(String()), NULL }; #if DEBUG if (HasPreferredApplication()) printf("HasPreferredApplication() == true\n"); else printf("HasPreferredApplication() == false\n"); #endif status = be_roster->Launch(_UrlMimeType().String(), 1, argv+1); if (status != B_OK) { fprintf(stderr, "Opening URL failed: %s\n", strerror(status)); } return status; }
BString BUrl::PreferredApplication() const { BString appSignature; BMimeType mime(_UrlMimeType().String()); mime.GetPreferredApp(appSignature.LockBuffer(B_MIME_TYPE_LENGTH)); appSignature.UnlockBuffer(); return BString(appSignature); }