本文整理汇总了C++中QUrl::port方法的典型用法代码示例。如果您正苦于以下问题:C++ QUrl::port方法的具体用法?C++ QUrl::port怎么用?C++ QUrl::port使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QUrl
的用法示例。
在下文中一共展示了QUrl::port方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: open
void QNetworkAccessHttpBackend::open()
{
QUrl url = request().url();
bool encrypt = url.scheme() == QLatin1String("https");
setAttribute(QNetworkRequest::ConnectionEncryptedAttribute, encrypt);
// set the port number in the reply if it wasn't set
url.setPort(url.port(encrypt ? DefaultHttpsPort : DefaultHttpPort));
// check if we have an open connection to this host
QByteArray cacheKey = makeCacheKey(this->url());
QNetworkAccessCache *cache = QNetworkAccessManagerPrivate::getCache(this);
if ((http = static_cast<QNetworkAccessHttpBackendCache *>(cache->requestEntryNow(cacheKey))) == 0) {
// no entry in cache; create an object
http = new QNetworkAccessHttpBackendCache(url.host(), url.port(), encrypt);
#ifndef QT_NO_NETWORKPROXY
QNetworkProxy networkProxy = proxy();
if (encrypt || networkProxy.type() == QNetworkProxy::HttpProxy)
http->setTransparentProxy(networkProxy);
else
http->setCacheProxy(networkProxy);
#endif
cache->addEntry(cacheKey, http);
}
setupConnection();
postRequest();
}
示例2: actionStarted
int
SmugMug::WebService::_httpGet (const QUrl &Url, QIODevice *to) {
int id = 0;
if (Url.port (80) == 443) {
_ssl = true;
_https.setHost (Url.host (), Url.port (443));
id = _https.get (Url.toEncoded (), to);
}
else {
_ssl = false;
_http.setHost (Url.host (), Url.port (80));
id = _http.get (Url.toEncoded (), to);
}
if (id) {
emit actionStarted ();
qDebug () << "actionStarted: " << id;
}
return id;
}
示例3: initAccountList
void SwitchAccountDialog::initAccountList()
{
accounts_ = seafApplet->accountManager()->loadAccounts();
int i, n = accounts_.size();
for (i = 0; i < n; i++) {
Account account = accounts_[i];
QIcon icon = QIcon(":/images/account.svg");
QUrl url = account.serverUrl;
QString text = account.username + "\t" + url.host();
if (url.port() > 0) {
text += QString().sprintf(":%d", url.port());
}
if (url.path().length() > 0) {
text += url.path();
}
QListWidgetItem *item = new QListWidgetItem(icon, text);
mAccountsList->addItem(item);
}
if (!accounts_.empty()) {
mAccountsList->setCurrentRow(0);
}
mAccountsList->setSelectionMode(QAbstractItemView::SingleSelection);
}
示例4: stream
void RtspSocket::stream(QUrl url,QString chid, bool aud)
{
qDebug("Start Streaming");
audioEnabled = aud;
channelid = chid;
if(url.port() == -1 || url.port()==0 )
url.setPort(554);
QDEBUG << url.toString();
qWarning() << tr("Stream: ") + url.toString();
if( state == statePlay || state == statePlaying || state == stateTeardown )
{
state = stateTeardown;
// set this after the teardown message
_url = url;
} else
{
_url = url;
// restart the state machine
state = stateInit;
}
slotStateMachine();
}
示例5: loadData
void VagrantProviderWidget::loadData()
{
VagrantSettings vagrantSettings;
QUrl url;
QString temp;
m_cloudDialog->m_iAcceptCheckBox->setChecked(vagrantSettings.userAgreementSigned());
bool isChecked = true;
m_runOnStartUpCheckBox->setChecked(isChecked);
m_serverUsernameLineEdit->setText(vagrantSettings.username().c_str());
m_serverPasswordLineEdit->setText(vagrantSettings.password().c_str());
url = vagrantSettings.serverUrl();
m_serverAddressIpLineEdit->setText(url.host());
m_serverPortIpLineEdit->setText(temp.setNum(url.port()));
m_serverDirLineEdit->setText(toQString(vagrantSettings.serverPath()));
url = vagrantSettings.serverUrl();
m_workerAddressIpLineEdit->setText(url.host());
m_workerPortIpLineEdit->setText(temp.setNum(url.port()));
m_workerDirLineEdit->setText(toQString(vagrantSettings.workerPath()));
//m_waitCheckBox->setChecked(vagrantSettings.terminationDelayEnabled());
//m_waitLineEdit->setText(temp.setNum(vagrantSettings.terminationDelay()));
}
示例6: get
bool Http::get(QUrl url, QByteArray data, QByteArray &result, QMap<QString, QString> cookies, int timeout)
{
QByteArray body;
QByteArray cookiesData = convertData(cookies);
QString urlstr;
if (!data.isEmpty()) {
urlstr.append(url.toEncoded());
urlstr.append('?');
urlstr.append(data);
} else {
urlstr = url.toEncoded();
}
body.append(QString("GET %1 HTTP/1.1\r\n").arg(urlstr));
body.append(QString("Host: %1:%2\r\n").arg(url.host()).arg(url.port()));
body.append("Connection: close\r\n");
if (!cookies.isEmpty()) {
body.append("Cookie: ");
body.append(cookiesData);
body.append("\r\n");
}
body.append("\r\n");
return send(url.host(),url.port(),body,result,timeout);
}
示例7: handleMediaAccessPermissionResponse
void MediaCaptureDevicesDispatcher::handleMediaAccessPermissionResponse(content::WebContents *webContents, const QUrl &securityOrigin
, WebContentsAdapterClient::MediaRequestFlags authorizationFlags)
{
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
content::MediaStreamDevices devices;
std::map<content::WebContents*, RequestsQueue>::iterator it = m_pendingRequests.find(webContents);
if (it == m_pendingRequests.end())
// WebContents has been destroyed. Don't need to do anything.
return;
RequestsQueue &queue(it->second);
if (queue.empty())
return;
content::MediaStreamRequest &request = queue.front().request;
const QUrl requestSecurityOrigin(toQt(request.security_origin));
bool securityOriginsMatch = (requestSecurityOrigin.host() == securityOrigin.host()
&& requestSecurityOrigin.scheme() == securityOrigin.scheme()
&& requestSecurityOrigin.port() == securityOrigin.port());
if (!securityOriginsMatch)
qWarning("Security origin mismatch for media access permission: %s requested and %s provided\n", qPrintable(requestSecurityOrigin.toString())
, qPrintable(securityOrigin.toString()));
bool microphoneRequested =
(request.audio_type && authorizationFlags & WebContentsAdapterClient::MediaAudioCapture);
bool webcamRequested =
(request.video_type && authorizationFlags & WebContentsAdapterClient::MediaVideoCapture);
if (securityOriginsMatch && (microphoneRequested || webcamRequested)) {
switch (request.request_type) {
case content::MEDIA_OPEN_DEVICE:
Q_UNREACHABLE(); // only speculative as this is for Pepper
getDefaultDevices("", "", microphoneRequested, webcamRequested, &devices);
break;
case content::MEDIA_DEVICE_ACCESS:
case content::MEDIA_GENERATE_STREAM:
case content::MEDIA_ENUMERATE_DEVICES:
getDefaultDevices(request.requested_audio_device_id, request.requested_video_device_id,
microphoneRequested, webcamRequested, &devices);
break;
}
}
content::MediaResponseCallback callback = queue.front().callback;
queue.pop_front();
if (!queue.empty()) {
// Post a task to process next queued request. It has to be done
// asynchronously to make sure that calling infobar is not destroyed until
// after this function returns.
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE, base::Bind(&MediaCaptureDevicesDispatcher::ProcessQueuedAccessRequest, base::Unretained(this), webContents));
}
callback.Run(devices, devices.empty() ? content::MEDIA_DEVICE_INVALID_STATE : content::MEDIA_DEVICE_OK, scoped_ptr<content::MediaStreamUI>());
}
示例8: testFindFreePort
void LocalQmlProfilerRunnerTest::testFindFreePort()
{
QUrl serverUrl = Utils::urlFromLocalHostAndFreePort();
QVERIFY(serverUrl.port() != -1);
QVERIFY(!serverUrl.host().isEmpty());
QTcpServer server;
QVERIFY(server.listen(QHostAddress(serverUrl.host()), serverUrl.port()));
}
示例9:
CetonRTSP::CetonRTSP(const QUrl &url) :
_ip(url.host()),
_port((url.port() >= 0) ? url.port() : 554),
_sequenceNumber(0),
_sessionId("0"),
_responseCode(-1)
{
_requestUrl = url.toString();
}
示例10: main
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
QStringList args = app.arguments();
QString appName = args.takeFirst();
bool notification = args.contains("-n");
if (notification)
args.removeAll("-n");
if (args.size() < 2) {
qDebug("usage: %s [-n] <service> <method> <arguments>", appName.toLocal8Bit().data());
return -1;
}
// try to process socket
QIODevice *device = 0;
QScopedPointer<QIODevice> devicePtr(device);
QString service = args.takeFirst();
QUrl serviceUrl = QUrl::fromUserInput(service);
QHostAddress serviceAddress(serviceUrl.host());
if (serviceAddress.isNull()) {
QLocalSocket *localSocket = new QLocalSocket;
device = localSocket;
localSocket->connectToServer(service);
if (!localSocket->waitForConnected(5000)) {
qDebug("could not connect to service: %s", service.toLocal8Bit().data());
return -1;
}
} else {
QTcpSocket *tcpSocket = new QTcpSocket;
device = tcpSocket;
int servicePort = serviceUrl.port() ? serviceUrl.port() : 5555;
tcpSocket->connectToHost(serviceAddress, servicePort);
if (!tcpSocket->waitForConnected(5000)) {
qDebug("could not connect to host at %s:%d", serviceUrl.host().toLocal8Bit().data(),
servicePort);
return -1;
}
}
QJsonRpcSocket socket(device);
QString method = args.takeFirst();
QVariantList arguments;
foreach (QString arg, args)
arguments.append(arg);
QJsonRpcMessage request = notification ? QJsonRpcMessage::createNotification(method, arguments) :
QJsonRpcMessage::createRequest(method, arguments);
QJsonRpcMessage response = socket.sendMessageBlocking(request, 5000);
if (response.type() == QJsonRpcMessage::Error) {
qDebug("error(%d): %s", response.errorCode(), response.errorMessage().toLocal8Bit().data());
return -1;
}
qDebug() << response.result();
}
示例11: setApplicationProxy
static void setApplicationProxy(QUrl url)
{
if (!url.isEmpty())
{
if (url.port() == -1)
url.setPort(8080);
QNetworkProxy proxy(QNetworkProxy::HttpProxy, url.host(), url.port(), url.userName(), url.password());
QNetworkProxy::setApplicationProxy(proxy);
}
}
示例12: ndefMessageRead
void NfcHandler::ndefMessageRead(QNdefMessage message)
{
foreach (const QNdefRecord &record, message) {
if (record.isRecordType<QNdefNfcUriRecord>()) {
QNdefNfcUriRecord uriRecord(record);
qDebug() << "********** Got URI record:" << uriRecord.uri();
QUrl uri = uriRecord.uri();
if(uri.scheme() == "kodi") {
qDebug() << "Got and xmbc:// uri" << uri.host() << uri.port() << uri.path();
KodiHost host;
host.setAddress(uri.host());
host.setPort(uri.port());
QString path = uri.path().right(uri.path().length() - 1);
if(path.split('/').count() >= 1) {
host.setHostname(path.split('/').first());
}
if(path.split('/').count() >= 2) {
host.setHwAddr(path.split('/').at(1));
}
qDebug() << "Should connect to" << host.address() << ':' << host.port() << host.hostname() << host.hwAddr();
int index = Kodi::instance()->hostModel()->insertOrUpdateHost(host);
Kodi::instance()->hostModel()->connectToHost(index);
} else {
qDebug() << "NDEF uri record not compatible with kodimote:" << uriRecord.uri();
emit tagError(tr("NFC tag is not compatible with Kodimote. In order to use it with Kodimote you need to write connection information to it."));
}
} else if (record.isRecordType<QNdefNfcTextRecord>()) {
QNdefNfcTextRecord textRecord(record);
qDebug() << "********** Got Text record:" << textRecord.text();
if(textRecord.text().startsWith("kodi:")) {
qDebug() << "outdated tag detected";
emit tagError(tr("NFC tag is outdated. In order to use it with Kodimote you need to update it by rewriting connection information to it."));
} else {
emit tagError(tr("NFC tag is not compatible with Kodimote. In order to use it with Kodimote you need to write connection information to it."));
}
}else {
if (record.typeNameFormat() == QNdefRecord::Mime &&
record.type().startsWith("image/")) {
qDebug() << "got image...";
}else if (record.typeNameFormat() == QNdefRecord::NfcRtd ) {
qDebug() << "Got Rtd tag" << record.payload();
QNdefNfcUriRecord uri(record);
qDebug() << "uri:" << uri.uri();
}else if (record.typeNameFormat() == QNdefRecord::ExternalRtd ){
qDebug() << "Got ExtRtd tag";
} else if (record.isEmpty()) {
qDebug() << "got empty record...";
} else {
qDebug() << "got unknown ndef message type";
}
emit tagError(tr("NFC tag is not compatible with Kodimote. In order to use it with Kodimote you need to write connection information to it."));
}
}
}
示例13: download
void FileDownloader::download(QUrl url) {
QHttp::ConnectionMode mode = url.scheme().toLower() == "https" ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp;
http->setHost(url.host(), mode, url.port() == -1 ? 0 : url.port());
if (!url.userName().isEmpty())
http->setUser(url.userName(), url.password());
http_request_aborted = false;
http_get_id = http->get(url.path(), &buffer);
setLabelText(tr("Downloading %1").arg(url.toString()));
}
示例14: setup
void setup(const QUrl &uri, const HttpHeaders &_headers, const QHostAddress &connectAddr = QHostAddress(), int connectPort = -1, int _maxRedirects = -1)
{
assert(!method.isEmpty());
QUrl tmp = uri;
if(connectPort != -1)
tmp.setPort(connectPort);
else if(tmp.port() == -1)
{
if(uri.scheme() == "https")
tmp.setPort(443);
else
tmp.setPort(80);
}
curl_easy_setopt(easy, CURLOPT_URL, tmp.toEncoded().data());
if(!connectAddr.isNull())
{
curl_slist_free_all(dnsCache);
QByteArray cacheEntry = tmp.encodedHost() + ':' + QByteArray::number(tmp.port()) + ':' + connectAddr.toString().toUtf8();
dnsCache = curl_slist_append(dnsCache, cacheEntry.data());
curl_easy_setopt(easy, CURLOPT_RESOLVE, dnsCache);
}
HttpHeaders headers = _headers;
bool chunked = false;
if(headers.contains("Content-Length"))
{
curl_off_t content_len = (curl_off_t)headers.get("Content-Length").toLongLong();
/*if(method == "POST")
curl_easy_setopt(easy, CURLOPT_POSTFIELDSIZE_LARGE, content_len);
else*/
curl_easy_setopt(easy, CURLOPT_INFILESIZE_LARGE, content_len);
// curl will set this for us
headers.removeAll("Content-Length");
}
else
{
if(expectBody)
chunked = true;
else if(alwaysSetBody)
curl_easy_setopt(easy, CURLOPT_INFILESIZE_LARGE, (curl_off_t)0);
}
curl_slist_free_all(headersList);
foreach(const HttpHeader &h, headers)
{
QByteArray i = h.first + ": " + h.second;
headersList = curl_slist_append(headersList, i.data());
}
示例15: port
int Url::port ( lua_State * L )// const : int
{
QUrl* lhs = ValueInstaller2<QUrl>::check( L, 1 );
if(Util::isNum( L, 2 ))
{
Util::push( L, lhs->port(Util::toInt( L, 2 )) );
}
else
{
Util::push( L, lhs->port() );
}
return 1;
}