void LinkImporter::addTransfer(QString &link) { KUrl auxUrl; if (link.contains("://")) { auxUrl = KUrl(link); } else { auxUrl = KUrl(QString("http://") + link); } if(!link.isEmpty() && auxUrl.isValid() && m_transfers.indexOf(link) < 0 && !auxUrl.scheme().isEmpty() && !auxUrl.host().isEmpty()) { m_transfers << link; } }
KexiFileWidget::KexiFileWidget( const KUrl &startDirOrVariable, Mode mode, QWidget *parent) : KFileWidget(startDirOrVariable, parent) , d(new Private()) { kDebug() << startDirOrVariable.scheme(); if (startDirOrVariable.protocol() == "kfiledialog") { KFileDialog::getStartUrl(startDirOrVariable, d->recentDirClass); } setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); setMode(mode); QAction *previewAction = actionCollection()->action("preview"); if (previewAction) previewAction->setChecked(false); setFocusProxy(locationEdit()); connect(this, SIGNAL(fileHighlighted(QString)), this, SLOT(slotExistingFileHighlighted(QString))); }
void ChooseSocket::setValues(const QVariantHash &args) { if (m_args == args) { return; } m_args = args; ui->addressLE->clear(); ui->portISB->setValue(9100); QString deviceUri = args[KCUPS_DEVICE_URI].toString(); KUrl url = deviceUri; if (url.scheme() == QLatin1String("socket")) { ui->addressLE->setText(url.host()); ui->portISB->setValue(url.port(9100)); } ui->addressLE->setFocus(); m_isValid = true; }
QString Playlist::toRelativeUrl(const KUrl &trackUrl) const { if ((trackUrl.scheme() == url.scheme()) && (trackUrl.authority() == url.authority())) { QByteArray playlistPath = url.encodedPath(); int index = playlistPath.lastIndexOf('/'); playlistPath.truncate(index + 1); QByteArray trackPath = trackUrl.encodedPath(); if (trackPath.startsWith(playlistPath)) { trackPath.remove(0, index + 1); KUrl relativeUrl; relativeUrl.setEncodedPath(trackPath); relativeUrl.setEncodedQuery(trackUrl.encodedQuery()); relativeUrl.setEncodedFragment(trackUrl.encodedFragment()); return relativeUrl.url(); } } return trackUrl.url(); }
KexiFileWidget::KexiFileWidget( const KUrl &startDirOrVariable, Mode mode, QWidget *parent) : KFileWidget(startDirOrVariable, parent) , d(new Private()) { kDebug() << startDirOrVariable.scheme(); if (startDirOrVariable.protocol() == "kfiledialog") { KFileDialog::getStartUrl(startDirOrVariable, d->recentDirClass); } setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); setMode(mode); QAction *previewAction = actionCollection()->action("preview"); if (previewAction) previewAction->setChecked(false); //setMinimumHeight(100); //setSizeGripEnabled ( false ); //dirty hack to customize filedialog view: /* { QList<QPushButton*> l = findChildren<QPushButton*>(); foreach (QPushButton* btn, l) btn->hide(); QList<QWidget*> wl = findChildren<QWidget*>(); foreach (QWidget* w, wl) w->installEventFilter(this); } */ /* Qt4 #ifdef Q_WS_WIN if (startDirOrVariable.startsWith(":")) m_lastVisitedPathsVariable = startDirOrVariable; //store for later use #else*/ // toggleSpeedbar(false); setFocusProxy(locationEdit()); //#endif connect(this, SIGNAL(fileHighlighted(QString)), this, SLOT(slotExistingFileHighlighted(QString))); }
void InfoCommand::fetchItems() { Item item; // See if user input is a valid integer as an item ID bool ok; int id = mEntityArg.toInt(&ok); if (ok) item = Item(id); // conversion succeeded else { // Otherwise check if we have an Akonadi URL const KUrl url = QUrl::fromUserInput(mEntityArg); if (url.isValid() && url.scheme()==QLatin1String("akonadi")) { item = Item::fromUrl(url); } else { emit error(i18nc("@info:shell", "Invalid item/collection syntax")); emit finished(RuntimeError); return; } } ItemFetchJob *job = new ItemFetchJob(item, this); job->fetchScope().setFetchModificationTime(true); job->fetchScope().fetchAllAttributes(true); // Need this so that parentCollection() will be valid. job->fetchScope().setAncestorRetrieval(ItemFetchScope::Parent); // Not actually going to use the payload here, but if we don't set it // to be fetched then hasPayload() will not return a meaningful result. job->fetchScope().fetchFullPayload(true); connect(job, SIGNAL(result(KJob *)), SLOT(onItemsFetched(KJob *))); }
QNetworkReply *AccessManager::createRequest(Operation op, const QNetworkRequest &req, QIODevice *outgoingData) { const KUrl reqUrl (req.url()); if (!d->externalContentAllowed && !KDEPrivate::AccessManagerReply::isLocalRequest(reqUrl) && reqUrl.scheme() != QL1S("data")) { kDebug( 7044 ) << "Blocked: " << reqUrl; return new KDEPrivate::AccessManagerReply(op, req, QNetworkReply::ContentAccessDenied, i18n("Blocked request."), this); } // Check if the internal ignore content disposition header is set. const bool ignoreContentDisposition = req.hasRawHeader("x-kdewebkit-ignore-disposition"); // Retrieve the KIO meta data... KIO::MetaData metaData; d->setMetaDataForRequest(req, metaData); KIO::SimpleJob *kioJob = 0; switch (op) { case HeadOperation: { //kDebug( 7044 ) << "HeadOperation:" << reqUrl; kioJob = KIO::mimetype(reqUrl, KIO::HideProgressInfo); break; } case GetOperation: { //kDebug( 7044 ) << "GetOperation:" << reqUrl; if (!reqUrl.path().isEmpty() || reqUrl.host().isEmpty()) kioJob = KIO::get(reqUrl, KIO::NoReload, KIO::HideProgressInfo); else kioJob = KIO::stat(reqUrl, KIO::HideProgressInfo); // WORKAROUND: Avoid the brain damaged stuff QtWebKit does when a POST // operation is redirected! See BR# 268694. metaData.remove(QL1S("content-type")); // Remove the content-type from a GET/HEAD request! break; } case PutOperation: { //kDebug( 7044 ) << "PutOperation:" << reqUrl; if (outgoingData) kioJob = KIO::storedPut(outgoingData->readAll(), reqUrl, -1, KIO::HideProgressInfo); else kioJob = KIO::put(reqUrl, -1, KIO::HideProgressInfo); break; } case PostOperation: { kioJob = KIO::http_post(reqUrl, outgoingData, sizeFromRequest(req), KIO::HideProgressInfo); if (!metaData.contains(QL1S("content-type"))) { const QVariant header = req.header(QNetworkRequest::ContentTypeHeader); if (header.isValid()) { metaData.insert(QL1S("content-type"), (QL1S("Content-Type: ") + header.toString())); } else { metaData.insert(QL1S("content-type"), QL1S("Content-Type: application/x-www-form-urlencoded")); } } break; } case DeleteOperation: { //kDebug(7044) << "DeleteOperation:" << reqUrl; kioJob = KIO::http_delete(reqUrl, KIO::HideProgressInfo); break; } case CustomOperation: { const QByteArray& method = req.attribute(QNetworkRequest::CustomVerbAttribute).toByteArray(); //kDebug(7044) << "CustomOperation:" << reqUrl << "method:" << method << "outgoing data:" << outgoingData; if (method.isEmpty()) { return new KDEPrivate::AccessManagerReply(op, req, QNetworkReply::ProtocolUnknownError, i18n("Unknown HTTP verb."), this); } if (outgoingData) kioJob = KIO::http_post(reqUrl, outgoingData, sizeFromRequest(req), KIO::HideProgressInfo); else kioJob = KIO::get(reqUrl, KIO::NoReload, KIO::HideProgressInfo); metaData.insert(QL1S("CustomHTTPMethod"), method); break; } default: { kWarning(7044) << "Unsupported KIO operation requested! Defering to QNetworkAccessManager..."; return QNetworkAccessManager::createRequest(op, req, outgoingData); } } // Set the job priority switch (req.priority()) { case QNetworkRequest::HighPriority: KIO::Scheduler::setJobPriority(kioJob, -5); break; case QNetworkRequest::LowPriority: KIO::Scheduler::setJobPriority(kioJob, 5); break; default: break; } KDEPrivate::AccessManagerReply *reply; /* NOTE: Here we attempt to handle synchronous XHR requests. Unfortunately, due to the fact that QNAM is both synchronous and multi-thread while KIO is completely the opposite (asynchronous and not thread safe), the code below might cause crashes like the one reported in bug# 287778 (nested event loops are inherently dangerous). Unfortunately, all attempts to address the crash has so far failed due to the many regressions they caused, e.g. bug# 231932 and 297954. Hence, until a solution is found, we have to live with the side effects of creating nested event loops. */ if (req.attribute(gSynchronousNetworkRequestAttribute).toBool()) { KUrl finalURL; QByteArray data; if (KIO::NetAccess::synchronousRun(kioJob, d->window, &data, &finalURL, &metaData)) { reply = new KDEPrivate::AccessManagerReply(op, req, data, finalURL, metaData, this); kDebug(7044) << "Synchronous XHR:" << reply << reqUrl; } else { kWarning(7044) << "Failed to create a synchronous XHR for" << reqUrl; reply = new KDEPrivate::AccessManagerReply(op, req, QNetworkReply::UnknownNetworkError, kioJob->errorText(), this); } } else { // Set the window on the the KIO ui delegate if (d->window) { kioJob->ui()->setWindow(d->window); } // Disable internal automatic redirection handling kioJob->setRedirectionHandlingEnabled(false); // Set the job priority switch (req.priority()) { case QNetworkRequest::HighPriority: KIO::Scheduler::setJobPriority(kioJob, -5); break; case QNetworkRequest::LowPriority: KIO::Scheduler::setJobPriority(kioJob, 5); break; default: break; } // Set the meta data for this job... kioJob->setMetaData(metaData); // Create the reply... reply = new KDEPrivate::AccessManagerReply(op, req, kioJob, d->emitReadyReadOnMetaDataChange, this); //kDebug(7044) << reply << reqUrl; } if (ignoreContentDisposition && reply) { //kDebug(7044) << "Content-Disposition WILL BE IGNORED!"; reply->setIgnoreContentDisposition(ignoreContentDisposition); } return reply; }