本文整理汇总了C++中QNetworkProxyQuery::setUrl方法的典型用法代码示例。如果您正苦于以下问题:C++ QNetworkProxyQuery::setUrl方法的具体用法?C++ QNetworkProxyQuery::setUrl怎么用?C++ QNetworkProxyQuery::setUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QNetworkProxyQuery
的用法示例。
在下文中一共展示了QNetworkProxyQuery::setUrl方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_connectBtn_clicked
void MainWindow::on_connectBtn_clicked()
{
VpnInfo *vpninfo = NULL;
StoredServer *ss = new StoredServer(this->settings);
QFuture < void >future;
QString name, str, url;
QList < QNetworkProxy > proxies;
QUrl turl;
QNetworkProxyQuery query;
if (ui->connectBtn->isEnabled() == false) {
return;
}
if (this->cmd_fd != INVALID_SOCKET) {
QMessageBox::information(this,
tr(APP_NAME),
tr
("A previous VPN instance is still running (socket is active)"));
return;
}
if (this->futureWatcher.isRunning() == true) {
QMessageBox::information(this,
tr(APP_NAME),
tr
("A previous VPN instance is still running"));
return;
}
if (ui->comboBox->currentText().isEmpty()) {
QMessageBox::information(this,
tr(APP_NAME),
tr
("You need to specify a gateway. E.g. vpn.example.com:443"));
return;
}
name = ui->comboBox->currentText();
ss->load(name);
turl.setUrl("https://" + ss->get_servername());
query.setUrl(turl);
/* ss is now deallocated by vpninfo */
vpninfo = new VpnInfo(tr(APP_STRING), ss, this);
if (vpninfo == NULL) {
QMessageBox::information(this,
tr(APP_NAME),
tr
("There was an issue initializing the VPN."));
goto fail;
}
this->minimize_on_connect = vpninfo->get_minimize();
vpninfo->parse_url(ss->get_servername().toLocal8Bit().data());
this->cmd_fd = vpninfo->get_cmd_fd();
if (this->cmd_fd == INVALID_SOCKET) {
QMessageBox::information(this,
tr(APP_NAME),
tr
("There was an issue establishing IPC with openconnect; try restarting the application."));
goto fail;
}
proxies = QNetworkProxyFactory::systemProxyForQuery(query);
if (proxies.size() > 0 && proxies.at(0).type() != QNetworkProxy::NoProxy) {
if (proxies.at(0).type() == QNetworkProxy::Socks5Proxy)
url = "socks5://";
else if (proxies.at(0).type() == QNetworkProxy::HttpCachingProxy
|| proxies.at(0).type() == QNetworkProxy::HttpProxy)
url = "http://";
if (url.isEmpty() == false) {
str =
proxies.at(0).user() + ":" + proxies.at(0).password() + "@" +
proxies.at(0).hostName();
if (proxies.at(0).port() != 0) {
str += ":" + QString::number(proxies.at(0).port());
}
this->updateProgressBar(tr("Setting proxy to: ") + str);
openconnect_set_http_proxy(vpninfo->vpninfo, str.toAscii().data());
}
}
future = QtConcurrent::run(main_loop, vpninfo, this);
this->futureWatcher.setFuture(future);
return;
fail:
if (vpninfo != NULL)
delete vpninfo;
return;
}