QNetworkReply* DownloadThread::downloadUrl(const QString &url, const QList<QNetworkCookie>& cookies) {
  // Update proxy settings
  applyProxySettings();
  // Set cookies
  if (!cookies.empty()) {
    qDebug("Setting %d cookies for url: %s", cookies.size(), qPrintable(url));
    m_networkManager.cookieJar()->setCookiesFromUrl(cookies, url);
  }
  // Process download request
  qDebug("url is %s", qPrintable(url));
  const QUrl qurl = QUrl::fromEncoded(url.toUtf8());
  QNetworkRequest request(qurl);
  // Spoof Firefox 3.5 user agent to avoid
  // Web server banning
  request.setRawHeader("User-Agent", "Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5");
  qDebug("Downloading %s...", request.url().toEncoded().data());
  qDebug("%d cookies for this URL", m_networkManager.cookieJar()->cookiesForUrl(url).size());
  for (int i=0; i<m_networkManager.cookieJar()->cookiesForUrl(url).size(); ++i) {
    qDebug("%s=%s", m_networkManager.cookieJar()->cookiesForUrl(url).at(i).name().data(), m_networkManager.cookieJar()->cookiesForUrl(url).at(i).value().data());
    qDebug("Domain: %s, Path: %s", qPrintable(m_networkManager.cookieJar()->cookiesForUrl(url).at(i).domain()), qPrintable(m_networkManager.cookieJar()->cookiesForUrl(url).at(i).path()));
  }
  // accept gzip
  request.setRawHeader("Accept-Encoding", "gzip");
  return m_networkManager.get(request);
}
Exemple #2
0
void OptionsWidget::onDoneClicked()
{
  createSettings();

  applyProxySettings();

  emit done();
}
Net::DownloadManager::DownloadManager(QObject *parent)
    : QObject(parent)
{
    connect(&m_networkManager, &QNetworkAccessManager::sslErrors, this, &Net::DownloadManager::ignoreSslErrors);
    connect(&m_networkManager, &QNetworkAccessManager::finished, this, &DownloadManager::handleReplyFinished);
    connect(ProxyConfigurationManager::instance(), &ProxyConfigurationManager::proxyConfigurationChanged
            , this, &DownloadManager::applyProxySettings);
    m_networkManager.setCookieJar(new NetworkCookieJar(this));
    applyProxySettings();
}
Exemple #4
0
OptionsWidget::OptionsWidget(QString productName,QWidget *parent) :
QScrollArea(parent), m_productName(productName), m_settings(QSettings::SystemScope,"osll",m_productName)
{
  m_widget = new QWidget(this);

  QVBoxLayout * layout = new QVBoxLayout(m_widget);

  layout->addWidget(new QLabel("Login", m_widget));
  layout->addWidget(m_nameEdit = new QLineEdit(m_widget));
  layout->addWidget(new QLabel("Password", m_widget));
  layout->addWidget(m_passwordEdit = new QLineEdit(m_widget));
  layout->addWidget(m_passwordCheckBox = new QCheckBox("Show password", m_widget));
  layout->addWidget(new QLabel("Channel name", m_widget));
  layout->addWidget(m_channelEdit = new QLineEdit(m_widget));
  // NOTE if we use m_widget windget in tracker addition field for username will displayed
  if (m_productName == "tracker")
  {
    layout->addWidget(new QLabel("Name that will be displayed\non Observer map:", m_widget));
    layout->addWidget(m_visibleNameEdit = new QLineEdit());
  }

  m_passwordEdit->setEchoMode(QLineEdit::Password);
  m_passwordCheckBox->setChecked(false);

  layout->addWidget(new QLabel("Server", m_widget));
  layout->addWidget(m_serverUrlEdit = new QLineEdit(m_widget));
  layout->addWidget(new QLabel("Port", m_widget));
  layout->addWidget(m_serverPortEdit = new QSpinBox(m_widget));

  m_serverPortEdit->setMinimum(0);
  m_serverPortEdit->setMaximum(65535);

  layout->addWidget(new QLabel("Proxy type", m_widget));
  layout->addWidget(m_proxyType = new QComboBox(m_widget));
  layout->addWidget(new QLabel("Proxy host", m_widget));
  layout->addWidget(m_proxyHostEdit = new QLineEdit(m_widget));
  layout->addWidget(new QLabel("Proxy port", m_widget));
  layout->addWidget(m_proxyPortEdit = new QSpinBox(m_widget));

  m_proxyType->addItem("DefaultProxy", QNetworkProxy::DefaultProxy);
  m_proxyType->addItem("Socks5Proxy", QNetworkProxy::Socks5Proxy);
  m_proxyType->addItem("NoProxy", QNetworkProxy::NoProxy);
  m_proxyType->addItem("HttpProxy", QNetworkProxy::HttpProxy);
  m_proxyType->addItem("HttpCachingProxy", QNetworkProxy::HttpCachingProxy);
  m_proxyType->addItem("FtpCachingProxy", QNetworkProxy::FtpCachingProxy);
  m_proxyPortEdit->setMinimum(0);
  m_proxyPortEdit->setMaximum(65535);

  layout->addWidget(new QLabel("Cache type", m_widget));
  layout->addWidget(m_cacheType = new QComboBox(m_widget));
  layout->addWidget(new QLabel("Cache path", m_widget));
  layout->addWidget(m_cachePath = new QLineEdit(m_widget));
  layout->addWidget(m_cachePathButton = new QPushButton("Choose dir...", m_widget));
  layout->addWidget(new QLabel("Max cache size", m_widget));
  layout->addWidget(m_cacheMaxSize = new QSpinBox(m_widget));

  m_cacheType->addItem("None", 0);
  m_cacheType->addItem("Network cache", 1);
  m_cacheType->addItem("Disk cache", 2);
  m_cacheType->setCurrentIndex(-1);

  layout->addWidget(m_doneButton = new QPushButton("Done", m_widget));
  layout->addWidget(m_defaultButton = new QPushButton("Default settings", m_widget));
  layout->addWidget(m_cancelButton = new QPushButton("Cancel", m_widget));

  m_widget->setLayout(layout);
  this->setWidget(m_widget);
  this->setWidgetResizable(true);

  connect(m_doneButton, SIGNAL(clicked()), this, SLOT(onDoneClicked()));
  connect(m_cancelButton, SIGNAL(clicked()), this, SLOT(onCancelClicked()));
  connect(m_defaultButton,SIGNAL(clicked()), this, SLOT(setDefaultSettings()));
  connect(m_proxyType, SIGNAL(currentIndexChanged(int)), this, SLOT(onProxyTypeChanged(int)));
  connect(m_cacheType, SIGNAL(currentIndexChanged(int)), this, SLOT(onCacheTypeChanged(int)));
  connect(m_cachePathButton, SIGNAL(clicked()), this, SLOT(onCachePathButtonClick()));
  connect(m_passwordCheckBox, SIGNAL(clicked(bool)), this, SLOT(onShowPasswordChecked(bool)));

  onProxyTypeChanged(m_proxyType->currentIndex());

  if( m_settings.value("magic").toString() != APP_MAGIC )
  {
    setDefaultSettings();
    createSettings();
  }

  initSettings();
  applyProxySettings();
}
Exemple #5
0
void GameUIConfig::reloadValues(void)
{
    Form->ui.pageOptions->WeaponTooltip->setChecked(value("misc/weaponTooltips", true).toBool());

    int t = Form->ui.pageOptions->CBResolution->findText(value("video/fullscreenResolution").toString());
    if (t < 0)
    {
        if (Form->ui.pageOptions->CBResolution->count() > 1)
            Form->ui.pageOptions->CBResolution->setCurrentIndex(1);
        else
            Form->ui.pageOptions->CBResolution->setCurrentIndex(0);
    }
    else Form->ui.pageOptions->CBResolution->setCurrentIndex(t);

    // Default the windowed resolution to 5/6 of the screen size
    QSize screenSize = SDLInteraction::instance().getCurrentResolution();
    screenSize *= 5.0 / 6;

    QString widthStr = QString::number(screenSize.width());
    QString heightStr = QString::number(screenSize.height());
    QString wWidth = value("video/windowedWidth", widthStr).toString();
    QString wHeight = value("video/windowedHeight", heightStr).toString();
    // If left blank reset the resolution to the default
    wWidth = (wWidth == "" ? widthStr : wWidth);
    wHeight = (wHeight == "" ? heightStr : wHeight);
    Form->ui.pageOptions->windowWidthEdit->setValue(wWidth.toInt());
    Form->ui.pageOptions->windowHeightEdit->setValue(wHeight.toInt());

    Form->ui.pageOptions->CBResolution->setCurrentIndex((t < 0) ? 1 : t);
    Form->ui.pageOptions->CBFullscreen->setChecked(value("video/fullscreen", false).toBool());
    bool ffscr=value("frontend/fullscreen", false).toBool();
    Form->ui.pageOptions->CBFrontendFullscreen->setChecked(ffscr);

    Form->ui.pageOptions->SLQuality->setValue(value("video/quality", 5).toUInt());
    Form->ui.pageOptions->CBStereoMode->setCurrentIndex(value("video/stereo", 0).toUInt());
    Form->ui.pageOptions->CBFrontendEffects->setChecked(value("frontend/effects", true).toBool());
    Form->ui.pageOptions->CBSound->setChecked(value("audio/sound", true).toBool());
    Form->ui.pageOptions->CBFrontendSound->setChecked(value("frontend/sound", true).toBool());
    Form->ui.pageOptions->CBMusic->setChecked(value("audio/music", true).toBool());
    Form->ui.pageOptions->CBFrontendMusic->setChecked(value("frontend/music", true).toBool());
    Form->ui.pageOptions->SLVolume->setValue(value("audio/volume", 100).toUInt());

    QString netNick = value("net/nick", tr("Guest")+QString("%1").arg(rand())).toString();
    Form->ui.pageOptions->editNetNick->setText(netNick);
    bool savePwd = value("net/savepassword",true).toBool();
    Form->ui.pageOptions->CBSavePassword->setChecked(savePwd);

    Form->ui.pageOptions->editNetPassword->installEventFilter(this);

    int passLength = value("net/passwordlength", 0).toInt();
    if (!savePwd) {
        Form->ui.pageOptions->editNetPassword->setEnabled(false);
        Form->ui.pageOptions->editNetPassword->setText("");
        setNetPasswordLength(0);
    } else
    {
        setNetPasswordLength(passLength);
    }

    delete netHost;
    netHost = new QString(value("net/ip", "").toString());
    netPort = value("net/port", NETGAME_DEFAULT_PORT).toUInt();

    Form->ui.pageNetServer->leServerDescr->setText(value("net/servername", "hedgewars server").toString());
    Form->ui.pageNetServer->sbPort->setValue(value("net/serverport", NETGAME_DEFAULT_PORT).toUInt());

    Form->ui.pageOptions->CBShowFPS->setChecked(value("fps/show", false).toBool());
    Form->ui.pageOptions->fpsedit->setValue(value("fps/limit", 27).toUInt());

    Form->ui.pageOptions->CBAltDamage->setChecked(value("misc/altdamage", true).toBool());
    Form->ui.pageOptions->CBNameWithDate->setChecked(value("misc/appendTimeToRecords", false).toBool());

    Form->ui.pageOptions->CBTeamTag->setChecked(value("misc/teamtag", true).toBool());
    Form->ui.pageOptions->CBHogTag->setChecked(value("misc/hogtag", true).toBool());
    Form->ui.pageOptions->CBHealthTag->setChecked(value("misc/healthtag", true).toBool());
    Form->ui.pageOptions->CBTagOpacity->setChecked(value("misc/tagopacity", false).toBool());

#ifdef SPARKLE_ENABLED
    Form->ui.pageOptions->CBAutoUpdate->setChecked(value("misc/autoUpdate", true).toBool());
#endif

    Form->ui.pageOptions->CBLanguage->setCurrentIndex(Form->ui.pageOptions->CBLanguage->findData(value("misc/locale", "").toString()));

    Form->ui.pageOptions->cbProxyType->setCurrentIndex(value("proxy/type", 0).toInt());
    Form->ui.pageOptions->leProxy->setText(value("proxy/host", "").toString());
    Form->ui.pageOptions->sbProxyPort->setValue(value("proxy/port", "8080").toInt());
    Form->ui.pageOptions->leProxyLogin->setText(value("proxy/login", "").toString());
    Form->ui.pageOptions->leProxyPassword->setText(value("proxy/password", "").toString());

    applyProxySettings();

    { // load colors
        QStandardItemModel * model = DataManager::instance().colorsModel();
        for(int i = model->rowCount() - 1; i >= 0; --i)
            model->item(i)->setData(QColor(value(QString("colors/color%1").arg(i), model->item(i)->data()).toString()));
    }

    { // load binds
        for(int i = 0; i < BINDS_NUMBER; i++)
        {
            m_binds[i].strbind = value(QString("Binds/%1").arg(m_binds[i].action), cbinds[i].strbind).toString();
            if (m_binds[i].strbind.isEmpty() || m_binds[i].strbind == "default") m_binds[i].strbind = cbinds[i].strbind;
        }
    }
}
Exemple #6
0
void GameUIConfig::SaveOptions()
{
    setValue("video/fullscreenResolution", Form->ui.pageOptions->CBResolution->currentText());
    setValue("video/windowedWidth", Form->ui.pageOptions->windowWidthEdit->text());
    setValue("video/windowedHeight", Form->ui.pageOptions->windowHeightEdit->text());
    setValue("video/fullscreen", vid_Fullscreen());

    setValue("video/quality", Form->ui.pageOptions->SLQuality->value());
    setValue("video/stereo", stereoMode());

    setValue("frontend/effects", isFrontendEffects());

    setValue("misc/weaponTooltips", Form->ui.pageOptions->WeaponTooltip->isChecked());

    bool ffscr = isFrontendFullscreen();
    setValue("frontend/fullscreen", ffscr);
    emit frontendFullscreen(ffscr);
    if (!ffscr)
    {
        setValue("frontend/width", Form->width());
        setValue("frontend/height", Form->height());
    }
    else
    {
        //resizeToConfigValues(); // TODO: why this has been made?
    }

    setValue("audio/sound", isSoundEnabled());
    setValue("frontend/sound", isFrontendSoundEnabled());
    setValue("audio/music", isMusicEnabled());
    setValue("frontend/music", isFrontendMusicEnabled());
    setValue("audio/volume", Form->ui.pageOptions->SLVolume->value());

    setValue("net/nick", netNick());
    if (netPasswordIsValid() && Form->ui.pageOptions->CBSavePassword->isChecked()) {
        setPasswordHash(netPasswordHash());
    }
    else if(!Form->ui.pageOptions->CBSavePassword->isChecked()) {
        clearPasswordHash();
    }

    setValue("net/savepassword", Form->ui.pageOptions->CBSavePassword->isChecked());
    setValue("net/ip", *netHost);
    setValue("net/port", netPort);
    setValue("net/servername", Form->ui.pageNetServer->leServerDescr->text());
    setValue("net/serverport", Form->ui.pageNetServer->sbPort->value());

    setValue("fps/show", isShowFPSEnabled());
    setValue("fps/limit", Form->ui.pageOptions->fpsedit->value());

    setValue("misc/altdamage", isAltDamageEnabled());

    setValue("misc/teamtag",   Form->ui.pageOptions->CBTeamTag->isChecked());
    setValue("misc/hogtag",    Form->ui.pageOptions->CBHogTag->isChecked());
    setValue("misc/healthtag", Form->ui.pageOptions->CBHealthTag->isChecked());
    setValue("misc/tagopacity",Form->ui.pageOptions->CBTagOpacity->isChecked());

    setValue("misc/appendTimeToRecords", appendDateTimeToRecordName());
    setValue("misc/locale", language());

#ifdef SPARKLE_ENABLED
    setValue("misc/autoUpdate", isAutoUpdateEnabled());
#endif

    { // setup proxy
        int proxyType = Form->ui.pageOptions->cbProxyType->currentIndex();
        setValue("proxy/type", proxyType);

        if(proxyType == PageOptions::Socks5Proxy || proxyType == PageOptions::HTTPProxy)
        {
            setValue("proxy/host", Form->ui.pageOptions->leProxy->text());
            setValue("proxy/port", Form->ui.pageOptions->sbProxyPort->value());
            setValue("proxy/login", Form->ui.pageOptions->leProxyLogin->text());
            setValue("proxy/password", Form->ui.pageOptions->leProxyPassword->text());
        }

        applyProxySettings();
    }

    { // save colors
        QStandardItemModel * model = DataManager::instance().colorsModel();
        for(int i = model->rowCount() - 1; i >= 0; --i)
            setValue(QString("colors/color%1").arg(i), model->item(i)->data().value<QColor>().name());
    }

    sync();
}
Exemple #7
0
void LLProxy::applyProxySettings(LLCurl::Easy* handle)
{
	applyProxySettings(handle->getCurlHandle());
}
Exemple #8
0
void LLProxy::applyProxySettings(LLCurlEasyRequest* handle)
{
	applyProxySettings(handle->getEasy());
}