当前位置: 首页>>代码示例>>C++>>正文


C++ QNetworkProxy::setPassword方法代码示例

本文整理汇总了C++中QNetworkProxy::setPassword方法的典型用法代码示例。如果您正苦于以下问题:C++ QNetworkProxy::setPassword方法的具体用法?C++ QNetworkProxy::setPassword怎么用?C++ QNetworkProxy::setPassword使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QNetworkProxy的用法示例。


在下文中一共展示了QNetworkProxy::setPassword方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: applyProxySettings

void DownloadThread::applyProxySettings() {
  QNetworkProxy proxy;
  const Preferences pref;
  if (pref.isProxyEnabled()) {
    // Proxy enabled
    proxy.setHostName(pref.getProxyIp());
    proxy.setPort(pref.getProxyPort());
    // Default proxy type is HTTP, we must change if it is SOCKS5
    const int proxy_type = pref.getProxyType();
    if (proxy_type == Proxy::SOCKS5 || proxy_type == Proxy::SOCKS5_PW) {
      qDebug() << Q_FUNC_INFO << "using SOCKS proxy";
      proxy.setType(QNetworkProxy::Socks5Proxy);
    } else {
      qDebug() << Q_FUNC_INFO << "using HTTP proxy";
      proxy.setType(QNetworkProxy::HttpProxy);
    }
    // Authentication?
    if (pref.isProxyAuthEnabled()) {
      qDebug("Proxy requires authentication, authenticating");
      proxy.setUser(pref.getProxyUsername());
      proxy.setPassword(pref.getProxyPassword());
    }
  } else {
    proxy.setType(QNetworkProxy::NoProxy);
  }
  m_networkManager.setProxy(proxy);
}
开发者ID:Borrisholt,项目名称:qBittorrent,代码行数:27,代码来源:downloadthread.cpp

示例2: SetProxy

    void NetworkAccessManager::SetProxy(const QString& server, int Port, bool IsHttp, const QString& name, const QString& password, const QString& callback)
    {
        if(server.isEmpty() || Port<=0)
        {
            CaptureManager->setProxy(QNetworkProxy::NoProxy);
        }else
        {
            QNetworkProxy proxy;
            if(IsHttp)
            {
                proxy.setType(QNetworkProxy::HttpProxy);
            }else
            {
                proxy.setType(QNetworkProxy::Socks5Proxy);
            }

            proxy.setHostName(server);
            proxy.setPort(Port);

            proxy.setUser(name);
            proxy.setPassword(password);

            CaptureManager->setProxy(proxy);
        }

        Worker->SetScript(callback);
        Worker->RunSubScript();
    }
开发者ID:MidoriYakumo,项目名称:BAS,代码行数:28,代码来源:networkaccessmanager.cpp

示例3: SetUp

void Logic::SetUp()
{
    qDebug("SetUp begin");
    settingObject = new QSettings("setting.ini",QSettings::IniFormat,0);
    settingObject->beginGroup("Proxy");
    if(settingObject->value("UseProxy","0").toString() == "1")
    {
        QNetworkProxy proxy;
        proxy.setType(QNetworkProxy::HttpProxy);
        proxy.setHostName(settingObject->value("ProxyServer","0").toString());
        proxy.setPort(settingObject->value("ProxyPort","0").toInt());
        proxy.setUser(settingObject->value("ProxyUserName","0").toString());
        proxy.setPassword(settingObject->value("ProxyPassword","0").toString());
        QNetworkProxy::setApplicationProxy(proxy);
    }
//    else
//    {
//        QNetworkProxy proxy;
//        QNetworkProxy::setApplicationProxy(proxy);
//    }
    settingObject->endGroup();

    settingObject->beginGroup("Message");
    CountReceiveMessage = settingObject->value("CountMessage", "0").toInt();
    qDebug("CountReceiveMessage: " + settingObject->value("CountMessage", "0").toString().toLatin1());
    CountSentMessage = settingObject->value("CountSendMessage","0").toInt();
    settingObject->endGroup();
    qDebug("SetUp end");
}
开发者ID:strizh,项目名称:Lab3_QML_,代码行数:29,代码来源:logic.cpp

示例4: loadSettings

void ThreadHandler::loadSettings() {
    settings->beginGroup("options");
    autoClose = settings->value("automatic_close", false).toBool();
    maxDownloads = settings->value("concurrent_downloads", 1).toInt();
    settings->endGroup();

    settings->beginGroup("network");
    QNetworkProxy proxy;

    if (settings->value("use_proxy", false).toBool()) {
        proxy.setType((QNetworkProxy::ProxyType)(settings->value("proxy_type", QNetworkProxy::HttpProxy).toInt()));
        proxy.setHostName(settings->value("proxy_hostname", "").toString());
        proxy.setPort(settings->value("proxy_port", 0).toUInt());
        if (settings->value("proxy_auth", false).toBool()) {
            proxy.setUser(settings->value("proxy_user", "").toString());
            proxy.setPassword(settings->value("proxy_pass", "").toString());
        }
    }
    else {
        proxy.setType(QNetworkProxy::NoProxy);
    }

    QNetworkProxy::setApplicationProxy(proxy);

    settings->endGroup();
}
开发者ID:ycaihua,项目名称:fourchan,代码行数:26,代码来源:threadhandler.cpp

示例5: conf

Server::Server(QWidget *parent)
    :   QDialog(parent), tcpServer(0), networkSession(0)
    {

    tcpServer = new QTcpServer(this);

    Configuration conf(QCoreApplication::applicationDirPath()+CONFIGURATION_PATH);

    if(conf.integer("USE_PROXY") == 1){
        QNetworkProxy proxy;
        proxy.setType(QNetworkProxy::HttpProxy);
        proxy.setHostName(conf.string("PROXY_HOST"));
        proxy.setPort(conf.integer("PROXY_PORT"));
        if(conf.string("PROXY_LOGIN")!="") proxy.setUser(conf.string("PROXY_LOGIN"));
        if(conf.string("PROXY_PASSWORD")!="") proxy.setPassword(conf.string("PROXY_PASSWORD"));
        tcpServer->setProxy(proxy);
    }


    if (!tcpServer->listen(QHostAddress::Any,11000)) {
        qDebug(QString("Unable to start the server: "+tcpServer->errorString()+".").toLatin1());

        return;
    }
    QString ipAddress;



    qDebug(QString("The server is running on\n\nIP: "+ipAddress+"\nport: 11000").toLatin1());
    messageSize = 0;
    QObject::connect(tcpServer, SIGNAL(newConnection()), this, SLOT(newConnected()));
}
开发者ID:Eih3,项目名称:yana4all-sources,代码行数:32,代码来源:server.cpp

示例6: restore

void settings::restore()
{
	QSettings settings("saschawillems", "glcapsviewer");
	submitterName = settings.value("global/submitterName", "").toString();
	proxyDns = settings.value("proxy/dns", "").toString();
	proxyPort = settings.value("proxy/port", "").toString();
	proxyUserName = settings.value("proxy/user", "").toString();
	proxyUserPassword = settings.value("proxy/password", "").toString();
	proxyEnabled = settings.value("proxy/enabled", "").toBool();

	// Apply proxy settings
	if (proxyEnabled) {
		QNetworkProxy proxy;
		proxy.setType(QNetworkProxy::Socks5Proxy);
		proxy.setHostName(proxyDns);
		if (!proxyPort.isEmpty()) {
			proxy.setPort(proxyPort.toInt());
		}
		else {
			proxy.setPort(80);
		}
		proxy.setUser(proxyUserName);
		proxy.setPassword(proxyUserPassword);
		QNetworkProxy::setApplicationProxy(proxy);
	}
	else {
		QNetworkProxy::setApplicationProxy(QNetworkProxy::NoProxy);
	}

}
开发者ID:Andy-hpliu,项目名称:VulkanCapsViewer,代码行数:30,代码来源:settings.cpp

示例7: loadSettings

void NetworkAccessManager::loadSettings()
{
    QSettings settings;
    settings.beginGroup(QLatin1String("proxy"));
    QNetworkProxy proxy;
    if (settings.value(QLatin1String("enabled"), false).toBool()) {
        if (settings.value(QLatin1String("type"), 0).toInt() == 0)
            proxy.setType(QNetworkProxy::Socks5Proxy);
        else
            proxy.setType(QNetworkProxy::HttpProxy);
        proxy.setHostName(settings.value(QLatin1String("hostName")).toString());
        proxy.setPort(settings.value(QLatin1String("port"), 1080).toInt());
        proxy.setUser(settings.value(QLatin1String("userName")).toString());
        proxy.setPassword(settings.value(QLatin1String("password")).toString());
    }
    setProxy(proxy);
    settings.endGroup();

#ifndef QT_NO_OPENSSL
    QSslConfiguration sslCfg = QSslConfiguration::defaultConfiguration();
    QList<QSslCertificate> ca_list = sslCfg.caCertificates();
    QList<QSslCertificate> ca_new = QSslCertificate::fromData(settings.value(QLatin1String("CaCertificates")).toByteArray());
    ca_list += ca_new;

    sslCfg.setCaCertificates(ca_list);
    QSslConfiguration::setDefaultConfiguration(sslCfg);
#endif
}
开发者ID:ariya,项目名称:arora,代码行数:28,代码来源:networkaccessmanager.cpp

示例8: loadSettings

void KNetwork::loadSettings()
{
#if 1

    QNetworkDiskCache *diskCache = new QNetworkDiskCache(this);
    QString location = QDesktopServices::storageLocation(QDesktopServices::CacheLocation);
    diskCache->setCacheDirectory(location);
    setCache(diskCache);
#endif

    QNetworkProxy proxy;
    KDocument doc;
    if (doc.openDocument(QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "/" + ENGINE_CONFIG_FILE))
    {
        if (doc.getValue("kludget/network/enableProxy", "0").toInt() != 0)
        {
            QString host = doc.getValue("kludget/network/proxyHost", "");
            QString port = "";
            if (host.indexOf(":") != -1)
            {
                QStringList tmp = host.split(":");
                host = tmp.at(0);
                port = tmp.at(1);
            }
            proxy = QNetworkProxy::HttpProxy;
            proxy.setHostName(host);
            proxy.setPort(port.toInt());
            proxy.setUser(doc.getValue("kludget/network/proxyUser", ""));
            proxy.setPassword(Util::decrypt(doc.getValue("kludget/network/proxyPassword", "")));
        }
    }
    setProxy(proxy);
}
开发者ID:Delgerdalai14,项目名称:kludgets,代码行数:33,代码来源:knetwork.cpp

示例9: checkProxy

void PBSystemTab::checkProxy()
{
  bool ok;
  int port;

  // If no proxy set
  if ( pcbsd::Utils::getProxyURL().isEmpty() )
    return;

  QNetworkProxy proxy;
  if ( pcbsd::Utils::getProxyType() == "SOCKS5" )
    proxy.setType(QNetworkProxy::Socks5Proxy);
  else
    proxy.setType(QNetworkProxy::HttpProxy);

  proxy.setHostName(pcbsd::Utils::getProxyURL());

  port = pcbsd::Utils::getProxyPort().toInt(&ok);
  if ( ! pcbsd::Utils::getProxyPort().isEmpty() && ok )
    proxy.setPort(port);
  if ( ! pcbsd::Utils::getProxyUser().isEmpty() )
    proxy.setUser(pcbsd::Utils::getProxyUser());
  if ( ! pcbsd::Utils::getProxyPass().isEmpty() )
    proxy.setPassword(pcbsd::Utils::getProxyPass());

  QNetworkProxy::setApplicationProxy(proxy);
}
开发者ID:andcricardo,项目名称:pcbsd,代码行数:27,代码来源:pbsystemtab.cpp

示例10: syncSettings

void QtMarbleConfigDialog::syncSettings()
{
    d->m_settings.sync();
    
    QNetworkProxy proxy;
    
    // Make sure that no proxy is used for an empty string or the default value: 
    if ( proxyUrl().isEmpty() || proxyUrl() == "http://" ) {
        proxy.setType( QNetworkProxy::NoProxy );
    } else {
        if ( proxyType() == Marble::Socks5Proxy ) {
            proxy.setType( QNetworkProxy::Socks5Proxy );
        }
        else if ( proxyType() == Marble::HttpProxy ) {
            proxy.setType( QNetworkProxy::HttpProxy );
        }
        else {
            mDebug() << "Unknown proxy type! Using Http Proxy instead.";
            proxy.setType( QNetworkProxy::HttpProxy );
        }
    }
    
    proxy.setHostName( proxyUrl() );
    proxy.setPort( proxyPort() );
    
    if ( proxyAuth() ) {
        proxy.setUser( proxyUser() );
        proxy.setPassword( proxyPass() );
    }
    
    QNetworkProxy::setApplicationProxy(proxy);
}
开发者ID:quannt24,项目名称:marble,代码行数:32,代码来源:QtMarbleConfigDialog.cpp

示例11: authenticate

	void YafOAuth::authenticate()
	{
        if(!m_view)
		{
			initializeWebView();
		}

		GeneralSettings generalSettings; 
		WebMounter::getSettingStorage()->getData(generalSettings);
        if(generalSettings.m_proxyAddress.length())
		{
			QNetworkProxy proxy;
			proxy.setType(QNetworkProxy::HttpProxy);
            proxy.setHostName(generalSettings.m_proxyAddress.left(generalSettings.m_proxyAddress.lastIndexOf(":")));
            QString portStr = generalSettings.m_proxyAddress.right(generalSettings.m_proxyAddress.length() - generalSettings.m_proxyAddress.lastIndexOf(":")-1);
			proxy.setPort(portStr.toInt());
            proxy.setUser(generalSettings.m_proxyLogin);
            proxy.setPassword(generalSettings.m_proxyPassword);

            m_view->page()->networkAccessManager()->setProxy(proxy);
        }

        m_view->load(QUrl("https://oauth.yandex.ru/authorize?response_type=token&client_id=e56c86e3da064686bbac48edbfb00fae"));
        m_view->show();
		//if (!_oAuthTimer->isActive())
		//	_oAuthTimer->start(20*1000);
	}
开发者ID:ershovdz,项目名称:WebMounter,代码行数:27,代码来源:yaf_oauth.cpp

示例12: loadSettings

void BrowserApplication::loadSettings()
{
    QSettings settings;
    settings.beginGroup(QLatin1String("websettings"));

    QWebEngineSettings *defaultSettings = QWebEngineSettings::globalSettings();
    QWebEngineProfile *defaultProfile = QWebEngineProfile::defaultProfile();

    QString standardFontFamily = defaultSettings->fontFamily(QWebEngineSettings::StandardFont);
    int standardFontSize = defaultSettings->fontSize(QWebEngineSettings::DefaultFontSize);
    QFont standardFont = QFont(standardFontFamily, standardFontSize);
    standardFont = qvariant_cast<QFont>(settings.value(QLatin1String("standardFont"), standardFont));
    defaultSettings->setFontFamily(QWebEngineSettings::StandardFont, standardFont.family());
    defaultSettings->setFontSize(QWebEngineSettings::DefaultFontSize, standardFont.pointSize());

    QString fixedFontFamily = defaultSettings->fontFamily(QWebEngineSettings::FixedFont);
    int fixedFontSize = defaultSettings->fontSize(QWebEngineSettings::DefaultFixedFontSize);
    QFont fixedFont = QFont(fixedFontFamily, fixedFontSize);
    fixedFont = qvariant_cast<QFont>(settings.value(QLatin1String("fixedFont"), fixedFont));
    defaultSettings->setFontFamily(QWebEngineSettings::FixedFont, fixedFont.family());
    defaultSettings->setFontSize(QWebEngineSettings::DefaultFixedFontSize, fixedFont.pointSize());

    defaultSettings->setAttribute(QWebEngineSettings::JavascriptEnabled, settings.value(QLatin1String("enableJavascript"), true).toBool());
    defaultSettings->setAttribute(QWebEngineSettings::ScrollAnimatorEnabled, settings.value(QLatin1String("enableScrollAnimator"), true).toBool());

    defaultSettings->setAttribute(QWebEngineSettings::PluginsEnabled, settings.value(QLatin1String("enablePlugins"), true).toBool());

    defaultSettings->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, true);

    if (! sawStyleSheetCommandLineOption) {
        m_stylesheetFilename = settings.value(QLatin1String("userStyleSheetFile")).toString();
        m_stylesheetRules = settings.value(QLatin1String("userStyleSheetRules")).toString();
        emit reloadStyleSheet();
    }
    if (! m_stylesheetFilename.isEmpty()) {
        m_fileSystemWatcher->addPath(m_stylesheetFilename);
        connect(m_fileSystemWatcher, &QFileSystemWatcher::fileChanged,
                this, &BrowserApplication::reloadStylesheet);
    }

    defaultProfile->setHttpUserAgent(settings.value(QLatin1String("httpUserAgent")).toString());
    defaultProfile->setHttpAcceptLanguage(settings.value(QLatin1String("httpAcceptLanguage")).toString());

    settings.endGroup();

    settings.beginGroup(QLatin1String("proxy"));
    QNetworkProxy proxy;
    if (settings.value(QLatin1String("enabled"), false).toBool()) {
        if (settings.value(QLatin1String("type"), 0).toInt() == 0)
            proxy = QNetworkProxy::Socks5Proxy;
        else
            proxy = QNetworkProxy::HttpProxy;
        proxy.setHostName(settings.value(QLatin1String("hostName")).toString());
        proxy.setPort(settings.value(QLatin1String("port"), 1080).toInt());
        proxy.setUser(settings.value(QLatin1String("userName")).toString());
        proxy.setPassword(settings.value(QLatin1String("password")).toString());
    }
    QNetworkProxy::setApplicationProxy(proxy);
    settings.endGroup();
}
开发者ID:rwhogg,项目名称:DomTerm,代码行数:60,代码来源:browserapplication.cpp

示例13: SetProxy

static QNetworkProxy SetProxy(int type, QString host, unsigned int port, QString name, QString pass)
{
    QNetworkProxy proxy;
    switch (type)
    {
        case 0:
            QNetworkProxy::setApplicationProxy(QNetworkProxy::NoProxy);
            return proxy;
        case 1:
            proxy.setType(QNetworkProxy::Socks5Proxy);
            break;
        case 2:
            proxy.setType(QNetworkProxy::HttpProxy);
            break;
        case 3:
            proxy.setType(QNetworkProxy::HttpCachingProxy);
            break;
        case 4:
            proxy.setType(QNetworkProxy::FtpCachingProxy);
            break;
        default:
            return proxy;
    }

    proxy.setHostName(host);
    proxy.setPort(port);
    proxy.setUser(name);
    proxy.setPassword(pass);
    QNetworkProxy::setApplicationProxy(proxy);
    return proxy;
}
开发者ID:grumpy-irc,项目名称:grumpy,代码行数:31,代码来源:proxy.cpp

示例14: qDebug

void Net::DownloadManager::applyProxySettings()
{
    const auto *proxyManager = ProxyConfigurationManager::instance();
    const ProxyConfiguration proxyConfig = proxyManager->proxyConfiguration();
    QNetworkProxy proxy;

    if (!proxyManager->isProxyOnlyForTorrents() && (proxyConfig.type != ProxyType::None)) {
        // Proxy enabled
        proxy.setHostName(proxyConfig.ip);
        proxy.setPort(proxyConfig.port);
        // Default proxy type is HTTP, we must change if it is SOCKS5
        if ((proxyConfig.type == ProxyType::SOCKS5) || (proxyConfig.type == ProxyType::SOCKS5_PW)) {
            qDebug() << Q_FUNC_INFO << "using SOCKS proxy";
            proxy.setType(QNetworkProxy::Socks5Proxy);
        }
        else {
            qDebug() << Q_FUNC_INFO << "using HTTP proxy";
            proxy.setType(QNetworkProxy::HttpProxy);
        }
        // Authentication?
        if (proxyManager->isAuthenticationRequired()) {
            qDebug("Proxy requires authentication, authenticating...");
            proxy.setUser(proxyConfig.username);
            proxy.setPassword(proxyConfig.password);
        }
    }
    else {
        proxy.setType(QNetworkProxy::NoProxy);
    }

    m_networkManager.setProxy(proxy);
}
开发者ID:qbittorrent,项目名称:qBittorrent,代码行数:32,代码来源:downloadmanager.cpp

示例15: getProxy

bool connection::getProxy()
{
	bool success = true;
        //QSettings settings(QSettings::defaultFormat(), QSettings::UserScope, "qutim/qutim."+m_profile_name, "icqsettings");
        QSettings settings(QSettings::defaultFormat(), QSettings::UserScope, "qutim/qutim."+m_profile_name+"/ICQ."+icqUin, "accountsettings");
	if ( settings.value("connection/useproxy", false).toBool() )
		{
			quint16 proxyType = settings.value("proxy/proxyType", 0).toInt();
			if ( proxyType )
			{
				QNetworkProxy connectionProxy;
				switch( proxyType )
				{
				case 1:
					connectionProxy.setType(QNetworkProxy::HttpProxy);
					break;
				case 2:
					connectionProxy.setType(QNetworkProxy::Socks5Proxy);
					break;
				default:
					break;
				
				}
				
				QString hostN = settings.value("proxy/host").toString();
				
				QHostAddress addr(hostN);
				if ( addr.isNull() )
				{
					success = false;
			         QHostInfo::lookupHost(hostN, const_cast<connection*>(this), SLOT(dnsResults(QHostInfo)));
					
				}
				
				connectionProxy.setHostName(hostN);
				connectionProxy.setPort(settings.value("proxy/port", 1).toInt());
				if ( settings.value("proxy/auth", false).toBool() )
				{

					connectionProxy.setUser(settings.value("proxy/user").toString());
					connectionProxy.setPassword(settings.value("proxy/pass").toString());
				}
				

				setCurrentProxy(connectionProxy);
//				currentProxy.setType(connectionProxy.type());
//				currentProxy.setHostName(connectionProxy.hostName());
//				currentProxy.setHostName("gggg");
//				currentProxy.setPort(connectionProxy.port());
//				currentProxy.setUser(connectionProxy.user());
//				currentProxy.setPassword(connectionProxy.password());
			}
//			else {
//				currentProxy.setType(QNetworkProxy::HttpCachingProxy);
//			}
		}
//	currentProxy.setType(QNetworkProxy::NoProxy);
	return success;
}
开发者ID:veksha,项目名称:vekshas-qutim-protocols,代码行数:59,代码来源:connection.cpp


注:本文中的QNetworkProxy::setPassword方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。