static KURL getNewFileName(const KURL &u, const QString &text) { bool ok; QString dialogText(text); if(dialogText.isEmpty()) dialogText = i18n("Filename for clipboard content:"); QString file = KInputDialog::getText(QString::null, dialogText, QString::null, &ok); if(!ok) return KURL(); KURL myurl(u); myurl.addPath(file); if(KIO::NetAccess::exists(myurl, false, 0)) { kdDebug(7007) << "Paste will overwrite file. Prompting..." << endl; KIO::RenameDlg_Result res = KIO::R_OVERWRITE; QString newPath; // Ask confirmation about resuming previous transfer res = Observer::self()->open_RenameDlg(0L, i18n("File Already Exists"), u.pathOrURL(), myurl.pathOrURL(), (KIO::RenameDlg_Mode)(KIO::M_OVERWRITE | KIO::M_SINGLE), newPath); if(res == KIO::R_RENAME) { myurl = newPath; } else if(res == KIO::R_CANCEL) { return KURL(); } } return myurl; }
wxFSFile *wxHtmlWinParser::OpenURL(wxHtmlURLType type, const wxString& url) const { if ( !m_windowInterface ) return wxHtmlParser::OpenURL(type, url); wxString myurl(url); wxHtmlOpeningStatus status; for (;;) { wxString myfullurl(myurl); // consider url as absolute path first wxURI current(myurl); myfullurl = current.BuildUnescapedURI(); // if not absolute then ... if( current.IsReference() ) { wxString basepath = GetFS()->GetPath(); wxURI base(basepath); // ... try to apply base path if valid ... if( !base.IsReference() ) { wxURI path(myfullurl); path.Resolve( base ); myfullurl = path.BuildUnescapedURI(); } else { // ... or force such addition if not included already if( !current.GetPath().Contains(base.GetPath()) ) { basepath += myurl; wxURI connected( basepath ); myfullurl = connected.BuildUnescapedURI(); } } } wxString redirect; status = m_windowInterface->OnHTMLOpeningURL(type, myfullurl, &redirect); if ( status != wxHTML_REDIRECT ) break; myurl = redirect; } if ( status == wxHTML_BLOCK ) return NULL; int flags = wxFS_READ; if (type == wxHTML_URL_IMAGE) flags |= wxFS_SEEKABLE; return GetFS()->OpenFile(myurl, flags); }
static QUrl getNewFileName(const QUrl &u, const QString &text, const QString &suggestedFileName, QWidget *widget) { bool ok; QString dialogText(text); if (dialogText.isEmpty()) { dialogText = i18n("Filename for clipboard content:"); } QString file = QInputDialog::getText(widget, QString(), dialogText, QLineEdit::Normal, suggestedFileName, &ok); if (!ok) { return QUrl(); } QUrl myurl(u); myurl.setPath(myurl.path() + '/' + file); KIO::StatJob *job = KIO::stat(myurl, myurl.isLocalFile() ? KIO::HideProgressInfo : KIO::DefaultFlags); job->setDetails(0); job->setSide(KIO::StatJob::DestinationSide); KJobWidgets::setWindow(job, widget); // Check for existing destination file. // When we were using CopyJob, we couldn't let it do that (would expose // an ugly tempfile name as the source URL) // And now we're using a put job anyway, no destination checking included. if (job->exec()) { //qDebug() << "Paste will overwrite file. Prompting..."; KIO::RenameDialog dlg(widget, i18n("File Already Exists"), u, myurl, KIO::RenameDialog_Overwrite); KIO::RenameDialog_Result res = static_cast<KIO::RenameDialog_Result>(dlg.exec()); if (res == KIO::Result_Rename) { myurl = dlg.newDestUrl(); } else if (res == KIO::Result_Cancel) { return QUrl(); } else if (res == KIO::Result_Overwrite) { // OK, proceed } } return myurl; }