Пример #1
0
void ChatClient::connectToServer(const QString &jid, const QString &password)
{
    QXmppConfiguration config;
    config.setResource(qApp->applicationName());
    config.setJid(jid);
    config.setPassword(password);
    // don't ignore SSL errors for wifirst and gmail, but do for other domains
    if (config.domain() == "wifirst.net" || config.domain() == "gmail.com" || config.domain() == "googlemail.com") {
        config.setStreamSecurityMode(QXmppConfiguration::TLSRequired);
        config.setIgnoreSslErrors(false);
    }
    QXmppClient::connectToServer(config);
}
Пример #2
0
void ChatClient::connectToGoogle(const QString &jid, const QString &accessToken)
{
    QXmppConfiguration config;
    config.setResource(qApp->applicationName());
    config.setGoogleAccessToken(accessToken);
    config.setJid(jid);
    config.setSaslAuthMechanism("X-OAUTH2");
    config.setStreamSecurityMode(QXmppConfiguration::TLSRequired);
    // don't ignore SSL errors for gmail, but do for other domains (google apps hosted domains)
    if (config.domain() == "gmail.com" || config.domain() == "googlemail.com")
        config.setIgnoreSslErrors(false);
    QXmppClient::connectToServer(config);
}
void FreyaMSConfig::InsertGlobalData(const QXmppConfiguration &config)
{
    QVariantMap globalConfigMap;
    globalConfigMap.insert(FREYAMS_CFG_CONFIDSERVER,   config.host());
    globalConfigMap.insert(FREYAMS_CFG_CONFIDPORT,     config.port());
    globalConfigMap.insert(FREYAMS_CFG_CONFIDDOMAIN,   config.domain());
    globalConfigMap.insert(FREYAMS_CFG_CONFIDRESOURCE, FREYAMS_INF_DEFCONFRESOURCE);
    globalConfigMap.insert(FREYAMS_CFG_CONFIDACCOUND,  config.jidBare().split("@").at(0));
    QVariantMap defaultConfig;
    defaultConfig.insert(FREYAMS_CFG_CONFIDDEFAULT, globalConfigMap);
    defaultConfig.insert(FREYAMS_CFG_CONFIDNONE, FreyaCryptogram::EnCryptogram(config.password()));
    FreyaBaseControl::GetFreyaControl()->SetConfigToFile(FREYAMS_PTH_GLOBALCONFIGPATH, defaultConfig);
}
void QXmppOutgoingClientPrivate::connectToHost(const QString &host, quint16 port)
{
    q->info(QString("Connecting to %1:%2").arg(host, QString::number(port)));

    // override CA certificates if requested
    if (!config.caCertificates().isEmpty())
        q->socket()->setCaCertificates(config.caCertificates());

    // respect proxy
    q->socket()->setProxy(config.networkProxy());

#if (QT_VERSION >= QT_VERSION_CHECK(4, 8, 0))
    // set the name the SSL certificate should match
    q->socket()->setPeerVerifyName(config.domain());
#endif

    // connect to host
    q->socket()->connectToHost(host, port);
}
Пример #5
0
void QXmppOutgoingClientPrivate::connectToHost(const QString &host, quint16 port)
{
    q->info(QString("Connecting to %1:%2").arg(host, QString::number(port)));

    // override CA certificates if requested
    if (!config.caCertificates().isEmpty())
        q->socket()->setCaCertificates(config.caCertificates());

    // set private key and certificate if available    
    if (!config.sslPrivateKey().isNull())
    {
        q->socket()->setPrivateKey(config.sslPrivateKey());
    }
    if (!config.localSslCertificate().isNull())
    {
        q->socket()->setLocalCertificate(config.localSslCertificate());
    }

    // respect proxy
    q->socket()->setProxy(config.networkProxy());

#if (QT_VERSION >= QT_VERSION_CHECK(4, 8, 0))
    // set the name the SSL certificate should match
    q->socket()->setPeerVerifyName(config.domain());
#endif

    // connect to host
    const QXmppConfiguration::StreamSecurityMode localSecurity = q->configuration().streamSecurityMode();
    if (localSecurity == QXmppConfiguration::LegacySSL) {
        if (!q->socket()->supportsSsl()) {
            q->warning("Not connecting as legacy SSL was requested, but SSL support is not available");
            return;
        }
        q->socket()->connectToHostEncrypted(host, port);
    } else {
        q->socket()->connectToHost(host, port);
    }
}