Esempio n. 1
0
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);
}
void TorController::auth_cb(TorControlConnection& conn, const TorControlReply& reply)
{
    if (reply.code == 250) {
        LogPrint("tor", "tor: Authentication successful\n");

        // Now that we know Tor is running setup the proxy for onion addresses
        // if -onion isn't set to something else.
        if (GetArg("-onion", "") == "") {
            proxyType addrOnion = proxyType(CService("127.0.0.1", 9050), true);
            SetProxy(NET_TOR, addrOnion);
            SetLimited(NET_TOR, false);
        }

        // Finally - now create the service
        if (private_key.empty()) // No private key, generate one
            private_key = "NEW:RSA1024"; // Explicitly request RSA1024 - see issue #9214
        // Request hidden service, redirect port.
        // Note that the 'virtual' port doesn't have to be the same as our internal port, but this is just a convenient
        // choice.  TODO; refactor the shutdown sequence some day.
        conn.Command(strprintf("ADD_ONION %s Port=%i,127.0.0.1:%i", private_key, GetListenPort(), GetListenPort()),
            boost::bind(&TorController::add_onion_cb, this, _1, _2));
    } else {
        LogPrintf("tor: Authentication failed\n");
    }
}
Esempio n. 3
0
void OptionsDialog::doProxyIpChecks(QValidatedLineEdit* pUiProxyIp, QLineEdit* pUiProxyPort)
{
    const std::string strAddrProxy = pUiProxyIp->text().toStdString();
    CService addrProxy;

    // Check for a valid IPv4 / IPv6 address
    if (!(fProxyIpValid = LookupNumeric(strAddrProxy.c_str(), addrProxy))) {
        disableOkButton();
        pUiProxyIp->setValid(false);
        ui->statusLabel->setStyleSheet("QLabel { color: red; }");
        ui->statusLabel->setText(tr("The supplied proxy address is invalid."));
        return;
    }
    // Check proxy port
    if (!pUiProxyPort->hasAcceptableInput()){
        disableOkButton();
        ui->statusLabel->setStyleSheet("QLabel { color: red; }");
        ui->statusLabel->setText(tr("The supplied proxy port is invalid."));
        return;
    }

    proxyType checkProxy = proxyType(addrProxy);
    if (!checkProxy.IsValid()) {
        disableOkButton();
        ui->statusLabel->setStyleSheet("QLabel { color: red; }");
        ui->statusLabel->setText(tr("The supplied proxy settings are invalid."));
        return;
    }

    enableOkButton();
    ui->statusLabel->clear();
}
Esempio n. 4
0
QString KProtocolManager::noProxyFor()
{
    QString noProxy = noProxyForRaw();
    if(proxyType() == EnvVarProxy)
        noProxy = QString::fromLocal8Bit(getenv(noProxy.local8Bit()));

    return noProxy;
}
Esempio n. 5
0
void MainApplication::saveState()
{
  QSettings settings(MainApplication::ORGANISATION_NAME, MainApplication::APPLICATION_NAME);
  settings.setValue("Application/homePage", homePage());
  settings.setValue("Application/openInTab", openInTab());
  settings.setValue("Application/pluginDefault", pluginDefault());
  settings.setValue("Application/proxyType", proxyType());
  settings.setValue("Application/proxyHostname", proxyHostName());
  settings.setValue("Application/proxyPort", m_networkProxy->port());
}
QValidator::State ProxyAddressValidator::validate(QString &input,
                                                  int &pos) const {
    Q_UNUSED(pos);
    // Validate the proxy
    CService serv(LookupNumeric(input.toStdString().c_str(), 9050));
    proxyType addrProxy = proxyType(serv, true);
    if (addrProxy.IsValid()) return QValidator::Acceptable;

    return QValidator::Invalid;
}
Esempio n. 7
0
QValidator::State ProxyAddressValidator::validate(QString& input, int& pos) const
{
    Q_UNUSED(pos);

    proxyType addrProxy = proxyType(CService(input.toStdString(), 9050), true);
    if (addrProxy.IsValid())
        return QValidator::Acceptable;

    return QValidator::Invalid;
}
Esempio n. 8
0
QString KProtocolManager::proxyForURL(const KURL &url)
{
    QString proxy;
    ProxyType pt = proxyType();

    switch(pt)
    {
        case PACProxy:
        case WPADProxy:
            if(!url.host().isEmpty())
            {
                KURL u(url);
                QString p = u.protocol().lower();

                // webdav is a KDE specific protocol. Look up proxy
                // information using HTTP instead...
                if(p == "webdav")
                {
                    p = "http";
                    u.setProtocol(p);
                }
                else if(p == "webdavs")
                {
                    p = "https";
                    u.setProtocol(p);
                }

                if(p.startsWith("http") || p == "ftp" || p == "gopher")
                    DCOPRef("kded", "proxyscout").call("proxyForURL", u).get(proxy);
            }
            break;
        case EnvVarProxy:
            proxy = QString::fromLocal8Bit(getenv(proxyFor(url.protocol()).local8Bit())).stripWhiteSpace();
            break;
        case ManualProxy:
            proxy = proxyFor(url.protocol());
            break;
        case NoProxy:
        default:
            break;
    }

    return (proxy.isEmpty() ? QString::fromLatin1("DIRECT") : proxy);
}
Esempio n. 9
0
QVariantMap CoreAccount::toVariantMap(bool forcePassword) const
{
    QVariantMap v;
    v["AccountId"] = accountId().toInt(); // can't use AccountId because then comparison fails
    v["AccountName"] = accountName();
    v["Uuid"] = uuid().toString();
    v["Internal"] = isInternal();
    v["User"] = user();
    if (_storePassword || forcePassword)
        v["Password"] = password();
    else
        v["Password"] = QString();
    v["StorePassword"] = storePassword();
    v["HostName"] = hostName();
    v["Port"] = port();
    v["UseSSL"] = useSsl();
    v["ProxyType"] = proxyType();
    v["ProxyUser"] = proxyUser();
    v["ProxyPassword"] = proxyPassword();
    v["ProxyHostName"] = proxyHostName();
    v["ProxyPort"] = proxyPort();
    return v;
}
Esempio n. 10
0
void QtMarbleConfigDialog::readSettings()
{
    d->m_initialGraphicsSystem = graphicsSystem();
    d->m_previousGraphicsSystem = d->m_initialGraphicsSystem;

    // Sync settings to make sure that we read the current settings.
    syncSettings();
    
    // View
    d->ui_viewSettings.kcfg_distanceUnit->setCurrentIndex( measurementSystem() );
    d->ui_viewSettings.kcfg_angleUnit->setCurrentIndex( angleUnit() );
    d->ui_viewSettings.kcfg_stillQuality->setCurrentIndex( stillQuality() );
    d->ui_viewSettings.kcfg_animationQuality->setCurrentIndex( animationQuality() );
    d->ui_viewSettings.kcfg_labelLocalization->setCurrentIndex( Marble::Native );
    d->ui_viewSettings.kcfg_mapFont->setCurrentFont( mapFont() );
    d->ui_viewSettings.kcfg_graphicsSystem->setCurrentIndex( graphicsSystem() );
    
    // Navigation
    d->ui_navigationSettings.kcfg_dragLocation->setCurrentIndex( Marble::KeepAxisVertically );
    d->ui_navigationSettings.kcfg_onStartup->setCurrentIndex( onStartup() );
    d->ui_navigationSettings.kcfg_inertialEarthRotation->setChecked( inertialEarthRotation() );
    d->ui_navigationSettings.kcfg_animateTargetVoyage->setChecked( animateTargetVoyage() );
    int editorIndex = 0;
    if ( externalMapEditor() == "potlatch") {
        editorIndex = 1;
    } else if ( externalMapEditor() == "josm") {
        editorIndex = 2;
    } else if ( externalMapEditor() == "merkaartor") {
        editorIndex = 3;
    }
    d->ui_navigationSettings.kcfg_externalMapEditor->setCurrentIndex( editorIndex );

    // Cache
    d->ui_cacheSettings.kcfg_volatileTileCacheLimit->setValue( volatileTileCacheLimit() );
    d->ui_cacheSettings.kcfg_persistentTileCacheLimit->setValue( persistentTileCacheLimit() );
    d->ui_cacheSettings.kcfg_proxyUrl->setText( proxyUrl() );
    d->ui_cacheSettings.kcfg_proxyPort->setValue( proxyPort() );
    d->ui_cacheSettings.kcfg_proxyUser->setText( proxyUser() );
    d->ui_cacheSettings.kcfg_proxyPass->setText( proxyPass() );
    d->ui_cacheSettings.kcfg_proxyType->setCurrentIndex( proxyType() );
    d->ui_cacheSettings.kcfg_proxyAuth->setChecked( proxyAuth() );
 
    // Time
    d->ui_timeSettings.kcfg_systemTimezone->setChecked( systemTimezone() );
    d->ui_timeSettings.kcfg_customTimezone->setChecked( customTimezone() );
    d->ui_timeSettings.kcfg_chosenTimezone->setCurrentIndex( chosenTimezone() );
    d->ui_timeSettings.kcfg_utc->setChecked( UTC() );
    d->ui_timeSettings.kcfg_systemTime->setChecked( systemTime() );
    d->ui_timeSettings.kcfg_lastSessionTime->setChecked( lastSessionTime() );
    if( systemTimezone() == true  )
    {
        QDateTime localTime = QDateTime::currentDateTime().toLocalTime();
        localTime.setTimeSpec( Qt::UTC );
        d->m_marbleWidget->model()->setClockTimezone( QDateTime::currentDateTime().toUTC().secsTo( localTime ) );
    }
    else if( UTC() == true )
    {
        d->m_marbleWidget->model()->setClockTimezone( 0 );
    }
    else if( customTimezone() == true )
    {
        d->m_marbleWidget->model()->setClockTimezone( d->m_timezone.value( chosenTimezone() ) );
    }

    // Routing

    // ownCloud
    d->ui_cloudSyncSettings.kcfg_enableSync->setChecked( syncEnabled() );
    d->ui_cloudSyncSettings.kcfg_syncBookmarks->setChecked( syncBookmarks() );
    d->ui_cloudSyncSettings.kcfg_syncRoutes->setChecked( syncRoutes() );
    d->ui_cloudSyncSettings.kcfg_owncloudServer->setText( owncloudServer() );
    d->ui_cloudSyncSettings.kcfg_owncloudUsername->setText( owncloudUsername() );
    d->ui_cloudSyncSettings.kcfg_owncloudPassword->setText( owncloudPassword() );
    
    // Read the settings of the plugins
    d->m_marbleWidget->readPluginSettings( d->m_settings );

    // The settings loaded in the config dialog have been changed.
    emit settingsChanged();
}
Esempio n. 11
0
QString KProtocolManager::slaveProtocol(const KURL &url, QString &proxy)
{
    if(url.hasSubURL()) // We don't want the suburl's protocol
    {
        KURL::List list = KURL::split(url);
        KURL::List::Iterator it = list.fromLast();
        return slaveProtocol(*it, proxy);
    }

    if(!d)
        d = new KProtocolManagerPrivate;

    if(d->url == url)
    {
        proxy = d->proxy;
        return d->protocol;
    }

    if(useProxy())
    {
        proxy = proxyForURL(url);
        if((proxy != "DIRECT") && (!proxy.isEmpty()))
        {
            bool isRevMatch = false;
            KProtocolManager::ProxyType type = proxyType();
            bool useRevProxy = ((type == ManualProxy) && useReverseProxy());

            QString noProxy;
            // Check no proxy information iff the proxy type is either
            // ManualProxy or EnvVarProxy
            if((type == ManualProxy) || (type == EnvVarProxy))
                noProxy = noProxyFor();

            if(!noProxy.isEmpty())
            {
                QString qhost = url.host().lower();
                const char *host = qhost.latin1();
                QString qno_proxy = noProxy.stripWhiteSpace().lower();
                const char *no_proxy = qno_proxy.latin1();
                isRevMatch = revmatch(host, no_proxy);

                // If no match is found and the request url has a port
                // number, try the combination of "host:port". This allows
                // users to enter host:port in the No-proxy-For list.
                if(!isRevMatch && url.port() > 0)
                {
                    qhost += ':' + QString::number(url.port());
                    host = qhost.latin1();
                    isRevMatch = revmatch(host, no_proxy);
                }

                // If the hostname does not contain a dot, check if
                // <local> is part of noProxy.
                if(!isRevMatch && host && (strchr(host, '.') == NULL))
                    isRevMatch = revmatch("<local>", no_proxy);
            }

            if((!useRevProxy && !isRevMatch) || (useRevProxy && isRevMatch))
            {
                d->url = proxy;
                if(d->url.isValid())
                {
                    // The idea behind slave protocols is not applicable to http
                    // and webdav protocols.
                    QString protocol = url.protocol().lower();
                    if(protocol.startsWith("http") || protocol.startsWith("webdav"))
                        d->protocol = protocol;
                    else
                    {
                        d->protocol = d->url.protocol();
                        kdDebug() << "slaveProtocol: " << d->protocol << endl;
                    }

                    d->url = url;
                    d->proxy = proxy;
                    return d->protocol;
                }
            }
        }
    }

    d->url = url;
    d->proxy = proxy = QString::null;
    d->protocol = url.protocol();
    return d->protocol;
}
Esempio n. 12
0
bool KProtocolManager::useProxy()
{
    return proxyType() != NoProxy;
}