void XMLHttpRequest::makeSimpleCrossSiteAccessRequest(ExceptionCode& ec) { ASSERT(isSimpleCrossSiteAccessRequest()); KURL url = m_url; url.setUser(String()); url.setPass(String()); ResourceRequest request(url); request.setHTTPMethod(m_method); request.setHTTPHeaderField("Access-Control-Origin", accessControlOrigin()); if (m_crossSiteRequestHeaders.size() > 0) request.addHTTPHeaderFields(m_crossSiteRequestHeaders); if (m_async) loadRequestAsynchronously(request); else loadRequestSynchronously(request, ec); }
void XMLHttpRequest::makeSimpleCrossSiteAccessRequest(ExceptionCode& ec) { ASSERT(isSimpleCrossSiteAccessRequest()); KURL url = m_url; url.setUser(String()); url.setPass(String()); ResourceRequest request(url); request.setHTTPMethod(m_method); request.setAllowHTTPCookies(m_includeCredentials); request.setHTTPOrigin(scriptExecutionContext()->securityOrigin()->toString()); if (m_requestHeaders.size() > 0) request.addHTTPHeaderFields(m_requestHeaders); if (m_async) loadRequestAsynchronously(request); else loadRequestSynchronously(request, ec); }
static KURL findUrlForAccount(const KMail::ImapAccountBase *a) { assert(a); const KMail::SieveConfig sieve = a->sieveConfig(); if(!sieve.managesieveSupported()) return KURL(); if(sieve.reuseConfig()) { // assemble Sieve url from the settings of the account: KURL u; u.setProtocol("sieve"); u.setHost(a->host()); u.setUser(a->login()); u.setPass(a->passwd()); u.setPort(sieve.port()); // Translate IMAP LOGIN to PLAIN: u.setQuery("x-mech=" + (a->auth() == "*" ? "PLAIN" : a->auth())); return u; } else { return sieve.alternateURL(); } }
void XMLHttpRequest::makeCrossSiteAccessRequestWithPreflight(ExceptionCode& ec) { String origin = scriptExecutionContext()->securityOrigin()->toString(); KURL url = m_url; url.setUser(String()); url.setPass(String()); if (!PreflightResultCache::shared().canSkipPreflight(origin, url, m_includeCredentials, m_method, m_requestHeaders)) { m_inPreflight = true; ResourceRequest preflightRequest(url); preflightRequest.setHTTPMethod("OPTIONS"); preflightRequest.setHTTPHeaderField("Origin", origin); preflightRequest.setHTTPHeaderField("Access-Control-Request-Method", m_method); if (m_requestHeaders.size() > 0) { Vector<UChar> headerBuffer; HTTPHeaderMap::const_iterator it = m_requestHeaders.begin(); append(headerBuffer, it->first); ++it; HTTPHeaderMap::const_iterator end = m_requestHeaders.end(); for (; it != end; ++it) { headerBuffer.append(','); headerBuffer.append(' '); append(headerBuffer, it->first); } preflightRequest.setHTTPHeaderField("Access-Control-Request-Headers", String::adopt(headerBuffer)); preflightRequest.addHTTPHeaderFields(m_requestHeaders); } if (m_async) { loadRequestAsynchronously(preflightRequest); return; } loadRequestSynchronously(preflightRequest, ec); m_inPreflight = false; if (ec) return; } // Send the actual request. ResourceRequest request(url); request.setHTTPMethod(m_method); request.setAllowHTTPCookies(m_includeCredentials); request.setHTTPHeaderField("Origin", origin); if (m_requestHeaders.size() > 0) request.addHTTPHeaderFields(m_requestHeaders); if (m_requestEntityBody) { ASSERT(m_method != "GET"); request.setHTTPBody(m_requestEntityBody.release()); } if (m_async) { loadRequestAsynchronously(request); return; } loadRequestSynchronously(request, ec); }
void Project::slotRemove(const KURL& urlToRemove) { emit statusMsg(i18n("Removing files...")); progressBar->setTotalSteps(d->m_projectFiles.count()); progressBar->setValue(0); progressBar->setTextEnabled(true); KURL url; bool isFolder = d->m_projectFiles.isFolder(urlToRemove); ProjectList projectFiles = d->m_projectFiles; ProjectList::Iterator it(projectFiles); for ( ; it.current(); ++it) { url = *(it.current()); if (urlToRemove == url || (isFolder && urlToRemove.isParentOf(url)) ) { d->m_projectFiles.removeFromListAndXML(url); d->m_modified = true; emit eventHappened("after_project_remove", url.url(), QString::null); if (!isFolder) break; } progressBar->advance(1); } progressBar->setTotalSteps(1); progressBar->setValue(0); progressBar->setTextEnabled(false); emit statusMsg(QString::null); if (d->m_modified) setModified(); // there happens more than setting the flag ! emit reloadTree( &(d->m_projectFiles), false, QStringList() ); emit newStatus(); QString urlPath = QExtFileInfo::toRelative(urlToRemove, d->baseURL).path(); QString nice = urlPath; nice = KStringHandler::lsqueeze(nice, 60); if (KMessageBox::warningContinueCancel(d->m_mainWindow, i18n("<qt>Do you want to remove <br><b>%1</b><br> from the server(s) as well?</qt>").arg(nice), i18n("Remove From Server"), KStdGuiItem::remove(), "RemoveFromServer") == KMessageBox::Continue ) { QDomNode profilesNode = d->m_sessionDom.firstChild().firstChild().namedItem("uploadprofiles"); QDomNodeList profileList = profilesNode.toElement().elementsByTagName("profile"); QDomElement e; QString s; for (uint i = 0; i < profileList.count(); i++) { e = profileList.item(i).toElement(); QString path = e.attribute("remote_path",""); if (!path.startsWith("/")) path.prepend("/"); KURL baseUrl; baseUrl.setProtocol(e.attribute("remote_protocol","ftp")); baseUrl.setPort(e.attribute("remote_port","").toInt()); baseUrl.setHost(e.attribute("remote_host","")); baseUrl.setPath(path); baseUrl.setUser(e.attribute("user","")); QString passwd = password(e.attribute("remote_protocol") + "://" + e.attribute("user") + "@" + e.attribute("remote_host")); baseUrl.setPass(passwd); baseUrl.addPath(urlPath); KIO::NetAccess::del(baseUrl, d->m_mainWindow); } } }
void EMailThread::send() { QStringList listTo; QString mQuery; KIO::MetaData slaveConfig; KURL destination; int i, count; _sendOk = false; KIO::Scheduler::connect(SIGNAL(slaveError(KIO::Slave *, int, const QString &)), this, SLOT(slaveError(KIO::Slave *, int, const QString &))); _strBody.insert( 0, QString("Subject:%1\n\n").arg(_strSubject).latin1()); _strBody.insert( 0, QString("To:%1\n").arg(_strTo).latin1()); _bodyOffset = 0; _bodyLength = _strBody.length(); mQuery = "headers=0&from="; mQuery += KURL::encode_string(_strFrom); listTo = QStringList::split(QRegExp("[ ,;]"), _strTo); count = listTo.count(); if (count > 0) { for (i=0; i<count; i++) { mQuery += "&to="; mQuery += KURL::encode_string(listTo[i]); } } else { mQuery += "&to="; mQuery += KURL::encode_string(_strTo); } mQuery += "&size="; mQuery += QString::number(_bodyLength); if (_encryption == EMailEncryptionSSL) { destination.setProtocol("smtps"); } else { destination.setProtocol("smtp"); } destination.setHost(_strSMTPServer); destination.setPort((short)_iPort); destination.setPath("/send"); destination.setQuery(mQuery); if (_useAuthentication) { destination.setUser(_strUsername); destination.setPass(_strPassword); } if (_encryption == EMailEncryptionTLS) { slaveConfig.insert("tls", "on"); } else { slaveConfig.insert("tls", "off"); } if (_useAuthentication) { switch (_authentication) { case EMailAuthenticationPLAIN: slaveConfig.insert("sasl", "PLAIN"); break; case EMailAuthenticationLOGIN: slaveConfig.insert("sasl", "LOGIN"); break; case EMailAuthenticationCRAMMD5: slaveConfig.insert("sasl", "CRAM-MD5"); break; case EMailAuthenticationDIGESTMD5: slaveConfig.insert("sasl", "DIGEST-MD5"); break; default: slaveConfig.insert("sasl", "PLAIN"); break; } } _slave = KIO::Scheduler::getConnectedSlave(destination, slaveConfig); if (_slave) { _job = KIO::put(destination, -1, false, false, false); if (_job) { _job->addMetaData("lf2crlf+dotstuff", "slave"); connect(_job, SIGNAL(result(KIO::Job *)), this, SLOT(result(KIO::Job *))); connect(_job, SIGNAL(dataReq(KIO::Job *, QByteArray &)), this, SLOT(dataReq(KIO::Job *, QByteArray &))); KIO::Scheduler::assignJobToSlave(_slave, _job); _sendOk = true; } } }